Revision: 200949
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 17 Dec 2009 08:52:27 +0200
changeset 0 95b198f216e5
child 1 c562c0bc23e5
Revision: 200949 Kit: 200951
commondrm/data/DRMRightsManager_stub.SIS
commondrm/data/DRMRightsManager_stub.pkg
commondrm/data/commondrm_stub.SIS
commondrm/data/commondrm_stub.pkg
commondrm/drmencryptor/data/DRMEncryptor.rss
commondrm/drmencryptor/data/DRMEncryptor_caption.rss
commondrm/drmencryptor/data/DRMEncryptor_reg.rss
commondrm/drmencryptor/group/DRMEncryptor.mmp
commondrm/drmencryptor/group/DRMEncryptor.pkg
commondrm/drmencryptor/group/icon.bmp
commondrm/drmencryptor/group/icon_mask_soft.bmp
commondrm/drmencryptor/group/qgn_menu_DRMEncryptor.bmp
commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_cxt.bmp
commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_cxt_mask_soft.bmp
commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_mask_soft.bmp
commondrm/drmencryptor/inc/DRMEncryptor.hrh
commondrm/drmencryptor/inc/DRMEncryptor.rh
commondrm/drmencryptor/inc/DRMEncryptorApp.h
commondrm/drmencryptor/inc/DRMEncryptorAppUi.h
commondrm/drmencryptor/inc/DRMEncryptorContainer.h
commondrm/drmencryptor/inc/DRMEncryptorDocument.h
commondrm/drmencryptor/inc/DRMEncryptorImage.h
commondrm/drmencryptor/inc/DRMPlayServerTest.h
commondrm/drmencryptor/inc/Performance.h
commondrm/drmencryptor/src/DRMEncryptorApp.cpp
commondrm/drmencryptor/src/DRMEncryptorAppUi.cpp
commondrm/drmencryptor/src/DRMEncryptorContainer.cpp
commondrm/drmencryptor/src/DRMEncryptorDocument.cpp
commondrm/drmencryptor/src/DRMEncryptorImage.cpp
commondrm/drmencryptor/src/DRMPlayServerTest.cpp
commondrm/drmencryptor/src/DrmBb5KeyStorage.cpp
commondrm/drmencryptor/src/DrmEncryptor.cpp
commondrm/drmencryptor/src/DrmKeyStorage.cpp
commondrm/drmencryptor/src/Performance.cpp
commondrm/drmrightsmanagerui/cenrep/keys_drmrightsmanager.xls
commondrm/drmrightsmanagerui/conf/drmrightsmanager.confml
commondrm/drmrightsmanagerui/conf/drmrightsmanager_102750B1.crml
commondrm/drmrightsmanagerui/data/DRMRightsManager.rss
commondrm/drmrightsmanagerui/data/DRMRightsManager_reg.rss
commondrm/drmrightsmanagerui/group/DRMRightsManager.mmp
commondrm/drmrightsmanagerui/help/data/xhtml.zip
commondrm/drmrightsmanagerui/help/group/bld.inf
commondrm/drmrightsmanagerui/help/inc/drm.hlp.hrh
commondrm/drmrightsmanagerui/help/rom/drmsettingspluginhelps_variant.iby
commondrm/drmrightsmanagerui/inc/DRMCommonUtilities.h
commondrm/drmrightsmanagerui/inc/DRMRightsManager.hrh
commondrm/drmrightsmanagerui/inc/DRMRightsManagerPrivateCRKeys.h
commondrm/drmrightsmanagerui/inc/DRMRightsMgrApp.h
commondrm/drmrightsmanagerui/inc/DRMRightsMgrAppUi.h
commondrm/drmrightsmanagerui/inc/DRMRightsMgrAppUi.inl
commondrm/drmrightsmanagerui/inc/DRMRightsMgrDetailsContainer.h
commondrm/drmrightsmanagerui/inc/DRMRightsMgrDetailsView.h
commondrm/drmrightsmanagerui/inc/DRMRightsMgrDocument.h
commondrm/drmrightsmanagerui/inc/DRMUILogger.h
commondrm/drmrightsmanagerui/inc/DrmViewItems.h
commondrm/drmrightsmanagerui/inc/DrmViewItems.inl
commondrm/drmrightsmanagerui/inc/MDRMMSKObserver.h
commondrm/drmrightsmanagerui/loc/DRMRightsManager.loc
commondrm/drmrightsmanagerui/src/DRMCommonUtilities.cpp
commondrm/drmrightsmanagerui/src/DRMRightsMgrApp.cpp
commondrm/drmrightsmanagerui/src/DRMRightsMgrAppUi.cpp
commondrm/drmrightsmanagerui/src/DRMRightsMgrDetailsContainer.cpp
commondrm/drmrightsmanagerui/src/DRMRightsMgrDetailsView.cpp
commondrm/drmrightsmanagerui/src/DRMRightsMgrDocument.cpp
commondrm/drmrightsmanagerui/src/DRMViewItems.cpp
commondrm/drmrightsstoringlocation/bwins/drmrightsstoringlocationu.def
commondrm/drmrightsstoringlocation/eabi/drmrightsstoringlocationu.def
commondrm/drmrightsstoringlocation/group/bld.inf
commondrm/drmrightsstoringlocation/group/drmrightsstoringlocation.mmp
commondrm/drmrightsstoringlocation/inc/drmstoringinternalcrkeys.h
commondrm/drmrightsstoringlocation/src/drmrightsstoringlocation.cpp
commondrm/drmserviceapiwrapper/BWINS/drmserviceapiwrapperu.def
commondrm/drmserviceapiwrapper/EABI/drmserviceapiwrapperu.def
commondrm/drmserviceapiwrapper/group/bld.inf
commondrm/drmserviceapiwrapper/group/drmserviceapiwrapper.mmp
commondrm/drmserviceapiwrapper/src/drmserviceapiwrapper.cpp
commondrm/drmsettingsplugin/data/102750CC.rss
commondrm/drmsettingsplugin/data/drmsettingspluginrsc.rss
commondrm/drmsettingsplugin/group/drmsettingsplugin.mmp
commondrm/drmsettingsplugin/inc/drmsettingsmodel.h
commondrm/drmsettingsplugin/inc/drmsettingsplugin.h
commondrm/drmsettingsplugin/inc/drmsettingsplugin.hrh
commondrm/drmsettingsplugin/inc/drmsettingsplugin.rh
commondrm/drmsettingsplugin/inc/drmsettingsplugincontainer.h
commondrm/drmsettingsplugin/inc/drmsettingsusagecheckbox.h
commondrm/drmsettingsplugin/inc/drmsettingsusagelist.h
commondrm/drmsettingsplugin/loc/drmsettingsplugin.loc
commondrm/drmsettingsplugin/src/drmsettingsmodel.cpp
commondrm/drmsettingsplugin/src/drmsettingsplugin.cpp
commondrm/drmsettingsplugin/src/drmsettingsplugincontainer.cpp
commondrm/drmsettingsplugin/src/drmsettingspluginimplementationtable.cpp
commondrm/drmsettingsplugin/src/drmsettingsusagecheckbox.cpp
commondrm/drmsettingsplugin/src/drmsettingsusagelist.cpp
commondrm/drmutility/bwinscw/DRMAutomatedUsageImplU.DEF
commondrm/drmutility/bwinscw/DRMAutomatedUsageU.DEF
commondrm/drmutility/bwinscw/DRMUiHandlingImplU.DEF
commondrm/drmutility/bwinscw/DRMUiHandlingU.DEF
commondrm/drmutility/bwinscw/DRMUtilityu.def
commondrm/drmutility/bwinscw/DrmRightsInfoImplU.DEF
commondrm/drmutility/bwinscw/DrmRightsInfoU.DEF
commondrm/drmutility/bwinscw/DrmUtilityDmgrWrapperu.def
commondrm/drmutility/bwinscw/drmutilitycommonu.def
commondrm/drmutility/bwinscw/drmutilitywmdrmwrapperu.def
commondrm/drmutility/data/DrmUtilityDmgrWrapper.rss
commondrm/drmutility/data/drmutility.rss
commondrm/drmutility/eabi/DRMAutomatedUsageImplU.DEF
commondrm/drmutility/eabi/DRMAutomatedUsageU.DEF
commondrm/drmutility/eabi/DRMUiHandlingImplU.DEF
commondrm/drmutility/eabi/DRMUiHandlingU.DEF
commondrm/drmutility/eabi/DRMUtilityu.def
commondrm/drmutility/eabi/DrmRightsInfoImplu.def
commondrm/drmutility/eabi/DrmRightsInfoU.DEF
commondrm/drmutility/eabi/DrmUtilityDmgrWrapperu.def
commondrm/drmutility/eabi/drmutilitycommonu.def
commondrm/drmutility/eabi/drmutilitywmdrmwrapperu.def
commondrm/drmutility/group/DRMAutomatedUsage.mmp
commondrm/drmutility/group/DRMAutomatedUsageImpl.mmp
commondrm/drmutility/group/DRMUiHandling.mmp
commondrm/drmutility/group/DRMUiHandlingImpl.mmp
commondrm/drmutility/group/DRMUtility.mmp
commondrm/drmutility/group/DrmRightsInfo.mmp
commondrm/drmutility/group/DrmRightsInfoImpl.mmp
commondrm/drmutility/group/DrmUtilityDmgrWrapper.mmp
commondrm/drmutility/group/bld.inf
commondrm/drmutility/group/drmutilitycommon.mmp
commondrm/drmutility/group/drmutilitywmdrmwrapper.mmp
commondrm/drmutility/inc/DrmAutomatedUsageImpl.h
commondrm/drmutility/inc/DrmQueue.h
commondrm/drmutility/inc/DrmRightsInfoData.h
commondrm/drmutility/inc/DrmRightsInfoImpl.h
commondrm/drmutility/inc/DrmUiHandlingImpl.h
commondrm/drmutility/inc/DrmUtilityDmgrWrapper.h
commondrm/drmutility/inc/DrmUtilityDmgrWrapperLogger.h
commondrm/drmutility/inc/DrmUtilityDownloadManager.h
commondrm/drmutility/inc/DrmUtilityGlobalNoteWrapper.h
commondrm/drmutility/inc/DrmUtilityInfoNoteWrapper.h
commondrm/drmutility/inc/drmautomatedtypes.h
commondrm/drmutility/inc/drmautomatedusagedata.h
commondrm/drmutility/inc/drmautomatedusageerrorhandling.h
commondrm/drmutility/inc/drmuierrorhandling.h
commondrm/drmutility/inc/drmuihandlingdata.h
commondrm/drmutility/inc/drmutilitycommon.h
commondrm/drmutility/inc/drmutilitysecondarydisplay.h
commondrm/drmutility/inc/drmutilityui.h
commondrm/drmutility/inc/drmutilitywmdrm.h
commondrm/drmutility/inc/drmutilitywmdrmwrapper.h
commondrm/drmutility/inc/drmwmdrmwrapper.h
commondrm/drmutility/inc/rdrmhelperclient.h
commondrm/drmutility/loc/DRMUtility.loc
commondrm/drmutility/src/DrmAutomatedUsage.cpp
commondrm/drmutility/src/DrmAutomatedUsageImpl.cpp
commondrm/drmutility/src/DrmQueue.inl
commondrm/drmutility/src/DrmRightsInfo.cpp
commondrm/drmutility/src/DrmRightsInfoData.cpp
commondrm/drmutility/src/DrmRightsInfoImpl.cpp
commondrm/drmutility/src/DrmUiHandling.cpp
commondrm/drmutility/src/DrmUiHandlingImpl.cpp
commondrm/drmutility/src/DrmUtility.cpp
commondrm/drmutility/src/DrmUtilityDmgrWrapper.cpp
commondrm/drmutility/src/DrmUtilityDownloadManager.cpp
commondrm/drmutility/src/DrmUtilityGlobalNoteWrapper.cpp
commondrm/drmutility/src/DrmUtilityInfoNoteWrapper.cpp
commondrm/drmutility/src/drmautomatedusagedata.cpp
commondrm/drmutility/src/drmautomatedusageerrorhandling.cpp
commondrm/drmutility/src/drmuierrorhandling.cpp
commondrm/drmutility/src/drmuihandlingdata.cpp
commondrm/drmutility/src/drmutilitycommon.cpp
commondrm/drmutility/src/drmutilityui.cpp
commondrm/drmutility/src/drmutilitywmdrm.cpp
commondrm/drmutility/src/drmutilitywmdrmutilities.cpp
commondrm/drmutility/src/drmutilitywmdrmwrapper.cpp
commondrm/drmutility/src/rdrmhelperclient.cpp
commondrm/group/bld.inf
commondrm/rom/DRMEncryptor.iby
commondrm/rom/DRMEncryptorResources.iby
commondrm/rom/DRMRightsManagerUI.iby
commondrm/rom/DRMRightsManagerUIResources.iby
commondrm/rom/drmrightsstoringlocation.iby
commondrm/rom/drmserviceapiwrapper.iby
commondrm/rom/drmsettingsplugin.iby
commondrm/rom/drmsettingspluginresources.iby
commondrm/rom/drmutility.iby
commondrm/rom/drmutility_resources.iby
drm_plat/camese_framework_api/camese_framework_api.metaxml
drm_plat/camese_framework_api/group/bld.inf
drm_plat/camese_framework_api/inc/wmdrmdlacancelobserver.h
drm_plat/camese_framework_api/inc/wmdrmdlahttpplugin.h
drm_plat/camese_framework_api/inc/wmdrmdlahttpplugin.inl
drm_plat/camese_framework_api/inc/wmdrmdlatypes.h
drm_plat/camese_framework_api/inc/wmdrmdlauinotifier.h
drm_plat/camese_framework_api/inc/wmdrmdlauiplugin.h
drm_plat/camese_framework_api/inc/wmdrmdlauiplugin.inl
drm_plat/camese_utility_api/camese_utility_api.metaxml
drm_plat/camese_utility_api/group/bld.inf
drm_plat/camese_utility_api/inc/CameseObserver.h
drm_plat/camese_utility_api/inc/CameseUtility.h
drm_plat/dcf_repository_api/dcf_repository_api.metaxml
drm_plat/dcf_repository_api/group/bld.inf
drm_plat/dcf_repository_api/inc/DcfEntry.h
drm_plat/dcf_repository_api/inc/DcfRep.h
drm_plat/dcf_repository_api/inc/DcfRepCli.h
drm_plat/drm_agents_api/drm_agents_api.metaxml
drm_plat/drm_agents_api/group/bld.inf
drm_plat/drm_agents_api/inc/drmagents.h
drm_plat/drm_common_api/drm_common_api.metaxml
drm_plat/drm_common_api/group/bld.inf
drm_plat/drm_common_api/inc/DRMCommon.h
drm_plat/drm_common_api/tsrc/Bmarm/DRMCommonTestU.DEF
drm_plat/drm_common_api/tsrc/Bwins/DRMCommonTestU.DEF
drm_plat/drm_common_api/tsrc/EABI/DRMCommonTestU.def
drm_plat/drm_common_api/tsrc/data/mmc/DRM/content.dcf
drm_plat/drm_common_api/tsrc/group/DRMCommonTest.mmp
drm_plat/drm_common_api/tsrc/group/DrmCommonTest.pkg
drm_plat/drm_common_api/tsrc/group/bld.inf
drm_plat/drm_common_api/tsrc/inc/DRMCommonTest.h
drm_plat/drm_common_api/tsrc/src/DRMCommonTest.cpp
drm_plat/drm_common_api/tsrc/src/DRMCommonTestCases.cpp
drm_plat/drm_legacy_api/drm_legacy_api.metaxml
drm_plat/drm_legacy_api/group/bld.inf
drm_plat/drm_legacy_api/inc/DRMEvent.h
drm_plat/drm_legacy_api/inc/DRMEventAddRemove.h
drm_plat/drm_legacy_api/inc/DRMEventObserver.h
drm_plat/drm_legacy_api/inc/DRMLicenseChecker.mmi
drm_plat/drm_legacy_api/inc/DRMLicenseManager.mmi
drm_plat/drm_legacy_api/inc/DRMMessageParser.h
drm_plat/drm_legacy_api/inc/DRMNotifier.h
drm_plat/drm_legacy_api/inc/DRMRightsClient.h
drm_plat/drm_legacy_api/inc/Oma1DcfCreator.h
drm_plat/drm_legacy_api/inc/Oma2Dcf.h
drm_plat/drm_license_manager_api/drm_license_manager_api.metaxml
drm_plat/drm_license_manager_api/group/bld.inf
drm_plat/drm_license_manager_api/inc/DRMLicenseManager.h
drm_plat/drm_rights_api/drm_rights_api.metaxml
drm_plat/drm_rights_api/group/bld.inf
drm_plat/drm_rights_api/inc/DRMConstraint.h
drm_plat/drm_rights_api/inc/DRMIndividualConstraintExtension.h
drm_plat/drm_rights_api/inc/DRMPermission.h
drm_plat/drm_rights_api/inc/DRMTypes.h
drm_plat/drm_rights_api/inc/DcfCommon.h
drm_plat/drm_rights_api/inc/DcfCommon.inl
drm_plat/drm_rights_api/inc/DrmAsset.h
drm_plat/drm_rights_api/inc/DrmRights.h
drm_plat/drm_rights_api/tsrc/Bmarm/DrmRightsTestU.DEF
drm_plat/drm_rights_api/tsrc/Bwins/DrmRightsTestU.DEF
drm_plat/drm_rights_api/tsrc/EABI/DrmRightsTestU.def
drm_plat/drm_rights_api/tsrc/data/c/content.dcf
drm_plat/drm_rights_api/tsrc/group/DrmRightsTest.mmp
drm_plat/drm_rights_api/tsrc/group/DrmRightsTest.pkg
drm_plat/drm_rights_api/tsrc/group/bld.inf
drm_plat/drm_rights_api/tsrc/inc/DrmRightsTest.h
drm_plat/drm_rights_api/tsrc/src/DrmRightsTest.cpp
drm_plat/drm_rights_api/tsrc/src/DrmRightsTestCases.cpp
drm_plat/drm_secondary_display_api/drm_secondary_display_api.metaxml
drm_plat/drm_secondary_display_api/group/bld.inf
drm_plat/drm_secondary_display_api/inc/SecondaryDisplay/DRMHelperSecondaryDisplay.h
drm_plat/drm_service_api/drm_service_api.metaxml
drm_plat/drm_service_api/group/bld.inf
drm_plat/drm_service_api/inc/drmserviceapi.h
drm_plat/drm_utility_api/drm_utility_api.metaxml
drm_plat/drm_utility_api/group/bld.inf
drm_plat/drm_utility_api/inc/drmasyncobserver.h
drm_plat/drm_utility_api/inc/drmautomatedusage.h
drm_plat/drm_utility_api/inc/drmautomatedusageobserver.h
drm_plat/drm_utility_api/inc/drmerrorhandling.h
drm_plat/drm_utility_api/inc/drmhandleerrorobserver.h
drm_plat/drm_utility_api/inc/drmrightsinfo.h
drm_plat/drm_utility_api/inc/drmuicheckrightsobserver.h
drm_plat/drm_utility_api/inc/drmuihandling.h
drm_plat/drm_utility_api/inc/drmutility.h
drm_plat/drm_utility_api/inc/drmutilitytypes.h
drm_plat/group/bld.inf
drm_plat/roap_api/group/bld.inf
drm_plat/roap_api/inc/RoapDef.h
drm_plat/roap_api/inc/RoapEng.h
drm_plat/roap_api/inc/RoapEngBase.h
drm_plat/roap_api/inc/RoapMessage.h
drm_plat/roap_api/inc/RoapObserver.h
drm_plat/roap_api/inc/RoapTrigger.h
drm_plat/roap_api/roap_api.metaxml
drm_plat/roap_api/tsrc/Bmarm/RoapTestU.DEF
drm_plat/roap_api/tsrc/Bwins/RoapTestU.DEF
drm_plat/roap_api/tsrc/EABI/RoapTestU.def
drm_plat/roap_api/tsrc/group/RoapTest.mmp
drm_plat/roap_api/tsrc/group/RoapTest.pkg
drm_plat/roap_api/tsrc/group/bld.inf
drm_plat/roap_api/tsrc/inc/RoapTest.h
drm_plat/roap_api/tsrc/src/RoapTest.cpp
drm_plat/roap_api/tsrc/src/RoapTestCases.cpp
drm_plat/wmdrm_access_api/group/bld.inf
drm_plat/wmdrm_access_api/inc/wmdrmaccess.h
drm_plat/wmdrm_access_api/inc/wmdrmaccessecominterface.h
drm_plat/wmdrm_access_api/inc/wmdrmaccessecominterface.inl
drm_plat/wmdrm_access_api/tsrc/bwins/helixstifu.def
drm_plat/wmdrm_access_api/tsrc/eabi/helixstifu.def
drm_plat/wmdrm_access_api/tsrc/group/bld.inf
drm_plat/wmdrm_access_api/tsrc/group/helixstif.mmp
drm_plat/wmdrm_access_api/tsrc/group/helixstif.pkg
drm_plat/wmdrm_access_api/tsrc/inc/helixstif.h
drm_plat/wmdrm_access_api/tsrc/src/helixstif.cpp
drm_plat/wmdrm_access_api/tsrc/src/helixstifcases.cpp
drm_plat/wmdrm_access_api/wmdrm_access_api.metaxml
drm_plat/wmdrm_core_api/group/bld.inf
drm_plat/wmdrm_core_api/inc/wmdrmagent.h
drm_plat/wmdrm_core_api/wmdrm_core_api.metaxml
drm_pub/drm_helper_api/drm_helper_api.metaxml
drm_pub/drm_helper_api/group/bld.inf
drm_pub/drm_helper_api/inc/DRMHelperServerInternalCRKeys.h
drm_pub/drm_helper_api/inc/Drmhelper.h
drm_pub/drm_helper_api/inc/RDRMHelper.h
drm_pub/drm_helper_api/loc/DRMCommon.loc
drm_pub/drm_helper_api/tsrc/BWINS/drmhelpertestu.def
drm_pub/drm_helper_api/tsrc/EABI/drmhelpertestu.def
drm_pub/drm_helper_api/tsrc/group/bld.inf
drm_pub/drm_helper_api/tsrc/group/drmhelpertest.mmp
drm_pub/drm_helper_api/tsrc/group/drmhelpertest.pkg
drm_pub/drm_helper_api/tsrc/inc/drmhelpertest.h
drm_pub/drm_helper_api/tsrc/inc/drmhelpertestdata.h
drm_pub/drm_helper_api/tsrc/src/drmhelpertest.cpp
drm_pub/drm_helper_api/tsrc/src/drmhelpertestcases.cpp
drm_pub/drm_license_checker_api/drm_license_checker_api.metaxml
drm_pub/drm_license_checker_api/group/bld.inf
drm_pub/drm_license_checker_api/inc/DRMLicenseChecker.h
drm_pub/drm_license_checker_api/tsrc/Bmarm/DrmLicenseCheckerTestU.DEF
drm_pub/drm_license_checker_api/tsrc/Bwins/DrmLicenseCheckerTestU.DEF
drm_pub/drm_license_checker_api/tsrc/EABI/DrmLicenseCheckerTestU.def
drm_pub/drm_license_checker_api/tsrc/data/c/checker.txt
drm_pub/drm_license_checker_api/tsrc/group/DrmLicenseCheckerTest.mmp
drm_pub/drm_license_checker_api/tsrc/group/DrmLicenseCheckerTest.pkg
drm_pub/drm_license_checker_api/tsrc/group/bld.inf
drm_pub/drm_license_checker_api/tsrc/inc/DrmLicenseCheckerTest.h
drm_pub/drm_license_checker_api/tsrc/src/DrmLicenseCheckerTest.cpp
drm_pub/drm_license_checker_api/tsrc/src/DrmLicenseCheckerTestCases.cpp
drm_pub/group/bld.inf
drm_pub/oma_drm_caf_agent_api/group/bld.inf
drm_pub/oma_drm_caf_agent_api/inc/Oma2Agent.h
drm_pub/oma_drm_caf_agent_api/oma_drm_caf_agent_api.metaxml
drm_pub/oma_drm_caf_agent_api/tsrc/bc/BCDRMCAFCAPS_exe/group/BCDRMCAFCAPS_exe.SIS
drm_pub/oma_drm_caf_agent_api/tsrc/bc/BCDRMCAFCAPS_exe/group/BCDRMCAFCAPS_exe.mmp
drm_pub/oma_drm_caf_agent_api/tsrc/bc/BCDRMCAFCAPS_exe/group/BCDRMCAFCAPS_exe.pkg
drm_pub/oma_drm_caf_agent_api/tsrc/bc/BCDRMCAFCAPS_exe/group/bld.inf
drm_pub/oma_drm_caf_agent_api/tsrc/bc/BCDRMCAFCAPS_exe/src/BCDRMCAFCAPS_exe.cpp
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/Bmarm/DRM_CAFU.DEF
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/Bwins/DRM_CAFU.DEF
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/EABI/DRM_CAFU.def
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/data/content-noenc-trunc.odf
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/data/content-noenc.odf
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/data/content.dcf
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/data/content.odf
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/data/content.txt
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/DRM_CAF.cfg
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/DRM_CAF.mmp
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/DRM_CAF.pkg
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/DRM_CAF_DoxyFile.txt
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/DRM_CAF_nrm.mmp
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/TestFramework.ini
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/bld.inf
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/drmcaf_c.bat
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/drmcaf_z.bat
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/inc/DRM_CAF.h
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/src/DRM_CAF.cpp
drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/src/DRM_CAFBlocks.cpp
drm_pub/oma_drm_caf_agent_api/tsrc/bc/group/bld.inf
drm_pub/oma_drm_caf_agent_api/tsrc/bc/sis/50_MM_DRMCAF.SIS
drm_pub/oma_drm_caf_agent_api/tsrc/bc/sis/50_MM_DRMCAF.pkg
drm_pub/oma_drm_caf_agent_api/tsrc/bc/sis/51_drm_drmcaf.pkg
drm_pub/oma_drm_caf_agent_api/tsrc/bc/sis/51_drm_drmcaf.sis
group/bld.inf
inc/Base64.h
inc/BitStream.h
inc/BitStream.inl
inc/CmlaCrypto.h
inc/DRMClockClient.h
inc/DRMEventModify.h
inc/DRMEventTimeChange.h
inc/DRMHelperCommon.h
inc/DRMHelperServer.h
inc/DRMHelperSession.h
inc/DrmKeyStorage.h
inc/DrmUdtHandler.h
inc/DrmUdtObserver.h
inc/DrmUtilityInternalcrkeys.h
inc/Oma1Dcf.h
inc/OmaCrypto.h
inc/RecDRM.h
inc/RoapStorageClient.h
inc/cleanupresetanddestroy.h
inc/cleanupresetanddestroy.inl
inc/drmrightsdb.h
inc/drmrightsstoringlocation.h
inc/drmserviceapiwrapper.h
inc/drmsettingsplugininternalcrkeys.h
inc/drmutilityinternaltypes.h
inc/drmutilitywmdrmutilities.h
inc/wbxmlroaptriggerparser.h
inc/wmdrmclient.h
inc/wmdrmclientwrapper.h
inc/wmdrmdlawrapper.h
inc/wmdrmfileserverclient.h
inc/wmdrmpkclientwrapper.h
inc/wmdrmserverinternalcrkeys.h
layers.sysdef.xml
omadrm/cenrep/keys_drm5.xls
omadrm/cenrep/keys_drmsettings.xls
omadrm/conf/drm5.confml
omadrm/conf/drm5_10205CA7.crml
omadrm/conf/drm5_10205CBF.crml
omadrm/conf/drm5_200195ad.crml
omadrm/conf/drmsettings.confml
omadrm/conf/drmsettings_102823B4.crml
omadrm/conf/drmutility.confml
omadrm/conf/drmutility_20022D51.crml
omadrm/data/OmaDrm_Stub.SIS
omadrm/data/OmaDrm_Stub.pkg
omadrm/drmengine/agentv2/inc/DcfCache.h
omadrm/drmengine/agentv2/inc/Oma2AgentAttributes.h
omadrm/drmengine/agentv2/inc/Oma2AgentContent.h
omadrm/drmengine/agentv2/inc/Oma2AgentData.h
omadrm/drmengine/agentv2/inc/Oma2AgentFactory.h
omadrm/drmengine/agentv2/inc/Oma2AgentImportFile.h
omadrm/drmengine/agentv2/inc/Oma2AgentManager.h
omadrm/drmengine/agentv2/inc/Oma2AgentRightsManager.h
omadrm/drmengine/agentv2/src/101F6DB4.rss
omadrm/drmengine/agentv2/src/DcfCache.cpp
omadrm/drmengine/agentv2/src/Oma2Agent.cpp
omadrm/drmengine/agentv2/src/Oma2AgentAttributes.cpp
omadrm/drmengine/agentv2/src/Oma2AgentContent.cpp
omadrm/drmengine/agentv2/src/Oma2AgentData.cpp
omadrm/drmengine/agentv2/src/Oma2AgentFactory.cpp
omadrm/drmengine/agentv2/src/Oma2AgentImportFile.cpp
omadrm/drmengine/agentv2/src/Oma2AgentManager.cpp
omadrm/drmengine/agentv2/src/Oma2AgentRightsManager.cpp
omadrm/drmengine/bwinscw/DRMCommonU.DEF
omadrm/drmengine/bwinscw/DcfRepU.DEF
omadrm/drmengine/bwinscw/DrmCryptoU.DEF
omadrm/drmengine/bwinscw/DrmDcfU.DEF
omadrm/drmengine/bwinscw/DrmKeyStorageU.DEF
omadrm/drmengine/bwinscw/DrmParsersU.DEF
omadrm/drmengine/bwinscw/DrmRightsU.DEF
omadrm/drmengine/bwinscw/DrmServerInterfacesU.DEF
omadrm/drmengine/bwinscw/DrmServiceAPIu.def
omadrm/drmengine/bwinscw/DrmStdKeyStorageU.DEF
omadrm/drmengine/bwinscw/OMADRM2AgentU.DEF
omadrm/drmengine/bwinscw/ROAPHandlerU.DEF
omadrm/drmengine/bwinscw/RightsServerU.DEF
omadrm/drmengine/dcf/inc/Oma2DcfPartInfo.h
omadrm/drmengine/dcf/src/DcfCommon.cpp
omadrm/drmengine/dcf/src/Oma1Dcf.cpp
omadrm/drmengine/dcf/src/Oma2Dcf.cpp
omadrm/drmengine/dcf/src/Oma2DcfPartInfo.cpp
omadrm/drmengine/dcfrepository/client/src/DcfEntry.cpp
omadrm/drmengine/dcfrepository/client/src/DcfRep.cpp
omadrm/drmengine/dcfrepository/client/src/DcfRepCli.cpp
omadrm/drmengine/dcfrepository/common/DcfRepCommon.h
omadrm/drmengine/dcfrepository/server/inc/DcfRepSrv.h
omadrm/drmengine/dcfrepository/server/inc/DcfRepSrvSes.h
omadrm/drmengine/dcfrepository/server/inc/FileScan.h
omadrm/drmengine/dcfrepository/server/inc/Pair.h
omadrm/drmengine/dcfrepository/server/inc/SearchLeaf.h
omadrm/drmengine/dcfrepository/server/inc/drmlog.h
omadrm/drmengine/dcfrepository/server/src/DcfRepSrv.cpp
omadrm/drmengine/dcfrepository/server/src/DcfRepSrvSes.cpp
omadrm/drmengine/dcfrepository/server/src/FileScan.cpp
omadrm/drmengine/dcfrepository/server/src/Pair.cpp
omadrm/drmengine/dcfrepository/server/src/SearchLeaf.cpp
omadrm/drmengine/dm/inc/b64.h
omadrm/drmengine/dm/src/DRMMessageParser.cpp
omadrm/drmengine/dm/src/Oma1DcfCreator.cpp
omadrm/drmengine/dm/src/b64.cpp
omadrm/drmengine/drmbackup/inc/DRMBackup.h
omadrm/drmengine/drmbackup/inc/DRMBackupInterface.h
omadrm/drmengine/drmbackup/inc/DRMBackupObserver.h
omadrm/drmengine/drmbackup/src/DRMBackup.cpp
omadrm/drmengine/drmbackup/src/DRMBackupObserver.cpp
omadrm/drmengine/drmclock/Inc/DRMClock.h
omadrm/drmengine/drmclock/Inc/DRMClockServer.h
omadrm/drmengine/drmclock/Inc/DRMClockSession.h
omadrm/drmengine/drmclock/Inc/DRMNitzObserver.h
omadrm/drmengine/drmclock/Src/DRMClock.cpp
omadrm/drmengine/drmclock/Src/DRMClockClient.cpp
omadrm/drmengine/drmclock/Src/DRMClockClient2.cpp
omadrm/drmengine/drmclock/Src/DRMClockServer.cpp
omadrm/drmengine/drmclock/Src/DRMClockSession.cpp
omadrm/drmengine/drmclock/Src/DRMNitzObserver.cpp
omadrm/drmengine/drmcrypto/inc/CmlaCrypto.h
omadrm/drmengine/drmcrypto/src/OmaCrypto.cpp
omadrm/drmengine/drmcrypto/stub/CmlaCryptoStub.cpp
omadrm/drmengine/drmserviceapi/src/drmserviceapi.cpp
omadrm/drmengine/eabi/DRMCommonU.DEF
omadrm/drmengine/eabi/DcfRepU.DEF
omadrm/drmengine/eabi/DrmCryptoU.DEF
omadrm/drmengine/eabi/DrmDcfU.DEF
omadrm/drmengine/eabi/DrmKeyStorageU.DEF
omadrm/drmengine/eabi/DrmParsersU.DEF
omadrm/drmengine/eabi/DrmRightsU.DEF
omadrm/drmengine/eabi/DrmServerInterfacesU.DEF
omadrm/drmengine/eabi/DrmServiceAPIu.def
omadrm/drmengine/eabi/DrmStdKeyStorageU.DEF
omadrm/drmengine/eabi/ROAPHandlerU.DEF
omadrm/drmengine/group/CryptoPrep.flm
omadrm/drmengine/group/CryptoPrep.mak
omadrm/drmengine/group/CryptoPrep.xml
omadrm/drmengine/group/DRMCommon.mmp
omadrm/drmengine/group/DRM_BAT.mmp
omadrm/drmengine/group/DcfRep.mmp
omadrm/drmengine/group/DcfRepSrv.mmp
omadrm/drmengine/group/DrmCrypto.mmp
omadrm/drmengine/group/DrmDcf.mmp
omadrm/drmengine/group/DrmKeyStorage.mmp
omadrm/drmengine/group/DrmParsers.mmp
omadrm/drmengine/group/DrmRel1_0StringDict00.mmp
omadrm/drmengine/group/DrmRel1_0StringDict00AttributeTable.mak
omadrm/drmengine/group/DrmRel1_0StringDict00AttributeValueTable.mak
omadrm/drmengine/group/DrmRel1_0StringDict00TagTable.mak
omadrm/drmengine/group/DrmRel2_1StringDict00.mmp
omadrm/drmengine/group/DrmRights.mmp
omadrm/drmengine/group/DrmServerInterfaces.mmp
omadrm/drmengine/group/DrmServiceAPI.mmp
omadrm/drmengine/group/DrmStdKeyStorage.mmp
omadrm/drmengine/group/OmaDrmAgent.mmp
omadrm/drmengine/group/ROAPHandler.mmp
omadrm/drmengine/group/RightsServer.mmp
omadrm/drmengine/group/backup_registration.xml
omadrm/drmengine/keystorage/data/CM/DeviceCert.der
omadrm/drmengine/keystorage/data/CM/DevicePrivateKey.der
omadrm/drmengine/keystorage/data/CM/SigningCert00.der
omadrm/drmengine/keystorage/data/CM/SigningCert01.der
omadrm/drmengine/keystorage/data/CMLA/DeviceCert.der
omadrm/drmengine/keystorage/data/CMLA/DevicePrivateKey.der
omadrm/drmengine/keystorage/data/CMLA/SigningCert00.der
omadrm/drmengine/keystorage/data/CMLA/SigningCert01.der
omadrm/drmengine/keystorage/data/DeviceCert.der
omadrm/drmengine/keystorage/data/DevicePrivateKey.der
omadrm/drmengine/keystorage/data/SigningCert00.der
omadrm/drmengine/keystorage/data/SigningCert01.der
omadrm/drmengine/keystorage/data/UdtCertificate.der
omadrm/drmengine/keystorage/inc/DrmStdKeyStorage.h
omadrm/drmengine/keystorage/src/DrmKeyStorage.cpp
omadrm/drmengine/keystorage/src/DrmStdKeyStorage.cpp
omadrm/drmengine/legacy/inc/DRMCommon.rh
omadrm/drmengine/legacy/src/DRMCommon.cpp
omadrm/drmengine/legacy/src/drmcommon.rss
omadrm/drmengine/notifier/inc/DRMEventHandler.h
omadrm/drmengine/notifier/inc/DRMMessageStorage.h
omadrm/drmengine/notifier/inc/DRMNotifierClient.h
omadrm/drmengine/notifier/inc/DRMNotifierServer.h
omadrm/drmengine/notifier/inc/DRMNotifierSession.h
omadrm/drmengine/notifier/src/DRMEvent.cpp
omadrm/drmengine/notifier/src/DRMEventAddRemove.cpp
omadrm/drmengine/notifier/src/DRMEventHandler.cpp
omadrm/drmengine/notifier/src/DRMEventModify.cpp
omadrm/drmengine/notifier/src/DRMEventTimeChange.cpp
omadrm/drmengine/notifier/src/DRMMessageStorage.cpp
omadrm/drmengine/notifier/src/DRMNotifier.cpp
omadrm/drmengine/notifier/src/DRMNotifierClient.cpp
omadrm/drmengine/notifier/src/DRMNotifierServer.cpp
omadrm/drmengine/notifier/src/DRMNotifierSession.cpp
omadrm/drmengine/ro/inc/DRMProtectedRoParser.h
omadrm/drmengine/ro/inc/DrmRel1_0StringDict00.h
omadrm/drmengine/ro/inc/DrmRel1_0StringDict00AttributeTable.h
omadrm/drmengine/ro/inc/DrmRel1_0StringDict00AttributeValueTable.h
omadrm/drmengine/ro/inc/DrmRel1_0StringDict00TagTable.h
omadrm/drmengine/ro/inc/DrmRightsParser.h
omadrm/drmengine/ro/src/101F6DB6.RSS
omadrm/drmengine/ro/src/DRMConstraint.cpp
omadrm/drmengine/ro/src/DRMPermission.cpp
omadrm/drmengine/ro/src/DrmAsset.cpp
omadrm/drmengine/ro/src/DrmProtectedRoParser.cpp
omadrm/drmengine/ro/src/DrmRel1_0StringDict00.cpp
omadrm/drmengine/ro/src/DrmRel1_0StringDict00AttributeTable.cpp
omadrm/drmengine/ro/src/DrmRel1_0StringDict00AttributeTable.st
omadrm/drmengine/ro/src/DrmRel1_0StringDict00AttributeValueTable.cpp
omadrm/drmengine/ro/src/DrmRel1_0StringDict00AttributeValueTable.st
omadrm/drmengine/ro/src/DrmRel1_0StringDict00TagTable.cpp
omadrm/drmengine/ro/src/DrmRel1_0StringDict00TagTable.st
omadrm/drmengine/ro/src/DrmRights.cpp
omadrm/drmengine/ro/src/DrmRightsParser.cpp
omadrm/drmengine/roap/inc/DeviceHello.h
omadrm/drmengine/roap/inc/JoinDomainReq.h
omadrm/drmengine/roap/inc/JoinDomainResp.h
omadrm/drmengine/roap/inc/JoinDomainRespParser.h
omadrm/drmengine/roap/inc/LeaveDomainReq.h
omadrm/drmengine/roap/inc/LeaveDomainResp.h
omadrm/drmengine/roap/inc/LeaveDomainRespParser.h
omadrm/drmengine/roap/inc/MeteringReportReq.h
omadrm/drmengine/roap/inc/MeteringReportResp.h
omadrm/drmengine/roap/inc/MeteringReportRespParser.h
omadrm/drmengine/roap/inc/RIContext.h
omadrm/drmengine/roap/inc/RIHello.h
omadrm/drmengine/roap/inc/RIHelloParser.h
omadrm/drmengine/roap/inc/RegistrationReq.h
omadrm/drmengine/roap/inc/RegistrationResp.h
omadrm/drmengine/roap/inc/RegistrationRespParser.h
omadrm/drmengine/roap/inc/RespParser.h
omadrm/drmengine/roap/inc/RightsReq.h
omadrm/drmengine/roap/inc/RightsResp.h
omadrm/drmengine/roap/inc/RightsRespParser.h
omadrm/drmengine/roap/inc/RoapConnection.h
omadrm/drmengine/roap/inc/RoapHttpHandler.h
omadrm/drmengine/roap/inc/RoapLog.h
omadrm/drmengine/roap/inc/RoapParser.h
omadrm/drmengine/roap/inc/RoapResponse.h
omadrm/drmengine/roap/inc/RoapSigner.h
omadrm/drmengine/roap/inc/RoapSyncWrapper.h
omadrm/drmengine/roap/inc/RoapTriggerParser.h
omadrm/drmengine/roap/src/DeviceHello.cpp
omadrm/drmengine/roap/src/JoinDomainReq.cpp
omadrm/drmengine/roap/src/JoinDomainResp.cpp
omadrm/drmengine/roap/src/JoinDomainRespParser.cpp
omadrm/drmengine/roap/src/LeaveDomainReq.cpp
omadrm/drmengine/roap/src/LeaveDomainResp.cpp
omadrm/drmengine/roap/src/LeaveDomainRespParser.cpp
omadrm/drmengine/roap/src/MeteringReportReq.cpp
omadrm/drmengine/roap/src/MeteringReportResp.cpp
omadrm/drmengine/roap/src/MeteringReportRespParser.cpp
omadrm/drmengine/roap/src/RIContext.cpp
omadrm/drmengine/roap/src/RIHello.cpp
omadrm/drmengine/roap/src/RIHelloParser.cpp
omadrm/drmengine/roap/src/RegistrationReq.cpp
omadrm/drmengine/roap/src/RegistrationResp.cpp
omadrm/drmengine/roap/src/RegistrationRespParser.cpp
omadrm/drmengine/roap/src/RightsReq.cpp
omadrm/drmengine/roap/src/RightsResp.cpp
omadrm/drmengine/roap/src/RightsRespParser.cpp
omadrm/drmengine/roap/src/RoapConnection.cpp
omadrm/drmengine/roap/src/RoapEng.cpp
omadrm/drmengine/roap/src/RoapEngBase.cpp
omadrm/drmengine/roap/src/RoapHttpHandler.cpp
omadrm/drmengine/roap/src/RoapMessage.cpp
omadrm/drmengine/roap/src/RoapParser.cpp
omadrm/drmengine/roap/src/RoapResponse.cpp
omadrm/drmengine/roap/src/RoapSigner.cpp
omadrm/drmengine/roap/src/RoapSyncWrapper.cpp
omadrm/drmengine/roap/src/RoapTrigger.cpp
omadrm/drmengine/roap/src/RoapTriggerParser.cpp
omadrm/drmengine/roapstorage/inc/DRMDomainContext.h
omadrm/drmengine/roapstorage/inc/DRMRIContext.h
omadrm/drmengine/roapstorage/inc/RoapOcsp.h
omadrm/drmengine/roapstorage/inc/RoapStorageServer.h
omadrm/drmengine/roapstorage/inc/RoapStorageSession.h
omadrm/drmengine/roapstorage/inc/certid.h
omadrm/drmengine/roapstorage/inc/oids.h
omadrm/drmengine/roapstorage/inc/responsedecoder.h
omadrm/drmengine/roapstorage/src/DRMContextDB.cpp
omadrm/drmengine/roapstorage/src/DRMDomainContext.cpp
omadrm/drmengine/roapstorage/src/DRMRIContext.cpp
omadrm/drmengine/roapstorage/src/RoapStorageClient.cpp
omadrm/drmengine/roapstorage/src/RoapStorageClientStub.cpp
omadrm/drmengine/roapstorage/src/RoapStorageServer.cpp
omadrm/drmengine/roapstorage/src/RoapStorageSession.cpp
omadrm/drmengine/roapstorage/src/certid.cpp
omadrm/drmengine/roapstorage/src/response.cpp
omadrm/drmengine/roapstorage/src/responsecertinfo.cpp
omadrm/drmengine/roapstorage/src/responsedecoder.cpp
omadrm/drmengine/server/data/101F51F2.exc
omadrm/drmengine/server/inc/DRMActiveDeletion.h
omadrm/drmengine/server/inc/DRMActiveOperation.h
omadrm/drmengine/server/inc/DRMCommonData.h
omadrm/drmengine/server/inc/DRMContextDB.h
omadrm/drmengine/server/inc/DRMDbSession.h
omadrm/drmengine/server/inc/DRMDbSession.inl
omadrm/drmengine/server/inc/DRMEngineClientServer.h
omadrm/drmengine/server/inc/DRMObsoleteFinder.h
omadrm/drmengine/server/inc/DRMPointerArray.h
omadrm/drmengine/server/inc/DRMPointerArray.inl
omadrm/drmengine/server/inc/DRMReplayCache.h
omadrm/drmengine/server/inc/DRMRightsCleaner.h
omadrm/drmengine/server/inc/DRMRightsData.h
omadrm/drmengine/server/inc/DRMRightsServer.h
omadrm/drmengine/server/inc/DRMXOma.h
omadrm/drmengine/server/inc/drmclockclientserver.h
omadrm/drmengine/server/inc/drmcommonclientserver.h
omadrm/drmengine/server/inc/drmconsume.h
omadrm/drmengine/server/inc/drmenginetypedefs.h
omadrm/drmengine/server/inc/drmlog.h
omadrm/drmengine/server/inc/drmmeteringdb.h
omadrm/drmengine/server/inc/drmmeteringdbdata.h
omadrm/drmengine/server/inc/drmnotifierclientserver.h
omadrm/drmengine/server/inc/drmparentstorage.h
omadrm/drmengine/server/inc/drmroapclientserver.h
omadrm/drmengine/server/src/DRMActiveDeletion.cpp
omadrm/drmengine/server/src/DRMActiveOperation.cpp
omadrm/drmengine/server/src/DRMCommonData.cpp
omadrm/drmengine/server/src/DRMDbSession.cpp
omadrm/drmengine/server/src/DRMObsoleteFinder.cpp
omadrm/drmengine/server/src/DRMReplayCache.cpp
omadrm/drmengine/server/src/DRMRightsCleaner.cpp
omadrm/drmengine/server/src/DRMRightsClient.cpp
omadrm/drmengine/server/src/DRMRightsClientStub.cpp
omadrm/drmengine/server/src/DRMRightsData.cpp
omadrm/drmengine/server/src/DRMRightsServer.cpp
omadrm/drmengine/server/src/DRMServerStarter.cpp
omadrm/drmengine/server/src/DRMXOma.cpp
omadrm/drmengine/server/src/drmconsume.cpp
omadrm/drmengine/server/src/drmcrypto.c
omadrm/drmengine/server/src/drmmeteringdb.cpp
omadrm/drmengine/server/src/drmmeteringdbdata.cpp
omadrm/drmengine/server/src/drmparentstorage.cpp
omadrm/drmengine/server/src/drmpermissionitem.cpp
omadrm/drmengine/server/src/drmrightsdb.cpp
omadrm/drmengine/utils/inc/MultipartHandler.h
omadrm/drmengine/utils/inc/dbwatcher.h
omadrm/drmengine/utils/inc/dirwatcher.h
omadrm/drmengine/utils/inc/drmaescrypto.h
omadrm/drmengine/utils/inc/drmrel2_1stringdict00.h
omadrm/drmengine/utils/inc/drmrel2_1stringdict00attributetable.h
omadrm/drmengine/utils/inc/drmrel2_1stringdict00attributevaluetable.h
omadrm/drmengine/utils/inc/drmrel2_1stringdict00tagtable.h
omadrm/drmengine/utils/inc/procwatcher.h
omadrm/drmengine/utils/inc/watcherobserver.h
omadrm/drmengine/utils/src/200B48A.rss
omadrm/drmengine/utils/src/Base64.cpp
omadrm/drmengine/utils/src/CmlaCryptoStub.cpp
omadrm/drmengine/utils/src/DrmRel2_1StringDict00.cpp
omadrm/drmengine/utils/src/DrmRel2_1StringDict00AttributeTable.mak
omadrm/drmengine/utils/src/DrmRel2_1StringDict00AttributeTable.st
omadrm/drmengine/utils/src/DrmRel2_1StringDict00AttributeValueTable.mak
omadrm/drmengine/utils/src/DrmRel2_1StringDict00AttributeValueTable.st
omadrm/drmengine/utils/src/DrmRel2_1StringDict00TagTable.mak
omadrm/drmengine/utils/src/DrmRel2_1StringDict00TagTable.st
omadrm/drmengine/utils/src/MultipartHandler.cpp
omadrm/drmengine/utils/src/dbwatcher.cpp
omadrm/drmengine/utils/src/dirwatcher.cpp
omadrm/drmengine/utils/src/drmaescrypto.cpp
omadrm/drmengine/utils/src/drmrel2_1stringdict00attributetable.cpp
omadrm/drmengine/utils/src/drmrel2_1stringdict00attributevaluetable.cpp
omadrm/drmengine/utils/src/drmrel2_1stringdict00tagtable.cpp
omadrm/drmengine/utils/src/procwatcher.cpp
omadrm/drmhelper/BMARM/DRMHELPERDMGRWRAPPERU.DEF
omadrm/drmhelper/BMARM/DRMHELPERU.DEF
omadrm/drmhelper/BWINSCW/DRMHelperU.DEF
omadrm/drmhelper/BWINSCW/drmhelperdmgrwrapperU.DEF
omadrm/drmhelper/EABI/DRMHelperU.DEF
omadrm/drmhelper/EABI/drmhelperdmgrwrapperU.DEF
omadrm/drmhelper/drmhelperserver/bwinscw/DRMHelperServerU.DEF
omadrm/drmhelper/drmhelperserver/eabi/DRMHelperServerU.DEF
omadrm/drmhelper/drmhelperserver/group/DRMHelperServer.mmp
omadrm/drmhelper/drmhelperserver/group/bld.inf
omadrm/drmhelper/drmhelperserver/inc/ConfigObserver.h
omadrm/drmhelper/drmhelperserver/inc/DRMHelperServerConfigInternalCRKeys.h
omadrm/drmhelper/drmhelperserver/inc/EndTimeBased.h
omadrm/drmhelper/drmhelperserver/inc/EndTimeFactory.h
omadrm/drmhelper/drmhelperserver/inc/IdleObserver.h
omadrm/drmhelper/drmhelperserver/inc/MDRMHelper.h
omadrm/drmhelper/drmhelperserver/src/ConfigObserver.cpp
omadrm/drmhelper/drmhelperserver/src/DRMHelperServer.cpp
omadrm/drmhelper/drmhelperserver/src/DRMHelperSession.cpp
omadrm/drmhelper/drmhelperserver/src/EndTimeBased.cpp
omadrm/drmhelper/drmhelperserver/src/EndTimeFactory.cpp
omadrm/drmhelper/drmhelperserver/src/IdleObserver.cpp
omadrm/drmhelper/group/Drmhelper.mmp
omadrm/drmhelper/group/Drmhelper.rss
omadrm/drmhelper/group/bld.inf
omadrm/drmhelper/group/drmhelperdmgrwrapper.mmp
omadrm/drmhelper/group/drmhelperdmgrwrapper.rss
omadrm/drmhelper/inc/ConsumeData.h
omadrm/drmhelper/inc/DRMHelperDMgrWrapper.h
omadrm/drmhelper/inc/DRMHelperDMgrWrapperLogger.h
omadrm/drmhelper/inc/DRMHelperDownloadManager.h
omadrm/drmhelper/inc/DRMHelperGlobalNoteWrapper.h
omadrm/drmhelper/inc/DRMHelperInfoNoteWrapper.h
omadrm/drmhelper/src/ConsumeData.cpp
omadrm/drmhelper/src/DRMHelperClient.cpp
omadrm/drmhelper/src/DRMHelperDMgrWrapper.cpp
omadrm/drmhelper/src/DRMHelperDll.cpp
omadrm/drmhelper/src/DRMHelperDownloadManager.cpp
omadrm/drmhelper/src/DRMHelperGlobalNoteWrapper.cpp
omadrm/drmhelper/src/DRMHelperInfoNoteWrapper.cpp
omadrm/drmhelper/src/DRMHelperStub.cpp
omadrm/drmhelper/src/RDRMHelper.cpp
omadrm/drmhelper/src/RDRMHelperStub.cpp
omadrm/drmhelper/src/drmhelper.cpp
omadrm/drmlicensemanager/BWINSCW/DRMLICENSECHECKERU.DEF
omadrm/drmlicensemanager/BWINSCW/DRMLICENSEMANAGERU.DEF
omadrm/drmlicensemanager/eabi/DRMLicenseCheckerU.DEF
omadrm/drmlicensemanager/eabi/DRMLicenseManagerU.DEF
omadrm/drmlicensemanager/group/DRMLicenseChecker.mmp
omadrm/drmlicensemanager/group/DRMLicenseManager.mmp
omadrm/drmlicensemanager/group/bld.inf
omadrm/drmlicensemanager/group/drm_lm_bat.mmp
omadrm/drmlicensemanager/src/DRMLicenseChecker.cpp
omadrm/drmlicensemanager/src/DRMLicenseManager.cpp
omadrm/drmlicensemanager/src/LMSecurity.cpp
omadrm/drmlicensemanager/src/LMSecurityDecrypt.cpp
omadrm/drmlicensemanager/src/LMSecurityEncrypt.cpp
omadrm/drmplugins/drmfilter/EABI/DRMFilterU.def
omadrm/drmplugins/drmfilter/data/101F9710.rss
omadrm/drmplugins/drmfilter/group/HTTPFilterDRM.mmp
omadrm/drmplugins/drmfilter/group/bld.inf
omadrm/drmplugins/drmfilter/inc/HTTPFilterDRM.h
omadrm/drmplugins/drmfilter/inc/HTTPFilterDRMDataSupplier.h
omadrm/drmplugins/drmfilter/src/HTTPFilterDRM.cpp
omadrm/drmplugins/drmfilter/src/HTTPFilterDRMDataSupplier.cpp
omadrm/drmplugins/drmfilter/src/HTTPFilterDRMMain.cpp
omadrm/drmplugins/drmrecognizer/group/RecDRM.mmp
omadrm/drmplugins/drmrecognizer/group/bld.inf
omadrm/drmplugins/drmrecognizer/src/101F51F4.RSS
omadrm/drmplugins/drmrecognizer/src/RecDRM.cpp
omadrm/drmplugins/drmrohandler/group/bld.inf
omadrm/drmplugins/drmrohandler/group/crohandler.mmp
omadrm/drmplugins/drmrohandler/inc/CRoHandler.h
omadrm/drmplugins/drmrohandler/inc/StringResourceReader.h
omadrm/drmplugins/drmrohandler/inc/rohandlerdmgrwrapper.h
omadrm/drmplugins/drmrohandler/inc/rohandlerinternalcrkeys.h
omadrm/drmplugins/drmrohandler/loc/RoHandler.loc
omadrm/drmplugins/drmrohandler/src/101F7B92.rss
omadrm/drmplugins/drmrohandler/src/CRoHandler.cpp
omadrm/drmplugins/drmrohandler/src/RoHandler.rss
omadrm/drmplugins/drmrohandler/src/StringResourceReader.cpp
omadrm/drmplugins/drmrohandler/src/rohandlerdmgrwrapper.cpp
omadrm/drmplugins/drmromtm/BMARM/ROMTMCLIU.DEF
omadrm/drmplugins/drmromtm/BMARM/ROMTMDATU.DEF
omadrm/drmplugins/drmromtm/BMARM/ROMTMSERU.DEF
omadrm/drmplugins/drmromtm/BMARM/ROMTMUIU.DEF
omadrm/drmplugins/drmromtm/BWINS/ROMTMCLIU.DEF
omadrm/drmplugins/drmromtm/BWINS/ROMTMDATU.DEF
omadrm/drmplugins/drmromtm/BWINS/ROMTMSERU.DEF
omadrm/drmplugins/drmromtm/BWINS/ROMTMUIU.DEF
omadrm/drmplugins/drmromtm/EABI/RoMtmCliU.DEF
omadrm/drmplugins/drmromtm/EABI/RoMtmDatU.DEF
omadrm/drmplugins/drmromtm/EABI/RoMtmSerU.DEF
omadrm/drmplugins/drmromtm/EABI/RoMtmUiU.DEF
omadrm/drmplugins/drmromtm/client/inc/RoMTMCC.h
omadrm/drmplugins/drmromtm/client/inc/RoMtmCli.h
omadrm/drmplugins/drmromtm/client/src/RoMtmCli.cpp
omadrm/drmplugins/drmromtm/group/RoMtmCli.mmp
omadrm/drmplugins/drmromtm/group/RoMtmDat.mmp
omadrm/drmplugins/drmromtm/group/RoMtmSer.mmp
omadrm/drmplugins/drmromtm/group/RoMtmUi.mmp
omadrm/drmplugins/drmromtm/group/bld.inf
omadrm/drmplugins/drmromtm/inc/RoMTMCommon.h
omadrm/drmplugins/drmromtm/loc/RoMtmUi.loc
omadrm/drmplugins/drmromtm/server/inc/RoMtmSer.h
omadrm/drmplugins/drmromtm/server/src/RoMtmSer.cpp
omadrm/drmplugins/drmromtm/ui/inc/RoMTMUiC.h
omadrm/drmplugins/drmromtm/ui/inc/RoMtmUi.h
omadrm/drmplugins/drmromtm/ui/src/RoMtmUi.cpp
omadrm/drmplugins/drmromtm/uiData/inc/RoMTMDaC.h
omadrm/drmplugins/drmromtm/uiData/inc/RoMtmCommands.hrh
omadrm/drmplugins/drmromtm/uiData/inc/RoMtmDat.h
omadrm/drmplugins/drmromtm/uiData/inc/RoMtmUi.hrh
omadrm/drmplugins/drmromtm/uiData/src/RoMtmDat.cpp
omadrm/drmplugins/drmromtm/uiData/src/RoMtmReg.rss
omadrm/drmplugins/drmromtm/uiData/src/RoMtmUi.rss
omadrm/drmplugins/drmudtmodule/bwinscw/DrmUdtModuleU.DEF
omadrm/drmplugins/drmudtmodule/eabi/DrmUdtModuleU.DEF
omadrm/drmplugins/drmudtmodule/group/DrmUdtModule.mmp
omadrm/drmplugins/drmudtmodule/inc/DrmUdtConn.h
omadrm/drmplugins/drmudtmodule/src/DrmUdtConn.cpp
omadrm/drmplugins/drmudtmodule/src/DrmUdtHandler.cpp
omadrm/drmroapwbxmlparser/bwins/drmroapwbxmlparseru.def
omadrm/drmroapwbxmlparser/eabi/drmroapwbxmlparseru.def
omadrm/drmroapwbxmlparser/group/bld.inf
omadrm/drmroapwbxmlparser/group/drmroapwbxmlparser.mmp
omadrm/drmroapwbxmlparser/src/wbxmlroaptriggerparser.cpp
omadrm/group/bld.inf
omadrm/rom/DRM5.iby
omadrm/rom/DRMHelper.iby
omadrm/rom/DRMHelperResources.iby
omadrm/rom/DRMLicenseManager.iby
omadrm/rom/DRMRoHandlerResources.iby
omadrm/rom/DRMRoMtmResources.iby
omadrm/rom/HTTPFilterDRM.iby
omadrm/rom/RoMTM.iby
omadrm/rom/drmroapwbxmlparser.iby
package_definition.xml
sysdef_1_4_0.dtd
wmdrm/camese/cameseutility/BWINS/cameseutilityU.DEF
wmdrm/camese/cameseutility/EABI/cameseutilityU.DEF
wmdrm/camese/cameseutility/group/CameseUtility.mmp
wmdrm/camese/cameseutility/group/bld.inf
wmdrm/camese/cameseutility/src/CameseUtility.cpp
wmdrm/camese/group/bld.inf
wmdrm/camese/httpfiltercamese/Data/10282936.rss
wmdrm/camese/httpfiltercamese/Inc/httpfiltercamese.hrh
wmdrm/camese/httpfiltercamese/Inc/httpfiltercamesedatasupplier.h
wmdrm/camese/httpfiltercamese/Inc/httpfiltercamesedrmheader.h
wmdrm/camese/httpfiltercamese/Src/httpfiltercamesedatasupplier.cpp
wmdrm/camese/httpfiltercamese/Src/httpfiltercamesedrmheader.cpp
wmdrm/camese/httpfiltercamese/Src/httpfiltercamesemain.cpp
wmdrm/camese/httpfiltercamese/group/bld.inf
wmdrm/camese/httpfiltercamese/group/httpfiltercamese.mmp
wmdrm/camese/inc/cameselog.h
wmdrm/camese/inc/cameselog.inl
wmdrm/camese/wmdrmdla/BWINS/wmdrmdlau.def
wmdrm/camese/wmdrmdla/EABI/wmdrmdlau.def
wmdrm/camese/wmdrmdla/group/bld.inf
wmdrm/camese/wmdrmdla/group/wmdrmdla.mmp
wmdrm/camese/wmdrmdla/inc/wmdrmdlahandler.h
wmdrm/camese/wmdrmdla/inc/wmdrmdlahandlerimpl.h
wmdrm/camese/wmdrmdla/inc/wmdrmdlahttpfwpluginresolver.h
wmdrm/camese/wmdrmdla/inc/wmdrmdlahttplicacqpluginfw.h
wmdrm/camese/wmdrmdla/inc/wmdrmdlahttpmeteringpluginfw.h
wmdrm/camese/wmdrmdla/inc/wmdrmdlaparser.h
wmdrm/camese/wmdrmdla/inc/wmdrmdlaplugincontainer.h
wmdrm/camese/wmdrmdla/inc/wmdrmdlarequest.h
wmdrm/camese/wmdrmdla/inc/wmdrmdlauinotifierimpl.h
wmdrm/camese/wmdrmdla/src/wmdrmdlahandler.cpp
wmdrm/camese/wmdrmdla/src/wmdrmdlahandlerimpl.cpp
wmdrm/camese/wmdrmdla/src/wmdrmdlahttpfwpluginresolver.cpp
wmdrm/camese/wmdrmdla/src/wmdrmdlahttplicacqpluginfw.cpp
wmdrm/camese/wmdrmdla/src/wmdrmdlahttpmeteringpluginfw.cpp
wmdrm/camese/wmdrmdla/src/wmdrmdlaparser.cpp
wmdrm/camese/wmdrmdla/src/wmdrmdlaplugincontainer.cpp
wmdrm/camese/wmdrmdla/src/wmdrmdlarequest.cpp
wmdrm/camese/wmdrmdla/src/wmdrmdlauinotifier.cpp
wmdrm/camese/wmdrmdla/src/wmdrmdlauinotifierimpl.cpp
wmdrm/camese/wmdrmdlaapp/data/wmdrmdlaapp.rss
wmdrm/camese/wmdrmdlaapp/data/wmdrmdlaapp_reg.rss
wmdrm/camese/wmdrmdlaapp/group/bld.inf
wmdrm/camese/wmdrmdlaapp/group/wmdrmdlaapp.mmp
wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaapp.h
wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaappconstants.h
wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaappdocument.h
wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaappserver.h
wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaappservicesession.h
wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaappui.h
wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlabrowsercontainer.h
wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlabrowserview.h
wmdrm/camese/wmdrmdlaapp/src/wmdrmdlaapp.cpp
wmdrm/camese/wmdrmdlaapp/src/wmdrmdlaappdocument.cpp
wmdrm/camese/wmdrmdlaapp/src/wmdrmdlaappserver.cpp
wmdrm/camese/wmdrmdlaapp/src/wmdrmdlaappservicesession.cpp
wmdrm/camese/wmdrmdlaapp/src/wmdrmdlaappui.cpp
wmdrm/camese/wmdrmdlaapp/src/wmdrmdlabrowsercontainer.cpp
wmdrm/camese/wmdrmdlaapp/src/wmdrmdlabrowserview.cpp
wmdrm/camese/wmdrmdladefaulthttpplugin/group/bld.inf
wmdrm/camese/wmdrmdladefaulthttpplugin/group/wmdrmdladefaulthttpplugin.mmp
wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaulthttpmanager.h
wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaulthttpmanagerobserver.h
wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaulthttpplugin.h
wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaultlicacq.h
wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaultmetering.h
wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaultplayready.h
wmdrm/camese/wmdrmdladefaulthttpplugin/src/20019574.rss
wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaulthttpmanager.cpp
wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaulthttpplugin.cpp
wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaulthttppluginproxy.cpp
wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaultlicacq.cpp
wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaultmetering.cpp
wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaultplayready.cpp
wmdrm/camese/wmdrmdladefaultuiplugin/group/bld.inf
wmdrm/camese/wmdrmdladefaultuiplugin/group/wmdrmdladefaultuiplugin.mmp
wmdrm/camese/wmdrmdladefaultuiplugin/inc/wmdrmdladefaultuiplugin.h
wmdrm/camese/wmdrmdladefaultuiplugin/src/20019575.rss
wmdrm/camese/wmdrmdladefaultuiplugin/src/wmdrmdladefaultuiplugin.cpp
wmdrm/camese/wmdrmdladefaultuiplugin/src/wmdrmdladefaultuipluginproxy.cpp
wmdrm/camese/wmdrmdlautils/BWINS/wmdrmdlautilsu.def
wmdrm/camese/wmdrmdlautils/EABI/wmdrmdlautilsu.def
wmdrm/camese/wmdrmdlautils/data/wmdrmdlautils.rss
wmdrm/camese/wmdrmdlautils/group/bld.inf
wmdrm/camese/wmdrmdlautils/group/wmdrmdlautils.mmp
wmdrm/camese/wmdrmdlautils/inc/wmdrmdlaappclient.h
wmdrm/camese/wmdrmdlautils/inc/wmdrmdlabrowserobserver.h
wmdrm/camese/wmdrmdlautils/inc/wmdrmdlabrowserviewhandler.h
wmdrm/camese/wmdrmdlautils/inc/wmdrmdlaui.h
wmdrm/camese/wmdrmdlautils/src/wmdrmdlaappclient.cpp
wmdrm/camese/wmdrmdlautils/src/wmdrmdlabrowserviewhandler.cpp
wmdrm/camese/wmdrmdlautils/src/wmdrmdlaui.cpp
wmdrm/camese/wmdrmdlawrapper/BWINS/wmdrmdlawrapperu.def
wmdrm/camese/wmdrmdlawrapper/EABI/wmdrmdlawrapperu.def
wmdrm/camese/wmdrmdlawrapper/group/bld.inf
wmdrm/camese/wmdrmdlawrapper/group/wmdrmdlawrapper.mmp
wmdrm/camese/wmdrmdlawrapper/src/wmdrmdlawrapper.cpp
wmdrm/cenrep/keys_wmdrm.xls
wmdrm/conf/wmdrm.confml
wmdrm/conf/wmdrm_20011118.crml
wmdrm/conf/wmdrm_2001FE55.crml
wmdrm/group/bld.inf
wmdrm/inc/WMDRMPrivateCRKeys.h
wmdrm/inc/logfn.h
wmdrm/inc/wmdrmkeystorage.h
wmdrm/rom/WMDRM.iby
wmdrm/rom/WMDRMResources.iby
wmdrm/rom/wmdrm_stub.sis
wmdrm/wmdrmengine/asf/BWINS/drmasfU.DEF
wmdrm/wmdrmengine/asf/EABI/drmasfU.DEF
wmdrm/wmdrmengine/asf/group/drmasf.mmp
wmdrm/wmdrmengine/asf/inc/asf.h
wmdrm/wmdrmengine/asf/src/asf.cpp
wmdrm/wmdrmengine/wmdrmaccess/bwins/wmdrmaccessu.def
wmdrm/wmdrmengine/wmdrmaccess/eabi/wmdrmaccessu.def
wmdrm/wmdrmengine/wmdrmaccess/group/bld.inf
wmdrm/wmdrmengine/wmdrmaccess/group/wmdrmaccess.mmp
wmdrm/wmdrmengine/wmdrmaccess/rom/wmdrmaccess.iby
wmdrm/wmdrmengine/wmdrmaccess/src/wmdrmaccess.cpp
wmdrm/wmdrmengine/wmdrmagent/group/bld.inf
wmdrm/wmdrmengine/wmdrmagent/group/wmdrmagent.mmp
wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentattributes.h
wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentcontent.h
wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentdata.h
wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentfactory.h
wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentimportfile.h
wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentmanager.h
wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentrightsmanager.h
wmdrm/wmdrmengine/wmdrmagent/src/10205CB6.rss
wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagent.cpp
wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentattributes.cpp
wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentcontent.cpp
wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentdata.cpp
wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentfactory.cpp
wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentimportfile.cpp
wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentmanager.cpp
wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentrightsmanager.cpp
wmdrm/wmdrmengine/wmdrmfileserver/client/BWINS/wmdrmfileserverclientU.DEF
wmdrm/wmdrmengine/wmdrmfileserver/client/EABI/wmdrmfileserverclientU.DEF
wmdrm/wmdrmengine/wmdrmfileserver/client/group/bld.inf
wmdrm/wmdrmengine/wmdrmfileserver/client/group/wmdrmfileserverclient.mmp
wmdrm/wmdrmengine/wmdrmfileserver/client/src/wmdrmfileserverclient.cpp
wmdrm/wmdrmengine/wmdrmfileserver/server/group/bld.inf
wmdrm/wmdrmengine/wmdrmfileserver/server/group/wmdrmfileserver.mmp
wmdrm/wmdrmengine/wmdrmfileserver/server/inc/wmdrmfileserver.h
wmdrm/wmdrmengine/wmdrmfileserver/server/inc/wmdrmfileserversession.h
wmdrm/wmdrmengine/wmdrmfileserver/server/inc/wmdrmfsclientserver.h
wmdrm/wmdrmengine/wmdrmfileserver/server/src/wmdrmfileserver.cpp
wmdrm/wmdrmengine/wmdrmfileserver/server/src/wmdrmfileserversession.cpp
wmdrm/wmdrmengine/wmdrmpd_dist/group/wmdrmpd_dist.mak
wmdrm/wmdrmengine/wmdrmpkserver/serverresources/data/wmdrmpkserver.rss
wmdrm/wmdrmengine/wmdrmpkserver/serverresources/group/wmdrmpkserverresources.mmp
wmdrm/wmdrmengine/wmdrmpkserver/serverresources/inc/wmdrmpkserverresources.h
wmdrm/wmdrmengine/wmdrmpkserver/serverresources/src/wmdrmpkserverresources.cpp
wmdrm/wmdrmengine/wmdrmserver/client/BWINS/wmdrmclientU.DEF
wmdrm/wmdrmengine/wmdrmserver/client/EABI/wmdrmclientU.DEF
wmdrm/wmdrmengine/wmdrmserver/client/group/bld.inf
wmdrm/wmdrmengine/wmdrmserver/client/group/wmdrmclient.mmp
wmdrm/wmdrmengine/wmdrmserver/client/src/wmdrmclient.cpp
wmdrm/wmdrmengine/wmdrmserver/clientwrapper/BWINS/wmdrmclientwrapperu.def
wmdrm/wmdrmengine/wmdrmserver/clientwrapper/EABI/wmdrmclientwrapperu.def
wmdrm/wmdrmengine/wmdrmserver/clientwrapper/group/bld.inf
wmdrm/wmdrmengine/wmdrmserver/clientwrapper/group/wmdrmclientwrapper.mmp
wmdrm/wmdrmengine/wmdrmserver/clientwrapper/src/wmdrmclientwrapper.cpp
wmdrm/wmdrmengine/wmdrmserver/server/data/10282F1B.exc
wmdrm/wmdrmengine/wmdrmserver/server/group/bld.inf
wmdrm/wmdrmengine/wmdrmserver/server/group/wmdrmserver.mmp
wmdrm/wmdrmengine/wmdrmserver/server/inc/clock.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/enumerator.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/enumeratordata.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/namespaceenumerator.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/slot.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/slotdata.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/slotdatacache.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/slotenumerator.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/slotenumeratorcache.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/wmdrmclientserver.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/wmdrmdatastore.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/wmdrmdb.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/wmdrmserver.h
wmdrm/wmdrmengine/wmdrmserver/server/inc/wmdrmsession.h
wmdrm/wmdrmengine/wmdrmserver/server/src/clock.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/enumerator.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/enumeratordata.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/namespaceenumerator.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/slot.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/slotdata.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/slotdatacache.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/slotenumerator.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/slotenumeratorcache.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/wmdrmdatastore.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/wmdrmdb.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/wmdrmserver.cpp
wmdrm/wmdrmengine/wmdrmserver/server/src/wmdrmsession.cpp
Binary file commondrm/data/DRMRightsManager_stub.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/data/DRMRightsManager_stub.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,21 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+&EN
+
+#{"DRMRightsManager Base"},(0x101F85C7),1,0,0,TYPE=SA
+%{"Nokia"}
+:"Nokia"
Binary file commondrm/data/commondrm_stub.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/data/commondrm_stub.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,21 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+&EN
+
+#{"commondrm base"},(0x2000B5E5),1,0,0,TYPE=SA
+%{"Nokia"}
+:"Nokia"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/data/DRMEncryptor.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,466 @@
+/*
+* Copyright (c) 2004 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME    DRME // 4 letter ID
+
+//  INCLUDES
+
+#include "DRMEncryptor.rh"
+#include "DRMEncryptor.hrh"
+#include <drmencryptor.mbg>
+#include <data_caging_paths_strings.hrh>
+
+#include <eikon.rh>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.mbg>
+
+#include <appinfo.rh>
+
+RESOURCE RSS_SIGNATURE {}
+
+RESOURCE TBUF { buf= ""; }
+
+RESOURCE EIK_APP_INFO
+    {
+    cba = R_AVKON_SOFTKEYS_EXIT;
+    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
+    menubar = r_DrmEncryptor_menubar;
+     // no menu bar
+    }
+
+// ---------------------------------------------------------
+//
+//   r_helloworldbasic_menubar
+//   Menubar for HelloWorldBasic example
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_BAR r_DrmEncryptor_menubar
+    {
+    titles =
+        {
+        MENU_TITLE
+            {
+            menu_pane = r_DrmEncryptor_menu;
+            }
+        };
+    }
+
+
+// ---------------------------------------------------------
+//
+//   r_helloworldbasic_menu
+//   Menu for "Options"
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_PANE r_DrmEncryptor_menu
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = EDrmEncryptorUICommand1;
+            txt = "Encrypt";
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EDrmEncryptorKeyCommand;
+            txt = "Import Keys";
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EDrmEncryptorDeleteCommand;
+            txt = "Delete Database";
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EDrmTimeCommand;
+            txt = "DRMClock time";
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = ESetDrmTimeCommand;
+            txt = "Set DRMClock";
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EAddROsIntoDb;
+            txt = "Process multiple ROs";
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EDrmBb5KeyTestCommand;
+            txt = "Bb5KeyTest";
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EDRMPlayServerCommand;
+            txt = "DrmPlayServerTest";
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EDRM_API_BATUICommand3;
+            txt = "Run Performance test";
+            cascade=r_DRM_API_sub_menu_1;
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EDrmEncryptorDeleteWmDrmCommand;
+            txt = "Delete WmDrm Rights";
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EDrmEncryptorBackupWmDrmCommand;
+            txt = "Backup WmDrm DB";
+            flags = EEikMenuItemAction;
+            },
+        MENU_ITEM
+            {
+            command = EDrmEncryptorRestoreWmDrmCommand;
+            txt = "Restore WmDrm DB";
+            flags = EEikMenuItemAction;
+            },                     
+        MENU_ITEM
+            {
+            command = EAknSoftkeyExit;
+            txt = "Exit";
+            }
+        };
+    }
+
+
+RESOURCE TITLE_PANE r_DRMEncryptor_title_pane
+    {
+    txt = "DRMEncryptor";
+    }
+
+// Texts and images appear in this order on the DRMEncryptor screen.
+// Every new text item starts from a new line.
+
+RESOURCE DRMEncryptor_ITEM_LIST r_DRMEncryptor_main_text
+    {
+    items =
+        {
+        DRMEncryptor_TEXT
+            {
+            txt = r_DRMEncryptor_copyright_text_1;
+            },
+        DRMEncryptor_TEXT
+            {
+            txt = r_DRMEncryptor_copyright_text_2;
+            },
+        DRMEncryptor_TEXT
+            {
+            txt = r_DRMEncryptor_copyright_text_3;
+            },
+        DRMEncryptor_TEXT
+            {
+            txt = r_DRMEncryptor_copyright_text_4;
+            },
+        DRMEncryptor_TEXT
+            {
+            txt = r_DRMEncryptor_copyright_text_5;
+            },
+        DRMEncryptor_TEXT
+            {
+            txt = r_DRMEncryptor_copyright_text_6;
+            },
+        DRMEncryptor_TEXT
+            {
+            txt = r_DRMEncryptor_copyright_text_7;
+            },
+        DRMEncryptor_TEXT
+            {
+            txt = r_DRMEncryptor_copyright_text_8;
+            },
+        DRMEncryptor_TEXT
+            {
+            txt = r_DRMEncryptor_copyright_text_9;
+            },
+        DRMEncryptor_TEXT
+            {
+            txt = r_DRMEncryptor_copyright_text_10;
+            },        
+        DRMEncryptor_TEXT
+            {
+            txt = r_DRMEncryptor_copyright_text_11;
+            }            
+        };
+    }
+
+RESOURCE DIALOG r_drm_time_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtMultilineQuery;
+            id = EMultilineFirstLine;
+            control = AVKON_DATA_QUERY
+                {
+                layout = EMultiDataFirstDateEd;
+                label = "Date";
+                control = DATE_EDITOR
+                    {
+                    minDate = DATE
+                        {
+                        year = 1900;
+                        };
+                    maxDate = DATE
+                        {
+                        year = 2100;
+                        };
+                    flags = 0;
+                    };
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMultilineQuery;
+            id = EMultilineSecondLine;
+            control = AVKON_DATA_QUERY
+                {
+                layout = EMultiDataSecondTimeEd;
+                label = "Time";
+                control = TIME_EDITOR
+                    {
+                    minTime = TIME
+                        {
+                        second = 0;
+                        minute = 0;
+                        hour = 0;
+                        };
+                    maxTime = TIME
+                        {
+                        second = 59;
+                        minute = 59;
+                        hour = 23;
+                        };
+                    flags = 0;
+                    };
+                };
+            }
+        };
+    }
+
+/////////////////////////////////
+// PERFORMANCE
+///////////////////////////////
+
+// ---------------------------------------------------------
+//
+//   r_DRM_API_sub_menu_1
+//   SubMenu for "Options->Performance"
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_PANE r_DRM_API_sub_menu_1
+    {
+    items=
+        {
+		MENU_ITEM
+            {
+            command=EDRM_API_SubMenuId_1;
+            txt="Generate test files";
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            txt="RFile plain";
+            cascade=r_DRM_API_sub_menu_1_1;
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            txt="CAF plain";
+            cascade=r_DRM_API_sub_menu_1_2;
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            txt="DRM";
+            cascade=r_DRM_API_sub_menu_1_3;
+            flags = EEikMenuItemSpecific;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//
+//   r_DRM_API_sub_menu_1
+//   SubMenu for "Options->Performance->RFile"
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_PANE r_DRM_API_sub_menu_1_1
+    {
+    items=
+        {
+		MENU_ITEM
+            {
+            command=EDRM_API_SubMenuId_1_1;
+            txt="File opening";
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            command=EDRM_API_SubMenuId_1_2;
+            txt="Sequential";
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            command=EDRM_API_SubMenuId_1_3;
+            txt="Random";
+            flags = EEikMenuItemSpecific;
+            }
+        };
+    }
+// ---------------------------------------------------------
+//
+//   r_DRM_API_sub_menu_1
+//   SubMenu for "Options->Performance->CAF"
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_PANE r_DRM_API_sub_menu_1_2
+    {
+    items=
+        {
+		MENU_ITEM
+            {
+            command=EDRM_API_SubMenuId_2_1;
+            txt="File opening";
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            command=EDRM_API_SubMenuId_2_2;
+            txt="Sequential";
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            command=EDRM_API_SubMenuId_2_3;
+            txt="Random";
+            flags = EEikMenuItemSpecific;
+            }
+        };
+    }
+
+// ---------------------------------------------------------
+//
+//   r_DRM_API_sub_menu_1
+//   SubMenu for "Options->Performance->DRM"
+//
+// ---------------------------------------------------------
+//
+RESOURCE MENU_PANE r_DRM_API_sub_menu_1_3
+    {
+    items=
+        {
+        MENU_ITEM
+            {
+            command=EDRM_API_SubMenuId_3_1_1;
+            txt="File Opening";
+            flags = EEikMenuItemSpecific;
+            },
+		MENU_ITEM
+            {
+            command=EDRM_API_SubMenuId_3_1_2;
+            txt="File Opening with ExecuteIntent";
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            command=EDRM_API_SubMenuId_3_1_3;
+            txt="Sequential";
+            flags = EEikMenuItemSpecific;
+            },
+        MENU_ITEM
+            {
+            command=EDRM_API_SubMenuId_3_1_4;
+            txt="Random";
+            flags = EEikMenuItemSpecific;
+            }
+        };
+    }
+
+RESOURCE DIALOG r_aknicon_icon_size_query
+	{
+	flags = EGeneralQueryFlags;
+	buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
+    items =
+		{
+		DLG_LINE
+			{
+			type = EAknCtQuery;
+			id = EGeneralQuery;
+			control = AVKON_DATA_QUERY
+				{
+				layout = ENumberLayout;
+				label = "Add multiplier";
+				control = AVKON_INTEGER_EDWIN
+				    {
+					min = 0;
+					max = 1000;
+					};
+				};
+			}
+		};
+	}
+
+RESOURCE TBUF r_DRMEncryptor_copyright_text_1  { buf = "DRMEncryptor - tool to process OMA DRM 1.0 content into terminal."; }
+RESOURCE TBUF r_DRMEncryptor_copyright_text_2  { buf = "Encryptor tool will process DRM messages (.dm) from e:\DRM - directory. If the directory does not exist, it will be created during the first execution. Output files will be placed into e:\Others -directory. On the emulator, the c: drive is used instead of the e: drive"; }
+RESOURCE TBUF r_DRMEncryptor_copyright_text_3  { buf = "Encryptor tool process separate delivery rights objects (.oro && .ro && .drc && dr). Place the files under e:\DRM directory and press Encrypt."; }
+RESOURCE TBUF r_DRMEncryptor_copyright_text_4  { buf = "With tool the PKI -keys can be imported into hardware. PKI -key files should be placed under e:\DRM\keys."; }
+RESOURCE TBUF r_DRMEncryptor_copyright_text_5  { buf = "The tool also allows removal of all rights in the rights database."; }
+RESOURCE TBUF r_DRMEncryptor_copyright_text_6  { buf = "DRMClock can be viewed via menu. DRM Time is shown as nitz time."; }
+RESOURCE TBUF r_DRMEncryptor_copyright_text_7  { buf = "DRMClock can be set via menu. Use Options -> Set DRM clock."; }
+RESOURCE TBUF r_DRMEncryptor_copyright_text_8  { buf = "DRMEncryptor can be used for processing same RO for multiple times. Place ROs into e:\drm -folder and choose Options->Process multiple ROs->add multiplier which will be used for every processed RO."; }
+RESOURCE TBUF r_DRMEncryptor_copyright_text_9  { buf = "DRMEncryptor can be used for checking that DrmPlayServer's usage is prohibited for WMDRM files. Place any WMDRM file named as test.wma into e:\drm and choose Options->DrmPlayServerTest"; }
+RESOURCE TBUF r_DRMEncryptor_copyright_text_10 { buf = "DRMEncryptor can be used for making backup and restoring WMDRM SQlite License Store. Backup will make a copy of [10282F1B]hds.db to e:\[10282F1B]hds.db. Restore will copy e:\[10282F1B]hds.db back to c:\private\10281e17\[10282F1B]hds.db"; }
+RESOURCE TBUF r_DRMEncryptor_copyright_text_11 { buf = "This tool is purposed only for R&D and should not be used commercially. Copyright © 2004 Nokia. All rights reserved."; }
+
+
+RESOURCE LOCALISABLE_APP_INFO r_DRMEncryptor_localisable_app_info
+    {
+    short_caption = "DRMEncryptor";
+    caption_and_icon =
+    CAPTION_AND_ICON_INFO
+        {
+        caption = "DRMEncryptor";
+        };
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/data/DRMEncryptor_caption.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <apcaptionfile.rh>
+
+RESOURCE CAPTION_DATA
+    {
+    caption = "DRMEncryptor";
+    shortcaption = "DRM";
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/data/DRMEncryptor_reg.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <appinfo.rh>
+#include <DRMEncryptor.rsg>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x01105901 // 0x10005A22 // Define your application UID here
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "DRMEncryptor";
+  
+
+    localisable_resource_file = APP_RESOURCE_DIR"\\DRMEncryptor";
+
+    localisable_resource_id = R_DRMENCRYPTOR_LOCALISABLE_APP_INFO;
+    datatype_list =
+        {
+        DATATYPE
+            {
+            priority = EDataTypePriorityNormal;
+            type = "application/x-device-key-chain";
+            }
+        };
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/group/DRMEncryptor.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,107 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Internal drm test tool
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET         DRMEncryptor.exe
+TARGETTYPE     exe
+
+UID            0x100039CE  0x01105901
+
+CAPABILITY CAP_APPLICATION ReadUserData AllFiles DRM PowerMgmt CommDD
+VENDORID VID_DEFAULT
+
+SOURCEPATH     ../src
+SOURCE         DrmKeyStorage.cpp
+SOURCE         DrmBb5KeyStorage.cpp
+SOURCE         DRMEncryptorApp.cpp
+SOURCE         DRMEncryptorAppUi.cpp
+SOURCE         DRMEncryptorDocument.cpp
+SOURCE         DRMEncryptorContainer.cpp
+SOURCE         DRMEncryptorImage.cpp
+SOURCE         DrmEncryptor.cpp
+SOURCE         DRMPlayServerTest.cpp
+SOURCE         Performance.cpp
+
+
+START RESOURCE ../data/DRMEncryptor.rss
+
+HEADER
+TARGETPATH APP_RESOURCE_DIR
+
+END //RESOURCE
+
+START RESOURCE ../data/DRMEncryptor_reg.rss
+DEPENDS drmencryptor.rsg
+    TARGETPATH /private/10003a3f/apps
+END
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE    ../inc
+USERINCLUDE    ../../../inc
+
+LIBRARY        DrmParsers.lib
+LIBRARY        DrmDcf.lib
+LIBRARY        DrmRights.lib
+LIBRARY        DrmServerInterfaces.lib
+LIBRARY        DRMCommon.lib
+LIBRARY        apparc.lib
+LIBRARY        avkon.lib
+LIBRARY        bafl.lib
+LIBRARY        cone.lib
+LIBRARY        eikcoctl.lib
+LIBRARY        eikcore.lib
+LIBRARY        euser.lib
+LIBRARY        fbscli.lib
+LIBRARY        efsrv.lib
+LIBRARY        estor.lib
+LIBRARY        asn1.lib
+LIBRARY        cryptography.lib
+LIBRARY        crypto.lib
+LIBRARY        x509.lib
+LIBRARY        pkixcert.lib
+LIBRARY        random.lib
+LIBRARY        hash.lib
+LIBRARY        flogger.lib
+LIBRARY        ezip.lib
+
+// DRMKeyStorage
+LIBRARY        DrmKeyStorage.lib
+LIBRARY        DrmCrypto.lib
+
+LIBRARY        gdi.lib
+
+
+LIBRARY        caf.lib
+LIBRARY        cafutils.lib
+LIBRARY        drmhelper.lib
+LIBRARY        XmlFramework.lib
+LIBRARY        apmime.lib
+LIBRARY        DcfRep.lib
+LIBRARY        ecom.lib
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY        platformenv.lib
+#endif
+
+LIBRARY        drmaudioplayutility.lib
+
+SMPSAFE
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/group/DRMEncryptor.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,39 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Languages
+; =========
+&EN
+
+; Name, UID for installation, Maj.Ver., Min.Ver., Variant, FLAG TO SPECIFY UNICODE, System component
+; ==================================================================================================
+#{"DRMEncryptor"}, (0x01105901),1,0,0,TYPE=SA
+
+;Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+"\epoc32\release\armv5\urel\DRMEncryptor.exe"-"!:\sys\bin\DRMEncryptor.exe"
+"\epoc32\data\Z\private\10003a3f\apps\DRMEncryptor_reg.RSC"-"!:\private\10003a3f\import\apps\DRMEncryptor_reg.rsc"
+
+
+"\epoc32\data\Z\Resource\apps\DRMEncryptor.mbm"-"!:\resource\apps\DRMEncryptor.mbm"
+"\epoc32\data\Z\Resource\apps\DRMEncryptor.mif"-"!:\resource\apps\DRMEncryptor.mif"
+"\epoc32\data\Z\Resource\apps\DRMEncryptor.RSC"-"!:\resource\apps\DRMEncryptor.RSC"
+"\epoc32\data\Z\Resource\apps\DRMEncryptor_AIF.mif"-"!:\resource\apps\DRMEncryptor_AIF.mif"
+
+; eof
Binary file commondrm/drmencryptor/group/icon.bmp has changed
Binary file commondrm/drmencryptor/group/icon_mask_soft.bmp has changed
Binary file commondrm/drmencryptor/group/qgn_menu_DRMEncryptor.bmp has changed
Binary file commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_cxt.bmp has changed
Binary file commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_cxt_mask_soft.bmp has changed
Binary file commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_mask_soft.bmp has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/inc/DRMEncryptor.hrh	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef DRMEncryptor_HRH
+#define DRMEncryptor_HRH
+
+enum TDRMEncryptorItemType
+    {
+    EDRMEncryptorTextItem,
+    EDRMEncryptorImageItem
+    };
+
+// DrmEncryptor enumerate command codes
+enum TDrmEncryptorIds
+    {
+    EDrmEncryptorUICommand1 = 1,  // start value must not be 0
+    EDrmEncryptorKeyCommand,
+    EDrmEncryptorDeleteCommand,
+    ESetDrmTimeCommand,
+    EAddROsIntoDb,
+    EDrmTimeCommand,
+    EDrmBb5KeyTestCommand,
+    EDRMPlayServerCommand,
+    EDRM_API_BATUICommand3,
+    EDRM_API_SubMenuId_1,
+    EDRM_API_SubMenuId_1_1,
+    EDRM_API_SubMenuId_1_2,
+    EDRM_API_SubMenuId_1_3,
+    EDRM_API_SubMenuId_2_1,
+    EDRM_API_SubMenuId_2_2,
+    EDRM_API_SubMenuId_2_3,
+    EDRM_API_SubMenuId_3_1_1,
+    EDRM_API_SubMenuId_3_1_2,
+    EDRM_API_SubMenuId_3_1_3,
+    EDRM_API_SubMenuId_3_1_4,
+    EDrmEncryptorDeleteWmDrmCommand,
+    EDrmEncryptorBackupWmDrmCommand,
+    EDrmEncryptorRestoreWmDrmCommand
+    };
+
+#endif // DRMEncryptor_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/inc/DRMEncryptor.rh	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef DRMEncryptor_RH
+#define DRMEncryptor_RH
+
+#include "DRMEncryptor.hrh"
+
+STRUCT DRMEncryptor_TEXT
+    {
+    BYTE type = EDRMEncryptorTextItem;
+    LLINK txt; // set this
+    }
+
+STRUCT DRMEncryptor_IMAGE
+    {
+    BYTE type = EDRMEncryptorImageItem;
+    LTEXT16 bmpfile = ""; // set this
+    WORD bmpid = 0xffff;  // set this
+    }
+
+STRUCT DRMEncryptor_ITEM_LIST
+    {
+    STRUCT items[]; // text or image items
+    }
+
+#endif // DRMEncryptor_RH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/inc/DRMEncryptorApp.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares main application class
+*
+*/
+
+
+#ifndef DRMEncryptorAPP_H
+#define DRMEncryptorAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+// CONSTANTS
+// UID of the application
+const TUid KUidDRMEncryptor = { 0x01105901 };
+
+// CLASS DECLARATION
+
+/**
+* CDRMEncryptorApp application class.
+* Provides factory to create concrete document object.
+*
+*/
+class CDRMEncryptorApp : public CAknApplication
+    {
+
+    public: // Functions from base classes
+    private:
+
+        /**
+        * From CApaApplication, creates CDRMEncryptorDocument document object.
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+
+        /**
+        * From CApaApplication, returns application's UID (KUidDRMEncryptor).
+        * @return The value of KUidDRMEncryptor.
+        */
+        TUid AppDllUid() const;
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/inc/DRMEncryptorAppUi.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares UI class for application.
+*
+*/
+
+
+#ifndef DRMEncryptorAPPUI_H
+#define DRMEncryptorAPPUI_H
+
+// INCLUDES
+#include <eikapp.h>
+#include <eikdoc.h>
+#include <e32std.h>
+#include <coeccntx.h>
+#include <aknappui.h>
+
+// FORWARD DECLARATIONS
+class CDRMEncryptorContainer;
+
+// CONSTANTS
+
+// CLASS DECLARATION
+
+/**
+* Application UI class.
+* Provides support for the following features:
+* - EIKON control architecture
+*
+*/
+class CDRMEncryptorAppUi : public CAknAppUi
+    {
+    public: // Constructors and destructor
+
+        /**
+        * EPOC default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CDRMEncryptorAppUi();
+
+    public: // New functions
+
+    public: // Functions from base classes
+
+        TBool ProcessCommandParametersL(
+            TApaCommand aCommand,
+            TFileName& aDocumentName,
+            const TDesC8& aTail);
+
+
+    private:
+        /**
+        * From CEikAppUi, takes care of command handling.
+        * @param aCommand command to be handled
+        */
+        void HandleCommandL( TInt aCommand );
+
+    private: // Data
+        CDRMEncryptorContainer* iAppContainer;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/inc/DRMEncryptorContainer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares container control for application.
+*
+*/
+
+
+#ifndef DRMEncryptorCONTAINER_H
+#define DRMEncryptorCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <gdi.h>
+
+// FORWARD DECLARATIONS
+class CEikScrollBarFrame;
+class CDRMEncryptorImage;
+class CFont;
+class TRect;
+class TBidiText;
+
+// CLASS DECLARATION
+
+/**
+*  CDRMEncryptorContainer  container control class.
+*
+*/
+class CDRMEncryptorContainer : public CCoeControl
+    {
+    public: // Constructors and destructor
+        CDRMEncryptorContainer();
+        void ConstructL( const TRect& aRect );
+        ~CDRMEncryptorContainer();
+
+    private: // from CCoeControl
+
+        void Draw( const TRect& aRect ) const;
+        void ActivateL();
+        TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
+                                     TEventCode aModifiers );
+
+    private: // new functions
+
+        void SetTextL( const TDesC& aText );
+        void SetImageL( const TDesC& aFileName, TInt aBitmapId );
+        void UpdateScrollIndicatorL();
+
+    private: // Data
+
+        CArrayPtr<HBufC>* iText;
+        CArrayPtr<CDRMEncryptorImage>* iImages;
+        CArrayFixFlat<TInt>* iScreenStarts;
+        TInt iCurrentScreen;
+        TBool iDoNotShowLastLineAgain;
+        CGraphicsContext::TTextAlign iTextAlign;
+        CEikScrollBarFrame* iSBFrame;
+        const CFont* iFont; // not owned
+        TInt iLineWidth;
+        TInt iBaseLineDelta;
+        TInt iTopBaseLineX;
+        TInt iTopBaseLineY;
+        TInt iLinesPerScreen;
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/inc/DRMEncryptorDocument.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef DRMEncryptorDOCUMENT_H
+#define DRMEncryptorDOCUMENT_H
+
+// INCLUDES
+#include <akndoc.h>
+   
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class  CEikAppUi;
+
+// CLASS DECLARATION
+
+/**
+*  CDRMEncryptorDocument application class.
+*/
+class CDRMEncryptorDocument : public CAknDocument
+    {
+    public: // Constructors and destructor
+        /**
+        * Two-phased constructor.
+        */
+        static CDRMEncryptorDocument* NewL( CEikApplication& aApp );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CDRMEncryptorDocument();
+
+        virtual CFileStore* OpenFileL(TBool aDoOpen,const TDesC& aFilename,RFs& aFs);
+
+    private:
+
+        /**
+        * Constructor.
+        */
+        CDRMEncryptorDocument( CEikApplication& aApp );
+
+        /**
+        * From CEikDocument, create CDRMEncryptorAppUi "App UI" object.
+        */
+        CEikAppUi* CreateAppUiL();
+    };
+
+#endif
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/inc/DRMEncryptorImage.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image to be shown in DRMEncryptor screen.
+*
+*/
+
+
+#ifndef DRMEncryptorIMAGE_H
+#define DRMEncryptorIMAGE_H
+
+// INCLUDES
+
+// FORWARD DECLARATIONS
+class CFbsBitmap;
+
+// CONSTANTS
+
+const TInt KImageTopMargin = 4 ;
+const TInt KImageBottomMargin = 4;
+
+// CLASS DECLARATION
+
+/**
+* CDRMEncryptorImage
+*/
+class CDRMEncryptorImage : public CBase
+    {
+    public: // Constructors and destructor
+
+        static CDRMEncryptorImage* NewLC( const TDesC& aFileName, TInt aBitmapId,
+                                   TInt aStartLine, TInt aBaseLineDelta );
+
+        /**
+        * Destructor
+        */
+        ~CDRMEncryptorImage();
+
+    public: // New functions
+
+        TInt HeightInPixels() const;
+        TInt WidthInPixels() const;
+        TInt StartLine() const;
+        TInt EndLine() const;
+        TInt Lines() const;
+        const CFbsBitmap* Bitmap() const;
+
+    private: // private constructor
+
+        /**
+        * C++ default constructor.
+        */
+        CDRMEncryptorImage();
+
+    private:  // Data
+
+        CFbsBitmap* iBitmap; // owned
+        TInt iStartLine;
+        TInt iEndLine;
+    };
+
+#endif // DRMEncryptorIMAGE_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/inc/DRMPlayServerTest.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,57 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef DRMPLAYSERVERTEST_H
+#define DRMPLAYSERVERTEST_H
+
+#include <e32base.h>
+#include <DrmAudioSamplePlayer.h>
+
+class CDRMPlayServerTest : public CBase, public MDrmAudioPlayerCallback
+    {
+    
+    public:
+        
+        static CDRMPlayServerTest* NewLC();
+
+        ~CDRMPlayServerTest();
+
+        TInt ExecutePlayServerTest();
+
+        void MdapcInitComplete( TInt aError, 
+                                const TTimeIntervalMicroSeconds& aDuration );
+
+        void MdapcPlayComplete( TInt aError );
+
+   private:
+        
+        CDRMPlayServerTest();
+        
+        void ConstructL();
+   
+   private:  // Data
+    
+        CDrmPlayerUtility* iDrmPlayerUtility;
+        CActiveSchedulerWait* iWait;
+        TInt iError;
+
+    };
+
+#endif // DRMPLAYSERVERTEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/inc/Performance.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef PERFORMANCE_H
+#define PERFORMANCE_H
+
+void TestPerformanceL(TInt aCommand);
+
+#endif      // PERFORMANCE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/src/DRMEncryptorApp.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include "DRMEncryptorApp.h"
+#include "DRMEncryptorDocument.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CDRMEncryptorApp::AppDllUid()
+// Returns application UID
+// ---------------------------------------------------------
+//
+TUid CDRMEncryptorApp::AppDllUid() const
+    {
+    return KUidDRMEncryptor;
+    }
+
+   
+// ---------------------------------------------------------
+// CDRMEncryptorApp::CreateDocumentL()
+// Creates CDRMEncryptorDocument object
+// ---------------------------------------------------------
+//
+CApaDocument* CDRMEncryptorApp::CreateDocumentL()
+    {
+    return CDRMEncryptorDocument::NewL( *this );
+    }
+
+#include <eikstart.h>
+
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CDRMEncryptorApp;
+    }
+
+// ---------------------------------------------------------
+// E32Main()
+//  Main startup entry point
+// Returns: KErrNone
+// ---------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication(NewApplication);
+    }
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/src/DRMEncryptorAppUi.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,257 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include "DRMEncryptorAppUi.h"
+#include "DRMEncryptorContainer.h" 
+#include "DRMEncryptor.hrh"
+#include "Performance.h"
+#include "DRMPlayServerTest.h"
+
+#include <avkon.hrh>
+#include <aknnotewrappers.h> 
+
+extern TUint EncryptL(TUint& aEncryptedCount, TUint& aRightsCount, TUint& aMessagesProcessed);
+extern TUint KeyStorage();
+extern void DeleteRdbL();
+extern void GetDrmClockL();
+extern void SetDrmClockL();
+extern TUint Bb5KeyStorage();
+extern void DeleteWmDrmRdbL();
+extern void BackupWmDrmDbL();
+extern void RestoreWmDrmDbL();
+
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// ----------------------------------------------------------
+// CDRMEncryptorAppUi::ConstructL()
+// ?implementation_description
+// ----------------------------------------------------------
+//
+void CDRMEncryptorAppUi::ConstructL()
+    {
+    BaseConstructL();
+    iAppContainer = new( ELeave ) CDRMEncryptorContainer;
+    iAppContainer->SetMopParent( this );
+    iAppContainer->ConstructL( ClientRect() );
+    AddToStackL( iAppContainer );
+    }
+
+// ----------------------------------------------------
+// CDRMEncryptorAppUi::~CDRMEncryptorAppUi()
+// Destructor
+// Frees reserved resources
+// ----------------------------------------------------
+//
+CDRMEncryptorAppUi::~CDRMEncryptorAppUi()
+    {
+    if ( iAppContainer )
+        {
+        RemoveFromStack( iAppContainer );
+        delete iAppContainer;
+        }
+   }
+
+// ----------------------------------------------------
+// CDRMEncryptorAppUi::HandleCommandL( TInt aCommand )
+// ?implementation_description
+// ----------------------------------------------------
+//
+void CDRMEncryptorAppUi::HandleCommandL( TInt aCommand )
+    {
+    TUint result = 0;
+    TUint aEncryptedCount = 0;
+    TUint aRightsCount = 0;
+    TUint aMessagesProcessed = 0;
+    TBuf<128> buffer;
+            
+    switch ( aCommand )
+        {
+        case EAknSoftkeyExit:
+        case EAknSoftkeyBack:
+        case EEikCmdExit:
+            {
+            Exit();
+            break;
+            }
+        case EDrmEncryptorUICommand1:
+            {
+
+            result = EncryptL(aEncryptedCount, aRightsCount, aMessagesProcessed);
+
+            buffer.Append(_L("Encryption done\n"));
+            if(result < 1) 
+            {
+                buffer.Append(_L("No files found"));
+            }
+            if(aMessagesProcessed != 0) 
+            {
+                buffer.AppendNum(aMessagesProcessed);
+                buffer.Append(_L(" messages processed\n"));
+            }
+            if(aRightsCount != 0) 
+            {
+                buffer.AppendNum(aRightsCount);
+                buffer.Append(_L(" rights objects processed\n"));
+            }
+            if(aMessagesProcessed != 0) 
+            {
+                buffer.AppendNum(aEncryptedCount);
+                buffer.Append(_L(" files encrypted\n"));
+            }
+            
+            CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+            informationNote->ExecuteLD(buffer);
+
+            break;
+            }
+        case EDrmEncryptorKeyCommand:
+            {
+            result = KeyStorage();
+
+            if(result < 1) 
+            {
+                buffer.Append(_L("No key files found"));
+            }
+            else 
+            {
+                buffer.Append(_L("Keys imported\n"));
+                buffer.AppendNum(result);
+                buffer.Append(_L(" keys imported"));
+            }
+            CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+            informationNote->ExecuteLD(buffer);
+            break;
+            }
+            case EDrmEncryptorDeleteCommand:
+            {
+                DeleteRdbL();
+                CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+                informationNote->ExecuteLD(_L("Database deleted"));
+                break;
+            }
+            case EDrmTimeCommand:
+            {
+                GetDrmClockL();
+                break;
+            }
+            case ESetDrmTimeCommand:
+            {
+                SetDrmClockL();
+                break;
+            }
+            case EDrmBb5KeyTestCommand:
+            {
+                result = Bb5KeyStorage();
+
+            if(result != KErrNone) 
+            {
+                buffer.Append(_L("No CMLA keys available"));
+                buffer.AppendNum(result);
+
+            }
+            else 
+            {
+                buffer.Append(_L(" CMLA data OK! \n"));
+                buffer.AppendNum(result);
+                buffer.Append(_L(" \n Check log for Root."));
+            }
+            CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+            informationNote->ExecuteLD(buffer);
+            break;
+            }
+            case EDRMPlayServerCommand:
+            {
+                CDRMPlayServerTest* test = CDRMPlayServerTest::NewLC();
+                TInt error = test->ExecutePlayServerTest();
+                CleanupStack::PopAndDestroy( test );
+                if ( error == KErrCANoRights )
+                    {
+                    buffer.Append(_L("Test succeeded\n"));
+                    buffer.Append(_L("DRMPlayServer can't be used with WMDRM"));
+                    }
+                else
+                    {
+                    buffer.Append(_L("Test failed with error code: "));
+                    buffer.AppendNum(error);
+                    }
+                CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+                informationNote->ExecuteLD(buffer);
+                break;
+            }
+            case EDrmEncryptorDeleteWmDrmCommand:
+            {
+                DeleteWmDrmRdbL();
+                CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+                informationNote->ExecuteLD(_L("WmDrm Rights Deleted"));
+                break;
+            }
+            case EDrmEncryptorBackupWmDrmCommand:
+            {
+                TRAPD( error, BackupWmDrmDbL() );
+                if ( !error )
+                    {
+                    buffer.Append(_L("WmDrm License DB backup succeeded"));
+                    }
+                else
+                    {
+                    buffer.Append(_L("WmDrm License DB backup failed"));
+                    }
+                CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+                informationNote->ExecuteLD(buffer);
+                break;
+            }
+            case EDrmEncryptorRestoreWmDrmCommand:
+            {
+                TRAPD( error, RestoreWmDrmDbL() );
+                if ( !error )
+                    {
+                    buffer.Append(_L("WmDrm License DB restore succeeded"));
+                    }
+                else
+                    {
+                    buffer.Append(_L("WmDrm License DB restore failed"));
+                    }
+                CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+                informationNote->ExecuteLD(buffer);
+                break;
+            }            
+        default:
+            TestPerformanceL(aCommand);
+                        
+            buffer.Append(_L("Performance test done\n"));
+            buffer.Append(_L("See results from \nc:\\logs\\performance.log"));
+            
+            CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+            informationNote->ExecuteLD(buffer);
+            
+            break;
+        }
+    }
+
+
+TBool CDRMEncryptorAppUi::ProcessCommandParametersL(
+    TApaCommand /*aCommand*/,
+    TFileName& /*aDocumentName*/,
+    const TDesC8& /*aTail*/)
+    {
+    return EFalse;
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/src/DRMEncryptorContainer.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,444 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <eiksbfrm.h>
+#include <eikscrlb.h>
+#include <eikrted.h>
+#include <txtrich.h>
+#include <barsread.h>
+#include <eikenv.h>
+#include <aknenv.h>
+#include <aknutils.h>
+#include <aknconsts.h>
+#include <txtfrmat.h>
+#include <AknBidiTextUtils.h>
+
+#include <DRMEncryptor.rsg>
+#include "DRMEncryptorContainer.h"
+#include "DRMEncryptorImage.h"
+#include "DRMEncryptor.hrh"
+
+// CONSTANTS
+
+_LIT( KDRMEncryptorPanicCategory, "DRMEncryptor" );
+
+enum TDRMEncryptorPanic
+    {
+    EDRMEncryptorNotSupported = 0
+    };
+
+// constructors
+
+CDRMEncryptorContainer::CDRMEncryptorContainer()
+    {
+    }
+
+void CDRMEncryptorContainer::ConstructL( const TRect& aRect )
+    {
+    CreateWindowL();
+
+    // In case of APAC layout, use APAC font
+    TAknLayoutId layoutId;
+    iAvkonEnv->GetCurrentLayoutId( layoutId );
+
+    if ( layoutId == EAknLayoutIdAPAC )
+        {
+        iFont = ApacPlain12();
+        }
+    else
+        {
+        iFont = LatinPlain12();
+        }
+
+    // Calculate various text positioning parameters
+    iBaseLineDelta = iFont->HeightInPixels() * 4 / 3;
+
+    TInt mainPaneWidth( aRect.iBr.iX - aRect.iTl.iX );
+    TInt mainPaneHeight( aRect.iBr.iY - aRect.iTl.iY );
+    // Line width is 87% of client rect, horizontal margins 13%
+    iLineWidth = mainPaneWidth * 87 / 100;
+
+    iTopBaseLineX = ( mainPaneWidth - iLineWidth ) / 2;
+
+    // top margin is 6.5% of the client rect
+    TInt topMargin = mainPaneHeight * 65 / 1000;
+    iTopBaseLineY = topMargin + iFont->AscentInPixels();
+
+    // minimum bottom margin is 3% of the client rect
+    TInt bottomMargin = mainPaneHeight * 3 / 100;
+    iLinesPerScreen =
+        ( mainPaneHeight - topMargin - bottomMargin ) / iBaseLineDelta;
+
+    iTextAlign = CGraphicsContext::ELeft;
+
+    // Every text line on screen is one entry in this array
+    iText = new( ELeave ) CArrayPtrFlat<HBufC>( 20 );
+    // Every image on screen is one entry in this array
+    iImages = new( ELeave ) CArrayPtrFlat<CDRMEncryptorImage>( 1 );
+    // This array contains indices for lines that start the subsequent
+    // screens, for custom scrolling
+    iScreenStarts = new( ELeave ) CArrayFixFlat<TInt>( 5 );
+    // Initialisation: first screen starts at line 0.
+    iScreenStarts->AppendL( 0 );
+
+    // Read text and image items to be shown on the screen from a resource file.
+
+    // real resource
+    TResourceReader reader;
+    iEikonEnv->CreateResourceReaderLC( reader, R_DRMENCRYPTOR_MAIN_TEXT );
+
+    TInt numItems( reader.ReadInt16() );
+
+    for ( TInt i = 0 ; i < numItems ; i++ )
+        {
+        TInt type = reader.ReadInt8();
+
+        if ( type == EDRMEncryptorTextItem )
+            {
+            HBufC* text = iEikonEnv->AllocReadResourceLC( reader.ReadInt32() );
+    SetTextL( *text );
+
+
+            CleanupStack::PopAndDestroy(); // text
+            }
+        else if ( type == EDRMEncryptorImageItem )
+            {
+            TPtrC bitmapFile = reader.ReadTPtrC();
+            TInt bitmapId = reader.ReadInt16();
+            SetImageL( bitmapFile, bitmapId );
+            }
+        else
+            {
+            User::Panic( KDRMEncryptorPanicCategory, EDRMEncryptorNotSupported );
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); // reader
+
+    UpdateScrollIndicatorL();
+    SetRect( aRect );
+    ActivateL();
+    }
+
+// destructor
+
+CDRMEncryptorContainer::~CDRMEncryptorContainer()
+    {
+    delete iSBFrame;
+    delete iScreenStarts;
+
+    if ( iText )
+        {
+        iText->ResetAndDestroy();
+        delete iText;
+        }
+
+    if ( iImages )
+        {
+        iImages->ResetAndDestroy();
+        delete iImages;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorContainer::Draw()
+// -----------------------------------------------------------------------------
+
+void CDRMEncryptorContainer::Draw( const TRect& aRect ) const
+    {
+    CWindowGc& gc = SystemGc();
+
+    //  clear the area
+
+    gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) );
+    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+    gc.Clear( aRect );
+
+    // draw text
+    gc.UseFont( iFont );
+
+    // index of the first line on the screen in the text array
+    TInt firstLine( (*iScreenStarts)[ iCurrentScreen ] );
+    // index of the last line on the screen in the text array
+    TInt lastLine( firstLine + iLinesPerScreen - 1 );
+
+    gc.SetBrushStyle( CGraphicsContext::ENullBrush );
+    TPoint position( iTopBaseLineX, iTopBaseLineY );
+    TPoint topLeft;
+    TSize rectSize( iLineWidth, iBaseLineDelta +iFont->DescentInPixels() );
+
+    for ( TInt index = firstLine ;
+          index < iText->Count() && index <= lastLine ;
+          index++, position.iY += iBaseLineDelta )
+        {
+        HBufC* text = (*iText)[ index ];
+
+        if ( text )
+            {
+            topLeft = TPoint( position.iX, position.iY-iBaseLineDelta );
+            gc.DrawText( *text,
+                         TRect( topLeft, rectSize ),
+                         iBaseLineDelta,
+                         iTextAlign );
+            }
+        }
+
+    gc.DiscardFont();
+
+    // draw images
+
+    for ( TInt i = 0 ; i < iImages->Count() ; i++ )
+        {
+        CDRMEncryptorImage* image = (*iImages)[ i ];
+
+        // If part of the image resides in visible lines, draw it.
+        if ( image->StartLine() <= lastLine && image->EndLine() >= firstLine )
+            {
+            position.SetXY( iTopBaseLineX, iTopBaseLineY );
+            position.iY += ( image->StartLine() - firstLine ) * iBaseLineDelta;
+
+            position.iY -= iBaseLineDelta - iFont->DescentInPixels();
+            // Now iY is the top line of rectangle where the picture is
+            // centered in.
+            position.iY += ( (image->Lines()+1) * iBaseLineDelta -
+                             iFont->HeightInPixels() -
+                             image->HeightInPixels() ) / 2;
+
+            // If text is right-aligned, also align images to the right.
+
+            if ( iTextAlign == CGraphicsContext::ERight )
+                {
+                position.iX += ( iLineWidth - image->WidthInPixels() );
+                }
+
+            gc.BitBlt( position, image->Bitmap(), aRect );
+            }
+        }
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorContainer::ActivateL()
+// -----------------------------------------------------------------------------
+
+void CDRMEncryptorContainer::ActivateL()
+    {
+    CCoeControl::ActivateL();
+    UpdateScrollIndicatorL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorContainer::SetTextL()
+// -----------------------------------------------------------------------------
+
+void CDRMEncryptorContainer::SetTextL( const TDesC& aText )
+    {
+    CArrayFix<TPtrC>* wrappedArray =
+        new( ELeave ) CArrayFixFlat<TPtrC>( 10 );
+
+    CleanupStack::PushL( wrappedArray );
+
+    HBufC* dataToDestroy =
+        AknBidiTextUtils::ConvertToVisualAndWrapToArrayL(
+            aText, iLineWidth, *iFont, *wrappedArray
+        );
+
+    TInt numLines( wrappedArray->Count() );
+    for ( TInt i = 0 ; i < numLines ; i++ )
+        {
+        HBufC* line = (*wrappedArray)[i].AllocLC();
+
+        if(!line->Length())
+            {
+            iText->AppendL( NULL );
+
+            CleanupStack::PopAndDestroy();  // line
+            }
+        else
+            {
+            iText->AppendL( line );
+            CleanupStack::Pop();  // line
+            }
+        }
+    iText->AppendL( NULL );
+
+    // If the last char was newline, add one extra, since
+    // wrapping automatically removes it.
+    if ( aText[ aText.Length() - 1 ] == '\n' )
+        {
+        iText->AppendL( NULL );
+        }
+
+    CleanupStack::PopAndDestroy(); // wrappedArray
+    delete dataToDestroy;
+
+    // update screen scrolling info array
+
+    TInt lastLine( iText->Count() - 1 );
+    TInt screenStart( (*iScreenStarts)[ iScreenStarts->Count() - 1 ] );
+
+    TBool firstNewScreenHandled( EFalse );
+
+    while ( lastLine >= screenStart + iLinesPerScreen )
+        {
+        if ( !firstNewScreenHandled && iDoNotShowLastLineAgain )
+            {
+            screenStart++;
+            firstNewScreenHandled = ETrue;
+            }
+
+        screenStart += iLinesPerScreen - 1;
+        iScreenStarts->AppendL( screenStart );
+        }
+
+    // if text, last line is shown again in next screen
+    iDoNotShowLastLineAgain = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorContainer::SetImageL()
+// -----------------------------------------------------------------------------
+
+void CDRMEncryptorContainer::SetImageL( const TDesC& aFileName, TInt aBitmapId )
+    {
+    TInt firstLineOfImage( iText->Count() );
+
+    CDRMEncryptorImage* image =
+    CDRMEncryptorImage::NewLC( aFileName, aBitmapId, firstLineOfImage, iBaseLineDelta );
+
+    // new lines to make room for the picture
+
+    for ( TInt i = 0 ; i < image->Lines() ; i++ )
+        {
+        iText->AppendL( NULL );
+        }
+
+    iImages->AppendL( image );
+    CleanupStack::Pop(); // image
+
+    // update screen scrolling info array
+
+    TInt lastLineOfImage( iText->Count() - 1 );
+    TInt screenStart( (*iScreenStarts)[ iScreenStarts->Count() - 1 ] );
+
+    TBool firstNewScreenHandled( EFalse );
+
+    // If the image was not fully shown in the first screen,
+    // start the next screen with the image.
+
+    if ( firstLineOfImage < screenStart + iLinesPerScreen &&
+         lastLineOfImage >= screenStart + iLinesPerScreen )
+        {
+        screenStart = firstLineOfImage;
+        iScreenStarts->AppendL( screenStart );
+        firstNewScreenHandled = ETrue;
+        }
+
+    while ( lastLineOfImage >= screenStart + iLinesPerScreen )
+        {
+        if ( !firstNewScreenHandled && iDoNotShowLastLineAgain )
+            {
+            screenStart++;
+            firstNewScreenHandled = ETrue;
+            }
+
+        screenStart += iLinesPerScreen - 1;
+        iScreenStarts->AppendL( screenStart );
+        }
+
+    if ( lastLineOfImage == screenStart + iLinesPerScreen - 1 )
+        {
+        iDoNotShowLastLineAgain = ETrue;
+        }
+    else
+        {
+        iDoNotShowLastLineAgain = EFalse;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorContainer::OfferKeyEventL()
+// -----------------------------------------------------------------------------
+
+TKeyResponse CDRMEncryptorContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
+                                              TEventCode aType )
+    {
+    if ( aType == EEventKey && iScreenStarts->Count() > 1 )
+        {
+        switch ( aKeyEvent.iCode )
+            {
+            case EKeyUpArrow:
+                if ( iCurrentScreen > 0 )
+                    {
+                    iCurrentScreen--;
+                    DrawNow();
+                    UpdateScrollIndicatorL();
+                    }
+                break;
+
+            case EKeyDownArrow:
+                if ( iCurrentScreen < iScreenStarts->Count() - 1 )
+                    {
+                    iCurrentScreen++;
+                    DrawNow();
+                    UpdateScrollIndicatorL();
+                    }
+                break;
+
+            default:
+                break;
+            }
+        }
+
+    return EKeyWasConsumed;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorContainer::UpdateScrollIndicatorL()
+// -----------------------------------------------------------------------------
+
+void CDRMEncryptorContainer::UpdateScrollIndicatorL()
+    {
+    if ( iScreenStarts->Count() <= 1 )
+        {
+        return;
+        }
+
+    if ( !iSBFrame )
+        {
+        iSBFrame = new( ELeave ) CEikScrollBarFrame( this, NULL, ETrue );
+        iSBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
+                                           CEikScrollBarFrame::EAuto );
+        iSBFrame->SetTypeOfVScrollBar( CEikScrollBarFrame::EArrowHead );
+        }
+
+    TEikScrollBarModel hSbarModel;
+    TEikScrollBarModel vSbarModel;
+    vSbarModel.iThumbPosition = iCurrentScreen;
+    vSbarModel.iScrollSpan = iScreenStarts->Count();
+    vSbarModel.iThumbSpan = 1;
+
+    TEikScrollBarFrameLayout layout;
+    TRect rect( Rect() );
+    iSBFrame->TileL( &hSbarModel, &vSbarModel, rect, rect, layout );
+    iSBFrame->SetVFocusPosToThumbPos( vSbarModel.iThumbPosition );
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/src/DRMEncryptorDocument.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include "DRMEncryptorDocument.h"
+#include "DRMEncryptorAppUi.h"
+#include "DrmKeyStorage.h"
+
+extern TUint KeyStorageFromZipL(const TDesC&, RFs&);
+
+// ================= MEMBER FUNCTIONS =======================
+
+// constructor
+CDRMEncryptorDocument::CDRMEncryptorDocument( CEikApplication& aApp ) : CAknDocument( aApp )
+    {
+    }
+
+// destructor
+CDRMEncryptorDocument::~CDRMEncryptorDocument()
+    {
+    }
+
+// Two-phased constructor.
+CDRMEncryptorDocument* CDRMEncryptorDocument::NewL( CEikApplication& aApp )
+    {
+    return new( ELeave ) CDRMEncryptorDocument( aApp );
+    }
+    
+CFileStore* CDRMEncryptorDocument::OpenFileL(TBool /*aDoOpen*/, const TDesC& aFileName, RFs& aFs)
+    {
+    KeyStorageFromZipL(aFileName, aFs);
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorDocument::CreateAppUiL()
+// constructs CDRMEncryptorAppUi
+// -----------------------------------------------------------------------------
+//
+CEikAppUi* CDRMEncryptorDocument::CreateAppUiL()
+    {
+    return new( ELeave ) CDRMEncryptorAppUi;
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/src/DRMEncryptorImage.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+// INCLUDE FILES
+#include <fbs.h>
+#include "DRMEncryptorImage.h"
+
+// ================= MEMBER FUNCTIONS ==========================================
+
+CDRMEncryptorImage::CDRMEncryptorImage()
+    {
+    }
+
+CDRMEncryptorImage::~CDRMEncryptorImage()
+    {
+    delete iBitmap;
+    }
+
+CDRMEncryptorImage* CDRMEncryptorImage::NewLC( const TDesC& aFileName,
+                                 TInt aBitmapId,
+                                 TInt aStartLine,
+                                 TInt aBaseLineDelta )
+    {
+    CDRMEncryptorImage* self = new( ELeave ) CDRMEncryptorImage();
+    CleanupStack::PushL( self );
+
+    self->iBitmap = new( ELeave ) CFbsBitmap;
+    self->iBitmap->Load( aFileName, aBitmapId );
+
+    self->iStartLine = aStartLine;
+
+    // enough lines so that image and margins fit in them.
+
+    TInt lines( ( self->HeightInPixels() + 
+                  KImageTopMargin + 
+                  KImageBottomMargin +
+                  aBaseLineDelta - 1 ) / aBaseLineDelta );
+
+    self->iEndLine = aStartLine + lines - 1;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorImage::HeightInPixels()
+// -----------------------------------------------------------------------------
+
+TInt CDRMEncryptorImage::HeightInPixels() const
+    {
+    return iBitmap->SizeInPixels().iHeight;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorImage::WidthInPixels()
+// -----------------------------------------------------------------------------
+
+TInt CDRMEncryptorImage::WidthInPixels() const
+    {
+    return iBitmap->SizeInPixels().iWidth;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorImage::StartLine()
+// -----------------------------------------------------------------------------
+
+TInt CDRMEncryptorImage::StartLine() const
+    {
+    return iStartLine;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorImage::EndLine()
+// -----------------------------------------------------------------------------
+
+TInt CDRMEncryptorImage::EndLine() const
+    {
+    return iEndLine;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorImage::Lines()
+// -----------------------------------------------------------------------------
+
+TInt CDRMEncryptorImage::Lines() const
+    {
+    return iEndLine - iStartLine + 1;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEncryptorImage::Bitmap()
+// -----------------------------------------------------------------------------
+
+const CFbsBitmap* CDRMEncryptorImage::Bitmap() const
+    {
+    return iBitmap;
+    }
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/src/DRMPlayServerTest.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#include <DrmAudioSamplePlayer.h>
+
+#include "DRMPlayServerTest.h"
+
+#ifdef __WINS__
+_LIT( KTestFile, "c:\\data\\drm\\test.wma" );
+#else
+_LIT( KTestFile, "e:\\drm\\test.wma" );
+#endif
+
+// ================= MEMBER FUNCTIONS ==========================================
+
+CDRMPlayServerTest::CDRMPlayServerTest()
+    {
+    }
+
+
+void CDRMPlayServerTest::ConstructL()
+    {
+    iWait = new (ELeave) CActiveSchedulerWait();
+    iDrmPlayerUtility = CDrmPlayerUtility::NewL( *this, 
+                                                 0, 
+                                                 EMdaPriorityPreferenceNone );
+    }
+
+CDRMPlayServerTest::~CDRMPlayServerTest()
+    {
+    delete iWait;
+    delete iDrmPlayerUtility;
+    }
+
+CDRMPlayServerTest* CDRMPlayServerTest::NewLC()
+    {
+    CDRMPlayServerTest* self = new( ELeave ) CDRMPlayServerTest();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+TInt CDRMPlayServerTest::ExecutePlayServerTest()
+    {
+    iError = KErrNone;
+    TRAP( iError, iDrmPlayerUtility->OpenFileL( KTestFile ) );
+    if ( iError )
+        {
+        return iError;
+        }
+    iWait->Start();
+    return iError;
+    }
+
+void CDRMPlayServerTest::MdapcInitComplete( 
+    TInt aError, 
+    const TTimeIntervalMicroSeconds& /*aDuration*/ )
+    {
+    iWait->AsyncStop();
+    iError = aError;
+    }
+
+void CDRMPlayServerTest::MdapcPlayComplete( TInt aError )
+    {
+    iWait->AsyncStop();
+    iError = aError;
+    }
+
+// End of File  
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/src/DrmBb5KeyStorage.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,239 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+#include <x509cert.h>
+#include <symmetric.h>
+#include <asymmetric.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "DrmKeyStorage.h"
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// Test logging macros
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT(KFullLogDir, "%c:\\logs\\drm\\");
+#else
+_LIT(KFullLogDir, "c:\\logs\\drm\\");
+#endif
+
+_LIT(KLogDir, "drm");
+_LIT(KLogName, "DrmEncryptorBb5KeyStorage.log");
+
+#define TEST_STEP(string) \
+    GBb5Log.WriteFormat(_L("Next Test: %S"), &string);
+
+#define CHECK(condition) \
+    if (!condition) GBb5Log.WriteFormat(_L("FAIL: line %d"), __LINE__);
+
+// MODULE DATA STRUCTURES
+
+RFs GBb5Fs;
+RFileLogger GBb5Log;
+
+// STATIC TEST CONTENT AND RIGHTS OBJECTS
+
+// LOCAL FUNCTION PROTOTYPES
+
+// ==================== LOCAL FUNCTIONS ====================
+
+HBufC8* I2OSPL(
+    RInteger& aInt)
+    {
+    HBufC8* r = aInt.BufferLC();
+    CleanupStack::Pop(r);
+    return r;
+    }
+
+RInteger OS2IPL(
+    const TDesC8& aOctetStream)
+    {
+    RInteger r;
+    TInt i;
+
+    r = RInteger::NewL(0);
+    for (i = 0; i < aOctetStream.Length(); i++)
+        {
+        r *= 256;
+        r += aOctetStream[i];
+        }
+    return r;
+    }
+
+HBufC8* RsaEncryptL(
+    CRSAPublicKey* aKey,
+    const TDesC8& aInput)
+    {
+    RInteger result;
+    RInteger input;
+    HBufC8* output;
+
+    input = OS2IPL(aInput);
+    CleanupClosePushL(input);
+    result = TInteger::ModularExponentiateL(input, aKey->E(), aKey->N());
+    CleanupClosePushL(result);
+    output = I2OSPL(result);
+    CleanupStack::PopAndDestroy(2); // result, input
+    return output;
+    }
+
+LOCAL_C TUint MDrmKeyStorage_GetCertificateChainL()
+    {
+    MDrmKeyStorage* storage = NULL;
+    RPointerArray<HBufC8> chain;
+    TInt i;
+    TUint result = NULL;
+
+    GBb5Log.WriteFormat(_L("MDrmKeyStorage_GetCertificateChainL -> DrmKeyStorageNewL"));
+    TRAPD(err,storage = DrmKeyStorageNewL());
+    if (err != KErrNone)
+        {
+            result = err;
+        }
+
+    GBb5Log.WriteFormat(_L("MDrmKeyStorage_GetCertificateChainL -> SelectDefaultRootL"));
+    storage->SelectDefaultRootL();
+
+    GBb5Log.WriteFormat(_L("MDrmKeyStorage_GetCertificateChainL -> GetCertificateChainL"));
+    storage->GetCertificateChainL(chain);
+
+    for (i = 0; i < chain.Count(); i++)
+        {
+        GBb5Log.WriteFormat(_L("Certificate %d:"), i);
+        GBb5Log.HexDump(_S(""), _S(""), chain[i]->Ptr(), chain[i]->Length());
+        }
+    chain.ResetAndDestroy();
+    chain.Close();
+    delete storage;
+    return result;
+    }
+
+LOCAL_C TUint MDrmKeyStorage_DecryptL()
+    {
+    MDrmKeyStorage* storage = NULL;
+    RPointerArray<HBufC8> chain;
+    CRSAPublicKey* key = NULL;
+    CX509Certificate* cert = NULL;
+    TX509KeyFactory factory;
+    TBuf8<128> data;
+    HBufC8* encData;
+    HBufC8* decData;
+    TUint result = KErrNone;
+
+
+    GBb5Log.WriteFormat(_L("MDrmKeyStorage_Decrypt"));
+    storage = DrmKeyStorageNewL();
+    storage->SelectDefaultRootL();
+    storage->GetCertificateChainL(chain);
+    cert = CX509Certificate::NewL(*chain[0]);
+    chain.ResetAndDestroy();
+    chain.Close();
+    key = factory.RSAPublicKeyL(cert->PublicKey().KeyData());
+    data.SetLength(128);
+    data.Fill(1);
+    GBb5Log.WriteFormat(_L("data:"));
+    GBb5Log.HexDump(_S(""), _S(""), &data[0], sizeof(data));
+
+    encData = RsaEncryptL(key, data);
+    GBb5Log.WriteFormat(_L("encrypted data:"));
+    GBb5Log.HexDump(_S(""), _S(""), encData->Ptr(), encData->Length());
+
+    decData = storage->RsaDecryptL(*encData);
+    GBb5Log.WriteFormat(_L("decrypted data :"));
+    GBb5Log.HexDump(_S(""), _S(""), decData->Ptr(), decData->Length());
+
+    delete cert;
+    delete key;
+    delete storage;
+    return result;
+    }
+
+// ==================== TEST FUNCTIONS =====================
+
+
+
+TUint Bb5KeyStorage()
+    {
+    TUint result = 0;
+    TInt catchy = 0;
+    result = GBb5Fs.Connect();
+    if( result != KErrNone )
+        {
+        return result;
+        }
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    GBb5Fs.MkDirAll(KFullLogDir);
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    GBb5Fs.DriveToChar( driveNumber, driveLetter );
+
+    TFileName fullLogDir;
+    fullLogDir.Format( KFullLogDir, (TUint)driveLetter );
+
+    GBb5Fs.MkDirAll(fullLogDir);
+
+#endif
+
+    result = GBb5Log.Connect();
+    if( result != KErrNone )
+        {
+        GBb5Fs.Close();
+        return result;
+        }
+    GBb5Log.CreateLog(KLogDir, KLogName, EFileLoggingModeOverwrite);
+    GBb5Log.Write(_L("Start %D"));
+
+    TRAPD(err,result = MDrmKeyStorage_GetCertificateChainL());
+    CHECK(err == KErrNone);
+    if (err ==KErrNone)
+        {
+        TRAP(catchy, result = MDrmKeyStorage_DecryptL());
+        if( catchy )
+            {
+            result = catchy;
+            }
+        }
+    CHECK(err == KErrNone);
+    GBb5Log.CloseLog();
+    GBb5Fs.Close();
+    return result;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/src/DrmEncryptor.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,577 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRM Encryption tool for DRM5
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32base.h>
+#include <barsc.h>
+#include <barsread.h>
+#include <apmstd.h>
+#include <e32test.h>
+#include <s32strm.h>
+#include <s32file.h>
+#include <bacline.h>
+#include <e32math.h>
+
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include <DrmRights.h>
+#include <DcfCommon.h>
+#include <DRMMessageParser.h>
+#include <Oma1DcfCreator.h>
+#include <DrmRightsClient.h>
+#include "DRMClockClient.h"
+
+#include <dcfrep.h>
+#include <dcfentry.h>
+
+#include <DRMEncryptor.rsg>
+
+#include <avkon.hrh>
+#include <aknnotewrappers.h>
+
+#include <wmdrmagent.h>
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+_LIT( KWmdrmBd, "c:\\private\\10281e17\\[10282F1B]hds.db" );
+_LIT( KWmdrmBdBackup, "e:\\[10282F1B]hds.db" );
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// ==================== LOCAL FUNCTIONS ====================
+
+LOCAL_C void ReadFileL(HBufC8*& aContent, const TDesC& aName, RFs& aFs)
+    {
+    TInt size = 0;
+    RFile file;
+    User::LeaveIfError(file.Open(aFs, aName, EFileRead));
+    User::LeaveIfError(file.Size(size));
+    aContent = HBufC8::NewLC(size);
+    TPtr8 ptr(aContent->Des());
+    User::LeaveIfError(file.Read(ptr, size));
+    CleanupStack::Pop(); //aContent
+    }
+
+// ---------------------------------------------------------
+// UpdateDCFRepositoryL()
+// Update saved file to DCFRepository
+// ---------------------------------------------------------
+//
+LOCAL_C void UpdateDCFRepositoryL( const TDesC& aFileName)
+    {
+    CDcfEntry* dcf( NULL );
+    CDcfRep* dcfRep( NULL );
+
+    dcf = CDcfEntry::NewL();
+    CleanupStack::PushL( dcf );
+
+    dcfRep = CDcfRep::NewL();
+    CleanupStack::PushL( dcfRep );
+
+    dcf->SetLocationL( aFileName, 0 );
+    dcfRep->UpdateL( dcf );
+
+    CleanupStack::PopAndDestroy(2); // dcf, dcfRep
+    }
+
+
+
+
+// ==================== TEST FUNCTIONS =====================
+
+const TInt KBufferSize = 20000;
+
+void ProcessMessageL(const TDesC& aFile, const TDesC& aOutput)
+    {
+    CDRMMessageParser* c = NULL;
+    HBufC8* d = NULL;
+    RFs fs;
+    TPtr8 inRead(NULL, 0);
+    TInt error = 1;
+    __UHEAP_MARK;
+
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    c = CDRMMessageParser::NewL();
+    CleanupStack::PushL(c);
+
+    d = HBufC8::NewLC( KBufferSize );
+
+    RFile input;
+    User::LeaveIfError(input.Open( fs, aFile, EFileRead ));
+    CleanupClosePushL( input );
+
+    RFileWriteStream output;
+    output.Replace( fs, aOutput, EFileWrite );
+    CleanupClosePushL( output );
+
+    c->InitializeMessageParserL( output );
+
+    while( error )
+        {
+        inRead.Set( const_cast<TUint8*>(d->Ptr()),0,KBufferSize);
+        error = input.Read( inRead );
+
+        if( error )
+            {
+            c->FinalizeMessageParserL();
+
+            User::Leave( error );
+            }
+        else
+            {
+            error = inRead.Length();
+            }
+
+        if( error )
+            {
+            c->ProcessMessageDataL(inRead);
+            }
+        }
+
+    c->FinalizeMessageParserL();
+
+
+    CleanupStack::PopAndDestroy( 5 ); // fs, c, d, input, output
+    UpdateDCFRepositoryL( aOutput );
+    __UHEAP_MARKEND;
+    }
+
+void ProcessRightsL(const TDesC& aFile)
+    {
+    CDRMMessageParser* c = NULL;
+    HBufC8* d = NULL;
+    RFs fs;
+    RPointerArray<CDRMRights> rights;
+
+    User::LeaveIfError(fs.Connect());
+    c = CDRMMessageParser::NewL();
+    ReadFileL(d, aFile, fs);
+    c->ProcessRightsObject(*d, rights);
+    rights.ResetAndDestroy();
+    delete d;
+    delete c;
+    fs.Close();
+    }
+
+void EncryptFileL(const TDesC& aFile, TDesC& aOutput, TInt aMultiplier)
+    {
+    COma1DcfCreator* c = NULL;
+    CDRMRights* rights = NULL;
+    TBuf8<64> mime;
+    RFs fs;
+    TFileName aDcfFile;
+    TInt aOriginalFileNameLength(aOutput.Length() - 4);
+
+    User::LeaveIfError(fs.Connect());
+    if (aFile.Right(3).CompareF(_L("amr")) == 0) //AMR
+        {
+        mime.Copy(_L8("audio/amr"));
+        }
+    else if (aFile.Right(3).CompareF(_L("awb")) == 0) //AMR-AWB
+        {
+        mime.Copy(_L8("audio/amr-wb"));
+        }
+    else if (aFile.Right(3).CompareF(_L("mp3")) == 0) //MP3
+        {
+        mime.Copy(_L8("audio/mpeg"));
+        }
+    else if (aFile.Right(3).CompareF(_L("mp4")) == 0) //MP4
+        {
+        mime.Copy(_L8("audio/mp4"));
+        }
+    else if (aFile.Right(3).CompareF(_L("m4a")) == 0) //M4A
+        {
+        mime.Copy(_L8("audio/mp4"));
+        }
+    else if (aFile.Right(3).CompareF(_L("3gp")) == 0) //3GPP
+        {
+        mime.Copy(_L8("audio/3gpp"));
+        }
+    else if (aFile.Right(3).CompareF(_L("3g2")) == 0) //3GPP2
+        {
+        mime.Copy(_L8("audio/3gpp2"));
+        }
+    else if (aFile.Right(3).CompareF(_L("aac")) == 0) //AAC
+        {
+        mime.Copy(_L8("audio/aac"));
+        }
+    else if (aFile.Right(3).CompareF(_L("mid")) == 0) //MIDI
+        {
+        mime.Copy(_L8("audio/midi"));
+        }
+    else if (aFile.Right(5).CompareF(_L(".spmid")) == 0) //SP-MIDI
+        {
+        mime.Copy(_L8("audio/sp-midi"));
+        }
+    else if (aFile.Right(3).CompareF(_L("rmf")) == 0) //RMF
+        {
+        mime.Copy(_L8("audio/rmf"));
+        }
+    else if (aFile.Right(4).CompareF(_L("mxmf")) == 0) //Mobile-XMF
+        {
+        mime.Copy(_L8("audio/mobile-xmf"));
+        }
+    else if (aFile.Right(3).CompareF(_L("wav")) == 0) //WAV
+        {
+        mime.Copy(_L8("audio/x-wav"));
+        }
+    else if (aFile.Right(3).CompareF(_L("gif")) == 0) // GIF
+        {
+        mime.Copy(_L8("image/gif"));
+        }
+    else if (aFile.Right(3).CompareF(_L("jpg")) == 0) // JPEG
+        {
+        mime.Copy(_L8("image/jpeg"));
+        }
+    else if (aFile.Right(3).CompareF(_L("txt")) == 0) // text
+        {
+        mime.Copy(_L8("text/plain"));
+        }
+    else if (aFile.Right(3).CompareF(_L("pip")) == 0) // PIP
+        {
+        mime.Copy(_L8("application/x-pip"));
+        }
+
+    aDcfFile.Append(aOutput);
+
+    for(TInt i = 0; i < aMultiplier ; ++i)
+        {
+        aDcfFile.Delete(aOriginalFileNameLength, aDcfFile.Length());
+        aDcfFile.Append(_L("-"));
+        aDcfFile.AppendNum(i);
+        aDcfFile.Append(_L(".dcf"));
+        c = COma1DcfCreator::NewL();
+        CleanupStack::PushL(c);
+        fs.Delete(aOutput);
+        c->EncryptFileL(aFile, aDcfFile, mime, rights);
+        UpdateDCFRepositoryL( aDcfFile );
+        delete rights;
+        CleanupStack::PopAndDestroy(); // c
+        }
+    fs.Close();
+
+    }
+
+TUint EncryptL(TUint& aEncryptedCount, TUint& aRightsCount, TUint& aMessagesProcessed)
+    {
+    TInt i;
+    CDir* files;
+    TFileName input;
+    TFileName output;
+    TUint inputNameSize = 0;
+    TUint outputNameSize = 0;
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    TInt aMultiplier(1);
+
+
+#ifdef __WINS__
+    input.Append(_L("c:\\data\\DRM\\"));
+    output.Append(_L("c:\\data\\Others\\"));
+#else
+#ifndef RD_MULTIPLE_DRIVE
+
+    input.Append(_L("e:\\DRM\\"));
+    output.Append(_L("e:\\Others\\"));
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNumber );
+    fs.DriveToChar( driveNumber, driveLetter );
+
+    _LIT( KdrmDir, "%c:\\DRM\\" );
+    input.Format( KdrmDir, (TUint)driveLetter );
+
+    _LIT( KothersDir, "%c:\\Others\\" );
+    output.Format( KothersDir, (TUint)driveLetter );
+
+#endif
+#endif
+
+    inputNameSize = input.Length();
+    outputNameSize = output.Length();
+
+
+    fs.MkDir(input);
+    fs.MkDir(output);
+
+    fs.GetDir(input, KEntryAttNormal, ESortNone, files);
+    for (i = 0; i < files->Count(); i++)
+        {
+        input.Append((*files)[i].iName);
+
+        output.Append((*files)[i].iName);
+
+        if (input.Right(2).CompareF(_L("dm")) == 0)
+            {
+
+            for(TInt ii = 0; ii < aMultiplier ; ++ii)
+                {
+                output.Delete(outputNameSize +(*files)[i].iName.Length() , output.Length()-1);
+                output.Append(_L("-"));
+                output.AppendNum(ii);
+                output.Append(_L(".dcf"));
+                ProcessMessageL(input, output);
+                ++aMessagesProcessed;
+                }
+            }
+        else if (input.Right(3).CompareF(_L("oro")) == 0 ||
+                input.Right(3).CompareF(_L("drc")) == 0 ||
+                input.Right(2).CompareF(_L("ro")) == 0 ||
+                input.Right(2).CompareF(_L("dr")) == 0 )
+            {
+            for (TInt iii = 0; iii < aMultiplier; ++iii)
+                {
+                ProcessRightsL(input);
+                ++aRightsCount;
+                }
+            }
+        else if (input.Right(3).CompareF(_L("dcf")) != 0)
+            {
+            output.Append(_L(".dcf"));
+            EncryptFileL(input, output, aMultiplier);
+            ++aEncryptedCount;
+            }
+
+        //restore paths
+        input.Delete(inputNameSize, input.Length()-1);
+        output.Delete(outputNameSize, output.Length()-1);
+        }
+
+    fs.Close();
+    
+    TRequestStatus status;
+    CDcfRep* rep = CDcfRep::NewL();
+    CleanupStack::PushL(rep);
+    rep->RefreshDcf(status);
+    User::WaitForRequest( status );
+    CleanupStack::PopAndDestroy( rep );
+    
+    delete files;
+
+    return (aEncryptedCount*aMultiplier + aRightsCount + aMessagesProcessed);
+    }
+
+void DeleteRdbL()
+    {
+    RDRMRightsClient client;
+
+    User::LeaveIfError(client.Connect());
+    client.DeleteAll();
+    client.Close();
+    }
+
+
+
+
+// -----------------------------------------------------------------------------
+// GetCafDataL
+// -----------------------------------------------------------------------------
+//
+ContentAccess::CManager* GetCafDataL( TAgent& aAgent )
+    {
+    TPtr8 ptr(NULL, 0, 0);
+    RArray<TAgent> agents;
+    TRequestStatus status;
+    TInt i;
+
+    CleanupClosePushL( agents );
+    CManager* manager = CManager::NewLC();
+
+    manager->ListAgentsL( agents );
+
+    for (i = 0; i < agents.Count(); i++)
+        {
+        if (agents[i].Name().Compare(KWmDrmAgentName) == 0)
+            {
+            aAgent = agents[i];
+            break;
+            }
+        }
+    CleanupStack::Pop( manager );
+    CleanupStack::PopAndDestroy(); // agents
+    return manager;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DeleteWmDrmRdbL
+//-----------------------------------------------------------------------------
+//
+
+void DeleteWmDrmRdbL()
+    {
+    // get the data part
+    ContentAccess::CManager* manager = NULL;
+    ContentAccess::TAgent agent;
+    TPtr8 ptr(NULL, 0, 0);
+    TPtrC8 ptr2;
+
+    // Find the caf agent and create manager
+    manager = GetCafDataL( agent );
+    CleanupStack::PushL( manager );
+
+    User::LeaveIfError(
+        manager->AgentSpecificCommand( agent,
+                                       (TInt)DRM::EWmDrmDeleteRights,
+                                       ptr2,
+                                       ptr) );
+    CleanupStack::PopAndDestroy( manager );
+    }
+
+
+
+void GetDrmClockL()
+    {
+    RDRMClockClient client;
+
+    TTime drmTime;
+    TDateTime date;
+    TInt aTimeZone;
+    DRMClock::ESecurityLevel secLevel = DRMClock::KInsecure;
+    TBuf< 80 > buf;
+
+
+
+    User::LeaveIfError( client.Connect() );
+
+    client.GetSecureTime(drmTime, aTimeZone, secLevel);
+
+    client.Close();
+
+    date = drmTime.DateTime();
+
+    if(secLevel == DRMClock::KSecure)
+        {
+        _LIT(KFormatTxt,"DRMClock Time:\n%d/%d/%d\n%d:%d:%d\nNitz available");
+        buf.Format( KFormatTxt,
+                date.Day()+1,
+                TInt(date.Month()+1),
+                date.Year(),
+                date.Hour(),
+                date.Minute(),
+                date.Second());
+        }
+    else
+        {
+        _LIT(KFormatTxt,"DRMClock Time:\n%d/%d/%d\n%d:%d:%d\nNitz unavailable");
+        buf.Format( KFormatTxt,
+                date.Day()+1,
+                TInt(date.Month()+1),
+                date.Year(),
+                date.Hour(),
+                date.Minute(),
+                date.Second());
+        }
+
+    CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+    informationNote->ExecuteLD(buf);
+
+
+    }
+
+void SetDrmClockL()
+    {
+    RDRMClockClient client;
+
+    TTime drmTime (_L("20000111:200600.000000"));
+    TTime aDate (_L("20040000:"));
+    TDateTime date;
+    TInt aTimeZone;
+    DRMClock::ESecurityLevel secLevel = DRMClock::KInsecure;
+
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+
+    client.GetSecureTime(drmTime, aTimeZone, secLevel);
+
+    aDate = drmTime;
+
+    CAknMultiLineDataQueryDialog* dlg = CAknMultiLineDataQueryDialog::NewL(aDate, drmTime);
+    if ( dlg->ExecuteLD( R_DRM_TIME_QUERY ) )
+        {
+        TTime aTime = aDate.Int64() + drmTime.Int64();
+        client.UpdateSecureTime(aTime, aTimeZone);
+        CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+        informationNote->ExecuteLD(_L("DRM time changed"));
+        }
+    else
+        {
+        //User pressed cancel on confirmation screen
+        CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+        informationNote->ExecuteLD(_L("DRM time not changed"));
+        }
+    CleanupStack::PopAndDestroy();
+    }
+
+void BackupWmDrmDbL()
+    {
+    RProcess process;
+    TFullName name;
+    TFindProcess wmDrmServerFinder( _L( "*wmdrmserver*" ) );
+    if ( wmDrmServerFinder.Next( name ) == KErrNone && process.Open( name ) == KErrNone )
+        {
+        process.Kill( -1 );
+        process.Close();
+        }
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    CFileMan* fileMan = CFileMan::NewL( fs );
+    CleanupStack::PushL( fileMan );
+    User::LeaveIfError( fileMan->Copy( KWmdrmBd, KWmdrmBdBackup, CFileMan::EOverWrite ) );
+    CleanupStack::PopAndDestroy( 2, &fs ); //fs, fileMan
+    }
+
+void RestoreWmDrmDbL()
+    {
+    RProcess process;
+    TFullName name;
+    TFindProcess wmDrmServerFinder( _L( "*wmdrmserver*" ) );
+    if ( wmDrmServerFinder.Next( name ) == KErrNone && process.Open( name ) == KErrNone )
+        {
+        process.Kill( -1 );
+        process.Close();
+        }
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    CFileMan* fileMan = CFileMan::NewL( fs );
+    CleanupStack::PushL( fileMan );
+    User::LeaveIfError( fileMan->Copy( KWmdrmBdBackup, KWmdrmBd, CFileMan::EOverWrite ) );
+    CleanupStack::PopAndDestroy( 2, &fs ); //fs, fileMan
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/src/DrmKeyStorage.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,334 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+#include <x509cert.h>
+#include <symmetric.h>
+#include <asymmetric.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include <ZipFile.h>
+#include <aknnotewrappers.h>
+
+#include "DrmKeyStorage.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// Test logging macros
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT(KPrivateRightsDir, "%c:\\private\\101F51F2\\PKI");
+_LIT(KFullLogDir, "%c:\\logs\\drm\\");
+#else
+_LIT(KPrivateRightsDir, "c:\\private\\101F51F2\\PKI");
+_LIT(KFullLogDir, "c:\\logs\\drm\\");
+#endif
+
+
+#ifdef __WINS__
+_LIT(KInputDir, "c:\\data\\drm\\keys\\");
+_LIT(KInputFilePattern, "c:\\data\\drm\\keys\\SigningCert*");
+#else
+#ifdef RD_MULTIPLE_DRIVE
+_LIT(KInputDir, "%c:\\drm\\keys\\");
+_LIT(KInputFilePattern, "%c:\\drm\\keys\\SigningCert*");
+#else
+_LIT(KInputDir, "e:\\drm\\keys\\");
+_LIT(KInputFilePattern, "e:\\drm\\keys\\SigningCert*");
+#endif
+#endif
+
+_LIT(KLogDir, "drm");
+_LIT(KLogName, "MtDrmKeyStorage.log");
+_LIT(KDeviceKeyFileName, "DevicePrivateKey.der");
+_LIT(KDeviceCertFileName, "DeviceCert.der");
+
+#define TEST_STEP(string) \
+    GLog.WriteFormat(_L("Next Test: %S"), &string);
+
+#define CHECK(condition) \
+    if (!condition) GLog.WriteFormat(_L("FAIL: line %d"), __LINE__);
+
+// MODULE DATA STRUCTURES
+
+RFs GFs;
+RFileLogger GLog;
+
+// STATIC TEST CONTENT AND RIGHTS OBJECTS
+
+// LOCAL FUNCTION PROTOTYPES
+
+// ==================== LOCAL FUNCTIONS ====================
+
+LOCAL_C void ReadFileL(HBufC8*& aContent, const TDesC& aName)
+    {
+    TInt size = 0;
+    RFile file;
+
+    User::LeaveIfError(file.Open(GFs, aName, EFileRead));
+    User::LeaveIfError(file.Size(size));
+    aContent = HBufC8::NewLC(size);
+    TPtr8 ptr(aContent->Des());
+    User::LeaveIfError(file.Read(ptr, size));
+    CleanupStack::Pop(); //aContent
+    }
+
+
+// ==================== TEST FUNCTIONS =====================
+
+LOCAL_C TUint MDrmKeyStorage_ImportDataL()
+    {
+    MDrmKeyStorage* storage = NULL;
+    HBufC8* privateKey = NULL;
+    HBufC8* cert = NULL;
+    RArray<TPtrC8> certChain;
+    RPointerArray<HBufC8> buffers;
+    TFileName fileName;
+    TInt i;
+    CDir* dir;
+    TEntry entry;
+    TUint fileCount = 0;
+
+    storage = DrmKeyStorageNewL();
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    GFs.SetSessionPath(KInputDir);
+
+#else //RD_MULTIPLE_DRIVE
+
+    TFileName tempPath;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNumber );
+    GFs.DriveToChar( driveNumber, driveLetter );
+
+    tempPath.Format( KInputDir, (TUint)driveLetter );
+
+    GFs.SetSessionPath(tempPath);
+
+#endif
+
+    ReadFileL(privateKey, KDeviceKeyFileName);
+    ReadFileL(cert, KDeviceCertFileName);
+    buffers.Append(cert);
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    GFs.GetDir(KInputFilePattern, KEntryAttNormal, ESortByName, dir);
+
+#else //RD_MULTIPLE_DRIVE
+
+    tempPath.Format( KInputFilePattern, (TUint)driveLetter );
+
+    GFs.GetDir(tempPath, KEntryAttNormal, ESortByName, dir);
+
+#endif
+
+    for (i = 0; i < dir->Count(); i++)
+        {
+        ReadFileL(cert, (*dir)[i].iName);
+        buffers.Append(cert);
+        }
+    for (i = 0; i < buffers.Count(); i++)
+        {
+        certChain.Append(*(buffers[i]));
+        }
+    storage->ImportDataL(*privateKey, certChain);
+    delete storage;
+    delete privateKey;
+    fileCount = buffers.Count();
+    certChain.Close();
+    buffers.ResetAndDestroy();
+    buffers.Close();
+    return fileCount;
+    }
+
+
+TUint KeyStorage()
+    {
+    TUint result = 0;
+    result = GFs.Connect();
+    if( result != KErrNone )
+        {
+        return result;
+        }
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    GFs.MkDirAll(KFullLogDir);
+    GFs.MkDirAll(KPrivateRightsDir);
+    GFs.MkDirAll(KInputDir);
+
+#else //RD_MULTIPLE_DRIVE
+
+    TFileName tempPath;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    GFs.DriveToChar( driveNumber, driveLetter );
+
+    tempPath.Format( KFullLogDir, (TUint)driveLetter );
+    GFs.MkDirAll(tempPath);
+
+    tempPath.Format( KPrivateRightsDir, (TUint)driveLetter );
+    GFs.MkDirAll(tempPath);
+
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNumber );
+    GFs.DriveToChar( driveNumber, driveLetter );
+
+    tempPath.Format( KInputDir, (TUint)driveLetter );
+    GFs.MkDirAll(tempPath);
+
+#endif
+
+
+    result = GLog.Connect();
+    if( result != KErrNone )
+        {
+        GFs.Close();
+        return result;
+        }
+    GLog.CreateLog(KLogDir, KLogName, EFileLoggingModeOverwrite);
+    GLog.Write(_L("Start %D"));
+
+    TRAPD(err,result = MDrmKeyStorage_ImportDataL());
+
+    GLog.WriteFormat(_L("Result: %d"), err);
+    CHECK(err == KErrNone);
+    GLog.CloseLog();
+    GFs.Close();
+    return result;
+    }
+
+TUint KeyStorageFromZipL(const TDesC& aFileName, RFs& aFs)
+    {
+    RFile f;
+    CZipFile* file;
+    CZipFileMemberIterator* iter;
+    CZipFileMember* member;
+    MDrmKeyStorage* storage = NULL;
+    TInt err = KErrNone;
+    HBufC8* privateKey = NULL;
+    HBufC8* cert = NULL;
+    RArray<TPtrC8> certChain;
+    TInt numCerts;
+    TInt i;
+    RZipFileMemberReaderStream* data;
+    TPtr8 ptr(NULL, 0);
+    TFileName fileName;
+    RPointerArray<HBufC8> buffers;
+
+    storage = DrmKeyStorageNewL();
+
+    err = f.Open( aFs, aFileName, EFileShareReadersOrWriters | EFileRead );
+    if ( err == KErrInUse )
+        {
+        err = f.Open( aFs, aFileName, EFileShareAny | EFileRead );
+        if ( err == KErrInUse )
+            {
+            err = f.Open( aFs, aFileName, EFileShareReadersOnly| EFileRead );
+            }
+        }
+    User::LeaveIfError( err );
+
+    CleanupClosePushL<RFile>( f );
+    file = CZipFile::NewL( aFs, f );
+    CleanupStack::PushL( file );
+    iter = file->GetMembersL();
+    CleanupStack::PushL( iter );
+    member = iter->NextL();
+    numCerts = 0;
+    while ( member != NULL )
+        {
+        if (member->Name()->Left(11).CompareF(_L("SigningCert")) == 0)
+            {
+            numCerts++;
+            }
+        delete member;
+        member = iter->NextL();
+        }
+
+    member = file->CaseInsensitiveMemberL(_L("DeviceCert.der"));
+    cert = HBufC8::NewL(member->UncompressedSize());
+    buffers.Append(cert);
+    file->GetInputStreamL(member, data);
+    ptr.Set(cert->Des());
+    data->Read(ptr, member->UncompressedSize());
+    certChain.Append(ptr);
+    delete data;
+    delete member;
+    for (i = 0; i < numCerts; i++)
+        {
+        fileName.Copy(_L("SigningCert"));
+        if (i < 10)
+            {
+            fileName.Append(_L("0"));
+            }
+        fileName.AppendNum(i);
+        fileName.Append(_L(".der"));
+        member = file->CaseInsensitiveMemberL(fileName);
+        cert = HBufC8::NewL(member->UncompressedSize());
+        buffers.Append(cert);
+        file->GetInputStreamL(member, data);
+        ptr.Set(cert->Des());
+        data->Read(ptr, member->UncompressedSize());
+        certChain.Append(ptr);
+        delete data;
+        delete member;
+        }
+    member = file->CaseInsensitiveMemberL(_L("DevicePrivateKey.der"));
+    privateKey = HBufC8::NewL(member->UncompressedSize());
+    file->GetInputStreamL(member, data);
+    ptr.Set(privateKey->Des());
+    data->Read(ptr, member->UncompressedSize());
+    delete data;
+    delete member;
+
+    storage->ImportDataL(*privateKey, certChain);
+    delete privateKey;
+    certChain.Close();
+    buffers.ResetAndDestroy();
+
+    CleanupStack::PopAndDestroy(3);
+    delete storage;
+
+    numCerts++;
+    fileName.SetLength(0);
+    fileName.AppendNum(numCerts);
+    fileName.Append(_L(" keys imported"));
+    CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
+    informationNote->ExecuteLD(fileName);
+
+    return KErrNone;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmencryptor/src/Performance.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,860 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// INCLUDE FILES
+#include <caf/caf.h>
+#include <f32file.h>
+#include <s32strm.h>
+#include <s32file.h>
+#include <oma1dcfcreator.h>
+#include <drmmessageparser.h>
+#include <e32math.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "base64.h"
+#include "performance.h"
+#include "DRMEncryptor.hrh"
+
+_LIT(KLogDir, "DRM");
+_LIT(KLogName, "Performance.log");
+#include "flogger.h"
+#define LOG(string) \
+    RFileLogger::Write(KLogDir, KLogName, \
+        EFileLoggingModeAppend, string);
+#define LOG2(string, a) \
+    RFileLogger::WriteFormat(KLogDir, KLogName, \
+        EFileLoggingModeAppend, string, a);
+#define LOGHEX(buffer) \
+    RFileLogger::HexDump(KLogDir, KLogName, \
+        EFileLoggingModeAppend, _S(""), _S(""), \
+        buffer.Ptr(), buffer.Length());
+
+_LIT8(KMidiContent,
+"TVRoZAAAAAYAAQAGAHhNVHJrAAAAGQD/WAQEAhgIAP9ZAgAAAP9RAwehIAD/LwBN\n\
+VHJrAAAKsgD/IQEAALkHaQCZLmQAM2QAI2QOIwAAMwAALgAuM2QOMwAuKGQAM2QO\n\
+MwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuKGQAM2QOMwAAKAAu\n\
+M2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQOKAAAMwAuI2QAM2QO\n\
+MwAAIwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQOKAAAMwAuMWQAM2QO\n\
+MwAAMQAuLmQAM2QAI2QOIwAAMwAALgAuM2QOMwAuKGQAM2QOMwAAKAAuM2QOMwAu\n\
+I2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QO\n\
+MwAAIwAuI2QAM2QOMwAAIwAuMmQAM2QAKGQOKAAAMwAAMgAuMmQAI2QAM2QOMwAA\n\
+IwAAMgAuMGQAI2QAM2QOMwAAIwAAMAAuMGQAI2QAM2QOMwAAIwAAMAAuMmQAM2QA\n\
+KGQOKAAAMwAAMgAQMmQOMgAQMGQAM2QOMwAAMAAQLWQOLQAQMWQALmQAM2QAI2QO\n\
+IwAAMQAALgAAMwAuM2QOMwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAu\n\
+I2QAM2QOMwAAIwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QO\n\
+MwAAIwAuM2QAKGQOKAAAMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuI2QAM2QO\n\
+MwAAIwAuM2QAKGQOKAAAMwAuMWQAM2QOMwAAMQAuLmQAM2QAI2QOIwAAMwAALgAu\n\
+M2QOMwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAu\n\
+KGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQO\n\
+KAAAMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQO\n\
+KAAAMwAuMWQAM2QOMwAAMQAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuMmQAM2QA\n\
+KGQOKAAAMwAAMgAuMmQAI2QAM2QOMwAAIwAAMgAuMGQAI2QAM2QOMwAAIwAAMAAu\n\
+MGQAI2QAM2QOMwAAIwAAMAAuMmQAM2QAKGQOKAAAMwAAMgAQMmQOMgAQMGQAM2QO\n\
+MwAAMAAQLWQOLQAQMWQALmQAM2QAI2QOIwAAMQAALgAAMwAuM2QOMwAuKGQAM2QO\n\
+MwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuKGQAM2QOMwAAKAAu\n\
+M2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQOKAAAMwAuI2QAM2QO\n\
+MwAAIwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQOKAAAMwAuMWQAM2QO\n\
+MwAAMQAuLmQAM2QAI2QOIwAAMwAALgAuM2QOMwAuKGQAM2QOMwAAKAAuM2QOMwAu\n\
+I2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuKGQAM2QOMwAAKAAuM2QOMwAuMWQALmQA\n\
+M2QAI2QOIwAAMQAALgAAMwAuM2QOMwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QO\n\
+MwAAIwAuI2QAM2QOMwAAIwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAu\n\
+I2QAM2QOMwAAIwAuM2QAKGQOKAAAMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAu\n\
+I2QAM2QOMwAAIwAuM2QAKGQOKAAAMwAuMWQAM2QOMwAAMQAuLmQAM2QAI2QOIwAA\n\
+MwAALgAuM2QOMwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QO\n\
+MwAAIwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAu\n\
+M2QAKGQOKAAAMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAu\n\
+M2QAKGQOKAAAMwAuMWQAM2QOMwAAMQAuMWQALmQAM2QAI2QOIwAAMQAALgAAMwAu\n\
+M2QOMwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAu\n\
+KGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQO\n\
+KAAAMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQO\n\
+KAAAMwAuMWQAM2QOMwAAMQAuLmQAM2QAI2QOIwAAMwAALgAuM2QOMwAuKGQAM2QO\n\
+MwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuKGQAM2QOMwAAKAAu\n\
+M2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuMmQAM2QAKGQOKAAAMwAAMgAu\n\
+MmQAI2QAM2QOMwAAIwAAMgAuMGQAI2QAM2QOMwAAIwAAMAAuMGQAI2QAM2QOMwAA\n\
+IwAAMAAuMmQAM2QAKGQOKAAAMwAAMgAQMmQOMgAQMGQAM2QOMwAAMAAQLWQOLQAQ\n\
+MWQALmQAM2QAI2QOIwAAMQAALgAAMwAuM2QOMwAuKGQAM2QOMwAAKAAuM2QOMwAu\n\
+I2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QO\n\
+MwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQOKAAAMwAuI2QAM2QOMwAAIwAuI2QAM2QO\n\
+MwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQOKAAAMwAuMWQAM2QOMwAAMQAuLmQAM2QA\n\
+I2QOIwAAMwAALgAuM2QOMwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAu\n\
+I2QAM2QOMwAAIwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QO\n\
+MwAAIwAuM2QAKGQOKAAAMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuI2QAM2QO\n\
+MwAAIwAuM2QAKGQOKAAAMwAuMWQAM2QOMwAAMQAuI2QAM2QOMwAAIwAuI2QAM2QO\n\
+MwAAIwAuMmQAM2QAKGQOKAAAMwAAMgAuMmQAI2QAM2QOMwAAIwAAMgAuMGQAI2QA\n\
+M2QOMwAAIwAAMAAuMGQAI2QAM2QOMwAAIwAAMAAuMmQAM2QAKGQOKAAAMwAAMgAQ\n\
+MmQOMgAQMGQAM2QOMwAAMAAQLWQOLQAQMWQALmQAM2QAI2QOIwAAMQAALgAAMwAu\n\
+M2QOMwAuKGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAu\n\
+KGQAM2QOMwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQO\n\
+KAAAMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuM2QAKGQO\n\
+KAAAMwAuMWQAM2QOMwAAMQAuLmQAM2QAI2QOIwAAMwAALgAuM2QOMwAuKGQAM2QO\n\
+MwAAKAAuM2QOMwAuI2QAM2QOMwAAIwAuI2QAM2QOMwAAIwAuKGQAM2QOMwAAKAAu\n\
+M2QOMwAA/y8ATVRyawAABTMA/yEBAADAIwCwB2kAkCRkHSQAHyRkDiQALiRkHSQA\n\
+HyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQA\n\
+HyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQA\n\
+HyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQA\n\
+HyRkDiQALiRkHSQAHyRkDiQALiRkHSQAWyRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAHyRkDiQALiRkHSQAWyRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQA\n\
+HyRkDiQALiRkHSQAWyRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAHyRkDiQALitkHSsAHytkDisALitkHSsAHytkDisALitkHSsAHytkDisA\n\
+LitkHSsAHytkDisALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAHyRkDiQALilkHSkAHylkDikALilkHSkAHylkDikALilkHSkAHylkDikA\n\
+LilkHSkAHylkDikALitkHSsAHytkDisALitkHSsAHytkDisALitkHSsAHytkDisA\n\
+LitkHSsAHyRkDiQALilkHSkAHylkDikALilkHSkAHylkDikALilkHSkAHylkDikA\n\
+LilkHSkAHy1kDi0ALitkHSsAHytkDisALitkHSsAHytkDisALitkHSsAHytkDisA\n\
+LitkHSsAHytkDisALilkHSkAHylkDikALilkHSkAHylkDikALilkHSkAHylkDikA\n\
+LilkHSkAHylkDikALitkHSsAHytkDisALitkHSsAHytkDisALitkHSsAHytkDisA\n\
+LitkHSsAHytkDisALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LiRkHSQAWyRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQA\n\
+WyRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+LitkHSsAHytkDisALitkHSsAHytkDisALitkHSsAHytkDisALitkHSsAHytkDisA\n\
+LiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQALiRkHSQAHyRkDiQA\n\
+AP8vAE1UcmsAAAEeAP8hAQAAwQGOCJFTZABUZA5UAABTAAFPZABRZA5RAABPAAFM\n\
+ZABNZA5NAABMAAFIZABKZA5KAABIAAFFZABHZA5HAABFAAFBZABDZA5DAABBAAE+\n\
+ZABAZA5AAAA+AAE8ZA48AJ0JU2QAVGQOVAAAUwABT2QAUWQOUQAATwABTGQATWQO\n\
+TQAATAABSGQASmQOSgAASAABRWQAR2QORwAARQABQWQAQ2QOQwAAQQABPmQAQGQO\n\
+QAAAPgABPGQOPAC7CVNkAFRkDlQAAFMAAU9kAFFkDlEAAE8AAUxkAE1kDk0AAEwA\n\
+AUhkAEpkDkoAAEgAAUVkAEdkDkcAAEUAAUFkAENkDkMAAEEAAT5kAEBkDkAAAD4A\n\
+ATxkDjwAAP8vAE1UcmsAAAQ9AP8hAQAAwh4AsgdkjwCSTGQANGQAMGR3MAAANAAA\n\
+TAABNGQAMGQdMAAANAAfLmQPRmQsRgAALgABSmQANGQAL2Q7LwAANAAASgABSmQA\n\
+NGQAL2Q7LwAANAAASgA9SGQATGQAMGQANGR3NAAASAAATAAAMACCLS5kOy4AAS9k\n\
+Oy8AAUxkADBkADRkdzQAADAAAEwAATRkADBkHTAAADQAH0hkAC5kOy4AAEgAAVFk\n\
+ADlkADVkOzUAADkAAFEAAVBkADlkADVkOzUAADkAAFAAAUxkHUwAAU1kHU0AAVRk\n\
+AExkADdkADRkdzQAADcAAEwAgyRUAAFMZAA0ZAAwZHcwAAA0AABMAAE0ZAAwZB0w\n\
+AAA0AB8uZA9GZCxGAAAuAAFKZAA0ZAAvZDsvAAA0AABKAAFKZAA0ZAAvZDsvAAA0\n\
+AABKAD1IZABMZAAwZAA0ZHc0AABIAABMAAAwAIMlR2QAQ2QAO2QAN2R3NwAARwAA\n\
+QwAAOwABQ2QAR2QAO2QAN2QdNwAAQwAARwAAOwAfSmQAPmQ7PgAASgABSGQAPGR3\n\
+PAAASAABT2QAN2QAO2Q7OwAANwAATwA9VGSDX1QAATlkADVkdzUAADkAPUhkO0gA\n\
+AUdkd0cAPUVkO0UAAUdkd0cAgXEwZHcwAAE5ZAA1ZHc1AAA5AD1IZDtIAAFKZHdK\n\
+AD1IZDtIAAFHZDtHAIMpOWQANWR3NQAAOQA9SGQ7SAABSmR3SgA9SGQ4NGQAN2QA\n\
+T2QATGQDSAA4TwAANAAANwAATAA9NGQAN2QAT2QATGQ7TAAANAAANwAATwA9MmQA\n\
+SmQ7SgAAMgABMGQASGQ7SAAAMAABL2QAR2Q7RwAALwABMGQASGQ7MACHQEgAAUxk\n\
+ADRkADBkdzAAADQAAEwAATRkADBkHTAAADQAHy5kD0ZkLEYAAC4AAUpkADRkAC9k\n\
+Oy8AADQAAEoAAUpkADRkAC9kOy8AADQAAEoAPUhkAExkADBkADRkdzQAAEgAAEwA\n\
+ADAAgi0uZDsuAAEvZDsvAAFMZAAwZAA0ZHc0AAAwAABMAAE0ZAAwZB0wAAA0AB9I\n\
+ZAAuZDsuAABIAAFRZAA5ZAA1ZDs1AAA5AABRAAFQZAA5ZAA1ZDs1AAA5AABQAAFM\n\
+ZB1MAAFNZB1NAAFUZABMZAA3ZAA0ZHc0AAA3AABMAIMkVAABTGQANGQAMGR3MAAA\n\
+NAAATAABNGQAMGQdMAAANAAfLmQPRmQsRgAALgABSmQANGQAL2Q7LwAANAAASgAB\n\
+SmQANGQAL2Q7LwAANAAASgA9SGQATGQAMGQANGR3NAAASAAATAAAMACDJUdkAENk\n\
+ADtkADdkdzcAAEcAAEMAADsAAUNkAEdkADtkADdkHTcAAEMAAEcAADsAH0pkAD5k\n\
+Oz4AAEoAAUhkADxkdzwAAEgAAU9kADdkADtkOzsAADcAAE8APVRkg19UAAD/LwBN\n\
+VHJrAAAAWAD/IQEAAMNQALMHeK0AkzVkg181AAE3ZINfNwABNWSDXzUAATdkg183\n\
+AAE1ZINfNQABN2SDXzcAATBkhz8wAAEwZJY/MAABN2SDXzcAATBkg18wAAD/LwA=\n");
+
+_LIT8(KContentHeader, "--boundary\r\nContent-type: audio/midi\r\nContent-Transfer-Encoding: base64\r\n\r\n");
+_LIT8(KCdStartEndHeader,
+"--boundary\r\n\
+Content-Type: application/vnd.oma.drm.rights+xml\r\n\
+Content-Transfer-Encoding: binary\r\n\
+\r\n\
+<o-ex:rights\
+   xmlns:o-ex=\"http://odrl.net/1.1/ODRL-EX\"\
+   xmlns:o-dd=\"http://odrl.net/1.1/ODRL-DD\"\
+   xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#/\"\
+>\
+<o-ex:context><o-dd:version>1.0</o-dd:version></o-ex:context>\
+<o-ex:agreement><o-ex:asset><o-ex:context>\
+<o-dd:uid>cid:content0000@localhost</o-dd:uid>\
+</o-ex:context></o-ex:asset>\
+<o-ex:permission><o-dd:play><o-ex:constraint>\
+<o-dd:datetime>\
+<o-dd:end>2020-01-01T00:00:00</o-dd:end><o-dd:start>1980-01-01T00:00:00</o-dd:start>\
+</o-dd:datetime>\
+</o-ex:constraint></o-dd:play></o-ex:permission>\
+</o-ex:agreement></o-ex:rights>\r\n\
+\r\n");
+_LIT8(KCdCountHeader,
+"--boundary\r\n\
+Content-Type: application/vnd.oma.drm.rights+xml\r\n\
+Content-Transfer-Encoding: binary\r\n\
+\r\n\
+<o-ex:rights\
+   xmlns:o-ex=\"http://odrl.net/1.1/ODRL-EX\"\
+   xmlns:o-dd=\"http://odrl.net/1.1/ODRL-DD\"\
+   xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#/\"\
+>\
+<o-ex:context><o-dd:version>1.0</o-dd:version></o-ex:context>\
+<o-ex:agreement><o-ex:asset><o-ex:context>\
+<o-dd:uid>cid:content0001@localhost</o-dd:uid>\
+</o-ex:context></o-ex:asset>\
+<o-ex:permission><o-dd:play><o-ex:constraint>\
+<o-dd:count>1000000</o-dd:count>\
+</o-ex:constraint></o-dd:play></o-ex:permission>\
+</o-ex:agreement></o-ex:rights>\r\n\
+\r\n");
+_LIT8(KFooter, "\r\n--boundary--\r\n");
+
+const TInt KFileNumber = 50;
+const TInt KOpenCount = 10;
+
+#ifdef __WINS__
+_LIT(KFilesDir, "c:\\data\\others\\DrmTest\\");
+#else
+#ifdef RD_MULTIPLE_DRIVE
+_LIT(KFilesDir, "%c:\\others\\DrmTest\\");
+#else
+_LIT(KFilesDir, "e:\\others\\DrmTest\\");
+#endif
+#endif
+_LIT(KFlFileNameBase, "-fl");
+_LIT(KPlainFileNameBase, "-plain.mid");
+_LIT(KCdStartEndFileNameBase, "-cd-se");
+_LIT(KCdCountFileNameBase, "-cd-count");
+_LIT(KFileSuffix, ".dcf");
+_LIT(KBigFilePlain, "bigfile.txt");
+_LIT(KBigFileEncrypted, "bigfile.dcf");
+
+enum ETestFileType
+    {
+    EFl,
+    ECdStartEnd,
+    ECdCount,
+    EPlain
+    };
+
+void SetupDirectoryL(const TDesC& aDir)
+    {
+    RFs fs;
+    TFileName fileName;
+    CFileMan* fm = NULL;
+
+    LOG(_L("SetupDirectoryL"));
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    fm = CFileMan::NewL(fs);
+    CleanupStack::PushL(fm);
+    fm->RmDir(aDir);
+    fs.MkDirAll(aDir);
+    CleanupStack::PopAndDestroy(2); // fm, fs
+    }
+
+void CreateFileL(RFs& aFs, CDRMMessageParser* aParser, ETestFileType aType, TInt aNumber)
+    {
+    TFileName fileName;
+    RFileWriteStream out;
+    HBufC8* buffer = NULL;
+
+    fileName.AppendNum(aNumber);
+    switch (aType)
+        {
+        case EPlain:
+            fileName.Append(KPlainFileNameBase);
+            break;
+        case EFl:
+            fileName.Append(KFlFileNameBase);
+            fileName.Append(KFileSuffix);
+            break;
+        case ECdStartEnd:
+            fileName.Append(KCdStartEndFileNameBase);
+            fileName.Append(KFileSuffix);
+            break;
+        case ECdCount:
+            fileName.Append(KCdCountFileNameBase);
+            fileName.Append(KFileSuffix);
+            break;
+        }
+    out.Create(aFs, fileName, EFileWrite);
+    CleanupClosePushL(out);
+    if (aType != EPlain)
+        {
+        aParser->InitializeMessageParserL(out);
+        switch (aType)
+            {
+            case ECdStartEnd:
+                aParser->ProcessMessageDataL(KCdStartEndHeader);
+                break;
+            case ECdCount:
+                aParser->ProcessMessageDataL(KCdCountHeader);
+                break;
+            }
+        aParser->ProcessMessageDataL(KContentHeader);
+        aParser->ProcessMessageDataL(KMidiContent);
+        aParser->ProcessMessageDataL(KFooter);
+        aParser->FinalizeMessageParserL();
+        }
+    else
+        {
+        buffer = Base64DecodeL(KMidiContent);
+        CleanupStack::PushL(buffer);
+        out.WriteL(*buffer);
+        CleanupStack::PopAndDestroy(); // buffer
+        }
+    CleanupStack::PopAndDestroy(); // out
+    }
+
+void GenerateFilesL(const TDesC& aDir, TInt aCount)
+    {
+    CDRMMessageParser* parser = NULL;
+    TInt i;
+    RFs fs;
+
+    LOG(_L("GenerateFilesL"));
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    fs.SetSessionPath(aDir);
+    parser = CDRMMessageParser::NewL();
+    CleanupStack::PushL(parser);
+    for (i = 0; i < aCount; i++)
+        {
+        CreateFileL(fs, parser, EPlain, i);
+        CreateFileL(fs, parser, EFl, i);
+        CreateFileL(fs, parser, ECdStartEnd, i);
+        CreateFileL(fs, parser, ECdCount, i);
+        }
+    CleanupStack::PopAndDestroy(2); // parser, fs
+    }
+
+
+void GenerateBigFilesL(const TDesC& aDir)
+    {
+    RFs fs;
+    RFileWriteStream out;
+    COma1DcfCreator* creator = NULL;
+    HBufC8* buffer = NULL;
+    TPtr8 ptr(NULL, 0);
+    TInt i;
+
+    LOG(_L("GenerateBigFilesL"));
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    fs.SetSessionPath(aDir);
+    creator = COma1DcfCreator::NewL();
+    CleanupStack::PushL(creator);
+
+    buffer = HBufC8::NewMax(50 * 1024);
+    CleanupStack::PushL(buffer);
+    ptr.Set(buffer->Des());
+    ptr.Fill('0');
+
+    LOG(_L("Creating plain file"));
+    fs.Delete(KBigFilePlain);
+    out.Create(fs, KBigFilePlain, EFileWrite);
+    CleanupClosePushL(out);
+    for (i = 0; i < 40; i++)
+        {
+        out.WriteL(ptr);
+        }
+    CleanupStack::PopAndDestroy(); // out
+
+    LOG(_L("Creating encrypted file"));
+    fs.Delete(KBigFileEncrypted);
+    out.Create(fs, KBigFileEncrypted, EFileWrite);
+    CleanupClosePushL(out);
+    creator->EncryptInitializeL(out, _L8("text/plain"), NULL);
+    for (i = 0; i < 40; i++)
+        {
+        creator->EncryptUpdateL(ptr);
+        }
+    creator->EncryptFinalizeL();
+    CleanupStack::PopAndDestroy(4); // out, creator, buffer, fs
+    }
+
+
+void TestDecryptionSpeedL(const TDesC& aDir, TBool aRandom, TInt aType)
+    {
+    TInt i;
+    TInt j;
+    HBufC8* buffer = NULL;
+    RFs fs;
+    TPtr8 ptr(NULL, 0);
+    CData* data = NULL;
+    RFile file;
+    TInt blockSize[5] = {64, 512, 1024, 2048, 4096};
+    TFileName fileName;
+    TInt pos = 0;
+
+    LOG(_L("TestDecryptionSpeedL"));
+    if (aRandom)
+        {
+        LOG(_L("Random Reading"));
+        }
+    else
+        {
+        LOG(_L("Sequential Reading"));
+        }
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    fs.SetSessionPath(aDir);
+
+    buffer = HBufC8::NewL(4096);
+    CleanupStack::PushL(buffer);
+    ptr.Set(buffer->Des());
+    for (j = 0; j < 5; j++)
+        {
+        LOG2(_L("Block size: %d"), blockSize[j]);
+
+        switch (aType)
+            {
+            case 1: //Plain file with RFile
+                {
+                LOG(_L("Reading plain file (RFile)"));
+                User::LeaveIfError(file.Open(fs, KBigFilePlain, EFileRead));
+                CleanupClosePushL(file);
+                for (i = 0; i < 40 * 50 * 1024 / blockSize[j]; i++)
+                    {
+                    if (aRandom)
+                        {
+                        pos = Abs(Math::Random() % (40 * 50 * 1024 - 2 * blockSize[j]));
+                        file.Seek(ESeekStart, pos);
+                        }
+                    file.Read(ptr, blockSize[j]);
+                    }
+                CleanupStack::PopAndDestroy(); // file
+                LOG2(_L("Reading plain file (RFile) done (%d blocks)"), i);
+                }
+                break;
+            case 2: //Plain file with CAF
+                {
+                LOG(_L("Reading plain file (CAF)"));
+                fileName.Copy(aDir);
+                fileName.Append(KBigFilePlain);
+                data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+                EPeek, EContentShareReadOnly);
+                CleanupStack::PushL(data);
+                for (i = 0; i < 40 * 50 * 1024 / blockSize[j]; i++)
+                    {
+                    if (aRandom)
+                        {
+                        pos = Abs(Math::Random() % (40 * 50 * 1024 - 2 * blockSize[j]));
+                        data->Seek(ESeekStart, pos);
+                        }
+                    data->Read(ptr, blockSize[j]);
+                    }
+                CleanupStack::PopAndDestroy(); // data
+                LOG2(_L("Reading plain file (CAF) done (%d blocks)"), i);
+                }
+                break;
+            case 3: //DRM Protected on server side
+                {
+                LOG(_L("Reading encrypted file (server decryption)"));
+                fileName.Copy(aDir);
+                fileName.Append(KBigFileEncrypted);
+                __UHEAP_MARK;
+                data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+                EPeek, EContentShareReadOnly);
+                CleanupStack::PushL(data);
+                data->ExecuteIntent(EView); //!!!!!!!!!!!!!
+                for (i = 0; i < 40 * 50 * 1024 / blockSize[j]; i++)
+                    {
+                    if (aRandom)
+                        {
+                        pos = Abs(Math::Random() % (40 * 50 * 1024 - 2 * blockSize[j]));
+                        data->Seek(ESeekStart, pos);
+                        }
+                    data->Read(ptr, blockSize[j]);
+                    }
+
+                CleanupStack::PopAndDestroy(); // data
+                __UHEAP_MARKEND;
+                LOG2(_L("Reading encrypted file done (%d blocks)"), i);
+
+                // DRM protected on client side
+                LOG(_L("Reading encrypted file (client decryption)"));
+                fileName.Copy(aDir);
+                fileName.Append(KBigFileEncrypted);
+                __UHEAP_MARK;
+                data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+                    EPeek, EContentShareReadOnly);
+                CleanupStack::PushL(data);
+                data->ExecuteIntent(EView);
+                for (i = 0; i < 40 * 50 * 1024 / blockSize[j]; i++)
+                    {
+                    if (aRandom)
+                        {
+                        pos = Math::Random() % (40 * 50 * 1024 - blockSize[j]);
+                        data->Seek(ESeekStart, pos);
+                        }
+                    data->Read(ptr, blockSize[j]);
+                    }
+                CleanupStack::PopAndDestroy(); // data
+                __UHEAP_MARKEND;
+                LOG2(_L("Reading encrypted file done (%d blocks)"), i);
+                }
+                break;
+            }
+        }
+    CleanupStack::PopAndDestroy(); // buffer
+
+    CleanupStack::PopAndDestroy(); // fs
+    }
+
+void TestFileOpeningSpeedL(const TDesC& aDir, TInt aType)
+    {
+    TFileName fileName;
+    TInt j;
+    TInt i;
+    CData* data = NULL;
+    RFs fs;
+    RFile file;
+
+    LOG2(_L("TestFileOpeningSpeedL (%d files)"), KFileNumber * KOpenCount);
+
+    switch( aType)
+        {
+        case 1: // With RFile
+            {
+            LOG(_L("Opening plain files (with RFs::Connect)"));
+            for (i = 0; i < KFileNumber; i++)
+                {
+                fileName.Copy(aDir);
+                fileName.AppendNum(i);
+                fileName.Append(KFlFileNameBase);
+                fileName.Append(KFileSuffix);
+                for (j = 0; j < KOpenCount; j++)
+                    {
+                    User::LeaveIfError(fs.Connect());
+                    CleanupClosePushL(fs);
+                    User::LeaveIfError(file.Open(fs, fileName, EFileRead));
+                    file.Close();
+                    CleanupStack::PopAndDestroy();
+                    }
+                }
+            LOG(_L("Opening plain files done"));
+
+            LOG(_L("Opening plain files (without RFs::Connect)"));
+            User::LeaveIfError(fs.Connect());
+            CleanupClosePushL(fs);
+            for (i = 0; i < KFileNumber; i++)
+                {
+                fileName.Copy(aDir);
+                fileName.AppendNum(i);
+                fileName.Append(KFlFileNameBase);
+                fileName.Append(KFileSuffix);
+                for (j = 0; j < KOpenCount; j++)
+                    {
+                    User::LeaveIfError(file.Open(fs, fileName, EFileRead));
+                    file.Close();
+                    }
+                }
+            CleanupStack::PopAndDestroy();
+            LOG(_L("Opening plain files done"));
+            }
+            break;
+
+        case 2: //With CAF
+            {
+
+            LOG(_L("Opening plain files (CAF)"));
+            for (i = 0; i < KFileNumber; i++)
+                {
+                fileName.Copy(aDir);
+                fileName.AppendNum(i);
+                fileName.Append(KPlainFileNameBase);
+                for (j = 0; j < KOpenCount; j++)
+                    {
+                    data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+                    EPlay, EContentShareReadOnly);
+                    delete data;
+                    }
+                }
+
+
+            LOG(_L("Opening plain files done"));
+
+            User::After(3000000);
+
+            LOG(_L("Opening plain files CAF with Filehandle"));
+
+            User::LeaveIfError(fs.Connect());
+            CleanupClosePushL(fs);
+            for (i = 0; i < KFileNumber; i++)
+                {
+                fileName.Copy(aDir);
+                fileName.AppendNum(i);
+                fileName.Append(KPlainFileNameBase);
+                for (j = 0; j < KOpenCount; j++)
+                    {
+                    User::LeaveIfError(file.Open(fs, fileName, EFileRead | EFileShareAny));
+                    CleanupClosePushL(file);
+                    data = CData::NewL(file, KDefaultContentObject, EPlay );
+                    delete data;
+                    CleanupStack::PopAndDestroy(); // file
+                    }
+                }
+            CleanupStack::PopAndDestroy();
+
+
+            LOG(_L("Opening plain files (CAF with filehandle) done"));
+            }
+            break;
+
+        case 3: //With DRM
+            {
+
+            LOG(_L("Opening FL files"));
+            for (i = 0; i < KFileNumber; i++)
+                {
+                fileName.Copy(aDir);
+                fileName.AppendNum(i);
+                fileName.Append(KFlFileNameBase);
+                fileName.Append(KFileSuffix);
+                for (j = 0; j < KOpenCount; j++)
+                    {
+                    data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+                    EPlay, EContentShareReadOnly);
+                    delete data;
+                    }
+                }
+            LOG(_L("Opening FL files done"));
+
+            User::After(3000000);
+
+            LOG(_L("Opening DRM FL files (CAF with filehandle)"));
+
+            User::LeaveIfError(fs.Connect());
+            CleanupClosePushL(fs);
+            for (i = 0; i < KFileNumber; i++)
+                {
+                fileName.Copy(aDir);
+                fileName.AppendNum(i);
+                fileName.Append(KFlFileNameBase);
+                fileName.Append(KFileSuffix);
+                for (j = 0; j < KOpenCount; j++)
+                    {
+                    User::LeaveIfError(file.Open(fs, fileName, EFileRead | EFileShareAny));
+                    CleanupClosePushL(file);
+                    data = CData::NewL(file, KDefaultContentObject, EPlay );
+                    delete data;
+                    CleanupStack::PopAndDestroy();
+                    }
+                }
+            CleanupStack::PopAndDestroy();
+
+            LOG(_L("Opening DRM FL files (CAF with filehandle) done"));
+
+            User::After(3000000);
+
+            LOG(_L("Opening CD (Start/End) files"));
+            for (i = 0; i < KFileNumber; i++)
+                {
+                fileName.Copy(aDir);
+                fileName.AppendNum(i);
+                fileName.Append(KCdStartEndFileNameBase);
+                fileName.Append(KFileSuffix);
+                for (j = 0; j < KOpenCount; j++)
+                    {
+                    data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+                    EPlay, EContentShareReadOnly);
+                    delete data;
+                    }
+                }
+            LOG(_L("Opening CD (Start/End) files done"));
+
+            User::After(3000000);
+
+            LOG(_L("Opening CD (Count) files"));
+            for (i = 0; i < KFileNumber; i++)
+                {
+                fileName.Copy(aDir);
+                fileName.AppendNum(i);
+                fileName.Append(KCdCountFileNameBase);
+                fileName.Append(KFileSuffix);
+                for (j = 0; j < KOpenCount; j++)
+                    {
+                    data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+                    EPlay, EContentShareReadOnly);
+                    delete data;
+                    }
+                }
+            LOG(_L("Opening CD (Count) files done"));
+
+            }
+            break;
+        case 4:
+            {
+            LOG(_L("Opening CD (Count) files with Consumption"));
+            for (i = 0; i < KFileNumber; i++)
+                {
+                fileName.Copy(aDir);
+                fileName.AppendNum(i);
+                fileName.Append(KCdCountFileNameBase);
+                fileName.Append(KFileSuffix);
+                for (j = 0; j < KOpenCount; j++)
+                    {
+                    data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+                    EPlay, EContentShareReadOnly);
+                    data->ExecuteIntent(EPlay);
+                    delete data;
+                    }
+                }
+            LOG(_L("Opening CD (Count) files with Consumption done"));
+            }
+            break;
+        }
+    }
+void TestDatabasePerformanceL()
+    {
+    LOG(_L("TestDatabasePerformanceL"));
+    }
+
+void TestPerformanceL(TInt aCommand)
+    {
+    LOG(_L("TestPerformanceL"));
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    switch(aCommand)
+    {
+    case EDRM_API_SubMenuId_1:        // Generate files
+        {
+        SetupDirectoryL(KFilesDir);
+        GenerateFilesL(KFilesDir, KFileNumber);
+        GenerateBigFilesL(KFilesDir);
+        break;
+        }
+    case EDRM_API_SubMenuId_1_1:        // RFile opening
+        {
+        TestFileOpeningSpeedL(KFilesDir, 1);
+        break;
+        }
+    case EDRM_API_SubMenuId_1_2:        // RFile Sequential
+        {
+        TestDecryptionSpeedL(KFilesDir, EFalse, 1);
+        break;
+        }
+    case EDRM_API_SubMenuId_1_3:        // RFile Random
+        {
+        TestDecryptionSpeedL(KFilesDir, ETrue, 1);
+        break;
+        }
+    case EDRM_API_SubMenuId_2_1:        // CAF File Opening
+        {
+        TestFileOpeningSpeedL(KFilesDir, 2);
+        break;
+        }
+    case EDRM_API_SubMenuId_2_2:        // CAF Sequential
+        {
+        TestDecryptionSpeedL(KFilesDir, EFalse, 2);
+        break;
+        }
+    case EDRM_API_SubMenuId_2_3:        // CAF Random
+        {
+        TestDecryptionSpeedL(KFilesDir, ETrue, 2);
+        break;
+        }
+    case EDRM_API_SubMenuId_3_1_1:        // DRM file opening
+        {
+        TestFileOpeningSpeedL(KFilesDir, 3);
+        break;
+        }
+    case EDRM_API_SubMenuId_3_1_2:        // DRM file opening with consume
+        {
+        TestFileOpeningSpeedL(KFilesDir, 4);
+        break;
+        }
+    case EDRM_API_SubMenuId_3_1_3:    // Sequential DRM
+        {
+        TestDecryptionSpeedL(KFilesDir, EFalse, 3);
+        break;
+        }
+    case EDRM_API_SubMenuId_3_1_4:    // Random DRM
+        {
+        TestDecryptionSpeedL(KFilesDir, ETrue, 3);
+        break;
+        }
+    }
+
+#else //RD_MULTIPLE_DRIVE
+
+    RFs fs;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNumber );
+
+    User::LeaveIfError( fs.Connect() );
+    fs.DriveToChar( driveNumber, driveLetter );
+    fs.Close();
+
+    TFileName filesDir;
+    filesDir.Format( KFilesDir, (TUint)driveLetter );
+
+    switch(aCommand)
+    {
+    case EDRM_API_SubMenuId_1:        // Generate files
+        {
+        SetupDirectoryL(filesDir);
+        GenerateFilesL(filesDir, KFileNumber);
+        GenerateBigFilesL(filesDir);
+        break;
+        }
+    case EDRM_API_SubMenuId_1_1:        // RFile opening
+        {
+        TestFileOpeningSpeedL(filesDir, 1);
+        break;
+        }
+    case EDRM_API_SubMenuId_1_2:        // RFile Sequential
+        {
+        TestDecryptionSpeedL(filesDir, EFalse, 1);
+        break;
+        }
+    case EDRM_API_SubMenuId_1_3:        // RFile Random
+        {
+        TestDecryptionSpeedL(filesDir, ETrue, 1);
+        break;
+        }
+    case EDRM_API_SubMenuId_2_1:        // CAF File Opening
+        {
+        TestFileOpeningSpeedL(filesDir, 2);
+        break;
+        }
+    case EDRM_API_SubMenuId_2_2:        // CAF Sequential
+        {
+        TestDecryptionSpeedL(filesDir, EFalse, 2);
+        break;
+        }
+    case EDRM_API_SubMenuId_2_3:        // CAF Random
+        {
+        TestDecryptionSpeedL(filesDir, ETrue, 2);
+        break;
+        }
+    case EDRM_API_SubMenuId_3_1_1:        // DRM file opening
+        {
+        TestFileOpeningSpeedL(filesDir, 3);
+        break;
+        }
+    case EDRM_API_SubMenuId_3_1_2:        // DRM file opening with consume
+        {
+        TestFileOpeningSpeedL(filesDir, 4);
+        break;
+        }
+    case EDRM_API_SubMenuId_3_1_3:    // Sequential DRM
+        {
+        TestDecryptionSpeedL(filesDir, EFalse, 3);
+        break;
+        }
+    case EDRM_API_SubMenuId_3_1_4:    // Random DRM
+        {
+        TestDecryptionSpeedL(filesDir, ETrue, 3);
+        break;
+        }
+    }
+
+#endif
+
+    //TestDatabasePerformanceL();
+    }
Binary file commondrm/drmrightsmanagerui/cenrep/keys_drmrightsmanager.xls has changed
Binary file commondrm/drmrightsmanagerui/conf/drmrightsmanager.confml has changed
Binary file commondrm/drmrightsmanagerui/conf/drmrightsmanager_102750B1.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/data/DRMRightsManager.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,268 @@
+/*
+* Copyright (c) 2003 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file contains all the resources for the DRMRightsManager.
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME  DRMR // 4 letter ID
+
+
+//  INCLUDES
+
+#include <eikon.rh>
+#include <drmrightsmanager.loc>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.loc>
+#include <appinfo.rh>
+
+#include <avkon.mbg>
+
+#include <data_caging_paths_strings.hrh>
+
+#include <drmrightsmanager.mbg>
+
+#include "DRMRightsManager.hrh"
+
+// CONSTANTS
+
+#ifdef __SCALABLE_ICONS
+
+#define KDRMBitmap "Z:"APP_BITMAP_DIR"\\DRMRightsManager.mif"
+
+#else
+
+#define KDRMBitmap "Z:"APP_BITMAP_DIR"\\DRMRightsManager.mbm"
+
+#endif //__SCALABLE_ICONS
+
+
+//  RESOURCE DEFINITIONS
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf="DRMRightsManager"; }
+
+RESOURCE EIK_APP_INFO
+    {
+    }
+
+
+//----------------------------------------------------
+//
+//    r_drmui_localisable_app_info
+//    Localisable application info
+//
+//----------------------------------------------------
+//
+RESOURCE LOCALISABLE_APP_INFO r_drmui_localisable_app_info
+    {
+    short_caption = qtn_drm_mgr;
+    caption_and_icon =
+    CAPTION_AND_ICON_INFO
+        {
+        caption = qtn_drm_mgr;
+
+#ifdef __SCALABLE_ICONS
+        number_of_icons = 1;
+
+        icon_file = "Z:"APP_BITMAP_DIR"\\DRMRightsManager_aif.mif";
+
+#else
+        number_of_icons = 2;
+
+        icon_file = "Z:"APP_BITMAP_DIR"\\DRMRightsManager_aif.mbm";
+
+#endif  // __SCALABLE_ICONS
+        };
+    }
+
+//----------------------------------------------------
+//
+//    r_drmrightsmanager_detailsview
+//    Definition of DetailsView
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_drmrightsmanager_detailsview
+    {
+    cba=R_AVKON_SOFTKEYS_OK_EMPTY__OK;
+    }
+
+//----------------------------------------------------
+//
+//    r_waitnote
+//    WaitNote used during opening and refreshing of the RightsObjects
+//
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_waitnote
+    {
+    flags = EEikDialogFlagWait | EAknWaitNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EDRMRightsMgrCtrlIdWaitNote;
+            control= AVKON_NOTE
+                {
+                layout = EWaitLayout;
+                singular_label = qtn_gen_note_opening;
+                animation = R_QGN_GRAF_WAIT_BAR_ANIM;
+                };
+          }
+        };
+    }
+
+//----------------------------------------------------
+//
+//    r_drm_confirmation_query
+//    ConfirmationQuery dialog
+//
+//----------------------------------------------------
+//
+RESOURCE DIALOG r_drm_confirmation_query
+    {
+    flags = EGeneralQueryFlags;
+    buttons = R_AVKON_SOFTKEYS_YES_NO__YES;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtQuery;
+            id = EGeneralQuery;
+            control = AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                };
+            }
+        };
+    }
+
+//  Localized strings definitions
+
+RESOURCE TBUF r_qtn_drm_mgr_query_restart   { buf = qtn_drm_mgr_query_restart; }
+RESOURCE TBUF r_qtn_drm_mgr_note_ro_removed { buf = qtn_drm_mgr_note_ro_removed; }
+
+RESOURCE TBUF r_qtn_drm_mgr_det_stat        { buf = qtn_drm_mgr_det_stat;    }
+RESOURCE TBUF r_qtn_drm_mgr_det_valid       { buf = qtn_drm_mgr_det_valid;   }
+RESOURCE TBUF r_qtn_drm_mgr_det_exp         { buf = qtn_drm_mgr_det_exp;     }
+RESOURCE TBUF r_qtn_drm_mgr_det_cip         { buf = qtn_drm_mgr_det_cip;     }
+RESOURCE TBUF r_qtn_drm_mgr_det_yes         { buf = qtn_drm_mgr_det_yes;     }
+RESOURCE TBUF r_qtn_drm_mgr_det_no          { buf = qtn_drm_mgr_det_no;      }
+RESOURCE TBUF r_qtn_drm_mgr_det_cs          { buf = qtn_drm_mgr_det_cs;      }
+RESOURCE TBUF r_qtn_drm_mgr_det_allowed     { buf = qtn_drm_mgr_det_allowed; }
+RESOURCE TBUF r_qtn_drm_mgr_det_forbid      { buf = qtn_drm_mgr_det_forbid;  }
+
+RESOURCE TBUF r_qtn_drm_mgr_det_unlimited   { buf = qtn_drm_mgr_det_unlimited; }
+RESOURCE TBUF r_qtn_drm_mgr_det_1_count     { buf = qtn_drm_mgr_det_1_count; }
+RESOURCE TBUF r_qtn_drm_mgr_det_n_counts    { buf = qtn_drm_mgr_det_n_counts; }
+RESOURCE TBUF r_qtn_drm_mgr_det_not_act     { buf = qtn_drm_mgr_det_not_act; }
+RESOURCE TBUF r_qtn_drm_mgr_det_inter       { buf = qtn_drm_mgr_det_inter; }
+RESOURCE TBUF r_qtn_drm_mgr_det_inter_two   { buf = qtn_drm_mgr_det_inter_two; }
+
+RESOURCE TBUF r_qtn_drm_mgr_det_full_x      { buf = qtn_drm_mgr_det_full_x; }
+RESOURCE TBUF r_qtn_drm_mgr_det_utl_x       { buf = qtn_drm_mgr_det_utl_x; }
+RESOURCE TBUF r_qtn_drm_mgr_det_uts_x       { buf = qtn_drm_mgr_det_uts_x; }
+RESOURCE TBUF r_qtn_drm_mgr_det_udl_x       { buf = qtn_drm_mgr_det_udl_x; }
+RESOURCE TBUF r_qtn_drm_mgr_det_rvf_x       { buf = qtn_drm_mgr_det_rvf_x; }
+RESOURCE TBUF r_qtn_drm_mgr_det_rvt_x       { buf = qtn_drm_mgr_det_rvt_x; }
+
+RESOURCE TBUF r_qtn_drm_mgr_det2_play       { buf = qtn_drm_mgr_det2_play; }
+RESOURCE TBUF r_qtn_drm_mgr_det2_display    { buf = qtn_drm_mgr_det2_display; }
+RESOURCE TBUF r_qtn_drm_mgr_det2_execute    { buf = qtn_drm_mgr_det2_execute; }
+RESOURCE TBUF r_qtn_drm_mgr_det2_print      { buf = qtn_drm_mgr_det2_print; }
+
+RESOURCE TBUF r_qtn_drm_nbr_of_years_one        { buf = qtn_drm_nbr_of_years_one; }
+RESOURCE TBUF r_qtn_drm_nbr_of_years_one_final  { buf = qtn_drm_nbr_of_years_one_final; }
+RESOURCE TBUF r_qtn_drm_nbr_of_years_two_four   { buf = qtn_drm_nbr_of_years_two_four; }
+RESOURCE TBUF r_qtn_drm_nbr_of_years_five_zero  { buf = qtn_drm_nbr_of_years_five_zero; }
+RESOURCE TBUF r_qtn_drm_nbr_of_months_one       { buf = qtn_drm_nbr_of_months_one; }
+RESOURCE TBUF r_qtn_drm_nbr_of_months_two_four  { buf = qtn_drm_nbr_of_months_two_four; }
+RESOURCE TBUF r_qtn_drm_nbr_of_months_five_zero { buf = qtn_drm_nbr_of_months_five_zero; }
+RESOURCE TBUF r_qtn_drm_nbr_of_days_one         { buf = qtn_drm_nbr_of_days_one; }
+RESOURCE TBUF r_qtn_drm_nbr_of_days_one_final   { buf = qtn_drm_nbr_of_days_one_final; }
+RESOURCE TBUF r_qtn_drm_nbr_of_days_two_four    { buf = qtn_drm_nbr_of_days_two_four; }
+RESOURCE TBUF r_qtn_drm_nbr_of_days_five_zero   { buf = qtn_drm_nbr_of_days_five_zero; }
+RESOURCE TBUF r_qtn_drm_nbr_of_hours_one        { buf = qtn_drm_nbr_of_hours_one; }
+RESOURCE TBUF r_qtn_drm_nbr_of_hours_one_final  { buf = qtn_drm_nbr_of_hours_one_final; }
+RESOURCE TBUF r_qtn_drm_nbr_of_hours_two_four   { buf = qtn_drm_nbr_of_hours_two_four; }
+RESOURCE TBUF r_qtn_drm_nbr_of_hours_five_zero  { buf = qtn_drm_nbr_of_hours_five_zero; }
+RESOURCE TBUF r_qtn_drm_nbr_of_mins_one         { buf = qtn_drm_nbr_of_mins_one; }
+RESOURCE TBUF r_qtn_drm_nbr_of_mins_one_final   { buf = qtn_drm_nbr_of_mins_one_final; }
+RESOURCE TBUF r_qtn_drm_nbr_of_mins_two_four    { buf = qtn_drm_nbr_of_mins_two_four; }
+RESOURCE TBUF r_qtn_drm_nbr_of_mins_five_zero   { buf = qtn_drm_nbr_of_mins_five_zero; }
+RESOURCE TBUF r_qtn_drm_nbr_of_secs_one         { buf = qtn_drm_nbr_of_secs_one; }
+RESOURCE TBUF r_qtn_drm_nbr_of_secs_one_final   { buf = qtn_drm_nbr_of_secs_one_final; }
+RESOURCE TBUF r_qtn_drm_nbr_of_secs_two_four    { buf = qtn_drm_nbr_of_secs_two_four; }
+RESOURCE TBUF r_qtn_drm_nbr_of_secs_five_zero   { buf = qtn_drm_nbr_of_secs_five_zero; }
+
+RESOURCE TBUF r_qtn_drm_mgr_det_several_files   { buf = qtn_drm_mgr_det_several_files; }
+RESOURCE TBUF r_qtn_drm_mgr_det_subscription    { buf = qtn_drm_mgr_det_subscription; }
+RESOURCE TBUF r_qtn_drm_mgr_det_belongs_to      { buf = qtn_drm_mgr_det_belongs_to; }
+RESOURCE TBUF r_qtn_drm_det_ro_number           { buf = qtn_drm_det_ro_number; }
+RESOURCE TBUF r_qtn_drm_mgr_det_invalid         { buf = qtn_drm_mgr_det_invalid; }
+RESOURCE TBUF r_qtn_drm_mgr_det_not_valid_yet   { buf = qtn_drm_mgr_det_not_valid_yet; }
+
+RESOURCE TBUF r_qtn_drm_mgr_det_accum_time_left { buf = qtn_drm_mgr_det_accum_time_left; }
+
+RESOURCE TBUF r_qtn_drm_det_content_use         { buf = qtn_drm_det_content_use; }
+RESOURCE TBUF r_qtn_drm_det_sim_allowed         { buf = qtn_drm_det_sim_allowed; }
+RESOURCE TBUF r_qtn_drm_det_sim_not_allowed     { buf = qtn_drm_det_sim_not_allowed; }
+
+RESOURCE TBUF r_qtn_drm_mgr_det_phone_memory    { buf = qtn_drm_mgr_det_phone_memory; }
+RESOURCE TBUF r_qtn_drm_mgr_det_memory_card     { buf = qtn_drm_mgr_det_memory_card; }
+RESOURCE TBUF r_qtn_drm_mgr_det_location        { buf = qtn_drm_mgr_det_location; }
+
+RESOURCE TBUF r_qtn_drm_key_details             { buf = qtn_msk_drm_key_details; }
+
+// New string definitions
+RESOURCE TBUF r_qtn_drm_details_status                    { buf = qtn_drm_details_status; }
+RESOURCE TBUF r_qtn_drm_details_no_licence_available      { buf = qtn_drm_details_no_licence_available; }
+RESOURCE TBUF r_qtn_drm_details_valid                     { buf = qtn_drm_details_valid; }
+RESOURCE TBUF r_qtn_drm_details_not_valid_yet             { buf = qtn_drm_details_not_valid_yet; }
+RESOURCE TBUF r_qtn_drm_details_sending                   { buf = qtn_drm_details_sending; }
+RESOURCE TBUF r_qtn_drm_details_content_use               { buf = qtn_drm_details_content_use; }
+RESOURCE TBUF r_qtn_drm_details_allowed_with_this_sim     { buf = qtn_drm_details_allowed_with_this_sim; }
+RESOURCE TBUF r_qtn_drm_details_not_allowed_with_this_sim { buf = qtn_drm_details_not_allowed_with_this_sim; }
+RESOURCE TBUF r_qtn_drm_details_plays_left                { buf = qtn_drm_details_plays_left; }
+RESOURCE TBUF r_qtn_drm_details_views_left                { buf = qtn_drm_details_views_left; }
+RESOURCE TBUF r_qtn_drm_details_prints_left               { buf = qtn_drm_details_prints_left; }
+RESOURCE TBUF r_qtn_drm_details_exec_times                { buf = qtn_drm_details_exec_times; }
+RESOURCE TBUF r_qtn_drm_details_1_time                    { buf = qtn_drm_details_1_time; }
+RESOURCE TBUF r_qtn_drm_details_n_times                   { buf = qtn_drm_details_n_times; }
+RESOURCE TBUF r_qtn_drm_details_playing_time_left         { buf = qtn_drm_details_playing_time_left; }
+RESOURCE TBUF r_qtn_drm_details_validity_period           { buf = qtn_drm_details_validity_period; }
+RESOURCE TBUF r_qtn_drm_details_viewing_rights            { buf = qtn_drm_details_viewing_rights; }
+RESOURCE TBUF r_qtn_drm_details_printing_rights           { buf = qtn_drm_details_printing_rights; }
+RESOURCE TBUF r_qtn_drm_details_valid_from                { buf = qtn_drm_details_valid_from; }
+RESOURCE TBUF r_qtn_drm_details_view_rights_from          { buf = qtn_drm_details_view_rights_from; }
+RESOURCE TBUF r_qtn_drm_details_print_rights_from         { buf = qtn_drm_details_print_rights_from; }
+RESOURCE TBUF r_qtn_drm_details_valid_until               { buf = qtn_drm_details_valid_until; }
+RESOURCE TBUF r_qtn_drm_details_view_rights_until         { buf = qtn_drm_details_view_rights_until; }
+RESOURCE TBUF r_qtn_drm_details_print_rights_until        { buf = qtn_drm_details_print_rights_until; }
+
+RESOURCE TBUF r_qtn_drm_mgr_det_pl_unlimited              { buf = qtn_drm_mgr_det_pl_unlimited; }
+RESOURCE TBUF r_qtn_drm_mgr_det_vi_unlimited              { buf = qtn_drm_mgr_det_vi_unlimited; }
+RESOURCE TBUF r_qtn_drm_mgr_det_pr_unlimited              { buf = qtn_drm_mgr_det_pr_unlimited; }
+RESOURCE TBUF r_qtn_drm_mgr_det_ex_unlimited              { buf = qtn_drm_mgr_det_ex_unlimited; }
+
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/data/DRMRightsManager_reg.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  RSS for registration file for DRMRightsManager.
+*
+*/
+
+
+#include <appinfo.rh>
+#include <drmrightsmanager.rsg>
+#include <data_caging_paths_strings.hrh>
+
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x101F85C7
+
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "DRMRightsManager";
+
+    localisable_resource_file = APP_RESOURCE_DIR"\\DRMRightsManager";
+
+    localisable_resource_id = R_DRMUI_LOCALISABLE_APP_INFO;
+    
+#ifdef RD_DRM_RIGHTS_MANAGER_REMOVAL
+
+    hidden = KAppIsHidden;
+    
+#endif //RD_DRM_RIGHTS_MANAGER_REMOVAL
+    
+    embeddability = KAppEmbeddableUiNotStandAlone;
+    newfile = KAppDoesNotSupportNewFile;
+    }
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/group/DRMRightsManager.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is the project specification file for DRMRightsManager.
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET  drmrightsmanager.exe
+EPOCSTACKSIZE 0x5000
+TARGETTYPE  exe
+
+UID  0x100039CE 0x101F85C7
+
+CAPABILITY CAP_APPLICATION PowerMgmt DRM
+VENDORID VID_DEFAULT
+
+SOURCEPATH ../src
+SOURCE  DRMRightsMgrApp.cpp
+SOURCE  DRMRightsMgrAppUi.cpp
+SOURCE  DRMRightsMgrDocument.cpp
+SOURCE  DRMRightsMgrDetailsContainer.cpp
+SOURCE  DRMRightsMgrDetailsView.cpp
+SOURCE  DRMViewItems.cpp
+SOURCE  DRMCommonUtilities.cpp
+
+START RESOURCE ../data/DRMRightsManager.rss
+HEADER
+
+TARGETPATH APP_RESOURCE_DIR
+
+LANGUAGE_IDS
+END  // RESOURCE
+
+
+USERINCLUDE     .
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+
+// Default system include paths for middleware layer modules.
+APP_LAYER_SYSTEMINCLUDE
+
+
+LIBRARY euser.lib apparc.lib cone.lib eikcore.lib eikcoctl.lib eikctl.lib
+LIBRARY avkon.lib bafl.lib commonengine.lib efsrv.lib
+LIBRARY aknskins.lib commonui.lib servicehandler.lib
+LIBRARY dcfrep.lib caf.lib cafutils.lib
+LIBRARY ecom.lib
+LIBRARY commondialogs.lib
+LIBRARY directorylocalizer.lib
+
+LIBRARY drmparsers.lib
+LIBRARY drmdcf.lib
+LIBRARY drmrights.lib
+LIBRARY drmserverinterfaces.lib
+LIBRARY drmcommon.lib
+LIBRARY drmutilitywmdrmwrapper.lib
+
+LIBRARY starterclient.lib
+LIBRARY charconv.lib
+
+DEBUGLIBRARY flogger.lib
+
+
+START RESOURCE ../data/DRMRightsManager_reg.rss
+DEPENDS drmrightsmanager.rsg
+// Do not change the UID below.
+TARGETPATH /private/10003a3f/apps
+END
+
+SMPSAFE
Binary file commondrm/drmrightsmanagerui/help/data/xhtml.zip has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/help/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - Initial contribution
+* 
+* Contributors:
+* 
+* 
+* Description:
+* 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/drm.hlp.hrh	MW_LAYER_PLATFORM_EXPORT_PATH(csxhelp/drm.hlp.hrh)
+../rom/drmsettingspluginhelps_variant.iby		CUSTOMER_MW_LAYER_IBY_EXPORT_PATH(drmsettingspluginhelps_variant.iby)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/help/inc/drm.hlp.hrh	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Symbian Foundation License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description:
+*
+*/
+	
+//
+// drm.hlp.hrh generated by CSXHelp Utilities.
+//           
+
+#ifndef __DRM_HLP_HRH__
+#define __DRM_HLP_HRH__
+
+_LIT(KSET_HLP_PROTECTED_CONTENT, "SET_HLP_PROTECTED_CONTENT"); // 
+_LIT(KDRM_HLP_REGISTRATION_METERING, "DRM_HLP_REGISTRATION_METERING"); // 
+_LIT(KDRM_HLP_REGISTRATION, "DRM_HLP_REGISTRATION"); // 
+
+#endif 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/help/rom/drmsettingspluginhelps_variant.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description:
+*
+*/
+
+#ifndef __DRMSETTINGSPLUGINHELPS_VARIANT_IBY__
+#define __DRMSETTINGSPLUGINHELPS_VARIANT_IBY__
+
+#if defined(FF_S60_HELPS_IN_USE)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F85C7\contents.zip, RESOURCE_FILES_DIR\xhtml\%02d\0x101F85C7\contents.zip)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F85C7\index.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x101F85C7\index.xml)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F85C7\keywords.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x101F85C7\keywords.xml)
+    data=LOCALISE(DATAZ_\resource\xhtml\%02d\0x101F85C7\meta.xml, RESOURCE_FILES_DIR\xhtml\%02d\0x101F85C7\meta.xml)
+#endif
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DRMCommonUtilities.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,187 @@
+/*
+* 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:  Definition of common utilities functions
+*
+*/
+
+
+#ifndef DRMCOMMONUTILITIES_H
+#define DRMCOMMONUTILITIES_H
+
+
+#include <e32std.h>
+#include <coemain.h>
+#include <DRMRights.h>
+#include <DRMCommon.h>
+
+class CDRMRightsMgrAppUi;
+
+// CONSTANTS
+
+const TInt KUrlMaxLen( 1024 );
+
+const TInt KMSKControlID( 3 );
+
+// Started operation
+enum TOperation
+    {
+    EDRMRefreshingOnlyForDetails    // Refreshing when starting DRMUI embedded
+    };
+
+// CLASS DECLARATION
+
+/**
+*  DRMCommonUtilities
+*
+*  Collection of common utilities
+*/
+class DRMCommonUtilities
+{
+    private:
+        /**
+        * Shows a confirmation note
+        * @param aPrompt  Prompt to be shown in the note
+        */
+        static void ShowConfirmationNoteL( const TDesC& aPrompt );
+
+        /**
+        * Shows a confirmation query
+        * @param aPrompt  Prompt to be shown in the query
+        * @return   ETrue if the query was accepted
+        */
+        static TBool ShowConfirmationQueryL( const TDesC& aPrompt );
+
+    public:
+        /**
+        * Shows a confirmation query
+        * @param aResourceId The numeric ID of the resource string to be read.
+        * @param aString     Reference to the replacing string.
+        * @param aLoaderEnv  Pointer to the control environment. 
+        * @return   ETrue if the query was accepted
+        */
+        static TBool ShowConfirmationQueryL( const TInt aResourceId, 
+                                             const TDesC& aString,
+                                             CCoeEnv* aLoaderEnv );
+
+        /**
+        * Shows a confirmation query
+        * @param aResourceId The numeric ID of the resource string to be read.
+        * @param aLoaderEnv  Pointer to the control environment. 
+        * @return   ETrue if the query was accepted
+        */
+        static TBool ShowConfirmationQueryL( const TInt aResourceId, 
+                                             CCoeEnv* aLoaderEnv );
+
+        /**
+        * Shows a confirmation note
+        * @param aResourceId The numeric ID of the resource string to be read.
+        * @param aString     Reference to the replacing string.
+        * @param aLoaderEnv  Pointer to the control environment. 
+        */
+        static void ShowConfirmationNoteL( const TInt aResourceId, 
+                                           const TDesC& aString,
+                                           CCoeEnv* aLoaderEnv );
+
+        /**
+        * Shows a confirmation note
+        * @param aResourceId The numeric ID of the resource string to be read.
+        * @param aLoaderEnv  Pointer to the control environment. 
+        */
+        static void ShowConfirmationNoteL( const TInt aResourceId, 
+                                           CCoeEnv* aLoaderEnv );
+
+        /**
+        * Shows information note
+        * @param aResourceId The numeric ID of the resource string to be read.
+        * @param aLoaderEnv  Pointer to the control environment. 
+        */
+        static void ShowInformationNoteL( const TInt aResourceId, 
+                                          CCoeEnv* aLoaderEnv );
+
+        /**
+        * Gets the activation time for an object that will be activated in the
+        * future
+        * @param aRights    The RO to be parsed
+        * @return   The future activation time
+        */
+        static TTime GetFutureActivationTime( CDRMRights& aRights );
+
+        /**
+        * Gets the path name where the icons reside
+        * @param aIconsFileName The pathname.
+        */
+        static void GetIconsFileName( TDes& aIconsFileName );
+
+        /**
+        * Tells if the MO is located in a private folder
+        * @param aContentPath   The full name of the MO
+        * @return   ETrue if the MO is located in a private folder
+        */
+        static TBool IsInPrivateFolderL( const TDesC& aContentPath );
+
+        /**
+        * Tells if the active view is a list view
+        * @param aViewId    The Id of the active view
+        * @return   ETrue if the active view is a list view
+        */
+        static TBool IsListView( const TUid& aViewId );
+
+        /**
+        * Gets the URL of the issuer of the rights
+        * @param aDRMCommon         Pointer to the current instance of 
+        *                           DRMCommon
+        * @param aFileName          The full name of the MO
+        * @param aRightsIssuerURL   In output it contains the URL of the issuer
+        *                           of the rights
+        * @return   Error code.
+        */
+        static TInt RightsIssuerUrlL( const TFileName& aFileName, 
+                                      HBufC*& aRightsIssuerURL );
+
+        /**
+        * Gets the status of the rights: valid, expired, or future
+        * @param aRights    The rights to be parsed
+        * @param aExpir     Status of rights
+        * @return           Error code 
+        */
+        static TInt GetRightsStatus( CDRMRights& aRights,
+        							 CDRMRights::TExpiration& aExpir);
+
+        /**
+        * Parse the parameters used to load the DRMUI and starts the UI 
+        * directly on Details View.
+        * @param aLex           The parameters used to load the DRMUI (embedded
+        *                       or not)
+        * @param aStartEmbedded ETrue if DRMUI was launched embedded
+        * @param aAppUi         Pointer to the application Ui
+        */
+        static void ParseParametersAndStartL( TLex aLex, TBool aStartEmbedded,
+                                      		  CDRMRightsMgrAppUi& aAppUi );
+                                      		  
+        /**
+        * Separates beginning of file path and rest of path + filename
+        * e.g.for localization purposes
+        * @param aFileName    File name with full path
+        * @param aRestOfName  End part of file name string
+        * @return Beginning part of file path if found, otherwise KNullDesc
+        */
+		static TPtrC SplitPath( const TDesC& aFileName,
+								TPtrC& aRestOfName );
+                                      		  
+};
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DRMRightsManager.hrh	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2003-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:  Resource header file
+*                This file contains declarations for constants of 
+*                DRMRightsManager.
+*                The file can be included in C++ or resource file.
+*
+*/
+
+
+
+#ifndef DRMRIGHTSMANAGER_HRH
+#define DRMRIGHTSMANAGER_HRH
+
+// DEFINES
+
+// Uid of the application
+#define EUidDRMRightsManager 0x101F85C7
+
+
+// ENUMERATIONS
+
+// Commands IDs
+enum TDRMRightsManagerCommandIds
+    {
+    EDRMRightsManagerCmdAppViewDet = 1      // View details
+    };
+ 
+// IDs of the views
+enum TDRMViewId
+    {
+    EDRMDetailsView                         // Details View
+    };
+
+// IDs of controls
+enum TDRMRightsMgrControlIds
+    {
+    EDRMRightsMgrCtrlIdWaitNote = 0x100     // Wait note
+    };
+
+// Type of object
+enum TObjectType
+    {
+    EUndefinedObject   = 0x0000,            // No definition
+    EValidObject       = 0x0001,            // Object is valid
+    EInvalidObject     = 0x0002,            // Object is invalid
+    EUnusedObject      = 0x0004,            // Object is unused
+    EExpiredObject     = 0x0010,            // Object has expired rights
+    EFutureObject      = 0x0020,            // Object has future rights
+    EGroupObject       = 0x0100,            // Group Object
+    EGroupObjectMember = 0x0200             // Object is a member of a group
+    };
+
+
+#endif      // DRMRIGHTSMANAGER_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DRMRightsManagerPrivateCRKeys.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Private Central Repository keys.
+*
+*/
+
+
+#ifndef DRMRIGHTSMANAGERPRIVATECRKEYS_H
+#define DRMRIGHTSMANAGERPRIVATECRKEYS_H
+
+const TUid KCRUidDRMRightsManager = {0x102750B1};
+
+#endif      // DRMRIGHTSMANAGERPRIVATECRKEYS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DRMRightsMgrApp.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,60 @@
+/*
+* 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:  Declares main application class.
+*
+*/
+
+
+
+#ifndef DRMRIGHTSMGRAPP_H
+#define DRMRIGHTSMGRAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+#include "DRMRightsManager.hrh"
+
+
+// CONSTANTS
+// Uid of the application
+const TUid KUidDRMRightsManager = { EUidDRMRightsManager };
+
+
+// CLASS DECLARATION
+
+/**
+* CDRMRightsMgrApp application class.
+* Provides factory to create concrete document object.
+*/
+class CDRMRightsMgrApp : public CAknApplication
+    {
+    private:
+        /**
+        * From CApaApplication, creates CDRMRightsMgrDocument document object.
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * From CApaApplication, returns application's UID (KUidDRMRightsManager).
+        * @return The value of KUidDRMRightsManager.
+        */
+        TUid AppDllUid() const;
+    };
+
+#endif
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DRMRightsMgrAppUi.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,402 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares UI class for application.
+*
+*/
+
+
+
+#ifndef DRMRIGHTSMGRAPPUI_H
+#define DRMRIGHTSMGRAPPUI_H
+
+// INCLUDES
+#include <aknviewappui.h>
+#include <aknprogressdialog.h>
+#include <apparc.h>
+#include <drmrightsclient.h>
+
+#include "drmviewitems.h"
+
+#include "drmrightsmanager.hrh"
+
+
+// FORWARD DECLARATIONS
+class CAknWaitDialog;
+class CDRMRights;
+class DRMCommon;
+
+
+// CLASS DECLARATION
+
+/**
+* Application UI class.
+* Provides support for the following features:
+* - EIKON control architecture
+* - view architecture
+* - status pane
+*/
+class CDRMRightsMgrAppUi :  public  CAknViewAppUi,
+                            public  MApaEmbeddedDocObserver,
+                            private MProgressDialogCallback,
+                            public  MCoeForegroundObserver
+    {
+    public:     // Data Types
+        // Status of scanning of the ROs
+        enum TStatusScan
+            {
+            // Scanning started when app launched
+            EDRMStatusOpening = 0,
+
+            // Scanning started when app launched embedded
+            EDRMStatusOpeningEmbedded,
+
+            // Scanning finished
+            EDRMStatusFinished
+            };
+
+    public:    // Constructors and destructor
+        /**
+        * C++ default constructor
+        */
+        CDRMRightsMgrAppUi();
+
+        /**
+        * Symbian default constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */
+        ~CDRMRightsMgrAppUi();
+
+
+    private:    // New functions
+
+        /**
+        * Processes engine error
+        * @param aCloseImmediately  ETrue if program should be close
+        *                           immediately. EFalse if only app shutter
+        *                           should be started.
+        */
+        void ProcessEngineErrorL( TBool aCloseImmediately );
+
+        /**
+        * Open Details View only, when DRMUi is launched to show only that
+        * view, but not in embedded mode
+        * @param aParams    The params used to launch DRMUI
+        */
+        void OpenDetailsViewNotEmbeddedL( const TDesC& aParams );
+
+        /**
+        * Creates the Wait Dialog to be showed during long asynchronous
+        * operations
+        */
+        void CreateWaitDialogLC();
+
+        /**
+        * Extracts the name of the object to be showed in the list
+        * @param aFullName  The path name of the object
+        * @param aItemName  In output the name of the object to be showed in
+        *                   the list
+        * @param aID        The ID of the object
+        * @param aIsGroup   Tells if the object is a group
+        */
+        void GetItemNameL( const TDesC& aFullName, TDes& aItemName,
+                           const TDesC8& aID, const TBool aIsGroup );
+
+
+        /**
+        * Evaluates if the given content file can be shown in keys list, and if it
+        * can be forwarded or not. Returns KErrNone if successful otherwise error code.
+        * @param aFileName    File name with full path
+        * @param aContentURI  Content id
+        * @param aListable    Tells if MO can be shown in keys list
+        * @param aSendable    Tells if MO can be forwarded
+        */
+        TInt GetItemDataL( const TDesC& aFileName,
+                           const TDesC8& aContentURI,
+                           TBool& aListable,
+                           TBool& aSendable );
+
+        /**
+        * Get a rights manager instance
+        * @return               Rights Manager instance
+        */
+        ContentAccess::CRightsManager* GetRightsManagerL();
+
+        /**
+        * Checks the status of WM DRM rights
+        * @param aContentURI    ContentURI for object to be opened when
+        *                       application is launched
+        * @param aStatus        Status of the rights
+        * @param aArray         Array for storing the rights
+        */
+        void CheckWmDrmRightsL( const TDesC8& aContentURI, TInt& aStatus,
+            ContentAccess::RStreamablePtrArray<ContentAccess::CRightsInfo>& aArray );
+
+        /**
+        * Checks the status of OMA DRM rights
+        * @param aContentURI    ContentURI for object to be opened when
+        *                       application is launched
+        * @param aLocalID       LocalID for object to be opened when
+        *                       application is launched
+        * @param aRights        Pointer to instance of CDRMRights for
+        *                       storing the rights
+        * @param aStatus        Status of the rights
+        */
+        void CheckOmaDrmRightsL( const TDesC8& aContentURI,
+                                 const TUint32 aLocalID,
+                                 CDRMRights*& aRights,
+                                 TInt& aStatus );
+
+        /**
+        * Checks the individual constraint of OMA DRM rights
+        * @param aContentURI            ContentURI for object to be opened when
+        *                               application is launched
+        * @param aIndividualConstraint  Whether rights have an individual
+        *                               constraint or not
+        * @param aUsageAllowed          Whether individually constrained rights
+        *                               can be used for using the content
+        */
+        void CheckIndividualConstraint( const TDesC8& aContentURI,
+                                        TBool& aIndividualConstraint,
+                                        TBool& aUsageAllowed );
+
+
+
+    public: // New functions
+        /**
+        * @param aContentURI    ContentURI for object to be opened when
+        *                       application is launched embedded
+        * @param aLocalID       LocalID for object to be opened when
+        *                       application is launched embedded
+        * @param aEmbedded      Tells if the DRMUi was launched embedded
+        * @param aDrmScheme     Tells the DRM protection scheme of the file
+        */
+        void StartOnlyForDetailsL( const TDesC8& aContentURI,
+                                   const TUint32 aLocalID,
+                                   const TBool aEmbedded,
+                                   const TBool aDrmScheme );
+
+        /**
+        * Gets the index in array of items of the selected item.
+        * @return The index of the selected item.
+        */
+        inline TInt SelectedIndexInArray();
+
+        /**
+        * Returns the selected item name.
+        * @param aItemName  In output the selected item name
+        */
+        inline void SelectedItemName( TFileName& aItemName );
+
+        /**
+        * Returns the selected item path name.
+        * @param aItemFullName  In output the selected item path name
+        */
+        inline void SelectedItemFullName( TFileName& aItemFullName );
+
+        /**
+        * Tells if the selected item content can be sent
+        * @return   ETrue if the selected item content can be sent
+        */
+        inline TBool SelectedContentCanBeSent();
+
+        /**
+        * Tells if the selected item has unlimited rights
+        * @return   ETrue if the selected item has unlimited rights
+        */
+        inline TBool UnlimitedRights();
+
+        /**
+        * Tells if the selected item has individual constraint
+        * @return   ETrue if the selected item has individual constraint
+        */
+        inline TBool IndividualConstraint();
+
+        /**
+        * Tells if the selected item can be used with current SIM
+        * @return   ETrue if the selected item can be used with current SIM
+        */
+        inline TBool UsageAllowed();
+
+        /**
+        * Returns the local ID of the selected RO
+        * @return The local ID of the selected RO
+        */
+        inline TUint32 SelectedLocalID();
+
+        /**
+        * Returns the content URI of the selected RO
+        * @param aContentURI    In output, the content URI of the selected RO
+        */
+        inline void SelectedContentURI( TBuf8<KMaxFileName>& aContentURI );
+
+        /**
+        * Tells if the selected item is a group
+        * @return   ETrue if the selected item is a group
+        */
+        inline TBool SelectedIsGroup();
+
+        /**
+        * Sets the name of the selected item
+        * @param aItemName  The name of the selected item
+        */
+        inline void SetSelectedItemName( const TDesC& aItemName );
+
+        /**
+        * Sets the path name of the selected item
+        * @param aItemFullName  The path name of the selected item
+        */
+        inline void SetSelectedItemFullName( const TDesC& aItemFullName );
+
+        /**
+        * Sets the attribute that tells if the selected item content can be
+        * forwarded or not
+        * @param aContentCanBeSent  ETrue if the selected item content can be
+        *                           forwarded
+        */
+        inline void SetSelectedContentCanBeSent( const TBool aContentCanBeSent );
+
+        /**
+        * Sets the individual constraint attribute.
+        * @param aIndividualConstraint ETrue if individual constraint
+        */
+        inline void SetSelectedIndividualConstraint( const TBool aIndividualConstraint );
+
+        /**
+        * Sets the usage allowed with current SIM attribute.
+        * @param aUsageAllowed ETrue if allowed
+        */
+        inline void SetSelectedUsageAllowed( const TBool aUsageAllowed );
+
+
+
+
+    private:    // From CEikAppUi
+        /**
+        * From CEikAppUi, handles key events.
+        * @param aKeyEvent Event to handled.
+        * @param aType Type of the key event.
+        * @return Response code (EKeyWasConsumed, EKeyWasNotConsumed).
+        */
+        virtual TKeyResponse HandleKeyEventL( const TKeyEvent& aKeyEvent,
+                                              TEventCode aType);
+
+        /**
+        * Handles resource change events.
+        * @param aType: The type of resources that have changed
+        */
+        void HandleResourceChangeL( TInt aType );
+
+
+    public:    // From CEikAppUi
+        /**
+        * Takes care of command handling.
+        * @param aCommand command to be handled
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /**
+        * Processes shell commands.
+        * @param aCommand       The shell command sent to the application.
+        * @param aDocumentName  The name of the document
+        * @param aTail          Command line tail.
+        * @return               Always EFalse
+        */
+        TBool ProcessCommandParametersL( TApaCommand aCommand,
+                                         TFileName& aDocumentName,
+                                         const TDesC8& aTail );
+
+        /**
+        * Processes Application Architecture messages.
+        * @param aUid       The message’s unique identifier.
+        * @param aParams    Message parameters
+        */
+        void ProcessMessageL( TUid aUid, const TDesC8& aParams );
+
+
+    public: // From MApaEmbeddedDocObserver
+
+        /**
+        * Implements the required behaviour when the editing of an embedded
+        * document completes.
+        * @param aMode  Indicates the state of the document
+        */
+        void NotifyExit( TExitMode aMode );
+
+
+    public: // From MProgressDialogCallback
+        /**
+        * Called when/if the dialog has been dismissed.
+        * @param aButtonId  Pressed button
+        */
+        void DialogDismissedL( TInt aButtonId );
+
+    public: // From MCoeForegroundObserver
+        /**
+        * Handles the application coming to the foreground 
+        *
+        */
+        void HandleGainingForeground();
+
+        /**
+        * Handles the application going into the background
+        *
+        */
+        void HandleLosingForeground();
+
+    private: //Data
+        // ETrue whan DRMUI is started embedded to show the Details View only.
+        TBool iStartEmbedded;
+
+        // Data of the selected item.
+        TItemData iSelectedItem;
+
+        // Status of the scanning.
+        TStatusScan iStatusScan;
+
+        // Wait dialog. Owned.
+        CAknWaitDialog* iWaitDialog;
+
+        // Pointer to DRMCommon. Owned.
+        DRMCommon* iDRMCommon;
+
+        // The DRM Rights Client.
+        RDRMRightsClient iRightsClient;
+
+        // The DRM protection of the given file.
+        TInt iDrmScheme;
+        
+        // The local ID of the rights
+        TUint32 iLocalID;
+        
+        // Content URI of the file for which the details view has been opened
+        HBufC8* iContentURI;  
+        
+        // The details view has been opened once. This information is used to
+        // update the details view when returning to details view from another
+        // application
+        TBool iForegroundHasBeenActive;
+
+    };
+
+// Include inline functions
+#include "drmrightsmgrappui.inl"
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DRMRightsMgrAppUi.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,177 @@
+/*
+* 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:  CDRMRightsMgrAppUi inline functions
+*
+*/
+
+
+
+#ifndef DRMRIGHTSMGRAPPUI_INL
+#define DRMRIGHTSMGRAPPUI_INL
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SelectedIndexInArray
+// ---------------------------------------------------------
+//
+inline TInt CDRMRightsMgrAppUi::SelectedIndexInArray()
+    {
+    return iSelectedItem.IndexInArray();
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SelectedItemName
+// ---------------------------------------------------------
+//
+inline void CDRMRightsMgrAppUi::SelectedItemName( TFileName& aItemName )
+	{ 
+    iSelectedItem.ItemName( aItemName );
+	}
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SelectedItemFullName
+// ---------------------------------------------------------
+//
+inline void CDRMRightsMgrAppUi::SelectedItemFullName( 
+                                                     TFileName& aItemFullName )
+	{ 
+    iSelectedItem.ItemFullName( aItemFullName );
+	}
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SelectedLocalID
+// ---------------------------------------------------------
+//
+inline TUint32 CDRMRightsMgrAppUi::SelectedLocalID()
+    {
+    return iSelectedItem.LocalID();
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SelectedContentURI
+// ---------------------------------------------------------
+//
+inline void CDRMRightsMgrAppUi::SelectedContentURI( 
+                                            TBuf8<KMaxFileName>& aContentURI )
+    {
+    iSelectedItem.ContentURI( aContentURI );
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SelectedContentCanBeSent
+// ---------------------------------------------------------
+//
+inline TBool CDRMRightsMgrAppUi::SelectedContentCanBeSent()
+    {
+    return iSelectedItem.ContentCanBeSent();
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::UnlimitedRights
+// ---------------------------------------------------------
+//
+inline TBool CDRMRightsMgrAppUi::UnlimitedRights()
+    {
+    return iSelectedItem.UnlimitedRights();
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::IndividualConstraint
+// ---------------------------------------------------------
+//
+inline TBool CDRMRightsMgrAppUi::IndividualConstraint()
+    {
+    return iSelectedItem.IndividualConstraint();
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::UsageAllowed
+// ---------------------------------------------------------
+//
+inline TBool CDRMRightsMgrAppUi::UsageAllowed()
+    {
+    return iSelectedItem.UsageAllowed();
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SelectedIsGroup
+// ---------------------------------------------------------
+//
+inline TBool CDRMRightsMgrAppUi::SelectedIsGroup()
+    {
+    return iSelectedItem.IsGroup();
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SetSelectedItemName
+// ---------------------------------------------------------
+//
+inline void CDRMRightsMgrAppUi::SetSelectedItemName( const TDesC& aItemName )
+    {
+    iSelectedItem.SetItemName( aItemName );
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SetSelectedItemFullName
+// ---------------------------------------------------------
+//
+inline void CDRMRightsMgrAppUi::SetSelectedItemFullName( 
+                                                const TDesC& aItemFullName )
+    {
+    iSelectedItem.SetItemFullName( aItemFullName );
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SetSelectedContentCanBeSent
+// ---------------------------------------------------------
+//
+inline void CDRMRightsMgrAppUi::SetSelectedContentCanBeSent( 
+                                                const TBool aContentCanBeSent )
+    {
+    iSelectedItem.SetContentCanBeSent( aContentCanBeSent );
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SetSelectedIndividualConstraint
+// ---------------------------------------------------------
+//
+inline void CDRMRightsMgrAppUi::SetSelectedIndividualConstraint( 
+                                                const TBool aIndividualConstraint )
+    {
+    iSelectedItem.SetIndividualConstraint( aIndividualConstraint );
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::SetSelectedUsageAllowed
+// ---------------------------------------------------------
+//
+inline void CDRMRightsMgrAppUi::SetSelectedUsageAllowed( const TBool aUsageAllowed )
+    {
+    iSelectedItem.SetUsageAllowed( aUsageAllowed );
+    }
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DRMRightsMgrDetailsContainer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,405 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares container control for details view
+*
+*/
+
+
+#ifndef DRMRIGHTSMGRDETAILSCONTAINER_H
+#define DRMRIGHTSMGRDETAILSCONTAINER_H
+
+// INCLUDES
+#include <coecntrl.h>
+#include <eiklbo.h>
+#include <eiktxlbx.h>
+
+#include <aknnavide.h>
+#include <eikspane.h>
+#include <aknappui.h>
+
+// caf
+#include <caf/caf.h>
+#include <caf/caftypes.h>
+#include <caf/rightsinfo.h>
+
+#include "drmrightsmgrdetailscontainer.h"
+
+// FORWARD DECLARATIONS
+class CDRMRightsConstraints;
+
+/**
+* Status of the RO
+*/
+enum TDRMUIRightsStatus
+    {
+    EDRMUIStatusInvalid,    // RO is invalid
+    EDRMUIStatusValid,      // RO is valid
+    EDRMUIStatusFuture,     // RO has future rights
+    EDRMUIStatusExpired     // RO expired
+    };
+
+
+// STRUCT DEFINITIONS
+
+/**
+* Data about a certain RightsObject
+*/
+struct TRights
+    {
+    // Status of the RO
+    TDRMUIRightsStatus iStatus;
+
+    // Play constraints
+    CDRMRightsConstraints* iPlayConstraint;
+
+    // Display constraints
+    CDRMRightsConstraints* iDisplayConstraint;
+
+    // Print constraints
+    CDRMRightsConstraints* iPrintConstraint;
+
+    // Execute constraints
+    CDRMRightsConstraints* iExecuteConstraint;
+    };
+
+/**
+* Data about a certain Content
+*/
+struct TDetails
+    {
+    // Array containing data about related rights
+    CArrayFixFlat<TRights>* iRights;
+
+    // The index in the array of the active RO
+    TInt iActiveROindex;
+
+    // ETrue if the object can be sent
+    TBool iContentCanBeSent;
+
+    // Location of the content
+    TFileName iContentPath;
+
+    // ETrue if Individual constraint exists
+    TBool iIndividualConstraint;
+
+    // ETrue if content can be used with current SIM
+    TBool iUsageAllowed;
+
+    // The DRM protection of the given file.
+    TInt iDrmScheme;
+
+    };
+
+
+// CLASS DECLARATION
+
+/**
+*  CDRMRightsMgrDetailsContainer
+*  container control class.
+*/
+class CDRMRightsMgrDetailsContainer : public CCoeControl,
+                                      public MEikListBoxObserver,
+                                      private MCoeControlObserver
+
+    {
+    public: // Constructors and destructor
+        /**
+        * C++ constructor.
+        * @param aDetails       The details to be displayed
+        * @param aStartEmbedded ETrue if it has to display details when DRMUI
+        *                       was started embedded.
+        */
+        CDRMRightsMgrDetailsContainer( TDetails& aDetails,
+                                       TBool aStartEmbedded );
+
+        /**
+        * Symbian default constructor.
+        * const TRect& aRect Frame rectangle for container.
+        */
+        void ConstructL( const TRect& aRect );
+
+        /**
+        * Destructor.
+        */
+        ~CDRMRightsMgrDetailsContainer();
+
+    protected: // Functions from base classes
+        /**
+        * Handle resource change events.
+        * @param aType: The type of resources that have changed
+        */
+        void HandleResourceChange( TInt aType );
+
+        /**
+        * From CoeControl. Responds to size changes to sets the size and
+        * position of the contents of this control.
+        */
+        void SizeChanged();
+
+        /**
+        * Handle key events.
+        * @param aKeyEvent: key event
+        * @param aType: type of event
+        * @return The key response, if it was consumed or not.
+        */
+        TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
+                                     TEventCode aType );
+
+        /**
+        * From CoeControl. Responds to focus changes.
+        */
+        void FocusChanged(TDrawNow aDrawNow);
+
+    private: // Functions from base classes
+
+        /**
+        * From CoeControl. Gets the number of controls contained in a compound
+        * control.
+        * @return The number of component controls contained.
+         */
+        TInt CountComponentControls() const;
+
+        /**
+        * From CCoeControl. Gets the specified component of a compound control.
+        * @param  The index of the control to get
+        * @return The component control with an index of aIndex
+        */
+        CCoeControl* ComponentControl( TInt aIndex ) const;
+
+        /**
+        * From CCoeControl. Draw controls
+        * @param aRect The region of the control to be redrawn.
+        */
+        void Draw( const TRect& aRect ) const;
+
+        /**
+        * Event handling section
+        * @param aControl The control that sent the event
+        * @param aEventType The event type
+        */
+        virtual void HandleControlEventL( CCoeControl* aControl,
+                                          TCoeEvent aEventType );
+
+     public: // New functions
+        /**
+        * Updates scrollbar in order to draw correct scroll bar.
+        */
+        void SetScrollBarL();
+
+        /**
+        * Updates content of the listbox.
+        * @param aDetails   The details to be displayed
+        */
+        void UpdateListBoxContentL( TDetails& aDetails );
+
+
+    private:    // New functions
+        /**
+        * Constructs listbox and initializes its sub-folders
+        * @param aResLbxId resource ID of the listbox item array
+        */
+        void ConstructListBoxL();
+
+        /**
+        * Appending icons from resource file
+        */
+        virtual void SetIconsL();
+
+        /** Handles listbox event.
+        * @param aListBox   The originating list box
+        * @param aEventType Type of event to be handled.
+        */
+        void HandleListBoxEventL( CEikListBox* aListBox,
+                                  TListBoxEvent aEventType );
+
+        /**
+        * Add Rights details line(s) in listbox.
+        * @param aNumberOfKey   The index of the key to be processed
+        * @param aDetails       The details to be displayed
+        * @param aItems         Array where the listbox items have to be added
+        */
+        void AddRightsDetailsL( TInt aNumberOfKey, TDetails& aDetails,
+                                CDesCArray* aItems );
+        /**
+        * Add Status line in listbox.
+        * @param aStatus        Status of the key that is processed
+        * @param aItems         Array where the listbox items have to be added
+        */
+        void AddStatusLineL( TDRMUIRightsStatus aStatus, CDesCArray* aItems );
+
+        /**
+        * Add Content Sending line in listbox.
+        * @param aContentCanBeSent ETrue if content can be sent
+        * @param aItems Array where the listbox items have to be added
+        */
+        void AddContentSendingLineL( TBool aContentCanBeSent,
+                                     CDesCArray* aItems );
+
+        /**
+        * Add Content use line in listbox.
+        * @param aUsageAllowed ETrue if content can be used with this SIM
+        * @param aItems        Array where the listbox items have to be added
+        */
+        void AddContentUseLineL( TBool aUsageAllowed,
+                                 CDesCArray* aItems );
+
+        /**
+        * Add Rights line in listbox.
+        * @param aResourceId Resource Id of the type of right
+        * @param aConstraint Constraint to be parsed
+        * @param aItems      Array where the listbox items have to be added
+        * @param aIsWmDrm    Whether WM DRM or OMA DRM file is concerned
+        * @param aIntent     The usage intent of the file, possible values
+                             ContentAccess:EPlay, ContentAccess:EView,
+                             ContentAccess:EExecute and ContentAccess:EPrint
+        */
+        void AddRightsLineL( CDRMRightsConstraints* aConstraint,
+                               CDesCArray* aItems,
+                               const TBool aIsWmDrm,
+                               const TUint32& aIntent );
+
+        /**
+        * Split time in single elements
+        * @param aInterval  Time interval to be split
+        * @param aIntYrs    Contains in output the number of years
+        * @param aIntMon    Contains in output the number of months
+        * @param aIntDay    Contains in output the number of days
+        * @param aIntHrs    Contains in output the number of hours
+        * @param aIntMin    Contains in output the number of minutes
+        * @param aIntSec    Contains in output the number of seconds
+        */
+        void SplitTime( const TTimeIntervalSeconds& aInterval,
+                        TInt& aIntYrs, TInt& aIntMon, TInt& aIntDay,
+                        TInt& aIntHrs, TInt& aIntMin, TInt& aIntSec );
+
+        /**
+        * Add elements of time to the string
+        * @param aIntYrs    Number of years
+        * @param aIntMon    Number of months
+        * @param aIntDay    Number of days
+        * @param aIntHrs    Number of hours
+        * @param aIntMin    Number of minutes
+        * @param aIntSec    Number of seconds
+        * @return   Buffer where the parts have to be written
+        */
+        HBufC* AddPartsOfTimeL( TInt aIntYrs, TInt aIntMon, TInt aIntDay,
+                                TInt aIntHrs, TInt aIntMin, TInt aIntSec );
+
+        /**
+        * Add a single element of time to the string array
+        * @param aNumOfElements         Number of elements of the interval
+        * @param aResourceIdSingle      Resource id to be used in case of
+        *                               single unit
+        * @param aResourceIdOneFinal    Resource id to be used in case of
+        *                               units ending with 1, from 21
+        *                               (requested by Slavic languages)
+        * @param aResourceIdTwoFour     Resource id to be used in case of
+        *                               units included from two to four, except
+        *                               12-14 (requested by Slavic languages)
+        * @param aResourceIdFiveZero    Resource id to be used in case of
+        *                               units ending from 5 to 9, plus range
+        *                               from 11 to 14 (requested by Slavic
+        *                               languages)
+        * @param aStrings               Array of strings where to add the
+        *                               element
+        */
+        void AddSinglePartOfTimeL( TInt aNumOfElements,
+                                   TInt aResourceIdSingle,
+                                   TInt aResourceIdOneFinal,
+                                   TInt aResourceIdTwoFour,
+                                   TInt aResourceIdFiveZero,
+                                   CDesCArrayFlat* aStrings );
+
+        /**
+        * Add File location line in listbox.
+        * @param aContent   Array containing paths of related MOs
+        * @param aItems     Array where the listbox items have to be added
+        */
+        void AddLocationLineL( const TDesC& aContentPath,
+                               CDesCArray* aItems );
+
+        /**
+        * Add "Usage rights" line
+        * @param aItems         Array where the listbox items have to be added
+        * @param aTypeOfRights  String reporting the type of rights
+                                ContentAccess:EPlay, ContentAccess:EView,
+                                ContentAccess:EExecute and ContentAccess:EPrint
+        */
+        void AddUsageRightsL( CDesCArray* aItems,
+                              const TUint32& aIntent );
+
+        /**
+        * Add "Usage times left" line
+        * @param aCounter       Number of times
+        * @param aItems         Array where the listbox items have to be added
+        * @param aTypeOfRights  String reporting the type of rights
+                                ContentAccess:EPlay, ContentAccess:EView,
+                                ContentAccess:EExecute and ContentAccess:EPrint
+        */
+        void AddUsageTimesLeftL( TUint32 aCounter, CDesCArray* aItems,
+                                 const TUint32& aIntent );
+
+        /**
+        * Add "Rights valid from" line
+        * @param aStartDateTime Start Datetime
+        * @param aItems         Array where the listbox items have to be added
+        * @param aTypeOfRights  String reporting the type of rights
+                                ContentAccess:EPlay, ContentAccess:EView,
+                                ContentAccess:EExecute and ContentAccess:EPrint
+        */
+        void AddRightsValidFromL( const TTime& aStartDateTime,
+                                  CDesCArray* aItems,
+                                  const TUint32& aIntent );
+
+        /**
+        * Add "Rights valid until" line
+        * @param aEndDateTime   Expiring Datetime
+        * @param aItems         Array where the listbox items have to be added
+        * @param aTypeOfRights  String reporting the type of rights
+                                ContentAccess:EPlay, ContentAccess:EView,
+                                ContentAccess:EExecute and ContentAccess:EPrint
+        */
+        void AddRightsValidUntilL( const TTime& aEndDateTime,
+                                   CDesCArray* aItems,
+                                   const TUint32& aIntent );
+
+        /**
+        * Add "Usage time left" line
+        * @param aInterval      Interval of usage time left
+        * @param aItems         Array where the listbox items have to be added
+        * @param aIsAccumulatedTime ETrue if the line is for accumulated time
+
+                                ContentAccess:EPlay, ContentAccess:EView,
+                                ContentAccess:EExecute and ContentAccess:EPrint
+        */
+        void AddUsageTimeLeftL( const TTimeIntervalSeconds& aInterval,
+                                CDesCArray* aItems,
+                                const TBool aIsAccumulatedTime,
+                                const TUint32& aIntent );
+
+    private: //data
+        // The details to be displayed
+        TDetails iDetails;
+
+        // Tells if it has to display details when DRMUI was started embedded.
+        TBool iStartEmbedded;
+
+        //pointer to newly created list box.
+        CEikTextListBox* iListBox;
+
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DRMRightsMgrDetailsView.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,250 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares view for Details class
+*
+*/
+
+
+
+#ifndef DRMRIGHTSMGRDETAILSVIEW_H
+#define DRMRIGHTSMGRDETAILSVIEW_H
+
+// INCLUDES
+#include <aknview.h>
+#include "drmrightsmgrdetailscontainer.h"
+
+// FORWARD DECLARATIONS
+class CDRMRightsMgrDetailsContainer;
+class CDRMRights;
+class DRMCommon;
+
+
+// CLASS DECLARATION
+
+/**
+*  CDRMRightsMgrDetailsView
+*  view class.
+*/
+class CDRMRightsMgrDetailsView : public CAknView
+    {
+    public:
+        // Panic code used in this class
+        enum TDRMUIViewPanicCodes
+            {
+            EDRMUIViewPanicNullPtr = 1      // Failed to create the container
+            };
+
+    public: // Constructors and destructor
+        /**
+        * Constructor.
+        * @param aStartEmbedded ETrue if it has to display details when DRMUI
+        *                       was started embedded.
+        * @param aViewId  ID of the view
+        * @param aContext The context for the help
+        */
+        CDRMRightsMgrDetailsView( TBool aStartEmbedded );
+
+        /**
+        * Symbian OS two-phased constructor
+        * @param aStartEmbedded ETrue if it has to display details when DRMUI
+        *                       was started embedded.
+        * @return DRMUI DetailsView.
+        */
+        static CDRMRightsMgrDetailsView* NewL( TBool aStartEmbedded );
+
+        /**
+        * Symbian OS two-phased constructor
+        * @param aStartEmbedded ETrue if it has to display details when DRMUI
+        *                       was started embedded.
+        * @return DRMUI DetailsView.
+        */
+        static CDRMRightsMgrDetailsView* NewLC( TBool aStartEmbedded );
+
+        /**
+        * Symbian default constructor.
+        * @param aResourceId Title resource
+        */
+        void ConstructL( const TInt aResourceId );
+
+        /**
+        * Destructor.
+        */
+        ~CDRMRightsMgrDetailsView();
+
+
+    public: // from CAknView
+
+        /**
+        * Returns view id.
+        * @return TUid
+        */
+        TUid Id() const;
+
+        /**
+        * Handles the changes of the client rect
+        */
+        void HandleClientRectChange();
+
+
+     public:
+
+        /**
+        * From MEikCommandObserver. Handles commands.
+        * @param aCommand Command to be handled.
+        */
+        void HandleCommandL( TInt aCommand );
+
+
+    protected:
+        /**
+        * From AknView. Called when the view is going to be activated
+        * @param aPrevViewId        Previous View ID. Not used
+        * @param aCustomMessageId   Custom message ID. Not used
+        * @param aCustomMessage     Custom Message. Not used
+        */
+        void DoActivateL(const TVwsViewId& aPrevViewId,
+                        TUid aCustomMessageId,
+                        const TDesC8& aCustomMessage);
+
+        /**
+        * From AknView. Called when the view is going to be deactivated
+        */
+        void DoDeactivate();
+
+        /**
+        * From MEikMenuObserver. Function called by the EIKON framework just
+        * before it displays a menu pane.
+        * @param aResourceId Menu pane resource ID
+        * @param aMenuPane Menu pane pointer
+        */
+        void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+
+
+    public: // new
+        /**
+        * Refreshes the content of the listbox. Used when it is requested to
+        * view details from a RO, e.g. from Keys not in use view or when DRMUI
+        * is started to show only Details View.
+        * @param aRights               The Rights Object
+        * @param aTitle                Title to be showed in the title pane
+        * @param aFullName             Full name of the object
+        * @param aContentCanBeSent     ETrue if the object can be sent
+        * @param aIndividualConstraint ETrue if object has individual constraint
+        * @param aUsageAllowed         ETrue if object use allowed with current SIM
+        */
+        void RefreshListBoxL( CDRMRights* aRights, const TDesC& aTitle,
+                              const TDesC& aFullName,
+                              const TBool aContentCanBeSent = EFalse,
+                              const TBool aIndividualConstraint = EFalse,
+                              const TBool aUsageAllowed = ETrue );
+
+        /**
+        * Refreshes the content of the listbox. Used when it is requested to
+        * view details from a Windows Media DRM license.
+        * @param aArray                The WM DRM Rights Object array
+        * @param aTitle                Title to be showed in the title pane
+        * @param aFullName             Full name of the object
+        */
+        void RefreshListBoxL(
+            ContentAccess::RStreamablePtrArray<ContentAccess::CRightsInfo>& aArray,
+            const TDesC& aTitle,
+            const TDesC& aFullName );
+
+    private:    // new
+
+        /**
+        * Creates the details view container
+        */
+        void CreateContainerL();
+
+        /**
+        * Instantiates the new details view container. Called by DoActivateL.
+        */
+        void NewContainerL();
+
+        /**
+        * Removes the container
+        */
+        void RemoveContainer();
+
+        /**
+        * Sets the title of the view
+        * @param aTitle Text to be showed as the title
+        */
+        void SetTitlePaneL( const TDesC& aTitle );
+
+        /**
+        * Sets Help context
+        * @return The array of help contexts.
+        */
+        CArrayFix<TCoeHelpContext>* HelpContextL() const;
+
+        /**
+        * Sets MSK id + label
+        */
+        void SetMiddleSoftKeyLabelL( const TInt aResourceId,
+                                     const TInt aCommandId );
+
+        /**
+        * Makes the left softkey visible or invisible
+        * @param aVisible   ETrue when the left softkey should be visible.
+        */
+        void MakeLeftSoftkeyVisible( TBool aVisible );
+
+        void DeleteConstraints();
+
+        /**
+        * Initializes and prepares internal data for refreshing of the
+        * list box.
+        * @param aFullName             Full name of the object
+        * @param aDrmScheme            Tells the DRM protection scheme of the file
+        * @param aRights               Data of a Rights Object
+        * @param aContentCanBeSent     ETrue if the object can be sent
+        * @param aIndividualConstraint ETrue if object has individual constraint
+        * @param aUsageAllowed         ETrue if object use allowed with current SIM
+        */
+        void PrepareRefreshL( const TDesC& aFullName,
+                              const TInt& aDrmScheme,
+                              TRights& aRights,
+                              const TBool& aContentCanBeSent,
+                              const TBool& aIndividualConstraint,
+                              const TBool& aUsageAllowed );
+
+        /**
+        * Finalizes refreshing of the list box
+        * @param aTitle                Title to be showed in the title pane
+        * @param aRights               Data of a Rights Object
+        */
+        void FinalizeRefreshL( const TDesC& aTitle,
+                               const TRights& aRights );
+
+    private: // Data
+
+        // Pointer to the container
+        CDRMRightsMgrDetailsContainer* iContainer;
+
+        // ID of the view
+        TUid iViewId;
+
+        // Data about RO to be shown
+        TDetails iDetails;
+
+        // Tells if it has to display details when DRMUI was started embedded.
+        TBool iStartEmbedded;
+    };
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DRMRightsMgrDocument.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declares document for application.
+*
+*/
+
+
+
+#ifndef DRMRIGHTSMGRDOCUMENT_H
+#define DRMRIGHTSMGRDOCUMENT_H
+
+// INCLUDES
+#include <akndoc.h>
+
+#include <genericparamconsumer.h>
+
+#include "drmrightsmanager.hrh"
+
+
+// FORWARD DECLARATIONS
+class CEikAppUi;
+
+// CLASS DECLARATION
+
+/**
+*  CDRMRightsMgrDocument application class.
+*/
+class CDRMRightsMgrDocument : public CAiwGenericParamConsumer
+    {
+    private:
+        /**
+        * Symbian default constructor.
+        * @param aApp The application instance with which the new document is
+        * associated.
+        */
+        CDRMRightsMgrDocument( CEikApplication& aApp );
+
+        /**
+        * Symbian default constructor.
+        */
+        void ConstructL();
+
+
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        * @param aApp   The application instance with which the new document is
+        *               associated.
+        * @return       The document
+        */
+        static CDRMRightsMgrDocument* NewL( CEikApplication& aApp );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CDRMRightsMgrDocument();
+
+
+    public:     // Functions from base classes
+        /**
+        * This function is called when UI has to be opened embedded
+        * @param aDoOpen    Normally ETrue
+        * @param aParams    Not used
+        * @param aFs        Not used
+        * @return           Always NULL
+        */
+        CFileStore* OpenFileL( TBool aDoOpen, const TDesC& aParams, RFs& aFs );
+
+
+    private:
+        /**
+        * From CEikDocument, create CDRMRightsMgrAppUi "App UI" object.
+        * @return The AppUi object
+        */
+        CEikAppUi* CreateAppUiL();
+    };
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DRMUILogger.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,216 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logger utility.
+*
+*/
+
+
+#ifndef DRMUILOGGER_H
+#define DRMUILOGGER_H
+
+
+// INCLUDES
+
+#include <e32std.h>
+#include <e32def.h>
+#include <eikenv.h>
+#include <flogger.h>
+
+
+#ifdef _DEBUG
+#define __TEST_DRM_LOG__
+#endif // _DEBUG
+
+
+#ifdef __TEST_DRM_LOG__
+
+// CONSTANTS
+
+// DRMUI logging directory.
+_LIT( KDRMUILogDir,                   "DRMUI" );
+// DRMUI log file name.
+_LIT( KDRMUILogFile,                  "DRMUI.log" );
+// Format string: enter function.
+_LIT( KDRMUILogEnterFn,               "-> %S" );
+// Format string: leave function.
+_LIT( KDRMUILogLeaveFn,               "<- %S" );
+// Format string: time.
+_LIT( KDRMUILogTimeFormatString,      "%H:%T:%S:%*C2" );
+// Format string: timestamp.
+_LIT( KDRMUILogTimeStampFormatString, "%S %S" );
+//Banner message
+_LIT( KDRMUILogBanner,                "DRMUI 3.0");
+// Message of exit from app
+_LIT( KDRMUILogExit,                  "DRMUI: Application exit");
+
+// DEFINES
+
+// Create the log
+#define CLOG_CREATE                 { FCreate(); }
+
+// Close the log
+#define CLOG_CLOSE                  \
+    {                               \
+    RFileLogger::Write              \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        KDRMUILogExit               \
+        );                          \
+    }
+
+// Write log: enter function.
+#define CLOG_ENTERFN( a )           \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::WriteFormat        \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        KDRMUILogEnterFn,           \
+        &temp                       \
+        );                          \
+    }
+
+// Write log: leave function.
+#define CLOG_LEAVEFN( a )           \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::WriteFormat        \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        KDRMUILogLeaveFn,           \
+        &temp                       \
+        );                          \
+    }
+
+// Write log: string 'a'.
+#define CLOG_WRITE( a )             \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::Write              \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        temp                        \
+        );                          \
+    }
+
+// Write log: formatted.
+#define CLOG_WRITE_FORMAT( a, b )   \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::WriteFormat        \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        temp,                       \
+        b                           \
+        );                          \
+    }
+
+// Write log: timestamp.
+#define CLOG_WRITE_TIMESTAMP( a )                                   \
+    {                                                               \
+    _LIT( temp, a );                                                \
+    TTime time;                                                     \
+    time.HomeTime();                                                \
+    TBuf<32> timeBuf;                                               \
+    TRAPD( err, time.FormatL( timeBuf, KDRMUILogTimeFormatString ) ); \
+    if ( !err )                                                     \
+        {                                                           \
+        RFileLogger::WriteFormat                                    \
+            (                                                       \
+            KDRMUILogDir,                                           \
+            KDRMUILogFile,                                          \
+            EFileLoggingModeAppend,                                 \
+            KDRMUILogTimeStampFormatString,                         \
+            &temp,                                                  \
+            &timeBuf                                                \
+            );                                                      \
+        }                                                           \
+    }
+
+// Write formatted
+#define CLOG_WRITEF                 FPrint
+
+
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, 
+                              EFileLoggingModeAppend, aFmt, list );
+    }
+
+
+inline void FPrint( const TDesC& aDes )
+    {
+    RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, 
+                              EFileLoggingModeAppend, aDes );
+    }
+
+
+inline void FCreate()
+    {
+    TFileName path( _L( "c:\\logs\\" ) );
+    path.Append( KDRMUILogDir );
+    path.Append( _L( "\\" ) );
+    RFs& fs = CEikonEnv::Static()->FsSession();
+    fs.MkDirAll( path );
+    RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, 
+                              EFileLoggingModeOverwrite, KDRMUILogBanner );
+    }
+
+
+#else // not defined __TEST_DRM_LOG__
+
+inline void FPrint( const TRefByValue<const TDesC> /*aFmt*/, ... ) {};
+
+
+// DEFINES
+
+// Empty definition (disable log).
+#define CLOG_CREATE
+
+// Empty definition (disable log).
+#define CLOG_CLOSE
+
+// Empty definition (disable log).
+#define CLOG_ENTERFN( a )
+
+// Empty definition (disable log).
+#define CLOG_LEAVEFN( a )
+
+// Empty definition (disable log).
+#define CLOG_WRITE( a )
+
+// Empty definition (disable log).
+#define CLOG_WRITE_FORMAT( a, b )
+
+// Empty definition (disable log).
+#define CLOG_WRITE_TIMESTAMP( a )
+
+// Empty definition (disable log).
+#define CCDLGLOGGER_WRITEF   1 ? ((void)0) : FPrint
+
+#endif // __TEST_DRM_LOG__
+
+#endif // DRMUILOGGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DrmViewItems.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,266 @@
+/*
+* Copyright (c) 2003-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:  Declares class TViewItems
+*
+*/
+
+
+#ifndef DRMVIEWITEMS_H
+#define DRMVIEWITEMS_H
+
+
+// INCLUDES
+#include "DRMRightsManager.hrh"
+
+
+/**
+* Class containing data for the items to be showed in the view
+*/
+class TItemData
+	{
+    public:  // Constructor
+        /**
+        * C++ default constructor.
+        */      
+        TItemData();
+
+        /**
+        * C++ default constructor.
+        * @param aIndexInArray          Index in array
+        * @param aItemName              Name of the item
+        * @param aItemFullName          Path name of the item
+        * @param aIndexIcon             Index of the icon
+        * @param aTypeOfObject          Attributes of the object
+        * @param aContentCanBeSent      Object can be sent or not
+        * @param aContentURI            Content URI of the object
+        * @param aFutureActivationTime  Time in the future when the RO will be
+        *                               activated.
+        * @param aUnlimitedRights       Rights unlimited or not
+        * @param aIndividualConstraint  Individual constraint exists or not
+        * @param aUsageAllowed          Content usage allowed or not with current SIM
+        */      
+        TItemData( const TInt aIndexInArray,
+                   const TDesC& aItemName, 
+                   const TDesC& aItemFullName, 
+                   const TInt aIndexIcon, 
+                   const TInt aTypeOfObject,
+                   const TBool aContentCanBeSent,
+                   const TDesC8& aContentURI, 
+                   const TTime& aFutureActivationTime,
+                   const TBool aUnlimitedRights,
+                   const TBool aIndividualConstraint,
+                   const TBool aUsageAllowed );
+
+        /**
+        * C++ default constructor.
+        * @param aIndexInArray          Index in array
+        * @param aItemName              Name of the item
+        * @param aItemFullName          Path name of the item
+        * @param aIndexIcon             Index of the icon
+        * @param aTypeOfObject          Attributes of the object
+        * @param aLocalID               Local ID of the object
+        * @param aContentURI            Content URI of the object
+        * @param aFutureActivationTime  Time in the future when the RO will be
+        *                               activated.
+        * @param aUnlimitedRights       Rights unlimited or not
+        */      
+        TItemData( const TInt aIndexInArray,
+                   const TDesC& aItemName, 
+                   const TDesC& aItemFullName, 
+                   const TInt aIndexIcon, 
+                   const TInt aTypeOfObject,
+                   const TUint32 aLocalID,
+                   const TDesC8& aContentURI, 
+                   const TTime& aFutureActivationTime,
+                   const TBool aUnlimitedRights,
+                   const TBool aIndividualConstraint,
+                   const TBool aUsageAllowed );
+                   
+
+
+    public:     // New functions
+        /**
+        * Returns the index of the element in the array.
+        * @return Index in array
+        */
+        inline TInt IndexInArray();
+
+        /**
+        * Returns the name of the item.
+        * @param aItemName The name of the item.
+        */
+        inline void ItemName( TFileName& aItemName );
+
+        /**
+        * Returns the path Name of the item.
+        * @param aItemFullName  The path name of the item.
+        */
+        inline void ItemFullName( TFileName& aItemFullName );
+
+        /**
+        * Returns the index of the icon.
+        * @return Index of the icon to be used for the object.
+        */
+        inline TInt IndexIcon();
+
+        /**
+        * Returns the type of object
+        * @return The type of the object.
+        */
+        inline TInt TypeOfObject();
+
+        /**
+        * Returns the future rights attribute of the object.
+        * @return ETrue if the object has future rights.
+        */
+        inline TBool IsFuture();
+
+        /**
+        * Returns the group attribute of the object.
+        * @return ETrue if the object is a Group.
+        */
+        inline TBool IsGroup();
+
+        /**
+        * Returns if the content can be sent or not.
+        * @return ETrue if the rights object is connected to an object that can
+        * be sent.
+        */
+        inline TBool ContentCanBeSent();
+
+        /**
+        * Returns if objects rights are unlimited or not.
+        * @param aUnlimitedRights ETrue if unlimited rights.
+        */
+        inline TBool UnlimitedRights();
+
+        /**
+        * Returns if object contains individual constraint or not.
+        * @param aIndividualConstraint ETrue if individual constraint
+        */
+        inline TBool IndividualConstraint();
+
+        /**
+        * Returns if object use is allowed with current SIM or not.
+        * @param aUsageAllowed ETrue if allowed
+        */
+        inline TBool UsageAllowed();
+
+        /**
+        * Returns the time in the future when the RO will be activated.
+        * @return The activation time.
+        */
+        inline TTime FutureActivationTime();
+
+        /**
+        * Returns the local ID of the active RO.
+        * @return The local ID.
+        */
+        inline TUint32 LocalID();
+
+        /**
+        * Returns the content URI of the object.
+        * @param aContentURI The content URI.
+        */
+        inline void ContentURI( TBuf8<KMaxFileName>& aContentURI );
+
+        /**
+        * Sets the value for the index in array.
+        * @param aIndex The index to be set.
+        */
+        inline void SetIndexInArray( TInt aIndex );
+
+        /**
+        * Sets the name of the item.
+        * @param aItemName The name of the item.
+        */
+        inline void SetItemName( const TDesC& aItemName );
+
+        /**
+        * Sets the path name of the item.
+        * @param aItemFullName The pathname of the item.
+        */
+        inline void SetItemFullName( const TDesC& aItemFullName );
+
+        /**
+        * Sets the "content can be sent" attribute of the object.
+        * @param aContentCanBeSent ETrue if the content can be sent.
+        */
+        inline void SetContentCanBeSent( const TBool aContentCanBeSent );
+
+        /**
+        * Sets the unlimited rights attribute of the object.
+        * @param aUnlimitedRights ETrue if unlimited rights.
+        */
+        inline void SetUnlimitedRights( const TBool aUnlimitedRights );
+        
+        /**
+        * Sets the individual constraint attribute.
+        * @param aIndividualConstraint ETrue if individual constraint
+        */
+        inline void SetIndividualConstraint( const TBool aIndividualConstraint );
+
+        /**
+        * Sets the usage allowed with current SIM attribute.
+        * @param aUsageAllowed ETrue if allowed
+        */
+        inline void SetUsageAllowed( const TBool aUsageAllowed );
+
+    private:
+        // The index in the array of the elements
+        TInt iIndexInArray;
+
+        // Name of the item
+        TFileName iItemName;
+
+        // Full name of the item
+        TFileName iItemFullName;
+
+        // Index of the icon to be used
+        TInt iIndexIcon;
+
+        // Attributes of the object
+        TInt iTypeOfObject;
+
+        // ETrue if object can be sent
+        TBool iContentCanBeSent;
+
+        // Local ID of the active RO
+        TUint32 iLocalID;
+
+        // Content URI of the object
+        TBuf8<KMaxFileName> iContentURI;
+
+        // Time in the future when the RO will be activated
+        TTime iFutureActivationTime;    
+        
+        // ETrue if unlimited rights
+        TBool iUnlimitedRights;
+        
+        // ETrue if individual constraint exists
+        TBool iIndividualConstraint;
+        
+        // ETrue if content usage is allowed with current SIM
+        TBool iUsageAllowed;
+             
+	};
+
+
+// Include inline functions
+#include "DRMViewItems.inl"
+
+#endif
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/DrmViewItems.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,232 @@
+/*
+* Copyright (c) 2003-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:  TItemData inline functions
+*
+*/
+
+
+#ifndef DRMVIEWITEMS_INL
+#define DRMVIEWITEMS_INL
+
+
+// ---------------------------------------------------------
+// TItemData::IndexInArray
+// ---------------------------------------------------------
+//
+inline TInt TItemData::IndexInArray() 
+    { 
+    return iIndexInArray; 
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::ItemName
+// ---------------------------------------------------------
+//
+inline void TItemData::ItemName( TFileName& aItemName ) 
+    { 
+    aItemName = iItemName; 
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::ItemFullName
+// ---------------------------------------------------------
+//
+inline void TItemData::ItemFullName( TFileName& aItemFullName ) 
+    { 
+    aItemFullName = iItemFullName; 
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::IndexIcon
+// ---------------------------------------------------------
+//
+inline TInt TItemData::IndexIcon()
+    {
+    return iIndexIcon;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::TypeOfObject
+// ---------------------------------------------------------
+//
+inline TInt TItemData::TypeOfObject()
+    {
+    return iTypeOfObject;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::ContentCanBeSent
+// ---------------------------------------------------------
+//
+inline TBool TItemData::ContentCanBeSent()
+    {
+    return iContentCanBeSent;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::UnlimitedRights
+// ---------------------------------------------------------
+//
+inline TBool TItemData::UnlimitedRights()
+    {
+    return iUnlimitedRights;
+    }
+
+// ---------------------------------------------------------
+// TItemData::IndividualConstraint
+// ---------------------------------------------------------
+//
+inline TBool TItemData::IndividualConstraint()
+    {
+    return iIndividualConstraint;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::UsageAllowed
+// ---------------------------------------------------------
+//
+inline TBool TItemData::UsageAllowed()
+    {
+    return iUsageAllowed;
+    }
+
+// ---------------------------------------------------------
+// TItemData::IsFuture
+// ---------------------------------------------------------
+//
+inline TBool TItemData::IsFuture()
+    {
+    return iTypeOfObject & EFutureObject;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::IsGroup
+// ---------------------------------------------------------
+//
+inline TBool TItemData::IsGroup()
+    {
+    return iTypeOfObject & EGroupObject;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::FutureActivationTime
+// ---------------------------------------------------------
+//
+inline TTime TItemData::FutureActivationTime()
+    {
+    return iFutureActivationTime;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::LocalID
+// ---------------------------------------------------------
+//
+inline TUint32 TItemData::LocalID()
+    {
+    return iLocalID;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::ContentURI
+// ---------------------------------------------------------
+//
+inline void TItemData::ContentURI( TBuf8<KMaxFileName>& aContentURI )
+    {
+    aContentURI = iContentURI;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::SetIndexInArray
+// ---------------------------------------------------------
+//
+inline void TItemData::SetIndexInArray( TInt aIndex )
+    {
+    iIndexInArray = aIndex;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::SetItemName
+// ---------------------------------------------------------
+//
+inline void TItemData::SetItemName( const TDesC& aItemName )
+    {
+    iItemName = aItemName;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::SetItemFullName
+// ---------------------------------------------------------
+//
+inline void TItemData::SetItemFullName( const TDesC& aItemFullName )
+    {
+    iItemFullName = aItemFullName;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::SetContentCanBeSent
+// ---------------------------------------------------------
+//
+inline void TItemData::SetContentCanBeSent( const TBool aContentCanBeSent )
+    {
+    iContentCanBeSent = aContentCanBeSent;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::SetUnlimitedRights
+// ---------------------------------------------------------
+//
+inline void TItemData::SetUnlimitedRights( const TBool aUnlimitedRights )
+    {
+    iUnlimitedRights = aUnlimitedRights;
+    }
+
+// ---------------------------------------------------------
+// TItemData::IndividualConstraint
+// ---------------------------------------------------------
+//
+inline void TItemData::SetIndividualConstraint( const TBool aIndividualConstraint )
+    {
+    iIndividualConstraint = aIndividualConstraint;
+    }
+
+
+// ---------------------------------------------------------
+// TItemData::UsageAllowed
+// ---------------------------------------------------------
+//
+inline void TItemData::SetUsageAllowed( const TBool aUsageAllowed )
+    {
+    iUsageAllowed = aUsageAllowed;
+    }
+
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/inc/MDRMMSKObserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,43 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef MDRMMSKOBSERVER_H
+#define MDRMMSKOBSERVER_H
+
+/**
+ *  Observer interface to enable observer to verify currently displayed 
+ *  middle softkey label. The inherited method should be called when 
+ *  the middle softkey label is in need of updating after a navigation 
+ *  event has been detected.
+ */
+class MDRMMSKObserver
+    {
+
+public:
+
+    /**
+     * Observer interface to verify currently displayed middle softkey label.
+     */
+    IMPORT_C virtual void CheckMiddleSoftkeyLabelL() = 0;
+
+    };
+
+
+#endif // MDRMMSKOBSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/loc/DRMRightsManager.loc	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1263 @@
+/*
+* Copyright (c) 2003 - 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:  This is a localisation file for DRMRightsManager
+*
+*/
+
+
+
+//d:Command in options menu.
+//l:list_single_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_view_det        "Licence details"
+
+//d:Command in options menu.
+//l:list_single_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_refresh         "Reload"
+
+//d:Command in options menu.
+//l:list_single_pane_t1_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_del             "Delete"
+
+// Menu item text on main menu
+//d:Command in options menu.
+//l:list_single_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_restore         "Restore licences"
+
+//d:Caption and short caption. "Activ." stands for "Activation"
+//l:cell_app_pane_t1
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr                 "Licences"
+
+//d:Title pane text in main view
+//l:title_pane_t2/opt9
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_title_pane      "Licences"
+
+//d:Error message
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_query_restart   "Unable to access licences. Phone will restart. Continue?"
+
+//d:Error message
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_note_backup     "Unable to access licences. Licence list should be restored."
+
+//d:Empty text in listbox
+//l:main_list_empty_pane
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_no_files        "no licences"
+
+//d:Text to be used when related Media Object is not found in device
+//d:%N is a progressive number
+//l:list_single_graphic_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_no_name         "Unknown %N"
+
+//d:First line of first entry of Details View listbox
+//d:It indicates the current status of the selected Right Object
+//d:Second line is qtn_drm_mgr_det_valid or qtn_drm_mgr_det_exp
+//l:list_double_pane_t1_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_stat        "Status"
+
+//d:Possible second line for first entry of Details View listbox
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_det_valid       "Licence is valid"
+
+//d:Possible second line for first entry of Details View listbox
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_det_exp         "Licence expired"
+
+//d:First line of 'Content in phone' entry in Details View listbox.
+//d:It says if related Media Object is in device or not. If Media object is in device and not in a private
+//directory, it is told whether it is stored in phone memory or memory card.
+//d:Second line is qtn_drm_mgr_det_yes, qtn_drm_mgr_det_no, qtn_drm_mgr_det_phone_memory or qtn_drm_mgr_det_memory_card.
+//l:list_double_pane_t1_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_cip         "Content in phone"
+
+//d:Possible second line of 'Content in phone' entry in Details View listbox.
+//d:It means that related Media object is present in phone, but stored in private directory that cannot be shown.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_yes         "Yes"
+
+//d:Possible second line of 'Content in phone' entry in Details View listbox.
+//d:It means that related Media object is not present in phone.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_no          "No"
+
+//d:First line of third entry of Details View listbox
+//d:It reports if it is possible to send Media Object or not.
+//d:Second line is qtn_drm_mgr_det_allowed or qtn_drm_mgr_det_forbid
+//l:list_double_pane_t1_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_cs          "Content sending"
+
+//d:Possible second line for third entry of Details View listbox
+//d:Sending of the content is allowed
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_allowed     "Allowed"
+
+//d:Possible second line for third entry of Details View listbox
+//d:Sending of the content is forbidden
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_det_forbid      "Not allowed"
+
+//d:Possible first line for fourth entry of Details View listbox
+//d:%U is the type of rigths (qtn_drm_mgr_det2_play, qtn_drm_mgr_det2_display,
+//d:qtn_drm_mgr_det2_execute or qtn_drm_mgr_det2_print)
+//d:Second line is qtn_drm_mgr_det_unlimited, meaning that there are no
+//d:constraints for this type of rights
+//l:list_double_pane_t1_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_full_x      "Rights (%U)"
+
+//d:Possible first line for fourth entry of Details View listbox
+//d:%U is the type of rigths (qtn_drm_mgr_det2_play, qtn_drm_mgr_det2_display,
+//d:qtn_drm_mgr_det2_execute or qtn_drm_mgr_det2_print)
+//d:Second line is qtn_drm_mgr_det_1_count or qtn_drm_mgr_det_n_counts,
+//d:meaning the number of times that this object can be used.
+//l:list_double_pane_t1_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_utl_x       "Times left (%U)"
+
+//d:Possible first line for fourth entry of Details View listbox
+//d:%U is the type of rigths (qtn_drm_mgr_det2_play, qtn_drm_mgr_det2_display,
+//d:qtn_drm_mgr_det2_execute or qtn_drm_mgr_det2_print)
+//d:Second line is qtn_drm_mgr_det_not_act, meaning that this object has not
+//d:been activated yet.
+//l:list_double_pane_t1_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_uts_x       "Times status (%U)"
+
+//d:Possible first line for fourth entry of Details View listbox
+//d:%U is the type of rigths (qtn_drm_mgr_det2_play, qtn_drm_mgr_det2_display,
+//d:qtn_drm_mgr_det2_execute or qtn_drm_mgr_det2_print)
+//d:Second line is qtn_drm_mgr_det_inter or qtn_drm_mgr_det_inter_two, meaning
+//d:a quantity of time that specifies how long this object can be used.
+//l:list_double_pane_t1_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_udl_x       "Time left (%U)"
+
+//d:Possible first line for fourth entry of Details View listbox
+//d:%U is the type of rigths (qtn_drm_mgr_det2_play, qtn_drm_mgr_det2_display,
+//d:qtn_drm_mgr_det2_execute or qtn_drm_mgr_det2_print)
+//d:Second line is a date, meaning when the object started to be valid.
+//l:list_double_pane_t1_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_rvf_x       "Valid from (%U)"
+
+//d:Possible first line for fourth entry of Details View listbox
+//d:%U is the type of rigths (qtn_drm_mgr_det2_play, qtn_drm_mgr_det2_display,
+//d:qtn_drm_mgr_det2_execute or qtn_drm_mgr_det2_print)
+//d:Second line is a date, meaning until when the object is valid.
+//l:list_double_pane_t1_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_rvt_x       "Valid until (%U)"
+
+//d:Second part of the first line of the fourth entry of Details View listbox
+//d:Related Media Object can be played (for example a video)
+//l:list_double_large_graphic_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det2_play       "Play"
+
+//d:Second part of the first line of the fourth entry of Details View listbox
+//d:Related Media Object can be displayed (for example an image)
+//l:list_double_large_graphic_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det2_display    "Display"
+
+//d:Second part of the first line of the fourth entry of Details View listbox
+//d:Related Media Object can be executed (for example an application)
+//l:list_double_large_graphic_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det2_execute    "Execute"
+
+//d:Second part of the first line of the fourth entry of Details View listbox
+//d:Related Media Object can be printed (for example an image or a text)
+//l:list_double_large_graphic_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det2_print      "Print"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:No constraints for this type of Right.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_unlimited   "Unlimited"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:Usage times left is 1: it means that this object can be played, displayed,
+//d:executed or printed (according to the examined type of right) only once
+//d:more.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_1_count     "1 count"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N is the number of counts
+//d:Usage times left is %n: it means that this object can be played, displayed,
+//d:executed or printed (according to the examined type of right) only %N times
+//d:more.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_n_counts    "%N counts"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:Rights not activated
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_not_act     "Not activated"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:There is only one entry for an interval: e.g. "1 year"
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_inter       "%U"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:There are two entries for an interval: e.g. "1 year, 2 months"
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_mgr_det_inter_two   "%0U, %1U"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:It reports that the time constraint for this type of object is 1 year.
+//d:Other quantities of time may follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_years_one        "1 year"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of years of an interval
+//d:It is used for period of years ending with 1 from 21 (21, 31, 41, etc.)
+//d:It reports that the time constraint for this type of object is %N years.
+//d:Other quantities of time may follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_years_one_final  "%N years"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of years of an interval
+//d:It is used for period of years ending from 2 to 4, excluded 12-14 (2-4,
+//d:22-24, 32-34, etc.)
+//d:It reports that the time constraint for this type of object is %N years.
+//d:Other quantities of time may follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_years_two_four   "%N years"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of years of an interval
+//d:It is used for period of years ending from 5 to 0 plus range between 11 and
+//d:14 (5-20, 25-30, 35-40, etc.)
+//d:It reports that the time constraint for this type of object is %N years.
+//d:Other quantities of time may follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_years_five_zero  "%N years"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:It reports that the time constraint for this type of object is 1 month.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_months_one       "1 month"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of months of an interval
+//d:It is used for period from two to four months
+//d:It reports that the time constraint for this type of object is %N months.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_months_two_four  "%N months"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of months of an interval
+//d:It is used for period greater than four months
+//d:It reports that the time constraint for this type of object is %N months.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_months_five_zero "%N months"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:It reports that the time constraint for this type of object is 1 day.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_days_one         "1 day"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of days of an interval
+//d:It is used for a period of 21 days
+//d:It reports that the time constraint for this type of object is %N days.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_days_one_final   "%N days"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of days of an interval
+//d:It is used for period of days ending from 2 to 4, excluded 12-14 (2-4,
+//d:22-24)
+//d:It reports that the time constraint for this type of object is %N days.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_days_two_four    "%N days"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of days of an interval
+//d:It is used for period of days ending from 5 to 0 plus range between 11 and
+//d:14 (5-20, 25-30)
+//d:It reports that the time constraint for this type of object is %N days.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_days_five_zero   "%N days"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:It reports that the time constraint for this type of object is 1 hour.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_hours_one        "1 hour"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of hours of an interval
+//d:It is used for a period of 21 hours
+//d:It reports that the time constraint for this type of object is %N hours.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_hours_one_final  "%N hours"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of hours of an interval
+//d:It is used for period of hours ending from 2 to 4, excluded 12-14 (2-4,
+//d:22-23)
+//d:It reports that the time constraint for this type of object is %N hours.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_hours_two_four   "%N hours"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of hours of an interval
+//d:It is used for a period included from 5 to 20 hours
+//d:It reports that the time constraint for this type of object is %N hours.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_hours_five_zero  "%N hours"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:It reports that the time constraint for this type of object is 1 minute.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_mins_one         "1 minute"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of minutes of an interval
+//d:It is used for period of minutes ending with 1 from 21 (21, 31, 41, 51)
+//d:It reports that the time constraint for this type of object is %N minutes.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_mins_one_final   "%N minutes"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of minutes of an interval
+//d:It is used for period of minutes ending from 2 to 4, excluded 12-14 (2-4,
+//d:22-24, 32-34, 42-44, 52-54)
+//d:It reports that the time constraint for this type of object is %N minutes.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_mins_two_four    "%N minutes"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of minutes of an interval
+//d:It is used for period of minutes ending from 5 to 0 plus range between 11
+//d:and 14 (5-20, 25-30, 35-40, 45-50, 53-59)
+//d:It reports that the time constraint for this type of object is %N minutes.
+//d:Other quantities of time may precede or follow.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_mins_five_zero   "%N minutes"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:It reports that the time constraint for this type of object is 1 second.
+//d:Other quantities of time may precede.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_secs_one         "1 second"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of seconds of an interval
+//d:It is used for period of seconds ending with 1 from 21 (21, 31, 41, 51)
+//d:It reports that the time constraint for this type of object is %N seconds.
+//d:Other quantities of time may precede.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_secs_one_final   "%N seconds"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of seconds of an interval
+//d:It is used for period of seconds ending from 2 to 4, excluded 12-14 (2-4,
+//d:22-24, 32-34, 42-44, 52-54)
+//d:It reports that the time constraint for this type of object is %N seconds.
+//d:Other quantities of time may precede.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_secs_two_four    "%N seconds"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:%N number of seconds of an interval
+//d:It is used for period of minutes ending from 5 to 0 plus range between 11
+//d:and 14 (5-20, 25-30, 35-40, 45-50, 53-59)
+//d:It reports that the time constraint for this type of object is %N seconds.
+//d:Other quantities of time may precede.
+//l:list_double_pane_t2_cp2
+//w:
+//r:2.6
+//
+#define qtn_drm_nbr_of_secs_five_zero   "%N seconds"
+
+//d:Text showed during refreshing
+//l:popup_note_wait_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_wait_refreshing "Reloading"
+
+//d:Confirmation query text used when deleting a Right Object
+//d:%U name of the file
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_auto_del_romo   "If you delete licence, %U will also be deleted. Continue?"
+
+//d:Confirmation query text used when deleting a Right Object
+//d:%U name of the file
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_del_single_ro   "If you delete licence, file %U cannot be used. Continue?"
+
+//d:Confirmation query text proposed to ask if also related file should be deleted
+//d:%U name of the file
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_del_single_cont "Delete file %U also?"
+
+//d:Text during deletion
+//d:%U name of the file
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_wait_del_one_ro "Deleting licence for %U"
+
+//d:Text during deletion
+//d:%U name of the file
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_wait_del_roco   "Deleting %U and licence"
+
+//d:Notification after deletion
+//d:%U name of the file
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_deleted_one_ro  "Licence for %U deleted"
+
+//d:Notification after deletion
+//d:%U name of the file
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_deleted_roco    "Licence and %U deleted"
+
+//d:Confirmation query text
+//d:%U name of the file
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_no_mo_found     "Unable to delete %U. Continue?"
+
+//d:Notification to the user that it is impossible to show the details of the
+//d:selected Rights Object, as the object cannot be found in the database
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_note_ro_removed "Unable to access licence"
+
+
+// NEW STRINGS
+
+//d:First item data text of Main View
+//l:list_single_large_graphic_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_list_valid_keys     "Valid licences"
+
+//d:Second item data text of Main View
+//l:list_single_large_graphic_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_list_invalid_keys   "Invalid licences"
+
+//d:Third item data text of Main View
+//l:list_single_large_graphic_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_list_keys_not_used  "Licenses not in use"
+
+//d:Message query of a list query
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_del_group_ro_descr  "After deleting the licence, several files may not be used"
+
+//d:Title of the list query
+//l:heading_pane_t1
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_del_group_ro_warn   "Warning"
+
+//d:First selectable line of the list query
+//l:list_single_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_view_files_group_ro "View files"
+
+//d:Second selectable line of the list query
+//l:list_single_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_delete_group_ro     "Delete licence to the files"
+
+//d:Notification after deletion
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_deleted_ro          "Licence deleted"
+
+//d:Data query prompt text When renaming an item
+//l:popup_query_data_window
+//w:
+//r:3.0
+//
+#define qtn_album_prmpt_new_name        "New name:"
+
+
+//d:Title pane text for Valid keys View
+//l:title_pane_t2/opt9
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_title_valid_keys    "Valid licences"
+
+//d:Title pane text for Invalid keys View
+//l:title_pane_t2/opt9
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_title_invalid_keys  "Invalid licences"
+
+//d:Title pane text for Keys not in use View
+//l:title_pane_t2/opt9
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_title_keys_not_used "Licences not in use"
+
+//d:Empty text in listbox
+//l:main_list_empty_pane
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_no_related_files    "No related files in device"
+
+
+
+//d:Text to be used when a Group Activation key is found in device. %N is a
+//d:progressive number
+//l:list_single_graphic_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_name_group_key      "Group licence %N"
+
+//d:Menu item used in Group view to see the details of a Media Object.
+//l:list_single_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_group_mo_view_det   "View details"
+
+//d:Possible second line for second entry of Details View listbox
+//d:(qtn_drm_mgr_det_cip), when more than one file is related to the same
+//d:Activation key.
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_det_several_files   "Several files"
+
+//d:First line of an entry of Details View listbox, for a child Activation key.
+//d:Second line is qtn_drm_mgr_det_subscription.
+//l:list_double_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_det_belongs_to      "Belongs to"
+
+//d:Second line of an entry of Details View listbox, for a child Activation key.
+//d:First line is qtn_drm_mgr_det_belongs_to.
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_det_subscription    "Subscription"
+
+//d:First line of an entry of Details View listbox, displayed for the items,
+//d:which are related to multiple valid and/or future ROs. %0N is the number of
+//d:the activation key and %1N is the amount of activation keys.
+//d:Second line is qtn_drm_mgr_det_valid or qtn_drm_mgr_det_not_valid_yet.
+//l:list_double_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_det_ro_number           "Licence %0N/%1N"
+
+//d:Possible second line for first entry (qtn_drm_mgr_det_stat) of Details View
+//d:listbox, when the activation key is missing.
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_det_invalid         "Licence is invalid"
+
+//d:Possible second line for first entry (qtn_drm_det_ro_number) of Details
+//d:View listbox, when the activation key is not yet valid.
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_det_not_valid_yet   "Licence not valid yet"
+
+//d:Command in options menu, used to rename a Group key.
+//l:list_single_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_options_rename      "Rename"
+
+//d:Info note to inform the user that scanning is still running in background
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_info_not_updated    "Lists may not be up-to-date. Scanning still running on the background."
+
+//d:Confirmation note to inform the user that lists are updated.
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_conf_lists_updated  "Scanning is complete. Lists are up-to-date."
+
+//d:Confirmation query to ask if the user really wants to reload the activation
+//d:keys
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_query_reload        "Reloading activation query may take some time. Continue?"
+
+//d:Info note to inform the user that deletion cannot be performed
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_info_unable_delete  "Licence lists are updated. Unable to delete during updating."
+
+//d:Info popup for an activation key with future rights. %U is the date when
+//d:the activation key will start to be valid
+//l:popup_preview_text_window/opt6
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_info_popup_future   "Licence is valid from %U"
+
+//d:Possible first line for fourth entry of Details View listbox
+//d:Second line is qtn_drm_mgr_det_inter or qtn_drm_mgr_det_inter_two, meaning
+//d:a quantity of time that specifies how long this object can be used.
+//l:list_double_pane_t1_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_det_accum_time_left "Usage time left"
+
+//d:Confirmation query text
+//d:Confirmation query text for UDT process confirmation
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_drm_mgr_query_enable_keys "Restore licences and enable on this phone?"
+
+//d:Progress dialog text
+//d:Label for UDT progress note until HTTP connection has been estabilished
+//l:popup_note_wait_window
+//r:3.0
+//
+#define qtn_drm_udt_wait_note_text "Connecting..."
+
+//d:Progress dialog text
+//d:Info notification after successfull UDT process
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_drm_mgr_conf_restore_ready "Restoration complete"
+
+//d:Progress dialog text
+//d:Info message shown during UDT restore process
+//l:popup_note_wait_window
+//r:3.0
+//
+#define qtn_drm_mgr_prgr_restoring_keys "Restoring licences"
+
+
+//d:Text for password editor in multiline query
+//d:Title for connection query password field
+//l:popup_query_data_code_window/opt2
+//r:3.0
+//
+#define qtn_drm_mgr_prompt_txt_password "Password"
+
+//d:Text for http address editor in multiline query
+//d:Title for connection query web address field
+//l:popup_query_data_code_window/opt2
+//r:3.0
+//
+#define qtn_drm_mgr_prompt_txt_web_addr "Web address"
+
+//d:Information note layout
+//d:UDT server address is invalid
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_drm_err_invalid_server_addr "Incorrect web address"
+
+//d:Information note layout
+//d:Incorrect authentication information
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_drm_info_psswrd_request_err "Password is incorrect or request is not authorized"
+
+//d:Information note layout
+//d:No activation keys found from backup file
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_drm_mgr_info_no_backup_ros "No licences to restore"
+
+//d:Information note layout
+//d:Server unavailable
+//l:popup_note_window
+//r:3.0
+//
+#define qtn_drm_mgr_info_server_error "Server is not able to complete the process. Try again later."
+
+//d:Command in options menu.
+//l:list_single_pane_t1_cp2
+//w:
+//r:3.1
+//
+#define qtn_drm_mgr_options_get_new_key "Get new licence"
+
+//d:Confirmation query text
+//d:Shown when user has selected option Get new key, but valid, unlimited rights exist
+//l:popup_note_window
+//w:
+//r:3.1
+//
+#define qtn_drm_mgr_query_unlimited_ro "Licence is valid for unlimited time. Get still new licence?"
+
+//d:First line of an entry of Details View listbox, for an individual constraint.
+//d:Second line is qtn_drm_det_sim_allowed or qtn_drm_det_sim_not_allowed.
+//l:list_double_pane_t1_cp2
+//w:
+//r:3.1
+//
+#define qtn_drm_det_content_use "Content use"
+
+//d:Second line of an entry of Details View listbox, for an individual constraint.
+//d:First line is qtn_drm_det_content_use.
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.1
+//
+#define qtn_drm_det_sim_allowed "Allowed with this SIM"
+
+//d:Second line of an entry of Details View listbox, for an individual constraint.
+//d:First line is qtn_drm_det_content_use.
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.1
+//
+#define qtn_drm_det_sim_not_allowed "Not allowed with this SIM"
+
+//d:Possible second line of 'Content in phone' entry in Details View listbox.
+//d:It means that related Media object is present in phone, and stored in phone memory.
+//This term should be the same which is used when selecting storage place when downloading content.
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.1
+//
+#define qtn_drm_mgr_det_phone_memory         "Phone memory"
+
+//d:Possible second line of 'Content in phone' entry in Details View listbox.
+//d:It means that related Media object is present in phone, and stored in memory card.
+//This term should be the same which is used when selecting storage place when downloading content.
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.1
+//
+#define qtn_drm_mgr_det_memory_card         "Memory card"
+
+//d:First line of 'File location' entry in Details View listbox.
+//d:Second line shows the path of related Media Object in phone.
+//l:list_double_pane_t1_cp2
+//w:
+//r:3.1
+//
+#define qtn_drm_mgr_det_location         "File location"
+
+//d:Middle soft key text in Valid/Invalid/Not in use keys view
+//l:control_pane_t3/opt7
+//w:
+//r:3.1
+//
+#define qtn_msk_drm_key_details         "Details"
+
+//d:Middle soft key text in Group key view
+//l:control_pane_t3/opt7
+//w:
+//r:3.1
+//
+#define qtn_msk_drm_view_details         "Details"
+
+// NEW LOCALIZED STRINGS
+
+//d:First line of first entry of Details View listbox
+//d:It indicates the current status of the selected Right Object
+//d:Second line is qtn_drm_details_valid or qtn_drm_details_not_valid
+//d:or qtn_drm_details_no_licence_available
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+#define qtn_drm_details_status          "License status"
+
+//d:Possible second line for first entry of Details View listbox
+//l:list_double_pane_t2_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_valid       "Licence is valid"
+
+//d:Possible second line for first entry of Details View listbox
+//l:list_double_pane_t2_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_not_valid_yet       "Not valid yet"
+
+//d:Possible second line for first entry of Details View listbox
+//l:list_double_pane_t2_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_no_licence_available       "No licence available"
+
+//d:First line of third entry of Details View listbox
+//d:It reports if it is possible to send Media Object or not.
+//d:Second line is qtn_drm_mgr_det_allowed or qtn_drm_mgr_det_forbid
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_sending          "Sending"
+
+//d:First line of fourth entry of Details View listbox, for an individual constraint.
+//d:Second line is qtn_drm_details_allowed_with_this_sim or
+//d:qtn_drm_details_not_allowed_with_this_sim.
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_content_use         "Content use"
+
+//d:Second line of fourth entry of Details View listbox, for an individual constraint.
+//d:First line is qtn_drm_details_content_use.
+//l:list_double_pane_t2_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_allowed_with_this_sim "Allowed with this SIM"
+
+//d:Second line of fourth entry of Details View listbox, for an individual constraint.
+//d:First line is qtn_drm_details_content_use.
+//l:list_double_pane_t2_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_not_allowed_with_this_sim "Not allowed with this SIM"
+
+//d:Possible first line for second entry of Details View listbox, for
+//d:constraints when the intent is to play the file. Second line is
+//d:qtn_drm_mgr_det_unlimited, meaning that there is no constraint for playing
+//d:the file, or qtn_drm_details_1_time or qtn_drm_details_n_times
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_plays_left      "Plays left"
+
+//d:Possible first line for second entry of Details View listbox, for
+//d:constraints when the intent is to view the file. Second line is
+//d:qtn_drm_mgr_det_unlimited, meaning that there is no constraint for viewing
+//d:the file, or qtn_drm_details_1_time or qtn_drm_details_n_times
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_views_left      "Views left"
+
+//d:Possible first line for second entry of Details View listbox, for
+//d:constraints when the intent is to print the file. Second line is
+//d:qtn_drm_mgr_det_unlimited, meaning that there is no constraint for printing
+//d:the file, or qtn_drm_details_1_time or qtn_drm_details_n_times
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_prints_left      "Prints left"
+
+//d:Possible first line for second entry of Details View listbox, for
+//d:constraints when the intent is to execute the file. Second line is
+//d:qtn_drm_mgr_det_unlimited, meaning that there are is no constraint for
+//d:executing the file, or qtn_drm_details_1_time or qtn_drm_details_n_times
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_exec_times      "Exec times"
+
+//d:Possible second line for second entry of Details View listbox
+//d:Usage times left is 1: it means that this object can be played, displayed,
+//d:executed or printed (according to the examined type of right) only once
+//d:more.
+//l:list_double_pane_t2_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_1_time     "1 time"
+
+//d:Possible second line for second entry of Details View listbox
+//d:%N is the number of counts. Usage times left is %n: it means that this object
+//d:can be played, displayed, executed or printed (according to the examined
+//d:type of right) only %N times more.
+//l:list_double_pane_t2_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_n_times    "%N times"
+
+//d:Possible first line for second entry of Details View listbox, for accumulated
+//d:time constraint. Second line is qtn_drm_mgr_det_inter or
+//d:qtn_drm_mgr_det_inter_two, meaning a quantity of time that specifies how
+//d:long this object can be used.
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_playing_time_left       "Playing time left"
+
+//d:Possible first line for second entry of Details View listbox
+//d:Means validity period of the interval constraint for play and execute intents
+//d:of the file. Only used when the interval has not been activated.
+//d:Second line is qtn_drm_mgr_det_inter or qtn_drm_mgr_det_inter_two, meaning
+//d:a quantity of time that specifies how long this object can be used.
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_validity_period       "Validity period"
+
+//d:Possible first line for second entry of Details View listbox
+//d:Means viewing rights for display/view intent of the file. Only used when
+//d:the interval constraint has not been activated.
+//d:Second line is qtn_drm_mgr_det_inter or qtn_drm_mgr_det_inter_two, meaning
+//d:a quantity of time that specifies how long this object can be used.
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_viewing_rights       "Viewing rights"
+
+//d:Possible first line for second entry of Details View listbox
+//d:Means printing rights for print intent of the file. Only used when
+//d:the interval constraint has not been activated.
+//d:Second line is qtn_drm_mgr_det_inter or qtn_drm_mgr_det_inter_two, meaning
+//d:a quantity of time that specifies how long this object can be used.
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_printing_rights       "Printing rights"
+
+//d:Possible first line for second entry of Details View listbox. Means start time
+//d:constraint for play and execute intents of the file.
+//d:Second line is a date, meaning when the object will be valid.
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_valid_from       "Valid from"
+
+//d:Possible first line for second entry of Details View listbox. Means start time
+//d:constraint for view intent of the file.
+//d:Second line is a date, meaning when the object will be valid.
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_view_rights_from       "View rights from"
+
+//d:Possible first line for second entry of Details View listbox. Means start time
+//d:constraint for print intent of the file.
+//d:Second line is a date, meaning when the object will be valid.
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_print_rights_from       "Print rights from"
+
+//d:Possible first line for second entry of Details View listbox. Means end time
+//d:constraint for play and execute intents of the file. Second line is a date,
+//d:meaning until when the object will be valid.
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_valid_until       "Valid until"
+
+//d:Possible first line for second entry of Details View listbox. Means end time
+//d:constraint for view intent of the file. Second line is a date, meaning until when
+//d:the object will be valid.
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_view_rights_until       "View rights until"
+
+//d:Possible first line for second entry of Details View listbox. Means end time
+//d:constraint for print intent of the file. Second line is a date, meaning until when
+//d:the object will be valid.
+//l:list_double_pane_t1_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_details_print_rights_until       "Print rights until"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:No constraints for Play rights.
+//l:list_double_pane_t2_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_mgr_det_pl_unlimited   "Unlimited"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:No constraints for View rights.
+//l:list_double_pane_t2_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_mgr_det_vi_unlimited   "Unlimited"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:No constraints for Print rights.
+//l:list_double_pane_t2_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_mgr_det_pr_unlimited   "Unlimited"
+
+//d:Possible second line for fourth entry of Details View listbox
+//d:No constraints for Execution rights.
+//l:list_double_pane_t2_cp2
+//w:
+//r:9.1
+//
+#define qtn_drm_mgr_det_ex_unlimited   "Unlimited"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/src/DRMCommonUtilities.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,451 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common utilities functions
+*
+*/
+
+
+// INCLUDE FILES
+#include <stringloader.h>
+#include <aknquerydialog.h>
+#include <aknnotewrappers.h>
+#include <oma2agent.h>
+
+#include <drmrightsmanager.rsg>
+#include <data_caging_path_literals.hrh>
+
+#include <utf.h>
+
+#include "drmcommonutilities.h"
+#include "drmrightsmgrapp.h"
+#include "drmuilogger.h"
+#include "drmrightsmgrappui.h"
+#include "drmutilityinternaltypes.h"
+
+// CONSTANTS
+
+// ROM folder
+_LIT( KDriveZ, "z:" );
+
+// Private folder
+_LIT( KPrivateFolder, "\\private" );
+_LIT( KSystemFolder, "\\system" );
+_LIT( KTempFolder, "\\temp" );
+
+// Name of the MBM file containing icons
+_LIT( KDRMUIMBMFile, "drmrightsmanager.mbm" );
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::ShowConfirmationQueryL
+// -----------------------------------------------------------------------------
+//
+TBool DRMCommonUtilities::ShowConfirmationQueryL( const TInt aResourceId,
+                                                  const TDesC& aString,
+                                                  CCoeEnv* aLoaderEnv )
+    {
+    HBufC* stringNote = StringLoader::LoadLC( aResourceId, aString,
+                                              aLoaderEnv );
+    TBool retVal = ShowConfirmationQueryL( *stringNote );
+    CleanupStack::PopAndDestroy( stringNote ); // stringNote
+
+    return retVal;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::ShowConfirmationQueryL
+// -----------------------------------------------------------------------------
+//
+TBool DRMCommonUtilities::ShowConfirmationQueryL( const TInt aResourceId,
+                                                  CCoeEnv* aLoaderEnv )
+    {
+    HBufC* stringNote = StringLoader::LoadLC( aResourceId, aLoaderEnv );
+    TBool retVal = ShowConfirmationQueryL( *stringNote );
+    CleanupStack::PopAndDestroy( stringNote ); // stringNote
+
+    return retVal;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::ShowConfirmationQueryL
+// -----------------------------------------------------------------------------
+//
+TBool DRMCommonUtilities::ShowConfirmationQueryL( const TDesC& aPrompt )
+    {
+    CAknQueryDialog *queryDialog = CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
+
+    return queryDialog->ExecuteLD( R_DRM_CONFIRMATION_QUERY, aPrompt ) != 0;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::ShowConfirmationNoteL
+// -----------------------------------------------------------------------------
+//
+void DRMCommonUtilities::ShowConfirmationNoteL( const TInt aResourceId,
+                                                const TDesC& aString,
+                                                CCoeEnv* aLoaderEnv )
+    {
+    HBufC* stringNote = StringLoader::LoadLC( aResourceId, aString,
+                                              aLoaderEnv );
+    ShowConfirmationNoteL( *stringNote );
+    CleanupStack::PopAndDestroy( stringNote ); // stringNote
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::ShowConfirmationNoteL
+// -----------------------------------------------------------------------------
+//
+void DRMCommonUtilities::ShowConfirmationNoteL( const TInt aResourceId,
+                                                CCoeEnv* aLoaderEnv )
+    {
+    HBufC* stringNote = StringLoader::LoadLC( aResourceId, aLoaderEnv );
+    ShowConfirmationNoteL( *stringNote );
+    CleanupStack::PopAndDestroy( stringNote ); // stringNote
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::ShowConfirmationNoteL
+// -----------------------------------------------------------------------------
+//
+void DRMCommonUtilities::ShowConfirmationNoteL( const TDesC& aPrompt )
+    {
+    CAknConfirmationNote* confNote = new( ELeave )CAknConfirmationNote(
+                                                                    ETrue );
+    confNote->ExecuteLD( aPrompt );
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::ShowConfirmationNoteL
+// -----------------------------------------------------------------------------
+//
+void DRMCommonUtilities::ShowInformationNoteL( const TInt aResourceId,
+                                               CCoeEnv* aLoaderEnv )
+    {
+    HBufC* stringLabel = StringLoader::LoadLC( aResourceId, aLoaderEnv );
+    CAknInformationNote* dialog = new( ELeave )CAknInformationNote( ETrue );
+    dialog->ExecuteLD( *stringLabel );
+    CleanupStack::PopAndDestroy( stringLabel );   // stringLabel
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::GetFutureActivationTime
+// -----------------------------------------------------------------------------
+//
+TTime DRMCommonUtilities::GetFutureActivationTime( CDRMRights& aRights )
+    {
+    CDRMRightsConstraints* constraints = NULL;
+    TTime playStartTime( Time::MaxTTime() );
+    TTime displayStartTime( Time::MaxTTime() );
+    TTime printStartTime( Time::MaxTTime() );
+    TTime executeStartTime( Time::MaxTTime() );
+
+    aRights.GetPlayRight( constraints );
+    if ( constraints )
+        {
+        constraints->GetStartTime( playStartTime );
+        delete constraints;
+        constraints = NULL;
+        }
+
+    aRights.GetDisplayRight( constraints );
+    if ( constraints )
+        {
+        constraints->GetStartTime( displayStartTime );
+        delete constraints;
+        constraints = NULL;
+        }
+
+    aRights.GetPrintRight( constraints );
+    if ( constraints )
+        {
+        constraints->GetStartTime( printStartTime );
+        delete constraints;
+        constraints = NULL;
+        }
+
+    aRights.GetExecuteRight( constraints );
+    if ( constraints )
+        {
+        constraints->GetStartTime( executeStartTime );
+        delete constraints;
+        constraints = NULL;
+        }
+
+    return ( Min( Min( playStartTime, displayStartTime ),
+                  Min( printStartTime, executeStartTime ) ) );
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::GetIconsFileName
+// -----------------------------------------------------------------------------
+//
+void DRMCommonUtilities::GetIconsFileName( TDes& aIconsFileName )
+    {
+    aIconsFileName.Append( KDriveZ );
+    aIconsFileName.Append( KDC_APP_BITMAP_DIR );
+    aIconsFileName.Append( KDRMUIMBMFile );
+
+    return;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::IsInPrivateFolderL
+// -----------------------------------------------------------------------------
+//
+TBool DRMCommonUtilities::IsInPrivateFolderL( const TDesC& aContentPath )
+    {
+    TInt retval = EFalse;
+    TParse path;
+    User::LeaveIfError( path.Set( KNullDesC, &aContentPath, NULL ) );
+
+    HBufC* driveBuf = HBufC::NewLC( KMaxFileName );
+
+    TPtr driveAndPath( const_cast<TUint16*>( driveBuf->Ptr()), 0, KMaxFileName );
+    driveAndPath = path.DriveAndPath();
+    driveAndPath.LowerCase();
+
+    retval = ( driveAndPath.Find( KPrivateFolder ) == path.Drive().Length() ||
+               driveAndPath.Find( KSystemFolder ) == path.Drive().Length() ||
+               driveAndPath.Find( KTempFolder ) == path.Drive().Length() );
+    CleanupStack::PopAndDestroy( driveBuf );
+    return retval;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::RightsIssuerUrlL
+// -----------------------------------------------------------------------------
+//
+TInt DRMCommonUtilities::RightsIssuerUrlL( const TFileName& aFileName,
+                                           HBufC*& aRightsIssuerURL )
+    {
+    TVirtualPathPtr virtualPath( aFileName, KDefaultContentObject );
+    TBuf<KUrlMaxLen> rightsIssuer;
+    TInt retval( KErrNone );
+
+    CData* content = NULL;
+    TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( r == KErrInUse )
+        {
+        content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+        }
+    else if ( r != KErrNone )
+        {
+        retval = r;
+        }
+
+    CleanupStack::PushL( content );
+
+    if ( retval == KErrNone )
+        {
+        // Get value of rights-issuer header field
+        retval = content->GetStringAttribute( ERightsIssuerUrl, rightsIssuer );
+        if ( ( retval == KErrNone ) && ( rightsIssuer.Length() != 0 ) )
+            {
+            aRightsIssuerURL = rightsIssuer.AllocL();
+            }
+        else
+            {
+            delete aRightsIssuerURL;
+            aRightsIssuerURL = NULL;
+            retval = KErrNotFound;
+            }
+        }
+    CleanupStack::PopAndDestroy( content );
+    return retval;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::GetRightsStatus
+// -----------------------------------------------------------------------------
+//
+TInt DRMCommonUtilities::GetRightsStatus( CDRMRights& aRights,
+                                          CDRMRights::TExpiration& aExpir)
+    {
+    TUint32 constraintSpec = 0;
+    CDRMRights::TRestriction restriction;
+    TUint32 constType;
+    TInt err = KErrNone;
+
+    err = aRights.GetRightsInfo( constraintSpec, restriction, aExpir, constType );
+
+    return err;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::ParseParametersAndStartL
+// -----------------------------------------------------------------------------
+//
+void DRMCommonUtilities::ParseParametersAndStartL( TLex aLex,
+                                                   TBool aStartEmbedded,
+                                                   CDRMRightsMgrAppUi& aAppUi )
+    {
+    CArrayFixFlat<TPtrC>* params;       // array of parameters
+    HBufC* url16( NULL );
+    HBufC* fullName( NULL );
+    TUint32 drmScheme( EDrmSchemeUnknownDrm );
+    params = new( ELeave )CArrayFixFlat<TPtrC>( sizeof( TPtrC ) );
+    CleanupStack::PushL( params );
+
+    while ( !aLex.Eos() )                // Extract the parameters
+        {
+        params->AppendL( aLex.NextToken() );
+        }
+
+    TInt startParam = KMaxTInt;
+
+    // Parse the DRM Rights Manager launch parameter string. First parameter
+    // indicates the launching type (embedded, stand alone, embedded with full
+    // path name parameter or stand alone with full path name parameter), second
+    // parameter is Local ID for OMA DRM file, third one is the content URI in
+    // case of OMA DRM and full file path name in case of WM DRM, whereas the fourth
+    // parameter indicates the DRM protection scheme of the file for which the
+    // details view has been launched. The fifth parameter is the full file path in
+    // case of an OMA DRM file.
+    TLex lexStart ( params->At( 0 ) );
+
+    // First parameter: type of operation to be performed
+    User::LeaveIfError( lexStart.Val( startParam ) );
+
+    if ( ( aStartEmbedded && ( startParam == EDrmLaunchParamEmbeddedHelper ||
+        startParam == EDrmLaunchParamEmbeddedUtility ) ) ||
+         ( !aStartEmbedded && ( startParam == EDrmLaunchParamStandAloneHelper ||
+        startParam == EDrmLaunchParamStandAloneUtility ) ) )
+        {
+        TUint32 localID;
+
+        TLex lexLocalID ( params->At( 1 ) );
+
+        // Second parameter: LocalID
+        User::LeaveIfError( lexLocalID.Val( localID, EDecimal ) );
+
+        // Third parameter: Content URI
+        HBufC8* contentURI = HBufC8::NewLC( params->At( 2 ).Length() );
+        contentURI->Des().Copy( params->At( 2 ) );
+
+        if ( params->Count() > 3 && ( startParam == EDrmLaunchParamEmbeddedUtility
+            || startParam == EDrmLaunchParamStandAloneUtility ) )
+            {
+
+            // Fourth parameter: DRM protection scheme
+            TLex lexDrmType( params->At( 3 ) );
+            lexDrmType.Val( drmScheme, EDecimal );
+
+            TParse parser;
+
+            if ( drmScheme == EDrmSchemeWmDrm )
+                {
+                // We have a WM DRM file
+                // Find out the file name and the item name and store them to
+                // the file details.
+                url16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+                    contentURI->Des() );
+                CleanupStack::PushL( url16 );
+
+                if ( url16 )
+                    {
+                    // The received fourth parameter already has the
+                    // full path name
+                    aAppUi.SetSelectedItemFullName( url16->Des() );
+                    User::LeaveIfError( parser.Set( url16->Des(), NULL, NULL ) );
+                    // Get the file name and extension
+                    aAppUi.SetSelectedItemName( parser.NameAndExt() );
+                    }
+                CleanupStack::PopAndDestroy( url16 );
+                }
+
+            // Fifth parameter: Full file path for OMA DRM
+            if ( drmScheme == EDrmSchemeOmaDrm &&
+                ( startParam == EDrmLaunchParamEmbeddedUtility ||
+                startParam == EDrmLaunchParamStandAloneUtility ) )
+                {
+                // Find out the file name and the item name and store them to
+                // the file details.
+                fullName = HBufC::NewLC( params->At( 4 ).Length() );
+                fullName->Des().Copy( params->At( 4 ) );
+
+                aAppUi.SetSelectedItemFullName( fullName->Des() );
+                User::LeaveIfError( parser.Set( fullName->Des(), NULL, NULL ) );
+                // Get the file name and extension
+                aAppUi.SetSelectedItemName( parser.NameAndExt() );
+                CleanupStack::PopAndDestroy( fullName );
+                }
+            }
+        else
+            {
+            // DRM Helper has launched DRM Rights Manager. Currently DRM Helper
+            // blocks attempts to launch DRM Rights Manager for both the plain
+            // and WM DRM content.
+            drmScheme = EDrmSchemeOmaDrm;
+            }
+
+        aAppUi.StartOnlyForDetailsL( *contentURI, localID, aStartEmbedded,
+            drmScheme );
+
+        CleanupStack::PopAndDestroy( contentURI );
+        }
+
+    CleanupStack::PopAndDestroy( params );
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommonUtilities::SplitPath
+// -----------------------------------------------------------------------------
+//
+TPtrC DRMCommonUtilities::SplitPath( const TDesC& aFileName, TPtrC& aRestOfName )
+    {
+    TPtrC ptr( KNullDesC );
+    TInt pos = aFileName.Locate('\\'); // first backslash
+    TInt length = aFileName.Length();
+
+    if ( pos != KErrNotFound && pos < length )
+        {
+        TInt totalPos = pos;
+        TPtrC name1 = aFileName.Mid(totalPos + 1);
+        pos = name1.Locate('\\'); // second backslash
+        length = name1.Length();
+
+        if ( pos != KErrNotFound && pos < length )
+            {
+            totalPos += pos + 1;
+            TPtrC name2 = aFileName.Mid(totalPos + 1);
+            pos = name2.Locate('\\'); // third backslash
+            length = name2.Length();
+
+            if ( pos != KErrNotFound && pos < length )
+                {
+                totalPos += pos + 1;
+                aRestOfName.Set( aFileName.Mid( totalPos + 1, aFileName.Length() - 1 - totalPos ));
+                // return the leftmost part of the filename up to third backslash
+                return aFileName.Mid(0, totalPos + 1);
+                }
+            }
+        }
+    return ptr;
+    }
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/src/DRMRightsMgrApp.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Implementation of CDRMRightsMgrApp class
+*
+*/
+
+
+// INCLUDE FILES
+#include <eikstart.h>
+
+#include "drmrightsmgrapp.h"
+#include "drmrightsmgrdocument.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// ---------------------------------------------------------
+// CDRMRightsMgrApp::AppDllUid
+// ---------------------------------------------------------
+//
+TUid CDRMRightsMgrApp::AppDllUid() const
+    {
+    return KUidDRMRightsManager;
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrApp::CreateDocumentL
+// ---------------------------------------------------------
+//
+CApaDocument* CDRMRightsMgrApp::CreateDocumentL()
+    {
+    return CDRMRightsMgrDocument::NewL( *this );
+    }
+
+
+// ================= OTHER FUNCTIONS =======================
+//
+
+// ---------------------------------------------------------
+// NewApplication
+// ---------------------------------------------------------
+//
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CDRMRightsMgrApp;
+    }
+
+
+// ---------------------------------------------------------
+// E32Main
+// ---------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication( NewApplication );
+    }
+
+
+// ---------------------------------------------------------
+// Panic
+// ---------------------------------------------------------
+//
+void Panic( TInt aReason )
+    {
+    _LIT( KAppName, "DRM RightsMgrUI" );
+    User::Panic( KAppName, aReason );
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/src/DRMRightsMgrAppUi.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,927 @@
+/*
+* Copyright (c) 2003 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of CDRMRightsMgrAppUi class
+*
+*/
+
+
+// INCLUDE FILES
+#include <dcfrep.h>
+#include <dcfentry.h>
+#include <drmcommon.h>
+#include <dcfcommon.h>
+#include <wmdrmagent.h> // for WMDRM file details view
+
+#include <drmrightsmanager.rsg>
+
+#include <aknwaitdialog.h>
+#include <aknlistquerydialog.h>
+#include <stringloader.h>
+#include <aknnavide.h>
+#include <akndef.h>
+#include <barsread.h>  // for resource reader
+#include <centralrepository.h>
+#include <coeutils.h>
+
+#include <starterclient.h>
+
+// character conversions
+#include <utf.h>
+
+// caf
+#include <caf/data.h>
+#include <caf/caftypes.h>
+
+#include "drmrightsmgrappui.h"
+#include "drmrightsmgrdetailsview.h"
+#include "drmrightsmgrdocument.h"
+#include "drmcommonutilities.h"
+#include "drmuilogger.h"
+#include "drmrightsmanagerprivatecrkeys.h"
+#include "drmclockclient.h"
+#include "drmutilityinternaltypes.h"
+
+#include "oma1dcf.h"
+#include "oma2dcf.h"
+// CONSTANTS
+_LIT8( Kflk, "flk:" );
+_LIT8( Kldf, "ldf:" );
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// -----------------------------------------------------------------------------
+// CDRMRightsMgrAppUi::CDRMRightsMgrAppUi
+// -----------------------------------------------------------------------------
+//
+CDRMRightsMgrAppUi::CDRMRightsMgrAppUi()
+: iStartEmbedded( EFalse ),
+  iStatusScan( EDRMStatusFinished ),
+  iDrmScheme( EDrmSchemeUnknownDrm ),
+  iLocalID( 0 ),
+  iContentURI( NULL ),
+  iForegroundHasBeenActive( EFalse )
+    {
+    CLOG_WRITE( "CDRMRightsMgrAppUi::CDRMRightsMgrAppUi" );
+    }
+
+
+// ---------------------------------------------------------
+// void CDRMRightsMgrAppUi::ConstructL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::ConstructL()
+    {
+    CLOG_WRITE( "-->ConstructL" );
+    
+    iCoeEnv->AddForegroundObserverL( *this );
+    
+    CDRMRightsMgrDetailsView* detailsView( NULL );
+
+    BaseConstructL( EAknEnableSkin | EAppOrientationAutomatic | 
+    	EAknEnableMSK | EAknSingleClickCompatible  );
+
+    User::LeaveIfError( iRightsClient.Connect() );
+    iDRMCommon = DRMCommon::NewL();
+    if ( !iDRMCommon )
+        {
+        ProcessEngineErrorL( ETrue );
+        }
+
+    iStartEmbedded = iEikonEnv->StartedAsServerApp();
+
+    // Create details view
+    if ( iStartEmbedded )
+        {
+        detailsView = CDRMRightsMgrDetailsView::NewLC( ETrue );
+        }
+    else
+        {
+        detailsView = CDRMRightsMgrDetailsView::NewLC( EFalse );
+        }
+
+    AddViewL( detailsView );      // transfer ownership to CAknViewAppUi
+    CleanupStack::Pop( detailsView );
+    }
+
+
+// ----------------------------------------------------
+// CDRMRightsMgrAppUi::~CDRMRightsMgrAppUi
+// ----------------------------------------------------
+//
+CDRMRightsMgrAppUi::~CDRMRightsMgrAppUi()
+    {
+    
+    iCoeEnv->RemoveForegroundObserver( *this );
+    
+    delete iWaitDialog;
+
+    delete iDRMCommon;
+
+    iRightsClient.Close();
+
+    if ( iStartEmbedded && iDoorObserver )
+        {
+        iDoorObserver->NotifyExit( MApaEmbeddedDocObserver::ENoChanges );
+        }
+        
+    if ( iContentURI )
+        {
+        delete iContentURI;
+        }
+        
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::HandleKeyEventL
+// ---------------------------------------------------------
+//
+TKeyResponse CDRMRightsMgrAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent,
+                                                  TEventCode /*aType*/ )
+    {
+    TChar charCode( aKeyEvent.iCode );
+
+    if ( charCode == EKeyEnter )
+        // Default is to show details
+        {
+        TInt command = EDRMRightsManagerCmdAppViewDet;
+        HandleCommandL( command );
+        return EKeyWasConsumed;
+        }
+    else if ( charCode == EKeyLeftArrow || charCode == EKeyRightArrow
+        || charCode == EKeyBackspace )
+        {
+        return EKeyWasConsumed;
+        }
+
+    return EKeyWasNotConsumed;
+    }
+
+
+// ----------------------------------------------------
+// CDRMRightsMgrAppUi::HandleCommandL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::HandleCommandL( TInt aCommand )
+    {
+
+    switch ( aCommand )
+        {
+        case EEikCmdExit:
+        case EAknSoftkeyExit:
+            {
+            Exit();
+            break;
+            }
+        default:
+            break;
+        }
+    }
+
+
+// ----------------------------------------------------
+// CDRMRightsMgrAppUi::StartOnlyForDetailsL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::StartOnlyForDetailsL( const TDesC8& aContentURI,
+                                               const TUint32 aLocalID,
+                                               const TBool aEmbedded,
+                                               const TInt aDrmScheme )
+    {
+
+    // Store the content related information when the details view 
+    // is to be shown for the first time so that the information will be
+    // available for details view refreshing in the future.
+    if ( !iContentURI )
+        {
+        iDrmScheme = aDrmScheme;
+        iLocalID = aLocalID;
+        iContentURI = aContentURI.AllocL();
+        }
+    
+    // For storing WM DRM rights information
+    ContentAccess::RStreamablePtrArray<ContentAccess::CRightsInfo> array;
+    CleanupClosePushL( array );
+
+    TInt status( KErrCANoRights );
+    CDRMRights* rights = NULL;
+
+    if ( aEmbedded )
+        {
+        iStatusScan = EDRMStatusOpeningEmbedded;
+        }
+    else
+        {
+        iStatusScan = EDRMStatusOpening;
+        }
+
+    // Check the status of rights. Currently supports OMA and WM DRM.
+    switch ( iDrmScheme )
+        {
+        case EDrmSchemeOmaDrm:
+            CheckOmaDrmRightsL( aContentURI, aLocalID, rights, status );
+            if ( status ) 
+                {
+                rights = NULL;
+                }
+            break;
+
+        case EDrmSchemeWmDrm:
+            CheckWmDrmRightsL( aContentURI, status, array );
+            break;
+
+        default:
+            break;
+        }
+
+    TFileName itemName;
+    TFileName fullName;
+
+    // Find the name and full name for the current item
+    SelectedItemName( itemName );
+    SelectedItemFullName( fullName );
+
+    TUid uidView = TUid::Uid( EDRMDetailsView );
+    CDRMRightsMgrDetailsView* detailsView =
+                                ( CDRMRightsMgrDetailsView* )View( uidView );
+    if ( detailsView )
+        {
+        if ( !aEmbedded )
+            {
+            // If DRM Rights manager has not been launched as embedded,
+            // activate details wiew as a local view.
+            ActivateLocalViewL( uidView );
+            }
+
+            // Refresh the details view window with rights information of the
+            // current item
+            switch ( iDrmScheme )
+                {
+                case EDrmSchemeOmaDrm:
+                    // Refresh the listbox
+                    TRAP( status, detailsView->RefreshListBoxL( rights, itemName,
+                        fullName, SelectedContentCanBeSent(), IndividualConstraint(),
+                        UsageAllowed() ) );
+                    break;
+
+                case EDrmSchemeWmDrm:
+                    // WM DRM, Refresh the listbox
+                    TRAP( status, detailsView->RefreshListBoxL( array,
+                        itemName, fullName ) );
+                    break;
+
+                default:
+                    break;
+                }
+
+            if ( status != KErrNone )
+                {
+                // If there was an error, show to the user
+                ProcessEngineErrorL( ETrue );
+            }
+        }
+    if ( rights )
+        {
+        delete rights;
+        }
+
+    CleanupStack::PopAndDestroy( &array );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrAppUi::CreateWaitDialogLC
+// ----------------------------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::CreateWaitDialogLC()
+    {
+    if ( iWaitDialog )
+        {
+        delete iWaitDialog;
+        iWaitDialog = NULL;
+        }
+
+    // Create WaitDialog with message and Cancel button
+    iWaitDialog = new( ELeave )CAknWaitDialog( ( REINTERPRET_CAST(
+                                CEikDialog**, &iWaitDialog ) ), EFalse );
+
+    iWaitDialog->SetCallback( this );
+    iWaitDialog->PrepareLC( R_WAITNOTE );
+
+    iWaitDialog->RunLD();
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrAppUi::GetItemNameL
+// ----------------------------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::GetItemNameL( const TDesC& aFullName,
+                                       TDes& aItemName,
+                                       const TDesC8& aID,
+                                       const TBool aIsGroup )
+    {
+    CDcfCommon* dcf = NULL;
+    TBool getName = ETrue;
+    TParse parse;
+
+    // don't get the name if dealing with a file from a group
+    if ( !aIsGroup )
+        {
+        TRAPD( r, dcf = CDcfCommon::NewL( aFullName ) );
+        if ( r == KErrNone &&
+             dcf &&
+             dcf->iVersion == EOma2Dcf &&
+             static_cast<COma2Dcf*>( dcf )->iGroupId )
+            {
+            getName = EFalse;
+            parse.Set( aFullName, NULL, NULL );
+            aItemName = parse.NameAndExt();
+            }
+        delete dcf;
+        }
+    if ( getName )
+        {
+        HBufC* itemNameBuf = NULL;
+        TInt err = iRightsClient.GetName( aID, itemNameBuf );
+
+        if ( err == KErrNotFound || itemNameBuf->Length() == 0 )
+            {
+            if ( aIsGroup )
+                {
+                aItemName = aFullName;
+                }
+            else
+                {
+                parse.Set( aFullName, NULL, NULL );
+                aItemName = parse.NameAndExt();
+                }
+            }
+        else if ( err == KErrNone )
+            {
+            aItemName = *itemNameBuf;
+            }
+        else
+            {
+            User::Leave( err );
+            }
+
+        if ( itemNameBuf )
+            {
+            delete itemNameBuf;
+            }
+        }
+    }
+
+
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrAppUi::GetItemDataL
+// ----------------------------------------------------------------------------
+//
+TInt CDRMRightsMgrAppUi::GetItemDataL( const TDesC& aFileName,
+                                       const TDesC8& aContentURI,
+                                       TBool& aListable,
+                                       TBool& aSendable )
+    {
+    TInt retval( KErrNone );
+    aSendable = aListable = EFalse;
+    HBufC8* buffer;
+
+    if ( DRMCommonUtilities::IsInPrivateFolderL( aFileName ) )
+        {
+        if ( aContentURI.Left( 4 ).Compare( Kflk ) == 0 )
+            {
+            // FL or CD content
+            if ( iRightsClient.ForwardLockURI( buffer ) == KErrNone &&
+                 buffer )
+                {
+                if ( aContentURI.Compare( *buffer ) != 0 ) //forward lock content?
+                    {
+                    // CD content
+                    aListable = ETrue;
+                    }
+                delete buffer;
+                }
+            else
+                {
+                retval = KErrGeneral;
+                }
+            }
+        else if (aContentURI.Left( 4 ).Compare( Kldf ) != 0) //local data file?
+            {
+            // SD or OMA DRM2 content
+            // also rights issuer url existence SHOULD be checked but not possible here
+            aListable = aSendable = ETrue;
+            }
+        }
+    else
+        {
+        if ( ConeUtils::FileExists( aFileName ) )
+            {
+            TInt protection;
+            CData* content = NULL;
+            TVirtualPathPtr virtualPath( aFileName, KDefaultContentObject );
+
+            TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+            if ( r == KErrInUse )
+                {
+                content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+                }
+            else if ( r != KErrNone )
+                {
+                retval = r;
+                }
+            CleanupStack::PushL( content );
+
+            if ( retval == KErrNone )
+                {
+                retval = content->GetAttribute( EDeliveryMethod, protection );
+                if ( retval == KErrNone )
+                    {
+                    aListable = ( protection == EOmaDrm1ForwardLockDcf ||
+                                  protection == EOmaDrm1CombinedDelivery ||
+                                  protection == EOmaDrm1CombinedDeliveryDcf ||
+                                  protection == EOmaDrm1SeparateDelivery ||
+                                  protection == EOmaDrm2 );
+
+                    if ( protection == EOmaDrm1SeparateDelivery ||
+                         protection == EOmaDrm2 )
+                        {
+                        TBuf<KUrlMaxLen> rightsIssuer;
+
+                        // Get rights issuer URL
+                        retval = content->GetStringAttribute( ERightsIssuerUrl, rightsIssuer );
+                        if ( ( retval == KErrNone ) && ( rightsIssuer.Length() > 0 ) )
+                            {
+                            aSendable = ETrue;
+                            }
+                        else
+                            {
+                            // Can't be sent, any error returned can be ignored
+                            aSendable = EFalse;
+                            retval = KErrNone;
+                            }
+                        }
+                    }
+                }
+            CleanupStack::PopAndDestroy( content );
+            }
+        }
+
+    return retval;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrAppUi::DialogDismissedL
+// ----------------------------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::DialogDismissedL( TInt aButtonId )
+    {
+    if ( aButtonId == -1 )
+        {
+        // When pressing cancel button.
+        // Only cancel if we know that there is an outstanding request
+        if ( iStatusScan == EDRMStatusOpening ||
+             iStatusScan == EDRMStatusOpeningEmbedded )
+            {
+            // Issue cancel to service provider
+            iRightsClient.Cancel();
+
+            if ( iStatusScan == EDRMStatusOpening )
+                {
+                // Cancel pressed when opening application --> Exit
+                HandleCommandL( EEikCmdExit );
+                }
+            else if ( iStatusScan == EDRMStatusOpeningEmbedded )
+                {
+                // Cancel pressed when opening application embedded -->
+                // Shut the app
+                RunAppShutter();
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------
+// CDRMRightsMgrAppUi::HandleGainingForeground()
+// ----------------------------------------------------
+//
+void CDRMRightsMgrAppUi::HandleGainingForeground()
+    {
+    // Refresh details view when the details view is returned
+    // from the background to the foreground.
+    if ( iForegroundHasBeenActive && iContentURI )
+        {
+        StartOnlyForDetailsL( iContentURI->Des(), iLocalID, 
+            iStartEmbedded, iDrmScheme );
+        }
+    }
+
+
+// ----------------------------------------------------
+// CDRMRightsMgrAppUi::HandleLosingForeground()
+// ----------------------------------------------------
+//
+void CDRMRightsMgrAppUi::HandleLosingForeground()
+    {
+    iForegroundHasBeenActive = ETrue;
+    }
+
+// ----------------------------------------------------
+// CDRMRightsMgrAppUi::NotifyExit
+// ----------------------------------------------------
+//
+void CDRMRightsMgrAppUi::NotifyExit( TExitMode /*aMode*/ )
+    {
+    }
+
+
+// ----------------------------------------------------
+// CDRMRightsMgrAppUi::HandleResourceChangeL
+// ----------------------------------------------------
+//
+void CDRMRightsMgrAppUi::HandleResourceChangeL( TInt aType )
+    {
+
+    CAknViewAppUi::HandleResourceChangeL( aType );
+
+    if ( aType == KEikDynamicLayoutVariantSwitch )
+        {
+        TVwsViewId viewId;
+        CDRMRightsMgrDetailsView* detailsView;
+        if ( GetActiveViewId( viewId ) == KErrNone )
+            {
+            detailsView = ( CDRMRightsMgrDetailsView* )View( viewId.iViewUid );
+            if ( detailsView )
+                {
+                detailsView->HandleClientRectChange();
+                }
+            }
+        else
+            {
+             detailsView = ( CDRMRightsMgrDetailsView* )View( TUid::Uid( EDRMDetailsView ) );
+             if ( detailsView )
+                {
+                detailsView->HandleClientRectChange();
+                }
+            }
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsMgrAppUi::ProcessCommandParametersL
+// -----------------------------------------------------------------------------
+//
+TBool CDRMRightsMgrAppUi::ProcessCommandParametersL( TApaCommand aCommand,
+                                               TFileName& aDocumentName,
+                                               const TDesC8& /*aTail*/ )
+    {
+    if ( aCommand == EApaCommandOpen )
+        {
+        OpenDetailsViewNotEmbeddedL( aDocumentName );
+        }
+    else if ( !iStartEmbedded )
+        {
+        if ( IsForeground() )
+            {
+            ActivateLocalViewL( TUid::Uid( EDRMDetailsView ) );
+            }
+        }
+
+    return EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsMgrAppUi::ProcessMessageL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::ProcessMessageL( TUid /*aUid*/, const TDesC8& aParams )
+    {
+    HBufC16* buf16 = HBufC16::NewLC( aParams.Length() );
+    buf16->Des().Copy( aParams );
+    OpenDetailsViewNotEmbeddedL( *buf16 );
+    CleanupStack::PopAndDestroy( buf16 );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsMgrAppUi::OpenDetailsViewNotEmbeddedL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::OpenDetailsViewNotEmbeddedL( const TDesC& aParams )
+    {
+    TLex lex( aParams );
+    DRMCommonUtilities::ParseParametersAndStartL( lex, EFalse, *this );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrAppUi::ProcessEngineErrorL
+// ----------------------------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::ProcessEngineErrorL( TBool aCloseImmediately )
+    {
+    if ( DRMCommonUtilities::ShowConfirmationQueryL(
+                                                R_QTN_DRM_MGR_QUERY_RESTART,
+                                                iEikonEnv ) )
+        {
+        RStarterSession starterSession;
+        if ( starterSession.Connect() == KErrNone )
+            {
+            starterSession.Reset( RStarterSession::EUnknownReset );
+            starterSession.Close();
+            }
+        }
+
+    if ( aCloseImmediately )
+        {
+        HandleCommandL( EEikCmdExit ); // at least exit, if it doesn't restart
+        }
+    else
+        {
+        RunAppShutter();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsMgrAppUi::GetRightsManagerL
+// -----------------------------------------------------------------------------
+//
+ContentAccess::CRightsManager* CDRMRightsMgrAppUi::GetRightsManagerL()
+    {
+    ContentAccess::CManager* manager( NULL );
+    ContentAccess::CRightsManager* rightsManager( NULL );
+    RArray<ContentAccess::TAgent> agents;
+    TInt agent( 0 );
+
+    CleanupClosePushL( agents );
+    manager = ContentAccess::CManager::NewLC();
+
+    manager->ListAgentsL( agents );
+
+    for ( agent = 0; agent < agents.Count(); agent++ )
+        {
+        if (agents[agent].Name().Compare( KWmDrmAgentName ) == 0)
+            {
+            break;
+            }
+        }
+
+    // If no WM DRM agent is found, leave
+    if ( agent >= agents.Count() )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+
+    // Create a CRightsManager for the agent found
+    rightsManager = manager->CreateRightsManagerL( agents[agent] );
+
+    CleanupStack::PopAndDestroy( manager );
+    CleanupStack::PopAndDestroy( &agents );
+    return rightsManager;
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::CheckOmaDrmRightsL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::CheckOmaDrmRightsL( const TDesC8& aContentURI,
+                                             const TUint32 aLocalID,
+                                             CDRMRights*& aRights,
+                                             TInt& aStatus )
+    {
+    TBool listable( EFalse ), sendable( EFalse );
+    TBool individualConstraint( EFalse ), usageAllowed( EFalse );
+
+    CDcfRep* dcfRep = CDcfRep::NewL();
+    CleanupStack::PushL( dcfRep );
+
+    if ( dcfRep )
+        {
+        TRAPD( err, dcfRep->OrderListL( aContentURI ) );
+        if ( !err )
+            {
+            TFileName fullName;
+
+            CDcfEntry* entry = dcfRep->NextL();
+            if ( entry )
+                {
+                fullName = entry->FileName();
+                delete entry;
+                SetSelectedItemFullName( fullName );
+
+                TFileName itemName;
+                GetItemNameL( fullName, itemName, aContentURI, EFalse );
+                SetSelectedItemName( itemName );
+
+                if ( GetItemDataL( fullName, aContentURI, listable,
+                    sendable ) == KErrNone )
+                    {
+                    SetSelectedContentCanBeSent( sendable );
+                    }
+                }
+            }
+        else // No related media was found
+            {
+            SetSelectedItemFullName( KNullDesC );
+            TFileName itemName;
+            GetItemNameL( KNullDesC, itemName, aContentURI, ETrue );
+            SetSelectedItemName( itemName );
+
+            SetSelectedContentCanBeSent( EFalse );
+            }
+        }
+    else
+        {
+        User::Leave( KErrGeneral );
+        }
+
+    if ( aLocalID > 0 )
+        {
+        aStatus = iDRMCommon->GetSingleRightsObject( aContentURI,
+            aLocalID, aRights );
+        }
+        else
+        {
+        aStatus = iDRMCommon->GetActiveRights( aContentURI, 0, aRights );
+        }
+    if ( aStatus )
+        {
+        aRights = NULL;
+        }
+
+    CheckIndividualConstraint( aContentURI, individualConstraint, usageAllowed );
+    SetSelectedIndividualConstraint( individualConstraint );
+    SetSelectedUsageAllowed( usageAllowed );
+
+    CleanupStack::PopAndDestroy( dcfRep );
+
+    // Do not show the note, show license information in the details view.
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::CheckWmDrmRightsL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::CheckWmDrmRightsL( const TDesC8& aContentURI,
+    TInt& aStatus, ContentAccess::RStreamablePtrArray<ContentAccess::CRightsInfo>& aArray )
+    {
+
+    ContentAccess::CRightsManager* manager( NULL );
+    HBufC* url16( NULL );
+
+    manager = GetRightsManagerL();
+    CleanupStack::PushL( manager );
+
+    url16 = CnvUtfConverter::ConvertToUnicodeFromUtf8L( aContentURI );
+    CleanupStack::PushL( url16 );
+
+    // Wait note is not shown anymore when checking the rights.
+    // Get the list of rights, if leave occurs then there are no rights
+    // or the rights are expired.
+    TRAP( aStatus, manager->ListRightsL( aArray, url16->Des() ) );
+
+    if( aArray.Count() )
+        {
+        switch( aArray[0]->RightsStatus() )
+            {
+            // Rights don't exist
+            case ContentAccess::ERightsStatusNone:
+            case ContentAccess::ERightsStatusPending:
+
+                // Map the rights status
+                aStatus = KErrCANoRights;
+                break;
+
+            // Rights exist:
+            case ContentAccess::ERightsStatusValid:
+            case ContentAccess::ERightsStatusExpired:
+
+                aStatus = KErrNone;
+                break;
+
+            default:
+                aStatus = KErrCANoRights;
+                break;
+            }
+        }
+    else
+        {
+        aStatus = KErrCANoRights;
+        }
+
+    CleanupStack::PopAndDestroy( url16 );
+    CleanupStack::PopAndDestroy( manager );
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrAppUi::CheckIndividualConstraintL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrAppUi::CheckIndividualConstraint( const TDesC8& aContentURI,
+                                                    TBool& aIndividualConstraint,
+                                                    TBool& aUsageAllowed )
+    {
+    RPointerArray<CDRMRights>* uriList = NULL;
+    TInt r = KErrNone;
+    TUint32 retval(0);
+    DRMClock::ESecurityLevel secLevel = DRMClock::KInsecure;
+    CDRMRightsConstraints* constraint = NULL;
+    RDRMClockClient client;
+    RDRMRightsClient rclient;
+    TTime time;
+    RPointerArray<HBufC8> individuals;
+
+    r = client.Connect();
+    if ( r == KErrNone )
+        {
+        TTime time;
+        TInt timeZone(0);
+        client.GetSecureTime(time, timeZone, secLevel);
+        }
+
+    r = iDRMCommon->GetDetailedContentRights(aContentURI, uriList);
+    if ( r )
+        {
+        uriList=NULL;
+        }
+
+    r = KErrNone;
+
+    if ( !uriList || !uriList->Count() )
+        {
+        // no rights found
+        client.Close();
+        delete uriList;
+        uriList = NULL;
+        }
+    else
+        {
+        // supported IMSI information is provided by rights client
+        r = rclient.Connect();
+        if( r == KErrNone)
+            {
+            TRAP( r, r = rclient.GetSupportedIndividualsL( individuals ) );
+            rclient.Close();
+            }
+
+        // Check only the first entry in the list. This is to be expanded to check
+        // all the entries in the list.
+        for(TInt i = 0; i < 1; ++i)
+            {
+            r = (*uriList)[i]->GetPlayRight(constraint);
+            if ( r != KErrNone )
+                {
+                r = (*uriList)[i]->GetDisplayRight(constraint);
+                }
+            if ( r != KErrNone )
+                {
+                r = (*uriList)[i]->GetExecuteRight(constraint);
+                }
+            if ( r != KErrNone )
+                {
+                r = (*uriList)[i]->GetPrintRight(constraint);
+                }
+            if ( r != KErrNone )
+                {
+                delete constraint;
+                constraint = NULL;
+                continue;
+                }
+
+            if( constraint->GetConstraint().iActiveConstraints & EConstraintIndividual )
+                {
+                aIndividualConstraint = ETrue;
+                if ( constraint->GetConstraint().Valid( time, individuals, retval ) )
+                    {
+                    aUsageAllowed = ETrue;
+                    }
+                }
+            delete constraint;
+            constraint = NULL;
+            }
+
+        client.Close();
+        uriList->ResetAndDestroy();
+
+        delete uriList;
+        uriList = NULL;
+        individuals.ResetAndDestroy();
+        individuals.Close();
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/src/DRMRightsMgrDetailsContainer.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1133 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of CDRMRightsMgrDetailsContainer class
+*
+*/
+
+
+// INCLUDE FILES
+#include <stringloader.h>
+#include <aknlists.h>
+#include <cdirectorylocalizer.h>
+#include <drmrights.h>
+
+#include <drmrightsmanager.rsg>
+
+#include "drmrightsmgrdetailscontainer.h"
+#include "drmcommonutilities.h"
+#include "drmutilityinternaltypes.h"
+
+// CONSTANTS
+LOCAL_C const TInt KMsgLineLength = 100;
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::CDRMRightsMgrDetailsContainer
+// -----------------------------------------------------------------------------
+//
+CDRMRightsMgrDetailsContainer::CDRMRightsMgrDetailsContainer(
+                                                        TDetails& aDetails,
+                                                        TBool aStartEmbedded )
+: iDetails( aDetails ),
+  iStartEmbedded( aStartEmbedded ),
+  iListBox( NULL )
+    {
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::ConstructL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::ConstructL( const TRect& aRect )
+    {
+    iListBox = new( ELeave )CAknDoubleStyleListBox;     // Creates new object
+
+    CreateWindowL(); //makes the control a window-owning control
+
+    ConstructListBoxL();
+
+    if ( iListBox )
+        {
+        // set iListBox to be contained in this container
+        iListBox->SetContainerWindowL( *this );
+        SetScrollBarL();
+        }
+
+    SetRect( aRect );
+    ActivateL();
+
+    SetIconsL();
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::~CDRMRightsMgrDetailsContainer
+// ---------------------------------------------------------
+//
+CDRMRightsMgrDetailsContainer::~CDRMRightsMgrDetailsContainer()
+    {
+    delete iListBox;
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::SizeChanged
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::SizeChanged()
+   {
+    if ( iListBox )
+        {
+        iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
+        }
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::CountComponentControls
+// ---------------------------------------------------------
+//
+TInt CDRMRightsMgrDetailsContainer::CountComponentControls() const
+    {
+    TInt count( 0 );
+
+    if ( iListBox )
+        {
+        count++;
+        }
+
+    return count; // Returns number of controls inside this container.
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::ComponentControl
+// ---------------------------------------------------------
+//
+CCoeControl* CDRMRightsMgrDetailsContainer::ComponentControl( TInt aIndex ) const
+    {
+    switch ( aIndex )
+        {
+        case 0:
+            return iListBox;    // Returns the pointer to listbox object.
+        default:
+            return NULL;        // Exception : Returns NULL.
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::HandleResourceChange
+// ---------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::HandleResourceChange( TInt aType )
+    {
+    CCoeControl::HandleResourceChange( aType );
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::SetScrollBarL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::SetScrollBarL()
+    {
+    // Update scrollbar in order to draw correct scroll bar.
+    TInt pos( iListBox->View()->CurrentItemIndex() );
+    if ( iListBox->ScrollBarFrame() )
+        {
+        iListBox->ScrollBarFrame()->MoveVertThumbTo( pos );
+        }
+
+    iListBox->CreateScrollBarFrameL( ETrue );
+    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
+                                                CEikScrollBarFrame::EOff,
+                                                CEikScrollBarFrame::EAuto );
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::OfferKeyEventL
+// ---------------------------------------------------------
+//
+TKeyResponse CDRMRightsMgrDetailsContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
+                                                TEventCode aType )
+    {
+    if ( aType != EEventKey ) // Is not key event?
+        {
+        return EKeyWasNotConsumed;
+        }
+    else if ( aKeyEvent.iCode == EKeyLeftArrow ||
+              aKeyEvent.iCode == EKeyRightArrow )
+        {
+        return EKeyWasConsumed;
+        }
+    else
+        {
+        return iListBox ? iListBox->OfferKeyEventL( aKeyEvent, aType ) :
+                          EKeyWasNotConsumed;
+        }
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::Draw
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::Draw( const TRect& /*aRect*/ ) const
+    {
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::HandleControlEventL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::HandleControlEventL( CCoeControl* /*aControl*/,
+                                             TCoeEvent /*aEventType*/ )
+    {
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::SetIconsL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::SetIconsL()
+    {
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::FocusChanged
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::FocusChanged(TDrawNow /*aDrawNow*/)
+   {
+    if ( iListBox )
+        {
+        iListBox->SetFocus( IsFocused() );
+        }
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::ConstructListBoxL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::ConstructListBoxL()
+    {
+    iListBox->ConstructL( this, EAknListBoxViewerFlags /* | 
+        EAknListBoxItemSpecificMenuDisabled */ );
+
+    if ( iStartEmbedded )
+        {
+        iListBox->View()->SetListEmptyTextL( KNullDesC );
+        }
+    else
+        {
+        UpdateListBoxContentL( iDetails );        // Updates content
+        }
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::UpdateListBoxContentL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::UpdateListBoxContentL( TDetails& aDetails )
+    {
+    CDesCArray* items = ( CDesCArray* )( iListBox->Model()->ItemTextArray() );
+    items->Reset();
+
+    TInt rightsCount = aDetails.iRights->Count();
+
+    if ( rightsCount )
+        {
+        // Add only the details of the currently active RO, although the file
+        // could be related to multiple ROs.
+        AddRightsDetailsL( aDetails.iActiveROindex, aDetails, items );
+        }
+    else
+        {
+        // WMDRM agent returned an empty array of rights. Add the status line
+        // of rights.
+        if ( aDetails.iDrmScheme == EDrmSchemeWmDrm )
+            {
+            AddStatusLineL( aDetails.iRights->At( 0 ).iStatus, items );
+            }
+        }
+
+    // Content sending
+    if ( aDetails.iDrmScheme != EDrmSchemeUnknownDrm )
+        {
+        AddContentSendingLineL( aDetails.iContentCanBeSent, items );
+        }
+
+    // Individual constraint
+    if ( aDetails.iIndividualConstraint )
+        {
+        AddContentUseLineL( aDetails.iUsageAllowed, items );
+        }
+
+    iListBox->HandleItemAdditionL();
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::HandleListBoxEventL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::HandleListBoxEventL(
+                    CEikListBox* /*aListBox*/, TListBoxEvent /*aEventType*/ )
+    {
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddRightsDetailsL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::AddRightsDetailsL( TInt aNumberOfKey,
+                                                       TDetails& aDetails,
+                                                       CDesCArray* aItems )
+    {
+
+    if ( aNumberOfKey < aDetails.iRights->Count() && aNumberOfKey >= 0 )
+        {
+        // Status of Rights
+        AddStatusLineL( aDetails.iRights->At( aNumberOfKey ).iStatus,
+            aItems );
+
+        // Play Rights
+        AddRightsLineL( aDetails.iRights->At( aNumberOfKey ).iPlayConstraint,
+            aItems,
+            aDetails.iDrmScheme,
+            ContentAccess::EPlay );
+
+        // Display Rights
+        AddRightsLineL( aDetails.iRights->At( aNumberOfKey ).iDisplayConstraint,
+            aItems,
+            aDetails.iDrmScheme,
+            ContentAccess::EView );
+
+        // Print Rights
+        AddRightsLineL( aDetails.iRights->At( aNumberOfKey ).iPrintConstraint,
+            aItems,
+            aDetails.iDrmScheme,
+            ContentAccess::EPrint );
+
+        // Execute Rights
+        AddRightsLineL( aDetails.iRights->At( aNumberOfKey ).iExecuteConstraint,
+            aItems,
+            aDetails.iDrmScheme,
+            ContentAccess::EExecute );
+
+        }
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddStatusLineL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::AddStatusLineL( TDRMUIRightsStatus aStatus,
+                                                    CDesCArray* aItems )
+    {
+    TBuf<KMsgLineLength> msgLine;
+    HBufC* stringHolder;
+
+
+    stringHolder = StringLoader::LoadL( R_QTN_DRM_DETAILS_STATUS,
+                                            iEikonEnv );
+
+    msgLine.Zero();
+    msgLine.Append( '\t' );
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    msgLine.Append( '\t' );
+
+    TInt resourceId;
+    switch( aStatus )
+        {
+        case EDRMUIStatusInvalid:
+            resourceId = R_QTN_DRM_DETAILS_NO_LICENCE_AVAILABLE;
+            break;
+
+        case EDRMUIStatusValid:
+            resourceId = R_QTN_DRM_DETAILS_VALID;
+            break;
+
+        case EDRMUIStatusFuture:
+            resourceId = R_QTN_DRM_DETAILS_NOT_VALID_YET;
+            break;
+
+        case EDRMUIStatusExpired:
+            resourceId = R_QTN_DRM_DETAILS_NO_LICENCE_AVAILABLE;
+            break;
+
+        default:
+            resourceId = 0;
+            break;
+        }
+
+    if ( resourceId )
+        {
+        stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
+        msgLine.Append( *stringHolder );
+
+        delete stringHolder;
+        stringHolder = NULL;
+        }
+
+    if ( aItems )
+        {
+        aItems->AppendL( msgLine );
+        }
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddContentSendingLineL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::AddContentSendingLineL(
+                                                    TBool aContentCanBeSent,
+                                                    CDesCArray* aItems )
+    {
+    TBuf<KMsgLineLength> msgLine;
+
+    msgLine.Zero();
+    msgLine.Append( '\t' );
+    HBufC* stringHolder = StringLoader::LoadL( R_QTN_DRM_DETAILS_SENDING,
+                                               iEikonEnv );
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    msgLine.Append( '\t' );
+    stringHolder = StringLoader::LoadL( aContentCanBeSent ?
+                                        R_QTN_DRM_MGR_DET_ALLOWED :
+                                        R_QTN_DRM_MGR_DET_FORBID, iEikonEnv );
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    if ( aItems )
+        {
+        aItems->AppendL( msgLine );
+        }
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddContentUseLineL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::AddContentUseLineL( TBool aUsageAllowed,
+                                                        CDesCArray* aItems )
+    {
+    TBuf<KMsgLineLength> msgLine;
+
+    msgLine.Zero();
+    msgLine.Append( '\t' );
+    HBufC* stringHolder = StringLoader::LoadL( R_QTN_DRM_DET_CONTENT_USE,
+                                               iEikonEnv );
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    msgLine.Append( '\t' );
+    stringHolder = StringLoader::LoadL( aUsageAllowed ?
+                                        R_QTN_DRM_DET_SIM_ALLOWED :
+                                        R_QTN_DRM_DET_SIM_NOT_ALLOWED, iEikonEnv );
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    if ( aItems )
+        {
+        aItems->AppendL( msgLine );
+        }
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddRightsLineL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::AddRightsLineL(
+                                            CDRMRightsConstraints* aConstraint,
+                                            CDesCArray* aItems,
+                                            const TInt aDrmScheme,
+                                            const TUint32& aIntent )
+    {
+    if ( !aConstraint )
+        {
+        return;
+        }
+    else if ( aConstraint->FullRights() )
+        {
+        // Full Rights
+        AddUsageRightsL( aItems, aIntent );
+        }
+    else
+        {
+        TUint32 counter( 0 );
+        TUint32 originalCounter( 0 );
+        TTime startDateTime( 0 );
+        TTime endDateTime( 0 );
+        TTimeIntervalSeconds interval( 0 );
+
+        if ( aConstraint->GetCounters( counter, originalCounter ) == KErrNone )
+            {
+            // RO has a count constraint
+            AddUsageTimesLeftL( counter, aItems, aIntent );
+            }
+
+        if ( aDrmScheme == EDrmSchemeOmaDrm )
+            {
+            // For OMA DRM only
+            CDRMConstraint& drmConstraint = aConstraint->GetConstraint();
+            if ( drmConstraint.iActiveConstraints & EConstraintTimedCounter )
+                {
+                // RO has Timed Counter constraint
+                AddUsageTimesLeftL( drmConstraint.iTimedCounter, aItems,
+                                    aIntent );
+                }
+            }
+
+        if ( aConstraint->GetInterval( interval ) == KErrNone )
+            {
+
+            // RO has an interval constraint
+            // WM DRM duration rights are mapped to the interval constraint
+            // (which is not activated).
+            TTime intervalStart( 0 );
+
+            // If the file has an interval constraint which is activated,
+            // do not add information about the interval to the details view.
+            if ( aConstraint->GetIntervalStart( intervalStart ) != KErrNone )
+                {
+                // File has an interval constraint which is not activated.
+                AddUsageTimeLeftL( interval, aItems, EFalse, aIntent );
+                }
+            }
+
+        if ( aConstraint->GetStartTime( startDateTime ) == KErrNone )
+            {
+            // RO has a start time constraint
+            AddRightsValidFromL( startDateTime, aItems, aIntent );
+            }
+
+        if ( aConstraint->GetEndTime( endDateTime ) == KErrNone )
+            {
+            // RO has an expiring time constraint
+            AddRightsValidUntilL( endDateTime, aItems, aIntent );
+            }
+
+        if ( aDrmScheme == EDrmSchemeOmaDrm )
+            {
+            // For OMA DRM only
+            CDRMConstraint& drmConstraint = aConstraint->GetConstraint();
+
+            if ( drmConstraint.iActiveConstraints & EConstraintAccumulated )
+                {
+                TTimeIntervalSeconds accInterval(
+                    drmConstraint.iAccumulatedTime );
+
+                // RO has Accumulated Time constraint
+                AddUsageTimeLeftL( accInterval, aItems, ETrue, aIntent );
+                }
+            }
+
+        }
+
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddUsageRightsL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::AddUsageRightsL( CDesCArray* aItems,
+                                                     const TUint32& aIntent)
+    {
+    TBuf<KMaxFileName*2> msgLine;
+    msgLine.Zero();
+    msgLine.Append( '\t' );
+
+    // Usage Rights
+    // Check the intent and process the corresponding string.
+    TInt resourceId( 0 );
+    TInt resourceIdUnlimited( 0 );
+    switch ( aIntent )
+        {
+        case ContentAccess::EPlay:
+            resourceId = R_QTN_DRM_DETAILS_PLAYS_LEFT;
+            resourceIdUnlimited = R_QTN_DRM_MGR_DET_PL_UNLIMITED;
+            break;
+
+        case ContentAccess::EView:
+            resourceId = R_QTN_DRM_DETAILS_VIEWS_LEFT;
+            resourceIdUnlimited = R_QTN_DRM_MGR_DET_VI_UNLIMITED;
+            break;
+
+        case ContentAccess::EPrint:
+            resourceId = R_QTN_DRM_DETAILS_PRINTS_LEFT;
+            resourceIdUnlimited = R_QTN_DRM_MGR_DET_PR_UNLIMITED;
+            break;
+
+        case ContentAccess::EExecute:
+            resourceId = R_QTN_DRM_DETAILS_EXEC_TIMES;
+            resourceIdUnlimited = R_QTN_DRM_MGR_DET_EX_UNLIMITED;
+            break;
+
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    HBufC* stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    msgLine.Append( '\t' );
+
+    // Unlimited
+    stringHolder = StringLoader::LoadL( resourceIdUnlimited, iEikonEnv );
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    if ( aItems )
+        {
+        aItems->AppendL( msgLine );
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddUsageTimesLeftL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::AddUsageTimesLeftL( TUint32 aCounter,
+                                                CDesCArray* aItems,
+                                                const TUint32& aIntent )
+    {
+    TBuf<KMaxFileName*2> msgLine;
+    msgLine.Zero();
+    msgLine.Append( '\t' );
+
+    // Usage times left
+    // Check the intent and process the corresponding string.
+    TInt resourceId( 0 );
+    switch ( aIntent )
+        {
+        case ContentAccess::EPlay:
+            resourceId = R_QTN_DRM_DETAILS_PLAYS_LEFT;
+            break;
+
+        case ContentAccess::EView:
+            resourceId = R_QTN_DRM_DETAILS_VIEWS_LEFT;
+            break;
+
+        case ContentAccess::EPrint:
+            resourceId = R_QTN_DRM_DETAILS_PRINTS_LEFT;
+            break;
+
+        case ContentAccess::EExecute:
+            resourceId = R_QTN_DRM_DETAILS_EXEC_TIMES;
+            break;
+
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    HBufC* stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
+
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    msgLine.Append( '\t' );
+
+    if ( aCounter == 1 )
+        {
+        stringHolder = StringLoader::LoadL( R_QTN_DRM_DETAILS_1_TIME,
+                                            iEikonEnv );
+        }
+    else
+        {
+        stringHolder = StringLoader::LoadL( R_QTN_DRM_DETAILS_N_TIMES,
+                                            aCounter, iEikonEnv );
+        }
+
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    if ( aItems )
+        {
+        AknTextUtils::DisplayTextLanguageSpecificNumberConversion( msgLine );
+        aItems->AppendL( msgLine );
+        }
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddUsageTimeLeftL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::AddUsageTimeLeftL(
+                                        const TTimeIntervalSeconds& aInterval,
+                                        CDesCArray* aItems,
+                                        const TBool aIsAccumulatedTime,
+                                        const TUint32& aIntent )
+    {
+    TBuf<KMaxFileName*2> msgLine;
+    msgLine.Zero();
+    msgLine.Append( '\t' );
+
+    HBufC* stringHolder;
+
+    if ( aIsAccumulatedTime )
+        {
+        // Accumulated time constraint
+        stringHolder = StringLoader::LoadL( R_QTN_DRM_DETAILS_PLAYING_TIME_LEFT,
+                                            iEikonEnv );
+        }
+    else
+        {
+        // Interval constraint which has not been activated
+        TInt resourceId( 0 );
+        switch ( aIntent )
+            {
+            case ContentAccess::EPlay:
+                resourceId = R_QTN_DRM_DETAILS_VALIDITY_PERIOD;
+                break;
+
+            case ContentAccess::EView:
+                resourceId = R_QTN_DRM_DETAILS_VIEWING_RIGHTS;
+                break;
+
+            case ContentAccess::EPrint:
+                resourceId = R_QTN_DRM_DETAILS_PRINTING_RIGHTS;
+                break;
+
+            case ContentAccess::EExecute:
+                resourceId = R_QTN_DRM_DETAILS_VALIDITY_PERIOD;
+                break;
+
+            default:
+                User::Leave( KErrArgument );
+                break;
+            }
+
+        stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
+        }
+
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    msgLine.Append( '\t' );
+
+    TInt intYrs, intMon, intDay, intHrs, intMin, intSec;
+    SplitTime( aInterval, intYrs, intMon, intDay, intHrs, intMin, intSec );
+
+    stringHolder = AddPartsOfTimeL( intYrs, intMon, intDay,
+                                    intHrs, intMin, intSec );
+
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    if ( aItems )
+        {
+        AknTextUtils::DisplayTextLanguageSpecificNumberConversion( msgLine );
+        aItems->AppendL( msgLine );
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::SplitTime
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::SplitTime(
+                                const TTimeIntervalSeconds& aInterval,
+                                TInt& aIntYrs, TInt& aIntMon, TInt& aIntDay,
+                                TInt& aIntHrs, TInt& aIntMin, TInt& aIntSec )
+    {
+    TInt temp;
+    TInt i;
+
+    const TInt daysInYear = 365;
+    const TInt secsInMin = 60;
+    const TInt secsInHour = secsInMin*60;
+    const TInt secsInDay = secsInHour*24;
+
+    const TInt maxDaysInMonths[12] = {  30,  60,  90, 120, 150, 180,
+                                       210, 240, 270, 300, 330, 360 };
+
+    // calculate full days
+    temp = aInterval.Int() / secsInDay;
+
+    // calculate full years
+    aIntYrs = temp / daysInYear;
+
+    // calc remainder days
+    temp = temp % daysInYear;
+
+    aIntMon = 0;
+
+    i = 0;
+    if ( temp >= maxDaysInMonths[0] )
+        {
+        for ( i = 0; i < 11; i++ )
+            {
+            // found correct amount of months
+            if ( temp >= maxDaysInMonths[i] && temp < maxDaysInMonths[i+1] )
+                {
+                // i now contains amount of full months (+1 because of table index)
+                aIntMon = i+1;
+                break;
+                }
+            }
+        }
+
+    // calc remainder days = allSecs - secsInFullYears - secsInFullMonts
+    if( temp >= maxDaysInMonths[i] )
+        {
+        aIntDay = temp - maxDaysInMonths[i];
+        }
+    else
+        {
+        aIntDay = temp;
+        }
+
+    // calculate remainder secs
+    temp = aInterval.Int() % secsInDay;
+
+    aIntHrs = temp / secsInHour;
+
+    // calculate remainder secs
+    temp = temp % secsInHour;
+
+    aIntMin = temp / secsInMin;
+
+    // calculate remainder secs
+    aIntSec = temp % secsInMin;
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddPartsOfTimeL
+// ---------------------------------------------------------
+//
+HBufC* CDRMRightsMgrDetailsContainer::AddPartsOfTimeL(
+                                    TInt aIntYrs, TInt aIntMon, TInt aIntDay,
+                                    TInt aIntHrs, TInt aIntMin, TInt aIntSec )
+    {
+    // Only the two most meaningful data will be showed
+    TInt numOfData = 0;
+
+    CDesCArrayFlat* strings = new ( ELeave ) CDesCArrayFlat( 2 );
+    CleanupStack::PushL( strings );
+
+    if ( aIntYrs > 0 )
+        {
+        AddSinglePartOfTimeL( aIntYrs,
+                              R_QTN_DRM_NBR_OF_YEARS_ONE,
+                              R_QTN_DRM_NBR_OF_YEARS_ONE_FINAL,
+                              R_QTN_DRM_NBR_OF_YEARS_TWO_FOUR,
+                              R_QTN_DRM_NBR_OF_YEARS_FIVE_ZERO,
+                              strings );
+        numOfData++;
+        }
+
+    if ( aIntMon > 0 )
+        {
+        //  Second type not provided because 11 is the maximum
+        AddSinglePartOfTimeL( aIntMon,
+                              R_QTN_DRM_NBR_OF_MONTHS_ONE,
+                              0,
+                              R_QTN_DRM_NBR_OF_MONTHS_TWO_FOUR,
+                              R_QTN_DRM_NBR_OF_MONTHS_FIVE_ZERO,
+                              strings );
+        numOfData++;
+        }
+
+    // Only if years or months were missing
+    if ( aIntDay > 0 && numOfData < 2 )
+        {
+        AddSinglePartOfTimeL( aIntDay,
+                              R_QTN_DRM_NBR_OF_DAYS_ONE,
+                              R_QTN_DRM_NBR_OF_DAYS_ONE_FINAL,
+                              R_QTN_DRM_NBR_OF_DAYS_TWO_FOUR,
+                              R_QTN_DRM_NBR_OF_DAYS_FIVE_ZERO,
+                              strings );
+        numOfData++;
+        }
+
+    if ( aIntHrs > 0 && numOfData < 2 )
+        {
+        AddSinglePartOfTimeL( aIntHrs,
+                              R_QTN_DRM_NBR_OF_HOURS_ONE,
+                              R_QTN_DRM_NBR_OF_HOURS_ONE_FINAL,
+                              R_QTN_DRM_NBR_OF_HOURS_TWO_FOUR,
+                              R_QTN_DRM_NBR_OF_HOURS_FIVE_ZERO,
+                              strings );
+        numOfData++;
+        }
+
+    if ( aIntMin > 0 && numOfData < 2 )
+        {
+        AddSinglePartOfTimeL( aIntMin,
+                              R_QTN_DRM_NBR_OF_MINS_ONE,
+                              R_QTN_DRM_NBR_OF_MINS_ONE_FINAL,
+                              R_QTN_DRM_NBR_OF_MINS_TWO_FOUR,
+                              R_QTN_DRM_NBR_OF_MINS_FIVE_ZERO,
+                              strings );
+        numOfData++;
+        }
+
+    // If interval is 0, then it shows "0 seconds" anyway
+    if ( ( aIntSec > 0 && numOfData < 2 ) || numOfData == 0 )
+        {
+        AddSinglePartOfTimeL( aIntSec,
+                              R_QTN_DRM_NBR_OF_SECS_ONE,
+                              R_QTN_DRM_NBR_OF_SECS_ONE_FINAL,
+                              R_QTN_DRM_NBR_OF_SECS_TWO_FOUR,
+                              R_QTN_DRM_NBR_OF_SECS_FIVE_ZERO,
+                              strings );
+        numOfData++;
+        }
+
+    HBufC* stringHolder;
+    if ( numOfData == 1 )
+        {
+        stringHolder = StringLoader::LoadL( R_QTN_DRM_MGR_DET_INTER,
+                                            strings->MdcaPoint(0), iEikonEnv );
+        }
+    else
+        {
+        stringHolder = StringLoader::LoadL( R_QTN_DRM_MGR_DET_INTER_TWO,
+                                            *strings, iEikonEnv );
+        }
+
+    CleanupStack::PopAndDestroy( strings );
+
+    return stringHolder;
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddSinglePartOfTimeL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::AddSinglePartOfTimeL( TInt aNumOfElements,
+                                                    TInt aResourceIdSingle,
+                                                    TInt aResourceIdOneFinal,
+                                                    TInt aResourceIdTwoFour,
+                                                    TInt aResourceIdFiveZero,
+                                                    CDesCArrayFlat* aStrings )
+    {
+    HBufC* stringHolder;
+    TInt finalOneDigit = aNumOfElements % 10;
+    TInt finalTwoDigits = aNumOfElements % 100;
+
+    if ( aNumOfElements == 1 )
+        {
+        stringHolder = StringLoader::LoadLC( aResourceIdSingle, iEikonEnv );
+        }
+    else if ( finalOneDigit == 1 && finalTwoDigits != 11 )
+        {
+        stringHolder = StringLoader::LoadLC( aResourceIdOneFinal,
+                                             aNumOfElements,
+                                             iEikonEnv );
+        }
+    else if ( finalOneDigit == 0 ||
+              ( finalOneDigit >= 5 && finalOneDigit <= 9 ) ||
+              ( finalTwoDigits >= 11 && finalTwoDigits <= 14 ) )
+        {
+        stringHolder = StringLoader::LoadLC( aResourceIdFiveZero,
+                                             aNumOfElements,
+                                             iEikonEnv );
+        }
+    else
+        {
+        stringHolder = StringLoader::LoadLC( aResourceIdTwoFour,
+                                             aNumOfElements,
+                                             iEikonEnv );
+        }
+
+    if ( aStrings )
+        {
+        aStrings->AppendL( *stringHolder );
+        }
+
+    CleanupStack::PopAndDestroy ( stringHolder );
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddRightsValidFromL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::AddRightsValidFromL(
+                                                const TTime& aStartDateTime,
+                                                CDesCArray* aItems,
+                                                const TUint32& aIntent )
+    {
+    TBuf<KMaxFileName*2> msgLine;
+    msgLine.Zero();
+    msgLine.Append( '\t' );
+
+    TInt resourceId( 0 );
+    switch ( aIntent )
+        {
+        case ContentAccess::EPlay:
+            resourceId = R_QTN_DRM_DETAILS_VALID_FROM;
+            break;
+
+        case ContentAccess::EView:
+            resourceId = R_QTN_DRM_DETAILS_VIEW_RIGHTS_FROM;
+            break;
+
+        case ContentAccess::EPrint:
+            resourceId = R_QTN_DRM_DETAILS_PRINT_RIGHTS_FROM;
+            break;
+
+        case ContentAccess::EExecute:
+            resourceId = R_QTN_DRM_DETAILS_VALID_FROM;
+            break;
+
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    HBufC* stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    msgLine.Append( '\t' );
+
+    if ( aStartDateTime != Time::NullTTime() )
+        {
+        TBuf<32> stringDate;
+        TBuf<32> stringTime;
+
+        HBufC* stringFormatDate = StringLoader::LoadLC(
+                                                    R_QTN_DATE_USUAL_WITH_ZERO,
+                                                    iEikonEnv );
+        HBufC* stringFormatTime = StringLoader::LoadLC( R_QTN_TIME_USUAL,
+                                                       iEikonEnv );
+
+        aStartDateTime.FormatL( stringDate, *stringFormatDate );
+        aStartDateTime.FormatL( stringTime, *stringFormatTime );
+        CleanupStack::PopAndDestroy( stringFormatTime );
+        CleanupStack::PopAndDestroy( stringFormatDate );
+
+        msgLine.Append( stringDate );
+        msgLine.Append( ' ' );
+        msgLine.Append( stringTime );
+        }
+
+    if ( aItems )
+        {
+        AknTextUtils::DisplayTextLanguageSpecificNumberConversion( msgLine );
+        aItems->AppendL( msgLine );
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsContainer::AddRightsValidUntilL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsContainer::AddRightsValidUntilL(
+                                                const TTime& aEndDateTime,
+                                                CDesCArray* aItems,
+                                                const TUint32& aIntent )
+    {
+    TBuf<KMaxFileName*2> msgLine;
+    msgLine.Zero();
+    msgLine.Append( '\t' );
+
+    TInt resourceId( 0 );
+    switch ( aIntent )
+        {
+        case ContentAccess::EPlay:
+            resourceId = R_QTN_DRM_DETAILS_VALID_UNTIL;
+            break;
+
+        case ContentAccess::EView:
+            resourceId = R_QTN_DRM_DETAILS_VIEW_RIGHTS_UNTIL;
+            break;
+
+        case ContentAccess::EPrint:
+            resourceId = R_QTN_DRM_DETAILS_PRINT_RIGHTS_UNTIL;
+            break;
+
+        case ContentAccess::EExecute:
+            resourceId = R_QTN_DRM_DETAILS_VALID_UNTIL;
+            break;
+
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    HBufC* stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
+    msgLine.Append( *stringHolder );
+
+    delete stringHolder;
+    stringHolder = NULL;
+
+    msgLine.Append( '\t' );
+
+    if ( aEndDateTime != Time::NullTTime() )
+        {
+        TBuf<32> stringDate;
+        TBuf<32> stringTime;
+
+        HBufC* stringFormatDate = StringLoader::LoadLC(
+                                                    R_QTN_DATE_USUAL_WITH_ZERO,
+                                                    iEikonEnv );
+        HBufC* stringFormatTime = StringLoader::LoadLC( R_QTN_TIME_USUAL,
+                                                        iEikonEnv );
+
+        aEndDateTime.FormatL( stringDate, *stringFormatDate );
+        aEndDateTime.FormatL( stringTime, *stringFormatTime );
+        CleanupStack::PopAndDestroy( stringFormatTime );
+        CleanupStack::PopAndDestroy( stringFormatDate );
+
+        msgLine.Append( stringDate );
+        msgLine.Append( ' ' );
+        msgLine.Append( stringTime );
+        }
+
+    if ( aItems )
+        {
+        AknTextUtils::DisplayTextLanguageSpecificNumberConversion( msgLine );
+        aItems->AppendL( msgLine );
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/src/DRMRightsMgrDetailsView.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,475 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of details view class
+*
+*/
+
+
+// INCLUDE FILES
+#include <coeutils.h>
+#include <avkon.rsg>
+#include <akntitle.h>
+#include <aknview.h>
+#include <aknviewappui.h>
+#include <stringloader.h>
+#include <eikbtgpc.h>
+
+#include <drmrightsmanager.rsg>
+
+#include "drmrightsmgrdetailsview.h"
+#include "drmcommonutilities.h"
+#include "drmrightsmgrappui.h"
+#include "drmrightsmanager.hrh"
+#include "drmutilitywmdrmutilities.h"
+#include "drmutilityinternaltypes.h"
+
+#ifdef _DEBUG
+_LIT(KDRMUIDoActivateError, "DoActivateL");
+#endif
+
+// CONSTANTS
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// -----------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::CDRMRightsMgrDetailsView
+// -----------------------------------------------------------------------------
+//
+CDRMRightsMgrDetailsView::CDRMRightsMgrDetailsView( TBool aStartEmbedded )
+: iContainer( NULL ), iViewId( TUid::Uid( EDRMDetailsView ) ),
+  iStartEmbedded( aStartEmbedded )
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::NewL
+// ---------------------------------------------------------------------------
+//
+CDRMRightsMgrDetailsView* CDRMRightsMgrDetailsView::NewL(
+                                                        TBool aStartEmbedded )
+    {
+    CDRMRightsMgrDetailsView* self = NewLC( aStartEmbedded );
+
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::NewLC
+// ---------------------------------------------------------------------------
+//
+CDRMRightsMgrDetailsView* CDRMRightsMgrDetailsView::NewLC(
+                                                        TBool aStartEmbedded )
+    {
+    CDRMRightsMgrDetailsView* self =
+        new( ELeave ) CDRMRightsMgrDetailsView( aStartEmbedded );
+    CleanupStack::PushL( self );
+    self->ConstructL( 0 );
+
+    return self;
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsView::ConstructL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::ConstructL( const TInt /*aResourceId*/ )
+    {
+    BaseConstructL( R_DRMRIGHTSMANAGER_DETAILSVIEW );
+    iDetails.iRights = new( ELeave )CArrayFixFlat<TRights>( 1 );
+    }
+
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsView::~CDRMRightsMgrDetailsView
+// ---------------------------------------------------------
+//
+CDRMRightsMgrDetailsView::~CDRMRightsMgrDetailsView()
+    {
+    delete iDetails.iRights;
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::CreateContainerL()
+// ---------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::CreateContainerL()
+    {
+    NewContainerL();
+    __ASSERT_DEBUG( iContainer, User::Panic( KDRMUIDoActivateError,
+                                             EDRMUIViewPanicNullPtr ) );
+    iContainer->SetMopParent( this );
+
+    TRAPD( error, iContainer->ConstructL( ClientRect() ) );
+
+    if ( error )
+        {
+        delete iContainer;
+        iContainer = NULL;
+        User::Leave( error );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::NewContainerL
+// ---------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::NewContainerL()
+    {
+    iContainer = new( ELeave ) CDRMRightsMgrDetailsContainer( iDetails,
+                                                              iStartEmbedded );
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::RemoveContainer()
+// ---------------------------------------------------------------------------
+void CDRMRightsMgrDetailsView::RemoveContainer()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::SetTitlePaneL
+// ----------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::SetTitlePaneL( const TDesC& aTitle )
+    {
+    // Fetches pointer to the default title pane control.
+    CAknTitlePane* titlePane = static_cast<CAknTitlePane*>( StatusPane()->
+                            ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
+    if ( titlePane )
+        {
+        // Set title text
+        titlePane->SetTextL( aTitle );
+        }
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsView::Id()
+// ---------------------------------------------------------
+//
+TUid CDRMRightsMgrDetailsView::Id() const
+    {
+    return iViewId;
+    }
+
+// ---------------------------------------------------------
+// void CDRMRightsMgrDetailsView::HandleCommandL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::HandleCommandL( TInt aCommand )
+    {
+
+        CDRMRightsMgrAppUi& appUi =
+                                *static_cast<CDRMRightsMgrAppUi*>( AppUi() );
+
+    if ( aCommand == EAknSoftkeyOk )
+        {
+            appUi.HandleCommandL( EEikCmdExit ); // Ok softkey was pressed
+        }
+    else
+        {
+        appUi.HandleCommandL( aCommand );        // Any other case
+        }
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsView::DynInitMenuPaneL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::DynInitMenuPaneL( TInt /*aResourceId*/,
+                                     CEikMenuPane* /*aMenuPane*/ )
+    {
+    }
+
+// ---------------------------------------------------------
+// CDRMRightsMgrDetailsView::HandleClientRectChange
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::DoActivateL
+// ---------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
+                                            TUid /*aCustomMessageId*/,
+                                            const TDesC8& /*aCustomMessage*/ )
+    {
+    RemoveContainer();
+    CreateContainerL();
+    AppUi()->AddToStackL( *this, iContainer );
+
+    if ( iStartEmbedded )
+        {
+        MakeLeftSoftkeyVisible( EFalse );
+        }
+
+    HandleClientRectChange();
+
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::DoDeactivate
+// ---------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::DoDeactivate()
+    {
+
+    DeleteConstraints();
+    RemoveContainer();
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::RefreshListBoxL
+// ----------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::RefreshListBoxL( CDRMRights* aRights,
+                                                const TDesC& aTitle,
+                                                const TDesC& aFullName,
+                                                const TBool aContentCanBeSent,
+                                                const TBool aIndividualConstraint,
+                                                const TBool aUsageAllowed )
+    {
+    CDRMRights::TExpiration expir;
+    TInt err = KErrNone;
+
+    TRights rights;
+
+    PrepareRefreshL( aFullName, EDrmSchemeOmaDrm, rights, aContentCanBeSent,
+        aIndividualConstraint, aUsageAllowed );
+
+    if ( aRights )
+        {
+        err = DRMCommonUtilities::GetRightsStatus( *aRights, expir );
+
+        if ( err != KErrCANoRights &&
+             err != KErrCANoPermission )
+            {
+            if ( expir == CDRMRights::EExpiredRights )
+                {
+                rights.iStatus = EDRMUIStatusExpired;
+                }
+            else if ( expir == CDRMRights::EFutureRights )
+                {
+                rights.iStatus = EDRMUIStatusFuture;
+                }
+            else
+                {
+                rights.iStatus = EDRMUIStatusValid;
+                }
+
+            aRights->GetPlayRight( rights.iPlayConstraint );
+
+            aRights->GetDisplayRight( rights.iDisplayConstraint );
+
+            aRights->GetPrintRight( rights.iPrintConstraint );
+
+            aRights->GetExecuteRight( rights.iExecuteConstraint );
+            }
+
+        }
+
+    FinalizeRefreshL( aTitle, rights );
+
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::RefreshListBoxL
+// ----------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::RefreshListBoxL(
+    ContentAccess::RStreamablePtrArray<ContentAccess::CRightsInfo>& aRights,
+    const TDesC& aTitle,
+    const TDesC& aFullName )
+    {
+
+    TRights rights;
+
+    PrepareRefreshL( aFullName, EDrmSchemeWmDrm, rights, ETrue, EFalse, ETrue );
+
+    if ( aRights.Count() > 0 )
+        {
+        // Map pending or no rights to expired for the UI as default.
+        switch ( aRights[0]->RightsStatus() )
+            {
+            case ContentAccess::ERightsStatusNone:
+                rights.iStatus = EDRMUIStatusExpired;
+                break;
+            case ContentAccess::ERightsStatusPending:
+                rights.iStatus = EDRMUIStatusExpired;
+                break;
+            case ContentAccess::ERightsStatusValid:
+                rights.iStatus = EDRMUIStatusValid;
+                break;
+            case ContentAccess::ERightsStatusExpired:
+                rights.iStatus = EDRMUIStatusExpired;
+                break;
+            default:
+                rights.iStatus = EDRMUIStatusExpired;
+                break;
+            }
+
+#ifdef RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM
+
+        DrmUtilityWmDrmUtilities::ParseWmDrmStringL( *aRights[0],
+            rights.iPlayConstraint );
+#endif
+
+        }
+    else
+        {
+        // WMDRM agent returned an empty array of rights.
+        // The rights can be missing or expired -> show
+        // expired in the UI as default.
+        rights.iStatus = EDRMUIStatusExpired;
+        }
+
+    FinalizeRefreshL( aTitle, rights );
+
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::MakeLeftSoftkeyVisible
+// ----------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::MakeLeftSoftkeyVisible( TBool aVisible )
+    {
+    CEikButtonGroupContainer* btnGroupContainer = Cba();
+    if ( btnGroupContainer )
+        {
+        TInt commandID = btnGroupContainer->ButtonGroup()->CommandId( 0 );
+        TBool isVisible = btnGroupContainer->IsCommandVisible( commandID );
+
+        if ( isVisible != aVisible )
+            {
+            btnGroupContainer->MakeCommandVisible( commandID, aVisible );
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::DeleteConstraints
+// ----------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::DeleteConstraints()
+    {
+    for ( TInt i = 0; i < iDetails.iRights->Count(); i++ )
+        {
+        if ( iDetails.iRights->At( i ).iPlayConstraint )
+            {
+            delete iDetails.iRights->At( i ).iPlayConstraint;
+            iDetails.iRights->At( i ).iPlayConstraint = NULL;
+            }
+
+        if ( iDetails.iRights->At( i ).iDisplayConstraint )
+            {
+            delete iDetails.iRights->At( i ).iDisplayConstraint;
+            iDetails.iRights->At( i ).iDisplayConstraint = NULL;
+            }
+
+        if ( iDetails.iRights->At( i ).iPrintConstraint )
+            {
+            delete iDetails.iRights->At( i ).iPrintConstraint;
+            iDetails.iRights->At( i ).iPrintConstraint = NULL;
+            }
+
+        if ( iDetails.iRights->At( i ).iExecuteConstraint )
+            {
+            delete iDetails.iRights->At( i ).iExecuteConstraint;
+            iDetails.iRights->At( i ).iExecuteConstraint = NULL;
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::PrepareRefreshL
+// ----------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::PrepareRefreshL( const TDesC& aFullName,
+                                                const TInt&  aDrmScheme,
+                                                TRights& aRights,
+                                                const TBool& aContentCanBeSent,
+                                                const TBool& aIndividualConstraint,
+                                                const TBool& aUsageAllowed )
+    {
+
+    MakeLeftSoftkeyVisible( ETrue );
+
+    iDetails.iContentPath.Zero();
+
+    if ( DRMCommonUtilities::IsInPrivateFolderL( aFullName ) )
+        {
+        // not able to check further
+        iDetails.iContentPath = aFullName;
+        }
+    else
+        {
+        if ( aFullName.Length() && ConeUtils::FileExists( aFullName ) )
+            {
+            iDetails.iContentPath = aFullName;
+            }
+        }
+
+    iDetails.iContentCanBeSent = aContentCanBeSent;
+    iDetails.iIndividualConstraint = aIndividualConstraint;
+    iDetails.iUsageAllowed = aUsageAllowed;
+    iDetails.iActiveROindex = 0;
+    iDetails.iRights->Reset();
+    iDetails.iDrmScheme = aDrmScheme;
+
+    aRights.iPlayConstraint = NULL;
+    aRights.iDisplayConstraint = NULL;
+    aRights.iPrintConstraint = NULL;
+    aRights.iExecuteConstraint = NULL;
+    aRights.iStatus = EDRMUIStatusInvalid;
+
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsMgrDetailsView::FinalizeRefreshL
+// ----------------------------------------------------------------------------
+//
+void CDRMRightsMgrDetailsView::FinalizeRefreshL( const TDesC& aTitle,
+    const TRights& aRights )
+    {
+
+    iDetails.iRights->AppendL( aRights );
+
+    SetTitlePaneL( aTitle );
+
+    if ( iContainer )
+        {
+        CDRMRightsMgrDetailsContainer& container =
+                    *static_cast<CDRMRightsMgrDetailsContainer*>( iContainer );
+        container.UpdateListBoxContentL( iDetails );
+        }
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/src/DRMRightsMgrDocument.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,121 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of CDRMRightsMgrDocument class
+*
+*/
+
+
+// INCLUDE FILES
+#include <aiwgenericparam.h>
+#include <genericparamconsumer.h>
+
+#include "drmrightsmgrdocument.h"
+#include "drmrightsmgrappui.h"
+#include "drmcommonutilities.h"
+
+#include "drmuilogger.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// -----------------------------------------------------------------------------
+// CDRMRightsMgrDocument::CDRMRightsMgrDocument
+// -----------------------------------------------------------------------------
+//
+CDRMRightsMgrDocument::CDRMRightsMgrDocument( CEikApplication& aApp )
+: CAiwGenericParamConsumer( aApp )
+    {
+    }
+
+
+// ----------------------------------------------------
+// CDRMRightsMgrDocument::~CDRMRightsMgrDocument
+// ----------------------------------------------------
+//
+CDRMRightsMgrDocument::~CDRMRightsMgrDocument()
+    {
+    }
+
+
+// ----------------------------------------------------------
+// CDRMRightsMgrDocument::ConstructL
+// ---------------------------------------------------------
+//
+void CDRMRightsMgrDocument::ConstructL()
+    {
+    CLOG_CREATE
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsMgrDocument* CDRMRightsMgrDocument::NewL
+// -----------------------------------------------------------------------------
+//
+CDRMRightsMgrDocument* CDRMRightsMgrDocument::NewL( CEikApplication& aApp )
+    {
+    CDRMRightsMgrDocument* self = new( ELeave )CDRMRightsMgrDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+
+// ----------------------------------------------------
+// CDRMRightsMgrDocument::CreateAppUiL
+// ----------------------------------------------------
+//
+CEikAppUi* CDRMRightsMgrDocument::CreateAppUiL()
+    {
+    return new( ELeave )CDRMRightsMgrAppUi();
+    }
+
+
+// ----------------------------------------------------
+// CDRMRightsMgrDocument::OpenFileL
+// ----------------------------------------------------
+//
+CFileStore* CDRMRightsMgrDocument::OpenFileL( TBool aDoOpen,
+                                              const TDesC& /*aParams*/,
+                                              RFs& /*aFs*/ )
+    {
+    if ( aDoOpen )
+        {
+        TLex lex;
+
+        TPtrC filename;
+        const CAiwGenericParamList* paramList = GetInputParameters();
+        if ( paramList )
+            {
+            TInt index = 0;
+            const TAiwGenericParam* param = NULL;
+            param = paramList->FindFirst( index, EGenericParamFile,
+                                          EVariantTypeDesC );
+            if ( index >= 0 && param )
+                {
+                lex = param->Value().AsDes();
+                }
+            }
+
+        CDRMRightsMgrAppUi& appUi =
+                                *static_cast<CDRMRightsMgrAppUi*>( iAppUi );
+        DRMCommonUtilities::ParseParametersAndStartL( lex, ETrue, appUi );
+        }
+
+    return NULL;
+    }
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsmanagerui/src/DRMViewItems.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,110 @@
+/*
+* 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:  Implementation of TItemData class
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+
+#include "DRMViewItems.h"
+
+
+// ================= MEMBER FUNCTIONS =======================
+//
+// -----------------------------------------------------------------------------
+// TItemData::TItemData
+// -----------------------------------------------------------------------------
+//
+TItemData::TItemData()
+: iIndexInArray( -1 ),
+  iItemName( NULL ), 
+  iItemFullName( NULL ), 
+  iIndexIcon( -1 ), 
+  iTypeOfObject( -1 ),
+  iContentCanBeSent( EFalse ),
+  iLocalID( 0 ),
+  iContentURI( NULL ),
+  iFutureActivationTime( 0 ),
+  iUnlimitedRights( EFalse ),
+  iIndividualConstraint( EFalse ),
+  iUsageAllowed( ETrue )
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// TItemData::TItemData
+// -----------------------------------------------------------------------------
+//
+TItemData::TItemData( const TInt aIndexInArray,
+                      const TDesC& aItemName, 
+                      const TDesC& aItemFullName, 
+                      const TInt aIndexIcon, 
+                      const TInt aTypeOfObject,
+                      const TBool aContentCanBeSent, 
+                      const TDesC8& aContentURI, 
+                      const TTime& aFutureActivationTime, 
+                      const TBool aUnlimitedRights,
+                      const TBool aIndividualConstraint,
+                      const TBool aUsageAllowed )
+: iIndexInArray( aIndexInArray ),
+  iItemName( aItemName ), 
+  iItemFullName( aItemFullName ), 
+  iIndexIcon( aIndexIcon ), 
+  iTypeOfObject( aTypeOfObject ),
+  iContentCanBeSent( aContentCanBeSent ),
+  iLocalID( 0 ),
+  iContentURI( aContentURI ),
+  iFutureActivationTime( aFutureActivationTime ),
+  iUnlimitedRights( aUnlimitedRights ),
+  iIndividualConstraint( aIndividualConstraint ),
+  iUsageAllowed( aUsageAllowed )
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// TItemData::TItemData
+// -----------------------------------------------------------------------------
+//
+TItemData::TItemData( const TInt aIndexInArray,
+                      const TDesC& aItemName, 
+                      const TDesC& aItemFullName, 
+                      const TInt aIndexIcon, 
+                      const TInt aTypeOfObject,
+                      const TUint32 aLocalID,
+                      const TDesC8& aContentURI, 
+                      const TTime& aFutureActivationTime, 
+                      const TBool aUnlimitedRights,
+                      const TBool aIndividualConstraint,
+                      const TBool aUsageAllowed )
+: iIndexInArray( aIndexInArray ),
+  iItemName( aItemName ), 
+  iItemFullName( aItemFullName ), 
+  iIndexIcon( aIndexIcon ), 
+  iTypeOfObject( aTypeOfObject ),
+  iContentCanBeSent( EFalse ),
+  iLocalID( aLocalID ),
+  iContentURI( aContentURI ),
+  iFutureActivationTime( aFutureActivationTime ),
+  iUnlimitedRights( aUnlimitedRights ),
+  iIndividualConstraint( aIndividualConstraint ),
+  iUsageAllowed( aUsageAllowed )
+    {
+    }
+
+
+// End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsstoringlocation/bwins/drmrightsstoringlocationu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?CheckDrmRightsStorageDriveL@DrmRightsStoringLocation@@SAHAAVRFs@@AAW4TDrmScheme@@AAVTChar@@@Z @ 1 NONAME ; int DrmRightsStoringLocation::CheckDrmRightsStorageDriveL(class RFs &, enum TDrmScheme &, class TChar &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsstoringlocation/eabi/drmrightsstoringlocationu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	_ZN24DrmRightsStoringLocation27CheckDrmRightsStorageDriveLER3RFsR10TDrmSchemeR5TChar @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsstoringlocation/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project drmrightsstoringlocation
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+drmrightsstoringlocation.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsstoringlocation/group/drmrightsstoringlocation.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project drmrightsstoringlocation
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  drmrightsstoringlocation.dll
+TARGETTYPE              dll
+UID                     0x1000008d 0x20021199
+
+CAPABILITY              CAP_GENERAL_DLL
+ 
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  drmrightsstoringlocation.cpp
+
+USERINCLUDE             ../inc
+USERINCLUDE             ../../../inc // Ado level include dir
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY                 euser.lib
+LIBRARY                 centralrepository.lib
+LIBRARY                 efsrv.lib
+LIBRARY                 platformenv.lib 
+
+DEFFILE                 drmrightsstoringlocation.def
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsstoringlocation/inc/drmstoringinternalcrkeys.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handling storing location of Rights Objects
+*
+*/
+
+
+#ifndef DRMSTORINGINTERNALCRKEYS_H
+#define DRMSTORINGINTERNALCRKEYS_H
+
+const TUid KCrUidOmaDrmRightsServer = {0x2001FE33};
+
+const TUid KCrUidWmDrmRightsServer = {0x2001FE55};
+    
+/* Location (drive) for storing the OMA DRM rights objects as desired by the user */
+const TUint32 KConfigOmaDrmStoringLocation = 0x00000001;
+
+/* Location (drive) for storing the WM DRM licenses as desired by the user */
+const TUint32 KConfigWmDrmStoringLocation = 0x00000001;
+
+#endif      // DRMSTORINGINTERNALCRKEYS_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmrightsstoringlocation/src/drmrightsstoringlocation.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,133 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class provides the functionalities which are needed
+*                for implementing configurable OMA DRM rights storing
+*
+*/
+
+
+// INCLUDE
+#include <centralrepository.h>
+#include <f32file.h>
+#include <driveinfo.h>
+#include "drmrightsstoringlocation.h"
+#include "drmstoringinternalcrkeys.h"
+#include "drmutilityinternaltypes.h"
+
+// LOCAL CONSTANTS AND MACROS
+const TInt KStringMaxSize = 1024;
+
+// ----------------------------------------------------------------------------
+// DrmRightsStoringLocation::CheckDrmRightsStorageDriveL
+// Checks if the storing location of DRM Rights is configured in the
+// Central Repository key.
+// ----------------------------------------------------------------------------
+EXPORT_C TBool DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( RFs &aFs,
+    TDrmScheme& aDrmScheme, TChar& aDriveLetter  )
+    {
+    TInt err( KErrNotFound );
+    CRepository* repository( NULL );
+    TBuf<KStringMaxSize> string;
+    TBool configStoringLocationFound( EFalse );
+    TInt driveNumber( -1 );
+    TInt systemDriveNumber( -1 );
+    TDriveInfo driveInfo;
+    TInt loc( 0 );
+    TDriveList driveList;
+    
+    aDriveLetter = ' ';
+
+    // Check the Central Repository key for configurable storing location of
+    // the given DRM scheme
+    switch( aDrmScheme )
+        {
+        case EDrmSchemeOmaDrm:
+            {
+            break;
+            } 
+        case EDrmSchemeWmDrm:
+            {
+            TRAP( err, repository =
+                CRepository::NewL( KCrUidWmDrmRightsServer ) );
+            if ( !err )
+                {
+                // Read the string which should contain the drive letter
+                err = repository->Get( KConfigWmDrmStoringLocation, string );
+                delete repository;
+                repository = NULL;
+                }       
+            break;
+            }      
+        default: 
+            {
+            break;
+            } 
+        }
+      
+    if ( !err )
+        {    
+        
+        // Find out the first alphabet character of the string. It is expected 
+        // that it corresponds to the drive letter.
+        while ( ( loc < string.Length() ) && ( !aDriveLetter.IsAlpha() ) ) 
+            {
+            aDriveLetter = string[ loc ];
+            loc++;
+            }
+        
+        aFs.CharToDrive( aDriveLetter, driveNumber );
+        aFs.Drive( driveInfo, driveNumber );
+        
+        // Check if the drive actually exists
+        User::LeaveIfError( aFs.DriveList( driveList ) );
+        
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, systemDriveNumber );
+        
+        // Configured storing location is the same as the default system drive.
+        // This is not considered as an actual configuration. Use system drive also if
+        // the drive for the configured storing location of rights does not exist
+        if ( ( systemDriveNumber == driveNumber ) || ( !driveList[ driveNumber ] ) )
+            {
+            return configStoringLocationFound;
+            }
+        
+        // Check that the given drive exists and it is not RAM drive (D:)
+        if ( aDriveLetter.IsAlpha() && ( ( aDriveLetter != 'd' )
+            && ( aDriveLetter != 'D' ) ) ) 
+            {
+                
+            // Do not accept substed or ROM drive
+            if ( ( driveInfo.iDriveAtt & KDriveAttLocal ) &&
+                !( driveInfo.iDriveAtt & KDriveAttRom ) &&
+                !( driveInfo.iDriveAtt & KDriveAttSubsted ) &&
+                !( driveInfo.iDriveAtt & KDriveAttRemote ) )
+                {
+                configStoringLocationFound = ETrue;
+                }
+            }   
+        }
+           
+    if ( !configStoringLocationFound )
+        {
+        // Central repository key was not found or was found not to be
+        // alphabetic -> use the default path for storing OMA DRM rights
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+        aFs.DriveToChar( driveNumber, aDriveLetter );
+        }
+            
+    return configStoringLocationFound;   
+    }
+    
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmserviceapiwrapper/BWINS/drmserviceapiwrapperu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?GateFunctionDrmServiceApiWrapper@@YAPAXXZ @ 1 NONAME ; void * GateFunctionDrmServiceApiWrapper(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmserviceapiwrapper/EABI/drmserviceapiwrapperu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z32GateFunctionDrmServiceApiWrapperv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmserviceapiwrapper/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,20 @@
+/*
+* 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:  Build information file for project DrmServiceApiWrapper
+*
+*/
+
+
+PRJ_MMPFILES
+drmserviceapiwrapper.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmserviceapiwrapper/group/drmserviceapiwrapper.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project Drm Service Api Wrapper
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          drmserviceapiwrapper.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x2001B2CB
+
+CAPABILITY      CAP_GENERAL_DLL
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   .
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+
+SOURCEPATH      ../src
+
+SOURCE          drmserviceapiwrapper.cpp
+
+LIBRARY         euser.lib
+LIBRARY         drmserviceapi.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmserviceapiwrapper/src/drmserviceapiwrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,139 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Dynamically loadable wrapper for Drm Service Api
+*
+*/
+
+
+#include <drmserviceapi.h>
+#include "drmserviceapiwrapper.h"
+
+// CONSTANTS
+
+// ======== LOCAL FUNCTIONS ========
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+DRM::CDrmServiceApiWrapper::CDrmServiceApiWrapper()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDrmServiceApiWrapper::ConstructL
+// ---------------------------------------------------------------------------
+//
+void DRM::CDrmServiceApiWrapper::ConstructL()
+    {
+    iServiceApi = DRM::CDrmServiceApi::NewL();
+    }
+
+// ---------------------------------------------------------------------------
+// CDrmServiceApiWrapper::NewL
+// ---------------------------------------------------------------------------
+//
+DRM::CDrmServiceApiWrapper* DRM::CDrmServiceApiWrapper::NewL()
+    {
+    CDrmServiceApiWrapper* self = CDrmServiceApiWrapper::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmServiceApiWrapper::NewLC
+// ---------------------------------------------------------------------------
+//
+DRM::CDrmServiceApiWrapper* DRM::CDrmServiceApiWrapper::NewLC()
+    {
+	CDrmServiceApiWrapper* self = new( ELeave ) CDrmServiceApiWrapper();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+DRM::CDrmServiceApiWrapper::~CDrmServiceApiWrapper()
+    {
+    delete iServiceApi;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmServiceApiWrapper::GetSecureTime
+// ---------------------------------------------------------------------------
+//
+TInt DRM::CDrmServiceApiWrapper::GetSecureTime( 
+    TTime& aTime, 
+    TInt& aTimeZone,
+    DRMClock::ESecurityLevel& aSecurityLevel ) const
+    {
+    return iServiceApi->GetSecureTime( aTime, aTimeZone, aSecurityLevel );
+    }
+
+// ---------------------------------------------------------------------------
+// CDrmServiceApiWrapper::UpdateSecureTime
+// ---------------------------------------------------------------------------
+//
+TInt DRM::CDrmServiceApiWrapper::UpdateSecureTime( const TTime& aTime, 
+                                              const TInt& aTimeZone )
+    {
+    return iServiceApi->UpdateSecureTime( aTime, aTimeZone );
+    }
+
+// ---------------------------------------------------------------------------
+// CDrmServiceApiWrapper::GetDevicePublicKeyDerL
+// ---------------------------------------------------------------------------
+//
+void DRM::CDrmServiceApiWrapper::GetDevicePublicKeyDerL( HBufC8*& aPublicKey )
+    {
+    iServiceApi->GetDevicePublicKeyDerL( aPublicKey );
+    }
+
+// ---------------------------------------------------------------------------
+// CDrmServiceApiWrapper::SignL
+// ---------------------------------------------------------------------------
+//
+void DRM::CDrmServiceApiWrapper::SignL( const TDesC8& aHash, HBufC8*& aSignature )
+    {
+    iServiceApi->SignL( aHash, aSignature );
+    }
+
+
+// ======== GLOBAL FUNCTIONS ========
+
+//------------------------------------------------------------------------------
+// GateFunctionDrmServiceApiWrapper
+// DRM gate function
+//------------------------------------------------------------------------------
+EXPORT_C TAny* GateFunctionDrmServiceApiWrapper()
+	{
+	DRM::CDrmServiceApiWrapper* launcher = NULL;
+	TRAPD( err, launcher = DRM::CDrmServiceApiWrapper::NewL() );
+	if( err != KErrNone )
+	    {
+	    return NULL;
+	    }
+
+	return launcher;
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/data/102750CC.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM plugin resource file for DRMSettingsPlugin.
+*
+*/
+
+#include <ecom/registryinfo.rh>
+
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid     = 0x102750CC;
+	interfaces  = 
+		{
+		INTERFACE_INFO
+			{
+			interface_uid   = 0x10207236; // UID for CGSPluginInterface
+			implementations = 
+				{ 
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid  = 0x102750CD;
+					version_no          = 1;
+					display_name        = "DRM Settings Plugin";
+					default_data        = "0x1020743A";
+					opaque_data         = "2";//Order number
+					}
+				};
+			}
+		};
+	}
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/data/drmsettingspluginrsc.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,512 @@
+/*
+* Copyright (c) 2006 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource file for DRMSettinsPlugin
+*
+*/
+
+
+
+//  RESOURCE IDENTIFIER
+NAME    DRMS // 4 letter ID
+
+//  INCLUDES
+#include    <eikon.rh>
+#include    <uikon.rh>
+#include    <avkon.rsg>
+#include    <avkon.rh>
+#include    <avkon.mbg>
+#include    <eikcore.rsg>
+#include    <eikon.rsg>
+#include    <appinfo.rh>
+#include    <avkon.loc>
+#include    <AvkonIcons.hrh>
+#include    <data_caging_paths_strings.hrh>
+#include    <gs.loc>
+#include    <drmsettingsplugin.loc>
+
+#include    "drmsettingsplugin.hrh"
+#include    "drmsettingsplugin.rh"
+
+
+// CONSTANTS
+
+//  RESOURCE DEFINITIONS
+
+RESOURCE RSS_SIGNATURE
+    {
+    }
+
+
+RESOURCE TBUF
+    {
+    buf="DRMS";
+    }
+
+//----------------------------------------------------
+//
+//    EIK_APP_INFO
+//    It contains application information.
+//
+//----------------------------------------------------
+//
+RESOURCE EIK_APP_INFO
+    {
+    }
+
+
+
+//----------------------------------------------------
+//  r_drm_settings_view_caption
+//
+// Caption for DRM Settings plugin
+//----------------------------------------------------
+//
+RESOURCE TBUF r_drm_settings_view_caption
+    {
+    buf = qtn_set_protected_content;
+    }
+
+
+//----------------------------------------------------
+//
+//    r_drm_settings_view_title
+//    Title of DRM Settings view
+//
+//----------------------------------------------------
+//
+RESOURCE TITLE_PANE r_drm_settings_view_title
+    {
+    txt = qtn_set_protected_content;
+    }
+
+
+//----------------------------------------------------
+//
+//    r_drm_softkeys_options_back_change
+//    Text association with MSK ( CHANGE )
+//
+//----------------------------------------------------
+//
+RESOURCE CBA r_drm_softkeys_options_back_change
+    {
+    buttons =
+        {
+        CBA_BUTTON
+            {
+            id=EAknSoftkeyOptions;
+            txt = text_softkey_option;
+            },
+        CBA_BUTTON
+            {
+            id=EAknSoftkeyBack;
+            txt = text_softkey_back;
+            },
+        CBA_BUTTON
+            {
+            id=EDRMSettingsCmdAppChangeMSK;
+            txt = qtn_msk_change;
+            }
+        };
+    }
+
+
+
+
+//----------------------------------------------------
+//
+//    r_drm_settings_view
+//    DRM Settings view.
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_VIEW r_drm_settings_view
+    {
+    menubar = r_drm_settings_menubar_change_exit;
+    cba = r_drm_softkeys_options_back_change;
+    }
+
+
+// -----------------------------------------------------------------------------
+//
+// r_drm_settings_menubar_change_exit
+// Menu with 'change' and 'exit' items.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE MENU_BAR r_drm_settings_menubar_change_exit
+    {
+    titles =
+        {
+        MENU_TITLE
+            {
+            menu_pane = r_drm_settings_menu_item_exit;
+            },
+        MENU_TITLE
+            {
+            menu_pane = r_drm_settings_menu_item_change;
+            }
+        };
+    }
+
+
+    // -----------------------------------------------------------------------------
+    //
+    // r_drm_settings_menu_item_exit
+    // Options menu items 'Help' and 'Exit'. Used instead of plain 'Exit' when help
+    // is wanted to be shown in UI.
+    //
+    // -----------------------------------------------------------------------------
+    //
+    RESOURCE MENU_PANE r_drm_settings_menu_item_exit
+        {
+        items =
+            {
+            MENU_ITEM
+                {
+                command = EAknCmdHelp;
+                txt = qtn_options_help;
+                },
+            MENU_ITEM
+                {
+                command = EAknCmdExit;
+                txt = qtn_options_exit;
+                }
+            };
+        }
+
+
+// -----------------------------------------------------------------------------
+//
+// r_drm_settings_menu_item_change
+// Change item.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE MENU_PANE r_drm_settings_menu_item_change
+    {
+    items =
+        {
+        MENU_ITEM
+            {
+            command = EDRMSettingsCmdAppChange;
+            txt = qtn_set_options_change;
+            flags = EEikMenuItemAction;
+            }
+        };
+    }
+
+
+//----------------------------------------------------
+//
+//    r_drm_settings_lbx
+//    DRM Settings view's listbox.
+//
+//----------------------------------------------------
+//
+RESOURCE DRM_SETTINGS_FEATURE_ARRAY r_drm_settings_lbx
+    {
+    items =
+        {
+#ifdef __DRM_OMA2        
+#ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
+        DRM_SETTINGS_FEATURE
+            {
+            txt = " \t"qtn_set_automatic_activation"\t\t";
+            item = EDRMSettingsIdAutomaticActivation;
+            },
+#endif // RD_DRM_SILENT_RIGHTS_ACQUISITION
+        
+#ifdef RD_DRM_METERING
+        DRM_SETTINGS_FEATURE
+            {
+            txt = " \t"qtn_drm_set_usage_reporting"\t\t";
+            item = EDRMSettingsIdUsageReporting;
+            },
+#endif // RD_DRM_METERING
+   
+        DRM_SETTINGS_FEATURE
+            {
+            txt = " \t"qtn_set_transaction_tracking"\t\t";
+            item = EDRMSettingsIdTransactionTracking;
+            },
+#endif // __DRM_OMA2
+
+        DRM_SETTINGS_FEATURE
+            {
+            txt = " \t"qtn_drm_set_license_deletion"\t\t";
+            item = EDRMSettingsIdWMDRMLicenseDeletion;
+            }
+        };    
+    }
+
+
+//----------------------------------------------------
+//
+//    r_drm_settings_setting_listbox
+//    Common listbox editor resource for setting pages.
+//
+//----------------------------------------------------
+//
+RESOURCE LISTBOX r_drm_settings_setting_listbox
+    {
+    flags = EEikListBoxMultipleSelection;
+    }
+
+
+//----------------------------------------------------
+//
+//    r_ttracking_setting_page
+//    Transaction tracking setting page.
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_ttracking_setting_page
+    {
+    number = EAknSettingPageNoOrdinalDisplayed;
+    label = qtn_drm_set_popup_trans_track;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    type = EAknSetListBox;
+    editor_resource_id = r_drm_settings_setting_listbox;
+    }
+
+
+//----------------------------------------------------
+//
+//    r_ttracking_setting_page_lbx
+//    Transaction tracking setting page's listbox.
+//
+//----------------------------------------------------
+//
+RESOURCE ARRAY r_ttracking_setting_page_lbx
+    {
+    items =
+        {
+        LBUF
+            {
+            txt = qtn_set_transact_tracking_on;
+            },
+        LBUF
+            {
+            txt = qtn_set_transact_tracking_off;
+            }
+        };
+    }
+
+
+//----------------------------------------------------
+//  r_drm_settings_ttracking_on
+//
+// DRM Settings text for Transaction tracking "On"
+//----------------------------------------------------
+//
+RESOURCE TBUF r_drm_settings_ttracking_on
+    {
+    buf = qtn_set_transact_tracking_on;
+    }
+
+
+//----------------------------------------------------
+//  r_drm_settings_ttracking_off
+//
+// DRM Settings text for Transaction tracking "Off"
+//----------------------------------------------------
+//
+RESOURCE TBUF r_drm_settings_ttracking_off
+    {
+    buf = qtn_set_transact_tracking_off;
+    }
+
+
+//----------------------------------------------------
+//
+//    r_autom_activ_setting_page
+//    Automatic activation setting page.
+//
+//----------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_autom_activ_setting_page
+    {
+    number = EAknSettingPageNoOrdinalDisplayed;
+    label = qtn_drm_set_popup_autom_activat;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__OK;
+    type = EAknSetListBox;
+    editor_resource_id = r_drm_settings_setting_listbox;
+    }
+
+
+//----------------------------------------------------
+//
+//    r_autom_activ_setting_page_lbx
+//    Automatic activation setting page's listbox.
+//
+//----------------------------------------------------
+//
+RESOURCE ARRAY r_autom_activ_setting_page_lbx
+    {
+    items =
+        {
+        LBUF
+            {
+            txt = qtn_set_automat_act_allowed;
+            },
+        LBUF
+            {
+            txt = qtn_set_automat_act_not_allowed;
+            }
+        };
+    }
+
+
+//----------------------------------------------------
+//  r_drm_settings_autom_activ_on
+//
+// DRM Settings text for Automatic activation "Allowed"
+//----------------------------------------------------
+//
+RESOURCE TBUF r_drm_settings_autom_activ_on
+    {
+    buf = qtn_set_automat_act_allowed;
+    }
+
+
+//----------------------------------------------------
+//  r_drm_settings_autom_activ_off
+//
+// DRM Settings text for Automatic activation "Not allowed"
+//----------------------------------------------------
+//
+RESOURCE TBUF r_drm_settings_autom_activ_off
+    {
+    buf = qtn_set_automat_act_not_allowed;
+    }
+
+// ---------------------------------------------------------
+//
+//      r_drm_settings_metering_checkbox_page
+//      Used in checkbox list.
+//
+// ---------------------------------------------------------
+//
+RESOURCE AVKON_SETTING_PAGE r_drm_settings_metering_checkbox_page
+    {
+    number = EAknSettingPageNoOrdinalDisplayed;
+    label = qtn_drm_set_popup_usage_report;
+    softkey_resource = R_AVKON_SOFTKEYS_OK_CANCEL__MARK;
+    type =  EAknSetListBox;
+    editor_resource_id = r_drm_settings_metering_checkbox_list;
+    invalid_contents_softkey_resource = R_AVKON_SOFTKEYS_CANCEL;
+    }
+
+// ---------------------------------------------------------
+//
+//      r_drm_settings_metering_checkbox_list
+//      Used in checkbox list.
+//
+// ---------------------------------------------------------
+//
+RESOURCE AVKON_MULTISELECTION_LIST r_drm_settings_metering_checkbox_list
+    {
+    }
+
+//------------------------------------------------------------------------------
+//
+//    r_usage_reporting_list_title
+//    Title text for usage reporting listbox
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE TBUF r_usage_reporting_list_title
+    {
+    buf=qtn_drm_set_popup_usage_report;
+    }
+
+
+//------------------------------------------------------------------------------
+//
+//    r_usage_reporting_list_empty
+//    Empty text for usage reporting listbox
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE TBUF r_usage_reporting_list_empty
+    {
+    buf=qtn_drm_set_pane_no_providers;
+    }
+
+
+//------------------------------------------------------------------------------
+//
+//    r_drm_set_several_services
+//    'Several' value for 'Allow usage reporting for' field
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_set_several_services
+    {
+    buf=qtn_drm_set_several_services;
+    }
+
+
+//------------------------------------------------------------------------------
+//
+//    r_drm_set_usage_report_none
+//    'None' value for 'Allow usage reporting for' field
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_set_usage_report_none
+    {
+    buf=qtn_drm_set_usage_report_none;
+    }
+
+
+//------------------------------------------------------------------------------
+//
+//    r_drm_confirmation_query_metering
+//    Confirmation query dialog.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_drm_confirmation_query_metering
+    {
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_YES_NO__YES;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                label = " ";
+                };
+            }
+        };
+    }
+
+//------------------------------------------------------------------------------
+//
+//    r_drm_conf_query_metering
+//    Confirmation query text.
+//
+//------------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_conf_query_metering
+    {
+    buf=qtn_drm_conf_query_metering;
+    }
+
+//End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/group/drmsettingsplugin.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,84 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project specification file.
+*
+*/
+
+
+#include <data_caging_paths.hrh>    // For RESOURCE_FILES_DIR
+#include <platform_paths.hrh>
+
+CAPABILITY          CAP_ECOM_PLUGIN
+TARGET              drmsettingsplugin.dll
+TARGETTYPE          PLUGIN
+UID                 0x10009D8D 0x102750CC
+VENDORID            VID_DEFAULT
+
+
+SOURCEPATH      ../src
+SOURCE          drmsettingspluginimplementationtable.cpp
+SOURCE          drmsettingsplugin.cpp
+SOURCE          drmsettingsplugincontainer.cpp
+SOURCE          drmsettingsmodel.cpp
+SOURCE          drmsettingsusagecheckbox.cpp
+SOURCE          drmsettingsusagelist.cpp
+
+//User include paths
+USERINCLUDE     ../inc
+USERINCLUDE     ../data // For *.rh
+USERINCLUDE     ../../../inc   // ADo level inc dir
+USERINCLUDE     ../../../omadrm/drmengine/roapstorage/inc
+
+//System include paths
+// Default system include paths for middleware layer modules.
+// App layer include path needed for help launcher
+APP_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../data
+
+START RESOURCE  102750CC.rss
+TARGET          drmsettingsplugin.rsc
+END
+
+START RESOURCE  drmsettingspluginrsc.rss
+HEADER
+TARGETPATH      RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+
+LIBRARY   aknskins.lib          // for enhanced skinning
+LIBRARY   aknskinsrv.lib        // for enhanced skinning
+LIBRARY   avkon.lib
+LIBRARY   bafl.lib
+LIBRARY   centralrepository.lib
+LIBRARY   commonengine.lib      // For RConeResourceLoader
+LIBRARY   cone.lib
+LIBRARY   ecom.lib
+LIBRARY   efsrv.lib
+LIBRARY   egul.lib
+LIBRARY   eikcoctl.lib
+LIBRARY   eikcore.lib
+LIBRARY   euser.lib
+LIBRARY   featmgr.lib           // Feature manager
+LIBRARY   flogger.lib           // For GSLogger
+LIBRARY   gsecomplugin.lib
+LIBRARY   gsframework.lib       // For base classes
+LIBRARY   gslistbox.lib         // For CGSListBoxItemTextArray
+LIBRARY   hlplch.lib            // for "Help" options menu
+LIBRARY   drmserverinterfaces.lib  // Roap storage
+LIBRARY   charconv.lib
+
+SMPSAFE
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/inc/drmsettingsmodel.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,169 @@
+/*
+* Copyright (c) 2006-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:  DRMSettinsPlugin model.
+*
+*/
+
+#ifndef  DRMSETTINGSMODEL_H
+#define  DRMSETTINGSMODEL_H
+
+// INCLUDES
+#include    <centralrepository.h>
+#include    <e32property.h>
+#include    "roapstorageclient.h"
+
+// FORWARD DECLARATIONS
+class CDRMRIContext;
+
+// CONSTANTS
+const TInt KDRMTransactionTrackingDisabled = 0;
+const TInt KDRMTransactionTrackingEnabled = 1;
+
+const TInt KDRMAutomaticActivationNotAllowed = 0;
+const TInt KDRMAutomaticActivationAllowed = 1;
+    
+
+// CLASS DEFINITIONS
+
+/**
+*  CDRMSettingsModel is the model class of DRMSettingsPlugin.
+*  It provides functions to get and set setting values.
+*/
+class   CDRMSettingsModel : public CBase
+    {
+    
+    public:  // Constructor and destructor
+        /**
+        * Two-phased constructor
+        */
+        static CDRMSettingsModel* NewL();
+
+        /**
+        * Destructor
+        */
+        ~CDRMSettingsModel();
+
+    public: // New 
+         
+        /**
+        * Get transaction tracking state
+        * @return KDRMTransactionTrackingDisabled
+        *         KDRMTransactionTrackingEnabled
+        */
+        TInt TransactionTrackingStateL();
+
+        /**
+        * Set transaction tracking state
+        * @param aValue updated value
+        */
+        void SetTransactionTrackingStateL( TInt aValue );
+       
+        /**
+        * Get automatic activation state
+        * @return KDRMAutomaticActivationNotAllowed
+        *         KDRMAutomaticActivationAllowed
+        */
+        TInt AutomaticActivationStateL();
+
+        /**
+        * Set automatic activation state
+        * @param aValue updated value
+        */
+        void SetAutomaticActivationStateL( TInt aValue );
+        
+        /**
+        * Get usage reporting state
+        * @return count of services for which reporting is allowed
+        */
+        TInt UsageReportingCount();
+
+        /**
+        * Get RI alias
+        *
+        * @param aIndex : Index of the RI context
+        *
+        * @return RI alias name or RI url if no alias available
+        */
+        HBufC* GetSingleRIAliasL( TInt aIndex );
+        
+        /**
+        * Get the first RI alias, where metering is allowed 
+        * @return RI alias name or RI url if no alias available
+        */
+        HBufC* GetFirstAllowedMeteringRIAliasL();
+        
+        /**
+        * Get number of RI contexts 
+        * @return number of RIContexts
+        */
+        TInt GetRiContextCount();
+        
+        /**
+        * Get metering status of RI Context
+        * 
+        * @param aIndex : Index of the RI context
+        *
+        * @return Status of metering
+        */
+        TBool IsMeteringAllowed( TInt aIndex );
+        
+        /**
+        * Find out if metering is allowed for all RI Contexts
+        * 
+        * @return Status of metering
+        */
+        TBool IsMeteringAllowedForAll();
+        
+        /**
+        * Sets the value for metering to be enabled or disabled
+        *
+        * @param aIndex : Index of the RI context
+        * @param aIsAllowed : ETrue if set to allowed, EFalse if not allowed
+        */        
+        void SetMeteringStatus( TInt aIndex, TBool aIsAllowed );
+        
+        /**
+        * Save the changes done to RI Contexs
+        */
+        void SaveMeteringChanges();
+       
+    private: // Private constructors
+        
+        /**
+        * Default C++ contructor
+        */
+        CDRMSettingsModel();
+
+        /**
+        * Symbian OS default constructor
+        * @return void
+        */
+        void ConstructL();
+        
+    private: // Data
+        
+        // DRM Settings Central Repository.
+        CRepository* iDRMSettingsRepository;
+
+        // Roap storage client
+        Roap::RRoapStorageClient* iRoapStorageClient;
+
+        // List of service providers with which device has been registered
+        RPointerArray<CDRMRIContext> iRIContextList;
+        
+    };
+    
+#endif // DRMSETTINGSMODEL_H  
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/inc/drmsettingsplugin.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,189 @@
+/*
+* Copyright (c) 2006-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:  View for DRMSettingsPlugin.
+*
+*/
+
+
+#ifndef DRMSETTINGSPLUGIN_H
+#define DRMSETTINGSPLUGIN_H
+
+// INCLUDES
+#include <aknsettingpage.h>
+#include <coneresloader.h>
+#include <gsplugininterface.h>
+#include <gsfwviewuids.h>
+#include <gsbaseview.h>
+#include <eikmenup.h>
+
+#include "drmsettingsplugincontainer.h"
+
+//CONSTANTS
+const TUid KDRMSettingsPluginUid = { 0x1020750CC };
+
+// Listbox item indexes of the transcaction tracking setting items
+const TInt KDRMTTItemIndexDisabled  = 1;
+const TInt KDRMTTItemIndexEnabled   = 0;
+
+// Listbox item indexes of the automatic activation setting items
+const TInt KDRMAAItemIndexDisabled  = 1;
+const TInt KDRMAAItemIndexEnabled   = 0;
+
+// FORWARD DECLARATIONS
+class CAknViewAppUi;
+class CDRMSettingsPluginContainer;
+class CDRMSettingsModel;
+
+// CLASS DECLARATION
+
+/**
+*  CDRMSettingsPlugin view class
+*
+*  View class for DRM Settings plugin
+*/
+class CDRMSettingsPlugin : public CGSBaseView
+    {
+    
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS two-phased constructor
+        * @return connection view.
+        */
+        static CDRMSettingsPlugin* NewL( TAny* aInitParams );
+
+        /**
+        * Destructor.
+        */
+        ~CDRMSettingsPlugin();
+
+    private:
+        /**
+        * Symbian OS default constructor.
+        * 
+        */
+        void ConstructL();
+
+        /**
+        * C++ default constructor.
+        */
+        CDRMSettingsPlugin();
+
+    public: // from CAknView
+        
+        /**
+        * Returns view id.
+        * @return An unsigned integer (view id).
+        */
+        TUid Id() const;
+
+    public: // from MEikCommandObserver 
+
+        /**
+        * Handles commands.
+        * @param aCommand Command to be handled.
+        * 
+        */
+        void HandleCommandL( TInt aCommand );
+
+    public: //new
+
+        /**
+        * Updates listbox's item's value.
+        * @param aItemId An item which is updated.
+        * 
+        */
+        void UpdateListBoxL( TInt aItemId );
+
+    public: // From CGSPluginInterface
+
+        /**
+        * @see CGSPluginInterface header file.
+        */
+        void GetCaptionL( TDes& aCaption ) const;
+        
+        /**
+        * @see CGSPluginInterface header file.
+        */
+        TInt PluginProviderCategory() const;
+
+        /**
+        * @see CGSPluginInterface header file.
+        */
+        TBool Visible() const;
+
+    private: // from CGSBaseView
+        //
+        void NewContainerL();
+        //
+        void HandleListBoxSelectionL();
+
+    private: // new
+        
+        /**
+        * Update transaction tracking setting
+        */
+        void UpdateTransactionTrackingSettingL( TBool aShowSettingPage );
+
+        /**
+        * Update automatic activation setting
+        */
+        void UpdateAutomaticActivationSettingL( TBool aShowSettingPage );
+
+        /**
+        * Update usage reporting setting
+        */
+        void UpdateUsageReportingSettingL();
+
+        /**
+        * Delete WMDRM license store
+        */
+        void DoWMDRMLicenseDeletionL();
+
+        /**
+        * Display setting page
+        * @param aTTState Current state. This will be updated.
+        * @return ETrue if value is updated.
+        *         EFalse if value is not updated.
+        */
+        TBool ShowTransactionTrackingSettingPageL( TInt& aTTState );
+
+        /**
+        * Display setting page
+        * @param aAAState Current state. This will be updated.
+        * @return ETrue if value is updated.
+        *         EFalse if value is not updated.
+        */
+        TBool ShowAutomaticActivationSettingPageL( TInt& aAAState );
+
+        /**
+        * Get DRMSettingsPlugin's ccontainer.
+        */
+        CDRMSettingsPluginContainer* Container();
+
+    protected: // From MEikMenuObserver
+
+        void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
+        
+    private: // data
+        //resource loader
+        RConeResourceLoader iResourceLoader;
+        
+        TBool iWmdrmSupported;
+    };
+
+#endif //DRMSETTINGSPLUGIN_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/inc/drmsettingsplugin.hrh	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2006-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:  Contains common definitions for menu id:s
+*
+*/
+
+
+#ifndef DRMSETTINGSPLUGIN_HRH
+#define DRMSETTINGSPLUGIN_HRH
+
+   
+enum TSettingId
+    {
+    EDRMSettingsIdAutomaticActivation,
+    EDRMSettingsIdUsageReporting,
+    EDRMSettingsIdTransactionTracking,
+    EDRMSettingsIdWMDRMLicenseDeletion
+    };
+
+enum TMenuCmd
+    {
+    EDRMSettingsCmdAppChange = 1,
+    EDRMSettingsCmdAppChangeMSK 
+    };
+
+enum TListBoxItemVisibility
+    {
+    EDRMSettingsListBoxItemTypeIsAlwaysVisible = 0,
+    EDRMSettingsListBoxItemTypeIsDynamic
+    };
+
+#endif //  DRMSETTINGSPLUGIN_HRH
+
+//End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/inc/drmsettingsplugin.rh	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contains common declarations for resources.
+*                 The file can be included only in resource file.
+*
+*/
+
+#ifndef DRMSETTINGSPLUGIN_RH
+#define DRMSETTINGSPLUGIN_RH
+
+
+// Global definitions
+
+
+// ---------------------------------------------------------
+//    drm_settings_feature_array
+//    Defines a structure to contain information about items 
+//    to be able to included in the listbox.
+// ---------------------------------------------------------
+//
+STRUCT DRM_SETTINGS_FEATURE_ARRAY
+    {
+    STRUCT items[];
+    }
+
+// ---------------------------------------------------------
+//    drm_settings_feature
+//    Defines a structure that contains information about 
+//    a single listbox item.
+// ---------------------------------------------------------
+//
+STRUCT DRM_SETTINGS_FEATURE
+    {
+    LTEXT txt = "";    
+    WORD item = -1;
+    BYTE type = EDRMSettingsListBoxItemTypeIsAlwaysVisible;
+    }
+
+#endif // DRMSETTINGSPLUGIN_RH
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/inc/drmsettingsplugincontainer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,108 @@
+/*
+* Copyright (c) 2006-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:  Container for DRMSettinsPlugin view.
+*
+*/
+
+
+#ifndef DRMSETTINGSPLUGINCONTAINER_H
+#define DRMSETTINGSPLUGINCONTAINER_H
+
+// INCLUDES
+#include <gsbasecontainer.h>
+
+// FORWARD DECLARATIONS
+class CGSListBoxItemTextArray;
+class CDRMSettingsModel;
+
+// CLASS DECLARATION
+
+/**
+*  CDRMSettingsPluginContainer container class
+*  @since Series 60_3.1
+*
+*  Container class for DRM Settings view
+*/
+class CDRMSettingsPluginContainer : public CGSBaseContainer
+    {
+        
+    public: // Constructors and destructor
+
+        /**
+        * Symbian OS constructor.
+        * @param aRect Listbox's rect.
+        */
+        void ConstructL( const TRect& aRect );
+
+        CDRMSettingsPluginContainer( TBool aWmdrmSupported );
+        
+        /**
+        * Destructor.
+        */
+        ~CDRMSettingsPluginContainer();
+
+    public: // new
+
+        /**
+        * Updates listbox's item's value.
+        * @param aFeatureId An item which is updated.
+        */
+        void UpdateListBoxL( TInt aFeatureId );
+
+        /**
+        * Retrieves the currently selected listbox feature id
+        * @return feature id.
+        */
+        TInt CurrentFeatureId() const;
+        
+        /**
+        * @return Model for the plugin.
+        */
+        CDRMSettingsModel* Model();
+        
+    protected: // from CGSBaseContainer
+    
+        /**
+        * See base class.
+        */
+        void ConstructListBoxL( TInt aResLbxId );
+        
+    private: // new
+
+        void CreateListBoxItemsL();
+        void MakeTransactionTrackingItemL();
+        void MakeAutomaticActivationItemL();
+        void MakeUsageReportingItemL();
+        void MakeWMDRMLicenseDeletionItemL();
+
+    private:
+    
+        /**
+        * Required for help.
+        */
+        void GetHelpContext( TCoeHelpContext& aContext ) const;
+
+    private: // data
+
+        // GS listbox item array
+        CGSListBoxItemTextArray* iListboxItemArray;
+        
+        // Model for DRMSettingsPlugin.
+        CDRMSettingsModel* iModel;
+        TBool iWmdrmSupported;
+    };
+
+#endif //DRMSETTINGSPLUGINCONTAINER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/inc/drmsettingsusagecheckbox.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,79 @@
+/*
+* 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:  CheckBox class for Usage Reporting settings
+*
+*/
+
+
+#ifndef C_DRMSETTINGSUSAGECHECKBOX_H
+#define C_DRMSETTINGSUSAGECHECKBOX_H
+
+// INCLUDES
+#include <akncheckboxsettingpage.h>
+#include <aknsettingpage.h>
+
+// FORWARD DECLARATIONS
+class CDRMSettingUsageList;
+class CDRMSettingsModel;
+class CAknInfoPopupNoteController;
+
+/**
+ * CDrmSettingUsageCheckBox class
+ */
+NONSHARABLE_CLASS( CDrmSettingUsageCheckBox ) : public CAknCheckBoxSettingPage
+    {
+
+    public: // New functions
+
+        /**
+		* C++ default constructor.
+		*/
+		CDrmSettingUsageCheckBox( TInt aResourceId,
+		                          CDRMSettingUsageList* aList,
+		                          CDRMSettingsModel* aModel );
+		                          
+		/**
+		* Destructor.
+        */
+        virtual ~CDrmSettingUsageCheckBox();	
+
+	private: // From CAknSettingPage
+	
+	    TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, 
+	                                 TEventCode aType );
+	
+	    void DynamicInitL();
+	
+	    TBool OkToExitL(TBool aAccept);
+	    
+	    void AcceptSettingL();    
+	
+	private: // New functions
+	
+	    void ShowInfoPopupL();
+
+    private: // Data
+		
+		// Not owned
+		CDRMSettingUsageList* iList;
+		
+		// Not owned
+        CDRMSettingsModel* iModel;
+        
+        // Owned
+        CAknInfoPopupNoteController* iPopupController;
+
+    };
+
+#endif // C_DRMSETTINGSUSAGECHECKBOX_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/inc/drmsettingsusagelist.h	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  List class for Usage Reporting checkbox
+*
+*/
+
+
+#ifndef C_DRMSETTINGSUSAGELIST_H
+#define C_DRMSETTINGSUSAGELIST_H
+
+// INCLUDES
+#include <akncheckboxsettingpage.h>
+
+// FORWARD DECLARATIONS
+class CDRMSettingsModel;
+
+/**
+ * CDRMSettingUsageList class
+ */
+NONSHARABLE_CLASS( CDRMSettingUsageList ) : public CSelectionItemList
+	{
+
+    public: // New functions
+	
+	    /**
+		* Two-phased constructor.
+        */
+		static CDRMSettingUsageList* NewL( CDRMSettingsModel* aModel );
+
+        /**
+		* Destructor.
+        */
+        virtual ~CDRMSettingUsageList();
+        
+	    /**
+	    * Updates contexts
+	    */
+	    void UpdateContexts();
+	
+	private:
+	
+	    /**
+	    * Default constructor.
+	    */
+	    CDRMSettingUsageList( CDRMSettingsModel* aModel );
+	    
+	    /**
+        * Symbian OS constructor.
+        */
+	    void ConstructL();
+	    
+	private: // Data
+	
+	    // Not owned
+	    CDRMSettingsModel* iModel;
+	
+	};
+	
+#endif // C_DRMSETTINGSUSAGELIST_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/loc/drmsettingsplugin.loc	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,168 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Localization strings for DRMSettingsPlugin component.
+*
+*/
+
+
+//  LOCALISATION STRINGS
+
+//d:Title pane of General Settings / Protected Content view
+//l:title_pane_t2/opt9 
+//w:
+//r: 3.1
+#define qtn_set_protected_content "Protected content"
+
+//d:Text of a list item in Protected Content view
+//l: list_setting_pane_t1 
+//w:
+//r: 3.1
+#define qtn_set_transaction_tracking "Transaction tracking"
+
+//d:Popup setting item
+//l:main_pane_set_t1 
+//w:
+//r: 3.1
+#define qtn_drm_set_popup_trans_track "Transaction tracking"
+
+//d:Item in the Transaction tracking popup setting page list
+//l: list_set_graphic_pane_t1
+//w:
+//r: 3.1
+#define qtn_set_transact_tracking_off "Disabled"
+
+//d:Item in popup setting page list
+//l: list_set_graphic_pane_t1
+//w:
+//r: 3.1
+#define qtn_set_transact_tracking_on "Enabled"
+
+//d:Text of a list item in Protected Content view
+//l:list_setting_pane_t1
+//w:
+//r: 3.1
+#define qtn_set_automatic_activation "Automatic activation"
+
+//d:Popup setting item 
+//l:main_pane_set_t1 
+//w:
+//r: 3.1
+#define qtn_drm_set_popup_autom_activat "Automatic activation"
+
+//d:Item in popup setting page list
+//l: list_set_graphic_pane_t1 
+//w:
+//r: 3.1
+#define qtn_set_automat_act_not_allowed "Not allowed"
+           
+//d:Item in popup setting page list
+//l:list_set_graphic_pane_t1
+//w:
+//r: 3.1
+#define qtn_set_automat_act_allowed "Allowed"
+
+//d:Text of a list item in Protected Content view
+//l:list_setting_pane_t1
+//w:
+//r:3.2
+#define qtn_drm_set_usage_reporting "Allow usage reporting for"
+
+//d:One of alternative values for 'Allow usage reporting for' setting
+//l:list_set_graphic_pane_t1
+//w:
+//r:3.2
+#define qtn_drm_set_several_services "Several services"
+
+//d:One of alternative values for 'Allow usage reporting for' setting
+//l:list_set_graphic_pane_t1
+//w:
+//r:3.2
+#define qtn_drm_set_usage_report_none "None"
+
+//d:Popup setting item
+//l:list_setting_pane_t1
+//w:
+//r:3.2
+#define qtn_drm_set_popup_usage_report "Allow usage reporting for"
+
+//d:Empty listbox text
+//l:set_content_pane/opt8
+//w:
+//r:3.2
+#define qtn_drm_set_pane_no_providers "No registered service providers"
+
+//d:Confirmation query text, shown when user has unmarked some service providers 
+//l:popup_note_window
+//w:
+//r:3.2
+#define qtn_drm_conf_query_metering "After changing this setting some of your protected media files may not be used. Continue?"
+
+//d:Text of a list item in Protected Content view
+//l:list_setting_pane_t1
+//w:
+//r:3.2
+//
+#define qtn_drm_set_license_deletion "WMDRM license deletion"
+
+//d:Confirmation query text
+//d:Shown when user has selected to delete WMDRM licenses in situation where disk space isn't running out
+//l:popup_note_window
+//w:
+//r:3.2
+//
+#define qtn_drm_conf_not_out_of_space "You are currently not out of space. Delete licenses anyway?"
+
+//d:Confirmation query text
+//d:Shown when user has selected to delete WMDRM licenses in low disk space situation
+//l:popup_note_window
+//w:
+//r:3.2
+//
+#define qtn_drm_conf_license_deletion "You may need to delete and re-sync your protected media files with PC after this operation. Continue?"
+
+//d:Confirmation query text
+//d:Shown when WMDRM licenses have been deleted
+//l:popup_note_window
+//w:
+//r:3.2
+//
+#define qtn_drm_licenses_deleted "Licenses deleted. If you are unable to use your protected media files, re-sync with PC."
+
+//d:Global confirmation query text
+//d:Shown when user is trying to synchronize WMDRM media from PC to phone, but disk space is running low
+//l:popup_note_window
+//w:
+//r:3.2
+//
+#define qtn_drm_note_memory_low "Not enough memory to sync protected media. Delete data from C:"
+
+//d:Global message query header text
+//d:Shown when user is trying to synchronize WMDRM media from PC to phone, but license store is full 
+//l:heading_pane_t1
+//w:
+//r:3.2
+//
+#define qtn_drm_header_license_store_full "License store full"
+
+//d:Global message query text
+//d:Shown when user is trying to synchronize WMDRM media from PC to phone, but license store is full
+//l:popup_info_list_pane_t1
+//w:
+//r:3.2
+//
+#define qtn_drm_license_store_full "The license store is full. To continue sync of protected media delete licenses from Security settings > Protected content settings"
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/src/drmsettingsmodel.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,315 @@
+/*
+* Copyright (c) 2006-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:  Model for DRMSettinsPlugin.
+*
+*/
+
+
+// INCLUDE FILES
+#include <utf.h>
+#include <commdb.h>
+#include <featmgr.h>
+
+#include "drmsettingsmodel.h"
+#include "drmsettingsplugininternalcrkeys.h"
+#include "drmricontext.h"
+
+// CONSTANTS
+#ifdef _DEBUG
+// debug panic
+_LIT( KDRMSettingsDebugPanicMessage, "DrmSettingsDebugPanic" );
+const TInt KDRMSettingsDebugPanicCode( 1 );
+#endif
+
+// ================= MEMBER FUNCTIONS =======================
+
+
+// ----------------------------------------------------------------------------
+// CDRMSettingsModel::NewL
+//
+// EPOC two-phased constructor
+// ----------------------------------------------------------------------------
+//
+CDRMSettingsModel* CDRMSettingsModel::NewL()
+    {
+    CDRMSettingsModel* self = new( ELeave ) CDRMSettingsModel;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CDRMSettingsModel::CDRMSettingsModel
+//
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ----------------------------------------------------------------------------
+//
+CDRMSettingsModel::CDRMSettingsModel()
+    {
+    }
+
+
+// ----------------------------------------------------------------------------
+// CDRMSettingsModel::ConstructL
+//
+// EPOC default constructor can leave.
+// ----------------------------------------------------------------------------
+//
+void CDRMSettingsModel::ConstructL()
+    {
+    // create an instance of Central Repository
+    iDRMSettingsRepository = CRepository::NewL( KCRUidDRMSettings );
+
+#ifdef RD_DRM_METERING
+
+    // Create an instance of roap storage client
+    iRoapStorageClient = new (ELeave) Roap::RRoapStorageClient;
+
+    // Connect to server
+    User::LeaveIfError( iRoapStorageClient->Connect() );
+
+    // Fill the list
+    iRoapStorageClient->GetAllRIContextsL( iRIContextList );
+
+#endif // RD_DRM_METERING
+
+    }
+
+
+// ----------------------------------------------------------------------------
+// CDRMSettingsModel::~CDRMSettingsModel
+//
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CDRMSettingsModel::~CDRMSettingsModel()
+    {
+    if ( iDRMSettingsRepository )
+        {
+        delete iDRMSettingsRepository;
+        }
+    if ( iRoapStorageClient )
+        {
+        iRoapStorageClient->Close();
+        delete iRoapStorageClient;
+        }
+
+    iRIContextList.ResetAndDestroy();
+    iRIContextList.Close();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::SetTransactionTrackingStateL()
+//
+// Set transaction tracking state
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsModel::SetTransactionTrackingStateL( TInt aValue )
+    {
+    User::LeaveIfError( iDRMSettingsRepository->
+                                Set( KDRMSettingsTransactionTracking,
+                                     aValue ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::TransactionTrackingStateL()
+//
+// Get transaction tracking state
+// ---------------------------------------------------------------------------
+//
+TInt CDRMSettingsModel::TransactionTrackingStateL()
+    {
+    TInt value( KErrNone );
+
+    User::LeaveIfError( iDRMSettingsRepository->Get(
+                                    KDRMSettingsTransactionTracking,
+                                    value ) );
+
+    return value;
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::SetAutomaticActivationStateL()
+//
+// Set automatic activation state
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsModel::SetAutomaticActivationStateL( TInt aValue )
+    {
+    User::LeaveIfError( iDRMSettingsRepository->
+                                Set( KDRMSettingsSilentRightsAcquisition,
+                                     aValue ) );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::AutomaticActivationStateL()
+//
+// Get automatic activation state
+// ---------------------------------------------------------------------------
+//
+TInt CDRMSettingsModel::AutomaticActivationStateL()
+    {
+    TInt value( KErrNone );
+
+    User::LeaveIfError( iDRMSettingsRepository->Get(
+                                KDRMSettingsSilentRightsAcquisition,
+                                value ) );
+
+    return value;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::UsageReportingCount()
+//
+// Get usage reporting state. Return count of allowed services.
+// ---------------------------------------------------------------------------
+//
+TInt CDRMSettingsModel::UsageReportingCount()
+    {
+    TInt count( 0 );
+
+    for ( TInt i( 0 ); i < iRIContextList.Count(); i++ )
+        {
+        if ( iRIContextList[i]->IsMeteringAllowed() )
+            {
+            count++;
+            }
+        }
+
+    return count;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::GetSingleRIAliasL()
+// ---------------------------------------------------------------------------
+//
+HBufC* CDRMSettingsModel::GetSingleRIAliasL( TInt aIndex )
+    {
+    __ASSERT_DEBUG( aIndex >= 0 ||
+                    aIndex < iRIContextList.Count(),
+                        User::Panic( KDRMSettingsDebugPanicMessage,
+                                     KDRMSettingsDebugPanicCode ) );
+
+    HBufC* alias( NULL );
+
+    if ( &iRIContextList[aIndex]->RIAlias() )
+        {
+        alias =
+            CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+                iRIContextList[aIndex]->RIAlias() );
+        }
+    else
+        {
+        alias =
+            CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+                iRIContextList[aIndex]->RightsIssuerURL() );
+        }
+
+    return alias;
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::GetFirstAllowedMeteringRIAliasL()
+// ---------------------------------------------------------------------------
+//
+HBufC* CDRMSettingsModel::GetFirstAllowedMeteringRIAliasL()
+    {
+    for ( TInt i( 0 ); i < iRIContextList.Count(); i++ )
+        {
+        if( IsMeteringAllowed( i ) )
+            {
+            return GetSingleRIAliasL( i );
+            }
+        }
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::GetRiContextCount()
+// ---------------------------------------------------------------------------
+//
+TInt CDRMSettingsModel::GetRiContextCount()
+    {
+    return iRIContextList.Count();
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::IsMeteringAllowed()
+// ---------------------------------------------------------------------------
+//
+TBool CDRMSettingsModel::IsMeteringAllowed( TInt aIndex )
+    {
+    __ASSERT_DEBUG( aIndex >= 0 ||
+                    aIndex < iRIContextList.Count(),
+                        User::Panic( KDRMSettingsDebugPanicMessage,
+                                     KDRMSettingsDebugPanicCode ) );
+
+    return iRIContextList[aIndex]->IsMeteringAllowed();
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::IsMeteringAllowedForAll()
+// ---------------------------------------------------------------------------
+//
+TBool CDRMSettingsModel::IsMeteringAllowedForAll()
+    {
+    TBool isAllowed( ETrue );
+
+    for ( TInt i( 0 ); i < iRIContextList.Count() && isAllowed; i++ )
+        {
+        if( !IsMeteringAllowed( i ) )
+            {
+            isAllowed = EFalse;
+            }
+        }
+
+    return isAllowed;
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::SetMeteringStatus()
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsModel::SetMeteringStatus( TInt aIndex, TBool aIsAllowed )
+    {
+    __ASSERT_DEBUG( aIndex >= 0 ||
+                    aIndex < iRIContextList.Count(),
+                        User::Panic( KDRMSettingsDebugPanicMessage,
+                                     KDRMSettingsDebugPanicCode ) );
+
+    iRIContextList[aIndex]->SetMeteringStatus( aIsAllowed );
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsModel::SaveMeteringChanges()
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsModel::SaveMeteringChanges()
+    {
+    for ( TInt i( 0 ); i < iRIContextList.Count(); i++ )
+        {
+        TRAP_IGNORE(
+            iRoapStorageClient->UpdateRIContextL( *iRIContextList[i] ) );
+        }
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/src/drmsettingsplugin.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,728 @@
+/*
+* Copyright (c) 2006-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:  View for DRMSettinsPlugin
+*
+*/
+
+
+// INCLUDE FILES
+#include <coeaui.h>
+#include <hlplch.h>             // For HlpLauncher
+#include <bautils.h>
+#include <eikfrlbd.h>
+#include <featmgr.h>
+#include <stringloader.h>
+#include <aknviewappui.h>
+#include <aknradiobuttonsettingpage.h>
+#include <gsfwviewuids.h>
+#include <gsprivatepluginproviderids.h>
+#include <gscommon.hrh>
+#include <drmsettingspluginrsc.rsg>
+
+#include "drmsettingsplugin.h"
+#include "drmsettingsplugincontainer.h"
+#include "drmsettingsplugin.hrh"
+#include "drmsettingsmodel.h"
+#include "drmsettingsusagecheckbox.h"
+#include "drmsettingsusagelist.h"
+#include "wmdrmpkclientwrapper.h"
+
+// CONSTANTS
+_LIT( KDRMSettingsPluginResourceFileName, "z:drmsettingspluginrsc.rsc" );
+
+
+// ============================= LOCAL FUNCTIONS ==============================
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ----------------------------------------------------------------------------
+// CDRMSettingsPlugin::CDRMSettingsPlugin()
+//
+// Constructor
+// ----------------------------------------------------------------------------
+//
+CDRMSettingsPlugin::CDRMSettingsPlugin()
+  : iResourceLoader( *iCoeEnv )
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::NewL()
+//
+// Symbian OS default constructor
+// ---------------------------------------------------------------------------
+CDRMSettingsPlugin* CDRMSettingsPlugin::NewL( TAny* /*aInitParams*/ )
+    {
+    CDRMSettingsPlugin* self = new( ELeave ) CDRMSettingsPlugin;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::ConstructL()
+//
+// Symbian OS two-phased constructor
+// ---------------------------------------------------------------------------
+void CDRMSettingsPlugin::ConstructL()
+    {
+    FeatureManager::InitializeLibL();
+    // Find the resource file
+    TParse parse;
+    parse.Set( KDRMSettingsPluginResourceFileName,
+               &KDC_RESOURCE_FILES_DIR,
+               NULL );
+    TFileName fileName( parse.FullName() );
+
+    // Get language of resource file
+    BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), fileName );
+
+    // Open resource file
+    iResourceLoader.OpenL( fileName );
+
+    BaseConstructL( R_DRM_SETTINGS_VIEW );
+
+    if ( FeatureManager::FeatureSupported( KFeatureIdWindowsMediaDrm ) )
+        {
+        iWmdrmSupported = ETrue;
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CDRMSettingsPlugin::~CDRMSettingsPlugin
+//
+// Destructor
+// ----------------------------------------------------------------------------
+CDRMSettingsPlugin::~CDRMSettingsPlugin()
+    {
+    FeatureManager::UnInitializeLib();
+    iResourceLoader.Close();
+    }
+
+
+// ---------------------------------------------------------------------------
+// TUid CDRMSettingsPlugin::Id()
+//
+// Returns view's ID.
+// ---------------------------------------------------------------------------
+TUid CDRMSettingsPlugin::Id() const
+    {
+    return KDRMSettingsPluginUid;
+    }
+
+
+// ========================= From CGSPluginInterface ==================
+
+// ----------------------------------------------------------------------------
+// CDRMSettingsPlugin::GetCaption
+//
+// Return application/view caption.
+// ----------------------------------------------------------------------------
+//
+void CDRMSettingsPlugin::GetCaptionL( TDes& aCaption ) const
+    {
+    // the resource file is already opened.
+    HBufC* result( StringLoader::LoadL( R_DRM_SETTINGS_VIEW_CAPTION ) );
+    aCaption.Copy( *result );
+    delete result;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CDRMSettingsPlugin::PluginProviderCategory
+//
+// A means to identify the location of this plug-in in the framework.
+// ----------------------------------------------------------------------------
+//
+TInt CDRMSettingsPlugin::PluginProviderCategory() const
+    {
+    //To identify internal plug-ins.
+    return KGSPluginProviderInternal;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CDRMSettingsPlugin::Visible
+//
+// Provides the visibility status of self to framework.
+// ----------------------------------------------------------------------------
+//
+TBool CDRMSettingsPlugin::Visible() const
+    {
+    TBool visible( EFalse );
+
+    // The plugin is visible if __DRM_OMA2 or __WINDOWS_MEDIA_DRM are enabled.
+    if( FeatureManager::FeatureSupported( KFeatureIdDrmOma2 ) ||
+        FeatureManager::FeatureSupported( KFeatureIdWindowsMediaDrm ) )
+        {
+        visible = ETrue;
+        }
+
+    return visible;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::HandleCommandL(TInt aCommand)
+//
+// Handles commands directed to this class.
+// ---------------------------------------------------------------------------
+void CDRMSettingsPlugin::HandleCommandL( TInt aCommand )
+    {
+    switch ( aCommand )
+        {
+        case EDRMSettingsCmdAppChangeMSK:
+            {
+            const TInt currentFeatureId( Container()->CurrentFeatureId() );
+
+            switch ( currentFeatureId )
+                {
+#ifdef __DRM_OMA2
+                case EDRMSettingsIdTransactionTracking:
+
+                    UpdateTransactionTrackingSettingL( EFalse );
+
+                    break;
+
+#ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
+                case EDRMSettingsIdAutomaticActivation:
+
+                    UpdateAutomaticActivationSettingL( EFalse );
+
+                    break;
+#endif // RD_DRM_SILENT_RIGHTS_ACQUISITION
+
+#ifdef RD_DRM_METERING
+                case EDRMSettingsIdUsageReporting:
+
+                    UpdateUsageReportingSettingL();
+
+                    break;
+#endif // RD_DRM_METERING
+#endif // __DRM_OMA2
+
+                case EDRMSettingsIdWMDRMLicenseDeletion:
+
+                    if ( iWmdrmSupported )
+                        {
+                        DoWMDRMLicenseDeletionL();
+                        }
+
+                    break;
+
+                default:
+
+                    break;
+                }
+
+            break;
+            }
+        case EDRMSettingsCmdAppChange:
+            {
+            const TInt currentFeatureId( Container()->CurrentFeatureId() );
+
+            switch ( currentFeatureId )
+                {
+#ifdef __DRM_OMA2
+                case EDRMSettingsIdTransactionTracking:
+
+                    UpdateTransactionTrackingSettingL( ETrue );
+
+                    break;
+
+#ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
+                case EDRMSettingsIdAutomaticActivation:
+
+                    UpdateAutomaticActivationSettingL( ETrue );
+
+                    break;
+#endif // RD_DRM_SILENT_RIGHTS_ACQUISITION
+
+#ifdef RD_DRM_METERING
+                case EDRMSettingsIdUsageReporting:
+
+                    UpdateUsageReportingSettingL();
+
+                    break;
+#endif // RD_DRM_METERING
+#endif // __DRM_OMA2
+
+                case EDRMSettingsIdWMDRMLicenseDeletion:
+
+                    if ( iWmdrmSupported )
+                        {
+                        DoWMDRMLicenseDeletionL();
+                        }
+
+                    break;
+
+                default:
+
+                    break;
+                }
+            break;
+            }
+        case EAknSoftkeyBack:
+
+            iAppUi->ActivateLocalViewL( KGSSecurityPluginUid );
+
+            break;
+
+        case EAknCmdHelp:
+            {
+
+            if( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
+                {
+                HlpLauncher::LaunchHelpApplicationL(
+                                                iEikonEnv->WsSession(),
+                                                iAppUi->AppHelpContextL() );
+                }
+
+            break;
+
+            }
+        default:
+
+            iAppUi->HandleCommandL( aCommand );
+
+            break;
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::UpdateListBoxL
+//
+// Updates listbox items.
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPlugin::UpdateListBoxL( TInt aItemId )
+    {
+    Container()->UpdateListBoxL( aItemId );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CDRMSettingsPlugin::Container
+//
+// Return handle to container class.
+// ----------------------------------------------------------------------------
+//
+CDRMSettingsPluginContainer* CDRMSettingsPlugin::Container()
+    {
+    return static_cast<CDRMSettingsPluginContainer*>( iContainer );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::NewContainerL()
+//
+// Creates new iContainer.
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPlugin::NewContainerL()
+    {
+    iContainer = new( ELeave ) CDRMSettingsPluginContainer( iWmdrmSupported );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::HandleListBoxSelectionL()
+//
+// Handles events raised through a rocker key.
+// ---------------------------------------------------------------------------
+void CDRMSettingsPlugin::HandleListBoxSelectionL()
+    {
+    const TInt currentFeatureId( Container()->CurrentFeatureId() );
+
+    switch ( currentFeatureId )
+        {
+#ifdef __DRM_OMA2
+        case EDRMSettingsIdTransactionTracking:
+
+            UpdateTransactionTrackingSettingL( EFalse );
+
+            break;
+
+#ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
+        case EDRMSettingsIdAutomaticActivation:
+
+            UpdateAutomaticActivationSettingL( EFalse );
+
+            break;
+#endif // RD_DRM_SILENT_RIGHTS_ACQUISITION
+
+#ifdef RD_DRM_METERING
+        case EDRMSettingsIdUsageReporting:
+
+            UpdateUsageReportingSettingL();
+
+            break;
+#endif // RD_DRM_METERING
+#endif // __DRM_OMA2
+
+        case EDRMSettingsIdWMDRMLicenseDeletion:
+
+            if ( iWmdrmSupported )
+                {
+                DoWMDRMLicenseDeletionL();
+                }
+
+            break;
+
+       default:
+
+            break;
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::UpdateTransactionTrackingSettingL
+//
+// Display Transaction tracking setting page.
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPlugin::UpdateTransactionTrackingSettingL( TBool aShowSettingPage )
+    {
+    if( FeatureManager::FeatureSupported( KFeatureIdDrmOma2 ) )
+        {
+        TInt currentValue( Container()->Model()->TransactionTrackingStateL() );
+        TBool isValueUpdated( EFalse );
+
+        if ( aShowSettingPage )
+            {
+            isValueUpdated = ShowTransactionTrackingSettingPageL( currentValue );
+            }
+        else
+            {
+            switch ( currentValue )
+                {
+                case KDRMTransactionTrackingDisabled:
+
+                    currentValue = KDRMTransactionTrackingEnabled;
+
+                    break;
+
+                case KDRMTransactionTrackingEnabled:
+
+                    currentValue = KDRMTransactionTrackingDisabled;
+
+                    break;
+
+                default:
+
+                    break;
+                }
+            isValueUpdated = ETrue;
+            }
+        // If value is updated, store it to model:
+        if ( isValueUpdated )
+            {
+            Container()->Model()->SetTransactionTrackingStateL( currentValue );
+            UpdateListBoxL( EDRMSettingsIdTransactionTracking );
+            }
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::ShowTransactionTrackingSettingPageL()
+//
+// Display transaction tracking setting page. Selected listbox item index
+// must be mapped to transaction tracking state because index value is
+// different from state value.
+// ---------------------------------------------------------------------------
+//
+TBool CDRMSettingsPlugin::ShowTransactionTrackingSettingPageL(
+    TInt& aTTState )
+    {
+    // in case DRM Phase 2 is not supported, return EFalse.
+    TBool isValueUpdated( EFalse );
+    TInt selectedTTItemIndex( 0 );
+    TInt originalTTState( aTTState );
+
+    // Set selected listbox item to current transaction tracking state:
+    switch ( aTTState )
+        {
+        case KDRMTransactionTrackingDisabled:
+
+            selectedTTItemIndex = KDRMTTItemIndexDisabled;
+
+            break;
+
+        case KDRMTransactionTrackingEnabled:
+
+            selectedTTItemIndex = KDRMTTItemIndexEnabled;
+
+            break;
+        }
+
+    CDesCArrayFlat* items(
+        iCoeEnv->ReadDesC16ArrayResourceL( R_TTRACKING_SETTING_PAGE_LBX ) );
+    CleanupStack::PushL( items );
+    CAknRadioButtonSettingPage* dlg(
+        new (ELeave) CAknRadioButtonSettingPage( R_TTRACKING_SETTING_PAGE,
+                                                 selectedTTItemIndex,
+                                                 items ) );
+
+    dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
+    CleanupStack::PopAndDestroy( items );
+
+    // Map selected listbox item to correct state:
+    switch ( selectedTTItemIndex )
+        {
+        case KDRMTTItemIndexDisabled:
+
+            aTTState = KDRMTransactionTrackingDisabled;
+
+            break;
+
+        case KDRMTTItemIndexEnabled:
+
+            aTTState = KDRMTransactionTrackingEnabled;
+
+            break;
+        }
+
+    // Check is value updated:
+    if( aTTState != originalTTState )
+        {
+        isValueUpdated = ETrue;
+        }
+
+    return isValueUpdated;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::UpdateAutomaticActivationSettingL
+//
+// Display Automatic activation setting page.
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPlugin::UpdateAutomaticActivationSettingL( TBool aShowSettingPage )
+    {
+    if( FeatureManager::FeatureSupported( KFeatureIdDrmOma2 ) )
+        {
+        TInt currentValue( Container()->Model()->AutomaticActivationStateL() );
+        TBool isValueUpdated( EFalse );
+
+        if ( aShowSettingPage )
+            {
+            isValueUpdated = ShowAutomaticActivationSettingPageL( currentValue );
+            }
+        else
+            {
+            switch ( currentValue )
+                {
+                case KDRMAutomaticActivationNotAllowed:
+
+                    currentValue = KDRMAutomaticActivationAllowed;
+
+                    break;
+
+                case KDRMAutomaticActivationAllowed:
+
+                    currentValue = KDRMAutomaticActivationNotAllowed;
+
+                    break;
+
+                default:
+
+                    break;
+                }
+            isValueUpdated = ETrue;
+            }
+        // If value is updated, store it to model:
+        if ( isValueUpdated )
+            {
+            Container()->Model()->SetAutomaticActivationStateL( currentValue );
+            UpdateListBoxL( EDRMSettingsIdAutomaticActivation );
+            }
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::ShowAutomaticActivationSettingPageL()
+//
+// Display Automatic activation setting page. Selected listbox item index
+// must be mapped to automatic activation state because index value is
+// different from state value.
+// ---------------------------------------------------------------------------
+//
+TBool CDRMSettingsPlugin::ShowAutomaticActivationSettingPageL(
+    TInt& aAAState )
+    {
+    // in case DRM Phase 2 is not supported, return EFalse.
+    TBool isValueUpdated( EFalse );
+    TInt selectedAAItemIndex( 0 );
+    TInt originalAAState( aAAState );
+
+    // Set selected listbox item to current state:
+    switch ( aAAState )
+        {
+        case KDRMAutomaticActivationNotAllowed:
+
+            selectedAAItemIndex = KDRMAAItemIndexDisabled;
+
+            break;
+
+        case KDRMAutomaticActivationAllowed:
+
+            selectedAAItemIndex = KDRMAAItemIndexEnabled;
+
+            break;
+        }
+
+    CDesCArrayFlat* items(
+        iCoeEnv->ReadDesC16ArrayResourceL( R_AUTOM_ACTIV_SETTING_PAGE_LBX ) );
+    CleanupStack::PushL( items );
+    CAknRadioButtonSettingPage* dlg(
+        new (ELeave) CAknRadioButtonSettingPage( R_AUTOM_ACTIV_SETTING_PAGE,
+                                                 selectedAAItemIndex,
+                                                 items ) );
+
+    dlg->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
+    CleanupStack::PopAndDestroy( items );
+
+    // Map selected listbox item to correct state:
+    switch ( selectedAAItemIndex )
+        {
+        case KDRMAAItemIndexDisabled:
+
+            aAAState = KDRMAutomaticActivationNotAllowed;
+
+            break;
+
+        case KDRMAAItemIndexEnabled:
+
+            aAAState = KDRMAutomaticActivationAllowed;
+
+            break;
+
+        }
+
+    // Check is value updated:
+    if( aAAState != originalAAState )
+        {
+        isValueUpdated = ETrue;
+        }
+
+    return isValueUpdated;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::UpdateUsageReportingSettingL
+//
+// Display Usage Reporting setting page.
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPlugin::UpdateUsageReportingSettingL()
+    {
+    TBool isValueUpdated( EFalse );
+
+    if( FeatureManager::FeatureSupported( KFeatureIdDrmOma2 ) )
+        {
+        CDRMSettingsModel* model( this->Container()->Model() );
+
+        CDRMSettingUsageList* usageList( CDRMSettingUsageList::NewL( model ) );
+        CleanupStack::PushL( usageList );
+
+        CDrmSettingUsageCheckBox* usageCheckBox(
+            new (ELeave) CDrmSettingUsageCheckBox(
+                R_DRM_SETTINGS_METERING_CHECKBOX_PAGE,
+                usageList,
+                model ) );
+
+        isValueUpdated =
+            usageCheckBox->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted );
+
+        CleanupStack::PopAndDestroy( usageList );
+        }
+
+    if ( isValueUpdated )
+        {
+        UpdateListBoxL( EDRMSettingsIdUsageReporting );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPlugin::DoWMDRMLicenseDeletionL
+//
+// Display WMDRM license deletion setting page.
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPlugin::DoWMDRMLicenseDeletionL()
+    {
+    if ( iWmdrmSupported )
+        {
+        TInt r = KErrNone;
+        RLibrary library;
+        r = library.Load( KWmdrmPkClientWrapperName );
+        if( !r )
+            {
+            CleanupClosePushL( library );
+            CWmDrmPkClientWrapper* wrapper =
+                (CWmDrmPkClientWrapper*)library.Lookup( KWmdrmPkClientNewL )();
+            CleanupStack::PushL( wrapper );
+            User::LeaveIfError( wrapper->Connect() );
+            wrapper->DeleteRights();
+            wrapper->Close();
+            CleanupStack::PopAndDestroy( 2, &library );
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMSettingsPlugin::DynInitMenuPaneL()
+//
+// Display the dynamic menu
+// ----------------------------------------------------------------------------
+void CDRMSettingsPlugin::DynInitMenuPaneL(
+    TInt aResourceId,
+    CEikMenuPane* aMenuPane )
+    {
+    // show or hide the 'help' menu item when supported
+    if( aResourceId == R_DRM_SETTINGS_MENU_ITEM_EXIT )
+        {
+        User::LeaveIfNull( aMenuPane );
+
+#ifdef __DRM_OMA2
+        if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
+            {
+            aMenuPane->SetItemDimmed( EAknCmdHelp, EFalse );
+            }
+        else
+            {
+            aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
+            }
+#else
+
+        aMenuPane->SetItemDimmed( EAknCmdHelp, ETrue );
+
+#endif // __DRM_OMA2
+        }
+    }
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/src/drmsettingsplugincontainer.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,336 @@
+/*
+* Copyright (c) 2006-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:  Container for DRMSettinsPlugin
+*
+*/
+
+
+// INCLUDE FILES
+#include <aknlists.h>
+#include <aknutils.h>
+#include <csxhelp/drm.hlp.hrh>
+#include <gslistbox.h>
+#include <stringloader.h>
+#include <drmsettingspluginrsc.rsg>
+
+#include "drmsettingsplugincontainer.h"
+#include "drmsettingsplugin.hrh"
+#include "drmsettingsmodel.h"
+
+const TUid KUidRightsManager = { 0x101F85C7 };
+
+// ========================= MEMBER FUNCTIONS ================================
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::ConstructL()
+// 
+// Symbian OS two phased constructor
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPluginContainer::ConstructL( const TRect& aRect )
+    {
+    iListBox = new( ELeave ) CAknSettingStyleListBox;
+    iModel = CDRMSettingsModel::NewL();
+    BaseConstructL( aRect, R_DRM_SETTINGS_VIEW_TITLE, R_DRM_SETTINGS_LBX );
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::CDRMSettingsPluginContainer()
+// 
+// Constructor 
+// ---------------------------------------------------------------------------
+//
+CDRMSettingsPluginContainer::CDRMSettingsPluginContainer( 
+    TBool aWmdrmSupported ) : iWmdrmSupported( aWmdrmSupported )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::~CDRMSettingsPluginContainer()
+// 
+// Destructor 
+// ---------------------------------------------------------------------------
+//
+CDRMSettingsPluginContainer::~CDRMSettingsPluginContainer()
+    {
+    if ( iModel )
+        {
+        delete iModel;
+        }
+    // delete listbox item array
+    if ( iListboxItemArray )
+        {
+        delete iListboxItemArray;
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::ConstructListBoxL()
+// 
+// Construct the listbox from resource array.
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPluginContainer::ConstructListBoxL( TInt aResLbxId )
+    {
+    iListBox->ConstructL( this, EAknListBoxSelectionList /* | 
+        EAknListBoxItemSpecificMenuDisabled */ );
+    iListboxItemArray = CGSListBoxItemTextArray::NewL( aResLbxId, 
+                                                       *iListBox, 
+                                                       *iCoeEnv );
+    iListBox->Model()->SetItemTextArray( iListboxItemArray );
+    iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
+    CreateListBoxItemsL();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::CreateListBoxItemsL()
+// 
+// Create listbox items.
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPluginContainer::CreateListBoxItemsL()
+    {
+#ifdef __DRM_OMA2
+    MakeTransactionTrackingItemL();
+    
+#ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
+    MakeAutomaticActivationItemL();
+#endif // RD_DRM_SILENT_RIGHTS_ACQUISITION
+
+#ifdef RD_DRM_METERING
+    MakeUsageReportingItemL();
+#endif // RD_DRM_METERING
+#endif // __DRM_OMA2
+
+
+    MakeWMDRMLicenseDeletionItemL();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::UpdateListBoxL()
+// 
+// Update listbox item.
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPluginContainer::UpdateListBoxL( TInt aFeatureId )
+    {
+    switch( aFeatureId )
+        {
+#ifdef __DRM_OMA2
+        case EDRMSettingsIdTransactionTracking:
+            MakeTransactionTrackingItemL();
+            break;
+            
+#ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
+        case EDRMSettingsIdAutomaticActivation:
+            MakeAutomaticActivationItemL();
+            break;
+#endif // RD_DRM_SILENT_RIGHTS_ACQUISITION
+            
+#ifdef RD_DRM_METERING
+        case EDRMSettingsIdUsageReporting:
+            MakeUsageReportingItemL();
+            break;
+#endif // RD_DRM_METERING     
+#endif // __DRM_OMA2
+       
+        case EDRMSettingsIdWMDRMLicenseDeletion:
+            
+            MakeWMDRMLicenseDeletionItemL();
+            
+            break;
+       
+        default:
+            break;
+        }
+
+    iListBox->HandleItemAdditionL();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::MakeTransactionTrackingItemL()
+// 
+// Create Transaction tracking list item 
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPluginContainer::MakeTransactionTrackingItemL()
+    {
+    HBufC* dynamicText( NULL );
+    TInt trxTrState( iModel->TransactionTrackingStateL() );
+    
+    switch ( trxTrState )
+        {
+        case KDRMTransactionTrackingEnabled:
+            dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_TTRACKING_ON );
+            break;
+        default:
+            dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_TTRACKING_OFF );
+            break;
+        }
+    
+    TPtr ptrBuffer ( dynamicText->Des() );
+
+    
+    // Finally, set the dynamic text
+    iListboxItemArray->SetDynamicTextL( EDRMSettingsIdTransactionTracking, ptrBuffer );
+
+    CleanupStack::PopAndDestroy( dynamicText );
+
+    // And add to listbox
+    iListboxItemArray->SetItemVisibilityL( EDRMSettingsIdTransactionTracking, 
+        CGSListBoxItemTextArray::EVisible );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::MakeAutomaticActivationItemL()
+// 
+// Create Automatic activation list item 
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPluginContainer::MakeAutomaticActivationItemL()
+    {
+    TInt automActivState( iModel->AutomaticActivationStateL() );
+    
+    HBufC* dynamicText( NULL );
+    
+    switch ( automActivState )
+        {
+        case KDRMTransactionTrackingEnabled:
+            dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_AUTOM_ACTIV_ON );
+            break;
+        default:
+            dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_AUTOM_ACTIV_OFF );
+            break;
+        }
+    
+    TPtr ptrBuffer ( dynamicText->Des() );
+
+    // Finally, set the dynamic text
+    iListboxItemArray->SetDynamicTextL( EDRMSettingsIdAutomaticActivation, 
+                                        ptrBuffer );
+
+    CleanupStack::PopAndDestroy( dynamicText );
+
+    // And add to listbox
+    iListboxItemArray->SetItemVisibilityL( EDRMSettingsIdAutomaticActivation, 
+                                           CGSListBoxItemTextArray::EVisible );
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::MakeUsageReportingItemL()
+// 
+// Create Usage reporting list item 
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPluginContainer::MakeUsageReportingItemL()
+    {
+    TInt count( iModel->UsageReportingCount() );
+    
+    HBufC* dynamicText( NULL );
+    
+    switch ( count )
+        {
+        case 0:
+            dynamicText = StringLoader::LoadL( R_DRM_SET_USAGE_REPORT_NONE );
+            break;
+        case 1:
+            dynamicText = iModel->GetFirstAllowedMeteringRIAliasL();
+            break;
+        default:
+            dynamicText = StringLoader::LoadL( R_DRM_SET_SEVERAL_SERVICES );
+            break;
+        }
+    CleanupStack::PushL( dynamicText );
+    
+    TPtr ptrBuffer ( dynamicText->Des() );
+
+    // Finally, set the dynamic text
+    iListboxItemArray->SetDynamicTextL( EDRMSettingsIdUsageReporting, 
+                                        ptrBuffer );
+
+    CleanupStack::PopAndDestroy( dynamicText );
+
+    // And add to listbox
+    iListboxItemArray->SetItemVisibilityL( EDRMSettingsIdUsageReporting, 
+                                           CGSListBoxItemTextArray::EVisible );
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::MakeWMDRMLicenseDeletionItemL()
+// 
+// Create WMDRM license deletion list item 
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPluginContainer::MakeWMDRMLicenseDeletionItemL()
+    {
+    if ( iWmdrmSupported )
+        {
+        // Add to listbox
+        iListboxItemArray->
+            SetItemVisibilityL( EDRMSettingsIdWMDRMLicenseDeletion, 
+                                CGSListBoxItemTextArray::EVisible );
+        }
+    else
+        {
+        // Add to listbox
+        iListboxItemArray->
+            SetItemVisibilityL( EDRMSettingsIdWMDRMLicenseDeletion, 
+                                CGSListBoxItemTextArray::EInvisible );
+        
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::GetHelpContext() const
+//  
+// Gets Help 
+// ---------------------------------------------------------------------------
+//
+void CDRMSettingsPluginContainer::GetHelpContext( 
+    TCoeHelpContext& aContext ) const
+    {
+    aContext.iMajor = KUidRightsManager;
+    aContext.iContext = KSET_HLP_PROTECTED_CONTENT;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::CurrentFeatureId()
+//
+// Return the feature id of selected listitem  
+// ---------------------------------------------------------------------------
+//
+TInt CDRMSettingsPluginContainer::CurrentFeatureId( ) const
+    {
+    return iListboxItemArray->CurrentFeature();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMSettingsPluginContainer::Model()
+//
+//
+// -----------------------------------------------------------------------------
+//
+CDRMSettingsModel* CDRMSettingsPluginContainer::Model()
+    {
+    return iModel;
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/src/drmsettingspluginimplementationtable.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2006 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM proxy table for DRMSettinsPlugin
+*
+*/
+
+
+// INCLUDES
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+
+#include "drmsettingsplugin.h"
+
+
+// CONSTANTS
+const TImplementationProxy KDRMSettingsPluginImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY( 0x102750CD, CDRMSettingsPlugin::NewL )
+    };
+
+
+// ---------------------------------------------------------------------------
+// ImplementationGroupProxy
+//
+// Gate/factory function
+// ---------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(
+                                                  TInt& aTableCount )
+    {
+    aTableCount = sizeof( KDRMSettingsPluginImplementationTable )
+        / sizeof( TImplementationProxy );
+    return KDRMSettingsPluginImplementationTable;
+    }
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/src/drmsettingsusagecheckbox.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,150 @@
+/*
+* 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:  CheckBox class for Usage Reporting settings
+*
+*/
+
+
+// INCLUDE FILES
+#include <stringloader.h>
+#include <aknquerydialog.h>
+#include <akninfopopupnotecontroller.h>
+#include <drmsettingspluginrsc.rsg>
+
+#include "drmsettingsusagecheckbox.h"
+#include "drmsettingsusagelist.h"
+#include "drmsettingsmodel.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CDrmSettingUsageCheckBox::CDrmSettingUsageCheckBox
+// Default constructor.
+// -----------------------------------------------------------------------------
+//
+CDrmSettingUsageCheckBox::CDrmSettingUsageCheckBox( 
+    TInt aResourceId,
+    CDRMSettingUsageList* aList,
+    CDRMSettingsModel* aModel ) : CAknCheckBoxSettingPage( aResourceId, aList ),
+                                  iList( aList ),
+                                  iModel( aModel )
+    {
+	}
+
+// ----------------------------------------------------------------------------
+// CDrmSettingUsageCheckBox::~CDrmSettingUsageCheckBox
+//
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CDrmSettingUsageCheckBox::~CDrmSettingUsageCheckBox()
+    {
+    delete iPopupController;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmSettingUsageCheckBox::OfferKeyEventL
+// -----------------------------------------------------------------------------
+//
+TKeyResponse CDrmSettingUsageCheckBox::OfferKeyEventL( 
+    const TKeyEvent& aKeyEvent,
+    TEventCode aType )
+    {
+    TKeyResponse response( EKeyWasNotConsumed );
+    if ( aKeyEvent.iCode != EKeyApplicationF )
+        {
+        response = this->ListBoxControl()->OfferKeyEventL( aKeyEvent, aType );
+        }
+    
+    if ( aType == EEventKeyUp )
+        {
+        ShowInfoPopupL();
+        }
+    
+    return response;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmSettingUsageCheckBox::DynamicInitL
+// -----------------------------------------------------------------------------
+//
+void CDrmSettingUsageCheckBox::DynamicInitL()
+    {
+    HBufC* emptyText( StringLoader::LoadLC( R_USAGE_REPORTING_LIST_EMPTY,
+                                            iEikonEnv ) );
+	this->ListBoxControl()->View()->SetListEmptyTextL( *emptyText );
+	CleanupStack::PopAndDestroy( emptyText );
+	}
+
+// -----------------------------------------------------------------------------
+// CDrmSettingUsageCheckBox::OkToExitL
+// -----------------------------------------------------------------------------
+//
+TBool CDrmSettingUsageCheckBox::OkToExitL( TBool aAccept )
+    {
+    TBool exit( ETrue );
+    
+    if ( aAccept )
+        {
+        iList->UpdateContexts();
+    
+        if ( !iModel->IsMeteringAllowedForAll() )
+            {
+            HBufC* query( StringLoader::LoadLC( R_DRM_CONF_QUERY_METERING,
+                                                iEikonEnv ) );
+        
+            CAknQueryDialog* queryDialog( CAknQueryDialog::NewL() );
+        
+            TBool retVal( queryDialog->ExecuteLD( R_DRM_CONFIRMATION_QUERY_METERING,
+                                                  *query ) );
+            CleanupStack::PopAndDestroy( query );
+            
+            if ( !retVal )
+                {
+                exit = EFalse;
+                }
+            }
+        }
+    
+    return exit;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmSettingUsageCheckBox::AcceptSettingL
+// -----------------------------------------------------------------------------
+//
+void CDrmSettingUsageCheckBox::AcceptSettingL()
+    {
+    iModel->SaveMeteringChanges();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmSettingUsageCheckBox::ShowInfoPopupL
+// -----------------------------------------------------------------------------
+//
+void CDrmSettingUsageCheckBox::ShowInfoPopupL()
+    {
+    if ( !iPopupController )
+        {
+        iPopupController = CAknInfoPopupNoteController::NewL();
+        }
+    TInt index( this->ListBoxControl()->View()->CurrentItemIndex() );
+    if ( index != -1 )
+        {
+        iPopupController->SetTextL( iList->At(index)->ItemText() );
+        iPopupController->ShowInfoPopupNote();    
+        }
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmsettingsplugin/src/drmsettingsusagelist.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,97 @@
+/*
+* 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:  List class for Usage Reporting checkbox
+*
+*/
+
+
+// INCLUDE FILES
+#include "drmsettingsusagelist.h"
+#include "drmsettingsmodel.h"
+
+// CONSTANTS
+const TInt KDRMSettingsListGranularity( 5 );
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ----------------------------------------------------------------------------
+// CDRMSettingUsageList::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CDRMSettingUsageList* CDRMSettingUsageList::NewL( 
+    CDRMSettingsModel* aModel )
+    {
+    CDRMSettingUsageList* self( 
+        new( ELeave ) CDRMSettingUsageList( aModel ) );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+	CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ----------------------------------------------------------------------------
+// CDRMSettingUsageList::CDRMSettingUsageList
+// Default constructor.
+// ----------------------------------------------------------------------------
+//
+CDRMSettingUsageList::CDRMSettingUsageList( CDRMSettingsModel* aModel ) 
+    : CSelectionItemList( KDRMSettingsListGranularity ), iModel( aModel )
+    {
+	}
+
+// ----------------------------------------------------------------------------
+// CDRMSettingUsageList::ConstructL
+// ----------------------------------------------------------------------------
+//
+void CDRMSettingUsageList::ConstructL()
+    {
+    for ( TInt i( 0 ); i < iModel->GetRiContextCount(); i++ )
+        {
+        HBufC* alias( iModel->GetSingleRIAliasL( i ) );
+        CleanupStack::PushL( alias );
+        TBool isAllowed( iModel->IsMeteringAllowed( i ) );
+        CSelectableItem* selItem( new (ELeave) CSelectableItem( *alias, 
+                                                                isAllowed ) );
+        selItem->ConstructL();
+        this->AppendL( selItem );
+        CleanupStack::PopAndDestroy( alias );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMSettingUsageList::~CDRMSettingUsageList
+//
+// Destructor
+// ----------------------------------------------------------------------------
+//
+CDRMSettingUsageList::~CDRMSettingUsageList()
+    {
+    this->ResetAndDestroy();
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMSettingUsageList::UpdateContexts
+// ----------------------------------------------------------------------------
+//
+void CDRMSettingUsageList::UpdateContexts()
+    {
+    for ( TInt i( 0 ); i < iModel->GetRiContextCount(); i++ )
+        {
+        CSelectableItem* selItem( this->At( i ) );
+        iModel->SetMeteringStatus( i, selItem->SelectionStatus() );
+        }
+    }
+	
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/bwinscw/DRMAutomatedUsageImplU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,23 @@
+EXPORTS
+	?CanSetAutomatedL@CDrmAutomatedUsageImpl@DRM@@QAEHAAVRFile@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@@Z @ 1 NONAME ; int DRM::CDrmAutomatedUsageImpl::CanSetAutomatedL(class RFile &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType)
+	?CanSetAutomatedL@CDrmAutomatedUsageImpl@DRM@@QAEHABVCData@ContentAccess@@W4TIntent@4@W4TDrmAutomatedType@2@@Z @ 2 NONAME ; int DRM::CDrmAutomatedUsageImpl::CanSetAutomatedL(class ContentAccess::CData const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType)
+	?CancelOperation@CDrmAutomatedUsageImpl@DRM@@QAEHH@Z @ 3 NONAME ; int DRM::CDrmAutomatedUsageImpl::CancelOperation(int)
+	?HandleErrorAsyncL@CDrmAutomatedUsageImpl@DRM@@QAEHAAVCData@ContentAccess@@W4TIntent@4@HAAVMDrmHandleErrorObserver@2@@Z @ 4 NONAME ; int DRM::CDrmAutomatedUsageImpl::HandleErrorAsyncL(class ContentAccess::CData &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver &)
+	?HandleErrorAsyncL@CDrmAutomatedUsageImpl@DRM@@QAEHAAVRFile@@W4TIntent@ContentAccess@@HAAVMDrmHandleErrorObserver@2@@Z @ 5 NONAME ; int DRM::CDrmAutomatedUsageImpl::HandleErrorAsyncL(class RFile &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver &)
+	?HandleErrorL@CDrmAutomatedUsageImpl@DRM@@QAEXAAVCData@ContentAccess@@W4TIntent@4@HPAVMDrmHandleErrorObserver@2@@Z @ 6 NONAME ; void DRM::CDrmAutomatedUsageImpl::HandleErrorL(class ContentAccess::CData &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver *)
+	?HandleErrorL@CDrmAutomatedUsageImpl@DRM@@QAEXAAVRFile@@W4TIntent@ContentAccess@@HPAVMDrmHandleErrorObserver@2@@Z @ 7 NONAME ; void DRM::CDrmAutomatedUsageImpl::HandleErrorL(class RFile &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver *)
+	?NewL@CDrmAutomatedUsageImpl@DRM@@SAPAV12@PAVCCoeEnv@@PAVCDrmUtility@2@@Z @ 8 NONAME ; class DRM::CDrmAutomatedUsageImpl * DRM::CDrmAutomatedUsageImpl::NewL(class CCoeEnv *, class DRM::CDrmUtility *)
+	?NewLC@CDrmAutomatedUsageImpl@DRM@@SAPAV12@PAVCCoeEnv@@PAVCDrmUtility@2@@Z @ 9 NONAME ; class DRM::CDrmAutomatedUsageImpl * DRM::CDrmAutomatedUsageImpl::NewLC(class CCoeEnv *, class DRM::CDrmUtility *)
+	?RegisterEventObserverL@CDrmAutomatedUsageImpl@DRM@@QAEXAAVMDrmAutomatedUsageObserver@2@@Z @ 10 NONAME ; void DRM::CDrmAutomatedUsageImpl::RegisterEventObserverL(class DRM::MDrmAutomatedUsageObserver &)
+	?RemoveAutomatedAsyncL@CDrmAutomatedUsageImpl@DRM@@QAEHAAVRFile@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@AAVMDrmAsyncObserver@2@W4TDrmAutomatedServiceType@2@@Z @ 11 NONAME ; int DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL(class RFile &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, class DRM::MDrmAsyncObserver &, enum DRM::TDrmAutomatedServiceType)
+	?RemoveAutomatedAsyncL@CDrmAutomatedUsageImpl@DRM@@QAEHABVCData@ContentAccess@@W4TIntent@4@W4TDrmAutomatedType@2@AAVMDrmAsyncObserver@2@W4TDrmAutomatedServiceType@2@@Z @ 12 NONAME ; int DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL(class ContentAccess::CData const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, class DRM::MDrmAsyncObserver &, enum DRM::TDrmAutomatedServiceType)
+	?RemoveAutomatedAsyncL@CDrmAutomatedUsageImpl@DRM@@QAEHABVTDesC16@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@AAVMDrmAsyncObserver@2@W4TDrmAutomatedServiceType@2@@Z @ 13 NONAME ; int DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL(class TDesC16 const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, class DRM::MDrmAsyncObserver &, enum DRM::TDrmAutomatedServiceType)
+	?RemoveAutomatedL@CDrmAutomatedUsageImpl@DRM@@QAEXAAVRFile@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@W4TDrmAutomatedServiceType@2@@Z @ 14 NONAME ; void DRM::CDrmAutomatedUsageImpl::RemoveAutomatedL(class RFile &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, enum DRM::TDrmAutomatedServiceType)
+	?RemoveAutomatedL@CDrmAutomatedUsageImpl@DRM@@QAEXABVCData@ContentAccess@@W4TIntent@4@W4TDrmAutomatedType@2@W4TDrmAutomatedServiceType@2@@Z @ 15 NONAME ; void DRM::CDrmAutomatedUsageImpl::RemoveAutomatedL(class ContentAccess::CData const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, enum DRM::TDrmAutomatedServiceType)
+	?RemoveAutomatedL@CDrmAutomatedUsageImpl@DRM@@QAEXABVTDesC16@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@W4TDrmAutomatedServiceType@2@@Z @ 16 NONAME ; void DRM::CDrmAutomatedUsageImpl::RemoveAutomatedL(class TDesC16 const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, enum DRM::TDrmAutomatedServiceType)
+	?SetAutomatedAsyncL@CDrmAutomatedUsageImpl@DRM@@QAEHAAVRFile@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@AAVMDrmAsyncObserver@2@W4TDrmAutomatedServiceType@2@@Z @ 17 NONAME ; int DRM::CDrmAutomatedUsageImpl::SetAutomatedAsyncL(class RFile &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, class DRM::MDrmAsyncObserver &, enum DRM::TDrmAutomatedServiceType)
+	?SetAutomatedAsyncL@CDrmAutomatedUsageImpl@DRM@@QAEHABVCData@ContentAccess@@W4TIntent@4@W4TDrmAutomatedType@2@AAVMDrmAsyncObserver@2@W4TDrmAutomatedServiceType@2@@Z @ 18 NONAME ; int DRM::CDrmAutomatedUsageImpl::SetAutomatedAsyncL(class ContentAccess::CData const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, class DRM::MDrmAsyncObserver &, enum DRM::TDrmAutomatedServiceType)
+	?SetAutomatedL@CDrmAutomatedUsageImpl@DRM@@QAEXAAVRFile@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@W4TDrmAutomatedServiceType@2@@Z @ 19 NONAME ; void DRM::CDrmAutomatedUsageImpl::SetAutomatedL(class RFile &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, enum DRM::TDrmAutomatedServiceType)
+	?SetAutomatedL@CDrmAutomatedUsageImpl@DRM@@QAEXABVCData@ContentAccess@@W4TIntent@4@W4TDrmAutomatedType@2@W4TDrmAutomatedServiceType@2@@Z @ 20 NONAME ; void DRM::CDrmAutomatedUsageImpl::SetAutomatedL(class ContentAccess::CData const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, enum DRM::TDrmAutomatedServiceType)
+	?UnregisterEventObserverL@CDrmAutomatedUsageImpl@DRM@@QAEXAAVMDrmAutomatedUsageObserver@2@@Z @ 21 NONAME ; void DRM::CDrmAutomatedUsageImpl::UnregisterEventObserverL(class DRM::MDrmAutomatedUsageObserver &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/bwinscw/DRMAutomatedUsageU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+EXPORTS
+	?CanSetAutomatedL@CDrmAutomatedUsage@DRM@@QAEHAAVRFile@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@@Z @ 1 NONAME ; int DRM::CDrmAutomatedUsage::CanSetAutomatedL(class RFile &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType)
+	?CanSetAutomatedL@CDrmAutomatedUsage@DRM@@QAEHABVCData@ContentAccess@@W4TIntent@4@W4TDrmAutomatedType@2@@Z @ 2 NONAME ; int DRM::CDrmAutomatedUsage::CanSetAutomatedL(class ContentAccess::CData const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType)
+	?CancelOperation@CDrmAutomatedUsage@DRM@@QAEHH@Z @ 3 NONAME ; int DRM::CDrmAutomatedUsage::CancelOperation(int)
+	?GetErrorHandler@CDrmAutomatedUsage@DRM@@QBEAAVMDrmErrorHandling@2@XZ @ 4 NONAME ; class DRM::MDrmErrorHandling & DRM::CDrmAutomatedUsage::GetErrorHandler(void) const
+	?GetUtility@CDrmAutomatedUsage@DRM@@QBEAAVCDrmUtility@2@XZ @ 5 NONAME ; class DRM::CDrmUtility & DRM::CDrmAutomatedUsage::GetUtility(void) const
+	?HandleErrorAsyncL@CDrmAutomatedUsageErrorHandling@DRM@@UAEHAAVCData@ContentAccess@@W4TIntent@4@HAAVMDrmHandleErrorObserver@2@@Z @ 6 NONAME ; int DRM::CDrmAutomatedUsageErrorHandling::HandleErrorAsyncL(class ContentAccess::CData &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver &)
+	?HandleErrorAsyncL@CDrmAutomatedUsageErrorHandling@DRM@@UAEHAAVRFile@@W4TIntent@ContentAccess@@HAAVMDrmHandleErrorObserver@2@@Z @ 7 NONAME ; int DRM::CDrmAutomatedUsageErrorHandling::HandleErrorAsyncL(class RFile &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver &)
+	?HandleErrorL@CDrmAutomatedUsageErrorHandling@DRM@@UAEXAAVCData@ContentAccess@@W4TIntent@4@HPAVMDrmHandleErrorObserver@2@@Z @ 8 NONAME ; void DRM::CDrmAutomatedUsageErrorHandling::HandleErrorL(class ContentAccess::CData &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver *)
+	?HandleErrorL@CDrmAutomatedUsageErrorHandling@DRM@@UAEXAAVRFile@@W4TIntent@ContentAccess@@HPAVMDrmHandleErrorObserver@2@@Z @ 9 NONAME ; void DRM::CDrmAutomatedUsageErrorHandling::HandleErrorL(class RFile &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver *)
+	?NewL@CDrmAutomatedUsage@DRM@@SAPAV12@PAVCCoeEnv@@@Z @ 10 NONAME ; class DRM::CDrmAutomatedUsage * DRM::CDrmAutomatedUsage::NewL(class CCoeEnv *)
+	?NewL@CDrmAutomatedUsageErrorHandling@DRM@@SAPAV12@PAVCDrmAutomatedUsageImpl@2@@Z @ 11 NONAME ; class DRM::CDrmAutomatedUsageErrorHandling * DRM::CDrmAutomatedUsageErrorHandling::NewL(class DRM::CDrmAutomatedUsageImpl *)
+	?NewLC@CDrmAutomatedUsage@DRM@@SAPAV12@PAVCCoeEnv@@@Z @ 12 NONAME ; class DRM::CDrmAutomatedUsage * DRM::CDrmAutomatedUsage::NewLC(class CCoeEnv *)
+	?NewLC@CDrmAutomatedUsageErrorHandling@DRM@@SAPAV12@PAVCDrmAutomatedUsageImpl@2@@Z @ 13 NONAME ; class DRM::CDrmAutomatedUsageErrorHandling * DRM::CDrmAutomatedUsageErrorHandling::NewLC(class DRM::CDrmAutomatedUsageImpl *)
+	?RegisterEventObserverL@CDrmAutomatedUsage@DRM@@QAEXAAVMDrmAutomatedUsageObserver@2@@Z @ 14 NONAME ; void DRM::CDrmAutomatedUsage::RegisterEventObserverL(class DRM::MDrmAutomatedUsageObserver &)
+	?RemoveAutomatedAsyncL@CDrmAutomatedUsage@DRM@@QAEHAAVRFile@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@AAVMDrmAsyncObserver@2@W4TDrmAutomatedServiceType@2@@Z @ 15 NONAME ; int DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL(class RFile &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, class DRM::MDrmAsyncObserver &, enum DRM::TDrmAutomatedServiceType)
+	?RemoveAutomatedAsyncL@CDrmAutomatedUsage@DRM@@QAEHABVCData@ContentAccess@@W4TIntent@4@W4TDrmAutomatedType@2@AAVMDrmAsyncObserver@2@W4TDrmAutomatedServiceType@2@@Z @ 16 NONAME ; int DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL(class ContentAccess::CData const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, class DRM::MDrmAsyncObserver &, enum DRM::TDrmAutomatedServiceType)
+	?RemoveAutomatedAsyncL@CDrmAutomatedUsage@DRM@@QAEHABVTDesC16@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@AAVMDrmAsyncObserver@2@W4TDrmAutomatedServiceType@2@@Z @ 17 NONAME ; int DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL(class TDesC16 const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, class DRM::MDrmAsyncObserver &, enum DRM::TDrmAutomatedServiceType)
+	?RemoveAutomatedL@CDrmAutomatedUsage@DRM@@QAEXAAVRFile@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@W4TDrmAutomatedServiceType@2@@Z @ 18 NONAME ; void DRM::CDrmAutomatedUsage::RemoveAutomatedL(class RFile &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, enum DRM::TDrmAutomatedServiceType)
+	?RemoveAutomatedL@CDrmAutomatedUsage@DRM@@QAEXABVCData@ContentAccess@@W4TIntent@4@W4TDrmAutomatedType@2@W4TDrmAutomatedServiceType@2@@Z @ 19 NONAME ; void DRM::CDrmAutomatedUsage::RemoveAutomatedL(class ContentAccess::CData const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, enum DRM::TDrmAutomatedServiceType)
+	?RemoveAutomatedL@CDrmAutomatedUsage@DRM@@QAEXABVTDesC16@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@W4TDrmAutomatedServiceType@2@@Z @ 20 NONAME ; void DRM::CDrmAutomatedUsage::RemoveAutomatedL(class TDesC16 const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, enum DRM::TDrmAutomatedServiceType)
+	?SetAutomatedAsyncL@CDrmAutomatedUsage@DRM@@QAEHAAVRFile@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@AAVMDrmAsyncObserver@2@W4TDrmAutomatedServiceType@2@@Z @ 21 NONAME ; int DRM::CDrmAutomatedUsage::SetAutomatedAsyncL(class RFile &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, class DRM::MDrmAsyncObserver &, enum DRM::TDrmAutomatedServiceType)
+	?SetAutomatedAsyncL@CDrmAutomatedUsage@DRM@@QAEHABVCData@ContentAccess@@W4TIntent@4@W4TDrmAutomatedType@2@AAVMDrmAsyncObserver@2@W4TDrmAutomatedServiceType@2@@Z @ 22 NONAME ; int DRM::CDrmAutomatedUsage::SetAutomatedAsyncL(class ContentAccess::CData const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, class DRM::MDrmAsyncObserver &, enum DRM::TDrmAutomatedServiceType)
+	?SetAutomatedL@CDrmAutomatedUsage@DRM@@QAEXAAVRFile@@W4TIntent@ContentAccess@@W4TDrmAutomatedType@2@W4TDrmAutomatedServiceType@2@@Z @ 23 NONAME ; void DRM::CDrmAutomatedUsage::SetAutomatedL(class RFile &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, enum DRM::TDrmAutomatedServiceType)
+	?SetAutomatedL@CDrmAutomatedUsage@DRM@@QAEXABVCData@ContentAccess@@W4TIntent@4@W4TDrmAutomatedType@2@W4TDrmAutomatedServiceType@2@@Z @ 24 NONAME ; void DRM::CDrmAutomatedUsage::SetAutomatedL(class ContentAccess::CData const &, enum ContentAccess::TIntent, enum DRM::TDrmAutomatedType, enum DRM::TDrmAutomatedServiceType)
+	?UnregisterEventObserverL@CDrmAutomatedUsage@DRM@@QAEXAAVMDrmAutomatedUsageObserver@2@@Z @ 25 NONAME ; void DRM::CDrmAutomatedUsage::UnregisterEventObserverL(class DRM::MDrmAutomatedUsageObserver &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/bwinscw/DRMUiHandlingImplU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+EXPORTS
+	?AvailableUrlsAsyncL@CDrmUiHandlingImpl@DRM@@QAEHAAVCData@ContentAccess@@AAW4TDrmUiUrlType@2@AAVMDrmAsyncObserver@2@@Z @ 1 NONAME ; int DRM::CDrmUiHandlingImpl::AvailableUrlsAsyncL(class ContentAccess::CData &, enum DRM::TDrmUiUrlType &, class DRM::MDrmAsyncObserver &)
+	?AvailableUrlsAsyncL@CDrmUiHandlingImpl@DRM@@QAEHAAVRFile@@AAW4TDrmUiUrlType@2@AAVMDrmAsyncObserver@2@@Z @ 2 NONAME ; int DRM::CDrmUiHandlingImpl::AvailableUrlsAsyncL(class RFile &, enum DRM::TDrmUiUrlType &, class DRM::MDrmAsyncObserver &)
+	?AvailableUrlsL@CDrmUiHandlingImpl@DRM@@QAEXAAVCData@ContentAccess@@AAW4TDrmUiUrlType@2@@Z @ 3 NONAME ; void DRM::CDrmUiHandlingImpl::AvailableUrlsL(class ContentAccess::CData &, enum DRM::TDrmUiUrlType &)
+	?AvailableUrlsL@CDrmUiHandlingImpl@DRM@@QAEXAAVRFile@@AAW4TDrmUiUrlType@2@@Z @ 4 NONAME ; void DRM::CDrmUiHandlingImpl::AvailableUrlsL(class RFile &, enum DRM::TDrmUiUrlType &)
+	?CancelOperation@CDrmUiHandlingImpl@DRM@@QAEHH@Z @ 5 NONAME ; int DRM::CDrmUiHandlingImpl::CancelOperation(int)
+	?CheckRightsAmountAsyncL@CDrmUiHandlingImpl@DRM@@QAEHAAVCData@ContentAccess@@W4TIntent@4@AAVMDrmUiCheckRightsObserver@2@@Z @ 6 NONAME ; int DRM::CDrmUiHandlingImpl::CheckRightsAmountAsyncL(class ContentAccess::CData &, enum ContentAccess::TIntent, class DRM::MDrmUiCheckRightsObserver &)
+	?CheckRightsAmountAsyncL@CDrmUiHandlingImpl@DRM@@QAEHAAVRFile@@W4TIntent@ContentAccess@@AAVMDrmUiCheckRightsObserver@2@@Z @ 7 NONAME ; int DRM::CDrmUiHandlingImpl::CheckRightsAmountAsyncL(class RFile &, enum ContentAccess::TIntent, class DRM::MDrmUiCheckRightsObserver &)
+	?CheckRightsAmountL@CDrmUiHandlingImpl@DRM@@QAEXAAVCData@ContentAccess@@W4TIntent@4@PAVMDrmUiCheckRightsObserver@2@@Z @ 8 NONAME ; void DRM::CDrmUiHandlingImpl::CheckRightsAmountL(class ContentAccess::CData &, enum ContentAccess::TIntent, class DRM::MDrmUiCheckRightsObserver *)
+	?CheckRightsAmountL@CDrmUiHandlingImpl@DRM@@QAEXAAVRFile@@W4TIntent@ContentAccess@@PAVMDrmUiCheckRightsObserver@2@@Z @ 9 NONAME ; void DRM::CDrmUiHandlingImpl::CheckRightsAmountL(class RFile &, enum ContentAccess::TIntent, class DRM::MDrmUiCheckRightsObserver *)
+	?HandleErrorAsyncL@CDrmUiHandlingImpl@DRM@@QAEHAAVCData@ContentAccess@@W4TIntent@4@HAAVMDrmHandleErrorObserver@2@@Z @ 10 NONAME ; int DRM::CDrmUiHandlingImpl::HandleErrorAsyncL(class ContentAccess::CData &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver &)
+	?HandleErrorAsyncL@CDrmUiHandlingImpl@DRM@@QAEHAAVRFile@@W4TIntent@ContentAccess@@HAAVMDrmHandleErrorObserver@2@@Z @ 11 NONAME ; int DRM::CDrmUiHandlingImpl::HandleErrorAsyncL(class RFile &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver &)
+	?HandleErrorL@CDrmUiHandlingImpl@DRM@@QAEXAAVCData@ContentAccess@@W4TIntent@4@HPAVMDrmHandleErrorObserver@2@@Z @ 12 NONAME ; void DRM::CDrmUiHandlingImpl::HandleErrorL(class ContentAccess::CData &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver *)
+	?HandleErrorL@CDrmUiHandlingImpl@DRM@@QAEXAAVRFile@@W4TIntent@ContentAccess@@HPAVMDrmHandleErrorObserver@2@@Z @ 13 NONAME ; void DRM::CDrmUiHandlingImpl::HandleErrorL(class RFile &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver *)
+	?HandleUrlAsyncL@CDrmUiHandlingImpl@DRM@@QAEHAAVCData@ContentAccess@@W4TDrmUiUrlType@2@AAVMDrmAsyncObserver@2@@Z @ 14 NONAME ; int DRM::CDrmUiHandlingImpl::HandleUrlAsyncL(class ContentAccess::CData &, enum DRM::TDrmUiUrlType, class DRM::MDrmAsyncObserver &)
+	?HandleUrlAsyncL@CDrmUiHandlingImpl@DRM@@QAEHAAVRFile@@W4TDrmUiUrlType@2@AAVMDrmAsyncObserver@2@@Z @ 15 NONAME ; int DRM::CDrmUiHandlingImpl::HandleUrlAsyncL(class RFile &, enum DRM::TDrmUiUrlType, class DRM::MDrmAsyncObserver &)
+	?HandleUrlL@CDrmUiHandlingImpl@DRM@@QAEXAAVCData@ContentAccess@@W4TDrmUiUrlType@2@@Z @ 16 NONAME ; void DRM::CDrmUiHandlingImpl::HandleUrlL(class ContentAccess::CData &, enum DRM::TDrmUiUrlType)
+	?HandleUrlL@CDrmUiHandlingImpl@DRM@@QAEXAAVRFile@@W4TDrmUiUrlType@2@@Z @ 17 NONAME ; void DRM::CDrmUiHandlingImpl::HandleUrlL(class RFile &, enum DRM::TDrmUiUrlType)
+	?NewL@CDrmUiHandlingImpl@DRM@@SAPAV12@PAVCDrmUtility@2@PAVCCoeEnv@@@Z @ 18 NONAME ; class DRM::CDrmUiHandlingImpl * DRM::CDrmUiHandlingImpl::NewL(class DRM::CDrmUtility *, class CCoeEnv *)
+	?NewLC@CDrmUiHandlingImpl@DRM@@SAPAV12@PAVCDrmUtility@2@PAVCCoeEnv@@@Z @ 19 NONAME ; class DRM::CDrmUiHandlingImpl * DRM::CDrmUiHandlingImpl::NewLC(class DRM::CDrmUtility *, class CCoeEnv *)
+	?ShowDetailsViewAsyncL@CDrmUiHandlingImpl@DRM@@QAEHAAVCData@ContentAccess@@AAVMDrmAsyncObserver@2@@Z @ 20 NONAME ; int DRM::CDrmUiHandlingImpl::ShowDetailsViewAsyncL(class ContentAccess::CData &, class DRM::MDrmAsyncObserver &)
+	?ShowDetailsViewAsyncL@CDrmUiHandlingImpl@DRM@@QAEHAAVRFile@@AAVMDrmAsyncObserver@2@@Z @ 21 NONAME ; int DRM::CDrmUiHandlingImpl::ShowDetailsViewAsyncL(class RFile &, class DRM::MDrmAsyncObserver &)
+	?ShowDetailsViewL@CDrmUiHandlingImpl@DRM@@QAEXAAVCData@ContentAccess@@@Z @ 22 NONAME ; void DRM::CDrmUiHandlingImpl::ShowDetailsViewL(class ContentAccess::CData &)
+	?ShowDetailsViewL@CDrmUiHandlingImpl@DRM@@QAEXAAVRFile@@@Z @ 23 NONAME ; void DRM::CDrmUiHandlingImpl::ShowDetailsViewL(class RFile &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/bwinscw/DRMUiHandlingU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,29 @@
+EXPORTS
+	?AvailableUrlsAsyncL@CDrmUiHandling@DRM@@QAEHAAVCData@ContentAccess@@AAW4TDrmUiUrlType@2@AAVMDrmAsyncObserver@2@@Z @ 1 NONAME ; int DRM::CDrmUiHandling::AvailableUrlsAsyncL(class ContentAccess::CData &, enum DRM::TDrmUiUrlType &, class DRM::MDrmAsyncObserver &)
+	?AvailableUrlsAsyncL@CDrmUiHandling@DRM@@QAEHAAVRFile@@AAW4TDrmUiUrlType@2@AAVMDrmAsyncObserver@2@@Z @ 2 NONAME ; int DRM::CDrmUiHandling::AvailableUrlsAsyncL(class RFile &, enum DRM::TDrmUiUrlType &, class DRM::MDrmAsyncObserver &)
+	?AvailableUrlsL@CDrmUiHandling@DRM@@QAEXAAVCData@ContentAccess@@AAW4TDrmUiUrlType@2@@Z @ 3 NONAME ; void DRM::CDrmUiHandling::AvailableUrlsL(class ContentAccess::CData &, enum DRM::TDrmUiUrlType &)
+	?AvailableUrlsL@CDrmUiHandling@DRM@@QAEXAAVRFile@@AAW4TDrmUiUrlType@2@@Z @ 4 NONAME ; void DRM::CDrmUiHandling::AvailableUrlsL(class RFile &, enum DRM::TDrmUiUrlType &)
+	?CancelOperation@CDrmUiHandling@DRM@@QAEHH@Z @ 5 NONAME ; int DRM::CDrmUiHandling::CancelOperation(int)
+	?CheckRightsAmountAsyncL@CDrmUiHandling@DRM@@QAEHAAVCData@ContentAccess@@W4TIntent@4@AAVMDrmUiCheckRightsObserver@2@@Z @ 6 NONAME ; int DRM::CDrmUiHandling::CheckRightsAmountAsyncL(class ContentAccess::CData &, enum ContentAccess::TIntent, class DRM::MDrmUiCheckRightsObserver &)
+	?CheckRightsAmountAsyncL@CDrmUiHandling@DRM@@QAEHAAVRFile@@W4TIntent@ContentAccess@@AAVMDrmUiCheckRightsObserver@2@@Z @ 7 NONAME ; int DRM::CDrmUiHandling::CheckRightsAmountAsyncL(class RFile &, enum ContentAccess::TIntent, class DRM::MDrmUiCheckRightsObserver &)
+	?CheckRightsAmountL@CDrmUiHandling@DRM@@QAEXAAVCData@ContentAccess@@W4TIntent@4@PAVMDrmUiCheckRightsObserver@2@@Z @ 8 NONAME ; void DRM::CDrmUiHandling::CheckRightsAmountL(class ContentAccess::CData &, enum ContentAccess::TIntent, class DRM::MDrmUiCheckRightsObserver *)
+	?CheckRightsAmountL@CDrmUiHandling@DRM@@QAEXAAVRFile@@W4TIntent@ContentAccess@@PAVMDrmUiCheckRightsObserver@2@@Z @ 9 NONAME ; void DRM::CDrmUiHandling::CheckRightsAmountL(class RFile &, enum ContentAccess::TIntent, class DRM::MDrmUiCheckRightsObserver *)
+	?GetErrorHandler@CDrmUiHandling@DRM@@QBEAAVMDrmErrorHandling@2@XZ @ 10 NONAME ; class DRM::MDrmErrorHandling & DRM::CDrmUiHandling::GetErrorHandler(void) const
+	?GetUtility@CDrmUiHandling@DRM@@QBEAAVCDrmUtility@2@XZ @ 11 NONAME ; class DRM::CDrmUtility & DRM::CDrmUiHandling::GetUtility(void) const
+	?HandleErrorAsyncL@CDrmUiErrorHandling@DRM@@UAEHAAVCData@ContentAccess@@W4TIntent@4@HAAVMDrmHandleErrorObserver@2@@Z @ 12 NONAME ; int DRM::CDrmUiErrorHandling::HandleErrorAsyncL(class ContentAccess::CData &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver &)
+	?HandleErrorAsyncL@CDrmUiErrorHandling@DRM@@UAEHAAVRFile@@W4TIntent@ContentAccess@@HAAVMDrmHandleErrorObserver@2@@Z @ 13 NONAME ; int DRM::CDrmUiErrorHandling::HandleErrorAsyncL(class RFile &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver &)
+	?HandleErrorL@CDrmUiErrorHandling@DRM@@UAEXAAVCData@ContentAccess@@W4TIntent@4@HPAVMDrmHandleErrorObserver@2@@Z @ 14 NONAME ; void DRM::CDrmUiErrorHandling::HandleErrorL(class ContentAccess::CData &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver *)
+	?HandleErrorL@CDrmUiErrorHandling@DRM@@UAEXAAVRFile@@W4TIntent@ContentAccess@@HPAVMDrmHandleErrorObserver@2@@Z @ 15 NONAME ; void DRM::CDrmUiErrorHandling::HandleErrorL(class RFile &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver *)
+	?HandleUrlAsyncL@CDrmUiHandling@DRM@@QAEHAAVCData@ContentAccess@@W4TDrmUiUrlType@2@AAVMDrmAsyncObserver@2@@Z @ 16 NONAME ; int DRM::CDrmUiHandling::HandleUrlAsyncL(class ContentAccess::CData &, enum DRM::TDrmUiUrlType, class DRM::MDrmAsyncObserver &)
+	?HandleUrlAsyncL@CDrmUiHandling@DRM@@QAEHAAVRFile@@W4TDrmUiUrlType@2@AAVMDrmAsyncObserver@2@@Z @ 17 NONAME ; int DRM::CDrmUiHandling::HandleUrlAsyncL(class RFile &, enum DRM::TDrmUiUrlType, class DRM::MDrmAsyncObserver &)
+	?HandleUrlL@CDrmUiHandling@DRM@@QAEXAAVCData@ContentAccess@@W4TDrmUiUrlType@2@@Z @ 18 NONAME ; void DRM::CDrmUiHandling::HandleUrlL(class ContentAccess::CData &, enum DRM::TDrmUiUrlType)
+	?HandleUrlL@CDrmUiHandling@DRM@@QAEXAAVRFile@@W4TDrmUiUrlType@2@@Z @ 19 NONAME ; void DRM::CDrmUiHandling::HandleUrlL(class RFile &, enum DRM::TDrmUiUrlType)
+	?NewL@CDrmUiErrorHandling@DRM@@SAPAV12@PAVCDrmUiHandlingImpl@2@@Z @ 20 NONAME ; class DRM::CDrmUiErrorHandling * DRM::CDrmUiErrorHandling::NewL(class DRM::CDrmUiHandlingImpl *)
+	?NewL@CDrmUiHandling@DRM@@SAPAV12@PAVCCoeEnv@@@Z @ 21 NONAME ; class DRM::CDrmUiHandling * DRM::CDrmUiHandling::NewL(class CCoeEnv *)
+	?NewLC@CDrmUiErrorHandling@DRM@@SAPAV12@PAVCDrmUiHandlingImpl@2@@Z @ 22 NONAME ; class DRM::CDrmUiErrorHandling * DRM::CDrmUiErrorHandling::NewLC(class DRM::CDrmUiHandlingImpl *)
+	?NewLC@CDrmUiHandling@DRM@@SAPAV12@PAVCCoeEnv@@@Z @ 23 NONAME ; class DRM::CDrmUiHandling * DRM::CDrmUiHandling::NewLC(class CCoeEnv *)
+	?ShowDetailsViewAsyncL@CDrmUiHandling@DRM@@QAEHAAVCData@ContentAccess@@AAVMDrmAsyncObserver@2@@Z @ 24 NONAME ; int DRM::CDrmUiHandling::ShowDetailsViewAsyncL(class ContentAccess::CData &, class DRM::MDrmAsyncObserver &)
+	?ShowDetailsViewAsyncL@CDrmUiHandling@DRM@@QAEHAAVRFile@@AAVMDrmAsyncObserver@2@@Z @ 25 NONAME ; int DRM::CDrmUiHandling::ShowDetailsViewAsyncL(class RFile &, class DRM::MDrmAsyncObserver &)
+	?ShowDetailsViewL@CDrmUiHandling@DRM@@QAEXAAVCData@ContentAccess@@@Z @ 26 NONAME ; void DRM::CDrmUiHandling::ShowDetailsViewL(class ContentAccess::CData &)
+	?ShowDetailsViewL@CDrmUiHandling@DRM@@QAEXAAVRFile@@@Z @ 27 NONAME ; void DRM::CDrmUiHandling::ShowDetailsViewL(class RFile &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/bwinscw/DRMUtilityu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,11 @@
+EXPORTS
+	?CheckFileHandleL@CDrmUtility@DRM@@QBEXAAVRFile@@@Z @ 1 NONAME ; void DRM::CDrmUtility::CheckFileHandleL(class RFile &) const
+	?GetAgentL@CDrmUtility@DRM@@QBEHAAVRFile@@AAVTPtrC16@@@Z @ 2 NONAME ; int DRM::CDrmUtility::GetAgentL(class RFile &, class TPtrC16 &) const
+	?GetAgentL@CDrmUtility@DRM@@QBEHABVTDesC8@@AAVTPtrC16@@@Z @ 3 NONAME ; int DRM::CDrmUtility::GetAgentL(class TDesC8 const &, class TPtrC16 &) const
+	?GetDrmInfoL@CDrmUtility@DRM@@QBEHAAVRFile@@AAVTPtrC16@@AAW4TDrmProtectionStatus@2@@Z @ 4 NONAME ; int DRM::CDrmUtility::GetDrmInfoL(class RFile &, class TPtrC16 &, enum DRM::TDrmProtectionStatus &) const
+	?GetDrmInfoL@CDrmUtility@DRM@@QBEHABVTDesC8@@AAVTPtrC16@@AAW4TDrmProtectionStatus@2@@Z @ 5 NONAME ; int DRM::CDrmUtility::GetDrmInfoL(class TDesC8 const &, class TPtrC16 &, enum DRM::TDrmProtectionStatus &) const
+	?IsProtectedL@CDrmUtility@DRM@@QBEHAAVRFile@@@Z @ 6 NONAME ; int DRM::CDrmUtility::IsProtectedL(class RFile &) const
+	?IsProtectedL@CDrmUtility@DRM@@QBEHABVTDesC8@@@Z @ 7 NONAME ; int DRM::CDrmUtility::IsProtectedL(class TDesC8 const &) const
+	?NewL@CDrmUtility@DRM@@SAPAV12@XZ @ 8 NONAME ; class DRM::CDrmUtility * DRM::CDrmUtility::NewL(void)
+	?NewLC@CDrmUtility@DRM@@SAPAV12@XZ @ 9 NONAME ; class DRM::CDrmUtility * DRM::CDrmUtility::NewLC(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/bwinscw/DrmRightsInfoImplU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,7 @@
+EXPORTS
+	?CancelOperation@CDrmRightsInfoImpl@DRM@@QAEHH@Z @ 1 NONAME ; int DRM::CDrmRightsInfoImpl::CancelOperation(int)
+	?CheckRightsAsyncL@CDrmRightsInfoImpl@DRM@@QAEHABVTDesC16@@W4TIntent@ContentAccess@@AAW4TDrmRightsInfo@2@AAVMDrmAsyncObserver@2@@Z @ 2 NONAME ; int DRM::CDrmRightsInfoImpl::CheckRightsAsyncL(class TDesC16 const &, enum ContentAccess::TIntent, enum DRM::TDrmRightsInfo &, class DRM::MDrmAsyncObserver &)
+	?CheckRightsL@CDrmRightsInfoImpl@DRM@@QAEXABVTDesC16@@W4TIntent@ContentAccess@@AAW4TDrmRightsInfo@2@@Z @ 3 NONAME ; void DRM::CDrmRightsInfoImpl::CheckRightsL(class TDesC16 const &, enum ContentAccess::TIntent, enum DRM::TDrmRightsInfo &)
+	?NewL@CDrmRightsInfoImpl@DRM@@SAPAV12@XZ @ 4 NONAME ; class DRM::CDrmRightsInfoImpl * DRM::CDrmRightsInfoImpl::NewL(void)
+	?NewLC@CDrmRightsInfoImpl@DRM@@SAPAV12@XZ @ 5 NONAME ; class DRM::CDrmRightsInfoImpl * DRM::CDrmRightsInfoImpl::NewLC(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/bwinscw/DrmRightsInfoU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,8 @@
+EXPORTS
+	?CancelOperation@CDrmRightsInfo@DRM@@QAEHH@Z @ 1 NONAME ; int DRM::CDrmRightsInfo::CancelOperation(int)
+	?CheckRightsAsyncL@CDrmRightsInfo@DRM@@QAEHABVTDesC16@@W4TIntent@ContentAccess@@AAW4TDrmRightsInfo@2@AAVMDrmAsyncObserver@2@@Z @ 2 NONAME ; int DRM::CDrmRightsInfo::CheckRightsAsyncL(class TDesC16 const &, enum ContentAccess::TIntent, enum DRM::TDrmRightsInfo &, class DRM::MDrmAsyncObserver &)
+	?CheckRightsL@CDrmRightsInfo@DRM@@QAEXABVTDesC16@@W4TIntent@ContentAccess@@AAW4TDrmRightsInfo@2@@Z @ 3 NONAME ; void DRM::CDrmRightsInfo::CheckRightsL(class TDesC16 const &, enum ContentAccess::TIntent, enum DRM::TDrmRightsInfo &)
+	?GetUtility@CDrmRightsInfo@DRM@@QBEAAVCDrmUtility@2@XZ @ 4 NONAME ; class DRM::CDrmUtility & DRM::CDrmRightsInfo::GetUtility(void) const
+	?NewL@CDrmRightsInfo@DRM@@SAPAV12@XZ @ 5 NONAME ; class DRM::CDrmRightsInfo * DRM::CDrmRightsInfo::NewL(void)
+	?NewLC@CDrmRightsInfo@DRM@@SAPAV12@XZ @ 6 NONAME ; class DRM::CDrmRightsInfo * DRM::CDrmRightsInfo::NewLC(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/bwinscw/DrmUtilityDmgrWrapperu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?GateFunctionDMgr@@YAPAXXZ @ 1 NONAME ; void * GateFunctionDMgr(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/bwinscw/drmutilitycommonu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,23 @@
+EXPORTS
+	?DisplayNoteL@CDrmUtilityUI@DRM@@QAEXAAVTDesC16@@HABV3@H@Z @ 1 NONAME ; void DRM::CDrmUtilityUI::DisplayNoteL(class TDesC16 &, int, class TDesC16 const &, int)
+	?DisplayNoteL@CDrmUtilityUI@DRM@@QAEXH@Z @ 2 NONAME ; void DRM::CDrmUtilityUI::DisplayNoteL(int)
+	?DisplayNoteL@CDrmUtilityUI@DRM@@QAEXHABVTDesC16@@@Z @ 3 NONAME ; void DRM::CDrmUtilityUI::DisplayNoteL(int, class TDesC16 const &)
+	?DisplayNoteL@CDrmUtilityUI@DRM@@QAEXHH@Z @ 4 NONAME ; void DRM::CDrmUtilityUI::DisplayNoteL(int, int)
+	?DisplayPopupWindowsForPreviewL@CDrmUtilityUI@DRM@@QAEHAAVCData@ContentAccess@@HH@Z @ 5 NONAME ; int DRM::CDrmUtilityUI::DisplayPopupWindowsForPreviewL(class ContentAccess::CData &, int, int)
+	?DisplayQueryL@CDrmUtilityUI@DRM@@QAEHAAVTDesC16@@H@Z @ 6 NONAME ; int DRM::CDrmUtilityUI::DisplayQueryL(class TDesC16 &, int)
+	?DisplayQueryL@CDrmUtilityUI@DRM@@QAEHHABVTDesC16@@@Z @ 7 NONAME ; int DRM::CDrmUtilityUI::DisplayQueryL(int, class TDesC16 const &)
+	?DisplayQueryL@CDrmUtilityUI@DRM@@QAEHHABVTDesC16@@HHH@Z @ 8 NONAME ; int DRM::CDrmUtilityUI::DisplayQueryL(int, class TDesC16 const &, int, int, int)
+	?DisplayQueryL@CDrmUtilityUI@DRM@@QAEHHH@Z @ 9 NONAME ; int DRM::CDrmUtilityUI::DisplayQueryL(int, int)
+	?DisplayQueryWithIdL@CDrmUtilityUI@DRM@@QAEHHH@Z @ 10 NONAME ; int DRM::CDrmUtilityUI::DisplayQueryWithIdL(int, int)
+	?DisplayQueryWithIdValueL@CDrmUtilityUI@DRM@@QAEHHHABVTDesC16@@@Z @ 11 NONAME ; int DRM::CDrmUtilityUI::DisplayQueryWithIdValueL(int, int, class TDesC16 const &)
+	?GetOmaRightsStatusL@CDrmUtilityCommon@DRM@@QAE?AW4TDrmRightsInfo@2@AAPAVHBufC8@@W4TIntent@ContentAccess@@PAVCDRMConstraint@@@Z @ 12 NONAME ; enum DRM::TDrmRightsInfo DRM::CDrmUtilityCommon::GetOmaRightsStatusL(class HBufC8 * &, enum ContentAccess::TIntent, class CDRMConstraint *)
+	?GetWrapper@CDrmUtilityWMDrm@DRM@@QAEPAVMDrmUtilityWMDrmWrapper@2@XZ @ 13 NONAME ; class DRM::MDrmUtilityWMDrmWrapper * DRM::CDrmUtilityWMDrm::GetWrapper(void)
+	?NewL@CDrmUtilityCommon@DRM@@SAPAV12@XZ @ 14 NONAME ; class DRM::CDrmUtilityCommon * DRM::CDrmUtilityCommon::NewL(void)
+	?NewL@CDrmUtilityUI@DRM@@SAPAV12@PAVCCoeEnv@@@Z @ 15 NONAME ; class DRM::CDrmUtilityUI * DRM::CDrmUtilityUI::NewL(class CCoeEnv *)
+	?NewL@CDrmUtilityWMDrm@DRM@@SAPAV12@PAVCCoeEnv@@@Z @ 16 NONAME ; class DRM::CDrmUtilityWMDrm * DRM::CDrmUtilityWMDrm::NewL(class CCoeEnv *)
+	?NewLC@CDrmUtilityCommon@DRM@@SAPAV12@XZ @ 17 NONAME ; class DRM::CDrmUtilityCommon * DRM::CDrmUtilityCommon::NewLC(void)
+	?NewLC@CDrmUtilityUI@DRM@@SAPAV12@PAVCCoeEnv@@@Z @ 18 NONAME ; class DRM::CDrmUtilityUI * DRM::CDrmUtilityUI::NewLC(class CCoeEnv *)
+	?NewLC@CDrmUtilityWMDrm@DRM@@SAPAV12@PAVCCoeEnv@@@Z @ 19 NONAME ; class DRM::CDrmUtilityWMDrm * DRM::CDrmUtilityWMDrm::NewLC(class CCoeEnv *)
+	?SetAutomatedQueryL@CDrmUtilityUI@DRM@@QAEHPAVCDRMConstraint@@@Z @ 20 NONAME ; int DRM::CDrmUtilityUI::SetAutomatedQueryL(class CDRMConstraint *)
+	?ShowFutureRightsNoteL@CDrmUtilityUI@DRM@@QAEXPAVCDRMConstraint@@@Z @ 21 NONAME ; void DRM::CDrmUtilityUI::ShowFutureRightsNoteL(class CDRMConstraint *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/bwinscw/drmutilitywmdrmwrapperu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,12 @@
+EXPORTS
+	?CheckWmRightsAmountL@CDrmUtilityWMDrmWrapper@DRM@@UAEXAAVCData@ContentAccess@@W4TIntent@4@PAVMDrmUiCheckRightsObserver@2@H@Z @ 1 NONAME ; void DRM::CDrmUtilityWMDrmWrapper::CheckWmRightsAmountL(class ContentAccess::CData &, enum ContentAccess::TIntent, class DRM::MDrmUiCheckRightsObserver *, int)
+	?HandleWmErrorL@CDrmUtilityWMDrmWrapper@DRM@@UAEXAAVCData@ContentAccess@@W4TIntent@4@HPAVMDrmHandleErrorObserver@2@H@Z @ 2 NONAME ; void DRM::CDrmUtilityWMDrmWrapper::HandleWmErrorL(class ContentAccess::CData &, enum ContentAccess::TIntent, int, class DRM::MDrmHandleErrorObserver *, int)
+	?NewL@CDrmUtilityWMDrmWrapper@DRM@@SAPAV12@XZ @ 3 NONAME ; class DRM::CDrmUtilityWMDrmWrapper * DRM::CDrmUtilityWMDrmWrapper::NewL(void)
+	?NewLC@CDrmUtilityWMDrmWrapper@DRM@@SAPAV12@XZ @ 4 NONAME ; class DRM::CDrmUtilityWMDrmWrapper * DRM::CDrmUtilityWMDrmWrapper::NewLC(void)
+	?SetCoeEnv@CDrmUtilityWMDrmWrapper@DRM@@UAEXPAVCCoeEnv@@@Z @ 5 NONAME ; void DRM::CDrmUtilityWMDrmWrapper::SetCoeEnv(class CCoeEnv *)
+	?CheckWmDrmRightsL@DrmUtilityWmDrmUtilities@@SAXAAHAAVTTimeIntervalSeconds@@0AAVCRightsInfo@ContentAccess@@@Z @ 6 NONAME ; void DrmUtilityWmDrmUtilities::CheckWmDrmRightsL(int &, class TTimeIntervalSeconds &, int &, class ContentAccess::CRightsInfo &)
+	?ParseWmDrmCountRightsL@DrmUtilityWmDrmUtilities@@SAHAAVTLex16@@AAK@Z @ 7 NONAME ; int DrmUtilityWmDrmUtilities::ParseWmDrmCountRightsL(class TLex16 &, unsigned long &)
+	?ParseWmDrmDurationRightsL@DrmUtilityWmDrmUtilities@@SAHAAVTLex16@@AAVTTimeIntervalSeconds@@@Z @ 8 NONAME ; int DrmUtilityWmDrmUtilities::ParseWmDrmDurationRightsL(class TLex16 &, class TTimeIntervalSeconds &)
+	?ParseWmDrmStringL@DrmUtilityWmDrmUtilities@@SAXAAVCRightsInfo@ContentAccess@@AAPAVCDRMRightsConstraints@@@Z @ 9 NONAME ; void DrmUtilityWmDrmUtilities::ParseWmDrmStringL(class ContentAccess::CRightsInfo &, class CDRMRightsConstraints * &)
+	?ParseWmDrmTimeRightsL@DrmUtilityWmDrmUtilities@@SAXAAVTLex16@@AAVTTime@@1@Z @ 10 NONAME ; void DrmUtilityWmDrmUtilities::ParseWmDrmTimeRightsL(class TLex16 &, class TTime &, class TTime &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/data/DrmUtilityDmgrWrapper.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,73 @@
+/*
+* 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 file for DrmUtilityDmgrWrapper
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME    DRMD
+
+//  INCLUDES
+#include <eikon.rh>
+#include <eikon.rsg>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.loc>
+#include <avkon.mbg>
+
+#include <drmutility.loc>
+
+//  CONSTANTS
+
+//  MACROS
+
+//  RESOURCE DEFINITIONS
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF16 { buf=""; }
+
+// -----------------------------------------------------------------------------
+//
+// r_silent_progress_note
+// String displayed while getting silent rights
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_silent_progress_note
+    {
+    flags = EAknProgressNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EGeneralQuery;
+            control= AVKON_NOTE
+                {
+                layout = EProgressLayout;
+                singular_label = qtn_drm_progress_opening;
+                imagefile = AVKON_BITMAP_FILE;
+                imageid = EMbmAvkonQgn_note_progress;
+                imagemask = EMbmAvkonQgn_note_progress_mask;
+                };
+          }
+        };
+   }
+
+//End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/data/drmutility.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,600 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for DrmUtility
+*
+*/
+
+
+// RESOURCE IDENTIFIER
+NAME DRMU
+
+//  INCLUDES
+#include <eikon.rh>
+#include <eikon.rsg>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.loc>
+#include <avkon.mbg>
+
+#include <drmutility.loc>
+
+// RESOURCE DEFINITIONS
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF16 { buf=""; }
+
+
+// -----------------------------------------------------------------------------
+// r_drmutility_confirmation_query
+// Confirmation query dialog
+// -----------------------------------------------------------------------------
+RESOURCE DIALOG r_drmutility_confirmation_query
+    {
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_YES_NO__YES;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                label = " ";
+                };
+            }
+        };
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_waiting_rights_confirmation_query
+// Confirmation query dialog
+// -----------------------------------------------------------------------------
+RESOURCE DIALOG r_drmutility_waiting_rights_confirmation_query
+    {
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_OK_EMPTY__OK;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                label = " ";
+                animation = R_QGN_NOTE_INFO_ANIM;
+                };
+            }
+        };
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_qry_connect_to_activate
+// Confirmation query for silent rights acquisition if not allowed in settings
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_qry_connect_to_activate
+    {
+    buf = qtn_drm_qry_connect_to_activate;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_warn_no_conn_defined
+// Info note shown when silent rights activation failed because
+// no access points are defined.
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_warn_no_conn_defined
+    {
+    buf = qtn_drm_warn_no_conn_defined;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_warn_invalid_or_no_ap
+// Info note shown when silent rights activation failed because server cannot
+// be contacted either because access point is invalid, packet data context cannot
+// be established, or access point is of wrong type.
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_warn_invalid_or_no_ap
+    {
+    buf = qtn_drm_warn_invalid_or_no_ap;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_err_opening_fail_perm
+// Info note shown when silent rights activation failed because of permanent type
+// of error.
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_err_opening_fail_perm
+    {
+    buf = qtn_drm_err_opening_fail_perm;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_query_open_error_url
+// Confirmation query for opening error url in ROAP temporary error case.
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_query_open_error_url
+    {
+    buf = qtn_drm_query_open_error_url;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_usage_rights_in_future
+// Text displayed when usage rights are not yet valid.
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_usage_rights_in_future
+    {
+    buf = qtn_drm_note_ro_valid_on_future;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_info_expired_or_no_ro
+// String displayed in info note when usage rights expired or missing
+// rights.
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_info_expired_or_no_ro
+    {
+    buf = qtn_drm_info_expired_or_no_ro;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_query_expired_or_no_ro
+// String displayed in query when usage rights expired or missing
+// rights.
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_query_expired_or_no_ro
+    {
+    buf = qtn_drm_query_expired_or_no_ro;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_waiting_for_rights
+// Text displayed when waiting for rights
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_waiting_for_rights
+    {
+    buf = qtn_drm_query_waiting_for_ro;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_rights_should_have_come_no_ri
+// Text displayed when usage rights are missing but according to
+// x-oma-separate-delivery header they should have arrived
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_rights_should_have_come_no_ri
+    {
+    buf = qtn_drm_query_ro_late;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_rights_should_have_come
+// Text displayed in query when usage rights are missing but according to
+// x-oma-separate-delivery header they should have arrived
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_rights_should_have_come
+    {
+    buf = qtn_drm_query_ro_late_activate;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_activate_account
+// Text displayed in query when domain account must be upgraded.
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_activate_account
+    {
+    buf = qtn_drm_query_activate_account;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_info_sim_not_allowed
+// Text displayed in info note when content cannot be rendered because of wrong SIM.
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_info_sim_not_allowed
+    {
+    buf = qtn_drm_info_sim_not_allowed;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_invalid_sim
+// Text displayed in query when content cannot be rendered because of wrong SIM.
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_invalid_sim
+    {
+    buf = qtn_drm_query_sim_not_allowed;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_query_set_automated
+// Text displayed in query when already activated content is set for automated
+// use.
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_query_set_automated
+    {
+    buf = qtn_drm_query_valid_rights_until;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_query_set_auto_interval
+// Confirmation query for setting content with interval as automated content.
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_query_set_auto_interval
+    {
+    buf = qtn_drm_query_set_auto_interval;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_query_metering_disabled
+// Text displayed on trying to open content with metering rights and when 
+// metering is set as disabled
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_query_metering_disabled
+    {
+    buf = qtn_drm_query_metering_disabled;
+    }
+
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmutility_prev_audio_get_list_query
+//    Preview list query for audio with preview rights url.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_drmutility_prev_audio_get_list_query
+    {
+    softkeys = R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT;
+
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = qtn_drm_prmpt_activate_preview;
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; // not sure if this is needed
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknListQueryMessageBox;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = qtn_drm_desc_activate_or_prvw;
+                };
+            },
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            id = EListQueryControl;
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    flags = EAknListBoxSelectionList;
+                    array_id = r_drmutility_audio_prev_get_list;
+                    };
+                heading = qtn_drm_prmpt_activate_preview;
+                };
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmutility_prev_video_get_list_query
+//    Preview list query for video with preview rights url.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_drmutility_prev_video_get_list_query
+    {
+    softkeys = R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT;
+
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = qtn_drm_prmpt_activate_preview;
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; // not sure if this is needed
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknListQueryMessageBox;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = qtn_drm_desc_act_or_prev_video;
+                };
+            },
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            id = EListQueryControl;
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    flags = EAknListBoxSelectionList;
+                    array_id = r_drmutility_video_prev_get_list;
+                    };
+                heading = qtn_drm_prmpt_activate_preview;
+                };
+            }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmutility_prev_audio_play_list_query
+//    Preview list query for audio with embedded preview.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_drmutility_prev_audio_play_list_query
+    {
+    softkeys = R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT;
+
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = qtn_drm_prmpt_activate_preview;
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; // not sure if this is needed
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknListQueryMessageBox;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = qtn_drm_desc_play_preview_audio;
+                };
+            },
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            id = EListQueryControl;
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    flags = EAknListBoxSelectionList;
+                    array_id = r_drmutility_audio_prev_play_list;
+                    };
+                heading = qtn_drm_prmpt_activate_preview;
+                };
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmutility_prev_video_play_list_query
+//    Preview list query for video with embedded preview.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_drmutility_prev_video_play_list_query
+    {
+    softkeys = R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT;
+
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = qtn_drm_prmpt_activate_preview;
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; // not sure if this is needed
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknListQueryMessageBox;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = qtn_drm_desc_play_preview_video;
+                };
+            },
+
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            id = EListQueryControl;
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    flags = EAknListBoxSelectionList;
+                    array_id = r_drmutility_video_prev_play_list;
+                    };
+                heading = qtn_drm_prmpt_activate_preview;
+                };
+            }
+        };
+    }
+
+
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmutility_audio_prev_get_list
+//    Array elements for preview rights of audio dcf.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_drmutility_audio_prev_get_list
+    {
+    items=
+        {
+        LBUF
+            {
+            txt = qtn_drm_options_activate;
+            },
+        LBUF
+            {
+            txt = qtn_drm_options_get_preview;
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmutility_video_prev_get_list
+//    Array elements for preview rights of video dcf.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_drmutility_video_prev_get_list
+    {
+    items=
+        {
+        LBUF
+            {
+            txt = qtn_drm_options_activate;
+            },
+        LBUF
+            {
+            txt = qtn_drm_options_get_prev_video;
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmutility_audio_prev_play_list
+//    Array elements for embedded preview of audio dcf.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_drmutility_audio_prev_play_list
+    {
+    items=
+        {
+        LBUF
+            {
+            txt = qtn_drm_options_activate;
+            },
+        LBUF
+            {
+            txt = qtn_drm_options_play_preview;
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmutility_video_prev_play_list
+//    Array elements for embedded preview of video dcf.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_drmutility_video_prev_play_list
+    {
+    items=
+        {
+        LBUF
+            {
+            txt = qtn_drm_options_activate;
+            },
+        LBUF
+            {
+            txt = qtn_drm_options_play_prev_video;
+            }
+        };
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_activate_preview
+// Text displayed in header of global preview list query
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_activate_preview
+    {
+    buf = qtn_drm_prmpt_activate_preview;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_activate
+// Text displayed in global preview list query as a choise to activate content
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_activate
+    {
+    buf = qtn_drm_options_activate;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_play_preview
+// Text displayed in global preview list query as a choise to play preview
+// for audio
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_play_preview
+    {
+    buf = qtn_drm_options_play_preview;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_play_preview_video
+// Text displayed in global preview list query as a choise to play preview
+// for video
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_play_preview_video
+    {
+    buf = qtn_drm_options_play_prev_video;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_get_preview
+// Text displayed in global preview list query as a choise to get preview
+// rights for audio
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_get_preview
+    {
+    buf = qtn_drm_options_get_preview;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drmutility_get_preview_video
+// Text displayed in global preview list query as a choise to get preview
+// rights for video
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drmutility_get_preview_video
+    {
+    buf = qtn_drm_options_get_prev_video;
+    }
+
+#endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/eabi/DRMAutomatedUsageImplU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,23 @@
+EXPORTS
+	_ZN3DRM22CDrmAutomatedUsageImpl12HandleErrorLER5RFileN13ContentAccess7TIntentEiPNS_23MDrmHandleErrorObserverE @ 1 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl12HandleErrorLERN13ContentAccess5CDataENS1_7TIntentEiPNS_23MDrmHandleErrorObserverE @ 2 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl13SetAutomatedLER5RFileN13ContentAccess7TIntentENS_17TDrmAutomatedTypeENS_24TDrmAutomatedServiceTypeE @ 3 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl13SetAutomatedLERKN13ContentAccess5CDataENS1_7TIntentENS_17TDrmAutomatedTypeENS_24TDrmAutomatedServiceTypeE @ 4 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl15CancelOperationEi @ 5 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl16CanSetAutomatedLER5RFileN13ContentAccess7TIntentENS_17TDrmAutomatedTypeE @ 6 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl16CanSetAutomatedLERKN13ContentAccess5CDataENS1_7TIntentENS_17TDrmAutomatedTypeE @ 7 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl16RemoveAutomatedLER5RFileN13ContentAccess7TIntentENS_17TDrmAutomatedTypeENS_24TDrmAutomatedServiceTypeE @ 8 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl16RemoveAutomatedLERK7TDesC16N13ContentAccess7TIntentENS_17TDrmAutomatedTypeENS_24TDrmAutomatedServiceTypeE @ 9 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl16RemoveAutomatedLERKN13ContentAccess5CDataENS1_7TIntentENS_17TDrmAutomatedTypeENS_24TDrmAutomatedServiceTypeE @ 10 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl17HandleErrorAsyncLER5RFileN13ContentAccess7TIntentEiRNS_23MDrmHandleErrorObserverE @ 11 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl17HandleErrorAsyncLERN13ContentAccess5CDataENS1_7TIntentEiRNS_23MDrmHandleErrorObserverE @ 12 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl18SetAutomatedAsyncLER5RFileN13ContentAccess7TIntentENS_17TDrmAutomatedTypeERNS_17MDrmAsyncObserverENS_24TDrmAutomatedServiceTypeE @ 13 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl18SetAutomatedAsyncLERKN13ContentAccess5CDataENS1_7TIntentENS_17TDrmAutomatedTypeERNS_17MDrmAsyncObserverENS_24TDrmAutomatedServiceTypeE @ 14 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl21RemoveAutomatedAsyncLER5RFileN13ContentAccess7TIntentENS_17TDrmAutomatedTypeERNS_17MDrmAsyncObserverENS_24TDrmAutomatedServiceTypeE @ 15 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl21RemoveAutomatedAsyncLERK7TDesC16N13ContentAccess7TIntentENS_17TDrmAutomatedTypeERNS_17MDrmAsyncObserverENS_24TDrmAutomatedServiceTypeE @ 16 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl21RemoveAutomatedAsyncLERKN13ContentAccess5CDataENS1_7TIntentENS_17TDrmAutomatedTypeERNS_17MDrmAsyncObserverENS_24TDrmAutomatedServiceTypeE @ 17 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl22RegisterEventObserverLERNS_26MDrmAutomatedUsageObserverE @ 18 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl24UnregisterEventObserverLERNS_26MDrmAutomatedUsageObserverE @ 19 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl4NewLEP7CCoeEnvPNS_11CDrmUtilityE @ 20 NONAME
+	_ZN3DRM22CDrmAutomatedUsageImpl5NewLCEP7CCoeEnvPNS_11CDrmUtilityE @ 21 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/eabi/DRMAutomatedUsageU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,31 @@
+EXPORTS
+	_ZN3DRM18CDrmAutomatedUsage13SetAutomatedLER5RFileN13ContentAccess7TIntentENS_17TDrmAutomatedTypeENS_24TDrmAutomatedServiceTypeE @ 1 NONAME
+	_ZN3DRM18CDrmAutomatedUsage13SetAutomatedLERKN13ContentAccess5CDataENS1_7TIntentENS_17TDrmAutomatedTypeENS_24TDrmAutomatedServiceTypeE @ 2 NONAME
+	_ZN3DRM18CDrmAutomatedUsage15CancelOperationEi @ 3 NONAME
+	_ZN3DRM18CDrmAutomatedUsage16CanSetAutomatedLER5RFileN13ContentAccess7TIntentENS_17TDrmAutomatedTypeE @ 4 NONAME
+	_ZN3DRM18CDrmAutomatedUsage16CanSetAutomatedLERKN13ContentAccess5CDataENS1_7TIntentENS_17TDrmAutomatedTypeE @ 5 NONAME
+	_ZN3DRM18CDrmAutomatedUsage16RemoveAutomatedLER5RFileN13ContentAccess7TIntentENS_17TDrmAutomatedTypeENS_24TDrmAutomatedServiceTypeE @ 6 NONAME
+	_ZN3DRM18CDrmAutomatedUsage16RemoveAutomatedLERK7TDesC16N13ContentAccess7TIntentENS_17TDrmAutomatedTypeENS_24TDrmAutomatedServiceTypeE @ 7 NONAME
+	_ZN3DRM18CDrmAutomatedUsage16RemoveAutomatedLERKN13ContentAccess5CDataENS1_7TIntentENS_17TDrmAutomatedTypeENS_24TDrmAutomatedServiceTypeE @ 8 NONAME
+	_ZN3DRM18CDrmAutomatedUsage18SetAutomatedAsyncLER5RFileN13ContentAccess7TIntentENS_17TDrmAutomatedTypeERNS_17MDrmAsyncObserverENS_24TDrmAutomatedServiceTypeE @ 9 NONAME
+	_ZN3DRM18CDrmAutomatedUsage18SetAutomatedAsyncLERKN13ContentAccess5CDataENS1_7TIntentENS_17TDrmAutomatedTypeERNS_17MDrmAsyncObserverENS_24TDrmAutomatedServiceTypeE @ 10 NONAME
+	_ZN3DRM18CDrmAutomatedUsage21RemoveAutomatedAsyncLER5RFileN13ContentAccess7TIntentENS_17TDrmAutomatedTypeERNS_17MDrmAsyncObserverENS_24TDrmAutomatedServiceTypeE @ 11 NONAME
+	_ZN3DRM18CDrmAutomatedUsage21RemoveAutomatedAsyncLERK7TDesC16N13ContentAccess7TIntentENS_17TDrmAutomatedTypeERNS_17MDrmAsyncObserverENS_24TDrmAutomatedServiceTypeE @ 12 NONAME
+	_ZN3DRM18CDrmAutomatedUsage21RemoveAutomatedAsyncLERKN13ContentAccess5CDataENS1_7TIntentENS_17TDrmAutomatedTypeERNS_17MDrmAsyncObserverENS_24TDrmAutomatedServiceTypeE @ 13 NONAME
+	_ZN3DRM18CDrmAutomatedUsage22RegisterEventObserverLERNS_26MDrmAutomatedUsageObserverE @ 14 NONAME
+	_ZN3DRM18CDrmAutomatedUsage24UnregisterEventObserverLERNS_26MDrmAutomatedUsageObserverE @ 15 NONAME
+	_ZN3DRM18CDrmAutomatedUsage4NewLEP7CCoeEnv @ 16 NONAME
+	_ZN3DRM18CDrmAutomatedUsage5NewLCEP7CCoeEnv @ 17 NONAME
+	_ZN3DRM31CDrmAutomatedUsageErrorHandling12HandleErrorLER5RFileN13ContentAccess7TIntentEiPNS_23MDrmHandleErrorObserverE @ 18 NONAME
+	_ZN3DRM31CDrmAutomatedUsageErrorHandling12HandleErrorLERN13ContentAccess5CDataENS1_7TIntentEiPNS_23MDrmHandleErrorObserverE @ 19 NONAME
+	_ZN3DRM31CDrmAutomatedUsageErrorHandling17HandleErrorAsyncLER5RFileN13ContentAccess7TIntentEiRNS_23MDrmHandleErrorObserverE @ 20 NONAME
+	_ZN3DRM31CDrmAutomatedUsageErrorHandling17HandleErrorAsyncLERN13ContentAccess5CDataENS1_7TIntentEiRNS_23MDrmHandleErrorObserverE @ 21 NONAME
+	_ZN3DRM31CDrmAutomatedUsageErrorHandling4NewLEPNS_22CDrmAutomatedUsageImplE @ 22 NONAME
+	_ZN3DRM31CDrmAutomatedUsageErrorHandling5NewLCEPNS_22CDrmAutomatedUsageImplE @ 23 NONAME
+	_ZNK3DRM18CDrmAutomatedUsage10GetUtilityEv @ 24 NONAME
+	_ZNK3DRM18CDrmAutomatedUsage15GetErrorHandlerEv @ 25 NONAME
+	_ZThn4_N3DRM31CDrmAutomatedUsageErrorHandling12HandleErrorLER5RFileN13ContentAccess7TIntentEiPNS_23MDrmHandleErrorObserverE @ 26 NONAME ; #<thunk>#
+	_ZThn4_N3DRM31CDrmAutomatedUsageErrorHandling12HandleErrorLERN13ContentAccess5CDataENS1_7TIntentEiPNS_23MDrmHandleErrorObserverE @ 27 NONAME ; #<thunk>#
+	_ZThn4_N3DRM31CDrmAutomatedUsageErrorHandling17HandleErrorAsyncLER5RFileN13ContentAccess7TIntentEiRNS_23MDrmHandleErrorObserverE @ 28 NONAME ; #<thunk>#
+	_ZThn4_N3DRM31CDrmAutomatedUsageErrorHandling17HandleErrorAsyncLERN13ContentAccess5CDataENS1_7TIntentEiRNS_23MDrmHandleErrorObserverE @ 29 NONAME ; #<thunk>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/eabi/DRMUiHandlingImplU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+EXPORTS
+	_ZN3DRM18CDrmUiHandlingImpl10HandleUrlLER5RFileNS_13TDrmUiUrlTypeE @ 1 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl10HandleUrlLERN13ContentAccess5CDataENS_13TDrmUiUrlTypeE @ 2 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl12HandleErrorLER5RFileN13ContentAccess7TIntentEiPNS_23MDrmHandleErrorObserverE @ 3 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl12HandleErrorLERN13ContentAccess5CDataENS1_7TIntentEiPNS_23MDrmHandleErrorObserverE @ 4 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl14AvailableUrlsLER5RFileRNS_13TDrmUiUrlTypeE @ 5 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl14AvailableUrlsLERN13ContentAccess5CDataERNS_13TDrmUiUrlTypeE @ 6 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl15CancelOperationEi @ 7 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl15HandleUrlAsyncLER5RFileNS_13TDrmUiUrlTypeERNS_17MDrmAsyncObserverE @ 8 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl15HandleUrlAsyncLERN13ContentAccess5CDataENS_13TDrmUiUrlTypeERNS_17MDrmAsyncObserverE @ 9 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl16ShowDetailsViewLER5RFile @ 10 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl16ShowDetailsViewLERN13ContentAccess5CDataE @ 11 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl17HandleErrorAsyncLER5RFileN13ContentAccess7TIntentEiRNS_23MDrmHandleErrorObserverE @ 12 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl17HandleErrorAsyncLERN13ContentAccess5CDataENS1_7TIntentEiRNS_23MDrmHandleErrorObserverE @ 13 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl18CheckRightsAmountLER5RFileN13ContentAccess7TIntentEPNS_25MDrmUiCheckRightsObserverE @ 14 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl18CheckRightsAmountLERN13ContentAccess5CDataENS1_7TIntentEPNS_25MDrmUiCheckRightsObserverE @ 15 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl19AvailableUrlsAsyncLER5RFileRNS_13TDrmUiUrlTypeERNS_17MDrmAsyncObserverE @ 16 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl19AvailableUrlsAsyncLERN13ContentAccess5CDataERNS_13TDrmUiUrlTypeERNS_17MDrmAsyncObserverE @ 17 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl21ShowDetailsViewAsyncLER5RFileRNS_17MDrmAsyncObserverE @ 18 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl21ShowDetailsViewAsyncLERN13ContentAccess5CDataERNS_17MDrmAsyncObserverE @ 19 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl23CheckRightsAmountAsyncLER5RFileN13ContentAccess7TIntentERNS_25MDrmUiCheckRightsObserverE @ 20 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl23CheckRightsAmountAsyncLERN13ContentAccess5CDataENS1_7TIntentERNS_25MDrmUiCheckRightsObserverE @ 21 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl4NewLEPNS_11CDrmUtilityEP7CCoeEnv @ 22 NONAME
+	_ZN3DRM18CDrmUiHandlingImpl5NewLCEPNS_11CDrmUtilityEP7CCoeEnv @ 23 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/eabi/DRMUiHandlingU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,33 @@
+EXPORTS
+	_ZN3DRM14CDrmUiHandling10HandleUrlLER5RFileNS_13TDrmUiUrlTypeE @ 1 NONAME
+	_ZN3DRM14CDrmUiHandling10HandleUrlLERN13ContentAccess5CDataENS_13TDrmUiUrlTypeE @ 2 NONAME
+	_ZN3DRM14CDrmUiHandling14AvailableUrlsLER5RFileRNS_13TDrmUiUrlTypeE @ 3 NONAME
+	_ZN3DRM14CDrmUiHandling14AvailableUrlsLERN13ContentAccess5CDataERNS_13TDrmUiUrlTypeE @ 4 NONAME
+	_ZN3DRM14CDrmUiHandling15CancelOperationEi @ 5 NONAME
+	_ZN3DRM14CDrmUiHandling15HandleUrlAsyncLER5RFileNS_13TDrmUiUrlTypeERNS_17MDrmAsyncObserverE @ 6 NONAME
+	_ZN3DRM14CDrmUiHandling15HandleUrlAsyncLERN13ContentAccess5CDataENS_13TDrmUiUrlTypeERNS_17MDrmAsyncObserverE @ 7 NONAME
+	_ZN3DRM14CDrmUiHandling16ShowDetailsViewLER5RFile @ 8 NONAME
+	_ZN3DRM14CDrmUiHandling16ShowDetailsViewLERN13ContentAccess5CDataE @ 9 NONAME
+	_ZN3DRM14CDrmUiHandling18CheckRightsAmountLER5RFileN13ContentAccess7TIntentEPNS_25MDrmUiCheckRightsObserverE @ 10 NONAME
+	_ZN3DRM14CDrmUiHandling18CheckRightsAmountLERN13ContentAccess5CDataENS1_7TIntentEPNS_25MDrmUiCheckRightsObserverE @ 11 NONAME
+	_ZN3DRM14CDrmUiHandling19AvailableUrlsAsyncLER5RFileRNS_13TDrmUiUrlTypeERNS_17MDrmAsyncObserverE @ 12 NONAME
+	_ZN3DRM14CDrmUiHandling19AvailableUrlsAsyncLERN13ContentAccess5CDataERNS_13TDrmUiUrlTypeERNS_17MDrmAsyncObserverE @ 13 NONAME
+	_ZN3DRM14CDrmUiHandling21ShowDetailsViewAsyncLER5RFileRNS_17MDrmAsyncObserverE @ 14 NONAME
+	_ZN3DRM14CDrmUiHandling21ShowDetailsViewAsyncLERN13ContentAccess5CDataERNS_17MDrmAsyncObserverE @ 15 NONAME
+	_ZN3DRM14CDrmUiHandling23CheckRightsAmountAsyncLER5RFileN13ContentAccess7TIntentERNS_25MDrmUiCheckRightsObserverE @ 16 NONAME
+	_ZN3DRM14CDrmUiHandling23CheckRightsAmountAsyncLERN13ContentAccess5CDataENS1_7TIntentERNS_25MDrmUiCheckRightsObserverE @ 17 NONAME
+	_ZN3DRM14CDrmUiHandling4NewLEP7CCoeEnv @ 18 NONAME
+	_ZN3DRM14CDrmUiHandling5NewLCEP7CCoeEnv @ 19 NONAME
+	_ZN3DRM19CDrmUiErrorHandling12HandleErrorLER5RFileN13ContentAccess7TIntentEiPNS_23MDrmHandleErrorObserverE @ 20 NONAME
+	_ZN3DRM19CDrmUiErrorHandling12HandleErrorLERN13ContentAccess5CDataENS1_7TIntentEiPNS_23MDrmHandleErrorObserverE @ 21 NONAME
+	_ZN3DRM19CDrmUiErrorHandling17HandleErrorAsyncLER5RFileN13ContentAccess7TIntentEiRNS_23MDrmHandleErrorObserverE @ 22 NONAME
+	_ZN3DRM19CDrmUiErrorHandling17HandleErrorAsyncLERN13ContentAccess5CDataENS1_7TIntentEiRNS_23MDrmHandleErrorObserverE @ 23 NONAME
+	_ZN3DRM19CDrmUiErrorHandling4NewLEPNS_18CDrmUiHandlingImplE @ 24 NONAME
+	_ZN3DRM19CDrmUiErrorHandling5NewLCEPNS_18CDrmUiHandlingImplE @ 25 NONAME
+	_ZNK3DRM14CDrmUiHandling10GetUtilityEv @ 26 NONAME
+	_ZNK3DRM14CDrmUiHandling15GetErrorHandlerEv @ 27 NONAME
+	_ZThn4_N3DRM19CDrmUiErrorHandling12HandleErrorLER5RFileN13ContentAccess7TIntentEiPNS_23MDrmHandleErrorObserverE @ 28 NONAME ; #<thunk>#
+	_ZThn4_N3DRM19CDrmUiErrorHandling12HandleErrorLERN13ContentAccess5CDataENS1_7TIntentEiPNS_23MDrmHandleErrorObserverE @ 29 NONAME ; #<thunk>#
+	_ZThn4_N3DRM19CDrmUiErrorHandling17HandleErrorAsyncLER5RFileN13ContentAccess7TIntentEiRNS_23MDrmHandleErrorObserverE @ 30 NONAME ; #<thunk>#
+	_ZThn4_N3DRM19CDrmUiErrorHandling17HandleErrorAsyncLERN13ContentAccess5CDataENS1_7TIntentEiRNS_23MDrmHandleErrorObserverE @ 31 NONAME ; #<thunk>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/eabi/DRMUtilityu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,11 @@
+EXPORTS
+	_ZN3DRM11CDrmUtility4NewLEv @ 1 NONAME
+	_ZN3DRM11CDrmUtility5NewLCEv @ 2 NONAME
+	_ZNK3DRM11CDrmUtility11GetDrmInfoLER5RFileR7TPtrC16RNS_20TDrmProtectionStatusE @ 3 NONAME
+	_ZNK3DRM11CDrmUtility11GetDrmInfoLERK6TDesC8R7TPtrC16RNS_20TDrmProtectionStatusE @ 4 NONAME
+	_ZNK3DRM11CDrmUtility12IsProtectedLER5RFile @ 5 NONAME
+	_ZNK3DRM11CDrmUtility12IsProtectedLERK6TDesC8 @ 6 NONAME
+	_ZNK3DRM11CDrmUtility16CheckFileHandleLER5RFile @ 7 NONAME
+	_ZNK3DRM11CDrmUtility9GetAgentLER5RFileR7TPtrC16 @ 8 NONAME
+	_ZNK3DRM11CDrmUtility9GetAgentLERK6TDesC8R7TPtrC16 @ 9 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/eabi/DrmRightsInfoImplu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,7 @@
+EXPORTS
+	_ZN3DRM18CDrmRightsInfoImpl12CheckRightsLERK7TDesC16N13ContentAccess7TIntentERNS_14TDrmRightsInfoE @ 1 NONAME
+	_ZN3DRM18CDrmRightsInfoImpl15CancelOperationEi @ 2 NONAME
+	_ZN3DRM18CDrmRightsInfoImpl17CheckRightsAsyncLERK7TDesC16N13ContentAccess7TIntentERNS_14TDrmRightsInfoERNS_17MDrmAsyncObserverE @ 3 NONAME
+	_ZN3DRM18CDrmRightsInfoImpl4NewLEv @ 4 NONAME
+	_ZN3DRM18CDrmRightsInfoImpl5NewLCEv @ 5 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/eabi/DrmRightsInfoU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,8 @@
+EXPORTS
+	_ZN3DRM14CDrmRightsInfo12CheckRightsLERK7TDesC16N13ContentAccess7TIntentERNS_14TDrmRightsInfoE @ 1 NONAME
+	_ZN3DRM14CDrmRightsInfo15CancelOperationEi @ 2 NONAME
+	_ZN3DRM14CDrmRightsInfo17CheckRightsAsyncLERK7TDesC16N13ContentAccess7TIntentERNS_14TDrmRightsInfoERNS_17MDrmAsyncObserverE @ 3 NONAME
+	_ZN3DRM14CDrmRightsInfo4NewLEv @ 4 NONAME
+	_ZN3DRM14CDrmRightsInfo5NewLCEv @ 5 NONAME
+	_ZNK3DRM14CDrmRightsInfo10GetUtilityEv @ 6 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/eabi/DrmUtilityDmgrWrapperu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z16GateFunctionDMgrv @ 1 NONAME
+	_ZTI22CDrmUtilityDmgrWrapper @ 2 NONAME ; #<TI>#
+	_ZTV22CDrmUtilityDmgrWrapper @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/eabi/drmutilitycommonu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,23 @@
+EXPORTS
+	_ZN3DRM13CDrmUtilityUI12DisplayNoteLER7TDesC16iRKS1_i @ 1 NONAME
+	_ZN3DRM13CDrmUtilityUI12DisplayNoteLEi @ 2 NONAME
+	_ZN3DRM13CDrmUtilityUI12DisplayNoteLEiRK7TDesC16 @ 3 NONAME
+	_ZN3DRM13CDrmUtilityUI12DisplayNoteLEii @ 4 NONAME
+	_ZN3DRM13CDrmUtilityUI13DisplayQueryLER7TDesC16i @ 5 NONAME
+	_ZN3DRM13CDrmUtilityUI13DisplayQueryLEiRK7TDesC16 @ 6 NONAME
+	_ZN3DRM13CDrmUtilityUI13DisplayQueryLEiRK7TDesC16iii @ 7 NONAME
+	_ZN3DRM13CDrmUtilityUI13DisplayQueryLEii @ 8 NONAME
+	_ZN3DRM13CDrmUtilityUI18SetAutomatedQueryLEP14CDRMConstraint @ 9 NONAME
+	_ZN3DRM13CDrmUtilityUI19DisplayQueryWithIdLEii @ 10 NONAME
+	_ZN3DRM13CDrmUtilityUI21ShowFutureRightsNoteLEP14CDRMConstraint @ 11 NONAME
+	_ZN3DRM13CDrmUtilityUI24DisplayQueryWithIdValueLEiiRK7TDesC16 @ 12 NONAME
+	_ZN3DRM13CDrmUtilityUI30DisplayPopupWindowsForPreviewLERN13ContentAccess5CDataEii @ 13 NONAME
+	_ZN3DRM13CDrmUtilityUI4NewLEP7CCoeEnv @ 14 NONAME
+	_ZN3DRM13CDrmUtilityUI5NewLCEP7CCoeEnv @ 15 NONAME
+	_ZN3DRM16CDrmUtilityWMDrm10GetWrapperEv @ 16 NONAME
+	_ZN3DRM16CDrmUtilityWMDrm4NewLEP7CCoeEnv @ 17 NONAME
+	_ZN3DRM16CDrmUtilityWMDrm5NewLCEP7CCoeEnv @ 18 NONAME
+	_ZN3DRM17CDrmUtilityCommon19GetOmaRightsStatusLERP6HBufC8N13ContentAccess7TIntentEP14CDRMConstraint @ 19 NONAME
+	_ZN3DRM17CDrmUtilityCommon4NewLEv @ 20 NONAME
+	_ZN3DRM17CDrmUtilityCommon5NewLCEv @ 21 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/eabi/drmutilitywmdrmwrapperu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,15 @@
+EXPORTS
+	_ZN3DRM23CDrmUtilityWMDrmWrapper14HandleWmErrorLERN13ContentAccess5CDataENS1_7TIntentEiPNS_23MDrmHandleErrorObserverEi @ 1 NONAME
+	_ZN3DRM23CDrmUtilityWMDrmWrapper20CheckWmRightsAmountLERN13ContentAccess5CDataENS1_7TIntentEPNS_25MDrmUiCheckRightsObserverEi @ 2 NONAME
+	_ZN3DRM23CDrmUtilityWMDrmWrapper4NewLEv @ 3 NONAME
+	_ZN3DRM23CDrmUtilityWMDrmWrapper5NewLCEv @ 4 NONAME
+	_ZN3DRM23CDrmUtilityWMDrmWrapper9SetCoeEnvEP7CCoeEnv @ 5 NONAME
+	_ZThn4_N3DRM23CDrmUtilityWMDrmWrapper14HandleWmErrorLERN13ContentAccess5CDataENS1_7TIntentEiPNS_23MDrmHandleErrorObserverEi @ 6 NONAME ; #<thunk>#
+	_ZThn4_N3DRM23CDrmUtilityWMDrmWrapper20CheckWmRightsAmountLERN13ContentAccess5CDataENS1_7TIntentEPNS_25MDrmUiCheckRightsObserverEi @ 7 NONAME ; #<thunk>#
+	_ZThn4_N3DRM23CDrmUtilityWMDrmWrapper9SetCoeEnvEP7CCoeEnv @ 8 NONAME ; #<thunk>#
+	_ZN24DrmUtilityWmDrmUtilities17CheckWmDrmRightsLERiR20TTimeIntervalSecondsS0_RN13ContentAccess11CRightsInfoE @ 9 NONAME
+	_ZN24DrmUtilityWmDrmUtilities17ParseWmDrmStringLERN13ContentAccess11CRightsInfoERP21CDRMRightsConstraints @ 10 NONAME
+	_ZN24DrmUtilityWmDrmUtilities21ParseWmDrmTimeRightsLER6TLex16R5TTimeS3_ @ 11 NONAME
+	_ZN24DrmUtilityWmDrmUtilities22ParseWmDrmCountRightsLER6TLex16Rm @ 12 NONAME
+	_ZN24DrmUtilityWmDrmUtilities25ParseWmDrmDurationRightsLER6TLex16R20TTimeIntervalSeconds @ 13 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/group/DRMAutomatedUsage.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2006 - 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:  Project definition file for DRM Utility
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          DRMAutomatedUsage.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x10205CB8
+
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+#ifdef __DRM
+SOURCE          ../src/DrmAutomatedUsage.cpp
+SOURCE          ../src/drmautomatedusageerrorhandling.cpp
+#endif
+
+
+USERINCLUDE     ../inc      // subsystem level inc dir
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         flogger.lib
+
+LIBRARY         drmutility.lib
+LIBRARY         drmautomatedusageimpl.lib
+LIBRARY         caf.lib
+LIBRARY         cafutils.lib
+LIBRARY         efsrv.lib       // RFile
+LIBRARY         drmdcf.lib      // COma1Dcf
+
+DOCUMENT    bld.inf
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/group/DRMAutomatedUsageImpl.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2006 - 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:  Project definition file for DRM Utility
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          DRMAutomatedUsageImpl.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x10205CBC
+
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+#ifdef __DRM
+SOURCE          ../src/DrmAutomatedUsageImpl.cpp
+SOURCE          ../src/drmautomatedusagedata.cpp
+SOURCE          ../src/rdrmhelperclient.cpp
+#endif
+
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         flogger.lib
+LIBRARY         efsrv.lib
+LIBRARY         drmutility.lib
+LIBRARY         drmutilitycommon.lib
+LIBRARY         caf.lib
+LIBRARY         cafutils.lib
+LIBRARY         charconv.lib
+LIBRARY         drmrights.lib
+LIBRARY         drmserverinterfaces.lib
+LIBRARY         commonengine.lib
+
+
+DOCUMENT    bld.inf
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/group/DRMUiHandling.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for DRM Utility
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          DRMUiHandling.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x10205CBA
+
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+#ifdef __DRM
+SOURCE          ../src/DrmUiHandling.cpp
+SOURCE          ../src/drmuierrorhandling.cpp
+#endif
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         flogger.lib
+LIBRARY         drmuihandlingimpl.lib
+LIBRARY         caf.lib
+LIBRARY         cafutils.lib
+LIBRARY         efsrv.lib       // RFile
+LIBRARY         drmdcf.lib      // COma1Dcf
+LIBRARY         drmutility.lib  // DRMUtility
+LIBRARY         cone.lib        // CCoeEnv
+
+
+DOCUMENT    bld.inf
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/group/DRMUiHandlingImpl.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,82 @@
+/*
+* Copyright (c) 2006-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:  Project definition file for DRM Utility
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          DRMUiHandlingImpl.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x10205CBE
+
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+#ifdef __DRM
+SOURCE          ../src/DrmUiHandlingImpl.cpp
+SOURCE          ../src/drmuihandlingdata.cpp
+SOURCE          ../src/DrmUtilityDownloadManager.cpp
+#endif
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../omadrm/drmengine/roap/inc
+USERINCLUDE     ../../../omadrm/drmengine/roapstorage/inc
+USERINCLUDE     ../../../omadrm/drmengine/server/inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/ecom    // needed because of SchemeHandler
+
+LIBRARY         euser.lib
+LIBRARY         apparc.lib // for launching rights mgr ui embedded
+LIBRARY         avkon.lib
+LIBRARY         efsrv.lib // for launching rights mgr ui embedded
+LIBRARY         apgrfx.lib
+LIBRARY         ws32.lib
+LIBRARY         centralrepository.lib
+LIBRARY         servicehandler.lib
+LIBRARY         caf.lib
+LIBRARY         cafutils.lib
+LIBRARY         charconv.lib
+LIBRARY         ecom.lib // for scheme handling
+LIBRARY         cmmanager.lib
+
+#ifdef __DRM
+LIBRARY         drmutilitycommon.lib
+LIBRARY         drmutility.lib
+LIBRARY         roaphandler.lib
+LIBRARY         drmparsers.lib
+LIBRARY         drmdcf.lib
+LIBRARY         dcfrep.lib
+LIBRARY         drmrights.lib
+LIBRARY         drmserverinterfaces.lib
+LIBRARY         drmcommon.lib
+#endif
+
+DOCUMENT    bld.inf
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/group/DRMUtility.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2006-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:  Project definition file for DRM Utility
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          DRMUtility.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x102830B7
+
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+#ifdef __DRM
+SOURCE          ../src/DrmUtility.cpp
+#endif
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../omadrm/drmengine/server/inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib   // RFile
+LIBRARY         drmdcf.lib  // DRM Dcf
+LIBRARY         charconv.lib
+LIBRARY         centralrepository.lib
+
+DOCUMENT    bld.inf
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/group/DrmRightsInfo.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2006-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:  Project definition file for DRM Rights Info
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          DrmRightsInfo.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x10282E24
+
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+#ifdef __DRM
+SOURCE          ../src/DrmRightsInfo.cpp
+#endif
+
+
+USERINCLUDE     ../inc      // subsystem level inc dir
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         flogger.lib
+
+
+LIBRARY         caf.lib
+LIBRARY         cafutils.lib
+LIBRARY         efsrv.lib       // RFile
+LIBRARY         drmdcf.lib      // COma1Dcf
+LIBRARY         drmrightsinfoimpl.lib
+LIBRARY         drmutility.lib
+
+DOCUMENT    bld.inf
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/group/DrmRightsInfoImpl.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2006-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:  Project definition file for DrmRightsInfoImpl
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          DrmRightsInfoImpl.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x10282E25
+
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+#ifdef __DRM
+SOURCE          ../src/DrmRightsInfoImpl.cpp
+SOURCE          ../src/DrmRightsInfoData.cpp
+#endif
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+ 
+LIBRARY         euser.lib
+LIBRARY         flogger.lib
+
+LIBRARY         drmserverinterfaces.lib
+LIBRARY         caf.lib
+LIBRARY         cafutils.lib
+LIBRARY         charconv.lib
+LIBRARY         drmutilitycommon.lib
+
+DOCUMENT    bld.inf
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/group/DrmUtilityDmgrWrapper.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,75 @@
+/*
+* 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:  Project definition file for DrmUtilityDmgrWrapper
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET         DrmUtilityDmgrWrapper.dll
+TARGETTYPE     dll
+UID            0x1000008D 0x102830FE
+
+CAPABILITY     CAP_GENERAL_DLL
+VENDORID       VID_DEFAULT
+
+#ifdef __DRM
+SOURCE         ../src/DrmUtilityDmgrWrapper.cpp
+#endif
+
+START RESOURCE ../data/DrmUtilityDmgrWrapper.rss
+HEADER
+TARGETPATH RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+USERINCLUDE    ../inc
+USERINCLUDE    ../../../omadrm/drmengine/roap/inc
+USERINCLUDE    ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY        euser.lib
+LIBRARY        centralrepository.lib
+LIBRARY        cmmanager.lib
+LIBRARY        downloadmgr.lib
+LIBRARY        roaphandler.lib
+LIBRARY        efsrv.lib
+LIBRARY        avkon.lib
+LIBRARY        commonengine.lib
+LIBRARY        eikctl.lib
+LIBRARY        platformenv.lib
+
+DEBUGLIBRARY   flogger.lib
+
+START WINS
+END
+
+START MARM
+END
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006 - 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:  Project definition for DRM Utility
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT -ARMI
+
+PRJ_EXPORTS
+../loc/DRMUtility.loc MW_LAYER_LOC_EXPORT_PATH( drmutility.loc )
+
+
+PRJ_MMPFILES
+
+DRMUtility.mmp
+
+drmutilitycommon.mmp
+#if (defined __WINDOWS_MEDIA_DRM)
+drmutilitywmdrmwrapper.mmp
+#endif // __WINDOWS_MEDIA_DRM
+DrmUtilityDmgrWrapper.mmp
+DRMUiHandlingImpl.mmp
+DRMAutomatedUsageImpl.mmp
+DrmRightsInfoImpl.mmp
+
+DRMUiHandling.mmp
+DRMAutomatedUsage.mmp
+DrmRightsInfo.mmp
+
+
+PRJ_TESTMMPFILES
+
+PRJ_MMPFILES
+
+//  End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/group/drmutilitycommon.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2006-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:  Project definition file for DRM Utility Common functions
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          drmutilitycommon.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x10283302
+
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+#ifdef __DRM
+SOURCE          ../src/drmutilitycommon.cpp
+SOURCE          ../src/drmutilityui.cpp
+SOURCE          ../src/drmutilitywmdrm.cpp
+SOURCE          ../src/DrmUtilityGlobalNoteWrapper.cpp
+SOURCE          ../src/DrmUtilityInfoNoteWrapper.cpp
+#endif
+
+START RESOURCE ../data/drmutility.rss
+HEADER
+TARGETPATH RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END  // RESOURCE
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../omadrm/drmengine/server/inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib // RFile
+LIBRARY         bafl.lib
+LIBRARY         caf.lib // CAF
+LIBRARY         cone.lib // Control environment
+LIBRARY         avkon.lib // Avkon
+LIBRARY         commonengine.lib // RConeResourceLoader, StringLoader
+LIBRARY         estor.lib // Cover Display
+LIBRARY         mediatorclient.lib
+LIBRARY         featmgr.lib // Feature Manager
+LIBRARY         platformenv.lib // Platform Environment
+LIBRARY         eikdlg.lib
+LIBRARY         aknnotify.lib
+LIBRARY         drmrights.lib // Permission, Constraint
+LIBRARY         drmserverinterfaces.lib // DrmClockClient, DrmRightsClient
+
+DOCUMENT    bld.inf
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/group/drmutilitywmdrmwrapper.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2006 - 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:  Project definition file for DRM Utility WM Drm Wrapper
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          drmutilitywmdrmwrapper.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x10283301
+
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+#ifdef __DRM
+SOURCE          ../src/drmutilitywmdrmwrapper.cpp
+SOURCE          ../src/drmutilitywmdrmutilities.cpp
+#endif
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../omadrm/drmengine/server/inc
+USERINCLUDE     ../../../inc
+
+// Default system include paths for application layer modules.
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY         aknnotify.lib
+LIBRARY         apparc.lib // for launching rights mgr ui embedded
+LIBRARY         euser.lib
+LIBRARY         avkon.lib
+LIBRARY         caf.lib     // CAF
+LIBRARY         cafutils.lib // CRightsInfo
+LIBRARY         efsrv.lib   // RFile
+LIBRARY         apgrfx.lib
+LIBRARY         ws32.lib
+LIBRARY         centralrepository.lib
+LIBRARY         cmmanager.lib
+LIBRARY         drmutilitycommon.lib // Common utility
+LIBRARY         servicehandler.lib
+LIBRARY         drmserverinterfaces.lib // DrmClockClient
+LIBRARY         drmrights.lib
+
+DOCUMENT    bld.inf
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/DrmAutomatedUsageImpl.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,672 @@
+/*
+* 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:  Implementation class of DRM Automated Usage API
+*
+*/
+
+
+#ifndef CDRMAUTOMATEDUSAGEIMPL_H
+#define CDRMAUTOMATEDUSAGEIMPL_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <caf/caftypes.h>
+#include <caf/data.h>
+#include <drmrightsclient.h>
+#include <drmautomatedusage.h>
+#include <drmautomatedusageobserver.h>
+
+#include "rdrmhelperclient.h"
+#include "drmqueue.h"
+
+//forward declarations
+class CDRMConstraint;
+
+namespace DRM
+{
+class CDrmAutomatedUsageData;
+class CDrmUtility;
+class CDrmUtilityUI;
+
+/**
+*  Utility class for DRM related automated usage handling
+*
+*  This is implementation class for interface DRM::DrmAutomatedUsage.
+*  This is only used via class DRM::DrmAutomatedUsage
+*
+*  @lib drmautomatedusageimpl.lib
+*  @since S60 5.0
+*/
+NONSHARABLE_CLASS( CDrmAutomatedUsageImpl ) : public CActive
+    {
+
+public:
+
+    /** Automated usage states */
+    enum TState
+        {
+        EInit,
+        EHandeError,
+        ESetAutomated,
+        EReady,
+        EComplete
+        };
+
+public:
+
+    IMPORT_C static CDrmAutomatedUsageImpl* NewL( CCoeEnv* aCoeEnv,
+                                                  CDrmUtility* aDrmUtility );
+
+    IMPORT_C static CDrmAutomatedUsageImpl* NewLC( CCoeEnv* aCoeEnv,
+                                                   CDrmUtility* aDrmUtility );
+
+    virtual ~CDrmAutomatedUsageImpl();
+
+    /**
+    * Checks if given content can be set as an automated content.
+    *
+    * @since  S60 5.0
+    *
+    * @param[in]   aFile           file handle to the file
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   AutomatedType   Usage intention of the automated content
+    *
+    * @return ETrue if the content can be set as automated content
+    *         EFalse if the content can't be set as automated content
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see RFile
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C TBool CanSetAutomatedL(
+        RFile& aFile,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType );
+
+
+    /**
+    * Checks if given content can be set as an automated content.
+    *
+    * @since  S60 5.0
+    *
+    * @param[in]   aData           CData object to the protected content
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   AutomatedType   Usage intention of the automated content
+    *
+    * @return ETrue if the content can be set as automated content
+    *         EFalse if the content can't be set as automated content
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C TBool CanSetAutomatedL(
+        const ContentAccess::CData& aData,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType );
+
+
+    /**
+    * Registers given content to be used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aFile           file handle to the file
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see RFile
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::TDrmAutomatedServiceType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C void SetAutomatedL(
+        RFile& aFile,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Registers given content to be used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aFile           file handle to the file
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aObserver       Async callback observer
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see RFile
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::MDrmAsyncObserver
+    * @see DRM::TDrmAutomatedServiceType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C TInt SetAutomatedAsyncL(
+        RFile& aFile,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver& aObserver,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Registers given content to be used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aData           CData object to the protected content
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::TDrmAutomatedServiceType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C void SetAutomatedL(
+        const ContentAccess::CData& aData,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Registers given content to be used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aData           CData object to the protected content
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aObserver       Async callback observer
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::MDrmAsyncObserver
+    * @see DRM::TDrmAutomatedServiceType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C TInt SetAutomatedAsyncL(
+        const ContentAccess::CData& aData,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver& aObserver,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aFile           file handle to the file
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see RFile
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::TDrmAutomatedServiceType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C void RemoveAutomatedL(
+        RFile& aFile,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aFile           file handle to the file
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]  aObserver       Async callback observer
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see RFile
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::MDrmAsyncObserver
+    * @see DRM::TDrmAutomatedServiceType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C TInt RemoveAutomatedAsyncL(
+        RFile& aFile,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver& aObserver,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aData           CData object to the protected content
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::TDrmAutomatedServiceType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C void RemoveAutomatedL(
+        const ContentAccess::CData& aData,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aData           CData object to the protected content
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aObserver       Async callback observer
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::MDrmAsyncObserver
+    * @see DRM::TDrmAutomatedServiceType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C TInt RemoveAutomatedAsyncL(
+        const ContentAccess::CData& aData,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver& aObserver,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aUniqueId       unique content id
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::TIntent
+    *
+    * @see ContentAccess::CData::GetStringAttribute()
+    * @see ContentAccess::TStringAttribute
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::TDrmAutomatedServiceType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C void RemoveAutomatedL(
+        const TDesC& aUniqueId,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aUniqueId       unique content id
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aObserver       Async callback observer
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData::GetStringAttribute()
+    * @see ContentAccess::TStringAttribute
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::MDrmAsyncObserver
+    * @see DRM::TDrmAutomatedServiceType
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C TInt RemoveAutomatedAsyncL(
+        const TDesC& aUniqueId,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver& aObserver,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Registers client to listen events related to automated usage. If
+    * the client doesn't do this, all the events are handled automatically
+    * according to the S60 style.
+    *
+    * The observer registered with this function needs to be unregistered
+    * before it is deleted.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]    aObserver
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see DRM::MDrmAutomatedUsageObserver
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C void RegisterEventObserverL(
+        MDrmAutomatedUsageObserver& aObserver );
+
+
+    /**
+    * Unregisters client from listening to events related to automated usage.
+    *
+    * If register event observer has been called, it must be unregistered
+    * before the observer object is deleted.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]    aObserver
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see DRM::MDrmAutomatedUsageObserver
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C void UnregisterEventObserverL(
+        MDrmAutomatedUsageObserver& aObserver );
+
+
+    /**
+    * Cancel an asyncronous operation
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aOperationId    identifier of the async operation
+    *                              to be cancelled
+    * @return KErrNotFound if the operation has already been executed
+    *         or it does not exist
+    *
+    * @see DRM::CDrmaAutomatedUsage
+    */
+    IMPORT_C TInt CancelOperation( TInt aOperationId );
+
+
+    /**
+    * Implementation for MDrmErrorHandling::HandleErrorAsyncL
+    *
+    * Handles DRM error situations related to invalid rights.
+    * This method displays appropriate notes, which observer can override,
+    * to the user and acquires new rights if needed. Asynchronous version,
+    * all errors are signalled using request status.
+    *
+    * @since S60 v5.0
+    * @param[in]   aFile       file for which the error happened
+    * @param[in]   aIntent     the CAF intent which was used to recieve
+    *                          the error
+    * @param[in]   aError      error code
+    * @param[in]   aObserver   reference to observer
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @see MDrmHandleErrorObserver
+    * @see MDrmErrorHandling
+    */
+    IMPORT_C TInt HandleErrorAsyncL(
+        RFile& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver& aObserver );
+
+    /**
+    * Implementation for MDrmErrorHandling::HandleErrorL
+    *
+    * Handles DRM error situations related to invalid rights.
+    * This method displays appropriate notes, which observer can override,
+    * to the user and acquires new rights if needed. Synchronous version,
+    * leaves in case of error.
+    *
+    * @since S60 5.0
+    * @param[in]   aFile       file for which the error happened
+    * @param[in]   aIntent     the CAF intent which was used to recieve
+    *                          the error
+    * @param[in]   aError      error code
+    * @param[in]   aObserver   pointer to observer, NULL if no observer
+    *
+    * @leave   KErrArgument    File is not DRM protected.
+    *
+    * @see MDrmHandleErrorObserver
+    * @see MDrmErrorHandling
+    */
+    IMPORT_C void HandleErrorL(
+        RFile& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver* aObserver );
+
+    /**
+    * Implementation for MDrmErrorHandling::HandleErrorAsyncL
+    *
+    * Handles DRM error situations related to invalid rights.
+    * This method displays appropriate notes, which observer can override,
+    * to the user and acquires new rights if needed. Asynchronous version,
+    * all errors are signalled using request status.
+    *
+    * @since S60 5.0
+    * @param[in]   aFile       content for which the error happened
+    * @param[in]   aIntent     the CAF intent which was used to recieve
+    *                          the error
+    * @param[in]   aError      error code
+    * @param[in]   aObserver   reference to observer
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @see MDrmHandleErrorObserver
+    * @see MDrmErrorHandling
+    */
+    IMPORT_C TInt HandleErrorAsyncL(
+        ContentAccess::CData& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver& aObserver );
+
+    /**
+    * Implementation for MDrmErrorHandling::HandleErrorL
+    *
+    * Handles DRM error situations related to invalid rights.
+    * This method displays appropriate notes, which observer can override,
+    * to the user and acquires new rights if needed. Synchronous version,
+    * leaves in case of error.
+    *
+    * @since S60 5.0
+    * @param[in]   aFile       content for which the error happened
+    * @param[in]   aIntent     the CAF intent which was used to recieve
+    *                          the error
+    * @param[in]   aError      error code
+    * @param[in]   aObserver   pointer to observer, NULL if no observer
+    *
+    * @leave   KErrArgument    File is not DRM protected.
+    *
+    * @see MDrmHandleErrorObserver
+    * @see MDrmErrorHandling
+    */
+    IMPORT_C void HandleErrorL(
+        ContentAccess::CData& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver* aObserver );
+
+
+protected: // Functions from base classes
+
+    /**
+    * From CActive Cancels async request.
+    */
+    void DoCancel();
+
+    /**
+    * From CActive Called when async request completes.
+    */
+    void RunL();
+
+
+    /**
+    * From CActive Called if RunL leaves
+    */
+    TInt RunError( TInt aError );
+	    
+
+private: // Member functions
+
+    CDrmAutomatedUsageImpl( CCoeEnv* aCoeEnv,
+                            CDrmUtility* aDrmUtility );
+
+    void ConstructL();
+    
+    void Activate( TRequestStatus*& aStatus );
+
+    // Checks whether there exists suitable oma RO for automated use
+    TBool DoCanSetAutomatedL(
+        const TDesC8& aUniqueId8,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        const TBool aUseQueries = EFalse );
+
+    // Additional RO checks tor theme.
+    TBool DoCanSetAutomatedThemeL( const TDesC8& aUniqueId8 );
+
+
+    TInt DoSetAutomatedL( CDrmAutomatedUsageData* aAutomatedUsageData );
+
+
+    TInt DoRemoveAutomated( CDrmAutomatedUsageData* aAutomatedUsageData );
+
+
+private: // Data members
+
+    // Oma Drm client
+    RDRMRightsClient iOmaClient;
+
+    // WM Drm Client
+    // RWMDrmClient iWmClient;
+
+    // own
+    RDrmHelperClient iDrmHelperClient;
+
+    // not own
+    MDrmAutomatedUsageObserver* iAuObserver;
+
+    // not own
+    CCoeEnv* iCoeEnv;
+
+    // not own
+    CDrmUtility* iDrmUtility;
+
+    // own
+    CDrmQueue< CDrmAutomatedUsageData >* iDrmQueue;
+
+    // own
+    CDrmUtilityUI* iDrmUtilityUi;
+
+	 // Async observer and current operation id for async operations
+	 // not own
+    MDrmAsyncObserver* iObserver;
+	 // not own
+    TInt iOperationId;
+    };
+}
+
+#endif // CDrmAutomatedUsageImpl_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/DrmQueue.h	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  DRM Queue
+*
+*/
+
+
+#ifndef CDRMQUEUE_H
+#define CDRMQUEUE_H
+
+//*** system include files go here:
+#include <e32base.h>
+
+//*** user include files go here:
+
+//*** forward declarations go here:
+
+//*** constants go here:
+
+namespace DRM
+{
+ /**
+  *  DRM Queue
+  *
+  *
+  *
+  *  @lib drmutility.lib
+  *  @since S60 v4.0
+  */
+template< class C > class CDrmQueue : public CBase
+    {
+
+public:
+
+    /**
+    * Construction function
+    */
+    static CDrmQueue<C>* NewLC();
+
+    /**
+    * Construction function
+    */
+    static CDrmQueue<C>* NewL();
+
+
+    /**
+    * Destructor.
+    */
+    ~CDrmQueue();
+
+    /**
+    * C++ default constructor.
+    */
+    CDrmQueue();
+
+    /**
+    * Checks the rights and their status for a specific unique id
+    * implementation
+    *
+    * @param[in]   aData : a pointer to the data object
+    */
+    void AppendToQueueL( C* aData );
+
+
+
+    /**
+    * Checks the rights and their status for a specific unique id
+    * implementation
+    *
+    * @return pointer to popped data.
+    */
+    C* PopFront();
+
+    /**
+    * Checks 
+    * implementation
+    * @param[in]   aId : ID representing data to be popped from queue
+    * @return      Pointer to data object in queue, NULL if not found 
+    * 
+    */
+    C* PopItem( TInt aId );
+
+private:
+
+
+
+    /**
+    * 2nd phase constructor.
+    */
+    void ConstructL();
+
+
+    struct QueueData
+        {
+        C* iData;
+        QueueData* iNext;
+        };
+
+
+
+    // Operation Queue:
+    QueueData* iFirst;
+    QueueData* iLast;
+
+    // To prevent queue handling from being messed up by threads
+    RSemaphore iSemaphore;
+    };
+}
+
+// Since it's a template class include the implementation
+#include "drmqueue.inl"
+
+#endif // CDRMAUTOMATEDUSAGE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/DrmRightsInfoData.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2006-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:  Data class for async operations in DrmRightInfoImpl -class 
+*
+*/
+
+
+#ifndef CDRMRIGHTSINFODATA_H
+#define CDRMRIGHTSINFODATA_H
+
+//*** system include files go here:
+#include <e32base.h>
+#include <caf/caftypes.h>
+#include <drmutilitytypes.h>
+
+namespace DRM 
+{
+
+    //*** Forward declaration
+    class MDrmAsyncObserver;
+
+ /**
+  *  DRM Rights Info Data storage class
+  *
+  *  @lib drmrightsinfoimpl.lib
+  *  @since S60 v5.0
+  */
+NONSHARABLE_CLASS( CDrmRightsInfoData ) : public CBase
+    {
+
+public: // Members
+
+    /**
+    * Creates a new CDrmRightsInfoData -object
+    *
+    * @since S60 5.0
+    * @return A functional CDrmRightsInfoData -object
+    * @leave System wide or DRM specific error code
+    */
+    static CDrmRightsInfoData* NewL();
+
+
+    /**
+    * Creates a new CDrmRightsInfoData -object and leaves
+    * it into the cleanup stack
+    *
+    * @since S60 5.0
+    * @return A functional CDrmRightsInfoData -object
+    * @leave System wide or DRM specific error code
+    */    
+    static CDrmRightsInfoData* NewLC();
+   
+    /**
+    * Destructor.
+    */	
+    ~CDrmRightsInfoData();
+
+public: // Variables:
+    // Operation request status
+    MDrmAsyncObserver* iObserver;
+    
+    // Operation id
+    TInt iOperationId;
+
+    // Operation code
+    TInt iOperation;
+
+    // The content id requested as 16 bit descriptor
+    HBufC16* iUniqueId;
+
+    // The content id requested as 8 bit descriptor, this exists if it's
+    // required by the operation
+    HBufC8* iUniqueId8;
+
+    // Intent
+    ContentAccess::TIntent iIntent;
+    
+    // Details
+    TDrmRightsInfo* iDetails;
+    
+    // Queue Pointer:
+    CDrmRightsInfoData* iNext;
+
+private:
+
+	/**
+    * C++ default constructor.
+    */
+    CDrmRightsInfoData();
+
+    /**
+    * 2nd phase constructor
+    */
+    void ConstructL();
+ 
+    };
+}
+
+
+#endif // CDRMRIGHTSINFODATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/DrmRightsInfoImpl.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2006-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:  Implementation class of DRM Rights Info API
+*
+*/
+
+
+#ifndef CDRMRIGHTSINFOIMPL_H
+#define CDRMRIGHTSINFOIMPL_H
+
+//*** system include files go here:
+#include <e32base.h>
+#include <f32file.h>
+#include <caf/caftypes.h> 
+#include <drmrightsclient.h>
+#include <drmutilitytypes.h>
+
+namespace DRM 
+{
+    //*** Forward declarations
+    class CDrmRightsInfoData;
+    class MDrmAsyncObserver;
+    class CDrmUtilityCommon;
+    
+ /**
+  *  Utility class for DRM related rights information handling
+  *
+  *  @lib drmrightsinfoimpl.lib
+  *  @since S60 v5.0
+  */
+NONSHARABLE_CLASS( CDrmRightsInfoImpl ) : public CActive
+    {
+
+public:
+	
+    IMPORT_C static CDrmRightsInfoImpl* NewL();
+
+    IMPORT_C static CDrmRightsInfoImpl* NewLC();
+
+    virtual ~CDrmRightsInfoImpl();
+
+
+    /**
+     * Checks the rights and their status for a specific unique id
+     *
+     * @param[in]   aUniqueId : The unique identifier or the content
+     * @param[in]   aIntent : The intent for the rights to check
+     * @param[out]  aDetails : Details of the rights status 
+     * @return none
+     * @leave System wide error code
+     */	
+    IMPORT_C void CheckRightsL( 
+        const TDesC& aUniqueId, 
+        ContentAccess::TIntent aIntent,
+        TDrmRightsInfo& aDetails );
+
+    /**
+     * Checks the rights and their status for a specific unique id
+     *
+     * @param[in]   aUniqueId   The unique identifier or the content
+     * @param[in]   aIntent     The intent for the rights to check
+     * @param[out]  aDetails    Details of the rights status 
+     * @param[in]   aObserver   Observer which gets reported of
+     *                          the async operation
+     *
+     * @return Operation identifier
+     *
+     * @leave System wide error code
+     */	
+    IMPORT_C TInt CheckRightsAsyncL( 
+        const TDesC& aUniqueId, 
+        ContentAccess::TIntent aIntent,
+        TDrmRightsInfo& aDetails,
+        MDrmAsyncObserver& aObserver );
+
+
+    /**
+     * Cancel an asyncronous operation
+     *
+     * @since S60 v5.0
+     * @param[in]   aOperationId    identifier of the async operation
+     *                              to be cancelled      
+     * @return KErrNotFound if the operation has already been executed
+     *         or it does not exist
+     */
+    IMPORT_C TInt CancelOperation( TInt aOperationId ); 
+    
+
+public: // From base classes
+
+
+protected: // Functions from base classes
+        
+    /**
+    * From CActive Cancels async request.
+    */
+    void DoCancel();
+
+    /**
+    * From CActive Called when async request completes.
+    */
+    void RunL();
+
+    /**
+    * From CActive Called when RunL leaves
+    */
+ 	TInt RunError( TInt aError );
+
+private:
+
+    CDrmRightsInfoImpl();
+
+    void ConstructL();
+
+    void PerformCheckRightsL( CDrmRightsInfoData& aData );
+
+    void AppendToQueue( CDrmRightsInfoData* aData );
+    
+    CDrmRightsInfoData* PopFront();
+
+
+private: // Data members
+
+    // DrmUtilityCommon
+    CDrmUtilityCommon* iDrmUtilityCommon;
+    
+    // Oma Drm client
+    RDRMRightsClient iOmaClient;
+    
+    // WM Drm Client
+    // RWMDrmClient iWmClient;
+    
+    // current request status:
+    MDrmAsyncObserver* iObserver;
+    TInt iOperationId;
+    
+    // Operation Queue:
+    CDrmRightsInfoData* iFirst;
+    CDrmRightsInfoData* iLast;
+    
+    // To prevent queue handling from being messed up by threads
+    RSemaphore iSemaphore;
+    };
+    
+}
+
+#endif // CDRMRIGHTSINFOIMPL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/DrmUiHandlingImpl.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,888 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation class of DRM UI Handling
+*
+*/
+
+
+#ifndef C_CDRMUIHANDLINGIMPL_H
+#define C_CDRMUIHANDLINGIMPL_H
+
+//*** system include files go here:
+#include <e32base.h>
+#include <f32file.h>
+#include <aknserverapp.h>
+#include <caf/caftypes.h>
+#include <caf/caferr.h>
+#include <drmagents.h>
+#include <drmrightsclient.h>
+#include <drmutilitytypes.h>
+
+//*** forward declarations go here:
+class CCoeEnv;
+class CDRMConstraint;
+class CSchemeHandler;
+
+namespace ContentAccess
+    {
+    class CData;
+    }
+
+namespace DRM
+{
+
+    //*** forward declarations go here:
+    class CDrmUtility;
+    class CDrmUiHandlingData;
+    class CDrmUtilityCommon;
+    class CDrmUtilityUI;
+    class MDrmAsyncObserver;
+    class MDrmUiCheckRightsObserver;
+    class MDrmHandleErrorObserver;
+    class MDrmUtilityWMDrmWrapper;
+    class CDrmUtilityWMDrm;
+
+/**
+ *  Implementation class for CDrmUiHandling class
+ *
+ *  @lib drmuihandlingimpl.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CDrmUiHandlingImpl ) : public CActive, public MAknServerAppExitObserver
+    {
+
+public:
+
+    /** Error codes that are handled by HandleError */
+    enum TDrmUiError
+        {
+        ENoPermission = KErrCANoPermission,
+        ENoRights = KErrCANoRights,
+        EPendingRights = KErrCAPendingRights
+        };
+
+public:
+
+    /**
+    * Two-phased constructor.
+    */
+    IMPORT_C static CDrmUiHandlingImpl* NewL( CDrmUtility* aDrmUtility, CCoeEnv* aCoeEnv = NULL );
+    IMPORT_C static CDrmUiHandlingImpl* NewLC( CDrmUtility* aDrmUtility, CCoeEnv* aCoeEnv = NULL );
+
+    /**
+     * Destructor.
+     */
+    virtual ~CDrmUiHandlingImpl();
+
+    /**
+     * Check how much rights there are left for the content.
+     * This method also displays appropriate notes, which observer can
+     * override, if rights are invalid. Asynchronous version, all errors
+     * are signalled using request status.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file of which rights are checked.
+     * @param[in]   aIntent     the CAF intent to be used for checking
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave System wide error code
+     *        KErrArgument  if file is not DRM protected.
+     *
+     * @see MDrmUiCheckRightsObserver
+     */
+    IMPORT_C TInt CheckRightsAmountAsyncL(
+        RFile& aFile,
+        ContentAccess::TIntent aIntent,
+        MDrmUiCheckRightsObserver& aObserver );
+
+     /**
+     * Check how much rights there are left for the content.
+     * This method also displays appropriate notes, which observer can
+     * override, if rights are invalid. Synchronous version, leaves in case
+     * of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file of which rights are checked.
+     * @param[in]   aIntent     the CAF intent to be used for checking
+     * @param[in]   aObserver   pointer to observer, NULL if no observer
+     *
+     * @return none
+     * @leave System wide error code
+     *        KErrArgument  if file is not DRM protected.
+     *
+     * @see MDrmUiCheckRightsObserver
+     */
+    IMPORT_C void CheckRightsAmountL(
+        RFile& aFile,
+        ContentAccess::TIntent aIntent,
+        MDrmUiCheckRightsObserver* aObserver );
+
+    /**
+     * Check how much rights there are left for the content.
+     * This method also displays appropriate notes, which observer can
+     * override, if rights are invalid. Asynchronous version, all errors
+     * are signalled using request status.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content of which rights are checked.
+     * @param[in]   aIntent     the CAF intent to be used for checking
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave System wide error code
+     *        KErrArgument  if file is not DRM protected.
+     *
+     * @see MDrmUiCheckRightsObserver
+     */
+    IMPORT_C TInt CheckRightsAmountAsyncL(
+        ContentAccess::CData& aFile,
+        ContentAccess::TIntent aIntent,
+        MDrmUiCheckRightsObserver& aObserver );
+
+     /**
+     * Check how much rights there are left for the content.
+     * This method also displays appropriate notes, which observer can
+     * override, if rights are invalid. Synchronous version, leaves in case
+     * of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content of which rights are checked.
+     * @param[in]   aIntent     the CAF intent to be used for checking
+     * @param[in]   aObserver   pointer to observer, NULL if no observer
+     * @return none
+     * @leave System wide error code
+     *        KErrArgument  if file is not DRM protected.
+     *
+     * @see MDrmUiCheckRightsObserver
+     */
+    IMPORT_C void CheckRightsAmountL(
+        ContentAccess::CData& aFile,
+        ContentAccess::TIntent aIntent,
+        MDrmUiCheckRightsObserver* aObserver );
+
+    /**
+     * Displays information about rights for given content.
+     * Asynchronous version.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           file for which rights details are
+     *                              displayed.
+     * @param[in]   aObserver       reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave   System wide error code
+     */
+    IMPORT_C TInt ShowDetailsViewAsyncL(
+        RFile& aFile,
+        MDrmAsyncObserver& aObserver );
+
+    /**
+     * Displays information about rights for given content.
+     * Synchronous version, leaves in case of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file for which rights details are
+     *                          displayed.
+     *
+     * @leave   KErrArgument    File is not DRM protected.
+     * @leave   KErrCANoRights  Rights object does not exist.
+     *
+     * @see caferr.h
+     */
+    IMPORT_C void ShowDetailsViewL(
+        RFile& aFile );
+
+    /**
+     * Displays information about rights for given content.
+     * Asynchronous version.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content for which rights details are
+     *                          displayed.
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave System wide error code
+     */
+    IMPORT_C TInt ShowDetailsViewAsyncL(
+        ContentAccess::CData& aFile,
+        MDrmAsyncObserver& aObserver );
+
+     /**
+     * Displays information about rights for given content.
+     * Synchronous version, leaves in case of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile   content for which rights details are displayed.
+     *
+     * @leave   KErrArgument    Content is not DRM protected.
+     * @leave   KErrCANoRights  Rights object does not exist.
+     * @leave   System wide error code
+     *
+     * @see caferr.h
+     */
+    IMPORT_C void ShowDetailsViewL(
+        ContentAccess::CData& aFile );
+
+     /**
+     * Handle the specific url defined by the file, such as InfoUrl
+     * Asynchronous method
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           file whose url is being handled
+     * @param[in]   aType           type of the requested url,
+     *                              only a single url may be requested
+     *                              at a time
+     * @param[in]   aObserver       reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave   KErrArgument        File is not DRM protected.
+     * @leave   KErrNotSupported    Url type is not supported for the file
+     */
+    IMPORT_C TInt HandleUrlAsyncL(
+        RFile& aFile,
+        TDrmUiUrlType aType,
+        MDrmAsyncObserver& aObserver );
+
+
+     /**
+     * Handle the specific url defined by the file, such as InfoUrl
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile        file whose url is being handled
+     * @param[in]   aType        type of the requested url,
+     *                           only a single url may be requested
+     *                           at a time
+     *
+     * @leave   KErrArgument     File is not DRM protected.
+     * @leave   KErrNotSupported Url type is not supported for the file
+     */
+    IMPORT_C void HandleUrlL(
+        RFile& aFile,
+        TDrmUiUrlType aType );
+
+     /**
+     * Handle the specific url defined by the file, such as InfoUrl
+     * Asynchronous method
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           content whose url is being handled
+     * @param[in]   aType           type of the requested url,
+     *                              only a single url may be requested
+     *                              at a time
+     * @param[in]   aObserver       reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave   KErrArgument        File is not DRM protected,
+     *                              or multiple url:s were requested
+     * @leave   KErrNotSupported    Url type is not supported for the file
+     */
+    IMPORT_C TInt HandleUrlAsyncL(
+        ContentAccess::CData& aFile,
+        TDrmUiUrlType aType,
+        MDrmAsyncObserver& aObserver );
+
+     /**
+     * Handle the specific url defined by the file, such as InfoUrl
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile        content whose url is being handled
+     * @param[in]   aType        type of the requested url,
+     *                           only a single url may be requested
+     *                           at a time
+     *
+     * @leave   KErrArgument     File is not DRM protected.
+     * @leave   KErrNotSupported Url type is not supported for the file
+     */
+    IMPORT_C void HandleUrlL(
+        ContentAccess::CData& aFile,
+        TDrmUiUrlType aType );
+
+
+     /**
+     * Get information of the available urls
+     * Asynchronous method
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           file whose url is being handled
+     * @param[out]  aType           A bitmask of the supported url types
+     * @param[in]   aObserver       reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave   KErrArgument        File is not DRM protected.
+     */
+    IMPORT_C TInt AvailableUrlsAsyncL(
+        RFile& aFile,
+        TDrmUiUrlType& aType,
+        MDrmAsyncObserver& aObserver );
+
+     /**
+     * Get information of the available urls
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           file whose url is being handled
+     * @param[out]  aType           A bitmask of the supported url types
+     *
+     * @leave   KErrArgument        File is not DRM protected.
+     */
+    IMPORT_C void AvailableUrlsL(
+        RFile& aFile,
+        TDrmUiUrlType& aType );
+
+
+     /**
+     * Get information of the available urls
+     * Asynchronous method
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           content whose url is being handled
+     * @param[out]  aType           A bitmask of the supported url types
+     * @param[in]   aObserver       reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave   KErrArgument        File is not DRM protected.
+     */
+    IMPORT_C TInt AvailableUrlsAsyncL(
+        ContentAccess::CData& aFile,
+        TDrmUiUrlType& aType,
+        MDrmAsyncObserver& aObserver );
+
+     /**
+     * Get information of the available urls
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           content whose url is being handled
+     * @param[out]  aType           A bitmask of the supported url types
+     *
+     * @leave   KErrArgument        File is not DRM protected.
+     */
+    IMPORT_C void AvailableUrlsL(
+        ContentAccess::CData& aFile,
+        TDrmUiUrlType& aType );
+
+
+    /**
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override,
+     * to the user and acquires new rights if needed. Asynchronous version,
+     * all errors are signalled using request status.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve
+     *                          the error
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @see MDrmHandleErrorObserver
+     */
+    IMPORT_C TInt HandleErrorAsyncL(
+        RFile& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver& aObserver );
+
+     /**
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override,
+     * to the user and acquires new rights if needed. Synchronous version,
+     * leaves in case of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve
+     *                          the error
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   pointer to observer, NULL if no observer
+     *
+     * @leave   KErrArgument    File is not DRM protected.
+     *
+     * @see MDrmHandleErrorObserver
+     */
+    IMPORT_C void HandleErrorL(
+        RFile& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver* aObserver );
+
+    /**
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override,
+     * to the user and acquires new rights if needed. Asynchronous version,
+     * all errors are signalled using request status.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve
+     *                          the error
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @see MDrmHandleErrorObserver
+     */
+    IMPORT_C TInt HandleErrorAsyncL(
+        ContentAccess::CData& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver& aObserver );
+
+    /**
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override,
+     * to the user and acquires new rights if needed. Synchronous version,
+     * leaves in case of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve
+     *                          the error
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   pointer to observer, NULL if no observer
+     *
+     * @leave   KErrArgument    File is not DRM protected.
+     *
+     * @see MDrmHandleErrorObserver
+     */
+    IMPORT_C void HandleErrorL(
+        ContentAccess::CData& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver* aObserver );
+
+
+    /**
+     * Cancel an asyncronous operation
+     *
+     * @since S60 v5.0
+     * @param[in]   aOperationId    identifier of the async operation
+     *                              to be cancelled
+     * @return KErrNotFound if the operation has already been executed
+     *         or it does not exist
+     */
+    IMPORT_C TInt CancelOperation( TInt aOperationId );
+
+public: //From base classes
+
+
+protected: // Functions from base classes
+
+    /**
+    * From CActive Cancels async request.
+    */
+    void DoCancel();
+
+    /**
+    * From CActive Called when async request completes.
+    */
+	void RunL();
+
+    /**
+    * From CActive Called when RunL leaves
+    */
+	TInt RunError( TInt aError );
+
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CDrmUiHandlingImpl( CDrmUtility* aDrmUtility, CCoeEnv* aCoeEnv );
+
+    void ConstructL();
+
+    void Activate( TRequestStatus*& aStatus );
+
+    void PerformCheckRightsAmountFileL( CDrmUiHandlingData& aData );
+
+    void PerformCheckRightsAmountDataL( CDrmUiHandlingData& aData );
+
+    void PerformShowDetailsViewFileL( CDrmUiHandlingData& aData );
+
+    void PerformShowDetailsViewDataL( CDrmUiHandlingData& aData );
+
+    void PerformHandleUrlFileL( CDrmUiHandlingData& aData );
+
+    void PerformHandleUrlDataL( CDrmUiHandlingData& aData );
+
+    void PerformAvailableUrlsFileL( CDrmUiHandlingData& aData );
+
+    void PerformAvailableUrlsDataL( CDrmUiHandlingData& aData );
+
+    void PerformHandleErrorFileL( CDrmUiHandlingData& aData );
+
+    void PerformHandleErrorDataL( CDrmUiHandlingData& aData );
+
+    void IsProtectedL( RFile& aFile, TPtrC& aAgent );
+
+    void IsProtectedL( ContentAccess::CData* aContent,
+                       TDrmAgentUid& aAgentUid );
+
+    void IsProperErrorL( TInt aError );
+
+    void CheckOmaRightsAmountL( ContentAccess::CData& aContent,
+                                ContentAccess::TIntent aIntent,
+                                MDrmUiCheckRightsObserver* aObserver,
+                                TInt aOperationId );
+
+    void DoCheckOmaRightsAmountL( ContentAccess::CData& aContent,
+                                  HBufC8*& aContentUri,
+                                  ContentAccess::TIntent aIntent,
+                                  const HBufC* aRightsUrl,
+                                  TDrmUiUrlType aUrlType,
+                                  const HBufC8* aSilentUrl,
+                                  MDrmUiCheckRightsObserver* aObserver,
+                                  TInt aOperationId );
+
+    void HandleOmaErrorL( ContentAccess::CData& aContent,
+                          ContentAccess::TIntent aIntent,
+                          TInt aError,
+                          MDrmHandleErrorObserver* aObserver,
+                          TInt aOperationId );
+
+
+    void CheckOmaBasedRightsAmountL( ContentAccess::CData& aContent,
+                                     ContentAccess::TIntent aIntent,
+                                     MDrmUiCheckRightsObserver* aObserver,
+                                     TInt aOperationId );
+
+    void DoCheckOmaBasedRightsAmountL( ContentAccess::CData& aContent,
+                                       const HBufC8* aContentUri,
+                                       ContentAccess::TIntent aIntent,
+                                       const HBufC* aRightsUrl,
+                                       TDrmUiUrlType aUrlType,
+                                       MDrmUiCheckRightsObserver* aObserver,
+                                       TInt aOperationId );
+
+    void GetOmaBasedEndTimeL( ContentAccess::CData& aData, TTime& aEndTime );
+
+    TInt OmaBasedHeaderParserL( TInt aOffset, TPtr8 aHeaderPtr, TTime& aEndTime );
+
+    void ShowDetailsViewL( const HBufC8* aContentId,
+                           const HBufC* aFullPath );
+
+    void ShowDetailsViewL( const HBufC* aFullPath );
+
+    void DoHandleOmaUrlL( ContentAccess::CData& aContent,
+                          TDrmUiUrlType aType );
+
+    void GetAvailableOmaUrlsL( ContentAccess::CData& aContent,
+                               TDrmUiUrlType& aType );
+
+    TInt GetContentIdLC( const ContentAccess::CData& aContent,
+                         HBufC8*& aId );
+
+    TInt GetOmaRightsIssuerLC( const ContentAccess::CData& aContent,
+                              HBufC*& aIssuer );
+
+    TInt GetOmaDomainRightsIssuerLC( const ContentAccess::CData& aContent,
+                                    HBufC*& aIssuer );
+
+    TInt GetOmaPreviewInfoLC( const ContentAccess::CData& aContent,
+                             HBufC*& aPreviewUrl,
+                             TInt& aPreviewType );
+
+    TInt GetOmaSilentRightsUrlLC( const ContentAccess::CData& aContent,
+                                  HBufC8*& aSilentUrl );
+
+    TInt GetOmaInfoUrlLC( const ContentAccess::CData& aContent,
+                         HBufC*& aInfoUrl );
+
+    TInt GetOmaPendingRightsInfoLC( const ContentAccess::CData& aContent,
+                                   HBufC*& aEta );
+
+    TInt GetContentLocationLC( const ContentAccess::CData& aContent,
+                               HBufC*& aPath );
+
+    void SelectOmaRightsUrlL( const ContentAccess::CData& aContent,
+                              const HBufC* aDomainRiUrl,
+                              TDrmUiUrlType& aUrlType );
+
+    void CallRightsNotValidL( MDrmUiCheckRightsObserver* aObserver,
+                              TInt aOperationId,
+                              TCheckRightsStatus aRightsStatus,
+                              TUint32 aReason,
+                              ContentAccess::CData& aContent,
+                              const HBufC8* aContentUri,
+                              CDRMConstraint* aConstraint,
+                              const HBufC* aRightsUrl,
+                              TDrmUiUrlType aUrlType,
+                              const HBufC8* aSilentUrl,
+                              ContentAccess::TIntent aIntent );
+
+    void CallRightsLeftL( MDrmUiCheckRightsObserver* aObserver,
+                          TInt aOperationId,
+                          TBool aUnconstrained,
+                          TTimeIntervalSeconds aTime,
+                          TInt aCounts,
+                          TTimeIntervalSeconds aAccumulated,
+                          const HBufC8* aContentUri,
+                          const HBufC* aRightsUrl,
+                          const HBufC8* aSilentUrl,
+                          CData& aData,
+                          ContentAccess::TIntent aIntent );
+
+    void CallEmbeddedPreviewAvailableL( MDrmHandleErrorObserver* aObserver,
+                                        TInt aOperationId,
+                                        ContentAccess::CData& aContent,
+                                        const HBufC* aPreviewUrl,
+                                        TDrmRightsInfo aRightsStatus,
+                                        TUint32 aReason,
+                                        const HBufC* aRightsUrl,
+                                        const HBufC8* aContentUri,
+                                        ContentAccess::TIntent aIntent );
+
+    void CallPreviewRightsUrlAvailableL( MDrmHandleErrorObserver* aObserver,
+                                         TInt aOperationId,
+                                         ContentAccess::CData& aContent,
+                                         const HBufC* aPreviewUrl,
+                                         TDrmRightsInfo aRightsStatus,
+                                         TUint32 aReason,
+                                         const HBufC* aRightsUrl,
+                                         const HBufC8* aContentUri,
+                                         ContentAccess::TIntent aIntent );
+
+    void CallSilentRightsUrlAvailableL( MDrmHandleErrorObserver* aObserver,
+                                        TInt aOperationId,
+                                        const HBufC8* aSilentUrl,
+                                        TDrmRightsInfo aRightsStatus,
+                                        TUint32 aReason,
+                                        const HBufC* aRightsUrl,
+                                        const HBufC8* aContentUri,
+                                        ContentAccess::TIntent aIntent );
+
+    void CallRightsUrlAvailableL( MDrmHandleErrorObserver* aObserver,
+                                  TInt aOperationId,
+                                  TDrmRightsInfo aRightsStatus,
+                                  TUint32 aReason,
+                                  CDRMConstraint* aConstraint,
+                                  ContentAccess::CData& aContent,
+                                  const HBufC8* aContentUri,
+                                  const HBufC* aRightsUrl,
+                                  TDrmUiUrlType aUrlType,
+                                  ContentAccess::TIntent aIntent,
+                                  TInt aError );
+
+    void CallPreviewRightsAvailable( MDrmHandleErrorObserver* aObserver,
+                                     TInt aOperationId,
+                                     TInt aError );
+
+    void CallSilentRightsAvailable( MDrmHandleErrorObserver* aObserver,
+                                    TInt aOperationId,
+                                    TInt aError );
+
+    void CallRightsAvailable( MDrmHandleErrorObserver* aObserver,
+                              TInt aOperationId,
+                              TInt aError );
+
+    void CallPlayEmbeddedPreviewSelected( MDrmHandleErrorObserver* aObserver,
+                                          TInt aOperationId,
+                                          const HBufC* aPreviewUrl );
+
+    /**
+    * @return ETrue if rights renewal wanted, EFalse  otherwise
+    */
+    TBool ShowNoRightsNoteL( ContentAccess::CData& aContent,
+                             TDrmRightsInfo aRightsStatus,
+                             TUint32 aReason,
+                             CDRMConstraint* aConstraint,
+                             const HBufC* aRightsUrl,
+                             TDrmUiUrlType aUrlType,
+                             TInt aError );
+
+    TInt GetOmaConstraintInfo( CDRMConstraint* aConstraint,
+                               TUint32& aCountsLeft,
+                               TTime& aEndTime );
+
+    TInt RejectReason( TUint32 aReason );
+
+    TDrmRightsInfo RightsInfoStatus( TCheckRightsStatus aStatus );
+
+    void CheckOmaDomainStatusL( const ContentAccess::CData& aContent,
+                                const HBufC* aDomainRiUrl,
+                                TInt& aIsRegistered,
+                                TInt& aIsJoined );
+
+    /**
+    * Launch rights manager UI
+    */
+    void LaunchRightsManagerUiL( const TDesC& aParam16 );
+
+    /**
+    * Form string needed to launch rights manager UI embedded.
+    */
+    void CreateLaunchParamL( const HBufC8* aUrl,
+                             HBufC*& aLaunchParam,
+                             const HBufC* aFullPath );
+
+    void CreateLaunchParamL( const HBufC* aFullPath,
+                             HBufC*& aLaunchParam );
+
+    /**
+    * Launch browser. Return ETrue if embedded launch
+    */
+    TBool LaunchBrowserL( const HBufC8* aUrl );
+    TBool LaunchBrowserL( const HBufC* aUrl );
+
+    /**
+    * Get rights silently, if notes are not intended to be shown, put aShowNotes to EFalse 
+    */
+    TInt GetSilentRightsL( const TDesC8& aUrl, const TBool aShowNotes );
+
+    /**
+    * Check if the user has allowed silent rights
+    */
+    TBool SilentRightsAllowedL();
+
+    /**
+    * Check if browser AP has been defined
+    */
+    TBool BrowserAPDefinedL();
+
+    /**
+    * Returns the number of access points on phone
+    */
+    TInt APCountL();
+
+    /**
+    * Handles exit from service
+    * from MAknServerAppExitObserver
+    */
+	void HandleServerAppExit(TInt aReason);
+
+    /**
+     * Appends new async request data to async operation queue.
+     *
+     * @param[in]   aData: The data set in/out.
+     * @return none
+     */
+    void AppendToQueue( CDrmUiHandlingData* aData );
+
+    /**
+     * Gets the next async request data from async operation queue
+     *
+     * @param[in]   none
+     * @return next request data
+     */
+    CDrmUiHandlingData* PopFront();
+
+    void GetOmaBasedInfoL();
+
+    /**
+    * Gets SilentRights and
+    * checks status after 
+    * CallSilentAvailble after right
+    * @return Etrue, if silent RO rerieval led to usable content
+    */
+    TBool CDrmUiHandlingImpl::GetSilentAndCallL(
+        MDrmHandleErrorObserver* aObserver,
+        TInt aOperationId,
+        const ContentAccess::TIntent aIntent,
+        const HBufC8* aContentUri,
+        const HBufC8* aSilentUrl,
+        const TBool aShowNotes );
+
+    /**
+    * Gets Rights and
+    * checks status if launched embedded.
+    * CallRightsAvailable, if launched embedded or righsUrl not present
+    */
+    void CDrmUiHandlingImpl::GetRightsAndCallL(
+        MDrmHandleErrorObserver* aObserver,
+        TInt aOperationId,
+        const ContentAccess::TIntent aIntent,
+        const HBufC8* aContentUri,
+        const HBufC* aRightsUrl );
+private: // data
+
+    // Control environment
+    CCoeEnv* iCoeEnv;
+
+    // DrmUtility
+    CDrmUtility* iDrmUtility;
+
+    // DrmUtilityCommon
+    CDrmUtilityCommon* iDrmUtilityCommon;
+
+    // DrmUtilityUI
+    CDrmUtilityUI* iDrmUtilityUi;
+
+    // Oma Drm client
+    RDRMRightsClient iOmaClient;
+
+    // WM Drm Wrapper - Owned
+    CDrmUtilityWMDrm* iWrapperLoader;
+
+    // WM Drm Client - Not Owned
+    MDrmUtilityWMDrmWrapper* iWmClient;
+
+    // Async observer and current operation id for async operations
+    MDrmAsyncObserver* iObserver;
+    TInt iOperationId;
+
+    // Wait for the notes and queries
+    CActiveSchedulerWait iWait;
+
+    // Schemehandler for url handling
+    CSchemeHandler* iSchemeHandler;
+
+    // Operation Queue:
+    CDrmUiHandlingData* iFirst;
+    CDrmUiHandlingData* iLast;
+
+    // To prevent queue handling from being messed up by threads
+    RSemaphore iSemaphore;
+
+    // Oma based extensions
+    HBufC* iOmaBasedAgentName;
+    TInt iOmaBasedUid;
+    HBufC8* iOmaBasedMimeType;
+
+    };
+
+}
+
+#endif // C_CDRMUIHANDLINGIMPL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/DrmUtilityDmgrWrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,176 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef CDRMUTILITYDMGRWRAPPER_H
+#define CDRMUTILITYDMGRWRAPPER_H
+
+#include <DownloadMgrClient.h>
+#include <aknprogressdialog.h>
+#include <eikprogi.h>
+
+/**
+* Environment gate function
+*
+* @since S60 v5.0
+* @return pointer to DMgr handler
+*/
+IMPORT_C TAny* GateFunctionDMgr();
+
+class MDrmUtilityDmgrWrapper
+    {
+
+public:
+    virtual void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl ) = 0;
+
+    virtual void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl,
+        CCoeEnv& aCoeEnv ) = 0;
+
+    virtual HBufC8* GetErrorUrlL() = 0;
+
+    };
+
+/**
+*  Class for downloading ROAP triggers
+*
+*  @lib DrmUtilityDmgrWrapper
+*  @since S60 v5.0
+*/
+class CDrmUtilityDmgrWrapper : CBase, 
+    public MHttpDownloadMgrObserver, 
+    public MDrmUtilityDmgrWrapper,
+    public MProgressDialogCallback
+    {
+
+public:
+
+    static CDrmUtilityDmgrWrapper* NewL();
+
+    static CDrmUtilityDmgrWrapper* NewLC();
+
+    virtual ~CDrmUtilityDmgrWrapper();
+
+    /**
+    * Download a ROAP trigger from URL and handle it
+    *
+    * @param aUrl  URL of ROAP trigger
+    */
+    void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl );
+
+    void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl,  
+        CCoeEnv& aCoeEnv );
+
+    HBufC8* GetErrorUrlL();
+
+
+    // from base class MHttpDownloadMgrObserver
+
+    /**
+    * From MHttpDownloadMgrObserver.
+    * Handle download manager events
+    *
+    * @param aDownload the download
+    * @param aEvent the event
+    */
+    void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent );
+
+public: // Call back methods of MAknProgressDialogCallback
+
+    /**
+    * ProgressDialog call back method.
+    * Get's called when a dialog is dismissed.
+    *
+    * @param aButtonId ID of the button pressed
+    */
+    void DialogDismissedL( TInt aButtonId );
+
+protected:
+
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CDrmUtilityDmgrWrapper();
+
+    void ConstructL();
+
+    /**
+    * Set the browser default access point to be used
+    */
+    void SetDefaultAccessPointL();
+
+    void DoDownloadAndHandleRoapTriggerL( const HBufC8* aUrl );
+
+    void ShowProgressNoteL( );
+
+    void RemoveProgressNoteL( );
+
+    void HandlePostResponseUrlL();
+
+
+private: // data
+
+    /**
+    * Download manager session
+    */
+    RHttpDownloadMgr iDlMgr;
+
+    /**
+    * Used to make downloads synchronous
+    */
+    CActiveSchedulerWait iWait;
+
+    /**
+    * to store information on download
+    */
+    TBool iDownloadSuccess;
+    TBool iConnectionError;
+
+    TBool iDialogDismissed;
+
+    /**
+    * Progess note dialog and progress info
+    */
+    CAknProgressDialog* iProgressNoteDialog;        // owned
+    CEikProgressInfo* iProgressInfo;                // not owned
+    TInt iCurrentProgressValue;                     // owned
+    TInt iProgressIncrement;                        // owned
+
+    /**
+    * Control environment
+    */
+    CCoeEnv* iCoeEnv;
+
+    /**
+    * Is CoeEnv given
+    */
+    TBool iUseCoeEnv;
+
+    /**
+    * Error url for ROAP temporary error
+    */
+    HBufC8* iErrorUrl;
+
+    /**
+    * Post response url for ROAP prUrl
+    */
+    HBufC8* iPostResponseUrl;
+
+    };
+
+#endif // CDRMUTILITYDMGRWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/DrmUtilityDmgrWrapperLogger.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,216 @@
+/*
+* 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:  Logger.
+*
+*/
+
+
+#ifndef DRMUILOGGER_H
+#define DRMUILOGGER_H
+
+
+// INCLUDES
+
+#include <e32std.h>
+#include <e32def.h>
+#include <eikenv.h>
+#include <flogger.h>
+
+
+#ifdef _DEBUG
+#define __TEST_DRM_LOG__
+#endif // _DEBUG
+
+
+#ifdef __TEST_DRM_LOG__
+
+// CONSTANTS
+
+// DRMUI logging directory.
+_LIT( KDRMUILogDir,                   "DRMUI" );
+// DRMUI log file name.
+_LIT( KDRMUILogFile,                  "DMgrWrapper.log" );
+// Format string: enter function.
+_LIT( KDRMUILogEnterFn,               "-> %S" );
+// Format string: leave function.
+_LIT( KDRMUILogLeaveFn,               "<- %S" );
+// Format string: time.
+_LIT( KDRMUILogTimeFormatString,      "%H:%T:%S:%*C2" );
+// Format string: timestamp.
+_LIT( KDRMUILogTimeStampFormatString, "%S %S" );
+//Banner message
+_LIT( KDRMUILogBanner,                "DRMUI 3.2");
+// Message of exit from app
+_LIT( KDRMUILogExit,                  "DRMUI: Application exit");
+
+// DEFINES
+
+// Create the log
+#define CLOG_CREATE                 { FCreate(); }
+
+// Close the log
+#define CLOG_CLOSE                  \
+    {                               \
+    RFileLogger::Write              \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        KDRMUILogExit               \
+        );                          \
+    }
+
+// Write log: enter function.
+#define CLOG_ENTERFN( a )           \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::WriteFormat        \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        KDRMUILogEnterFn,           \
+        &temp                       \
+        );                          \
+    }
+
+// Write log: leave function.
+#define CLOG_LEAVEFN( a )           \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::WriteFormat        \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        KDRMUILogLeaveFn,           \
+        &temp                       \
+        );                          \
+    }
+
+// Write log: string 'a'.
+#define CLOG_WRITE( a )             \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::Write              \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        temp                        \
+        );                          \
+    }
+
+// Write log: formatted.
+#define CLOG_WRITE_FORMAT( a, b )   \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::WriteFormat        \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        temp,                       \
+        b                           \
+        );                          \
+    }
+
+// Write log: timestamp.
+#define CLOG_WRITE_TIMESTAMP( a )                                   \
+    {                                                               \
+    _LIT( temp, a );                                                \
+    TTime time;                                                     \
+    time.HomeTime();                                                \
+    TBuf<32> timeBuf;                                               \
+    TRAPD( err, time.FormatL( timeBuf, KDRMUILogTimeFormatString ) ); \
+    if ( !err )                                                     \
+        {                                                           \
+        RFileLogger::WriteFormat                                    \
+            (                                                       \
+            KDRMUILogDir,                                           \
+            KDRMUILogFile,                                          \
+            EFileLoggingModeAppend,                                 \
+            KDRMUILogTimeStampFormatString,                         \
+            &temp,                                                  \
+            &timeBuf                                                \
+            );                                                      \
+        }                                                           \
+    }
+
+// Write formatted
+#define CLOG_WRITEF                 FPrint
+
+
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, 
+                              EFileLoggingModeAppend, aFmt, list );
+    }
+
+
+inline void FPrint( const TDesC& aDes )
+    {
+    RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, 
+                              EFileLoggingModeAppend, aDes );
+    }
+
+
+inline void FCreate()
+    {
+    TFileName path( _L( "c:\\logs\\" ) );
+    path.Append( KDRMUILogDir );
+    path.Append( _L( "\\" ) );
+    RFs& fs = CEikonEnv::Static()->FsSession();
+    fs.MkDirAll( path );
+    RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, 
+                              EFileLoggingModeOverwrite, KDRMUILogBanner );
+    }
+
+
+#else // not defined __TEST_DRM_LOG__
+
+inline void FPrint( const TRefByValue<const TDesC> /*aFmt*/, ... ) {};
+
+
+// DEFINES
+
+// Empty definition (disable log).
+#define CLOG_CREATE
+
+// Empty definition (disable log).
+#define CLOG_CLOSE
+
+// Empty definition (disable log).
+#define CLOG_ENTERFN( a )
+
+// Empty definition (disable log).
+#define CLOG_LEAVEFN( a )
+
+// Empty definition (disable log).
+#define CLOG_WRITE( a )
+
+// Empty definition (disable log).
+#define CLOG_WRITE_FORMAT( a, b )
+
+// Empty definition (disable log).
+#define CLOG_WRITE_TIMESTAMP( a )
+
+// Empty definition (disable log).
+#define CCDLGLOGGER_WRITEF   1 ? ((void)0) : FPrint
+
+#endif // __TEST_DRM_LOG__
+
+#endif // DRMUILOGGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/DrmUtilityDownloadManager.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,65 @@
+/*
+* 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:  DrmUtilityDownloadManager declaration
+*
+*/
+
+
+#ifndef CDRMUTILITYDOWNLOADMANAGER_H
+#define CDRMUTILITYDOWNLOADMANAGER_H
+
+#include <e32base.h>
+#include <ConeResLoader.h>
+
+class CDrmUtilityDmgrWrapper;
+
+/**
+ *  This class encapsulates Download manager functionality.
+ */
+NONSHARABLE_CLASS(CDrmUtilityDownloadManager) : public CBase
+    {
+public:
+    
+    static CDrmUtilityDownloadManager* NewL();
+    virtual ~CDrmUtilityDownloadManager();
+
+    /**
+     * Download a ROAP trigger from URL and handle it
+     *
+     * @param aUrl URL to be downloaded
+     */
+    void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl, CCoeEnv& aCoeEnv );
+
+    void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl );
+    
+    HBufC8* GetErrorUrlL();
+
+
+protected:
+            
+private:
+
+    CDrmUtilityDownloadManager();
+    void ConstructL();
+
+private:
+
+    /**
+	 * Download manager handler
+	 */
+    RLibrary iDMgrDll;
+    CDrmUtilityDmgrWrapper* iDMgrHandler;
+    };
+
+#endif      // CDRMUTILITYDOWNLOADMANAGER_H   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/DrmUtilityGlobalNoteWrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,157 @@
+/*
+* 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:  Synchronous wrapper for showing global notes
+*
+*/
+
+
+
+#ifndef __DRMUTILITYGLOBALNOTEWRAPPER_H__
+#define __DRMUTILITYGLOBALNOTEWRAPPER_H__
+
+//  INCLUDES
+#include <e32base.h>
+#include <stringresourcereader.h>
+
+namespace DRM 
+{
+
+// CONSTANTS
+const TInt KDRMNoteBufferMaxSize ( 256 );
+
+/**
+*  Wrapper class for displaying global notes.
+*/
+NONSHARABLE_CLASS ( CDrmUtilityGlobalNoteWrapper ) : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDrmUtilityGlobalNoteWrapper* NewL( 
+                                    CStringResourceReader* aResourceReader );
+        
+        static CDrmUtilityGlobalNoteWrapper* NewLC( 
+                                    CStringResourceReader* aResourceReader );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CDrmUtilityGlobalNoteWrapper();
+
+    public: // New functions
+
+        /**
+        * Synchronous wrapper for showing global note.
+        * @param aTextResourceId resource id of string to be displayed
+        * @param aButtonsId resource id of buttons of note
+        * @return button code
+        */
+        TInt ShowNoteWithButtonsL( TInt aResourceId, TInt aButtonsId );
+        
+        /**
+        * Synchronous wrapper for showing global note.
+        * @param aTextResourceId resource id of string to be displayed
+        * @param aButtonsId resource id of buttons of note
+        * @param aString string which replaces %U in resource string
+        * @return button code
+        */
+        TInt ShowNoteWithButtonsL( TInt aResourceId, 
+                                   TInt aButtonsId, 
+                                   const TDesC& aString );
+        
+        /**
+        * Synchronous wrapper for showing global note.
+        * @param aTextResourceId resource id of string to be displayed
+        * @param aValue integer that replaces %N in resource string        
+        * @return button code
+        */
+        TInt ShowNoteL( TInt aResourceId, TInt aValue );
+
+        /**
+        * Synchronous wrapper for showing global note.
+        * @param aTextResourceId resource id of string to be displayed
+        * @param aString string that replaces %U in resource string        
+        * @return button code
+        */
+        TInt ShowNoteL( TInt aResourceId, const TDesC& aString );
+
+        /**
+        * Synchronous wrapper for showing global note.
+        * @param aTextResourceId resource id of string to be displayed
+        * @param aString string that replaces %U in resource string        
+        * @param aValue integer that replaces %N in resource string        
+        * @return button code
+        */
+        TInt ShowNoteL( TInt aResourceId, 
+        	            const TDesC& aString, 
+        	            TInt aValue,
+        	            TInt aStringPos = -1,
+        	            TInt aValuePos = -1 );
+        	            
+        /**
+        * Synchronous wrapper for showing global  preview list query.
+        * @param aTextResourceId resource id of preview structure to be
+        *        displayed
+        * @return button code
+        */
+        TInt ShowPreviewListQueryL( TInt aResourceId ); 
+
+    private: // From CActive
+    
+    	void DoCancel();
+    	void RunL();
+        
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDrmUtilityGlobalNoteWrapper();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( CStringResourceReader* aResourceReader );
+
+        /**
+        * Do actual displaying of note
+        */
+        TInt DoShowNoteL(TInt aResourceId, 
+                         const TDesC& aString = KNullDesC, 
+                         TInt aValue = -1 );
+        
+    private:    // Data
+
+        // Used to make asynchronous call synchronous
+        CActiveSchedulerWait iWait;
+
+        // Text buffer used with global notes. Can contain max 
+        // KTextBufferMaxSize long string + filename.
+        TBuf<KDRMNoteBufferMaxSize + KMaxFileName> iTextBuffer;
+        
+        // used to read resources
+        CStringResourceReader* iResourceReader;
+        
+        // Resource id of buttons in confirmation query
+        TInt iButtonsId;
+    };
+
+}
+
+#endif      // __DRMUTILITYGLOBALNOTEWRAPPER_H__   
+            
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/DrmUtilityInfoNoteWrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Synchronous wrapper for showing global notes
+*
+*/
+
+
+
+#ifndef __DRMUTILITYINFONOTEWRAPPER_H__
+#define __DRMUTILITYINFONOTEWRAPPER_H__
+
+//  INCLUDES
+#include <e32base.h>
+#include <aknglobalnote.h>
+
+namespace DRM 
+{
+
+/**
+*  Wrapper class for displaying global notes.
+*/
+NONSHARABLE_CLASS ( CDrmUtilityInfoNoteWrapper ) : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDrmUtilityInfoNoteWrapper* NewL();
+        
+        static CDrmUtilityInfoNoteWrapper* NewLC();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CDrmUtilityInfoNoteWrapper();
+
+    public: // New functions
+
+
+        /**
+        * Synchronous wrapper for showing global note.
+        * @param aType type of Info note to be displayed
+        * @param aNoteText string containing note text       
+        * @param aResource resource identifier
+        * @param aString is transferred for CoverUi string data     
+        * @param aValue is transferred for CoverUi numerical data
+        * @return button code
+        */
+        void ShowNoteL(  TAknGlobalNoteType aType, 
+                         const TDesC& aNoteText,
+                         TInt aResourceId = -1, 
+                         const TDesC& aString = KNullDesC,
+                         TInt aValue = -1 );
+
+        /**
+        * Synchronous wrapper for showing global note.
+        * @param[inout] aResourceId takes primary display
+        *               resource ID and returns CoverUiId     
+        * @return       boolean if ID was valid CoverUiId
+        */
+        static TBool EvaluateCoverResourceId( TInt& aResourceId );
+    
+    private: // From CActive
+    
+    	void DoCancel();
+    	void RunL();
+        
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDrmUtilityInfoNoteWrapper();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();        
+       
+    private: // Data
+        
+        CAknGlobalNote* iNote; 
+    };
+
+}
+
+#endif      // __DRMUTILITYINFONOTEWRAPPER_H__   
+            
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/drmautomatedtypes.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Enumerations and constants used in DrmAutomatedUsage
+*
+*/
+
+
+#ifndef DRMAUTOMATEDTYPES_H
+#define DRMAUTOMATEDTYPES_H
+namespace DRM
+    {
+    /** Automated usage types */
+    enum TDrmAutomatedType
+        {
+        //This is a new type
+        EAutomatedTypeVideoRingingTone,
+        //These are from TDRMHelperAutomatedType
+        EAutomatedTypeRingingTone,
+        EAutomatedTypeMessageAlert,
+        EAutomatedTypeEmailAlert,
+        EAutomatedTypeIMAlert,
+        EAutomatedTypeCalendarAlarm,
+        EAutomatedTypeScreenSaver,
+        EAutomatedTypeWallpaper,
+        EAutomatedTypeTheme,
+        EAutomatedTypeClockAlarm,
+        EAutomatedTypeOther = KMaxTUint8
+        };
+
+
+    /** 
+    * Automated service types
+    *     EAUActive   registering application listens to expiry notifications 
+    *     EAUPassive  registering application does not listen to expiry
+    *                 notifications 
+    */ 
+    enum TDrmAutomatedServiceType
+        {
+        EAUPassive = 0, 
+        EAUActive
+        };
+    }
+#endif // DRMAUTOMATEDTYPES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/drmautomatedusagedata.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,193 @@
+/*
+* 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:  Data class for async operations
+*                in DrmAutomatedUsageImpl class
+*
+*/
+
+
+#ifndef CDRMAUTOMATEDUSAGEDATA_H
+#define CDRMAUTOMATEDUSAGEDATA_H
+
+#include <e32base.h>
+#include <caf/caftypes.h>
+#include <caf/data.h>
+#include <drmutilitytypes.h>
+
+namespace DRM
+{
+
+class MDrmAsyncObserver;
+
+/**
+*  DRM Automated Usage Data storage class
+*
+*  parameter container class used by DRM::CDrmAutomatedUsageImpl
+*
+*  @lib drmautomatedusageimpl.lib
+*
+*  @since S60 5.0
+*
+*  @see DRM::CDrmAutomatedUsageImpl
+*/
+NONSHARABLE_CLASS( CDrmAutomatedUsageData ) : public CBase
+    {
+
+public: // Members
+    /**
+    * Possible operations for atuomated content relresented by
+    * object of this class
+    */
+    enum TOperation
+        {
+        ESetAutomated,
+        ERemoveAutomated,
+        EHandeError
+        };
+
+    /**
+    * Creates a new CDrmAutomatedUsageData -object
+    *
+    * @since S60 5.0
+    * @return A functional CDrmAutomatedUsageData -object
+    * @leave System wide or DRM specific error code
+    */
+    static CDrmAutomatedUsageData* NewL(
+        const ContentAccess::CData& aData,
+        ContentAccess::TIntent aIntent,
+        TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver* aObserver,
+        TDrmAutomatedServiceType aServiceType,
+        TOperation aOperation );
+
+
+    /**
+    * Creates a new CDrmAutomatedUsageData -object and leaves
+    * it into the cleanup stack
+    *
+    * @since S60 5.0
+    * @return A functional CDrmAutomatedUsageData -object
+    * @leave System wide or DRM specific error code
+    */
+    static CDrmAutomatedUsageData* NewLC(
+        const ContentAccess::CData& aData,
+        ContentAccess::TIntent aIntent,
+        TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver* aObserver,
+        TDrmAutomatedServiceType aServiceType,
+        TOperation aOperation );
+
+    /**
+    * Creates a new CDrmAutomatedUsageData -object
+    *
+    * @since S60 5.0
+    * @return A functional CDrmAutomatedUsageData -object
+    * @leave System wide or DRM specific error code
+    */
+    static CDrmAutomatedUsageData* NewL(
+        const TDesC& aUniqueId,
+        ContentAccess::TIntent aIntent,
+        TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver* aObserver,
+        TDrmAutomatedServiceType aServiceType,
+        TOperation aOperation );
+
+
+    /**
+    * Creates a new CDrmAutomatedUsageData -object and leaves
+    * it into the cleanup stack
+    *
+    * @since S60 5.0
+    * @return A functional CDrmAutomatedUsageData -object
+    * @leave System wide or DRM specific error code
+    */
+    static CDrmAutomatedUsageData* NewLC(
+        const TDesC& aUniqueId,
+        ContentAccess::TIntent aIntent,
+        TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver* aObserver,
+        TDrmAutomatedServiceType aServiceType,
+        TOperation aOperation );
+
+    /**
+    * Destructor.
+    */
+    ~CDrmAutomatedUsageData();
+
+public: // Variables:
+    // Operation code
+    TOperation iOperation;
+
+    // Operation id
+    // Owned
+    TInt iOperationId;
+
+    // The content id requested as 16 bit descriptor
+    // Owned
+    HBufC16* iUniqueId;
+
+    // The content id requested as 8 bit descriptor, this exists if it's
+    // For internal DRM API
+    // Owned
+    HBufC8* iUniqueId8;
+
+    // Intent
+    // Owned
+    ContentAccess::TIntent iIntent;
+
+    // Desired automated content type for automated content
+    // Owned
+    TDrmAutomatedType iAutomatedType;
+
+    // Observer pointer for notifying asynchronous operations
+    // Not owned
+    MDrmAsyncObserver* iObserver;
+
+    // Desired automated content type for automated content
+    TDrmAutomatedServiceType iServiceType;
+
+
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CDrmAutomatedUsageData(
+        ContentAccess::TIntent aIntent,
+        TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver* aObserver,
+        TDrmAutomatedServiceType aServiceType,
+        TOperation aOperation );
+
+    /**
+    * C++ copy constructor.
+    */
+    CDrmAutomatedUsageData( const CDrmAutomatedUsageData& );
+
+    /**
+    * 2nd phase constructor
+    */
+    void ConstructL( const ContentAccess::CData& aData );
+
+    void ConstructL( const TDesC& aUniqueId );
+
+    /**
+    * Initialises operationId to unique value.
+    */
+    void SetOperationId();
+    };
+}
+
+
+#endif // CDRMAUTOMATEDUSAGEDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/drmautomatedusageerrorhandling.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,223 @@
+/*
+* 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:  Implementation class header of the implementation class that
+*                implements the MDrmErrorHandling API
+*
+*/
+
+
+
+
+#ifndef C_CDRMAUTOMATEDUSAGEERRORHANDLING_H
+#define C_CDRMAUTOMATEDUSAGEERRORHANDLING_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <caf/caferr.h>
+#include <caf/caftypes.h>
+
+#include <drmerrorhandling.h>
+#include <drmhandleerrorobserver.h>
+
+
+
+namespace DRM
+{
+
+class CDrmAutomatedUsageImpl;
+
+/**
+*  Implementation class for the MDrmErrorHandling interface
+*  For DRM automated usage errors
+*  This class uses methods in CDrmAutomatedUsageimpl, and is instantiated
+*  on instantiation of class DRM::CDrmAutomatedUsage.
+*  The class is not intended to be instantiated from any other place.
+*
+*  @code
+*      DRM::DrmAutomatedUsage* iMyAutomatedUsage = 
+*          DRM::DrmAutomatedUsage::NewL( iMyCoeEnv );
+*      // do some fancy automatedUsage related stuff
+*      // ...
+*      // DrmAutomatedUsage error occurs
+*      DRM::MDrmErrorHandling& myErrorHandler =
+*          iMyAutomatedUsage->GetErrorHandler();
+*      myErrorHandler.HandleErrorL( theAutomatedUsageError );
+*  @endcode
+*
+*  @lib drmautomatedusageimpl.lib
+*  @since S60 5.0
+*/
+NONSHARABLE_CLASS( CDrmAutomatedUsageErrorHandling ) :
+    public CBase, public MDrmErrorHandling
+    {
+public:
+
+    /**
+    * Two-phased constructor.
+    * @param aImplementation pointer to the implementation class
+    */
+    IMPORT_C static CDrmAutomatedUsageErrorHandling* NewL(
+        CDrmAutomatedUsageImpl* aImplementation );
+
+    /**
+    * Two-phased constructor. Leaves the created object into the
+    * cleanup stack
+    * @param aImplementation pointer to the implementation class
+    */
+    IMPORT_C static CDrmAutomatedUsageErrorHandling* NewLC(
+        CDrmAutomatedUsageImpl* aImplementation );
+    /**
+    * Destructor.
+    */
+    virtual ~CDrmAutomatedUsageErrorHandling();
+
+
+public: // from base class MDrmErrorHandling
+
+    /**
+    * From MDrmErrorHandling
+    *
+    * Handles DRM error situations related to invalid rights.
+    * This method displays appropriate notes, which observer can override,
+    * to the user and acquires new rights if needed. Asynchronous version,
+    * all errors are signalled using request status.
+    *
+    * @since S60 5.0
+    * @param[in]   aFile       file for which the error happened
+    * @param[in]   aIntent     the CAF intent which was used to recieve
+    *                          the error
+    * @param[in]   aError      error code
+    * @param[in]   aObserver   reference to observer
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @see MDrmHandleErrorObserver
+    * @see ContentAccess::TIntent
+    * @see MDrmErrorHandling
+    */
+    virtual TInt HandleErrorAsyncL(
+        RFile& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver& aObserver );
+
+    /**
+    * From MDrmErrorHandling
+    *
+    * Handles DRM error situations related to invalid rights.
+    * This method displays appropriate notes, which observer can override,
+    * to the user and acquires new rights if needed. Synchronous version,
+    * leaves in case of error.
+    *
+    * @since S60 5.0
+    * @param[in]   aFile       file for which the error happened
+    * @param[in]   aIntent     the CAF intent which was used to recieve
+    *                          the error
+    * @param[in]   aError      error code
+    * @param[in]   aObserver   pointer to observer, NULL if no observer
+    *
+    * @leave   KErrArgument    File is not DRM protected.
+    *
+    * @see MDrmHandleErrorObserver
+    * @see ContentAccess::TIntent
+    * @see MDrmErrorHandling
+    */
+    virtual void HandleErrorL(
+        RFile& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver* aObserver );
+
+    /**
+    * From MDrmErrorHandling
+    *
+    * Handles DRM error situations related to invalid rights.
+    * This method displays appropriate notes, which observer can override,
+    * to the user and acquires new rights if needed. Asynchronous version,
+    * all errors are signalled using request status.
+    *
+    * @since S60 5.0
+    * @param[in]   aFile       content for which the error happened
+    * @param[in]   aIntent     the CAF intent which was used to recieve
+    *                          the error
+    * @param[in]   aError      error code
+    * @param[in]   aObserver   reference to observer
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @see MDrmHandleErrorObserver
+    * @see ContentAccess::TIntent
+    * @see MDrmErrorHandling
+    */
+    virtual TInt HandleErrorAsyncL(
+        ContentAccess::CData& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver& aObserver );
+
+    /**
+    * From MDrmErrorHandling
+    *
+    * Handles DRM error situations related to invalid rights.
+    * This method displays appropriate notes, which observer can override,
+    * to the user and acquires new rights if needed. Synchronous version,
+    * leaves in case of error.
+    *
+    * @since S60 5.0
+    * @param[in]   aFile       content for which the error happened
+    * @param[in]   aIntent     the CAF intent which was used to recieve
+    *                          the error
+    * @param[in]   aError      error code
+    * @param[in]   aObserver   pointer to observer, NULL if no observer
+    *
+    * @leave   KErrArgument    File is not DRM protected.
+    *
+    * @see MDrmHandleErrorObserver
+    * @see ContentAccess::TIntent
+    * @see MDrmErrorHandling
+    */
+    virtual void HandleErrorL(
+        ContentAccess::CData& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver* aObserver );
+
+
+private:
+
+    /**
+    * C++ constructor
+    */
+    CDrmAutomatedUsageErrorHandling();
+
+    /**
+    * Second phase constructor
+    */
+    void ConstructL( CDrmAutomatedUsageImpl* aImplementation );
+
+private: // data
+
+    /**
+    * Pointer to the implementation class, which
+    * has actual error handling functionality
+    * Not owned
+    */
+    CDrmAutomatedUsageImpl* iImplementation;
+    };
+}
+#endif // C_CDRMAUTOMATEDUSAGEERRORHANDLING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/drmuierrorhandling.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,200 @@
+/*
+* 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:  Implementation class header of MDrmErrorHandling API
+*
+*/
+
+
+#ifndef C_CDRMUIERRORHANDLING_H
+#define C_CDRMUIERRORHANDLING_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <caf/caftypes.h>
+#include <drmerrorhandling.h>
+
+namespace DRM
+{
+    
+    //*** forward declarations go here:
+    class CDrmUiHandlingImpl;
+    class MDrmHandleErrorObserver;
+    
+/**
+ *  Implementation class for the MDrmErrorHandling interface
+ *  For DRM UI Handling
+ *
+ *  @lib drmuihandling.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CDrmUiErrorHandling ) :
+    public CBase, public MDrmErrorHandling
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aImplementation pointer to the implementation class
+     */
+    IMPORT_C static CDrmUiErrorHandling* NewL(
+        CDrmUiHandlingImpl* aImplementation );
+    
+    /**
+     * Two-phased constructor. Leaves the created object into the
+     * cleanup stack
+     * @param aImplementation pointer to the implementation class
+     */
+    IMPORT_C static CDrmUiErrorHandling* NewLC(
+        CDrmUiHandlingImpl* aImplementation );
+    /**
+    * Destructor.
+    */
+    virtual ~CDrmUiErrorHandling();
+
+
+public: // from base class MDrmErrorHandling
+
+    /**
+     * From MDrmErrorHandling
+     *
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override, 
+     * to the user and acquires new rights if needed. Asynchronous version,
+     * all errors are signalled using request status. 
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve 
+     *                          the error
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @see MDrmHandleErrorObserver
+     * @see ContentAccess::TIntent
+     */
+    virtual TInt HandleErrorAsyncL( 
+        RFile& aFile,
+        ContentAccess::TIntent aIntent, 
+        TInt aError, 
+        MDrmHandleErrorObserver& aObserver );
+        
+    /**
+     * From MDrmErrorHandling
+     *
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override, 
+     * to the user and acquires new rights if needed. Synchronous version,
+     * leaves in case of error. 
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve 
+     *                          the error
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   pointer to observer, NULL if no observer
+     *
+     * @leave   KErrArgument    File is not DRM protected.
+     *
+     * @see MDrmHandleErrorObserver
+     * @see ContentAccess::TIntent
+     */
+    virtual void HandleErrorL( 
+        RFile& aFile,
+        ContentAccess::TIntent aIntent,              
+        TInt aError, 
+        MDrmHandleErrorObserver* aObserver );
+    
+    /**
+     * From MDrmErrorHandling
+     *
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override, 
+     * to the user and acquires new rights if needed. Asynchronous version,
+     * all errors are signalled using request status. 
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve 
+     *                          the error         
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @see MDrmHandleErrorObserver
+     * @see ContentAccess::TIntent
+     */
+    virtual TInt HandleErrorAsyncL( 
+        ContentAccess::CData& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError, 
+        MDrmHandleErrorObserver& aObserver );
+        
+    /**
+     * From MDrmErrorHandling
+     *
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override, 
+     * to the user and acquires new rights if needed. Synchronous version,
+     * leaves in case of error. 
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve 
+     *                          the error         
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   pointer to observer, NULL if no observer
+     *
+     * @leave   KErrArgument    File is not DRM protected.
+     *
+     * @see MDrmHandleErrorObserver
+     * @see ContentAccess::TIntent
+     */
+    virtual void HandleErrorL( 
+        ContentAccess::CData& aFile,
+        ContentAccess::TIntent aIntent,
+        TInt aError, 
+        MDrmHandleErrorObserver* aObserver );
+
+
+private:
+
+    /**
+    * C++ constructor
+    */
+    CDrmUiErrorHandling();
+
+    /**
+    * Second phase constructor
+    */
+    void ConstructL( CDrmUiHandlingImpl* aImplementation );
+
+private: // data
+
+    /**
+     * Pointer to the implementation class
+     * Not own.
+     */
+    CDrmUiHandlingImpl* iImplementation;
+    };
+
+}
+    
+#endif // C_CDRMUIERRORHANDLING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/drmuihandlingdata.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2006-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:  Data class for async operations in DrmRightInfoImpl -class 
+*
+*/
+
+
+#ifndef CDRMUIHANDLINGDATA_H
+#define CDRMUIHANDLINGDATA_H
+
+//*** system include files go here:
+#include <e32base.h>
+#include <f32file.h>
+#include <caf/caftypes.h>
+#include <drmutilitytypes.h>
+
+//*** forward declarations go here:
+namespace ContentAccess
+    {
+    class CData;
+    }
+
+namespace DRM 
+{
+    
+    //*** forward declarations go here:
+    class MDrmAsyncObserver;
+    class MDrmHandleErrorObserver;
+    class MDrmUiCheckRightsObserver;
+    
+ /**
+  *  DRM UI Handling Data storage class
+  *
+  *  @lib drmuihandlingimpl.lib
+  *  @since S60 v5.0
+  */
+NONSHARABLE_CLASS( CDrmUiHandlingData ) : public CBase
+    {
+
+public: // Members
+
+    /**
+    * Creates a new CDrmUiHandlingData -object
+    *
+    * @since S60 v5.0
+    * @return A functional CDrmUiHandlingData -object
+    * @leave System wide or DRM specific error code
+    */
+    static CDrmUiHandlingData* NewL();
+
+
+    /**
+    * Creates a new CDrmUiHandlingData -object and leaves
+    * it into the cleanup stack
+    *
+    * @since S60 v5.0
+    * @return A functional CDrmUiHandlingData -object
+    * @leave System wide or DRM specific error code
+    */    
+    static CDrmUiHandlingData* NewLC();
+   
+    /**
+    * Destructor.
+    */	
+    ~CDrmUiHandlingData();
+
+public: // Variables:
+    // Operation request status
+    MDrmAsyncObserver* iObserver;
+    
+    // Operation identifier
+    TInt iOperationId;
+
+    // Operation code
+    TInt iOperation;
+    
+    // File / content
+    RFile* iFile;
+    ContentAccess::CData* iFileData;
+
+    // Intent
+    ContentAccess::TIntent iIntent;
+    
+    // Error code
+    TInt iError;
+    
+    // Error observer
+    MDrmHandleErrorObserver* iErrorObserver;
+    
+    // Check rights observer
+    MDrmUiCheckRightsObserver* iCheckRightsObserver;
+    
+    // Url type
+    TDrmUiUrlType* iType;
+    TDrmUiUrlType iTypeParam;
+    
+    // Queue Pointer:
+    CDrmUiHandlingData* iNext;
+
+private:
+
+	/**
+    * C++ default constructor.
+    */
+    CDrmUiHandlingData();
+
+    /**
+    * 2nd phase constructor
+    */
+    void ConstructL();
+ 
+    };
+}
+
+#endif // CDRMUIHANDLINGDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/drmutilitycommon.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2006-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:  Provides operations for common usage of DRM Utility API
+*
+*/
+
+
+#ifndef CDRMUTILITYCOMMON_H
+#define CDRMUTILITYCOMMON_H
+
+//*** system include files go here:
+#include <e32base.h>
+#include <caf/caftypes.h> 
+#include <drmrightsclient.h>
+#include <drmutilitytypes.h>
+
+//*** forward declarations go here:
+class CDRMConstraint;
+
+namespace DRM 
+{
+    
+ /**
+  *  Utility class for DRM related common functions
+  *
+  *  @lib drmutilitycommon.lib
+  *  @since S60 v5.0
+  */
+NONSHARABLE_CLASS( CDrmUtilityCommon ) : public CBase
+    {
+
+public:
+
+    /**
+     * Creates a new CDrmUtilityCommon object and returns a pointer to it
+     *
+     * @return A functional CDrmUtilityCommon -object
+     * @leave System wide error code
+     */	
+    IMPORT_C static CDrmUtilityCommon* NewL();
+
+    /**
+     * Creates a new CDrmUtilityCommon object and returns a pointer to it
+     * leaves the returned object to the cleanup stack
+     *
+     * @return A functional CDrmUtilityCommon -object
+     * @leave System wide error code
+     */	
+    IMPORT_C static CDrmUtilityCommon* NewLC();
+
+    /**
+     * Destructor
+     */
+    virtual ~CDrmUtilityCommon();
+     
+    /**
+     * Checks the rights and their status for a specific unique id
+     * implementation
+     *
+     * @param[in]   aContentUri The unique identifier or the content
+     * @param[in]   aIntent     The intent for the rights to check
+     * @param[out]  aConstraint A Constraint of the future rights,
+     *                          must be initialized
+     * 
+     * @return Rights status
+     * @leave System wide error code
+     * @see ContentAccess:TIntent
+     */	
+    IMPORT_C TDrmRightsInfo GetOmaRightsStatusL( 
+                                            HBufC8*& aContentUri, 
+                                            ContentAccess::TIntent aIntent,
+                                            CDRMConstraint* aConstraint );
+                                        
+
+protected:
+
+private:
+
+    CDrmUtilityCommon();
+
+    void ConstructL();
+    
+private: // Data members
+    
+    // Oma Drm client
+    RDRMRightsClient iOmaClient;
+
+    };
+}
+
+#endif // CDRMUTILITYCOMMON_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/drmutilitysecondarydisplay.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,125 @@
+/*
+* 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:  The set of messages provided to Secondary Display software by
+*              : DRMUtility
+*
+*/
+
+
+#ifndef T_DRMUTILITYSECONDARYDISPLAY_H
+#define T_DRMUTILITYSECONDARYDISPLAY_H
+
+// INCLUDES
+#include <e32base.h>
+
+// The category UID for the messages in this header file.
+// UID of the DrmUtilityCommon.Dll
+const TUid KUidCoverUiCategoryDrmUtility = { 0x10283302 };
+
+/*
+* ==============================================================================
+* Dialogs shown by DrmUtility. These messages are handled using the
+* Secondary Display support in Avkon.
+* ==============================================================================
+*/
+enum TSecondaryDisplayDRMUtilityDialogs
+    {
+    ECover_dialog_cancel = 1,
+    ECover_confirmation_query,
+    ECover_waiting_rights_confirmation_query,
+    ECover_usage_rights_expired_buy_new,
+    ECover_usage_rights_expired,
+    ECover_no_usage_rights_buy_new,
+    ECover_no_usage_rights,
+    ECover_database_corrupted,
+    ECover_set_automated,
+    ECover_activate_and_set_automated,
+    ECover_cal_alert_invalid_sim_buy_new,
+    ECover_cal_alert_expired_buy_new,
+    ECover_cal_alert_expired,
+    ECover_clock_alarm_invalid_sim_buy_new,
+    ECover_clock_alarm_expired_buy_new,
+    ECover_clock_alarm_expired,
+    ECover_email_tone_expired_buy_new,
+    ECover_email_tone_invalid_sim_buy_new,
+    ECover_email_tone_expired,
+    ECover_im_tone_expired_buy_new,
+    ECover_im_tone_expired,
+    ECover_message_tone_invalid_sim_buy_new,
+    ECover_message_tone_expired_buy_new,
+    ECover_message_tone_expired,
+    ECover_ringing_tone_expired_buy_new,
+    ECover_ringing_tone_invalid_sim_buy_new,
+    ECover_ringing_tone_expired,
+    ECover_screensaver_invalid_sim_buy_new,
+    ECover_screensaver_expired_buy_new,
+    ECover_screensaver_expired,
+    ECover_wallpaper_invalid_sim_buy_new,
+    ECover_wallpaper_expired_buy_new,
+    ECover_wallpaper_expired,
+    ECover_theme_invalid_sim_buy_new,
+    ECover_theme_expired_buy_new,
+    ECover_theme_expired,
+    ECover_usage_rights_in_future,
+    ECover_activate_after_preview,
+    ECover_waiting_for_rights,
+    ECover_rights_should_have_come,
+    ECover_rights_should_have_come_no_ri,
+    ECover_automated_sd_invalid_sim,
+    ECover_automated_sd_expired,
+    ECover_automated_cd_expired,
+    ECover_prev_audio_get_list_query,
+    ECover_prev_video_get_list_query,
+    ECover_prev_audio_play_list_query,
+    ECover_prev_video_play_list_query,
+    ECover_invalid_sim,
+    ECover_audio_prev_get_list,
+    ECover_video_prev_get_list,
+    ECover_audio_prev_play_list,
+    ECover_video_prev_play_list,
+    ECover_r_silent_wait_note,
+    ECover_usage_rights_expired_connect_buy_new,
+    ECover_no_usage_rights_connect_buy_new
+};
+
+/*
+* ==============================================================================
+* Parameter definitions for the messages in this file.
+* ==============================================================================
+*/
+
+// Package definition for Matched Item
+struct TUtilitySDData
+    {
+    TUid iUtilityUid;        // DrmUtilityCommon.dll process Id
+    TUid iHandlerProcessId;  // Process Id which is using DrmUtilityCommon.dll
+    TBuf<256> iStringParam;  // Used to transfer string note info
+                             // (like server names, filenames etc..)
+    TBuf<32> iNumParam;      // Used to transfer numeric note info data
+                             // (like days, counts, time)
+                                
+    };    
+
+typedef TPckgBuf<TUtilitySDData> TUtilitySDDataPckg;
+
+// Package definition for cancel event
+struct TUtilitySDDataCancel
+    {    
+    TUid iHandlerProcessId;     // Process Id which is using DrmUtilityCommon.dll
+    TInt iNoteId;               // Dialog id of the cancelled event
+    };
+
+typedef TPckgBuf<TUtilitySDDataCancel> TUtilitySDDataPckgCancel;
+
+#endif // T_DRMUTILITYSECONDARYDISPLAY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/drmutilityui.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,181 @@
+/*
+* 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:  Provides operations for ui usage of DRM Utility API
+*
+*/
+
+
+#ifndef CDRMUTILITYUI_H
+#define CDRMUTILITYUI_H
+
+//*** system include files go here:
+#include <e32base.h>
+#include <f32file.h>
+#include <aknnotifystd.h>
+
+//*** forward declarations go here:
+class CDRMConstraint;
+class CCoeEnv;
+class CStringResourceReader;
+class CEikDialog;
+class CAknResourceNoteDialog;
+class CMediatorEventProvider;
+
+namespace ContentAccess
+    {
+    class CData;
+    }
+
+namespace DRM 
+{
+    
+    //*** forward declarations go here:
+    class CDrmUtilityInfoNoteWrapper;
+    
+ /**
+  *  Utility class for DRM utility related graphic functions
+  *
+  *  @lib drmutilitycommon.lib
+  *  @since S60 v5.0
+  */
+NONSHARABLE_CLASS( CDrmUtilityUI ) : public CBase
+    {
+
+public:
+
+    /**
+     * Creates a new CDrmUtilityUI object and returns a pointer to it
+     *
+     * @return A functional CDrmUtilityUI -object
+     * @leave System wide error code
+     */	
+    IMPORT_C static CDrmUtilityUI* NewL( CCoeEnv* aCoeEnv = NULL );
+
+    /**
+     * Creates a new CDrmUtilityUI object and returns a pointer to it
+     * leaves the returned object to the cleanup stack
+     *
+     * @return A functional CDrmUtilityUI -object
+     * @leave System wide error code
+     */	
+    IMPORT_C static CDrmUtilityUI* NewLC( CCoeEnv* aCoeEnv = NULL );
+
+    /**
+     * Destructor
+     */
+    virtual ~CDrmUtilityUI();
+     
+    /**
+    * Display query dialog
+    */
+    IMPORT_C TInt DisplayQueryWithIdL( TInt aTextResourceId, 
+                                       TInt aQueryResourceId );
+    
+    IMPORT_C TInt DisplayQueryWithIdValueL( TInt aTextResourceId, 
+                                            TInt aQueryResourceId, 
+                                            const TDesC& aString );
+    
+    IMPORT_C TInt DisplayQueryL( TInt aTextResourceId, TInt aValue );
+    
+    IMPORT_C TInt DisplayQueryL( TInt aTextResourceId, const TDesC& aString );
+    
+    IMPORT_C TInt DisplayQueryL( TInt aTextResourceId, 
+        	                     const TDesC& aString, 
+                                 TInt aValue,
+        	                     TInt aStringPos = -1,
+        	                     TInt aValuePos = -1 );
+    
+    IMPORT_C TInt DisplayQueryL( TDesC& aPromptText, TInt aQueryResourceId );
+    
+    IMPORT_C TInt SetAutomatedQueryL( CDRMConstraint* aConstraint );
+
+   /**
+    * Display note
+    */
+    IMPORT_C void ShowFutureRightsNoteL( CDRMConstraint* aConstraint );
+
+    IMPORT_C void DisplayNoteL( TInt aTextResourceId );
+    
+    IMPORT_C void DisplayNoteL( TInt aTextResourceId, const TDesC& aString );
+    
+    IMPORT_C void DisplayNoteL( TInt aTextResourceId, TInt aValue );
+    
+    IMPORT_C void DisplayNoteL( TDesC& aPromptText, 
+                                TInt aResourceId, 
+                                const TDesC& aString = KNullDesC, 
+                                TInt aValue = -1 );   
+                                
+   /**
+    * Display list query
+    */
+    IMPORT_C TInt DisplayPopupWindowsForPreviewL( 
+                                                ContentAccess::CData& aContent,
+                                                TInt aPreviewType, 
+                                                TInt aMediaType );
+
+
+protected:
+
+private:
+
+    CDrmUtilityUI( CCoeEnv* aCoeEnv );
+
+    void ConstructL();
+    
+    CAknResourceNoteDialog* CreateNoteForResourceL( TInt aResId );
+    
+    TAknGlobalNoteType GlobalNoteTypeForResource( TInt aResId );
+    
+    TInt GetOmaStartTime( CDRMConstraint* aConstraint, TTime& aStartTime );
+    
+    TInt EvaluatePreviewMediaTypeL( ContentAccess::CData& aContent,
+                                    TInt aPreviewType );
+    
+    void PrepareSecondaryDisplayL( CEikDialog& aDialog, 
+                                   TInt aResourceId,
+                                   const TDesC& aString = KNullDesC, 
+                                   TInt aValue = -1 );
+                                   
+    void CancelSecondaryDisplayL( TInt aResourceId );
+
+
+private: // Data members
+
+    // Control environment, not owned
+    CCoeEnv* iCoeEnv;
+    
+    // Paths of the resource files
+    HBufC* iUtilityResourceFile;
+    HBufC* iAvkonResourceFile;
+
+    // Resource offsets in CoeEnv, when it is available
+    TInt iUtilityResourceFileOffset;
+    TInt iAvkonResourceFileOffset;
+
+    // Used to read resources when CoeEnv is not available
+    CStringResourceReader* iUtilityStringResourceReader;
+    CStringResourceReader* iAvkonStringResourceReader;
+    
+    // File server
+    RFs iFs;
+    
+    // Used to queue up global notes
+    RPointerArray<CDrmUtilityInfoNoteWrapper> iNoteList;
+
+    CMediatorEventProvider* iEventProvider;
+
+    };
+}
+
+#endif // CDRMUTILITYUI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/drmutilitywmdrm.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,105 @@
+/*
+* 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:  DrmUtilityWmdrmWrapper loader
+*
+*/
+
+
+#ifndef C_DRMUTILITYWMDRM_H
+#define C_DRMUTILITYWMDRM_H
+
+//*** system include files go here:
+#include <e32base.h>
+
+//*** forward declarations go here
+class CCoeEnv;
+
+namespace DRM 
+    {
+
+    //*** forward declarations go here:
+    class CDrmUtilityWMDrmWrapper;
+    class MDrmUtilityWMDrmWrapper;
+
+/**
+ *  This class encapsulates WMDrm functionality
+ *
+ *  @lib drmutilitycommon.lib
+ *  @since S60 v5.0
+ */
+NONSHARABLE_CLASS( CDrmUtilityWMDrm ) : public CBase
+    {
+    
+public:
+
+    /**
+     * Creates a new CDrmUtilityWMDrm object and returns a pointer to it
+     *
+     * @return A functional CDrmUtilityCommon -object
+     * @leave System wide error code
+     */	
+    IMPORT_C static CDrmUtilityWMDrm* NewL( CCoeEnv* aCoeEnv = NULL );
+    
+    /**
+     * Creates a new CDrmUtilityWMDrm object and returns a pointer to it
+     * leaves the returned object to the cleanup stack
+     *
+     * @return A functional CDrmUtilityCommon -object
+     * @leave System wide error code
+     */	
+    IMPORT_C static CDrmUtilityWMDrm* NewLC( CCoeEnv* aCoeEnv = NULL );
+
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDrmUtilityWMDrm();
+
+    /**
+     * Returns a pointer to a class which implements the
+     * MDrmUtilityWMDrmWrapper interface. The ownership
+     * of the instance stays with the CDrmUtilityWMDrm -class
+     *
+     * @since S60 v5.0
+     *
+     * @return A pointer to a functional object implementing the
+     *         MDrmUtilityWMDrmWrapper interface
+     *
+     * @leave None
+     *
+     * @see MDrmUtilityWMDrmWrapper
+     */
+    IMPORT_C MDrmUtilityWMDrmWrapper* GetWrapper();
+
+protected:
+
+private:
+
+    CDrmUtilityWMDrm();
+
+    void ConstructL( CCoeEnv* aCoeEnv );
+
+private: // Data members
+
+    // Handle to load WMDrmWrapper dynamically
+    RLibrary iWMDrmDll;
+    
+    // WMDrm wrapper
+    CDrmUtilityWMDrmWrapper* iWMDrmHandler;
+
+    };
+
+    }
+
+#endif // C_DRMUTILITYWMDRM_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/drmutilitywmdrmwrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,219 @@
+/*
+* Copyright (c) 2006-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:  Wraps WM DRM operations for use with DRM Utility
+*
+*/
+
+
+#ifndef CDRMUTILITYWMDRMWRAPPER_H
+#define CDRMUTILITYWMDRMWRAPPER_H
+
+//*** system include files go here:
+#include <e32base.h>
+#include <f32file.h>
+#include <aknserverapp.h>
+#include <caf/caf.h>
+#include <drmutilitytypes.h>
+
+//*** user include files go here:
+#include "drmwmdrmwrapper.h"
+
+class CWmDrmDlaWrapper;
+
+namespace DRM
+    {
+
+    class CDrmUtilityUI;
+
+ /**
+  *  Utility class for DRM related common functions
+  *
+  *  @lib drmutilityemdrmwrapper.lib
+  *  @since S60 v5.0
+  */
+NONSHARABLE_CLASS( CDrmUtilityWMDrmWrapper ) : public CBase, public MDrmUtilityWMDrmWrapper,
+    public MAknServerAppExitObserver
+    {
+
+public:
+
+    /**
+     * Creates a new CDrmUtilityWMDrmWrapper object and returns a pointer to it
+     *
+     * @return A functional CDrmUtilityWMDrmWrapper -object
+     * @leave System wide error code
+     */
+    IMPORT_C static CDrmUtilityWMDrmWrapper* NewL();
+
+    /**
+     * Creates a new CDrmUtilityWMDrmWrapper object and returns a pointer to it
+     * Leaves the pointer to the cleanup stack
+     *
+     * @return A functional CDrmUtilityWMDrmWrapper -object
+     * @leave System wide error code
+     */
+    IMPORT_C static CDrmUtilityWMDrmWrapper* NewLC();
+
+    /**
+     * Destructor
+     */
+    virtual ~CDrmUtilityWMDrmWrapper();
+
+
+public: // From MDrmUtilityWMDrmWrapper
+
+    /**
+     * Performs the check rights amount operation for windows media files
+     *
+     * @param[in]   aContent    The content itself
+     * @param[in]   aIntent     The intent for the rights to check
+     * @param[in]   aObserver   Observer for callbacks, NULL if not
+     *                          available
+     * @param[in]   aOperatioId The operation id of the async operation
+     * @return none
+     * @leave System wide error code
+     */
+    IMPORT_C void CheckWmRightsAmountL(
+        ContentAccess::CData& aContent,
+        ContentAccess::TIntent aIntent,
+        MDrmUiCheckRightsObserver* aObserver,
+        TInt aOperationId );
+
+    /**
+     * Performs the handle error operation for windows media files
+     *
+     * @param[in]   aContent    The content itself
+     * @param[in]   aIntent     The intent for the rights to check
+     * @param[in]   aError      The error code to be handled
+     * @param[in]   aObserver   Observer for callbacks, NULL if not
+     *                          available
+     * @param[in]   aOperatioId The operation id of the async operation
+     * @return none
+     * @leave System wide error code
+     */
+    IMPORT_C void HandleWmErrorL(
+        ContentAccess::CData& aContent,
+        ContentAccess::TIntent aIntent,
+        TInt aError,
+        MDrmHandleErrorObserver* aObserver,
+        TInt aOperationId );
+
+    /**
+     * Method for setting the control environment
+     *
+     * @param[in]   aCoeEnv     The control environment
+     * @return none
+     */
+    IMPORT_C void SetCoeEnv(
+        CCoeEnv* aCoeEnv );
+
+protected:
+
+private:
+
+    CDrmUtilityWMDrmWrapper();
+
+    void ConstructL();
+
+//*** Callback methods:
+
+    // Callback to observer with info rights not valid and why
+    void CallRightsNotValidL(
+        MDrmUiCheckRightsObserver* aObserver,
+        TInt aOperationId,
+        TCheckRightsStatus aRightsStatus,
+        TUint32 aReason,
+        ContentAccess::CData& aContent,
+        const TDesC& aContentUri );
+
+    // Callback to the observer with the rights left information
+    // if no observer do default handling
+    void CallRightsLeftL(
+        MDrmUiCheckRightsObserver* aObserver,
+        TInt aOperationId,
+        TBool aUnconstrained,
+        TTimeIntervalSeconds aTime,
+        TInt aCounts,
+        TTimeIntervalSeconds aAccumulated,
+        ContentAccess::CData& aContent,
+        const TDesC& aContentUri );
+
+    void CallRightsAvailable(
+        DRM::MDrmHandleErrorObserver* aObserver,
+        TInt aOperationId,
+        TInt aError );
+
+
+//*** Helper methods:
+
+    // Get rights data for WM DRM content
+    void GetRightsDataL(
+        const TDesC& aUniqueId,
+        TBool& aUnconstrained,
+        TTimeIntervalSeconds& aTime,
+        TInt& aCounts,
+        TTimeIntervalSeconds& aAccumulated );
+
+    // Get a rights manager instance
+    ContentAccess::CRightsManager* GetRightsManagerL();
+
+    // Rejection reason mapping from agent reasons to generic
+    TInt RejectReason( TUint32 aReason );
+
+    // Launch rights manager UI
+    void LaunchRightsManagerUiL( const TDesC& aParam16 );
+
+    // Form string needed to launch rights manager UI embedded.
+    void CreateLaunchParamL( const TDesC* aUrl,
+                             HBufC*& aLaunchParam );
+
+    // Handles exit from service from MAknServerAppExitObserver
+    void HandleServerAppExit( TInt aReason );
+
+//*** Notes:
+
+    // Show the appropriate notes
+    void ShowNoRightsNoteL(
+        ContentAccess::CData& aContent,
+        TUint32 aReason );
+
+//*** DLA:
+
+    void LoadDlaWrapperL();
+    void GetRFileFromCDataL( ContentAccess::CData& aContent, RFile& aFile );
+    TBool IsDlaLicenseAcquisitionSilentL( RFile& aFile  );
+    void DlaLicenseAcquisitionL( RFile& aFile );
+    void SilentDlaLicenseAcquisitionL( ContentAccess::CData& aContent );
+    TInt DefaultAccessPointL();
+
+private: // Data members
+
+    // Control environment, not owned
+    CCoeEnv* iCoeEnv;
+
+    // DrmUtilityCommon
+    CDrmUtilityUI* iDrmUtilityUi;
+
+    // Wait for the notes and queries
+    CActiveSchedulerWait iWait;
+
+    RFs iFs;
+
+    RLibrary iDlaWrapperDll;
+    CWmDrmDlaWrapper* iDlaWrapper;
+    };
+}
+
+
+#endif // CDRMUTILITYWMDRMWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/drmwmdrmwrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,93 @@
+/*
+* 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:  Interface for WM DRM Wrapper
+*
+*/
+
+
+#ifndef M_DRMUTILITYWMDRMWRAPPER_H
+#define M_DRMUTILITYWMDRMWRAPPER_H
+
+#include <e32base.h>
+
+//*** forward declarations go here:
+class CCoeEnv;
+
+namespace DRM
+    {
+ 
+class MDrmUiCheckRightsObserver;
+class MDrmHandleErrorObserver;   
+    
+
+/**
+ *
+ *  @since S60 v5.0
+ */
+class MDrmUtilityWMDrmWrapper
+    {
+
+public:
+
+    /**
+     * Performs the check rights amount operation for windows media files
+     *
+     * @param[in]   aContent    The content itself
+     * @param[in]   aIntent     The intent for the rights to check
+     * @param[in]   aObserver   Observer for callbacks, NULL if not 
+     *                          available
+     * @param[in]   aOperatioId The operation id of the async operation
+     * @return none
+     * @leave System wide error code
+     */	
+    virtual void CheckWmRightsAmountL(
+        ContentAccess::CData& aContent, 
+        ContentAccess::TIntent aIntent, 
+        MDrmUiCheckRightsObserver* aObserver,
+        TInt aOperationId ) = 0;
+
+    /**
+     * Performs the handle error operation for windows media files
+     *
+     * @param[in]   aContent    The content itself
+     * @param[in]   aIntent     The intent for the rights to check
+     * @param[in]   aError      The error code to be handled
+     * @param[in]   aObserver   Observer for callbacks, NULL if not 
+     *                          available
+     * @param[in]   aOperatioId The operation id of the async operation
+     * @return none
+     * @leave System wide error code
+     */	
+    virtual void HandleWmErrorL( 
+        ContentAccess::CData& aContent, 
+        ContentAccess::TIntent aIntent, 
+        TInt aError,
+        MDrmHandleErrorObserver* aObserver,
+        TInt aOperationId ) = 0;
+
+    /**
+     * Method for setting the control environment
+     *
+     * @param[in]   aCoeEnv     The control environment
+     * @return none
+     */	
+    virtual void SetCoeEnv(  
+        CCoeEnv* aCoeEnv ) = 0; 
+
+    };
+    
+    }
+
+
+#endif // M_MDRMUTILITYWMDRMWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/inc/rdrmhelperclient.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,146 @@
+/*
+* 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:  the client side class for DRMHelperServer
+*
+*/
+
+
+#ifndef RDRMHELPERCLIENT_H
+#define RDRMHELPERCLIENT_H
+
+// INCLUDES
+#include <e32base.h>
+#include <caf/caftypes.h>
+
+#include "drmutilitytypes.h"
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+using namespace DRM;
+
+/**
+*  This class provides the client-side interface to the server session
+*
+*  @since S60 4.0
+*/
+
+class RDrmHelperClient : public RSessionBase
+    {
+public:  // Constructors and destructor
+
+    /**
+    * C++ default constructor.
+    */
+    RDrmHelperClient();
+
+public:  // New functions
+
+    /**
+    * Connects to server.
+    * @return System-wide error code
+    */
+    TInt Connect();
+
+    /**
+    * Gets the version number
+    * @return version number
+    */
+    TVersion Version() const;
+
+    /**
+    * Register the given content uri as an automated content.
+    * @param aUri: content URI
+    * @param aAutomatedType: type of automated content
+    * @param aIntent: intent how content is used
+    * @param aServiceType: active or passive registration
+    * @return System-wide error code
+    * @see ContentAccess::TIntent
+    */
+    TInt SetAutomated(
+            const TDesC8& aUri,
+            const TDrmAutomatedType aAutomatedType,
+            const ContentAccess::TIntent aIntent,
+            const TDrmAutomatedServiceType aServiceType ) const;
+
+    /**
+    * Unregister the given content.
+    * @param aUri: content URI
+    * @param aServiceType: active or passive registration
+    * @param aAutomatedType: type of automated content
+    * @param aIntent: intent how content is used
+    * @return System-wide error code
+    * @see ContentAccess::TIntent
+    */
+    TInt RemoveAutomated(
+            const TDesC8& aUri,
+            const TDrmAutomatedType aAutomatedType,
+            const ContentAccess::TIntent aIntent,
+            const TDrmAutomatedServiceType aServiceType ) const;
+
+    /**
+    * Unregister all instances of the given content.
+    * @param aUri: content URI
+    * @param aServiceType: active or passive registration
+    * @param aAutomatedType: type of automated content
+    * @param aIntent: intent how content is used
+    * @return System-wide error code
+    * @see ContentAccess::TIntent
+    */
+    TInt RemoveAutomatedAll(
+            const TDesC8& aUri,
+            const TDrmAutomatedType aAutomatedType,
+            const ContentAccess::TIntent aIntent,
+            const TDrmAutomatedServiceType aServiceType ) const;
+            /*(const TDesC8& aUri,
+            TBool aActive,
+            TInt aAutomatedType,
+            TInt aIntent ) const;*/
+
+    /**
+    * Indicate that idle-screen has been activated.
+    * @return System-wide error code
+    */
+    TInt IndicateIdle() const;
+
+private:
+
+    /**
+    * Has given content been registered as automated content.
+    * @param aUri content URI of the content
+    * @param aAutomated (out) ETrue if registered as automated.
+    * @param aType (out) Tells whether content has been
+    *                    registered as active or passive.
+    * @return System-wide error code
+    * @see ContentAccess::TIntent
+    */
+    TInt IsAutomated(
+            const TDesC8& aUri,
+            const TDrmAutomatedType aAutomatedType,
+            const ContentAccess::TIntent aIntent,
+            const TDrmAutomatedServiceType aServiceType,
+            TBool& aAutomated ) const;
+
+    TInt StartServer();
+    TInt CreateServerProcess();
+    };
+
+
+
+#endif      // RDRMHELPERCLIENT_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/loc/DRMUtility.loc	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,162 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Localization strings for DRMUtility
+*
+*/
+
+
+//d: Text in information note when usage rights are not yet valid.
+//d: %U is start date of rights object
+//l: popup_note_window
+//w:
+//r: 2.6
+//
+#define qtn_drm_note_ro_valid_on_future "File can be used from %U"
+
+//d:Progress note shown while rights are acquired silently
+//l:popup_note_wait_window
+//r:3.2
+//
+#define qtn_drm_progress_opening "Opening"
+
+//d: Confirmation query for silent rights acquisition if not allowed in settings
+//l: popup_note_window
+//r: 3.2
+//
+#define qtn_drm_qry_connect_to_activate "File will be unlocked. Connection to Internet is needed. Continue?"
+
+//d: Information note shown when user tries to play content with a silent header and there is no
+//d: connection method defined on the phone.
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_warn_no_conn_defined "Unable to unlock file. Define at least one access point."
+
+//d: Information note shown when user tries to play content with a silent header and the server cannot
+//d: be contacted either because the access point is invalid, packet data context cannot be established,
+//d: or the access point is of wrong type.
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_warn_invalid_or_no_ap "Unable to unlock file. Connection failed with used access point."
+
+//d: Information note shown when user tries to play content with a silent header and there occurs a permanent
+//d: type of ROAP error.
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_err_opening_fail_perm  "Unable to unlock file."
+
+//d: Confirmation query shown when user tries to play content with a silent header and there occurs a temporary
+//d: type of ROAP error. If user accepts the query Browser opens error url.
+//l: popup_note_window
+//r: 3.2
+//
+#define qtn_drm_query_open_error_url "Unable to unlock file. See more information online?"
+
+//d: Text in confirmation query that is displayed when user tries to render MO that is missing RO.
+//d: The waiting time of RO to arrive has not passed yet.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_query_waiting_for_ro "Waiting for licence. Try again later."
+
+//d: Text in confirmation query that is displayed when user tries to render MO that is missing RO.
+//d: The waiting time of RO to arrive has passed, and there is no possibility to get new RO (no rights
+//d: issuer url).
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_query_ro_late "Licence not yet received. Expected time of delivery elapsed."
+
+//d: Text in confirmation query that is displayed when user tries to render MO that is missing RO.
+//d: The waiting time of RO to arrive has passed, and there is possibility to get new RO (rights issuer url exists).
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_query_ro_late_activate "Licence not yet received. Expected time of delivery elapsed. Get new licence?"
+
+//d: Text in confirmation query when user is asked about updating account.
+//d: Device is already connected to network, but must upgrade the domain key before rendering,
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_query_activate_account "Registration will be updated. Continue?"
+
+//d: Text in confirmation query shown when content cannot be rendered because of wrong SIM card in device
+//l: popup_note_window
+//w:
+//r: 3.1
+//
+#define qtn_drm_query_sim_not_allowed "File locked with current SIM card. Unlock for this SIM card?"
+
+//d: Text in information note shown when user tries to set a non-superdistributable file as automated content, but is not allowed with the current SIM
+//l: popup_info_list_pane_t1
+//w:
+//r: 3.1
+//
+#define qtn_drm_info_sim_not_allowed "File locked with current SIM card"
+
+//d: Information note shown when the user attempts to open or play a non-superdistributable MO related to an
+//d: expired RO or a missing RO.
+//l: popup_info_list_pane_t1
+//w:
+//r: 3.2
+//
+#define qtn_drm_info_expired_or_no_ro "License has expired or it is missing"
+
+//d: Confirmation query shown when the user attempts to open or play a non-superdistributable MO related to an
+//d: expired RO or a missing RO. %U in the query stands for the file name.
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_query_expired_or_no_ro "License for %U expired or missing. Get new license now?"
+
+
+//d: Text in confirmation query when content with activated rights is set as automated content.
+//d: %U is expiration date of rights object
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_query_valid_rights_until "Licence for selected item valid until %U. Continue?"
+
+//d: Text in confirmation query
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_query_set_auto_interval "Selected item is valid for limited time. Continue?"
+
+//d: Text in confirmation note when trying to open file but usage reporting is not allowed.
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_query_metering_disabled   "Unable to open file. Change 'Allow usage reporting for' settings."
+
+//d: Heading in message query when user attemps to play a WMDRM file with an expired or missing rights.
+//l: heading_pane_t1
+//w:
+//r: 9.1
+//
+#define qtn_drm_msg_qry_head_no_license "No license"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmAutomatedUsage.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,383 @@
+/*
+* 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:  DRM Automated Usage handling
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    <caf/caftypes.h>
+#include    <caf/data.h>
+#include    <drmautomatedusage.h>
+
+#include    "drmautomatedusageimpl.h"
+#include    "drmautomatedusageerrorhandling.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::CDrmAutomatedUsage
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsage::CDrmAutomatedUsage()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmAutomatedUsage::ConstructL( CCoeEnv* aCoeEnv )
+    {
+    // Create the utility instance
+    iUtility = DRM::CDrmUtility::NewL();
+
+    // Create the implementation class instance
+    iImplementation = DRM::CDrmAutomatedUsageImpl::NewL( aCoeEnv, iUtility );
+
+    // Create the error handler
+    iErrorHandler = DRM::CDrmAutomatedUsageErrorHandling::NewL(
+        iImplementation );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::NewL
+// Two-phased constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmAutomatedUsage* DRM::CDrmAutomatedUsage::NewL(
+    CCoeEnv* aCoeEnv )
+    {
+    DRM::CDrmAutomatedUsage* self( DRM::CDrmAutomatedUsage::NewLC( aCoeEnv ) );
+
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::NewLC
+// Two-phased constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmAutomatedUsage* DRM::CDrmAutomatedUsage::NewLC(
+    CCoeEnv* aCoeEnv )
+    {
+    DRM::CDrmAutomatedUsage* self( new( ELeave ) DRM::CDrmAutomatedUsage );
+
+    CleanupStack::PushL( self );
+    self->ConstructL( aCoeEnv );
+
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::~CDrmAutomatedUsage
+// Destructor
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsage::~CDrmAutomatedUsage()
+    {
+    delete static_cast< DRM::CDrmAutomatedUsageErrorHandling* >(
+        iErrorHandler );
+    delete iImplementation;
+    delete iUtility;
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::GetUtility
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUtility& DRM::CDrmAutomatedUsage::GetUtility() const
+    {
+    return *iUtility;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::GetErrorHandler
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::MDrmErrorHandling& DRM::CDrmAutomatedUsage::GetErrorHandler()
+    const
+    {
+    return *iErrorHandler;
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::CanSetAutomatedL
+// Checks whether given content can be set as automated.
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool DRM::CDrmAutomatedUsage::CanSetAutomatedL(
+    RFile& aFile,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType )
+    {
+    iUtility->CheckFileHandleL( aFile );
+    return iImplementation->CanSetAutomatedL( aFile, aIntent, aAutomatedType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::CanSetAutomatedL
+// Checks whether given content can be set as automated.
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool DRM::CDrmAutomatedUsage::CanSetAutomatedL(
+    const ContentAccess::CData& aData,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType )
+    {
+    return iImplementation->CanSetAutomatedL( aData, aIntent, aAutomatedType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::SetAutomatedL
+// Sets given content as automated.
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsage::SetAutomatedL(
+    RFile& aFile,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    iUtility->CheckFileHandleL( aFile );
+    iImplementation->SetAutomatedL( aFile, 
+                                    aIntent, 
+                                    aAutomatedType, 
+                                    aServiceType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::SetAutomatedAsyncL
+// Sets given content asynchronously as automated.
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsage::SetAutomatedAsyncL(
+    RFile& aFile,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver& aObserver,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    iUtility->CheckFileHandleL( aFile );
+    return iImplementation->SetAutomatedAsyncL( aFile, 
+                                                aIntent, 
+                                                aAutomatedType, 
+                                                aObserver, 
+                                                aServiceType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::SetAutomatedL
+// Sets given content as automated.
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsage::SetAutomatedL(
+    const ContentAccess::CData& aData,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    iImplementation->SetAutomatedL( aData, 
+                                    aIntent, 
+                                    aAutomatedType,
+                                    aServiceType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::SetAutomatedAsyncL
+// Sets given content asynchronously as automated.
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsage::SetAutomatedAsyncL(
+    const ContentAccess::CData& aData,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver& aObserver,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    return iImplementation->SetAutomatedAsyncL( aData, 
+                                                aIntent, 
+                                                aAutomatedType, 
+                                                aObserver, 
+                                                aServiceType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::RemoveAutomatedL
+// Removes content from automated use.
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsage::RemoveAutomatedL(
+    RFile& aFile,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    iUtility->CheckFileHandleL( aFile );
+    iImplementation->RemoveAutomatedL( aFile, 
+                                       aIntent, 
+                                       aAutomatedType, 
+                                       aServiceType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL
+// Removes content from automated use
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL(
+    RFile& aFile,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver& aObserver,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    iUtility->CheckFileHandleL( aFile );
+    return iImplementation->RemoveAutomatedAsyncL( aFile, 
+                                                   aIntent, 
+                                                   aAutomatedType, 
+                                                   aObserver, 
+                                                   aServiceType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::RemoveAutomatedL
+// Removes content from automated use
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsage::RemoveAutomatedL(
+    const ContentAccess::CData& aData,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    iImplementation->RemoveAutomatedL( aData, 
+                                       aIntent, 
+                                       aAutomatedType, 
+                                       aServiceType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL
+// Removes content from automated use
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL(
+    const ContentAccess::CData& aData,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver& aObserver,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    return iImplementation->RemoveAutomatedAsyncL( aData, 
+                                                   aIntent, 
+                                                   aAutomatedType, 
+                                                   aObserver, 
+                                                   aServiceType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::RemoveAutomatedL
+// Removes content from automated use
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsage::RemoveAutomatedL(
+    const TDesC& aUniqueId,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    iImplementation->RemoveAutomatedL( aUniqueId, 
+                                       aIntent, 
+                                       aAutomatedType, 
+                                       aServiceType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL
+// Removes content from automated use
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL(
+    const TDesC& aUniqueId,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver& aObserver,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    return iImplementation->RemoveAutomatedAsyncL( aUniqueId, 
+                                                   aIntent, 
+                                                   aAutomatedType, 
+                                                   aObserver, 
+                                                   aServiceType );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::RegisterEventObserverL
+// Registers the client to listen for automated usage events
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsage::RegisterEventObserverL(
+    DRM::MDrmAutomatedUsageObserver& aObserver )
+    {
+    iImplementation->RegisterEventObserverL( aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::UnregisterEventObserverL
+// Unregisters the client not to listen for automated usage events
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsage::UnregisterEventObserverL(
+    DRM::MDrmAutomatedUsageObserver& aObserver )
+    {
+    iImplementation->UnregisterEventObserverL( aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsage::CancelOperation
+// Cancels the operation
+// (more comments in header file)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsage::CancelOperation( TInt aOperationId )
+    {
+    return iImplementation->CancelOperation( aOperationId );
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmAutomatedUsageImpl.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1030 @@
+/*
+* 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:  DRM Automated Usage handling
+*
+*/
+
+
+// INCLUDE FILES
+#include    <caf/caftypes.h>
+#include    <caf/data.h>
+#include    <oma2agent.h>
+#include    <utf.h>
+#include    <drmrights.h>
+#include    <drmagents.h>
+#include    <e32cmn.h>
+#include    <drmutility.h>
+
+#include    "drmautomatedusageimpl.h"
+#include    "drmautomatedusagedata.h"
+#include    "drmutilityui.h"
+
+// CONSTANTS
+_LIT( KAuClassificationRingingTone, "Ringtone" );
+_LIT( KAuClassificationVideoTone, "Videotone" );
+
+const TInt KUrlMaxLen = 1024;
+const TInt KTimeMarginal = 5000000; // 5 seconds
+
+// FORWARD DECLARATIONS
+class CDRMConstraint;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+LOCAL_C TBool HasInterval( const CDRMConstraint *aConstraint )
+    {
+    return aConstraint->iActiveConstraints & EConstraintInterval;
+    }
+
+LOCAL_C TBool HasEndTime( const CDRMConstraint *aConstraint )
+    {
+    return aConstraint->iActiveConstraints & EConstraintEndTime;
+    }
+
+LOCAL_C TBool EndTimesEqual( const CDRMConstraint *aFirst,
+                             const CDRMConstraint *aSecond )
+    {
+    TBool equal( EFalse );
+    TInt64 difference( aFirst->iEndTime.Int64() - aSecond->iEndTime.Int64() );
+    if( -KTimeMarginal <= difference && difference <= KTimeMarginal )
+        {
+        equal = ETrue;
+        }
+    return equal;
+    }
+
+LOCAL_C TBool IntervalsEqual( const CDRMConstraint *aFirst,
+                              const CDRMConstraint *aSecond )
+    {
+    TBool equal( EFalse );
+    TInt64 startDifference( 
+        aFirst->iIntervalStart.Int64() - aSecond->iIntervalStart.Int64() );
+
+    if( aFirst->iInterval == aSecond->iInterval && 
+        -KTimeMarginal <= startDifference  && 
+        startDifference <= KTimeMarginal )
+        {
+        equal = ETrue;
+        }
+    return equal;    
+    }
+
+
+LOCAL_C HBufC8*  GetContentIdL( const ContentAccess::CData& aData )
+    {
+    HBufC* uniqueId( NULL );
+    HBufC8* uniqueId8( NULL );
+    TPtr value( NULL, 0 );
+
+    uniqueId = HBufC::NewLC( ContentAccess::KMaxCafContentName );
+
+    value.Set( uniqueId->Des() );
+
+    User::LeaveIfError( aData.GetStringAttribute( ContentAccess::EContentID,
+                                                  value ) );
+
+    uniqueId8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( value );
+    CleanupStack::PopAndDestroy( uniqueId );
+
+    return uniqueId8;
+    }
+
+LOCAL_C TBool HasCountOrAccumulated( const CDRMConstraint* aConstraint )
+    {
+    // constraint has counters, timed counters or accumulated
+    if ( aConstraint->iActiveConstraints &  ( EConstraintCounter |
+                                              EConstraintTimedCounter |
+                                              EConstraintAccumulated ) ) 
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+#pragma mark -
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::CDrmAutomatedUsageImpl
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsageImpl::CDrmAutomatedUsageImpl(
+    CCoeEnv* aCoeEnv,
+    DRM::CDrmUtility* aDrmUtility ): CActive( EPriorityStandard ),
+                                     iAuObserver( NULL ),
+                                     iCoeEnv( aCoeEnv ),
+                                     iDrmUtility( aDrmUtility )
+    {
+    
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmAutomatedUsageImpl::ConstructL()
+    {
+    iDrmUtilityUi = DRM::CDrmUtilityUI::NewL( iCoeEnv );
+
+    iDrmQueue = CDrmQueue< DRM::CDrmAutomatedUsageData >::NewL();
+
+    User::LeaveIfError( iOmaClient.Connect() );
+
+    //User::LeaveIfError( iWmClient.Connect() );
+
+    User::LeaveIfError( iDrmHelperClient.Connect() );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmAutomatedUsageImpl* DRM::CDrmAutomatedUsageImpl::NewL(
+    CCoeEnv* aCoeEnv, 
+    DRM::CDrmUtility* aDrmUtility )
+    {
+    DRM::CDrmAutomatedUsageImpl* self( 
+                        DRM::CDrmAutomatedUsageImpl::NewLC( aCoeEnv, 
+                                                            aDrmUtility ) );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmAutomatedUsageImpl* DRM::CDrmAutomatedUsageImpl::NewLC(
+    CCoeEnv* aCoeEnv, DRM::CDrmUtility* aDrmUtility )
+    {
+    DRM::CDrmAutomatedUsageImpl* self(
+                     new( ELeave ) DRM::CDrmAutomatedUsageImpl( aCoeEnv, 
+                                                                aDrmUtility ) );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// Destructor
+DRM::CDrmAutomatedUsageImpl::~CDrmAutomatedUsageImpl()
+    {
+    DRM::CDrmAutomatedUsageData* data( iDrmQueue->PopFront() );
+    
+    // Empty the queue:
+    while ( data )
+        {
+        // Complete the outstanding requestest with cancel
+        data->iObserver->OperationCompleted( data->iOperationId, KErrCancel );
+        delete data;
+        data = iDrmQueue->PopFront();
+        }
+    
+    delete iDrmQueue;
+    
+    delete iDrmUtilityUi;
+    
+    iDrmHelperClient.Close();
+    
+    //iWmClient.Close();
+    
+    iOmaClient.Close();
+    
+    // Remove the object from active scheduler etc.
+    if ( IsAdded() )
+        {
+        Deque();
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::CanSetAutomated
+// Implementation of file-based CanSetAutomated
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+EXPORT_C TBool DRM::CDrmAutomatedUsageImpl::CanSetAutomatedL(
+    RFile& aFile,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType )
+    {
+    TBool returnValue( EFalse );
+    TPtrC drmAgent( KNullDesC );
+    DRM::TDrmProtectionStatus protectedFile( DRM::EUUnknown );
+
+    returnValue = iDrmUtility->GetDrmInfoL( aFile, drmAgent, protectedFile );
+    if ( !returnValue || protectedFile == DRM::EUUnprotected )
+        {
+        // not DRM file at all or not protected DRM file.
+        // So can be set as automated.
+        return ETrue;
+        }
+    if ( drmAgent == DRM::KDrmWMAgentName )
+        {
+        //WMDRM not supported as automated. So no need to continue.
+        return EFalse;
+        }
+
+    ContentAccess::CData* data( 
+            ContentAccess::CData::NewLC( aFile, 
+                                         ContentAccess::KDefaultContentObject,
+                                         ContentAccess::EPeek ) );
+                                                              
+    returnValue = CanSetAutomatedL( *data, aIntent, aAutomatedType );
+    CleanupStack::PopAndDestroy( data );
+    return returnValue;
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::CanSetAutomated
+// Implementation of ContentAccess::CData-based CanSetAutomated
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+EXPORT_C TBool DRM::CDrmAutomatedUsageImpl::CanSetAutomatedL(
+    const ContentAccess::CData& aData,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType )
+    {
+    TInt err( 0 );
+    TInt agentUid( 0 );
+    HBufC8* uniqueId8( NULL );
+    TBool canSetAutomated( EFalse );
+    TBool protectedFile( EFalse );
+
+    User::LeaveIfError( aData.GetAttribute( ContentAccess::EIsProtected, 
+                                            protectedFile ) );
+    if ( !protectedFile )
+        {
+        // not protected. So can be set as automated.
+        return ETrue;
+        }
+
+    User::LeaveIfError( aData.GetAttribute( DRM::EDrmAgentUid, agentUid ) );
+                                                
+    if ( agentUid == DRM::EDrmWmAgent )
+        {
+        //WMDRM not supported as automated. So no need to continue.
+        return EFalse;
+        }
+    
+    uniqueId8 = GetContentIdL( aData );
+    CleanupStack::PushL( uniqueId8 );
+
+    // now check whether there is OMA RO
+    // suitable for automated use
+    canSetAutomated = DoCanSetAutomatedL( *uniqueId8, aIntent, aAutomatedType );
+
+    if( canSetAutomated )
+        {
+        TInt filetype( 0 );
+        User::LeaveIfError( aData.GetAttribute( EFileType, filetype ) );
+        if ( aIntent == ContentAccess::EPlay && filetype == EOma2Dcf )
+            {
+            // If Content type == OMA2 && intent == Play
+            // let's look at classification info
+            TPtr value( NULL, 0 );
+            HBufC* classificationInfo( HBufC::NewLC( KUrlMaxLen ) );
+            value.Set( classificationInfo->Des() );
+
+            err = aData.GetStringAttribute( EClassificationInfo, value );
+            if( err && err != KErrCANotSupported  )
+                {
+                User::Leave( err );
+                }
+
+            if ( classificationInfo->
+                 FindF( KAuClassificationRingingTone ) == KErrNotFound &&
+                 classificationInfo->
+                 FindF( KAuClassificationVideoTone ) == KErrNotFound )
+                {
+                canSetAutomated = EFalse;
+                }
+            CleanupStack::PopAndDestroy( classificationInfo );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( uniqueId8 );
+
+    return canSetAutomated;
+    }
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::SetAutomatedL
+// Implementation of file-based SetAutomated
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsageImpl::SetAutomatedL(
+    RFile& aFile,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    ContentAccess::CData* data =
+        ContentAccess::CData::NewLC( aFile, 
+                                     ContentAccess::KDefaultContentObject, 
+                                     ContentAccess::EPeek );
+    SetAutomatedL( *data, aIntent, aAutomatedType, aServiceType);
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::SetAutomatedAsyncL
+// Implementation of file-based SetAutomated
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsageImpl::SetAutomatedAsyncL(
+    RFile& aFile,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver& aObserver,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    TInt ret( KErrNone );
+
+    ContentAccess::CData* data =
+        ContentAccess::CData::NewLC( aFile, 
+                                     ContentAccess::KDefaultContentObject, 
+                                     ContentAccess::EPeek );
+
+    ret = SetAutomatedAsyncL( *data, aIntent, aAutomatedType, aObserver, aServiceType );
+    
+    CleanupStack::PopAndDestroy( data );
+    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::SetAutomatedL
+// Implementation of ContentAccess::CData-based SetAutomated
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsageImpl::SetAutomatedL(
+    const ContentAccess::CData& aData,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    if ( !CanSetAutomatedL( aData, aIntent, aAutomatedType ) )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    DRM::CDrmAutomatedUsageData* data( 
+        DRM::CDrmAutomatedUsageData::NewLC( 
+                                aData,
+                                aIntent,
+                                aAutomatedType, 
+                                NULL, 
+                                aServiceType,
+                                DRM::CDrmAutomatedUsageData::ESetAutomated ) );
+    
+    User::LeaveIfError ( DoSetAutomatedL( data ) );
+    
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::SetAutomatedAsyncL
+// Implementation of ContentAccess::CData-based SetAutomated
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsageImpl::SetAutomatedAsyncL(
+    const ContentAccess::CData& aData,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver& aObserver,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    if ( !CanSetAutomatedL( aData, aIntent, aAutomatedType ) )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    DRM::CDrmAutomatedUsageData* data( 
+        DRM::CDrmAutomatedUsageData::NewL(
+                                aData, 
+                                aIntent, 
+                                aAutomatedType, 
+                                &aObserver, 
+                                aServiceType,
+                                DRM::CDrmAutomatedUsageData::ESetAutomated ) );
+
+    iDrmQueue->AppendToQueueL( data );
+    
+    TRequestStatus* status( &iStatus );
+    
+    Activate( status );
+    
+    return data->iOperationId;
+    }
+
+#pragma mark -
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::RemoveAutomated
+// Removes content from automated use
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsageImpl::RemoveAutomatedL(
+    RFile& aFile,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    ContentAccess::CData* data( 
+            ContentAccess::CData::NewLC( aFile, 
+                                         ContentAccess::KDefaultContentObject, 
+                                         ContentAccess::EPeek ) );
+
+    RemoveAutomatedL( *data, aIntent, aAutomatedType, aServiceType );
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL
+// Removes content from automated use
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL(
+    RFile& aFile,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver& aObserver,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    TInt ret( KErrNone );
+    
+    ContentAccess::CData* data( 
+            ContentAccess::CData::NewLC( aFile, 
+                                         ContentAccess::KDefaultContentObject, 
+                                         ContentAccess::EPeek ) );
+    
+    ret = RemoveAutomatedAsyncL( *data, 
+                                 aIntent, 
+                                 aAutomatedType, 
+                                 aObserver, 
+                                 aServiceType );
+    
+    CleanupStack::PopAndDestroy( data );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::RemoveAutomatedL
+// Removes content from automated use
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsageImpl::RemoveAutomatedL(
+    const ContentAccess::CData& aData,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    DRM::CDrmAutomatedUsageData* data ( 
+        DRM::CDrmAutomatedUsageData::NewLC(
+                            aData,
+                            aIntent, 
+                            aAutomatedType, 
+                            NULL, 
+                            aServiceType,
+                            DRM::CDrmAutomatedUsageData::ERemoveAutomated ) );
+    
+    User::LeaveIfError( DoRemoveAutomated( data ) );
+    
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL
+// Removes content from automated use
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL(
+    const ContentAccess::CData& aData,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver& aObserver,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    DRM::CDrmAutomatedUsageData* data( 
+        DRM::CDrmAutomatedUsageData::NewL(
+                            aData, 
+                            aIntent, 
+                            aAutomatedType, 
+                            &aObserver, 
+                            aServiceType,
+                            DRM::CDrmAutomatedUsageData::ERemoveAutomated ) );
+
+    iDrmQueue->AppendToQueueL( data );
+    
+    TRequestStatus* status( &iStatus );
+    
+    Activate( status );
+    
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::RemoveAutomatedL
+// Removes content from automated use
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsageImpl::RemoveAutomatedL(
+    const TDesC& aUniqueId,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const DRM::TDrmAutomatedServiceType aServiceType )
+    {
+    DRM::CDrmAutomatedUsageData* data( 
+        DRM::CDrmAutomatedUsageData::NewLC(
+                            aUniqueId,
+                            aIntent,
+                            aAutomatedType,
+                            NULL,
+                            aServiceType,
+                            DRM::CDrmAutomatedUsageData::ERemoveAutomated ) );
+    
+    User::LeaveIfError( DoRemoveAutomated( data ) );
+    
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL
+// Removes content from automated use
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsageImpl::RemoveAutomatedAsyncL(
+    const TDesC& aUniqueId,
+    const ContentAccess::TIntent aIntent,
+    const TDrmAutomatedType aAutomatedType,
+    MDrmAsyncObserver& aObserver,
+    const TDrmAutomatedServiceType aServiceType )
+    {
+    DRM::CDrmAutomatedUsageData* data( 
+        DRM::CDrmAutomatedUsageData::NewL(
+                            aUniqueId, 
+                            aIntent, 
+                            aAutomatedType, 
+                            &aObserver, 
+                            aServiceType,
+                            DRM::CDrmAutomatedUsageData::ERemoveAutomated ) );
+
+    iDrmQueue->AppendToQueueL( data );
+    
+    TRequestStatus* status( &iStatus );
+    
+    Activate( status );
+    
+    return data->iOperationId;
+    }
+
+#pragma mark -
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::RegisterEventObserverL
+// Registers the client to listen for automated usage events
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsageImpl::RegisterEventObserverL(
+    DRM::MDrmAutomatedUsageObserver& aObserver )
+    {
+    if ( iAuObserver )
+        {
+        User::Leave( KErrInUse );
+        }
+    iAuObserver = &aObserver;
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::UnregisterEventObserverL
+// Registers the client to listen for automated usage events
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsageImpl::UnregisterEventObserverL(
+    DRM::MDrmAutomatedUsageObserver& aObserver )
+    {
+    if ( iAuObserver == &aObserver )
+        {
+        iAuObserver=NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::CancelOperation
+// Cancels the async operation
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRM::CDrmAutomatedUsageImpl::CancelOperation( TInt aOperationId )
+    {
+    TInt returnValue( KErrNotFound );
+    DRM::CDrmAutomatedUsageData* data( iDrmQueue->PopItem( aOperationId ) );
+    
+    if ( data )
+        {
+        data->iObserver->OperationCompleted( aOperationId, KErrCancel );
+        delete data;
+        returnValue = KErrNone;
+        }
+    
+    return returnValue;
+    }
+#pragma mark -
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRM::CDrmAutomatedUsageImpl::HandleErrorAsyncL(
+    RFile& /* aFile */,
+    ContentAccess::TIntent /* aIntent */,
+    TInt /* aError */,
+    DRM::MDrmHandleErrorObserver& /* aObserver */ )
+    {
+    User::Leave( KErrNotSupported );
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+EXPORT_C void DRM::CDrmAutomatedUsageImpl::HandleErrorL(
+    RFile& /* aFile */,
+    ContentAccess::TIntent /* aIntent */,
+    TInt /* aError */,
+    DRM::MDrmHandleErrorObserver* /* aObserver */ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRM::CDrmAutomatedUsageImpl::HandleErrorAsyncL(
+    ContentAccess::CData& /* aFile */,
+    ContentAccess::TIntent /* aIntent */,
+    TInt /* aError */,
+    DRM::MDrmHandleErrorObserver& /* aObserver */ )
+    {
+    User::Leave( KErrNotSupported );
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+EXPORT_C void DRM::CDrmAutomatedUsageImpl::HandleErrorL(
+    ContentAccess::CData& /* aFile */,
+    ContentAccess::TIntent /* aIntent */,
+    TInt /* aError */,
+    DRM::MDrmHandleErrorObserver* /* aObserver */ )
+    {
+    }
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDrmAutomatedUsageImpl::DoSetAutomatedL
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmAutomatedUsageImpl::DoSetAutomatedL(
+    DRM::CDrmAutomatedUsageData* aAutomatedUsageData )
+    {
+    if ( DoCanSetAutomatedL(
+            aAutomatedUsageData->iUniqueId8->Des(),
+            aAutomatedUsageData->iIntent,
+            aAutomatedUsageData->iAutomatedType,
+            ETrue ) )
+        {
+        return iDrmHelperClient.SetAutomated(
+            aAutomatedUsageData->iUniqueId8->Des(),
+            aAutomatedUsageData->iAutomatedType,
+            aAutomatedUsageData->iIntent,
+            aAutomatedUsageData->iServiceType );
+        }
+    else
+        {
+        return KErrCancel;
+        }
+    }
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDrmAutomatedUsageImpl::DoCanSetAutomatedL
+// -----------------------------------------------------------------------------
+//
+TBool DRM::CDrmAutomatedUsageImpl::DoCanSetAutomatedL(
+    const TDesC8& aUniqueId8,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const TBool aUseQueries )
+    {
+    TBool canSetAutomated( EFalse );
+    CDRMPermission* activePermission( NULL );
+    TUint32 rejection( KErrNone );
+    CDRMConstraint* constraint( NULL );
+    CDRMConstraint* toplevel( NULL );
+
+    // First, fetch active permission from rights server
+    activePermission = iOmaClient.GetActiveRightsL(
+        aIntent, aUniqueId8, rejection );
+
+    if ( !activePermission )
+        {
+        // No permission found so not possible to set as automated
+        return EFalse;
+        }
+
+    CleanupStack::PushL( activePermission );
+
+    toplevel = activePermission->TopLevelConstraint();
+    constraint = activePermission->ConstraintForIntent( aIntent );
+
+    if ( toplevel )
+        {
+        constraint->Merge( *toplevel );
+        }
+
+    // Active permission for given intent must have valid constraint
+    // and it must not be count or accumulated time based
+    canSetAutomated = !HasCountOrAccumulated( constraint );
+
+    if ( canSetAutomated && aAutomatedType == DRM::EAUAutomatedTypeTheme )
+        {
+        // Automated type is theme so must check whether active RO suits
+        // for theme use
+        canSetAutomated = DoCanSetAutomatedThemeL( aUniqueId8 );
+        }
+
+    if ( canSetAutomated && aUseQueries )
+        {
+        canSetAutomated = iDrmUtilityUi->SetAutomatedQueryL( constraint );
+        }
+    CleanupStack::PopAndDestroy( activePermission );
+    return canSetAutomated;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmAutomatedUsageImpl::DoCanSetAutomatedThemeL
+// -----------------------------------------------------------------------------
+//
+TBool DRM::CDrmAutomatedUsageImpl::DoCanSetAutomatedThemeL(
+    const TDesC8& aUniqueId8 )
+    {
+    TBool canSetAutomatedTheme( ETrue );
+    TUint32 rejection( KErrNone );
+    CDRMPermission* playPermission( NULL );
+    CDRMConstraint* playConstraint( NULL );
+    CDRMConstraint* playToplevel( NULL );
+
+    CDRMPermission* displayPermission( NULL );
+    CDRMConstraint* displayConstraint( NULL );
+    CDRMConstraint* displayToplevel( NULL );
+
+    CDRMPermission* executePermission( NULL );
+    CDRMConstraint* executeConstraint( NULL );
+    CDRMConstraint* executeToplevel( NULL );
+
+    //Check are there active play rights
+    playPermission = iOmaClient.GetActiveRightsL(
+        ContentAccess::EPlay, aUniqueId8, rejection );
+
+    if( !playPermission )
+        {
+        return EFalse;
+        }
+
+    CleanupStack::PushL( playPermission );
+
+    //Check are there active view rights
+    displayPermission = iOmaClient.GetActiveRightsL(
+        ContentAccess::EView, aUniqueId8, rejection );
+
+    if( !displayPermission )
+        {
+        CleanupStack::PopAndDestroy( playPermission );
+        return EFalse;
+        }
+
+    CleanupStack::PushL( displayPermission );
+
+    //Check are there active execute rights
+    executePermission = iOmaClient.GetActiveRightsL(
+        ContentAccess::EExecute, aUniqueId8, rejection );
+
+    if( !executePermission )
+        {
+        CleanupStack::PopAndDestroy( 2 ); //playPermission, displayPermission
+        return EFalse;
+        }
+
+    CleanupStack::PushL( executePermission );
+
+    //If Play, View and Execute rights are valid, test constraints
+    playConstraint =
+        playPermission->ConstraintForIntent( ContentAccess::EPlay );
+    playToplevel = playPermission->TopLevelConstraint();
+    if ( playToplevel )
+        {
+        playConstraint->Merge( *playToplevel );
+        }
+
+    displayConstraint =
+        displayPermission->ConstraintForIntent( ContentAccess::EView );
+    displayToplevel = displayPermission->TopLevelConstraint();
+    if ( displayToplevel )
+        {
+        displayConstraint->Merge( *displayToplevel );
+        }
+
+    executeConstraint =
+        executePermission->ConstraintForIntent( ContentAccess::EExecute );
+    executeToplevel = executePermission->TopLevelConstraint();
+    if ( executeToplevel )
+        {
+        executeConstraint->Merge( *executeToplevel );
+        }
+
+    // Check that all the constraints are not statefull
+    // from stateful ROs, uncactivated interval is ok.
+    if ( HasCountOrAccumulated( playConstraint ) ||
+         HasCountOrAccumulated( displayConstraint ) ||
+         HasCountOrAccumulated( executeConstraint ) )
+        {
+        canSetAutomatedTheme = EFalse;
+        }
+
+    // For end time based, end times must match
+    if ( canSetAutomatedTheme &&
+         ( HasEndTime( playConstraint ) ||
+           HasEndTime( displayConstraint ) ||
+           HasEndTime( executeConstraint ) ) )
+        {
+        canSetAutomatedTheme =
+            HasEndTime( playConstraint ) &&
+            HasEndTime( displayConstraint ) &&
+            HasEndTime( executeConstraint ) &&
+            EndTimesEqual( playConstraint, displayConstraint ) &&
+            EndTimesEqual( playConstraint, executeConstraint );
+        }
+
+    // For Interval based, intervals and interval activation times must match
+    if ( canSetAutomatedTheme &&
+         ( HasInterval( playConstraint ) ||
+           HasInterval( displayConstraint ) ||
+           HasInterval( executeConstraint ) ) )
+        {
+        canSetAutomatedTheme =
+            HasInterval( playConstraint ) &&
+            HasInterval( displayConstraint ) &&
+            HasInterval( executeConstraint ) &&
+            IntervalsEqual( playConstraint, displayConstraint ) &&
+            IntervalsEqual( playConstraint, executeConstraint );
+        }
+
+    CleanupStack::PopAndDestroy( 3 ); //playPermission, viewPermission,
+    //executePermission
+
+    return canSetAutomatedTheme;
+    }
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDrmAutomatedUsageImpl::DoRemoveAutomated
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmAutomatedUsageImpl::DoRemoveAutomated(
+    DRM::CDrmAutomatedUsageData* aAutomatedUsageData )
+    {
+    return iDrmHelperClient.RemoveAutomated(
+        aAutomatedUsageData->iUniqueId8->Des(),
+        aAutomatedUsageData->iAutomatedType,
+        aAutomatedUsageData->iIntent,
+        aAutomatedUsageData->iServiceType );
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDrmAutomatedUsageImpl::DoCancel
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmAutomatedUsageImpl::DoCancel()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmAutomatedUsageImpl::RunL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmAutomatedUsageImpl::RunL()
+    {
+    DRM::CDrmAutomatedUsageData* data( iDrmQueue->PopFront() );
+    TRequestStatus *status( &iStatus );
+    
+    if ( !data )
+        {
+        return;
+        }
+    
+    CleanupStack::PushL( data );        
+    
+    // Take this into the "current" variable in case an error occurs
+    iObserver = data->iObserver;
+    iOperationId = data->iOperationId;
+    
+    TInt err( KErrNone );
+        
+    switch ( data->iOperation )
+        {
+        case DRM::CDrmAutomatedUsageData::ESetAutomated:
+            
+            err = DoSetAutomatedL( data );
+            
+            break;
+        
+        case DRM::CDrmAutomatedUsageData::ERemoveAutomated:
+            
+            err = DoRemoveAutomated( data );
+            
+            break;
+        
+        default:
+            
+            err = KErrArgument;
+            
+            break;
+        }
+    
+    iObserver->OperationCompleted( iOperationId, err );
+    
+    CleanupStack::PopAndDestroy( data );
+    
+    // Get ready for another round:    
+    SetActive();
+    
+    // complete internal request: 
+    User::RequestComplete( status, KErrNone );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageImpl::RunError
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmAutomatedUsageImpl::RunError( 
+    TInt aError )
+    {
+    iObserver->OperationCompleted( iOperationId, aError );
+    iObserver = NULL;
+    iOperationId = NULL;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmAutomatedUsageImpl::Activate
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmAutomatedUsageImpl::Activate( TRequestStatus*& aStatus )
+    {
+    if ( !IsAdded() )
+        {
+        CActiveScheduler::Add( this );
+        }
+   
+    if ( !IsActive() ) 
+        {
+        SetActive();        
+    
+        // complete internal request: 
+        User::RequestComplete( aStatus, KErrNone ); 
+        }
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmQueue.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,213 @@
+/*
+* Copyright (c) 2006 - 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:  DRM Queue
+*
+*/
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmQueue
+// Constructor
+// -----------------------------------------------------------------------------
+//
+template< class T > inline DRM::CDrmQueue< T >::CDrmQueue() : CBase()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// ~CDrmQueue
+// Destructor
+// -----------------------------------------------------------------------------
+//
+template< class T > inline DRM::CDrmQueue< T >::~CDrmQueue()
+    {
+    T* payload = PopFront();
+
+    // Empty the queue:
+    while( payload )
+        {
+        delete payload;
+        payload = PopFront();
+        }
+    iSemaphore.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmQueue::ConstructL()
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+template< class T > inline void DRM::CDrmQueue< T >::ConstructL()
+    {
+    User::LeaveIfError( iSemaphore.CreateLocal(1) );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmQueue::NewLC
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+template< class T > inline DRM::CDrmQueue< T >* DRM::CDrmQueue< T >::NewLC()
+    {
+    DRM::CDrmQueue< T >* self( new( ELeave ) DRM::CDrmQueue< T >() );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmQueue::NewL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+template< class T > inline DRM::CDrmQueue< T >* DRM::CDrmQueue< T >::NewL()
+    {
+    DRM::CDrmQueue< T >* self( DRM::CDrmQueue< T >::NewLC() );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::AppendToQueue
+// -----------------------------------------------------------------------------
+//
+template< class T > inline void DRM::CDrmQueue< T >::AppendToQueueL( T* aData )
+    {
+    CleanupStack::PushL( aData );
+
+    QueueData* data( new (ELeave) QueueData );
+    // insert the data into the queue object
+    data->iData = aData;
+    data->iNext = NULL;
+
+    CleanupStack::Pop( aData );
+
+    // Critical area start:
+    iSemaphore.Wait();
+
+    if( !iLast )
+        {
+        iFirst = data;
+        iLast = iFirst;
+        }
+    else
+        {
+        iLast->iNext = data;
+        iLast = data;
+        }
+
+    // Critical area end
+    iSemaphore.Signal();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::PopFront
+// -----------------------------------------------------------------------------
+//
+template< class T > inline T* DRM::CDrmQueue< T >::PopFront()
+    {
+    QueueData* data = NULL;
+    T* payload = NULL;
+
+    // If there is nothing in the queue return NULL
+    if( !iFirst )
+        {
+        return payload;
+        }
+
+    // Critical area start:
+    iSemaphore.Wait();
+
+    data = iFirst;
+
+    // Set the first and the next
+    iFirst = iFirst->iNext;
+
+    // reset the pointer on data
+    data->iNext = NULL;
+
+    // if there is no next in iFirst, this is the last or if there is no iFirst
+    if( !iFirst || !iFirst->iNext )
+        {
+        iLast = iFirst;
+        }
+
+    // Critical Area End
+    iSemaphore.Signal();
+
+    payload = data->iData;
+    delete data;
+    data = NULL;
+
+    return payload;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::PopItem
+// -----------------------------------------------------------------------------
+//
+template< class T > inline T* DRM::CDrmQueue< T >::PopItem( TInt aId )
+    {
+    QueueData* current( iFirst );
+    QueueData* previous( NULL );
+    T* payload( NULL );
+
+    // If there is nothing in the queue return NULL
+    if( !iFirst )
+        {
+        return payload;
+        }
+    // Critical area start:
+    iSemaphore.Wait();
+    // Iterate over all items in the queue
+    while ( current )
+        {
+        if ( aId == current->iData->iOperationId )
+            {
+            payload = current->iData;
+            current->iData = NULL;
+            if ( previous )
+                {
+                // Previous present. So its member iNext must be updated.
+                previous->iNext = current->iNext;
+                }
+            else
+                {
+                // previous not present, so current was first,
+                // and iFirst must be updated.
+                iFirst = current->iNext;
+                }
+
+            if ( !current->iNext )
+                {
+                // Current was last item. So iLast must be updated.
+                iLast = previous;
+                }
+            current->iNext = NULL;
+            delete current;
+            break;
+            }
+        previous = current;
+        current = current->iNext;
+        }
+    // Critical Area End
+    iSemaphore.Signal();
+    return payload;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmRightsInfo.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2006-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:  DRM Rights Information Handling
+*
+*/
+
+
+// INCLUDE FILES
+#include <drmutility.h>
+#include <drmrightsinfo.h>
+#include <drmasyncobserver.h>
+
+#include "drmrightsinfoimpl.h"
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfo::CDrmRightsInfo
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmRightsInfo::CDrmRightsInfo()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfo::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmRightsInfo::ConstructL()
+    {
+    iImplementation = DRM::CDrmRightsInfoImpl::NewL();
+    iUtility = DRM::CDrmUtility::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfo::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmRightsInfo* DRM::CDrmRightsInfo::NewL()
+    {
+    DRM::CDrmRightsInfo* self( NewLC() );
+    
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfo::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmRightsInfo* DRM::CDrmRightsInfo::NewLC()
+    {
+    DRM::CDrmRightsInfo* self( new( ELeave ) CDrmRightsInfo );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    return self;
+    }
+
+    
+// Destructor
+DRM::CDrmRightsInfo::~CDrmRightsInfo()
+    {
+    delete iImplementation;
+    delete iUtility;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfo::GetUtility
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C DRM::CDrmUtility& DRM::CDrmRightsInfo::GetUtility() const
+    {
+    return *iUtility;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfo::CheckRightsL
+// Syncronous method
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C void DRM::CDrmRightsInfo::CheckRightsL( 
+    const TDesC& aUniqueId, 
+    ContentAccess::TIntent aIntent,
+    DRM::TDrmRightsInfo& aDetails )
+    {
+    iImplementation->CheckRightsL( aUniqueId, aIntent, aDetails );    
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfo::CheckRightsL
+// Asyncronous method
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C TInt DRM::CDrmRightsInfo::CheckRightsAsyncL( 
+    const TDesC& aUniqueId, 
+    ContentAccess::TIntent aIntent,
+    DRM::TDrmRightsInfo& aDetails,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    TInt operation = iImplementation->CheckRightsAsyncL( aUniqueId, 
+                                                         aIntent, 
+                                                         aDetails, 
+                                                         aObserver );
+    return operation;                                                
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfo::CancelOperation
+// Cancels the operation
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmRightsInfo::CancelOperation( TInt aOperationId )
+    {
+    return iImplementation->CancelOperation( aOperationId );
+    } 
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmRightsInfoData.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* Copyright (c) 2006-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:  DrmRightsInfoImpl async command storage class
+*
+*/
+
+
+// INCLUDE FILES
+#include "drmrightsinfodata.h"
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoData::NewLC
+// Two-Phase constructor
+// -----------------------------------------------------------------------------
+//     
+DRM::CDrmRightsInfoData* DRM::CDrmRightsInfoData::NewL()
+    {
+    DRM::CDrmRightsInfoData* self( NewLC() );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoData::NewLC
+// Two-Phase constructor
+// -----------------------------------------------------------------------------
+//     
+DRM::CDrmRightsInfoData* DRM::CDrmRightsInfoData::NewLC()
+    {
+    DRM::CDrmRightsInfoData* self( new (ELeave) CDrmRightsInfoData );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;    
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+//  
+DRM::CDrmRightsInfoData::CDrmRightsInfoData()
+	{
+	}
+	
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//  
+DRM::CDrmRightsInfoData::~CDrmRightsInfoData()
+	{
+	delete iUniqueId;
+	delete iUniqueId8;
+	}
+	
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoData::ConstructL
+// Second phase constructor
+// -----------------------------------------------------------------------------
+//  
+void DRM::CDrmRightsInfoData::ConstructL()
+    {
+    }
+    
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmRightsInfoImpl.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,429 @@
+/*
+* Copyright (c) 2006-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:  DRM Rights Information handling implementation class
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <caf/caftypes.h>
+#include <oma2agent.h>
+#include <utf.h>
+#include <drmutilitytypes.h>
+#include <drmasyncobserver.h>
+
+#include "drmrightsinfoimpl.h"
+#include "drmrightsinfodata.h"
+#include "drmutilitycommon.h"
+
+// CONSTANTS
+const TInt KCommandCheckRights( 1 );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::CDrmRightsInfoImpl
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmRightsInfoImpl::CDrmRightsInfoImpl(): CActive( EPriorityStandard )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmRightsInfoImpl::ConstructL()
+    {
+    iDrmUtilityCommon = DRM::CDrmUtilityCommon::NewL();
+
+    User::LeaveIfError( iOmaClient.Connect() );
+
+    User::LeaveIfError( iSemaphore.CreateLocal( 1 ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmRightsInfoImpl* DRM::CDrmRightsInfoImpl::NewL()
+    {
+    DRM::CDrmRightsInfoImpl* self( NewLC() );
+
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmRightsInfoImpl* DRM::CDrmRightsInfoImpl::NewLC()
+    {
+    DRM::CDrmRightsInfoImpl* self( new( ELeave ) CDrmRightsInfoImpl );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+
+    return self;
+    }
+
+
+// Destructor
+DRM::CDrmRightsInfoImpl::~CDrmRightsInfoImpl()
+    {
+    DRM::CDrmRightsInfoData* data( PopFront() );
+
+    // Empty the queue:
+    while ( data )
+        {
+        // Complete the outstanding requestest with cancel
+        data->iObserver->OperationCompleted( data->iOperationId, KErrCancel );
+        delete data;
+        data = PopFront();
+        }
+
+    delete iDrmUtilityCommon;
+
+    iOmaClient.Close();
+
+    // Close the semaphone
+    iSemaphore.Close();
+
+    // Remove the object from active scheduler etc.
+    if ( IsAdded() )
+        {
+        Deque();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfo::CheckRightsL
+// Syncronous method
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmRightsInfoImpl::CheckRightsL(
+    const TDesC& aUniqueId,
+    ContentAccess::TIntent aIntent,
+    DRM::TDrmRightsInfo& aDetails )
+    {
+    DRM::CDrmRightsInfoData* data( DRM::CDrmRightsInfoData::NewLC() );
+
+    data->iUniqueId = aUniqueId.AllocL();
+    TRAPD( err, data->iUniqueId8 =
+                CnvUtfConverter::ConvertFromUnicodeToUtf8L( aUniqueId ) );
+    if ( err )
+        {
+        data->iUniqueId8 = NULL;
+        }
+    data->iIntent = aIntent;
+    data->iDetails = &aDetails;
+
+    PerformCheckRightsL( *data );
+
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfo::CheckRightsAsyncL
+// Asyncronous method
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmRightsInfoImpl::CheckRightsAsyncL(
+    const TDesC& aUniqueId,
+    ContentAccess::TIntent aIntent,
+    DRM::TDrmRightsInfo& aDetails,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    // Create Queue object:
+    DRM::CDrmRightsInfoData* data( DRM::CDrmRightsInfoData::NewLC() );
+    TRequestStatus* status( &iStatus );
+
+    data->iObserver = &aObserver;
+    data->iOperationId = reinterpret_cast<TInt>( data );
+    data->iOperation = KCommandCheckRights;
+    data->iUniqueId = aUniqueId.AllocL();
+    TRAPD( err, data->iUniqueId8 =
+                CnvUtfConverter::ConvertFromUnicodeToUtf8L( aUniqueId ) );
+    if ( err )
+        {
+        data->iUniqueId8 = NULL;
+        }
+    data->iIntent = aIntent;
+    data->iDetails = &aDetails;
+
+    // Add it to the queue:
+    AppendToQueue( data );
+
+    // Pop it from the cleanup stack
+    CleanupStack::Pop( data );
+
+    if( !IsAdded() )
+        {
+        CActiveScheduler::Add( this );
+        }
+
+    if ( !IsActive() )
+        {
+        SetActive();
+
+        // complete internal request:
+        User::RequestComplete( status, KErrNone );
+
+        }
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::CancelOperation
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmRightsInfoImpl::CancelOperation( TInt aOperationId )
+    {
+    // Critical area start:
+    iSemaphore.Wait();
+
+    TBool found( EFalse );
+
+    DRM::CDrmRightsInfoData* previousData( NULL );
+    DRM::CDrmRightsInfoData* currentData( iFirst );
+
+    while ( currentData )
+        {
+        if ( currentData->iOperationId == aOperationId )
+            {
+            found = ETrue;
+
+            //Update the previous link
+            if ( previousData )
+                {
+                previousData->iNext = currentData->iNext;
+                }
+            else
+                {
+                iFirst = currentData->iNext;
+                }
+
+            //If the current is the only one, set iLast NULL
+            if ( !iFirst )
+                {
+                iLast = NULL;
+                }
+            //If only one left, set it also to be the iLast
+            else if ( iFirst && !currentData->iNext )
+                {
+                iLast = iFirst;
+                }
+
+            //Delete the cancelled operation
+            currentData->iObserver->OperationCompleted( currentData->iOperationId, KErrCancel );
+            delete currentData;
+            currentData = NULL;
+            }
+        else
+            {
+            previousData = currentData;
+            currentData = currentData->iNext;
+            }
+        }
+
+    if( !found )
+        {
+        // Critical Area End
+        iSemaphore.Signal();
+        return KErrNotFound;
+        }
+    // Critical Area End
+    iSemaphore.Signal();
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::DoCancel
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmRightsInfoImpl::DoCancel()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::RunL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmRightsInfoImpl::RunL()
+    {
+    DRM::CDrmRightsInfoData* data( PopFront() );
+    TRequestStatus* status( &iStatus );
+
+    if( !data )
+        {
+        return;
+        }
+
+    CleanupStack::PushL( data );
+
+    switch ( data->iOperation )
+        {
+        case KCommandCheckRights:
+
+          // Take this into the "current" variable in case an error occurs
+          iObserver = data->iObserver;
+          iOperationId = data->iOperationId;
+
+          // Perform the operation
+          PerformCheckRightsL( *data );
+
+          // Compelete the client request
+          iObserver->OperationCompleted( iOperationId, KErrNone );
+
+          break;
+        default:
+          // Do nothing
+          break;
+        }
+
+    // destroy the object:
+    CleanupStack::PopAndDestroy( data );
+
+
+    // Get ready for another round:
+    SetActive();
+
+    // complete internal request:
+    User::RequestComplete( status, KErrNone );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::RunError
+// If an error occurs complete the async request with it
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmRightsInfoImpl::RunError( TInt aError )
+    {
+    iObserver->OperationCompleted( iOperationId, aError );
+    iObserver = NULL;
+    iOperationId = NULL;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::PerformCheckRightsL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmRightsInfoImpl::PerformCheckRightsL(
+    DRM::CDrmRightsInfoData& aData )
+    {
+    // Check for Oma Drm Rights, if not found, check for WmDrm Rights
+    TInt omaerror( KErrNone );
+    TInt wmerror( KErrNone );
+    TUint32 reason( 0 );
+
+    // if the outcome is KErrCANoRights we have the check both:
+    omaerror = iOmaClient.CheckRights( aData.iIntent, *aData.iUniqueId8,  reason );
+    if ( omaerror == KErrCANoRights )
+        {
+        *aData.iDetails = DRM::EURightsInfoMissing;
+        // Check Also WmDrm
+        // wmerror = check rights for WMDRM
+        // Show info for wm drm error
+        if ( !wmerror )
+            {
+
+            }
+        }
+    else
+        {
+        if ( !omaerror )
+            {
+            *aData.iDetails = DRM::EURightsInfoValid;
+            }
+        else
+            {
+            *aData.iDetails = iDrmUtilityCommon->GetOmaRightsStatusL(
+                                                        aData.iUniqueId8,
+                                                        aData.iIntent,
+                                                        NULL );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::AppendToQueue
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmRightsInfoImpl::AppendToQueue( DRM::CDrmRightsInfoData* aData )
+    {
+    // Critical area start:
+    iSemaphore.Wait();
+
+    if ( !iLast )
+        {
+        iFirst = aData;
+        iLast = iFirst;
+        }
+    else
+        {
+        iLast->iNext = aData;
+        iLast = aData;
+        }
+
+    // Critical area end
+    iSemaphore.Signal();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsInfoImpl::PopFront
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmRightsInfoData* DRM::CDrmRightsInfoImpl::PopFront()
+    {
+    DRM::CDrmRightsInfoData* data = NULL;
+
+    // If there is nothing in the queue return NULL
+    if ( !iFirst )
+        {
+        return data;
+        }
+
+    // Critical area start:
+    iSemaphore.Wait();
+
+    data = iFirst;
+
+    // Set the first and the next
+    iFirst = iFirst->iNext;
+
+    // reset the pointer on data
+    data->iNext = NULL;
+
+    // if there is no next in iFirst, this is the last or if there is no iFirst
+    if ( !iFirst || !iFirst->iNext )
+        {
+        iLast = iFirst;
+        }
+
+    // Critical Area End
+    iSemaphore.Signal();
+
+    return data;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmUiHandling.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,357 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRM UI Handling
+*
+*/
+
+
+// INCLUDE FILES
+#include <drmutility.h>
+#include <drmuihandling.h>
+#include <coemain.h>
+
+#include "drmuierrorhandling.h"
+#include "drmuihandlingimpl.h"
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::CDrmUiHandling
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUiHandling::CDrmUiHandling( )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandling::ConstructL( CCoeEnv* aCoeEnv )
+    {
+    // CDrmUtility instance
+    iUtility = DRM::CDrmUtility::NewL();
+
+    // Implementation instance
+    iImplementation = DRM::CDrmUiHandlingImpl::NewL(
+        iUtility, aCoeEnv ? aCoeEnv : CCoeEnv::Static() );
+
+    // Does not take ownership of the iImplementation, just uses it
+    iErrorHandler = DRM::CDrmUiErrorHandling::NewL( iImplementation );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUiHandling* DRM::CDrmUiHandling::NewL( CCoeEnv* aCoeEnv )
+    {
+    DRM::CDrmUiHandling* self( NewLC( aCoeEnv ) );
+
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUiHandling* DRM::CDrmUiHandling::NewLC( CCoeEnv* aCoeEnv )
+    {
+   DRM:: CDrmUiHandling* self( new( ELeave ) CDrmUiHandling );
+
+    CleanupStack::PushL( self );
+    self->ConstructL( aCoeEnv );
+
+    return self;
+    }
+
+
+// Destructor
+DRM::CDrmUiHandling::~CDrmUiHandling()
+    {
+    delete static_cast< DRM::CDrmUiErrorHandling* >( iErrorHandler );
+    delete iImplementation;
+    delete iUtility;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::GetUtility
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUtility& DRM::CDrmUiHandling::GetUtility() const
+    {
+    return *iUtility;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::GetErrorHandler
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::MDrmErrorHandling& DRM::CDrmUiHandling::GetErrorHandler() const
+    {
+    return *iErrorHandler;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::CheckRightsAmountAsyncL
+// Check how much rights there are left for the content.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandling::CheckRightsAmountAsyncL(
+    RFile& aFile,
+    ContentAccess::TIntent aIntent,
+    DRM::MDrmUiCheckRightsObserver& aObserver )
+    {
+    TInt operation = iImplementation->CheckRightsAmountAsyncL( aFile,
+                                                               aIntent,
+                                                               aObserver );
+    return operation;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::CheckRightsAmount
+// Check how much rights there are left for the content.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandling::CheckRightsAmountL(
+    RFile& aFile,
+    ContentAccess::TIntent aIntent,
+    DRM::MDrmUiCheckRightsObserver* aObserver )
+    {
+    iImplementation->CheckRightsAmountL( aFile, aIntent, aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::CheckRightsAmountAsyncL
+// Check how much rights there are left for the content.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandling::CheckRightsAmountAsyncL(
+    ContentAccess::CData& aFile,
+    ContentAccess::TIntent aIntent,
+    DRM::MDrmUiCheckRightsObserver& aObserver )
+    {
+    TInt operation = iImplementation->CheckRightsAmountAsyncL( aFile,
+                                                               aIntent,
+                                                               aObserver );
+    return operation;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::CheckRightsAmountL
+// Check how much rights there are left for the content.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandling::CheckRightsAmountL(
+    ContentAccess::CData& aFile,
+    ContentAccess::TIntent aIntent,
+    DRM::MDrmUiCheckRightsObserver* aObserver )
+    {
+    iImplementation->CheckRightsAmountL( aFile, aIntent, aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::ShowDetailsViewAsyncL
+// Shows DRM specif details
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandling::ShowDetailsViewAsyncL(
+    RFile& aFile,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    TInt operation = iImplementation->ShowDetailsViewAsyncL( aFile, aObserver );
+    return operation;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::ShowDetailsViewL
+// Shows DRM specif details
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandling::ShowDetailsViewL( RFile& aFile )
+    {
+    iImplementation->ShowDetailsViewL( aFile );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::ShowDetailsViewAsyncL
+// Shows DRM specif details
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandling::ShowDetailsViewAsyncL(
+    ContentAccess::CData& aFile,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    TInt operation = iImplementation->ShowDetailsViewAsyncL( aFile, aObserver );
+    return operation;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::ShowDetailsViewL
+// Shows DRM specif details
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandling::ShowDetailsViewL( ContentAccess::CData& aFile )
+    {
+    iImplementation->ShowDetailsViewL( aFile );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::HandleUrlAsyncL
+// Handles the specific url defined by the file
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandling::HandleUrlAsyncL(
+    RFile& aFile,
+    DRM::TDrmUiUrlType aType,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    TInt operation = iImplementation->HandleUrlAsyncL( aFile, aType, aObserver );
+    return operation;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::HandleUrlL
+// Handles the specific url defined by the file
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandling::HandleUrlL(
+    RFile& aFile,
+    DRM::TDrmUiUrlType aType )
+    {
+    iImplementation->HandleUrlL( aFile, aType );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::HandleUrlAsyncL
+// Handles the specific url defined by the file
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandling::HandleUrlAsyncL(
+    ContentAccess::CData& aFile,
+    DRM::TDrmUiUrlType aType,
+    DRM::MDrmAsyncObserver& aObserver  )
+    {
+    TInt operation = iImplementation->HandleUrlAsyncL( aFile, aType, aObserver );
+    return operation;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::HandleUrlL
+// Handles the specific url defined by the file
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandling::HandleUrlL(
+    ContentAccess::CData& aFile,
+    DRM::TDrmUiUrlType aType )
+    {
+    iImplementation->HandleUrlL( aFile, aType );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::AvailableUrlsAsyncL
+// Gets information of the available urls
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandling::AvailableUrlsAsyncL(
+    RFile& aFile,
+    DRM::TDrmUiUrlType& aType,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    TInt operation = iImplementation->AvailableUrlsAsyncL( aFile, aType, aObserver );
+    return operation;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::AvailableUrlsL
+// Gets information of the available urls
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandling::AvailableUrlsL(
+    RFile& aFile,
+    DRM::TDrmUiUrlType& aType )
+    {
+    iImplementation->AvailableUrlsL( aFile, aType );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::AvailableUrlsAsyncL
+// Gets information of the available urls
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandling::AvailableUrlsAsyncL(
+    ContentAccess::CData& aFile,
+    DRM::TDrmUiUrlType& aType,
+    DRM::MDrmAsyncObserver& aObserver  )
+    {
+    TInt operation = iImplementation->AvailableUrlsAsyncL( aFile, aType, aObserver );
+    return operation;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::AvailableUrlsL
+// Gets information of the available urls
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandling::AvailableUrlsL(
+    ContentAccess::CData& aFile,
+    DRM::TDrmUiUrlType& aType )
+    {
+    iImplementation->AvailableUrlsL( aFile, aType );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandling::CancelOperation
+// Cancels the operation
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandling::CancelOperation( TInt aOperationId )
+    {
+    return iImplementation->CancelOperation( aOperationId );
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmUiHandlingImpl.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4341 @@
+/*
+ * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  DRM UI Handling implementation class
+ *
+ */
+
+// INCLUDE FILES
+
+// connection
+#include <cmconnectionmethod.h>
+#include <cmdestination.h>
+#include <cmconnectionmethoddef.h>
+#include <cmmanager.h>
+#include <sacls.h>
+#include <utf.h>
+
+// publish & subscribe
+#include <e32property.h>
+#include <psvariables.h>
+#include <centralrepository.h>
+
+// coeenv
+#include <coemain.h>
+#include <apgtask.h>
+#include <avkon.hrh>
+#include <aknenv.h>
+
+// browser
+#ifdef __SERIES60_NATIVE_BROWSER
+#include <browseruisdkcrkeys.h>
+#endif
+
+// caf
+#include <caf/data.h>
+#include <caf/caftypes.h>
+
+// launching embedded details view
+#include <aknlaunchappservice.h>
+#include <aiwgenericparam.h>
+#include <apgcli.h>
+
+// character conversions
+#include <utf.h>
+
+// handling urls
+#include <schemehandler.h>
+
+// resources
+#include <data_caging_path_literals.hrh>
+#include <drmutility.rsg>
+
+// drm
+#include <oma2agent.h>
+#include <drmagents.h>
+#include <drmpermission.h>
+#include <drmconstraint.h>
+#include <drmrightsclient.h>
+#include <drmutility.h>
+#include <drmutilitytypes.h>
+#include <drmasyncobserver.h>
+#include <drmhandleerrorobserver.h>
+
+#ifdef _DEBUG
+#include <e32debug.h>
+#endif
+
+#include "drmutilitycommon.h"
+#include "drmutilityui.h"
+#include "drmuihandlingimpl.h"
+#include "drmuihandlingdata.h"
+#include "drmutilitydownloadmanager.h"
+#include "drmutilityinternaltypes.h"
+#include "drmuicheckrightsobserver.h"
+#include "drmutilitywmdrm.h"
+#include "drmutilitywmdrmwrapper.h"
+
+#include "roapstorageclient.h"
+#include "drmtypes.h"
+#include "drmsettingsplugininternalcrkeys.h"
+#include "drmricontext.h"
+#include "drmdomaincontext.h"
+
+#include "drmutilityinternalcrkeys.h"      // Cenrep extension for OmaBased
+
+// CONSTANTS
+const TInt KCommandHandleErrorFile( 1 );
+const TInt KCommandHandleErrorData( 2 );
+const TInt KCommandCheckRightsAmountFile( 3 );
+const TInt KCommandCheckRightsAmountData( 4 );
+const TInt KCommandShowDetailsViewFile( 5 );
+const TInt KCommandShowDetailsViewData( 6 );
+const TInt KCommandHandleUrlFile( 7 );
+const TInt KCommandHandleUrlData( 8 );
+const TInt KCommandAvailableUrlsFile( 9 );
+const TInt KCommandAvailableUrlsData( 10 );
+// browser
+#ifndef __SERIES60_NATIVE_BROWSER
+const TUid KCRUidBrowser =
+    {0x10008D39};
+const TUint32 KBrowserDefaultAccessPoint = 0x0000000E;
+const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
+const TUint32 KBrowserNGDefaultSnapId = 0x00000053;
+#endif
+
+_LIT( KEncryptedRightsIssuerMatchString, "flk*" );
+
+// buffer sizes
+const TInt KDRMMaxETABufSize( 11 );
+const TInt KUrlMaxLen( 1024 );
+const TInt KIntegerMaxLen( 10 );
+
+// constant sizes
+const TInt KOmaDomainGenerationLength( 3 );
+
+// masks for constraint existence
+const TInt KDRMOmaConstraintCount( 1 );
+const TInt KDRMOmaConstraintTime( 2 );
+const TInt KDRMOmaConstraintAccumulated( 4 );
+
+const TInt KCenRepDataLength( 50 );
+
+const TInt KresOmaBasedBuf( 512 );
+const TInt KNameBuf( 256 );
+#ifdef _DEBUG
+// debug panic
+_LIT( KDRMUtilityDebugPanicMessage, "DrmUiHandlingDebugPanic" );
+const TInt KDRMUtilityDebugPanicCode( 1 );
+#endif
+
+// ============================= LOCAL FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// MapToCallError
+// -----------------------------------------------------------------------------
+//
+LOCAL_C inline TInt CheckAndMapToCallError(
+    RDRMRightsClient& aOmaClient,
+    ContentAccess::TIntent aIntent,
+    const TDesC8& aContentUri )
+    {
+    TUint32 rr( KErrNone );
+    TInt err( aOmaClient.CheckRights( aIntent, aContentUri, rr ) );
+    return err ? KErrCANoRights : KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// IapIdOfDefaultSnapL
+// for trapping purposes only
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TUint32 IapIdOfDefaultSnapL(
+    RCmManager& aCmManager,
+    const TUint32 aDefaultSnap )
+    {
+    RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) );
+    CleanupClosePushL( dest );
+    TUint32 iapIdOfDest( 0 );
+
+    if ( dest.ConnectionMethodCount() <= 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
+    CleanupClosePushL( cMeth );
+
+    iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId );
+    CleanupStack::PopAndDestroy( &cMeth );
+    CleanupStack::PopAndDestroy( &dest );
+    return iapIdOfDest;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CDrmUiHandlingImpl
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUiHandlingImpl::CDrmUiHandlingImpl(
+    DRM::CDrmUtility* aDrmUtility,
+    CCoeEnv* aCoeEnv ) :
+    CActive( EPriorityStandard ), iCoeEnv( aCoeEnv ), iDrmUtility(
+        aDrmUtility )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::ConstructL()
+    {
+    TInt err( KErrNone );
+
+    iDrmUtilityCommon = DRM::CDrmUtilityCommon::NewL();
+
+    iDrmUtilityUi = DRM::CDrmUtilityUI::NewL( iCoeEnv );
+
+    User::LeaveIfError( iOmaClient.Connect() );
+
+    User::LeaveIfError( iSemaphore.CreateLocal( 1 ) );
+
+        TRAP_IGNORE( iWrapperLoader = DRM::CDrmUtilityWMDrm::NewL( iCoeEnv ) );
+
+    if ( iWrapperLoader )
+        {
+        iWmClient = iWrapperLoader->GetWrapper();
+        }
+        TRAP(err, GetOmaBasedInfoL() );
+    if ( err )
+        {
+        if ( iOmaBasedAgentName )
+            {
+            delete iOmaBasedAgentName;
+            }
+        iOmaBasedAgentName = NULL;
+        iOmaBasedUid = 0;
+        if ( iOmaBasedMimeType )
+            {
+            delete iOmaBasedMimeType;
+            }
+        iOmaBasedMimeType = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetOmaBasedInfoL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::GetOmaBasedInfoL()
+    {
+    TInt err = KErrNone;
+    CRepository* repository( NULL );
+    RBuf bOmaBasedAgentName;
+    RBuf bOmaBasedMimeType;
+
+    CleanupClosePushL( bOmaBasedAgentName );
+    CleanupClosePushL( bOmaBasedMimeType );
+    bOmaBasedAgentName.CreateL( KCenRepDataLength );
+    bOmaBasedMimeType.CreateL( KCenRepDataLength );
+
+        TRAP( err, repository = CRepository::NewL( KCRUidOmaBased ) );
+    if ( !err )
+        {
+        CleanupStack::PushL( repository );
+
+        err = repository->Get( KDrmOmaBasedName, bOmaBasedAgentName );
+        if ( !err )
+            {
+            iOmaBasedAgentName = bOmaBasedAgentName.AllocL();
+            }
+
+        err = repository->Get( KDrmOmaBasedUID, iOmaBasedUid );
+
+        err = repository->Get( KOmaBasedMimeType, bOmaBasedMimeType );
+        if ( !err )
+            {
+            iOmaBasedMimeType = CnvUtfConverter::ConvertFromUnicodeToUtf8L(
+                bOmaBasedMimeType );
+            }
+        CleanupStack::PopAndDestroy( repository );
+        }
+
+    CleanupStack::PopAndDestroy( 2, &bOmaBasedAgentName );
+    User::LeaveIfError( err );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUiHandlingImpl* DRM::CDrmUiHandlingImpl::NewL(
+    DRM::CDrmUtility* aDrmUtility,
+    CCoeEnv* aCoeEnv )
+    {
+    DRM::CDrmUiHandlingImpl* self( NewLC( aDrmUtility, aCoeEnv ) );
+
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUiHandlingImpl* DRM::CDrmUiHandlingImpl::NewLC(
+    DRM::CDrmUtility* aDrmUtility,
+    CCoeEnv* aCoeEnv )
+    {
+    DRM::CDrmUiHandlingImpl* self( new ( ELeave ) CDrmUiHandlingImpl(
+        aDrmUtility, aCoeEnv ) );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::~CDrmUiHandlingImpl()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUiHandlingImpl::~CDrmUiHandlingImpl()
+    {
+    DRM::CDrmUiHandlingData* data( PopFront() );
+
+    // Empty the queue:
+    while ( data )
+        {
+        // Complete the outstanding requestest with cancel
+        data->iObserver->OperationCompleted( data->iOperationId, KErrCancel );
+        delete data;
+        data = PopFront();
+        }
+
+    delete iDrmUtilityCommon;
+
+    delete iDrmUtilityUi;
+
+    delete iSchemeHandler;
+
+    delete iWrapperLoader;
+
+    delete iOmaBasedAgentName;
+
+    delete iOmaBasedMimeType;
+
+    iOmaClient.Close();
+
+    // Close the semaphone
+    iSemaphore.Close();
+
+    // Remove the object from active scheduler etc.
+    if ( IsAdded() )
+        {
+        Deque();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CheckRightsAmountAsyncL
+// Check how much rights there are left for the content.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandlingImpl::CheckRightsAmountAsyncL(
+    RFile& aFile,
+    ContentAccess::TIntent aIntent,
+    DRM::MDrmUiCheckRightsObserver& aObserver )
+    {
+    TRequestStatus* status( &iStatus );
+
+    // Create data object:
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+    data->iObserver = &aObserver;
+    data->iOperationId = reinterpret_cast<TInt> ( data );
+    data->iOperation = KCommandCheckRightsAmountFile;
+    data->iFile = &aFile;
+    data->iIntent = aIntent;
+    data->iCheckRightsObserver = &aObserver;
+
+    // Add it to the queue:
+    AppendToQueue( data );
+
+    // Pop it from the cleanup stack
+    CleanupStack::Pop( data );
+
+    Activate( status );
+
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CheckRightsAmountL
+// Check how much rights there are left for the content.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandlingImpl::CheckRightsAmountL(
+    RFile& aFile,
+    ContentAccess::TIntent aIntent,
+    DRM::MDrmUiCheckRightsObserver* aObserver )
+    {
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iOperationId = 0; // operation id zero for a syncronous operation
+    data->iFile = &aFile;
+    data->iIntent = aIntent;
+    data->iCheckRightsObserver = aObserver;
+
+    PerformCheckRightsAmountFileL( *data );
+
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CheckRightsAmountAsyncL
+// Check how much rights there are left for the content.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandlingImpl::CheckRightsAmountAsyncL(
+    ContentAccess::CData& aFile,
+    ContentAccess::TIntent aIntent,
+    DRM::MDrmUiCheckRightsObserver& aObserver )
+    {
+    TRequestStatus* status( &iStatus );
+
+    // create data object:
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iObserver = &aObserver;
+    data->iOperationId = reinterpret_cast<TInt> ( data );
+    data->iOperation = KCommandCheckRightsAmountData;
+    data->iFileData = &aFile;
+    data->iIntent = aIntent;
+    data->iCheckRightsObserver = &aObserver;
+
+    // Add it to the queue:
+    AppendToQueue( data );
+
+    // Pop it from the cleanup stack
+    CleanupStack::Pop( data );
+
+    Activate( status );
+
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CheckRightsAmountL
+// Check how much rights there are left for the content.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandlingImpl::CheckRightsAmountL(
+    ContentAccess::CData& aFile,
+    ContentAccess::TIntent aIntent,
+    DRM::MDrmUiCheckRightsObserver* aObserver )
+    {
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iOperationId = 0; // operation id zero for a syncronous operation
+    data->iFileData = &aFile;
+    data->iIntent = aIntent;
+    data->iCheckRightsObserver = aObserver;
+
+    PerformCheckRightsAmountDataL( *data );
+
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::ShowDetailsViewAsyncL
+// Shows DRM specific details
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandlingImpl::ShowDetailsViewAsyncL(
+    RFile& aFile,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    TRequestStatus* status( &iStatus );
+
+    // create data object:
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iObserver = &aObserver;
+    data->iOperationId = reinterpret_cast<TInt> ( data );
+    data->iOperation = KCommandShowDetailsViewFile;
+    data->iFile = &aFile;
+
+    // Add it to the queue:
+    AppendToQueue( data );
+
+    // Pop it from the cleanup stack
+    CleanupStack::Pop( data );
+
+    Activate( status );
+
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::ShowDetailsViewL
+// Shows DRM specific details
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandlingImpl::ShowDetailsViewL( RFile& aFile )
+    {
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iOperationId = 0; // operation id zero for a syncronous operation
+    data->iFile = &aFile;
+
+    PerformShowDetailsViewFileL( *data );
+
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::ShowDetailsViewAsyncL
+// Shows DRM specific details
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandlingImpl::ShowDetailsViewAsyncL(
+    ContentAccess::CData& aFile,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    TRequestStatus* status( &iStatus );
+
+    // create data object:
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iObserver = &aObserver;
+    data->iOperationId = reinterpret_cast<TInt> ( data );
+    data->iOperation = KCommandShowDetailsViewData;
+    data->iFileData = &aFile;
+
+    // Add it to the queue:
+    AppendToQueue( data );
+
+    // Pop it from the cleanup stack
+    CleanupStack::Pop( data );
+
+    Activate( status );
+
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::ShowDetailsViewL
+// Shows DRM specific details.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandlingImpl::ShowDetailsViewL(
+    ContentAccess::CData& aFile )
+    {
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iOperationId = 0; // operation id zero for a syncronous operation
+    data->iFileData = &aFile;
+
+    PerformShowDetailsViewDataL( *data );
+
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::HandleUrlAsyncL
+// Handles a specific url defined by the file, such as InfoUrl
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandlingImpl::HandleUrlAsyncL(
+    RFile& aFile,
+    DRM::TDrmUiUrlType aType,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    TRequestStatus* status( &iStatus );
+
+    // create data object:
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iObserver = &aObserver;
+    data->iOperationId = reinterpret_cast<TInt> ( data );
+    data->iOperation = KCommandHandleUrlFile;
+    data->iFile = &aFile;
+    data->iTypeParam = aType;
+
+    // Add it to the queue:
+    AppendToQueue( data );
+
+    // Pop it from the cleanup stack
+    CleanupStack::Pop( data );
+
+    Activate( status );
+
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::HandleUrlL
+// Handles a specific url defined by the file, such as InfoUrl
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandlingImpl::HandleUrlL(
+    RFile& aFile,
+    DRM::TDrmUiUrlType aType )
+    {
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iOperationId = 0; // operation id zero for a syncronous operation
+    data->iFile = &aFile;
+    data->iTypeParam = aType;
+
+    PerformHandleUrlFileL( *data );
+
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::HandleUrlAsyncL
+// Handles the specific url defined by the file, such as InfoUrl
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandlingImpl::HandleUrlAsyncL(
+    ContentAccess::CData& aFile,
+    DRM::TDrmUiUrlType aType,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    TRequestStatus* status( &iStatus );
+
+    // create data object:
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iObserver = &aObserver;
+    data->iOperationId = reinterpret_cast<TInt> ( data );
+    data->iOperation = KCommandHandleUrlData;
+    data->iFileData = &aFile;
+    data->iTypeParam = aType;
+
+    // Add it to the queue:
+    AppendToQueue( data );
+
+    // Pop it from the cleanup stack
+    CleanupStack::Pop( data );
+
+    Activate( status );
+
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::HandleUrlL
+// Handles the specific url defined by the file, such as InfoUrl
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandlingImpl::HandleUrlL(
+    ContentAccess::CData& aFile,
+    DRM::TDrmUiUrlType aType )
+    {
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iOperationId = 0; // operation id zero for a syncronous operation
+    data->iFileData = &aFile;
+    data->iTypeParam = aType;
+
+    PerformHandleUrlDataL( *data );
+
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::AvailableUrlsAsyncL
+// Gets information of the available urls
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandlingImpl::AvailableUrlsAsyncL(
+    RFile& aFile,
+    DRM::TDrmUiUrlType& aType,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    TRequestStatus* status( &iStatus );
+
+    // create data object:
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iObserver = &aObserver;
+    data->iOperationId = reinterpret_cast<TInt> ( data );
+    data->iOperation = KCommandAvailableUrlsFile;
+    data->iFile = &aFile;
+    data->iType = &aType;
+
+    // Add it to the queue:
+    AppendToQueue( data );
+
+    // Pop it from the cleanup stack
+    CleanupStack::Pop( data );
+
+    Activate( status );
+
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::AvailableUrlsL
+// Gets information of the available urls
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandlingImpl::AvailableUrlsL(
+    RFile& aFile,
+    DRM::TDrmUiUrlType& aType )
+    {
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iOperationId = 0; // operation id zero for a syncronous operation
+    data->iFile = &aFile;
+    data->iType = &aType;
+
+    PerformAvailableUrlsFileL( *data );
+
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::AvailableUrlsAsyncL
+// Gets information of the available urls
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandlingImpl::AvailableUrlsAsyncL(
+    ContentAccess::CData& aFile,
+    DRM::TDrmUiUrlType& aType,
+    DRM::MDrmAsyncObserver& aObserver )
+    {
+    TRequestStatus* status( &iStatus );
+
+    // create data object:
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iObserver = &aObserver;
+    data->iOperationId = reinterpret_cast<TInt> ( data );
+    data->iOperation = KCommandAvailableUrlsData;
+    data->iFileData = &aFile;
+    data->iType = &aType;
+
+    // Add it to the queue:
+    AppendToQueue( data );
+
+    // Pop it from the cleanup stack
+    CleanupStack::Pop( data );
+
+    Activate( status );
+
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::AvailableUrlsL
+// Gets information of the available urls
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandlingImpl::AvailableUrlsL(
+    ContentAccess::CData& aFile,
+    DRM::TDrmUiUrlType& aType )
+    {
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iOperationId = 0; // operation id zero for a syncronous operation
+    data->iFileData = &aFile;
+    data->iType = &aType;
+
+    PerformAvailableUrlsDataL( *data );
+
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::HandleErrorAsyncL
+// Handles DRM specific error
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandlingImpl::HandleErrorAsyncL(
+    RFile& aFile,
+    ContentAccess::TIntent aIntent,
+    TInt aError,
+    DRM::MDrmHandleErrorObserver& aObserver )
+    {
+    TRequestStatus* status( &iStatus );
+
+    // create data object:
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iObserver = &aObserver;
+    data->iOperationId = reinterpret_cast<TInt> ( data );
+    data->iOperation = KCommandHandleErrorFile;
+    data->iFile = &aFile;
+    data->iIntent = aIntent;
+    data->iError = aError;
+    data->iErrorObserver = &aObserver;
+
+    // Add it to the queue:
+    AppendToQueue( data );
+
+    // Pop it from the cleanup stack
+    CleanupStack::Pop( data );
+
+    Activate( status );
+
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::HandleError
+// Handles DRM specific error
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandlingImpl::HandleErrorL(
+    RFile& aFile,
+    ContentAccess::TIntent aIntent,
+    TInt aError,
+    DRM::MDrmHandleErrorObserver* aObserver )
+    {
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iOperationId = 0; // operation id zero for a syncronous operation
+    data->iFile = &aFile;
+    data->iIntent = aIntent;
+    data->iError = aError;
+    data->iErrorObserver = aObserver;
+
+    PerformHandleErrorFileL( *data );
+
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::HandleErrorAsyncL
+// Handles DRM specific error
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandlingImpl::HandleErrorAsyncL(
+    ContentAccess::CData& aFile,
+    ContentAccess::TIntent aIntent,
+    TInt aError,
+    DRM::MDrmHandleErrorObserver& aObserver )
+    {
+    TRequestStatus* status( &iStatus );
+
+    // create data object:
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iObserver = &aObserver;
+    data->iOperationId = reinterpret_cast<TInt> ( data );
+    data->iOperation = KCommandHandleErrorData;
+    data->iFileData = &aFile;
+    data->iIntent = aIntent;
+    data->iError = aError;
+    data->iErrorObserver = &aObserver;
+
+    // Add it to the queue:
+    AppendToQueue( data );
+
+    // Pop it from the cleanup stack
+    CleanupStack::Pop( data );
+
+    Activate( status );
+
+    return data->iOperationId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::HandleError
+// Handles DRM specific error
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiHandlingImpl::HandleErrorL(
+    ContentAccess::CData& aFile,
+    ContentAccess::TIntent aIntent,
+    TInt aError,
+    DRM::MDrmHandleErrorObserver* aObserver )
+    {
+    DRM::CDrmUiHandlingData* data( DRM::CDrmUiHandlingData::NewLC() );
+
+    data->iOperationId = 0; // operation id zero for a syncronous operation
+    data->iFileData = &aFile;
+    data->iIntent = aIntent;
+    data->iError = aError;
+    data->iErrorObserver = aObserver;
+
+    PerformHandleErrorDataL( *data );
+
+    CleanupStack::PopAndDestroy( data );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CancelOperation
+// Cancels the operation
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiHandlingImpl::CancelOperation( TInt aOperationId )
+    {
+    // Critical area start:
+    iSemaphore.Wait();
+
+    TBool found( EFalse );
+
+    DRM::CDrmUiHandlingData* previousData( NULL );
+    DRM::CDrmUiHandlingData* currentData( iFirst );
+
+    while ( currentData )
+        {
+        if ( currentData->iOperationId == aOperationId )
+            {
+            found = ETrue;
+
+            //Update the previous link
+            if ( previousData )
+                {
+                previousData->iNext = currentData->iNext;
+                }
+            else
+                {
+                iFirst = currentData->iNext;
+                }
+
+            //If the current is the only one, set iLast NULL
+            if ( !iFirst )
+                {
+                iLast = NULL;
+                }
+            //If only one left,set it also to be the iLast
+            else if ( iFirst && !currentData->iNext )
+                {
+                iLast = iFirst;
+                }
+
+            //Delete the cancelled operation
+            currentData->iObserver->OperationCompleted(
+                currentData->iOperationId, KErrCancel );
+            delete currentData;
+            currentData = NULL;
+            }
+        else
+            {
+            previousData = currentData;
+            currentData = currentData->iNext;
+            }
+        }
+
+    if ( !found )
+        {
+        // Critical Area End
+        iSemaphore.Signal();
+        return KErrNotFound;
+        }
+
+    // Critical Area End
+    iSemaphore.Signal();
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::DoCancel()
+// From CActive Cancels async request.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::DoCancel()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::RunL()
+// From CActive Called when async request completes.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::RunL()
+    {
+    DRM::CDrmUiHandlingData* data( PopFront() );
+    TRequestStatus* status( &iStatus );
+
+    if ( !data )
+        {
+        return;
+        }
+
+    CleanupStack::PushL( data );
+
+    // Take this into the "current" variable in case an error occurs
+    iObserver = data->iObserver;
+    iOperationId = data->iOperationId;
+
+    switch ( data->iOperation )
+        {
+        case KCommandHandleErrorFile:
+
+            // Perform the operation
+            PerformHandleErrorFileL( *data );
+
+            break;
+
+        case KCommandHandleErrorData:
+
+            // Perform the operation
+            PerformHandleErrorDataL( *data );
+
+            break;
+
+        case KCommandCheckRightsAmountFile:
+
+            // Perform the operation
+            PerformCheckRightsAmountFileL( *data );
+
+            break;
+
+        case KCommandCheckRightsAmountData:
+
+            // Perform the operation
+            PerformCheckRightsAmountDataL( *data );
+
+            break;
+
+        case KCommandShowDetailsViewFile:
+
+            // Perform the operation
+            PerformShowDetailsViewFileL( *data );
+
+            break;
+
+        case KCommandShowDetailsViewData:
+
+            // Perform the operation
+            PerformShowDetailsViewDataL( *data );
+
+            break;
+
+        case KCommandHandleUrlFile:
+
+            // Perform the operation
+            PerformHandleUrlFileL( *data );
+
+            break;
+
+        case KCommandHandleUrlData:
+
+            // Perform the operation
+            PerformHandleUrlDataL( *data );
+
+            break;
+
+        case KCommandAvailableUrlsFile:
+
+            // Perform the operation
+            PerformAvailableUrlsFileL( *data );
+
+            break;
+
+        case KCommandAvailableUrlsData:
+
+            // Perform the operation
+            PerformAvailableUrlsDataL( *data );
+
+            break;
+
+        default:
+
+            break;
+        }
+
+    // Complete the client request
+    iObserver->OperationCompleted( iOperationId, KErrNone );
+
+    // destroy the object:
+    CleanupStack::PopAndDestroy( data );
+
+    // Get ready for another round:
+    SetActive();
+
+    // complete internal request:
+    User::RequestComplete( status, KErrNone );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::RunError()
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::RunError( TInt aError )
+    {
+    iObserver->OperationCompleted( iOperationId, aError );
+    iObserver = NULL;
+    iOperationId = NULL;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::Activate
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::Activate( TRequestStatus*& aStatus )
+    {
+    if ( !IsAdded() )
+        {
+        CActiveScheduler::Add( this );
+        }
+
+    if ( !IsActive() )
+        {
+        SetActive();
+
+        // complete internal request:
+        User::RequestComplete( aStatus, KErrNone );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::PerformCheckRightsAmountFileL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::PerformCheckRightsAmountFileL(
+    DRM::CDrmUiHandlingData& aData )
+    {
+    TPtrC agent( KNullDesC );
+    IsProtectedL( *aData.iFile, agent );
+
+    ContentAccess::CData* content = ContentAccess::CData::NewLC(
+        *aData.iFile, ContentAccess::KDefaultContentObject,
+        ContentAccess::EPeek );
+
+    if ( !agent.Compare( DRM::KDrmOmaAgentName ) )
+        {
+        CheckOmaRightsAmountL( *content, aData.iIntent,
+            aData.iCheckRightsObserver, aData.iOperationId );
+        }
+
+    else if ( iOmaBasedAgentName && ( !agent.Compare( *iOmaBasedAgentName ) ) )
+        {
+        CheckOmaBasedRightsAmountL( *content, aData.iIntent,
+            aData.iCheckRightsObserver, aData.iOperationId );
+        }
+
+    else if ( !agent.Compare( DRM::KDrmWMAgentName ) && iWmClient )
+        {
+        iWmClient->CheckWmRightsAmountL( *content, aData.iIntent,
+            aData.iCheckRightsObserver, aData.iOperationId );
+        }
+
+    CleanupStack::PopAndDestroy( content );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::PerformCheckRightsAmountDataL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::PerformCheckRightsAmountDataL(
+    DRM::CDrmUiHandlingData& aData )
+    {
+    DRM::TDrmAgentUid agentUid( DRM::EDrmOmaAgent );
+    IsProtectedL( aData.iFileData, agentUid );
+
+    switch ( agentUid )
+        {
+        case DRM::EDrmOmaAgent:
+
+            CheckOmaRightsAmountL( *aData.iFileData, aData.iIntent,
+                aData.iCheckRightsObserver, aData.iOperationId );
+
+            break;
+
+        case DRM::EDrmWmAgent:
+
+            if ( iWmClient )
+                {
+                iWmClient->CheckWmRightsAmountL( *aData.iFileData,
+                    aData.iIntent, aData.iCheckRightsObserver,
+                    aData.iOperationId );
+                }
+
+            break;
+
+        default:
+
+            break;
+        }
+    if ( agentUid == iOmaBasedUid )
+        {
+        CheckOmaBasedRightsAmountL( *aData.iFileData, aData.iIntent,
+            aData.iCheckRightsObserver, aData.iOperationId );
+        }
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::PerformShowDetailsViewFileL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::PerformShowDetailsViewFileL(
+    DRM::CDrmUiHandlingData& aData )
+    {
+    HBufC* fullPath( NULL );
+    TPtr pathPtr( NULL, 0 );
+    TPtrC agent( KNullDesC );
+    IsProtectedL( *aData.iFile, agent );
+
+    ContentAccess::CData* content = ContentAccess::CData::NewLC(
+        *aData.iFile, ContentAccess::KDefaultContentObject,
+        ContentAccess::EPeek );
+
+    HBufC8* contentId( NULL );
+
+    fullPath = HBufC::NewLC( KUrlMaxLen );
+    pathPtr.Set( fullPath->Des() );
+    User::LeaveIfError( aData.iFile->FullName( pathPtr ) );
+
+    if ( !agent.Compare( DRM::KDrmOmaAgentName ) )
+        {
+        GetContentIdLC( *content, contentId );
+        ShowDetailsViewL( contentId, fullPath );
+        CleanupStack::PopAndDestroy( contentId );
+        }
+
+    else if ( !agent.Compare( DRM::KDrmWMAgentName ) && iWmClient )
+        {
+        // Show details view for WMDRM file needs full path name
+        ShowDetailsViewL( fullPath );
+        }
+
+    CleanupStack::PopAndDestroy( fullPath );
+    CleanupStack::PopAndDestroy( content ); // content
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::PerformShowDetailsViewDataL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::PerformShowDetailsViewDataL(
+    DRM::CDrmUiHandlingData& aData )
+    {
+    DRM::TDrmAgentUid agentUid( DRM::EDrmOmaAgent );
+    IsProtectedL( aData.iFileData, agentUid );
+    HBufC* fullPath( NULL );
+    HBufC8* contentId( NULL );
+
+    // For OMA and WM DRM, the full path is needed, not just the Content Id
+    GetContentLocationLC( *aData.iFileData, fullPath );
+
+    switch ( agentUid )
+        {
+        case DRM::EDrmOmaAgent:
+            GetContentIdLC( *aData.iFileData, contentId );
+            ShowDetailsViewL( contentId, fullPath );
+            CleanupStack::PopAndDestroy( contentId );
+            break;
+
+        case DRM::EDrmWmAgent:
+
+            if ( iWmClient )
+                {
+                // For WM DRM, the full path is needed, not just the Content Id
+                ShowDetailsViewL( fullPath );
+                }
+
+            break;
+
+        default:
+
+            break;
+        }
+
+    if ( agentUid == iOmaBasedUid )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    CleanupStack::PopAndDestroy( fullPath );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::PerformHandleUrlFileL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::PerformHandleUrlFileL(
+    DRM::CDrmUiHandlingData& aData )
+    {
+    TPtrC agent( KNullDesC );
+    IsProtectedL( *aData.iFile, agent );
+
+    ContentAccess::CData* content = ContentAccess::CData::NewLC(
+        *aData.iFile, ContentAccess::KDefaultContentObject,
+        ContentAccess::EPeek );
+
+    if ( !agent.Compare( DRM::KDrmOmaAgentName ) )
+        {
+        DoHandleOmaUrlL( *content, aData.iTypeParam );
+        }
+
+    else if ( !agent.Compare( DRM::KDrmWMAgentName ) && iWmClient )
+        {
+        //*** WMDRM does not support URL:s like that thus leaving with not supported
+        User::Leave( KErrNotSupported );
+        }
+
+    CleanupStack::PopAndDestroy( content );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::PerformHandleUrlDataL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::PerformHandleUrlDataL(
+    DRM::CDrmUiHandlingData& aData )
+    {
+    DRM::TDrmAgentUid agentUid( DRM::EDrmOmaAgent );
+    IsProtectedL( aData.iFileData, agentUid );
+
+    // *** WMDRM
+    switch ( agentUid )
+        {
+        case DRM::EDrmOmaAgent:
+
+            DoHandleOmaUrlL( *aData.iFileData, aData.iTypeParam );
+
+            break;
+
+        case DRM::EDrmWmAgent:
+
+            if ( iWmClient )
+                {
+                User::Leave( KErrNotSupported );
+                }
+
+            break;
+
+        default:
+
+            break;
+
+        }
+
+    if ( agentUid == iOmaBasedUid )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    // *** WMDRM
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::PerformAvailableUrlsFileL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::PerformAvailableUrlsFileL(
+    DRM::CDrmUiHandlingData& aData )
+    {
+    TPtrC agent( KNullDesC );
+    IsProtectedL( *aData.iFile, agent );
+
+    ContentAccess::CData* content = ContentAccess::CData::NewLC(
+        *aData.iFile, ContentAccess::KDefaultContentObject,
+        ContentAccess::EPeek );
+
+    if ( !agent.Compare( DRM::KDrmOmaAgentName ) )
+        {
+        GetAvailableOmaUrlsL( *content, *aData.iType );
+        }
+
+    else if ( !agent.Compare( DRM::KDrmWMAgentName ) && iWmClient )
+        {
+        //*** WMDRM does not support URL:s like that thus leaving with not supported
+        User::Leave( KErrNotSupported );
+        }
+    CleanupStack::PopAndDestroy( content );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::PerformAvailableUrlsDataL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::PerformAvailableUrlsDataL(
+    DRM::CDrmUiHandlingData& aData )
+    {
+    DRM::TDrmAgentUid agentUid( DRM::EDrmOmaAgent );
+    IsProtectedL( aData.iFileData, agentUid );
+
+    // *** WMDRM
+    switch ( agentUid )
+        {
+        case DRM::EDrmOmaAgent:
+
+            GetAvailableOmaUrlsL( *aData.iFileData, *aData.iType );
+
+            break;
+
+        case DRM::EDrmWmAgent:
+
+            if ( iWmClient )
+                {
+                User::Leave( KErrNotSupported );
+                }
+
+            break;
+
+        default:
+
+            break;
+
+        }
+
+    if ( agentUid == iOmaBasedUid )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    // *** WMDRM
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::PerformHandleErrorFileL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::PerformHandleErrorFileL(
+    DRM::CDrmUiHandlingData& aData )
+    {
+    TPtrC agent( KNullDesC );
+    IsProtectedL( *aData.iFile, agent );
+    IsProperErrorL( aData.iError );
+
+    ContentAccess::CData* content = ContentAccess::CData::NewLC(
+        *aData.iFile, ContentAccess::KDefaultContentObject,
+        ContentAccess::EPeek );
+
+    if ( ( !agent.Compare( DRM::KDrmOmaAgentName ) ) || ( iOmaBasedAgentName
+        && !agent.Compare( *iOmaBasedAgentName ) ) )
+        {
+        HandleOmaErrorL( *content, aData.iIntent, aData.iError,
+            aData.iErrorObserver, aData.iOperationId );
+        }
+
+    else if ( !agent.Compare( DRM::KDrmWMAgentName ) && iWmClient )
+        {
+        // *** WMDRM
+        iWmClient->HandleWmErrorL( *content, aData.iIntent, aData.iError,
+            aData.iErrorObserver, aData.iOperationId );
+        }
+
+    CleanupStack::PopAndDestroy( content );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::PerformHandleErrorDataL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::PerformHandleErrorDataL(
+    DRM::CDrmUiHandlingData& aData )
+    {
+    DRM::TDrmAgentUid agentUid( DRM::EDrmOmaAgent );
+    IsProtectedL( aData.iFileData, agentUid );
+    IsProperErrorL( aData.iError );
+
+    // *** WMDRM
+    switch ( agentUid )
+        {
+        case DRM::EDrmOmaAgent:
+
+            HandleOmaErrorL( *aData.iFileData, aData.iIntent, aData.iError,
+                aData.iErrorObserver, aData.iOperationId );
+
+            break;
+
+        case DRM::EDrmWmAgent:
+
+            if ( iWmClient )
+                {
+                iWmClient->HandleWmErrorL( *aData.iFileData, aData.iIntent,
+                    aData.iError, aData.iErrorObserver, aData.iOperationId );
+                }
+
+            break;
+
+        default:
+
+            break;
+
+        }
+    if ( agentUid == iOmaBasedUid )
+        {
+        HandleOmaErrorL( *aData.iFileData, aData.iIntent, aData.iError,
+            aData.iErrorObserver, aData.iOperationId );
+        }
+    // *** WMDRM
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::IsProtectedL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::IsProtectedL( RFile& aFile, TPtrC& aAgent )
+    {
+    DRM::TDrmProtectionStatus drmProtected( DRM::EUUnknown );
+    TInt ret( 0 );
+    ret = iDrmUtility->GetDrmInfoL( aFile, aAgent, drmProtected );
+    if ( !ret || !drmProtected ) // do nothing if non-DRM file
+        {
+        User::Leave( KErrArgument );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::IsProtectedL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::IsProtectedL(
+    ContentAccess::CData* aContent,
+    DRM::TDrmAgentUid& aAgentUid )
+    {
+    TInt drmProtected( 0 );
+    User::LeaveIfError( aContent->GetAttribute( EIsProtected, drmProtected ) );
+    if ( !drmProtected ) // do nothing if non-DRM file
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TInt temp( 0 );
+
+    HBufC* nameString = HBufC::NewLC( KNameBuf );
+
+    TPtr namePtr( nameString->Des() );
+
+    User::LeaveIfError( aContent->GetStringAttribute( DRM::EDrmAgentName,
+        namePtr ) );
+
+    if ( iOmaBasedAgentName && ( !namePtr.CompareF( *iOmaBasedAgentName ) ) )
+        {
+        aAgentUid = static_cast<DRM::TDrmAgentUid> ( iOmaBasedUid );
+        }
+    else
+        {
+        User::LeaveIfError( aContent->GetAttribute( DRM::EDrmAgentUid, temp ) );
+        aAgentUid = static_cast<DRM::TDrmAgentUid> ( temp );
+        }
+    CleanupStack::PopAndDestroy( nameString );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::IsProperErrorL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::IsProperErrorL( TInt aError )
+    {
+    if ( aError != ENoPermission && aError != ENoRights && aError
+        != EPendingRights )
+        {
+        User::Leave( aError );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CheckOmaRightsAmountL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CheckOmaRightsAmountL(
+    ContentAccess::CData& aContent,
+    ContentAccess::TIntent aIntent,
+    DRM::MDrmUiCheckRightsObserver* aObserver,
+    TInt aOperationId )
+    {
+    HBufC8* contentId( NULL );
+    HBufC8* silentUrl( NULL );
+    HBufC* riUrl( NULL );
+    HBufC* domainRiUrl( NULL );
+    DRM::TDrmUiUrlType urlType( DRM::EUHRightsIssuerUrl );
+
+    User::LeaveIfError( GetContentIdLC( aContent, contentId ) );
+    GetOmaSilentRightsUrlLC( aContent, silentUrl );
+    GetOmaRightsIssuerLC( aContent, riUrl );
+    GetOmaDomainRightsIssuerLC( aContent, domainRiUrl );
+    SelectOmaRightsUrlL( aContent, domainRiUrl, urlType );
+
+    DoCheckOmaRightsAmountL( aContent, contentId, aIntent, urlType
+        == DRM::EUHRightsIssuerUrl ? riUrl : domainRiUrl, urlType, silentUrl,
+        aObserver, aOperationId );
+
+    CleanupStack::PopAndDestroy( domainRiUrl );
+    CleanupStack::PopAndDestroy( riUrl );
+    CleanupStack::PopAndDestroy( silentUrl );
+    CleanupStack::PopAndDestroy( contentId );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::DoCheckOmaRightsAmountL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::DoCheckOmaRightsAmountL(
+    ContentAccess::CData& aContent,
+    HBufC8*& aContentUri,
+    ContentAccess::TIntent aIntent,
+    const HBufC* aRightsUrl,
+    DRM::TDrmUiUrlType aUrlType,
+    const HBufC8* aSilentUrl,
+    DRM::MDrmUiCheckRightsObserver* aObserver,
+    TInt aOperationId )
+    {
+    TInt omaError( KErrNone );
+    CDRMPermission* permission( NULL );
+    CDRMConstraint* constraint( NULL );
+    CDRMConstraint* toplevel( NULL );
+    DRM::TDrmRightsInfo status( DRM::EURightsInfoMissing );
+    DRM::TCheckRightsStatus rightsStatus( DRM::EUHCheckRightsNoRights );
+    TTime now( Time::NullTTime() ); // current time
+    TTime endTime( Time::NullTTime() ); // end time of time-based rights
+    TInt mask( 0 ); // tells if object has count or time based rights
+    TUint32 reason( 0 );
+    TBool unlimited( EFalse );
+    TUint32 countsLeft( 0 ); // number of counts left
+    TTimeIntervalSeconds secondsLeft( 0 ); // seconds to end of time based rights
+    TTimeIntervalSeconds accumulatedSecondsLeft( 0 ); // seconds to end of
+    // accumulated time rights
+
+    // Check rights
+    omaError = iOmaClient.CheckRights( aIntent, *aContentUri, reason );
+
+    // valid rights
+    if ( !omaError )
+        {
+        permission = iOmaClient.GetActiveRightsL( aIntent, *aContentUri,
+            reason );
+        CleanupStack::PushL( permission );
+
+        toplevel = permission->TopLevelConstraint();
+        constraint = permission->ConstraintForIntent( aIntent );
+
+        // if top level constraint exists, merge it to constraint for intent
+        if ( toplevel )
+            {
+            constraint->Merge( *toplevel );
+            }
+
+        // find out type of constraint
+        mask = GetOmaConstraintInfo( constraint, countsLeft, endTime );
+
+        // get the current time
+        now.HomeTime();
+
+        // calculate days left in case of time
+        // and accumulated time constraints
+        if ( mask & KDRMOmaConstraintTime )
+            {
+            endTime.SecondsFrom( now, secondsLeft );
+            }
+        if ( mask & KDRMOmaConstraintAccumulated )
+            {
+            endTime.SecondsFrom( now, accumulatedSecondsLeft );
+            }
+        // if no count or time based constraint, then unlimited
+        if ( !mask )
+            {
+            unlimited = ETrue;
+            }
+
+        CallRightsLeftL( aObserver, aOperationId, unlimited, secondsLeft,
+            countsLeft, accumulatedSecondsLeft, aContentUri, aRightsUrl,
+            aSilentUrl, aContent, aIntent );
+
+        CleanupStack::PopAndDestroy( permission );
+        }
+
+    // Not valid rights
+    else
+        {
+        constraint = CDRMConstraint::NewLC();
+
+        // No rights at all
+        if ( omaError == KErrCANoRights )
+            {
+            rightsStatus = DRM::EUHCheckRightsNoRights;
+            }
+        else
+            {
+            // rights expired or future for given content URI
+            status = iDrmUtilityCommon->GetOmaRightsStatusL( aContentUri,
+                aIntent, constraint );
+            if ( status == DRM::EURightsInfoFuture )
+                {
+                rightsStatus = DRM::EUHCheckRightsFutureRights;
+                }
+            else if ( status == DRM::EURightsInfoExpired )
+                {
+                rightsStatus = DRM::EUHCheckRightsExpiredRights;
+                }
+            }
+
+        CallRightsNotValidL( aObserver, aOperationId, rightsStatus, reason,
+            aContent, aContentUri, constraint, aRightsUrl, aUrlType,
+            aSilentUrl, aIntent );
+
+        CleanupStack::PopAndDestroy( constraint );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::HandleOmaErrorL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::HandleOmaErrorL(
+    ContentAccess::CData& aContent,
+    ContentAccess::TIntent aIntent,
+    TInt aError,
+    DRM::MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId )
+    {
+    TInt omaError( KErrNone );
+    HBufC8* contentId( NULL );
+    HBufC* riUrl( NULL );
+    HBufC* domainRiUrl( NULL );
+    HBufC* previewUrl( NULL );
+    HBufC8* silentUrl( NULL );
+    CDRMConstraint* constraint( NULL );
+    DRM::TDrmRightsInfo rightsStatus( DRM::EURightsInfoValid );
+    DRM::TDrmUiUrlType urlType( DRM::EUHRightsIssuerUrl );
+    TInt previewType( ContentAccess::ENoPreview );
+    TUint32 reason( 0 );
+    TBool handled( EFalse );
+
+    User::LeaveIfError( GetContentIdLC( aContent, contentId ) );
+
+    // Check that this really is an error situation
+    omaError = iOmaClient.CheckRights( aIntent, *contentId, reason );
+
+    // Show that only reason for error was rejected metering.
+    TBool onlyMeteringRejection( reason == DRM::EURejectionMetering );
+    if ( onlyMeteringRejection )
+        {
+        iDrmUtilityUi->DisplayQueryWithIdL( R_DRM_QUERY_METERING_DISABLED,
+            R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY );
+
+        CleanupStack::PopAndDestroy( contentId );
+        return;
+        }
+
+    if ( omaError )
+        {
+
+        // Get rights status
+        constraint = CDRMConstraint::NewLC();
+        rightsStatus = iDrmUtilityCommon->GetOmaRightsStatusL( contentId,
+            aIntent, constraint );
+
+        // Try to get all needed urls
+        GetOmaPreviewInfoLC( aContent, previewUrl, previewType );
+        GetOmaSilentRightsUrlLC( aContent, silentUrl );
+        GetOmaRightsIssuerLC( aContent, riUrl );
+        GetOmaDomainRightsIssuerLC( aContent, domainRiUrl );
+        SelectOmaRightsUrlL( aContent, domainRiUrl, urlType );
+
+        // If content has EmbeddedPreviewUrl, PreviewRightsUrl or
+        // SilentRightsUrl, handle it
+        if ( previewType == ContentAccess::EInstantPreview )
+            {
+            handled = ETrue;
+            CallEmbeddedPreviewAvailableL( aObserver, aOperationId, aContent,
+                previewUrl, rightsStatus, reason, urlType
+                    == DRM::EUHRightsIssuerUrl ? riUrl : domainRiUrl,
+                contentId, aIntent );
+            }
+
+        else if ( previewType == ContentAccess::EPreviewRights )
+            {
+            handled = ETrue;
+            CallPreviewRightsUrlAvailableL( aObserver, aOperationId,
+                aContent, previewUrl, rightsStatus, reason, urlType
+                    == DRM::EUHRightsIssuerUrl ? riUrl : domainRiUrl,
+                contentId, aIntent );
+            }
+
+        else if ( silentUrl )
+            {
+            handled = ETrue;
+            CallSilentRightsUrlAvailableL( aObserver, aOperationId,
+                silentUrl, rightsStatus, reason, urlType
+                    == DRM::EUHRightsIssuerUrl ? riUrl : domainRiUrl,
+                contentId, aIntent );
+            }
+
+        // Check if rights were retrieved in earlier url handling
+        if ( handled )
+            {
+            omaError = iOmaClient.CheckRights( aIntent, *contentId, reason );
+            }
+
+        if ( omaError )
+            {
+            // No rights available
+            // Perform this even if no rights issuer url found
+            CallRightsUrlAvailableL( aObserver, aOperationId, rightsStatus,
+                reason, constraint, aContent, contentId, urlType
+                    == DRM::EUHRightsIssuerUrl ? riUrl : domainRiUrl,
+                urlType, aIntent, aError );
+            }
+
+        CleanupStack::PopAndDestroy( domainRiUrl );
+        CleanupStack::PopAndDestroy( riUrl );
+        CleanupStack::PopAndDestroy( silentUrl );
+        CleanupStack::PopAndDestroy( previewUrl );
+        CleanupStack::PopAndDestroy( constraint );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    CleanupStack::PopAndDestroy( contentId );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::ShowOmaDetailsViewL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::ShowDetailsViewL(
+    const HBufC8* aContentId,
+    const HBufC* aFullPath )
+    {
+    __ASSERT_DEBUG( aContentId, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    __ASSERT_DEBUG( aFullPath, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    // For OMA DRM
+    HBufC* launchParam( NULL );
+
+    // create parameter string
+    CreateLaunchParamL( aContentId, launchParam, aFullPath );
+    CleanupStack::PushL( launchParam );
+
+    // show details
+    LaunchRightsManagerUiL( *launchParam );
+
+    CleanupStack::PopAndDestroy( launchParam );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CheckOmaBasedRightsAmountL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CheckOmaBasedRightsAmountL(
+    ContentAccess::CData& aContent,
+    ContentAccess::TIntent aIntent,
+    DRM::MDrmUiCheckRightsObserver* aObserver,
+    TInt aOperationId )
+    {
+    HBufC8* contentId( NULL );
+    HBufC* riUrl( NULL );
+
+    DRM::TDrmUiUrlType urlType( DRM::EUHRightsIssuerUrl );
+
+    User::LeaveIfError( GetContentIdLC( aContent, contentId ) );
+
+    DoCheckOmaBasedRightsAmountL( aContent, contentId, aIntent, riUrl,
+        urlType, aObserver, aOperationId );
+
+    CleanupStack::PopAndDestroy( contentId );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::DoCheckOmaBasedRightsAmountL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::DoCheckOmaBasedRightsAmountL(
+    ContentAccess::CData& aContent,
+    const HBufC8* aContentUri,
+    ContentAccess::TIntent aIntent,
+    const HBufC* aRightsUrl,
+    DRM::TDrmUiUrlType aUrlType,
+    DRM::MDrmUiCheckRightsObserver* aObserver,
+    TInt aOperationId )
+    {
+    TInt canPlay( KErrNone );
+    CDRMConstraint* constraint( NULL );
+    DRM::TCheckRightsStatus rightsStatus( DRM::EUHCheckRightsNoRights );
+
+    TTime now( Time::NullTTime() ); // current time
+    TTime endTime( Time::NullTTime() ); // end time of time-based rights
+
+    TUint32 reason( EConstraintEndTime );
+    TBool unlimited( EFalse );
+    TUint32 countsLeft( 0 ); // number of counts left
+    TTimeIntervalSeconds secondsLeft( 0 ); // seconds to end of time based rights
+    TTimeIntervalSeconds accumulatedSecondsLeft( 0 ); // seconds to end of
+    // accumulated time rights
+
+    // Check rights
+
+    User::LeaveIfError( aContent.GetAttribute( ECanPlay, canPlay ) );
+
+    GetOmaBasedEndTimeL( aContent, endTime );
+
+    // valid rights
+    if ( canPlay ) // check the CAF parameters
+        {
+        // get the current time
+        now.HomeTimeSecure();
+
+        endTime.SecondsFrom( now, secondsLeft );
+
+        CallRightsLeftL( aObserver, aOperationId, unlimited, secondsLeft,
+            countsLeft, accumulatedSecondsLeft, aContentUri, aRightsUrl,
+            NULL, aContent, aIntent );
+        }
+
+    // Not valid rights
+    else
+        {
+        constraint = CDRMConstraint::NewLC();
+        rightsStatus = DRM::EUHCheckRightsExpiredRights;
+        constraint->iActiveConstraints |= EConstraintEndTime;
+        constraint->iEndTime = endTime;
+
+        CallRightsNotValidL( aObserver, aOperationId, rightsStatus, reason,
+            aContent, aContentUri, constraint, aRightsUrl, aUrlType, NULL,
+            aIntent );
+
+        CleanupStack::PopAndDestroy( constraint );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetOmaBasedEndTimeL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::GetOmaBasedEndTimeL(
+    ContentAccess::CData& aData,
+    TTime& aEndTime )
+    {
+    TInt err = KErrNone;
+    RFs fileSession;
+    RFile file;
+    TBuf8<KIntegerMaxLen> lenTxt;
+    TInt readStart = 0;
+    TInt headerLen = 0;
+    TInt tempVal = 0;
+
+    __UHEAP_MARK;
+
+    User::LeaveIfError( fileSession.Connect() );
+
+    CleanupClosePushL( fileSession );
+    CleanupClosePushL( file );
+
+    HBufC* filename = HBufC::NewLC( KNameBuf );
+
+    TPtr resOmaBased( const_cast<TUint16*> ( filename->Ptr() ), 0,
+        KresOmaBasedBuf );
+    err = aData.GetStringAttribute( DRM::EDrmFullName, resOmaBased );
+
+    if ( file.Open( fileSession, resOmaBased, EFileShareReadersOrWriters
+        | EFileRead ) == KErrNone )
+        {
+        /* Read content type and uri lengths */
+        err = file.Read( 1, lenTxt, 2 );
+        if ( err == KErrNone && lenTxt.Length() == 2 )
+            {
+            readStart = lenTxt[0] + lenTxt[1];
+            }
+        if ( readStart > 0 )
+            {
+            /* Add the length of version and length informations */
+            const TInt KReadSkip( 3 );
+            readStart += KReadSkip;
+            /* Read header length information (exact length not known
+             since it is Uintvar, so read plentily) */
+            err = file.Read( readStart, lenTxt, lenTxt.MaxLength() );
+            if ( err == KErrNone && lenTxt.Length() > 0 )
+                {
+                TBool cont = ETrue;
+                /* Start reading the header length */
+                TInt i = 0;
+                while ( i < lenTxt.Length() && cont )
+                    {
+                    tempVal = lenTxt[i];
+                    i++;
+                    if ( !( tempVal & 0x80 ) )
+                        { /* Highest bit not set, it's the last value */
+                        cont = EFalse;
+                        }
+                    else
+                        { /* Clear the highest bit */
+                        tempVal &= ~( 0x80 );
+                        }
+                    headerLen = ( ( headerLen << 0x07 ) | tempVal );
+                    }
+                if ( cont != EFalse )
+                    { /* Reading the length failed */
+                    headerLen = 0;
+                    }
+                else
+                    {
+                    /* Continue to read past the content length */
+                    cont = ETrue;
+                    while ( i < lenTxt.Length() && cont )
+                        {
+                        tempVal = lenTxt[i];
+                        i++;
+                        if ( !( tempVal & 0x80 ) )
+                            { /* Highest bit not set, it's the last value */
+                            cont = EFalse;
+                            }
+                        }
+                    if ( cont != EFalse )
+                        { /* Reading the length failed */
+                        headerLen = 0;
+                        }
+                    else
+                        {
+                        /* Increase read start index past length
+                         informations */
+                        readStart += i;
+                        }
+                    }
+                }
+            }
+        if ( headerLen > 0 )
+            {
+            HBufC8 *header = HBufC8::NewLC( headerLen );
+            /* Read header */
+            TPtr8 headerPtr( header->Des() );
+            err = file.Read( readStart, headerPtr, headerLen );
+            if ( err == KErrNone && headerPtr.Length() == headerLen )
+                {
+                // seperate function call from here
+                OmaBasedHeaderParserL( tempVal, headerPtr, aEndTime );
+                }
+            /* Pop and destroy header */
+            CleanupStack::PopAndDestroy( header );
+            }
+        }
+    CleanupStack::PopAndDestroy( filename );
+    CleanupStack::PopAndDestroy( &file );
+    CleanupStack::PopAndDestroy( &fileSession );
+    __UHEAP_MARKEND;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::OmaBasedHeaderParserL
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::OmaBasedHeaderParserL(
+    TInt aOffset,
+    TPtr8 aHeaderPtr,
+    TTime& aEndTime )
+    {
+    TInt err = KErrNone;
+    TTime *time = NULL;
+    _LIT8( KEndTimeStr, "Time-Not-After/" );
+    _LIT( KZero, "0" );
+
+    /* Get the time */
+    TInt pos = aHeaderPtr.FindF( KEndTimeStr );
+    if ( pos != KErrNotFound )
+        {
+        TPtrC8 endTimeStr( aHeaderPtr.Mid( pos + KEndTimeStr().Length() ) );
+        pos = endTimeStr.Locate( ',' );
+        if ( pos != KErrNotFound )
+            {
+            endTimeStr.Set( endTimeStr.Left( pos ) );
+            /* Check if it contains timezone information */
+            pos = endTimeStr.Locate( 'Z' );
+            if ( pos != KErrNotFound )
+                { /* Cut the time zone information "Zxxx" */
+                endTimeStr.Set( endTimeStr.Left( pos ) );
+                }
+            pos = endTimeStr.Locate( '+' );
+            if ( pos != KErrNotFound )
+                { /* Cut the time zone information "+xx" */
+                endTimeStr.Set( endTimeStr.Left( pos ) );
+                }
+            pos = endTimeStr.Locate( '-' );
+            if ( pos != KErrNotFound )
+                { /* Cut the time zone information "-xx" */
+                endTimeStr.Set( endTimeStr.Left( pos ) );
+                }
+            /* Allocate new buffer with length enough
+             for adding needed ':' character between date and time */
+            const TInt KPlaceOfColon( 8 );
+            HBufC16* dateTimeBuf = HBufC16::NewLC( endTimeStr.Length() + 1 );
+            /* Copy provides sufficient 8bit -> 16bit conversion here */
+            dateTimeBuf->Des().Copy( endTimeStr );
+            dateTimeBuf->Des().Insert( KPlaceOfColon, _L16 ( ":" ) );
+
+            /* Decrease 1 from month and day, cause
+             TTime::FormatL expects them to start from 0 */
+            TPtrC16 tempPtr( dateTimeBuf->Des().Mid( 4, 2 ) );
+            TLex16 lex( dateTimeBuf->Des().Mid( 4, 2 ) );
+            TBuf<2> replace;
+            err = lex.Val( aOffset );
+            if ( err == KErrNone )
+                {
+                replace.Num( ( aOffset - 1 ) );
+                if ( replace.Length() == 1 )
+                    { /* Insert the '0' needed by TTime */
+                    replace.Insert( 0, KZero );
+                    }
+                dateTimeBuf->Des().Replace( 4, 2, replace );
+
+                lex.Assign( dateTimeBuf->Des().Mid( 6, 2 ) );
+                TBuf<2> replace;
+                err = lex.Val( aOffset );
+                if ( err == KErrNone )
+                    {
+                    replace.Num( ( aOffset - 1 ) );
+                    if ( replace.Length() == 1 )
+                        { /* Insert the '0' needed by TTime */
+                        replace.Insert( 0, KZero );
+                        }
+                    dateTimeBuf->Des().Replace( 6, 2, replace );
+
+                    time = new ( ELeave ) TTime( dateTimeBuf->Des() );
+
+                    CleanupStack::PushL( time );
+                    aEndTime = *time;
+
+                    /* Pop and destroy time */
+                    CleanupStack::PopAndDestroy( time );
+                    }
+                }
+            /* Pop and destroy dateTimeBuf */
+            CleanupStack::PopAndDestroy( dateTimeBuf );
+            }
+        }
+    else
+        {
+        return KErrNotFound;
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::ShowDetailsViewL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::ShowDetailsViewL( const HBufC* aFullPath )
+    {
+
+    __ASSERT_DEBUG( aFullPath, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+    // For WM DRM
+    HBufC* launchParam( NULL );
+
+    // create parameter string
+    CreateLaunchParamL( aFullPath, launchParam );
+    CleanupStack::PushL( launchParam );
+
+    // show details
+    LaunchRightsManagerUiL( *launchParam );
+
+    CleanupStack::PopAndDestroy( launchParam );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::DoHandleOmaUrlL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::DoHandleOmaUrlL(
+    ContentAccess::CData& aContent,
+    DRM::TDrmUiUrlType aType )
+    {
+    HBufC* url( NULL );
+    HBufC8* url8( NULL );
+    TInt previewType( 0 );
+
+    switch ( aType )
+        {
+        // handle RightsIssuerUrl
+        case DRM::EUHRightsIssuerUrl:
+
+            GetOmaRightsIssuerLC( aContent, url );
+            if ( !url )
+                {
+                User::Leave( KErrNotFound );
+                }
+
+            LaunchBrowserL( url );
+
+            CleanupStack::PopAndDestroy( url );
+
+            break;
+
+            // handle PreviewUrl
+        case DRM::EUHPreviewRightsUrl:
+
+            GetOmaPreviewInfoLC( aContent, url, previewType );
+            if ( !url )
+                {
+                User::Leave( KErrNotFound );
+                }
+
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+            if ( previewType == ContentAccess::EPreviewRights )
+                {
+                url8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *url );
+                CleanupStack::PushL( url8 );
+
+                GetSilentRightsL( *url8, ETrue );
+
+                CleanupStack::PopAndDestroy( url8 );
+                }
+
+#endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+            CleanupStack::PopAndDestroy( url );
+
+            break;
+
+            // handle SilentRightsUrl
+        case DRM::EUHSilentRightsUrl:
+
+            GetOmaSilentRightsUrlLC( aContent, url8 );
+            if ( !url8 )
+                {
+                User::Leave( KErrNotFound );
+                }
+
+            GetSilentRightsL( *url8, ETrue );
+
+            CleanupStack::PopAndDestroy( url8 );
+
+            break;
+
+            // handle InfoUrl
+        case DRM::EUHInfoUrl:
+
+            GetOmaInfoUrlLC( aContent, url );
+            if ( !url )
+                {
+                User::Leave( KErrNotFound );
+                }
+
+            LaunchBrowserL( url );
+
+            CleanupStack::PopAndDestroy( url );
+
+            break;
+
+            // handle DomainRightsIssuerUrl
+        case DRM::EUHDomainRiUrl:
+
+            GetOmaDomainRightsIssuerLC( aContent, url );
+            if ( !url )
+                {
+                User::Leave( KErrNotFound );
+                }
+
+            LaunchBrowserL( url );
+
+            CleanupStack::PopAndDestroy( url );
+
+            break;
+
+        default:
+
+            User::Leave( KErrNotSupported );
+
+            break;
+
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetAvailableOmaUrlsL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::GetAvailableOmaUrlsL(
+    ContentAccess::CData& aContent,
+    DRM::TDrmUiUrlType& aType )
+    {
+    HBufC* riUrl( NULL );
+    HBufC* previewUrl( NULL );
+    HBufC8* silentUrl( NULL );
+    HBufC* infoUrl( NULL );
+    HBufC* domainRiUrl( NULL );
+
+    TInt dummy( 0 );
+    TInt temp( 0 );
+
+    // Try to get all Urls
+    GetOmaRightsIssuerLC( aContent, riUrl );
+    if ( riUrl )
+        {
+        temp |= DRM::EUHRightsIssuerUrl;
+        }
+    CleanupStack::PopAndDestroy( riUrl );
+    riUrl = NULL;
+
+    GetOmaPreviewInfoLC( aContent, previewUrl, dummy );
+    if ( previewUrl )
+        {
+        temp |= DRM::EUHPreviewRightsUrl;
+        }
+    CleanupStack::PopAndDestroy( previewUrl );
+    previewUrl = NULL;
+
+    GetOmaSilentRightsUrlLC( aContent, silentUrl );
+    if ( silentUrl )
+        {
+        temp |= DRM::EUHSilentRightsUrl;
+        }
+    CleanupStack::PopAndDestroy( silentUrl );
+    silentUrl = NULL;
+
+    GetOmaInfoUrlLC( aContent, infoUrl );
+    if ( infoUrl )
+        {
+        temp |= DRM::EUHInfoUrl;
+        }
+    CleanupStack::PopAndDestroy( infoUrl );
+    infoUrl = NULL;
+
+    GetOmaDomainRightsIssuerLC( aContent, domainRiUrl );
+    if ( domainRiUrl )
+        {
+        temp |= DRM::EUHDomainRiUrl;
+        }
+    CleanupStack::PopAndDestroy( domainRiUrl );
+    domainRiUrl = NULL;
+
+    // Return a bit mask of available urls
+    aType = static_cast<TDrmUiUrlType> ( temp );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetContentIdLC
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::GetContentIdLC(
+    const ContentAccess::CData& aContent,
+    HBufC8*& aId )
+    {
+    __ASSERT_DEBUG( !aId, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    TInt error( KErrNone );
+    TInt currentLength( KUrlMaxLen );
+    HBufC* contentId( NULL );
+    TPtr idPtr( NULL, 0 );
+
+    contentId = HBufC::NewLC( currentLength );
+    idPtr.Set( contentId->Des() );
+
+    error = aContent.GetStringAttribute( ContentAccess::EContentID, idPtr );
+
+    while ( error == KErrOverflow )
+        {
+        currentLength += currentLength;
+        CleanupStack::PopAndDestroy( contentId );
+        contentId = HBufC::NewLC( currentLength );
+        idPtr.Set( contentId->Des() );
+        error
+            = aContent.GetStringAttribute( ContentAccess::EContentID, idPtr );
+        }
+
+    if ( !error && idPtr.Length() )
+        {
+        aId = CnvUtfConverter::ConvertFromUnicodeToUtf8L( idPtr );
+        }
+
+    CleanupStack::PopAndDestroy( contentId );
+    CleanupStack::PushL( aId );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetOmaRightsIssuerLC
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::GetOmaRightsIssuerLC(
+    const ContentAccess::CData& aContent,
+    HBufC*& aIssuer )
+    {
+    __ASSERT_DEBUG( !aIssuer, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    TInt error( KErrNone );
+    TInt currentLength( KUrlMaxLen );
+    HBufC* decodedIssuer( NULL );
+    HBufC* rightsIssuer( NULL );
+    TPtr riPtr( NULL, 0 );
+
+    rightsIssuer = HBufC::NewLC( currentLength );
+    riPtr.Set( rightsIssuer->Des() );
+
+    // Get value of riUrl
+    error = aContent.GetStringAttribute( ContentAccess::ERightsIssuerUrl,
+        riPtr );
+
+    while ( error == KErrOverflow )
+        {
+        currentLength += currentLength;
+        CleanupStack::PopAndDestroy( rightsIssuer );
+        rightsIssuer = HBufC::NewLC( currentLength );
+        riPtr.Set( rightsIssuer->Des() );
+        error = aContent.GetStringAttribute( ContentAccess::ERightsIssuerUrl,
+            riPtr );
+        }
+
+    if ( !error && riPtr.Length() )
+        {
+        riPtr.TrimLeft();
+        // check if rights issuer is encrypted
+        if ( riPtr.MatchF( KEncryptedRightsIssuerMatchString )
+            != KErrNotFound )
+            {
+            HBufC8* input( NULL );
+            HBufC8* output( NULL );
+
+            input = CnvUtfConverter::ConvertFromUnicodeToUtf8L( riPtr );
+
+            CleanupStack::PushL( input );
+            // encrypted, decrypt
+            User::LeaveIfError( iOmaClient.DecodeRightsIssuerField( *input,
+                output ) );
+            CleanupStack::PopAndDestroy( input );
+
+            CleanupStack::PushL( output );
+            decodedIssuer = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+                *output );
+            CleanupStack::PopAndDestroy( output );
+
+            CleanupStack::PushL( decodedIssuer );
+            riPtr.Set( decodedIssuer->Des() );
+            aIssuer = riPtr.AllocL();
+            CleanupStack::PopAndDestroy( decodedIssuer );
+            }
+        else
+            {
+            aIssuer = riPtr.AllocL();
+            }
+        }
+
+    CleanupStack::PopAndDestroy( rightsIssuer );
+    CleanupStack::PushL( aIssuer );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetOmaDomainRightsIssuerLC
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::GetOmaDomainRightsIssuerLC(
+    const ContentAccess::CData& aContent,
+    HBufC*& aIssuer )
+    {
+    __ASSERT_DEBUG( !aIssuer, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    TInt error( KErrNone );
+    TInt currentLength( KUrlMaxLen );
+    HBufC* rightsIssuer( NULL );
+    TPtr riPtr( NULL, 0 );
+
+    rightsIssuer = HBufC::NewLC( currentLength );
+    riPtr.Set( rightsIssuer->Des() );
+
+    // Get value of domainRIUrl
+    error = aContent.GetStringAttribute(
+        ContentAccess::EDomainRightsIssuerUrl, riPtr );
+
+    while ( error == KErrOverflow )
+        {
+        currentLength += currentLength;
+        CleanupStack::PopAndDestroy( rightsIssuer );
+        rightsIssuer = HBufC::NewLC( currentLength );
+        riPtr.Set( rightsIssuer->Des() );
+        error = aContent.GetStringAttribute(
+            ContentAccess::EDomainRightsIssuerUrl, riPtr );
+        }
+
+    if ( !error && riPtr.Length() )
+        {
+        aIssuer = riPtr.AllocL();
+        }
+
+    CleanupStack::PopAndDestroy( rightsIssuer );
+    CleanupStack::PushL( aIssuer );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetOmaPreviewInfoLC
+// -----------------------------------------------------------------------------
+TInt DRM::CDrmUiHandlingImpl::GetOmaPreviewInfoLC(
+    const ContentAccess::CData& aContent,
+    HBufC*& aPreviewUrl,
+    TInt& aPreviewType )
+    {
+    __ASSERT_DEBUG( !aPreviewUrl, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    TInt error( KErrNone );
+    TInt currentLength( KUrlMaxLen );
+    HBufC* preview( NULL );
+    TPtr previewPtr( NULL, 0 );
+
+    aPreviewType = ContentAccess::ENoPreview;
+
+    preview = HBufC::NewLC( currentLength );
+    previewPtr.Set( preview->Des() );
+
+    error = aContent.GetAttribute( ContentAccess::EPreviewType, aPreviewType );
+
+    switch ( aPreviewType )
+        {
+
+        case ContentAccess::EInstantPreview:
+            // get URI of embedded preview
+            error = aContent.GetStringAttribute(
+                ContentAccess::EInstantPreviewUri, previewPtr );
+
+            while ( error == KErrOverflow )
+                {
+                currentLength += currentLength;
+                CleanupStack::PopAndDestroy( preview );
+                preview = HBufC::NewLC( currentLength );
+                previewPtr.Set( preview->Des() );
+                error = aContent.GetStringAttribute(
+                    ContentAccess::EInstantPreviewUri, previewPtr );
+                }
+
+            if ( !error && previewPtr.Length() )
+                {
+                aPreviewUrl = previewPtr.AllocL();
+                }
+            else
+                {
+                aPreviewType = ContentAccess::ENoPreview;
+                }
+            break;
+
+        case ContentAccess::EPreviewRights:
+            // get URI of preview rights
+            error = aContent.GetStringAttribute(
+                ContentAccess::EPreviewRightsUri, previewPtr );
+
+            while ( error == KErrOverflow )
+                {
+                currentLength += currentLength;
+                CleanupStack::PopAndDestroy( preview );
+                preview = HBufC::NewLC( currentLength );
+                previewPtr.Set( preview->Des() );
+                error = aContent.GetStringAttribute(
+                    ContentAccess::EPreviewRightsUri, previewPtr );
+                }
+
+            if ( !error && previewPtr.Length() )
+                {
+                aPreviewUrl = previewPtr.AllocL();
+                }
+            else
+                {
+                aPreviewType = ContentAccess::ENoPreview;
+                }
+            break;
+
+        default:
+            // no preview
+            break;
+        }
+
+    CleanupStack::PopAndDestroy( preview );
+    CleanupStack::PushL( aPreviewUrl );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetOmaSilentRightsUrlLC
+// -----------------------------------------------------------------------------
+TInt DRM::CDrmUiHandlingImpl::GetOmaSilentRightsUrlLC(
+    const ContentAccess::CData& aContent,
+    HBufC8*& aSilentUrl )
+    {
+    __ASSERT_DEBUG( !aSilentUrl, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    TInt error( KErrNone );
+    TInt currentLength( KUrlMaxLen );
+    Roap::RRoapStorageClient storage;
+    HBufC8* silent8( NULL );
+    HBufC* silent( NULL );
+    TPtr silentPtr( NULL, 0 );
+
+    silent = HBufC::NewLC( currentLength );
+    silentPtr.Set( silent->Des() );
+
+    // get SilentRightsUrl
+    error = aContent.GetStringAttribute( ContentAccess::ESilentRightsUrl,
+        silentPtr );
+
+    while ( error == KErrOverflow )
+        {
+        currentLength += currentLength;
+        CleanupStack::PopAndDestroy( silent );
+        silent = HBufC::NewLC( currentLength );
+        silentPtr.Set( silent->Des() );
+        error = aContent.GetStringAttribute( ContentAccess::ESilentRightsUrl,
+            silentPtr );
+        }
+
+    if ( !error && silentPtr.Length() )
+        {
+        silentPtr.TrimLeft();
+        silent8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( silentPtr );
+        TPtr8 silentPtr8( silent8->Des() );
+        CleanupStack::PushL( silent8 );
+
+        User::LeaveIfError( storage.Connect() );
+        CleanupClosePushL( storage );
+
+        // check that SilentRightsUrl is on the white list
+        // URL is not searched from pre-configured white list
+        TBool fromPreConfiguredWhiteList( EFalse );
+        if ( storage.WhiteListURLExistsL( *silent8,
+            fromPreConfiguredWhiteList ) )
+            {
+            aSilentUrl = silentPtr8.AllocL();
+            }
+
+        CleanupStack::PopAndDestroy( 2, silent8 ); //storage, silent8
+        }
+
+    CleanupStack::PopAndDestroy( silent );
+    CleanupStack::PushL( aSilentUrl );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetOmaInfoUrlLC
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::GetOmaInfoUrlLC(
+    const ContentAccess::CData& aContent,
+    HBufC*& aInfoUrl )
+    {
+    __ASSERT_DEBUG( !aInfoUrl, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    TInt error( KErrNone );
+    TInt currentLength( KUrlMaxLen );
+    HBufC* info( NULL );
+    TPtr infoPtr( NULL, 0 );
+
+    info = HBufC::NewLC( currentLength );
+    infoPtr.Set( info->Des() );
+
+    // get InfoUrl
+    error = aContent.GetStringAttribute( ContentAccess::EInfoURL, infoPtr );
+
+    while ( error == KErrOverflow )
+        {
+        currentLength += currentLength;
+        CleanupStack::PopAndDestroy( info );
+        info = HBufC::NewLC( currentLength );
+        infoPtr.Set( info->Des() );
+        error
+            = aContent.GetStringAttribute( ContentAccess::EInfoURL, infoPtr );
+        }
+
+    if ( !error && infoPtr.Length() )
+        {
+        aInfoUrl = infoPtr.AllocL();
+        }
+
+    CleanupStack::PopAndDestroy( info );
+    CleanupStack::PushL( aInfoUrl );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetOmaPendingRightsInfoLC
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::GetOmaPendingRightsInfoLC(
+    const ContentAccess::CData& aContent,
+    HBufC*& aEta )
+    {
+    __ASSERT_DEBUG( !aEta, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    TInt error( KErrNone );
+    HBufC* eta( NULL );
+    TPtr etaPtr( NULL, 0 );
+
+    eta = HBufC::NewLC( KDRMMaxETABufSize );
+    etaPtr.Set( eta->Des() );
+
+    // get eta info
+    error = aContent.GetStringAttribute( EPendingRightsETA, etaPtr );
+
+    if ( !error && etaPtr.Length() )
+        {
+        aEta = etaPtr.AllocL();
+        }
+
+    CleanupStack::PopAndDestroy( eta );
+    CleanupStack::PushL( aEta );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetContentLocationLC
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::GetContentLocationLC(
+    const ContentAccess::CData& aContent,
+    HBufC*& aPath )
+    {
+    __ASSERT_DEBUG( !aPath, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    TInt error( KErrNone );
+    TInt currentLength( KUrlMaxLen );
+    TPtr pathPtr( NULL, 0 );
+
+    aPath = HBufC::NewLC( currentLength );
+    pathPtr.Set( aPath->Des() );
+
+    error = aContent.GetStringAttribute( DRM::EDrmFullName, pathPtr );
+
+    while ( error == KErrOverflow )
+        {
+        currentLength += currentLength;
+        CleanupStack::PopAndDestroy( aPath );
+        aPath = HBufC::NewLC( currentLength );
+        pathPtr.Set( aPath->Des() );
+        error = aContent.GetStringAttribute( DRM::EDrmFullName, pathPtr );
+        }
+
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CheckOmaDomainStatusL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CheckOmaDomainStatusL(
+    const ContentAccess::CData& aContent,
+    const HBufC* aDomainRiUrl,
+    TInt& aIsRegistered,
+    TInt& aIsJoined )
+    {
+    Roap::RRoapStorageClient storage;
+    CDRMRIContext* riContext( NULL );
+    CDRMDomainContext* domainContext( NULL );
+
+    HBufC* riId( NULL );
+    HBufC8* riId8( NULL );
+    HBufC* domainId( NULL );
+    HBufC8* domainId8( NULL );
+
+    TInt error( KErrNone );
+    TPtr ptr( NULL, 0 );
+
+    aIsJoined = EFalse;
+    aIsRegistered = EFalse;
+
+    riId = HBufC::NewLC( KUrlMaxLen );
+    domainId = HBufC::NewLC( KUrlMaxLen );
+
+    // create attribute set
+    RStringAttributeSet stringAttributeSet;
+    CleanupClosePushL( stringAttributeSet );
+    // add the attributes we are interested in
+    stringAttributeSet.AddL( EDomainId );
+    stringAttributeSet.AddL( EDomainRightsIssuerId );
+
+    User::LeaveIfError( aContent.GetStringAttributeSet( stringAttributeSet ) );
+
+    // pass on values of string attributes
+    ptr.Set( domainId->Des() );
+    error = stringAttributeSet.GetValue( EDomainId, ptr );
+    if ( !error )
+        {
+        ptr.Set( riId->Des() );
+        stringAttributeSet.GetValue( EDomainRightsIssuerId, ptr );
+        if ( !error )
+            {
+            riId8 = HBufC8::NewLC( riId->Length() );
+            riId8->Des().Copy( riId->Des() );
+            domainId8 = HBufC8::NewLC( domainId->Length() );
+            domainId8->Des().Copy( domainId->Des() );
+
+            if ( riId8 && riId8->Length() && aDomainRiUrl
+                && aDomainRiUrl->Length() )
+                {
+                // Check if we have domain RO
+                User::LeaveIfError( storage.Connect() );
+                CleanupClosePushL( storage );
+                riContext = storage.GetRIContextL( *riId8 );
+                if ( riContext )
+                    {
+                    aIsRegistered = ETrue;
+                    delete riContext;
+                    if ( domainId8 && domainId8->Length() )
+                        {
+                        domainContext
+                            = storage.GetDomainContextL( *domainId8 );
+                        if ( domainContext )
+                            {
+                            // last three digits presents
+                            // the domain generation
+                            TInt generation( 0 );
+                            TLex8 lex( domainId8->Right(
+                                KOmaDomainGenerationLength ) );
+                            lex.Val( generation );
+
+                            if ( domainContext->DomainGeneration()
+                                >= generation )
+                                {
+                                aIsJoined = ETrue;
+                                }
+                            delete domainContext;
+                            }
+                        }
+                    }
+                CleanupStack::PopAndDestroy( &storage );
+                }
+            CleanupStack::PopAndDestroy( 2, riId8 ); // domainId8, riId8
+            }
+        }
+    CleanupStack::PopAndDestroy( &stringAttributeSet );
+    CleanupStack::PopAndDestroy( 2, riId ); // domainId, riId
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CallRightsNotValidL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CallRightsNotValidL(
+    DRM::MDrmUiCheckRightsObserver* aObserver,
+    TInt aOperationId,
+    DRM::TCheckRightsStatus aRightsStatus,
+    TUint32 aReason,
+    ContentAccess::CData& aContent,
+    const HBufC8* aContentUri,
+    CDRMConstraint* aConstraint,
+    const HBufC* aRightsUrl,
+    DRM::TDrmUiUrlType aUrlType,
+    const HBufC8* aSilentUrl,
+    ContentAccess::TIntent aIntent )
+    {
+    DRM::TCheckRightsAction rightsAction( DRM::EUHCheckRightsActionDefault );
+
+    if ( aObserver )
+        {
+        // call given CheckRightsObserver
+        rightsAction = aObserver->RightsNotValid( aOperationId,
+            aRightsStatus, RejectReason( aReason ) );
+        }
+
+    switch ( rightsAction )
+        {
+        case DRM::EUHCheckRightsActionDefault:
+            {
+            if ( RejectReason( aReason ) == DRM::EURejectionMetering )
+                {
+                // Show that only reason for error was rejected metering.
+                iDrmUtilityUi->DisplayQueryWithIdL(
+                    R_DRM_QUERY_METERING_DISABLED,
+                    R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY );
+                }
+            else
+                {
+                if ( !GetSilentAndCallL( aObserver, aOperationId, aIntent,
+                    aContentUri, aSilentUrl, ETrue ) )
+                    {
+                    // Silent URL not present or silent retrieval failed
+                    // show appropriate notes
+                    if ( ShowNoRightsNoteL( aContent, RightsInfoStatus(
+                        aRightsStatus ), aReason, aConstraint, aRightsUrl,
+                        aUrlType, ENoRights ) )
+                        {
+                        GetRightsAndCallL( aObserver, aOperationId, aIntent,
+                            aContentUri, aRightsUrl );
+                        }
+                    }
+                }
+            }
+            break;
+
+        case DRM::EUHCheckRightsActionOpenDetailsView:
+            {
+            HBufC* fullPath( NULL );
+            GetContentLocationLC( aContent, fullPath );
+            ShowDetailsViewL( aContentUri, fullPath );
+            CleanupStack::PopAndDestroy( fullPath );
+            }
+            break;
+
+        case DRM::EUHCheckRightsActionAcquireNewRights:
+            {
+            if ( !GetSilentAndCallL( aObserver, aOperationId, aIntent,
+                aContentUri, aSilentUrl, EFalse ) )
+                {
+                GetRightsAndCallL( aObserver, aOperationId, aIntent,
+                    aContentUri, aRightsUrl );
+                if ( !aRightsUrl )
+                    {
+                    User::Leave( KErrArgument );
+                    }
+                }
+            }
+            break;
+
+        case DRM::EUHCheckRightsActionIgnore:
+            // do nothing
+            break;
+
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CallRightsLeftL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CallRightsLeftL(
+    DRM::MDrmUiCheckRightsObserver* aObserver,
+    TInt aOperationId,
+    TBool aUnconstrained,
+    TTimeIntervalSeconds aTime,
+    TInt aCounts,
+    TTimeIntervalSeconds aAccumulated,
+    const HBufC8* aContentUri,
+    const HBufC* aRightsUrl,
+    const HBufC8* aSilentUrl,
+    ContentAccess::CData& aContent,
+    ContentAccess::TIntent aIntent )
+    {
+    DRM::TCheckRightsAction rightsAction( DRM::EUHCheckRightsActionDefault );
+    HBufC* fullPath( NULL );
+
+    if ( aObserver )
+        {
+        // call given CheckRightsObserver
+        rightsAction = aObserver->RightsLeft( aOperationId, aUnconstrained,
+            aTime, aCounts, aAccumulated );
+        }
+
+    switch ( rightsAction )
+        {
+        case DRM::EUHCheckRightsActionDefault:
+            {
+            // show appropriate notes, none at the moment
+            }
+            break;
+
+        case DRM::EUHCheckRightsActionOpenDetailsView:
+            {
+            GetContentLocationLC( aContent, fullPath );
+            ShowDetailsViewL( aContentUri, fullPath );
+            CleanupStack::PopAndDestroy( fullPath );
+            }
+            break;
+
+        case DRM::EUHCheckRightsActionAcquireNewRights:
+            {
+            if ( !GetSilentAndCallL( aObserver, aOperationId, aIntent,
+                aContentUri, aSilentUrl, EFalse ) )
+                {
+                if ( !aRightsUrl )
+                    {
+                    User::Leave( KErrArgument );
+                    }
+                // launch browser to get new rights
+                LaunchBrowserL( aRightsUrl );
+                }
+            }
+            break;
+
+        case DRM::EUHCheckRightsActionIgnore:
+            // do nothing
+            break;
+
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CallEmbeddedPreviewAvailableL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CallEmbeddedPreviewAvailableL(
+    DRM::MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId,
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+    ContentAccess::CData& aContent,
+#else
+    ContentAccess::CData& /*aContent*/,
+#endif
+    const HBufC* aPreviewUrl,
+    DRM::TDrmRightsInfo aRightsStatus,
+    TUint32 aReason,
+    const HBufC* aRightsUrl,
+    const HBufC8* aContentUri,
+    ContentAccess::TIntent aIntent )
+    {
+    DRM::TEmbeddedPreviewAction embeddedPreviewAction(
+        DRM::EUEmbeddedPreviewActionDefault );
+
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+    TInt buttonCode( 0 );
+
+#endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+    if ( aObserver )
+        {
+        // call given HandleErrorObserver
+        embeddedPreviewAction
+            = aObserver->EmbeddedPreviewAvailable( aOperationId,
+                *aPreviewUrl, aRightsStatus, RejectReason( aReason ) );
+        }
+
+    switch ( embeddedPreviewAction )
+        {
+        case DRM::EUEmbeddedPreviewActionDefault:
+        case DRM::EUEmbeddedPreviewActionDefaultAudio:
+        case DRM::EUEmbeddedPreviewActionDefaultVideo:
+            {
+
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+            buttonCode = iDrmUtilityUi->DisplayPopupWindowsForPreviewL(
+                aContent, ContentAccess::EInstantPreview,
+                embeddedPreviewAction );
+
+            switch ( buttonCode )
+                {
+                case 1: // Normal Rights
+
+                    {
+                    GetRightsAndCallL( aObserver, aOperationId, aIntent,
+                        aContentUri, aRightsUrl );
+                    }
+                    break;
+
+                case 2: // Play Preview
+
+                    CallPlayEmbeddedPreviewSelected( aObserver, aOperationId,
+                        aPreviewUrl );
+
+                    break;
+
+                default:
+
+                    break;
+                }
+
+#endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+            }
+            break;
+
+        case DRM::EUEmbeddedPreviewActionFetchRights:
+            {
+            GetRightsAndCallL( aObserver, aOperationId, aIntent, aContentUri,
+                aRightsUrl );
+            }
+            break;
+
+        case DRM::EUEmbeddedPreviewActionPlayPreview:
+            // do nothing (observer plays the preview)
+        case DRM::EUEmbeddedPreviewActionIgnore:
+            // do nothing
+            break;
+
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CallPreviewRightsUrlAvailableL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CallPreviewRightsUrlAvailableL(
+    DRM::MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId,
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+    ContentAccess::CData& aContent,
+#else
+    ContentAccess::CData& /*aContent*/,
+#endif
+    const HBufC* aPreviewUrl,
+    DRM::TDrmRightsInfo aRightsStatus,
+    TUint32 aReason,
+    const HBufC* aRightsUrl,
+    const HBufC8* aContentUri,
+    ContentAccess::TIntent aIntent )
+    {
+    DRM::TPreviewRightsAction previewRightsAction(
+        DRM::EUPreviewRightsActionDefault );
+
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+    TInt buttonCode( 0 );
+    HBufC8* url8( NULL );
+
+#endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+    if ( aObserver )
+        {
+        // call given HandleErrorObserver
+        previewRightsAction
+            = aObserver->PreviewRightsUrlAvailable( aOperationId,
+                *aPreviewUrl, aRightsStatus, RejectReason( aReason ) );
+        }
+
+    switch ( previewRightsAction )
+        {
+        case DRM::EUPreviewRightsActionDefault:
+        case DRM::EUPreviewRightsActionDefaultAudio:
+        case DRM::EUPreviewRightsActionDefaultVideo:
+            {
+
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+            buttonCode = iDrmUtilityUi->DisplayPopupWindowsForPreviewL(
+                aContent, ContentAccess::EPreviewRights, previewRightsAction );
+
+            switch ( buttonCode )
+                {
+                case 1: // Normal rights
+
+                    {
+                    GetRightsAndCallL( aObserver, aOperationId, aIntent,
+                        aContentUri, aRightsUrl );
+
+                    }
+                    break;
+
+                case 2: // Preview rights
+                    {
+                    TInt callError( KErrNotFound );
+                    if ( aPreviewUrl )
+                        {
+                        url8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L(
+                            *aPreviewUrl );
+                        CleanupStack::PushL( url8 );
+
+                        GetSilentRightsL( *url8, ETrue );
+
+                        CleanupStack::PopAndDestroy( url8 );
+
+                        // check if rights exist now
+                        callError = CheckAndMapToCallError( iOmaClient,
+                            aIntent, *aContentUri );
+                        }
+                    CallPreviewRightsAvailable( aObserver, aOperationId,
+                        callError );
+                    }
+                    break;
+
+                default:
+
+                    break;
+                }
+
+#endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+            }
+            break;
+
+        case DRM::EUPreviewRightsActionFetchRights:
+            {
+            GetRightsAndCallL( aObserver, aOperationId, aIntent, aContentUri,
+                aRightsUrl );
+            }
+            break;
+
+        case DRM::EUPreviewRightsActionFetchPreviewRights:
+            // do nothing (observer fetches preview rights)
+        case DRM::EUPreviewRightsActionIgnore:
+            // do nothing
+            break;
+
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CallSilentRightsUrlAvailableL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CallSilentRightsUrlAvailableL(
+    DRM::MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId,
+    const HBufC8* aSilentUrl,
+    DRM::TDrmRightsInfo aRightsStatus,
+    TUint32 aReason,
+    const HBufC* aRightsUrl,
+    const HBufC8* aContentUri,
+    ContentAccess::TIntent aIntent )
+    {
+    DRM::TSilentRightsAction silentRightsAction(
+        DRM::EUSilentRightsActionDefault );
+    TInt callError( KErrNotFound );
+    HBufC * silent16(
+        CnvUtfConverter::ConvertToUnicodeFromUtf8L( *aSilentUrl ) );
+
+    if ( aObserver )
+        {
+        // call given HandleErrorObserver
+        silentRightsAction = aObserver->SilentRightsUrlAvailable(
+            aOperationId, *silent16, aRightsStatus, RejectReason( aReason ) );
+        }
+
+    delete silent16;
+
+    switch ( silentRightsAction )
+        {
+        case DRM::EUSilentRightsActionDefault:
+            {
+
+            GetSilentRightsL( *aSilentUrl, ETrue );
+
+            // check if rights exist now
+            callError = CheckAndMapToCallError( iOmaClient, aIntent,
+                *aContentUri );
+            CallSilentRightsAvailable( aObserver, aOperationId, callError );
+
+            }
+            break;
+
+        case DRM::EUSilentRightsActionFetchRights:
+            {
+            GetRightsAndCallL( aObserver, aOperationId, aIntent, aContentUri,
+                aRightsUrl );
+            }
+            break;
+
+        case DRM::EUSilentRightsActionFetchSilentRights:
+            // do nothing (observer fetches silent rights)
+        case DRM::EUSilentRightsActionIgnore:
+            // do nothing
+            break;
+
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CallRightsUrlAvailableL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CallRightsUrlAvailableL(
+    DRM::MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId,
+    DRM::TDrmRightsInfo aRightsStatus,
+    TUint32 aReason,
+    CDRMConstraint* aConstraint,
+    ContentAccess::CData& aContent,
+    const HBufC8* aContentUri,
+    const HBufC* aRightsUrl,
+    DRM::TDrmUiUrlType aUrlType,
+    ContentAccess::TIntent aIntent,
+    TInt aError )
+    {
+    DRM::TRightsAction rightsAction( DRM::EURightsActionDefault );
+
+    if ( aObserver && aRightsUrl )
+        {
+        // call given HandleErrorObserver
+        rightsAction = aObserver->RightsUrlAvailable( aOperationId,
+            *aRightsUrl, aRightsStatus, RejectReason( aReason ), aUrlType );
+        }
+
+    switch ( rightsAction )
+        {
+        case DRM::EURightsActionDefault:
+            {
+            if ( ShowNoRightsNoteL( aContent, aRightsStatus, aReason,
+                aConstraint, aRightsUrl, aUrlType, aError ) )
+                {
+                GetRightsAndCallL( aObserver, aOperationId, aIntent,
+                    aContentUri, aRightsUrl );
+                }
+            }
+            break;
+
+        case DRM::EURightsActionFetchRights:
+            {
+            GetRightsAndCallL( aObserver, aOperationId, aIntent, aContentUri,
+                aRightsUrl );
+            }
+            break;
+
+        case DRM::EURightsActionIgnore:
+            // do nothing
+            break;
+
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CallPreviewRightsAvailable
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CallPreviewRightsAvailable(
+    DRM::MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId,
+    TInt aError )
+    {
+
+    if ( aObserver )
+        {
+        // call given HandleErrorObserver
+        aObserver->PreviewRightsAvailable( aOperationId, aError );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CallSilentRightsAvailable
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CallSilentRightsAvailable(
+    DRM::MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId,
+    TInt aError )
+    {
+
+    if ( aObserver )
+        {
+        // call given HandleErrorObserver
+        aObserver->SilentRightsAvailable( aOperationId, aError );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CallRightsAvailable
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CallRightsAvailable(
+    DRM::MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId,
+    TInt aError )
+    {
+
+    if ( aObserver )
+        {
+        // call given HandleErrorObserver
+        aObserver->RightsAvailable( aOperationId, aError );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CallPlayEmbeddedPreviewSelected
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CallPlayEmbeddedPreviewSelected(
+    DRM::MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId,
+    const HBufC* aPreviewUrl )
+    {
+    if ( aObserver )
+        {
+        // call given HandleErrorObserver
+        aObserver->PlayEmbeddedPreviewSelected( aOperationId, *aPreviewUrl );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::ShowNoRightsNoteL
+// -----------------------------------------------------------------------------
+//
+TBool DRM::CDrmUiHandlingImpl::ShowNoRightsNoteL(
+    ContentAccess::CData& aContent,
+    DRM::TDrmRightsInfo aRightsStatus,
+    TUint32 aReason,
+    CDRMConstraint* aConstraint,
+    const HBufC* aRightsUrl,
+    DRM::TDrmUiUrlType aUrlType,
+    TInt aError )
+    {
+    HBufC* etaBuf( NULL );
+    TBool isRegistered( EFalse );
+    TBool isJoined( EFalse );
+    TInt ret( 0 );
+    TInt err( KErrNone );
+    TInt eta( 0 );
+    TFileName fileName;
+    TBool rightsRenewalWanted( EFalse );
+
+    if ( aError != EPendingRights && aRightsStatus == DRM::EURightsInfoFuture )
+        {
+        iDrmUtilityUi->ShowFutureRightsNoteL( aConstraint );
+        }
+    else
+        {
+        // check if rights are expected to arrive
+        GetOmaPendingRightsInfoLC( aContent, etaBuf );
+        if ( etaBuf )
+            {
+            TLex lexer( *etaBuf );
+            err = lexer.Val( eta );
+            }
+        CleanupStack::PopAndDestroy( etaBuf );
+
+        if ( !err && aError == EPendingRights && eta == -1 )
+            {
+            // rights should have come already
+            if ( aRightsUrl )
+                {
+                ret = iDrmUtilityUi->DisplayQueryWithIdL(
+                    R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME,
+                    R_DRMUTILITY_CONFIRMATION_QUERY );
+                }
+            else
+                {
+                // no rights issuer
+                iDrmUtilityUi->DisplayQueryWithIdL(
+                    R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME_NO_RI,
+                    R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY );
+                }
+            }
+        else if ( !eta || err || eta == -1 )
+            {
+            // rights not expected to arrive
+            if ( aUrlType == DRM::EUHDomainRiUrl )
+                {
+                CheckOmaDomainStatusL( aContent, aRightsUrl, isRegistered,
+                    isJoined );
+                }
+
+            if ( aRightsUrl && isRegistered && !isJoined ) // Domain ro case
+                {
+                ret = iDrmUtilityUi->DisplayQueryWithIdL(
+                    R_DRMUTILITY_ACTIVATE_ACCOUNT,
+                    R_DRMUTILITY_CONFIRMATION_QUERY );
+                }
+            else if ( aRightsUrl ) // Device ro case
+                {
+                if ( aReason & EConstraintIndividual )
+                    {
+                    ret = iDrmUtilityUi->DisplayQueryWithIdL(
+                        R_DRMUTILITY_INVALID_SIM,
+                        R_DRMUTILITY_CONFIRMATION_QUERY );
+                    }
+                else
+                    {
+                    // get filename
+                    User::LeaveIfError( aContent.GetStringAttribute(
+                        EFileName, fileName ) );
+
+                    ret = iDrmUtilityUi->DisplayQueryL(
+                        R_DRM_QUERY_EXPIRED_OR_NO_RO, fileName );
+                    }
+                }
+            else // no rights issuer
+                {
+                if ( aReason & EConstraintIndividual )
+                    {
+                    iDrmUtilityUi->DisplayNoteL( R_DRM_INFO_SIM_NOT_ALLOWED );
+                    }
+                else
+                    {
+                    iDrmUtilityUi->DisplayNoteL( R_DRM_INFO_EXPIRED_OR_NO_RO );
+                    }
+                }
+            }
+        else
+            {
+            // rights expected to arrive
+            if ( eta != KErrCAPendingRights )
+                {
+                // rights expected to arrive in eta seconds
+                iDrmUtilityUi->DisplayQueryWithIdL(
+                    R_DRMUTILITY_WAITING_FOR_RIGHTS,
+                    R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY );
+                }
+            else
+                {
+                // rights should have come
+                if ( aRightsUrl )
+                    {
+                    ret = iDrmUtilityUi->DisplayQueryWithIdL(
+                        R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME,
+                        R_DRMUTILITY_CONFIRMATION_QUERY );
+                    }
+                else
+                    {
+                    // no rights issuer
+                    iDrmUtilityUi->DisplayQueryWithIdL(
+                        R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME_NO_RI,
+                        R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY );
+                    }
+                }
+            }
+        }
+
+    if ( ret == EAknSoftkeyYes || ret == EAknSoftkeyOk )
+        {
+        rightsRenewalWanted = ETrue;
+        }
+    return rightsRenewalWanted;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetOmaConstraintInfo
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::GetOmaConstraintInfo(
+    CDRMConstraint* aConstraint,
+    TUint32& aCountsLeft,
+    TTime& aEndTime )
+    {
+    __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    TInt ret( 0 );
+    TTime start( Time::NullTTime() );
+    aCountsLeft = 0;
+    aEndTime = Time::NullTTime();
+
+    if ( aConstraint->iActiveConstraints & EConstraintCounter )
+        {
+        ret |= KDRMOmaConstraintCount;
+        aCountsLeft = aConstraint->iCounter;
+        }
+    if ( aConstraint->iActiveConstraints & EConstraintTimedCounter )
+        {
+        ret |= KDRMOmaConstraintCount;
+        if ( aConstraint->iTimedCounter > aCountsLeft )
+            {
+            aCountsLeft = aConstraint->iTimedCounter;
+            }
+        }
+    if ( aConstraint->iActiveConstraints & EConstraintEndTime )
+        {
+        ret |= KDRMOmaConstraintTime;
+        aEndTime = aConstraint->iEndTime;
+        }
+    if ( aConstraint->iActiveConstraints & EConstraintInterval )
+        {
+        start = aConstraint->iIntervalStart;
+        if ( start == Time::NullTTime() )
+            {
+            start.HomeTime();
+            }
+        aEndTime = start + aConstraint->iInterval;
+        ret |= KDRMOmaConstraintTime;
+        }
+    if ( aConstraint->iActiveConstraints & EConstraintAccumulated )
+        {
+        if ( aEndTime != Time::NullTTime() && aEndTime
+            + aConstraint->iAccumulatedTime > aEndTime || aEndTime
+            == Time::NullTTime() )
+            {
+            aEndTime.HomeTime();
+            aEndTime = aEndTime + aConstraint->iAccumulatedTime;
+            ret |= KDRMOmaConstraintAccumulated;
+            }
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::RejectReason
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::RejectReason( TUint32 aReason )
+    {
+    TInt ret( DRM::EURejectionNone );
+
+    if ( aReason & EConstraintStartTime )
+        {
+        ret |= DRM::EURejectionStartTime;
+        }
+
+    if ( aReason & EConstraintEndTime )
+        {
+        ret |= DRM::EURejectionEndTime;
+        }
+
+    if ( aReason & EConstraintInterval )
+        {
+        ret |= DRM::EURejectionInterval;
+        }
+
+    if ( aReason & EConstraintCounter )
+        {
+        ret |= DRM::EURejectionCounter;
+        }
+
+    if ( aReason & EConstraintTopLevel )
+        {
+        ret |= DRM::EURejectionTopLevel;
+        }
+
+    if ( aReason & EConstraintTimedCounter )
+        {
+        ret |= DRM::EURejectionTimedCounter;
+        }
+
+    if ( aReason & EConstraintAccumulated )
+        {
+        ret |= DRM::EURejectionAccumulated;
+        }
+
+    if ( aReason & EConstraintIndividual )
+        {
+        ret |= DRM::EURejectionIndividual;
+        }
+
+    if ( aReason & EConstraintSystem )
+        {
+        ret |= DRM::EURejectionSystem;
+        }
+
+    if ( aReason & EConstraintVendor )
+        {
+        ret |= DRM::EURejectionVendor;
+        }
+
+    if ( aReason & EConstraintSoftware )
+        {
+        ret |= DRM::EURejectionSoftware;
+        }
+
+    if ( aReason & EConstraintMetering )
+        {
+        ret |= DRM::EURejectionMetering;
+        }
+
+    if ( aReason & EConstraintNullDrmTime )
+        {
+        ret |= DRM::EURejectionDrmTime;
+        }
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::RightsInfoStatus
+// -----------------------------------------------------------------------------
+//
+DRM::TDrmRightsInfo DRM::CDrmUiHandlingImpl::RightsInfoStatus(
+    DRM::TCheckRightsStatus aStatus )
+    {
+    DRM::TDrmRightsInfo ret( DRM::EURightsInfoValid );
+
+    if ( aStatus == DRM::EUHCheckRightsExpiredRights )
+        {
+        ret = DRM::EURightsInfoExpired;
+        }
+    else if ( aStatus == DRM::EUHCheckRightsNoRights )
+        {
+        ret = DRM::EURightsInfoMissing;
+        }
+    else if ( aStatus == DRM::EUHCheckRightsFutureRights )
+        {
+        ret = DRM::EURightsInfoFuture;
+        }
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::SelectOmaRightsUrlL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::SelectOmaRightsUrlL(
+    const ContentAccess::CData& aContent,
+    const HBufC* aDomainRiUrl,
+    DRM::TDrmUiUrlType& aUrlType )
+    {
+    Roap::RRoapStorageClient storage;
+    CDRMRIContext* riContext( NULL );
+    CDRMDomainContext* domainContext( NULL );
+
+    HBufC* riId( NULL );
+    HBufC8* riId8( NULL );
+    HBufC* domainId( NULL );
+    HBufC8* domainId8( NULL );
+
+    TInt error( KErrNone );
+    TPtr ptr( NULL, 0 );
+    TBool isJoined( EFalse );
+    TBool isRegistered( EFalse );
+
+    aUrlType = DRM::EUHRightsIssuerUrl;
+    riId = HBufC::NewLC( KUrlMaxLen );
+    domainId = HBufC::NewLC( KUrlMaxLen );
+
+    // create attribute set
+    RStringAttributeSet stringAttributeSet;
+    CleanupClosePushL( stringAttributeSet );
+    // add the attributes we are interested in
+    stringAttributeSet.AddL( EDomainId );
+    stringAttributeSet.AddL( EDomainRightsIssuerId );
+
+    User::LeaveIfError( aContent.GetStringAttributeSet( stringAttributeSet ) );
+
+    // pass on values of string attributes
+    ptr.Set( domainId->Des() );
+    error = stringAttributeSet.GetValue( EDomainId, ptr );
+    if ( !error )
+        {
+        ptr.Set( riId->Des() );
+        stringAttributeSet.GetValue( EDomainRightsIssuerId, ptr );
+        if ( !error )
+            {
+            riId8 = HBufC8::NewLC( riId->Length() );
+            riId8->Des().Copy( riId->Des() );
+            domainId8 = HBufC8::NewLC( domainId->Length() );
+            domainId8->Des().Copy( domainId->Des() );
+
+            if ( riId8 && riId8->Length() && aDomainRiUrl
+                && aDomainRiUrl->Length() )
+                {
+                // Check if we have domain RO
+                User::LeaveIfError( storage.Connect() );
+                CleanupClosePushL( storage );
+                riContext = storage.GetRIContextL( *riId8 );
+                if ( riContext )
+                    {
+                    isRegistered = ETrue;
+                    delete riContext;
+                    if ( domainId8 && domainId8->Length() )
+                        {
+                        domainContext
+                            = storage.GetDomainContextL( *domainId8 );
+                        if ( domainContext )
+                            {
+                            // last three digits presents
+                            // the domain generation
+                            TInt generation( 0 );
+                            TLex8 lex( domainId8->Right(
+                                KOmaDomainGenerationLength ) );
+                            lex.Val( generation );
+
+                            if ( domainContext->DomainGeneration()
+                                >= generation )
+                                {
+                                isJoined = ETrue;
+                                }
+                            delete domainContext;
+                            }
+                        }
+                    }
+                CleanupStack::PopAndDestroy( &storage );
+
+                if ( aDomainRiUrl && aDomainRiUrl->Length()
+                    && ( !isRegistered | !isJoined ) )
+                    {
+                    aUrlType = DRM::EUHDomainRiUrl;
+                    }
+
+                }
+            CleanupStack::PopAndDestroy( 2, riId8 ); // domainId8, riId8
+            }
+        }
+    CleanupStack::PopAndDestroy( &stringAttributeSet );
+    CleanupStack::PopAndDestroy( 2, riId ); // domainId, riId
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::LaunchRightsManagerUiL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::LaunchRightsManagerUiL( const TDesC& aParam16 )
+    {
+    const TUid KUidDRMUI =
+        {
+        0x101f85c7
+        };
+
+    if ( iCoeEnv )
+        {
+        CAiwGenericParamList* paramList( CAiwGenericParamList::NewLC() );
+        TAiwVariant variantObject( aParam16 );
+        TAiwGenericParam param( EGenericParamFile, variantObject );
+        paramList->AppendL( param );
+
+        CAknLaunchAppService* launchAppService( CAknLaunchAppService::NewL(
+            KUidDRMUI, this, paramList ) );
+        iWait.Start();
+        delete launchAppService;
+        CleanupStack::PopAndDestroy( paramList );
+        }
+    else
+        {
+        // no UI to embed, launch Rights Manager UI stand-alone
+        // check if Rights Manager UI is already running
+        RWsSession wsSession;
+        User::LeaveIfError( wsSession.Connect() );
+        CleanupClosePushL( wsSession );
+        TApaTaskList tasklist( wsSession );
+        TApaTask task( tasklist.FindApp( KUidDRMUI ) );
+        if ( task.Exists() )
+            {
+            // Rights Manager UI is already running
+            HBufC8* param8( HBufC8::NewLC( aParam16.Length() ) );
+            TPtr8 parametersPtr( param8->Des() );
+            parametersPtr.Copy( aParam16 );
+            task.SendMessage( TUid::Uid( KUidApaMessageSwitchOpenFileValue ),
+                *param8 );
+            CleanupStack::PopAndDestroy( param8 );
+            }
+        else
+            {
+            RApaLsSession appArcSession;
+            User::LeaveIfError( appArcSession.Connect() );
+            CleanupClosePushL( appArcSession );
+            TThreadId id;
+            appArcSession.StartDocument( aParam16, KUidDRMUI, id );
+            CleanupStack::PopAndDestroy( &appArcSession );
+            }
+        CleanupStack::PopAndDestroy( &wsSession );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CreateLaunchParamL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CreateLaunchParamL(
+    const HBufC8* aUrl,
+    HBufC*& aLaunchParam,
+    const HBufC* aFullPath )
+    {
+    __ASSERT_DEBUG( !aLaunchParam && aUrl && aFullPath,
+        User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+    _LIT( KSpace, " " );
+
+    RPointerArray<CDRMPermission> uriList;
+    TPtr ptr( NULL, 0 );
+
+    TInt localId( 0 );
+    TInt err( KErrNone );
+
+        TRAP( err, iOmaClient.GetDBEntriesL( *aUrl, uriList ) );
+
+    if ( uriList.Count() == 1 )
+        {
+        localId = ( uriList[0] )->iUniqueID;
+        }
+
+    uriList.ResetAndDestroy();
+    uriList.Close();
+
+    // MaxInt will fit into 10 characters
+    HBufC* localIDBuf( HBufC::NewLC( KIntegerMaxLen ) );
+    ptr.Set( localIDBuf->Des() );
+    ptr.AppendNum( localId );
+
+    // length of startparam and drm protection scheme are always 1 and
+    // 4 spaces are needed
+    const TInt KSpacesBetweenParams( 4 );
+    TInt length( 1 + aUrl->Length() + ptr.Length() + aFullPath->Length()
+        + KSpacesBetweenParams + 1 );
+
+    aLaunchParam = HBufC::NewLC( length );
+    ptr.Set( aLaunchParam->Des() );
+
+    // Start parameter is 3 or 4 for launching details view embedded or standalone from
+    // DRM Utility, respectively, with full path name included as a parameter. Values 1
+    // and 2 are for launching details view from DRM Helper.
+    if ( iCoeEnv )
+        {
+        ptr.AppendNum( EDrmLaunchParamEmbeddedUtility );
+        }
+    else
+        {
+        ptr.AppendNum( EDrmLaunchParamStandAloneUtility );
+        }
+    ptr.Append( KSpace );
+    ptr.Append( *localIDBuf );
+    ptr.Append( KSpace );
+
+    HBufC* contentUrl( CnvUtfConverter::ConvertToUnicodeFromUtf8L( *aUrl ) );
+
+    ptr.Append( *contentUrl );
+    ptr.Append( KSpace );
+
+    // OMA DRM protection scheme
+    ptr.AppendNum( EDrmSchemeOmaDrm );
+    ptr.Append( KSpace );
+
+    ptr.Append( *aFullPath );
+
+    delete contentUrl;
+
+    CleanupStack::Pop( aLaunchParam );
+    CleanupStack::PopAndDestroy( localIDBuf );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::CreateLaunchParamL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::CreateLaunchParamL(
+    const HBufC* aUrl,
+    HBufC*& aLaunchParam )
+    {
+    __ASSERT_DEBUG( !aLaunchParam && aUrl,
+        User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+    _LIT( KZero, "0" );
+    _LIT( KSpace, " " );
+
+    TPtr ptr( NULL, 0 );
+
+    // Length of startparam and drm protection scheme and zero local id
+    // are always 1 and total of 3 spaces are needed
+    TInt length( 1 + aUrl->Length() + 1 + 3 + 1 );
+
+    aLaunchParam = HBufC::NewLC( length );
+    ptr.Set( aLaunchParam->Des() );
+
+    // Start parameter is 3 or 4 for launching details view embedded or standalone from
+    // DRM Utility, respectively, with full path name included as a parameter. Values 1
+    // and 2 are for launching details view from DRM Helper.
+    if ( iCoeEnv )
+        {
+        ptr.AppendNum( EDrmLaunchParamEmbeddedUtility );
+        }
+    else
+        {
+        ptr.AppendNum( EDrmLaunchParamStandAloneUtility );
+        }
+    ptr.Append( KSpace );
+    // Default value 0 for localId in case of WM DRM file
+    ptr.Append( KZero );
+    ptr.Append( KSpace );
+    ptr.Append( *aUrl );
+    ptr.Append( KSpace );
+    // WM DRM protection scheme
+    ptr.AppendNum( EDrmSchemeWmDrm );
+
+    CleanupStack::Pop( aLaunchParam );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::LaunchBrowserL
+// Launches browser embedded with given URL
+// -----------------------------------------------------------------------------
+//
+TBool DRM::CDrmUiHandlingImpl::LaunchBrowserL( const HBufC8* aUrl )
+    {
+    __ASSERT_DEBUG( aUrl, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    // URL needs to be unicode
+    HBufC* parameters( HBufC::NewLC( aUrl->Length() ) );
+    parameters->Des().Copy( *aUrl );
+    TBool embeddedLaunch( LaunchBrowserL( parameters ) );
+    CleanupStack::PopAndDestroy( parameters );
+    return embeddedLaunch;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::LaunchBrowserL
+// Launches browser embedded with given URL
+// -----------------------------------------------------------------------------
+//
+TBool DRM::CDrmUiHandlingImpl::LaunchBrowserL( const HBufC* aUrl )
+    {
+    __ASSERT_DEBUG( aUrl, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    HBufC* newUrl( NULL );
+    TPtrC ptrc( NULL, 0 );
+
+    ptrc.Set( *aUrl );
+    TBool embeddedLaunch( EFalse );
+    // if no scheme exists, use http as default scheme
+    _LIT( KColon, ":" );
+    if ( ptrc.Find( KColon ) == KErrNotFound )
+        {
+        _LIT( KHttp, "http://" );
+        const TInt KHttpLen( 7 );
+        newUrl = HBufC::NewLC( KHttpLen + aUrl->Length() );
+        TPtr ptr( newUrl->Des() );
+        ptr.Append( KHttp );
+        ptr.Append( *aUrl );
+        ptrc.Set( *newUrl );
+        }
+
+    CSchemeHandler* schemeHandler( CSchemeHandler::NewL( ptrc ) );
+    CleanupStack::PushL( schemeHandler );
+    if ( iCoeEnv )
+        {
+        embeddedLaunch = ETrue;
+        // launch embedded
+        schemeHandler->Observer( this );
+        schemeHandler->HandleUrlEmbeddedL();
+        CleanupStack::Pop( schemeHandler );
+        iSchemeHandler = schemeHandler;
+        iWait.Start();
+        }
+    else
+        {
+        // no CoeEnv, launch standalone with scheme app
+        schemeHandler->HandleUrlStandaloneL();
+        CleanupStack::PopAndDestroy( schemeHandler );
+        }
+    schemeHandler = NULL;
+
+    // delete newUrl if needed
+    if ( newUrl )
+        {
+        CleanupStack::PopAndDestroy( newUrl );
+        }
+    return embeddedLaunch;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetSilentRightsL
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::GetSilentRightsL(
+    const TDesC8& aUrl,
+    const TBool aShowNotes )
+    {
+    TInt r( KErrCancel );
+    TInt buttonCode( EAknSoftkeyYes );
+    HBufC8* url( NULL );
+
+    if ( !SilentRightsAllowedL() )
+        {
+        buttonCode = EAknSoftkeyNo;
+        if ( aShowNotes )
+            {
+            buttonCode = iDrmUtilityUi->DisplayQueryWithIdL(
+                R_DRM_QRY_CONNECT_TO_ACTIVATE,
+                R_DRMUTILITY_CONFIRMATION_QUERY );
+            }
+        }
+    else if ( !BrowserAPDefinedL() )
+        {
+        buttonCode = EAknSoftkeyNo;
+        if ( aShowNotes )
+            {
+            buttonCode = iDrmUtilityUi->DisplayQueryWithIdL(
+                R_DRM_QRY_CONNECT_TO_ACTIVATE,
+                R_DRMUTILITY_CONFIRMATION_QUERY );
+            }
+        }
+
+    if ( buttonCode == EAknSoftkeyYes || buttonCode == EAknSoftkeyOk )
+        {
+        TInt APs( APCountL() );
+        if ( !APs )
+            {
+            // No AP defined
+            if ( aShowNotes )
+                {
+                iDrmUtilityUi->DisplayNoteL( R_DRM_WARN_NO_CONN_DEFINED );
+                }
+            r = KErrCANoRights;
+            }
+        else
+            {
+            // ok to start download
+            CDrmUtilityDownloadManager* dlMgr(
+                CDrmUtilityDownloadManager::NewL() );
+            CleanupStack::PushL( dlMgr );
+            url = aUrl.AllocLC();
+
+            if ( iCoeEnv && aShowNotes )
+                {
+                    TRAP( r, dlMgr->DownloadAndHandleRoapTriggerL( url,
+                            *iCoeEnv ) );
+                }
+            else
+                {
+                    TRAP( r, dlMgr->DownloadAndHandleRoapTriggerL( url ) );
+                }
+            CleanupStack::PopAndDestroy( url );
+
+            if ( r )
+                {
+                // rights were tried to get only if
+                // the user hasn't cancelled
+                if ( r != KErrCancel )
+                    {
+                    if ( r == KErrCouldNotConnect )
+                        {
+                        // Connection failed with selected AP
+                        if ( aShowNotes )
+                            {
+                            iDrmUtilityUi->DisplayNoteL(
+                                R_DRM_WARN_INVALID_OR_NO_AP );
+                            }
+                        r = KErrCANoRights;
+                        }
+                    else
+                        {
+                        if ( aShowNotes )
+                            {
+                            // get error url
+                            HBufC8* errorUrl( dlMgr->GetErrorUrlL() );
+                            CleanupStack::PushL( errorUrl );
+
+                            // error url is got only if temporary roap error
+
+                            if ( errorUrl )
+                                {
+                                // ask user whether error url should be opened
+                                buttonCode
+                                    = iDrmUtilityUi->DisplayQueryWithIdL(
+                                        R_DRM_QUERY_OPEN_ERROR_URL,
+                                        R_DRMUTILITY_CONFIRMATION_QUERY );
+
+                                if ( buttonCode == EAknSoftkeyYes
+                                    || buttonCode == EAknSoftkeyOk )
+                                    {
+                                    // Launch browser
+                                    LaunchBrowserL( errorUrl );
+                                    }
+                                }
+                            else
+                                {
+                                iDrmUtilityUi->DisplayNoteL(
+                                    R_DRM_ERR_OPENING_FAIL_PERM );
+                                }
+                            CleanupStack::PopAndDestroy( errorUrl );
+                            }
+                        }
+                    }
+                }
+            CleanupStack::PopAndDestroy( dlMgr );
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::SilentRightsAllowedL
+// -----------------------------------------------------------------------------
+//
+TBool DRM::CDrmUiHandlingImpl::SilentRightsAllowedL()
+    {
+    TInt value( KErrNone );
+    CRepository* repository( CRepository::NewL( KCRUidDRMSettings ) );
+    repository->Get( KDRMSettingsSilentRightsAcquisition, value );
+    delete repository;
+    return !value ? EFalse : ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::BrowserAPDefinedL
+// -----------------------------------------------------------------------------
+//
+TBool DRM::CDrmUiHandlingImpl::BrowserAPDefinedL()
+    {
+    const TInt KDestinationSelectionMode( 2 );
+    TInt err( KErrNone );
+    TInt ap( 0 );
+    TInt alwaysAsk( 0 );
+    TInt defaultSnap( 0 );
+
+    CRepository* repository( CRepository::NewL( KCRUidBrowser ) );
+    repository->Get( KBrowserDefaultAccessPoint, ap );
+    repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
+    repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
+    delete repository;
+    if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
+        {
+        alwaysAsk = ETrue;
+        }
+    else
+        {
+        RCmManager cmManager;
+        CleanupClosePushL( cmManager );
+        cmManager.OpenL();
+        if ( !alwaysAsk )
+            {
+                TRAP( err, cmManager.GetConnectionMethodInfoIntL(
+                        ap, CMManager::ECmIapId ) );
+            }
+        else if ( alwaysAsk == KDestinationSelectionMode )
+            {
+                TRAP( err, IapIdOfDefaultSnapL( cmManager, defaultSnap ) );
+            }
+        CleanupStack::PopAndDestroy( &cmManager );
+        if ( !err && ( !alwaysAsk || alwaysAsk == KDestinationSelectionMode ) )
+            {
+            return ETrue;
+            }
+        }
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::APCountL
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUiHandlingImpl::APCountL()
+    {
+    TInt apCount( 0 );
+    RCmManager cmManager;
+    CleanupClosePushL( cmManager );
+    cmManager.OpenL();
+    RArray<TUint32> aps;
+    CleanupClosePushL( aps );
+    cmManager.ConnectionMethodL( aps, EFalse, EFalse, ETrue );
+    apCount = aps.Count();
+    CleanupStack::PopAndDestroy( 2, &cmManager ); //aps, cmManager
+    return apCount;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::HandleServerAppExit
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::HandleServerAppExit( TInt aReason )
+    {
+    if ( aReason == EAknCmdExit && !iSchemeHandler )
+        {
+        CAknEnv::RunAppShutter();
+        }
+
+    if ( iSchemeHandler )
+        {
+        delete iSchemeHandler;
+        iSchemeHandler = NULL;
+        }
+
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::AppendToQueue
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::AppendToQueue( DRM::CDrmUiHandlingData* aData )
+    {
+    __ASSERT_DEBUG( aData, User::Panic( KDRMUtilityDebugPanicMessage,
+            KDRMUtilityDebugPanicCode ) );
+
+    // Critical area start:
+    iSemaphore.Wait();
+
+    if ( !iLast )
+        {
+        iFirst = aData;
+        iLast = iFirst;
+        }
+    else
+        {
+        iLast->iNext = aData;
+        iLast = aData;
+        }
+
+    // Critical area end
+    iSemaphore.Signal();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::PopFront
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUiHandlingData* DRM::CDrmUiHandlingImpl::PopFront()
+    {
+    DRM::CDrmUiHandlingData* data( NULL );
+
+    // If there is nothing in the queue return NULL
+    if ( !iFirst )
+        {
+        return data;
+        }
+
+    // Critical area start:
+    iSemaphore.Wait();
+
+    data = iFirst;
+
+    // Set the first and the next
+    iFirst = iFirst->iNext;
+
+    // reset the pointer on data
+    data->iNext = NULL;
+
+    // if there is no next in iFirst, this is the last or if there is no iFirst
+    if ( !iFirst || !iFirst->iNext )
+        {
+        iLast = iFirst;
+        }
+
+    // Critical Area End
+    iSemaphore.Signal();
+
+    return data;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetSilentAndCallL
+// -----------------------------------------------------------------------------
+//
+TBool DRM::CDrmUiHandlingImpl::GetSilentAndCallL(
+    MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId,
+    const ContentAccess::TIntent aIntent,
+    const HBufC8* aContentUri,
+    const HBufC8* aSilentUrl,
+    const TBool aShowNotes )
+    {
+    TInt callError( KErrNotFound );
+    if ( aSilentUrl )
+        {
+        GetSilentRightsL( *aSilentUrl, aShowNotes );
+        callError
+            = CheckAndMapToCallError( iOmaClient, aIntent, *aContentUri );
+        CallSilentRightsAvailable( aObserver, aOperationId, callError );
+        }
+    return callError == KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingImpl::GetRightsAndCallL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUiHandlingImpl::GetRightsAndCallL(
+    MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId,
+    const ContentAccess::TIntent aIntent,
+    const HBufC8* aContentUri,
+    const HBufC* aRightsUrl )
+    {
+    TInt callError( KErrNotFound );
+    TBool embeddedLaunch( EFalse );
+    if ( aRightsUrl && LaunchBrowserL( aRightsUrl ) )
+        {
+        embeddedLaunch = ETrue;
+        // Browser launched in embedded mode.
+        // Check if rights exist now.
+        callError
+            = CheckAndMapToCallError( iOmaClient, aIntent, *aContentUri );
+        }
+    // Inform status to observer if possible
+    if ( embeddedLaunch || !aRightsUrl )
+        {
+        CallRightsAvailable( aObserver, aOperationId, callError );
+        }
+
+    }
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmUtility.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,505 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRM Utility
+*
+*/
+
+
+// INCLUDE FILES
+#include <Oma2Dcf.h>
+#include <drmagents.h>
+#include <drmutility.h>
+#include <centralrepository.h>
+#include <UTF.h>
+
+#include "Oma1Dcf.h"
+
+#include "DrmUtilityInternalcrkeys.h"      // Cenrep extension for OmaBased
+
+// CONSTANTS
+_LIT8( KASFHeaderObject, "75B22630668E11CFA6D900AA0062CE6C" );
+_LIT8( KWrmHeader, "W\0R\0M\0H\0E\0A\0D\0E\0R\0" );
+
+const TInt KMinContentLength( 16 );
+const TInt KOma2EncryptionFieldOffset( 8 );
+const TInt KOmaHeaderLength( 512 );
+// This constant is for OMA1 case in which a buffer of 35-40
+// bytes is needed to recognize the mime type.
+const TInt KMinContentLengthOma1Based( 40 );
+const TInt KWMHeaderObjectLength( 8 );
+const TInt KWMTopLevelHeaderObjectLength( 30 );
+const TInt KMaxWMHeaderLength( ( KMaxTInt32 / 2 ) - 1 );
+
+const TInt KCenRepDataLength( 50 );
+
+// ============================ LOCAL FUNCTIONS ================================
+
+// -----------------------------------------------------------------------------
+// FormatGUID
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void FormatGUID( TDes8 &aGUID )
+    {
+    TBuf8<16> copyGUID( aGUID );
+    TInt i( 0 );
+    for ( i = 0; i < 4; i++ )
+        {
+        copyGUID[i] = aGUID[3-i];
+        }
+    for ( i = 4; i < 6; i++ )
+        {
+        copyGUID[i] = aGUID[9 - i];
+        }
+    for ( i = 6; i < 8; i++ )
+        {
+        copyGUID[i] = aGUID[13 - i];
+        }
+    for ( i = 8; i < 16 ; i++) 
+        {
+        copyGUID[i] = aGUID[i];
+        }
+    aGUID.Delete( 0, 32 );
+    for ( i = 0; i < 16; i++ )
+        {
+        aGUID.AppendNumFixedWidthUC( copyGUID[i], EHex, 2 );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// ConvertToInt64
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt64 ConvertToInt64( TDesC8& aDes )
+    {
+    TInt64 num( 0 );
+    TInt i( 0 );
+    for ( i = 7 ; i >= 0; i-- )
+        {
+        num <<= 8;
+        num |= aDes[i];
+        }
+    return num;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Default constructor
+// -----------------------------------------------------------------------------
+//  
+DRM::CDrmUtility::CDrmUtility()
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//  
+DRM::CDrmUtility::~CDrmUtility()
+    {
+    delete iOmaBasedAgentName;
+    delete iOmaBasedMimeType;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDrmUtility::NewLC
+// First phase constructor
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C DRM::CDrmUtility* DRM::CDrmUtility::NewLC()
+    {
+    DRM::CDrmUtility* self( new( ELeave ) CDrmUtility );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtility::NewL
+// First phase constructor
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C DRM::CDrmUtility* DRM::CDrmUtility::NewL()
+    {
+    DRM::CDrmUtility* self( NewLC() );
+    CleanupStack::Pop();
+    return self;
+    }
+
+void DRM::CDrmUtility::ConstructL()
+    {
+    TInt err( KErrNone );
+             
+     TRAP(err, FetchOmaBasedInfoL() );
+     if( err)
+         {
+         if( iOmaBasedAgentName )
+             {
+             delete iOmaBasedAgentName;
+             }
+         iOmaBasedAgentName = NULL;
+         if( iOmaBasedMimeType )
+             {
+             delete iOmaBasedMimeType;
+             }
+         iOmaBasedMimeType = NULL;
+         }   
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtility::FetchOmaBasedInfoL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtility::FetchOmaBasedInfoL()
+    {
+    TInt err = KErrNone;
+    CRepository* repository( NULL );
+    RBuf bOmaBasedAgentName;
+    RBuf bOmaBasedMimeType;
+    
+    CleanupClosePushL(bOmaBasedAgentName);
+    CleanupClosePushL(bOmaBasedMimeType);
+    bOmaBasedAgentName.CreateL( KCenRepDataLength );
+    bOmaBasedMimeType.CreateL( KCenRepDataLength );
+ 
+    TRAP( err, repository = CRepository::NewL( KCRUidOmaBased ) );
+    if ( !err )
+        {
+        CleanupStack::PushL( repository );
+        
+        err = repository->Get( KDrmOmaBasedName, bOmaBasedAgentName );
+        if( !err )
+            {
+            iOmaBasedAgentName = bOmaBasedAgentName.AllocL(); 
+            }
+        
+        err = repository->Get( KOmaBasedMimeType, bOmaBasedMimeType );
+        if( !err )
+            {
+            iOmaBasedMimeType = CnvUtfConverter::ConvertFromUnicodeToUtf8L( bOmaBasedMimeType );
+            }
+        CleanupStack::PopAndDestroy( repository );
+        }
+    
+    CleanupStack::PopAndDestroy(2);
+    
+    User::LeaveIfError( err );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtility::GetDrmInfoL
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C TBool DRM::CDrmUtility::GetDrmInfoL( 
+    RFile& aFileHandle,
+    TPtrC& aAgent,
+    DRM::TDrmProtectionStatus& aProtected ) const
+    {
+    TInt r( KErrNone );
+    HBufC8* buffer( NULL );
+    TInt pos( 0 );
+    RFile file;
+    TBuf8< 32 > header;
+    TInt64 headerSize( 0 );
+    TBool isDrmFile( EFalse );
+    TPtr8 headerPtr( NULL, 0 );
+        
+    aProtected = DRM::EUUnprotected;
+    aAgent.Set( KNullDesC );
+    
+    CheckFileHandleL( aFileHandle );
+    User::LeaveIfError( file.Duplicate( aFileHandle ) );
+    CleanupClosePushL( file );
+
+    User::LeaveIfError( file.Seek( ESeekStart, pos ) );
+    
+    // Check if the file is an ASF file
+    // To be Checked on runtime wether WM DRM is supporeted or not
+    User::LeaveIfError( file.Read( 0, header, KMinContentLength ) );
+    if ( header.Length() < KMinContentLength )
+        {
+        User::Leave( KErrArgument ); 
+        }    
+        
+    FormatGUID( header );
+    
+    if ( header == KASFHeaderObject )
+        {
+        // It's ASF, check still whether it's WM DRM protected or not
+        file.Read( header, KWMHeaderObjectLength );
+        headerSize = ConvertToInt64( header );
+        if( headerSize <= KWMTopLevelHeaderObjectLength || 
+            headerSize > KMaxWMHeaderLength )
+            {
+            User::Leave( KErrArgument );
+            }
+        buffer = HBufC8::NewLC( headerSize );
+
+        headerPtr.Set( buffer->Des() ); 
+        User::LeaveIfError( file.Read( headerPtr, 
+                headerSize - ( KMinContentLength + KWMHeaderObjectLength ) ) );
+    
+        r = headerPtr.Find( KWrmHeader );
+        if ( r == KErrNotFound ) 
+            {
+            aProtected = DRM::EUUnprotected;
+            }
+        else
+            {
+            isDrmFile = ETrue;
+            aProtected = DRM::EUProtected;
+            aAgent.Set( DRM::KDrmWMAgentName );                            
+            }
+        CleanupStack::PopAndDestroy( buffer ); // buffer    
+        }
+    else
+        {
+        // Check whether it's OMA DRM protected or not
+        buffer = HBufC8::NewLC( KOmaHeaderLength );
+        
+        headerPtr.Set( buffer->Des() );
+        User::LeaveIfError( file.Read( 0, headerPtr ));
+        
+        if ( COma1Dcf::IsValidDcf( headerPtr ) )
+            {
+            isDrmFile = ETrue;
+            aProtected = DRM::EUProtected;                             
+            aAgent.Set( DRM::KDrmOmaAgentName );                
+            }
+        else if ( COma2Dcf::IsValidDcf( headerPtr ) )
+            {
+            isDrmFile = ETrue;
+            _LIT8( KCommonHeadersBox, "ohdr" );
+            pos = headerPtr.Find( KCommonHeadersBox );
+            
+            // If no box can be found or if there isn't enough data
+            // set protection as unknown
+            if( pos == KErrNotFound || 
+                headerPtr.Length() < pos + KOma2EncryptionFieldOffset )
+                {
+                aProtected = DRM::EUUnknown;
+                }
+            // If encryption field is 0, then content isn't protected
+            else if ( !headerPtr[pos + KOma2EncryptionFieldOffset] )
+                {
+                aProtected = DRM::EUUnprotected;
+                }
+            else
+                {
+                aProtected = DRM::EUProtected;
+                }                  
+            aAgent.Set( DRM::KDrmOmaAgentName );                
+            }   
+        else if ( (buffer->Des())[0] == 1)
+            {
+            // set the mimetype from the buffer which is in the beginning
+            // starting from byte 3 with the length specified at position 2		
+            TPtrC8 mimeType( buffer->Des().Mid(3, (buffer->Des())[1]) );
+            if( !mimeType.CompareF( *iOmaBasedMimeType ) ) 
+                {	
+                aAgent.Set( *DRM::CDrmUtility::iOmaBasedAgentName );
+                isDrmFile = ETrue;
+                }
+            }
+        CleanupStack::PopAndDestroy( buffer );
+        }  
+    CleanupStack::PopAndDestroy( &file ); // file
+    return isDrmFile;
+    }  
+  
+// -----------------------------------------------------------------------------
+// CDrmUtility::GetDrmInfoL
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C TBool DRM::CDrmUtility::GetDrmInfoL( 
+    const TDesC8& aContent,
+    TPtrC& aAgent,
+    DRM::TDrmProtectionStatus& aProtected ) const
+    {
+    TInt r( KErrNone );
+    RFile file;
+    TPtr8 asfPtr( NULL, 0 );
+    TBuf8< 32 > asfGuidHex;
+    TBool isDrmFile( EFalse );
+    
+    aProtected = DRM::EUUnprotected;
+    aAgent.Set( KNullDesC );
+
+    if ( aContent.Length() < KMinContentLength )
+        {
+        User::Leave( KErrArgument );   
+        }
+        
+    // Check if the file is an ASF file
+    asfPtr.Set( 
+        const_cast<TUint8*>( asfGuidHex.Ptr() ), 0, KMinContentLength * 2 );
+    asfPtr.Copy( aContent.Left( KMinContentLength ) );    
+    FormatGUID( asfPtr );
+    
+    if ( asfPtr == KASFHeaderObject )
+        {
+        // It's ASF, check still whether it's WM DRM protected or not
+        r = aContent.Find( KWrmHeader );
+        if ( r == KErrNotFound ) 
+            {
+            aProtected = DRM::EUUnprotected;   
+            }
+        else
+            {
+            isDrmFile = ETrue;
+            aProtected = DRM::EUProtected;                               
+            aAgent.Set( DRM::KDrmWMAgentName ); 
+            }   
+        }
+    else
+        {
+        // Check whether it's OMA DRM protected or not.
+        if ( ( aContent.Length() >= KMinContentLengthOma1Based ) && 
+            ( COma1Dcf::IsValidDcf( aContent ) ) )
+            {
+            isDrmFile = ETrue;
+            aProtected = DRM::EUProtected;                          
+            aAgent.Set( DRM::KDrmOmaAgentName );
+            }
+        else if ( COma2Dcf::IsValidDcf( aContent ) )
+            {
+            isDrmFile = ETrue;
+            _LIT8( KCommonHeadersBox, "ohdr" );
+            TInt pos( aContent.Find( KCommonHeadersBox ) );
+            
+            // If no box can be found or if there isn't enough data
+            // set protection as unknown
+            if ( pos == KErrNotFound || 
+                 aContent.Length() < pos + KOma2EncryptionFieldOffset )
+                {
+                aProtected = DRM::EUUnknown;
+                }
+            // If encryption field is 0, then content isn't protected    
+            else if ( !aContent[pos + KOma2EncryptionFieldOffset] )
+                {
+                aProtected = DRM::EUUnprotected;    
+                }
+            else
+                {
+                aProtected = DRM::EUProtected;    
+                }                               
+            aAgent.Set( DRM::KDrmOmaAgentName );            
+            }
+        else if ( (aContent)[0] == 1)
+            {
+            // set the mimetype from the buffer which is in the beginning
+            // starting from byte 3 with the length specified at position 2     
+            TPtrC8 mimeType( aContent.Mid(3, (aContent)[1]) );
+            if( !mimeType.CompareF( *iOmaBasedMimeType ) )
+                {   
+                aAgent.Set( *DRM::CDrmUtility::iOmaBasedAgentName );
+                isDrmFile = ETrue;
+                aProtected = DRM::EUProtected;
+                }
+            }
+        }
+    return isDrmFile;
+    }      
+
+// -----------------------------------------------------------------------------
+// CDrmUtility::IsProtectedL
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C TBool DRM::CDrmUtility::IsProtectedL( RFile& aFileHandle ) const
+    {
+    DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
+    TPtrC agent( KNullDesC );
+    TBool isDrmFile( EFalse );
+    TBool isProtected( EFalse );
+    
+    isDrmFile = GetDrmInfoL( aFileHandle, agent, protection );
+    
+    if ( isDrmFile && protection == DRM::EUProtected )
+        {
+        isProtected = ETrue;
+        }
+    return isProtected;
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CDrmUtility::IsProtectedL
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C TBool DRM::CDrmUtility::IsProtectedL( const TDesC8& aContent ) const
+    {
+    DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
+    TPtrC agent( KNullDesC );
+    TBool isDrmFile( EFalse );
+    TBool isProtected( EFalse );
+    
+    isDrmFile = GetDrmInfoL( aContent, agent, protection );
+    
+    if( isDrmFile && protection == DRM::EUProtected )
+        {
+        isProtected = ETrue;
+        }
+    return isProtected;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtility::GetAgentL
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C TBool DRM::CDrmUtility::GetAgentL( 
+    RFile& aFileHandle,
+    TPtrC& aAgent ) const
+    {
+    DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
+    TBool isDrmFile( EFalse );
+
+    isDrmFile = GetDrmInfoL( aFileHandle, aAgent, protection );
+
+    return isDrmFile;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDrmUtility::GetAgentL
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C TBool DRM::CDrmUtility::GetAgentL( 
+    const TDesC8& aContent,
+    TPtrC& aAgent ) const
+    {
+    DRM::TDrmProtectionStatus protection( DRM::EUUnknown );
+    TBool isDrmFile( EFalse );
+
+    isDrmFile = GetDrmInfoL( aContent, aAgent, protection );
+
+    return isDrmFile;
+    }
+ 	
+
+// -----------------------------------------------------------------------------
+// CDrmUtility::CheckFileHandlerL
+// Checks whether given filehandle is valid if not leaves with KErrArgument
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+// 
+EXPORT_C void DRM::CDrmUtility::CheckFileHandleL( RFile& aFileHandle ) const
+    {
+    if ( !aFileHandle.SubSessionHandle() )
+        {
+        User::Leave( KErrBadHandle );
+        }
+    }
+       
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmUtilityDmgrWrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,740 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Dynamically loadable wrapper for Download manager
+*
+*/
+
+#include <centralrepository.h>
+#include <cdblen.h>
+#include <cmconnectionmethod.h>
+#include <cmdestination.h>
+#include <cmconnectionmethoddef.h>
+#include <cmmanager.h>
+
+#ifdef __SERIES60_NATIVE_BROWSER
+#include <browseruisdkcrkeys.h>
+#endif
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <driveinfo.h>
+#endif
+
+#include <stringloader.h>
+#include <data_caging_path_literals.hrh>
+
+#include <coneresloader.h>
+#include <apparc.h>
+#include <drmutilitydmgrwrapper.rsg>
+
+#include "roapeng.h"
+#include "roapsyncwrapper.h"
+#include "roapdef.h"
+
+#include "drmutilitydmgrwrapper.h"
+#include "drmutilitydmgrwrapperlogger.h"
+
+// DEBUG macros
+#ifdef _DEBUG
+#define DRMDEBUGLIT( a, b ) \
+_LIT( a , b )
+#define DRMDEBUG( a ) \
+RDebug::Print( a )
+#define DRMDEBUG2( a, b ) \
+RDebug::Print( a, b )
+#else
+#define DRMDEBUGLIT( a, b )
+#define DRMDEBUG( a )
+#define DRMDEBUG2( a, b )
+#endif
+
+// CONSTANTS
+#ifndef __SERIES60_NATIVE_BROWSER
+const TUid KCRUidBrowser = {0x10008D39};
+const TUint32 KBrowserDefaultAccessPoint = 0x0000000E;
+const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
+#endif
+
+#ifndef RD_MULTIPLE_DRIVE
+_LIT( KDriveZ, "z:" );
+_LIT( KDrmUtilityTriggerFilePath, "d:\\" );
+#else
+_LIT( KRomDriveFormatter, "%c:" );
+_LIT( KKDrmUtilityTriggerFilePathFormatter, "%c:\\" );
+#endif
+
+_LIT( KCDrmUtilityDmgrWrapperResFileName,"DrmUtilityDmgrWrapper.rsc" );
+const TInt KProgressInfoFinalValue( 200 );
+const TInt KProgressInfoIncrementSmall( 5 );
+const TInt KProgressInfoIncrementMedium( 10 );
+const TInt KProgressInfoIncrementLarge( 30 );
+
+// ======== LOCAL FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// DeleteHttpDowload
+// ---------------------------------------------------------------------------
+//
+LOCAL_C void DeleteHttpDowload( TAny* aDownload )
+    {
+    reinterpret_cast< RHttpDownload* >( aDownload )->Delete();
+    }
+
+// ---------------------------------------------------------------------------
+// IapIdOfDefaultSnapL
+// for trapping purposes only
+// ---------------------------------------------------------------------------
+//
+LOCAL_C TUint32 IapIdOfDefaultSnapL(
+    RCmManager& aCmManager,
+    const TUint32 aDefaultSnap )
+    {
+    RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) );
+    CleanupClosePushL( dest );
+    TUint32 iapIdOfDest( 0 );
+
+    if ( dest.ConnectionMethodCount() <= 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
+    CleanupClosePushL( cMeth );
+
+    iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId );
+    CleanupStack::PopAndDestroy( &cMeth );
+    CleanupStack::PopAndDestroy( &dest );
+    return iapIdOfDest;
+    }
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::CDrmUtilityDmgrWrapper
+// ---------------------------------------------------------------------------
+//
+CDrmUtilityDmgrWrapper::CDrmUtilityDmgrWrapper() :
+    iUseCoeEnv( EFalse )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDrmUtilityDmgrWrapper::ConstructL()
+    {
+    CLOG_WRITE( "DMgrWrapper::ConstructL" );
+    const TInt KDrmUtilityDmgrWrapperUid = 0x102830FE;
+    iDlMgr.ConnectL( TUid::Uid(KDrmUtilityDmgrWrapperUid), *this, EFalse );
+    iProgressInfo = NULL;
+    iProgressNoteDialog = NULL;
+    iDialogDismissed = ETrue;
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::NewL
+// ---------------------------------------------------------------------------
+//
+CDrmUtilityDmgrWrapper* CDrmUtilityDmgrWrapper::NewL()
+    {
+    CLOG_WRITE( "DMgrWrapper::NewL" );
+    CDrmUtilityDmgrWrapper* self( CDrmUtilityDmgrWrapper::NewLC() );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::NewLC
+// ---------------------------------------------------------------------------
+//
+CDrmUtilityDmgrWrapper* CDrmUtilityDmgrWrapper::NewLC()
+    {
+    CLOG_WRITE( "DMgrWrapper::NewLC" );
+    CDrmUtilityDmgrWrapper* self( new( ELeave ) CDrmUtilityDmgrWrapper() );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::~CDrmUtilityDmgrWrapper
+// ---------------------------------------------------------------------------
+//
+CDrmUtilityDmgrWrapper::~CDrmUtilityDmgrWrapper()
+    {
+    CLOG_WRITE( "DMgrWrapper destructor" );
+    if ( iProgressNoteDialog )
+       {
+       // deletes the dialog
+       TRAPD( err, iProgressNoteDialog->ProcessFinishedL() );
+       if ( err )
+           {
+           delete iProgressNoteDialog;
+           }
+       iProgressNoteDialog = NULL;
+       }
+    delete iErrorUrl;
+    delete iPostResponseUrl;
+
+#ifdef _DEBUG
+
+    if ( iDlMgr.Handle() )
+        {
+        iDlMgr.Close();
+        }
+
+#else
+
+    iDlMgr.Close();
+
+#endif
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL
+// ---------------------------------------------------------------------------
+//
+void CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL( const HBufC8* aUrl )
+    {
+    CLOG_WRITE( "DMgrWrapper::DownloadAndHandleRoapTriggerL" );
+    iUseCoeEnv = EFalse;
+    DoDownloadAndHandleRoapTriggerL( aUrl );
+    HandlePostResponseUrlL();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL
+// ---------------------------------------------------------------------------
+//
+void CDrmUtilityDmgrWrapper::DownloadAndHandleRoapTriggerL(
+    const HBufC8* aUrl, CCoeEnv& aCoeEnv )
+    {
+    CLOG_WRITE( "DMgrWrapper::DownloadAndHandleRoapTriggerL" );
+    iCoeEnv = &aCoeEnv;
+    iUseCoeEnv = ETrue;
+    DoDownloadAndHandleRoapTriggerL( aUrl );
+    HandlePostResponseUrlL();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::HandlePostResponseUrlL
+// ---------------------------------------------------------------------------
+//
+void CDrmUtilityDmgrWrapper::HandlePostResponseUrlL()
+    {
+    if ( iPostResponseUrl )
+        {
+        DoDownloadAndHandleRoapTriggerL( iPostResponseUrl );
+        // prevent infinite post response fetches.
+        delete iPostResponseUrl;
+        iPostResponseUrl = NULL;
+
+        // Ensure progress note gets deleted.
+        // It remains open if prUrl initialted ROAP operation has PrUrl
+        // (unsupported chained metering report)
+        RemoveProgressNoteL();
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::DoDownloadAndHandleRoapTriggerL
+// ---------------------------------------------------------------------------
+//
+void CDrmUtilityDmgrWrapper::DoDownloadAndHandleRoapTriggerL(
+    const HBufC8* aUrl )
+    {
+    RFs fs;
+    RFile roapTrigger;
+    HBufC8* triggerBuf( NULL );
+    TBool result( EFalse );
+    TFileName triggerFileName;
+
+    CLOG_WRITE( "DMgrWrapper::DoDownloadAndHandleRoapTriggerL" );
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    User::LeaveIfError( fs.ShareProtected() );
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    User::LeaveIfError( roapTrigger.Temp(
+            fs, KDrmUtilityTriggerFilePath, triggerFileName, EFileWrite ) );
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRam, driveNumber );
+    fs.DriveToChar( driveNumber, driveLetter );
+
+    TFileName utilityTriggerFilePath;
+
+    utilityTriggerFilePath.Format( KKDrmUtilityTriggerFilePathFormatter,
+        (TUint)driveLetter );
+
+    User::LeaveIfError( roapTrigger.Temp(
+            fs, utilityTriggerFilePath, triggerFileName, EFileWrite ) );
+
+#endif
+
+
+    TPtrC8 KNullPtr8( NULL, 0 );
+    RHttpDownload* downloadPtr( iDlMgr.FindDownload( *aUrl, KNullPtr8 ) );
+    if ( downloadPtr )
+        {
+        // Stale download found.
+        // Remove it, and re-create a new download.
+        downloadPtr->Delete();
+        downloadPtr = NULL;
+        }
+
+    // create and start download
+    RHttpDownload& download = iDlMgr.CreateDownloadL( *aUrl, result );
+    // Put download for proper cleanup.
+    TCleanupItem item( DeleteHttpDowload, &download );
+    CleanupStack::PushL( item );
+
+    CleanupClosePushL( roapTrigger );
+
+    if ( !iPostResponseUrl )
+        {
+        // No post response retieval. Note must be created.
+        ShowProgressNoteL();
+        }
+
+    if ( result )
+        {
+        const TInt KReadBufSize( 512 );
+        TInt triggerFileSize( 0 );
+
+        CLOG_WRITE(
+            "DMgrWrapper::DoDownloadAndHandleRoapTriggerL: download created" );
+        iDownloadSuccess = EFalse;
+        iConnectionError = EFalse;
+
+        SetDefaultAccessPointL();
+
+        User::LeaveIfError( download.SetFileHandleAttribute( roapTrigger ) );
+        User::LeaveIfError(
+            download.SetBoolAttribute( EDlAttrNoContentTypeCheck, ETrue ) );
+        User::LeaveIfError( download.Start() );
+
+        // wait until download is finished
+        iWait.Start();
+
+        // Check success of download
+        CLOG_WRITE(
+            "DMgrWrapper::DoDownloadAndHandleRoapTriggerL: download finished" );
+
+        CleanupStack::Pop( &roapTrigger );
+        roapTrigger.Close();
+        if ( !iDownloadSuccess )
+            {
+            RemoveProgressNoteL();
+            if ( iConnectionError )
+                {
+                User::Leave( KErrCouldNotConnect );
+                }
+            else
+                {
+                User::Leave( KErrGeneral );
+                }
+            }
+        User::LeaveIfError( roapTrigger.Open( fs,
+                                              triggerFileName,
+                                              EFileShareReadersOrWriters ) );
+        CleanupClosePushL( roapTrigger );
+
+        // Get filehandle of ROAP trigger
+        // Read file to buffer
+        User::LeaveIfError( roapTrigger.Size( triggerFileSize ) );
+        triggerBuf = HBufC8::NewLC( triggerFileSize );
+
+        RBuf8 readBuf;
+        readBuf.CleanupClosePushL();
+        readBuf.CreateL( KReadBufSize );
+
+        User::LeaveIfError( roapTrigger.Read( readBuf, KReadBufSize ) );
+        triggerBuf->Des().Copy( readBuf );
+        while ( readBuf.Length() == KReadBufSize )
+            {
+            User::LeaveIfError( roapTrigger.Read( readBuf, KReadBufSize ) );
+            triggerBuf->Des().Append( readBuf );
+            }
+
+        CleanupStack::PopAndDestroy( &readBuf );
+
+        if ( iUseCoeEnv && iProgressInfo )
+            {
+            iProgressInfo->IncrementAndDraw( KProgressInfoIncrementMedium );
+            }
+
+        // And let ROAP handle it...
+        CRoapSyncWrapper* roapWrapper( CRoapSyncWrapper::NewL() );
+        CleanupStack::PushL( roapWrapper );
+        TRAPD( err, roapWrapper->HandleTriggerL( *triggerBuf ) );
+        if ( err )
+            {
+            TInt errorType( 0 );
+            TRAPD( err2,
+                iErrorUrl = roapWrapper->GetErrorUrlL( err, errorType ) );
+            if ( err2 )
+                {
+                RemoveProgressNoteL();
+                delete iErrorUrl;
+                iErrorUrl = NULL;
+                User::Leave( err2 );
+                }
+            else if ( errorType != KErrRoapTemporary )
+                {
+                RemoveProgressNoteL();
+                delete iErrorUrl;
+                iErrorUrl = NULL;
+                User::Leave( err );
+                }
+            else
+                {
+                RemoveProgressNoteL();
+                User::Leave( err );
+                }
+            }
+        if ( iPostResponseUrl )
+            {
+            delete iPostResponseUrl;
+            iPostResponseUrl = NULL;
+            }
+        iPostResponseUrl = roapWrapper->GetPostResponseUrlL();
+        CleanupStack::PopAndDestroy( 2, triggerBuf );
+
+        if ( iUseCoeEnv && iProgressInfo && !iPostResponseUrl )
+            {
+            // No PrUrl found. Progess is complete.
+            iProgressInfo->SetAndDraw( KProgressInfoFinalValue );
+            }
+        }
+
+    // Trick to keep note open long enough during prUrl retrieval
+    if ( !iPostResponseUrl )
+        {
+        RemoveProgressNoteL();
+        }
+    else
+        {
+        if ( iUseCoeEnv && iProgressInfo )
+            {
+            iProgressInfo->IncrementAndDraw( KProgressInfoIncrementMedium );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &roapTrigger );
+    CleanupStack::PopAndDestroy( &download );
+
+    fs.Delete( triggerFileName );
+    CleanupStack::PopAndDestroy( &fs );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::SetDefaultAccessPointL
+// ---------------------------------------------------------------------------
+//
+void CDrmUtilityDmgrWrapper::SetDefaultAccessPointL()
+    {
+    const TInt KDestinationSelectionMode( 2 );
+    CRepository* repository( NULL );
+    TInt ap( 0 );
+    TInt alwaysAsk( 0 );
+    TUint32 iapd32( 0 );
+    TInt defaultSnap( 0 );
+    TInt err( KErrNone );
+
+    CLOG_WRITE( "DMgrWrapper::SetDefaultAccessPointL" );
+    DRMDEBUGLIT( KDuiBrApFormat,
+        "CDrmUtilityDmgrWrapper::SetDefaultAccessPointL %d" );
+    DRMDEBUGLIT( KDuiBrApFormat2, " KBrowserDefaultAccessPoint = %d" );
+    DRMDEBUGLIT( KDuiBrApFormat3, " KBrowserAccessPointSelectionMode = %d" );
+    DRMDEBUGLIT( KDuiBrApFormat4, " KBrowserNGDefaultSnapId = %d" );
+
+    repository = CRepository::NewL( KCRUidBrowser );
+    CleanupStack::PushL( repository );
+    repository->Get( KBrowserDefaultAccessPoint, ap );
+    repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
+    repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
+    DRMDEBUG2( KDuiBrApFormat(), __LINE__ );
+    DRMDEBUG2( KDuiBrApFormat2(), ap );
+    DRMDEBUG2( KDuiBrApFormat3(), alwaysAsk );
+    DRMDEBUG2( KDuiBrApFormat4(), defaultSnap );
+
+    if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
+        {
+        alwaysAsk = ETrue;
+        }
+    else
+        {
+        RCmManager cmManager;
+        cmManager.OpenLC();
+        if ( !alwaysAsk )
+            {
+            TRAP( err, iapd32 = cmManager.GetConnectionMethodInfoIntL(
+                    ap, CMManager::ECmIapId ) );
+            }
+        else if ( alwaysAsk == KDestinationSelectionMode )
+            {
+            TRAP( err, iapd32 =
+                IapIdOfDefaultSnapL( cmManager, defaultSnap ) );
+            }
+        CleanupStack::PopAndDestroy( &cmManager );
+        }
+    if ( !err && ( !alwaysAsk || alwaysAsk == KDestinationSelectionMode ) )
+        {
+        err = iDlMgr.SetIntAttribute( EDlMgrIap, iapd32 );
+        }
+    CleanupStack::PopAndDestroy( repository );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::GetErrorUrlL
+// ---------------------------------------------------------------------------
+//
+HBufC8* CDrmUtilityDmgrWrapper::GetErrorUrlL()
+    {
+    if( iErrorUrl )
+        {
+        return iErrorUrl->AllocL();
+        }
+    return NULL;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MHttpDownloadMgrObserver
+//
+// CDrmUtilityDmgrWrapper::HandleDMgrEventL
+// ---------------------------------------------------------------------------
+//
+void CDrmUtilityDmgrWrapper::HandleDMgrEventL(
+    RHttpDownload& aDownload,
+    THttpDownloadEvent aEvent )
+    {
+    _LIT8( KDrmUtilityMimeTypeROAPTrigger,
+        "application/vnd.oma.drm.roap-trigger+xml" );
+
+    CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL" );
+    CLOG_WRITE_FORMAT( "iDownLoadState = %d", aEvent.iDownloadState );
+    CLOG_WRITE_FORMAT( "iProgressState = %d", aEvent.iProgressState );
+
+    if ( aEvent.iProgressState == EHttpContentTypeReceived )
+        {
+        // check received mimetype
+        RBuf8 contentType;
+        contentType.CleanupClosePushL();
+        contentType.CreateL( KMaxContentTypeLength );
+        User::LeaveIfError(
+            aDownload.GetStringAttribute( EDlAttrContentType, contentType ) );
+        if ( !contentType.FindF( KDrmUtilityMimeTypeROAPTrigger ) )
+            {
+            // ROAP trigger found, continue download
+            User::LeaveIfError( aDownload.Start() );
+            }
+        else
+            {
+            // wrong MIME type, so stop download
+            iDownloadSuccess = EFalse;
+            User::LeaveIfError( aDownload.Delete() );
+            }
+        CleanupStack::PopAndDestroy( &contentType );
+        }
+
+    if ( aEvent.iDownloadState == EHttpDlCreated )
+        {
+        CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlCreated" );
+        if ( iUseCoeEnv )
+            {
+        iProgressInfo->IncrementAndDraw( KProgressInfoIncrementMedium );
+            }
+        }
+    else if ( aEvent.iProgressState == EHttpProgDisconnected )
+        {
+        CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpProgDisconnected" );
+        // store failure
+        iDownloadSuccess = EFalse;
+        iConnectionError = ETrue;
+        // finished
+        iWait.AsyncStop();
+        }
+    else if ( aEvent.iDownloadState == EHttpDlInprogress )
+        {
+        CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlInprogress" );
+        if ( iUseCoeEnv )
+            {
+        iProgressInfo->IncrementAndDraw( KProgressInfoIncrementSmall );
+            }
+        }
+    else if ( aEvent.iDownloadState == EHttpDlCompleted )
+        {
+        // store success
+        CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlCompleted" );
+        iDownloadSuccess = ETrue;
+        if ( iUseCoeEnv )
+            {
+        iProgressInfo->IncrementAndDraw( KProgressInfoIncrementLarge );
+            }
+        // finished
+        iWait.AsyncStop();
+        }
+    else if ( aEvent.iDownloadState == EHttpDlFailed )
+        {
+        TInt32 err( KErrNone );
+
+        CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlFailed" );
+        // store failure
+        iDownloadSuccess = EFalse;
+        User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrErrorId, err ) );
+        CLOG_WRITE_FORMAT( "EDlAttrErrorId = %d", err );
+
+        if ( err == EConnectionFailed ||
+             err == ETransactionFailed)
+            {
+            CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EConnectionFailed" );
+            iConnectionError = ETrue;
+            }
+
+        // finished
+        iWait.AsyncStop();
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::ShowProgressNoteL
+// ---------------------------------------------------------------------------
+//
+void CDrmUtilityDmgrWrapper::ShowProgressNoteL()
+    {
+    TFileName resFileName;
+
+    CLOG_WRITE( "DMgrWrapper::ShowProgressNoteL" );
+    if ( iUseCoeEnv )
+        {
+        // Initialize the progress note dialog, it's values,
+        // and execute it
+#ifndef RD_MULTIPLE_DRIVE
+
+        resFileName.Copy( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+
+        iCoeEnv->FsSession().DriveToChar( driveNumber, driveLetter );
+
+        resFileName.Format( KRomDriveFormatter, (TUint)driveLetter );
+
+#endif
+
+        resFileName.Append( KDC_RESOURCE_FILES_DIR );
+        resFileName.Append( KCDrmUtilityDmgrWrapperResFileName );
+        RConeResourceLoader loader( *iCoeEnv );
+        loader.OpenL( resFileName );
+
+        iProgressNoteDialog = new (ELeave) CAknProgressDialog(
+            reinterpret_cast< CEikDialog** >( &iProgressNoteDialog ) );
+        iProgressNoteDialog->PrepareLC( R_SILENT_PROGRESS_NOTE );
+        iProgressNoteDialog->SetCallback( this );
+        iProgressInfo = iProgressNoteDialog->GetProgressInfoL();
+        iProgressInfo->SetFinalValue( KProgressInfoFinalValue );
+        iDialogDismissed = EFalse;
+        iProgressNoteDialog->RunLD();
+
+        loader.Close();
+        }
+
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityDmgrWrapper::RemoveProgressNoteL
+// ---------------------------------------------------------------------------
+//
+void CDrmUtilityDmgrWrapper::RemoveProgressNoteL()
+    {
+
+    if ( iUseCoeEnv )
+        {
+        if (iProgressNoteDialog && !iDialogDismissed)
+            {
+            // deletes the dialog
+            TRAPD(err, iProgressNoteDialog->ProcessFinishedL());
+            if (err != KErrNone)
+                {
+                delete iProgressNoteDialog;
+                }
+            iProgressNoteDialog = NULL;
+            }
+        }
+
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MAknProgressDialogCallback
+//
+// CDrmUtilityDmgrWrapper::DialogDismissedL
+// ---------------------------------------------------------------------------
+//
+void CDrmUtilityDmgrWrapper::DialogDismissedL( TInt /*aButtonId*/ )
+    {
+    iDialogDismissed = ETrue;
+
+    // Already freed, just set to NULL
+    iProgressNoteDialog = NULL;
+    iProgressInfo = NULL;
+
+    if( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+
+    }
+
+
+// ======== GLOBAL FUNCTIONS ========
+
+//------------------------------------------------------------------------------
+// GateFunctionDRM
+// DRM gate function
+//------------------------------------------------------------------------------
+EXPORT_C TAny* GateFunctionDMgr()
+    {
+    CDrmUtilityDmgrWrapper* launcher = NULL;
+    TRAPD( err, launcher = CDrmUtilityDmgrWrapper::NewL() );
+    if( err != KErrNone )
+        {
+        return NULL;
+        }
+
+    return launcher;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmUtilityDownloadManager.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,114 @@
+/*
+* 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:  DrmUtilityDownloadManager implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "drmutilitydownloadmanager.h"
+#include "drmutilitydmgrwrapper.h"
+
+// CONSTANTS
+_LIT( KDrmUtilityDmgrHandlerName, "\\system\\libs\\DrmUtilityDmgrWrapper.dll" );
+
+typedef TAny* (*NewDMgrL)();
+
+const TInt KFirstFunction( 1 );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityDownloadManager::CDrmUtilityDownloadManager
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDrmUtilityDownloadManager::CDrmUtilityDownloadManager()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityDownloadManager::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDrmUtilityDownloadManager::ConstructL()
+    {
+    User::LeaveIfError( iDMgrDll.Load( KDrmUtilityDmgrHandlerName ) );
+    NewDMgrL createDMgr = (NewDMgrL) iDMgrDll.Lookup( KFirstFunction );
+    if ( !createDMgr )
+        {
+        User::Leave( KErrGeneral );
+        }
+    // Create the class, leaves in case of failure
+    iDMgrHandler = (CDrmUtilityDmgrWrapper*) (*createDMgr)();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityDownloadManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDrmUtilityDownloadManager* CDrmUtilityDownloadManager::NewL()
+    {
+    CDrmUtilityDownloadManager* self( 
+                                new( ELeave ) CDrmUtilityDownloadManager() );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+// Destructor
+CDrmUtilityDownloadManager::~CDrmUtilityDownloadManager()
+    {
+    delete iDMgrHandler;
+    iDMgrDll.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityDownloadManager::DownloadAndHandleRoapTriggerL
+//
+// -----------------------------------------------------------------------------
+//    
+void CDrmUtilityDownloadManager::DownloadAndHandleRoapTriggerL(
+    const HBufC8* aUrl, CCoeEnv& aCoeEnv )
+    {
+    iDMgrHandler->DownloadAndHandleRoapTriggerL( aUrl, aCoeEnv );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityDownloadManager::DownloadAndHandleRoapTriggerL
+//
+// -----------------------------------------------------------------------------
+//
+void CDrmUtilityDownloadManager::DownloadAndHandleRoapTriggerL(
+    const HBufC8* aUrl )
+    {
+    iDMgrHandler->DownloadAndHandleRoapTriggerL( aUrl );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityDownloadManager::GetErrorUrlL
+// 
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDrmUtilityDownloadManager::GetErrorUrlL()
+    {
+    return iDMgrHandler->GetErrorUrlL();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmUtilityGlobalNoteWrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,385 @@
+/*
+* 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:  Implementation of CDrmUtilityGlobalNoteWrapper class
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <stringloader.h>
+#include <aknglobalconfirmationquery.h>
+#include <akngloballistquery.h>
+#include <badesca.h>
+#include <avkon.hrh> // EAknSoftkeyNo
+#include <drmutility.rsg>
+
+#include <aknmediatorfacade.h>
+#include <aknsddata.h>
+#include <featmgr.h>
+
+#include "drmutilitysecondarydisplay.h"
+#include "drmutilityglobalnotewrapper.h"
+#include "drmutilityinfonotewrapper.h"
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::CDrmUtilityGlobalNoteWrapper
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUtilityGlobalNoteWrapper::CDrmUtilityGlobalNoteWrapper() 
+    : CActive( EPriorityStandard )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityGlobalNoteWrapper::ConstructL( 
+    CStringResourceReader* aResourceReader )
+    {
+    iResourceReader = aResourceReader;
+    iButtonsId = R_AVKON_SOFTKEYS_YES_NO__YES;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUtilityGlobalNoteWrapper* DRM::CDrmUtilityGlobalNoteWrapper::NewLC( 
+    CStringResourceReader* aResourceReader )
+    {
+    DRM::CDrmUtilityGlobalNoteWrapper* self( 
+                                new (ELeave) CDrmUtilityGlobalNoteWrapper() );
+    CleanupStack::PushL( self );
+    self->ConstructL( aResourceReader );
+    return self;
+    }
+
+DRM::CDrmUtilityGlobalNoteWrapper* DRM::CDrmUtilityGlobalNoteWrapper::NewL(
+    CStringResourceReader* aResourceReader )
+    {
+    DRM::CDrmUtilityGlobalNoteWrapper* self( NewLC( aResourceReader ) );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+    
+// Destructor
+DRM::CDrmUtilityGlobalNoteWrapper::~CDrmUtilityGlobalNoteWrapper()
+    {
+    Cancel(); // Cancel active object
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::ShowNoteL
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUtilityGlobalNoteWrapper::ShowNoteWithButtonsL( 
+    TInt aResourceId, 
+    TInt aButtonsId )
+    {
+    TInt ret( 0 );
+    
+    iTextBuffer = iResourceReader->ReadResourceString( aResourceId );
+    
+    iButtonsId = aButtonsId;   
+    ret = DoShowNoteL( aResourceId );
+    iButtonsId = R_AVKON_SOFTKEYS_YES_NO__YES;
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::ShowNoteWithButtonsL
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUtilityGlobalNoteWrapper::ShowNoteWithButtonsL( 
+    TInt aResourceId, 
+    TInt aButtonsId,
+    const TDesC& aString )
+    {
+    TInt ret( 0 );
+    
+    TBuf<DRM::KDRMNoteBufferMaxSize> srcBuffer( 
+        iResourceReader->ReadResourceString( aResourceId ) );
+    
+    StringLoader::Format( iTextBuffer, srcBuffer, -1, aString );
+            
+    iButtonsId = aButtonsId;   
+    ret = DoShowNoteL( aResourceId, aString );
+    iButtonsId = R_AVKON_SOFTKEYS_YES_NO__YES;
+    return ret;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::ShowNoteL
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUtilityGlobalNoteWrapper::ShowNoteL( 
+    TInt aResourceId, 
+    TInt aValue )
+    {
+    TBuf<DRM::KDRMNoteBufferMaxSize> srcBuffer( 
+        iResourceReader->ReadResourceString( aResourceId ) );
+        
+    StringLoader::Format( iTextBuffer, srcBuffer, -1, aValue );
+    return DoShowNoteL( aResourceId, KNullDesC, aValue );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::ShowNoteL
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUtilityGlobalNoteWrapper::ShowNoteL( 
+    TInt aResourceId, 
+    const TDesC& aString )
+    {
+    TBuf<DRM::KDRMNoteBufferMaxSize> srcBuffer( 
+        iResourceReader->ReadResourceString( aResourceId ) );
+        
+    StringLoader::Format( iTextBuffer, srcBuffer, -1, aString );
+    return DoShowNoteL( aResourceId, aString );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::ShowNoteL
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUtilityGlobalNoteWrapper::ShowNoteL( 
+    TInt aResourceId, 
+    const TDesC& aString,
+    TInt aValue, 
+    TInt aStringPos,
+    TInt aValuePos)
+    {
+    TBuf<DRM::KDRMNoteBufferMaxSize> srcBuffer( 
+        iResourceReader->ReadResourceString( aResourceId ) );
+    
+    StringLoader::Format( iTextBuffer, srcBuffer, aValuePos, aValue );
+    srcBuffer = iTextBuffer;
+    StringLoader::Format( iTextBuffer, srcBuffer, aStringPos, aString );
+    return DoShowNoteL( aResourceId, aString, aValue );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::ShowPreviewListQueryL
+// -----------------------------------------------------------------------------
+//
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+TInt DRM::CDrmUtilityGlobalNoteWrapper::ShowPreviewListQueryL( 
+    TInt aResourceId )
+    {
+    TInt index( 0 );
+    CAknGlobalListQuery* listQuery( CAknGlobalListQuery::NewLC() );
+    HBufC* buffer( HBufC::NewLC( DRM::KDRMNoteBufferMaxSize ) );
+    TPtr bufPtr( buffer->Des() );
+    
+    bufPtr = iResourceReader->ReadResourceString( R_DRMUTILITY_ACTIVATE_PREVIEW );
+    listQuery->SetHeadingL( bufPtr );
+    
+    CDesCArray* listArray( new( ELeave ) CDesCArrayFlat( 2 ) );
+    CleanupStack::PushL( listArray );
+    
+    bufPtr = iResourceReader->ReadResourceString( R_DRMUTILITY_ACTIVATE );
+    listArray->AppendL( bufPtr );
+    
+    switch( aResourceId )
+        {
+        case R_DRMUTILITY_PREV_AUDIO_GET_LIST_QUERY:
+        
+            bufPtr = iResourceReader->ReadResourceString( 
+                                            R_DRMUTILITY_GET_PREVIEW );
+            
+            
+            break;
+            
+        case R_DRMUTILITY_PREV_VIDEO_GET_LIST_QUERY:
+        
+            bufPtr = iResourceReader->ReadResourceString( 
+                                            R_DRMUTILITY_GET_PREVIEW_VIDEO );
+            
+            break;
+            
+        case R_DRMUTILITY_PREV_AUDIO_PLAY_LIST_QUERY:
+        
+            bufPtr = iResourceReader->ReadResourceString( 
+                                            R_DRMUTILITY_PLAY_PREVIEW );
+            
+            break;
+            
+        case R_DRMUTILITY_PREV_VIDEO_PLAY_LIST_QUERY:
+        
+            bufPtr = iResourceReader->ReadResourceString( 
+                                            R_DRMUTILITY_PLAY_PREVIEW_VIDEO );
+            
+            break;
+        
+        default:
+        
+            return 0;
+
+        }
+    
+    listArray->AppendL( bufPtr );
+    
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) &&
+        DRM::CDrmUtilityInfoNoteWrapper::EvaluateCoverResourceId( aResourceId ) )
+        {
+        RProcess myProcess;
+        TUid myProcessUid( KNullUid );
+        RThread().Process( myProcess );
+        myProcessUid = myProcess.Identity();
+   
+        TUtilitySDData utilityData;
+        // First field is DrmUtility's Uid
+        utilityData.iUtilityUid = KUidCoverUiCategoryDrmUtility;
+        // ProcessId which uses DrmUtility
+        utilityData.iHandlerProcessId = myProcessUid; 
+        TUtilitySDDataPckg pckg( utilityData );                   
+        CAknSDData* sd( CAknSDData::NewL( KUidCoverUiCategoryDrmUtility, 
+                                          aResourceId, 
+                                          pckg ) );
+        
+        // ownership to notifier client                                   
+        listQuery->SetSecondaryDisplayData( sd );
+        }
+    
+    iStatus = KRequestPending;
+    listQuery->ShowListQueryL( listArray, iStatus );
+    SetActive();
+    iWait.Start();
+    
+    CleanupStack::PopAndDestroy( 3, listQuery ); //listArray, buffer, listQuery
+    
+    if ( iStatus.Int() != EAknSoftkeyNo )
+        {
+        index = iStatus.Int() + 1;
+        }
+    
+    return index;
+    }
+
+#else
+
+TInt DRM::CDrmUtilityGlobalNoteWrapper::ShowPreviewListQueryL( 
+    TInt /*aResourceId*/ )
+    {
+    return 0;
+    }
+
+#endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::DoCancel
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityGlobalNoteWrapper::DoCancel()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::RunL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityGlobalNoteWrapper::RunL()
+    {
+    iWait.AsyncStop();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityGlobalNoteWrapper::DoShowNoteL
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUtilityGlobalNoteWrapper::DoShowNoteL( 
+    TInt aResourceId, 
+    const TDesC& aString, 
+    TInt aValue )
+    {
+    TPtr bufPtr( NULL, 0 );
+    TInt animation( iButtonsId == R_AVKON_SOFTKEYS_YES_NO__YES ? 
+                                                    0 : R_QGN_NOTE_INFO_ANIM );
+    
+    CAknGlobalConfirmationQuery* globalNote(
+                                        CAknGlobalConfirmationQuery::NewLC() );
+         	
+    bufPtr.Set( const_cast <TUint16*>( iTextBuffer.Ptr() ), 
+                                       iTextBuffer.Length(), 
+                                       iTextBuffer.Length() );
+    
+    AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+
+
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) &&
+        DRM::CDrmUtilityInfoNoteWrapper::EvaluateCoverResourceId( aResourceId ) )
+        {
+        RProcess myProcess;
+        TUid myProcessUid( KNullUid );
+        RThread().Process( myProcess );
+        myProcessUid = myProcess.Identity();
+   
+        TUtilitySDData utilityData;
+        // First field is DrmUtility's Uid
+        utilityData.iUtilityUid = KUidCoverUiCategoryDrmUtility;
+        // ProcessId which uses DrmUtility
+        utilityData.iHandlerProcessId = myProcessUid; 
+        if ( aString.Compare( KNullDesC ) )
+            {
+            // If there is filename given, it's always in the PrimaryString
+            utilityData.iStringParam.Append( aString );
+            }
+        if ( aValue >= 0 )
+            {
+            // If there is no other than numeric data, put it as SecondaryString
+            utilityData.iNumParam.AppendNum( aValue );
+            }
+
+        TUtilitySDDataPckg pckg( utilityData );                   
+        CAknSDData* sd( CAknSDData::NewL( KUidCoverUiCategoryDrmUtility, 
+                                          aResourceId, 
+                                          pckg ) );
+        
+        // ownership to notifier client                                   
+        globalNote->SetSecondaryDisplayData( sd );
+        }
+
+    iStatus = KRequestPending;
+    globalNote->ShowConfirmationQueryL( iStatus, 
+                                        iTextBuffer, 
+                                        iButtonsId,
+                                        animation );
+                                         
+    SetActive();
+    iWait.Start();
+    CleanupStack::PopAndDestroy( globalNote );
+    if ( iStatus.Int() != EAknSoftkeyNo )
+        {
+        return iStatus.Int();    
+        }
+    else
+        {
+        return 0;
+        }
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/DrmUtilityInfoNoteWrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,441 @@
+/*
+* 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:  Implementation of CDrmUtilityInfoNoteWrapper class
+*
+*/
+
+
+// INCLUDE FILES
+#include <stringloader.h>
+#include <aknglobalconfirmationquery.h>
+#include <avkon.hrh> // EAknSoftkeyNo
+#include <aknglobalnote.h>
+
+#include <aknmediatorfacade.h>
+#include <featmgr.h>
+#include <aknsddata.h>
+#include <drmutility.rsg>
+
+#include "drmutilitysecondarydisplay.h"
+#include "drmutilityinfonotewrapper.h"
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityInfoNoteWrapper::CDrmUtilityInfoNoteWrapper
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUtilityInfoNoteWrapper::CDrmUtilityInfoNoteWrapper() 
+    : CActive( EPriorityStandard )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityInfoNoteWrapper::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityInfoNoteWrapper::ConstructL()
+    {
+    iNote = CAknGlobalNote::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityInfoNoteWrapper::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUtilityInfoNoteWrapper* DRM::CDrmUtilityInfoNoteWrapper::NewLC()
+    {
+    DRM::CDrmUtilityInfoNoteWrapper* self( 
+                                new (ELeave) CDrmUtilityInfoNoteWrapper() );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityInfoNoteWrapper::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUtilityInfoNoteWrapper* DRM::CDrmUtilityInfoNoteWrapper::NewL()
+    {
+    DRM::CDrmUtilityInfoNoteWrapper* self( NewLC() );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+    
+// Destructor
+DRM::CDrmUtilityInfoNoteWrapper::~CDrmUtilityInfoNoteWrapper()
+    {
+    Cancel(); // Cancel active object
+    delete iNote;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityInfoNoteWrapper::ShowNoteL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityInfoNoteWrapper::ShowNoteL( TAknGlobalNoteType aType , 
+                                                 const TDesC& aNoteText,
+                                                 TInt aResourceId,
+                                                 const TDesC& aString,
+                                                 TInt aValue )
+    {
+    RProcess myProcess;
+    TUid myProcessUid( KNullUid );
+        
+    // Convert primary display resource ID to Cover Ui
+    // do nothing if not found 
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) &&
+         EvaluateCoverResourceId( aResourceId ) )
+        {  
+        RThread().Process( myProcess );
+        myProcessUid = myProcess.Identity();             
+            
+        TUtilitySDData utilityData;
+        // First field is DrmUtility's Uid
+        utilityData.iUtilityUid = KUidCoverUiCategoryDrmUtility;
+        // ProcessId which uses DrmUtility
+        utilityData.iHandlerProcessId = myProcessUid; 
+        if ( aNoteText.Compare( KNullDesC ) )
+            {
+            // If there is filename given, it's always in the PrimaryString
+            utilityData.iStringParam.Append( aString );
+            }
+        if ( aValue > -1 )
+            {
+            // If there is filename given, it's always in the PrimaryString
+            utilityData.iStringParam.Append( aValue );
+            }            
+
+        TUtilitySDDataPckg pckg( utilityData );                   
+        CAknSDData* sd( CAknSDData::NewL( KUidCoverUiCategoryDrmUtility, 
+                                          aResourceId, 
+                                          pckg ) );
+        iNote->SetSecondaryDisplayData( sd ); // ownership to notifier client          
+        }
+
+    iNote->ShowNoteL( iStatus , aType , aNoteText );
+    SetActive();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityInfoNoteWrapper::DoCancel
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityInfoNoteWrapper::DoCancel()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityInfoNoteWrapper::RunL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityInfoNoteWrapper::RunL()
+    {
+    }
+
+// ---------------------------------------------------------
+// CDrmUtilityInfoNoteWrapper::EvaluateCoverResourceId
+// ---------------------------------------------------------
+//     
+TBool DRM::CDrmUtilityInfoNoteWrapper::EvaluateCoverResourceId( 
+    TInt& aResourceId )
+    { 
+    switch ( aResourceId )
+        {
+        case R_DRMUTILITY_CONFIRMATION_QUERY:
+            {
+            aResourceId = ECover_confirmation_query;
+            }
+            break;
+        case R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY:
+            {
+            aResourceId = ECover_waiting_rights_confirmation_query;
+            }
+            break;
+        case R_DRMUTILITY_INVALID_SIM:
+            {
+            aResourceId = ECover_invalid_sim;
+            }
+            break;
+        /*
+        case R_DRMUTILITY_USAGE_RIGHTS_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_usage_rights_expired_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_USAGE_RIGHTS_EXPIRED:
+            {
+            aResourceId = ECover_usage_rights_expired;
+            }
+            break;
+        case R_DRMUTILITY_NO_USAGE_RIGHTS_BUY_NEW:
+            {
+            aResourceId = ECover_no_usage_rights_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_NO_USAGE_RIGHTS:
+            {
+            aResourceId = ECover_no_usage_rights;
+            }
+            break;
+        case R_DRMUTILITY_DATABASE_CORRUPTED:
+            {
+            aResourceId = ECover_database_corrupted;
+            }
+            break;
+        case R_DRMUTILITY_SET_AUTOMATED:
+            {
+            aResourceId = ECover_set_automated;
+            }
+            break;
+        case R_DRMUTILITY_ACTIVATE_AND_SET_AUTOMATED:
+            {
+            aResourceId = ECover_activate_and_set_automated;
+            }
+            break;
+        case R_DRMUTILITY_CAL_ALERT_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_cal_alert_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_CAL_ALERT_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_cal_alert_expired_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_CAL_ALERT_EXPIRED:
+            {
+            aResourceId = ECover_cal_alert_expired;
+            }
+            break;
+        case R_DRMUTILITY_CLOCK_ALARM_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_clock_alarm_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_CLOCK_ALARM_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_clock_alarm_expired_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_CLOCK_ALARM_EXPIRED:
+            {
+            aResourceId = ECover_clock_alarm_expired;
+            }
+            break;
+        case R_DRMUTILITY_EMAIL_TONE_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_email_tone_expired_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_EMAIL_TONE_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_email_tone_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_EMAIL_TONE_EXPIRED:
+            {
+            aResourceId = ECover_email_tone_expired;
+            }
+            break;
+        case R_DRMUTILITY_IM_TONE_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_im_tone_expired_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_IM_TONE_EXPIRED:
+            {
+            aResourceId = ECover_im_tone_expired;
+            }
+            break;
+        case R_DRMUTILITY_MESSAGE_TONE_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_message_tone_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_MESSAGE_TONE_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_message_tone_expired_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_MESSAGE_TONE_EXPIRED:
+            {
+            aResourceId = ECover_message_tone_expired;
+            }
+            break;
+        case R_DRMUTILITY_RINGING_TONE_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_ringing_tone_expired_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_RINGING_TONE_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_ringing_tone_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_RINGING_TONE_EXPIRED:
+            {
+            aResourceId = ECover_ringing_tone_expired;
+            }
+            break;
+        case R_DRMUTILITY_SCREENSAVER_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_screensaver_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_SCREENSAVER_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_screensaver_expired_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_SCREENSAVER_EXPIRED:
+            {
+            aResourceId = ECover_screensaver_expired;
+            }
+            break;
+        case R_DRMUTILITY_WALLPAPER_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_wallpaper_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_WALLPAPER_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_wallpaper_expired_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_WALLPAPER_EXPIRED:
+            {
+            aResourceId = ECover_wallpaper_expired;
+            }
+            break;
+        case R_DRMUTILITY_THEME_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_theme_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_THEME_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_theme_expired_buy_new;
+            }
+            break;
+        case R_DRMUTILITY_THEME_EXPIRED:
+            {
+            aResourceId = ECover_theme_expired;
+            }
+            break;
+        case R_DRMUTILITY_USAGE_RIGHTS_IN_FUTURE:
+            {
+            aResourceId = ECover_usage_rights_in_future;
+            }
+            break;
+        case R_DRMUTILITY_ACTIVATE_AFTER_PREVIEW:
+            {
+            aResourceId = ECover_activate_after_preview;
+            }
+            break;
+        case R_DRMUTILITY_WAITING_FOR_RIGHTS:
+            {
+            aResourceId = ECover_waiting_for_rights;
+            }
+            break;
+        case R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME:
+            {
+            aResourceId = ECover_rights_should_have_come;
+            }
+            break;
+        case R_DRMUTILITY_RIGHTS_SHOULD_HAVE_COME_NO_RI:
+            {
+            aResourceId = ECover_rights_should_have_come_no_ri;
+            }
+            break;
+        case R_DRMUTILITY_AUTOMATED_SD_INVALID_SIM:
+            {
+            aResourceId = ECover_automated_sd_invalid_sim;
+            }
+            break;
+        case R_DRMUTILITY_AUTOMATED_SD_EXPIRED:
+            {
+            aResourceId = ECover_automated_sd_expired;
+            }
+            break;
+        case R_DRMUTILITY_AUTOMATED_CD_EXPIRED:
+            {
+            aResourceId = ECover_automated_cd_expired;
+            }
+            break;
+        */
+        
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO        
+        
+        case R_DRMUTILITY_PREV_AUDIO_GET_LIST_QUERY:
+            {
+            aResourceId = ECover_prev_audio_get_list_query;
+            }
+            break;
+        case R_DRMUTILITY_PREV_VIDEO_GET_LIST_QUERY:
+            {
+            aResourceId = ECover_prev_video_get_list_query;
+            }
+            break;
+        case R_DRMUTILITY_PREV_AUDIO_PLAY_LIST_QUERY:
+            {
+            aResourceId = ECover_prev_audio_play_list_query;
+            }
+            break;
+        case R_DRMUTILITY_PREV_VIDEO_PLAY_LIST_QUERY:
+            {
+            aResourceId = ECover_prev_video_play_list_query;
+            }
+            break;
+        case R_DRMUTILITY_AUDIO_PREV_GET_LIST:
+            {
+            aResourceId = ECover_audio_prev_get_list;
+            }
+            break;
+        case R_DRMUTILITY_VIDEO_PREV_GET_LIST:
+            {
+            aResourceId = ECover_video_prev_get_list;
+            }
+            break;
+        case R_DRMUTILITY_AUDIO_PREV_PLAY_LIST:
+            {
+            aResourceId = ECover_audio_prev_play_list;
+            }
+            break;
+        case R_DRMUTILITY_VIDEO_PREV_PLAY_LIST:
+            {
+            aResourceId = ECover_video_prev_play_list;
+            }
+            break;
+            
+#endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+            
+        default:
+            return EFalse; // No proper dialog found, skipping
+        }    
+    return ETrue; // Dialog found
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/drmautomatedusagedata.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,204 @@
+/*
+* 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:  Async command storage class for DRM::DrmAutomatedUsageImpl
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    <utf.h>
+
+#include "drmautomatedusagedata.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageData::NewL
+// Two-Phase constructor
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsageData* DRM::CDrmAutomatedUsageData::NewL(
+    const ContentAccess::CData& aData,
+    ContentAccess::TIntent aIntent,
+    DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver* aObserver,
+    DRM::TDrmAutomatedServiceType aServiceType,
+    TOperation aOperation )
+    {
+    DRM::CDrmAutomatedUsageData* self( NewLC( aData, 
+                                              aIntent, 
+                                              aAutomatedType, 
+                                              aObserver, 
+                                              aServiceType, 
+                                              aOperation ) );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageData::NewLC
+// Two-Phase constructor
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsageData* DRM::CDrmAutomatedUsageData::NewLC(
+    const ContentAccess::CData& aData,
+    ContentAccess::TIntent aIntent,
+    DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver* aObserver,
+    DRM::TDrmAutomatedServiceType aServiceType,
+    TOperation aOperation )
+    {
+    DRM::CDrmAutomatedUsageData* self(
+        new (ELeave) DRM::CDrmAutomatedUsageData( aIntent, 
+                                                  aAutomatedType, 
+                                                  aObserver, 
+                                                  aServiceType, 
+                                                  aOperation ) );
+    CleanupStack::PushL( self );
+    self->ConstructL( aData );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageData::NewL
+// Two-Phase constructor
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsageData* DRM::CDrmAutomatedUsageData::NewL(
+    const TDesC& aUniqueId,
+    ContentAccess::TIntent aIntent,
+    DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver* aObserver,
+    DRM::TDrmAutomatedServiceType aServiceType,
+    TOperation aOperation )
+    {
+    DRM::CDrmAutomatedUsageData* self( NewLC( aUniqueId, 
+                                              aIntent, 
+                                              aAutomatedType, 
+                                              aObserver, 
+                                              aServiceType,
+                                              aOperation ) );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageData::NewLC
+// Two-Phase constructor
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsageData* DRM::CDrmAutomatedUsageData::NewLC(
+    const TDesC& aUniqueId,
+    ContentAccess::TIntent aIntent,
+    DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver* aObserver,
+    DRM::TDrmAutomatedServiceType aServiceType,
+    TOperation aOperation )
+    {
+    DRM::CDrmAutomatedUsageData* self(
+        new (ELeave) DRM::CDrmAutomatedUsageData( aIntent, 
+                                                  aAutomatedType, 
+                                                  aObserver, 
+                                                  aServiceType, 
+                                                  aOperation ) );
+    CleanupStack::PushL( self );
+    self->ConstructL( aUniqueId );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsageData::CDrmAutomatedUsageData(
+    ContentAccess::TIntent aIntent,
+    DRM::TDrmAutomatedType aAutomatedType,
+    DRM::MDrmAsyncObserver* aObserver,
+    DRM::TDrmAutomatedServiceType aServiceType,
+    TOperation aOperation ) : iOperation( aOperation ), 
+                              iIntent( aIntent ),
+                              iAutomatedType( aAutomatedType ), 
+                              iObserver( aObserver ),
+                              iServiceType( aServiceType )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Copy constructor
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsageData::CDrmAutomatedUsageData(
+    const DRM::CDrmAutomatedUsageData& )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsageData::~CDrmAutomatedUsageData()
+    {
+    delete iUniqueId;
+    delete iUniqueId8;
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageData::ConstructL
+// Second phase constructor
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmAutomatedUsageData::ConstructL(
+    const ContentAccess::CData& aData )
+    {
+    TPtr value( NULL, 0 );
+    HBufC* uniqueId( HBufC::NewLC( ContentAccess::KMaxCafContentName ) );
+    value.Set( uniqueId->Des() );
+
+    User::LeaveIfError(aData.GetStringAttribute( ContentAccess::EContentID, 
+                                                 value ) );
+
+    iUniqueId8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( value );
+    iUniqueId = uniqueId->AllocL();
+    CleanupStack::PopAndDestroy( uniqueId );
+    SetOperationId();
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageData::ConstructL
+// Second phase constructor
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmAutomatedUsageData::ConstructL( const TDesC& aUniqueId )
+    {
+    iUniqueId = aUniqueId.AllocL();
+    iUniqueId8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aUniqueId );
+    SetOperationId();
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageData::SetOperationId
+// Calculates unique operationId related to this object's parameters
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmAutomatedUsageData::SetOperationId()
+    {
+    iOperationId = reinterpret_cast< TInt >( this );
+    }
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/drmautomatedusageerrorhandling.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,146 @@
+/*
+* 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:  Implementation class that implements the MDrmErrorHandling
+*                API
+*
+*/
+
+
+#include "drmautomatedusageerrorhandling.h"
+#include "drmautomatedusageimpl.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsageErrorHandling::CDrmAutomatedUsageErrorHandling()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageErrorHandling::ConstructL
+// Second phase constructor
+// ---------------------------------------------------------------------------
+//
+void DRM::CDrmAutomatedUsageErrorHandling::ConstructL(
+    DRM::CDrmAutomatedUsageImpl* aImplementation )
+    {
+    iImplementation = aImplementation;
+    }
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmAutomatedUsageErrorHandling* 
+DRM::CDrmAutomatedUsageErrorHandling::NewL(
+    DRM::CDrmAutomatedUsageImpl* aImplementation )
+    {
+    DRM::CDrmAutomatedUsageErrorHandling* self(
+        DRM::CDrmAutomatedUsageErrorHandling::NewLC( aImplementation ) );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmAutomatedUsageErrorHandling*
+DRM::CDrmAutomatedUsageErrorHandling::NewLC(
+    DRM::CDrmAutomatedUsageImpl* aImplementation )
+    {
+    DRM::CDrmAutomatedUsageErrorHandling* self(
+        new ( ELeave ) DRM::CDrmAutomatedUsageErrorHandling );
+    CleanupStack::PushL( self );
+    self->ConstructL( aImplementation );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+DRM::CDrmAutomatedUsageErrorHandling::~CDrmAutomatedUsageErrorHandling()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageErrorHandling::HandleErrorAsyncL
+// RFile based asynchronous method
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsageErrorHandling::HandleErrorAsyncL( 
+    RFile& aFile,
+    ContentAccess::TIntent aIntent, 
+    TInt aError, 
+    DRM::MDrmHandleErrorObserver& aObserver )
+    {
+    return iImplementation->HandleErrorAsyncL( aFile, 
+                                               aIntent, 
+                                               aError, 
+                                               aObserver );
+    }
+
+// ---------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageErrorHandling::HandleErrorL
+// RFile based method
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsageErrorHandling::HandleErrorL( 
+    RFile& aFile,
+    ContentAccess::TIntent aIntent,              
+    TInt aError, 
+    DRM::MDrmHandleErrorObserver* aObserver )
+    {
+    iImplementation->HandleErrorL( aFile, aIntent, aError, aObserver );
+    }
+
+// ---------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageErrorHandling::HandleErrorAsyncL
+// CData based asynchronous method
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmAutomatedUsageErrorHandling::HandleErrorAsyncL( 
+    ContentAccess::CData& aFile,
+    ContentAccess::TIntent aIntent,
+    TInt aError, 
+    DRM::MDrmHandleErrorObserver& aObserver )
+    {
+    return iImplementation->HandleErrorAsyncL( aFile, 
+                                               aIntent, 
+                                               aError, 
+                                               aObserver);
+    }
+
+// ---------------------------------------------------------------------------
+// DRM::CDrmAutomatedUsageErrorHandling::HandleErrorL
+// CData based method
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmAutomatedUsageErrorHandling::HandleErrorL( 
+    ContentAccess::CData& aData,
+    ContentAccess::TIntent aIntent,
+    TInt aError, 
+    DRM::MDrmHandleErrorObserver* aObserver )
+    {
+    iImplementation->HandleErrorL( aData, aIntent, aError, aObserver );    
+    }
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/drmuierrorhandling.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,149 @@
+/*
+* 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:  Implementation class that implements the MDrmErrorHandling
+*                API
+*
+*/
+
+
+#include "drmuierrorhandling.h"
+#include "drmuihandlingimpl.h"
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+DRM::CDrmUiErrorHandling::CDrmUiErrorHandling()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDrmUiErrorHandling::ConstructL
+// Second phase constructor
+// ---------------------------------------------------------------------------
+//
+void DRM::CDrmUiErrorHandling::ConstructL( DRM::CDrmUiHandlingImpl* aImplementation )
+    {
+    iImplementation = aImplementation;
+    }
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUiErrorHandling* DRM::CDrmUiErrorHandling::NewL(
+    DRM::CDrmUiHandlingImpl* aImplementation )
+    {
+    DRM::CDrmUiErrorHandling* self( NewLC( aImplementation ) );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Two-phased constructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUiErrorHandling* DRM::CDrmUiErrorHandling::NewLC(
+    DRM::CDrmUiHandlingImpl* aImplementation )
+    {
+    DRM::CDrmUiErrorHandling* self( new( ELeave ) CDrmUiErrorHandling );
+    CleanupStack::PushL( self );
+    self->ConstructL( aImplementation );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+DRM::CDrmUiErrorHandling::~CDrmUiErrorHandling()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDrmUiErrorHandling::HandleErrorAsyncL
+// RFile based method
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiErrorHandling::HandleErrorAsyncL( 
+    RFile& aFile,
+    ContentAccess::TIntent aIntent, 
+    TInt aError, 
+    DRM::MDrmHandleErrorObserver& aObserver )
+    {
+    TInt operation = iImplementation->HandleErrorAsyncL( aFile, 
+                                                         aIntent, 
+                                                         aError, 
+                                                         aObserver);
+    return operation;                                           
+    }
+        
+// ---------------------------------------------------------------------------
+// CDrmUiErrorHandling::HandleErrorL
+// RFile based method
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiErrorHandling::HandleErrorL( 
+    RFile& aFile,
+    ContentAccess::TIntent aIntent,              
+    TInt aError, 
+    DRM::MDrmHandleErrorObserver* aObserver )
+    {
+    iImplementation->HandleErrorL( aFile, 
+                                   aIntent, 
+                                   aError, 
+                                   aObserver);
+    }
+
+// ---------------------------------------------------------------------------
+// CDrmUiErrorHandling::HandleErrorAsyncL
+// ContentAccess::CData based method
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUiErrorHandling::HandleErrorAsyncL( 
+    ContentAccess::CData& aFile,
+    ContentAccess::TIntent aIntent,
+    TInt aError, 
+    DRM::MDrmHandleErrorObserver& aObserver )
+    {
+    TInt operation = iImplementation->HandleErrorAsyncL( aFile, 
+                                                         aIntent, 
+                                                         aError, 
+                                                         aObserver);
+    return operation;     
+    }
+    
+// ---------------------------------------------------------------------------
+// CDrmUiErrorHandling::HandleErrorL
+// ContentAccess::CData based method
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUiErrorHandling::HandleErrorL( 
+    ContentAccess::CData& aFile,
+    ContentAccess::TIntent aIntent,
+    TInt aError, 
+    DRM::MDrmHandleErrorObserver* aObserver )
+    {
+    iImplementation->HandleErrorL( aFile, 
+                                   aIntent, 
+                                   aError, 
+                                   aObserver);    
+    }
+
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/drmuihandlingdata.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,76 @@
+/*
+* Copyright (c) 2006-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:  Data class for async operations in DrmUiHandlingImpl class
+*
+*/
+
+
+// INCLUDE FILES
+#include "drmuihandlingdata.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingData::NewLC
+// Two-Phase constructor
+// -----------------------------------------------------------------------------
+//     
+DRM::CDrmUiHandlingData* DRM::CDrmUiHandlingData::NewL()
+    {
+    DRM::CDrmUiHandlingData* self( NewLC() );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingData::NewLC
+// Two-Phase constructor
+// -----------------------------------------------------------------------------
+//     
+DRM::CDrmUiHandlingData* DRM::CDrmUiHandlingData::NewLC()
+    {
+    DRM::CDrmUiHandlingData* self( new (ELeave) CDrmUiHandlingData );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;    
+    }
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+//  
+DRM::CDrmUiHandlingData::CDrmUiHandlingData()
+	{
+	}
+	
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//  
+DRM::CDrmUiHandlingData::~CDrmUiHandlingData()
+	{
+	}
+	
+// -----------------------------------------------------------------------------
+// CDrmUiHandlingData::ConstructL
+// Second phase constructor
+// -----------------------------------------------------------------------------
+//  
+void DRM::CDrmUiHandlingData::ConstructL()
+    {
+    }
+    
+    
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/drmutilitycommon.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,201 @@
+/*
+* Copyright (c) 2006-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:  DRM Utility common functionality
+*
+*/
+
+
+// INCLUDE FILES
+#include <drmpermission.h>
+#include <drmconstraint.h>
+
+#include "drmutilitycommon.h"
+#include "drmclockclient.h"
+#include "drmpointerarray.h"
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityCommon::CDrmUtilityCommon
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUtilityCommon::CDrmUtilityCommon()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityCommon::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityCommon::ConstructL()
+    {
+    User::LeaveIfError( iOmaClient.Connect() );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityCommon::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUtilityCommon* DRM::CDrmUtilityCommon::NewLC()
+    {
+    DRM::CDrmUtilityCommon* self( new( ELeave ) CDrmUtilityCommon() );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityCommon::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUtilityCommon* DRM::CDrmUtilityCommon::NewL()
+    {
+    DRM::CDrmUtilityCommon* self( NewLC() );
+    
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// Destructor
+DRM::CDrmUtilityCommon::~CDrmUtilityCommon()
+    {
+    iOmaClient.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityCommon::GetOmaRightsStatusL
+//
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C DRM::TDrmRightsInfo DRM::CDrmUtilityCommon::GetOmaRightsStatusL( 
+    HBufC8*& aContentUri,
+    ContentAccess::TIntent aIntent,
+    CDRMConstraint* aConstraint )
+    {
+    CDRMPointerArray<CDRMPermission>* uriList( NULL );
+    CDRMPointerArray<HBufC8>* individuals( NULL );
+    RDRMClockClient clockClient;
+    DRMClock::ESecurityLevel secLevel( DRMClock::KInsecure );
+    TTime drmTime( Time::NullTTime() );
+    TBool possiblefuture( EFalse );
+    CDRMConstraint* constraint( NULL );
+    CDRMConstraint* toplevel( NULL );
+    TUint32 retval( 0 );
+    TInt r( KErrNone );          
+        
+    r = clockClient.Connect();
+    CleanupClosePushL( clockClient );
+    if ( !r )
+        {
+        TInt timeZone( 0 );        
+        clockClient.GetSecureTime( drmTime, timeZone, secLevel );
+        }
+                                      
+    uriList = CDRMPointerArray<CDRMPermission>::NewLC();
+    uriList->SetAutoCleanup( ETrue );
+    TRAP_IGNORE( iOmaClient.GetDBEntriesL( *aContentUri, *uriList ) );                                  
+                                      
+    if ( !uriList->Count() )
+        {
+        CleanupStack::PopAndDestroy( 2, &clockClient ); //clockClient, uriList
+        return DRM::EURightsInfoMissing;
+        }
+    
+    individuals = CDRMPointerArray<HBufC8>::NewLC();
+    individuals->SetAutoCleanup( ETrue );
+    TRAP_IGNORE( iOmaClient.GetSupportedIndividualsL( *individuals ) );    
+    
+    // Now we have the time, rights and the individual constraints do the
+    // checking. The rights are never valid if we get here so we don't have
+    // to check for that
+    for ( TInt i( 0 ); i < uriList->Count() && !possiblefuture ; i++ )
+        {
+        toplevel = NULL;
+        constraint = NULL;
+        
+        // If the toplevel constraint is defined, get it:
+        toplevel = (*uriList)[i]->TopLevelConstraint();
+        // If constraint for the intent is defined, get it
+        constraint = (*uriList)[i]->ConstraintForIntent( aIntent );
+        
+        // Top level constraint and constraint for intent, merge them
+        if ( toplevel && constraint )
+            {
+            constraint->Merge( *toplevel );
+            }
+        // Only constraint for intent, use it
+        else if ( constraint )
+            {
+            }
+        // Only top level constraint or no constraints at all, continue
+        else 
+            {
+            continue;
+            }
+                    
+        // If the constraint is rejected due to non time reasons or there is no
+        // time it can't be future
+        constraint->Valid( drmTime, *individuals, retval );
+        if ( retval & EConstraintCounter ||
+             retval & EConstraintAccumulated ||
+             retval & EConstraintTimedCounter ||
+             retval & EConstraintIndividual ||
+             retval & EConstraintNullDrmTime )
+            {
+            continue;
+            }
+        
+        drmTime.HomeTime();
+        
+        // If the constrain has active start time and it is not valid,
+        // it must be future
+        if ( constraint->iActiveConstraints & EConstraintStartTime )
+            {
+            possiblefuture = ETrue;
+            if ( aConstraint )
+                {
+                aConstraint->DuplicateL( *constraint );                       
+                }
+            }
+                
+        // If the constrain has active interval and it´s start time is in 
+        // future, it must be future
+        else if ( constraint->iActiveConstraints & EConstraintInterval &&
+                  constraint->iIntervalStart > drmTime )
+            {
+            possiblefuture = ETrue;
+            if ( aConstraint )
+                {
+                aConstraint->DuplicateL( *constraint );                     
+                }
+            }
+        } // End of for loop
+        
+	CleanupStack::PopAndDestroy( 3, &clockClient ); //individuals, urilist, 
+                                                    //clockClient
+	return possiblefuture ? DRM::EURightsInfoFuture : DRM::EURightsInfoExpired;
+	}
+	
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/drmutilityui.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1029 @@
+/*
+* 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:  DRM Utility common UI
+*
+*/
+
+
+// INCLUDE FILES
+
+// multiple drive support
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+// notes and queries
+#include <coemain.h>
+#include <bautils.h>
+#include <stringloader.h>
+#include <stringresourcereader.h>
+#include <aknnotewrappers.h>
+#include <aknglobalnote.h>
+#include <aknquerydialog.h>
+#include <aknlistquerydialog.h>
+
+// secondary display support
+#include <aknmediatorfacade.h>
+#include <featmgr.h>
+#include <aknsddata.h>
+#include <mediatoreventprovider.h>
+#include <mediatordomainuids.h>
+
+// caf
+#include <caf/caftypes.h>
+#include <caf/data.h>
+
+// resources
+#include <data_caging_path_literals.hrh>
+#include <drmutility.rsg>
+
+// drm
+#include <drmconstraint.h>
+#include <oma2agent.h>
+#include <drmutilitytypes.h>
+
+#include "drmutilityui.h"
+#include "drmutilitysecondarydisplay.h"
+#include "drmutilityglobalnotewrapper.h"
+#include "drmutilityinfonotewrapper.h"
+
+// CONSTANTS
+#ifndef RD_MULTIPLE_DRIVE
+_LIT( KDriveZ, "z:" );
+#else
+_LIT( KRomDriveFormatter, "%c:" );                                      
+#endif
+
+_LIT( KCDrmUtilityResFileName,"drmutility.rsc" );
+_LIT( KAvkonResFileName, "avkon.rsc" );
+
+// buffer sizes
+const TInt KDRMUtilityMaxDateFormatLen( 30 );
+const TInt KDRMUtilityMaxDateLen( 30 );
+const TInt KDRMUtilityMaxTimeFormatLen( 30 );
+const TInt KDRMUtilityMaxTimeLen( 30 );
+const TInt KDRMUtilityNoteMaxSize ( 256 );
+
+#ifdef _DEBUG
+// debug panic
+_LIT( KDRMUtilityDebugPanicMessage, "DrmUtilityCommonDebugPanic" );
+const TInt KDRMUtilityDebugPanicCode( 1 );
+#endif
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::CDrmUtilityUI
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUtilityUI::CDrmUtilityUI( 
+    CCoeEnv* aCoeEnv ) : iCoeEnv( aCoeEnv )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityUI::ConstructL()
+    {
+    if ( !iCoeEnv )
+        {
+        User::LeaveIfError( iFs.Connect() );
+        User::LeaveIfError( iFs.ShareAuto() );    
+        }
+    
+    TPtr utilityResourcePtr( NULL, 0 );
+    iUtilityResourceFile = HBufC::NewL( KMaxFileName );
+    utilityResourcePtr.Set( iUtilityResourceFile->Des() );
+    
+    TPtr avkonResourcePtr( NULL, 0 );
+    iAvkonResourceFile = HBufC::NewL( KMaxFileName );
+    avkonResourcePtr.Set( iAvkonResourceFile->Des() );
+
+#ifndef RD_MULTIPLE_DRIVE
+    
+    utilityResourcePtr.Append( KDriveZ );
+    avkonResourcePtr.Append( KDriveZ );
+    
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+    
+    if ( iCoeEnv )
+        {
+        iCoeEnv->FsSession().DriveToChar( driveNumber, driveLetter );
+        }
+    else
+        {
+        iFs.DriveToChar( driveNumber, driveLetter );    
+        }
+    
+    utilityResourcePtr.AppendFormat( KRomDriveFormatter, (TUint)driveLetter );
+    avkonResourcePtr.AppendFormat( KRomDriveFormatter, (TUint)driveLetter );
+    
+#endif
+    
+    utilityResourcePtr.Append( KDC_RESOURCE_FILES_DIR );
+    utilityResourcePtr.Append( KCDrmUtilityResFileName );
+    
+    avkonResourcePtr.Append( KDC_RESOURCE_FILES_DIR );
+    avkonResourcePtr.Append( KAvkonResFileName );
+    
+    TFileName resourceFile;
+    if ( iCoeEnv )
+        {
+        resourceFile = *iUtilityResourceFile;
+        BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), resourceFile );
+        iUtilityResourceFileOffset = iCoeEnv->AddResourceFileL( resourceFile );
+        
+        resourceFile = *iAvkonResourceFile;
+        BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), resourceFile );
+        iAvkonResourceFileOffset = iCoeEnv->AddResourceFileL( resourceFile );
+        }
+    else
+        {
+        resourceFile = *iUtilityResourceFile;
+        iUtilityStringResourceReader = CStringResourceReader::NewL( resourceFile, iFs );
+        
+        resourceFile = *iAvkonResourceFile;
+        iAvkonStringResourceReader = CStringResourceReader::NewL( resourceFile, iFs );
+        }
+
+    FeatureManager::InitializeLibL();
+    
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+        {
+    	iEventProvider = CMediatorEventProvider::NewL();
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUtilityUI* DRM::CDrmUtilityUI::NewLC( 
+    CCoeEnv* aCoeEnv )
+    {
+    DRM::CDrmUtilityUI* self( new( ELeave ) CDrmUtilityUI( aCoeEnv ) );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUtilityUI* DRM::CDrmUtilityUI::NewL( 
+    CCoeEnv* aCoeEnv )
+    {
+    DRM::CDrmUtilityUI* self( NewLC( aCoeEnv ) );
+    
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// Destructor
+DRM::CDrmUtilityUI::~CDrmUtilityUI()
+    {
+    if ( iCoeEnv )
+        {
+        iCoeEnv->DeleteResourceFile( iUtilityResourceFileOffset );
+        iCoeEnv->DeleteResourceFile( iAvkonResourceFileOffset );
+        }
+    else
+        {
+        delete iUtilityStringResourceReader;
+        delete iAvkonStringResourceReader;
+        iFs.Close();
+        }
+    
+    delete iUtilityResourceFile;
+    delete iAvkonResourceFile;
+    delete iEventProvider;
+    
+    iNoteList.ResetAndDestroy();
+    iNoteList.Close();
+    
+    FeatureManager::UnInitializeLib();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::DisplayQueryWithIdL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryWithIdL(
+    TInt aTextResourceId,
+    TInt aQueryResourceId )
+    {
+    TInt button( 0 );
+    
+    if ( iCoeEnv )
+        {
+        HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) );
+        button = DisplayQueryL( *msgText, aQueryResourceId );
+        CleanupStack::PopAndDestroy( msgText );
+        }
+    else
+        {
+        TInt buttonsId(
+            aQueryResourceId == R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY ?
+                                                R_AVKON_SOFTKEYS_OK_EMPTY__OK : 
+                                                R_AVKON_SOFTKEYS_YES_NO__YES );
+        
+        DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper(
+            DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) );
+
+        button = noteWrapper->ShowNoteWithButtonsL( aTextResourceId, buttonsId );
+        
+        CleanupStack::PopAndDestroy( noteWrapper );
+        }
+        
+    return button;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::DisplayQueryWithIdValueL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryWithIdValueL(
+    TInt aTextResourceId,
+    TInt aQueryResourceId,
+    const TDesC& aString )
+    {
+    TInt button( 0 );
+    
+    if ( iCoeEnv )
+        {
+        HBufC* msgText( StringLoader::LoadLC( aTextResourceId, 
+                                              aString, 
+                                              iCoeEnv ) );
+        button = DisplayQueryL( *msgText, aQueryResourceId );
+        CleanupStack::PopAndDestroy( msgText );
+        }
+    else
+        {
+        TInt buttonsId(
+            aQueryResourceId == R_DRMUTILITY_WAITING_RIGHTS_CONFIRMATION_QUERY ?
+                                                R_AVKON_SOFTKEYS_OK_EMPTY__OK : 
+                                                R_AVKON_SOFTKEYS_YES_NO__YES );
+        
+        DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper(
+            DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) );
+
+        button = noteWrapper->ShowNoteWithButtonsL( aTextResourceId, 
+                                                    buttonsId, 
+                                                    aString );
+        CleanupStack::PopAndDestroy( noteWrapper );
+        }
+        
+    return button;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::DisplayQueryL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL( 
+    TInt aTextResourceId, 
+    TInt aValue )
+    {
+    TInt buttonCode( 0 );
+    
+    if ( iCoeEnv )
+        {
+        TPtr bufPtr( NULL, 0 );
+
+        HBufC* stringholder( StringLoader::LoadLC( aTextResourceId, 
+                                                   aValue,
+                                                   iCoeEnv ) );
+        CAknQueryDialog* dlg( 
+                        CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ) );
+
+        bufPtr.Set( stringholder->Des() );
+        AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+        PrepareSecondaryDisplayL( *dlg, aTextResourceId, KNullDesC, aValue );
+
+        buttonCode = dlg->ExecuteLD( R_DRMUTILITY_CONFIRMATION_QUERY, 
+                                     *stringholder );
+        
+        CancelSecondaryDisplayL( aTextResourceId );
+        CleanupStack::PopAndDestroy( stringholder );
+        }
+    else
+        {
+        DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper(
+            DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) );
+        
+        buttonCode = noteWrapper->ShowNoteL( aTextResourceId, aValue );
+        
+        CleanupStack::PopAndDestroy( noteWrapper );
+        }
+    return buttonCode;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::DisplayQueryL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL( 
+    TInt aTextResourceId, 
+    const TDesC& aString )
+    {
+    TInt buttonCode( 0 );
+    
+    if ( iCoeEnv )
+        {
+        TPtr bufPtr( NULL, 0 );
+
+        HBufC* stringholder( StringLoader::LoadLC( aTextResourceId, 
+                                                   aString,
+                                                   iCoeEnv ) );
+        CAknQueryDialog* dlg(  
+            CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ) );
+
+        bufPtr.Set( stringholder->Des() );
+        AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+        PrepareSecondaryDisplayL( *dlg, aTextResourceId, aString, -1 );
+
+        buttonCode = dlg->ExecuteLD( R_DRMUTILITY_CONFIRMATION_QUERY, 
+                                     *stringholder );
+        
+        CancelSecondaryDisplayL( aTextResourceId );
+        CleanupStack::PopAndDestroy( stringholder );
+        }
+    else
+        {
+        DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper(
+            DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) );
+        
+        buttonCode = noteWrapper->ShowNoteL( aTextResourceId, aString );
+        
+        CleanupStack::PopAndDestroy( noteWrapper );
+        }
+        
+    return buttonCode;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::DisplayQueryL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL(
+    TInt aTextResourceId,
+    const TDesC& aString,
+    TInt aValue,
+    TInt aStringPos,
+    TInt aValuePos )
+    {
+    TInt buttonCode( 0 );
+    
+    if ( iCoeEnv )
+        {
+        TPtr bufPtr( NULL, 0 );
+
+        TBuf<KDRMUtilityNoteMaxSize> textBuffer;
+        TBuf<KDRMUtilityNoteMaxSize> textBuffer2;
+        StringLoader::Load( textBuffer, aTextResourceId, iCoeEnv );
+        StringLoader::Format( textBuffer2, textBuffer, aValuePos, aValue );
+        textBuffer = textBuffer2;
+        StringLoader::Format( textBuffer2, textBuffer, aStringPos, aString );
+
+        bufPtr.Set( const_cast <TUint16*>( textBuffer2.Ptr() ), 
+                                           textBuffer2.Length(),
+                                           textBuffer2.Length() );
+                                           
+        AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+
+        CAknQueryDialog* dlg(
+            CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ) );
+        
+        PrepareSecondaryDisplayL( *dlg, aTextResourceId, aString, aValue );
+        
+        buttonCode =
+            dlg->ExecuteLD( R_DRMUTILITY_CONFIRMATION_QUERY, textBuffer2 );
+           
+        CancelSecondaryDisplayL( aTextResourceId );
+        }
+    else
+        {
+        DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper(
+            DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) );
+        
+        buttonCode = noteWrapper->ShowNoteL( aTextResourceId, 
+                                             aString,
+                                             aValue, 
+                                             aStringPos, 
+                                             aValuePos );
+        
+        CleanupStack::PopAndDestroy( noteWrapper );
+        }
+        
+    return buttonCode;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::DisplayQueryL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmUtilityUI::DisplayQueryL( 
+    TDesC& aPromptText, 
+    TInt aQueryResourceId )
+    {
+    CAknQueryDialog* dlg( new (ELeave) CAknQueryDialog( 
+                                                aPromptText, 
+                                                CAknQueryDialog::ENoTone ) );
+
+    TPtr bufPtr( NULL, 0 );
+    bufPtr.Set( const_cast <TUint16*>( aPromptText.Ptr() ), 
+                                       aPromptText.Length(),
+                                       aPromptText.Length() );
+    
+    AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+
+    PrepareSecondaryDisplayL( *dlg, aQueryResourceId, aPromptText, -1 );
+    
+    TInt ret( dlg->ExecuteLD( aQueryResourceId ) );
+    
+    CancelSecondaryDisplayL( aQueryResourceId );
+    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::SetAutomatedQuery
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C TInt DRM::CDrmUtilityUI::SetAutomatedQueryL( 
+    CDRMConstraint* aConstraint )
+    {
+    __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage, 
+                                              KDRMUtilityDebugPanicCode ) );
+                                              
+    TInt buttonCode( 1 );
+    
+    if ( aConstraint->iActiveConstraints & EConstraintEndTime ) 
+        {
+        TBuf<KDRMUtilityMaxDateLen> dateFormat;
+        TBuf<KDRMUtilityMaxDateLen> endDate;
+        TTime endTime( aConstraint->iEndTime );
+        
+        if ( iCoeEnv )
+            {
+            StringLoader::Load( dateFormat, 
+                                R_QTN_DATE_USUAL_WITH_ZERO, 
+                                iCoeEnv );
+            }
+        else
+            {
+            dateFormat = iAvkonStringResourceReader->ReadResourceString(
+                                                R_QTN_DATE_USUAL_WITH_ZERO );
+            }
+        
+        endTime.FormatL( endDate, dateFormat );
+        buttonCode = DisplayQueryL(R_DRM_QUERY_SET_AUTOMATED, endDate );
+        }
+    else if ( aConstraint->iActiveConstraints & EConstraintInterval )
+        {
+        buttonCode = DisplayQueryWithIdL( R_DRM_QUERY_SET_AUTO_INTERVAL,
+                                          R_DRMUTILITY_CONFIRMATION_QUERY );
+
+        }
+    return buttonCode;                                          
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::ShowFutureRightsNoteL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUtilityUI::ShowFutureRightsNoteL( 
+    CDRMConstraint* aConstraint)
+    {
+    __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage, 
+                                              KDRMUtilityDebugPanicCode ) );
+    _LIT( KSpace, " " );
+    TTime startTime( Time::NullTTime() );
+    
+    User::LeaveIfError( GetOmaStartTime( aConstraint, startTime ) );
+
+    TBuf<KDRMUtilityMaxDateFormatLen> dateFormat;
+    TBuf<KDRMUtilityMaxTimeFormatLen> timeFormat;
+    TBuf<KDRMUtilityMaxDateLen + KDRMUtilityMaxTimeLen + 1> startDateBuf;
+    TBuf<KDRMUtilityMaxTimeLen> startTimeBuf;
+        
+    if ( iCoeEnv )
+        {
+        StringLoader::Load( dateFormat, R_QTN_DATE_USUAL_WITH_ZERO, iCoeEnv );
+        StringLoader::Load( timeFormat, R_QTN_TIME_USUAL_WITH_ZERO, iCoeEnv );
+        }
+    else
+        {
+        dateFormat = iAvkonStringResourceReader->ReadResourceString( 
+                                            R_QTN_DATE_USUAL_WITH_ZERO );
+        timeFormat = iAvkonStringResourceReader->ReadResourceString( 
+                                            R_QTN_TIME_USUAL_WITH_ZERO );
+        }
+    
+    // format date and time
+    startTime.FormatL( startDateBuf, dateFormat );
+    startTime.FormatL( startTimeBuf, timeFormat );
+    startDateBuf.Append( KSpace );
+    startDateBuf.Append( startTimeBuf );
+
+    // display note with start date
+    DisplayNoteL( R_DRMUTILITY_USAGE_RIGHTS_IN_FUTURE, startDateBuf );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::DisplayNoteL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( TInt aTextResourceId )
+    {
+    if ( iCoeEnv )
+        {
+        HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) );
+        DisplayNoteL( *msgText, aTextResourceId );
+        CleanupStack::PopAndDestroy( msgText );
+        }
+    
+    else
+        {
+        TBuf<KDRMUtilityNoteMaxSize> buffer(
+            iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) );
+
+        DisplayNoteL( buffer, aTextResourceId );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::DisplayNoteL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( 
+    TInt aTextResourceId, 
+    const TDesC& aString )
+    {
+    if ( iCoeEnv )
+        {
+        HBufC* msgText( StringLoader::LoadLC( aTextResourceId, 
+                                              aString,
+                                              iCoeEnv ) );
+        DisplayNoteL( *msgText, aTextResourceId );
+        CleanupStack::PopAndDestroy( msgText );
+        }
+    else
+        {
+        TBuf<KDRMUtilityNoteMaxSize + KMaxFileName> destBuffer;
+
+
+        TBuf<KDRMUtilityNoteMaxSize> buffer(
+            iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) );
+
+
+        StringLoader::Format( destBuffer, buffer, -1, aString );
+        DisplayNoteL( destBuffer, aTextResourceId, aString, -1 );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::DisplayNoteL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( 
+    TInt aTextResourceId, 
+    TInt aValue )
+    {
+    if ( iCoeEnv )
+        {
+        HBufC* msgText( StringLoader::LoadLC( aTextResourceId, 
+                                              aValue,
+                                              iCoeEnv ) );
+        
+        DisplayNoteL( *msgText, aTextResourceId, KNullDesC, aValue );
+        CleanupStack::PopAndDestroy( msgText );
+        }
+    else
+        {
+        TBuf<KDRMUtilityNoteMaxSize + KMaxFileName> destBuffer;
+
+        TBuf<KDRMUtilityNoteMaxSize> buffer(
+            iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) );
+
+
+        StringLoader::Format( destBuffer, buffer, -1, aValue );
+        DisplayNoteL( destBuffer, aTextResourceId, KNullDesC, aValue );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::DisplayNoteL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( 
+    TDesC& aPromptText, 
+    TInt aResourceId, 
+    const TDesC& aString, 
+    TInt aValue )
+    {
+    TPtr bufPtr( NULL, 0 );
+    bufPtr.Set( const_cast <TUint16*>( aPromptText.Ptr() ), 
+                                       aPromptText.Length(), 
+                                       aPromptText.Length() );
+                                       
+    AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+
+    if ( iCoeEnv )
+        {
+        CAknResourceNoteDialog* note( CreateNoteForResourceL( aResourceId ) );
+        PrepareSecondaryDisplayL( *note, aResourceId, aString, aValue );
+        note->ExecuteLD( aPromptText );
+        CancelSecondaryDisplayL( aResourceId );
+        }
+    else
+        {
+        DRM::CDrmUtilityInfoNoteWrapper* note( 
+                                DRM::CDrmUtilityInfoNoteWrapper::NewL() );
+        
+        //a list for simultanous notes
+        User::LeaveIfError( iNoteList.Append( note ) );
+        
+        note->ShowNoteL( GlobalNoteTypeForResource( aResourceId ),
+                         aPromptText, 
+                         aResourceId, 
+                         aString, 
+                         aValue );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::DisplayPopupWindowsForPreviewL
+// -----------------------------------------------------------------------------
+//
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+EXPORT_C TInt DRM::CDrmUtilityUI::DisplayPopupWindowsForPreviewL(
+    ContentAccess::CData& aContent,
+    TInt aPreviewType,
+    TInt aMediaType )
+    {
+    TInt buttonCode( 0 );
+    TInt resourceId( 0 );
+    TInt index( 0 );
+    TInt answer( 0 );
+
+    // if media type is not given, try to get if from MIME type
+    if( aMediaType == DRM::EUPreviewRightsActionDefault ||
+        aMediaType == DRM::EUEmbeddedPreviewActionDefault )
+        {
+        aMediaType = EvaluatePreviewMediaTypeL( aContent, aPreviewType );
+        }
+
+    if ( aPreviewType == ContentAccess::EPreviewRights )
+        {
+        // preview rights for audio
+        if ( aMediaType == DRM::EUPreviewRightsActionDefaultAudio )
+            {
+            resourceId = R_DRMUTILITY_PREV_AUDIO_GET_LIST_QUERY;
+            }
+        // preview rights for video
+        else if ( aMediaType == DRM::EUPreviewRightsActionDefaultVideo )
+            {
+            resourceId = R_DRMUTILITY_PREV_VIDEO_GET_LIST_QUERY;
+            }
+        }
+    else if ( aPreviewType == ContentAccess::EInstantPreview )
+        {
+        // embedded preview for audio
+        if ( aMediaType == DRM::EUEmbeddedPreviewActionDefaultAudio )
+            {
+            resourceId = R_DRMUTILITY_PREV_AUDIO_PLAY_LIST_QUERY;
+            }
+        // embedded preview for video
+        else if ( aMediaType == DRM::EUEmbeddedPreviewActionDefaultVideo )
+            {
+            resourceId = R_DRMUTILITY_PREV_VIDEO_PLAY_LIST_QUERY;
+            }
+        }
+
+    if ( iCoeEnv && resourceId )
+        {
+        CAknListQueryDialog* dlg = new( ELeave ) CAknListQueryDialog( &index );
+
+        PrepareSecondaryDisplayL( *dlg, resourceId );
+        answer = dlg->ExecuteLD( resourceId );
+        CancelSecondaryDisplayL( resourceId );
+        
+        if ( answer )
+            {
+            buttonCode = index + 1;
+            }
+        }
+    else if( resourceId )
+        {
+        DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper(
+            DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) );
+            
+        buttonCode = noteWrapper->ShowPreviewListQueryL( resourceId );
+        
+        CleanupStack::PopAndDestroy( noteWrapper );
+        }
+
+    return buttonCode;
+    }
+    
+#else
+
+EXPORT_C TInt DRM::CDrmUtilityUI::DisplayPopupWindowsForPreviewL(
+    ContentAccess::CData& /*aContent*/,
+    TInt /*aPreviewType*/, 
+    TInt /*aMediaType*/ )
+    {
+    return 0;
+    }
+
+#endif  // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::CreateNoteForResourceL
+// -----------------------------------------------------------------------------
+//
+CAknResourceNoteDialog* DRM::CDrmUtilityUI::CreateNoteForResourceL(
+    TInt aResId )
+    {
+    CAknResourceNoteDialog* resourceDialog( NULL );
+    
+    switch ( aResId )
+        {
+        case R_DRM_ERR_OPENING_FAIL_PERM:
+            
+            resourceDialog = new ( ELeave ) CAknErrorNote( ETrue );
+            
+            break;
+        
+        case R_DRM_WARN_NO_CONN_DEFINED:
+        case R_DRM_WARN_INVALID_OR_NO_AP:
+            
+            resourceDialog = new  ( ELeave ) CAknWarningNote( ETrue );
+            
+            break;
+        
+        default:
+            
+            resourceDialog = new ( ELeave ) CAknInformationNote( ETrue );
+            
+            break;
+        }
+        
+    return resourceDialog;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::GlobalNoteTypeForResource
+// -----------------------------------------------------------------------------
+///  
+TAknGlobalNoteType DRM::CDrmUtilityUI::GlobalNoteTypeForResource( 
+    TInt aResId )
+    {
+    TAknGlobalNoteType noteType( EAknGlobalInformationNote );
+    
+    switch ( aResId )
+        {
+        case R_DRM_ERR_OPENING_FAIL_PERM:
+            
+            noteType = EAknGlobalErrorNote;
+            
+            break;
+        
+        case R_DRM_WARN_NO_CONN_DEFINED:
+        case R_DRM_WARN_INVALID_OR_NO_AP:
+            
+            noteType = EAknGlobalWarningNote;
+            
+            break;
+        
+        default:
+            
+            break;
+        }
+    
+    return noteType;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::GetOmaStartTime
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUtilityUI::GetOmaStartTime( 
+    CDRMConstraint* aConstraint, 
+    TTime& aStartTime)
+    {
+    __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage, 
+                                              KDRMUtilityDebugPanicCode ) );
+    TInt err( KErrNone );
+    
+    // Activated interval is always the same or later than
+    // the start time of the start-end
+    if ( aConstraint->iActiveConstraints & EConstraintInterval &&
+        (aConstraint->iIntervalStart != Time::NullTTime() ) )
+        {
+        aStartTime = aConstraint->iIntervalStart;
+        }    
+    else if ( aConstraint->iActiveConstraints & EConstraintStartTime )
+        {
+        aStartTime = aConstraint->iStartTime;
+        }
+    else
+        {
+        err = KErrCANoPermission;
+        }
+        
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::EvaluatePreviewMediaType
+// -----------------------------------------------------------------------------
+//
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+TInt DRM::CDrmUtilityUI::EvaluatePreviewMediaTypeL( 
+    ContentAccess::CData& aContent,
+    TInt aPreviewType )
+    {    
+    _LIT( KDRMUtilityMimeTypeVideo, "Video" );
+    _LIT( KDRMUtilityMimeTypeRealMedia, "Application/x-pn-realmedia" );
+    _LIT( KDRMUtilityMimeTypeVndRealMedia, "Application/vnd.rn-realmedia" );
+    TInt mediaType( 0 );
+    HBufC* mimeType( HBufC::NewLC( KMaxDataTypeLength ) );
+    TPtr mimePtr( mimeType->Des() );
+    
+    User::LeaveIfError( aContent.GetStringAttribute( ContentAccess::EMimeType, mimePtr ) );
+    
+    if( mimePtr.FindF( KDRMUtilityMimeTypeVideo ) == KErrNotFound &&
+        mimePtr.FindF( KDRMUtilityMimeTypeRealMedia ) == KErrNotFound &&
+        mimePtr.FindF( KDRMUtilityMimeTypeVndRealMedia ) == KErrNotFound )
+        {
+        if ( aPreviewType == ContentAccess::EPreviewRights )
+            {
+            mediaType = DRM::EUPreviewRightsActionDefaultAudio;
+            }
+        else if ( aPreviewType == ContentAccess::EInstantPreview )
+            {
+            mediaType = DRM::EUEmbeddedPreviewActionDefaultAudio;
+            }
+        }
+    else
+        {
+        if ( aPreviewType == ContentAccess::EPreviewRights )
+            {
+            mediaType = DRM::EUPreviewRightsActionDefaultVideo;
+            }
+        else if ( aPreviewType == ContentAccess::EInstantPreview )
+            {
+            mediaType = DRM::EUEmbeddedPreviewActionDefaultVideo;
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( mimeType );
+    return mediaType;
+    }
+    
+#else
+
+TInt DRM::CDrmUtilityUI::EvaluatePreviewMediaTypeL( 
+    ContentAccess::CData& /*aContent*/,
+    TInt /*aPreviewType*/ )
+    {
+    return 0;
+    }
+
+#endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO    
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::PrepareSecondaryDisplayL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityUI::PrepareSecondaryDisplayL( 
+    CEikDialog& aDialog, 
+    TInt aResourceId,
+    const TDesC& aString, 
+    TInt aValue )
+    {
+    // Check if we have cover display and shall we display something
+    if ( !FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ||
+         !DRM::CDrmUtilityInfoNoteWrapper::EvaluateCoverResourceId( 
+                                                                aResourceId ) )
+        {
+        return;
+        }
+    
+    RProcess myProcess;
+    TUid myProcessUid( KNullUid );
+    
+    RThread().Process( myProcess );
+    myProcessUid = myProcess.Identity();
+
+    aDialog.PublishDialogL( aResourceId, KUidCoverUiCategoryDrmUtility );
+
+    // fetch akn utility for mediator support
+    CAknMediatorFacade* covercl( AknMediatorFacade( &aDialog ) );    
+
+    if ( covercl ) // returns null if cover display is not available
+        {
+        // Package dialog data 
+        // <oem/SecondaryDisplay/DrmUtilitySecondaryDisplay.h>
+        TUtilitySDData utilityData;
+
+        // First field is DrmUtility's Uid
+        utilityData.iUtilityUid = KUidCoverUiCategoryDrmUtility;
+        // ProcessId which uses DrmUtility
+        utilityData.iHandlerProcessId = myProcessUid;
+        if ( aString.Compare( KNullDesC ) )
+            {
+            // If there is filename given, it's always in the PrimaryString
+            utilityData.iStringParam.Append( aString );
+            }
+        if ( aValue >= 0 )
+            {
+            // If there is no other than numeric data, put it as NumericString
+            utilityData.iNumParam.AppendNum( aValue );
+            }
+        TUtilitySDDataPckg pckg( utilityData );
+ 
+        covercl->BufStream() << pckg;   // Write the package data
+        covercl->BufStream().CommitL(); // no more data to send so commit buf
+        }          
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityUI::CancelSecondaryDisplayL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityUI::CancelSecondaryDisplayL( TInt aResourceId )
+    {
+    
+    // Check if we have cover display and shall we display something
+    if( !FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ||
+        !DRM::CDrmUtilityInfoNoteWrapper::EvaluateCoverResourceId( 
+                                                                aResourceId ) )
+        {
+        return;
+        }
+        
+    RProcess myProcess;
+    TUid myProcessUid( KNullUid );
+    
+    RThread().Process( myProcess );
+    myProcessUid = myProcess.Identity();
+    
+    TUtilitySDDataCancel cancelData;
+    cancelData.iHandlerProcessId = myProcessUid;
+    cancelData.iNoteId = aResourceId;
+    
+    TPckgBuf<TUtilitySDDataCancel> cancel( cancelData );
+    
+    HBufC8* buf( 
+        HBufC8::NewLC( sizeof( TUtilitySDDataCancel ) + sizeof( TInt ) ) );
+    TPtr8 ptr( buf->Des() );
+    
+    RDesWriteStream stream( ptr );
+    stream << cancel;
+    stream.CommitL();
+    
+    iEventProvider->RaiseEvent( KMediatorSecondaryDisplayDomain,
+                                KUidCoverUiCategoryDrmUtility,
+                                ECover_dialog_cancel,
+                                TVersion( 0, 0, 0 ),
+                                *buf );
+    
+    stream.Close();
+    CleanupStack::PopAndDestroy( buf );
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/drmutilitywmdrm.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,96 @@
+/*
+* 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:  DrmUtilityWMDrm implementation
+*
+*/
+
+
+#include "drmutilitywmdrm.h"
+#include "drmutilitywmdrmwrapper.h"
+
+// CONSTANTS
+_LIT( KDrmUtilityWMDrmWrapperName, "\\system\\libs\\drmutilitywmdrmwrapper.dll" );
+const TInt KGateFunction( 3 );
+
+// ======== MEMBER FUNCTIONS ========
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrm::CDrmUtilityWMDrm
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUtilityWMDrm::CDrmUtilityWMDrm()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrm::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrm::ConstructL( CCoeEnv* aCoeEnv )
+    {
+    User::LeaveIfError( iWMDrmDll.Load( KDrmUtilityWMDrmWrapperName ) );
+    iWMDrmHandler = 
+        (DRM::CDrmUtilityWMDrmWrapper*) iWMDrmDll.Lookup( KGateFunction )();
+        
+    if ( iWMDrmHandler )
+        {
+        iWMDrmHandler->SetCoeEnv( aCoeEnv );
+        }
+        
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrm::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUtilityWMDrm* DRM::CDrmUtilityWMDrm::NewLC( CCoeEnv* aCoeEnv )
+    {
+    DRM::CDrmUtilityWMDrm* self( new( ELeave ) CDrmUtilityWMDrm );
+    CleanupStack::PushL( self );
+    self->ConstructL( aCoeEnv );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrm::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUtilityWMDrm* DRM::CDrmUtilityWMDrm::NewL( CCoeEnv* aCoeEnv )
+    {
+    DRM::CDrmUtilityWMDrm* self( NewLC( aCoeEnv ) );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// Destructor
+DRM::CDrmUtilityWMDrm::~CDrmUtilityWMDrm()
+    {
+    delete iWMDrmHandler;
+    iWMDrmDll.Close();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDrmUtilityWMDrm::GetWrapper()
+// ---------------------------------------------------------------------------
+//
+EXPORT_C DRM::MDrmUtilityWMDrmWrapper* DRM::CDrmUtilityWMDrm::GetWrapper()
+    {
+    return iWMDrmHandler;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/drmutilitywmdrmutilities.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,580 @@
+/*
+* 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:  WM DRM specific methods for DRM Rights Manager
+*
+*/
+
+
+#include <e32std.h>
+#include <DRMRights.h>
+
+#include "drmclockclient.h"
+#include "drmutilitywmdrmutilities.h"
+#include "drmrights.h"
+
+// CONSTANTS
+_LIT( KLicenseType, "licensetype=" );
+_LIT( KTime, "time" );
+_LIT( KCount, "count" );
+_LIT( KDuration, "duration" );
+_LIT( KTimeCount, "time-count" );
+_LIT( KUnlimited, "unlimited" );
+
+_LIT( KDurationLeft, "duration=" );
+_LIT( KCountLeft, "countleft=" );
+_LIT( KStartTime, "starttime=" );
+_LIT( KEndTime, "endtime=" );
+
+const TUint8 KFoundStartTime = 0x01;
+const TUint8 KFoundEndTime = 0x02;
+
+// masks for constraint existence
+const TInt KWmDrmConstraintCount( 1 );
+const TInt KWmDrmConstraintStartTime ( 2 );
+const TInt KWmDrmConstraintEndTime( 4 );
+const TInt KWmDrmConstraintDuration( 8 );
+
+#ifdef _DEBUG
+// debug panic
+_LIT( KWmDrmUtilitiesDebugPanicMessage, "WmDrmUtilitiesDebugPanic" );
+const TInt KWmDrmUtilitiesDebugPanicCode( 2 );
+#endif
+
+// LOCAL FUNCTION PROTOTYPES
+// Parses the given lexicographic representation. Return value indicates
+// whether the given end character of the searched substring was found or not.
+// Special handling is applied for certain separators (e.g. ';', '-')
+LOCAL_C TBool ParseString( TChar aChar, TLex& aLex, TPtrC16& aPtr );
+
+// ================= MEMBER FUNCTIONS =======================
+
+LOCAL_C TBool ParseString( TChar aChar, TLex& aLex, TPtrC16& aPtr )
+    {
+    TBool found( EFalse );
+    aLex.Mark();
+    
+    while ( !aLex.Eos() && found == EFalse )
+        {
+        TChar ch;
+        ch = aLex.Get();
+        if ( ch == aChar )
+            {
+            if ( ch == ';' || ch == '-' || ch == ':' || ch == 'T' || ch == 'Z' )
+                {
+                // Remove char from the token string and read it from the lex.
+                aLex.UnGet();
+                aPtr.Set( aLex.MarkedToken() );
+                aLex.Get();
+                }
+            else 
+                {
+                aPtr.Set( aLex.MarkedToken() );
+                }
+            found = ETrue;
+            }
+        }
+    return found;
+    }
+
+// ----------------------------------------------------------------------------
+// DrmUtilityWmDrmUtilities::ParseWmDrmTimeRightsL
+// ----------------------------------------------------------------------------
+EXPORT_C void DrmUtilityWmDrmUtilities::ParseWmDrmTimeRightsL( TLex& aLex,
+    TTime& aStartTime, TTime& aEndTime )
+    {
+    TPtrC16 token( NULL, 0 );
+    TUint8 times( 0 );
+    TTime localTime( Time::NullTTime() );
+    TTime universalTime( Time::NullTTime() );
+    TTimeIntervalSeconds timeDifference( 0 ); // local time - secure time
+    TInt years, months, days, hours, minutes, secs; 
+    TChar ch;
+    TLex lex;
+    TTime drmTime;
+    TInt timeZone;
+    
+    DRMClock::ESecurityLevel secLevel = DRMClock::KInsecure;
+    
+    // The format of the start and end time strings is the following:
+    // "starttime=yy-mm-ddThh:mins:ssZ
+    // "endtime=yy-mm-ddThh:mins:ssZ
+    // where yy = years, mm = months, dd = days, hh = hours, 
+    // mins = minutes and ss = seconds, "-", "T", ":" and "Z" 
+    // are separators.     
+    while ( !aLex.Eos() && ( aLex.Peek() != 0 ) )
+        {
+        // The next string should be start time, end time or then
+        // it does not exist.
+        ParseString( '=', aLex, token );
+        
+        if ( token.CompareF( KStartTime ) == 0 )
+            {
+            times |= KFoundStartTime;
+            } 
+        else if ( token.CompareF( KEndTime ) == 0 )
+            {
+            times |= KFoundEndTime;
+            }
+        else 
+            {
+            // No start time ("starttime=") or end time ("endtime=")  
+            // string was found -> return   
+            return;
+            }
+               
+        if ( ( times & KFoundStartTime ) || ( times & KFoundEndTime ) )
+            {     
+            // Search for years, months, days, hours, minutes, secs     
+            if ( ParseString( '-', aLex, token ) )
+                {
+                TLex lexYear( token );
+                User::LeaveIfError( lexYear.Val( years ) );
+                }
+            else 
+                {
+                User::Leave( KErrNotFound );    
+                }
+            
+            if ( ParseString( '-', aLex, token ) )
+                {
+                TLex lexMonths( token );
+                User::LeaveIfError( lexMonths.Val( months ) );
+                }
+            else 
+                {
+                User::Leave( KErrNotFound );    
+                }
+            
+            if ( ParseString( 'T', aLex, token ) )
+                {
+                TLex lexDays( token );
+                User::LeaveIfError( lexDays.Val( days ) );
+                }
+            else 
+                {
+                User::Leave( KErrNotFound );    
+                }
+            
+            if( ParseString( ':', aLex, token ) )
+                {
+                TLex lexHours( token );
+                User::LeaveIfError( lexHours.Val( hours ) );
+                }
+            else 
+                {
+                User::Leave( KErrNotFound );
+                }
+            
+            if ( ParseString( ':', aLex, token ) )
+                {
+                TLex lexMinutes( token );
+                User::LeaveIfError( lexMinutes.Val( minutes ) );
+                }
+            else 
+                {
+                User::Leave( KErrNotFound );
+                }
+            
+            if( ParseString( 'Z', aLex, token ) )
+                {
+                TLex lexSeconds( token );
+                User::LeaveIfError( lexSeconds.Val( secs ) );
+                }
+            else 
+                {
+                User::Leave( KErrNotFound );
+                }    
+            
+            ParseString( ';', aLex, token );
+            token.Set( NULL, 0 );
+            
+            TDateTime date( years, (TMonth)( months - 1 ), days - 1, hours, 
+                minutes, secs, 0 );
+            TTime dateTime( date );
+            
+            // Get secure time from DRM clock 
+            RDRMClockClient client;
+            
+            User::LeaveIfError( client.Connect() );
+            client.GetSecureTime( drmTime, timeZone, secLevel );
+            client.Close();
+            
+			localTime.HomeTime();
+			        	
+          	if ( secLevel == DRMClock::KSecure ) 
+          		{
+				// Calculate the difference between local time and secure time
+            	localTime.SecondsFrom( drmTime, timeDifference );
+            	}
+			else 
+				{
+				// Calculate the difference between local and universal time	
+				universalTime.UniversalTime();	
+				localTime.SecondsFrom( universalTime, timeDifference ); 	
+				}
+          	
+			dateTime += timeDifference;
+			               
+            if ( times & KFoundStartTime )
+                {
+                aStartTime = dateTime;
+                times &= ~KFoundStartTime;
+                }
+            else if ( times & KFoundEndTime )
+                {
+                aEndTime = dateTime;
+                times &= ~KFoundEndTime;
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// DrmUtilityWmDrmUtilities::ParseWmDrmCountRightsL
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TBool DrmUtilityWmDrmUtilities::ParseWmDrmCountRightsL( TLex& aLex,
+    TUint32& aCounts )
+    {
+    TPtrC16 token( NULL, 0 );
+    TInt counts( 0 ); 
+    TChar ch;
+    TLex lex;
+        
+    ParseString( '=', aLex, token );
+        
+    if ( token.CompareF( KCountLeft ) == 0 )
+        {
+        ParseString( ';', aLex, token );
+        TLex lexCount( token );
+        User::LeaveIfError( lexCount.Val( counts ) );
+        aCounts = counts;
+        return ETrue;
+        }    
+    else 
+        {
+        // No counts left ("countleft=") string was found.
+        // -> No count information was found, return EFalse
+        return EFalse;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// DrmUtilityWmDrmUtilities::ParseWmDrmDurationRightsL
+// ----------------------------------------------------------------------------
+//
+EXPORT_C TBool DrmUtilityWmDrmUtilities::ParseWmDrmDurationRightsL( TLex& aLex, 
+    TTimeIntervalSeconds& aDuration )
+    {
+    TPtrC16 token( NULL, 0 );
+    TChar ch;
+    TInt duration( 0 );
+        
+    ParseString( '=', aLex, token );
+        
+    if ( token.CompareF( KDurationLeft ) == 0 )
+        {
+        ParseString( ';', aLex, token );
+        TLex lexDuration( token );
+        User::LeaveIfError( lexDuration.Val( duration ) );
+        aDuration = duration;
+        return ETrue;
+        }
+    else 
+        {
+        // No duration left ("durationleft=") string was found.
+        // -> No duration information was found, return EFalse
+        return EFalse;
+        }         
+    }
+
+// ----------------------------------------------------------------------------
+// DrmUtilityWmDrmUtilities::ParseWmDrmStringL
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void DrmUtilityWmDrmUtilities::ParseWmDrmStringL(
+    ContentAccess::CRightsInfo& aRights,
+    CDRMRightsConstraints*& aRightsConstraint )
+    {
+    
+    __ASSERT_DEBUG( !aRightsConstraint, 
+                    User::Panic( KWmDrmUtilitiesDebugPanicMessage,
+                                 KWmDrmUtilitiesDebugPanicCode ) );
+       
+    TChar ch;
+    TTime startTime( Time::NullTTime() );
+    TTime endTime( Time::NullTTime() );
+    TTimeIntervalSeconds duration( 0 );
+    TUint32 counter( 0 );
+    
+    TPtrC16 token( NULL, 0 );
+    
+    // Parse the WM DRM rights string
+    TLex lex( aRights.Description() );
+    
+    // First, find the license type format string ("licensetype=") 
+    ParseString( '=', lex, token );
+    
+    if ( token.CompareF( KLicenseType ) != 0 )
+        {
+        // License type format string was not found  
+        User::Leave( KErrArgument );
+        }
+ 
+    // Peek for the end of string (eos) in case of (licensetype="") 
+    ch = lex.Peek();
+    if ( ch == 0 ) 
+        {
+        return;
+        }
+    
+    // Check the license type
+    ParseString( ';', lex, token );
+    
+    aRightsConstraint = CDRMRightsConstraints::NewL();
+    CleanupStack::PushL( aRightsConstraint );
+    
+    // Check what kind of rights are in question by parsing the string
+    // onward. The possible rights are date time (start time and/or end time),
+    // count, duration, time count (count and/or date time) and unlimited
+    // rights. The substrings for certain rights are further parsed in
+    // specific methods. 
+    if ( token.CompareF( KTime ) == 0 )
+        {
+        ParseWmDrmTimeRightsL( lex, startTime, endTime );
+        if ( Time::NullTTime() != startTime )
+            {
+            aRightsConstraint->SetStartTime( startTime );
+            }
+        if ( Time::NullTTime() != endTime )
+            {
+            aRightsConstraint->SetEndTime( endTime );
+            }
+        }
+    else if ( token.CompareF( KCount ) == 0 )
+        {
+        if ( ParseWmDrmCountRightsL( lex, counter ) )
+            {
+            aRightsConstraint->SetCounters( counter, counter );
+            }
+        }
+    else if ( token.CompareF( KDuration ) == 0 )
+        {
+        if ( ParseWmDrmDurationRightsL( lex, duration ) )
+            {
+            aRightsConstraint->SetInterval( duration );
+            }
+        }
+    else if ( token.CompareF( KTimeCount ) == 0 )
+        {
+        counter = 0;
+        if ( ParseWmDrmCountRightsL( lex, counter ) )
+            {
+            aRightsConstraint->SetCounters( counter, counter );
+            }
+        ParseWmDrmTimeRightsL( lex, startTime, endTime );
+        if ( Time::NullTTime() != startTime )
+            {
+            aRightsConstraint->SetStartTime( startTime );
+            }
+        if ( Time::NullTTime() != endTime )
+            {
+            aRightsConstraint->SetEndTime( endTime );
+            }
+        }
+    else if ( token.CompareF( KUnlimited ) != 0 )
+        {
+        // Unknown license type  
+        User::Leave( KErrArgument );
+        }
+          
+    CleanupStack::Pop( aRightsConstraint );
+        
+    }
+
+// -----------------------------------------------------------------------------
+// DrmUtilityWmDrmUtilities::CheckWmDrmRightsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DrmUtilityWmDrmUtilities::CheckWmDrmRightsL( TBool& aUnconstrained, 
+    TTimeIntervalSeconds& aTime,
+    TInt& aCounts,  
+    ContentAccess::CRightsInfo& aRights )
+    {
+    
+    TChar ch;
+    TPtrC16 token( NULL, 0 );
+    TInt constraints( 0 );
+    TInt error( KErrNone );
+    TTime startTime( Time::NullTTime() );
+    TTime endTime( Time::NullTTime() );
+    TUint32 counter( 0 );
+    TTime now( Time::NullTTime() ); // current time
+    // End time of rights when duration is taken into account.
+    TTime durationEndTime( Time::NullTTime() );
+    TTimeIntervalSeconds secondsLeft( 0 ); // seconds to end of time based rights
+    
+    // Parse WM DRM rights string  
+    TLex lex( aRights.Description() );
+    
+    // First, find the license type format string ("licensetype=") 
+    ParseString( '=', lex, token );
+    
+    if ( token.CompareF( KLicenseType ) != 0 )
+        {
+        // License type format string was not found  
+        User::Leave( KErrArgument );
+        }
+    
+    // Peek for the end of string (Eos) in case of (licensetype="") 
+    ch = lex.Peek();
+    if ( ch == 0 ) 
+        {
+        return;
+        }
+    
+    // Check the license type
+    ParseString( ';', lex, token );
+    
+    // Check what kind of rights are in question by parsing the string
+    // onward. The possible rights are date time (start time and/or end time),
+    // count, duration, time count (count and/or date time) and unlimited
+    // rights. The substrings for certain rights are further parsed in
+    // specific methods. 
+    if ( token.CompareF( KTime ) == 0 )
+        {
+        ParseWmDrmTimeRightsL( lex, startTime, endTime );
+        if ( Time::NullTTime() != startTime )
+            {
+            constraints |= KWmDrmConstraintStartTime;
+            }
+        if ( Time::NullTTime() != endTime )
+            {
+            constraints |= KWmDrmConstraintEndTime;
+            }
+        }
+    else if ( token.CompareF( KCount ) == 0 )
+        {
+        if ( ParseWmDrmCountRightsL( lex, counter ) )
+            {
+            aCounts = counter;
+            constraints |= KWmDrmConstraintCount;
+            }    
+        }
+    else if ( token.CompareF( KDuration ) == 0 )
+        {
+        if ( ParseWmDrmDurationRightsL( lex, aTime ) )
+            {
+            if ( aTime < (TTimeIntervalSeconds)0 )
+                {
+                aTime = 0;
+                }
+            constraints |= KWmDrmConstraintDuration;
+            }
+        }
+    else if ( token.CompareF( KTimeCount ) == 0 )
+        {
+        if ( ParseWmDrmCountRightsL( lex, counter ) )
+            {
+            aCounts = counter;
+            constraints |= KWmDrmConstraintCount;
+            }
+        ParseWmDrmTimeRightsL( lex, startTime, endTime );
+        if ( Time::NullTTime() != startTime )
+            {
+            constraints |= KWmDrmConstraintStartTime;
+            }
+        if ( Time::NullTTime() != endTime )
+            {
+            constraints |= KWmDrmConstraintEndTime;
+            }
+        }        
+    else if ( token.CompareF( KUnlimited ) == 0 ) 
+        {
+        aUnconstrained = ETrue;
+        return;
+        }
+    else 
+        {
+        // Unknown license type
+        User::Leave( KErrArgument );
+        }
+    
+    // Get current time
+    now.HomeTime();
+        
+    // The rights are not constrained
+    if ( !constraints )
+        {
+        aUnconstrained = ETrue;
+        }
+    
+    if ( constraints & KWmDrmConstraintStartTime )
+        {
+        // The start time is in the past or the current time
+        if ( ( now >= startTime ) && 
+            !( constraints & KWmDrmConstraintEndTime ) &&
+            !( constraints & KWmDrmConstraintCount ) )
+            {
+            aUnconstrained = ETrue;
+            }
+        
+        // This use case is unclear and should be specified later.
+        // There are counts for the content, but the start time has
+        // not been reached.    
+        if ( ( constraints & KWmDrmConstraintCount ) &&
+            ( now < startTime ) ) 
+            {
+            aCounts = 0;
+            }               
+        }
+    
+    // Find out the amount of time that the rights have left in
+    // case the rights have end time constraint.
+    if ( constraints & KWmDrmConstraintEndTime )
+        {
+        error = endTime.SecondsFrom( now, secondsLeft );
+        
+        // The difference between current time and the end time does not
+        // fit to 32-bit number, the start time has been reached and there
+        // are no count constraints defined.
+        if ( ( error == KErrOverflow ) && 
+            ( !( constraints & KWmDrmConstraintStartTime ) || 
+            ( now >= startTime ) ) && !( constraints & KWmDrmConstraintCount ) )
+            {
+            aUnconstrained = ETrue;
+            }
+        
+        // End time has not been reached and start time has been reached
+        if ( ( secondsLeft > (TTimeIntervalSeconds)0 ) && ( now >= startTime ) )
+            {
+            aTime = secondsLeft;
+            }
+       
+        // This use case is unclear and should be specified later.
+        // There are counts for the content, but the end time has
+        // been reached.
+        if ( ( constraints & KWmDrmConstraintCount ) &&
+            ( now > endTime ) )
+            {
+            aCounts = 0;
+            }
+        }
+        
+    return;
+    
+    }
+    
+// End of File
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/drmutilitywmdrmwrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,852 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  WM Drm wrapper implementation
+*
+*/
+
+
+// INCLUDE FILES
+
+// launching embedded details view
+#include <aknlaunchappservice.h>
+#include <aiwgenericparam.h>
+#include <apgcli.h>
+#include <apgtask.h>
+#include <w32std.h>
+
+// character conversions
+#include <utf.h>
+#include <f32file.h>
+#include <avkon.hrh>
+
+// access point utils
+#include <centralrepository.h>
+#include <cdblen.h>
+#include <cmconnectionmethod.h>
+#include <cmdestination.h>
+#include <cmconnectionmethoddef.h>
+#include <cmmanager.h>
+#ifdef __SERIES60_NATIVE_BROWSER
+#include <browseruisdkcrkeys.h>
+#endif
+
+#include    <wmdrmagent.h> // for WMDRM file details view
+#include    <drmutilitytypes.h>
+#include    <drmuicheckrightsobserver.h>
+
+// resources
+#include    <drmutility.rsg>
+
+#include    "drmutilitywmdrmwrapper.h"
+#include    "drmutilityui.h"
+
+#include    "drmagents.h"
+#include    "drmclockclient.h"
+
+#include    "drmutilityinternaltypes.h"
+#include    "drmutilitywmdrmutilities.h"
+
+#include    "wmdrmdlawrapper.h"
+
+// CONSTANTS
+const TInt KMaxUrlLength( 1024 );
+const TInt KMaxUrlSanityLength( 102400 );
+
+#ifndef __SERIES60_NATIVE_BROWSER
+const TUid KCRUidBrowser = {0x10008D39};
+const TUint32 KBrowserDefaultAccessPoint = 0x0000000E;
+const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
+#endif
+
+#ifdef _DEBUG
+// debug panic
+_LIT( KWmDrmWrapperDebugPanicMessage, "WmDrmWrapperDebugPanic" );
+const TInt KWmDrmWrapperDebugPanicCode( 1 );
+#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::CDrmUtilityWMDrmWrapper
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CDrmUtilityWMDrmWrapper::CDrmUtilityWMDrmWrapper() :
+    iCoeEnv( NULL ),
+    iDrmUtilityUi( NULL )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::ConstructL()
+    {
+    User::LeaveIfError( iFs.Connect() );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUtilityWMDrmWrapper* DRM::CDrmUtilityWMDrmWrapper::NewL()
+    {
+    DRM::CDrmUtilityWMDrmWrapper* self( NewLC() );
+
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmUtilityWMDrmWrapper* DRM::CDrmUtilityWMDrmWrapper::NewLC()
+    {
+    DRM::CDrmUtilityWMDrmWrapper* self( new( ELeave ) CDrmUtilityWMDrmWrapper );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+
+    return self;
+    }
+
+
+// Destructor
+DRM::CDrmUtilityWMDrmWrapper::~CDrmUtilityWMDrmWrapper()
+    {
+    delete iDrmUtilityUi;
+    delete iDlaWrapper;
+    iDlaWrapperDll.Close();
+    iFs.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::CheckWmRightsAmountL()
+// Syncronous method
+// -----------------------------------------------------------------------------
+//
+
+EXPORT_C void DRM::CDrmUtilityWMDrmWrapper::CheckWmRightsAmountL(
+    ContentAccess::CData& aContent,
+    ContentAccess::TIntent aIntent,
+    DRM::MDrmUiCheckRightsObserver* aObserver,
+    TInt aOperationId )
+    {
+    TInt value( EFalse );
+    HBufC* contentId( HBufC::NewLC( KMaxUrlLength ) ); // 1024
+    TPtr cid( contentId->Des() );
+    TBool unlimited( EFalse );
+    TInt32 reason( 0 );
+    TInt counts( 0 );
+    TTimeIntervalSeconds time( 0 );
+    TTimeIntervalSeconds accumulated( 0 );
+    TInt error( KErrNone );
+
+    // Check intent:
+    switch( aIntent )
+        {
+        case ContentAccess::EPlay:
+        case ContentAccess::EView:
+
+            break;
+
+        default:
+
+            // Intent not supported, leave with argument:
+            User::Leave( KErrArgument );
+
+            break;
+        }
+
+
+    // Ask the rights from CAF, same call for both ECanPlay and ECanView
+    User::LeaveIfError( aContent.GetAttribute( ContentAccess::ECanPlay, value ) );
+
+    // Loop needed to make sure the full path name fits to the cid.
+    // If the size is not enough, increase it in steps of one kB.
+    while ( ( error = aContent.GetStringAttribute( DRM::EDrmFullName, cid ) )
+        == KErrOverflow )
+        {
+        if ( contentId->Size() + KMaxUrlLength > KMaxUrlSanityLength )
+            {
+            // Cid is so big that it can not fit to the 100 kB default max buffer.
+            User::Leave( error );
+            }
+        CleanupStack::Pop( contentId );
+        contentId->ReAllocL( contentId->Size() + KMaxUrlLength );
+        cid.Set( contentId->Des() );
+        CleanupStack::PushL( contentId );
+        }
+
+    if ( error )
+        {
+        User::Leave( error );
+        }
+
+    // Object can be played and rights are in order:
+    if ( value )
+        {
+        // Get the rights data
+        GetRightsDataL(
+            cid,
+            unlimited,
+            time,
+            counts,
+            accumulated );
+
+        // call given CheckRightsObserver
+        // What kind of rights are available:
+        CallRightsLeftL (
+            aObserver,
+            aOperationId,
+            unlimited,
+            time,
+            counts,
+            accumulated,
+            aContent,
+            cid );
+        }
+    else // The rights are not valid at this point always claim they have expired
+        {
+        CallRightsNotValidL(
+            aObserver,
+            aOperationId,
+            EUHCheckRightsExpiredRights,
+            reason,
+            aContent,
+            cid );
+        }
+
+    CleanupStack::PopAndDestroy( contentId );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::HandleWmErrorL()
+// Syncronous method
+// -----------------------------------------------------------------------------
+//
+
+EXPORT_C void DRM::CDrmUtilityWMDrmWrapper::HandleWmErrorL(
+    ContentAccess::CData& aContent,
+    ContentAccess::TIntent /* aIntent */,
+    TInt /* aError */,
+    DRM::MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId )
+    {
+
+    TInt32 reason( 0 );
+    TInt value( EFalse );
+    HBufC* contentId( HBufC::NewLC( KMaxUrlLength ) ); // 1024
+    TPtr cid( contentId->Des() );
+
+    // Check Content Id via CAF
+    User::LeaveIfError( aContent.GetStringAttribute( ContentAccess::EContentId, cid ) );
+
+    // Ask the rights from CAF, same call for both ECanPlay and ECanView
+    User::LeaveIfError( aContent.GetAttribute( ContentAccess::ECanPlay, value ) );
+
+    if ( !value )
+        {
+        ShowNoRightsNoteL( aContent, reason );
+        User::LeaveIfError( aContent.GetAttribute( ContentAccess::ECanPlay, value ) );
+        if ( value )
+            {
+            CallRightsAvailable( aObserver, aOperationId, KErrNone );
+            }
+        else
+            {
+            CallRightsAvailable( aObserver, aOperationId, KErrCANoRights );
+            }
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    CleanupStack::PopAndDestroy( contentId );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::SetCoeEnv()
+// Syncronous method
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmUtilityWMDrmWrapper::SetCoeEnv( CCoeEnv* aCoeEnv )
+    {
+    iCoeEnv = aCoeEnv;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::GetRightsManagerL
+// -----------------------------------------------------------------------------
+//
+ContentAccess::CRightsManager* DRM::CDrmUtilityWMDrmWrapper::GetRightsManagerL()
+    {
+    ContentAccess::CManager* manager( NULL );
+    ContentAccess::CRightsManager* rightsManager( NULL );
+    RArray<ContentAccess::TAgent> agents;
+    TInt agent( 0 );
+
+    CleanupClosePushL( agents );
+    manager = ContentAccess::CManager::NewLC();
+
+    manager->ListAgentsL( agents );
+
+    for ( agent = 0; agent < agents.Count(); agent++ )
+        {
+        if (agents[agent].Name().Compare( KWmDrmAgentName ) == 0)
+            {
+            break;
+            }
+        }
+
+    // If no WM DRM agent is found, leave
+    if( agent >= agents.Count() )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+
+    // Create a CRightsManager for the agent found
+    rightsManager = manager->CreateRightsManagerL( agents[agent] );
+
+    CleanupStack::PopAndDestroy( manager ); // manager
+    CleanupStack::PopAndDestroy( &agents ); // agents
+    return rightsManager;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::GetRightsDataL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::GetRightsDataL(
+    const TDesC& aUniqueId,
+    TBool& aUnconstrained,
+    TTimeIntervalSeconds& aTime,
+    TInt& aCounts,
+    TTimeIntervalSeconds& aAccumulated )
+    {
+    ContentAccess::RStreamablePtrArray<ContentAccess::CRightsInfo> aArray;
+    ContentAccess::CRightsManager* manager( NULL );
+    CleanupClosePushL(aArray);
+
+    aUnconstrained = EFalse;
+    aTime = 0;
+    aCounts = 0;
+    aAccumulated = 0;
+
+    // Create the manager:
+    manager = GetRightsManagerL();
+    CleanupStack::PushL( manager );
+
+    // Get the list of rights:
+    manager->ListRightsL( aArray, aUniqueId );
+
+    // Evaluate the rights:
+    if( aArray.Count() )
+        {
+        for ( TInt i( 0 ); i < aArray.Count(); i++ )
+            {
+            switch( aArray[i]->RightsStatus() )
+                {
+                // All of these the rights don't exist or are expired:
+                case ContentAccess::ERightsStatusNone:
+                case ContentAccess::ERightsStatusExpired:
+                case ContentAccess::ERightsStatusPending:
+
+                    break;
+
+                // the rights are valid:
+                // Check the duration, counts and whether the rights
+                // are unlimited or not
+                case ContentAccess::ERightsStatusValid:
+                    DrmUtilityWmDrmUtilities::CheckWmDrmRightsL( 
+                        aUnconstrained, aTime, aCounts, *aArray[0] );
+                    break;
+                }
+            }
+        }
+    else
+        {
+        User::Leave( KErrCANoRights );
+        }
+
+    CleanupStack::PopAndDestroy( manager );
+    CleanupStack::PopAndDestroy( &aArray ); // aArray
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::CallRightsLeftL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::CallRightsLeftL(
+    DRM::MDrmUiCheckRightsObserver* aObserver,
+    TInt aOperationId,
+    TBool aUnconstrained,
+    TTimeIntervalSeconds aTime,
+    TInt aCounts,
+    TTimeIntervalSeconds aAccumulated,
+    ContentAccess::CData& aContent,
+    const TDesC& aContentUri )
+    {
+    DRM::TCheckRightsAction rightsAction( DRM::EUHCheckRightsActionDefault );
+
+    if ( aObserver )
+        {
+        rightsAction = aObserver->RightsLeft( aOperationId,
+                                              aUnconstrained,
+                                              aTime,
+                                              aCounts,
+                                              aAccumulated );
+        }
+
+    switch ( rightsAction )
+        {
+        case DRM::EUHCheckRightsActionDefault:
+            {
+            // show appropriate notes, none at the moment
+            }
+            break;
+
+        case DRM::EUHCheckRightsActionOpenDetailsView:
+            {
+            // Commented out for now, should do details for WM DRM when supported
+            // create parameter string
+            HBufC* launchParam( NULL );
+            CreateLaunchParamL( &aContentUri, launchParam ); // use zero as localid
+            CleanupStack::PushL( launchParam );
+
+            // show details
+            LaunchRightsManagerUiL( *launchParam );
+            CleanupStack::PopAndDestroy( launchParam );
+            }
+            break;
+
+        case DRM::EUHCheckRightsActionAcquireNewRights:
+            TRAPD( err, LoadDlaWrapperL() );
+            if ( !err )
+                {
+                SilentDlaLicenseAcquisitionL( aContent );
+                }
+            break;
+
+        case DRM::EUHCheckRightsActionIgnore:
+            // do nothing
+            break;
+
+        default:
+            break;
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::CallRightsNotValidL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::CallRightsNotValidL(
+    DRM::MDrmUiCheckRightsObserver* aObserver,
+    TInt aOperationId,
+    DRM::TCheckRightsStatus aRightsStatus,
+    TUint32 aReason,
+    ContentAccess::CData& aContent,
+    const TDesC& aContentUri )
+    {
+    DRM::TCheckRightsAction rightsAction( DRM::EUHCheckRightsActionDefault );
+
+    if ( aObserver )
+        {
+        // call given CheckRightsObserver
+        rightsAction = aObserver->RightsNotValid( aOperationId,
+                                                  aRightsStatus,
+                                                  RejectReason( aReason ) );
+        }
+
+    //rightsAction = DRM::EUHCheckRightsActionDefault;
+
+    switch ( rightsAction )
+        {
+        case DRM::EUHCheckRightsActionDefault:
+            {
+            ShowNoRightsNoteL( aContent, aReason );
+            }
+            break;
+
+        case DRM::EUHCheckRightsActionOpenDetailsView:
+            {
+            // Commented out for now, should do details for WM DRM when supported
+            // create parameter string
+            HBufC* launchParam( NULL );
+            CreateLaunchParamL( &aContentUri, launchParam ); // use zero as localid
+            CleanupStack::PushL( launchParam );
+
+            // show details
+            LaunchRightsManagerUiL( *launchParam );
+            CleanupStack::PopAndDestroy( launchParam );
+            }
+            break;
+
+        case DRM::EUHCheckRightsActionAcquireNewRights:
+            TRAPD( err, LoadDlaWrapperL() );
+            if ( !err )
+                {
+                SilentDlaLicenseAcquisitionL( aContent );
+                }
+            break;
+
+        case DRM::EUHCheckRightsActionIgnore:
+            // do nothing
+            break;
+
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::CallRightsAvailable
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::CallRightsAvailable(
+    DRM::MDrmHandleErrorObserver* aObserver,
+    TInt aOperationId,
+    TInt aError )
+    {
+
+    if ( aObserver )
+        {
+        // call given HandleErrorObserver
+        aObserver->RightsAvailable( aOperationId, aError );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::ShowNoRightsNoteL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::ShowNoRightsNoteL(
+    ContentAccess::CData& aContent,
+    TUint32 /*aReason*/ )
+    {
+    TRAPD( err, LoadDlaWrapperL() );
+    if ( !err )
+        {
+        TInt ret( EAknSoftkeyYes );
+        RFile file;
+        GetRFileFromCDataL( aContent, file );
+        CleanupClosePushL( file );
+        TBool isSilent( EFalse );
+        TRAP( err, isSilent = IsDlaLicenseAcquisitionSilentL( file ) );
+        if ( !err && !isSilent )
+            {
+            if ( !iDrmUtilityUi )
+                {
+                iDrmUtilityUi = DRM::CDrmUtilityUI::NewL( iCoeEnv );
+                }
+            TFileName fileName;
+            User::LeaveIfError( aContent.GetStringAttribute( DRM::EDrmFileName, fileName ) );
+            ret = iDrmUtilityUi->DisplayQueryL( R_DRM_QUERY_EXPIRED_OR_NO_RO, fileName );
+            }
+
+        if ( !err && ( ret == EAknSoftkeyYes || ret == EAknSoftkeyOk ) )
+            {
+            TRAP_IGNORE( DlaLicenseAcquisitionL( file ) );
+            }
+        CleanupStack::PopAndDestroy( &file );
+        }
+    else
+        {
+        if ( !iDrmUtilityUi )
+            {
+            iDrmUtilityUi = DRM::CDrmUtilityUI::NewL( iCoeEnv );
+            }
+        iDrmUtilityUi->DisplayNoteL( R_DRM_INFO_EXPIRED_OR_NO_RO );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::RejectReason
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUtilityWMDrmWrapper::RejectReason(
+    TUint32 /* aReason */ )
+    {
+    TInt ret = DRM::EURejectionNone;
+
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::LaunchRightsManagerUiL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::LaunchRightsManagerUiL(
+    const TDesC& aParam16 )
+    {
+
+    const TUid KUidDRMUI = { 0x101f85c7 };
+
+    if ( iCoeEnv )
+        {
+        CAiwGenericParamList* paramList( CAiwGenericParamList::NewLC() );
+        TAiwVariant variantObject( aParam16 );
+        TAiwGenericParam param( EGenericParamFile, variantObject );
+        paramList->AppendL( param );
+
+        CAknLaunchAppService* launchAppService(
+                                    CAknLaunchAppService::NewL( KUidDRMUI,
+                                                                this,
+                                                                paramList ) );
+        iWait.Start();
+        delete launchAppService;
+        CleanupStack::PopAndDestroy( paramList );
+        }
+    else
+        {
+        // no UI to embed, launch Rights Manager UI stand-alone
+        // check if Rights Manager UI is already running
+        RWsSession wsSession;
+        User::LeaveIfError( wsSession.Connect() );
+        CleanupClosePushL( wsSession );
+        TApaTaskList tasklist( wsSession );
+        TApaTask task( tasklist.FindApp( KUidDRMUI ) );
+        if ( task.Exists() )
+            {
+            // Rights Manager UI is already running
+            HBufC8* param8( HBufC8::NewLC( aParam16.Length() ) );
+            TPtr8 parametersPtr( param8->Des() );
+            parametersPtr.Copy( aParam16 );
+            task.SendMessage( TUid::Uid( KUidApaMessageSwitchOpenFileValue ),
+                                         *param8 );
+            CleanupStack::PopAndDestroy( param8 );
+            }
+        else
+            {
+            RApaLsSession appArcSession;
+            User::LeaveIfError( appArcSession.Connect() );
+            TThreadId id;
+            appArcSession.StartDocument( aParam16, KUidDRMUI, id );
+            appArcSession.Close();
+            }
+        CleanupStack::PopAndDestroy( &wsSession );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::CreateLaunchParamL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::CreateLaunchParamL(
+    const TDesC* aUrl,
+    HBufC*& aLaunchParam )
+    {
+
+    __ASSERT_DEBUG( !aLaunchParam && aUrl,
+                    User::Panic( KWmDrmWrapperDebugPanicMessage,
+                                 KWmDrmWrapperDebugPanicCode ) );
+
+    _LIT( KZero, "0" );
+    _LIT( KSpace, " " );
+
+    TPtr ptr( NULL, 0 );
+
+    // length of startparam and drm protection type indicator and zero local id
+    // are always 1 and total of 3 spaces are needed
+    TInt length( 1 + aUrl->Length() + 1 + 3 + 1 );
+
+    aLaunchParam = HBufC::NewLC( length );
+    ptr.Set( aLaunchParam->Des() );
+
+    // Start parameter is 3 or 4 for launching details view embedded or standalone from
+    // DRM Utility, respectively, with full path name included as a parameter. Values 1
+    // and 2 are for launching details view from DRM Helper.
+    if ( iCoeEnv )
+        {
+        ptr.AppendNum( EDrmLaunchParamEmbeddedUtility );
+        }
+    else
+        {
+        ptr.AppendNum( EDrmLaunchParamStandAloneUtility );
+        }
+    ptr.Append( KSpace );
+    // Default value 0 for localId in case of WM DRM file
+    ptr.Append( KZero );
+    ptr.Append( KSpace );
+    ptr.Append( *aUrl );
+    ptr.Append( KSpace );
+    // WM DRM protection scheme
+    ptr.AppendNum( EDrmSchemeWmDrm );
+
+    CleanupStack::Pop( aLaunchParam );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::HandleServerAppExit
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::HandleServerAppExit( TInt /*aReason*/ )
+    {
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::LoadDlaWrapperL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::LoadDlaWrapperL()
+    {
+    if ( !iDlaWrapper )
+        {
+        User::LeaveIfError( iDlaWrapperDll.Load( KWmDrmDlaWrapperName ) );
+        iDlaWrapper = (CWmDrmDlaWrapper*)iDlaWrapperDll.Lookup( KWmDrmDlaNewL )();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::GetRFileFromCDataL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::GetRFileFromCDataL( 
+    ContentAccess::CData& aContent,
+    RFile& aFile )
+    {
+    TFileName fileName;
+    User::LeaveIfError( aContent.GetStringAttribute( DRM::EDrmFullName, fileName ) );
+    User::LeaveIfError( aFile.Open( iFs, fileName, EFileRead | EFileShareReadersOnly ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::IsDlaLicenseAcquisitionSilentL
+// -----------------------------------------------------------------------------
+//
+TBool DRM::CDrmUtilityWMDrmWrapper::IsDlaLicenseAcquisitionSilentL( 
+    RFile& aFile  )
+    {
+    LoadDlaWrapperL();
+    return iDlaWrapper->SilentL( aFile );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::DlaLicenseAcquisitionL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::DlaLicenseAcquisitionL( 
+    RFile& aFile )
+    {
+    TInt iapId( 0 );
+    HBufC* contentUrl( NULL );
+    HBufC* htmlData( NULL );
+    LoadDlaWrapperL();
+    TRAPD( err, iapId = DefaultAccessPointL() );
+    if ( !err )
+        {
+        iDlaWrapper->SetIapId( iapId );
+        }
+    iDlaWrapper->AcquireLicenseL( aFile, contentUrl, htmlData  );
+    delete contentUrl;
+    delete htmlData;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::SilentDlaLicenseAcquisitionL
+// -----------------------------------------------------------------------------
+//
+void DRM::CDrmUtilityWMDrmWrapper::SilentDlaLicenseAcquisitionL(
+    ContentAccess::CData& aContent )
+    {
+    RFile file;
+    GetRFileFromCDataL( aContent, file );
+    CleanupClosePushL( file );
+    DlaLicenseAcquisitionL( file );
+    CleanupStack::PopAndDestroy( &file );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmUtilityWMDrmWrapper::DefaultAccessPointL
+// -----------------------------------------------------------------------------
+//
+TInt DRM::CDrmUtilityWMDrmWrapper::DefaultAccessPointL()
+    {
+    const TInt KDestinationSelectionMode( 2 );
+    CRepository* repository( NULL );
+    TInt ap( 0 );
+    TInt alwaysAsk( 0 );
+    TUint32 iapd32( 0 );
+    TInt defaultSnap( 0 );
+
+    repository = CRepository::NewL( KCRUidBrowser );
+    CleanupStack::PushL( repository );
+    repository->Get( KBrowserDefaultAccessPoint, ap );
+    repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
+    repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
+    CleanupStack::PopAndDestroy( repository );
+    
+    if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
+        {
+        alwaysAsk = ETrue;
+        }
+    else
+        {
+        RCmManager cmManager;
+        cmManager.OpenLC();
+        if ( !alwaysAsk )
+            {
+            iapd32 = 
+                cmManager.GetConnectionMethodInfoIntL( ap, 
+                                                       CMManager::ECmIapId );
+            }
+        else if ( alwaysAsk == KDestinationSelectionMode )
+            {
+            RCmDestination dest( cmManager.DestinationL( defaultSnap ) );
+            CleanupClosePushL( dest );
+
+            if ( dest.ConnectionMethodCount() <= 0 )
+                {
+                User::Leave( KErrNotFound );
+                }
+
+            RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
+            CleanupClosePushL( cMeth );
+
+            iapd32 = cMeth.GetIntAttributeL( CMManager::ECmIapId );
+            CleanupStack::PopAndDestroy( 2, &dest ); //cMeth, dest
+            }
+        CleanupStack::PopAndDestroy( &cmManager );
+        }
+    if ( alwaysAsk && alwaysAsk != KDestinationSelectionMode )
+        {
+        User::Leave( KErrAccessDenied );
+        }
+    return iapd32;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/drmutility/src/rdrmhelperclient.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,361 @@
+/*
+* 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:  Implementation of the DRMHelperServer Client
+*                session functionality
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32math.h>
+#include "drmhelpercommon.h"
+#include "drmhelperserver.h"
+#include "rdrmhelperclient.h"
+
+// LOCAL CONSTANTS AND MACROS
+
+// Number of message slots to reserve for this client server session.
+// Since we only communicate synchronously here, we never have any
+// outstanding asynchronous requests.
+
+const TUint KDefaultMessageSlots = 0;
+const TUid KServerUid3 = {0x101F6DC5};
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// AutomatedServiceTypeToHs Converts AutomatedUsage service type
+//                           to HelperServer.
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt AutomatedServiceTypeToHs(
+    const DRM::TDrmAutomatedServiceType aServiceType,
+    TInt& aHsServiceType )
+    {
+    if ( aServiceType == DRM::EAUActive )
+        {
+        aHsServiceType = CDRMHelperServer::EActive;
+        return KErrNone;
+        }
+    if ( aServiceType == DRM::EAUPassive )
+        {
+        aHsServiceType = CDRMHelperServer::EPassive;
+        return KErrNone;
+        }
+  return KErrArgument;
+  }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDrmHelperClient::RDrmHelperClient
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+RDrmHelperClient::RDrmHelperClient() : RSessionBase()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmHelperClient::Connect
+//
+// Connect to the server session
+// -----------------------------------------------------------------------------
+//
+TInt RDrmHelperClient::Connect()
+    {
+    TInt error = StartServer();
+
+    if ( !error )
+        {
+        error = CreateSession( KDRMHelperServerName, 
+                               Version(),
+                               KDefaultMessageSlots );
+        }
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmHelperClient::Version
+//
+// return server version
+// -----------------------------------------------------------------------------
+//
+TVersion RDrmHelperClient::Version() const
+    {
+    return ( TVersion( KDRMHSMajorVersionNumber, 
+                       KDRMHSMinorVersionNumber,
+                       KDRMHSBuildVersionNumber ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmHelperClient::SetAutomated
+//
+// Register one content uri to the helper server
+// -----------------------------------------------------------------------------
+//
+TInt RDrmHelperClient::SetAutomated(
+    const TDesC8& aUri,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedServiceType aServiceType ) const
+    {
+    TInt ret( KErrNone );
+    TInt drmHsServiceType( 0 );
+    
+    ret = AutomatedServiceTypeToHs( aServiceType, drmHsServiceType );
+    if ( ret )
+        {
+        return ret;
+        }
+
+    // Create descriptor to enable copying data between
+    // client and server. Note: This can be local since
+    // this is a synchronous call.
+    // Note : Using TPtr8 since this is binary information
+    TPtrC8 descriptor( aUri );
+
+    // This call waits for the server to complete the request before
+    // proceeding.
+    return SendReceive( ERegister, 
+                        TIpcArgs( aIntent, 
+                                  drmHsServiceType, 
+                                  aAutomatedType, 
+                                  &descriptor ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmHelperClient::RemoveAutomated
+//
+// Unregister one content uri
+// -----------------------------------------------------------------------------
+//
+TInt RDrmHelperClient::RemoveAutomated(
+    const TDesC8& aUri,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedServiceType aServiceType ) const
+    {
+    TInt ret( KErrNone );
+    TInt drmHsServiceType( 0 );
+    
+    ret = AutomatedServiceTypeToHs( aServiceType, drmHsServiceType );
+    if( ret )
+        {
+        return ret;
+        }
+    
+    // Create descriptor to enable copying data between
+    // client and server. Note: This can be local since
+    // this is a synchronous call.
+    // Note : Using TPtr8 since this is binary information
+    TPtrC8 descriptor( aUri );
+
+    // This call waits for the server to complete the request before
+    // proceeding.
+    ret = SendReceive( ERemove, 
+                       TIpcArgs( aIntent, 
+                                 drmHsServiceType, 
+                                 aAutomatedType, 
+                                 &descriptor ) );
+
+    if ( ret == KErrNotFound )
+        {
+        // content was never actually registered
+        ret = KErrNone;
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmHelperClient::RemoveAutomatedAll
+//
+// Unregister one content uri
+// -----------------------------------------------------------------------------
+//
+TInt RDrmHelperClient::RemoveAutomatedAll(
+    const TDesC8& aUri,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedServiceType aServiceType ) const
+    {
+    TPtrC8 descriptor( aUri );
+    TInt ret( KErrNone );
+    TInt drmHsServiceType( 0 );
+    
+    ret = AutomatedServiceTypeToHs( aServiceType, drmHsServiceType );
+    if ( ret )
+        {
+        return ret;
+        }
+    
+    TBool automated( EFalse );
+
+    // This call waits for the server to complete the request before
+    // proceeding.
+    ret = SendReceive( ERemove, 
+                       TIpcArgs( aIntent, 
+                                 drmHsServiceType,
+                                 aAutomatedType, 
+                                 &descriptor ) );
+    
+    ret = IsAutomated( aUri, 
+                       aAutomatedType, 
+                       aIntent, 
+                       aServiceType, 
+                       automated );
+                       
+    while ( automated )
+        {
+        // unregister all
+        ret = SendReceive( ERemove, 
+                           TIpcArgs( aIntent, 
+                                     drmHsServiceType, 
+                                     aAutomatedType, 
+                                     &descriptor ) );
+                                     
+        IsAutomated( aUri, aAutomatedType, aIntent, aServiceType, automated );
+        }
+
+    if ( ret == KErrNotFound )
+        {
+        ret = KErrNone;
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmHelperClient::IndicateIdle
+// -----------------------------------------------------------------------------
+//
+TInt RDrmHelperClient::IndicateIdle() const
+    {
+    return SendReceive( EIndicateIdle, TIpcArgs() );
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmHelperClient::IsAutomated
+// -----------------------------------------------------------------------------
+//
+TInt RDrmHelperClient::IsAutomated(
+    const TDesC8& aUri,
+    const DRM::TDrmAutomatedType aAutomatedType,
+    const ContentAccess::TIntent aIntent,
+    const DRM::TDrmAutomatedServiceType aServiceType,
+    TBool& aAutomated ) const
+    {
+    TPtr8 flag( reinterpret_cast< TUint8* >( &aAutomated ), 0, sizeof( TInt ) );
+    TInt ret( KErrNone );
+    TInt drmHsServiceType( 0 );
+    
+    ret = AutomatedServiceTypeToHs( aServiceType, drmHsServiceType );
+    if ( ret )
+        {
+        return ret;
+        }
+    
+    TInt type( CDRMHelperServer::EActive );
+
+    // Create descriptor to enable copying data between
+    // client and server. Note: This can be local since
+    // this is a synchronous call.
+    // Note : Using TPtr8 since this is binary information
+    TPtrC8 descriptor( aUri );
+
+    // This call waits for the server to complete the request before
+    // proceeding.
+    ret = SendReceive( EIsRegistered,
+                       TIpcArgs( aIntent, 
+                                 type, 
+                                 aAutomatedType, 
+                                 &descriptor ) );
+    if ( !ret )
+        {
+        type = CDRMHelperServer::EPassive;
+        
+        ret = SendReceive( EIsRegistered,
+                           TIpcArgs( aIntent, 
+                                     type, 
+                                     aAutomatedType, 
+                                     &descriptor ) );
+        }
+    aAutomated = ret ? ETrue : EFalse;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmHelperClient::StartServer
+// -----------------------------------------------------------------------------
+//
+TInt RDrmHelperClient::StartServer()
+    {
+    TInt result(0);
+
+    TFindServer findHelperServer( KDRMHelperServerName );
+    TFullName name;
+
+    result = findHelperServer.Next( name );
+    if ( !result )
+        {
+        // Server already running
+        return KErrNone;
+        }
+
+    RSemaphore semaphore;
+    result = semaphore.CreateGlobal( KDRMHelperServerSemaphoreName, 0 );
+    if ( result )
+        {
+        return result;
+        }
+
+    result = CreateServerProcess();
+    if ( result )
+        {
+        return result;
+        }
+
+    semaphore.Wait();
+    semaphore.Close();
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmHelperClient::CreateServerProcess
+// -----------------------------------------------------------------------------
+//
+TInt RDrmHelperClient::CreateServerProcess()
+    {
+    TInt result( 0 );
+    const TUidType serverUid( KNullUid, KNullUid, KServerUid3 );
+    
+    RProcess server;
+    result = server.Create( KDRMHSServerFileName, _L(""), serverUid );
+    if ( result )
+        {
+        return result;
+        }
+
+    server.Resume();
+    server.Close();
+
+    return KErrNone;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build file for Common DRM
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../drmrightsmanagerui/conf/drmrightsmanager.confml        MW_LAYER_CONFML(drmrightsmanager.confml)
+../drmrightsmanagerui/conf/drmrightsmanager_102750B1.crml MW_LAYER_CRML(drmrightsmanager_102750B1.crml)
+
+// SIS stub for RightsManagerUI
+../data/DRMRightsManager_stub.SIS /epoc32/data/z/system/install/DRMRightsManager_stub.SIS
+// SIS stub for other commondrm components
+../data/commondrm_stub.SIS /epoc32/data/z/system/install/commondrm_stub.sis
+// loc file of rights manager to loc files folder
+../drmrightsmanagerui/loc/DRMRightsManager.loc   MW_LAYER_LOC_EXPORT_PATH( drmrightsmanager.loc )
+// DRMSettingsPlugin loc file
+../drmsettingsplugin/loc/drmsettingsplugin.loc MW_LAYER_LOC_EXPORT_PATH( drmsettingsplugin.loc )
+
+// IBY files
+../rom/DRMEncryptor.iby                 CORE_MW_LAYER_IBY_EXPORT_PATH( drmencryptor.iby )
+../rom/DRMEncryptorResources.iby        LANGUAGE_MW_LAYER_IBY_EXPORT_PATH( drmencryptorresources.iby )
+../rom/DRMRightsManagerUI.iby           CORE_MW_LAYER_IBY_EXPORT_PATH( drmrightsmanagerui.iby )
+../rom/DRMRightsManagerUIResources.iby  LANGUAGE_MW_LAYER_IBY_EXPORT_PATH( drmrightsmanageruiresources.iby )
+../rom/drmsettingsplugin.iby            CORE_MW_LAYER_IBY_EXPORT_PATH( drmsettingsplugin.iby )
+../rom/drmsettingspluginresources.iby   LANGUAGE_MW_LAYER_IBY_EXPORT_PATH( drmsettingspluginresources.iby )
+../rom/drmutility.iby                   CORE_MW_LAYER_IBY_EXPORT_PATH( drmutility.iby )
+../rom/drmutility_resources.iby         LANGUAGE_MW_LAYER_IBY_EXPORT_PATH( drmutility_resources.iby )
+../rom/drmserviceapiwrapper.iby         CORE_MW_LAYER_IBY_EXPORT_PATH( drmserviceapiwrapper.iby )
+../rom/drmrightsstoringlocation.iby     CORE_MW_LAYER_IBY_EXPORT_PATH( drmrightsstoringlocation.iby )
+
+PRJ_MMPFILES
+
+// DRMEncryptor
+../drmencryptor/group/DRMEncryptor.mmp
+
+// DRMSettingsPlugin
+../drmsettingsplugin/group/drmsettingsplugin.mmp
+
+// DRMRightsManagerUi
+../drmrightsmanagerui/group/DRMRightsManager.mmp
+
+// drmutility
+#if (defined RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM)
+PRJ_MMPFILES
+#include "../drmutility/group/bld.inf"
+#endif // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM
+
+PRJ_MMPFILES
+#include "../drmserviceapiwrapper/group/bld.inf"
+
+PRJ_MMPFILES
+#include "../drmrightsstoringlocation/group/bld.inf"
+
+PRJ_MMPFILES
+// Help exports
+#include "../drmrightsmanagerui/help/group/bld.inf"
+
+// Testfiles
+PRJ_TESTMMPFILES
+
+
+PRJ_EXTENSIONS
+
+START EXTENSION s60/mifconv
+OPTION TARGETFILE drmencryptor.mif
+OPTION HEADERFILE drmencryptor.mbg
+OPTION SOURCES -c8,8 qgn_menu_DRMEncryptor_cxt -c8 icon
+OPTION SOURCEDIR ../drmencryptor/group
+END
+
+START EXTENSION s60/mifconv
+OPTION TARGETFILE drmencryptor_aif.mif
+OPTION SOURCES -c8,8 qgn_menu_drmencryptor -c8 icon
+OPTION SOURCEDIR ../drmencryptor/group
+END
+
+START EXTENSION s60/mifconv
+OPTION TARGETFILE drmrightsmanager.mif
+OPTION HEADERFILE drmrightsmanager.mbg
+OPTION SOURCES \
+              -c16,8 qgn_prop_drm_rights_valid -c16,8 qgn_prop_drm_rights_exp \
+              -c16,8 qgn_prop_drm_rights_group -c16,8 qgn_prop_drm_valid_large \
+              -c16,8 qgn_prop_drm_exp_large -c16,8 qgn_prop_drm_removed_large \
+              -c16,8 qgn_prop_drm_rights_valid_tab3 -c16,8 qgn_prop_drm_rights_invalid_tab3 \
+              -c16,8 qgn_prop_drm_removed_tab3
+END
+
+START EXTENSION s60/mifconv
+OPTION TARGETFILE drmrightsmanager_aif.mif
+OPTION SOURCES -c8,8 qgn_menu_drm
+END
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/rom/DRMEncryptor.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file
+*
+*/
+
+
+#ifndef __DRMENCRYPTOR_IBY__
+#define __DRMENCRYPTOR_IBY__
+
+#include <data_caging_paths_for_iby.hrh>
+#ifndef _IMAGE_TYPE_PRD
+
+S60_APP_EXE(DRMENCRYPTOR)
+
+
+SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,DRMEncryptor)
+
+
+S60_APP_AIF_ICONS(DRMENCRYPTOR)
+S60_APP_AIF_RSC(DRMENCRYPTOR)
+
+data=DATAZ_\APP_RESOURCE_DIR\drmencryptor.rsc         APP_RESOURCE_DIR\drmencryptor.rsc
+
+#endif //_IMAGE_TYPE_PRD
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/rom/DRMEncryptorResources.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file
+*
+*/
+
+
+#ifndef __DRMENCRYPTOR_RESOURCES_IBY__
+#define __DRMENCRYPTOR_RESOURCES_IBY__
+
+#ifndef _IMAGE_TYPE_PRD
+
+//resource exports here
+
+#endif //_IMAGE_TYPE_PRD
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/rom/DRMRightsManagerUI.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  IBY file
+*
+*/
+
+
+#ifndef __DRMRIGHTSMANAGERUI_IBY__
+#define __DRMRIGHTSMANAGERUI_IBY__
+
+// DRM Rights Manager Application
+
+#ifdef __DRM_FULL
+
+S60_APP_EXE(DRMRightsManager)
+S60_APP_BITMAP(DRMRightsManager)
+S60_APP_AIF_ICONS(DRMRightsManager)
+
+data=\epoc32\data\z\private\10003a3f\apps\DRMRightsManager_reg.rsc	\private\10003a3f\import\apps\DRMRightsManager_reg.rsc
+data=ZSYSTEM\install\DRMRightsManager_stub.SIS             \system\install\DRMRightsManager_stub.SIS
+
+#endif	// __DRM_FULL
+
+
+#endif	// __DRMRIGHTSMANAGERUI_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/rom/DRMRightsManagerUIResources.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,30 @@
+/*
+* 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:  IBY file
+*
+*/
+
+
+#ifndef __DRMRIGHTSMANAGERUIRESOURCES_IBY__
+#define __DRMRIGHTSMANAGERUIRESOURCES_IBY__
+
+
+#ifdef __DRM_FULL
+
+S60_APP_RESOURCE(DRMRightsManager)
+
+#endif	// __DRM_FULL
+
+
+#endif	// __DRMRIGHTSMANAGERUIRESOURCES_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/rom/drmrightsstoringlocation.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project drmrightsstoringlocation
+*
+*/
+
+
+#ifndef DRMRIGHTSSTORINGLOCATION_IBY
+#define DRMRIGHTSSTORINGLOCATION_IBY
+
+#include <data_caging_paths_for_iby.hrh>
+
+file=ABI_DIR\BUILD_DIR\drmrightsstoringlocation.dll      SHARED_LIB_DIR\drmrightsstoringlocation.dll
+
+#endif // DRMRIGHTSSTORINGLOCATION_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/rom/drmserviceapiwrapper.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file
+*
+*/
+
+
+#ifndef __DRMSERVICEAPIWRAPPER_IBY__
+#define __DRMSERVICEAPIWRAPPER_IBY__
+
+#include <data_caging_paths_for_iby.hrh>
+#ifdef __DRM_CLOCK
+
+file=ABI_DIR\BUILD_DIR\drmserviceapiwrapper.dll                    SHARED_LIB_DIR\drmserviceapiwrapper.dll
+
+#endif //__DRM_CLOCK
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/rom/drmsettingsplugin.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRMSettingsPlugin ROM resources
+*
+*/
+
+#ifndef DRMSETTINGSPLUGIN_IBY
+#define DRMSETTINGSPLUGIN_IBY
+
+ECOM_PLUGIN( drmsettingsplugin.dll, 102750CC.rsc )
+//data=DATAZ_\BITMAP_DIR\drmsettingsplugin.mif BITMAP_DIR\drmsettingsplugin.mif
+
+data=ZSYSTEM\install\commondrm_stub.SIS             \system\install\commondrm_stub.SIS
+#endif // DRMSETTINGSPLUGIN_IBY
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/rom/drmsettingspluginresources.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,24 @@
+/*
+* 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:  DRMSettingsPlugin ROM resources.
+*
+*/
+
+#ifndef DRMSETTINGSPLUGINRESOURCES_IBY
+#define DRMSETTINGSPLUGINRESOURCES_IBY
+
+data=DATAZ_\RESOURCE_FILES_DIR\drmsettingspluginrsc.rsc RESOURCE_FILES_DIR\drmsettingspluginrsc.rsc
+
+#endif // DRMSETTINGSPLUGINRESOURCES_IBY
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/rom/drmutility.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project DrmUtility
+*
+*/
+
+
+#ifndef DRMUTILITY_IBY
+#define DRMUTILITY_IBY
+
+#include <data_caging_paths_for_iby.hrh>
+
+#ifdef RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM
+
+file=ABI_DIR\BUILD_DIR\DRMUtility.dll                    SHARED_LIB_DIR\DRMUtility.dll
+
+file=ABI_DIR\BUILD_DIR\drmutilitycommon.dll              SHARED_LIB_DIR\drmutilitycommon.dll
+
+#ifdef __WINDOWS_MEDIA_DRM
+file=ABI_DIR\BUILD_DIR\drmutilitywmdrmwrapper.dll        SHARED_LIB_DIR\drmutilitywmdrmwrapper.dll
+#endif // __WINDOWS_MEDIA_DRM
+
+file=ABI_DIR\BUILD_DIR\DrmUtilityDmgrWrapper.dll         SHARED_LIB_DIR\DrmUtilityDmgrWrapper.dll
+
+file=ABI_DIR\BUILD_DIR\DrmRightsInfo.dll                 SHARED_LIB_DIR\DrmRightsInfo.dll
+file=ABI_DIR\BUILD_DIR\DrmRightsInfoImpl.dll             SHARED_LIB_DIR\DrmRightsInfoImpl.dll
+
+file=ABI_DIR\BUILD_DIR\DRMUiHandling.dll                 SHARED_LIB_DIR\DRMUiHandling.dll
+file=ABI_DIR\BUILD_DIR\DRMUiHandlingImpl.dll             SHARED_LIB_DIR\DRMUiHandlingImpl.dll
+
+file=ABI_DIR\BUILD_DIR\DRMAutomatedUsage.dll             SHARED_LIB_DIR\DRMAutomatedUsage.dll
+file=ABI_DIR\BUILD_DIR\DRMAutomatedUsageImpl.dll         SHARED_LIB_DIR\DRMAutomatedUsageImpl.dll
+
+#endif // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM
+
+#endif // DRMUTILITY_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/commondrm/rom/drmutility_resources.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2007-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Image description file for project DrmUtility_Resources
+*
+*/
+
+
+#ifndef DRMUTILITY_RESOURCES_IBY
+#define DRMUTILITY_RESOURCES_IBY
+
+#include <data_caging_paths_for_iby.hrh>
+
+#ifdef RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM
+
+data=DATAZ_\RESOURCE_FILES_DIR\DrmUtility.rsc                RESOURCE_FILES_DIR\DrmUtility.rsc
+data=DATAZ_\RESOURCE_FILES_DIR\DrmUtilityDmgrWrapper.rsc        RESOURCE_FILES_DIR\DrmUtilityDmgrWrapper.rsc
+
+#endif // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM
+
+#endif // DRMUTILITY_RESOURCES_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_framework_api/camese_framework_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,14 @@
+<?xml version="1.0" ?>
+<api id="bd75b8cdec8227a98d287e7dcb2a3ff1" dataversion="1.0">
+<name>camese framework api</name>
+<description>WMDRM DLA framework plugin interfaces</description>
+<type>c++</type>
+<subsystem>WMDRM</subsystem>
+<libs><lib name="wmdrmdla.lib"/>
+</libs>
+<release category="domain" sinceversion="5.1"/>
+<attributes>
+<htmldocprovided>yes</htmldocprovided>
+<adaptation>no</adaptation>
+</attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_framework_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to Camese Framework API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../inc/wmdrmdlatypes.h                      MW_LAYER_PLATFORM_EXPORT_PATH( wmdrmdlatypes.h )
+../inc/wmdrmdlacancelobserver.h             MW_LAYER_PLATFORM_EXPORT_PATH( wmdrmdlacancelobserver.h )
+../inc/wmdrmdlauinotifier.h                 MW_LAYER_PLATFORM_EXPORT_PATH( wmdrmdlauinotifier.h )
+../inc/wmdrmdlahttpplugin.h                 MW_LAYER_PLATFORM_EXPORT_PATH( wmdrmdlahttpplugin.h )
+../inc/wmdrmdlahttpplugin.inl               MW_LAYER_PLATFORM_EXPORT_PATH( wmdrmdlahttpplugin.inl )
+../inc/wmdrmdlauiplugin.h                   MW_LAYER_PLATFORM_EXPORT_PATH( wmdrmdlauiplugin.h )
+../inc/wmdrmdlauiplugin.inl                 MW_LAYER_PLATFORM_EXPORT_PATH( wmdrmdlauiplugin.inl )
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_framework_api/inc/wmdrmdlacancelobserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,38 @@
+/*
+* 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:  Interface class for the WMDRM DLA cancel observer
+*
+*/
+
+
+#ifndef M_WMDRMDLACANCELOBSERVER_H
+#define M_WMDRMDLACANCELOBSERVER_H
+
+#include <e32base.h>
+
+/**
+* MWmDrmDlaCancelObserver
+* Cancellation observer for UI plugin to inform framework
+* if user has cancelled DLA progress from UI component
+*/
+class MWmDrmDlaCancelObserver
+    {
+    
+    public:
+        
+        virtual void UserCancellation() = 0;
+        
+    };
+
+#endif // M_WMDRMDLACANCELOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_framework_api/inc/wmdrmdlahttpplugin.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,301 @@
+/*
+* 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:  Pure virtual interface for WMDRM DLA plugins
+*
+*/
+
+
+#ifndef C_WMDRMDLAHTTPPLUGINIF_H
+#define C_WMDRMDLAHTTPPLUGINIF_H
+
+#include <e32base.h>
+#include <f32file.h>
+
+class CWmDrmDlaUiNotifier;
+class CGulIcon;
+
+/**
+ *  Interface which all WMDRM DLA HTTP Plugins have to implement
+ *
+ *  @since S60 v9.1
+ */
+class CWmDrmDlaHttpPluginIf : public CBase
+    {
+
+public:
+
+    // Instantiates an object of this type 
+    inline static CWmDrmDlaHttpPluginIf* NewL( TUid aUid );
+
+    // Destructor.
+    inline virtual ~CWmDrmDlaHttpPluginIf();
+
+    /**
+     * Get service icon to be used in service selection query, if
+     * more than one service is recognized to support content.
+     * Will be deleted by the caller.
+     *
+     * @return Service icon or NULL
+     */
+    virtual CGulIcon* ServiceIcon() = 0;
+    
+    /**
+     * Check if file is supported by this plugin
+     *
+     * @param aFile WMDRM file
+     * @param aUiNotifer If file is supported, contains initialized UI Notifier
+     *                   upon completion. Will be deleted by the caller after 
+     *                   the plugin has been deleted.
+     * @return ETrue if file is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+     virtual TBool SupportedFileL( const RFile& aFile, 
+                                   CWmDrmDlaUiNotifier*& aUiNotifier ) = 0;
+
+    /**
+     * Check if DRM Header is supported by this plugin
+     *
+     * @param aHeader DRM Header
+     * @param aUiNotifer If headr is supported, contains initialized UI Notifier
+     *                   upon completion. Will be deleted by the caller after 
+     *                   the plugin has been deleted.
+     * @return ETrue if header is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    virtual TBool SupportedDrmHeaderL( const TDesC8& aHeader, 
+                                       CWmDrmDlaUiNotifier*& aUiNotifier ) = 0;
+
+    /**
+     * Check if metering certificate is supported by this plugin
+     *
+     * @param aCertificate Metering certificate
+     * @param aUiNotifer If certificate is supported, contains initialized 
+     *                   UI Notifier upon completion. Will be deleted by the
+     *                   caller after the plugin has been deleted.
+     * @return ETrue if certificate is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    virtual TBool SupportedMeteringCertificateL( 
+                                    const TDesC8& aCertificate, 
+                                    CWmDrmDlaUiNotifier*& aUiNotifier ) = 0;
+
+    /**
+     * Check if initiator is supported by this plugin
+     * This method is called only for playready content
+     * 
+     * @param aInitiator Initiator
+     * @param aUiNotifer If initiator is supported, contains initialized 
+     *                   UI Notifier upon completion. Will be deleted by
+     *                   the caller after the plugin has been deleted.
+     * @return ETrue if initiator is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    virtual TBool SupportedInitiatorL( const TDesC8& aInitiator, 
+                                       CWmDrmDlaUiNotifier*& aUiNotifier ) = 0;
+
+    /**
+     * Check if license acquisition should be silent for this file
+     *
+     * @param aFile WMDRM file
+     * @return ETrue if file is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    virtual TBool SilentL( const RFile& aFile ) = 0;
+
+    /**
+     * Process DRM Header. This method is used only to pass DRM Header to the
+     * plugin. The framework does not require the plugin to do anything 
+     *
+     * @param aDrmHeader DRM Header
+     * @leave with standard Symbian error code in case of fatal error (the 
+     * framework does not proceed with license acquisition if this method
+     * leaves)
+     */
+    virtual void ProcessDrmHeaderL( const TDesC8& aDrmHeader ) = 0;
+
+    /**
+     * Process the initiator. This method is used only to pass initiator to the
+     * plugin. The framework does not require the plugin to do anything. 
+     * This method is called only for playready content
+     *
+     * @param aInitiator Initiator
+     * @leave with standard Symbian error code in case of fatal error (the 
+     * framework does not proceed with license acquisition if this method
+     * leaves)
+     */
+    virtual void ProcessInitiatorL( const TDesC8& aInitiator ) = 0;
+
+    /**
+     * Acquire License. 
+     *
+     * @param aLicenseChallenge License challenge based on which license will
+     *                          be acquired.
+     * @param aLicenseServerUrl URL where license challenge is sent
+     * @param aStatus Request status, will contain error code upon completion 
+     * including but not limited to:
+     * - KErrCancel if user cancelled the license acquisition at any point
+     * - KErrCommsBreak if network connection was lost during communication 
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    virtual void AcquireLicense( const TDesC8& aLicenseChallenge, 
+                                 HBufC* aLicenseServerUrl, 
+                                 TRequestStatus& aStatus ) = 0;
+
+    /**
+     * Get downloaded License. 
+     *
+     * @leave standard Symbian error code in case of error.
+     * @return Buffer containing license data. Will be deleted by the caller.
+     */
+    virtual HBufC8* GetLicenseResponseL() = 0;
+
+    /**
+     * Send license storage status. 
+     *
+     * @param aTid Transaction ID parsed from the license response, can be NULL
+     * @param aUrl URL where license storage status is sent
+     * @param aError License storage status.
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    virtual void SendLicenseStorageStatus( HBufC8* aTid, const TDesC& aUrl, 
+                                           TInt aError, 
+                                           TRequestStatus& aStatus ) = 0;
+
+    /**
+     * Send error code to server if drm header parsing failed.
+     *
+     * @param   aErrorUrl   URL where error code is sent
+     * @param   aError      Error code
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    virtual void SendDrmHeaderError( const TDesC& aErrorUrl, TInt aError,
+                                     TRequestStatus& aStatus ) = 0;
+
+    /**
+     * Get content url. Called only if framework fails to parse content URL 
+     * from the license response. Needs to be implemented only if the supported
+     * service uses non-standard way to pass the Content URL, otherwise this
+     * can return NULL.
+     *
+     * @return Content URL, can be NULL. Will be deleted by the caller.
+     */
+    virtual HBufC* GetContentUrlL() = 0;
+
+    /**
+     * Get HTML data returned by license server. 
+     *
+     * @return HTML data, can be NULL. Will be deleted by the caller.
+     */
+    virtual HBufC* GetHtmlDataL() = 0;
+
+    /*
+     * Cancel license acquisition
+     */
+    virtual void CancelLicenseAcquisition() = 0;
+    
+    /**
+     * Process metering challenge. 
+     *
+     * @param aMeteringChallenge Metering challenge
+     * @param aUrl Url to be used in metering request
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                   with server
+     * - KErrGeneral if unspecified error happened
+     */
+    virtual void ProcessMeteringChallenge( const TDesC8& aMeteringChallenge, 
+                                           const TDesC& aUrl, 
+                                           TRequestStatus& aStatus ) = 0;
+
+    /**
+     * Get metering response. 
+     *
+     * @param aResponse Contains metering response upon completion. Will be
+     *                  deleted by the caller.
+     * @param aStatus Request status, will contain error code upon completion
+     */
+    virtual void GetMeteringResponse( HBufC8*& aResponse, 
+                                      TRequestStatus& aStatus ) = 0;
+
+    /**
+     * Inform plugin that metering finished. 
+     *
+     */
+    virtual void MeteringFinished() = 0;
+    
+    /*
+     * Cancel metering
+     */
+    virtual void CancelMetering() = 0;
+
+    /*
+     * Process join domain challenge.
+     * This method is called only for playready content
+     *
+     * @param aJoinDomainChallenge Join domain challenge
+     * @param aUrl Url to be used in join domain request
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    virtual void ProcessJoinDomainChallenge( 
+        const TDesC8& aJoinDomainChallenge, 
+        const TDesC& aUrl, 
+        TRequestStatus& aStatus ) = 0;
+
+    /*
+     * Process leave domain challenge.
+     * This method is called only for playready content
+     *
+     * @param aLeaveDomainChallenge Leave domain challenge
+     * @param aUrl Url to be used in leave domain request
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    virtual void ProcessLeaveDomainChallenge( 
+        const TDesC8& aLeaveDomainChallenge, 
+        const TDesC& aUrl, 
+        TRequestStatus& aStatus ) = 0;
+
+    /**
+     * Sets the IAP to be used in the HTTP transactions
+     *
+     * @param   aIapId  Internet Access Point id
+     */
+    virtual void SetIapId( TInt aIapId ) = 0;
+    
+private: // data
+
+    TUid iDlaHttpPluginUid;
+
+    };
+
+#include <wmdrmdlahttpplugin.inl>
+
+#endif // C_WMDRMDLAHTTPPLUGINIF_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_framework_api/inc/wmdrmdlahttpplugin.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation for HTTP plugins ECOM structure
+*
+*/
+
+
+#include <ecom/ecom.h>
+#include <wmdrmdlahttpplugin.h>
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpPluginIf::NewL(
+// ---------------------------------------------------------------------------
+//
+inline CWmDrmDlaHttpPluginIf* CWmDrmDlaHttpPluginIf::NewL( TUid aUid )
+    {
+    return static_cast<CWmDrmDlaHttpPluginIf*>( 
+        REComSession::CreateImplementationL( aUid, 
+                                             _FOFF( CWmDrmDlaHttpPluginIf, 
+                                                    iDlaHttpPluginUid ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpPluginIf::~CWmDrmDlaHttpPluginIf
+// ---------------------------------------------------------------------------
+//
+inline CWmDrmDlaHttpPluginIf::~CWmDrmDlaHttpPluginIf()
+    {
+    REComSession::DestroyedImplementation( iDlaHttpPluginUid );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_framework_api/inc/wmdrmdlatypes.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  common type definitions needed by multiple classes
+*
+*/
+
+
+#ifndef C_WMDRMDLATYPES_H
+#define C_WMDRMDLATYPES_H
+
+#include <e32base.h>
+
+/** ECOM interface UIDs */
+const TUid KWmDrmDlaHttpPluginIfUid = { 0x20019544 };
+const TUid KWmDrmDlaUiPluginIfUid = { 0x20019545  };
+
+/** plugin specific progress states can start after this */ 
+const TInt KWmDrmDlaCustomLicenseAcquisitionStateBase = 32;
+
+/**  States for progress information */
+enum
+    {
+    EIdle = 0,
+    EProcessingDRMHeader,            
+    ERetrievingLicense,
+    EProcessingLicense,
+    EAddingLicense,
+    ESendingLicenseStorageStatus,
+    ELicensingComplete,
+    EInvisibleRedirection,
+    ESendingDrmHeaderStatus,
+    EProcessingMeteringChallenge,
+    EProcessingJoinDomainChallenge,
+    EProcessingLeaveDomainChallenge
+    };
+
+
+#endif // C_WMDRMDLATYPES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_framework_api/inc/wmdrmdlauinotifier.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface to send notifications from http plugin ui plugin
+*
+*/
+
+
+#ifndef C_WMDRMDLAUINOTIFIER_H
+#define C_WMDRMDLAUINOTIFIER_H
+
+#include <e32base.h>
+
+class MWmDrmDlaCancelObserver;
+class CWmDrmDlaUiNotifierImpl;
+
+/**
+ *  WMDRM DLA UiNotifier
+ *
+ *  @lib wmdrmdla.lib
+ *  @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaUiNotifier ) : public CBase
+    {
+
+public:
+
+    IMPORT_C static CWmDrmDlaUiNotifier* NewL();
+    IMPORT_C static CWmDrmDlaUiNotifier* NewLC();    
+
+    /**
+    * Destructor.
+    */
+    virtual ~CWmDrmDlaUiNotifier();
+
+    /**
+     * Selects UI plugin based on UID
+     *
+     * @param aUid Uid of the plugin implementation
+     * @leave KErrNotFound if corresponding plugin is not found
+     */
+    IMPORT_C void InitializeL( TUid aUid );
+
+    /**
+     * Selects UI plugin based on data
+     * If corresponding plugin is not be found, tries to initialize default
+     * plugin
+     *
+     * @param aOpaqueData Opaque data of the plugin implementation
+     * @leave KErrNotFound if corresponding and default plugin is not found
+     */
+    IMPORT_C void InitializeL( TDesC8& aOpaqueData );
+
+    /**
+     * Called by the framework to set cancel observer. UI plugin can use this
+     * to inform framework about user cancelling DLA process from UI component.
+     * 
+     * @param aObserver Cancellation observer
+     */
+    IMPORT_C void SetCancelObserver( MWmDrmDlaCancelObserver* aObserver );
+    
+    /**
+     * Informs that license acquisition is silent
+     *
+     * @param aSilent Is license acquisition silent
+     */
+    IMPORT_C void SetSilent( TBool aSilent );
+
+    /**
+     * Passes progress information to UI plugin
+     *
+     * @param aState License acquisition progress state
+     * @see wmdrmdlatypes.h
+     */
+    IMPORT_C void SetProgress( TInt aState );
+
+    /**
+     * Informs that error happened during the license acquisition
+     *
+     * @param aError Error code
+     */
+    IMPORT_C void HandleErrorL( TInt aError );
+
+protected:
+
+private:
+
+    CWmDrmDlaUiNotifier();
+
+    void ConstructL();
+
+private: // data
+
+    /**
+     * Implementation class
+     * Own.
+     */
+    CWmDrmDlaUiNotifierImpl* iImpl;
+
+    };
+
+#endif // C_WMDRMDLAUINOTIFIER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_framework_api/inc/wmdrmdlauiplugin.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,86 @@
+/*
+* 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:  Interface for UI plugins
+*
+*/
+
+
+#ifndef C_WMDRMDLAUIPLUGINIF_H
+#define C_WMDRMDLAUIPLUGINIF_H
+
+#include <e32base.h>
+
+class MWmDrmDlaCancelObserver;
+
+/**
+ *  Interface which all WMDRM DLA UI Plugins have to implement
+ *
+ *  @since S60 v9.1
+ */
+class CWmDrmDlaUiPluginIf : public CBase
+    {
+
+public:
+
+    // Instantiates an object of this type 
+    inline static CWmDrmDlaUiPluginIf* NewL( TUid aUid );
+
+    // Destructor.
+    inline virtual ~CWmDrmDlaUiPluginIf();
+
+    /**
+     * Called by the framework to set cancel observer. UI plugin can use
+     * observer to inform framework about user cancelling DLA process from
+     * UI component.
+     * 
+     * @param aObserver Cancellation observer
+     */
+    virtual void SetCancelObserver( MWmDrmDlaCancelObserver* aObserver ) = 0;
+    
+    /**
+     * Called to inform UI plugin if the license acquisition is silent
+     *
+     * @param aSilent ETrue if license acquisition should be silent
+     */
+    virtual void SetSilent( TBool aSilent ) = 0;
+
+    /**
+     * Called to inform UI plugin about the progress
+     *
+     * @param aState License acquisition progress state
+     * @see wmdrmdlatypes.h
+     */
+    virtual void SetProgress( TInt aState ) = 0;
+
+    /**
+     * Informs that error happened during the license acquisition.
+     * If HandleErrorL leaves with KErrNotSupported the framework handles the
+     * error code.
+     * If HandleErrorL leaves with any other standard Symbian error code than
+     * KErrNotSupported the framework handles the leave code.
+     *
+     * @param aError Error code
+     * @leave KErrNotSupported if plugin does not handle the error code
+     */
+    virtual void HandleErrorL( TInt aError ) = 0;
+
+private: // data
+
+    TUid iDlaUiPluginUid;
+
+    };
+
+#include <wmdrmdlauiplugin.inl>
+
+#endif // C_WMDRMDLAUIPLUGINIF_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_framework_api/inc/wmdrmdlauiplugin.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* 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:  Implementation for UI plugins ECOM structure
+*
+*/
+
+
+#include <ecom/ecom.h>
+#include <wmdrmdlauiplugin.h>
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiPluginIf::NewL
+// ---------------------------------------------------------------------------
+//
+inline CWmDrmDlaUiPluginIf* CWmDrmDlaUiPluginIf::NewL( TUid aUid )
+    {
+    return static_cast<CWmDrmDlaUiPluginIf*>( 
+        REComSession::CreateImplementationL( aUid, 
+                                             _FOFF( CWmDrmDlaUiPluginIf, 
+                                                    iDlaUiPluginUid ) ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiPluginIf::~CWmDrmDlaUiPluginIf
+// ---------------------------------------------------------------------------
+//
+inline CWmDrmDlaUiPluginIf::~CWmDrmDlaUiPluginIf()
+    {
+    REComSession::DestroyedImplementation( iDlaUiPluginUid );
+    }
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_utility_api/camese_utility_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,15 @@
+<?xml version="1.0" ?>
+<api id="8a97bbf60f3cdcfecfa8cddef25281ac" dataversion="1.0">
+    <name>Camese Utility API</name>
+    <description>WMDRM DLA API</description>
+    <type>c++</type>
+    <subsystem>WMDRM</subsystem>
+    <libs>
+        <lib name="cameseutility.lib"/>
+    </libs>
+    <release category="domain" sinceversion="5.0"/>
+    <attributes>
+        <htmldocprovided>no</htmldocprovided>
+        <adaptation>no</adaptation>
+    </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_utility_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* 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:  File that exports the files belonging to Camese Utility API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/cameseutility.h      MW_LAYER_PLATFORM_EXPORT_PATH(cameseutility.h)
+../inc/cameseobserver.h     MW_LAYER_PLATFORM_EXPORT_PATH(cameseobserver.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_utility_api/inc/CameseObserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,59 @@
+/*
+* Copyright (c) 2006-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:  Defines the observer interface for the CameseUtility library
+*
+*/
+
+
+#ifndef CAMESEOBSERVER_H
+#define CAMESEOBSERVER_H
+
+/**
+* MCameseObserver
+*  Notification interface used by the Camese Utility to report progress.
+*
+*  @lib CameseUtility.dll
+*  @since 5.0
+*/
+class MCameseObserver
+    {
+    public:
+        enum TLicenseAcquisitionState
+            {
+            EIdle = 0,
+            ESendingContentStorageStatus,
+            ERetrievingDRMHeaderFromFileHandle,
+            EProcessingDRMHeader,            
+            ERetrievingChallenge,
+            ERetrievingChallengeFromFileHandle,
+            ERetrievingLicense,
+            EProcessingLicense,
+            EAddingLicense,
+            ESendingLicenseStorageStatus,
+            ELicensingComplete,
+            EInvisibleRedirection,
+            ESendingDrmHeaderStatus
+            };
+
+    public:
+        /**
+         * Progress notification generated by the Camese Utility.
+         * @param aState Current state of the license acquisition process.
+         */
+        virtual void OnLicenseAcquisitionProgress(TLicenseAcquisitionState aState) = 0;
+    };
+
+#endif  // CAMESEOBSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/camese_utility_api/inc/CameseUtility.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,163 @@
+/*
+* Copyright (c) 2006-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:  Defines the entry point for the CameseUtility library.
+*
+*/
+
+
+#ifndef CAMESEUTILITY_H
+#define CAMESEUTILITY_H
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class CCameseEngine;
+class RConnection;
+class RFile;
+class MCameseObserver;
+
+/**
+* CCameseUtility
+*  Interface published by the Camese Utility library.
+*
+*  @lib CameseUtility.dll
+*  @since 5.0
+*/
+NONSHARABLE_CLASS( CCameseUtility ) : public CBase
+    {
+    public:
+        /**
+         * Creates an new instance for license acquisition.
+         * @param aObserver Observer interface to be notified on license 
+         * acquisition states. If NULL then no notifications will be supplied 
+         * (when handling the download result for example)
+         * @return address of an instance of this class
+         */
+        IMPORT_C static CCameseUtility* NewL( MCameseObserver* aObserver = NULL );
+
+
+        /**
+         * Creates an new instance for license acquisition.
+         * @param aIapNumber a IAP connection to use for communications.
+         * @param aObserver Observer interface to be notified on license 
+         * acquisition states. If NULL then no notifications will be supplied 
+         * (when handling the download result for example)
+         * @return address of an instance of this class
+         */
+        IMPORT_C static CCameseUtility* NewL( TInt aIapNumber, 
+            MCameseObserver* aObserver = NULL );
+
+
+        /** 
+         * Creates an new instance for license acquisition.
+         * @param aSockServHandle a socket server handle. If 0 a new socket 
+         * server connection is created
+         * @param aConnPtr a connection to use for communications. If NULL 
+         * a new connection is created
+         * @param aObserver Observer interface to be notified on license 
+         * acquisition states. If NULL then no notifications will be supplied 
+         * (when handling the download result for example)
+         * @return address of an instance of this class
+         */
+        IMPORT_C static CCameseUtility* NewL( TInt aSockServHandle,
+            RConnection* aConnPtr, MCameseObserver* aObserver = NULL );
+
+
+        /**
+         * Destructor
+         */
+        IMPORT_C virtual ~CCameseUtility();
+
+
+        /**
+         * Starts the license acquisition based on a specified DRM header.
+         * @param aDrmHeader DRM header to use for license acquisition
+         * @param aUrl Heap descriptor to populate with the content URL. 
+         * Can be NULL.
+         * @param aStatus Request status. On completion contains the error code
+         */
+        IMPORT_C void AcquireLicense( const TDesC8& aDrmHeader, HBufC8*& aUrl, 
+            TRequestStatus& aStatus );
+
+
+        /**
+         * Starts the license acquisition based on a specified file handle.
+         * @param aFileHandle a handle to the file for which the license is 
+         * acquired.
+         * @param aUrl Heap descriptor to populate with the Music Shop URL for 
+         * non-silent acquisition or an error page. Can be NULL.
+         * @param aStatus Request status. On completion contains the error code.
+         */
+        IMPORT_C void AcquireLicense( const RFile& aFileHandle, HBufC8*& aUrl, 
+            TRequestStatus& aStatus );
+
+
+        /**
+         * Starts the license acquisition based on a specified file path.
+         * @param aFileHandle a file handle to use for non-silent license 
+         * acquisition
+         * @param aLicenseResponse The license response sent by the license 
+         * server in a non-silent post-delivery scenerio
+         * @param aStatus Request status. On completion contains the error code.
+         */
+        IMPORT_C void AcquireLicense( const RFile& aFileHandle, 
+            const TDesC8& aLicenseResponse, TRequestStatus& aStatus );
+
+
+        /**
+         * Sending the download result.
+         * @param aContentUrl The URL to the Content Server where status 
+         * should be reported.
+         * @param aResult Symbian error code indicating the result of the 
+         * content download operation
+         * This will be converted to an HRESULT value before being sent to the 
+         * Content Server.
+         * @param aStatus Request status. On completion contains the error code.
+         */
+        IMPORT_C void SendDownloadResult(const TDesC8& aContentUrl, TInt aResult, 
+            TRequestStatus& aStatus);
+
+
+        /**
+         * Cancels an existing asynchronous call.
+         */
+        IMPORT_C void Cancel();
+
+
+        /**
+         * Sets the IAP connection to use for communications.
+         * @param aIapId The IAP connection that will be used
+         */
+        IMPORT_C void SetIapId( TInt aIapId );
+
+    private:
+        /**
+         * Constructor
+         */
+        CCameseUtility();
+
+
+        /**
+         * Symbian OS 2nd phase constructor.
+         */
+        void ConstructL( TInt aIapNumber, MCameseObserver* aObserver );
+
+    private:
+        CCameseEngine* iEngine;
+    };
+
+#endif  // CAMESEUTILITY_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/dcf_repository_api/dcf_repository_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="7ef7309b014a80bb32284c6941556225" dataversion="1.0">
+  <name>DCF Repository API</name>
+  <description>An API for accessing services provided by DCF Repository Server. Can be used e.g. for getting a list of the device's DCFs,</description>
+  <type>c++</type>
+  <subsystem>omadrm</subsystem>
+  <libs>
+    <lib name="DcfRep.lib" />
+  </libs>
+  <release category="domain"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/dcf_repository_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,29 @@
+/*
+* 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:  File that exports the files belonging to 
+:                DCF Repository API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/DcfEntry.h     MW_LAYER_PLATFORM_EXPORT_PATH(DcfEntry.h)
+../inc/DcfRep.h     MW_LAYER_PLATFORM_EXPORT_PATH(DcfRep.h)
+../inc/DcfRepCli.h     MW_LAYER_PLATFORM_EXPORT_PATH(DcfRepCli.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/dcf_repository_api/inc/DcfEntry.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,155 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client side implementation
+*
+*/
+
+
+
+#ifndef CDCFENTRY_H
+#define CDCFENTRY_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  CDcfEntry
+*  Client of DCF Repository
+*
+*  @lib ?library
+*  @since Series 60 3.0
+*/
+class CDcfEntry : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CDcfEntry* NewL();
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CDcfEntry();
+
+    public: // New functions
+        
+        /**
+        * SetCidL
+        * @since Series 60 3.0
+        * @param aCid content ID
+        * @return 
+        */        
+        IMPORT_C void SetCidL(const TDesC8& aCid);
+
+
+        /**
+        * SetGroupIdL
+        * @since Series 60 3.0
+        * @param aGroup Id group ID
+        * @return 
+        */        
+        IMPORT_C void SetGroupIdL(const TDesC8& aGroupId);        
+        
+        /**
+        * SetLocationL
+        * @since Series 60 3.0
+        * @param aFile filename of the DCF and 
+        * @param position inside the file
+        * @return 
+        */        
+        IMPORT_C void SetLocationL(const TDesC& aFile, const TUint16& aPos);
+        
+        /**
+        * FileName
+        * @since Series 60 3.0
+        * @param 
+        * @return file name
+        */        
+        IMPORT_C const TDesC16& FileName() const;
+        
+        /**
+        * Position
+        * @since Series 60 3.0
+        * @param 
+        * @return position inside a file
+        */        
+        IMPORT_C TUint16 Position() const;
+
+        /**
+        * Cid
+        * @since Series 60 3.0
+        * @param 
+        * @return content ID
+        */        
+        IMPORT_C const TDesC8& Cid() const;
+        
+        /**
+        * GroupId
+        * @since Series 60 3.0
+        * @param 
+        * @return group ID
+        */        
+        IMPORT_C const TDesC8& GroupId() const;
+        
+
+    public: // Functions from base classes
+    protected:  // New functions
+    protected:  // Functions from base classes
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDcfEntry();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        CDcfEntry( const CDcfEntry& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CDcfEntry& operator=( const CDcfEntry& );
+
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+        HBufC8* iCid;
+        HBufC* iFileName;
+        TUint16 iPosition;
+        HBufC8* iGroupId;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+#endif      // CDCFENTRY_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/dcf_repository_api/inc/DcfRep.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,247 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client side implementation
+*
+*/
+
+
+
+#ifndef CDCFREP_H
+#define CDCFREP_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include <D32DBMS.H>
+#include "dcfrepcli.h"
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CDcfEntry;
+// CLASS DECLARATION
+
+/**
+*  CDcfRep
+*  Client of DCF Repository
+*
+*  @lib ?library
+*  @since Series 60 3.0
+*/
+class CDcfRep : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CDcfRep* NewL();
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CDcfRep();
+
+    public: // New functions
+        
+        /**
+        * UpdateL 
+        * the function will add the entry into database. 
+        * in 3.0 file info will be added 
+        * @since Series 60 3.0
+        * @param aEntry protected file entry to database, either filename or content ID field shall be filled,
+        *           if filename is filled, the file is added into DCF DB and also rights DB, domain RO is added into the file
+                    if content ID is filled, domain RO are added into all files(registered in DCF DB) that are linked with this content ID 
+        *           if both are filled, then content ID is ignored.
+                    if none is filled, then KErrArgument is returned
+        *   server will obtain other info from the file or DCF DB.
+        * @Leave with KErrNotSupported if file is not protected file 
+        */
+        IMPORT_C void UpdateL( const CDcfEntry* aEntry);
+        
+
+        /**
+        * GetFileHandleL 
+        * The function get file info from database and return read-only file handle back
+        * @since Series 60 3.0
+        * @param aCid a content ID
+        * @param aFile a file handle
+        * @param aFs file server session that is connected with server.
+        * @return function will leave with KErrNotFound if the content ID is not found in database or 
+        *   info is out of date, and will leave with KErrAccessDenied if caller doesnt have access to
+        *   the file.
+        */
+        IMPORT_C void GetFileHandleL( const TDesC8& aCid , RFile& aFile , RFs& aFs );        
+
+        /**
+        * NextL 
+        * After a list is ordered, the function will return entries as iteration.
+        * Caller must call OrderListL before calling this function.
+        * @since Series 60 3.0
+        * @return DCF entry from database, NULL if no entry left.
+        */
+        IMPORT_C CDcfEntry* NextL();   
+        
+        /**
+        * GetTtidL 
+        * The function will go through database to get transaction IDs for every specific CID
+        * @since Series 60 3.0
+        * @param aList contain content IDs and transaction ID will be filled afterwards
+            TPair.iCid must be filled by user. TPair.iTtid must be NULL
+        * @return TPair.iTtid will be filled if corresponding info is found in database.
+            caller owns TPair.iCid and TPair.iTtid. 
+        */
+        IMPORT_C void GetTtidL( RArray<TPair>& aList );
+        
+        
+        /**
+        * OrderListL 
+        * Order all entries from DB, NextL will be used after this function call in order to get entries.
+        * @since Series 60 3.0
+        * @Leave with KErrNotFound if there is no entries
+        */
+        IMPORT_C void OrderListL(void);
+         
+        /**
+        * OrderListL 
+        * Order all entries with specific CID from DB, 
+        * if the CID cannot be found as a CID then DB will search for it as a Group ID 
+        * NextL will be used after this function call in order to get entries.
+        * @since Series 60 3.0
+        * @param aCid a content ID
+        * @Leave with KErrNotFound if there is no entries for the CID
+        */
+        IMPORT_C void OrderListL(const TDesC8& aCid); 
+        
+
+        /**
+        * RemoveDcfFromDbL 
+        *
+        * the function will remove all the entries that have the filename in database.
+        * @since Series 60 3.0
+        * @param aFileName file name of Dcf to be removed
+        * @return 
+        */
+        IMPORT_C void RemoveDcfFromDbL( const TDesC& aFileName );
+
+        /**
+        * RefreshDcf 
+        * the function will refresh the DCF list for both OMA 1 and OMA 2(.odf) DCFs
+        * and save it into DB. 
+        * Note. if CDcfRep is destructed, the status will not be completed afterwards even server becomes idle.
+        * @since Series 60 3.0
+        * @param aStatus a status for this request
+        * @return 
+        */
+        IMPORT_C void RefreshDcf( TRequestStatus& aStatus );
+
+
+        /**
+        * RefreshDcf 
+        * the function will refresh the DCF list for both OMA 1 and OMA 2(.odf) DCFs
+        * and save it into DB. the function will complete when every single Cid has found at least one 
+        * corresponding DCFs in the file system
+        * Note. if CDcfRep is destructed, the status will not be completed afterwards even server becomes idle.
+        * @since Series 60 3.0
+        * @param aList contain content IDs which info need to be refreshed 
+        * @param aStatus a status for this request
+        * @return 
+        */
+        IMPORT_C void RefreshDcf( RPointerArray<HBufC8>& aList , TRequestStatus& aStatus );
+       
+        /**
+        * SetTtid 
+        * the function will scan whole file system, whenever a .odf with a specifed CID is found, server
+        * will reset the TTID for the .odf with the value in TPair.iTtid and also update info in database. 
+        * Note. if CDcfRep is destructed, the status will not be completed afterwards even server becomes idle.
+        * @since Series 60 3.0
+        * @param aList a list of CID and TTID pairs, Caller owns TPair.iCid and TPair.iTtid.
+        *        CID and TTID must be filled by caller, no default value is given. 
+        * @param aStatus a status for this request
+        * @param aRefresh ETrue by default, EFalse is not supported in this version
+        * @return 
+        */
+        IMPORT_C void SetTtid( 
+            RArray<TPair>& aList,
+            TRequestStatus& aStatus, 
+            TBool aRefresh = ETrue);   
+
+        /**
+        * NotifyServerIdle 
+        * the function will complete the status when DCF Repository server becomes idle
+        * if the server is in ilde status right now, then the status will get completed right now.
+        * Note. if CDcfRep is destructed, the status will not be completed afterwards even server becomes idle.
+        * @since Series 60 3.0
+        * @param aStatus a status for this request
+        * @return 
+        */            
+        IMPORT_C void NotifyServerIdle( TRequestStatus& aStatus );       
+                
+    public: // Functions from base classes
+    protected:  // New functions
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDcfRep();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        /**
+        * Open database
+        */
+        void OpenDatabaseL(); 
+
+        // Prohibit copy constructor if not deriving from CBase.
+        CDcfRep( const CDcfRep& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CDcfRep& operator=( const CDcfRep& );
+        
+        void GetTtidL(const TDesC8& aCid , HBufC8*& aTtid);
+        
+        TInt SetName(const TDesC8& aCid , const TDesC16& aName);
+        
+        void GetFilenameL(const TDesC8& aCid , RPointerArray<HBufC>& aList);
+        
+        void GetCidL(const TDesC16& aName , RPointerArray<HBufC8>& aList);
+  
+        void DoGetFileHandleL( const TDesC8& aCid , RFile& aFile , RFs& aFs ); 
+      
+    public:     // Data
+        RDcfRepCli iClient;  
+        RDbs iDbs;
+        RDbNamedDatabase iDb;
+        RDbView iView;
+    
+    protected:  // Data
+    private:    // Data
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+    };
+
+#endif      // CDCFREP_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/dcf_repository_api/inc/DcfRepCli.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,174 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client side implementation
+*
+*/
+
+
+
+#ifndef RDCFREPCLI_H
+#define RDCFREPCLI_H
+
+//  INCLUDES
+#include <e32base.h>
+// CONSTANTS
+// MACROS
+// DATA TYPES
+typedef struct TPair // interface structure
+    {
+    HBufC8* iCid; // Caller owns it, initial value must be given (for example: NULL)
+    HBufC8* iTtid; // Caller owns it, initial value must be given (for example: NULL)
+    }TPair;
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class RFile;
+
+
+// CLASS DECLARATION
+
+/**
+*  RDcfRepCli
+*  Client of DCF Repository
+*
+*  @lib 
+*  @since Series 60 3.0
+*/
+class RDcfRepCli : public RSessionBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * C++ default constructor.
+        */
+        IMPORT_C RDcfRepCli();
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~RDcfRepCli();
+
+    public: // New functions
+        
+        
+        /**
+        * AddFile
+        * The function add a file into dababase. server will check file info and add them into database
+        * @since Series 60 3.0 
+        * @param aFile filename
+        * @return KErrNotSupported if file is not protected file
+        */
+        IMPORT_C TInt AddFile(const TDesC& aFile);
+        
+        /**
+        * Connect
+        * The function try to connect DcfRepSrv server.
+        * @since Series 60 3.0 
+        * @param 
+        * @return errors if failed to connect to server 
+        */
+        IMPORT_C TInt Connect();
+        
+        
+        /**
+        * Close
+        * This function closes the connection between the client and the server.
+        * It is safe to call this method even if connection is not established.
+        * @since Series 60 3.0 
+        * @param 
+        * @return errors if failed to connect to server 
+        */
+        IMPORT_C void Close();    
+     
+          
+        /**
+        * Version 
+        * Server version
+        * @since Series 60 3.0
+        * @param 
+        * @return version of server
+        */        
+        IMPORT_C TVersion Version() const;
+
+        /**
+        * ScanDcf
+        * This function will triger the file scanning on the server side for all DCFs
+        * @since Series 60 3.0 
+        * @param aStatus status of this request
+        * @return 
+        */
+        IMPORT_C void ScanDcf(TRequestStatus& aStatus);
+        
+        /**
+        * ScanDcf
+        * The function will scan Dcfs for a list of content ID, 
+        * when all content ID are paired with at least one file, scanning get stopped.
+        * @since Series 60 3.0 
+        * @param aList a list of content ID
+        * @param aStatus status of this request
+        * @return 
+        */
+        IMPORT_C void ScanDcf(  
+            RPointerArray<HBufC8>& aList , 
+            TRequestStatus& aStatus );
+                
+        /**
+        * SetTtid
+        * This function is an asynchronous call. It goes through whole file system 
+        * to replace old Ttid pairs(transaction ID and dcf)
+        * @since Series 60 3.0 
+        * @param aStatus status of this request
+        * @return 
+        */
+        IMPORT_C void SetTtid( 
+            RArray<TPair>& aList , 
+            TRequestStatus& aStatus 
+            );                
+        
+        /**
+        * NotifyServerIdle
+        * This function will notify when server becomes idle
+        * @since Series 60 3.0 
+        * @param aStatus status of this request
+        * @return 
+        */            
+        IMPORT_C void NotifyServerIdle( TRequestStatus& aStatus );
+
+        /**
+        * StopWatching
+        * Tell the server to stop watching the rights server
+        * @since Series 60 3.1
+        */
+        IMPORT_C void StopWatching();
+        
+    public: // Functions from base classes
+    protected:  // New functions
+    protected:  // Functions from base classes
+    private:
+
+        // Prohibit copy constructor if not deriving from CBase.
+        RDcfRepCli( const RDcfRepCli& );
+        // Prohibit assigment operator if not deriving from CBase.
+        RDcfRepCli& operator=( const RDcfRepCli& );
+
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+    };
+
+#endif      // RDCFREPCLI_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_agents_api/drm_agents_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="50c80ef91596711627063e8158cb892e" dataversion="1.0">
+  <name>DRM Agents API</name>
+  <description>Contains agent specific data types, commands and attributes that are common DRM agents</description>
+  <type>c++</type>
+  <subsystem>commondrm</subsystem>
+  <libs>
+  </libs>
+  <release category="domain"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>no</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_agents_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,24 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for DRM Agents API
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../inc/drmagents.h  MW_LAYER_PLATFORM_EXPORT_PATH(drmagents.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_agents_api/inc/drmagents.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,181 @@
+/*
+* 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:  Contains agent specific data types, commands
+*                and attributes that are common DRM agents
+*
+*/
+
+
+#ifndef DRMAGENTS_H
+#define DRMAGENTS_H
+
+#include <caf/caftypes.h>
+
+namespace DRM 
+{
+
+/**
+* OMA DRM CAF Agent name
+*/
+_LIT(KDrmOmaAgentName, "OMA DRM Agent");
+
+/**
+* WMDRM CAF Agent name
+*/
+_LIT(KDrmWMAgentName, "WM DRM Agent");
+
+/**
+* Common attributes for DRM CAF Agents
+*/
+enum TDrmAgentAttribute
+    {
+    EDrmFileType = ContentAccess::EAgentSpecificAttributeBase + ContentAccess::EAgentSpecificAttributeBase + 1,
+    EDrmAgentUid,
+    EDrmAllowedOutputs
+    };
+
+/**
+* Common string attributes for DRM CAF Agents
+*/
+enum TDrmAgentStringAttribute
+    {
+    EDrmAgentName = ContentAccess::EAgentSpecificAttributeBase + ContentAccess::EAgentSpecificAttributeBase + 1,
+    EDrmFileName,
+    EDrmOriginalArtist,
+    EDrmRatingInfo,
+    EDrmTrackNumber,
+    EDrmRecordingYear,
+    EDrmFullName
+    };
+
+/**
+* DRM protection type of the file
+*/
+enum TDrmFileType
+    {
+    EDrmNone             = 0,    ///< No DRM
+    EDrmOma1Dcf          = 1,    ///< OMA DRM v1
+    EDrmOma2Dcf          = 2,    ///< OMA DRM v2
+    EDrmWMFile           = 3,    ///< WMDRM
+    EDrmOma1DcfBased     = 4     ///< OMA DRM v1 DCF based format with extensions
+    };
+
+/**
+* DRM CAF Agent UIDs
+*/
+enum TDrmAgentUid
+    {
+    EDrmOmaAgent    = 0x101F6DB4,   ///< OMA DRM CAF Agent UID
+    EDrmWmAgent     = 0x10205CB6,   ///< WMDRM CAF Agent UID
+    };
+
+/**
+* Allowed outputs for the content. The values below are used as bitmasks and
+* can be combined to allow multiple allowed outputs. Note that not all possible
+* outputs are listed here. The outputs will be added once their impact to the
+* adpatation layer and their compliance rule impact is understood. Only
+* outputs which have been analysed before are listed here.
+*/
+enum TDrmAllowedOutputs
+    {
+    /**
+    * Allow all audio and video outputs
+    */
+    EDrmAllowAll                = 0xFFFFFFFF,
+    
+    /**
+    * Allow none of the outputs
+    */
+    EDrmAllowNone               = 0x00000000,
+    
+    /**
+    * Allow analog audio output via line out or the built-in speaker
+    */
+    EDrmAllowAudioAnalog        = 0x00000001,
+    
+    /**
+    * Allow playback via an analog radio transmitter broadcasting device,
+    * commonly called FM Transmitter
+    */
+    EDrmAllowAudioFmTransmitter = 0x00000002,
+    
+    /**
+    * Allow playback via a mono Bluetooth link using the Handset or
+    * Handsfree Profiles (HSP, HFP), or using an A2DP profile, but in neither
+    * case playing back with more than 48kHz sample rate, 16 bits sample width,
+    * 2 channels and a playback speed of 1.5 times the original speed
+    */
+    EDrmAllowAudioBluetooth     = 0x00000004,
+    
+    /**
+    * Allow mixing the audio stream upwards into other audio playback streams,
+    * e.g. into a phone call
+    */
+    EDrmAllowAudioUplink        = 0x00000008,
+    
+    /**
+    * Allow output of the video signal to an analog video output device,
+    * e.g. S-Video
+    */
+    EDrmAllowVideoAnalog        = 0x00000010,
+    
+    /**
+    * Allow video output over an anlog output channel which has MacroVision
+    * video protection
+    */
+    EDrmAllowVideoMacroVision   = 0x00000020,
+    
+    /**
+    * Allow audio output via USB
+    */
+    EDrmAllowAudioUsb           = 0x00000040,
+    
+    /**
+    * Allow audio output to devices using HDCP, e.g. DVD players and HDTV.
+    */
+    EDrmAllowAudioHdcp              = 0x00000080,
+    
+    /**
+    * Licensed product is required to engage HDCP to protect the audio.
+    * If HDCP is not engaged or can't be engaged the audio must not be passed through to HDMI.
+    */
+    EDrmAllowAudioHdmiHdcpRequired  = 0x00000080,
+    
+    /**
+    * Allow audio output to devices using HDMI, e.g. DVD players and HDTV.
+    */
+    EDrmAllowAudioHdmi              = 0x00000100,
+
+    /**
+    * Allow the passing the video data to devices using HDMI, eg DVD players and HDTV
+    */
+    EDrmAllowVideoHDMI              = 0x00000200,
+            
+    /**
+    * Licensed product must attempt to engage HDCP to protect the video. 
+    * However it should be passed through to HDMI even if HDCP is not engaged or fails to engage.
+    */
+    EDrmAllowVideoHdmiHdcpRequested = 0x00000400,
+
+        
+    /**
+    * Licensed product is required to engage HDCP to protect the video.
+    * If HDCP is not engaged or can not be engaged the video must not be passed through to HDMI.
+    */
+    EDrmAllowVideoHdmiHdcpRequired  = 0x00000800
+
+    };
+}
+
+#endif // DRMAGENTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/drm_common_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="d800b0a7e0bef93074308dda17745235" dataversion="1.0">
+  <name>DRM Common API</name>
+  <description>DRM utility functions (inspecting content files, checking rights)</description>
+  <type>c++</type>
+  <subsystem>omadrm</subsystem>
+  <libs>
+    <lib name="DRMCommon.lib" />
+  </libs>
+  <release category="domain" deprecatedsince="2.8"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* 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:  File that exports the files belonging to 
+:                DRM Common API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/DRMCommon.h     MW_LAYER_PLATFORM_EXPORT_PATH(DRMCommon.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/inc/DRMCommon.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,682 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of class DRMCommon for accessing common
+*                DRM functions
+*
+*/
+
+
+#ifndef DRMCOMMON_H
+#define DRMCOMMON_H
+
+#include <e32base.h>
+#include <DrmRights.h>
+#include <caf/caf.h>
+
+const TUint KDrmMaxContentInfoSize = 512;
+
+// FORWARD DECLARATIONS
+class TDataType;
+
+// CLASS DECLARATION
+
+/**
+*  DRMCommon: provides common DRM functions.
+*
+*  @lib    DRMCommon.dll
+*  @since  2.0
+*/
+class DRMCommon: public CBase
+    {
+public:     // Data Types
+    enum
+        {
+        EPlay = ContentAccess::EPlay,
+        EDisplay = ContentAccess::EView, 
+        EExecute = ContentAccess::EExecute, 
+        EPrint = ContentAccess::EPrint, 
+        EInstall = ContentAccess::EInstall, 
+        };
+
+    enum TConsumeAction
+        {
+        EStart,
+        EFinish,
+        };
+    
+    enum
+        {
+        EOk = KErrNone, 
+        EGeneralError = -30100, 
+        EUnknownMIME = -30101, 
+        EVersionNotSupported = -30102, 
+        ESessionError = -30103, 
+        ENoRights = KErrCANoRights, 
+        ERightsDBCorrupted = -30105, 
+        EUnsupported = KErrCANotSupported, 
+        ERightsExpired = KErrCANoPermission, 
+        EInvalidRights = -30108,
+        EPaddingFailed = -30109,
+        EFileError = -30110
+        };
+    
+    enum TContentProtection
+        {
+        ENoDCFFile, 
+        EForwardLocked, 
+        ESuperDistributable
+        };
+    
+    enum TOMALevel
+        {
+        EOMA_None, 
+        EOMA_1_0,
+        EOMA_2_0
+        };
+    
+    enum
+        {
+        EForwardLock = 0x0001, 
+        ECombinedDelivery = 0x0002, 
+        ESeparateDelivery = 0x0004, 
+        ESuperDistribution = 0x0008
+        };
+    
+public:  // Constructors and destructor
+    
+    /**
+    * Two-phased constructor.
+    */
+    IMPORT_C static DRMCommon* NewL(void);
+    
+    /**
+    * Destructor.
+    */
+    IMPORT_C virtual ~DRMCommon(void);
+    
+    public: // New functions
+    
+    /**
+    * Version
+    *
+    * Returns the version of this API.
+    *
+    * @since  2.0
+    * @return Version of the API
+    */
+    IMPORT_C static TVersion Version(void);
+    
+    /**
+    * ServerVersion
+    * 
+    * Returns the version of the DRM Engine.
+    *
+    * @since  2.0
+    * @return Version of the DRM Engine
+    */
+    IMPORT_C static TVersion ServerVersion(void);
+    
+    /**
+    * Connect
+    *
+    * Connect to the DRM Engine.
+    *
+    * @since  2.0
+    * @return EOk if the connection has been made
+    */
+    IMPORT_C TInt Connect(void);
+    
+    /**
+    * Disconnect
+    *
+    * Disconnect the current connection.
+    *
+    * @since  2.0
+    * @return EOk if the connection has been disconnected
+    */
+    IMPORT_C TInt Disconnect(void);
+    
+    /**
+    * CheckContentRights
+    * 
+    * Takes a Content URI and a rights specification.
+    * Checks if the specified rights can be exercised with this content 
+    * by looking up the content URI in the rights database and checking
+    * the stored rights.
+    *
+    * @since  2.0
+    * @param  aContentURI: the content URI of the content to be tested
+    * @param  aRightsSpec: The rights to be checked defined as a bitmask
+    *         combination of EPlay, EDisplay, EExecute and EPrint
+    * @return EOk if all of the given rights can be exercised, otherwise
+    *         or if the content URI cannot be found, ENoRights
+    */
+    IMPORT_C TInt CheckContentRights(
+        const TDesC8& aContentURI, 
+        TUint32 aRightsSpec);
+    
+    /**
+    * CheckFileRights
+    *
+    * Takes a file name and a rights specification. Opens the given file
+    * and checks if the specified rights can be exercised with this file 
+    * by extracting the content URI from the file, looking up the content
+    * URI in the rights database and checking the stored rights.
+    *
+    * @since  2.0
+    * @param  aFileName: the name of the file to be tested.
+    * @param  aRightsSpec: The rights to be checked defined as a bitmask
+    *         combination of EPlay, EDisplay, EExecute and EPrint
+    * @return EOk if all of the given rights can be exercised, otherwise
+    *         or if the file is not a DCF file or if the content URI cannot
+    *         be found, ENoRights
+    */
+    IMPORT_C TInt CheckFileRights(
+        const TDesC& aFileName, 
+        TUint32 aRightsSpec);
+
+    /**
+    * CheckFileRights
+    *
+    * Takes a file name and a rights specification. Opens the given file
+    * and checks if the specified rights can be exercised with this file 
+    * by extracting the content URI from the file, looking up the content
+    * URI in the rights database and checking the stored rights.
+    *
+    * @since  3.0
+    * @param  aFileHandle: file handle to the file.
+    * @param  aRightsSpec: The rights to be checked defined as a bitmask
+    *         combination of EPlay, EDisplay, EExecute and EPrint
+    * @return EOk if all of the given rights can be exercised, otherwise
+    *         or if the file is not a DCF file or if the content URI cannot
+    *         be found, ENoRights
+    */
+    IMPORT_C TInt CheckFileRights(
+        RFile& aFileHandle, 
+        TUint32 aRightsSpec);
+    
+    /**
+    * IsProtectedContent
+    *
+    * Takes a memory buffer containing a file and checks if it is a DCF file
+    * or a regular file.
+    *
+    * @since  2.0
+    * @param  aContent: memory buffer containing a file
+    * @param  aProtection: return parameter, true if the file is a DCF file
+    * @return EOk if the content could be checked.
+    */
+    IMPORT_C TInt IsProtectedContent(
+        const TDesC8& aContent, 
+        TBool& aProtection);
+    
+    /**
+    * IsProtectedFile
+    *
+    * Takes a file name and checks if it is a DCF file or a regular file.
+    *
+    * @since  2.0
+    * @param  aFileName: the name of the file to be tested.
+    * @param  aProtection: return parameter, true if the file is a DCF file
+    * @return EOk if the content could be checked.
+    */
+    IMPORT_C TInt IsProtectedFile(
+        const TDesC& aFileName, 
+        TBool& aProtection);
+
+    /**
+    * IsProtectedFile
+    *
+    * Takes a file name and checks if it is a DCF file or a regular file.
+    *
+    * @since  3.0
+    * @param  aFileHandle: handle to the file to be tested.
+    * @param  aProtection: return parameter, true if the file is a DCF file
+    * @return EOk if the content could be checked.
+    */
+    IMPORT_C TInt IsProtectedFile(
+        RFile& aFileHandle, 
+        TBool& aProtection);
+    
+    /**
+    * GetContentInfo
+    *
+    * Takes a memory buffer containing a DCF(or at least the header part
+        * of it) and returns the protection for this content, the MIME type, 
+    * Content URI and encrypted data length in out parameters.
+    *
+    * @since  2.0
+    * @param  aContent: memory buffer containing a DCF
+    * @param  aProtection: return parameter for the type of protection for
+    *         this DCF
+    * @param  aMIMEType: return parameter for the MIME type header field
+    * @param  aContentURI: return parameter for the content URI header field
+    * @param  aDataLength: return parameter for the length of the encrypted
+    *         data
+    * @return EOk if the information could be extracted from the DCF
+    */
+    IMPORT_C TInt GetContentInfo(
+        const TDesC8& aContent, 
+        TContentProtection& aProtection, 
+        HBufC8*& aMIMEType, 
+        HBufC8*& aContentURI, 
+        TUint& aDataLength);
+    
+    /**
+    * GetFileInfo
+    * 
+    * Takes the name of a DCF file, opens it and returns the protection for
+    * this content, the MIME type, Content URI and encrypted data length in
+    * out parameters.
+    *
+    * @since  2.0
+    * @param  aFileName: the name of the file to be inspected
+    * @param  aProtection: return parameter for the type of protection for
+    *         this DCF
+    * @param  aMIMEType: return parameter for the MIME type header field
+    * @param  aContentURI: return parameter for the content URI header field
+    * @param  aDataLength: return parameter for the length of the encrypted
+    *         data
+    * @return EOk if the information could be extracted from the DCF
+    */
+    IMPORT_C TInt GetFileInfo(
+        const TDesC& aFileName, 
+        TContentProtection& aProtection, 
+        HBufC8*& aMIMEType, 
+        HBufC8*& aContentURI, 
+        TUint& aDataLength);
+
+    /**
+    * GetFileInfo
+    * 
+    * Takes the name of a DCF file, opens it and returns the protection for
+    * this content, the MIME type, Content URI and encrypted data length in
+    * out parameters.
+    *
+    * @since  3.0
+    * @param  aFileHandle: handle to the file to be inspected
+    * @param  aProtection: return parameter for the type of protection for
+    *         this DCF
+    * @param  aMIMEType: return parameter for the MIME type header field
+    * @param  aContentURI: return parameter for the content URI header field
+    * @param  aDataLength: return parameter for the length of the encrypted
+    *         data
+    * @return EOk if the information could be extracted from the DCF
+    */
+    IMPORT_C TInt GetFileInfo(
+        RFile& aFileHandle, 
+        TContentProtection& aProtection, 
+        HBufC8*& aMIMEType, 
+        HBufC8*& aContentURI, 
+        TUint& aDataLength);
+    
+    /**
+    * GetContentHeader
+    *
+    * Takes a memory buffer containing a DCF(or at least the header part of
+    * it) and a header name and returns the value of the header field in an
+    * out parameter. Return value specifies if the header has been found.
+    * Search is case insensitive.
+    *
+    * @since  2.0
+    * @param  aContent: memory buffer containing a DCF
+    * @param  aHeaderName: Name of the header to look for
+    * @param  aHeaderValue: return parameter for value of the header
+    * @return EOk if the header was found
+    */
+    IMPORT_C TInt GetContentHeader(
+        const TDesC8& aContent, 
+        const TDesC8& aHeaderName, 
+        HBufC8*& aHeaderValue);
+    
+    /**
+    * GetFileHeader
+    *
+    * Takes the name of a DCF file and a header name, opens the DCF file and
+    * returns the value of the header field in an out parameter. Return value
+    * specifies if the header has been found. Search is case insensitive.
+    *
+    * @since  2.0
+    * @param  aFileName: the name of the DCF file to be opened
+    * @param  aHeaderName: Name of the header to look for
+    * @param  aHeaderValue: return parameter for value of the header
+    * @return EOk if the header was found
+    */
+    IMPORT_C TInt GetFileHeader(
+        const TFileName& aFileName, 
+        const TDesC8& aHeaderName, 
+        HBufC8*& aHeaderValue);
+ 
+    /**
+    * GetFileHeader
+    *
+    * Takes the name of a DCF file and a header name, opens the DCF file and
+    * returns the value of the header field in an out parameter. Return value
+    * specifies if the header has been found. Search is case insensitive.
+    *
+    * @since  3.0
+    * @param  aFileHandle: handle to the DCF file
+    * @param  aHeaderName: Name of the header to look for
+    * @param  aHeaderValue: return parameter for value of the header
+    * @return EOk if the header was found
+    */
+    IMPORT_C TInt GetFileHeader(
+        RFile& aFileHandle, 
+        const TDesC8& aHeaderName, 
+        HBufC8*& aHeaderValue);
+    
+    /**
+    * SetContentHeader
+    *
+    * Takes a memory buffer containing a DCF(or at least the header part of
+        * it), a header name and the value for the header field. Sets the header
+    * field in the optional DCF header. If the header field has not existed
+    * before, it is created. Any previous value of the header field will be
+    * overwritten.
+    *
+    * @since  2.0
+    * @param  aContent: memory buffer containing a DCF
+    * @param  aHeaderName: Name of the header to set
+    * @param  aHeaderValue: New value of the heade
+    * @return EOk if the header was set.
+    */
+    IMPORT_C TInt SetContentHeader(
+        HBufC8*& aContent, 
+        const TDesC8& aHeaderName, 
+        const TDesC8& aHeaderValue);
+    
+    /**
+    * SetFileHeader
+    *
+    * Takes the name of a DCF file, a header name and the value for the header
+    * field. Opens the DCF file, sets the header field in the optional DCF
+    * header and writes the DCF file. If the header field has not existed
+    * before, it is created. Any previous value of the header field will be
+    * overwritten.
+    *
+    * @since  2.0
+    * @param  aFileName: the name of the DCF file to be opened
+    * @param  aHeaderName: Name of the header to set
+    * @param  aHeaderValue: New value of the heade
+    * @return EOk if the header was set.
+    */
+    IMPORT_C TInt SetFileHeader(
+        const TDesC16& aFileName, 
+        const TDesC8& aHeaderName, 
+        const TDesC8& aHeaderValue);
+
+    /**
+    * SetFileHeader
+    *
+    * Takes the name of a DCF file, a header name and the value for the header
+    * field. Opens the DCF file, sets the header field in the optional DCF
+    * header and writes the DCF file. If the header field has not existed
+    * before, it is created. Any previous value of the header field will be
+    * overwritten.
+    *
+    * @since  3.0
+    * @param  aFileHandle: handle to the DCF file
+    * @param  aHeaderName: Name of the header to set
+    * @param  aHeaderValue: New value of the heade
+    * @return EOk if the header was set.
+    */
+    IMPORT_C TInt SetFileHeader(
+        RFile& aFileHandle, 
+        const TDesC8& aHeaderName, 
+        const TDesC8& aHeaderValue);
+
+    /**
+    * GetSingleRightsObject
+    *
+    * Takes a content URI, a local ID and a rights object out parameter.
+    * Looks up the rights object using the content URI and the local ID
+    * and returns it in the out parameter.
+    *
+    * @since  2.5
+    * @param  aContentURI: the content URI of the content to be tested.
+    * @param  aLocalID: local ID of the rights object
+    * @param  aRightsObject: Out parameter for the rights object. It has
+    *         to be released by the caller.
+    * @return EOk if the rights object could be retreived, ENoRights if
+    *         no rights object exists.
+    */
+    IMPORT_C TInt GetSingleRightsObject(
+        const TDesC8& aContentURI, 
+        TUint32 aLocalID, 
+        CDRMRights*& aRightsObject);
+    
+    /**
+    * GetDetailedContentRights
+    *
+    * Takes a Content URI and an array out parameter. Fills the rights
+    * specification array with the available rights by looking up the content
+    * URI in the rights database and retrieving the stored rights. The array
+    * parameter will contain a list of pointers to all rights object for the 
+    * given content URI. The rights objects themselves can be distinguished by
+    * their local ID.
+    *
+    * @since  2.5
+    * @param  aContentURI: the content URI of the content to be tested.
+    * @param  aRightsList: Out parameter for the available rights. It has to
+    *         be released by the caller.
+    * @return EOk if the rights could be retreived, ENoRights if no rights 
+    *         object exists.
+    */
+    IMPORT_C TInt GetDetailedContentRights(
+        const TDesC8& aContentURI, 
+        RPointerArray<CDRMRights>*& aRightsList);
+    
+    /**
+    * GetDetailedFileRights
+    *
+    * Takes a file name and a rights specification. Opens the given file and 
+    * fills the rights specification array with the available rights by
+    * looking up the content URI in the rights database and retrieving the
+    * stored rights. The array parameter will contain a list of pointers to
+    * all rights object for the given content URI. The rights objects
+    * themselves can be distinguished by their local ID.
+    *
+    * @since  2.5
+    * @param  aFileName: the name of the file to be tested.
+    * @param  aRightsList: Out parameter for the available rights.
+    * @return EOk if the rights could be retreived, if the file is not a DCF
+    *         file or if the content URI cannot be found, ENoRights.
+    */
+    IMPORT_C TInt GetDetailedFileRights(
+        const TDesC& aFileName, 
+        RPointerArray<CDRMRights>*& aRightsList);
+
+    /**
+    * GetDetailedFileRights
+    *
+    * Takes a file name and a rights specification. Opens the given file and 
+    * fills the rights specification array with the available rights by
+    * looking up the content URI in the rights database and retrieving the
+    * stored rights. The array parameter will contain a list of pointers to
+    * all rights object for the given content URI. The rights objects
+    * themselves can be distinguished by their local ID.
+    *
+    * @since  3.0
+    * @param  aFileHandle: handle to the file to be tested.
+    * @param  aRightsList: Out parameter for the available rights.
+    * @return EOk if the rights could be retreived, if the file is not a DCF
+    *         file or if the content URI cannot be found, ENoRights.
+    */
+    IMPORT_C TInt GetDetailedFileRights(
+        RFile& aFileHandle, 
+        RPointerArray<CDRMRights>*& aRightsList);
+    
+    /**
+    * GetActiveRights
+    *
+    * Takes a Content URI and a rights specification. Finds all rights objects
+    * associated with given URI and returns a possible active one. The out 
+    * parameters will contain a pointer to the found rights object. The found
+    * rights object can be expired. The details about expiration and constraints
+    * of the rights can be retrieved with the CDRMRights::GetRightsInfo function. 
+    *
+    * @since  2.5
+    * @param  aContentURI: the content URI of the content to be tested.
+    * @param  aRightsSpec: The rights to be checked defined as a bitmask
+    *		  combination of EPlay, EDisplay, EExecute and EPrint
+    * @param  aRightsObject: Out parameter for the rights object. It has
+    *         to be released by the caller.
+    * @return EFullRights, ERestrictedRights, EPreviewRights if a possble active
+    *         rights object was found. ENoRights if no rights object for given 
+    *         content URI or permissions.
+    */
+    IMPORT_C TInt GetActiveRights(
+        const TDesC8& aContentURI,
+        TUint32 aRightsSpec,
+        CDRMRights*& aRightsObject);
+    
+    /**
+    * GetContentURIList
+    *
+    * Returns a list of all content URIs that have rights in the rights 
+    * database.
+    *
+    * @since  2.5
+    * @param  aURIList: Out parameter for the URI list.
+    * @return Ok if the URI list could be retreived.
+    */
+    IMPORT_C TInt GetContentURIList(
+        RPointerArray<HBufC8>*& aURIList);
+    
+    /**
+    * DataTypesCount
+    *
+    * Returns the number of previously registered datatypes which are
+    * supported by the DRM system and associated applications.
+    *
+    * @since  2.0
+    * @param  aCount: Out parameter for the datatype count
+    * @return EOk if the number of datatypes has been returned correctly
+    */
+    IMPORT_C TInt DataTypesCount(
+        TInt& aCount);
+    
+    /**
+    * SupportedDataType
+    *
+    * Returns a specific datatype which has been registered before by giving an index
+    *
+    * @since  2.0
+    * @param  aIndex: Number of the datatype to return
+    * @param  aDataType: Out parameter for the datatype
+    * @return EOk if the datatype was returned correctly
+    */
+    
+    IMPORT_C TInt SupportedDataType(
+        const TInt aIndex, TDataType& aDataType);
+    
+    /**
+    * StaticDataTypesCount
+    *
+    * Returns the number of default registered datatypes which are
+    * supported by the DRM system and associated applications.
+    *
+    * @since  2.0
+    * @param  aCount: Out parameter for the static datatype count
+    * @return EOk if the number of datatypes has been returned correctly
+    */
+    IMPORT_C TInt StaticDataTypesCount(
+        TInt& aCount);
+    
+    /**
+    * RegisterDataType
+    *
+    * Registers a datatype as a supported datatype.
+    *
+    * @since  2.0
+    * @param  aDataType: Datatype to register
+    * @return EOk if the datatype has been registered
+    */
+    
+    IMPORT_C TInt RegisterDataType(
+        const TDataType& aDataType);
+    
+    /**
+    * UnRegisterDataType
+    *
+    * Unregisters a datatype via its index.
+    *
+    * @since  2.5
+    * @param  aIndex: Number of the datatype to unregister
+    * @return EOk if the datatype has been unregistered
+    */
+    
+    IMPORT_C TInt UnRegisterDataType(
+        const TInt aIndex);
+    
+    /**
+    * SupportedDRMMethods
+    *
+    * Returns the supported DRM protection methods and the OMA compliance
+    * level of the DRM engine
+    *
+    * @since  2.0
+    * @param  aDRMMethod: Out parameter, bit mask containing any 
+    *         combination of EForwardLock, ECombinedDelivery, 
+    *         ESeparateDelivery etc.
+    * @param  aOMALevel: OMA compliance of the DRM engine
+    * @return DRMCommon error code
+    */
+    
+    IMPORT_C TInt SupportedDRMMethods(
+        TInt& aDRMMethod, TOMALevel& aOMALevel);
+        
+    /**
+    * MergeParentAndChild
+    *
+    * Merge rights with their parent rights
+    *
+    * @since  3.0
+    * @param  aRights Rights to be merged with their parent rights
+    */
+
+    IMPORT_C void MergeParentAndChild(CDRMRights* aRights);
+        
+    
+    
+protected:
+    
+    /**
+    * C++ default constructor.
+    */
+    IMPORT_C DRMCommon(void);
+    
+    /**
+    * 2nd phase constructor.
+    */
+    IMPORT_C void ConstructL(void);
+    
+    /**
+    * MapErrorCode
+    *
+    * Maps the error codes returned by the core engine to DRMCommon
+    * error codes.
+    *
+    * @since  2.5
+    * @param  aCode: core error code
+    * @return DRMCommon error code.
+    */
+    IMPORT_C TInt MapErrorCode(
+        const TInt aCode);
+    
+    };
+
+#endif      // DRMCOMMON_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/tsrc/Bmarm/DRMCommonTestU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	LibEntryL__Fv @ 1 NONAME R3UNUSED ; LibEntryL(void)
+	SetRequirements__FRP16CTestModuleParamRUl @ 2 NONAME R3UNUSED ; SetRequirements(CTestModuleParam *&, unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/tsrc/Bwins/DRMCommonTestU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * __cdecl LibEntryL(void)
+	?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int __cdecl SetRequirements(class CTestModuleParam * &,unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/tsrc/EABI/DRMCommonTestU.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	_Z9LibEntryLv @ 1 NONAME
+	_Z15SetRequirementsRP16CTestModuleParamRm @ 2 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/tsrc/data/mmc/DRM/content.dcf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,7 @@
+
+8image/jpegcid:testcontent20090526095637-2657230746@testcontent.comgàEncryption-Method: AES128CBC;padding=RFC2630
+Content-Name: "content_name"
+Rights-Issuer: http://127.0.0.1/testcontent
+Content-Description: "content_description"
+Content-Vendor: "content_vendor"
+Icon-Uri: iconuritestcontent.comù•Å¨´A•n)¯Oª‘[Ž»×s‚Ö›Þ®7¯æXØé©¿í†Ù›92÷Ýõ¦3e¿±ÐQ”æ¾Ú82_“Wµê×4ÐЯÅŒ‘ýïàqÍ•³€ÕºvMZ«4Dz‰P‘j{g…¦gÈè–«[ÛÆE“>:µ,ƒ¥‚ Ró­‘w;_õX©†uZÌ¥dp¼0ëùœÛèh˜ÄÊÓ¼`¡ÙrgÀ§¼v
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/tsrc/group/DRMCommonTest.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2002 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for DRMCommonTest
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DRMCommonTest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E7
+
+CAPABILITY      ALL -TCB
+
+DEFFILE         DRMCommonTest.def
+
+SOURCEPATH      ../src
+SOURCE          DRMCommonTest.cpp
+SOURCE          DRMCommonTestCases.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../../omadrm/drmengine/ro/inc
+USERINCLUDE     ../../../../omadrm/drmengine/server/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         drmcommon.lib
+LIBRARY         drmserverinterfaces.lib
+LIBRARY         drmrights.lib
+LIBRARY         drmparsers.lib
+LIBRARY         apmime.lib
+
+SMPSAFE
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/tsrc/group/DrmCommonTest.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,37 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Languages
+; =========
+&EN
+
+; Name, UID for installation, Maj.Ver., Min.Ver., Variant, FLAG TO SPECIFY UNICODE, System component
+; ==================================================================================================
+#{"DRM Common test"},(0x101FB3E7),1,0,1,TYPE=SA
+
+
+; Localised Vendor name
+%{"Nokia-EN"}
+
+; Unique Vendor name
+:"Nokia"
+
+"\epoc32\release\armv5\urel\drmcommontest.dll"      -"$:\sys\bin\drmcommontest.dll"
+
+
+"..\data\mmc\drm\content.dcf"    -"e:\testing\data\drm\content.dcf"
+
+; eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/tsrc/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2002 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DrmCommon API tests
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTEXPORTS
+../data/mmc/drm/content.dcf /epoc32/winscw/c/content.dcf
+
+PRJ_EXPORTS
+
+PRJ_TESTMMPFILES
+drmcommontest.mmp
+
+PRJ_MMPFILES
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/tsrc/inc/DRMCommonTest.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,466 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRMCommonTest test module.
+*
+*/
+
+
+
+#ifndef DRMCOMMONTEST_H
+#define DRMCOMMONTEST_H
+
+// INCLUDES
+#include "StifTestModule.h"
+#include <StifLogger.h>
+
+// Logging path
+_LIT( KDRMCommonTestLogPath, "\\logs\\testframework\\DRMCommonTest\\" ); 
+// Log file
+_LIT( KDRMCommonTestLogFile, "DRMCommonTest.txt" ); 
+
+
+#define GETPTR &
+#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
+#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
+#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
+#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
+
+// FORWARD DECLARATIONS
+class CDRMCommonTest;
+
+typedef TInt (CDRMCommonTest::* TestFunction)(TTestResult&);
+
+// CLASS DECLARATION
+
+/**
+*  An internal structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib DRMCommonTest.lib
+*  @since S60 3.2
+*/
+class TCaseInfoInternal
+    {
+    public:
+        const TText*    iCaseName;
+        TestFunction    iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+    };
+
+// CLASS DECLARATION
+
+/**
+*  A structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib DRMCommonTest.lib
+*  @since S60 3.2
+*/
+class TCaseInfo
+    {
+    public:
+        TPtrC iCaseName;
+        TestFunction iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+
+    TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
+        {
+        };
+
+    };
+
+
+// CLASS DECLARATION
+
+/**
+*  This a DRMCommonTest class.
+*
+*  @lib DRMCommonTest.lib
+*  @since S60 3.2
+*/
+NONSHARABLE_CLASS(CDRMCommonTest) : public CTestModuleBase
+    {
+    public:  // Constructors and destructor
+
+
+        /**
+        * Two-phased constructor.
+        */
+        static CDRMCommonTest* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CDRMCommonTest();
+
+    public: // Functions from base classes
+
+        /**
+        * From CTestModuleBase InitL is used to initialize the 
+        *       DRMCommonTest. It is called once for every instance of 
+        *       TestModuleDRMCommonTest after its creation.
+        * @since S60 3.2
+        * @param aIniFile Initialization file for the test module (optional)
+        * @param aFirstTime Flag is true when InitL is executed for first 
+        *               created instance of DRMCommonTest.
+        * @return Symbian OS error code
+        */
+        TInt InitL( TFileName& aIniFile, TBool aFirstTime );
+
+        /**
+        * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
+        *   from DRMCommonTest. 
+        * @since S60 3.2
+        * @param aTestCaseFile Test case file (optional)
+        * @param aTestCases  Array of TestCases returned to test framework
+        * @return Symbian OS error code
+        */
+        TInt GetTestCasesL( const TFileName& aTestCaseFile, 
+                            RPointerArray<TTestCaseInfo>& aTestCases );
+
+        /**
+        * From CTestModuleBase RunTestCaseL is used to run an individual 
+        *   test case. 
+        * @since S60 3.2
+        * @param aCaseNumber Test case number
+        * @param aTestCaseFile Test case file (optional)
+        * @param aResult Test case result returned to test framework (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error, which is 
+        *           not reported in aResult parameter as test case failure).
+        */   
+        TInt RunTestCaseL( const TInt aCaseNumber, 
+                           const TFileName& aTestCaseFile,
+                           TTestResult& aResult );
+
+        /**
+        * From CTestModuleBase; OOMTestQueryL is used to specify is particular
+        * test case going to be executed using OOM conditions
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailureType OOM failure type (optional)
+        * @param aFirstMemFailure The first heap memory allocation failure value (optional)
+        * @param aLastMemFailure The last heap memory allocation failure value (optional)
+        * @return TBool
+        */
+        virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
+                                     const TInt /* aCaseNumber */, 
+                                     TOOMFailureType& aFailureType, 
+                                     TInt& /* aFirstMemFailure */, 
+                                     TInt& /* aLastMemFailure */ );
+
+        /**
+        * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
+                                    const TInt /* aCaseNumber */ ); 
+
+        /**
+        * From CTestModuleBase; OOMHandleWarningL
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailNextValue FailNextValue for OOM test execution (optional)
+        * @return None
+        *
+        * User may add implementation for OOM test warning handling. Usually no
+        * implementation is required.           
+        */
+        virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
+                                        const TInt /* aCaseNumber */, 
+                                        TInt& /* aFailNextValue */); 
+
+        /**
+        * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        *
+        */
+        virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
+                                       const TInt /* aCaseNumber */ );
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDRMCommonTest();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Function returning test case name and pointer to test case function.
+        * @since S60 3.2
+        * @param aCaseNumber test case number
+        * @return TCaseInfo 
+        */
+        const TCaseInfo Case ( const TInt aCaseNumber ) const;
+
+        /**
+        * Constructor tests..
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConstructTestL( TTestResult& aResult );
+
+        /**
+        * Version tests
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt VersionTestL( TTestResult& aResult );
+
+        /**
+        * Connection tests
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConnectionTestL( TTestResult& aResult );
+        
+        /**
+        * Contents rights test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt CheckContentRightsTestL( TTestResult& aResult );
+        
+        /**
+        * Contents rights test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt CheckFileRightsTestForFileNameL( TTestResult& aResult );
+        
+        /**
+        * Contents rights test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt CheckFileRightsTestForFileHandleL( TTestResult& aResult );
+        
+        /**
+        * Contents protection test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt IsProtectedContentTestL( TTestResult& aResult );
+        
+        /**
+        * Contents protection test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt IsProtectedFileTestForFileNameL( TTestResult& aResult );
+        
+        /**
+        * Contents protection test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt IsProtectedFileTestForFileHandleL( TTestResult& aResult );
+        
+        /**
+        * Contents info test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetContentInfoTestL( TTestResult& aResult );
+        
+        /**
+        * Contents info test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetFileInfoTestForFileNameL( TTestResult& aResult );
+        
+        /**
+        * Contents info test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetFileInfoTestForFileHandleL( TTestResult& aResult );
+        
+        /**
+        * Contents header test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetContentHeaderTestL( TTestResult& aResult );
+        
+        /**
+        * Contents header test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetFileHeaderTestForFileNameL( TTestResult& aResult );
+        
+        /**
+        * Contents header test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetFileHeaderTestForFileHandleL( TTestResult& aResult );
+        
+        /**
+        * Set content header test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt SetContentHeaderTestL( TTestResult& aResult );
+        
+        /**
+        * Set content header test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt SetFileHeaderTestForFileNameL( TTestResult& aResult );
+        
+        /**
+        * Set content header test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt SetFileHeaderTestForFileHandleL( TTestResult& aResult );
+        
+        /**
+        * Get rights object test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetSingleRightsObjectTestL( TTestResult& aResult );
+        
+        /**
+        * Get detailed content rights test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetDetailedContentRightsTestL( TTestResult& aResult );
+        
+        /**
+        * Get detailed content rights test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetDetailedFileRightsTestForFileNameL( TTestResult& aResult );
+        
+        /**
+        * Get detailed content rights test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetDetailedFileRightsTestForFileHandleL( TTestResult& aResult );
+        
+        /**
+        * Get active rights test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetActiveRightsTestL( TTestResult& aResult );
+        
+        /**
+        * Get content uri list test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetContentURIListTestL( TTestResult& aResult );
+        
+        /**
+        * Data types tests
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt DataTypesTestL( TTestResult& aResult );
+        
+        /**
+        * Merge parent and child rights test
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt MergeParentAndChildTestL( TTestResult& aResult );
+
+    private:    // Data
+        // Pointer to test (function) to be executed
+        TestFunction iMethod;
+
+        // Pointer to logger
+        CStifLogger * iLog; 
+
+    };
+
+#endif      // DRMCOMMONTEST_H
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/tsrc/src/DRMCommonTest.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,313 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRMCommonTest class member functions
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <Stiftestinterface.h>
+#include "DRMCommonTest.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::CDRMCommonTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMCommonTest::CDRMCommonTest()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+//
+// Note: If OOM test case uses STIF Logger, then STIF Logger must be created
+// with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
+// allocates memory from heap and therefore causes error situations with OOM 
+// testing. For more information about STIF Logger construction, see STIF Users 
+// Guide.
+// -----------------------------------------------------------------------------
+//
+void CDRMCommonTest::ConstructL()
+    {
+    iLog = CStifLogger::NewL( KDRMCommonTestLogPath, 
+                          KDRMCommonTestLogFile);
+
+    // Sample how to use logging
+    _LIT( KLogStart, "DRMCommonTest logging starts!" );
+    iLog->Log( KLogStart );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMCommonTest* CDRMCommonTest::NewL()
+    {
+    CDRMCommonTest* self = new (ELeave) CDRMCommonTest;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+CDRMCommonTest::~CDRMCommonTest()
+    {
+    delete iLog;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::InitL
+// InitL is used to initialize the Test Module.
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::InitL( 
+    TFileName& /*aIniFile*/, 
+    TBool /*aFirstTime*/ )
+    {
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetTestCasesL
+// GetTestCases is used to inquire test cases from the Test Module. Test
+// cases are stored to array of test cases. The Test Framework will be 
+// the owner of the data in the RPointerArray after GetTestCases return
+// and it does the memory deallocation. 
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetTestCasesL( 
+    const TFileName& /*aConfig*/, 
+    RPointerArray<TTestCaseInfo>& aTestCases )
+    {
+
+    // Loop through all test cases and create new
+    // TTestCaseInfo items and append items to aTestCase array    
+    for( TInt i = 0; Case(i).iMethod != NULL; i++ )
+        {
+
+        // Allocate new TTestCaseInfo from heap for a testcase definition.
+        TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
+
+        // PushL TTestCaseInfo to CleanupStack.    
+        CleanupStack::PushL( newCase );
+
+        // Set number for the testcase.
+        // When the testcase is run, this comes as a parameter to RunTestCaseL.
+        newCase->iCaseNumber = i;
+
+        // Set title for the test case. This is shown in UI to user.
+        newCase->iTitle.Copy( Case(i).iCaseName );
+
+        // Append TTestCaseInfo to the testcase array. After appended 
+        // successfully the TTestCaseInfo object is owned (and freed) 
+        // by the TestServer. 
+        User::LeaveIfError(aTestCases.Append ( newCase ) );
+
+        // Pop TTestCaseInfo from the CleanupStack.
+        CleanupStack::Pop( newCase );
+
+        }
+
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::RunTestCaseL
+// RunTestCaseL is used to run an individual test case specified 
+// by aTestCase. Test cases that can be run may be requested from 
+// Test Module by GetTestCases method before calling RunTestCase.
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::RunTestCaseL( 
+    const TInt aCaseNumber,   
+    const TFileName& /*aConfig*/,
+    TTestResult& aResult )
+    {
+
+    // Return value
+    TInt execStatus = KErrNone;
+
+    // Get the pointer to test case function
+    TCaseInfo tmp = Case ( aCaseNumber );
+
+    _LIT( KLogStartTC, "Starting testcase [%S]" );
+    iLog->Log( KLogStartTC, &tmp.iCaseName);
+
+    // Check that case number was valid
+    if ( tmp.iMethod != NULL )
+        {
+        // Valid case was found, call it via function pointer
+        iMethod = tmp.iMethod;        
+        execStatus  = ( this->*iMethod )( aResult );
+        }
+    else
+        {
+        // Valid case was not found, return error.
+        execStatus = KErrNotFound;
+        }
+
+    // Return case execution status (not the result of the case execution)
+    return execStatus;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::OOMTestQueryL
+// Used to check if a particular test case should be run in OOM conditions and 
+// which memory allocations should fail.    
+// -----------------------------------------------------------------------------
+//
+TBool CDRMCommonTest::OOMTestQueryL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt aCaseNumber, 
+                                TOOMFailureType& /* aFailureType */, 
+                                TInt& aFirstMemFailure, 
+                                TInt& aLastMemFailure ) 
+    {
+    _LIT( KLogOOMTestQueryL, "CDRMCommonTest::OOMTestQueryL" );
+    iLog->Log( KLogOOMTestQueryL );     
+
+    aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
+    aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation;
+
+    return Case( aCaseNumber ).iIsOOMTest;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::OOMTestInitializeL
+// Used to perform the test environment setup for a particular OOM test case. 
+// Test Modules may use the initialization file to read parameters for Test 
+// Module initialization but they can also have their own configure file or 
+// some other routine to initialize themselves.  
+//
+// NOTE: User may add implementation for OOM test environment initialization.
+// Usually no implementation is required.
+// -----------------------------------------------------------------------------
+//
+void CDRMCommonTest::OOMTestInitializeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::OOMHandleWarningL
+// In some cases the heap memory allocation should be skipped, either due to
+// problems in the OS code or components used by the code being tested, or even 
+// inside the tested components which are implemented this way on purpose (by 
+// design), so it is important to give the tester a way to bypass allocation 
+// failures.
+//
+// NOTE: User may add implementation for OOM test warning handling. Usually no
+// implementation is required.
+// -----------------------------------------------------------------------------
+//
+void CDRMCommonTest::OOMHandleWarningL( 
+                                const TFileName& /* aTestCaseFile */,
+                                const TInt /* aCaseNumber */, 
+                                TInt& /* aFailNextValue */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::OOMTestFinalizeL
+// Used to perform the test environment cleanup for a particular OOM test case.
+//
+// NOTE: User may add implementation for OOM test environment finalization.
+// Usually no implementation is required.
+// -----------------------------------------------------------------------------
+//
+void CDRMCommonTest::OOMTestFinalizeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point
+// Returns: CTestModuleBase*: Pointer to Test Module object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTestModuleBase* LibEntryL()
+    {
+    return CDRMCommonTest::NewL();
+
+    }
+
+// -----------------------------------------------------------------------------
+// SetRequirements handles test module parameters(implements evolution
+// version 1 for test module's heap and stack sizes configuring).
+// Returns: TInt: Symbian error code.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
+                                TUint32& /*aParameterValid*/ )
+    {
+
+    /* --------------------------------- NOTE ---------------------------------
+    USER PANICS occurs in test thread creation when:
+    1) "The panic occurs when the value of the stack size is negative."
+    2) "The panic occurs if the minimum heap size specified is less
+       than KMinHeapSize".
+       KMinHeapSize: "Functions that require a new heap to be allocated will
+       either panic, or will reset the required heap size to this value if
+       a smaller heap size is specified".
+    3) "The panic occurs if the minimum heap size specified is greater than
+       the maximum size to which the heap can grow".
+    Other:
+    1) Make sure that your hardware or Symbian OS is supporting given sizes.
+       e.g. Hardware might support only sizes that are divisible by four.
+    ------------------------------- NOTE end ------------------------------- */
+
+    // Normally STIF uses default heap and stack sizes for test thread, see:
+    // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
+    // If needed heap and stack sizes can be configured here by user. Remove
+    // comments and define sizes.
+
+/*
+    aParameterValid = KStifTestModuleParameterChanged;
+
+    CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
+    // Stack size
+    param->iTestThreadStackSize= 16384; // 16K stack
+    // Heap sizes
+    param->iTestThreadMinHeap = 4096;   // 4K heap min
+    param->iTestThreadMaxHeap = 1048576;// 1M heap max
+
+    aTestModuleParam = param;
+*/
+    return KErrNone;
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_common_api/tsrc/src/DRMCommonTestCases.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1877 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRMCommonTest hard coded test cases
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <apmstd.h>
+#include <drmcommon.h>
+
+#include "drmcommontest.h"
+#include "drmrightsclient.h"
+#include "drmpermission.h"
+#include "drmrights.h"
+#include "drmrightsparser.h"
+#include "drmpointerarray.h"
+
+// CONSTANTS
+#ifdef __WINSCW__
+_LIT( KTempFile, "c:\\temp.tmp" );
+_LIT( KOma1Content, "c:\\content.dcf" );
+#else
+_LIT( KTempFile, "e:\\testing\\data\\drm\\temp.tmp" );
+_LIT( KOma1Content, "e:\\testing\\data\\drm\\content.dcf" );
+#endif
+
+_LIT8( KOma1ContentID, "cid:testcontent20090526095637-2657230746@testcontent.com" );
+_LIT8( KOma1ContentMime, "image/jpeg" );
+
+_LIT8( KROHeadOMA1, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\
+<!DOCTYPE o-ex:rights PUBLIC \"-//OMA//DTD DRMREL 1.0//EN\" \
+\"http://www.oma.org/dtd/dr\">\
+<o-ex:rights\
+   xmlns:o-ex=\"http://odrl.net/1.1/ODRL-EX\" \
+   xmlns:o-dd=\"http://odrl.net/1.1/ODRL-DD\" \
+   xmlns:oma-dd=\"http://www.openmobilealliance.com/oma-dd\" \
+   xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#/\">\
+  <o-ex:context>\
+    <o-dd:version>1.0</o-dd:version>\
+  </o-ex:context>\
+  <o-ex:agreement>\
+    <o-ex:asset>\
+      <o-ex:context>\
+        <o-dd:uid>" );
+
+_LIT8( KROTailFullOMA1, "</o-dd:uid>\
+      </o-ex:context>\
+      <ds:KeyInfo><ds:KeyValue>PgIkd7w3E5TWWcc7Inp8Yw==</ds:KeyValue></ds:KeyInfo>\
+    </o-ex:asset>\
+  <o-ex:permission>\
+\
+<o-dd:play>\
+      <o-ex:constraint>\
+      </o-ex:constraint>\
+    </o-dd:play>\
+\
+<o-dd:display>\
+      <o-ex:constraint>\
+      </o-ex:constraint>\
+    </o-dd:display>\
+\
+<o-dd:execute>\
+      <o-ex:constraint>\
+      </o-ex:constraint>\
+    </o-dd:execute>\
+\
+<o-dd:print>\
+      <o-ex:constraint>\
+      </o-ex:constraint>\
+    </o-dd:print>\
+  </o-ex:permission>\
+  </o-ex:agreement>\
+</o-ex:rights>" );
+
+_LIT8( KContentName, "Content-Name" );
+_LIT8( KNewName, "New Name" );
+
+_LIT( KRunning, "Running" );
+_LIT( KFinished, "Finished" );
+_LIT( KPassed, "Passed" );
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C void DoResetDestroyAndClose( TAny* aPtr );
+LOCAL_C void DoResetDestroyAndClose2( TAny* aPtr );
+LOCAL_C void ReadFileL( RFs& aFs, const TDesC& aName, HBufC8*& aContent );
+LOCAL_C void WriteFileL( RFs& aFs, const TDesC& aName, HBufC8*& aContent );
+LOCAL_C void DeleteRODBL( );
+LOCAL_C TUint32 AddROL( const TDesC8& aHead, const TDesC8& aCID, const TDesC8& aTail );
+//LOCAL_C void ConsumeRoL( const TInt aIntent, const TDesC8& aContentID, const TInt seconds );
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// DoResetDestroyAndClose
+// Does ResetAndDestroy() to given RPointerArray< CDRMRights >
+// -----------------------------------------------------------------------------
+LOCAL_C void DoResetDestroyAndClose( TAny* aPtr )
+    {
+    ( reinterpret_cast<RPointerArray<CDRMRights>*>( aPtr ) )->ResetAndDestroy();
+    ( reinterpret_cast<RPointerArray<CDRMRights>*>( aPtr ) )->Close();
+    }
+
+// -----------------------------------------------------------------------------
+// DoResetDestroy2
+// Does ResetAndDestroy() to given RPointerArray< CDRMRights >
+// -----------------------------------------------------------------------------
+LOCAL_C void DoResetDestroyAndClose2( TAny* aPtr )
+    {
+    reinterpret_cast<RPointerArray<HBufC8>*>( aPtr )->ResetAndDestroy();
+    reinterpret_cast<RPointerArray<HBufC8>*>( aPtr )->Close();
+    }
+
+// -----------------------------------------------------------------------------
+// ReadFileL
+// Helper function with which test cases can read file to the buffer
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void ReadFileL( RFs& aFs, const TDesC& aName, HBufC8*& aContent )
+	{	
+	RFile file;
+	TInt size( 0 );
+	User::LeaveIfError( file.Open ( aFs, aName, EFileRead ) );
+	CleanupClosePushL( file );
+	User::LeaveIfError( file.Size( size ) );
+	aContent = HBufC8::NewLC( size );
+	TPtr8 ptr( aContent->Des() );
+	User::LeaveIfError( file.Read( 0, ptr, size ) );
+	CleanupStack::Pop( aContent ); //aContent
+	CleanupStack::PopAndDestroy( &file ); //file
+	}
+
+// -----------------------------------------------------------------------------
+// WriteFileL
+// Helper function with which test cases can write buffer to the file
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void WriteFileL( RFs& aFs, const TDesC& aName, HBufC8*& aContent )
+	{	
+	RFile file;
+    User::LeaveIfError( file.Replace( aFs, aName, EFileWrite | EFileShareReadersOrWriters  ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Write( *aContent ) );
+    CleanupStack::PopAndDestroy( &file );
+	}
+
+// -----------------------------------------------------------------------------
+// DeleteRODBL
+// Helper function with which test cases can delete RO DB
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void DeleteRODBL( )
+    {
+	RDRMRightsClient client;
+    User::LeaveIfError( client.Connect() );
+    client.DeleteAll();
+    client.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// AddROL
+// Helper function with which test cases can add ROs
+// Returns local id of added RO
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TUint32 AddROL(
+    const TDesC8& aHead,
+    const TDesC8& aCID, 
+    const TDesC8& aTail
+    )
+    {
+	TInt roSize( aHead.Size() + aCID.Size() + aTail.Size() );
+    HBufC8* buf( HBufC8::NewLC( roSize ) );
+    TPtr8 tmp( buf->Des() );
+    
+    tmp.Append( aHead );
+    tmp.Append( aCID );
+    tmp.Append( aTail );
+    
+    CDRMPointerArray<CDRMRights>* rights( CDRMPointerArray<CDRMRights>::NewLC() );
+    rights->SetAutoCleanup( ETrue );
+    
+    CDrmRightsParser* rp( CDrmRightsParser::NewL() );
+    CleanupStack::PushL( rp );
+    
+    rp->ParseAndStoreL( *buf, *rights );
+    
+    TUint32 localId( rights[0][0]->GetLocalID() );
+    
+    CleanupStack::PopAndDestroy( 3, buf ); //rp, rights, buf
+    
+    return localId;
+	}
+   
+// -----------------------------------------------------------------------------
+// ConsumeRoL
+// Helper function which consumes content´s rights
+// -----------------------------------------------------------------------------
+//
+/*LOCAL_C void ConsumeRoL( 
+    const TInt aIntent, 
+    const TDesC8& aContentID, 
+    const TInt seconds )
+    {
+	RDRMRightsClient client;
+    User::LeaveIfError( client.Connect() );
+    
+    client.Consume( aIntent, aContentID );
+    User::After( seconds*1000*1000 ); // seconds
+    
+    client.Close();
+    }*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::Case
+// Returns a test case by number.
+//
+// This function contains an array of all available test cases 
+// i.e pair of case name and test function. If case specified by parameter
+// aCaseNumber is found from array, then that item is returned.
+// 
+// The reason for this rather complicated function is to specify all the
+// test cases only in one place. It is not necessary to understand how
+// function pointers to class member functions works when adding new test
+// cases. See function body for instructions how to add new test case.
+// -----------------------------------------------------------------------------
+//
+const TCaseInfo CDRMCommonTest::Case ( 
+    const TInt aCaseNumber ) const 
+     {
+
+    /**
+    * To add new test cases, implement new test case function and add new 
+    * line to KCases array specify the name of the case and the function 
+    * doing the test case
+    * In practice, do following
+    * 1) Make copy of existing test case function and change its name
+    *    and functionality. Note that the function must be added to 
+    *    DRMCommonTest.cpp file and to DRMCommonTest.h 
+    *    header file.
+    *
+    * 2) Add entry to following KCases array either by using:
+    *
+    * 2.1: FUNCENTRY or ENTRY macro
+    * ENTRY macro takes two parameters: test case name and test case 
+    * function name.
+    *
+    * FUNCENTRY macro takes only test case function name as a parameter and
+    * uses that as a test case name and test case function name.
+    *
+    * Or
+    *
+    * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
+    * only with OOM (Out-Of-Memory) testing!
+    *
+    * OOM_ENTRY macro takes five parameters: test case name, test case 
+    * function name, TBool which specifies is method supposed to be run using
+    * OOM conditions, TInt value for first heap memory allocation failure and 
+    * TInt value for last heap memory allocation failure.
+    * 
+    * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
+    * that as a test case name, TBool which specifies is method supposed to be
+    * run using OOM conditions, TInt value for first heap memory allocation 
+    * failure and TInt value for last heap memory allocation failure. 
+    */ 
+
+    static TCaseInfoInternal const KCases[] =
+        {
+        // To add new test cases, add new items to this array
+        
+        // NOTE: When compiled to GCCE, there must be Classname::
+        // declaration in front of the method name, e.g. 
+        // CDRMCommonTest::PrintTest. Otherwise the compiler
+        // gives errors.
+        ENTRY( "Com::ConstructTestL", CDRMCommonTest::ConstructTestL ),
+        ENTRY( "Com::VersionTestL", CDRMCommonTest::VersionTestL ),
+        ENTRY( "Com::ConnectionTestL", CDRMCommonTest::ConnectionTestL ),
+        ENTRY( "Com::CheckContentRightsTestL", CDRMCommonTest::CheckContentRightsTestL ),
+        ENTRY( "Com::CheckFileRightsTestForFileNameL", CDRMCommonTest::CheckFileRightsTestForFileNameL ),
+        ENTRY( "Com::CheckFileRightsTestForFileHandleL", CDRMCommonTest::CheckFileRightsTestForFileHandleL ),
+        ENTRY( "Com::IsProtectedContentTestL", CDRMCommonTest::IsProtectedContentTestL ),
+        ENTRY( "Com::IsProtectedFileTestForFileNameL", CDRMCommonTest::IsProtectedFileTestForFileNameL ),
+        ENTRY( "Com::IsProtectedFileTestForFileHandleL", CDRMCommonTest::IsProtectedFileTestForFileHandleL ),
+        ENTRY( "Com::GetContentInfoTestL", CDRMCommonTest::GetContentInfoTestL ),
+        ENTRY( "Com::GetFileInfoTestForFileNameL", CDRMCommonTest::GetFileInfoTestForFileNameL ),
+        ENTRY( "Com::GetFileInfoTestForFileHandleL", CDRMCommonTest::GetFileInfoTestForFileHandleL ),
+        ENTRY( "Com::GetContentHeaderTestL", CDRMCommonTest::GetContentHeaderTestL ),
+        ENTRY( "Com::GetFileHeaderTestForFileNameL", CDRMCommonTest::GetFileHeaderTestForFileNameL ),
+        ENTRY( "Com::GetFileHeaderTestForFileHandleL", CDRMCommonTest::GetFileHeaderTestForFileHandleL ),
+        ENTRY( "Com::SetContentHeaderTestL", CDRMCommonTest::SetContentHeaderTestL ),
+        ENTRY( "Com::SetFileHeaderTestForFileNameL", CDRMCommonTest::SetFileHeaderTestForFileNameL ),
+        ENTRY( "Com::SetFileHeaderTestForFileHandleL", CDRMCommonTest::SetFileHeaderTestForFileHandleL ),
+        ENTRY( "Com::GetSingleRightsObjectTestL", CDRMCommonTest::GetSingleRightsObjectTestL ),
+        ENTRY( "Com::GetDetailedContentRightsTestL", CDRMCommonTest::GetDetailedContentRightsTestL ),
+        ENTRY( "Com::GetDetailedFileRightsTestForFileNameL", CDRMCommonTest::GetDetailedFileRightsTestForFileNameL ),
+        ENTRY( "Com::GetDetailedFileRightsTestForFileHandleL", CDRMCommonTest::GetDetailedFileRightsTestForFileHandleL ),
+        ENTRY( "Com::GetActiveRightsTestL", CDRMCommonTest::GetActiveRightsTestL ),
+        ENTRY( "Com::GetContentURIListTestL", CDRMCommonTest::GetContentURIListTestL ),
+        ENTRY( "Com::DataTypesTestL", CDRMCommonTest::DataTypesTestL ),
+        ENTRY( "Com::MergeParentAndChildTestL", CDRMCommonTest::MergeParentAndChildTestL ),
+        };
+
+    // Verify that case number is valid
+    if( (TUint) aCaseNumber >= sizeof( KCases ) / 
+                               sizeof( TCaseInfoInternal ) )
+        {
+        // Invalid case, construct empty object
+        TCaseInfo null( (const TText*) L"" );
+        null.iMethod = NULL;
+        null.iIsOOMTest = EFalse;
+        null.iFirstMemoryAllocation = 0;
+        null.iLastMemoryAllocation = 0;
+        return null;
+        } 
+
+    // Construct TCaseInfo object and return it
+    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
+    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
+    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
+    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
+    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
+    return tmp;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::ConstructTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::ConstructTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::ConstructTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Testing NewL of DrmCommon: Expecting functional DRMCommon" );
+    iLog->Log( KTestCase1 );
+    
+    DRMCommon* common = DRMCommon::NewL();
+    TL( common );
+    delete common;
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::ConstructTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::VersionTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::VersionTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::VersionTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    TVersion version;
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get Version of DrmCommon: Expecting version name" );
+    iLog->Log( KTestCase1 );
+
+    version = DRMCommon::Version();
+    TL( version.Name() != KNullDesC );
+    
+    //Passed
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    
+    _LIT( KTestCase2, "TestCase2: Trying to get ServerVersion of DrmCommon: Expecting version name" );
+    iLog->Log( KTestCase2 );
+    
+    version = DRMCommon::ServerVersion();
+    TL( version.Name() != KNullDesC );
+    
+    //Passed
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    
+    _LIT( KTestCase3, "TestCase2: Trying to check supported drm methods: Expecting 15, EOMA_2_0, DRMCommon::EOk" );
+    iLog->Log( KTestCase3 );
+    
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    TInt drmMethod( 0 );
+    DRMCommon::TOMALevel omaLevel( DRMCommon::EOMA_None );
+    
+    TInt ret( KErrNone );
+    
+    ret = common->SupportedDRMMethods( drmMethod, omaLevel);
+    T1L( ret, DRMCommon::EOk );
+    T1L( drmMethod, 15 );
+    T1L( omaLevel, DRMCommon::EOMA_2_0 );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( common );
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::VersionTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::ConnectionTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::ConnectionTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::ConnectionTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    TInt ret( DRMCommon::EOk );
+       
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase1: Testing Connect of DrmCommon: Expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    ret = common->Connect();
+    T1L( ret, DRMCommon::EOk );
+    
+    //Passed
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    
+    _LIT( KTestCase2, "TestCase2: Testing Disconnect of DrmCommon: Expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    ret = common->Disconnect();
+    T1L( ret, DRMCommon::EOk );
+    
+    //Passed
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common );
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::ConnectionTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::CheckContentRightsTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::CheckContentRightsTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::CheckContentRightsTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    TInt ret( DRMCommon::EOk );
+       
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase1: Trying to check Oma1 content rights: Expecting ENoRights" );
+    iLog->Log( KTestCase1 );
+
+    //Delete RO database
+    DeleteRODBL();
+
+    ret = common->CheckContentRights( KOma1ContentID, EPlay );
+    T1L( ret, DRMCommon::ENoRights );
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common );
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::CheckContentRightsTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::CheckFileRightsTestForFileNameL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::CheckFileRightsTestForFileNameL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::CheckFileRightsTestForFileNameL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    //Delete RO database
+    DeleteRODBL();
+
+    _LIT( KTestCase1, "TestCase1: Trying to check Oma1 file rights: Expecting ENoRights" );
+    iLog->Log( KTestCase1 );
+
+    ret = common->CheckFileRights( KOma1Content, EPlay );
+    T1L( ret, DRMCommon::ENoRights );
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common );
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::CheckFileRightsTestForFileNameL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::CheckFileRightsTestForFileHandleL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::CheckFileRightsTestForFileHandleL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::CheckFileRightsTestForFileHandleL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    TInt ret( DRMCommon::EOk );
+   
+    //File
+    RFile file;
+	RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to check Oma1 file rights: Expecting ENoRights" );
+    iLog->Log( KTestCase1 );
+
+    //Delete RO database
+    DeleteRODBL();
+
+    User::LeaveIfError( file.Open( GFs, KOma1Content, EFileRead | EFileShareReadersOrWriters ) );
+    CleanupClosePushL( file );
+
+    ret = common->CheckFileRights( file, EPlay );
+    T1L( ret, DRMCommon::ENoRights );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( &file );
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( 2, common ); //GFs, common
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::CheckFileRightsTestForFileHandleL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::IsProtectedContentTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::IsProtectedContentTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::IsProtectedContentTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    //file
+    RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    HBufC8* content( NULL );
+    TBool protection( EFalse );
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to find out is OMA1 content protected: Expecting ETrue, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    ReadFileL( GFs, KOma1Content, content );
+    CleanupStack::PushL( content );
+
+    ret = common->IsProtectedContent( *content, protection );
+    T1L( ret, DRMCommon::EOk );
+    TL( protection );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( content );
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( 2, common ); //GFs, common
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::IsProtectedContentTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::IsProtectedFileTestForFileNameL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::IsProtectedFileTestForFileNameL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::IsProtectedFileTestForFileNameL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    TBool protection( EFalse );
+    TInt ret( DRMCommon::EOk );
+    
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to find out is OMA1 file protected: Expecting ETrue, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    ret = common->IsProtectedFile( KOma1Content, protection );
+    T1L( ret, DRMCommon::EOk );
+    TL( protection );
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common );
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::IsProtectedFileTestForFileNameL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::IsProtectedFileTestForFileHandleL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::IsProtectedFileTestForFileHandleL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::IsProtectedFileTestForFileHandleL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    //file
+    RFile file;
+    RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    TBool protection( EFalse );
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to find out is OMA1 content protected: Expecting ETrue, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    User::LeaveIfError( file.Open( GFs, KOma1Content, EFileRead | EFileShareReadersOrWriters ) );
+    CleanupClosePushL( file );
+
+    ret = common->IsProtectedFile( file, protection );
+    T1L( ret, DRMCommon::EOk );
+    TL( protection );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( &file );
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( 2, common ); //GFs, common
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::IsProtectedFileTestForFileHandleL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetContentInfoTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetContentInfoTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetContentInfoTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    //file
+    RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    HBufC8* content( NULL );
+    DRMCommon::TContentProtection protection( DRMCommon::ENoDCFFile );
+    HBufC8* mime( NULL );
+    HBufC8* contentUri( NULL );
+    TUint dataLength( 0 );
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get OMA1 content info: Expecting DRMCommon::EOk, ESuperDistributable, KOma1ContentMime, KOma1ContentID, >0" );
+    iLog->Log( KTestCase1 );
+
+    ReadFileL( GFs, KOma1Content, content );
+    CleanupStack::PushL( content );
+
+    ret = common->GetContentInfo( *content, protection, mime, contentUri, dataLength );
+    T1L( ret, DRMCommon::EOk );
+    TL( protection == DRMCommon::ESuperDistributable );
+    T1L( mime->Compare( KOma1ContentMime ), 0 );
+    T1L( contentUri->Compare( KOma1ContentID ), 0 );
+    TL( dataLength > 0 );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( content );
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( 2, common ); //GFs, common 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetContentInfoTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetFileInfoTestForFileNameL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetFileInfoTestForFileNameL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetFileInfoTestForFileNameL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    DRMCommon::TContentProtection protection( DRMCommon::ENoDCFFile );
+    HBufC8* mime( NULL );
+    HBufC8* contentUri( NULL );
+    TUint dataLength( 0 );
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get OMA1 file info: Expecting DRMCommon::EOk, ESuperDistributable, KOma1ContentMime, KOma1ContentID, >0" );
+    iLog->Log( KTestCase1 );
+
+    ret = common->GetFileInfo( KOma1Content, protection, mime, contentUri, dataLength );
+    T1L( ret, DRMCommon::EOk );
+    TL( protection == DRMCommon::ESuperDistributable );
+    T1L( mime->Compare( KOma1ContentMime ), 0 );
+    T1L( contentUri->Compare( KOma1ContentID ), 0 );
+    TL( dataLength > 0 );
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common ); 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetFileInfoTestForFileNameL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetFileInfoTestForFileHandleL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetFileInfoTestForFileHandleL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetFileInfoTestForFileHandleL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    //file
+    RFile file;
+    RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    DRMCommon::TContentProtection protection( DRMCommon::ENoDCFFile );
+    HBufC8* mime( NULL );
+    HBufC8* contentUri( NULL );
+    TUint dataLength( 0 );
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get OMA1 file info: Expecting DRMCommon::EOk, ESuperDistributable, KOma1ContentMime, KOma1ContentID, >0" );
+    iLog->Log( KTestCase1 );
+
+    User::LeaveIfError( file.Open( GFs, KOma1Content, EFileRead | EFileShareReadersOrWriters ) );
+    CleanupClosePushL( file );
+
+    ret = common->GetFileInfo( file, protection, mime, contentUri, dataLength );
+    T1L( ret, DRMCommon::EOk );
+    TL( protection == DRMCommon::ESuperDistributable );
+    T1L( mime->Compare( KOma1ContentMime ), 0 );
+    T1L( contentUri->Compare( KOma1ContentID ), 0 );
+    TL( dataLength > 0 );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( &file );
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( 2, common ); //GFs, common
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetFileInfoTestForFileHandleL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetContentHeaderTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetContentHeaderTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetContentHeaderTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    //file
+    RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    HBufC8* content( NULL );
+    HBufC8* header( NULL );
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get content name -header from Oma1 content: Expecting ContentName, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    ReadFileL( GFs, KOma1Content, content );
+    CleanupStack::PushL( content );
+
+    ret = common->GetContentHeader( *content, KContentName, header );
+    CleanupStack::PushL( header );
+    T1L( ret, DRMCommon::EOk );
+    TL( header != NULL );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( 2, content ); //header, content
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( 2, common ); //GFs, common  
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetContentHeaderTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetFileHeaderTestForFileNameL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetFileHeaderTestForFileNameL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetFileHeaderTestForFileNameL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    TFileName filename( KOma1Content );
+    HBufC8* header( NULL );
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get content name -header from Oma1 file: Expecting ContentName, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    ret = common->GetFileHeader( filename, KContentName, header );
+    CleanupStack::PushL( header );
+    T1L( ret, DRMCommon::EOk );
+    TL( header != NULL );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( header );
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common ); 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetFileHeaderTestForFileNameL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetFileHeaderTestForFileHandleL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetFileHeaderTestForFileHandleL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetFileHeaderTestForFileHandleL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    //file
+    RFile file;
+    RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    HBufC8* header( NULL );
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get content name -header from Oma1 file: Expecting ContentName, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    User::LeaveIfError( file.Open( GFs, KOma1Content, EFileRead | EFileShareReadersOrWriters ) );
+    CleanupClosePushL( file );
+
+    ret = common->GetFileHeader( file, KContentName, header );
+    CleanupStack::PushL( header );
+    T1L( ret, DRMCommon::EOk );
+    TL( header != NULL );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( 2, &file ); //header, file
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( 2, common ); //GFs, common   
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetFileHeaderTestForFileHandleL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::SetContentHeaderTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::SetContentHeaderTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::SetContentHeaderTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    //file
+    RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    HBufC8* content( NULL );
+    HBufC8* header( NULL );
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to set content name -header for Oma1 content: Expecting new name to be set, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    ReadFileL( GFs, KOma1Content, content );
+    
+    ret = common->SetContentHeader( content, KContentName, KNewName );
+    CleanupStack::PushL( content );
+    T1L( ret, DRMCommon::EOk );
+    
+    ret = common->GetContentHeader( *content, KContentName, header );
+    CleanupStack::PushL( header );
+    T1L( ret, DRMCommon::EOk );
+    T1L( header->Compare( KNewName ), 0 );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( 2, content ); //header, content
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( 2, common ); //GFs, common
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::SetContentHeaderTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::SetFileHeaderTestForFileNameL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::SetFileHeaderTestForFileNameL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::SetFileHeaderTestForFileNameL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    //file
+    RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    HBufC8* content( NULL );
+    ReadFileL( GFs, KOma1Content, content );
+    CleanupStack::PushL( content );
+    WriteFileL( GFs, KTempFile, content );
+    CleanupStack::PopAndDestroy( 2, &GFs ); //file, GFs    
+
+    TFileName filename( KTempFile );
+    HBufC8* header( NULL );
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to set content name -header for Oma1 file: Expecting new name to be set, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    ret = common->SetFileHeader( KTempFile, KContentName, KNewName );
+    T1L( ret, DRMCommon::EOk );
+    
+    ret = common->GetFileHeader( filename, KContentName, header );
+    CleanupStack::PushL( header );
+    T1L( ret, DRMCommon::EOk );
+    T1L( header->Compare( KNewName ), 0 );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( header );
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common ); 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::SetFileHeaderTestForFileNameL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::SetFileHeaderTestForFileHandleL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::SetFileHeaderTestForFileHandleL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::SetFileHeaderTestForFileHandleL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    //file
+    RFile file;
+    RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    HBufC8* content( NULL );
+    ReadFileL( GFs, KOma1Content, content );
+    CleanupStack::PushL( content );
+    WriteFileL( GFs, KTempFile, content );
+    CleanupStack::PopAndDestroy( content );
+    
+    HBufC8* header( NULL );
+    TInt ret( DRMCommon::EOk );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to set content name -header for Oma1 file: Expecting new name to be set, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    User::LeaveIfError( file.Open( GFs, KTempFile, EFileWrite | EFileShareReadersOrWriters ) );
+    CleanupClosePushL( file );
+
+    ret = common->SetFileHeader( file, KContentName, KNewName );
+    T1L( ret, DRMCommon::EOk );
+    CleanupStack::PopAndDestroy( &file );
+    
+    User::LeaveIfError( file.Open( GFs, KTempFile, EFileRead | EFileShareReadersOrWriters ) );
+    CleanupClosePushL( file );
+    
+    ret = common->GetFileHeader( file, KContentName, header );
+    CleanupStack::PushL( header );
+    T1L( ret, DRMCommon::EOk );
+    T1L( header->Compare( KNewName ), 0 );
+    
+    //Passed
+    CleanupStack::PopAndDestroy( 2, &file ); //header, file
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( 2, common ); //GFs, common 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::SetFileHeaderTestForFileHandleL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetSingleRightsObjectTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetSingleRightsObjectTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetSingleRightsObjectTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+   
+    TUint32 localId( 0 );
+    CDRMRights* right( NULL );
+    TInt ret( DRMCommon::EOk );
+    
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get single RO: Expecting RO, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    //Delete RO database
+    DeleteRODBL();
+
+    localId = AddROL( KROHeadOMA1, KOma1ContentID, KROTailFullOMA1 );
+    
+    ret = common->GetSingleRightsObject( KOma1ContentID, localId, right );
+    CleanupStack::PushL( right );
+    T1L( ret, DRMCommon::EOk );
+    TL( right );
+
+    //Passed
+    CleanupStack::PopAndDestroy( right );
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common );
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetSingleRightsObjectTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetDetailedContentRightsTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetDetailedContentRightsTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetDetailedContentRightsTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+   
+    RPointerArray<CDRMRights>* rights( NULL );
+    TInt ret( DRMCommon::EOk );
+    
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get detailed rights of Oma1 full rights content: Expecting 1 RO, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    //Delete RO database
+    DeleteRODBL();
+
+    AddROL( KROHeadOMA1, KOma1ContentID, KROTailFullOMA1 );
+    
+    ret = common->GetDetailedContentRights( KOma1ContentID, rights );
+    TCleanupItem cleanup( DoResetDestroyAndClose, rights );
+    CleanupStack::PushL( cleanup );
+    
+    T1L( ret, DRMCommon::EOk );
+    T1L( rights->Count(), 1 );
+
+    //Passed
+    CleanupStack::PopAndDestroy(); //cleanup
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common );
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetDetailedContentRightsTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetDetailedFileRightsTestForFileNameL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetDetailedFileRightsTestForFileNameL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetDetailedFileRightsTestForFileNameL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+   
+    RPointerArray<CDRMRights>* rights( NULL );
+    TInt ret( DRMCommon::EOk );
+    
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get detailed rights of Oma1 full rights file: Expecting 1 RO, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    //Delete RO database
+    DeleteRODBL();
+
+    AddROL( KROHeadOMA1, KOma1ContentID, KROTailFullOMA1 );
+    
+    ret = common->GetDetailedFileRights( KOma1Content, rights );
+    TCleanupItem cleanup( DoResetDestroyAndClose, rights );
+    CleanupStack::PushL( cleanup );
+    
+    T1L( ret, DRMCommon::EOk );
+    T1L( rights->Count(), 1 );
+
+    //Passed
+    CleanupStack::PopAndDestroy(); //cleanup
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common ); 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetDetailedFileRightsTestForFileNameL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetDetailedFileRightsTestForFileHandleL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetDetailedFileRightsTestForFileHandleL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetDetailedFileRightsTestForFileHandleL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+   
+    //File
+    RFile file;
+	RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+   
+    RPointerArray<CDRMRights>* rights( NULL );
+    TInt ret( DRMCommon::EOk );
+    
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get detailed rights of Oma1 full rights file: Expecting 1 RO, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    //Delete RO database
+    DeleteRODBL();
+
+    AddROL( KROHeadOMA1, KOma1ContentID, KROTailFullOMA1 );
+    
+    User::LeaveIfError( file.Open( GFs, KOma1Content, EFileRead | EFileShareReadersOrWriters ) );
+    CleanupClosePushL( file );
+    
+    ret = common->GetDetailedFileRights( file, rights );
+    TCleanupItem cleanup( DoResetDestroyAndClose, rights );
+    CleanupStack::PushL( cleanup );
+    
+    T1L( ret, DRMCommon::EOk );
+    T1L( rights->Count(), 1 );
+
+    //Passed
+    CleanupStack::PopAndDestroy( 2, &file ); //cleanup, file
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( 2, common ); //GFs, common
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetDetailedFileRightsTestForFileHandleL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetActiveRightsTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetActiveRightsTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetActiveRightsTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+   
+    CDRMRights* right( NULL );
+    TInt ret( DRMCommon::ENoRights );
+    
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get active rights of Oma1 full rights content: Expecting RO, CDRMRights::EFullRights" );
+    iLog->Log( KTestCase1 );
+
+    //Delete RO database
+    DeleteRODBL();
+
+    AddROL( KROHeadOMA1, KOma1ContentID, KROTailFullOMA1 );
+    
+    ret = common->GetActiveRights( KOma1ContentID, EPlay,  right );
+    CleanupStack::PushL( right );
+    T1L( ret, CDRMRights::EFullRights );
+    TL( right );
+
+    //Passed
+    CleanupStack::PopAndDestroy( right ),
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common );
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetActiveRightsTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::GetContentURIListTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::GetContentURIListTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::GetContentURIListTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+   
+    RPointerArray<HBufC8>* uris( NULL );
+    TInt ret( DRMCommon::EOk );
+    
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get content uri list with Oma1 content: Expecting only Oma1 content, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    //Delete RO database
+    DeleteRODBL();
+
+    AddROL( KROHeadOMA1, KOma1ContentID, KROTailFullOMA1 );
+    
+    ret = common->GetContentURIList( uris );
+    TCleanupItem cleanup( DoResetDestroyAndClose2, uris );
+    CleanupStack::PushL( cleanup );
+    
+    T1L( ret, DRMCommon::EOk );
+    T1L( uris->Count(), 1 );
+    T1L( uris[0][0]->Compare( KOma1ContentID ), 0 );
+
+    //Passed
+    CleanupStack::PopAndDestroy(); //cleanup
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common );
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::GetContentURIListTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::DataTypesTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::DataTypesTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::DataTypesTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+   
+    TInt ret( DRMCommon::EOk );
+    
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Trying to get number of static data types: Expecting count>0, DRMCommon::EOk" );
+    iLog->Log( KTestCase1 );
+
+    TInt count( 0 );
+
+    ret = common->StaticDataTypesCount( count );
+    T1L( ret, DRMCommon::EOk );
+    TL( count > 0 );
+    
+    //Passed
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    
+    _LIT( KTestCase2, "TestCase2: Trying to get number of data types: Expecting count>0, DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+
+    ret = common->DataTypesCount( count );
+    T1L( ret, DRMCommon::EOk );
+    TL( count > 0 );
+    
+    //Passed
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    
+    _LIT( KTestCase3, "TestCase3: Trying to register a data type: Expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase3 );
+
+    _LIT8( KDataType, "foo/bar" );
+    TDataType datatype( KDataType );
+
+    ret = common->RegisterDataType( datatype );
+    T1L( ret, DRMCommon::EOk );
+    
+    //Passed
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    
+    _LIT( KTestCase4, "TestCase4: Trying to get get previously added data type: KDataType, DRMCommon::EOk" );
+    iLog->Log( KTestCase4 );
+
+    TDataType datatype2;
+
+    ret = common->SupportedDataType( count, datatype2 );
+    T1L( ret, DRMCommon::EOk );
+    T1L( datatype2.Des8().Compare( KDataType ), 0 );
+    
+    //Passed
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    
+    _LIT( KTestCase5, "TestCase5: Trying to unregister a data type: Expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase5 );
+
+    ret = common->UnRegisterDataType( count );
+    T1L( ret, DRMCommon::EOk );
+    
+    //Passed
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common ); 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::DataTypesTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+        
+// -----------------------------------------------------------------------------
+// CDRMCommonTest::MergeParentAndChildTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMCommonTest::MergeParentAndChildTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDRMCommonTest::MergeParentAndChildTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    DRMCommon* common( DRMCommon::NewL() );
+    CleanupStack::PushL( common );
+    
+    CDRMRights* right( NULL );
+    
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase1: Trying to merge NULL parent and child rights: Expecting function call to finish" );
+    iLog->Log( KTestCase1 );
+
+    common->MergeParentAndChild( right );
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    CleanupStack::PopAndDestroy( common );
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDRMCommonTest::MergeParentAndChildTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/drm_legacy_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,20 @@
+<?xml version="1.0" ?>
+<api id="63f0f2e5bef1fed147e4108b91daa4cf" dataversion="1.0">
+  <name>DRM Legacy API</name>
+  <description>Collection of deprecated DRM interfaces that should not be exported</description>
+  <type>c++</type>
+  <subsystem>omadrm</subsystem>
+  <libs>
+    <lib name="DrmDcf.lib" />
+    <lib name="DrmParsers.lib" />
+    <lib name="DrmServerInterfaces.lib" />
+  </libs>
+  <release category="domain" deprecatedsince="3.2"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  File that exports the files belonging to 
+:                DRM Legacy API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/DRMEventAddRemove.h     MW_LAYER_PLATFORM_EXPORT_PATH(DRMEventAddRemove.h)
+../inc/DRMRightsClient.h     MW_LAYER_PLATFORM_EXPORT_PATH(DRMRightsClient.h)
+../inc/DRMLicenseManager.mmi     MW_LAYER_PLATFORM_EXPORT_PATH(DRMLicenseManager.mmi)
+../inc/DRMMessageParser.h     MW_LAYER_PLATFORM_EXPORT_PATH(DRMMessageParser.h)
+../inc/Oma1DcfCreator.h     MW_LAYER_PLATFORM_EXPORT_PATH(Oma1DcfCreator.h)
+../inc/DRMEventObserver.h     MW_LAYER_PLATFORM_EXPORT_PATH(DRMEventObserver.h)
+../inc/Oma2Dcf.h     MW_LAYER_PLATFORM_EXPORT_PATH(oma2dcf.h)
+../inc/DRMNotifier.h     MW_LAYER_PLATFORM_EXPORT_PATH(DRMNotifier.h)
+../inc/DRMEvent.h     MW_LAYER_PLATFORM_EXPORT_PATH(DRMEvent.h)
+../inc/DRMLicenseChecker.mmi     MW_LAYER_PLATFORM_EXPORT_PATH(DRMLicenseChecker.mmi)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/inc/DRMEvent.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,119 @@
+/*
+* 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:  Notification Event object base class
+*
+*/
+
+
+
+#ifndef MDRMEVENT_H
+#define MDRMEVENT_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <s32strm.h> 
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+typedef TUint32 TDRMEventType;
+
+const TDRMEventType KEventNone      = 0;
+const TDRMEventType KEventAddRemove = 1;
+const TDRMEventType KEventModify    = 2;
+const TDRMEventType KEventTimeChange = 3;
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  This class offers the base class for all DRM Notification events
+*  It can be used as it is, but it is meant that Other specific to an event
+*  classes are derived from it
+*
+*  @lib DRMCommon.dll    
+*  @since S60Rel2.6
+*/
+
+class MDRMEvent
+{
+public: // Constructors and destructor
+    /**
+    * Constructor
+    *
+    * @param aEvent The event type of the object to be created
+    */
+    IMPORT_C MDRMEvent(const TDRMEventType& aEvent); 
+
+    /**
+    * Destructor
+    */
+    IMPORT_C virtual ~MDRMEvent();
+
+public: // new functions
+    /**
+    * ExternalizeL
+    *
+    * Writes the objects data into a stream
+    *
+    * @param aOutput : an output stream where to write
+    * @since S60Rel2.6
+    */
+    IMPORT_C virtual void ExternalizeL(RWriteStream& aOutput);
+    
+    /**
+    * InternalizeL
+    *
+    * Reads the objects data from a stream
+    *
+    * @param aInput : an input stream where to read from
+    * @since S60Rel2.6
+    */
+    IMPORT_C virtual void InternalizeL(RReadStream& aInput);
+
+    /**
+    * GetEventType
+    *
+    * Returns the event type of the Event in aEventType
+    *
+    * @param aEventType : Out parameter for the event type
+    * @since S60Rel2.6
+    */
+    IMPORT_C void GetEventType(TDRMEventType& aEventType) const;
+
+protected:  // Data
+
+    TDRMEventType iType;
+
+private:   
+    /**
+    * Default constructor - prevented
+    */
+    MDRMEvent( void );
+    
+    // Prohibit copy constructor
+    MDRMEvent( const MDRMEvent& );
+
+    // Prohibit assigment operator
+    MDRMEvent& operator=( const MDRMEvent& );    
+};
+
+#endif      // MDRMEVENT_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/inc/DRMEventAddRemove.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,174 @@
+/*
+* Copyright (c) 2004-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:  Rights object notification event
+*
+*/
+
+
+
+#ifndef CDRMEVENTADDREMOVE_H
+#define CDRMEVENTADDREMOVE_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <DRMEvent.h>   
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+typedef enum 
+    {
+    ERightsObjectRecieved = 0,
+    ERightsObjectDeleted = 1,
+    ERightsObjectDeletedAll = 2,
+    } TAddRemoveEventStatus;
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  DRM Rights Object notication event class
+*  Used as data structure in the notification service
+*
+*  @lib DRMCommon.dll
+*  @since S60Rel2.6
+*/
+
+class CDRMEventAddRemove : public MDRMEvent, public CBase 
+{
+public: // Constructors and destructor
+
+
+    /**
+    * NewLC
+    *
+    * Creates and instance of the CDRMEventAddRemove class and
+    * returns a pointer to it Leaves the object in the cleanup
+    * stack
+    *
+    * @return A functional CDRMEventAddRemove -object
+    * @since S60Rel3.0
+    */
+    IMPORT_C static CDRMEventAddRemove* NewLC( TAddRemoveEventStatus aStatus );
+
+    /**
+    * NewL
+    *
+    * Creates and instance of the CDRMEventAddRemove class and
+    * returns a pointer to it
+    *
+    * @return A functional CDRMEventAddRemove -object
+    * @since S60Rel3.0
+    */
+    IMPORT_C static CDRMEventAddRemove* NewL( TAddRemoveEventStatus aStatus );
+    
+    /**
+    * Destructor
+    */   
+    IMPORT_C virtual ~CDRMEventAddRemove();
+
+public: // new functions
+
+
+    /**
+    * SetContentIDL
+    *
+    * Sets the content id of the object and leaves if an error occurs
+    *
+    * @param aContentID : Descriptor containing the content id
+    * @since S60Rel2.6
+    */
+    IMPORT_C virtual void SetContentIDL( const TDesC8& aContentID );
+
+    /**
+    * Status
+    *
+    * Returns the Rights Object event status
+    *
+    * @param aEventType : Out parameter for the event type
+    * @since S60Rel2.6
+    */
+    IMPORT_C virtual TAddRemoveEventStatus Status() const;
+
+    /**
+    * GetContentIDL
+    *
+    * Returns a pointer to newly reserved buffer that containts the
+    * content id. The caller must free the memory. 
+    *
+    * @since S60Rel2.6
+    */
+    IMPORT_C virtual HBufC8* GetContentIDL() const;
+
+public: // Functions from base classes
+    /**
+    * ExternalizeL
+    *
+    * Writes the objects data into a stream
+    *
+    * @param aOutput : an output stream where to write
+    * @since S60Rel2.6
+    */
+    IMPORT_C virtual void ExternalizeL(RWriteStream& aOutput);
+
+    /**
+    * InternalizeL
+    *
+    * Reads the objects data from a stream
+    *
+    * @param aInput : an input stream where to read from
+    * @since S60Rel2.6
+    */
+    IMPORT_C virtual void InternalizeL(RReadStream& aInput);
+
+private:
+
+    /**
+    * Constructor
+    *
+    * @param  aStatus the status of the event as TAddRemoveEventStatus 
+    */
+    CDRMEventAddRemove( TAddRemoveEventStatus aStatus );
+    
+    /**
+    * C++ default constructor.
+    */
+    CDRMEventAddRemove( void );
+
+    /**
+    * First Phase constructor
+    */
+    void ConstructL();
+   
+    // Prohibit copy constructor
+    CDRMEventAddRemove( const CDRMEventAddRemove& );
+
+    // Prohibit assigment operator
+    CDRMEventAddRemove& operator=( const CDRMEventAddRemove& );
+
+    // The content identifier
+    HBufC8* iContentID;
+
+    // The status of the event
+    TAddRemoveEventStatus iStatus;
+};
+
+#endif      // CDRMEVENTADDREMOVE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/inc/DRMEventObserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2004-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:  The applications that want to use the notification service
+*                need to inherit from this class.
+*
+*/
+
+
+
+#ifndef MDRMEVENTOBSERVER_H
+#define MDRMEVENTOBSERVER_H
+
+//  INCLUDES
+#include <DRMEvent.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  This class offers abstract interface to receive DRM notifications
+*  from DRM notifier.
+*
+*  @lib DRMCommon.dll
+*  @since S60Rel2.6
+*/
+class MDRMEventObserver
+{
+public: // New functions
+    /**
+    * HandleNotificationL
+    *
+    * Callback function for the event notifications
+    * The MDRMEvent object ownership stays with the notifier,
+    * do not delete it
+    *
+    * @param aEvent : an object of the type MDRMEvent
+    * @since S60Rel2.6
+    */
+   virtual void HandleEventL( MDRMEvent* aEvent ) = 0;
+};
+
+#endif      // MDRMEVENTOBSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/inc/DRMLicenseChecker.mmi	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* 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 the License "Symbian Foundation License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MMP include file. Contains files to link against when using
+*                the License Checker
+*
+*/
+
+LIBRARY       DRMLicenseChecker.lib
+
+LIBRARY         DrmParsers.lib
+LIBRARY         DrmDcf.lib
+LIBRARY         DrmRights.lib
+LIBRARY         DrmServerInterfaces.lib
+LIBRARY         DRMCommon.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/inc/DRMLicenseManager.mmi	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,29 @@
+/*
+* 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 the License "Symbian Foundation License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: MMP include file. Contains files to link against when using
+*                the License Manager
+*
+*/
+
+LIBRARY         DRMLicenseManager.lib
+LIBRARY         ezlib.lib
+LIBRARY         efsrv.lib
+LIBRARY         estor.lib
+LIBRARY         charconv.lib
+
+LIBRARY         DrmParsers.lib
+LIBRARY         DrmDcf.lib
+LIBRARY         DrmRights.lib
+LIBRARY         DrmServerInterfaces.lib
+LIBRARY         DRMCommon.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/inc/DRMMessageParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,380 @@
+/*
+* 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:  Interface to BbB encryption.
+*
+*/
+
+
+
+#ifndef CDRMMESSAGEPARSER_H
+#define CDRMMESSAGEPARSER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <s32strm.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class COma1DcfCreator;
+class CDRMRights;
+class RDRMRightsClient;
+
+// CLASS DECLARATION
+
+/**
+*  This class handles all DRM Message parsing and B64 decoding, 
+*  and feeds the resulting data either to 
+*  DRMAuthenticated::Encrypt[Initialize|Update|Finalize]L or writes the 
+*  data directly to given output stream (DCF in DRM Message).
+*  The internal state iState is modified in quite many places in the
+*  class methods.
+*
+*  @lib DRMAuthenticated.dll
+*  @since S60Rel2.5
+*/
+NONSHARABLE_CLASS(CDRMMessageParser): public CBase
+    {
+public:  // Constructors and destructor
+     enum TDRMMessageParserState
+         {
+         ESearchingBoundary =       0x00, // The first operation to do.
+         EGotBoundary =             0x01,
+         EReadingHeaderPart =       0x02,
+         EReadingRightsPart =       0x04,
+         EGotRightsPart =           0x08,
+         EReadingContentPart =      0x10,
+         EGotContentPart =          0x20,
+         EGotContentEncoding =      0x40,
+         EBase64 =                  0x80,
+         EGotContentType =          0x100,
+         EDCFFile =                 0x200,
+         EDCFURIModified =          0x400,
+         EDCFHeadersModified =      0x800,
+         EEncryptStreamOk =		   0x1000,
+         EFLContent =               0x2000,
+         EAllDone =                 0x4000,
+         EBroken =                  0x8000
+         };
+    /**
+     * Two-phased constructor.
+     */
+    IMPORT_C static CDRMMessageParser* NewL( void );
+    
+    /**
+     * Destructor.
+     */
+    IMPORT_C virtual ~CDRMMessageParser( void );
+    
+    
+public: // New functions
+    
+    /**
+    * InitializeMessageParserL
+    *
+    * @since 2.0
+    * DRM message Block-by-Block parser initialization method must be called 
+    * once before ProcessMessageDataL can be called. All processed data is 
+    * written to given write stream when calling ProcessMessageDataL and 
+    * FinalizeMessageParserL methods.
+    * 
+    * InitializeMessageParserL, ProcessMessageDataL and FinalizeMessageParserL
+    * use EncryptInitializeL, EncryptUpdateL and EncryptFinalizeL internally,
+    * so one instance of DRMAuthenticated can only process one encryption
+    * session at a time.
+    * @param aOutput Write stream where the processed data is written.
+    */
+    IMPORT_C void InitializeMessageParserL( 
+        RWriteStream& aOutput );
+
+    /**
+    * ProcessMessageDataL
+    *
+    * @since 2.0
+    * This method processes the given part of DRM message data. If 
+    * there is some data to be returned (there might not always be),
+    * the processed data is written to the output stream.
+    * @param aMessageData Part of DRM message data to be processed.
+    */
+    IMPORT_C void ProcessMessageDataL( 
+        const TDesC8& aMessageData );
+
+    /**
+    * FinalizeMessageParserL
+    * 
+    * @since 2.0
+    * This method finalizes the BbB parsing of DRM message. The method
+    * flushes the internal buffers returns any remaining processed data
+    * to output stream depending on the initialization. After calling this 
+    * method the parser needs to 
+    * be re-initialized in order to process more data.
+    */ 
+    IMPORT_C void FinalizeMessageParserL();
+    
+    /**
+    * ProcessMessage
+    *
+    * Takes a memory buffer containing a DRM message, splits the message 
+    * into the contained parts and processes the parts. After completion 
+    * of the function, the input buffer contains the DCF from the message, 
+    * the Rights Object is saved to the rights database..
+    *
+    * @since  2.0
+    * @param  aDRMMessage: In/out parameter containing the DRM message 
+    *         before the function call and the DCF after the function call 
+    * @return EOk if the message has been processed successfully
+    */
+    IMPORT_C TInt ProcessMessage(
+        HBufC8*& aDRMMessage);
+    
+    /**
+    * ProcessRightsObject
+    *
+    * Takes a memory buffer containing a Rights Object and saves it to the 
+    * rights database. Returns the detailed rights specification of the
+    * Rights Object.
+    *
+    * @since  2.0
+    * @param  aRightsObject: Buffer containing the rights object
+    * @param  aRightsDetail: Out parameter for the details of the rights
+    *         in the rights object
+    * @return EOk if the rights object could be stored successfully
+    */
+    IMPORT_C TInt ProcessRightsObject(
+        const TDesC8& aRightsObject, 
+        RPointerArray<CDRMRights>& aRightsDetail);
+    
+        /** 
+        * Cleans up the internal storages in case of 
+        * CleanupStack::PopAndDestroy()
+        */
+        void Release( void );
+
+public: // Functions from base classes
+    
+protected:  // New functions
+    
+    /**
+    * C++ default constructor.
+    */
+    CDRMMessageParser( void );
+
+protected:  // Functions from base classes
+    
+private:
+    
+    /**
+    * By default Symbian 2nd phase constructor is private.
+    */
+    void ConstructL( void );
+    
+    /**
+    * Processes the data from DRM Message body.
+    */
+    void HandleContentDataL( void );
+
+    /**
+    * Processes the rights object data part from DRM Message.
+    */
+    void HandleRightsDataL( void );
+
+    /**
+    * Tries to locate the boundary separator from the beginning of the 
+    * message, and if a boundary is found, it is stored.
+    */
+    void FindBoundaryL( void );
+
+    /**
+    * Parses the DRM Message header part.
+    */
+    void ReadHeaderL( void );
+    
+    /**
+    * Returns a single line from the message, ending to \n.
+    * @return Reference to a single line in the message.
+    */
+    TPtrC8 GetLineL( void );
+
+    /**
+    * Extracts a MIME header value from the given line. Ignores
+    * possible parameters.
+    * @param aLine Line to be searched for the header value.
+    * @return Reference to the header value found.
+    */
+    TPtrC8 HeaderValueL( const TDesC8& aLine );
+    
+    /**
+    * Compresses the internal buffers discarding all already used
+    * data.
+    */
+    void CompressInputBuffer( void );
+    
+    /**
+    * Prepares the content data to be encrypted/processed, i.e.
+    * constructs a descriptor to iInputBuffer which can then be
+    * processed.
+    */
+    void PrepareContentDataL( void );
+
+    /**
+    * Do base64 decoding to the given descriptor. 
+    * @param aData in/out descriptor: after successful call, the 
+    * descriptor contains base64 decoded data.
+    * @return How many base64 encoded bytes from aData was consumed.
+    */ 
+    TInt HandleBase64DataL( TPtrC8& aData );
+
+    /**
+    * Extracts the endline characters from the given descriptor.
+    * @param aBuf A single line to be stripped from endline characters.
+    * The descriptor length is changed to corresponding value.
+    */
+    void StripEndLineL( TPtrC8& aBuf );
+
+    /**
+    * Tells whether the given line is a boundary line, and if so, is it
+    * the final boundary marking the end of the message.
+    * @param aLine Line.
+    * @param aLast Out-parameter: if the line is a boundary line and this
+    * is the last boundary, aLast == ETrue after the call.
+    * @return Truth value.
+    */
+    TBool IsBoundary( const TDesC8& aLine, 
+                      TBool& aLast ) const;
+    
+    /**
+    * This method generates a FL rights object if the message being
+    * processed is a FL message. If the message is a CD message,
+    * no rights object. Saves the rights object into rights database.
+    */
+    void HandleFlContentL( void );
+    
+    /**
+    * Helper method for HandleFlContentL: saves the RO to the database.
+    * @param aCID Content-ID.
+    * @param aData rights data.
+    */
+    void ProcessRightsDataL( const TDesC8& aCID,
+                            const TDesC8& aData );
+                            
+    /**
+    * Writes the (base64 decoded) data to EncryptUpdateL or directly to 
+    * the output stream. Modifies the content-type of DCF file in case 
+    * "DCF inside DRM Message" case.
+    * @param aData Data to be encrypted / written to the stream.
+    */
+    void ProcessContentDataL( TPtrC8& aData );
+
+    void EnsureFLRightsExistL( RDRMRightsClient& aClient, CDRMRights** aOutput );
+    /**
+    * Checks whether the given character is valid base64 encoded character.
+    * @param aChar Character to be checked.
+    * @return Truth value.
+    */
+    TBool ValidB64CharL( const TUint8 aChar );
+
+    /** 
+    * Sets an internal state bit.
+    * @param aBit New state bit to be enabled.
+    */
+     void SetBit( TUint32 aBit );
+
+    /**
+    * Clears an internal state bit.
+    * @param aBit The state bit to be cleared.
+    */        
+     void ClearBit( TUint32 aBit );
+
+    /**
+    * Do cleanup operations & update internal state to indicate an 
+    * error occured.
+    * @param aError Error code which is thrown. KErrNone does not leave.
+    */
+    void SetBrokenStateL( const TInt aError );
+    
+    void Reset();
+    
+    void DoProcessMessageL( HBufC8*& aDRMMessage );
+    void DoProcessRightsObjectL( const TDesC8& aRightsObject, 
+                               RPointerArray<CDRMRights>& aRightsDetail );
+    void DeletePermission();
+    void InitDCFBufferL();
+    
+    void CreateCDCIDL( HBufC8*& aCID );
+    TInt RetrieveFlRights();
+    void ProcessDCFDataL( TPtrC8& aData );
+    
+    void FillDCFBufferL( TPtrC8& aData );
+    void CompressDCFBuffer( const TInt aHowMuch );
+    TBool FindDCFHeader( const TDesC8& aString,
+                         TUint& aOffset,
+                         TUint& aLength );
+
+    HBufC8* EncryptDCFFieldLC( const TDesC8& aOldHeader );
+    
+    // Prohibit copy constructor if not deriving from CBase.
+    CDRMMessageParser( const CDRMMessageParser& );
+    // Prohibit assigment operator if not deriving from CBase.
+    CDRMMessageParser& operator=( const CDRMMessageParser& );
+    
+public:     // Data
+    TBool iDoPop;
+    
+protected:  // Data
+    
+private:    // Data
+    // Given stream
+    RWriteStream iOutputStream;
+    
+    COma1DcfCreator* iDcfCreator;
+    
+    // CD rights object.
+    HBufC8* iRightsData;
+    CDRMRights* iRightsObject;
+    
+    // Boundary obtained from the given data.
+    HBufC8* iBoundary;
+    
+    // Content type from the given data.
+    HBufC8* iContentType;
+    
+    // Temporary store for DCF data.
+    HBufC8* iDCFBuffer;
+    
+    // Current internal state.
+    TUint32 iState;
+    
+    // DCF header sizes.
+    TUint32 iDCFHeaderSize[ 2 ];
+    
+    // Input cache & counter.
+    TPtr8 iInputBuffer;
+    TInt iUsedFromInput;
+    
+    // Temporary storage & counter
+    TPtrC8 iInputData;
+
+public:     // Friend classes
+protected:  // Friend classes
+private:    // Friend classes
+};
+
+#endif      // CDRMMESSAGEPARSER_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/inc/DRMNotifier.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,160 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class handles registering and unregistering of
+*                DRM event observers to DRM notifier, and sending
+*                DRM notifications to other registered observers.
+*
+*/
+
+
+
+#ifndef CDRMNOTIFIER_H
+#define CDRMNOTIFIER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <DRMEventObserver.h>
+#include <DRMEvent.h>
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CDRMEventHandler;
+
+// CLASS DECLARATION
+
+/**
+ *  With this class an application can register to receive DRM related 
+ *  notifications.
+ *
+ *  @lib DRMCommon.dll
+ *  @since S60Rel2.6
+ */
+class CDRMNotifier : public CBase
+{
+public:  // Constructors and destructor   
+    /**
+    * Two-phased constructor.
+    */
+    IMPORT_C static CDRMNotifier* NewL( void );
+   
+    /**
+    * Two-phased constructor.
+    */
+    IMPORT_C static CDRMNotifier* NewLC( void );
+   
+    /**
+    * Destructor.
+    */
+    IMPORT_C virtual ~CDRMNotifier();
+   
+public: // New functions   
+    /**
+    * RegisterEventObserverL
+    *
+    * Registers a new event observer to DRM Notifier. Listens to all events
+    * of the given type
+    *
+    * @since S60Rel2.6
+    * @param aObserver Observer.
+    * @param aEvent the type of event to listen to
+    * @return none, leaves with Symbian OS error code if an error occurs
+    */
+    IMPORT_C void RegisterEventObserverL( MDRMEventObserver& aObserver , 
+                                          const TDRMEventType& aEvent);   
+    /**
+    * UnRegisterEventObserverL
+    *
+    * Unregisters existing event observer from DRM Notifier.
+    *
+    * @since S60Rel2.6
+    * @param aObserver Observer.
+    * @param aEvent the type of event to unregister
+    * @return none, leaves with Symbian OS error code if an error occurs
+    */
+    IMPORT_C void UnRegisterEventObserverL( MDRMEventObserver& aObserver, 
+                                            const TDRMEventType& aEvent);
+    /**
+    * RegisterEventObserverL
+    *
+    * Registers a new event observer to DRM Notifier. Only recieves
+    * notification when the rights accociated with the given content id
+    * are handled
+    *
+    * @since S60Rel2.6
+    * @param aObserver Observer
+    * @param aEvent the type of event to listen to
+    * @param aContentID the specific content id to listen to
+    * @return none, leaves with Symbian OS error code if an error occurs
+    */
+    IMPORT_C void RegisterEventObserverL( MDRMEventObserver& aObserver , 
+                                          const TDRMEventType& aEvent,
+                                          const TDesC8& aContentID);
+    /**
+    * UnRegisterEventObserverL
+    *
+    * Unregisters existing event observer from DRM Notifier.
+    *
+    * @since S60Rel2.6
+    * @param aObserver Observer.
+    * @param aEvent the type of event to listen to
+    * @param aContentID the specific content id to listen to
+    * @return none, leaves with Symbian OS error code if an error occurs
+    */
+    IMPORT_C void UnRegisterEventObserverL( MDRMEventObserver& aObserver, 
+                                            const TDRMEventType& aEvent,
+                                            const TDesC8& aContentID);
+
+    /**
+    * SendEventL
+    *
+    * Sends a notification to registered observers
+    *
+    * @since S60Rel2.6
+    * @param aEvent  the event to be sent
+    * @param aStatus  the request status for the event, will be updated when
+    *                 the event has been sent
+    * @return none
+    */
+    IMPORT_C void SendEventL( MDRMEvent& aEvent, TRequestStatus& aStatus ); 
+   
+private:
+   
+    /**
+    * C++ default constructor.
+    */
+    CDRMNotifier( void );
+
+    /**
+    * First Phase constructor
+    */
+    void ConstructL();
+   
+    // Prohibit copy constructor if not deriving from CBase.
+    CDRMNotifier( const CDRMNotifier& );
+
+    // Prohibit assigment operator if not deriving from CBase.
+    CDRMNotifier& operator=( const CDRMNotifier& );
+
+  private:    // Data
+   // Event handler.
+   CDRMEventHandler* iEventHandler;
+};
+
+#endif      // CDRMNOTIFIER_H   
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/inc/DRMRightsClient.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,731 @@
+/*
+* Copyright (c) 2003-2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class is the client side handle of DRM Engine
+*
+*/
+
+
+
+#ifndef RDRMRIGHTSCLIENT_H
+#define RDRMRIGHTSCLIENT_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <Oma2Agent.h>
+#include <DRMTypes.h>
+
+using namespace ContentAccess;
+
+// CONSTANTS
+// MACROS
+
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class RFs;
+class CDRMPermission;
+
+// CLASS DECLARATION
+
+/**
+*  This class is the client side interface for DRM3 Rights Server.
+*  This class can be used to access the DRM Rights Database.
+*
+*  @lib DRM Core
+*  @since S60 Release 2.5
+*/
+class RDRMRightsClient : public RSessionBase
+    {
+    public:  // Constructor & destructor
+        /**
+         * C++ default constructor.
+         */
+        IMPORT_C RDRMRightsClient();
+        
+        /** 
+         * Destructor.
+         */
+        IMPORT_C virtual ~RDRMRightsClient();
+        
+        /** 
+         * This method opens the connection between the client and the server.
+         * @since 2.5
+         * @return Error code. KErrNone if the operation is successful.
+         */
+        IMPORT_C TInt Connect();
+        
+        /**
+         * This function closes the connection between the client and the server.
+         * It is safe to call this method even if connection is not established.
+         * @since S60Rel2.5
+         */ 
+        IMPORT_C void Close();
+        
+    public: // New functions
+        
+        /**
+        * Starts the rights server in case it is not yet started. It is
+        * safe to call this method even if the server is running.
+        * @since S60Rel3.0
+        * @return Symbian OS error code if any.
+        */ 
+        IMPORT_C static TInt StartServer();
+        
+        /**
+         * Adds the given rights object into rights database.
+         * @since S60Rel2.5
+         * @param aCEK CEK.
+         * @param aRightsObject Rights object to be added.
+         * @param aCID Content-ID.
+         * @return Error code.
+         */ 
+        IMPORT_C TInt AddRecord(
+            const TDesC8& aCEK,
+            const CDRMPermission& aRightsObject,
+            const TDesC8& aCID,
+            TDRMUniqueID& aID );
+        
+        /**
+         * Adds a protected RO where the CEK wrapped with another key.
+         * @since 3.0
+         * @param aProtectedCek wrapped CEK
+         * @param aDomainPermission Domain or regular permission
+         * @param aRightsObject Rights object to be added.
+         * @param aCID Content-ID.
+         * @return Error code.
+         */ 
+
+        IMPORT_C TInt AddProtectedRecord(
+            const TDesC8& aProtectedCek,
+            TBool aDomainRecord,
+            const CDRMPermission& aRightsObject,
+            const TDesC8& aCID,
+            TDRMUniqueID& aID ); // Unique ID, out-parameter
+
+        /**
+         * Gets all database entries related to specified Content-ID.
+         * @since S60Rel2.5
+         * @param aId Content ID.
+         * @param aRightsList List of rights objects.
+         */
+        IMPORT_C void GetDBEntriesL(
+            const TDesC8& aId,
+            RPointerArray< CDRMPermission >& aRightsList );
+        
+        /**
+         * Gets a database entry related to given content ID and unique ID.
+         * @since S60Rel2.5
+         * @param aContentID Content-ID.
+         * @param aUniqueID Unique identifier.
+         * @return Associated rights object.
+         */
+        IMPORT_C CDRMPermission* GetDbEntryL(
+            const TDesC8& aContentID,
+            const TDRMUniqueID& aUniqueID );
+        
+        /** 
+         * Deletes all rights objects with specified Content-ID.
+         * @since S60Rel2.5
+         * @param aContentID Content-ID of the rights objects to be deleted.
+         * @return Error code. KErrNone if successful.
+         */ 
+        IMPORT_C TInt DeleteDbEntry( const TDesC8& aContentID );
+        
+        /**
+         * Deletes one rights object, identified by Content-ID and unique ID.
+         * @since S60Rel2.5
+         * @param aContentID Content-ID of the rights object.
+         * @param aUniqueID Unique ID.
+         * @return Error code. KErrNone if successful operation.
+         */
+        IMPORT_C TInt DeleteDbEntry(
+            const TDesC8& aContentID, 
+            const TDRMUniqueID& aUniqueID );
+        
+        /**
+         * Exports all content ID's from the database to a file.
+         * @since S60Rel2.5
+         * @param aFileName Out-parameter: contains the name of the file
+         *                  if the method completes with KErrNone. The 
+         *                  descriptor parameter is assumed to be large 
+         *                  enough. The caller is responsible of  deleting 
+         *                  the file afterwards.       
+         * @return Error code. KErrNone if successful operation.
+         */
+        IMPORT_C TInt ExportContentIDList( TDes& aFileName );
+        
+        /**
+         * This method exports all Content-IDs from the database file
+         * in an array. The caller is responsible of destroying the array
+         * afterwards.
+         * @since S60Rel2.5
+         * @param aCIDList An out-parameter: contains the Content-IDs 
+         *        after successful return.
+         * @return A Symbian OS error code or DRM3 error code. KErrNone in
+         *         successful operation.
+         */
+        IMPORT_C TInt ExportContentIDList( RPointerArray< HBufC8 >& aCIDList );
+        
+        /** 
+         * Returns the decryption key to the content.
+         *
+         * @since 2.5
+         * @param aIntent In-parameter: How the content is going to be consumed.
+         * @param aContentID Content-ID of the related content.
+         * @param aKey Out-parameter: Contains the key if function returns 
+         *             successfully.
+         * @return Error code. KErrNone if successful operation.
+        */
+        IMPORT_C TInt GetDecryptionKey(
+            const TInt aIntent,
+            const TDesC8& aContentID,
+            TDes8& aKey );
+        
+        /** 
+         * This method checks whether the caller has sufficient rights over
+         * the content at this very moment.
+         * @param aIntent Intended usage.
+         * @param aContentID Content-ID.
+         * @return KErrNone in successful
+         * completition.
+         */
+        IMPORT_C TInt CheckRights(
+            const TInt aIntent,
+            const TDesC8& aContentID,
+            TUint32& aRejection );
+            
+        /** 
+         * This method checks whether the caller has sufficient rights over
+         * the content at this very moment. It also returns the active rights.
+         * @param aIntent Intended usage.
+         * @param aContentID Content-ID.
+         * @return Permission for the intent. NULL if no permissions exist
+         * completition.
+         */
+        IMPORT_C CDRMPermission* GetActiveRightsL(
+            const TInt aIntent,
+            const TDesC8& aContentID,
+            TUint32& aRejection );           
+       
+        /**
+        * Sets the key for subsequent encryption and decryption operations.
+        * The key is stored on the server side in the session and will
+        * be usable until the session is closed. The key will be fetched
+        * from the rights database by looking up the content ID.
+        *
+        * @param aContentId Content ID to get the key for
+        * @return KErrNone if the key was initialized properly
+        */                                       
+        IMPORT_C TInt InitializeKey( const TDesC8& aContentId );
+        
+        /**
+        * Similar to InitializeKeyL, but sets the key by using a group
+        * key as the input.
+        *
+        * @param aContentId Group ID to get the key for
+        * @param aGroupKey Group key
+        * @param aEncryptionMethod encryption method
+        * @return KErrNone if the key was initialized properly
+        */                                       
+        IMPORT_C TInt InitializeGroupKey(
+            const TDesC8& aGroupId,
+            const TDesC8& aGroupKey,
+            TEncryptionMethod aMethod );
+        
+        /**
+        * Encrypts data using the session key. The data parameter must
+        * have enough space to accomodate for the addition of the paddding
+        * if it shall be added (up to 32 bytes more data)
+        *
+        * @param aIv AES CBC initialization vector
+        * @param aData data to be encrypted, encrypted data on return
+        * @return KErrNone if the encryption succeeded
+        */                                       
+        IMPORT_C TInt Encrypt(
+            const TDesC8& aIv,
+            TPtr8& aData,
+            TBool aAddPadding = EFalse );
+        
+        /** 
+         * Decrypts data using the session key. Padding will be removed
+         * if requested.
+         *
+        * @param aIv AES CBC initialization vector
+        * @param aData data to be encrypted, encrypted data on return
+        * @return KErrNone if the encryption succeeded
+         */
+        IMPORT_C TInt Decrypt(
+            const TDesC8& aIv,
+            TPtr8& aData,
+            TBool aRemovePadding = EFalse );        
+        /**
+         * Returns the amount of unique URIs in the database.
+         * @since 2.5
+         * @return => 0: Amount of ROs,
+         *         < 0 : error.
+         */
+        IMPORT_C TInt Count();
+
+        /**
+         * Empties the rights database totally.
+         * @since 2.5
+         * @return Symbian OS / DRM3 wide error code.
+         */
+        IMPORT_C TInt DeleteAll();
+
+        /**
+         * Consume the right with specific contentID and intent
+         * @since 2.5
+         * @return Symbian OS / DRM3 wide error code.
+         */
+		IMPORT_C TInt Consume( 
+			const TInt aIntent, 
+			const TDesC8& aContentID);
+
+        /**
+         * Check if Consume is possible. Does not consume rights.
+         * @since 3.0
+         * @return KErrNone if Consume is possible
+         */
+		IMPORT_C TInt CheckConsume( 
+			const TInt aIntent, 
+			const TDesC8& aContentID);
+
+        /**
+         * Calculate the padding amount for a data block
+         * @since 3.0
+         * @return The padding value
+         */
+        IMPORT_C TInt CalculatePadding(
+            const TDesC8& aLastTwoDataBlocks);
+
+        IMPORT_C TInt ForwardLockURI( HBufC8*& aURI );
+        
+        /**
+        * AddDomainRO
+        *
+        * Add the xml representation of the domain RO to the database
+        *
+        * @param    aRoId : the rights object id of the domain ro
+        * @param    aXmlData : the xml data of the rights object
+        * @return   Symbian OS error code
+        */
+        IMPORT_C TInt AddDomainRO(
+            const TDesC8& aRoId, 
+            const TDesC8& aXmlData );        
+
+        /**
+        * GetDomainROL
+        *
+        * Get the xml representation of the domain RO from the database
+        *
+        * @param    aRoId : the rights object id of the domain ro
+        * @return   Functional RO xml representation or Leave with
+        *           Symbian OS error code
+        */
+        IMPORT_C HBufC8* GetDomainROL( const TDesC8& aRoId ); 
+
+        /**
+        * GetDomainRoForCidL
+        *
+        * Get the domain RO for a content ID from the database
+        *
+        * @param    aContentId the content ID of the domain ro
+        * @param    aRoList list of domain rights objects for this ID
+        * @return   Symbian OS error code
+        */
+        IMPORT_C void GetDomainRosForCidL(
+            const TDesC8& aContentId,
+            RPointerArray<HBufC8>& aRoList );
+
+        /**
+        * DeleteDomainRO
+        *
+        * Delete the xml representation of the domain RO from the database
+        *
+        * @param    aRoId : the rights object id of the domain ro
+        * @return   Symbian OS error code
+        */
+        IMPORT_C TInt DeleteDomainRO( const TDesC8& aRoId );          
+        
+        /**
+        * IsInReplayCache
+        *
+        * Checks whether the protected RO identified by aID and aTime 
+        * has already been added to Replay Cache.
+        *
+        * @param aID:       rights ID
+        * @param aTime:     RO timestamp
+        * @param aInCache:  out-parameter: boolean result
+        * @return Symbian OS error code
+        */
+        IMPORT_C TInt IsInCache( const TDesC8& aID, 
+                                 const TTime& aTime, 
+                                 TBool& aInCache );
+
+        /**
+        * IsInReplayCache
+        *
+        * Checks whether the protected RO identified by aID
+        * has already been added to Replay Cache. 
+        *
+        * @param aID:       rights ID
+        * param aInCache:  out-parameter: boolean result
+        * @return Symbian OS error code
+        */
+        IMPORT_C TInt IsInCache( const TDesC8& aID,
+                                 TBool& aInCache );
+                                       
+        /**
+        * AddToReplayCache
+        *
+        * Adds an entry to Replay Cache. 
+        * Note! Does not check whether the entry is already in cache. Use
+        * IsInCache() first to determine whether the entry already exists.
+        *
+        * @param aID:       RO ID
+        * @param aTIme:     RO timestamp
+        * @return Symbian OS error code.
+        */                                       
+        IMPORT_C TInt AddToCache( const TDesC8& aID,
+                                  const TTime& aTime );
+                                  
+        /**
+        * AddToReplayCache
+        *
+        * Adds an entry to Replay Cache. 
+        * Note! Does not check whether the entry is already in cache. Use
+        * IsInCache() first to determine whether the entry already exists.
+        *
+        * @param aID:       RO ID
+        * @return Symbian OS error code.
+        */                                       
+        IMPORT_C TInt AddToCache( const TDesC8& aID );
+        
+        /**
+        * DeleteExpiredPermissions
+        *
+        * Deletes expired permissions from the rights database
+        * Note this function will possibly take a lot of time to complete
+        * and if the drm time is not available it does not touch any time
+        * based rights
+        *
+        * @param aStatus:	asynchronous request status
+        * @return 	none        
+        */
+        IMPORT_C void DeleteExpiredPermissions( TRequestStatus& aStatus );
+        
+        /**
+         * SetEstimatedArrival
+         *
+         * Sets the time in which the rights object should arrive
+         *
+         * @since   3.0
+         * @param   aContentID : content URI
+         * @param   aDeltaSeconds : time in seconds to wait for rights
+         * @return  Symbian OS error code if any.
+         */
+        IMPORT_C TInt SetEstimatedArrival( const TDesC8& aContentID,
+                                   TTimeIntervalSeconds aDeltaSeconds );
+                                  
+        /**
+         * GetEstimatedArrival
+         *
+         * Gets the time in which the rights object should arrive
+         *
+         * @since   3.0
+         * @param   aContentID : content URI
+         * @param   aDeltaSeconds : time in seconds to wait for rights
+         *                          -1 if the content should have arrived
+         * @return  Symbian OS error code if any.
+         *          KErrNotFound if the content is not in the list       
+         */
+        IMPORT_C TInt GetEstimatedArrival( const TDesC8& aContentID,
+                                 TTimeIntervalSeconds& aDeltaSeconds );  
+                                 
+        
+        /**
+        * SetName
+        *
+        * Associates a human-readable name to given content-ID.
+        *
+        * @since    3.0
+        * @param    aContentID: Content URI.
+        * @param    aName: New name.
+        * @return   Symbian OS error code if any
+        */
+        IMPORT_C TInt SetName( const TDesC8& aContentID,
+                               const TDesC& aName );
+        
+        /**
+        * GetName
+        * 
+        * Retrieves the human-readable name associated to given content-ID
+        * 
+        * @since    3.0
+        * @param    aContentID: Content URI.
+        * @param    aName:      Out-parameter: The name associated to content.
+        * @return   Symbian OS error code if any. KErrNotFound in case the
+        *           content URI is not in the database.
+        */
+        IMPORT_C TInt GetName( const TDesC8& aContentID,
+                               HBufC*& aName );
+        
+        /**
+        * Cancel
+        * 
+        * Cancel any asynchronous operation.
+        *
+        * @since    3.0
+        */
+        IMPORT_C void Cancel();
+        
+        /**
+        * GetUdtData
+        * 
+        * Retrieves the udt data from the server
+        * 
+        * @since    3.0
+        * @param    aUdtData: the udt data
+        * @return   Symbian OS error code if any. KErrNotFound in case the
+        *           content URI is not in the database.
+        */
+        IMPORT_C TInt GetUdtData( TDes8& aUdtData );        
+
+        /**
+        * InitializeUdt
+        * 
+        * Initializes the user data transfer
+        * 
+        * @since    3.0
+        * @param    aKey : Encryption key of the udt file encrypted with the
+        *                  device public key
+        * @return   Symbian OS error code if any. KErrNotFound in case the
+        *           content URI is not in the database.
+        */
+        IMPORT_C TInt InitiateUdt( const TDesC8& aKey );
+
+
+        /**
+         * Initializes the export all orphaned content ID's.
+         * When the request completes, you can ask for the
+         * contents with the ExportOrphanedContentIdList functions
+         *
+         * @since   3.0
+         * @param   aPerformScan : ETrue if file system scan needs to be
+         *                         performed
+         *                         EFalse if not
+         * @param   aStatus : Request status for the asynchronous call           
+         * @return  None
+         */
+        IMPORT_C void InitOrphanedContentIdList( TBool aPerformScan,
+                                                 TRequestStatus& aStatus );
+
+        
+        /**
+         * Exports all orphaned content ID's from the database to a file.
+         * @since   3.0
+         * @param   aFileName Out-parameter: contains the name of the file
+         *                  if the method completes with KErrNone. The 
+         *                  descriptor parameter is assumed to be large 
+         *                  enough. The caller is responsible of  deleting 
+         *                  the file afterwards.
+         * @param   aPerformScan : ETrue if file system scan needs to be
+         *                         performed
+         *                         EFalse if not       
+         * @return  Error code. KErrNone if successful operation.
+         */
+        IMPORT_C TInt ExportOrphanedContentIdList( TDes& aFileName );        
+                 
+        /**
+         * Exports all orphaned content ID's from the database
+         * in an array. The caller is responsible of destroying the array
+         * afterwards.
+         * @since   3.0
+         * @param   aContentIdList : An out-parameter: contains the Content-IDs 
+         *                           after successful return.
+         * @param   aPerformScan : ETrue if file system scan needs to be
+         *                         performed
+         *                         EFalse if not           
+         * @return  A Symbian OS error code or DRM error code. KErrNone in
+         *          successful operation.
+         */
+        IMPORT_C TInt ExportOrphanedContentIdList( 
+                        RPointerArray<HBufC8>& aContentIdList); 
+
+        IMPORT_C TInt EncodeRightsIssuerField( const TDesC8& aOldValue,
+                                               HBufC8*& aNewValue );
+                                               
+        IMPORT_C TInt DecodeRightsIssuerField( const TDesC8& aEncoded,
+                                               HBufC8*& aDecoded );
+                                               
+        /**
+         * Sets the authentication seed data for a content ID
+         * @since   3.0
+         * @param   aContentID Content ID
+         * @param   aSeed Authentication seed
+         * @return  Error code. KErrNone if successful operation.
+         */
+        IMPORT_C TInt SetAuthenticationSeed( const TDesC8& aContentId,
+                                             const TDesC8& aSeed );
+                                               
+        /**
+         * GSets the authentication seed data for a content ID
+         * @since   3.0
+         * @param   aContentID Content ID
+         * @param   aSeed Authentication seed
+         * @return  Error code. KErrNone if successful operation.
+         */
+        IMPORT_C TInt GetAuthenticationSeed( const TDesC8& aContentId,
+                                             TDes8& aSeed );
+        /**
+         * Integrity protection for protected ROs. Calculates HMAC value
+         * usign aSignedInfoElement and MAC key. MAC key is unwrapped
+         * in AddRecord method. So AddRecord must be called successfully
+         * before this method can be called.
+         *
+         * @since   3.0
+         * @param   aSignedInfoElement Complete XML ro element <roap:ro>
+         * @param   aMacValue  MAC value from protectedRO element
+         * @return  Error code. KErrNone if successful operation.
+                    KErrRightsServerMacFailed, if MAC validation fails 
+         */                               
+        IMPORT_C TInt VerifyMacL( const TDesC8& aSignedInfoElement,
+                                  const TDesC8& aMacValue ) const;
+
+
+        /**
+         * Retrieve the individuals from the Rights Server so proper
+         * comparisons of rights object validity can be performed outside
+         * of the rights server
+         *
+         * @since   3.1
+         * @param   aIndividuals : Pointer array of the individuals supported
+         * @return  Error code with server side error. 
+         *          KErrNone if successful operation.
+         */
+        IMPORT_C TInt GetSupportedIndividualsL(
+                                    RPointerArray<HBufC8>& aIndividuals) const;
+                                 
+        /**
+         * Stop watching the DCF repository server
+         *
+         * @since   3.1
+         */
+        IMPORT_C void StopWatching() const;
+        
+        
+        /**
+         * Unwraps MAC and REK keys that are protected using device public key
+         * or domain key. If the keys are wrapped with device public key aDomainId
+         * parameter must be set to zero length.
+         *
+         * @since   3.1
+         * @param   aMacAndRek : Public key protected MAC and REK keys
+         * @param   aTransportScheme: Used key wrapping scheme (e.g. OMA or CMLA)
+         * @param   aRightsIssuerId: Defines the RI that has wrapped the keys
+         * @param   aDomainId: Defines the domain key that used for wrapping the keys.
+         *          If a device public key is used, the length of aDomainId must be zero
+         * @return  Error code with server side error. 
+         *          KErrNone if successful operation.
+         */
+        IMPORT_C TInt UnwrapMacAndRek( const TDesC8& aMacAndRek,
+                                       TKeyTransportScheme aTransportScheme,
+                                       const TDesC8& aRightsIssuerId,
+                                       const TDesC8& aDomainId ) const;
+                                       
+        /**
+        * Fills the input buffer with random data. The length of the aRandomData must
+        * be set to the correct value.
+        * 
+        * @since   3.1
+        * @param   aRandomData : Out-parameter that will be filled with random data
+        */                              
+        IMPORT_C void GetRandomDataL( TDes8& aRandomData ) const;
+        
+        /**
+        * Returns the metering data for the requested rights-issuer id
+        * 
+        * @since   3.2
+        * @param   aRiId : Rights-Issuer Id for which the metering data is acquired
+        * @return  MeteringData which includes the cipher data and all tags inside
+        *          meteringReport -element       
+        */    
+                      
+        IMPORT_C HBufC8* GetMeteringDataL( const TDesC8& aRiId );
+
+        /**
+        * Deletes the metering data of the requested rights-issuer id
+        * 
+        * @since   3.2
+        * @param   aRiId : Rights-Issuer Id for which the metering data is deleted
+        * @return  Error code with server side error. 
+        *          KErrNone if successful operation.        
+        */    
+        
+        IMPORT_C TInt DeleteMeteringDataL( const TDesC8& aRiId );
+                    
+
+    public: // Functions from base classes
+        
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+        
+    private:
+        
+        /**
+         * Convert internally used temporary file into list.
+         * @since S60Rel2.5
+         * @param aFs       Open file server session.
+         * @param aFileName Source file name
+         * @param aList     Destination list.
+         */ 
+        void FileToListL( RFs& aFs,
+                          const TDesC& aFileName,
+                          RPointerArray< CDRMPermission >& aList );
+        /**
+         * Converts a file of URIs into an array.
+         * @since S60Rel2.5
+         * @param aFs      Open file server session.
+         * @param aFile    Input file.
+         * @param aList    Output list.
+         */
+        void URIFileToArrayL( RFs& aFs,
+                              const TDesC& aFile,
+                              RPointerArray< HBufC8 >& aList );
+        
+        
+        // Prohibit copy constructor if not deriving from CBase.
+        RDRMRightsClient( const RDRMRightsClient& );
+        // Prohibit assigment operator if not deriving from CBase.
+        RDRMRightsClient& operator=( const RDRMRightsClient& );
+        
+    public:     // Data
+        
+    protected:  // Data
+        
+    private:    // Data
+        TAny* iPtr; // Reserved for future use
+        
+    public:     // Friend classes
+        
+    protected:  // Friend classes
+        
+    private:    // Friend classes
+    };
+    
+#endif      // RDRMRIGHTSCLIENT_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/inc/Oma1DcfCreator.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,186 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of class DRMCommon for accessing common
+*     DRM functions
+*
+*/
+
+
+#ifndef OMADCF1CREATOR_H
+#define OMADCF1CREATOR_H
+
+// INCLUDES
+#include <f32file.h>
+#include <DRMRightsClient.h>
+
+// CONSTANTS
+const TUint KBlockSize = 16;
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+class RWriteStream;
+class CDRMRights;
+class CSymmetricCipher;
+
+// CLASS DECLARATION
+
+/**
+*  Accessing content and rights.
+*
+*  @lib COma1DcfCreator.dll
+*  @since Series 60 2.0
+*/
+NONSHARABLE_CLASS(COma1DcfCreator): public CBase
+    {
+public:  // Constructors and destructor
+    
+    /**
+    * Two-phased constructor.
+    */
+    IMPORT_C static COma1DcfCreator* NewL(void);
+
+    /**
+    * Destructor.
+    */
+    IMPORT_C virtual ~COma1DcfCreator(void);
+    
+public: // New functions
+    
+    IMPORT_C void EncryptInitializeL(
+        RWriteStream& anOutput,
+        const TDesC8& aMIMEType, 
+        CDRMRights* aRightsObject);
+    
+    /**
+    * EncryptUpdateL
+    *
+    * add processed content into stream
+    *
+    * @since  2.5
+    * @param  aMessageData: contains processed content 
+    * @return 
+    */
+	IMPORT_C void EncryptUpdateL( 
+		const TDesC8& aMessageData);
+
+
+    /**
+    * EncryptFinalizeL
+    *
+    * finalize the encryption
+    *
+    * @since  2.0
+    * @return 
+    */
+	IMPORT_C void EncryptFinalizeL();
+  
+    /**
+    * EncryptContentL
+    *
+    * Takes a memory buffer with plain text closed content and turns it
+    * into a DCF by adding the necessary headers.
+    *
+    * @since  3.0
+    * @param  aContent: buffer containing the plain content, this will 
+    *         be overwritten with the resulting DCF data
+    * @param  aMIMEType: MIME type to use for the DCF
+    * @param  aRightsObject: Rights and content URI for the new content.
+    * @return -
+    */
+    IMPORT_C void EncryptContentL(
+        HBufC8*& aContent, 
+        const TDesC8& aMIMEType, 
+        CDRMRights* aRightsObject = NULL);
+    
+    /**
+    * EncryptContentToFileL
+    *
+    * Takes a memory buffer with plain text closed content and turns it
+    * into a DCF by adding the necessary headers.
+    *
+    * @since  3.0
+    * @param  aPlainContent: buffer containing the plain content.
+    * @param  aFileName: The file name for  the DCF 
+    * @param  aMIMEType: MIME type to use for the DCF 
+    * @param  aRightsObject: Rights and content URI for the new content.
+    * @return -
+    */
+    IMPORT_C void EncryptContentToFileL(
+        const TDesC8& aContent, 
+        const TDesC& aFileName, 
+        const TDesC8& aMIMEType, 
+        CDRMRights* aRightsObject = NULL);
+    
+    /**
+    * EncryptFileL
+    *
+    * Takes the name of a file with plain text closed content and turns it
+    * into a DCF by adding the necessary headers.
+    *
+    * @since  3.0
+    * @param  aFileName: The file name for the original content.
+    * @param  aDCFFile: The file name for the DCF
+    * @param  aMIMEType: MIME type to use for the DCF.
+    * @param  aRightsObject: Rights and content URI for the new content.
+    * @return -
+    */
+    IMPORT_C void EncryptFileL(
+        const TDesC& aFileName, 
+        const TDesC& aDCFFileName, 
+        const TDesC8& aMIMEType, 
+        CDRMRights* aRightsObject = NULL);
+
+    /**
+    * GetBytesWritten
+    *
+    * Returns the number of bytes written in the encryption process
+    *
+    * @since  3.0
+    * @return The number of bytes written.
+    */
+    IMPORT_C TUint GetBytesWritten(void);
+    
+protected:
+    
+    /**
+    * C++ default constructor.
+    */
+    IMPORT_C COma1DcfCreator(void);
+    
+private:
+    
+    /**
+    * By default Symbian 2nd phase constructor is private.
+    */
+    IMPORT_C void ConstructL(void);
+
+private: //data
+    RWriteStream* iEncryptionStream;
+    TUint iBytesWritten;
+    RDRMRightsClient iRdb;
+    TBuf8<KDCFKeySize> iIv;
+    TBuf8<KDCFKeySize> iRemainder;
+    HBufC8* iEncryptionBuffer;
+    };
+
+#endif      // OMADCF1CREATOR_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_legacy_api/inc/Oma2Dcf.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,245 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of the DCF file format class
+*
+*/
+
+
+
+#ifndef OMA2DCF_H
+#define OMA2DCF_H
+
+//  INCLUDES
+#include "Oma2Agent.h"
+#include "DcfCommon.h"
+
+// LOCAL CONSTANTS AND MACROS
+/* constant for variable-length definitions */
+#define	SRVSEC_ANY_SIZE	             1
+
+#define SWAP32( num ) ( (num) = ( (((num) & 0xff000000) >>24) | (((num) & 0x00ff0000) >>8) | \
+			  (((num) & 0x0000ff00) <<8) | (((num) & 0x000000ff) <<24) ) )
+
+// STRUCTURES
+typedef struct
+    {
+    TUint32 size;
+    TUint32 type;
+    TUint32 versionAndFlags;
+    } tBoxHeaderStr;
+    
+// CLASS DECLARATION
+class COma2DcfPartInfo;
+
+/**
+*  Encapsulates an OMA DRM 2.0 DCF file
+*
+*  @lib DrmDcf.lib
+*  @since Series 60 3.0
+*/
+class COma2Dcf : public CDcfCommon
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static COma2Dcf* NewL(
+            const RFile& aFile,
+            TInt aPart = 0);
+            
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~COma2Dcf();
+
+    public: // New functions
+        
+        IMPORT_C void SetTransactionIdL(
+            const TDesC8& aTransactionId);
+        
+        IMPORT_C void SetRightsObjectsL(
+            RPointerArray<HBufC8>& aRoList);
+        
+        IMPORT_C void GetHashL();
+        
+        IMPORT_C static TBool IsValidDcf(
+            const TDesC8& aDcfFragment);
+
+        void ReadPartsL(void);
+
+        void ReadContainerL(
+            TInt aOffset,
+            TInt& aSize);
+        
+        void ReadDiscreteMediaHeaderL(
+            TInt aOffset,
+            TInt& aSize);
+        
+        void ReadContentObjectL(
+            TInt aOffset,
+            TInt& aSize);
+        
+        void ReadCommonHeadersL(
+            TInt aOffset,
+            TInt& aSize);
+        
+        void ReadMutableInfoL(
+            TInt aOffset,
+            TInt& aSize);
+        
+        void ReadExtendedHeadersL(
+            TInt aOffset,
+            TInt aEndOfBox);
+        
+        void ReadBoxSizeAndTypeL(
+            TInt aOffset,
+            TInt& aSize,
+            TUint32& aType,
+            TInt& aHeaderSize);
+
+        void ParseTextualHeadersL(
+            const TDesC8& aMemoryBlock);
+            
+    	void RewriteMutableInfoL(
+    	    const TDesC8& aTransactionId,
+    	    RPointerArray<HBufC8>& aRoList);
+    	
+        TInt CheckUniqueId(
+            const TDesC& aUniqueId);
+            
+        TInt OpenPart(
+            const TDesC& aUniqueId);
+            
+        TInt OpenPart(
+            TInt aPart);
+            
+        void GetPartIdsL(
+            RPointerArray<HBufC8>& aPartList);
+        
+    private: // New functions 
+        /**
+        * VerifyTypeL
+        * @param aType the type value to be verified
+        * @param aRefType the reference type
+        */
+    	void VerifyTypeL(
+    	    TUint32 aType,
+    	    TUint32 aRefType);
+
+        /**
+        * ReadOneTextualHeaderL
+        * @param aBlock header buffer
+        * @param aName Textual header name
+        * @param aBuf Buffer to save value, if not found, it should be NULL, previous data is discarded
+        * @param aError KErrNone if the header was found, otherwise KErrNotFound or other errors
+        * @return Offset of the header in the data block
+        */    	
+    	TInt ReadOneTextualHeaderL(
+    	    const TDesC8& aBlock,
+    	    const TDesC8& aName,
+    	    HBufC8*& aBuf,
+    	    TInt& aError);
+    	
+    	/**
+        * SetHeaderWithParameterL
+        * @param aValue header value
+        * @param aMethod Buffer to save method value, if not found, it should be NULL, previous data is discarded
+        * @param aParameter Buffer to save paramter value, if not found, it should be NULL, previous data is discarded
+        */   
+    	void SetHeaderWithParameterL(
+    	    const TDesC8& aValue,
+    	    HBufC8*& aMethod,
+    	    HBufC8*& aParameter);
+    	    
+    	void ReadPartInfoL(
+    	    COma2DcfPartInfo* aPart,
+    	    TInt aOffset);
+    	 
+        void ReadUserDataL(
+            TInt aOffset,
+            TInt& aSize);
+   
+    	void ParseUserDataSubBoxesL(
+            const TDesC8& aMemoryBlock);
+            
+        void ReadOneUserDataBoxL(
+            const TDesC8& aBlock,
+            const TDesC8& aName,
+            HBufC8*& aBuf);
+            
+    	    
+    protected:
+
+        /**
+        * C++ default constructor.
+        */
+        COma2Dcf();
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL(
+            const RFile& aFile,
+            TInt aPart);
+    public:     // Data
+        TEncryptionPadding iEncrytionPadding;
+        TSilentRefresh iSilentRefresh;
+        TPreview iPreview;
+        HBufC8* iPreviewParameter;
+        HBufC8* iSilentParameter;
+        HBufC8* iTextualHeaders;
+        HBufC8* iContentUrl;
+        HBufC8* iContentVersion;
+        HBufC8* iContentLocation;
+        HBufC8* iTransactionTracking;
+        RPointerArray<HBufC8> iRightsObjects;
+        HBufC8* iUserData;
+        HBufC8* iAuthor;
+        HBufC8* iCopyRight;
+        HBufC8* iInfoUri;
+        HBufC8* iGroupId;
+        HBufC8* iGroupKey;
+        TEncryptionMethod iGkEncryptionMethod;
+        RPointerArray<COma2DcfPartInfo> iParts;
+        COma2DcfPartInfo* iMutablePart;
+        
+        // metadataboxes
+        HBufC8* iPerformer;
+        HBufC8* iGenre;
+        HBufC8* iRatingInfo;
+        HBufC8* iClassificationInfo;
+        HBufC8* iKeyword;
+        HBufC8* iLocInfoName;
+        HBufC8* iLocInfoAstronomicalBody;
+        HBufC8* iLocInfoAdditionalNotes;
+        HBufC8* iAlbumTitle;        
+        HBufC8* iCoverUri;
+        HBufC8* iLyricsURL;
+        TUint16 iRecordingYear;
+        TUint8 iAlbumTrack;
+        
+        // Set to ETrue if both preview and silent headers are present
+        // and preview rights are to be used, EFalse otherwise
+        TBool iPreviewOverridesSilentRefresh;
+
+    protected:  // Data
+
+    private:    // Data
+        TBool iUserDataLanguageDefined;
+    };
+
+#endif      // OMA2DCF_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_license_manager_api/drm_license_manager_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="4e432dd831f10b72a954a46f3e552f83" dataversion="1.0">
+  <name>DRM License Manager API</name>
+  <description>Protection for native applications and skins</description>
+  <type>c++</type>
+  <subsystem>omadrm</subsystem>
+  <libs>
+    <lib name="DRMLicenseManager.lib" />
+  </libs>
+  <release category="domain"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_license_manager_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* 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:  File that exports the files belonging to 
+:                DRM License Manager API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/DRMLicenseManager.h     MW_LAYER_PLATFORM_EXPORT_PATH(DRMLicenseManager.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_license_manager_api/inc/DRMLicenseManager.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,256 @@
+/*
+* 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:  Declaration of the license manager functionality used in the
+*                install process
+*
+*/
+
+
+#ifndef DRMLICENSEMANAGER_H
+#define DRMLICENSEMANAGER_H
+
+// INCLUDES
+
+#include <f32file.h>
+
+// DATA TYPES
+
+struct TDRMDataFile
+    {
+    TFileName iSourceName;
+    TFileName iTargetName;
+    TBuf8<128> iMimeType;
+    };
+
+// FORWARD DECLARATIONS
+
+class CZipFile;
+class CZipFileMember;
+class RZipFileMemberReaderStream;
+class CDRMRights;
+
+// CLASS DECLARATION
+
+/**
+*  Processes protected installation packages for use by the license checker.
+*
+*  @lib DRMLicenseManager.lib
+*  @since Series 60 2.5
+*/
+class CDRMLicenseManager: public CBase
+    {
+    public:  // Local enumerations and types
+
+        enum
+            {
+            ENoRights = -100000,
+            ERightsExpired = -100001,
+            EPIPInvalid = -100002,
+            ESISNotFound = -100003
+            };
+
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CDRMLicenseManager* NewL();
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CDRMLicenseManager();
+
+    public: // New functions
+        
+        /**
+        * This function performs the actual processing of a protected
+        * installation package. It identifies the data files to be protected
+        * by reading the definition file. Each identified data file in the PIP
+        * will be encrypted and stored in the location indicated by the
+        * definition file. The definition file can refer to these locations
+        * relative to the installation destination, which can be given as a
+        * separate parameter.
+        *
+        * @since Series 60 2.6
+        * @param aZIPFile: file name of the PIP file to be installed
+        * @param aDestination: target directory where the contained SIS file was
+        *        installed
+        * @return ENoRights, ERightsExpired if the PIP file could not be opened
+        *         because of insufficient rights, EPIPInvalid if the file is
+        *         not a PIP file, KErrNone otherwise.
+        */
+        IMPORT_C TInt ProcessL(
+            const TDesC& aZIPFile,
+            const TDesC& aDestination);
+
+        /**
+        * This is the file handle based equivalent of the ProcessL function
+        *
+        * @since Series 60 3.0
+        * @param aZIPFile: file handle of the PIP file to be installed
+        * @param aDestination: target directory where the contained SIS file was
+        *        installed
+        * @return ENoRights, ERightsExpired if the PIP file could not be opened
+        *         because of insufficient rights, EPIPInvalid if the file is
+        *         not a PIP file, KErrNone otherwise.
+        */
+        IMPORT_C TInt ProcessL(
+            RFile& aZIPFile,
+            const TDesC& aDestination);
+
+        /**
+        * Extracts the SIS file from within the PIP file and stores it in a 
+        * defined location.
+        *
+        * @since Series 60 2.6
+        * @param aZIPFile: file name of the PIP which contains the SIS file to
+        *        be extracted.
+        * @param aDestination: target directory where the contained SIS file
+        *        should be stored.
+        * @return ENoRights, ERightsExpired if the PIP file could not be opened
+        *         because of insufficient rights, EPIPInvalid if the file is
+        *         not a PIP file, ESISNotFound if the PIP file did not contain
+        *         a SIS file, KErrNone otherwise.
+        */
+        IMPORT_C TInt ExtractSISFileL(
+            const TDesC& aZIPFile,
+            const TDesC& aDestination);
+
+        /**
+        * This is the file handle based equivalent of the ExtractSISFileL
+        * function.
+        *
+        * @since Series 60 3.0
+        * @param aZIPFile: file name of the PIP which contains the SIS file to
+        *        be extracted.
+        * @param aDestination: target directory where the contained SIS file
+        *        should be stored.
+        * @return ENoRights, ERightsExpired if the PIP file could not be opened
+        *         because of insufficient rights, EPIPInvalid if the file is
+        *         not a PIP file, ESISNotFound if the PIP file did not contain
+        *         a SIS file, KErrNone otherwise.
+        */
+        IMPORT_C TInt ExtractSISFileL(
+            RFile& aZIPFile,
+            const TDesC& aDestination);
+
+        /**
+        * Returns the SIS member contained in a PIP file.
+        * 
+        * @since Series 60 2.5
+        * @return Pointer to the SIS member, has to be released by the caller
+        */
+        IMPORT_C CZipFileMember* GetSISMemberL(void);
+
+    protected:  // New functions
+        
+        /**
+        * Writes the SIS member contents to a file.
+        *
+        * @since Series 60 2.5
+        * @param aSisMember: SIS member to be written
+        * @param aDestination: target directory for the SIS member
+        */
+        void WriteSISMemberL(
+            CZipFileMember* aSisMember,
+            const TDesC& aDestination);
+
+        /**
+        * Reads the definition file from a PIP file
+        *
+        * @since Series 60 2.5
+        * @return ENoRights, ERightsExpired if the PIP file could not be opened
+        *         because of insufficient rights, EPIPInvalid if the file is
+        *         not a PIP file, KErrNone otherwise.
+        */
+        TInt ReadDefinitionFileL(void);
+
+        /**
+        * Reads the description line for one file
+        *
+        * @since Series 60 2.5
+        * @param aStream: Pointer to the definition file member stream
+        * @return KErrNone or EPIPInvalid
+        */
+        TInt ReadFileDescription(
+            RZipFileMemberReaderStream* aStream);
+
+        /**
+        * Reads one line from the definition file.
+        *
+        * @since Series 60 2.5
+        * @param aStream: Pointer to the definition file member stream
+        * @param aLine: Descriptor for the line's content
+        */
+        void ReadLine(
+            RZipFileMemberReaderStream* aStream,
+            TDes8& aLine);
+
+        /**
+        * Process all data files by encrypting them and writing them to their
+        * target locations.
+        *
+        * @since Series 60 2.5
+        * @param aDestination: Directory where the SIS file was installed to.
+        * @return KErrNone or EPIPInvalid
+        */
+        TInt ProcessDataFilesL(
+            const TDesC& aDestination);
+
+        /**
+        * Encrypts a single data file.
+        *
+        * @since Series 60 2.5
+        * @param aDataFile: Data file parameters
+        * @param aDestination: Directory where the SIS file was installed to.
+        * @param aZipMember: Pointer to the data member to be encrypted.
+        * @return ?description
+        */
+        void EncryptDataFileL(
+            TDRMDataFile* aDataFile,
+            const TDesC& aDestination,
+            CZipFileMember* aZipMember);
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDRMLicenseManager();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    protected:  // Data
+        // Pointer to the currently opened PIP file
+        CZipFile* iZipFile;
+
+        // File server session
+        RFs* iFs;
+
+        // Array of data files as read from the definition file.
+        RPointerArray<TDRMDataFile> iDataFiles;
+
+        // Rights object used for the PIP file
+        CDRMRights* iRights;
+        
+        HBufC8* iRightsIssuer;
+    };
+
+#endif      // DRMLICENSEMANAGER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/drm_rights_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="232d510d44d891815239afa9331911ea" dataversion="1.0">
+  <name>DRM Rights API</name>
+  <description>Provides information about Rights</description>
+  <type>c++</type>
+  <subsystem>omadrm</subsystem>
+  <libs>
+    <lib name="DRMRights.lib" />
+  </libs>
+  <release category="domain"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  File that exports the files belonging to 
+:                DRM Rights API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/DRMTypes.h     MW_LAYER_PLATFORM_EXPORT_PATH(DRMTypes.h)
+../inc/DrmAsset.h     MW_LAYER_PLATFORM_EXPORT_PATH(DrmAsset.h)
+../inc/DrmRights.h     MW_LAYER_PLATFORM_EXPORT_PATH(DRMRights.h)
+../inc/DRMIndividualConstraintExtension.h     MW_LAYER_PLATFORM_EXPORT_PATH(DRMIndividualConstraintExtension.h)
+../inc/DcfCommon.h     MW_LAYER_PLATFORM_EXPORT_PATH(DcfCommon.h)
+../inc/DcfCommon.inl     MW_LAYER_PLATFORM_EXPORT_PATH(DcfCommon.inl)
+../inc/DRMConstraint.h     MW_LAYER_PLATFORM_EXPORT_PATH(DrmConstraint.h)
+../inc/DRMPermission.h     MW_LAYER_PLATFORM_EXPORT_PATH(DrmPermission.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/inc/DRMConstraint.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,317 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Datatype for Rights Constraint
+*
+*/
+
+
+#ifndef DRMCONSTRAINT_H
+#define DRMCONSTRAINT_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include "DRMTypes.h"
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class RReadStream;
+class RWriteStream;
+
+// TYPE DEFINITIONS
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMConstraint implements a constraint for OMA DRM usage
+*
+*  @lib DrmRights.dll
+*  @since S60 3.0
+*/
+
+class CDRMConstraint : public CBase
+    {
+    
+public:
+
+    struct TDrmMeteringInfo
+        {
+        TDrmMeteringInfo() : 
+            iGraceTime( 0 ), 
+            iAllowUseWithoutMetering( EFalse ){};
+        
+        TTimeIntervalSeconds iGraceTime;
+        TBool iAllowUseWithoutMetering;
+        };
+    
+public: // Constructors and destructor
+    /**
+    * NewLC
+    *
+    * Creates a new CDRMConstraint object and returns a pointer to it.
+    * The function leaves the object to the cleanup stack.
+    *
+    * @since    3.0
+    * @return   a functional CDRMConstraint object, The function leaves
+    *           with SymbianOS error code if an error occurs.
+    */
+    IMPORT_C static CDRMConstraint* NewLC();
+
+    /**
+    * NewL
+    *
+    * Creates a new CDRMConstraint object and returns a pointer to it.
+    *
+    * @since    3.0
+    * @return   a functional CDRMConstraint object, The function leaves
+    *           with SymbianOS error code if an error occurs.
+    */
+    IMPORT_C static CDRMConstraint* NewL();
+    
+    /*
+    * Destructor
+    */ 
+    IMPORT_C virtual ~CDRMConstraint(); 
+
+
+public: // New functions
+    /**
+    * ExternalizeL
+    * 
+    * Writes the data of the object into the stream
+    *
+    * @since    3.0
+    * @param    aStream : the output stream to write to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
+    
+    /**
+    * InternalizeL
+    * 
+    * Reads the data of the object from the stream
+    *
+    * @since    3.0
+    * @param    aStream : the output stream to write to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    IMPORT_C void InternalizeL( RReadStream& aStream );
+    
+    
+    /**
+    * Stateful
+    * 
+    * The function checks if the constraint is stateful
+    *
+    * @since    3.0
+    * @return   returns ETrue if the constraint is stateful
+    *                   EFalse if it is not.
+    */
+    IMPORT_C TBool Stateful() const;
+
+    /**
+    * Size
+    *
+    * returns the size of the externalized object
+    *
+    * @since    3.0
+    * @return   returns the size of the constraint
+    */   
+    IMPORT_C TInt Size() const;
+   
+    /**
+    * Expired
+    *
+    * returns a boolean valua about the validity of the constraint
+    * Future rights are considered not be be expired and EFalse
+    * is returned for them
+    *
+    * @since    3.0
+    * @param	aTime : current secure time, if the time is
+    *			        Time::NullTTime() time based constraints
+    *					will not be considered to be expised and 
+    *					EFalse is returned for them
+    * @return   returns ETrue if the constraint is expired
+    *					EFalse if the constraint is not expired
+    *
+    */     
+    IMPORT_C TBool Expired( const TTime& aTime ) const;
+
+    /**
+    * Merge
+    *
+    * Merges the two constraints
+    *
+    * @since    3.0
+    * @param	aConstraint : the constraint merged to this one
+    * @return   none
+    */     
+    IMPORT_C void Merge( const CDRMConstraint& aConstraint );
+
+
+    /**
+    * Consume
+    *
+    * Consumes rights
+    *
+    * @since    3.0
+    * @param	aCurrentTime : The current secure time
+    * @return   none
+    */     
+    IMPORT_C void Consume( const TTime& aCurrentTime );
+    
+    
+    /**
+    * DuplicateL
+    *
+    * copies all data from the given constraint to the current one
+    *
+    * @since    3.0
+    * @param	aConstraint : the constraint to copy from
+    * @return   none, Leaves with symbian OS error code if an error occurs
+    */ 
+    IMPORT_C void DuplicateL( const CDRMConstraint& aConstraint );
+    
+    /**
+    * Valid
+    *
+    * returns if the constraint is valid/usable at this time
+    *
+    * @since    3.0
+    * @param	aTime : current secure time, if the time is
+    *			        Time::NullTTime() time based constraints
+    *					will be considered to be invalid
+    * @param    aIndividual : the imsi of the phone
+    * @param    aRejection : return value for why the content was rejected    
+    * @return   returns ETrue if the constraint is valid
+    *					EFalse if the constraint is not valid
+    */ 
+    IMPORT_C TBool Valid( const TTime& aTime,
+                          const RPointerArray<HBufC8>& aIndividual,
+                          TUint32& aRejection ) const;
+    
+public:
+
+    // synchronizing marker
+    TInt32 iSyncMark;
+    
+    // version number
+    TInt32 iVersion;
+ 
+    // usage start time
+    TTime iStartTime;
+
+    // usage end time
+    TTime iEndTime;
+
+    // interval start time
+    TTime iIntervalStart;
+
+    // interval duration
+    TTimeIntervalSeconds iInterval;
+
+    // counter
+    TDRMCounter iCounter;
+
+    // original counter value
+    TDRMCounter iOriginalCounter;
+
+    // timed counter
+    TDRMCounter iTimedCounter;
+
+    // Interval of the timed counter constraint
+    TTimeIntervalSeconds iTimedInterval;
+
+    // accumulated time
+    TTimeIntervalSeconds iAccumulatedTime;
+
+    // individual allowed usage
+    RPointerArray<HBufC8> iIndividual;
+	
+    // Software Vendor Id
+    TUid iVendorId;
+    
+    // Secure Id of the allowed application
+    TUid iSecureId;
+
+	// Bitmask of active constraints
+    TUint32 iActiveConstraints;	// Bitmask
+    
+    // Metering allowance information
+    TDrmMeteringInfo* iDrmMeteringInfo;
+    
+    // system allowed usage
+	RPointerArray<HBufC8> iSystem;
+
+    // Original timed counter
+    TDRMCounter iOriginalTimedCounter;
+
+protected:
+
+    /*
+    * Default Constructor
+    */ 
+    IMPORT_C CDRMConstraint();
+
+private:
+
+    /**
+    * 2nd phase constructor
+    */
+    void ConstructL();
+
+    /**
+    * Copy constructor.
+    */
+    CDRMConstraint( const CDRMConstraint& aConstraint ); // Prevented
+    
+    /**
+    * WriteInt64L
+    * 
+    * Writes the 64 bit integer to the stream
+    *
+    * @since    3.0
+    * @param    aWrite : the 64 bit integer to write
+    * @param    aStream : the output stream to write to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const;
+
+    /**
+    * ReadInt64L
+    * 
+    * Reads the 64 bit integer from the stream
+    *
+    * @since    3.0
+    * @param    aRead : the 64 bit integer read
+    * @param    aStream : the output stream to write to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void ReadInt64L( TInt64& aRead, RReadStream& aStream );    
+    };
+
+#endif      // DRMCONSTRAINT_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/inc/DRMIndividualConstraintExtension.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Defines an interface to extend DRM to support and validate non 
+*                standard DRM individual constraints (i.e. constraints other than 
+*                "IMSI:" or "WIM:")
+*
+*/
+
+
+#ifndef __DRMINDIVIDUALCONSTRAINTEXTENSION_H__
+#define __DRMINDIVIDUALCONSTRAINTEXTENSION_H__
+
+// INCLUDES
+#include <e32base.h>
+
+// CONSTANTS
+_LIT(KDRMIndividualConstraintExtensionDll,"z:\\sys\\bin\\DRMIndividualConstraintExtension.dll");
+
+// FORWARD DECLARATIONS
+class RMobilePhone;
+
+// CLASS DECLARATION
+
+/**
+*  Defines an interface to extend DRM to support and validate non standard DRM 
+*  individual constraints (i.e. constraints other than "IMSI:" or "WIM:")
+*
+*  Must be implemented within a DLL named KDRMIndividualConstraintExtensionDll 
+*  which exports a non leaving factory method at ordinal 1 returning 
+*  MDRMIndividualConstraintExtension* or NULL
+*
+*  The DRM engine will only load and use this DLL if it exists.
+*
+*  @since Series60_3.1
+*/
+class MDRMIndividualConstraintExtension
+    {
+    public: // New functions
+
+        /**
+        * The method should be coded to append additional valid individual
+        * constraint strings to the supplied array.
+        * 
+        * Constraints must be of the format "<alpha string>:<digit string>"
+        *
+        * @since Series60_3.1
+        * @param aConstraint array of individual constraint strings
+        * @param aMobilePhone optional connected session to RMobilePhone, if
+        *        not supplied then a new session will be created
+        * @return void
+        */
+        virtual void AppendConstraintsL(RPointerArray<HBufC8>& aConstraint,
+            RMobilePhone* aMobilePhone = NULL) =0;
+
+        /**
+        * This method should be coded to Release any resources. CBase derived classes
+        * should call delete this.
+        * @since Series60_3.1
+        * @return void
+        */
+        virtual void Release() =0;
+    };
+
+#endif //__DRMINDIVIDUALCONSTRAINTEXTENSION_H__
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/inc/DRMPermission.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,365 @@
+/*
+* 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:  Interface for the DRM Rights database
+*
+*/
+
+
+#ifndef DRMPERMISSION_H
+#define DRMPERMISSION_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <caf/caf.h>
+#include "DRMTypes.h"
+
+using namespace ContentAccess;
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class RReadStream;
+class RWriteStream;
+class CDRMConstraint;
+
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMPermission implements the permission for OMA DRM usage
+*
+*  @lib DrmRights.dll
+*  @since S60 3.0
+*/
+
+class CDRMPermission : public CBase
+    {
+public:
+    enum TExportMode
+        {
+        ECopy,
+        EMove
+        };
+    
+public: // CBase
+
+    /**
+    * NewLC
+    *
+    * Creates a new CDRMPermission object and returns a pointer to it.
+    * The function leaves the object to the cleanup stack.
+    *
+    * @since    3.0
+    * @return   a functional CDRMPermission object, The function leaves
+    *           with SymbianOS error code if an error occurs.
+    */
+    IMPORT_C static CDRMPermission* NewLC();
+
+    /**
+    * NewL
+    *
+    * Creates a new CDRMPermission object and returns a pointer to it.
+    *
+    * @since    3.0
+    * @return   a functional CDRMPermission object, The function leaves
+    *           with SymbianOS error code if an error occurs.
+    */
+    IMPORT_C static CDRMPermission* NewL();
+    
+    /**
+    * Destructor
+    */
+    IMPORT_C virtual ~CDRMPermission();
+
+public: // New functions    
+    /**
+    * ExternalizeL
+    * 
+    * Writes the data of the object into the stream
+    *
+    * @since    3.0
+    * @param    aStream : the output stream to write to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
+    
+    /**
+    * InternalizeL
+    * 
+    * Reads the data of the object from the stream
+    *
+    * @since    3.0
+    * @param    aStream : the output stream to write to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    IMPORT_C void InternalizeL( RReadStream& aStream );
+    
+    /**
+    * Stateful() 
+    *
+    * Tells if the rights object is stateful or not
+    *
+    * @since    3.0
+    * @return   returns ETrue if the rights object is stateful
+    *                   EFalse if it is not    
+    */
+	IMPORT_C TBool Stateful() const;
+	
+	/**
+	* Child()
+	*
+	* Tells if the rights object is a child or not
+	*
+    * @since    3.0
+    * @return   returns ETrue if the rights object is child
+    *                   EFalse if it is not
+    */
+    IMPORT_C TBool Child() const;
+
+    /**
+    * Size
+    *
+    * returns the size of the externalized object
+    *
+    * @since    3.0
+    * @return   returns the size of the constraint
+    */   
+    IMPORT_C TInt Size() const;
+    
+    /**
+    * NULL or actual constraints.
+    */
+    IMPORT_C CDRMConstraint* ConstraintForIntent( const ContentAccess::TIntent aIntent );
+    
+    /**
+    * NULL or actual constraint.
+    */
+    IMPORT_C CDRMConstraint* TopLevelConstraint(  );
+
+    /**
+    * Note: Top level constraint is always consumed if it exists.
+    */
+    IMPORT_C void ConsumeRights( const ContentAccess::TIntent aIntent, const TTime& aCurrentTime );
+
+
+    /**
+    * ImportL
+    * 
+    * Reads the data of the object from the descriptor and initialized the 
+    * object accordingly
+    *
+    * @since    3.0
+    * @param    aBuffer : the buffer containing the data of the imported object
+    * @return   None, The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    IMPORT_C void ImportL( const TDesC8& aBuffer );
+    
+    /**
+    * ExportL
+    * 
+    * Writes the data of the object into an HBufC8 and returns a pointer
+    * to it. The caller is responsible for deleting the object.
+    *
+    * @since    3.0
+    * @return   Returns an HBufC8* containing the data of the object,
+    *           The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    IMPORT_C HBufC8* ExportL() const;
+
+    /**
+    * DuplicateL
+    * 
+    * Copies the data of the permission into the current one.
+    *
+    * @since    3.0
+    * @param    aPermission : the permission to duplicate into this one
+    * @return   None. The function leaves with Symbian OS error code if an
+    *           error occurs
+    */    
+    IMPORT_C void DuplicateL( const CDRMPermission& aPermission );
+    
+    /**
+    * Expired   
+    *
+    * Checks if the permission has expired
+    *
+    * @since	3.0
+    * @param	aTime : The current secure time
+    *                   if the time is Time::NullTTime() time based rights
+    *                   will be ignored
+    * @return   ETrue if the permission has expired
+    * 			EFalse if it is still valid or has future rights 
+    */
+    IMPORT_C TBool Expired( const TTime& aTime );
+    
+    
+    /**
+    * Valid
+    *
+    * returns if the permission is valid/usable at this time
+    *
+    * If no second parameter is given all the constraints will
+    * be checked for validity and if any of them is invalid
+    * the permission is considered to be invalid.
+    *
+    * For ERightsPlay, ERightsDisplay, ERightsExecute, ERightsPrint
+    * also the toplevel constraint will be checked for validity
+    *
+    * @since    3.0
+    * @param	aTime : current secure time, if the time is
+    *			        Time::NullTTime() time based constraints
+    *					will be considered to be invalid
+    * @param    aIndividual : the imsi of the phone
+    * @param    aRejection : return value for why the content was rejected
+    * @param	aConstraint : the constraint to check validity on
+    *							
+    * @return   returns ETrue if the constraint is valid
+    *					EFalse if the constraint is not valid
+    */ 
+    IMPORT_C TBool Valid( const TTime& aTime,
+                          const RPointerArray<HBufC8>& aIndividual, 
+                          TUint32& aRejection,
+                          const TRightsType aType = ERightsAll ) const;
+                          
+    /**
+    * Merge permission with another permission
+    *
+    * @since	3.0
+    * @param	aPermission permission to merge with
+    */
+    IMPORT_C void Merge( const CDRMPermission& aPermission );
+    
+    /**
+    * Checks if the permission has software constaints
+    *
+    * @since	3.0
+    * @return   ETrue if the permission has software constaints, EFalse otherwise
+    */
+    IMPORT_C TBool SoftwareConstrained() const;
+    
+    
+public:
+
+    // synchronizing marker
+    TInt32 iSyncMark;
+   
+    // Version number
+    TInt32 iVersion;
+    
+    // Unique ID of the permission
+    TDRMUniqueID iUniqueID;
+    
+    // The original insertion time
+    TTime iOriginalInsertTime;
+    
+    // Top level constraint
+    CDRMConstraint* iTopLevel;
+    
+    // Play constraint
+    CDRMConstraint* iPlay;
+    
+    // Display constraint
+    CDRMConstraint* iDisplay;
+    
+    // Execute constraint
+    CDRMConstraint* iExecute;
+    
+    // Print constraint
+    CDRMConstraint* iPrint;
+    
+    // Export constraint
+    CDRMConstraint* iExport;
+    
+    // Export mode
+    TExportMode iExportMode;
+    
+    // Content ID of the parent rights object
+    HBufC8* iParentUID;
+    
+    // Rights Object ID of the rights delivery container
+    HBufC8* iRoID;
+    
+    // Domain identifier
+    HBufC8* iDomainID;
+    
+    // Available rights
+    TUint16 iAvailableRights;	// Bitmask
+    
+    // Version number of the rights object
+    TROVersion iRightsObjectVersion;
+    
+    // Additional information bitvector
+    TInt32 iInfoBits;
+    
+    // Right issuer identifier
+    TBuf8<KRiIdSize> iRiId;
+    
+    // URL to send HTTP GET on expiration of permission 
+    HBufC8* iOnExpiredUrl;
+
+protected:
+
+    /**
+    * Default constructor
+    */
+    IMPORT_C CDRMPermission();
+
+private:
+
+    /**
+    * 2nd phase constructor
+    */
+    void ConstructL();
+
+    /**
+    * WriteInt64L
+    * 
+    * Writes the 64 bit integer to the stream
+    *
+    * @since    3.0
+    * @param    aWrite : the 64 bit integer to write
+    * @param    aStream : the output stream to write to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const;
+
+    /**
+    * ReadInt64L
+    * 
+    * Reads the 64 bit integer from the stream
+    *
+    * @since    3.0
+    * @param    aRead : the 64 bit integer read
+    * @param    aStream : the output stream to write to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void ReadInt64L( TInt64& aRead, RReadStream& aStream );    
+
+    };
+
+#endif      // DRMPERMISSION_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/inc/DRMTypes.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,128 @@
+/*
+* 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:  Datatype definitions for DRM Rights Database
+*
+*/
+
+
+#ifndef DRMTYPES_H
+#define DRMTYPES_H
+
+// INCLUDES
+
+#include <caf/caf.h>
+
+// CONSTANTS
+
+const TUint KDCFKeySize = 16;
+const TInt KDRMCounterMax = KMaxTInt32;
+const TInt KWrappedMacAndRekSize = 40;
+const TInt KWrappedCekSize = 24;
+const TInt KCekSize = 16;
+const TInt KMacAndRekSize = 32;
+const TInt KRiIdSize = 20;
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// TYPE DEFINITIONS
+
+typedef TUint32 TDRMUniqueID;
+typedef TInt32 TDRMCounter;
+
+// TExportMode defines value of the export mode
+/*
+typedef enum
+    {   
+    EExportNone = 0;
+    EExportCopy,
+    EExportMove
+    } TExportMode;
+*/
+
+// Rights Object version
+struct TROVersion
+    {
+    TUint16 iVersionMain;
+    TUint16 iVersionSub;
+    
+    TROVersion() : iVersionMain(0),iVersionSub(0) { };
+    
+    };
+
+// Rights type enumeration, determines the bits in the bitvector
+typedef enum 
+    {
+    ERightsPlay     = 0x0001,
+    ERightsDisplay  = 0x0002,
+    ERightsExecute  = 0x0004,
+    ERightsPrint    = 0x0008,
+    ERightsExport   = 0x0010,
+    ERightsTopLevel = 0x0020,
+    ERightsAll      = 0x003F
+    } TRightsType;
+
+// Constraint type enumeration
+typedef enum 
+    { 
+    EConstraintNone         = 0x00000000,
+    EConstraintStartTime    = 0x00000001,
+    EConstraintEndTime      = 0x00000002,
+    EConstraintInterval     = 0x00000004,
+    EConstraintCounter      = 0x00000008,
+    EConstraintTopLevel     = 0x00000010,
+    EConstraintTimedCounter = 0x00000020,
+    EConstraintAccumulated  = 0x00000040,
+    EConstraintIndividual   = 0x00000080,
+    EConstraintSystem       = 0x00000100,
+    EConstraintVendor       = 0x00000200,
+    EConstraintSoftware     = 0x00000400,
+    EConstraintMetering     = 0x00000800,
+    EConstraintNullDrmTime  = 0x10000000
+    } TConstraintType;
+
+typedef enum
+    {
+    } TDrmIntents;
+    
+typedef enum
+    {
+    ENoRestriction = 0x00000000,
+    ENoRingingTone = 0x00000001      
+    } TInfoBits;
+    
+// Rights Server specific error codes    
+    
+enum
+    {
+    KErrRightsServerRiNotRegistered = -30150,
+    KErrRightsServerDomainNotRegistered = -30151,
+    KErrRightsServerMacFailed = -30152
+    };
+
+namespace DRMClock
+    {
+    // Security level of the drm clock
+    typedef enum 
+        {
+        KSecure = 0,
+        KInsecure = 1
+        } ESecurityLevel;
+    }
+#endif      // DRMTYPES_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/inc/DcfCommon.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,195 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef DCFCOMMON_H
+#define DCFCOMMON_H
+
+//  INCLUDES
+#include <apmstd.h>
+#include <f32file.h>
+#include <oma2agent.h>
+#include <drmtypes.h>
+
+using namespace ContentAccess;
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class RFile;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CDcfCommon : public CBase
+    {
+    public:  // Enumerations
+
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CDcfCommon* NewL(
+            const RFile& aFile);
+            
+        IMPORT_C static CDcfCommon* NewL(
+            const TDesC& aFileName,
+            RFs* aFs = NULL);
+            
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CDcfCommon();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+		virtual TInt CheckUniqueId(const TDesC& aUniqueId);
+        virtual TInt OpenPart(const TDesC& aUniqueId) = 0;
+        virtual TInt OpenPart(TInt Index) = 0;
+        virtual void GetPartIdsL(RPointerArray<HBufC8>& aPartList) = 0;
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    protected:
+
+        /**
+        * C++ default constructor.
+        */
+        CDcfCommon();
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL(
+            const RFile& aFile);
+            
+        void ConstructL(
+            const TDesC8& aMemoryBlock);
+            
+        // Prohibit copy constructor if not deriving from CBase.
+        // CDcfCommon( const CDcfCommon& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CDcfCommon& operator=( const CDcfCommon& );
+
+    public:     // Data
+        // File to be used for reading
+        RFile iFile;
+
+        // Offset of the data part from the beginning of the file
+        TInt iOffset;
+
+        // The data part, used only when opening from a memory block
+        HBufC8* iData;
+    
+        // DCF version
+        TUint iVersion;
+
+        // Size of the DCF itself
+        TInt iLength;
+
+        // Size of the encrypted data
+        TUint iDataLength;
+
+        // Size of the decrypted data
+        TUint iPlainTextLength;
+
+        // Flag indicating if the padding is removed from the plaintext length
+        TBool iPlainTextLengthValid;
+
+        // Original MIME type
+        HBufC8* iMimeType;
+
+        // Unique OMA DCF content ID
+        HBufC8* iContentID;
+
+        // Rights issuer URL for rights refresh
+        HBufC8* iRightsIssuerURL;
+
+        // Size of the padding for the encrypted data, negative if not valid
+        TInt iPadding;
+        
+        // Encryption method (NULL, CBC or CTR)
+        TEncryptionMethod iEncryptionMethod;
+
+        // Title of the content (content name for OMA DRM 1.0 DCF files)
+        HBufC8* iTitle;
+        
+        // Content description
+        HBufC8* iDescription;
+        
+        // URI for a descriptive icon
+        HBufC8* iIconUri;
+
+    protected:  // Data
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+#endif      // DCFCOMMON_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/inc/DcfCommon.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDcfCommon::Version
+// 
+// -----------------------------------------------------------------------------
+//
+inline TInt CDcfCommon::Version()
+    {
+    return iVersion;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/inc/DrmAsset.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,69 @@
+/*
+* 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:  Declaration of class CDRMAsset
+*
+*/
+
+
+#ifndef DRMASSET_H
+#define DRMASSET_H
+
+#include <e32base.h>
+#include <caf/caf.h>
+#include "DcfCommon.h"
+
+// FORWARD DECLARATIONS
+
+const TInt KProtectedDCFKeySize = 24;
+const TInt KDcfDigestSize = 20;
+
+class RWriteStream;
+class RReadStream;
+
+// CLASS DECLARATION
+
+/**
+*  CDrmAsset: Encapsulates the content ID, the key and the hash for a RO
+*
+*  @lib    DrmRights.dll
+*  @since  3.0
+*/
+class CDRMAsset: public CBase
+    {
+public:
+
+    IMPORT_C static CDRMAsset* NewL(void);
+    IMPORT_C static CDRMAsset* NewLC(void);
+    IMPORT_C virtual ~CDRMAsset(void);
+    
+    IMPORT_C void DuplicateL(CDRMAsset& aAsset);
+    IMPORT_C void ExternalizeL(RWriteStream& aStream);
+    IMPORT_C void InternalizeL(RReadStream& aStream);
+    
+    HBufC8* iUid;
+    HBufC8* iParentRights;
+    TBuf8<KDCFKeySize> iKey;
+    TBuf8<KProtectedDCFKeySize> iProtectedKey;
+    TBuf8<KDcfDigestSize> iDigest;
+
+    TBuf8<KDCFKeySize> iAuthenticationSeed;
+    TBuf8<KProtectedDCFKeySize> iProtectedAuthSeed;
+    
+protected:
+    CDRMAsset(void);
+    };
+
+#endif      // DRMASSET_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/inc/DrmRights.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,753 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of class DrmRights for accessing common
+*                DRM functions
+*
+*/
+
+
+#ifndef DRMRIGHTS_H
+#define DRMRIGHTS_H
+
+#include <e32base.h>
+#include <caf/caf.h>
+#include "DcfCommon.h"
+#include "DrmAsset.h"
+#include "DrmPermission.h"
+#include "DrmConstraint.h"
+
+using namespace ContentAccess;
+// TEST DEFINITION
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  CDRMRightsConstraints: Encapsulates rights constaints for a specific right.
+*
+*  @lib    DrmRights.dll
+*  @since  2.5
+*/
+class CDRMRightsConstraints: public CBase
+    {
+public:     // Data Types
+    enum TConstraintPriority
+        {
+        ENoConstraints = 8,
+        ETime = 7,
+        ETimeInterval = 6,
+        ETimeIntervalCount = 5,
+        ETimeCount = 4,
+        EInterval = 3,
+        EIntervalCount = 2,
+        ECount = 1
+        };
+public:  // Constructors and destructor
+    
+    /**
+    * Two-phased constructor.
+    */
+    IMPORT_C static CDRMRightsConstraints* NewL(void);
+    
+    /**
+    * Destructor.
+    */
+    IMPORT_C virtual ~CDRMRightsConstraints(void);
+    
+public: // New functions
+    
+    /**
+    * FullRights
+    * 
+    * The FullRights function checks if the object contains any restrictions 
+    * or if usage is unconstrained.
+    *
+    * @since  2.5
+    * @return ETrue if this object represents unconstrained rights, EFalse if
+    *         there are some constraints set
+    */
+    IMPORT_C TBool FullRights(void);
+    
+    /**
+    * IsPreview
+    * 
+    * The function checks if the object represents a preview constraint.
+    *
+    * @since  2.5
+    * @return ETrue if this object represents a preview constraint, EFalse
+    *         otherwise
+    */
+    IMPORT_C TBool IsPreview(void);
+
+    /**
+    * GetConstraintInfo
+    * 
+    * The fucntion retunrs expiration and constraint details of the object  
+    *
+    * @since  2.5
+    * @param  aExpiration: return parameter for the expiration detail of the
+    *         object. EValid, EExpired, EFuture
+    * @param  aConstType: return parameter for the constraint details of the
+    *         object. A bitmask combination of ETimeBased, EInActiveInterval,
+    *         ECountBased. Or only ENoConstraints 
+    * @return Priority value of the object, if the details were returned
+    *         succesfully. Priority value defines, which constraint is used
+    *         during decryption. The highest one is consumed first.
+    *         EInvalidRights if details cannot be retrieved. 
+    */
+    IMPORT_C TInt GetConstraintInfo(
+        TUint32& aExpiration,
+        TUint32& aConstType);
+
+    /**
+    * GetExpirationDetails
+    * 
+    * The function returns the end time and amount of counts left of the object.
+    * 
+    * @since  2.5
+    * @param  aEndTime: return parameter for the end time value of the object.
+    *         If end time restriction is not defined, parameter is set to 0.
+    * @param  aCountsLeft: return parameter for amount of counts left. If count
+    *         restriction is not defined, parameter is set to -1.          
+    * @return EOk if details were retrieved successfully.
+    * 
+    */
+    IMPORT_C TInt GetExpirationDetails(
+        TTime& aEndTime,
+        TInt& aCountsLeft);
+	
+    /**
+    * GetCounters
+    * 
+    * This function returns the current value of the count restriction and
+    * original value of the count restriction(value when the rights object
+        * was added to the rights database)
+    *
+    * @since  2.5
+    * @param  aCounter: out parameter for the current counter value
+    * @param  aOriginalCounter: out parameter for the original counter value
+    * @return EOk if the counters were returned successfully, ENoRights if 
+    *         the object does not contain count based restrictions
+    */
+    IMPORT_C TInt GetCounters(
+        TUint32& aCounter, 
+        TUint32& aOriginalCounter);
+    
+    /**
+    * GetTimedCounters
+    * 
+    * This function returns the current value of the timed count restriction and
+    * original value of the count restriction(value when the rights object
+        * was added to the rights database)
+    *
+    * @since  3.0
+    * @param  aCounter: out parameter for the current timed counter value
+    * @param  aOriginalCounter: out parameter for the original counter value
+    * @return EOk if the counters were returned successfully, ENoRights if 
+    *         the object does not contain count based restrictions
+    */
+    IMPORT_C TInt GetTimedCounters(
+        TUint32& aCounter, 
+        TUint32& aOriginalCounter);
+    
+    /**
+    * GetStartTime
+    * 
+    * This function returns the start time constraint.
+    *
+    * @since  2.5
+    * @param  aStartTime: out parameter for the start time restriction
+    * @return EOk if the time restriction were returned successfully, 
+    *         ENoRights if the object does not contain a start time
+    *         restrictions
+    */
+    IMPORT_C TInt GetStartTime(
+        TTime& aStartTime);
+    
+    /**
+    * GetEndTime
+    * 
+    * This function returns the end time constraint.
+    *
+    * @since  2.5
+    * @param  aEndTime: out parameter for the end time restriction
+    * @return EOk if the time restriction were returned successfully, 
+    *         ENoRights if the object does not contain an end time
+    *         restrictions
+    */
+    IMPORT_C TInt GetEndTime(
+        TTime& aEndTime);
+    
+    /**
+    * GetInterval
+    * 
+    * This function returns interval time constraint
+    *
+    * @since  2.5
+    * @param  anInterval: out parameter for the interval restriction
+    * @return EOk if the interval time restriction was returned successfully, 
+    *         ENoRights if the object does not contain interval based restrictions
+    */
+    IMPORT_C TInt GetInterval(
+        TTimeIntervalSeconds& anInterval);
+    
+    /**
+    * GetIntervalStart
+    * 
+    * This function returns the start time of an activated interval
+    *
+    * @since  2.5
+    * @param  anInterval: out parameter for the start of an activated interval 
+    * @return EOk if the interval start time was returned successfully, 
+    *         ENoRights if the interval has not been started yet
+    */
+    IMPORT_C TInt GetIntervalStart(
+        TTime& aStartTime);
+    
+    /**
+    * GetAccumulated
+    * 
+    * This function returns accumulated time constraint
+    *
+    * @since  3.0
+    * @param  aAccumulated: out parameter for the accumulated time restriction
+    * @return EOk if the accumulated time restriction was returned successfully, 
+    *         ENoRights if the object does not contain accumulated time based restrictions
+    */
+    IMPORT_C TInt GetAccumulated(
+        TTimeIntervalSeconds& anInterval);
+    
+    /**
+    * SetCounters
+    * 
+    * Sets the counter instance variables of the rights constraint
+    *
+    * @since  2.5
+    * @param  aCounter: the current counter value
+    * @param  aOriginalCounter: the original counter value
+    * @return EOk if the counters were set successfully
+    */
+    IMPORT_C TInt SetCounters(
+        TUint32 aCounter, 
+        TUint32 aOriginalCounter);
+    
+    /**
+    * SetStartTime
+    * 
+    * Sets the start time constraint.
+    *
+    * @since  2.5
+    * @param  aStartTime: the start time restriction
+    * @return EOk if the time restriction was set successfully, 
+    *         ENoRights if the object does not contain a start time
+    *         restrictions
+    */
+    IMPORT_C TInt SetStartTime(
+        TTime aStartTime);
+    
+    /**
+    * SetEndTime
+    * 
+    * Sets the end time constraint.
+    *
+    * @since  2.5
+    * @param  aEndTime: the end time restriction
+    * @return EOk if the time restriction was set successfully, 
+    */
+    IMPORT_C TInt SetEndTime(
+        TTime aEndTime);
+    
+    /**
+    * SetInterval
+    * 
+    * Sets the interval time constraint
+    *
+    * @since  2.5
+    * @param  anInterval: the interval restriction
+    * @return EOk if the interval time restriction was set successfully.
+    */
+    IMPORT_C TInt SetInterval(
+        TTimeIntervalSeconds anInterval);
+    
+    /**
+    * SetIntervalStart
+    * 
+    * Sets the interval start time constraint
+    *
+    * @since  2.5
+    * @param  anInterval: the interval start restriction
+    * @return EOk if the interval start restriction was set successfully.
+    */
+    IMPORT_C TInt SetIntervalStart(
+        TTime aStartTime);
+    
+    /**
+    *
+    * @since  3.0
+    * @param  
+    * @return 
+    */
+    IMPORT_C CDRMConstraint& GetConstraint(void);
+
+    /**
+    *
+    * @since  3.0
+    * @param  
+    * @return 
+    */
+    IMPORT_C void SetConstraint(CDRMConstraint&);
+
+    /**
+    * operator=
+    * 
+    * Assignment operator.
+    *
+    * @since  2.5
+    * @param  aConstraint: constraint to copy data from
+    * @return a copy of the aConstraint parameter.
+    */
+    IMPORT_C CDRMRightsConstraints& operator=(
+        CDRMRightsConstraints& aConstraint);
+
+protected:
+    
+    /**
+    * Default constructor.
+    */
+    IMPORT_C CDRMRightsConstraints(void);
+    
+    /**
+    * 2nd phase constructor.
+    */
+    IMPORT_C void ConstructL(void);
+    
+    
+protected: // Data
+
+    CDRMConstraint* iConstraint;    
+    };
+
+// CLASS DECLARATION
+
+/**
+*  CDRMRights: Encapsulates a single rights object.
+*
+*  @lib    DrmRights.dll
+*  @since  2.5
+*/
+class CDRMRights: public CBase, public MAgentRightsBase
+    {
+public:     // Data Types
+    enum TExpiration
+        {
+        EValidRights = 100,
+        EFutureRights = 10,
+        EExpiredRights = 1 
+        };
+    
+    enum TConstraintType
+        {
+        ENoConstraints = 0x0001,
+        ETimeBased = 0x0002,
+        EInActiveInterval = 0x0004,
+        ECountBased = 0x0008,
+        ETimeIsAccumulatedTime = 0x0010
+        };
+    
+    enum TRestriction
+        {
+        EFullRights = 1, 
+        ERestrictedRights,
+        EPreviewRights
+        };
+
+    enum
+        {
+        EPlay = ContentAccess::EPlay,
+        EDisplay = ContentAccess::EView, 
+        EExecute = ContentAccess::EExecute, 
+        EPrint = ContentAccess::EPrint, 
+        EInstall = ContentAccess::EInstall, 
+        };
+
+    enum TConsumeAction
+        {
+        EStart,
+        EFinish,
+        };
+    
+    enum
+        {
+        EOk = KErrNone, 
+        EGeneralError = -30100, 
+        EUnknownMIME = -30101, 
+        EVersionNotSupported = -30102, 
+        ESessionError = -30103, 
+        ENoRights = KErrCANoRights, 
+        ERightsDBCorrupted = -30105, 
+        EUnsupported = KErrCANotSupported, 
+        ERightsExpired = KErrCANoPermission, 
+        EInvalidRights = -30108
+        };
+    
+    enum
+        {
+        EForwardLock = 0x0001, 
+        ECombinedDelivery = 0x0002, 
+        ESeparateDelivery = 0x0004, 
+        ESuperDistribution = 0x0008
+        };
+
+public:  // Constructors and destructor
+    
+    /**
+    * Two-phased constructor.
+    */
+    IMPORT_C static CDRMRights* NewL(void);
+    
+    /**
+    * Destructor.
+    */
+    IMPORT_C virtual ~CDRMRights(void);
+    
+public: // New functions
+    
+    /**
+    * GetContentURI
+    * 
+    * This function returns the content URI of the object
+    *
+    * @since  2.5
+    * @param  aContentURI: out parameter for the content URI.
+    * @return EOk if the URI was returned successfully.
+    */
+    IMPORT_C TInt GetContentURI(
+        HBufC8*& aContentURI);
+    
+    /**
+    * GetLocalID
+    * 
+    * This function returns the local ID of the object
+    *
+    * @since  2.5
+    * @return the local ID.
+    */
+    IMPORT_C TUint32 GetLocalID(void);
+    
+    /**
+    * GetAddTime
+    * 
+    * This function returns the time when the rights object was added to the
+    * rights database
+    *
+    * @since  2.5
+    * @param  aTime: out parameter for the time.
+    */
+    IMPORT_C void GetAddTime(
+        TTime& aTime);
+    
+    /**
+    * GetRightsInfo
+    * 
+    * This function returns the restriction details associated with given
+    * permission.
+    *
+    * @since  2.5
+    * @param  aConstraintSpec: The permissions to be checked defined as a 
+    *         bitmask combination of EPlay, EDisplay, EExecute and EPrint
+    * @param  aRestriction: return paramer for the restriction detail of the
+    *         object: EFullRights, ERestrictedRights or EPreviewRights
+    * @param  aExpiration: return parameter for the expiration detail of the
+    *         object: EValid, EExpired, EFuture
+    * @param  aConstType: return parameter for the constraint details of the
+    *         object. ETimeBased, EInActiveInterval, ECountBased or ENoConstraints 
+    * @return Priority value of the object, if the details were returned
+    *         succesfully. Priority value defines, which object is used
+    *         during decryption. The value is calculated with formula:
+    *         TConstraintPriority * TRightsExpiration.
+    *         ENoRights if no rights for given permissions.	      
+    */
+    IMPORT_C TInt GetRightsInfo(
+        TUint32 aConstraintSpec,
+        TRestriction& aRestriction,
+        TExpiration& aExpiration,
+        TUint32& aConstType);
+
+    /**
+    * GetExpirationDetails
+    * 
+    * The function returns the end time and amount of counts left of the object
+    * associated with given permission. The use of this method is only recommended
+    * for objects, which contain a end time or a count restriction. The constraint
+    * type information can be retrieved with e.g. GetRightsInfo -function.
+    * In cases of full rights and inactive interval rights the aEndTime is set to
+    * 0 and the aCountsLeft is set to < 0.
+    * 
+    * @since  2.5
+    * @param  aConstraintSpec: The permissions to be checked defined as a 
+    *         bitmask combination of EPlay, EDisplay, EExecute and EPrint.
+    * @param  aEndTime: return parameter for the end time value of the object.
+    *         If end time restriction is not defined, parameter is set to 0.
+    * @param  aCountsLeft: return parameter for amount of counts left. If count
+    *         restriction is not defined, parameter is set to -1.          
+    * @return EOk if details were retrieved successfully. ENoRights if no rights
+    *         for given permissions.	 
+    */
+    IMPORT_C TInt GetExpirationDetails(
+        TUint32 aConstraintSpec,
+        TTime& aEndTime,
+        TInt& aCountsLeft);
+    
+    /**
+    * GetPlayRight
+    * 
+    * This function returns the constraints associated with the play right.
+    *
+    * @since  2.5
+    * @param  aConstraint: out parameter for the constraints associated with
+    *         this right. It must be deleted by the caller.
+    * @return EOk if the right exists and the associated restrictions were 
+    *         returned successfully, ENoRights if the object does not contain
+    *         the given right.
+    */
+    IMPORT_C TInt GetPlayRight(
+        CDRMRightsConstraints*& aConstraint);
+    
+    /**
+    * GetDisplayRight
+    * 
+    * This function returns the constraints associated with the display right.
+    *
+    * @since  2.5
+    * @param  aConstraint: out parameter for the constraints associated with
+    *         this right. It must be deleted by the caller.
+    * @return EOk if the right exists and the associated restrictions were 
+    *         returned successfully, ENoRights if the object does not contain
+    *         the given right.
+    */
+    IMPORT_C TInt GetDisplayRight(
+        CDRMRightsConstraints*& aConstraint);
+    
+    /**
+    * GetPrintRight
+    * 
+    * This function returns the constraints associated with the print right.
+    *
+    * @since  2.5
+    * @param  aConstraint: out parameter for the constraints associated with
+    *         this right. It must be deleted by the caller.
+    * @return EOk if the right exists and the associated restrictions were 
+    *         returned successfully, ENoRights if the object does not contain
+    *         the given right.
+    */
+    IMPORT_C TInt GetPrintRight(
+        CDRMRightsConstraints*& aConstraint);
+    
+    /**
+    * GetExecuteRight
+    * 
+    * This function returns the constraints associated with the execute right.
+    *
+    * @since  2.5
+    * @param  aConstraint: out parameter for the constraints associated with
+    *         this right. It must be deleted by the caller.
+    * @return EOk if the right exists and the associated restrictions were 
+    *         returned successfully, ENoRights if the object does not contain
+    *         the given right.
+    */
+    IMPORT_C TInt GetExecuteRight(
+        CDRMRightsConstraints*& aConstraint);
+    
+    /**
+    * GetContentURIAndLocalID
+    * 
+    * This function sets the content URI and local ID of the object.
+    *
+    * @since  2.5
+    * @param  aContentURI: the new content URI.
+    * @param  aLocalID: the new local ID.
+    * @return EOk if the values were set successfully.
+    */
+    IMPORT_C TInt SetContentURIAndLocalID(
+        HBufC8* aContentURI, 
+        TUint32 aLocalID);
+
+    IMPORT_C TInt SetContentURI(
+        HBufC8* aContentURI);
+
+    IMPORT_C TInt SetLocalID(
+        TUint32 aLocalID);
+    
+    /**
+    * SetAddTime
+    * 
+    * Sets the add time of the object.
+    *
+    * @since  2.5
+    * @param  aTime: the new add time.
+    * @return EOk if the value was set successfully.
+    */
+    IMPORT_C void SetAddTime(
+        TTime aTime);
+    
+    /**
+    * SetPlayRight
+    * 
+    * This function sets the play constraints.
+    *
+    * @since  2.5
+    * @param  aConstraint: the constraints associated with the play right.
+    *         It must be deleted by the caller.
+    * @return EOk if the restrictions were set successfully
+    */
+    IMPORT_C TInt SetPlayRight(
+        CDRMRightsConstraints* aConstraint);
+    
+    /**
+    * SetDisplayRight
+    * 
+    * This function sets the constraints.
+    *
+    * @since  2.5
+    * @param  aConstraint: the constraints associated with the display right.
+    *         It must be deleted by the caller. 
+    * @return EOk if the restrictions were set successfully
+    */
+    IMPORT_C TInt SetDisplayRight(
+        CDRMRightsConstraints* aConstraint);
+    
+    /**
+    * SetPrintRight
+    * 
+    * This function sets the print constraints.
+    *
+    * @since  2.5
+    * @param  aConstraint: the constraints associated with the print right.
+    *         It must be deleted by the caller.
+    * @return EOk if the restrictions were set successfully
+    */
+    IMPORT_C TInt SetPrintRight(
+        CDRMRightsConstraints* aConstraint);
+    
+    /**
+    * SetExecuteRight
+    * 
+    * This function sets the execute constraints.
+    *
+    * @since  2.5
+    * @param  aConstraint: the constraints associated with the execute right.
+    *         It must be deleted by the caller.
+    * @return EOk if the restrictions were set successfully
+    */
+    IMPORT_C TInt SetExecuteRight(
+        CDRMRightsConstraints* aConstraint);
+    
+    /**
+    * operator=
+    * 
+    * Assignment operator.
+    *
+    * @since  2.5
+    * @param  aRight: object to copy data from
+    * @return a copy of the aRight parameter.
+    */
+    IMPORT_C CDRMRights& operator=(
+        CDRMRights& aRight);
+
+    /**
+    * 
+    *
+    * @since  3.0
+    * @param  
+    * @return 
+    */
+    IMPORT_C CDRMPermission& GetPermission(void);
+
+    /**
+    * Permission needs to be freed, doesn't take control
+    *
+    * @since  3.0
+    * @param  
+    * @return 
+    */
+    IMPORT_C void SetPermissionL(CDRMPermission& aPermission);
+
+    /**
+    * 
+    *
+    * @since  3.0
+    * @param  
+    * @return 
+    */
+    IMPORT_C CDRMAsset& GetAsset(void);
+
+    /**
+    * Asset needs to be freed, doesn't take control
+    *
+    * @since  3.0
+    * @param  
+    * @return 
+    */
+    IMPORT_C void SetAssetL(CDRMAsset& aAsset);
+    
+    /**
+    * 
+    *
+    * @since  3.0
+    * @param  
+    * @return 
+    */
+    IMPORT_C void ExternalizeL(RWriteStream& aStream) const;
+
+    /**
+    * 
+    *
+    * @since  3.0
+    * @param  
+    * @return 
+    */
+	IMPORT_C void InternalizeL(RReadStream& aStream);
+    
+    /**
+    * Merge with another rights object
+    *
+    * @since  3.0
+    * @param  
+    * @return 
+    */
+	IMPORT_C void Merge(const CDRMRights& aRights);
+    
+protected:
+    
+    /**
+    * Default constructor.
+    */
+    IMPORT_C CDRMRights(void);
+    
+    /**
+    * 2nd phase constructor.
+    */
+    IMPORT_C void ConstructL(void);
+    
+    
+protected: // Data
+
+    CDRMAsset* iAsset;
+    CDRMPermission* iPermission;
+    };
+
+#endif      // DRMRIGHTS_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/tsrc/Bmarm/DrmRightsTestU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	LibEntryL__Fv @ 1 NONAME R3UNUSED ; LibEntryL(void)
+	SetRequirements__FRP16CTestModuleParamRUl @ 2 NONAME R3UNUSED ; SetRequirements(CTestModuleParam *&, unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/tsrc/Bwins/DrmRightsTestU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * __cdecl LibEntryL(void)
+	?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int __cdecl SetRequirements(class CTestModuleParam * &,unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/tsrc/EABI/DrmRightsTestU.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	_Z9LibEntryLv @ 1 NONAME
+	_Z15SetRequirementsRP16CTestModuleParamRm @ 2 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/tsrc/data/c/content.dcf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,7 @@
+
+8image/jpegcid:testcontent20090526095637-2657230746@testcontent.comgàEncryption-Method: AES128CBC;padding=RFC2630
+Content-Name: "content_name"
+Rights-Issuer: http://127.0.0.1/testcontent
+Content-Description: "content_description"
+Content-Vendor: "content_vendor"
+Icon-Uri: iconuritestcontent.comù•Å¨´A•n)¯Oª‘[Ž»×s‚Ö›Þ®7¯æXØé©¿í†Ù›92÷Ýõ¦3e¿±ÐQ”æ¾Ú82_“Wµê×4ÐЯÅŒ‘ýïàqÍ•³€ÕºvMZ«4Dz‰P‘j{g…¦gÈè–«[ÛÆE“>:µ,ƒ¥‚ Ró­‘w;_õX©†uZÌ¥dp¼0ëùœÛèh˜ÄÊÓ¼`¡ÙrgÀ§¼v
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/tsrc/group/DrmRightsTest.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DrmRightsTest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E7
+
+CAPABILITY      ALL -TCB
+
+DEFFILE         DrmRightsTest.def
+
+SOURCEPATH      ../src
+SOURCE          DrmRightsTest.cpp
+SOURCE          DrmRightsTestCases.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../../inc
+USERINCLUDE     ../../../../omadrm/drmengine/ro/inc
+USERINCLUDE     ../../../../omadrm/drmengine/server/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         drmcommon.lib
+LIBRARY         drmdcf.lib
+LIBRARY         drmparsers.lib
+LIBRARY         drmrights.lib
+LIBRARY         drmserverinterfaces.lib
+LIBRARY         apmime.lib
+LIBRARY         efsrv.lib
+LIBRARY         estor.lib
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+
+SMPSAFE
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/tsrc/group/DrmRightsTest.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,35 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Languages
+; =========
+&EN
+
+; Name, UID for installation, Maj.Ver., Min.Ver., Variant, FLAG TO SPECIFY UNICODE, System component
+; ==================================================================================================
+#{"DRM rights test"},(0x101FB3E7),1,0,1,TYPE=SA
+
+
+; Localised Vendor name
+%{"Nokia-EN"}
+
+; Unique Vendor name
+:"Nokia"
+
+"\epoc32\release\armv5\urel\DrmRightsTest.dll"      -"$:\sys\bin\DrmRightsTest.dll"
+"..\data\c\content.dcf"                             -"c:\testing\data\content.dcf"
+
+; eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/tsrc/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file
+*
+*/
+
+
+
+PRJ_PLATFORMS
+WINSCW ARMV5
+
+DEFAULT
+
+PRJ_TESTEXPORTS
+../data/c/content.dcf /epoc32/winscw/c/testing/data/content.dcf
+
+PRJ_EXPORTS
+
+PRJ_TESTMMPFILES
+DrmRightsTest.mmp
+
+PRJ_MMPFILES
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/tsrc/inc/DrmRightsTest.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,740 @@
+/*
+* Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DrmRightsTest test module.
+*
+*/
+
+
+
+#ifndef DRMRIGHTSTEST_H
+#define DRMRIGHTSTEST_H
+
+// INCLUDES
+#include "StifTestModule.h"
+#include <StifLogger.h>
+
+// Logging path
+_LIT( KDrmRightsTestLogPath, "\\logs\\testframework\\DrmRightsTest\\" ); 
+// Log file
+_LIT( KDrmRightsTestLogFile, "DrmRightsTest.txt" ); 
+
+#define GETPTR &
+#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
+#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
+#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
+#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
+
+// FORWARD DECLARATIONS
+class CDrmRightsTest;
+
+typedef TInt (CDrmRightsTest::* TestFunction)(TTestResult&);
+
+// CLASS DECLARATION
+
+/**
+*  An internal structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib DRMCommonTest.lib
+*  @since S60 3.2
+*/
+class TCaseInfoInternal
+    {
+    public:
+        const TText*    iCaseName;
+        TestFunction    iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+    };
+
+// CLASS DECLARATION
+
+/**
+*  A structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib DRMCommonTest.lib
+*  @since S60 3.2
+*/
+class TCaseInfo
+    {
+    public:
+        TPtrC iCaseName;
+        TestFunction iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+
+    TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
+        {
+        };
+
+    };
+
+
+// CLASS DECLARATION
+
+
+/**
+*  This a DrmRightsTest class.
+*  ?other_description_lines
+*
+*  @lib DrmRightsTest.lib
+*  @since S60 3.2
+*/
+NONSHARABLE_CLASS(CDrmRightsTest) : public CTestModuleBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CDrmRightsTest* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CDrmRightsTest();
+
+    
+    public: // Functions from base classes
+
+        /**
+        * From CTestModuleBase InitL is used to initialize the DrmRightsTest. 
+        *       It is called once for every instance of DrmRightsTest after
+        *       its creation.
+        * @since S60 3.2
+        * @param aIniFile Initialization file for the test module (optional)
+        * @param aFirstTime Flag is true when InitL is executed for first 
+        *               created instance of DrmRightsTest.
+        * @return Symbian OS error code
+        */
+        TInt InitL( TFileName& aIniFile, TBool aFirstTime );
+
+        /**
+        * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
+        *   from DrmRightsTest. 
+        * @since S60 3.2
+        * @param aTestCaseFile Test case file (optional)
+        * @param aTestCases  Array of TestCases returned to test framework
+        * @return Symbian OS error code
+        */
+        TInt GetTestCasesL( const TFileName& aTestCaseFile, 
+                            RPointerArray<TTestCaseInfo>& aTestCases );
+
+        /**
+        * From CTestModuleBase RunTestCaseL is used to run an individual 
+        *   test case. 
+        * @since S60 3.2
+        * @param aCaseNumber Test case number
+        * @param aTestCaseFile Test case file (optional)
+        * @param aResult Test case result returned to test framework (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error, which is 
+        *           not reported in aResult parameter as test case failure).
+        */   
+        TInt RunTestCaseL( const TInt aCaseNumber, 
+                           const TFileName& aTestCaseFile,
+                           TTestResult& aResult );
+
+        /**
+        * From CTestModuleBase; OOMTestQueryL is used to specify is particular
+        * test case going to be executed using OOM conditions
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailureType OOM failure type (optional)
+        * @param aFirstMemFailure The first heap memory allocation failure value (optional)
+        * @param aLastMemFailure The last heap memory allocation failure value (optional)
+        * @return TBool
+        */
+        virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
+                                     const TInt /* aCaseNumber */, 
+                                     TOOMFailureType& /* aFailureType */,
+                                     TInt& /* aFirstMemFailure */, 
+                                     TInt& /* aLastMemFailure */ );
+
+        /**
+        * From CTestModuleBase; User may add implementation for OOM test 
+        * environment initialization. Usually no implementation is required.
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
+                                    const TInt /* aCaseNumber */ ); 
+
+        /**
+        * From CTestModuleBase; OOMHandleWarningL. User may add implementation 
+        * for OOM test warning handling. Usually no implementation is required.
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailNextValue FailNextValue for OOM test execution (optional)
+        * @return None
+        */
+        virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
+                                        const TInt /* aCaseNumber */, 
+                                        TInt& /* aFailNextValue */);
+
+        /**
+        * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
+        * test environment. Usually no implementation is required.
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
+                                       const TInt /* aCaseNumber */ );
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDrmRightsTest();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Function returning test case name and pointer to test case function.
+        * @since S60 3.2
+        * @param aCaseNumber test case number
+        * @return TCaseInfo 
+        */
+        const TCaseInfo Case ( const TInt aCaseNumber ) const;
+    
+        /**
+        * Constructor test, constructs DcfCommon object from the file
+        * of which the name is given as an argument.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConstructDcfCommonFileNameTestL( TTestResult& aResult );
+        
+        /**
+        * Constructor test, constructs DcfCommon object from the file
+        * to which a file handle is given as an argument.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConstructDcfCommonFileHandleTestL( TTestResult& aResult );
+        
+        /**
+        * Constructor tests, constructs CDrmAsset object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConstructAssetTestL( TTestResult& aResult );
+        
+        /**
+        * Duplication test, duplicates CDrmAsset object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt AssetDuplicateTestL( TTestResult& aResult );
+        
+        /**
+        * Externalization/Internalization test, CDrmAsset object
+        * is first externalized and then internalized.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt AssetExternalizeInternalizeTestL( TTestResult& aResult );
+        
+        /**
+        * Constructor test, constructs CDrmPermission object
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConstructPermissionTestL( TTestResult& aResult );
+        
+        /**
+        * Size definition test, counts the size of CDrmPermission object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionSizeTestL( TTestResult& aResult );
+        
+        /**
+        * Externalization/Internalization test, CDrmPermission object
+        * is first externalized and then internalized.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionExternalizeInternalizeTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking whether Permission is stateful or not.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionStatefulTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking whether rights is of parent or child type.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionChildTestL( TTestResult& aResult );
+        
+        /**
+        * Test for fetching constraint matching the given intent.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionConstraintForIntentTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking top level constraint of the permission.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionTopLevelConstraintTestL( TTestResult& aResult );
+        
+        /**
+        * Test for consuming rights of the permission.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionConsumeRightsTestL( TTestResult& aResult );
+        
+        /**
+        * Test for exporting and importing permission.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionExportImportTestL( TTestResult& aResult );
+        
+        /**
+        * Test for duplicating permission.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionDuplicateTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking if permission is expired.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionExpiredTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking if permission is valid.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionValidTestL( TTestResult& aResult );
+        
+        /**
+        * Test for merging two permissions.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionMergeTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking if permission has software constraint or not.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PermissionSoftwareConstrainedTestL( TTestResult& aResult );
+        
+        /**
+        * Constructor test, construct CDrmConstraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConstructConstraintTestL( TTestResult& aResult );
+        
+        /**
+        * Constructor test, construct CDrmRightsConstraints.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConstructRightsConstraintsTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking if object has full rights or not.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsFullRightsTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking if object has preview rights constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsIsPreviewTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking the expiration and constraint details
+        * of the object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsGetConstraintInfoTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking the end time and amount of counts left of
+        * of the object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsGetExpirationDetailsTestL( 
+            TTestResult& aResult );
+        
+        /**
+        * Test for checking the current and original value of the count
+        * restriction.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsGetCountersTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking the current and original value of the timed
+        * count restriction.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsGetTimedCountersTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking the start time constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsGetStartTimeTestL( TTestResult& aResult );
+        
+       /**
+        * Test for checking the end time constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsGetEndTimeTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking the interval time constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsGetIntervalTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking the interval start time constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsGetIntervalStartTestL( TTestResult& aResult );
+        
+        /**
+        * Test for checking the accumulated time constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsGetAccumulatedTestL( TTestResult& aResult );
+        
+        /**
+        * Test for setting the counters of the constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsSetCountersTestL( TTestResult& aResult );
+        
+        /**
+        * Test for setting the start time constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsSetStartTimeTestL( TTestResult& aResult );
+        
+        
+        /**
+        * Test for setting the end time constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsSetEndTimeTestL( TTestResult& aResult );
+        
+        /**
+        * Test for setting the interval time constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsSetIntervalTestL( TTestResult& aResult );
+        
+        /**
+        * Test for setting the interval start time constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsSetIntervalStartTestL( TTestResult& aResult );
+        
+        /**
+        * Test for getting constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsGetConstraintTestL( TTestResult& aResult );
+        
+        /**
+        * Test for setting constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsSetConstraintTestL( TTestResult& aResult );
+        
+        /**
+        * Test for assigning constraint to another constraint.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsAssignmentTestL( TTestResult& aResult );
+        
+        /**
+        * Test for getting the local id of the object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsGetLocalIdTestL( TTestResult& aResult );
+        
+        /**
+        * Test for getting the time when rights object was added to
+        * the database.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsGetAddTimeTestL( TTestResult& aResult );
+               
+        /**
+        * Test for getting the restriction details associated with
+        * given permission.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsGetRightsInfoTestL( TTestResult& aResult );
+     
+        /**
+        * Test for getting the end time and amount of counts left of 
+        * the object associated with given permission.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsGetExpirationDetailsTestL( TTestResult& aResult );
+        
+        /**
+        * Test for getting the constraints associated with the print
+        * right.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsGetPrintRightTestL( TTestResult& aResult );
+        
+        /**
+        * Test for setting the content URI and Local Id of the object
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsSetContentURIAndLocalIDTestL( TTestResult& aResult );
+        
+        /**
+        * Test for setting the content URI of the object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsSetContentURITestL( TTestResult& aResult );
+        
+       /**
+        * Test for setting the add time of the object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsSetAddTimeTestL( TTestResult& aResult );
+         
+       /**
+        * Test for setting the play right constraint of the object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsSetPlayRightTestL( TTestResult& aResult );
+        
+      /**
+        * Test for setting the display right constraint of the object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsSetDisplayRightTestL( TTestResult& aResult );     
+     
+      /**
+        * Test for setting the print right constraint of the object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsSetPrintRightTestL( TTestResult& aResult );  
+      
+      /**
+        * Test for setting the execute right constraint of the object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsSetExecuteRightTestL( TTestResult& aResult );  
+      
+      /**
+        * Test for assignment operator.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsAssignmentTestL( TTestResult& aResult );
+      
+      /**
+        * Test for externalizing and internalizing rights object.
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsExternalizeInternalizeTestL( TTestResult& aResult );
+      
+      /**
+        * Test for 
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsMergeTestL( TTestResult& aResult );
+      
+      
+    private:    // Data
+        // Pointer to test (function) to be executed
+        TestFunction iMethod;
+
+        CStifLogger * iLog;
+
+   
+    };
+
+#endif      // DRMRIGHTSTEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/tsrc/src/DrmRightsTest.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,313 @@
+/*
+* Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DrmRightsTest class member functions
+*
+*/
+
+
+// INCLUDE FILES
+#include <Stiftestinterface.h>
+#include "DrmRightsTest.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmRightsTest::CDrmRightsTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDrmRightsTest::CDrmRightsTest()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// Note: If OOM test case uses STIF Logger, then STIF Logger must be created
+// with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
+// allocates memory from heap and therefore causes error situations with OOM 
+// testing. For more information about STIF Logger construction, see STIF Users 
+// Guide.
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsTest::ConstructL()
+    {
+    iLog = CStifLogger::NewL( KDrmRightsTestLogPath, 
+                          KDrmRightsTestLogFile);
+                          
+    // Sample how to use logging
+    _LIT( KLogStart, "DRMCommonTest logging starts!" );
+    iLog->Log( KLogStart );
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDrmRightsTest* CDrmRightsTest::NewL()
+    {
+    CDrmRightsTest* self = new (ELeave) CDrmRightsTest;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+CDrmRightsTest::~CDrmRightsTest()
+    { 
+    delete iLog;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsTest::InitL
+// InitL is used to initialize the Test Module.
+// -----------------------------------------------------------------------------
+//
+TInt CDrmRightsTest::InitL( 
+    TFileName& /*aIniFile*/, 
+    TBool /*aFirstTime*/ )
+    {
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsTest::GetTestCasesL
+// GetTestCases is used to inquire test cases from the Test Module. Test
+// cases are stored to array of test cases. The Test Framework will be 
+// the owner of the data in the RPointerArray after GetTestCases return
+// and it does the memory deallocation. 
+// -----------------------------------------------------------------------------
+//
+TInt CDrmRightsTest::GetTestCasesL( 
+    const TFileName& /*aConfig*/, 
+    RPointerArray<TTestCaseInfo>& aTestCases )
+    {
+
+    // Loop through all test cases and create new
+    // TTestCaseInfo items and append items to aTestCase array    
+    for( TInt i = 0; Case(i).iMethod != NULL; i++ )
+        {
+
+        // Allocate new TTestCaseInfo from heap for a testcase definition.
+        TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
+
+        // PushL TTestCaseInfo to CleanupStack.    
+        CleanupStack::PushL( newCase );
+
+        // Set number for the testcase.
+        // When the testcase is run, this comes as a parameter to RunTestCaseL.
+        newCase->iCaseNumber = i;
+
+        // Set title for the test case. This is shown in UI to user.
+        newCase->iTitle.Copy( Case(i).iCaseName );
+
+        // Append TTestCaseInfo to the testcase array. After appended 
+        // successfully the TTestCaseInfo object is owned (and freed) 
+        // by the TestServer. 
+        User::LeaveIfError(aTestCases.Append ( newCase ) );
+
+        // Pop TTestCaseInfo from the CleanupStack.
+        CleanupStack::Pop( newCase );
+
+        }
+
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsTest::RunTestCaseL
+// RunTestCaseL is used to run an individual test case specified 
+// by aTestCase. Test cases that can be run may be requested from 
+// Test Module by GetTestCases method before calling RunTestCase.
+// -----------------------------------------------------------------------------
+//
+TInt CDrmRightsTest::RunTestCaseL(
+    const TInt aCaseNumber,
+    const TFileName& /*aConfig*/,
+    TTestResult& aResult )
+    {
+    // Return value
+    TInt execStatus = KErrNone;
+
+    // Get the pointer to test case function
+    TCaseInfo tmp = Case ( aCaseNumber );
+
+    _LIT( KLogStartTC, "Starting testcase [%S]" );
+    iLog->Log( KLogStartTC, &tmp.iCaseName);
+
+    // Check that case number was valid
+    if ( tmp.iMethod != NULL )
+        {
+        // Valid case was found, call it via function pointer
+        iMethod = tmp.iMethod;        
+        execStatus  = ( this->*iMethod )( aResult );
+        }
+    else
+        {
+        // Valid case was not found, return error.
+        execStatus = KErrNotFound;
+        }
+
+    // Return case execution status (not the result of the case execution)
+    return execStatus;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsTest::OOMTestQueryL
+// Used to check if a particular test case should be run in OOM conditions and 
+// which memory allocations should fail.    
+//
+// NOTE: This method is virtual and must be implemented only if test case
+// should be executed using OOM conditions.  
+// -----------------------------------------------------------------------------
+//
+TBool CDrmRightsTest::OOMTestQueryL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt aCaseNumber, 
+                                TOOMFailureType& /* aFailureType */, 
+                                TInt& aFirstMemFailure, 
+                                TInt& aLastMemFailure ) 
+    {
+    _LIT( KLogOOMTestQueryL, "CDRMCommonTest::OOMTestQueryL" );
+    iLog->Log( KLogOOMTestQueryL );     
+
+    aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
+    aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation;
+
+    return Case( aCaseNumber ).iIsOOMTest;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsTest::OOMTestInitializeL
+// Used to perform the test environment setup for a particular OOM test case. 
+// Test Modules may use the initialization file to read parameters for Test 
+// Module initialization but they can also have their own configure file or 
+// some other routine to initialize themselves.  
+//
+// NOTE: This method is virtual and must be implemented only if test case
+// should be executed using OOM conditions.  
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsTest::OOMTestInitializeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsTest::OOMHandleWarningL
+// In some cases the heap memory allocation should be skipped, either due to
+// problems in the OS code or components used by the code being tested, or even 
+// inside the tested components which are implemented this way on purpose (by 
+// design), so it is important to give the tester a way to bypass allocation 
+// failures.
+//
+// NOTE: This method is virtual and must be implemented only if test case
+// should be executed using OOM conditions.  
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsTest::OOMHandleWarningL( 
+                                const TFileName& /* aTestCaseFile */,
+                                const TInt /* aCaseNumber */, 
+                                TInt& /* aFailNextValue */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsTest::OOMTestFinalizeL
+// Used to perform the test environment cleanup for a particular OOM test case.
+//
+// NOTE: This method is virtual and must be implemented only if test case
+// should be executed using OOM conditions.  
+// -----------------------------------------------------------------------------
+//                  
+void CDrmRightsTest::OOMTestFinalizeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point
+// Returns: CTestModuleBase*: Pointer to Test Module object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTestModuleBase* LibEntryL()
+    {
+    return CDrmRightsTest::NewL();
+
+    }
+
+// -----------------------------------------------------------------------------
+// SetRequirements handles test module parameters(implements evolution
+// version 1 for test module's heap and stack sizes configuring).
+// Returns: TInt: Symbian error code.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
+                                TUint32& /*aParameterValid*/ )
+    {
+
+    /* --------------------------------- NOTE ---------------------------------
+    USER PANICS occurs in test thread creation when:
+    1) "The panic occurs when the value of the stack size is negative."
+    2) "The panic occurs if the minimum heap size specified is less
+       than KMinHeapSize".
+       KMinHeapSize: "Functions that require a new heap to be allocated will
+       either panic, or will reset the required heap size to this value if
+       a smaller heap size is specified".
+    3) "The panic occurs if the minimum heap size specified is greater than
+       the maximum size to which the heap can grow".
+    Other:
+    1) Make sure that your hardware or Symbian OS is supporting given sizes.
+       e.g. Hardware might support only sizes that are divisible by four.
+    ------------------------------- NOTE end ------------------------------- */
+
+    // Normally STIF uses default heap and stack sizes for test thread, see:
+    // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
+    // If needed heap and stack sizes can be configured here by user. Remove
+    // comments and define sizes.
+
+/*
+    aParameterValid = KStifTestModuleParameterChanged;
+
+    CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
+    // Stack size
+    param->iTestThreadStackSize= 16384; // 16K stack
+    // Heap sizes
+    param->iTestThreadMinHeap = 4096;   // 4K heap min
+    param->iTestThreadMaxHeap = 1048576;// 1M heap max
+
+    aTestModuleParam = param;
+*/
+    return KErrNone;
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_rights_api/tsrc/src/DrmRightsTestCases.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4247 @@
+/*
+* Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DrmRightsTest hard coded test cases
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <apmstd.h>
+#include <f32file.h>
+#include <s32std.h>
+#include <s32file.h>
+#include <drmcommon.h>
+
+#include "drmpermission.h"
+#include "drmpointerarray.h"
+#include "drmrights.h"
+#include "drmrightsclient.h"
+#include "drmrightsparser.h"
+#include "drmrightstest.h"
+
+// CONSTANTS
+
+const TInt KCountsLeft = 99;
+const TInt KNewCount = 50;
+const TInt KNewOriginalCount = 70;
+const TInt KNewIntervalSeconds = 300;
+const TInt KTimedCount = 100;
+const TInt KUriSize = 20;
+
+//#ifdef __WINSCW__
+_LIT( KOma1Content, "c:\\testing\\data\\content.dcf" );
+_LIT( KStoreFile, "c:\\testing\\data\\asset.dat" );
+_LIT( KStoreFile2, "c:\\testing\\data\\permission.dat" );
+_LIT( KStoreFile3, "c:\\testing\\data\\rights.dat" );
+//#else
+//_LIT( KOma1Content, "e:\\testing\\data\\drm\\content.dcf" );
+//_LIT( KStoreFile, "e:\\testing\\data\\drm\\asset.dat" );
+//_LIT( KStoreFile2, "e:\\testing\\data\\drm\\permission.dat" );
+//_LIT( KStoreFile3, "e:\\testing\\data\\drm\\rights.dat" );
+//#endif
+
+_LIT8( KContentId1, "cid:http://test.content@test.com" );
+_LIT8( KContentId2, "cid:" );
+_LIT8( KContentIdParent, "ro-parent2" );
+_LIT8( KUri, "test.encrypt");
+
+_LIT(KNullDate,"00000000:000000.000000");
+
+_LIT8( KROHead1, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\
+<!DOCTYPE o-ex:rights PUBLIC \"-//OMA//DTD DRMREL 1.0//EN\" \
+\"http://www.oma.org/dtd/dr\">\
+<o-ex:rights \
+xmlns:o-ex=\"http://odrl.net/1.1/ODRL-EX\" \
+xmlns:o-dd=\"http://odrl.net/1.1/ODRL-DD\" \
+xmlns:oma-dd=\"http://www.openmobilealliance.com/oma-dd\" \
+xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#/\">\
+<o-ex:context><o-dd:version>1.0</o-dd:version>\
+</o-ex:context><o-ex:agreement><o-ex:asset><o-ex:context>\
+<o-dd:uid>" );
+
+_LIT8( KROHead2, "<o-ex:rights \
+xmlns:o-ex = \"http://odrl.net/1.1/ODRL-EX\" \
+xmlns:o-dd = \"http://odrl.net/1.1/ODRL-DD\" \
+xmlns:ds = \"http://www.w3.org/2000/09/xmldsig#/\">\
+<o-ex:context><o-dd:version>1.0</o-dd:version></o-ex:context>\
+<o-ex:agreement><o-ex:asset><o-ex:context>\
+<o-dd:uid>" );
+
+_LIT8( KROParentHeadPlay, "<rights \
+xmlns:o-ex= \"http://odrl.net/1.1/ODRL-EX\" o-ex:id= \"REL0\"><o-ex:context>\
+<o-dd:version xmlns:o-dd= \"http://odrl.net/1.1/ODRL-DD\">\
+2.0</o-dd:version><o-dd:uid xmlns:o-dd= \"http://odrl.net/1.1/ODRL-DD\">\
+offer-parent2-full.offer-parent2-full.6otCOdBKVXzA0WLE</o-dd:uid>\
+</o-ex:context><o-ex:agreement><o-ex:asset o-ex:id= \"a1\"><o-ex:context>\
+<o-dd:uid xmlns:o-dd= \"http://odrl.net/1.1/ODRL-DD\">ro-parent2)" );
+
+_LIT8( KROParentTailPlay, "</o-dd:uid></o-ex:context></o-ex:asset>\
+<o-ex:permission><o-ex:asset o-ex:idref= \"a1\"></o-ex:asset>\
+<o-dd:play xmlns:o-dd= \"http://odrl.net/1.1/ODRL-DD\">\
+</o-dd:play></o-ex:permission></o-ex:agreement></rights>" );
+
+_LIT8( KROTailAccumulatedPlay, "</o-dd:uid></o-ex:context><ds:KeyInfo>\
+<ds:KeyValue>MyK9p+SvfH1vJhAR/9Uhww==</ds:KeyValue></ds:KeyInfo>\
+</o-ex:asset><o-ex:permission><o-dd:play><o-ex:constraint>\
+<o-dd:accumulated>P5DT10H00M30S</o-dd:accumulated></o-ex:constraint>\
+</o-dd:play></o-ex:permission></o-ex:agreement></o-ex:rights>" );
+
+_LIT8( KROTailCounterExecute, "</o-dd:uid></o-ex:context><ds:KeyInfo>\
+<ds:KeyValue>NyxU8kZzX280ssYV9aCvgQ==</ds:KeyValue></ds:KeyInfo>\
+</o-ex:asset><o-ex:permission><o-dd:execute><o-ex:constraint>\
+<o-dd:count>99</o-dd:count></o-ex:constraint></o-dd:execute>\
+</o-ex:permission></o-ex:agreement></o-ex:rights>" );
+
+_LIT8( KROTailPreviewCounterExecute, "</o-dd:uid></o-ex:context><ds:KeyInfo>\
+<ds:KeyValue>NyxU8kZzX280ssYV9aCvgQ==</ds:KeyValue></ds:KeyInfo>\
+</o-ex:asset><o-ex:permission><o-dd:execute><o-ex:constraint>\
+<o-dd:count>1</o-dd:count></o-ex:constraint></o-dd:execute>\
+</o-ex:permission></o-ex:agreement></o-ex:rights>" );
+
+_LIT8(KROTailDisplayPrint, "</o-dd:uid></o-ex:context><ds:KeyInfo>\
+<ds:KeyValue>NyxU8kZzX280ssYV9aCvgQ==</ds:KeyValue></ds:KeyInfo>\
+</o-ex:asset><o-ex:permission><o-dd:display></o-dd:display><o-dd:print>\
+</o-dd:print></o-ex:permission></o-ex:agreement></o-ex:rights>" );
+
+_LIT8( KROTailFull, "</o-dd:uid></o-ex:context>\
+<ds:KeyInfo><ds:KeyValue>PgIkd7w3E5TWWcc7Inp8Yw==</ds:KeyValue>\
+</ds:KeyInfo></o-ex:asset><o-ex:permission>\
+<o-dd:play><o-ex:constraint></o-ex:constraint></o-dd:play>\
+<o-dd:display><o-ex:constraint></o-ex:constraint></o-dd:display>\
+<o-dd:execute><o-ex:constraint></o-ex:constraint></o-dd:execute>\
+<o-dd:print><o-ex:constraint></o-ex:constraint></o-dd:print>\
+</o-ex:permission></o-ex:agreement></o-ex:rights>" );
+
+_LIT8( KROTailIntervalExecute, "</o-dd:uid></o-ex:context><ds:KeyInfo>\
+<ds:KeyValue>NyxU8kZzX280ssYV9aCvgQ==</ds:KeyValue></ds:KeyInfo>\
+</o-ex:asset><o-ex:permission><o-dd:execute><o-ex:constraint>\
+<o-dd:interval>P7DT20M</o-dd:interval></o-ex:constraint>\
+</o-dd:execute></o-ex:permission></o-ex:agreement></o-ex:rights>" );
+
+_LIT8( KROTailPlay, "</o-dd:uid></o-ex:context><ds:KeyInfo>\
+<ds:KeyValue>NyxU8kZzX280ssYV9aCvgQ==</ds:KeyValue>\
+</ds:KeyInfo></o-ex:asset><o-ex:permission>\
+<o-dd:play/></o-ex:permission></o-ex:agreement></o-ex:rights>" );
+
+_LIT8( KROTailStartEndExecute, "</o-dd:uid></o-ex:context><ds:KeyInfo>\
+<ds:KeyValue>NyxU8kZzX280ssYV9aCvgQ==</ds:KeyValue></ds:KeyInfo>\
+</o-ex:asset><o-ex:permission><o-dd:execute><o-ex:constraint>\
+<o-dd:datetime><o-dd:start>2003-05-12T15:35:56Z</o-dd:start>\
+<o-dd:end>2005-01-30T15:35:56Z</o-dd:end></o-dd:datetime>\
+</o-ex:constraint></o-dd:execute></o-ex:permission>\
+</o-ex:agreement></o-ex:rights>" );
+
+_LIT8( KROTailStartEndIntervalPlay, "</o-dd:uid></o-ex:context><ds:KeyInfo>\
+<ds:KeyValue>MyK9p+SvfH1vJhAR/9Uhww==</ds:KeyValue></ds:KeyInfo>\
+</o-ex:asset><o-ex:permission><o-dd:play><o-ex:constraint>\
+<o-dd:datetime><o-dd:start>2007-05-12T15:35:56</o-dd:start>\
+<o-dd:end>2008-01-30T15:35:56</o-dd:end></o-dd:datetime>\
+<o-dd:interval>P15DT10H30M20S</o-dd:interval></o-ex:constraint>\
+</o-dd:play></o-ex:permission></o-ex:agreement>\
+</o-ex:rights>" );
+
+_LIT8( KROTailTimedPlay, "</o-dd:uid></o-ex:context><ds:KeyInfo>\
+<ds:KeyValue>MyK9p+SvfH1vJhAR/9Uhww==</ds:KeyValue></ds:KeyInfo>\
+</o-ex:asset><o-ex:permission><o-dd:play><o-ex:constraint>\
+<o-dd:timed-count timer=\"60\">100</o-dd:timed-count>\
+</o-ex:constraint></o-dd:play></o-ex:permission></o-ex:agreement>\
+</o-ex:rights>" );
+
+_LIT( KRunning, "Running" );
+_LIT( KFinished, "Finished" );
+_LIT( KPassed, "Passed" );
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C void DeleteRODBL( );
+LOCAL_C void AddROGetRightsL( const TDesC8& aHead, const TDesC8& aCID, 
+    const TDesC8& aTail, RPointerArray<CDRMRights>& aRights  );
+
+
+// ============================= LOCAL FUNCTIONS ==============================
+    
+// ----------------------------------------------------------------------------
+// AddROGetRightsL
+// Helper function with which test cases can add ROs and get the added rights
+// (in the CDRMPointerArray).
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void AddROGetRightsL( const TDesC8& aHead, const TDesC8& aCID, 
+    const TDesC8& aTail, RPointerArray<CDRMRights>& aRights )
+    {
+    
+    aRights.ResetAndDestroy();
+    
+	TInt roSize( aHead.Size() + aCID.Size() + aTail.Size() );
+    HBufC8* buf( HBufC8::NewLC( roSize ) );
+    TPtr8 tmp( buf->Des() );
+    
+    tmp.Append( aHead );
+    tmp.Append( aCID );
+    tmp.Append( aTail );
+    
+    CDrmRightsParser* rp( CDrmRightsParser::NewL() );
+    CleanupStack::PushL( rp );
+    
+    rp->ParseAndStoreL( *buf, aRights );
+    
+    CleanupStack::PopAndDestroy( 2, buf ); // buf, rp
+    
+	}
+
+// ----------------------------------------------------------------------------
+// DeleteRODBL
+// Helper function with which test cases can delete RO database.
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void DeleteRODBL( )
+    {
+	RDRMRightsClient client;
+    User::LeaveIfError( client.Connect() );
+    client.DeleteAll();
+    client.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// TDoResetAndDestroy
+// Template method used to push RPointerArrays to the cleanup stack. Takes
+// care of deleting all pointers in the array.
+// ----------------------------------------------------------------------------
+template < class T > class TDoResetAndDestroy
+    {
+    public:
+        TDoResetAndDestroy( T& aT ):iObj( &aT )
+            {
+            };
+        void PushL()
+            {
+            TCleanupItem item( &Reset, iObj );
+            CleanupStack::PushL( item );
+            };
+                         
+        void Pop()
+            {
+            CleanupStack::Pop();
+            };
+        static void Reset( TAny* aPtr )
+            {
+            __ASSERT_ALWAYS( aPtr, User::Invariant() );
+            reinterpret_cast< T* >( aPtr )->ResetAndDestroy();
+            };
+                
+    private:
+        TDoResetAndDestroy(); // prohibit
+    
+    private:
+        T* iObj;
+    };
+
+// ============================ MEMBER FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// CDrmRightsTest::Case
+// Returns a test case by number.
+//
+// This function contains an array of all available test cases 
+// i.e pair of case name and test function. If case specified by parameter
+// aCaseNumber is found from array, then that item is returned.
+// 
+// The reason for this rather complicated function is to specify all the
+// test cases only in one place. It is not necessary to understand how
+// function pointers to class member functions works when adding new test
+// cases. See function body for instructions how to add new test case.
+// ----------------------------------------------------------------------------
+//
+const TCaseInfo CDrmRightsTest::Case ( 
+    const TInt aCaseNumber ) const 
+     {
+
+    /**
+    * To add new test cases, implement new test case function and add new 
+    * line to KCases array specify the name of the case and the function 
+    * doing the test case
+    * In practice, do following
+    * 1) Make copy of existing test case function and change its name
+    *    and functionality. Note that the function must be added to 
+    *    DRMRightsTest.cpp file and to DRMRightsTest.h 
+    *    header file.
+    *
+    * 2) Add entry to following KCases array either by using:
+    *
+    * 2.1: FUNCENTRY or ENTRY macro
+    * ENTRY macro takes two parameters: test case name and test case 
+    * function name.
+    *
+    * FUNCENTRY macro takes only test case function name as a parameter and
+    * uses that as a test case name and test case function name.
+    *
+    * Or
+    *
+    * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
+    * only with OOM (Out-Of-Memory) testing!
+    *
+    * OOM_ENTRY macro takes five parameters: test case name, test case 
+    * function name, TBool which specifies is method supposed to be run using
+    * OOM conditions, TInt value for first heap memory allocation failure and 
+    * TInt value for last heap memory allocation failure.
+    * 
+    * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
+    * that as a test case name, TBool which specifies is method supposed to be
+    * run using OOM conditions, TInt value for first heap memory allocation 
+    * failure and TInt value for last heap memory allocation failure. 
+    */ 
+
+    static TCaseInfoInternal const KCases[] =
+        {
+        // To add new test cases, add new items to this array
+        
+        // NOTE: When compiled to GCCE, there must be Classname::
+        // declaration in front of the method name, e.g. 
+        // CDRMRightsTest::PrintTest. Otherwise the compiler
+        // gives errors.
+        ENTRY( "Rig::ConstructDcfCommonFileNameTestL", 
+                CDrmRightsTest::ConstructDcfCommonFileNameTestL ),
+        ENTRY( "Rig::ConstructDcfCommonFileHandleTestL", 
+                CDrmRightsTest::ConstructDcfCommonFileHandleTestL ),
+        ENTRY( "Rig::ConstructAssetTestL", 
+                CDrmRightsTest::ConstructAssetTestL ),
+        ENTRY( "Rig::AssetDuplicateTestL", 
+                CDrmRightsTest::AssetDuplicateTestL ),
+        ENTRY( "Rig::AssetExternalizeInternalizeTestL", 
+                CDrmRightsTest::AssetExternalizeInternalizeTestL ),
+        ENTRY( "Rig::ConstructPermissionTestL", 
+                CDrmRightsTest::ConstructPermissionTestL ),
+        ENTRY( "Rig::PermissionSizeTestL", 
+                CDrmRightsTest::PermissionSizeTestL ),
+        ENTRY( "Rig::PermissionExternalizeInternalizeTestL", 
+                CDrmRightsTest::PermissionExternalizeInternalizeTestL ),
+        ENTRY( "Rig::PermissionStatefulTestL",
+                CDrmRightsTest::PermissionStatefulTestL ),
+        ENTRY( "Rig::PermissionChildTestL",
+                CDrmRightsTest::PermissionChildTestL ),
+        ENTRY( "Rig::PermissionConstraintForIntentTestL",
+                CDrmRightsTest::PermissionConstraintForIntentTestL ), 
+        ENTRY( "Rig::PermissionTopLevelConstraintTestL",
+                CDrmRightsTest::PermissionTopLevelConstraintTestL ),
+        ENTRY( "Rig::PermissionConsumeRightsTestL",
+                CDrmRightsTest::PermissionConsumeRightsTestL ),
+        ENTRY( "Rig::PermissionExportImportTestL",
+                CDrmRightsTest::PermissionExportImportTestL ),
+        ENTRY( "Rig::PermissionDuplicateTestL",
+                CDrmRightsTest::PermissionDuplicateTestL ),
+        ENTRY( "Rig::PermissionExpiredTestL",
+                CDrmRightsTest::PermissionExpiredTestL ),
+        ENTRY( "Rig::PermissionValidTestL",
+                CDrmRightsTest::PermissionValidTestL ),
+        ENTRY( "Rig::PermissionMergeTestL",
+                CDrmRightsTest::PermissionMergeTestL ),
+        ENTRY( "Rig::PermissionSoftwareConstrainedTestL",
+                CDrmRightsTest::PermissionSoftwareConstrainedTestL ),
+        ENTRY( "Rig::ConstructConstraintTestL",
+                CDrmRightsTest::ConstructConstraintTestL ),
+        ENTRY( "Rig::ConstructRightsConstraintsTestL",
+                CDrmRightsTest::ConstructRightsConstraintsTestL ),
+        ENTRY( "Rig::RightsConstraintsFullRightsTestL",
+                CDrmRightsTest::RightsConstraintsFullRightsTestL ),
+        ENTRY( "Rig::RightsConstraintsIsPreviewTestL",
+                CDrmRightsTest::RightsConstraintsIsPreviewTestL ),
+        ENTRY( "Rig::RightsConstraintsGetConstraintInfoTestL",
+                CDrmRightsTest::RightsConstraintsGetConstraintInfoTestL ),
+        ENTRY( "Rig::RightsConstraintsGetExpirationDetailsTestL",
+                CDrmRightsTest::RightsConstraintsGetExpirationDetailsTestL ),
+        ENTRY( "Rig::RightsConstraintsGetCountersTestL",
+                CDrmRightsTest::RightsConstraintsGetCountersTestL ),
+        ENTRY( "Rig::RightsConstraintsGetTimedCountersTestL",
+                CDrmRightsTest::RightsConstraintsGetTimedCountersTestL ),
+        ENTRY( "Rig::RightsConstraintsGetStartTimeTestL",
+                CDrmRightsTest::RightsConstraintsGetStartTimeTestL ),
+        ENTRY( "Rig::RightsConstraintsGetEndTimeTestL",
+                CDrmRightsTest::RightsConstraintsGetEndTimeTestL ),
+        ENTRY( "Rig::RightsConstraintsGetIntervalTestL",
+                CDrmRightsTest::RightsConstraintsGetIntervalTestL ),
+        ENTRY( "Rig::RightsConstraintsGetIntervalStartTestL", 
+                CDrmRightsTest::RightsConstraintsGetIntervalStartTestL ),
+        ENTRY( "Rig::RightsConstraintsGetAccumulatedTestL",
+                CDrmRightsTest::RightsConstraintsGetAccumulatedTestL ),
+        ENTRY( "Rig::RightsConstraintsSetCountersTestL",
+                CDrmRightsTest::RightsConstraintsSetCountersTestL ),
+        ENTRY( "Rig::RightsConstraintsSetStartTimeTestL",
+                CDrmRightsTest::RightsConstraintsSetStartTimeTestL ),
+        ENTRY( "Rig::RightsConstraintsSetEndTimeTestL",
+                CDrmRightsTest::RightsConstraintsSetEndTimeTestL ),
+        ENTRY( "Rig::RightsConstraintsSetIntervalTestL",
+                CDrmRightsTest::RightsConstraintsSetIntervalTestL ),
+        ENTRY( "Rig::RightsConstraintsSetIntervalStartTestL",
+                CDrmRightsTest::RightsConstraintsSetIntervalStartTestL ),
+        ENTRY( "Rig::RightsConstraintsGetConstraintTestL",
+                CDrmRightsTest::RightsConstraintsGetConstraintTestL ),
+        ENTRY( "Rig::RightsConstraintsSetConstraintTestL",
+                CDrmRightsTest::RightsConstraintsSetConstraintTestL ),
+        ENTRY( "Rig::RightsConstraintsAssignmentTestL",
+                CDrmRightsTest::RightsConstraintsAssignmentTestL ),
+        ENTRY( "Rig::RightsGetLocalIdTestL",
+                CDrmRightsTest::RightsGetLocalIdTestL ),
+        ENTRY( "Rig::RightsGetAddTimeL",
+                CDrmRightsTest::RightsGetAddTimeTestL ),
+        ENTRY( "Rig::RightsGetRightsInfoTestL",
+                CDrmRightsTest::RightsGetRightsInfoTestL ),
+        ENTRY( "Rig::RightsGetExpirationDetailsTestL",
+                CDrmRightsTest::RightsGetExpirationDetailsTestL ),
+        ENTRY( "Rig::RightsGetPrintRightTestL",
+                CDrmRightsTest::RightsGetPrintRightTestL ),
+        ENTRY( "Rig::RightsSetContentURIandLocalIDTestL",
+                CDrmRightsTest::RightsSetContentURIAndLocalIDTestL ),
+        ENTRY( "Rig::RightsSetContentURITestL",
+                CDrmRightsTest::RightsSetContentURITestL ),
+        ENTRY( "Rig::RightsSetAddTimeTestL",
+                CDrmRightsTest::RightsSetAddTimeTestL ),
+        ENTRY( "Rig::RightsSetPlayRightTestL",
+                CDrmRightsTest::RightsSetPlayRightTestL ),
+        ENTRY( "Rig::RightsSetDisplayRightTestL",
+                CDrmRightsTest::RightsSetDisplayRightTestL ),
+        ENTRY( "Rig::RightsSetPrintRightTestL",
+                CDrmRightsTest::RightsSetPrintRightTestL ),
+        ENTRY( "Rig::RightsSetExecuteRightTestL",
+                CDrmRightsTest::RightsSetExecuteRightTestL ),
+        ENTRY( "Rig::RightsAssignmentTestL",
+                CDrmRightsTest::RightsAssignmentTestL ),
+        ENTRY( "Rig::RightsExternalizeInternalizeTestL",
+                CDrmRightsTest::RightsExternalizeInternalizeTestL ),
+        ENTRY( "Rig::RightsMergeTestL",
+                CDrmRightsTest::RightsMergeTestL ),                                                       
+        };
+
+    // Verify that case number is valid
+    if( (TUint) aCaseNumber >= sizeof( KCases ) / 
+                               sizeof( TCaseInfoInternal ) )
+        {
+        // Invalid case, construct empty object
+        TCaseInfo null( (const TText*) L"" );
+        null.iMethod = NULL;
+        null.iIsOOMTest = EFalse;
+        null.iFirstMemoryAllocation = 0;
+        null.iLastMemoryAllocation = 0;
+        return null;
+        } 
+
+    // Construct TCaseInfo object and return it
+    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
+    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
+    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
+    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
+    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
+    return tmp;
+
+    }
+
+// ----------------------------------------------------------------------------
+// ConstructDcfCommonFileNameTestL
+// Constructor test, constructs DcfCommon object from the file
+// of which the name is given as an argument.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::ConstructDcfCommonFileNameTestL( TTestResult& aResult ) 
+    {
+    
+    _LIT( KData, "CDrmRights::ConstructDcfCommonFileNameTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase1: Testing NewL of DcfCommon: Filename given" );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "as an argument, expecting functional DcfCommon" );
+    iLog->Log( KTestCase2 ); 
+    
+    CDcfCommon* dcf = CDcfCommon::NewL( KOma1Content );
+    TL( dcf );
+    delete dcf;
+    
+    // Passed
+    iLog->Log( KPassed );
+
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData );
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::ConstructDcfCommonFileNameTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// ConstructDcfCommonFileHandleTestL
+// Constructor test, constructs DcfCommon object from the file
+// to which a file handle is given as an argument.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::ConstructDcfCommonFileHandleTestL( TTestResult& aResult ) 
+    {
+    
+    _LIT( KData, "CDrmRights::ConstructDcfCommonFileHandleTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    RFile file;
+    RFs GFs;
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase2: Testing NewL of DcfCommon: File handle" );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "given as an argument, expecting functional DcfCommon" );
+    iLog->Log( KTestCase2 );
+    
+    User::LeaveIfError( file.Open( GFs, KOma1Content, 
+        EFileRead | EFileShareReadersOrWriters ) );
+    CleanupClosePushL( file );
+    
+    CDcfCommon* dcf = CDcfCommon::NewL( file );
+    TL( dcf );
+    delete dcf;
+    CleanupStack::PopAndDestroy(2, &GFs ); // file
+    
+    // Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::ConstructDcfCommonFileHandleTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// ConstructAssetTestL
+// Constructor tests, constructs CDrmAsset object.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::ConstructAssetTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::ConstructAssetTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase3: Testing NewL of CDrmAsset, expecting" );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "functional CDrmAsset" );
+    iLog->Log( KTestCase2 );
+    
+    CDRMAsset* asset = CDRMAsset::NewL();
+    TL( asset );
+    delete asset;
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase3, "TestCase4: Testing NewLC of CDrmAsset, expecting" ); 
+    iLog->Log( KTestCase3 );
+    
+    _LIT( KTestCase4, "functional CDrmAsset" );
+    iLog->Log( KTestCase4 );
+    
+    CDRMAsset* asset2 = CDRMAsset::NewLC();
+    TL( asset2 );
+    CleanupStack::PopAndDestroy( asset2 );
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::ConstructAssetTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    
+    }
+
+// ----------------------------------------------------------------------------
+// AssetDuplicateTestL
+// Duplication test, duplicates CDrmAsset object.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::AssetDuplicateTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::AssetDuplicateTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMAsset* duplicate( NULL );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase5: Testing duplicating of CDrmAsset,");
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting functional duplicate of CDrmAsset" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId1, KROTailIntervalExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+     
+    // Check the validity of the asset
+    TL( &( rights[0]->GetAsset() ) );
+    
+    duplicate = CDRMAsset::NewLC();
+    
+    // Make a duplicate from the asset part of the rights.
+    duplicate->DuplicateL( rights[0]->GetAsset() );
+    
+    TL( duplicate );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // item, duplicate
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::AssetDuplicateTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;
+    
+    }
+
+// ----------------------------------------------------------------------------
+// AssetExternalizeInternalizeTestL
+// Externalization/Internalization test, CDrmAsset object
+// is first externalized and then internalized.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::AssetExternalizeInternalizeTestL ( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::AssetExternalizeInternalizeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase6: Testing externalizing of CDrmAsset" );
+    iLog->Log( KTestCase1 );
+    
+    RPointerArray<CDRMRights> rights;
+    RFs GFs;
+    RStoreWriteStream outStream;
+    TStreamId rootId, assetId;
+    
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+ 
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId1, KROTailCounterExecute, rights ); 
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+     
+    // Check the validity of the asset
+    TL( &( rights[0]->GetAsset() ) );
+    
+    // Create a file store for externalization   
+    CDirectFileStore* store = CDirectFileStore::ReplaceLC( GFs, 
+        KStoreFile, EFileWrite );
+    
+    // Set the UID of the file
+    store->SetTypeL( KDirectFileStoreLayoutUid );
+    
+    // Declare and construct the output stream 
+    assetId = outStream.CreateLC( *store );
+    
+    ( rights[0]->GetAsset() ).ExternalizeL( outStream );
+    outStream.CommitL();
+    
+    // Set this stream Id to be the root Id
+    store->SetRootL( assetId );
+    
+    // Flush the client side buffer to the store
+    store->CommitL();
+    
+    CleanupStack::PopAndDestroy( 2, store ); // store, outStream
+    store = NULL;
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase2, "TestCase7: Testing internalizing of CDrmAsset" );
+    iLog->Log( KTestCase2 );
+    
+    RStoreReadStream inStream;
+ 
+    // Open the file store
+    store = CDirectFileStore::OpenLC( GFs, KStoreFile, 
+        EFileRead );
+    
+    // Open the root stream
+    inStream.OpenLC( *store, store->Root() );
+    
+    // Read the data
+    ( rights[0]->GetAsset() ).InternalizeL( inStream );
+    
+    CleanupStack::PopAndDestroy( 4, &rights ); // item, GFs, store, inStream
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::AssetExternalizeInternalizeTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed 
+    return KErrNone; 
+    }
+
+// ----------------------------------------------------------------------------
+// ConstructPermissionTestL
+// Constructor test, constructs CDrmPermission object
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::ConstructPermissionTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::ConstructPermissionTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    // Test Cases
+    // ----------------------------------------------------------------------
+    // ----------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase8: Testing NewL, expecting CDrmPermission" );
+    iLog->Log( KTestCase1 );
+    
+    CDRMPermission* permission = CDRMPermission::NewL();
+    TL( permission );
+    delete permission;
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase2, "TestCase9: Testing NewLC, expecting CDrmPermission" );
+    iLog->Log( KTestCase2 );
+    
+    CDRMPermission* permission2 = CDRMPermission::NewLC();
+    TL( permission2 );
+    CleanupStack::PopAndDestroy( permission2 );
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::ConstructPermissionTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;
+    
+    }
+
+// ----------------------------------------------------------------------------
+// PermissionSizeTestL
+// Size definition test, counts the size of CDrmPermission object.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::PermissionSizeTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::PermissionSizeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TInt size = 0;
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase10: Testing Size of CDrmPermission," ); 
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting size > 0" );
+    iLog->Log( KTestCase2 );
+           
+    RPointerArray<CDRMRights> rights;     
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId1, KROTailIntervalExecute, rights );
+    
+    // Get the permission
+    CDRMPermission& permission = rights[0]->GetPermission();
+    
+    TL( &permission );
+    
+    // Check size of the permission
+    size = permission.Size();
+    
+    TL( size > 0 );
+    
+    CleanupStack::PopAndDestroy( &rights );
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::PermissionSizeTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;
+   
+    }
+
+// ----------------------------------------------------------------------------
+// PermissionExternalizeInternalizeTestL
+// Externalization/Internalization test, CDrmPermission object
+// is first externalized and then internalized.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::PermissionExternalizeInternalizeTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::PermissionExternalizeInternalizeL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase11: Testing externalize of CDrmPermission" );
+    iLog->Log( KTestCase1 );
+    
+    RStoreWriteStream outStream;
+    TStreamId rootId, permissionId;
+    RFs GFs;
+    
+    RPointerArray<CDRMRights> rights;    
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    DeleteRODBL();
+    
+    AddROGetRightsL( KROHead2, KContentId2, KROTailStartEndExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+     
+    CDRMPermission& permission = rights[0]->GetPermission();
+    
+    TL( &permission );
+    
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+     
+    CDirectFileStore* store = CDirectFileStore::ReplaceLC( GFs, 
+        KStoreFile2, EFileWrite );
+    
+    store->SetTypeL( KDirectFileStoreLayoutUid );
+     
+    permissionId = outStream.CreateLC( *store );
+    permission.ExternalizeL( outStream );
+    outStream.CommitL();
+    
+    store->SetRootL( permissionId );
+    store->CommitL();
+    
+    CleanupStack::PopAndDestroy( 2 ); // store, outStream 
+    store = NULL;
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase2, "TestCase12: Testing internalize of CDrmPermission" );
+    iLog->Log( KTestCase2 );
+    
+    RStoreReadStream inStream;
+ 
+    // Open the file store
+    store = CDirectFileStore::OpenLC( GFs, KStoreFile2, 
+        EFileRead );
+    
+    // Open the root stream
+    inStream.OpenLC( *store, store->Root() );
+    
+    // Read the data
+    permission.InternalizeL( inStream );
+    
+    CleanupStack::PopAndDestroy( 4, &rights ); // rights, GFs, store, inStream
+     
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::PermissionExternalizeInternTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;
+    } 
+
+
+// ----------------------------------------------------------------------------
+// PermissionStatefulTestL
+// Test for checking whether Permission is stateful or not.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::PermissionStatefulTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::PermissionStatefulTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TBool ret( EFalse );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase13: Testing if RO stateful, expecting ETrue" );
+    iLog->Log( KTestCase1 );
+
+    RPointerArray<CDRMRights> rights;    
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    DeleteRODBL();
+    
+    AddROGetRightsL( KROHead2, KContentId2, KROTailCounterExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the permission
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    ret = permission.Stateful();
+    
+    TL( ret );
+    
+    CleanupStack::PopAndDestroy( &rights );
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::PermissionStatefulTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// PermissionChildTestL
+// Test for checking whether rights is of parent or child type. 
+// ----------------------------------------------------------------------------    
+TInt CDrmRightsTest::PermissionChildTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::PermissionChildTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TBool ret( EFalse );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase14: Testing if RO is child: expecting EFalse");
+    iLog->Log( KTestCase1 );
+
+    RPointerArray<CDRMRights> rights;    
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    //AddROGetRightsL( KROHead1, KContentId1, KROTailFull, rights );
+    AddROGetRightsL( KROParentHeadPlay, KContentId1, KROParentTailPlay, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the permission
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    ret = permission.Child();
+    
+    TL( !ret );
+    
+    CleanupStack::PopAndDestroy( &rights );
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::PermissionChildTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+
+// ----------------------------------------------------------------------------
+// PermissionConstraintForIntentTestL
+// Test for fetching constraint matching the given intent. 
+// ----------------------------------------------------------------------------  
+TInt CDrmRightsTest::PermissionConstraintForIntentTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::ConstraintForIntentTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMConstraint* constraint( NULL );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase15: Testing constraint for Play intent," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting functional CDrmConstraint" );
+    iLog->Log( KTestCase2 );
+   
+    RPointerArray<CDRMRights> rights;        
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailPlay, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the permission
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    constraint = permission.ConstraintForIntent( ContentAccess::EPlay );
+    TL( constraint );
+    
+    CleanupStack::PopAndDestroy( &rights );
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::PermissionConstrForIntentTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// PermissionTopLevelConstraintTestL
+// Test for checking top level constraint of the permission. 
+// ----------------------------------------------------------------------------  
+TInt CDrmRightsTest::PermissionTopLevelConstraintTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::TopLevelConstraintTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMConstraint* top( NULL );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase16: Testing fetching top level constraint," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting NULL pointer" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;       
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROParentHeadPlay, KContentIdParent, KROParentTailPlay, 
+        rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the permission
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    // Check whether top level constraint exists or not
+    top = permission.TopLevelConstraint();
+    
+    // Check top level constraint
+    TL( !top );
+    
+    CleanupStack::PopAndDestroy( &rights );
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::PermissionTopLevelConstraintTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;
+    }
+    
+// ----------------------------------------------------------------------------
+// PermissionConsumeRightsTestL
+// Test for consuming rights of the permission. 
+// ----------------------------------------------------------------------------    
+TInt CDrmRightsTest::PermissionConsumeRightsTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::ConsumeRightsTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TTime currentTime ( Time::NullTTime() );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase17: Testing consuming rights" );
+    iLog->Log( KTestCase1 );
+    
+    RPointerArray<CDRMRights> rights;     
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailIntervalExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the permission
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    currentTime.UniversalTime();
+    permission.ConsumeRights( ContentAccess::EExecute, currentTime );
+    
+    CleanupStack::PopAndDestroy( &rights );
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::ConsumeRightsTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;    
+    }
+// ----------------------------------------------------------------------------
+// PermissionExportImportTestL
+// Test for exporting and importing permission. 
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::PermissionExportImportTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::ExportTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    HBufC8* buf( NULL );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase18: Testing exporting CDrmPermission," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting HBufC8" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;     
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead1, KContentId1, KROTailFull, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the permission
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    // Export permission
+    buf = permission.ExportL();
+    
+    // Check exported buffer
+    TL( buf );
+    
+    CleanupStack::PopAndDestroy( &rights );
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase3, "TestCase19: Testing importing HBufC8" );
+    iLog->Log( KTestCase3 );
+    
+    _LIT( KTestCase4, "for CDrmPermission" );
+    iLog->Log( KTestCase4 );
+    
+    CDRMPermission* permission2 = CDRMPermission::NewLC();
+    
+    CleanupStack::PushL( buf );    
+    permission2->ImportL( *buf );
+    CleanupStack::PopAndDestroy( 2, permission2 ); // permission2, buf
+  
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::PermissionExportImportTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// PermissionDuplicateTestL
+// Test for duplicating permission. 
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::PermissionDuplicateTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::PermissionDuplicateTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase20: Testing duplicating CDrmPermission," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting valid duplicate of CDrmPermission" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;     
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    CDRMPermission* duplicate = CDRMPermission::NewLC();
+    TL( duplicate );
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailCounterExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the permission
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    // Duplicate permission
+    duplicate->DuplicateL( permission );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, duplicate
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::PermissionDuplicateTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// PermissionExpiredTestL
+// Test for checking if permission is expired. 
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::PermissionExpiredTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::PermissionExpiredTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TTime currentTime( Time::NullTTime() );
+    TBool ret( EFalse );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase21: Testing if CDrmPermission is expired," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting ETrue" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;     
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailStartEndExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the permission
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    currentTime.UniversalTime();
+    
+    ret = permission.Expired( currentTime );
+    TL( ret );
+    
+    CleanupStack::PopAndDestroy( &rights ); // rights
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::PermissionExpiredTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// PermissionValidTestL
+// Test for checking if permission is valid. 
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::PermissionValidTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::PermissionValidTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TTime currentTime;
+    TUint32 reason;
+    TBool ret( EFalse );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase22: Testing if CDrmPermission is valid," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "Expecting: ETrue" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    RPointerArray<HBufC8> imsi;
+    
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead1, KContentId1, KROTailFull, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the permission
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    currentTime.UniversalTime();
+    
+    // Check if permission is valid
+    ret = permission.Valid( currentTime, imsi, reason );
+    TL( ret )
+    
+    CleanupStack::PopAndDestroy( &rights ); // rights
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::PermissionValidTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// PermissionMergeTestL
+// Test for merging two permissions. 
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::PermissionMergeTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::PermissionMergeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase23: Test to merge two CDrmPermissions," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting functional merged CDrmPermission." );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add the first RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailCounterExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the first permission
+    CDRMPermission* permission1 = CDRMPermission::NewLC();
+    permission1->DuplicateL( rights[0]->GetPermission() );
+    TL( &permission1 );
+    
+    rights.ResetAndDestroy();
+    
+    // Add the second RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailPlay, rights );
+    
+    // Get the second permission
+    CDRMPermission* permission2 = CDRMPermission::NewLC();
+    permission2->DuplicateL( rights[0]->GetPermission() );
+    TL( &permission2 );
+    
+    permission1->Merge( *permission2 );
+    
+    CleanupStack::PopAndDestroy( 3, &rights ); // rights, perm1, permission2
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::PermissionMergeTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+
+// ----------------------------------------------------------------------------
+// PermissionSoftwareConstrainedTestL
+// Test for checking if permission has software constraint or not. 
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::PermissionSoftwareConstrainedTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::SoftwareConstrainedTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TBool ret( ETrue );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase24: Testing if CDrmPermission has software" );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "constraint, expecting EFalse" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add the first RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailStartEndExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+     
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    ret = permission.SoftwareConstrained();
+    T1L( ret, EFalse );
+    
+    CleanupStack::PopAndDestroy( &rights ); // rights
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::SoftwareConstrainedTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// ConstructConstraintTestL
+// Constructor test, constructs CDrmConstraint.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::ConstructConstraintTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::ConstructConstraintTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+       
+    CDRMConstraint* constraint( NULL );
+       
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase25: Testing NewLC of CDrmConstraint,");
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting functional CDrmConstraint object" );
+    iLog->Log( KTestCase2 );
+    
+    constraint = CDRMConstraint::NewLC();
+    TL( constraint )
+    CleanupStack::PopAndDestroy();
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescription, "CDrmRightsTest::ConstructConstraintTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    // Case was executed
+    return KErrNone;    
+    }
+    
+// ----------------------------------------------------------------------------
+// ConstructRightsConstraintsTestL
+// Constructor test, constructs CDrmRightsConstraints object. 
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::ConstructRightsConstraintsTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::ConstructRightsConstraintsTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+       
+    CDRMRightsConstraints* constraint( NULL );
+       
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase26: Testing NewL of CDrmRightsConstraints:" ); 
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting functional CDrmRightsConstraints");
+    iLog->Log( KTestCase2 );
+    
+    constraint = CDRMRightsConstraints::NewL();
+    TL( constraint )
+    delete constraint;
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstraintsConstructTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsFullRightsTestL
+// Test for checking if object has full rights or not.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsFullRightsTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsFullRightsTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase27: Testing if object has full rights," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting ETrue" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead1, KContentId1, KROTailFull, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get display rights
+    error = rights[0]->GetDisplayRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and display rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk );
+    
+    // Check whether we have full rights or not.
+    T1L( ETrue, constraint->FullRights() );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstraintsFullRightsTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsIsPreviewTestL
+// Test for checking if object has preview rights constraint.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsIsPreviewTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsIsPreviewTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase28: Testing if object has preview rights," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting ETrue" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailPreviewCounterExecute, 
+        rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get exeecute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and play rights.
+    TL( constraint );
+    T1L( error, KErrNone );
+    
+    // Check whether we have preview rights or not
+    T1L( ETrue, constraint->IsPreview() );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstraintsFullRightsTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsGetConstraintInfoTestL
+// Test for checking the expiration and constraint details of the object.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsGetConstraintInfoTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsGetConstraintInfoTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TUint32 expiration;
+    TUint32 constType;
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    TInt temp( CDRMRights::EInvalidRights);
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase29: Test to get object constraint info," ); 
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTest2, "expecting: !EInvalidRights, EValidRights, ECountBased" );
+    iLog->Log( KTest2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();  
+  
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailCounterExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk );
+    
+    // Check the expiration and constraint details of the object
+    TL( temp != constraint->GetConstraintInfo( 
+          expiration, constType ) );
+    T1L( CDRMRights::EValidRights, expiration)
+    T1L( CDRMRights::ECountBased, constType );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstrGetConstrInfoTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsGetExpirationDetailsTestL
+// Test for checking the end time and amount of counts left of of the object.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsGetExpirationDetailsTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstrGetExpirationDetailsTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TTime endTime;
+    TTime tempTime;
+    TInt countsLeft;
+    
+    TInt error( KErrNone );
+    CDRMRightsConstraints* constraint( NULL );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase30: Test to get end time and amount" );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "of counts left, expecting: 0, 99, DRMCommon:EOk" );
+    iLog->Log( KTestCase2 ); 
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailCounterExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk );
+    
+    // Default value
+    endTime.Set( KNullDate );
+    
+    // Get expiration details
+    error = constraint->GetExpirationDetails( endTime, countsLeft );
+    
+    // Initialize for comparison of the end time 
+    tempTime.Set( KNullDate );
+    
+    // Check return value, end time and counts left
+    T1L( error, DRMCommon::EOk );
+    TL( endTime == tempTime );
+    T1L( countsLeft, KCountsLeft );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstrGetExpirDetailsTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+    
+// ----------------------------------------------------------------------------
+// RightsConstraintsGetCountersL
+// Test for checking the current and original value of the count
+// restriction.
+// ---------------------------------------------------------------------------- 
+TInt CDrmRightsTest::RightsConstraintsGetCountersTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsGetCountersL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TUint32 counter;
+    TUint32 originalCounter;
+    TTime currentTime;
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+     
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase31: Test to get counter details of" ); 
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "object, expecting: 98, 99, DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+      
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailCounterExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    currentTime.UniversalTime();
+    
+    // Consume one rights first
+    permission.ConsumeRights( ContentAccess::EExecute, currentTime );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Get counters
+    error = constraint->GetCounters( counter, originalCounter );
+    
+    // Check return value, count (should be original count minus one) 
+    // and original count
+    T1L( error, DRMCommon::EOk );
+    T1L( counter, KCountsLeft - 1 );
+    T1L( originalCounter, KCountsLeft );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstraintsGetCountersTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsGetTimedCountersTestL
+// Test for checking the current and original value of the timed
+// count restriction.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsGetTimedCountersTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsGetTimedCountersTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TUint32 timedCounter;
+    TUint32 originalCounter;
+    TTime currentTime;
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase32: Test to get timed counter details of" ); 
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "object, expecting 100, 0, DRMCommon:EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailTimedPlay, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get play rights
+    error = rights[0]->GetPlayRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Get timed count and original count
+    error = constraint->GetTimedCounters( timedCounter, originalCounter );
+    
+    // Check return value, timed count and original count 
+    T1L( error, DRMCommon::EOk );
+    T1L( timedCounter, KTimedCount  );
+    T1L( originalCounter, 0 );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstrGetTimedCountersTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsGetStartTimeTestL
+// Test for checking the start time constraint.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsGetStartTimeTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsGetStartTimeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TTime currentTime( Time::NullTTime() );
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase33: Test to get start time constraint of" ); 
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "object, expecting: start time, DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailStartEndExecute, rights );
+
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Get start time
+    error = constraint->GetStartTime( currentTime );
+    
+    // Check start time
+    T1L( error, DRMCommon::EOk );
+    TL( currentTime != Time::NullTTime() );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstrGetStartTimeTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsGetEndTimeTestL
+// Test for checking the end time constraint.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsGetEndTimeTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsGetEndTimeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    TTime currentTime( Time::NullTTime() );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase34: Test to get end time constraint of" ); 
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "object, expecting: end time, DRMCommon::EOk" ); 
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailStartEndExecute, rights );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Get end time
+    error = constraint->GetEndTime( currentTime );
+    
+    T1L( DRMCommon::EOk, error );
+    TL( currentTime != Time::NullTTime() );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstraintsGetEndTimeTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsGetIntervalTestL
+// Test for checking the interval time constraint.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsGetIntervalTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsGetIntervalTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    TTimeIntervalSeconds interval( 0 );
+    TTimeIntervalSeconds temp( 0 ); 
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase35: Test to get interval constraint of" );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "object, expecting interval, DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailIntervalExecute, rights );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Get interval 
+    error = constraint->GetInterval( interval );
+    
+    // Check return value and interval
+    T1L( DRMCommon::EOk, error );
+    TL( interval > temp );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstraintsGetIntervalTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsGetIntervalStartTestL
+// Test for checking the interval start time constraint.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsGetIntervalStartTestL
+    ( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsGetIntervalStartTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TTime currentTime( Time::NullTTime() );
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    TTime intervalStart( Time::NullTTime() ); 
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase36: Test to get interval start time" ); 
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "constraint, expecting DRMCommon::EOk, interval" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+   
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, 
+        KROTailStartEndIntervalPlay, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    CDRMPermission& permission = rights[0]->GetPermission();
+    TL( &permission );
+    
+    currentTime.UniversalTime();
+    
+    // Consume one rights to start the interval
+    permission.ConsumeRights( ContentAccess::EPlay, currentTime );
+    
+    // Get play rights
+    error = rights[0]->GetPlayRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Get interval 
+    error = constraint->GetIntervalStart( intervalStart );
+    
+    T1L( DRMCommon::EOk, error );
+    TL( intervalStart != Time::NullTTime() );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstrGetIntervalStartL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsGetAccumulatedTestL
+// Test for checking the accumulated time constraint.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsGetAccumulatedTestL(
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsGetAccumulatedTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    TTimeIntervalSeconds accumulated( 0 );
+    TTimeIntervalSeconds temp( 0 ); 
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase37: Test to get accumulated constraint" );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "of object, expecting DRMCommon::EOk, accumul. time" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailAccumulatedPlay, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get play rights
+    error = rights[0]->GetPlayRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and play rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Get accumulated time 
+    error = constraint->GetAccumulated( accumulated );
+    
+    // Check return value and accumulated time constraint
+    T1L( DRMCommon::EOk, error );
+    TL( accumulated > temp );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstrGetAccumulatedTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+    
+// ----------------------------------------------------------------------------
+// RightsConstraintsSetCountersTestL
+// Test for setting the counters of the constraint.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsSetCountersTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsSetCountersTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TUint32 counter;
+    TUint32 originalCounter;
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase38: Test to set counter constraints of" );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "object, expecting: DRMCommon:EOk" );
+    iLog->Log( KTestCase2 );
+      
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailCounterExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Set count and original count to new values
+    error = constraint->SetCounters( KNewCount, KNewOriginalCount );
+    T1L( error, DRMCommon::EOk );
+    
+    // Get count and original count to check that setting 
+    // count and original count was successful.
+    error = constraint->GetCounters( counter, originalCounter );
+    T1L( error, DRMCommon::EOk );
+    
+    T1L( counter, KNewCount );
+    T1L( originalCounter, KNewOriginalCount );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstraintsSetCountersTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }        
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsSetStartTimeTestL
+// Test for setting the start time constraint.
+// ----------------------------------------------------------------------------    
+TInt CDrmRightsTest::RightsConstraintsSetStartTimeTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsSetStartTimeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    TTime startTime( Time::NullTTime() );
+    TTime newStartTime( Time::NullTTime() ); 
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase39: Test to set start time of" ); 
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "object, expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailStartEndExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    startTime.UniversalTime();
+    
+    // Set start time
+    error = constraint->SetStartTime( startTime );
+    T1L( error, DRMCommon::EOk );
+    
+    // Check that start time change has been made succesfully
+    error = constraint->GetStartTime( newStartTime );
+    T1L( error, DRMCommon::EOk );
+    
+    TL( startTime == newStartTime );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstrSetStartTimeTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }            
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsSetEndTimeTestL
+// Test for setting the end time constraint.
+// ---------------------------------------------------------------------------- 
+TInt CDrmRightsTest::RightsConstraintsSetEndTimeTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsSetEndTimeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    TTime endTime( Time::NullTTime() );
+    TTime newEndTime( Time::NullTTime() ); 
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    _LIT( KTestCase1, "TestCase40: Test to set end time constraint of" ); 
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "object, expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailStartEndExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    endTime.UniversalTime();
+    
+    // Set end time
+    error = constraint->SetEndTime( endTime );    
+    T1L( error, DRMCommon::EOk );
+    
+    // Check that end time change has been made succesfully
+    error = constraint->GetEndTime( newEndTime );
+    T1L( error, DRMCommon::EOk );
+    
+    TL( endTime == newEndTime );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstraintsSetEndTimeTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }            
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsSetIntervalTestL
+// Test for setting the interval time constraint.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsSetIntervalTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsSetIntervalTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    TTimeIntervalSeconds interval( KNewIntervalSeconds );
+    TTimeIntervalSeconds newInterval( 0 ); 
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase41: Test to set interval constraint of "); 
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "object, expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailIntervalExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Set interval
+    error = constraint->SetInterval( interval );
+    T1L( error, DRMCommon::EOk );
+    
+    // Get interval to check that interval change has been made correctly.
+    error = constraint->GetInterval( newInterval );
+    T1L( error, DRMCommon::EOk );
+    
+    TL( interval == newInterval );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstraintsSetIntervalTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }            
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsSetIntervalStartTestL
+// Test for setting the interval start time constraint.
+// ----------------------------------------------------------------------------    
+TInt CDrmRightsTest::RightsConstraintsSetIntervalStartTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsSetIntervalStartTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    TTime startTime( Time::NullTTime() );
+    TTime newStartTime( Time::NullTTime() ); 
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase42: Test to set interval start time" );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "constraint of object, expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, 
+        KROTailStartEndIntervalPlay, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+     
+    // Get play rights
+    error = rights[0]->GetPlayRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and play rights
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    startTime.UniversalTime();
+    
+    // Set interval
+    error = constraint->SetIntervalStart( startTime );
+    T1L( error, DRMCommon::EOk );
+    
+    // Check that interval start time change has been made succesfully
+    error = constraint->GetIntervalStart( newStartTime );
+    T1L( error, DRMCommon::EOk );
+    
+    TL( startTime == newStartTime );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstrSetIntervalStartTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsGetConstraintTestL
+// Test for getting constraint.
+// ----------------------------------------------------------------------------    
+TInt CDrmRightsTest::RightsConstraintsGetConstraintTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsGetConstraintTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+     
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase43: Test to get constraint of object," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting valid reference to CDrmRightsConstraints" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailDisplayPrint, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get display rights
+    error = rights[0]->GetDisplayRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and display rights
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Get constraint
+    CDRMConstraint& constraintRef = constraint->GetConstraint();
+    
+    // Check reference
+    TL( &constraintRef );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstrGetConstraintTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }                
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsSetConstraintTestL
+// Test for setting constraint.
+// ----------------------------------------------------------------------------    
+TInt CDrmRightsTest::RightsConstraintsSetConstraintTestL( 
+    TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsSetConstraintTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase44: Test to set constraint of rights object" );
+    iLog->Log( KTestCase1 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailCounterExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Get constraint
+    CDRMConstraint& constraintRef = constraint->GetConstraint();
+    
+    TL( &constraintRef );
+    
+    // Create new CDrmRightsConstraints for setting the constraint.
+    CDRMRightsConstraints* constraint2 = CDRMRightsConstraints::NewL();
+    
+    TL( constraint2 )
+    CleanupStack::PushL( constraint2 );
+    
+    // Set the constraint according to the referenced constraint
+    constraint2->SetConstraint( constraintRef );
+    
+    CleanupStack::PopAndDestroy( 3, &rights ); // rights, constraint, constr2
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstrSetConstraintTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }                
+
+
+// ----------------------------------------------------------------------------
+// RightsConstraintsAssignmentTestL
+// Test for assigning constraint to another constraint.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsConstraintsAssignmentTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsConstraintsAssignmentTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase45: Test for assignment operator of" );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "CDrmRightsConstraints, expecting functional copy" );
+    iLog->Log( KTestCase2 );
+    
+    _LIT( KTestCase3, "of CDrmRightsConstraints" );
+    iLog->Log( KTestCase3 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailIntervalExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and execute rights
+    TL( constraint );
+    T1L( error, DRMCommon::EOk);
+    
+    // Create new CDrmRightsConstraints for assign operation.
+    CDRMRightsConstraints* constraint2 = CDRMRightsConstraints::NewL();
+    
+    TL( constraint2 )
+    CleanupStack::PushL( constraint2 );
+    
+    constraint2 = constraint;
+    TL( constraint2 )
+    
+    CleanupStack::PopAndDestroy( 3, &rights ); // rights, constraint, constr2
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsConstraintsAssignmentTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }                
+
+// ----------------------------------------------------------------------------
+// RightsGetLocalIdTestL
+// Test for getting local id of the object.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsGetLocalIdTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsGetLocalIdTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TUint32 localId( 0 );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase46: Test for getting local id of object," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting non-zero local id" );
+    iLog->Log( KTestCase2 );
+     
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailDisplayPrint, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get local id
+    localId = rights[0]->GetLocalID();
+    
+    // Check local id value
+    TL( localId );
+    
+    CleanupStack::PopAndDestroy( &rights ); // rights
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsGetLocalIdTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }                
+
+// ----------------------------------------------------------------------------
+// RightsGetAddTimeTestL
+// Test for getting time when rights object was added to the database.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsGetAddTimeTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsGetAddTimeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TTime time( Time::NullTTime() );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase47: Test to get time when rights object" );
+    iLog->Log( KTestCase1 );
+     
+    _LIT( KTestCase2, "was added to the database, expecting NULL time" );
+    iLog->Log( KTestCase2 ); 
+     
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead1, KContentId1, KROTailFull, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the time when rights object was added to the database
+    rights[0]->GetAddTime( time );
+    
+    // Check time
+    TL( time == Time::NullTTime() );
+    
+    CleanupStack::PopAndDestroy( &rights ); // rights
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsGetAddTimeTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }                
+
+// ----------------------------------------------------------------------------
+// RightsGetRightsInfoTestL
+// Test for getting restriction details associated with given permission.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsGetRightsInfoTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsGetAddTimeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRights::TRestriction restriction;
+    CDRMRights::TExpiration expiration;
+    TUint32 constraints;
+    TInt ret( CDRMRights::ENoRights );
+    
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase48: Test to get restriction details of" );
+    iLog->Log( KTestCase1 );
+     
+    _LIT( KTestCase2, "the rights object, expecting ERestrictedRights," );
+    iLog->Log( KTestCase2 );
+    
+    _LIT( KTestCase3, "EInActiveInterval, !ENoRights" );
+    iLog->Log( KTestCase3 ); 
+     
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailIntervalExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the time when rights object was added to the database
+    ret = rights[0]->GetRightsInfo( EExecute, restriction, expiration,
+        constraints );
+    
+    // Check rights status
+    T1L( restriction, CDRMRights::ERestrictedRights );
+    
+    // Check expiration status
+    T1L( expiration, CDRMRights::EValidRights );
+    
+    // Check constraint details
+    T1L( constraints, CDRMRights::EInActiveInterval );
+    
+    // Check priority value of the rights object
+    TL( ret != CDRMRights::ENoRights );
+    
+    CleanupStack::PopAndDestroy( &rights ); // rights
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsGetRightsInfoTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }           
+
+//  End of File
+
+// ----------------------------------------------------------------------------
+// RightsGetRightsDetailsTestL
+// Test for getting restriction details associated with given permission.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsGetExpirationDetailsTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsGetRightsDetailsTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    TTime endTime( Time::NullTTime() );
+    TInt error( CDRMRights::ENoRights );
+    TInt counts( 0 );
+   
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase48: Test to get the end time and amount" );
+    iLog->Log( KTestCase1 );
+     
+    _LIT( KTestCase2, "of counts of the rights object, expecting valid" );
+    iLog->Log( KTestCase2 );
+    
+    _LIT( KTestCase3, "end time, -1, EOk" );
+    iLog->Log( KTestCase3 ); 
+     
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailStartEndExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get the end time and amount of counts of the rights object
+    error = rights[0]->GetExpirationDetails( EExecute, endTime, counts );
+    
+    // Check end time
+    TL( endTime != Time::NullTTime() );
+    
+    // Check amount of counts (should be no rights, i.e. -1)
+    T1L( counts, -1 );
+    
+    // Check return value
+    T1L( error, CDRMRights::EOk );
+    
+    CleanupStack::PopAndDestroy( &rights ); // rights
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsGetRightsInfoTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }           
+
+// ----------------------------------------------------------------------------
+// RightsGetPrintRightTestL
+// Test for getting the constraints associated with the print rights.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsGetPrintRightTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsGetPrintRightTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase49: Test to get the constraint associated" );
+    iLog->Log( KTestCase1 );
+     
+    _LIT( KTestCase2, "with the print right, expecting valid constraint" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailDisplayPrint, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get print rights
+    error = rights[0]->GetPrintRight( constraint );
+    
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and display rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsGetPrintRightTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }           
+
+// ----------------------------------------------------------------------------
+// RightsSetContentURIandLocalIDTestL
+// Test for setting the content Uri and Local Id of the object.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsSetContentURIAndLocalIDTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsSetContentURIandLocalIDTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRights* rights( NULL );
+    HBufC8* uri( NULL );
+    TUint id( 0 );
+    TPtr8 contentUri(NULL, 0, 0);
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase50: Test to set the content Uri and the" );
+    iLog->Log( KTestCase1 );
+     
+    _LIT( KTestCase2, "local Id of the object, expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    // Create rights object
+    rights = CDRMRights::NewL();
+    CleanupStack::PushL( rights );
+	
+	// Compose Content URI 
+	uri = HBufC8::NewL( KUriSize );
+	contentUri.Set( uri->Des() );
+	contentUri.Format( KUri );
+	
+	// Set Content URI and local ID
+	error = rights->SetContentURIAndLocalID( uri, id );    
+    
+    T1L( error, DRMCommon::EOk );
+    
+    CleanupStack::PopAndDestroy( rights ); // rights
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDesc, "CDrmRightsTest::RightsSetContentURIandLocalIDTestL passed" );
+    iLog->Log( KDesc );
+    aResult.SetResult( KErrNone, KDesc );
+
+    // Case was executed
+    return KErrNone;    
+    }           
+
+//  End of File
+
+// ----------------------------------------------------------------------------
+// RightsSetContentURITestL
+// Test for setting the content Uri.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsSetContentURITestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsSetContentURITestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRights* rights( NULL );
+    HBufC8* uri( NULL );
+    TPtr8 contentUri(NULL, 0, 0);
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase51: Test to set the content Uri of the" );
+    iLog->Log( KTestCase1 );
+     
+    _LIT( KTestCase2, "object, expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    // Create rights object
+    rights = CDRMRights::NewL();
+    CleanupStack::PushL( rights );
+	
+	// Compose Content URI 
+	uri = HBufC8::NewL( KUriSize );
+	contentUri.Set( uri->Des() );
+	contentUri.Format( KUri );
+	
+	// Set Content URI and local ID
+	error = rights->SetContentURI( uri );    
+    
+    T1L( error, DRMCommon::EOk );
+    
+    CleanupStack::PopAndDestroy( rights ); // rights
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsSetContentURITestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }           
+
+// ----------------------------------------------------------------------------
+// RightsSetAddTimeTestL
+// Test for setting the time when rights object was added to the database
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsSetAddTimeTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsSetAddTimeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRights* rights( NULL );
+    TTime time( Time::NullTTime() );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase52: Test to set the add time, expecting" );
+    iLog->Log( KTestCase1 );
+     
+    _LIT( KTestCase2, "DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    // Create rights object
+    rights = CDRMRights::NewL();
+    CleanupStack::PushL( rights );
+	
+	time.UniversalTime();
+	
+	// Set current time
+	rights->SetAddTime( time );    
+    
+    CleanupStack::PopAndDestroy( rights ); // rights
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsSetAddTimeTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }           
+
+// ----------------------------------------------------------------------------
+// RightsSetPlayRightL
+// Test for setting the play constraints.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsSetPlayRightTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsSetPlayRightTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase53: Test to set the play constraint" );
+    iLog->Log( KTestCase1 );
+     
+    _LIT( KTestCase2, "of the object, expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailPlay, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get play rights
+    error = rights[0]->GetPlayRight( constraint );
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and play rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk );
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailTimedPlay, rights );
+    T1L( rights.Count(), 1 );
+    
+    // Try to set play rights
+    error = rights[0]->SetPlayRight( constraint ); 
+	
+	T1L( error, DRMCommon::EOk );
+	
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsSetPlayRightTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }
+    
+// ----------------------------------------------------------------------------
+// RightsSetDisplayRightL
+// Test for setting the display constraints.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsSetDisplayRightTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsSetDisplayRightTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase54: Test to set the display constraint" );
+    iLog->Log( KTestCase1 );
+     
+    _LIT( KTestCase2, "of the object, expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailDisplayPrint, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get play rights
+    error = rights[0]->GetDisplayRight( constraint );
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and display rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk );
+    
+    // Try to set display rights
+    error = rights[0]->SetDisplayRight( constraint ); 	
+	T1L( error, DRMCommon::EOk );
+	
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsSetDisplayRightTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }           
+
+// ----------------------------------------------------------------------------
+// RightsSetPrintRightTestL
+// Test for setting the print constraints.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsSetPrintRightTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsSetPrintRightTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase55: Test to set the print constraint" );
+    iLog->Log( KTestCase1 );
+     
+    _LIT( KTestCase2, "of the object, expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailDisplayPrint, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get play rights
+    error = rights[0]->GetPrintRight( constraint );
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and display rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk );
+    
+    // Try to set print rights 
+    error = rights[0]->SetPrintRight( constraint ); 	
+	T1L( error, DRMCommon::EOk );
+	
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsSetPrintRightTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }           
+
+// ----------------------------------------------------------------------------
+// RightsSetExecuteRightTestL
+// Test for setting the execute constraints.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsSetExecuteRightTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsSetExecuteRightTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRightsConstraints* constraint( NULL );
+    TInt error( KErrNone );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase56: Test to set the execute constraint" );
+    iLog->Log( KTestCase1 );
+     
+    _LIT( KTestCase2, "of the object, expecting DRMCommon::EOk" );
+    iLog->Log( KTestCase2 );
+    
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailCounterExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Get execute rights
+    error = rights[0]->GetExecuteRight( constraint );
+    CleanupStack::PushL( constraint );
+    
+    // Check constraint and display rights.
+    TL( constraint );
+    T1L( error, DRMCommon::EOk );
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailIntervalExecute, rights );
+    T1L( rights.Count(), 1 );
+    
+    // Set execute rights
+    error = rights[0]->SetExecuteRight( constraint );
+
+    T1L( error, DRMCommon::EOk );   
+  
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, constraint
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsSetExecuteRightTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }      
+
+// ----------------------------------------------------------------------------
+// RightsAssignmentTestL
+// Test for assignment operator
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsAssignmentTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsAssignmentTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    CDRMRights* testRights( NULL );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase57: Test of assignment operator for " );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "CDrmRights." );
+    iLog->Log( KTestCase2 );
+     
+    RPointerArray<CDRMRights> rights;  
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+    
+    testRights = CDRMRights::NewL();
+    CleanupStack::PushL( testRights );
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailCounterExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    *testRights = *rights[0];
+    
+    // Check the assignment operation
+    TL( testRights );
+    
+    CleanupStack::PopAndDestroy( 2, &rights ); // rights, testRights
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsAssignmentTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }      
+
+// ----------------------------------------------------------------------------
+// RightsExternalizeInternalizeTestL
+// Test for externalizing and internalizing rights.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsExternalizeInternalizeTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsExternalizeInternalizeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase58: Test to externalize CDrmRights" );
+    iLog->Log( KTestCase1 );
+     
+    RPointerArray<CDRMRights> rights;
+    RFs GFs;
+    RStoreWriteStream outStream;
+    TStreamId rootId, assetId;
+    
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item( rights );
+    item.PushL();
+ 
+    User::LeaveIfError( GFs.Connect() );
+    CleanupClosePushL( GFs );
+    
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId1, KROTailCounterExecute, rights ); 
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+     
+    // Check the validity of the rights
+    TL( rights[0] );
+    
+    // Create a file store for externalization   
+    CDirectFileStore* store = CDirectFileStore::ReplaceLC( GFs, 
+        KStoreFile3, EFileWrite );
+    
+    // Set the UID of the file
+    store->SetTypeL( KDirectFileStoreLayoutUid );
+    
+    // Declare and construct the output stream 
+    assetId = outStream.CreateLC( *store );
+    
+    rights[0]->ExternalizeL( outStream );
+    outStream.CommitL();
+    
+    // Set this stream Id to be the root Id
+    store->SetRootL( assetId );
+    
+    // Flush the client side buffer to the store
+    store->CommitL();
+    
+    CleanupStack::PopAndDestroy( 2, store ); // store, outStream
+    store = NULL;
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase2, "TestCase59: Test to internalize CDrmRights" );
+    iLog->Log( KTestCase2 );
+    
+    RStoreReadStream inStream;
+ 
+    // Open the file store
+    store = CDirectFileStore::OpenLC( GFs, KStoreFile3, 
+        EFileRead );
+    
+    // Open the root stream
+    inStream.OpenLC( *store, store->Root() );
+    
+    // Read the data
+    rights[0]->InternalizeL( inStream );
+    
+    CleanupStack::PopAndDestroy( 4, &rights ); // item, GFs, store, inStream
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsExternalizeInternalizeL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }      
+
+// ----------------------------------------------------------------------------
+// RightsMergeTestL
+// Test for merging two rights objects.
+// ----------------------------------------------------------------------------
+TInt CDrmRightsTest::RightsMergeTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmRightsTest::RightsMergeTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    // Test Cases
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    
+    _LIT( KTestCase1, "TestCase60: Test to merge two CDrmRights objects," );
+    iLog->Log( KTestCase1 );
+    
+    _LIT( KTestCase2, "expecting functional merged CDrmRights" );
+    iLog->Log( KTestCase2 );
+     
+    RPointerArray<CDRMRights> rights;  
+    RPointerArray<CDRMRights> rights2;
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item1( rights );
+    TDoResetAndDestroy< RPointerArray<CDRMRights> > item2( rights2 );
+    item1.PushL();
+    item2.PushL();
+        
+    // Delete RO database
+    DeleteRODBL();
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailCounterExecute, rights );
+    
+    // Check that rights are stored
+    T1L( rights.Count(), 1 );
+    
+    // Add RO and get the rights from the added RO
+    AddROGetRightsL( KROHead2, KContentId2, KROTailStartEndIntervalPlay, 
+        rights2 );
+    
+    T1L( rights2.Count(), 1 );
+    
+    // Merge the two rights objects
+    rights[0]->Merge( *rights2[0] );
+    
+    TL( rights[0] );
+    
+    CleanupStack::PopAndDestroy( 2, &rights );
+    
+    // Passed
+    iLog->Log( KPassed );
+    
+    // ------------------------------------------------------------------------
+    // ------------------------------------------------------------------------
+    // Test Cases End
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    // Test case passed
+    _LIT( KDescr, "CDrmRightsTest::RightsMergeTestL passed" );
+    iLog->Log( KDescr );
+    aResult.SetResult( KErrNone, KDescr );
+
+    // Case was executed
+    return KErrNone;    
+    }      
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_secondary_display_api/drm_secondary_display_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="aa9d8146b7acb41ed0a5b9c9dc278444" dataversion="1.0">
+  <name>DRM Secondary Display API</name>
+  <description>Definitions for Cover UI.</description>
+  <type>c++</type>
+  <subsystem>omadrm</subsystem>
+  <libs>
+  </libs>
+  <release category="domain"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_secondary_display_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* 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:  File that exports the files belonging to 
+:                DRM Secondary Display API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/SecondaryDisplay/DRMHelperSecondaryDisplay.h     MW_LAYER_PLATFORM_EXPORT_PATH(SecondaryDisplay/DRMHelperSecondaryDisplay.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_secondary_display_api/inc/SecondaryDisplay/DRMHelperSecondaryDisplay.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,177 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  The set of messages provided to Secondary Display software by
+*              : DRMHelper.
+*
+*/
+
+#ifndef DRMHELPER_SECONDARY_DISPLAY_H
+#define DRMHELPER_SECONDARY_DISPLAY_H
+
+// INCLUDES
+#include <e32base.h>
+
+// The category UID for the messages in this header file.
+//
+const TUid KUidCoverUiCategoryDRMHelper = { 0x101F8647 };   // UID of the DRMHelper Dll
+
+
+/*
+* ==============================================================================
+* Dialogs shown by DRMHelper. These messages are handled using the
+* Secondary Display support in Avkon.
+* ==============================================================================
+*/
+enum TSecondaryDisplayDRMHelperDialogs
+    {
+    ECover_confirmation_query = 1,
+    ECover_waiting_rights_confirmation_query,
+    ECover_usage_rights_expired_buy_new,
+    ECover_usage_rights_expired,
+    ECover_no_usage_rights_buy_new,
+    ECover_no_usage_rights,
+    ECover_database_corrupted,
+    ECover_usage_rights_to_expire_1_count,
+    ECover_usage_rights_to_expire_n_counts,
+    ECover_usage_rights_to_expire_1_day,
+    ECover_usage_rights_to_expire_n_days,
+    ECover_usage_rights_to_expire,
+    ECover_set_automated,
+    ECover_activate_and_set_automated,
+    ECover_cal_alert_to_expire_1_day,
+    ECover_cal_alert_to_expire_n_days,
+    ECover_clock_alarm_to_expire_1_day,
+    ECover_clock_alarm_to_expire_n_days,
+    ECover_email_tone_to_expire_1_day,
+    ECover_email_tone_to_expire_n_days,
+    ECover_im_tone_to_expire_1_day,
+    ECover_im_tone_to_expire_n_days,
+    ECover_message_tone_to_expire_1_day,
+    ECover_message_tone_to_expire_n_days,
+    ECover_ringing_tone_to_expire_1_day,
+    ECover_ringing_tone_to_expire_n_days,
+    ECover_screensaver_to_expire_1_day,
+    ECover_screensaver_to_expire_n_days,
+    ECover_wallpaper_to_expire_1_day,
+    ECover_wallpaper_to_expire_n_days,
+    ECover_theme_to_expire_1_day,
+    ECover_theme_to_expire_n_days,
+    ECover_cal_alert_invalid_sim_buy_new,
+    ECover_cal_alert_expired_buy_new,
+    ECover_cal_alert_expired,
+    ECover_clock_alarm_invalid_sim_buy_new,
+    ECover_clock_alarm_expired_buy_new,
+    ECover_clock_alarm_expired,
+    ECover_email_tone_expired_buy_new,
+    ECover_email_tone_invalid_sim_buy_new,
+    ECover_email_tone_expired,
+    ECover_im_tone_expired_buy_new,
+    ECover_im_tone_expired,
+    ECover_message_tone_invalid_sim_buy_new,
+    ECover_message_tone_expired_buy_new,
+    ECover_message_tone_expired,
+    ECover_ringing_tone_expired_buy_new,
+    ECover_ringing_tone_invalid_sim_buy_new,
+    ECover_ringing_tone_expired,
+    ECover_screensaver_invalid_sim_buy_new,
+    ECover_screensaver_expired_buy_new,
+    ECover_screensaver_expired,
+    ECover_wallpaper_invalid_sim_buy_new,
+    ECover_wallpaper_expired_buy_new,
+    ECover_wallpaper_expired,
+    ECover_theme_invalid_sim_buy_new,
+    ECover_theme_expired_buy_new,
+    ECover_theme_expired,
+    ECover_usage_rights_in_future,
+    ECover_activate_after_preview,
+    ECover_usage_rights_to_expire_1_minute,
+    ECover_usage_rights_to_expire_n_minutes,
+    ECover_automated_to_expire_1_day,
+    ECover_automated_to_expire_n_days,
+    ECover_waiting_for_rights,
+    ECover_rights_should_have_come,
+    ECover_rights_should_have_come_no_ri,
+    ECover_automated_sd_invalid_sim,
+    ECover_automated_sd_expired,
+    ECover_automated_cd_expired,
+    ECover_info_exp_1_use,
+    ECover_info_exp_n_uses,
+    ECover_info_exp_1_day,
+    ECover_info_exp_n_days,
+    ECover_query_exp_1_use_get_new,
+    ECover_query_exp_n_use_get_new,
+    ECover_query_exp_1_day_get_new,
+    ECover_query_exp_n_day_get_new,
+    ECover_query_exp_1_min_get_new,
+    ECover_query_exp_n_min_get_new,
+    ECover_query_exp_many_constr,
+    ECover_prev_audio_get_list_query,
+    ECover_prev_video_get_list_query,
+    ECover_prev_audio_play_list_query,
+    ECover_prev_video_play_list_query,
+    ECover_invalid_sim,
+
+    ECover_audio_prev_get_list,
+    ECover_video_prev_get_list,
+    ECover_audio_prev_play_list,
+    ECover_video_prev_play_list,
+    ECover_r_silent_wait_note,
+    ECover_usage_rights_expired_connect_buy_new,
+    ECover_no_usage_rights_connect_buy_new,
+    ECover_dialog_cancel,
+    ECover_warn_no_conn_defined,
+    ECover_err_no_coverage,
+    ECover_warn_invalid_or_no_ap,
+    ECover_err_opening_fail_perm,
+    ECover_gen_rights_exp,
+    ECover_no_rights_for_some
+};
+
+/*
+* ==============================================================================
+* Parameter definitions for the messages in this file.
+* ==============================================================================
+*/
+
+// Package definition for Matched Item
+struct THelperSDData
+    {
+    TUid iHelperUid;            // drmhelper.dll process Id {0x101F8647}
+    TUid iHandlerProcessId;     // Process Id which is using drmhelper.dll
+    TUid iCreatorProcessId;     // Process Id of creator of process
+                                // using drmhelper.dll
+    TBuf<256> iStringParam;     // Used to transfer string note info
+                                // (like server names, filenames etc..)
+    TBuf<32> iNumParam;         // Used to transfer numeric note info data
+                                // (like days, counts, time)
+
+    };
+
+typedef TPckgBuf<THelperSDData> THelperSDDataPckg;
+
+
+// Package definition for cancel event
+struct THelperSDDataCancel
+    {
+    TUid iHandlerProcessId;     // Process Id which is using drmhelper.dll
+    TUid iCreatorProcessId;     // Process Id of creator of process
+                                // using drmhelper.dll
+    TInt iNoteId;               // Dialog id of the cancelled event
+    };
+
+typedef TPckgBuf<THelperSDDataCancel> THelperSDDataPckgCancel;
+
+
+#endif      // DRMHELPER_SECONDARY_DISPLAY_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_service_api/drm_service_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="c5208bdf54baf55f196d3d159cef17e0" dataversion="1.0">
+  <name>DRM Service API</name>
+  <description>An API for accessing DRM time and some cryptographic operations</description>
+  <type>c++</type>
+  <subsystem>omadrm</subsystem>
+  <libs>
+    <lib name="drmserviceapi.lib" />
+  </libs>
+  <release category="domain"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_service_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* 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:  File that exports the files belonging to 
+:                DRM Service API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/drmserviceapi.h     MW_LAYER_PLATFORM_EXPORT_PATH(drmserviceapi.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_service_api/inc/drmserviceapi.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,158 @@
+/*
+* 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:  Service api which exposes some of the private functionality
+*                as a domain API
+*
+*/
+
+
+#ifndef C_CDRMSERVICEAPI_H
+#define C_CDRMSERVICEAPI_H
+
+#include <e32base.h>
+#include "drmtypes.h"
+
+// Forward declarations
+class RDRMClockClient;
+
+namespace Roap
+    {
+    class RRoapStorageClient;   
+    }
+
+
+namespace DRM 
+    {
+
+/**
+ *  Drm Service Api which provides access to some drm private functionality
+ *
+ *  @lib DrmServiceAPI.lib
+ *  @since S60 v3.2
+ */
+NONSHARABLE_CLASS( CDrmServiceApi ) : public CBase
+    {
+
+public:
+
+    /**
+     * Two-phased constructor
+     *
+     * Creates a function CDrmServiceApi -object and returns a pointer to it
+     * pointer is owned by the caller
+     *
+     * @since   S60 v3.2
+     * @return  Symbian OS error code if any.
+     */
+    IMPORT_C static CDrmServiceApi* NewL();
+
+    /**
+     * Two-phased constructor
+     *
+     * Creates a function CDrmServiceApi -object and returns a pointer to it
+     * pointer is owned by the caller, the pointer is left to the cleanup stack
+     *
+     * @since   S60 v3.2
+     * @return  Symbian OS error code if any.
+     */
+    IMPORT_C static CDrmServiceApi* NewLC();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDrmServiceApi();
+
+
+    /**
+     * Get the secure time
+     *
+     * @since   S60 v3.2
+     * @param   aTime           Output parameter containing the 
+     *                          secure time in UTC.
+     * @param   aTimeZone       Time zone information including summer/winter time
+     *                          in +/- 15 minutes
+     * @param   aSecurityLevel  Output parameter Securiry level.
+     * @return  Symbian OS error code if any.
+     */
+    IMPORT_C TInt GetSecureTime( TTime& aTime, 
+                                 TInt& aTimeZone,
+                                 DRMClock::ESecurityLevel& aSecurityLevel ) const;
+                        
+    /**
+     * Update the secure time
+     *
+     * Requires DRM Capability
+     *
+     * @since   S60 v3.2
+     * @param   aTime           Input parameter containing the 
+     *                          secure time in UTC.
+     * @param   aTimeZone       Time zone information including 
+     *                          summer/winter time
+     *                          in +/- 15 minutes         
+     * @return  Symbian OS error code if any.
+     */
+    IMPORT_C TInt UpdateSecureTime( const TTime& aTime, const TInt& aTimeZone );
+
+
+    /**
+     * Get the device public key in Der format
+     *
+     * @since   S60 v3.2
+     * @param   aPublicKey      Return parameter for the public key owned by
+     *                          the caller
+     * @return  none
+     * @leave Symbian OS error code
+     */
+    IMPORT_C void GetDevicePublicKeyDerL( HBufC8*& aPublicKey );
+
+    /**
+     * Sign the value given
+     *
+     * @since   S60 v3.2
+     * @param   aHash           Value to be signed
+     * @param   aSignature      Return parameter for the signature, owned by
+     *                          the caller
+     * @return  none
+     * @leave Symbian OS error code
+     */
+    IMPORT_C void SignL( const TDesC8& aHash, HBufC8*& aSignature );
+
+private:
+
+    /**
+    * Default constructor
+    */
+    CDrmServiceApi();
+
+    /**
+    * 2nd phase constructor
+    */
+    void ConstructL();
+
+
+private: // data
+    /**
+    * Owned clock client
+    */
+    RDRMClockClient* iClockClient;
+    
+    /**
+    * Owned roap storage client
+    */
+    Roap::RRoapStorageClient* iRoapStorageClient;
+    };
+    
+    }
+
+#endif // C_CDRMSERVICEAPI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/drm_utility_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,21 @@
+<?xml version="1.0" ?>
+<api id="48877fa588c2ec787dec2facaf96aa89" dataversion="1.0">
+  <name>DRM Utility API</name>
+  <description>DRM scheme agnostic interface for DRM specific error handling and registering and unregistering DRM protected content as automated content</description>
+  <type>c++</type>
+  <subsystem>commondrm</subsystem>
+  <libs>
+    <lib name="drmutility.lib" />
+    <lib name="drmrightsinfo.lib" />
+    <lib name="drmuihandling.lib" />
+    <lib name="drmautomatedusage.lib" />
+  </libs>
+  <release category="domain"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,48 @@
+/*
+* 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:  File that exports the files belonging to 
+:                DRM Utility API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+#if (defined RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM)
+// Utility
+../inc/drmutility.h                  MW_LAYER_PLATFORM_EXPORT_PATH( drmutility.h )
+
+// Api classes
+../inc/drmautomatedusage.h           MW_LAYER_PLATFORM_EXPORT_PATH( drmautomatedusage.h )
+../inc/drmrightsinfo.h               MW_LAYER_PLATFORM_EXPORT_PATH( drmrightsinfo.h )
+../inc/drmuihandling.h               MW_LAYER_PLATFORM_EXPORT_PATH( drmuihandling.h )
+
+// Error handling
+../inc/drmerrorhandling.h            MW_LAYER_PLATFORM_EXPORT_PATH( drmerrorhandling.h )
+
+// Observers
+../inc/drmasyncobserver.h            MW_LAYER_PLATFORM_EXPORT_PATH( drmasyncobserver.h )
+../inc/drmautomatedusageobserver.h   MW_LAYER_PLATFORM_EXPORT_PATH( drmautomatedusageobserver.h )
+../inc/drmhandleerrorobserver.h      MW_LAYER_PLATFORM_EXPORT_PATH( drmhandleerrorobserver.h )
+../inc/drmuicheckrightsobserver.h    MW_LAYER_PLATFORM_EXPORT_PATH( drmuicheckrightsobserver.h )
+
+// Types
+../inc/drmutilitytypes.h             MW_LAYER_PLATFORM_EXPORT_PATH( drmutilitytypes.h )
+
+#endif // RD_DRM_COMMON_INTERFACE_FOR_OMA_AND_WMDRM
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/inc/drmasyncobserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,59 @@
+/*
+* 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:  Generic interface class for Asynchronous callbacks from
+ *                asynchronous functions in the DRM Utility API
+ *
+ *
+*/
+
+
+#ifndef MDRMASYNCOBSERVER_H
+#define MDRMASYNCOBSERVER_H
+
+#include <e32def.h>
+
+namespace DRM
+    {
+    /**
+     *  Observer class for Asynchronous operations in DRM Utility
+     *
+     *  Provides callback(s) to the the observer when the asynchronous operations
+     *  complete
+     *  @code
+     *   ?good_class_usage_example(s)
+     *  @endcode
+     *
+     *  @since S60 v5.0
+     */
+class MDrmAsyncObserver
+    {
+public:
+
+    /**
+     * A callback function which tells when the asynchronous operation has been
+     * completed
+     *
+     * @since S60 v5.0
+     * @param[in] aOperationId          Identifier of the asynchronous operation
+     *                                  which was returned when the asynchronous
+     *                                  operation was initiated
+     * @param[in] aOperationStatus      The final status of the operation
+     * @return None
+     * @leave None
+     */
+    virtual void OperationCompleted( TInt aOperationId, TInt aOperationStatus ) = 0;
+    };
+
+    }
+#endif // MDRMASYNCOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/inc/drmautomatedusage.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,587 @@
+/*
+* 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:  Provides operations for automated usage of DRM content
+*
+*/
+
+
+#ifndef CDRMAUTOMATEDUSAGE_H
+#define CDRMAUTOMATEDUSAGE_H
+
+#include <e32base.h>
+#include <f32file.h>
+
+#include <caf/caftypes.h>
+#include <caf/data.h>
+
+#include <drmutilitytypes.h>
+#include <drmautomatedusageobserver.h>
+#include <drmutility.h>
+#include <drmerrorhandling.h>
+
+
+
+class CCoeEnv;
+
+namespace DRM
+{
+class CDrmAutomatedUsageImpl;
+
+/**
+*  Utility class for DRM related automated usage handling
+*
+*  Usage:
+*  @code
+*      #include <drmautomatedusage.h>
+*      // Instantiate class CDrmAutomatedUsage
+*      DRM::CDrmAutomatedUsage* iAutomatedUsage =
+*          DRM::CDrmAutomatedUsage::NewLC();
+*      // ...
+*      // RFile myRingToneFile;
+*      // open my Ringtone for reading
+*      // ...
+*      ContentAccess::CData* myDataObject = ContentAccess::CData::NewL(
+*          myRingToneFile,
+*          ContentAccess::KDefaultContentObject,
+*          ContentAccess::EPeek );
+*      // check if content can be set as automated
+*      if ( iAutomatedUsage->CanSetAutomatedL(
+*          myDataObject,
+*          ContentAccess::EPlay,
+*          DRM::EAUAutomatedTypeRingingTone ) )
+*          {
+*          // automated usage allowed
+*
+*          // we register content as ringing tone in this example
+*          iAutomatedUsage->SetAutomated(
+*              myDataObject,
+*              ContentAccess::EPlay,
+*              DRM::EAUAutomatedTypeRingingTone,
+*              DRM::EAUPassive );
+*
+*          }
+*          else
+*          {
+*          // automated usage not allowed
+*          }
+*  @endcode
+*
+*  @lib drmautomatedusage.lib
+*  @since S60 5.0
+*/
+NONSHARABLE_CLASS( CDrmAutomatedUsage ) : public CBase
+    {
+public:
+
+    /**
+    * Creates a new CDrmAutomatedUsage object and returns a pointer to it
+    *
+    * @since S60 5.0
+    *
+    * @param aCoeEnv   A pointer to an instance of CCoeEnv. If the
+    *                  parameter is not provided the global instance
+    *                  will be used. In the case of a server process
+    *                  where the global instance is not available,
+    *                  global notes will be used.
+    *
+    *                  If no CCoeEnv instance is available, applications
+    *                  launched will be launched as standalone
+    *                  applications.
+    *
+    * @return A functional CDrmAutomatedUsage -object
+    *
+    * @leave System wide error code
+    *
+    * @see CCoeEnv
+    *
+    */
+    IMPORT_C static CDrmAutomatedUsage* NewL( CCoeEnv* aCoeEnv = NULL );
+
+
+    /**
+    * Creates a new CDrmAutomatedUsage object and returns a pointer to it
+    * Leaves the pointer to the cleanup stack
+    *
+    * @since S60 5.0
+    *
+    * @param aCoeEnv   A pointer to an instance of CCoeEnv. If the
+    *                  parameter is not provided the global instance
+    *                  will be used. In the case of a server process
+    *                  where the global instance is not available,
+    *                  global notes will be used.
+    *
+    *                  If no CCoeEnv instance is available, applications
+    *                  launched will be launched as standalone
+    *                  applications.
+    *
+    * @return A functional CDrmAutomatedUsage -object
+    *
+    * @leave System wide error code
+    *
+    * @see CCoeEnv
+    *
+    */
+    IMPORT_C static CDrmAutomatedUsage* NewLC( CCoeEnv* aCoeEnv = NULL );
+
+
+    /**
+    * Destructor
+    */
+    virtual ~CDrmAutomatedUsage();
+
+
+    /**
+    * Returns a reference to a CDrmUtility instance. The ownership
+    * of the instance stays with the CDrmAutomatedUsage -class
+    *
+    * @since S60 5.0
+    *
+    * @return A reference to a functional CDrmUtility instance
+    *
+    * @see DRM::CDrmUtility
+    */
+    IMPORT_C CDrmUtility& GetUtility() const;
+
+
+    /**
+    * Returns a reference to a class which implements the
+    * MDrmErrorHandling interface. The ownership
+    * of the instance stays with the CDrmAutomatedUsage -class
+    *
+    * @since S60 5.0
+    *
+    * @return A reference to a functional object implementing the
+    *         MDrmErrorHandling interface
+    *
+    * @see DRM::MDrmErrorHandling
+    */
+    IMPORT_C MDrmErrorHandling& GetErrorHandler() const;
+
+
+    /**
+    * Checks if given content can be set as an automated content.
+    *
+    * @since  S60 5.0
+    *
+    * @param[in]   aFile           file handle to the file
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   AutomatedType   Usage intention of the automated content
+    *
+    * @return ETrue if the content can be set as automated content
+    *         EFalse if the content can't be set as automated content
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see RFile
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    */
+    IMPORT_C TBool CanSetAutomatedL(
+        RFile& aFile,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType );
+
+
+    /**
+    * Checks if given content can be set as an automated content.
+    *
+    * @since  S60 5.0
+    *
+    * @param[in]   aData           CData object to the protected content
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   AutomatedType   Usage intention of the automated content
+    *
+    * @return ETrue if the content can be set as automated content
+    *         EFalse if the content can't be set as automated content
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    */
+    IMPORT_C TBool CanSetAutomatedL(
+        const ContentAccess::CData& aData,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType );
+
+
+    /**
+    * Registers given content to be used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aFile           file handle to the file
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see RFile
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::TDrmAutomatedServiceType
+    */
+    IMPORT_C void SetAutomatedL(
+        RFile& aFile,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Registers given content to be used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aFile           file handle to the file
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aObserver       Async callback observer
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see RFile
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::MDrmAsyncObserver
+    * @see DRM::TDrmAutomatedServiceType
+    *
+    */
+    IMPORT_C TInt SetAutomatedAsyncL(
+        RFile& aFile,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver& aObserver,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Registers given content to be used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aData           CData object to the protected content
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::TDrmAutomatedServiceType
+    */
+    IMPORT_C void SetAutomatedL(
+        const ContentAccess::CData& aData,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Registers given content to be used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aData           CData object to the protected content
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aObserver       Async callback observer
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::MDrmAsyncObserver
+    * @see DRM::TDrmAutomatedServiceType
+    */
+    IMPORT_C TInt SetAutomatedAsyncL(
+        const ContentAccess::CData& aData,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver& aObserver,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aFile           file handle to the file
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see RFile
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::TDrmAutomatedServiceType
+    */
+    IMPORT_C void RemoveAutomatedL(
+        RFile& aFile,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aFile           file handle to the file
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]  aObserver       Async callback observer
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see RFile
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::MDrmAsyncObserver
+    * @see DRM::TDrmAutomatedServiceType
+    */
+    IMPORT_C TInt RemoveAutomatedAsyncL(
+        RFile& aFile,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver& aObserver,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aData           CData object to the protected content
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::TDrmAutomatedServiceType
+    */
+    IMPORT_C void RemoveAutomatedL(
+        const ContentAccess::CData& aData,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aData           CData object to the protected content
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aObserver       Async callback observer
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::MDrmAsyncObserver
+    * @see DRM::TDrmAutomatedServiceType
+    */
+    IMPORT_C TInt RemoveAutomatedAsyncL(
+        const ContentAccess::CData& aData,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver& aObserver,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aUniqueId       unique content id
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::TIntent
+    *
+    * @see ContentAccess::CData::GetStringAttribute()
+    * @see ContentAccess::TStringAttribute
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::TDrmAutomatedServiceType
+    */
+    IMPORT_C void RemoveAutomatedL(
+        const TDesC& aUniqueId,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Unregisters given content from being used as an automated content.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aUniqueId       unique content id
+    * @param[in]   aIntent         See ContentAccess::Intent
+    * @param[in]   aAutomatedType  Usage intention of the automated content
+    * @param[in]   aObserver       Async callback observer
+    * @param[in]   aServiceType    default: EAUActive
+    *
+    * @return Operation Identifier for the async request
+    *         required for cancelling an operation and
+    *         identifying which request has been completed
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see ContentAccess::CData::GetStringAttribute()
+    * @see ContentAccess::TStringAttribute
+    * @see ContentAccess::TIntent
+    * @see DRM::TDrmAutomatedType
+    * @see DRM::MDrmAsyncObserver
+    * @see DRM::TDrmAutomatedServiceType
+    */
+    IMPORT_C TInt RemoveAutomatedAsyncL(
+        const TDesC& aUniqueId,
+        const ContentAccess::TIntent aIntent,
+        const TDrmAutomatedType aAutomatedType,
+        MDrmAsyncObserver& aObserver,
+        const TDrmAutomatedServiceType aServiceType = EAUActive );
+
+
+    /**
+    * Registers client to listen events related to automated usage. If
+    * the client doesn't do this, all the events are handled automatically
+    * according to the S60 style.
+    *
+    * The observer registered with this function needs to be unregistered
+    * before it is deleted.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]    aObserver
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see DRM::MDrmAutomatedUsageObserver
+    */
+    IMPORT_C void RegisterEventObserverL(
+        MDrmAutomatedUsageObserver& aObserver );
+
+
+    /**
+    * Unregisters client from listening to events related to automated usage.
+    *
+    * If register event observer has been called, it must be unregistered
+    * before the observer object is deleted.
+    *
+    * @since S60 5.0
+    *
+    * @param[in]    aObserver
+    *
+    * @leave System wide or DRM specific error code.
+    *
+    * @see DRM::MDrmAutomatedUsageObserver
+    */
+    IMPORT_C void UnregisterEventObserverL(
+        MDrmAutomatedUsageObserver& aObserver );
+
+
+    /**
+    * Cancel an asyncronous operation
+    *
+    * @since S60 5.0
+    *
+    * @param[in]   aOperationId    identifier of the async operation
+    *                              to be cancelled
+    * @return KErrNotFound if the operation has already been executed
+    *         or it does not exist
+    */
+    IMPORT_C TInt CancelOperation( TInt aOperationId );
+
+
+private: // member functions
+
+    /**
+    *  Default constructor
+    */
+    CDrmAutomatedUsage();
+
+
+    /**
+    *  Second phase constructor
+    */
+    void ConstructL( CCoeEnv* aCoeEnv );
+
+
+private: // data members
+    /**
+    * Implementation class pointer
+    * Owned
+    */
+    CDrmAutomatedUsageImpl* iImplementation;
+
+    /**
+    * Implementation class pointer
+    * Owned
+    */
+    MDrmErrorHandling* iErrorHandler;
+
+    /**
+    * Implementation class pointer
+    * Owned
+    */
+    CDrmUtility* iUtility;
+    };
+}
+
+
+#endif // CDRMAUTOMATEDUSAGE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/inc/drmautomatedusageobserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,115 @@
+/*
+* 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:  Observer for automated usage UI notifications
+ *
+*/
+
+
+#ifndef MDRMAUTOMATEDUSAGEOBSERVER_H
+#define MDRMAUTOMATEDUSAGEOBSERVER_H
+
+
+#include <caf/caftypes.h>
+
+#include <drmutilitytypes.h>
+
+namespace DRM
+    {
+
+
+/**
+*  Observer for DRM automated usage
+*
+*  In order to be able to get notifications of drm automated usage events
+*  client must implement this interface
+*
+*  Usage:
+*  @code
+*        // Call NewL() to create an instance of CDrmAutomatedUsage. 
+*        iDrmAutomatedUsage = DRM::CDrmAutomatedUsage::NewL();
+*        
+*        // register to listen automated usage events
+*        iDrmAutomatedUsage->RegisterEventObserverL( this );
+*        
+*        // Implement automated usage callback
+*        DRM::TAutomatedUsageAction CMyClass::AutomatedUsageEvent( 
+*            DRM::TAutomatedUsageEvent aAutomatedUsageEvent,
+*            const TDesC& aUniqueId,
+*            ContentAccess::TIntent aIntent )
+*            {
+*            if ( aAutomatedUsageEvent == DRM::EAutomatedContentExpired )
+*                {
+*                // some automated content expired
+*                
+*                // check unique id if we are interested about this content
+*                if ( !aUniqueId.Compare( myUniqueId ) )
+*                    {
+*                    // in this example we let utility to handle situation
+*                    return DRM::EAUActionDefault;
+*                    }
+*                }
+*                return DRM::EAUActionIgnore;
+*            }
+*  @endcode
+*
+*
+*  @lib drmautomatedusage.lib
+*  @since S60 5.0
+*/
+class MDrmAutomatedUsageObserver
+    {
+public:
+
+    /**
+    * Callback for automated usage events
+    *
+    * @since S60 5.0
+    * @param aAutomatedUsageEvent   Automated usage event type
+    * @param aUniqueId              Unique ID of the content related to event
+    * @param aType                  Type of the automated content related to
+    *                               the event
+    *
+    * @return action how to proceed
+    *
+    * @see ContentAccess::TIntent
+    * @see DRM::TAutomatedUsageAction
+    * @see DRM::TAutomatedUsageEvent
+    */
+    virtual TAutomatedUsageAction AutomatedUsageEvent(
+        TAutomatedUsageEvent aAutomatedUsageEvent,
+        const TDesC& aUniqueId,
+        const TDrmAutomatedType aType,
+        const TDrmAutomatedServiceType aServiceType,
+        ContentAccess::TIntent aIntent = ContentAccess::EUnknown ) = 0;
+
+    /**
+    * Callback for drm utility handled event keycodes.
+    *
+    * @since S60 5.0
+    * @param aAutomatedUsageEvent   Automated usage event type
+    * @param aUniqueId              Unique ID of the content under event
+    * @apram aKeycode               button/key code returned from user
+    *                               interaction
+    * @return action how to proceed
+    *
+    * @see DRM::TAutomatedUsageEvent
+    */
+    virtual void AutomatedUsageKeyCode(
+        TAutomatedUsageEvent aAutomatedUsageEvent,
+        const TDesC& aUniqueId,
+        TInt aKeyCode ) = 0;
+    };
+}
+
+#endif // MDRMAUTOMATEDUSAGEOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/inc/drmerrorhandling.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,149 @@
+/*
+* Copyright (c) 2006, 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:  Utility API definition for Error Handling
+ *
+*/
+
+
+#ifndef MDRMERRORHANDLING_H
+#define MDRMERRORHANDLING_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <caf/caferr.h>
+#include <caf/caf.h>
+
+#include "drmhandleerrorobserver.h"
+
+namespace DRM
+    {
+    /**
+     *  Utility class for DRM related UI
+     *
+     *  By using this class an application can resolve situation where there is
+     *  no valid rights for the content, check status of rights and display
+     *  an embedded rights details view.
+     *
+     *  @since S60 v5.0
+     */
+class MDrmErrorHandling
+    {
+
+public:
+
+    /**
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override,
+     * to the user and acquires new rights if needed. Asynchronous version,
+     * all errors are signalled using request status.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve
+     *                          the error
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @see MDrmHandleErrorObserver
+     * @see ContentAccess::TIntent
+     */
+    IMPORT_C virtual TInt HandleErrorAsyncL(
+            RFile& aFile,
+            ContentAccess::TIntent aIntent,
+            TInt aError,
+            MDrmHandleErrorObserver& aObserver ) = 0;
+
+    /**
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override,
+     * to the user and acquires new rights if needed. Synchronous version,
+     * leaves in case of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve
+     *                          the error
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   pointer to observer, NULL if no observer
+     *
+     * @leave   KErrArgument    File is not DRM protected.
+     *
+     * @see MDrmHandleErrorObserver
+     * @see ContentAccess::TIntent
+     */
+    IMPORT_C virtual void HandleErrorL(
+            RFile& aFile,
+            ContentAccess::TIntent aIntent,
+            TInt aError,
+            MDrmHandleErrorObserver* aObserver ) = 0;
+
+    /**
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override,
+     * to the user and acquires new rights if needed. Asynchronous version,
+     * all errors are signalled using request status.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve
+     *                          the error
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @see MDrmHandleErrorObserver
+     * @see ContentAccess::TIntent
+     */
+    IMPORT_C virtual TInt HandleErrorAsyncL(
+            ContentAccess::CData& aFile,
+            ContentAccess::TIntent aIntent,
+            TInt aError,
+            MDrmHandleErrorObserver& aObserver ) = 0;
+
+    /**
+     * Handles DRM error situations related to invalid rights.
+     * This method displays appropriate notes, which observer can override,
+     * to the user and acquires new rights if needed. Synchronous version,
+     * leaves in case of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content for which the error happened
+     * @param[in]   aIntent     the CAF intent which was used to recieve
+     *                          the error
+     * @param[in]   aError      error code
+     * @param[in]   aObserver   pointer to observer, NULL if no observer
+     *
+     * @leave   KErrArgument    File is not DRM protected.
+     *
+     * @see MDrmHandleErrorObserver
+     * @see ContentAccess::TIntent
+     */
+    IMPORT_C virtual void HandleErrorL(
+            ContentAccess::CData& aFile,
+            ContentAccess::TIntent aIntent,
+            TInt aError,
+            MDrmHandleErrorObserver* aObserver ) = 0;
+    };
+    }
+
+
+
+#endif // MDRMERRORHANDLING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/inc/drmhandleerrorobserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,313 @@
+/*
+* Copyright (c) 2006-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:  Observer interface for HandleError
+ *
+*/
+
+
+#ifndef MDRMHANDLEERROROBSERVER_H
+#define MDRMHANDLEERROROBSERVER_H
+
+#include <drmasyncobserver.h>
+#include <drmutilitytypes.h>
+
+namespace DRM
+    {
+
+    /**
+     *  An interface containing callbacks for CDrmUiHandling::HandleError().
+     *
+     *  By implementing these methods observer can get more information about
+     *  what kind of rights are available and can also override the default
+     *  behaviour.
+     *
+     *  @code
+     *      #include <DrmUiHandling.h>
+     *      #include <DrmHandleErrorObserver.h>
+     *
+     *      using namespace DRM;
+     *
+     *      // Call NewLC() to create an instance of CDrmUiHandling.
+     *      CDrmUiHandling* drmUiHandler = CDrmUiHandling::NewLC();
+     *
+     *      // Handling the error got when tried to read the file
+     *      drmHandlerError = drmUiHandler->HandleErrorL( file, error, this );
+     *
+     *      // delete the created instance of CDrmUiHandling
+     *      CleanupStack::PopAndDestroy( drmUiHandler );
+     *
+     *      ...
+     *
+     *      // implement callbacks
+     *      TEmbeddedPreviewAction CMyClass::EmbeddedPreviewAvailable( const TDesC& aUniqueId )
+     *          {
+     *          return EEmbeddedPreviewActionDefault;
+     *          }
+     *
+     *      TPreviewRightsAction CMyClass::PreviewRightsUrlAvailable( const TDesC& aPreviewRightsUrl )
+     *          {
+     *          return EPreviewRightsActionDefault;
+     *          }
+     *
+     *      TSilentRightsAction CMyClass::SilentRightsUrlAvailable( const TDesC& aSilentRightsUrl )
+     *          {
+     *          return ESilentRightsActionDefault;
+     *          }
+     *
+     *      void CMyClass::PreviewRightsAvailable()
+     *          {
+     *          // play the content, since preview rights were retrieved
+     *          }
+     *
+     *      void CMyClass::SilentRightsAvailable()
+     *          {
+     *          // play the content, since silent rights were retrieved
+     *          }
+     *
+     *      void CMyClass::PlayEmbeddedPreviewSelected( const TDesC& aUniqueId )
+     *          {
+     *          // play embedded preview part
+     *          ...
+     *          }
+     *  @endcode
+     *
+     *  @since S60 v5.0
+     *  @see CDrmUiHandling::HandleError
+     */
+class MDrmHandleErrorObserver : public MDrmAsyncObserver
+    {
+
+public:
+
+    /**
+     * Called when content has embedded preview part. If
+     * EEmbeddedPreviewActionDefault is returned,
+     * PlayEmbeddedPreviewSelected is called if user selects to play
+     * embedded preview.
+     *
+     * @since S60 v5.0
+     * @param[in] aOperationId  Identifier of the asynchronous operation
+     *                          which was returned when the asynchronous
+     *                          operation was initiated, Zero(0) if it
+     *                          is a call back from a synchronous
+     *                          operation
+     * @param[in]   aUniqueId   Unique ID of embedded preview part.
+     * @param[in]   aRightsStatus Status of the rights as defined per
+     *                            TDrmRightsInfo
+     * @param[in]   aReason     Rejection reason, a bitvector which
+     *                          states for what reasons rights have
+     *                          been rejected from use using
+     *                          TRejectionType
+     *
+     * @return  EEmbeddedPreviewActionDefault DRM Utility asks if user
+     *          wants to play preview or acquire new rights
+     *          EUEmbeddedPreviewActionDefaultAudio DRM Utility asks if user
+     *          wants to play preview or acquire new rights for audio
+     *          EUEmbeddedPreviewActionDefaultVideo DRM Utility asks if user
+     *          wants to play preview or acquire new rights for video
+     *          EEmbeddedPreviewActionFetchRights  DRM Utility acquires
+     *          new rights, no queries shown by DRM Utility
+     *          EEmbeddedPreviewActionPlayPreview  Observer takes care
+     *          of playing embedded preview
+     */
+    virtual TEmbeddedPreviewAction EmbeddedPreviewAvailable(
+            TInt aOperationId,
+            const TDesC& aUniqueId,
+            TInt aRightsStatus,
+            TInt aReason ) = 0;
+
+    /**
+     * Called if preview rights can be acquired for content.
+     *
+     * @since S60 v5.0
+     * @param[in] aOperationId  Identifier of the asynchronous operation
+     *                          which was returned when the asynchronous
+     *                          operation was initiated, Zero(0) if it
+     *                          is a call back from a synchronous
+     *                          operation
+     * @param[in]   aPreviewRightsUrl   URL from where preview rights can
+     *                                  be fetched.
+     * @param[in]   aRightsStatus Status of the rights as defined per
+     *                            TDrmRightsInfo
+     * @param[in]   aReason     Rejection reason, a bitvector which
+     *                          states for what reasons rights have
+     *                          been rejected from use using
+     *                          TRejectionType
+     *
+     * @return  EPreviewRightsActionDefault DRM Utility asks if user
+     *          wants to acquire preview rights or normal rights
+     *          EUPreviewRightsActionDefaultAudio DRM Utility asks if user
+     *          wants to acquire preview rights or normal rights for audio and 
+     *          acquires them
+     *          EUPreviewRightsActionDefaultVideo DRM Utility asks if user 
+     *          wants to acquire preview rights or normal rights for video and
+     *          acquires them
+     *          EPreviewRightsActionFetchRights DRM Utility acquires normal
+     *          rights, no queries shown by DRM utility
+     *          EPreviewRightsActionFetchPreviewRights Observer takes care
+     *          of acquiring preview rights
+     */
+    virtual TPreviewRightsAction PreviewRightsUrlAvailable(
+            TInt aOperationId,
+            const TDesC& aPreviewRightsUrl,
+            TInt aRightsStatus,
+            TInt aReason ) = 0;
+
+    /**
+     * Called if silent rights can be acquired for content.
+     *
+     * @since S60 v5.0
+     * @param[in] aOperationId  Identifier of the asynchronous operation
+     *                          which was returned when the asynchronous
+     *                          operation was initiated, Zero(0) if it
+     *                          is a call back from a synchronous
+     *                          operation
+     * @param[in]   aSilentRightsUrl    URL from where silent rights can
+     *                                  be fetched.
+     * @param[in]   aRightsStatus Status of the rights as defined per
+     *                            TDrmRightsInfo
+     * @param[in]   aReason     Rejection reason, a bitvector which
+     *                          states for what reasons rights have
+     *                          been rejected from use using
+     *                          TRejectionType
+     *
+     * @return  ESilentRightsActionDefault DRM Utility performs the
+     *          default silent rights handling
+     *          ESilentRightsActionFetchRights DRM Utility acquires normal
+     *          rights
+     *          ESilentRightsActionFetchSilentRights   Observer takes care
+     *          of acquiring silent rights
+     */
+    virtual TSilentRightsAction SilentRightsUrlAvailable(
+            TInt aOperationId,
+            const TDesC& aSilentRightsUrl,
+            TInt aRightsStatus,
+            TInt aReason ) = 0;
+
+    /**
+     * Called if only rights-issuer URL or domain rights-issuer URL is
+     * available.
+     *
+     * @since S60 v5.0
+     * @param[in] aOperationId  Identifier of the asynchronous operation
+     *                          which was returned when the asynchronous
+     *                          operation was initiated, Zero(0) if it
+     *                          is a call back from a synchronous
+     *                          operation
+     * @param[in]   aRightsUrl          URL from where rights can
+     *                                  be fetched.
+     * @param[in]   aRightsStatus Status of the rights as defined per
+     *                            TDrmRightsInfo
+     * @param[in]   aReason     Rejection reason, a bitvector which
+     *                          states for what reasons rights have
+     *                          been rejected from use using
+     *                          TRejectionType
+     * @param[in]   aUrlType    The type of url available in TDrmUiUrlType
+     *
+     * @return  ERightsActionDefault DRM Utility performs the
+     *          default rights handling
+     *          ERightsActionFetchRights DRM Utility acquires normal
+     *          rights
+     */
+    virtual TRightsAction RightsUrlAvailable(
+            TInt aOperationId,
+            const TDesC& aRightsUrl,
+            TInt aRightsStatus,
+            TInt aReason,
+            TInt aUrlType ) = 0;
+
+    /**
+     * Called when preview rights have been acquired for content.
+     *
+     * @since S60 v5.0
+     * @param[in] aOperationId  Identifier of the asynchronous operation
+     *                          which was returned when the asynchronous
+     *                          operation was initiated, Zero(0) if it
+     *                          is a call back from a synchronous
+     *                          operation
+     * @param[in] aError        Return status of the requested URI type
+     *                          KErrNone if successful and rights are
+     *                          available
+     *                          KErrCANoRights if the rights are not
+     *                          available
+     *                          KErrNotFound if the requested URI type was
+     *                          not available
+     */
+    virtual void PreviewRightsAvailable(
+            TInt aOperationId,
+            TInt aError ) = 0;
+
+    /**
+     * Called when silent rights have been acquired for content.
+     *
+     * @since S60 v5.0
+     * @param[in] aOperationId  Identifier of the asynchronous operation
+     *                          which was returned when the asynchronous
+     *                          operation was initiated, Zero(0) if it
+     *                          is a call back from a synchronous
+     *                          operation
+     * @param[in] aError        Return status of the requested URI type
+     *                          KErrNone if successful and rights are
+     *                          available
+     *                          KErrCANoRights if the rights are not
+     *                          available
+     *                          KErrNotFound if the requested URI type was
+     *                          not available
+     */
+    virtual void SilentRightsAvailable(
+            TInt aOperationId,
+            TInt aError ) = 0;
+
+    /**
+     * Called when rights have been acquired for content.
+     *
+     * @param[in] aOperationId  Identifier of the asynchronous operation
+     *                          which was returned when the asynchronous
+     *                          operation was initiated, Zero(0) if it
+     *                          is a call back from a synchronous
+     *                          operation
+     * @param[in] aError        Return status of the requested URI type
+     *                          KErrNone if successful and rights are
+     *                          available
+     *                          KErrCANoRights if the rights are not
+     *                          available
+     *                          KErrNotFound if the requested URI type was
+     *                          not available
+     * @since S60 v5.0
+     */
+    virtual void RightsAvailable(
+            TInt aOperationId,
+            TInt aError ) = 0;
+
+    /**
+     * Called if user selected to play embedded preview part.
+     *
+     * @since S60 v5.0
+     * @param[in] aOperationId  Identifier of the asynchronous operation
+     *                          which was returned when the asynchronous
+     *                          operation was initiated, Zero(0) if it
+     *                          is a call back from a synchronous
+     *                          operation
+     * @param[in]   aUniqueId   Unique ID of embedded preview part.
+     */
+    virtual void PlayEmbeddedPreviewSelected(
+            TInt aOperationId,
+            const TDesC& aUniqueId ) = 0;
+
+protected:
+
+    };
+    }
+
+#endif // MDRMHANDLEERROROBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/inc/drmrightsinfo.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,165 @@
+/*
+* Copyright (c) 2006-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:  Provides operations for rights information handling of DRM
+ *                content
+ *
+*/
+
+
+#ifndef CDRMRIGHTSINFO_H
+#define CDRMRIGHTSINFO_H
+
+//*** system include files go here:
+#include <e32base.h>
+#include <caf/caftypes.h>
+#include <drmutilitytypes.h>
+
+namespace DRM
+    {
+
+    //*** forward declarations go here:
+    class CDrmUtility;
+    class CDrmRightsInfoImpl;
+    class MDrmAsyncObserver;
+
+    /**
+     *  Utility class for DRM related rights information handling
+     *
+     *  @lib drmrightsinfo.lib
+     *  @since S60 v5.0
+     */
+NONSHARABLE_CLASS( CDrmRightsInfo ) : public CBase
+    {
+
+public:
+
+    /**
+     * Creates a new CDrmRightsInfo object and returns a pointer to it
+     *
+     * @return A functional CDrmRightsInfo -object
+     * @leave System wide error code
+     */
+    IMPORT_C static CDrmRightsInfo* NewL();
+
+    /**
+     * Creates a new CDrmRightsInfo object and returns a pointer to it
+     * Leaves the pointer to the cleanup stack
+     *
+     * @return A functional CDrmRightsInfo -object
+     * @leave System wide error code
+     */
+    IMPORT_C static CDrmRightsInfo* NewLC();
+
+    /**
+     * Destructor
+     */
+    virtual ~CDrmRightsInfo();
+
+
+    /**
+     * Returns a reference to a CDrmUtility instance. The ownership
+     * of the instance stays with the CDrmRightsInfo -class
+     *
+     * @since S60 v5.0
+     *
+     * @return A reference to a functional CDrmUtility instance
+     *
+     * @leave None
+     *
+     * @see CDrmUtility
+     */
+    IMPORT_C CDrmUtility& GetUtility() const;
+
+
+
+    /**
+     * Checks the rights and their status for a specific unique id
+     *
+     * @param[in]   aUniqueId   The unique identifier of the content
+     * @param[in]   aIntent     The intent for the rights to check
+     * @param[out]  aDetails    Details of the rights status
+     * @return none
+     * @leave System wide error code
+     * @see ContentAccess::TIntent
+     */
+    IMPORT_C void CheckRightsL(
+            const TDesC& aUniqueId,
+            ContentAccess::TIntent aIntent,
+            TDrmRightsInfo& aDetails );
+
+    /**
+     * Checks the rights and their status for a specific unique id
+     *
+     * @param[in]   aUniqueId   The unique identifier of the content
+     * @param[in]   aIntent     The intent for the rights to check
+     * @param[out]  aDetails    Details of the rights status, the
+     *                          details are available via this
+     *                          parameter, once the async call completes
+     *                          successfully
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave System wide error code
+     * @see ContentAccess::TIntent
+     */
+    IMPORT_C TInt CheckRightsAsyncL(
+            const TDesC& aUniqueId,
+            ContentAccess::TIntent aIntent,
+            TDrmRightsInfo& aDetails,
+            MDrmAsyncObserver& aObserver );
+
+
+    /**
+     * Cancel an asyncronous operation
+     *
+     * @since S60 v5.0
+     * @param[in]   aOperationId    identifier of the async operation
+     *                              to be cancelled
+     * @return KErrNotFound if the operation has already been executed
+     *         or it does not exist
+     */
+    IMPORT_C TInt CancelOperation( TInt aOperationId );
+
+private:
+
+    //*** private, non-derived functions go here, starting with the C++
+    //*** constructor and the Symbian second-phase constructor
+
+    CDrmRightsInfo();
+
+    void ConstructL();
+
+private: // Data members
+
+    /**
+     * Implementation class pointer
+     * Owned
+     */
+    CDrmRightsInfoImpl* iImplementation;
+
+
+    /**
+     * CDrmUtility class pointer
+     * Owned
+     */
+    CDrmUtility* iUtility;
+
+    };
+    }
+
+
+#endif // CDRMRIGHTSINFO_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/inc/drmuicheckrightsobserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,154 @@
+/*
+* Copyright (c) 2006-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:  Observer interface for CheckRightsAmount
+ *
+*/
+
+
+#ifndef MDRMUICHECKRIGHTSOBSERVER_H
+#define MDRMUICHECKRIGHTSOBSERVER_H
+
+#include <drmhandleerrorobserver.h>
+#include <drmutilitytypes.h>
+
+namespace DRM
+    {
+
+    /**
+     *  An interface containing callbacks for CDrmUiHandling::CheckRightsAmount()
+     *
+     *  By implementing these methods observer can get more information about
+     *  what kind of rights content has and can also override the default
+     *  behaviour.
+     *
+     *  @code
+     *      #include <DrmUiHandling.h>
+     *      #include <DrmUiCheckRightsObserver.h>
+     *
+     *      using namespace DRM;
+     *
+     *      // Call NewLC() to create an instance of CDrmUiHandling.
+     *      CDrmUiHandling* drmUiHandler = CDrmUiHandling::NewLC();
+     *
+     *      // Handling the error got when tried to read the file
+     *      drmHandlerError = drmUiHandler->CheckRightsAmountL( file, this );
+     *
+     *      // delete the created instance of CDrmUiHandling
+     *      CleanupStack::PopAndDestroy( drmUiHandler );
+     *
+     *      ...
+     *
+     *      // implement callbacks
+     *      TCheckRightsAction CMyClass::RightsLeft( TInt aDays, TInt aCounts, TInt aAccumulatedMinutes )
+     *          {
+     *          return ECheckRightsActionDefault;
+     *          }
+     *
+     *      TCheckRightsAction CMyClass::RightsNotValid( TCheckRightsStatus aRightsStatus )
+     *          {
+     *          return ECheckRightsActionDefault;
+     *          }
+     *
+     *  @endcode
+     *
+     *  @since S60 V5.0
+     *  @see CDrmUiHandling::CheckRightsAmount
+     */
+class MDrmUiCheckRightsObserver : public MDrmHandleErrorObserver
+    {
+
+public:
+
+    /**
+     * Tells how much rights are left
+     *
+     * @since S60 v5.0
+     * @param[in] aOperationId     Identifier of the asynchronous operation
+     *                             which was returned when the asynchronous
+     *                             operation was initiated, Zero(0) if it
+     *                             is a call back from a synchronous
+     *                             operation
+     * @param[in] aUnconstrained   ETrue, if the content either has no
+     *                             constraints or if the content is only
+     *                             for example start time based. Or the
+     *                             time left is so long that it does not
+     *                             fit to the aTime parameter's
+     *                             TTimeIntervalSeconds otherwise EFalse.
+     *
+     *                             This parameter needs to always be
+     *                             checked first, if the value is ETrue
+     *                             the other parameters: aTime, aCounts and
+     *                             aAccumulated should be ignored.
+     *
+     * @param[in] aTime            Time left in seconds. Zero(0) if
+     *                             the content does not have count
+     *                             constraint
+     * @param[in] aCounts          Counts left. Zero(0) if content
+     *                             does not have count constraint.
+     * @param[in] aAccumulated     Accumulated time left in seconds.
+     *                             Zero(0) if content does not have
+     *                             accumulated time constraint.
+     *
+     * @return ECheckRightsActionDefault DRM Utility performs the default
+     *         handling which is the handling specified in the S60 UI
+     *         specification
+     *         ECheckRightsActionOpenDetailsView Details view is opened,
+     *         no notes shown by DRM Utility
+     *         ECheckRightsActionAcquireNewRights New rights are acquired,
+     *         no notes shown by DRM Utility
+     *         ECheckRightsActionIgnore DRM Utility does not do anything
+     */
+    virtual TCheckRightsAction RightsLeft(
+            TInt aOperationId,
+            TBool aUnconstrained,
+            TTimeIntervalSeconds aTime,
+            TInt aCounts,
+            TTimeIntervalSeconds aAccumulated ) = 0;
+
+    /**
+     * Called if there are no valid rights.
+     *
+     * @since S60 v5.0
+     * @param[in] aOperationId      Identifier of the asynchronous operation
+     *                              which was returned when the asynchronous
+     *                              operation was initiated, Zero(0) if it
+     *                              is a call back from a synchronous
+     *                              operation
+     * @parem[in] aRightsStatus     The reason why rights are invalid
+     * @param[in] aReason           Rejection reason, a bitvector which
+     *                              states for what reasons rights have
+     *                              been rejected from use using
+     *                              TRejectionType
+     *
+     * @return ECheckRightsActionDefault DRM Utility performs the default
+     *         handling which is the handling specified by the S60 UI
+     *         specification
+     *         ECheckRightsActionOpenDetailsView Details view is opened,
+     *         no notes shown by DRM Utility
+     *         ECheckRightsActionAcquireNewRights New rights are acquired,
+     *         no notes shown by DRM Utility
+     *         ECheckRightsActionIgnore DRM Utility does not do anything
+     */
+    virtual TCheckRightsAction RightsNotValid(
+            TInt aOperationId,
+            TCheckRightsStatus aRightsStatus,
+            TInt aReason ) = 0;
+
+protected:
+
+    };
+    
+    }
+
+#endif // MDRMUICHECKRIGHTSOBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/inc/drmuihandling.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,522 @@
+/*
+* Copyright (c) 2006-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:  Utility API for DRM related UI
+ *
+*/
+
+
+#ifndef C_CDRMUIHANDLING_H
+#define C_CDRMUIHANDLING_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <caf/caftypes.h>
+#include <drmutilitytypes.h>
+
+//*** forward declarations go here:
+namespace ContentAccess
+    {
+    class CData;
+    }
+
+class CCoeEnv;
+
+namespace DRM
+    {
+
+    //*** forward declarations go here:
+    class CDrmUtility;
+    class MDrmErrorHandling;
+    class MDrmAsyncObserver;
+    class MDrmHandleErrorObserver;
+    class MDrmUiCheckRightsObserver;
+    class CDrmUiHandlingImpl;
+
+    /**
+     *  Utility class for DRM related UI
+     *
+     *  By using this class an application can resolve situation where there is
+     *  no valid rights for the content, check status of rights and display
+     *  an embedded rights details view.
+     *
+     *  Usage:
+     *  @code
+     *      #include <DrmUiHandling.h>
+     *
+     *      using namespace DRM;
+     *
+     *      // Call NewLC() to create an instance of CDrmUiHandling.
+     *      CDrmUiHandling* drmUiHandler = CDrmUiHandling::NewLC();
+     *
+     *      // Handling the error got when tried to read the file
+     *      drmHandlerError = drmUiHandler->HandleErrorL( file, error, NULL );
+     *
+     *      // checking the status of the rights
+     *      drmHandlerError = drmUiHandler->CheckRightsAmountL( file, NULL );
+     *
+     *      // opening embedded details view
+     *      drmHandlerError = drmUiHandler->ShowDetailsViewL( file );
+     *
+     *      // delete the created instance of CDrmUiHandling
+     *      CleanupStack::PopAndDestroy( drmUiHandler );
+     *  @endcode
+     *
+     *  @lib drmutilityuihandling.lib
+     *  @since S60 v5.0
+     */
+NONSHARABLE_CLASS( CDrmUiHandling ) : public CBase
+    {
+
+public:
+
+    /**
+     * Creates a new CDrmUiHandling object and returns a pointer to it
+     *
+     * @param aCoeEnv   A pointer to an instance of CCoeEnv. If the
+     *                  parameter is not provided the global instance
+     *                  will be used. In the case of a server process
+     *                  where the global instance is not available,
+     *                  global notes will be used.
+     *
+     *                  If no CCoeEnv instance is available, applications
+     *                  launched will be launched as standalone
+     *                  applications.
+     *
+     * @return A functional CDrmUiHandling -object
+     *
+     * @leave System wide error code
+     */
+    IMPORT_C static CDrmUiHandling* NewL( CCoeEnv* aCoeEnv = NULL );
+
+    /**
+     * Creates a new CDrmUiHandling object and returns a pointer to it
+     * Leaves the pointer to the cleanup stack
+     *
+     * @param aCoeEnv   A pointer to an instance of CCoeEnv. If the
+     *                  parameter is not provided the global instance
+     *                  will be used. In the case of a server process
+     *                  where the global instance is not available,
+     *                  global notes will be used.
+     *
+     *                  If no CCoeEnv instance is available, applications
+     *                  launched will be launched as standalone
+     *                  applications.
+     *
+     * @return A functional CDrmUiHandling -object
+     *
+     * @leave System wide error code
+     */
+
+    IMPORT_C static CDrmUiHandling* NewLC( CCoeEnv* aCoeEnv = NULL );
+
+    /**
+     * Destructor
+     */
+    virtual ~CDrmUiHandling();
+
+
+    /**
+     * Returns a reference to a CDrmUtility instance. The ownership
+     * of the instance stays with the CDrmUiHandling -class
+     *
+     * @since S60 v5.0
+     *
+     * @return A reference to a functional CDrmUtility instance
+     *
+     * @leave None
+     *
+     * @see CDrmUtility
+     */
+    IMPORT_C CDrmUtility& GetUtility() const;
+
+
+    /**
+     * Returns a reference to a class which implements the
+     * MDrmErrorHandling interface. The ownership
+     * of the instance stays with the CDrmUiHandling -class
+     *
+     * @since S60 v5.0
+     *
+     * @return A reference to a functional object implementing the
+     *         MDrmErrorHandling interface
+     *
+     * @leave None
+     *
+     * @see MDrmErrorHandling
+     */
+    IMPORT_C MDrmErrorHandling& GetErrorHandler() const;
+
+
+    /**
+     * Check how much rights there are left for the content.
+     * This method also displays appropriate notes, which observer can
+     * override, if rights are invalid. Asynchronous version, all errors
+     * are signalled using request status.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file of which rights are checked.
+     * @param[in]   aIntent     the CAF intent to be used for checking
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave System wide error code
+     *        KErrArgument  if file is not DRM protected.
+     *
+     * @see MDrmUiCheckRightsObserver
+     * @see ContentAccess::TIntent
+     */
+    IMPORT_C TInt CheckRightsAmountAsyncL(
+            RFile& aFile,
+            ContentAccess::TIntent aIntent,
+            MDrmUiCheckRightsObserver& aObserver );
+
+    /**
+     * Check how much rights there are left for the content.
+     * This method also displays appropriate notes, which observer can
+     * override, if rights are invalid. Synchronous version, leaves in case
+     * of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file of which rights are checked.
+     * @param[in]   aIntent     the CAF intent to be used for checking
+     * @param[in]   aObserver   pointer to observer, NULL if no observer
+     *
+     * @return none
+     * @leave System wide error code
+     *        KErrArgument  if file is not DRM protected.
+     *
+     * @see MDrmUiCheckRightsObserver
+     * @see ContentAccess::TIntent
+     */
+    IMPORT_C void CheckRightsAmountL(
+            RFile& aFile,
+            ContentAccess::TIntent aIntent,
+            MDrmUiCheckRightsObserver* aObserver );
+
+    /**
+     * Check how much rights there are left for the content.
+     * This method also displays appropriate notes, which observer can
+     * override, if rights are invalid. Asynchronous version, all errors
+     * are signalled using request status.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content of which rights are checked.
+     * @param[in]   aIntent     the CAF intent to be used for checking
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave System wide error code
+     *        KErrArgument  if file is not DRM protected.
+     *
+     * @see MDrmUiCheckRightsObserver
+     * @see ContentAccess::TIntent
+     */
+    IMPORT_C TInt CheckRightsAmountAsyncL(
+            ContentAccess::CData& aFile,
+            ContentAccess::TIntent aIntent,
+            MDrmUiCheckRightsObserver& aObserver );
+
+    /**
+     * Check how much rights there are left for the content.
+     * This method also displays appropriate notes, which observer can
+     * override, if rights are invalid. Synchronous version, leaves in case
+     * of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content of which rights are checked.
+     * @param[in]   aIntent     the CAF intent to be used for checking
+     * @param[in]   aObserver   pointer to observer, NULL if no observer
+     * @return none
+     * @leave System wide error code
+     *        KErrArgument  if file is not DRM protected.
+     *
+     * @see MDrmUiCheckRightsObserver
+     * @see ContentAccess::TIntent
+     */
+    IMPORT_C void CheckRightsAmountL(
+            ContentAccess::CData& aFile,
+            ContentAccess::TIntent aIntent,
+            MDrmUiCheckRightsObserver* aObserver );
+
+    /**
+     * Displays information about rights for given content.
+     * Asynchronous version.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           file for which rights details are
+     *                              displayed.
+     * @param[in]   aObserver       reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave   System wide error code
+     */
+    IMPORT_C TInt ShowDetailsViewAsyncL( RFile& aFile,
+            MDrmAsyncObserver& aObserver );
+
+    /**
+     * Displays information about rights for given content.
+     * Synchronous version, leaves in case of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       file for which rights details are
+     *                          displayed.
+     *
+     * @leave   KErrArgument    File is not DRM protected.
+     * @leave   KErrCANoRights  Rights object does not exist.
+     *
+     * @see caferr.h
+     */
+    IMPORT_C void ShowDetailsViewL( RFile& aFile );
+
+    /**
+     * Displays information about rights for given content.
+     * Asynchronous version.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile       content for which rights details are
+     *                          displayed.
+     * @param[in]   aObserver   reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave System wide error code
+     */
+    IMPORT_C TInt ShowDetailsViewAsyncL( ContentAccess::CData& aFile,
+            MDrmAsyncObserver& aObserver );
+
+    /**
+     * Displays information about rights for given content.
+     * Synchronous version, leaves in case of error.
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile   content for which rights details are displayed.
+     *
+     * @leave   KErrArgument    Content is not DRM protected.
+     * @leave   KErrCANoRights  Rights object does not exist.
+     * @leave   System wide error code
+     *
+     * @see caferr.h
+     */
+    IMPORT_C void ShowDetailsViewL( ContentAccess::CData& aFile );
+
+
+    /**
+     * Handle the specific url defined by the file, such as InfoUrl
+     * Asynchronous method
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           file whose url is being handled
+     * @param[in]   aType           type of the requested url,
+     *                              only a single url may be requested
+     *                              at a time
+     * @param[in]   aObserver       reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave   KErrArgument        File is not DRM protected.
+     * @leave   KErrNotSupported    Url type is not supported for the file
+     */
+    IMPORT_C TInt HandleUrlAsyncL(
+            RFile& aFile,
+            TDrmUiUrlType aType,
+            MDrmAsyncObserver& aObserver );
+
+
+    /**
+     * Handle the specific url defined by the file, such as InfoUrl
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile        file whose url is being handled
+     * @param[in]   aType           type of the requested url,
+     *                              only a single url may be requested
+     *                              at a time
+     *
+     * @leave   KErrArgument     File is not DRM protected.
+     * @leave   KErrNotSupported Url type is not supported for the file
+     */
+    IMPORT_C void HandleUrlL(
+            RFile& aFile,
+            TDrmUiUrlType aType );
+
+    /**
+     * Handle the specific url defined by the file, such as InfoUrl
+     * Asynchronous method
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           content whose url is being handled
+     * @param[in]   aType           type of the requested url,
+     *                              only a single url may be requested
+     *                              at a time
+     * @param[in]   aObserver       reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave   KErrArgument        File is not DRM protected,
+     *                              or multiple url:s were requested
+     * @leave   KErrNotSupported    Url type is not supported for the file
+     */
+    IMPORT_C TInt HandleUrlAsyncL(
+            ContentAccess::CData& aFile,
+            TDrmUiUrlType aType,
+            MDrmAsyncObserver& aObserver );
+
+    /**
+     * Handle the specific url defined by the file, such as InfoUrl
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile        content whose url is being handled
+     * @param[in]   aType           type of the requested url,
+     *                              only a single url may be requested
+     *                              at a time
+     *
+     * @leave   KErrArgument     File is not DRM protected.
+     * @leave   KErrNotSupported Url type is not supported for the file
+     */
+    IMPORT_C void HandleUrlL(
+            ContentAccess::CData& aFile,
+            TDrmUiUrlType aType );
+
+
+    /**
+     * Get information of the available urls
+     * Asynchronous method
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           file whose url is being handled
+     * @param[out]  aType           A bitmask of the supported url types
+     * @param[in]   aObserver       reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave   KErrArgument        File is not DRM protected.
+     */
+    IMPORT_C TInt AvailableUrlsAsyncL(
+            RFile& aFile,
+            TDrmUiUrlType& aType,
+            MDrmAsyncObserver& aObserver );
+
+    /**
+     * Get information of the available urls
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           file whose url is being handled
+     * @param[out]  aType           A bitmask of the supported url types
+     *
+     * @leave   KErrArgument        File is not DRM protected.
+     */
+    IMPORT_C void AvailableUrlsL(
+            RFile& aFile,
+            TDrmUiUrlType& aType );
+
+
+    /**
+     * Get information of the available urls
+     * Asynchronous method
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           content whose url is being handled
+     * @param[out]  aType           A bitmask of the supported url types
+     * @param[in]   aObserver       reference to observer
+     *
+     * @return Operation Identifier for the async request
+     *         required for cancelling an operation and
+     *         identifying which request has been completed
+     *
+     * @leave   KErrArgument        File is not DRM protected.
+     */
+    IMPORT_C TInt AvailableUrlsAsyncL(
+            ContentAccess::CData& aFile,
+            TDrmUiUrlType& aType,
+            MDrmAsyncObserver& aObserver );
+
+    /**
+     * Get information of the available urls
+     *
+     * @since S60 v5.0
+     * @param[in]   aFile           content whose url is being handled
+     * @param[out]  aType           A bitmask of the supported url types
+     *
+     * @leave   KErrArgument        File is not DRM protected.
+     */
+    IMPORT_C void AvailableUrlsL(
+            ContentAccess::CData& aFile,
+            TDrmUiUrlType& aType );
+
+
+    /**
+     * Cancel an asyncronous operation
+     *
+     * @since S60 v5.0
+     * @param[in]   aOperationId    identifier of the async operation
+     *                              to be cancelled
+     * @return KErrNotFound if the operation has already been executed
+     *         or it does not exist
+     */
+    IMPORT_C TInt CancelOperation( TInt aOperationId );
+
+
+private:
+    /**
+     * Default Constructor
+     */
+    CDrmUiHandling();
+
+    /**
+     * 2nd phase constructor
+     */
+    void ConstructL( CCoeEnv* aCoeEnv );
+
+private: // data
+
+    /**
+     * Pointer to the implementation
+     * Owned
+     */
+    CDrmUiHandlingImpl* iImplementation;
+
+    /**
+     * Pointer to a CDrmUtility -Instance
+     * Owned
+     */
+    CDrmUtility* iUtility;
+
+    /**
+     * Pointer to an MDrmErrorHandling interface class instance
+     * Owned
+     */
+    MDrmErrorHandling* iErrorHandler;
+
+    };
+    }
+
+
+
+#endif // C_CDRMUIHANDLING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/inc/drmutility.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,219 @@
+/*
+* Copyright (c) 2006-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:  DRM Utility base class
+ *
+*/
+
+
+#ifndef CDRMUTILITY_H
+#define CDRMUTILITY_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <drmutilitytypes.h>
+
+namespace DRM
+    {
+
+
+    /**
+     *  DRM Utility base class
+     *
+     *  Provides essential information about the DRM protection of a file
+     *  and the name of the CAF agent to be used without using CAF.
+     *
+     *  @lib drmutility.lib
+     *  @since S60 v5.0
+     */
+NONSHARABLE_CLASS( CDrmUtility ) : public CBase
+    {
+public:
+
+    /**
+     * Two-phased constructor.
+     * Creates a new CDrmUtility -object and leaves it in the cleanup stack
+     *
+     * @since S60 5.0
+     * @return A functional CDrmUtility -object
+     * @leave System wide or DRM specific error code
+     */
+    IMPORT_C static CDrmUtility* NewLC();
+
+    /**
+     * Two-phased constructor.
+     * Creates a new CDrmUtility -object
+     *
+     * @since S60 5.0
+     * @return A functional CDrmUtility -object
+     * @leave System wide or DRM specific error code
+     */
+    IMPORT_C static CDrmUtility* NewL();
+
+
+    /**
+     * Destructor.
+     */
+    virtual ~CDrmUtility();
+
+    /**
+     * Checks whether the given file belongs to a DRM protected
+     * content file
+     *
+     * @since S60 5.0
+     * @param[in]    aFileHandle Open filehandle to the file to be examined
+     * @param[out]   aAgent      Name of the agent that handles the file or
+     *                           KNullDesC if no agent is found
+     * @param[out]   aProtected  EProtected, if the default content object is
+     *                           protected
+     *                           EUnprotected, if the default content object
+     *                           is not protected
+     *
+     * @return   ETrue, if the content is handled by a DRM agent
+     *           EFalse, if the content is not handled by a DRM agent
+     *
+     * @leave    KErrBadHandle if the file handle is invalid
+     *           System wide or DRM specific error code
+     */
+    IMPORT_C TBool GetDrmInfoL( RFile& aFileHandle,
+            TPtrC& aAgent,
+            TDrmProtectionStatus& aProtected ) const;
+
+    /**
+     * Checks whether the given buffer belongs to a DRM protected
+     * content file
+     *
+     * @since S60 5.0
+     * @param[in]    aContent    Memory buffer containing the content (or part
+     *                           of it)
+     * @param[out]   aAgent      Name of the agent that handles the file or
+     *                           KNullDesC if no agent is found
+     * @param[out]   aProtected  EProtected, if the default content object is
+     *                           protected
+     *                           EUnprotected, if the default content object
+     *                           is not protected
+     *                           EUnknown, if there is not enough data to
+     *                           determine the protection status
+     *
+     * @return   ETrue, if the content is handled by a DRM agent
+     *           EFalse, if the content is not handled by a DRM agent
+     *
+     * @leave    KErrArgument if there is not sufficient amount of data
+     *           provided to the function to determine if the buffer has drm
+     *           data
+     *           System wide or DRM specific error code
+     */
+    IMPORT_C TBool GetDrmInfoL( const TDesC8& aContent,
+            TPtrC& aAgent,
+            TDrmProtectionStatus& aProtected) const;
+
+    /**
+     * Checks whether the given file is a drm content file and if it's default
+     * content object is protected or not
+     *
+     * @since S60 5.0
+     * @param[in]    aFileHandle Open filehandle to the file to be examined
+     *
+     * @return   ETrue, if the default content object is a drm content and
+     *           is protected otherwise EFalse
+     *
+     * @leave    KErrBadHandle if the file handle is invalid
+     *           System wide or DRM specific error code
+     */
+    IMPORT_C TBool IsProtectedL( RFile& aFileHandle ) const;
+
+
+    /**
+     * Checks whether the given buffer is a drm content and if it's default
+     * content object is protected or not
+     *
+     * @since S60 5.0
+     * @param[in]    aContent    Memory buffer containing the content (or part
+     *                           of it)
+     *
+     * @return   ETrue, if the default content object is a drm content and
+     *           is protected otherwise EFalse
+     *
+     * @leave    KErrArgument, if there is not sufficient amount of data
+     *           provided to the function to determine if the buffer has drm
+     *           data and the protection status
+     *           System wide or DRM specific error code
+     */
+    IMPORT_C TBool IsProtectedL( const TDesC8& aContent ) const;
+
+
+    /**
+     * Checks what agent handles the given drm content file
+     *
+     * @since S60 5.0
+     * @param[in]    aFileHandle Open filehandle to the file to be examined
+     * @param[out]   aAgent      Name of the agent that handles the file
+     *
+     * @return   ETrue, if the content is handled by a DRM agent
+     *           EFalse, if the content is not handled by a DRM agent
+     *
+     * @leave    KErrBadHandle if the file handle is invalid
+     *           System wide or DRM specific error code
+     */
+    IMPORT_C TBool GetAgentL( RFile& aFileHandle,
+            TPtrC& aAgent ) const;
+
+    /**
+     * Checks what agent handles the given drm content buffer
+     *
+     * @since S60 5.0
+     * @param[in]    aContent    Memory buffer containg the file (or part of it)
+     * @param[out]   aAgent      Name of the agent that handles the file
+     *
+     * @return   ETrue, if the content is handled by a DRM agent
+     *           EFalse, if the content is not handled by a DRM agent
+     *
+     * @leave    KErrArgument, if there is not sufficient amount of data
+     *           provided to the function to determine if the buffer has drm
+     *           data
+     *           System wide or DRM specific error code
+     */
+    IMPORT_C TBool GetAgentL( const TDesC8& aContent,
+            TPtrC& aAgent ) const;
+
+    /**
+     * Checks if the given file handle is valid
+     *
+     * @since S60 5.0
+     * @param[in]   aFileHandle Filehandle to be examined
+     *
+     * @return   None
+     *
+     * @leave KErrBadHandle if the filehandle is invalid
+     */
+    IMPORT_C void CheckFileHandleL( RFile& aFileHandle ) const;
+
+private:
+    /**
+     * C++ default constructor.
+     */
+    CDrmUtility();
+
+    // Oma based extensions    
+    void FetchOmaBasedInfoL();
+    
+    void ConstructL();
+      
+    HBufC* iOmaBasedAgentName;
+    HBufC8* iOmaBasedMimeType;
+
+    };
+    }
+
+
+#endif // CDRMUTILITY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/drm_utility_api/inc/drmutilitytypes.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,245 @@
+/*
+* 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:  Enumerations and constants used in the DRM Utility
+ *
+*/
+
+
+#ifndef DRMUTILITYTYPES_H
+#define DRMUTILITYTYPES_H
+
+namespace DRM
+    {
+
+    /*** Names:
+
+      EAU = Automated usage
+      EUH = UI handling
+      ERI = Rights Info
+      EU  = Utility / Common
+
+     ***/
+
+
+    /** Automated usage types */
+    enum TDrmAutomatedType
+        {
+        //This is a new type
+        EAUAutomatedTypeVideoRingingTone,
+        //These are from TDRMHelperAutomatedType
+        EAUAutomatedTypeRingingTone,
+        EAUAutomatedTypeMessageAlert,
+        EAUAutomatedTypeEmailAlert,
+        EAUAutomatedTypeIMAlert,
+        EAUAutomatedTypeCalendarAlarm,
+        EAUAutomatedTypeScreenSaver,
+        EAUAutomatedTypeWallpaper,
+        EAUAutomatedTypeTheme,
+        EAUAutomatedTypeClockAlarm,
+        EAUAutomatedTypeOther = KMaxTUint8
+        };
+
+
+    /**
+     * Automated service types
+     *     EAUActive   registering application listens to expiry notifications
+     *     EAUPassive  registering application does not listen to expiry
+     *                 notifications
+     */
+    enum TDrmAutomatedServiceType
+        {
+        EAUPassive = 0,
+        EAUActive
+        };
+
+
+
+    /**  Automated usage events */
+    enum TAutomatedUsageEvent
+        {
+        EAUAutomatedContentSetOK = 0,             // Content was successfully
+                                                  // set as automated
+        EAUAutomatedContentExpired = 1,           // Automated content was
+                                                  // expired, remove from use
+        EAUAutomatedContentIdleAfterExpired = 2,  // idle was activated, remove
+                                                  // from automated usage.
+        EAUxxx = 3
+        };
+
+    /**  Return code to indicate how to proceed */
+    enum TAutomatedUsageAction
+        {
+        EAUActionIgnore = KErrNotFound, // Nothing to be done.
+        EAUActionDefault = 0,           // DRM Utility performs default
+                                        // handling
+        EAUActionRightsAquisition = 1,  // Purchase new rights for the
+                                        // automated content
+        EAUActionClientHandles = 2      // client takes care of everything.
+        };
+
+
+    /**
+     * Return code to indicate how to proceed when embedded preview is
+     * available
+     */
+    enum TEmbeddedPreviewAction
+        {
+        EUEmbeddedPreviewActionDefault,      // < DRM Utility asks if user wants
+                                             //   to play preview or acquire new
+                                             //   rights
+        EUEmbeddedPreviewActionDefaultAudio, // < DRM Utility asks if user wants
+                                             //   to play preview or acquire new
+                                             //   rights for audio
+        EUEmbeddedPreviewActionDefaultVideo, // < DRM Utility asks if user wants
+                                             //   to play preview or acquire new
+                                             //   rights for video
+        EUEmbeddedPreviewActionFetchRights,  // < DRM Utility acquires new
+                                             //   rights, no query shown
+        EUEmbeddedPreviewActionPlayPreview,  // < Observer takes care of playing
+                                             //   preview
+        EUEmbeddedPreviewActionIgnore        // < Nothing to be done.
+        };
+
+    /**
+     * Return code to indicate how to proceed when preview rights are
+     * available
+     */
+    enum TPreviewRightsAction
+        {
+        EUPreviewRightsActionDefault,        // < DRM Utility asks if user wants
+                                             //   to acquire preview rights or
+                                             //   normal rights and acquires them
+        EUPreviewRightsActionDefaultAudio,   // < DRM Utility asks if user wants
+                                             //   to acquire preview rights or
+                                             //   normal rights for audio and 
+                                             //   acquires them
+        EUPreviewRightsActionDefaultVideo,   // < DRM Utility asks if user wants
+                                             //   to acquire preview rights or
+                                             //   normal rights for video and
+                                             //   acquires them
+        EUPreviewRightsActionFetchRights,    // < DRM Utility acquires normal
+                                             //   rights, no query shown
+        EUPreviewRightsActionFetchPreviewRights,  // < Observer acquires
+                                                  //   preview rights
+        EUPreviewRightsActionIgnore          // < Nothing to be done
+        };
+
+    /**
+     * Return code to indicate how to proceed when silent rights are
+     * available
+     */
+    enum TSilentRightsAction
+        {
+        EUSilentRightsActionDefault,           // < DRM Utility performs the
+                                               //   default silent rights 
+                                               //   handling
+        EUSilentRightsActionFetchRights,       // < DRM Utility acquires normal
+                                               //   rights
+        EUSilentRightsActionFetchSilentRights, // < Observer acquires silent
+                                               //   rights
+        EUSilentRightsActionIgnore             // < Nothing to be done
+        };
+
+    /**
+     * Return code to indicate how to proceed when rights are
+     * available
+     */
+    enum TRightsAction
+        {
+        EURightsActionDefault,       // < DRM Utility performs the default
+                                     //   rights handling
+        EURightsActionFetchRights,   // < DRM Utility acquires normal rights
+        EURightsActionIgnore         // < Nothing to be done
+        };
+
+    /**
+     * Information about rights status
+     */
+    enum TDrmRightsInfo
+        {
+        EURightsInfoValid = 0,
+        EURightsInfoExpired = 1,
+        EURightsInfoMissing = 2,
+        EURightsInfoFuture = 3,
+        };
+
+
+
+    /**  Return code to indicate how to proceed */
+    enum TCheckRightsAction
+        {
+        EUHCheckRightsActionDefault,          // < DRM Utility performs the
+                                              //   default handling
+        EUHCheckRightsActionOpenDetailsView,  // < Details view is opened, no
+                                              //   notes shown by DRM Utility
+        EUHCheckRightsActionAcquireNewRights, // < New rights are acquired, no
+                                              //   notes shown by DRM Utility
+        EUHCheckRightsActionAcquirePreviewRights, // < Preview rights are
+                                                  //   acquired, no notes shown 
+                                                  //   by DRM Utility
+        EUHCheckRightsActionIgnore            // < DRM Utility does not do
+                                              //   anything and stops the
+                                              //   operation
+        };
+
+    /**  Reason why rights are not valid */
+    enum TCheckRightsStatus
+        {
+        EUHCheckRightsExpiredRights,  // < Rights have been expired
+        EUHCheckRightsNoRights,       // < No rights at all
+        EUHCheckRightsFutureRights    // < Rights will become valid in future
+        };
+
+
+    /** Url types for HandleUrl */
+    enum TDrmUiUrlType
+        {
+        EUHRightsIssuerUrl   = 0x00000001,
+        EUHPreviewRightsUrl  = 0x00000002,
+        EUHSilentRightsUrl   = 0x00000004,
+        EUHInfoUrl           = 0x00000008,
+        EUHDomainRiUrl       = 0x00000010
+        };
+
+    /** Protection status of the drm content */
+    enum TDrmProtectionStatus
+        {
+        EUUnknown = KErrUnknown,
+        EUUnprotected = 0,
+        EUProtected = 1
+        };
+
+
+    // Rejection reason
+    enum TRejectionType
+        {
+        EURejectionNone         = 0x00000000,
+        EURejectionStartTime    = 0x00000001,
+        EURejectionEndTime      = 0x00000002,
+        EURejectionInterval     = 0x00000004,
+        EURejectionCounter      = 0x00000008,
+        EURejectionTopLevel     = 0x00000010,
+        EURejectionTimedCounter = 0x00000020,
+        EURejectionAccumulated  = 0x00000040,
+        EURejectionIndividual   = 0x00000080,
+        EURejectionSystem       = 0x00000100,
+        EURejectionVendor       = 0x00000200,
+        EURejectionSoftware     = 0x00000400,
+        EURejectionMetering     = 0x00000800,
+        EURejectionDrmTime      = 0x10000000
+        };
+
+    }
+
+#endif // DRMUTILITYTYPES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Includes all the Domain API specific bld.inf files, which
+*                export files.
+*
+*/
+
+
+
+#include "../roap_api/group/bld.inf"
+#include "../drm_common_api/group/bld.inf"
+#include "../drm_rights_api/group/bld.inf"
+#include "../drm_legacy_api/group/bld.inf"
+#include "../dcf_repository_api/group/bld.inf"
+#include "../drm_service_api/group/bld.inf"
+#include "../drm_secondary_display_api/group/bld.inf"
+#include "../drm_license_manager_api/group/bld.inf"
+#include "../drm_utility_api/group/bld.inf"
+#include "../drm_agents_api/group/bld.inf"
+#include "../wmdrm_core_api/group/bld.inf"
+#include "../wmdrm_access_api/group/bld.inf"
+
+#if (defined __WINDOWS_MEDIA_DRM)
+#include "../camese_utility_api/group/bld.inf"
+#include "../camese_framework_api/group/bld.inf"
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  File that exports the files belonging to 
+:                ROAP API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/RoapEng.h     MW_LAYER_PLATFORM_EXPORT_PATH(RoapEng.h)
+../inc/RoapEngBase.h     MW_LAYER_PLATFORM_EXPORT_PATH(RoapEngBase.h)
+../inc/RoapTrigger.h     MW_LAYER_PLATFORM_EXPORT_PATH(RoapTrigger.h)
+../inc/RoapObserver.h     MW_LAYER_PLATFORM_EXPORT_PATH(RoapObserver.h)
+../inc/RoapMessage.h     MW_LAYER_PLATFORM_EXPORT_PATH(RoapMessage.h)
+../inc/RoapDef.h     MW_LAYER_PLATFORM_EXPORT_PATH(RoapDef.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/inc/RoapDef.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef ROAP_DEF_H
+#define ROAP_DEF_H
+
+#include <e32def.h>
+
+// MIME-TYPES
+
+// The content type for ROAP protocol data unit
+_LIT8( KRoapPDUType, "application/vnd.oma.drm.roap-pdu+xml" );
+
+// The content type for multipart-mixed 
+_LIT8( KMultipartMixedType, "multipart/mixed" );
+
+// The content type for multipart-related 
+_LIT8( KMultipartRelatedType, "multipart/related" );
+
+_LIT8( KRoapVersion, "1.0" );
+
+_LIT8( KRoapCmlaRootHash, "GUZDJRYDWAs7KB4Wz7uz2K58WtA=" );
+_LIT8( KRoapCmlaRnDRootHashOld, "lipo7D75LumzfXEnbiCIdlmHvKE=" );
+_LIT8( KRoapCmlaRnDRootHash, "lrfbGaTQWkvI46UciFCI5nk1RGk=" );
+
+
+LOCAL_D const TInt KRoapTransIdLength = 16;
+// Amout of algorithms
+LOCAL_D const TInt KRoapAlgorithmCount = 7;
+
+_LIT(KOmaDrmOid, "2.23.43.6");
+_LIT(KOmaKpOid, "2.23.43.6.1");
+_LIT(KOmaKpRightsIssuerOid, "2.23.43.6.1.1");
+_LIT(KOmaKpDrmAgentOid, "2.23.43.6.1.1");
+
+// ROAP ERROR CODES
+
+LOCAL_D const TInt KErrRoapGeneral = -30341;
+
+LOCAL_D const TInt KErrRoapUnsupported = -30342;
+
+LOCAL_D const TInt KErrRoapServer = -30343;
+
+LOCAL_D const TInt KErrRoapServerFatal = -30344;
+
+LOCAL_D const TInt KErrRoapDevice = -30345;
+
+LOCAL_D const TInt KErrRoapInvalidDomain = -30346;
+
+LOCAL_D const TInt KErrRoapDomainFull = -30347;
+
+LOCAL_D const TInt KErrRoapNotRegistered = -30348;
+
+// ROAP protocol phases
+
+LOCAL_D const TInt KRoapProgressDelta = 1024;
+LOCAL_D const TInt KRoapProgressMax = 8192;
+
+enum
+		{
+		KErrRoapPermanent = 1,
+		KErrRoapTemporary = 2
+		};
+
+enum
+    {
+    ERoapStarted = 1,
+    ERoapRegistering = 2,
+    ERightsAcquisition = 3,
+    EDomainJoining = 4,
+    EDomainLeaving = 5,
+    ERoapCompleted = 6,
+    ERoapError = 7
+    };
+    
+// ROAP features
+// #define _DISABLE_SIGNATURE_CHECK
+// #define _DISABLE_OCSP_CHECK
+// #define _DISABLE_CERT_CHECK
+// #define _DISABLE_HASH_CHAIN_GENERATION // Use of Hash Chains for Domain Key Generation
+#define _DISABLE_DRM_TIME_UPDATE_CHECK // Checks that the OCSP responder's cert chain is signed by CMLA
+
+#endif // ROAP_DEF_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/inc/RoapEng.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,235 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#ifndef ROAP_ENG_H
+#define ROAP_ENG_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <hash.h>
+
+#include <RoapMessage.h>
+#include <RoapEngBase.h>
+#include <Oma2Agent.h>
+
+// FORWARD DECLARATIONS
+class CDrmProtectedRoParser;
+class RDRMClockClient;
+class CDcfRep;
+class CX509Certificate;
+class COCSPResponse;
+
+namespace Roap
+{
+class CRoapParser;
+class CRoapSigner;
+class CRIHello;
+class CRegistrationResp;
+class CRightsResp;
+class CJoinDomainResp;
+class CLeaveDomainResp;
+class RRoapStorageClient;
+
+
+// CLASS DECLARATION
+class CRoapEng: public CRoapEngBase
+    {
+
+    public:     // Constructors and destructor
+
+         /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CRoapEng* NewL( );
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C ~CRoapEng();
+
+    protected:
+    
+        // Needed in trigger parsing phase
+
+        CRoapTrigger* ParseTriggerL( const TDesC8& aXmlTrigger );
+
+        void GetRIContextL( TBool& aRegistered, const TDesC8& aRiId );
+        
+        void  GetDomainContextL( TBool& aIsJoined,
+                                 TBool& aIsValidGeneration,
+                                 const TDesC8& aDomainId );
+
+        
+        
+        // For creating ROAP requests
+        
+        void CreateReqMessageL();
+        
+        CRoapMessage* CreateDeviceHelloL();
+        
+        CRoapMessage* CreateRegistrationRequestL();
+        
+        CRoapMessage* CreateRightsRequestL();
+        
+        CRoapMessage* CreateJoinDomainRequestL();
+        
+        CRoapMessage* CreateLeaveDomainRequestL();
+        
+        CRoapMessage* CreateMeteringReportRequestL();
+        
+        
+        // For handling ROAP responses
+        
+        void HandleRoapResponseL( const TDesC8& aXmlResponse );
+        
+        void HandleRIHelloPduL( const TDesC8& aRiHello );
+        
+        void HandleReqResponsePduL( const TDesC8& aRegResp );
+        
+        void HandleRightsResponsePduL( const TDesC8& aRightsResp, TBool aOnePass );
+        
+        void HandleJoinDomainResponsePduL( const TDesC8& aJoinResp );
+        
+        void HandleLeaveDomainResponsePduL( const TDesC8& aLeaveResp );
+        
+        void HandleMeteringReportResponsePduL( const TDesC8& aMeteringResp );
+                 
+        void HandleMultipartL();
+        
+        
+        // For signing and certificate checking
+        
+        HBufC8* SignMessageL( const TDesC8& aMessage ) const;
+        
+        TBool VerifySignatureL( const TDesC8& aMessage,
+                                const TDesC8& aSignature,
+                                const RPointerArray< HBufC8 >& aCertificateChain ) const;
+                                
+        TBool VerifyTriggerSignatureL( const TDesC8& aXmlTrigger,
+                                         const CRoapTrigger& aTrigger  ) const;
+                                
+        TBool VerifyCertificateChainL( const RPointerArray< HBufC8 >& aCertificateChain,
+                                       const RPointerArray< HBufC8 >& aOcspResponses ) const;
+                                       
+        TBool VerifyOcspResponsesL( const RPointerArray< HBufC8 >& aOcspResponses,
+                                    const TDesC8& aRiCaCert,
+                                    const RPointerArray< HBufC8 >& aCertSerialNums ) const;
+                                    
+        TBool VerifyOcspCertChainL( COCSPResponse& aResponse,
+                                    const TDesC8& aRootCert,
+                                    CX509Certificate*& aOcspCert ) const;
+                                    
+        TBool ValidateRiCertificateL( const CX509Certificate* aCert );
+
+
+        // For fetching data for ROAP requests
+        
+		RPointerArray<HBufC8> GetCertificateChainL() const;
+		
+		RPointerArray<HBufC8> GetSupportedAlgorithmsL() const;
+		
+		void GetDeviceDetailsL( HBufC8*& aManufacturer,
+                                HBufC8*& aModel,
+                                HBufC8*& aVersion );
+                                         
+        HBufC8* GetOCSPResponderKeyHashL() const;
+                                
+        
+        // For transaction tracking
+        
+        void FetchTransactionIDL( RPointerArray<HBufC8>& aTransIDs,
+                                  RPointerArray<HBufC8>& aContentIDs );
+        
+        void InsertTransactionIDL( RPointerArray<HBufC8>& aTransIDs,
+                                   RPointerArray<HBufC8>& aContentIDs );
+
+        
+        // For fetching and setting DRM Time
+        
+        TTime GetDrmTimeL();
+        
+        void SetDrmTimeSecureL();
+        
+        void AdjustDrmTimeL(  const RPointerArray< HBufC8 >& aOcspResponses,
+                             TDesC8& aRegReqNonce ) const;
+                             
+                             
+        // For storing a Domain RO in implicit Join Domain case
+        void StoreDomainRightsL();
+        
+        // Inserting domain ROs after receiving                     
+        void InsertDomainRosL();
+
+        // For mapping ROAP status to error code
+        TInt MapStatusL();
+        
+        // For checking is the root certificate issued by CMLA
+        void IsTimeUpdateAllowedL( const RPointerArray<HBufC8>& aCertChain,
+                                   const RPointerArray<HBufC8>& aOcspResponses,
+                                   TBool& aIsAllowed ) const;
+      
+          
+        TBool ValidateRiIdL( TDesC8& aRiId, TDesC8& aCertBuf );
+   
+                // Update the status of transaction tracking variable	     
+        void UpdateTransactionTrackingStatusL();
+        
+        // Creates list of device IDs for Multi-PKI
+        TInt CreateDeviceIdHashArrayL( RPointerArray<TDesC8>& aIdArray);
+          
+    private:
+
+        CRoapEng();
+        
+        void ConstructL();
+        
+        enum TTransStatus
+            {
+            ENotAsked,
+            EForbidden,
+            EAllowed
+            };
+        
+    private:
+    
+    	CRoapParser* iParser;
+    	CRoapSigner* iSigner;
+    	RRoapStorageClient* iStorageClient;
+    	RDRMClockClient* iClockClient;
+    	CDcfRep* iDcfRep;
+    	TInt iRoapStatus;
+    	CDrmProtectedRoParser* iRoParser;  	
+    	TBool iCertNeeded;
+    	TBool iRiSupportsCertCaching;
+    	HBufC8* iDeviceId;
+    	TTransStatus iTransStatus;
+    	TKeyTransportScheme iSelectedAlgorithms;
+    	TBuf8< SHA1_HASH > iSelectedRoot;
+    	TBuf8< KDomainIdLength > iDomainId;
+    	TBuf8< SHA1_HASH > iRiId;
+        TBuf8< KMaxRoapVersionLength > iRiVersion;
+        RPointerArray< HBufC8 > iRiAlgorithms;
+        TBool iDeviceTimeError;
+        TBuf8< KDeviceNonceLength > iRegReqNonce; // for DRM Time sync
+        TBool iSecureTime;
+        TInt iZone;
+    };
+}
+
+#endif /* def ROAP_ENG_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/inc/RoapEngBase.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,296 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#ifndef ROAP_ENG_BASE_H
+#define ROAP_ENG_BASE_H
+
+// INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include <apmrec.h>
+#include <apparc.h>
+
+class CAiwGenericParamList;
+class CDRMRights;
+class CDRMRIContext;
+
+namespace Roap
+{
+// FORWARD DECLARATION
+
+class CRoapTrigger;
+class CRoapHttpHandler;
+class CRoapResponse;
+class CRoapMessage;
+class MRoapObserver;
+
+// CLASS DECLARATION
+
+enum TTriggerType
+    {
+    ERegistrationTrigger,
+    ERoAcquisitionTrigger,
+    EJoinDomainTrigger,
+    ELeaveDomainTrigger,
+    EExtendedTrigger,
+    EMeteringReportTrigger
+    };
+    
+enum TRiContextStatus
+    {
+    EValidContext,
+    EInvalidContext,
+    EInvalidContextNoConf    
+    };
+    
+enum TDomainOperation
+    {
+    ENotDomainOperation,
+    EJoinDomainOperation,
+    EKeyUpgradeOperation
+    };
+    
+
+class CRoapEngBase: public CActive
+    {
+    public:
+
+        enum TRoapState         
+            {
+            EInit,                           
+            EReady,                 
+            ECreateConn,           
+            EStartTrans,
+            ERespReceived,           
+            EComplete           
+            };
+            
+		enum TRequestType
+			{
+			EDeviceHello,
+			ERegistration,          
+			EROAcquisition,
+			EJoinDomain,
+			ELeaveDomain,
+			EMeteringRequest
+			};
+
+
+    public: // destructor
+     
+        IMPORT_C virtual ~CRoapEngBase();
+
+    public:
+    
+        /**
+        * SetTriggerL
+        * 
+        * The function takes in a ROAP Trigger and parses it. The the internal state
+        * of ROAP Engine is changed accordingly. After the trigger is set a caller
+        * can either accept the ROAP transaction by calling AcceptL or reject by calling
+        * Reject. 
+        * 
+        * @since  3.0
+        * @param  aXmlTrigger:    An ROAP Trigger in XML format
+        *
+        * @param  aParamList:     Generic paramaters from application that lauched the ROAP UI
+        *                         Can contain e.g. access point etc.
+        *
+        * @param  aType:          On return, defines the type of the parsed trigger
+        *
+        * @param  aContextStatus: On return, indicates if the Device has stored a valid
+        *                         RI context or not
+        *
+        * @param  aDomainOper:    On return, in the case of Join Domain protocol indicates
+        *                         the intended Domain operation. Join Domain or Key upgrade.                             
+        *
+        * @param  aContentIdList: Out parameter. ContentIDs that are related to  the
+        *                         RO acquisition. Can be used e.g. for opening the
+        *                         content file after the ROAP has succesfully finished.
+        *                         The elements inside the array must be deleted by the
+        *                         caller
+        *
+        * @leave  System wide error code
+        */
+        
+        IMPORT_C void SetTriggerL( const TDesC8& aXmlTrigger,
+                                   const CAiwGenericParamList* aParamList,        
+                                   TTriggerType& aType,
+                                   TRiContextStatus& aContextStatus,
+                                   TDomainOperation& aDomainOperation,
+                                   RPointerArray<HBufC8>& aContentIdList );
+        /**
+        * AcceptL
+        *
+        * The function starts the ROAP operation. SetTriggerL must be called successfully 
+        * before calling this function. 
+        * 
+        * @since  3.0
+        * @param  aObserver: An observer object. Can be NULL if the observer is not needed.
+        *
+        * @param  aStatus:   Indicates the completion status of ROAP. Contains an error code or
+        *                    KErrNone is everything worked ok.
+        *
+        * @leave  System wide error code
+        */        
+
+        IMPORT_C void AcceptL( MRoapObserver* aObserver, TRequestStatus* aStatus );
+        
+        /**
+        * Reject
+        *
+        * The function cancels the ROAP operation. The initial state (as it was before calling
+        * SetTriggerL) is restored. The function handles cleanup of stored data internally
+        * (by calling the DoCleanupL method)
+        * 
+        * @since  3.0
+        */        
+
+        IMPORT_C void Reject();
+        
+        /**
+        * DoCleanup
+        *
+        * The function deletes the data that has been stored during the last ROAP processing.
+        * The asynchronous AcceptL call must be finished before it is useful to call this method.
+        * 
+        * @since  3.0
+        *
+        * @return System wide error code
+        */    
+        
+        IMPORT_C TInt DoCleanup();   
+        
+        /**
+        * HandleRoReponseL
+        * 
+        * The function is for handling the 1-pass RO acquisition case. Takes in RO response
+        * PDU and parses it and stores the Rights Object into the database.
+        *
+        * @since  3.0
+        * @param  aResponse:     RO acquisition response PDU in XML format.
+        * @param  aParsedRights: Out parameter. Contains pointers to stored ROs. The array
+        *                        contents are owned by a caller. If the function leaves
+        *                        the caller must cleanup and close aParsedRights
+        *
+        * @leave  System wide error code
+        */        
+        
+        IMPORT_C void HandleRoReponseL( const TDesC8& aResponse, RPointerArray<CDRMRights>& aParsedRights );  
+        
+
+        /**
+        * Trigger
+        * 
+        * The function returns a reference to the parsed CRoapTrigger object. The SetTriggerL
+        * method must be called successfully before this method can be called. 
+        *
+        * @since  3.0
+        *
+        * @return Parsed CRoapTrigger obejct. 
+        */ 
+
+        IMPORT_C const CRoapTrigger& Trigger() const;
+            
+    protected:  // Constructors
+      
+        CRoapEngBase();
+        
+        void ConstructL();
+            
+        
+    protected:  // from CActive
+
+        virtual void DoCancel();
+
+        virtual void RunL();
+
+        virtual TInt RunError( TInt aError );
+
+
+    protected:
+
+        void SetL();
+
+        void CreateConnectionL();
+
+        void StartTransactionL();
+
+        void HandleResponseL();
+      
+        void SetProtocolL();
+        
+        void CompleteL();
+        
+        void CompleteRequest();
+        
+        void Continue( TRoapState aNextState );
+
+
+    protected:
+
+        virtual CRoapTrigger* ParseTriggerL( const TDesC8& aXmlTrigger ) = 0;
+
+        virtual void GetRIContextL( TBool& aRegistered, const TDesC8& aRiId ) = 0;
+        
+        virtual void  GetDomainContextL( TBool& aIsJoined,
+                                         TBool& aIsValidGeneration,
+                                         const TDesC8& aDomainId ) = 0;
+
+        virtual void CreateReqMessageL() = 0;
+        
+        virtual	void HandleRoapResponseL( const TDesC8& aXmlResponse ) = 0;
+        
+        virtual void HandleRightsResponsePduL( const TDesC8& aRightsResp,  TBool aOnePass ) = 0;
+        
+        virtual	void HandleMultipartL() = 0;
+        
+        virtual HBufC8* SignMessageL( const TDesC8& aMessage ) const = 0;
+        
+        virtual TInt MapStatusL() = 0;
+
+
+    protected:
+
+        CRoapTrigger* iTrigger;
+        CRoapMessage* iRequest;
+        CRoapMessage* iResponse;
+        CRoapHttpHandler* iHttpHandler;
+        CRoapResponse* iRoapResp;
+        CDRMRIContext* iStoredRiContext;
+        TRoapState iState;
+        TInt iStatusCode;
+        TInt iResult;
+        TRequestStatus* iParentStatus;
+        TUint32 iPreferredIap;
+        TRequestType iReqMessage;
+        TBool iCompleted;
+        MRoapObserver* iObserver;
+        TBool iTransTrackConf;
+        RPointerArray<CDRMRights> iReturnedROs;
+        TBool iAllowedToContactRi;
+        TBool iUseRiContextUrl;
+        TBool iImplicitJoinDomain;
+        HBufC8* iDomainRightsResp; // for the implicit Join Domain
+        TInt iProgressInBytes;
+        TBool iReRegistered;
+        HBufC8* iRiAlias;
+    };
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/inc/RoapMessage.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,197 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef ROAPMESSAGE_H
+#define ROAPMESSAGE_H
+
+
+//  INCLUDES
+//#include <?include_file>
+// #include <DrmRightsClient.h>
+
+class CBufFlat;
+
+namespace Roap
+{
+
+// CONSTANTS
+const TInt KMaxRoapVersionLength = 10;
+const TInt KDeviceNonceLength = 32;
+const TInt KDomainIdLength = 20;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+enum TRoapStatus
+    {
+    ESuccess,
+    EUnknownError,
+    EAbort,
+    ENotSupported,
+    EAccessDenied,
+    ENotFound,
+    EMalformedRequest,
+    EUnknownRequest,
+    EUnknownCriticalExtension,
+    EUnsupportedVersion,
+    EUnsupportedAlgorithm,
+    ENoCertificateChain,
+    EInvalidCertificateChain,
+    ETrustedRootCertificateNotPresent,
+    ESignatureError,
+    EDeviceTimeError,
+    ENotRegistered,
+    EInvalidDCFHash,
+    EInvalidDomain,
+    EDomainFull,
+	EDomainAccessDenied,
+	ERightsExpired,
+    EMalformedMeteringReport,
+    EUnableToDecryptMeteringReport,
+    EUnableToValidateMeteringReportMAC,
+    EUnknownStatus = -1,
+    };
+
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CRoapMessage : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CRoapMessage* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CRoapMessage();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        virtual HBufC8* MessageAsXmlL(void);
+        void SetXmlData(HBufC8*);
+        static HBufC8* TimeToIso8601L(TTime& aTime);
+        static TTime Iso8601ToTime(TDesC8& aTimeString);
+        static void BufAppendL(CBufFlat* aBuffer, const TDesC8& aConst);
+        static void BufAppendBase64L(CBufFlat* aBuffer, const TDesC8& aConst);
+        static void BufAppendTimeL(CBufFlat* aBuffer, TTime& aTime);
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+        /**
+        * C++ default constructor.
+        */
+        CRoapMessage();
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+    private:
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CRoapMessage( const CRoapMessage& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CRoapMessage& operator=( const CRoapMessage& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        HBufC8* iXmlData;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // ROAPMESSAGE_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/inc/RoapObserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,192 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ROAP observer interface
+*
+*/
+
+
+
+#ifndef ROAP_OBSERVER_H
+#define ROAP_OBSERVER_H
+
+
+// FORWARD DECLARATIONS
+class CDRMRights;
+
+// CLASS DECLARATION
+
+/**
+*  An interface containing callback methods for ROAP transaction
+*
+*  @since 3.0
+*/
+
+namespace Roap
+    {
+    class MRoapObserver
+        {
+        public:
+
+        /**
+        * ConnectionConfL
+        *
+        * The function is called by ROAP engine when a network connection is to
+        * be established. Return value ETrue indicates to the ROAP engine that
+        * the user consent has been retrieved to create the network connection.
+        *
+        * @since  3.0
+        *
+        * @return ETrue: the network can be establish
+        *         EFalse: the ROAP transaction is canceled
+        *
+        * @leave  System wide error code */
+
+        virtual TBool ConnectionConfL() = 0;
+
+        /**
+        * ContactRiConfL
+        *
+        *
+        * @since  3.0
+        *
+        * @return ETrue: the user consent is achieved
+        *         EFalse: the user consent is not achieved
+        *
+        * @leave  System wide error code */
+
+        virtual TBool ContactRiConfL() = 0;
+
+        /**
+        * TransIdConfL
+        *
+        * The function is called during RO acquisition when the ROAP engine wants
+        * to perform trasaction tracking. The user conset must be asked before
+        * the operation.
+        *
+        * @since  3.0
+        *
+        * @return ETrue: the user consent is achieved
+        *         EFalse: the user consent is not achieved
+        *
+        * @leave  System wide error code */
+
+        virtual TBool TransIdConfL() = 0;
+
+        /**
+        * RightsObjectDetailsL
+        *
+        * The function is called after successful completion of RO acquisition
+        * protocol. The passes information about stored rights objects to the
+        * observer.
+        *
+        * @since  3.0
+        * @param aRightsList: A list of pointers to rights objects.
+        *                     Contents of aRightsList are owend by ROAP engine
+        *
+        * @leave  System wide error code */
+
+        virtual void RightsObjectDetailsL( const RPointerArray<CDRMRights>& aRightsList ) = 0;
+
+        /**
+        * ContentDownloadInfoL
+        *
+        * The function is called when the ROAP engine notices that it is about to
+        * receive a multipart content as a ROAP response. The method must return via
+        * out-parameter the path to a temp folder where the content is saved during
+        * download. The name that is used as filename when saving the content to
+        * the appropriate palce and the maximum size of the content (a safety upper limit)
+        * must also be provided via out-parameters.
+        *
+        * @since 3.0
+        * @param aTempFolder: (out-param) The path of the temp folder, or KNullDesC
+        * @param aContentName: (out-param) The name of the content, or KNullDesC (defaut name is used)
+        * @param aMaxSize: (out-param) The maximum size of the content, or -1 if not known
+        *
+        * @leave System wide error code */
+
+        virtual void ContentDownloadInfoL( TPath& aTempFolder,
+                                           TFileName& aContentName,
+                                           TInt& aMaxSize ) = 0;
+
+        /**
+        * ContentDetailsL
+        *
+        * The function is called when the ROAP engine has received a DCF content (together
+        * with a ROAP response) The ROAP engine saves the DCF to the appropriate location
+        * and gives out the information about the saved DCF file by calling this method
+        *
+        * @since 3.0
+        * @param aPath: The path andf the filename of the saved DCF file
+        * @param aType: The plain MIME type of the saved DCF file
+        * @param aAppUid: The handler app UID of the saved DCF file
+        *
+        * @leave System wide error code */
+
+        virtual void ContentDetailsL( const TDesC& aPath,
+                                      const TDesC8& aType,
+                                      const TUid& aAppUid ) = 0;
+
+        /**
+        * RoapProgressInfoL
+        *
+        * The function provides progress information about ROAP processing to the
+        * observer
+        *
+        * @since  3.0
+        * @param aProgressInfo: An integer value representing the state of
+        *                       ROAP processing, counting in bytes
+        *
+        * @leave  System wide error code */
+
+        virtual void RoapProgressInfoL( const TInt aProgressInfo ) = 0;
+
+        /**
+        * ErrorUrlL
+        *
+        * The function is called in ROAP error case and it provides an error URL
+        * for the caller. The calling entity should send an HTTP GET request to
+        * the URL which should then return an HTML page.
+        *
+        * @since  3.0
+        * @param aErrorUrl: The error URL
+        *
+        *
+        * @leave  System wide error code */
+
+        virtual void ErrorUrlL( const TDesC8& aErrorUrl ) = 0;
+
+        /**
+        * PostResponseUrlL
+        *
+        * The function is called if handled ROAP metering report response
+        * contains PostResponseURL extension. The calling entity should send
+        * an HTTP GET request to the URL, which should return ROAP trigger,
+        * download descriptor or multipart message containing both
+        * download descriptor and ROAP trigger.
+        *
+        * @since  3.2
+        * @param aPostResponseUrl: The URL to be fetched
+        *                          after handling ROAP metering response
+        *                          with PostResponseURL extension.
+        *
+        *
+        * @leave  System wide error code */
+
+        virtual void PostResponseUrlL( const TDesC8& aPostResponseUrl ) = 0;
+
+        };
+    }
+#endif  // ROAP_OBSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/inc/RoapTrigger.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,116 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#ifndef ROAP_TRIGGER_H
+#define ROAP_TRIGGER_H
+
+// INCLUDES
+#include <e32base.h>
+
+#include <hash.h>
+#include "RoapMessage.h"
+#include "RoapEngBase.h"
+
+// CONSTANTS
+
+namespace Roap
+{
+
+// CLASS DECLARATION
+
+/**
+* ROAP Trigger Data.
+*/
+class CRoapTrigger: public CRoapMessage
+    {
+    public:     // Constructors and destructor
+
+        /**
+        * Two-phased constructor. Leaves on failure.
+        * @return 
+        */      
+        IMPORT_C static CRoapTrigger* NewL();
+
+        /**
+        * Two-phased constructor. Leaves on failure.
+        * @return
+        */      
+        IMPORT_C static CRoapTrigger* NewL( const TTriggerType& aTriggerType,
+                                            const TDesC8& aRiId,
+                                            const TDesC8& aDomainId,
+                                            const TDesC8& aRoapUrl,
+                                            const RPointerArray<HBufC8>& aRoIdList,
+                                            const RPointerArray<HBufC8>& aContentIdList );
+                                  
+        /**
+        * 
+        * @return
+        */                                   
+        IMPORT_C HBufC8* MessageAsXmlL(void);
+        
+        /**
+        * Destructor.
+        */      
+        IMPORT_C virtual ~CRoapTrigger();
+        
+        /**
+        * Validates Trigger.
+        * Returns ETrue if Trigge is valid 
+        */
+        IMPORT_C TBool ValidTrigger();
+        
+    protected:  // Constructors and destructor
+
+        /**
+        * Constructor.
+        */      
+        CRoapTrigger();
+        
+        /**
+        * Second phase constructor. Leaves on failure.
+        */      
+        void ConstructL();
+        
+        /**
+        * Second phase constructor. Leaves on failure.
+        */              
+        void ConstructL( const TTriggerType& aTriggerType,
+                         const TDesC8& aRiId,
+                         const TDesC8& aDomainId,
+                         const TDesC8& aRoapUrl,
+                         const RPointerArray<HBufC8>& aRoIdList,
+                         const RPointerArray<HBufC8>& aContentIdList );
+
+    public:    // data
+        TBuf8<SHA1_HASH> iRiId;
+        HBufC8* iId;
+        HBufC8* iDomainId;
+        RPointerArray<HBufC8> iRoIdList;
+        RPointerArray<HBufC8> iContentIdList;
+        TTriggerType iTriggerType;
+        HBufC8* iRoapUrl;
+        HBufC8* iSignature;
+        HBufC8* iEncKey;
+        HBufC8* iNonce;
+        HBufC8* iDigestValue;
+        HBufC8* iRiAlias;
+        HBufC8* iDomainAlias;
+    };
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/roap_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="2f1105a85f5d8839cd6cc58f9f9093df" dataversion="1.0">
+  <name>ROAP API</name>
+  <description>API for Rights Object Acquisition Protocoll</description>
+  <type>c++</type>
+  <subsystem>omadrm</subsystem>
+  <libs>
+    <lib name="RoapHandler.lib" />
+  </libs>
+  <release category="domain"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/tsrc/Bmarm/RoapTestU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	LibEntryL__Fv @ 1 NONAME R3UNUSED ; LibEntryL(void)
+	SetRequirements__FRP16CTestModuleParamRUl @ 2 NONAME R3UNUSED ; SetRequirements(CTestModuleParam *&, unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/tsrc/Bwins/RoapTestU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * __cdecl LibEntryL(void)
+	?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int __cdecl SetRequirements(class CTestModuleParam * &,unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/tsrc/EABI/RoapTestU.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	_Z9LibEntryLv @ 1 NONAME
+	_Z15SetRequirementsRP16CTestModuleParamRm @ 2 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/tsrc/group/RoapTest.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2002 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          RoapTest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E7
+
+CAPABILITY      ALL -TCB
+/* Remove comments and replace 0x00000000 with correct vendor id */
+// VENDORID     0x00000000
+/* Remove comments and replace 0x00000000 with correct secure id */
+// SECUREID     0x00000000
+
+//TARGETPATH      ?target_path
+DEFFILE         RoapTest.def
+
+SOURCEPATH      ../src
+SOURCE          RoapTest.cpp
+SOURCE          RoapTestCases.cpp
+
+//RESOURCE        resource_file
+//RESOURCE        resource_file2
+
+USERINCLUDE     ../inc 
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY         roaphandler.lib
+
+LANG            SC
+
+/*
+START WINS      
+?wins_specific_information
+END
+
+START MARM
+?marm_specific_information
+END
+*/
+// Other possible keywords:
+ 
+// DOCUMENT     ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes)
+/*
+START BITMAP ?target
+TARGETPATH   ?emulated_path_on_target_machine
+HEADER
+SOURCE       ?color_depth ?source_bitmap
+END
+*/
+// DEFFILE ?filename
+// AIF ?filename// End of File
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/tsrc/group/RoapTest.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,34 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Languages
+; =========
+&EN
+
+; Name, UID for installation, Maj.Ver., Min.Ver., Variant, FLAG TO SPECIFY UNICODE, System component
+; ==================================================================================================
+#{"Roap test"},(0x101FB3E7),1,0,1,TYPE=SA
+
+
+; Localised Vendor name
+%{"Nokia-EN"}
+
+; Unique Vendor name
+:"Nokia"
+
+"\epoc32\release\armv5\urel\roaptest.dll"      -"$:\sys\bin\roaptest.dll"
+
+; eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/tsrc/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+PRJ_TESTEXPORTS
+
+PRJ_EXPORTS
+
+PRJ_TESTMMPFILES
+RoapTest.mmp
+
+PRJ_MMPFILES
+
+//  End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/tsrc/inc/RoapTest.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,420 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  RoapTest test module.
+*
+*/
+
+
+
+#ifndef ROAPTEST_H
+#define ROAPTEST_H
+
+// INCLUDES
+#include "StifTestModule.h"
+#include <StifLogger.h>
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// Logging path
+_LIT( KRoapTestLogPath, "\\logs\\testframework\\RoapTest\\" ); 
+// Log file
+_LIT( KRoapTestLogFile, "RoapTest.txt" ); 
+_LIT( KRoapTestLogFileWithTitle, "RoapTest_[%S].txt" );
+
+#define GETPTR &
+#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
+#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
+#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
+#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+class CRoapTest;
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+// A typedef for function that does the actual testing,
+// function is a type 
+// TInt CRoapTest::<NameOfFunction> ( TTestResult& aResult )
+typedef TInt (CRoapTest::* TestFunction)(TTestResult&);
+
+// CLASS DECLARATION
+
+/**
+*  An internal structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class TCaseInfoInternal
+    {
+    public:
+        const TText*    iCaseName;
+        TestFunction    iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+    };
+
+// CLASS DECLARATION
+
+/**
+*  A structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class TCaseInfo
+    {
+    public:
+        TPtrC iCaseName;
+        TestFunction iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+
+    TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
+        {
+        };
+
+    };
+
+
+// CLASS DECLARATION
+
+/**
+*  This a RoapTest class.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS(CRoapTest) : public CTestModuleBase
+    {
+    public:  // Constructors and destructor
+
+
+        /**
+        * Two-phased constructor.
+        */
+        static CRoapTest* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CRoapTest();
+
+    public: // New functions
+
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From CTestModuleBase InitL is used to initialize the 
+        *       RoapTest. It is called once for every instance of 
+        *       TestModuleRoapTest after its creation.
+        * @since ?Series60_version
+        * @param aIniFile Initialization file for the test module (optional)
+        * @param aFirstTime Flag is true when InitL is executed for first 
+        *               created instance of RoapTest.
+        * @return Symbian OS error code
+        */
+        TInt InitL( TFileName& aIniFile, TBool aFirstTime );
+
+        /**
+        * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
+        *   from RoapTest. 
+        * @since ?Series60_version
+        * @param aTestCaseFile Test case file (optional)
+        * @param aTestCases  Array of TestCases returned to test framework
+        * @return Symbian OS error code
+        */
+        TInt GetTestCasesL( const TFileName& aTestCaseFile, 
+                            RPointerArray<TTestCaseInfo>& aTestCases );
+
+        /**
+        * From CTestModuleBase RunTestCaseL is used to run an individual 
+        *   test case. 
+        * @since ?Series60_version
+        * @param aCaseNumber Test case number
+        * @param aTestCaseFile Test case file (optional)
+        * @param aResult Test case result returned to test framework (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error, which is 
+        *           not reported in aResult parameter as test case failure).
+        */   
+        TInt RunTestCaseL( const TInt aCaseNumber, 
+                           const TFileName& aTestCaseFile,
+                           TTestResult& aResult );
+
+        /**
+        * From CTestModuleBase; OOMTestQueryL is used to specify is particular
+        * test case going to be executed using OOM conditions
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailureType OOM failure type (optional)
+        * @param aFirstMemFailure The first heap memory allocation failure value (optional)
+        * @param aLastMemFailure The last heap memory allocation failure value (optional)
+        * @return TBool
+        */
+        virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
+                                     const TInt /* aCaseNumber */, 
+                                     TOOMFailureType& aFailureType, 
+                                     TInt& /* aFirstMemFailure */, 
+                                     TInt& /* aLastMemFailure */ );
+
+        /**
+        * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
+                                    const TInt /* aCaseNumber */ ); 
+
+        /**
+        * From CTestModuleBase; OOMHandleWarningL
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailNextValue FailNextValue for OOM test execution (optional)
+        * @return None
+        *
+        * User may add implementation for OOM test warning handling. Usually no
+        * implementation is required.           
+        */
+        virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
+                                        const TInt /* aCaseNumber */, 
+                                        TInt& /* aFailNextValue */); 
+
+        /**
+        * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        *
+        */
+        virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
+                                       const TInt /* aCaseNumber */ );
+
+    protected:  // New functions
+
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CRoapTest();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // ?classname( const ?classname& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // ?classname& operator=( const ?classname& );
+
+        /**
+        * Function returning test case name and pointer to test case function.
+        * @since ?Series60_version
+        * @param aCaseNumber test case number
+        * @return TCaseInfo 
+        */
+        const TCaseInfo Case ( const TInt aCaseNumber ) const;
+
+        /**
+        * [test case declarations] - do not remove
+        */
+  
+        // from CRoapTrigger
+
+        /**
+        * Construction/Destruction testing of RoapTrigger
+        * @since ?Series60_version
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConstructionDestructionTriggerL( TTestResult& aResult );
+                                  
+        /**
+        * Message exporting of RoapTrigger
+        * @since 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */                                
+        TInt MessageAsXmlL( TTestResult& aResult );
+        
+        
+        /**
+        * Trigger validity checking of RoapTrigger
+        * @since 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */        
+        TInt ValidTriggerL( TTestResult& aResult );
+
+        // from CRoapEng
+
+        /**
+        * Construction/Destruction of RoapEng & RoapEngBase
+        * @since 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */ 
+        TInt ConstructionDestructionRoapEngL( TTestResult& aResult );
+        
+
+        // from CRoapEngBase
+    
+        /**
+        * Setting the trigger testing
+        * @since 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */ 
+        
+        TInt SetTriggerL( TTestResult& aResult );
+
+        /**
+        * Starting the roap operation
+        * @since 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */ 
+        TInt AcceptL( TTestResult& aResult );
+        
+        /**
+        * Cancel the roap operation
+        * @since 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */ 
+        TInt RejectL( TTestResult& aResult );
+        
+        /**
+        * Cleanup stored data
+        * @since 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */ 
+        TInt DoCleanupL( TTestResult& aResult );   
+        
+        /**
+        * Handling one pass RO response
+        * @since 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */ 
+        TInt HandleRoReponseL( TTestResult& aResult ); 
+        
+
+        /**
+        * Retrieve trigger
+        * @since 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */ 
+        TInt TriggerL( TTestResult& aResult );
+
+
+
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // Pointer to test (function) to be executed
+        TestFunction iMethod;
+
+        // Pointer to logger
+        CStifLogger * iLog; 
+
+        // Normal logger
+        CStifLogger* iStdLog;
+
+        // Test case logger
+        CStifLogger* iTCLog;
+
+        // Flag saying if test case title should be added to log file name
+        TBool iAddTestCaseTitleToLogName;
+
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+        CActiveScheduler* iActiveScheduler;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+#endif      // ROAPTEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/tsrc/src/RoapTest.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,427 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  RoapTest class member functions
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <Stiftestinterface.h>
+#include "RoapTest.h"
+#include <SettingServerClient.h>
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRoapTest::CRoapTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRoapTest::CRoapTest()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+//
+// Note: If OOM test case uses STIF Logger, then STIF Logger must be created
+// with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
+// allocates memory from heap and therefore causes error situations with OOM 
+// testing. For more information about STIF Logger construction, see STIF Users 
+// Guide.
+// -----------------------------------------------------------------------------
+//
+void CRoapTest::ConstructL()
+    {
+    //Read logger settings to check whether test case name is to be
+    //appended to log file name.
+    RSettingServer settingServer;
+    TInt ret = settingServer.Connect();
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        }
+    // Struct to StifLogger settigs.
+    TLoggerSettings loggerSettings; 
+    // Parse StifLogger defaults from STIF initialization file.
+    ret = settingServer.GetLoggerSettings(loggerSettings);
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        } 
+    // Close Setting server session
+    settingServer.Close();
+    iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle;
+
+    iStdLog = CStifLogger::NewL( KRoapTestLogPath, 
+                          KRoapTestLogFile);
+    iLog = iStdLog;
+
+    // Sample how to use logging
+    _LIT( KLogStart, "RoapTest logging starts!" );
+    iLog->Log( KLogStart );
+
+    
+    // Needed for async objects
+    iActiveScheduler = new CActiveScheduler();
+    
+    if( iActiveScheduler ) 
+        {
+        CActiveScheduler::Install( iActiveScheduler );        
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRoapTest* CRoapTest::NewL()
+    {
+    CRoapTest* self = new (ELeave) CRoapTest;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+CRoapTest::~CRoapTest()
+    {
+    delete iActiveScheduler;
+    iLog = NULL;
+    delete iStdLog;
+    iStdLog = NULL;
+    delete iTCLog;
+    iTCLog = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapTest::InitL
+// InitL is used to initialize the Test Module.
+// -----------------------------------------------------------------------------
+//
+TInt CRoapTest::InitL( 
+    TFileName& /*aIniFile*/, 
+    TBool /*aFirstTime*/ )
+    {
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapTest::GetTestCasesL
+// GetTestCases is used to inquire test cases from the Test Module. Test
+// cases are stored to array of test cases. The Test Framework will be 
+// the owner of the data in the RPointerArray after GetTestCases return
+// and it does the memory deallocation. 
+// -----------------------------------------------------------------------------
+//
+TInt CRoapTest::GetTestCasesL( 
+    const TFileName& /*aConfig*/, 
+    RPointerArray<TTestCaseInfo>& aTestCases )
+    {
+
+    // Loop through all test cases and create new
+    // TTestCaseInfo items and append items to aTestCase array    
+    for( TInt i = 0; Case(i).iMethod != NULL; i++ )
+        {
+
+        // Allocate new TTestCaseInfo from heap for a testcase definition.
+        TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
+
+        // PushL TTestCaseInfo to CleanupStack.    
+        CleanupStack::PushL( newCase );
+
+        // Set number for the testcase.
+        // When the testcase is run, this comes as a parameter to RunTestCaseL.
+        newCase->iCaseNumber = i;
+
+        // Set title for the test case. This is shown in UI to user.
+        newCase->iTitle.Copy( Case(i).iCaseName );
+
+        // Append TTestCaseInfo to the testcase array. After appended 
+        // successfully the TTestCaseInfo object is owned (and freed) 
+        // by the TestServer. 
+        User::LeaveIfError(aTestCases.Append ( newCase ) );
+
+        // Pop TTestCaseInfo from the CleanupStack.
+        CleanupStack::Pop( newCase );
+
+        }
+
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapTest::RunTestCaseL
+// RunTestCaseL is used to run an individual test case specified 
+// by aTestCase. Test cases that can be run may be requested from 
+// Test Module by GetTestCases method before calling RunTestCase.
+// -----------------------------------------------------------------------------
+//
+TInt CRoapTest::RunTestCaseL( 
+    const TInt aCaseNumber,   
+    const TFileName& /*aConfig*/,
+    TTestResult& aResult )
+    {
+
+    // Return value
+    TInt execStatus = KErrNone;
+
+    // Get the pointer to test case function
+    TCaseInfo tmp = Case ( aCaseNumber );
+
+    _LIT( KLogStartTC, "Starting testcase [%S]" );
+    iLog->Log( KLogStartTC, &tmp.iCaseName);
+
+    // Check that case number was valid
+    if ( tmp.iMethod != NULL )
+        {
+        //Open new log file with test case title in file name
+        if(iAddTestCaseTitleToLogName)
+            {
+            //Delete test case logger if exists
+            if(iTCLog)
+                {
+                delete iTCLog;
+                iTCLog = NULL;
+                }
+
+            TFileName logFileName;
+            TName title;
+            TestModuleIf().GetTestCaseTitleL(title);
+        
+            logFileName.Format(KRoapTestLogFileWithTitle, &title);
+
+            iTCLog = CStifLogger::NewL(KRoapTestLogPath, 
+                                       logFileName);
+            iLog = iTCLog;                                       
+            }
+
+        // Valid case was found, call it via function pointer
+        iMethod = tmp.iMethod;        
+        //execStatus  = ( this->*iMethod )( aResult );
+        TRAPD(err, execStatus  = ( this->*iMethod )( aResult ));
+        if(iAddTestCaseTitleToLogName)
+            {
+            //Restore standard log and destroy test case logger
+            iLog = iStdLog;
+            delete iTCLog; //Close test case log
+            iTCLog = NULL;
+            }
+        User::LeaveIfError(err);
+        }
+    else
+        {
+        // Valid case was not found, return error.
+        execStatus = KErrNotFound;
+        }
+
+    // Return case execution status (not the result of the case execution)
+    return execStatus;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapTest::OOMTestQueryL
+// Used to check if a particular test case should be run in OOM conditions and 
+// which memory allocations should fail.    
+// -----------------------------------------------------------------------------
+//
+TBool CRoapTest::OOMTestQueryL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt aCaseNumber, 
+                                TOOMFailureType& /* aFailureType */, 
+                                TInt& aFirstMemFailure, 
+                                TInt& aLastMemFailure ) 
+    {
+    _LIT( KLogOOMTestQueryL, "CRoapTest::OOMTestQueryL" );
+    iLog->Log( KLogOOMTestQueryL );     
+
+    aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
+    aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation;
+
+    return Case( aCaseNumber ).iIsOOMTest;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapTest::OOMTestInitializeL
+// Used to perform the test environment setup for a particular OOM test case. 
+// Test Modules may use the initialization file to read parameters for Test 
+// Module initialization but they can also have their own configure file or 
+// some other routine to initialize themselves.  
+//
+// NOTE: User may add implementation for OOM test environment initialization.
+// Usually no implementation is required.
+// -----------------------------------------------------------------------------
+//
+void CRoapTest::OOMTestInitializeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapTest::OOMHandleWarningL
+// In some cases the heap memory allocation should be skipped, either due to
+// problems in the OS code or components used by the code being tested, or even 
+// inside the tested components which are implemented this way on purpose (by 
+// design), so it is important to give the tester a way to bypass allocation 
+// failures.
+//
+// NOTE: User may add implementation for OOM test warning handling. Usually no
+// implementation is required.
+// -----------------------------------------------------------------------------
+//
+void CRoapTest::OOMHandleWarningL( 
+                                const TFileName& /* aTestCaseFile */,
+                                const TInt /* aCaseNumber */, 
+                                TInt& /* aFailNextValue */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapTest::OOMTestFinalizeL
+// Used to perform the test environment cleanup for a particular OOM test case.
+//
+// NOTE: User may add implementation for OOM test environment finalization.
+// Usually no implementation is required.
+// -----------------------------------------------------------------------------
+//
+void CRoapTest::OOMTestFinalizeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point
+// Returns: CTestModuleBase*: Pointer to Test Module object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTestModuleBase* LibEntryL()
+    {
+    return CRoapTest::NewL();
+
+    }
+
+// -----------------------------------------------------------------------------
+// SetRequirements handles test module parameters(implements evolution
+// version 1 for test module's heap and stack sizes configuring).
+// Returns: TInt: Symbian error code.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
+                                TUint32& /*aParameterValid*/ )
+    {
+
+    /* --------------------------------- NOTE ---------------------------------
+    USER PANICS occurs in test thread creation when:
+    1) "The panic occurs when the value of the stack size is negative."
+    2) "The panic occurs if the minimum heap size specified is less
+       than KMinHeapSize".
+       KMinHeapSize: "Functions that require a new heap to be allocated will
+       either panic, or will reset the required heap size to this value if
+       a smaller heap size is specified".
+    3) "The panic occurs if the minimum heap size specified is greater than
+       the maximum size to which the heap can grow".
+    Other:
+    1) Make sure that your hardware or Symbian OS is supporting given sizes.
+       e.g. Hardware might support only sizes that are divisible by four.
+    ------------------------------- NOTE end ------------------------------- */
+
+    // Normally STIF uses default heap and stack sizes for test thread, see:
+    // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
+    // If needed heap and stack sizes can be configured here by user. Remove
+    // comments and define sizes.
+
+/*
+    aParameterValid = KStifTestModuleParameterChanged;
+
+    CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
+    // Stack size
+    param->iTestThreadStackSize= 16384; // 16K stack
+    // Heap sizes
+    param->iTestThreadMinHeap = 4096;   // 4K heap min
+    param->iTestThreadMaxHeap = 1048576;// 1M heap max
+
+    aTestModuleParam = param;
+*/
+    return KErrNone;
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/roap_api/tsrc/src/RoapTestCases.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,849 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <e32math.h>
+#include "RoapTest.h"
+#include "RoapTrigger.h"
+#include "RoapEng.h"
+#include "RoapEngBase.h"
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+_LIT( KRunning, "Running" );
+_LIT( KFinished, "Finished" );
+_LIT( KPassed, "Passed" );
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRoapTest::Case
+// Returns a test case by number.
+//
+// This function contains an array of all available test cases 
+// i.e pair of case name and test function. If case specified by parameter
+// aCaseNumber is found from array, then that item is returned.
+// 
+// The reason for this rather complicated function is to specify all the
+// test cases only in one place. It is not necessary to understand how
+// function pointers to class member functions works when adding new test
+// cases. See function body for instructions how to add new test case.
+// -----------------------------------------------------------------------------
+//
+const TCaseInfo CRoapTest::Case ( 
+    const TInt aCaseNumber ) const 
+     {
+
+    /**
+    * To add new test cases, implement new test case function and add new 
+    * line to KCases array specify the name of the case and the function 
+    * doing the test case
+    * In practice, do following
+    * 1) Make copy of existing test case function and change its name
+    *    and functionality. Note that the function must be added to 
+    *    RoapTest.cpp file and to RoapTest.h 
+    *    header file.
+    *
+    * 2) Add entry to following KCases array either by using:
+    *
+    * 2.1: FUNCENTRY or ENTRY macro
+    * ENTRY macro takes two parameters: test case name and test case 
+    * function name.
+    *
+    * FUNCENTRY macro takes only test case function name as a parameter and
+    * uses that as a test case name and test case function name.
+    *
+    * Or
+    *
+    * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
+    * only with OOM (Out-Of-Memory) testing!
+    *
+    * OOM_ENTRY macro takes five parameters: test case name, test case 
+    * function name, TBool which specifies is method supposed to be run using
+    * OOM conditions, TInt value for first heap memory allocation failure and 
+    * TInt value for last heap memory allocation failure.
+    * 
+    * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
+    * that as a test case name, TBool which specifies is method supposed to be
+    * run using OOM conditions, TInt value for first heap memory allocation 
+    * failure and TInt value for last heap memory allocation failure. 
+    */ 
+
+    static TCaseInfoInternal const KCases[] =
+        {
+        // [test cases entries] - do not remove
+        
+        // NOTE: When compiled to GCCE, there must be Classname::
+        // declaration in front of the method name, e.g. 
+        // CRoapTest::PrintTest. Otherwise the compiler
+        // gives errors.
+        
+        ENTRY( "RoapTrigger::ConstructionDestructionTrigger", CRoapTest::ConstructionDestructionTriggerL ),
+        ENTRY( "RoapTrigger::MessageAsXml", CRoapTest::MessageAsXmlL ),
+        ENTRY( "RoapTrigger::ValidTrigger", CRoapTest::ValidTriggerL ),
+        ENTRY( "RoapEng/RoapEngBase::ConstructionDestructionRoapEng", CRoapTest::ConstructionDestructionRoapEngL ),
+        ENTRY( "RoapEngBase::SetTrigger", CRoapTest::SetTriggerL ),
+        ENTRY( "RoapEngBase::Accept", CRoapTest::AcceptL ),
+        ENTRY( "RoapEngBase::Reject", CRoapTest::RejectL ),
+        ENTRY( "RoapEngBase::DoCleanup", CRoapTest::DoCleanupL ),
+        ENTRY( "RoapEngBase::HandleRoReponse", CRoapTest::HandleRoReponseL ),
+        ENTRY( "RoapEngBase::Trigger", CRoapTest::TriggerL )
+                
+        // Example how to use OOM functionality
+        //OOM_ENTRY( "Loop test with OOM", CRoapTest::LoopTest, ETrue, 2, 3),
+        //OOM_FUNCENTRY( CRoapTest::PrintTest, ETrue, 1, 3 ),
+        };
+
+    // Verify that case number is valid
+    if( (TUint) aCaseNumber >= sizeof( KCases ) / 
+                               sizeof( TCaseInfoInternal ) )
+        {
+        // Invalid case, construct empty object
+        TCaseInfo null( (const TText*) L"" );
+        null.iMethod = NULL;
+        null.iIsOOMTest = EFalse;
+        null.iFirstMemoryAllocation = 0;
+        null.iLastMemoryAllocation = 0;
+        return null;
+        } 
+
+    // Construct TCaseInfo object and return it
+    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
+    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
+    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
+    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
+    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
+    return tmp;
+
+    }
+
+
+// from CRoapTrigger
+
+// -----------------------------------------------------------------------------
+// CRoapTest::
+// -----------------------------------------------------------------------------
+// 
+TInt CRoapTest::ConstructionDestructionTriggerL( TTestResult& aResult )
+    {
+    _LIT( KData, "CRoapTest::ConstructionDestructionTriggerL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Testing NewL:s of RoapTrigger: Expecting creation to succeed" );
+    iLog->Log( KTestCase1 );
+    
+    Roap::CRoapTrigger* trigger = Roap::CRoapTrigger::NewL();
+
+    TL( trigger );
+    delete trigger;
+    
+    
+    Roap::TTriggerType type = Roap::ERegistrationTrigger;
+    _LIT8(KRiIdDummy,"abcdefghijabcdefghij");
+    _LIT8(KDomainIdDummy,"DomainId001");
+    _LIT8(KRoapUrl,"http://www.localhost.localdomain:80");
+    RPointerArray<HBufC8> listRo;
+    RPointerArray<HBufC8> listCid;
+    
+    trigger = Roap::CRoapTrigger::NewL( type,
+                                        KRiIdDummy,
+                                        KDomainIdDummy,
+                                        KRoapUrl,
+                                        listRo,
+                                        listCid);
+
+    TL( trigger );
+    delete trigger;
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CRoapTest::ConstructionDestructionTriggerL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    };
+                                  
+// -----------------------------------------------------------------------------
+// CRoapTest::
+// -----------------------------------------------------------------------------
+//                                 
+TInt CRoapTest::MessageAsXmlL( TTestResult& aResult )
+    {
+    _LIT( KData, "CRoapTest::MessageAsXmlL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase2, "TestCase2: Testing MessageAsXmlL of RoapTrigger: Expecting an output buffer" );
+    iLog->Log( KTestCase2 );
+    
+    Roap::CRoapTrigger* trigger = Roap::CRoapTrigger::NewL();
+    HBufC8* xmlData = NULL;
+    
+    Roap::TTriggerType type = Roap::ERegistrationTrigger;
+    _LIT8(KRiIdDummy,"abcdefghijabcdefghij");
+    _LIT8(KDomainIdDummy,"DomainId001");
+    _LIT8(KRoapUrl,"http://www.localhost.localdomain:80");
+    RPointerArray<HBufC8> listRo;
+    RPointerArray<HBufC8> listCid;
+    
+    trigger = Roap::CRoapTrigger::NewL( type,
+                                        KRiIdDummy,
+                                        KDomainIdDummy,
+                                        KRoapUrl,
+                                        listRo,
+                                        listCid);
+                                                                            
+    TL( trigger );
+    CleanupStack::PushL(trigger);
+    
+    xmlData = trigger->MessageAsXmlL();
+    
+    delete xmlData;
+    CleanupStack::PopAndDestroy();
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CRoapTest::MessageAsXmlL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;    
+    };
+        
+        
+// -----------------------------------------------------------------------------
+// CRoapTest::
+// -----------------------------------------------------------------------------
+//        
+TInt CRoapTest::ValidTriggerL( TTestResult& aResult )
+    {
+    _LIT( KData, "CRoapTest::MessageAsXmlL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase3, "TestCase3: Testing ValidTrigger of RoapTrigger: Expecting an output buffer" );
+    iLog->Log( KTestCase3 );
+    
+    Roap::CRoapTrigger* trigger = Roap::CRoapTrigger::NewL();
+    
+    Roap::TTriggerType type = Roap::ERegistrationTrigger;
+    _LIT8(KRiIdDummy,"abcdefghijabcdefghij");
+    _LIT8(KDomainIdDummy,"DomainId001");
+    _LIT8(KRoapUrl,"http://www.localhost.localdomain:80");
+    RPointerArray<HBufC8> listRo;
+    RPointerArray<HBufC8> listCid;
+    
+    trigger = Roap::CRoapTrigger::NewL( type,
+                                        KRiIdDummy,
+                                        KDomainIdDummy,
+                                        KRoapUrl,
+                                        listRo,
+                                        listCid);
+                                                                            
+    TL( trigger );
+    
+    TL( trigger->ValidTrigger() );
+    
+    delete trigger;
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CRoapTest::ValidTriggerL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;    
+    };
+
+// from CRoapEng
+
+// -----------------------------------------------------------------------------
+// CRoapTest::
+// -----------------------------------------------------------------------------
+// 
+TInt CRoapTest::ConstructionDestructionRoapEngL( TTestResult& aResult )
+    {
+    _LIT( KData, "CRoapTest::ConstructionDestructionRoapEngL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase4, "TestCase4: Testing NewL:s of CRoapEng and CRoapEngBase: Expecting a working RoapEng" );
+    iLog->Log( KTestCase4 );
+    
+    Roap::CRoapEng* roapEng = Roap::CRoapEng::NewL();
+    
+    TL( roapEng );
+    
+    delete roapEng;
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CRoapTest::ConstructionDestructionRoapEngL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    };
+        
+
+// from CRoapEngBase
+    
+// -----------------------------------------------------------------------------
+// CRoapTest::
+// -----------------------------------------------------------------------------
+// 
+TInt CRoapTest::SetTriggerL( TTestResult& aResult )
+    {
+    _LIT( KData, "CRoapTest::SetTriggerL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase5, "TestCase5: Testing SetTriggerL of RoapEngBase" );
+    iLog->Log( KTestCase5 );
+    
+    Roap::CRoapTrigger* trigger = Roap::CRoapTrigger::NewL();
+    HBufC8* xmlData = NULL;
+    
+    Roap::TTriggerType type = Roap::ERegistrationTrigger;
+    _LIT8(KRiIdDummy,"abcdefghijabcdefghij");
+    _LIT8(KDomainIdDummy,"DomainId001");
+    _LIT8(KRoapUrl,"http://www.localhost.localdomain:80");
+    RPointerArray<HBufC8> listRo;
+    RPointerArray<HBufC8> listCid;
+    Roap::TRiContextStatus riStatus;
+    Roap::TDomainOperation domainOperation;    
+    
+    trigger = Roap::CRoapTrigger::NewL( type,
+                                        KRiIdDummy,
+                                        KDomainIdDummy,
+                                        KRoapUrl,
+                                        listRo,
+                                        listCid);
+                                                                            
+    TL( trigger );
+    CleanupStack::PushL(trigger);
+    
+    xmlData = trigger->MessageAsXmlL();
+    CleanupStack::PushL( xmlData );
+    
+    Roap::CRoapEng* roapEng = Roap::CRoapEng::NewL();
+    CleanupStack::PushL( roapEng );
+    
+    // Actual Test:
+    roapEng->SetTriggerL( *xmlData,
+                          NULL,
+                          type,
+                          riStatus,
+                          domainOperation,
+                          listCid );
+    
+    
+    CleanupStack::PopAndDestroy(roapEng);
+    CleanupStack::PopAndDestroy(xmlData);
+    CleanupStack::PopAndDestroy(trigger);
+            
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CRoapTest::SetTriggerL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;     
+    };
+
+// -----------------------------------------------------------------------------
+// CRoapTest::
+// -----------------------------------------------------------------------------
+//  
+TInt CRoapTest::AcceptL( TTestResult& aResult )
+    {
+    _LIT( KData, "CRoapTest::AcceptL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase6, "TestCase6: Testing AcceptL of CRoapEngBase" );
+    iLog->Log( KTestCase6 );
+    
+    Roap::CRoapEng* roapEng = Roap::CRoapEng::NewL();
+    TRequestStatus statusData;
+    TRequestStatus* status = &statusData;
+    
+    TL( roapEng );
+    
+    // Ignore error for now, method got called ok:
+    TRAPD( err, roapEng->AcceptL( NULL, status ));
+    
+    delete roapEng;
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CRoapTest::AcceptL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;    
+    };
+        
+// -----------------------------------------------------------------------------
+// CRoapTest::
+// -----------------------------------------------------------------------------
+// 
+TInt CRoapTest::RejectL( TTestResult& aResult )
+    {
+    _LIT( KData, "CRoapTest::RejectL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase7, "TestCase7: Testing RejectL of CRoapEngBase" );
+    iLog->Log( KTestCase7 );
+    
+    
+    Roap::CRoapTrigger* trigger = Roap::CRoapTrigger::NewL();
+    HBufC8* xmlData = NULL;
+    
+    Roap::TTriggerType type = Roap::ERegistrationTrigger;
+    _LIT8(KRiIdDummy,"abcdefghijabcdefghij");
+    _LIT8(KDomainIdDummy,"DomainId001");
+    _LIT8(KRoapUrl,"http://www.localhost.localdomain:80");
+    RPointerArray<HBufC8> listRo;
+    RPointerArray<HBufC8> listCid;
+    Roap::TRiContextStatus riStatus;
+    Roap::TDomainOperation domainOperation;    
+    
+    trigger = Roap::CRoapTrigger::NewL( type,
+                                        KRiIdDummy,
+                                        KDomainIdDummy,
+                                        KRoapUrl,
+                                        listRo,
+                                        listCid);
+                                                                            
+    TL( trigger );
+    CleanupStack::PushL(trigger);
+    
+    xmlData = trigger->MessageAsXmlL();
+    CleanupStack::PushL( xmlData );
+    
+    Roap::CRoapEng* roapEng = Roap::CRoapEng::NewL();
+    CleanupStack::PushL( roapEng );
+    
+
+    roapEng->SetTriggerL( *xmlData,
+                          NULL,
+                          type,
+                          riStatus,
+                          domainOperation,
+                          listCid );
+    
+    // Actual Test:    
+    roapEng->Reject();
+    
+    CleanupStack::PopAndDestroy(roapEng);
+    CleanupStack::PopAndDestroy(xmlData);
+    CleanupStack::PopAndDestroy(trigger);
+    
+    //Passed
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CRoapTest::RejectL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;    
+    };
+        
+// -----------------------------------------------------------------------------
+// CRoapTest::
+// -----------------------------------------------------------------------------
+// 
+TInt CRoapTest::DoCleanupL( TTestResult& aResult )
+    {
+    _LIT( KData, "CRoapTest::DoCleanupL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase8, "TestCase8: Testing DoCleanupL of CRoapEngBase" );
+    iLog->Log( KTestCase8 );
+    
+    Roap::CRoapTrigger* trigger = Roap::CRoapTrigger::NewL();
+    HBufC8* xmlData = NULL;
+    
+    Roap::TTriggerType type = Roap::ERegistrationTrigger;
+    _LIT8(KRiIdDummy,"abcdefghijabcdefghij");
+    _LIT8(KDomainIdDummy,"DomainId001");
+    _LIT8(KRoapUrl,"http://www.localhost.localdomain:80");
+    RPointerArray<HBufC8> listRo;
+    RPointerArray<HBufC8> listCid;
+    Roap::TRiContextStatus riStatus;
+    Roap::TDomainOperation domainOperation;    
+    
+    trigger = Roap::CRoapTrigger::NewL( type,
+                                        KRiIdDummy,
+                                        KDomainIdDummy,
+                                        KRoapUrl,
+                                        listRo,
+                                        listCid);
+                                                                            
+    TL( trigger );
+    CleanupStack::PushL(trigger);
+    
+    xmlData = trigger->MessageAsXmlL();
+    CleanupStack::PushL( xmlData );
+    
+    Roap::CRoapEng* roapEng = Roap::CRoapEng::NewL();
+    CleanupStack::PushL( roapEng );
+    
+
+    roapEng->SetTriggerL( *xmlData,
+                          NULL,
+                          type,
+                          riStatus,
+                          domainOperation,
+                          listCid );
+    
+    // Actual Test:    
+    roapEng->DoCleanup();
+    
+    CleanupStack::PopAndDestroy(roapEng);
+    CleanupStack::PopAndDestroy(xmlData);
+    CleanupStack::PopAndDestroy(trigger);
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CRoapTest::DoCleanupL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;     
+    };   
+        
+// -----------------------------------------------------------------------------
+// CRoapTest::
+// -----------------------------------------------------------------------------
+// 
+TInt CRoapTest::HandleRoReponseL( TTestResult& aResult )
+    {
+    _LIT( KData, "CRoapTest::HandleRoReponseL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase9, "TestCase9: Testing HandleRoReponseL of CRoapEngBase" );
+    iLog->Log( KTestCase9 );
+    
+    Roap::CRoapEng* roapEng = Roap::CRoapEng::NewL();
+    CleanupStack::PushL( roapEng );
+    
+    RPointerArray<CDRMRights> rights;
+    
+    TRAPD(err, roapEng->HandleRoReponseL( KNullDesC8, rights ));
+    
+    CleanupStack::PopAndDestroy(roapEng);
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CRoapTest::HandleRoReponseL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;    
+    }; 
+        
+
+// -----------------------------------------------------------------------------
+// CRoapTest::
+// -----------------------------------------------------------------------------
+// 
+TInt CRoapTest::TriggerL( TTestResult& aResult )
+    {
+    _LIT( KData, "CRoapTest::TriggerL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase10, "TestCase10: Testing Trigger of CRoapEngBase" );
+    iLog->Log( KTestCase10 );
+    
+    Roap::CRoapTrigger* trigger = Roap::CRoapTrigger::NewL();
+    HBufC8* xmlData = NULL;
+    
+    Roap::TTriggerType type = Roap::ERegistrationTrigger;
+    _LIT8(KRiIdDummy,"abcdefghijabcdefghij");
+    _LIT8(KDomainIdDummy,"DomainId001");
+    _LIT8(KRoapUrl,"http://www.localhost.localdomain:80");
+    RPointerArray<HBufC8> listRo;
+    RPointerArray<HBufC8> listCid;
+    Roap::TRiContextStatus riStatus;
+    Roap::TDomainOperation domainOperation;    
+    
+    trigger = Roap::CRoapTrigger::NewL( type,
+                                        KRiIdDummy,
+                                        KDomainIdDummy,
+                                        KRoapUrl,
+                                        listRo,
+                                        listCid);
+                                                                            
+    TL( trigger );
+    CleanupStack::PushL(trigger);
+    
+    xmlData = trigger->MessageAsXmlL();
+    CleanupStack::PushL( xmlData );
+    
+    Roap::CRoapEng* roapEng = Roap::CRoapEng::NewL();
+    CleanupStack::PushL( roapEng );
+    
+
+    roapEng->SetTriggerL( *xmlData,
+                          NULL,
+                          type,
+                          riStatus,
+                          domainOperation,
+                          listCid );
+    
+    // Actual Test:    
+    roapEng->Trigger();
+    
+    CleanupStack::PopAndDestroy(roapEng);
+    CleanupStack::PopAndDestroy(xmlData);
+    CleanupStack::PopAndDestroy(trigger);
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CRoapTest::TriggerL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;         
+    };
+
+
+
+
+// -----------------------------------------------------------------------------
+// ?classname::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?classname::?member_function(
+   ?arg_type arg,
+   ?arg_type arg )
+   {
+
+   ?code
+
+   }
+*/
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+/*
+?type  ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg )  // ?description
+    {
+
+    ?code
+
+    }
+*/
+//  [End of File] - do not remove
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+* File that exports the files belonging to WMDRM Access API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../inc/wmdrmaccess.h     MW_LAYER_PLATFORM_EXPORT_PATH(wmdrmaccess.h)
+
+../inc/wmdrmaccessecominterface.h \
+    MW_LAYER_PLATFORM_EXPORT_PATH(wmdrmaccessecominterface.h)
+
+../inc/wmdrmaccessecominterface.inl \
+    MW_LAYER_PLATFORM_EXPORT_PATH(wmdrmaccessecominterface.inl)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/inc/wmdrmaccess.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,132 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*  wmdrmaccess.h
+*
+*/
+
+#ifndef _WMDRM_ACCESS_API_H_
+#define _WMDRM_ACCESS_API_H_
+
+// Forward declarations
+class CWmDrmAccessEcomInterface;
+
+// Class declaration
+/**
+*  Provides access to WM DRM protected files
+*  (e.g. decrypting services for WM DRM protected files)
+*
+*  @code
+*  // Way to use CWmDrmAccess
+*
+*  CWmDrmAccess* access( CWmDrmAccess::NewL() );
+*  // ...
+*  // fetch file header of the WM DRM protected file to be decrypted.
+*  // Assign it to initializationData
+*  // ...
+*  // Initialize with given initialisation data
+*  access->Initialize( initializationData );
+*  // ...
+*  // read encrypted data block to buffer
+*  // ...
+*  CWmDrmAccess->Decrypt( buffer );
+*  // use decrypted data in buffer
+*  // ...
+*  // when all data has been decrypted, close decryption context
+*  access->Close();
+*  delete access;
+*  @endcode
+*
+*/
+NONSHARABLE_CLASS( CWmDrmAccess ) : public CBase
+    {
+public:
+    /** Constructors */
+    IMPORT_C static CWmDrmAccess* NewL();
+    IMPORT_C static CWmDrmAccess* NewLC();
+
+    /** Destructor */
+    IMPORT_C virtual ~CWmDrmAccess();
+
+    /**
+    * Initialises decryption context
+    * This initialises decryption session for given WM DRM protected file.
+    *
+    * @param aHeader    This parameter is for inputting header
+    *                   of the given WM DRM protected file to be decrypted
+    *                   to WM DRM system.
+    *
+    *
+    * @return           A Symbian OS error code, KErrNone on success.
+    *
+    * @see CWmDrmAccess::Close
+    *
+    */
+    IMPORT_C TInt Initialize( const TDesC8& aHeader );
+
+
+    /**
+    * Decrypts encrypted data in place.
+    * This is for decrypting data of the file, header of which is used
+    *  as initialisation parameter at CWmDrmAccess::Initialize.
+    *
+    * @param aBuffer    This will contain data to be decrypted.
+    *                   On successful completion, given data is
+    *                   decrypted in aBuffer.
+    *
+    * @return           A Symbian OS error code, KErrNone on success.
+    *
+    * One small sample describing the use of the function.
+    * @code
+    * RBuf8 buffer;
+    * // ...
+    * // Fetch encrypted data to buffer
+    * FetchEncryptedData( buffer );
+    *
+    * // Decrypt encrypted data.
+    * TInt error = access->Decrypt( buffer );
+    * if ( !error )
+    *     {
+    *     UseDecryptedData( buffer );
+    *     }
+    * @endcode
+    *
+    * @see CWmDrmAccess::Initialize
+    * @see CWmDrmAccess::Close
+    *
+    */
+    IMPORT_C TInt Decrypt( TDes8& aBuffer );
+
+
+    /**
+    * Closes decryption context.
+    *
+    * @return           A Symbian OS error code, KErrNone on success.
+    *
+    * @see CWmDrmAccess::Initialize
+    *
+    */
+    IMPORT_C TInt Close();
+
+private:
+    /** Default constructor */
+    CWmDrmAccess();
+    /** Second phase constructor */
+    void ConstructL();
+
+    /** Internal interface to the WM DRM system */
+    CWmDrmAccessEcomInterface* iWmDrmAccessEcomInterface;
+
+    };
+#endif // _WMDRM_ACCESS_API_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/inc/wmdrmaccessecominterface.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*  wmdrmaccessecominterface.h
+*
+*/
+
+#ifndef _WMDRMACCESSECOMINTERFACE_H_
+#define _WMDRMACCESSECOMINTERFACE_H_
+
+#include <e32base.h>
+
+// Class declaration
+// CWmDrmAccessEcomInterface
+// ecom plugin interface for WM DRM access implementation
+// @see CWmDrmAccess
+NONSHARABLE_CLASS( CWmDrmAccessEcomInterface ) : public CBase
+    {
+public:
+    // Constructors
+    static CWmDrmAccessEcomInterface* NewL();
+    static CWmDrmAccessEcomInterface* NewLC();
+
+    // Destructor
+    virtual ~CWmDrmAccessEcomInterface();
+
+    // Initialises decryption context.
+    // @see CWmDrmAccess::Initialize
+    // @post class ready for decrypting WM DRM protected file,
+    //  header of which is given in aHeader.
+    virtual TInt Initialize( const TDesC8& aHeader ) = 0;
+
+    // Decrypts encrypted data in place.
+    // @see CWmDrmAccess::Decrypt
+    // @pre Succesful call of Initialize, data to be decrypted in aBuffer
+    // @post decrypted data in aBuffer
+    virtual TInt Decrypt( TDes8& aBuffer ) = 0;
+
+    // Closes decryption context.
+    // @see CWmDrmAccess::Close
+    virtual TInt Close() = 0;
+
+private:
+    // internal variable used on freeing ecom related resources
+    TUid iDtor_ID_Key;
+    };
+
+#include "wmdrmaccessecominterface.inl"
+#endif _WMDRMACCESSECOMINTERFACE_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/inc/wmdrmaccessecominterface.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*  wmdrmaccessecominterface.inl
+*
+*/
+#include <ecom.h> // for interface
+
+// ---------------------------------------------------------------------------
+// CWmDrmAccessEcomInterface::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmAccessEcomInterface* CWmDrmAccessEcomInterface::NewL()
+    {
+    const TUid KWmdrmAccessEcomInterfaceUid =
+        {
+        0x20026FDB
+        };
+    TAny* theImplementation( NULL );
+
+    TEComResolverParams resolveParams;
+    resolveParams.SetWildcardMatch( ETrue );
+
+    theImplementation = REComSession::CreateImplementationL(
+        KWmdrmAccessEcomInterfaceUid,
+        _FOFF( CWmDrmAccessEcomInterface, iDtor_ID_Key ),
+        resolveParams );
+
+    return reinterpret_cast<CWmDrmAccessEcomInterface*>( theImplementation );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmAccessEcomInterface::NewLC
+// ---------------------------------------------------------------------------
+//
+CWmDrmAccessEcomInterface* CWmDrmAccessEcomInterface::NewLC()
+    {
+    CWmDrmAccessEcomInterface* self( CWmDrmAccessEcomInterface::NewL() );
+
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmAccessEcomInterface::~CWmDrmAccessEcomInterface
+// ---------------------------------------------------------------------------
+//
+CWmDrmAccessEcomInterface::~CWmDrmAccessEcomInterface()
+    {
+    REComSession::DestroyedImplementation( iDtor_ID_Key );
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/tsrc/bwins/helixstifu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * __cdecl LibEntryL(void)
+	?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int __cdecl SetRequirements(class CTestModuleParam * &,unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/tsrc/eabi/helixstifu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	_Z9LibEntryLv @ 1 NONAME
+	_Z15SetRequirementsRP16CTestModuleParamRm @ 2 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/tsrc/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description:
+*
+*/
+
+PRJ_PLATFORMS
+// specify the platforms your component needs to be built for here
+// defaults to WINS MARM so you can ignore this if you just build these
+
+	DEFAULT
+
+PRJ_TESTEXPORTS
+// NOTE: If using ARS requirements all export operations should be done under this.
+// 'abld test export'
+
+PRJ_EXPORTS
+// Specify the source file followed by its destination here
+// copy will be used to copy the source file to its destination
+// If there's no destination then the source file will be copied
+// to the same name in \epoc32\include
+// Example: 
+/*
+\agnmodel\inc\AGMCOMON.H
+*/
+
+PRJ_TESTMMPFILES
+
+	helixstif.mmp
+
+// Specify the .mmp files required for building the important component
+// releasables.
+//
+// Specify "tidy" if the component you need to build doesn't need to be
+// released. Specify "ignore" if the MMP file exists but should be
+// ignored.
+// Example:
+/*
+\agnmodel\group\agnmodel.mmp
+#if defined(MARM)
+\agnmodel\group\agsvexe.mmp
+#endif
+*/
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/tsrc/group/helixstif.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,54 @@
+/*TYPE HARDCODED*/
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: MMP file for STIF Test Framework's Hardcoded test 
+* module.
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET          helixstif.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E7
+
+CAPABILITY      ALL -TCB
+
+//TARGETPATH      ?target_path
+DEFFILE         helixstif.def
+
+USERINCLUDE     ../inc 
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../src
+
+SOURCE          helixstif.cpp
+SOURCE          helixstifCases.cpp
+
+//RESOURCE        resource_file
+//RESOURCE        resource_file2
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+LIBRARY         wmdrmaccess.lib
+
+LANG            SC
+
+// Other possible keywords:
+ 
+SMPSAFE
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/tsrc/group/helixstif.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,60 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+; 
+; Description:
+;
+; 	Installation file for STIF
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+"\epoc32\release\armv5\udeb\helixstif.dll"   -   "!:\Sys\Bin\helixstif.dll"
+  
+; Embedded SIS 
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/tsrc/inc/helixstif.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,352 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: STIF hardcoded module declaration
+*
+*/
+
+#ifndef HELIXSTIF_H
+#define HELIXSTIF_H
+
+// INCLUDES
+#include "StifTestModule.h"
+#include <StifLogger.h>
+#include <NormalHardcodedAssert.h>
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+#define TEST_MODULE_VERSION_MAJOR 0
+#define TEST_MODULE_VERSION_MINOR 0
+#define TEST_MODULE_VERSION_BUILD 0
+
+// Logging path
+_LIT( KhelixstifLogPath, "\\logs\\testframework\\helixstif\\" ); 
+// Log file
+_LIT( KhelixstifLogFile, "helixstif.txt" ); 
+_LIT( KhelixstifLogFileWithTitle, "helixstif_[%S].txt" );
+
+#define GETPTR &
+#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
+#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
+#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
+#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+class Chelixstif;
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+// A typedef for function that does the actual testing,
+// function is a type 
+// TInt Chelixstif::<NameOfFunction> ( TTestResult& aResult )
+typedef TInt (Chelixstif::* TestFunction)(TTestResult&);
+
+// CLASS DECLARATION
+
+/**
+*  An internal structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class TCaseInfoInternal
+    {
+    public:
+        const TText*    iCaseName;
+        TestFunction    iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+    };
+
+// CLASS DECLARATION
+
+/**
+*  A structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+class TCaseInfo
+    {
+    public:
+        TPtrC iCaseName;
+        TestFunction iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+
+    TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
+        {
+        };
+
+    };
+
+
+// CLASS DECLARATION
+
+/**
+*  This a helixstif class.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since ?Series60_version
+*/
+NONSHARABLE_CLASS(Chelixstif) : public CTestModuleBase
+    {
+    public:  // Constructors and destructor
+
+
+        /**
+        * Two-phased constructor.
+        */
+        static Chelixstif* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~Chelixstif();
+
+    public: // New functions
+
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From CTestModuleBase InitL is used to initialize the 
+        *       helixstif. It is called once for every instance of 
+        *       TestModulehelixstif after its creation.
+        * @since ?Series60_version
+        * @param aIniFile Initialization file for the test module (optional)
+        * @param aFirstTime Flag is true when InitL is executed for first 
+        *               created instance of helixstif.
+        * @return Symbian OS error code
+        */
+        TInt InitL( TFileName& aIniFile, TBool aFirstTime );
+
+        /**
+        * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
+        *   from helixstif. 
+        * @since ?Series60_version
+        * @param aTestCaseFile Test case file (optional)
+        * @param aTestCases  Array of TestCases returned to test framework
+        * @return Symbian OS error code
+        */
+        TInt GetTestCasesL( const TFileName& aTestCaseFile, 
+                            RPointerArray<TTestCaseInfo>& aTestCases );
+
+        /**
+        * From CTestModuleBase RunTestCaseL is used to run an individual 
+        *   test case. 
+        * @since ?Series60_version
+        * @param aCaseNumber Test case number
+        * @param aTestCaseFile Test case file (optional)
+        * @param aResult Test case result returned to test framework (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error, which is 
+        *           not reported in aResult parameter as test case failure).
+        */   
+        TInt RunTestCaseL( const TInt aCaseNumber, 
+                           const TFileName& aTestCaseFile,
+                           TTestResult& aResult );
+
+        /**
+        * From CTestModuleBase; OOMTestQueryL is used to specify is particular
+        * test case going to be executed using OOM conditions
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailureType OOM failure type (optional)
+        * @param aFirstMemFailure The first heap memory allocation failure value (optional)
+        * @param aLastMemFailure The last heap memory allocation failure value (optional)
+        * @return TBool
+        */
+        virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
+                                     const TInt /* aCaseNumber */, 
+                                     TOOMFailureType& aFailureType, 
+                                     TInt& /* aFirstMemFailure */, 
+                                     TInt& /* aLastMemFailure */ );
+
+        /**
+        * From CTestModuleBase; OOMTestInitializeL may be used to initialize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
+                                    const TInt /* aCaseNumber */ ); 
+
+        /**
+        * From CTestModuleBase; OOMHandleWarningL
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailNextValue FailNextValue for OOM test execution (optional)
+        * @return None
+        *
+        * User may add implementation for OOM test warning handling. Usually no
+        * implementation is required.           
+        */
+        virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
+                                        const TInt /* aCaseNumber */, 
+                                        TInt& /* aFailNextValue */); 
+
+        /**
+        * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
+        * test environment
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        *
+        */
+        virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
+                                       const TInt /* aCaseNumber */ );
+        
+        /**
+         * Method used to log version of test module
+         */
+        void SendTestModuleVersion();
+
+    protected:  // New functions
+
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        Chelixstif();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // ?classname( const ?classname& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // ?classname& operator=( const ?classname& );
+
+        /**
+        * Function returning test case name and pointer to test case function.
+        * @since ?Series60_version
+        * @param aCaseNumber test case number
+        * @return TCaseInfo 
+        */
+        const TCaseInfo Case ( const TInt aCaseNumber ) const;
+
+        /**
+        * [test case declarations] - do not remove
+        */
+        //ADD NEW METHOD DEC HERE"
+
+        /**
+        * Printing test case.
+        * @since ?Series60_version
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt PrintTest( TTestResult& aResult );
+
+        /**
+        * Printing loop test case.
+        * @since ?Series60_version
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        
+        TInt ConstructTestL( TTestResult& aResult );
+        
+        TInt InitializeTestL( TTestResult& aResult );
+        
+        TInt DecryptTestL( TTestResult& aResult );
+        
+        TInt Chelixstif::CloseTestL( TTestResult& aResult );
+        
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // Pointer to test (function) to be executed
+        TestFunction iMethod;
+
+        // Pointer to logger
+        CStifLogger * iLog; 
+
+        // Normal logger
+        CStifLogger* iStdLog;
+
+        // Test case logger
+        CStifLogger* iTCLog;
+
+        // Flag saying if test case title should be added to log file name
+        TBool iAddTestCaseTitleToLogName;
+
+        // Flag saying if version of test module was already sent
+        TBool iVersionLogged;
+
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+#endif      // HELIXSTIF_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/tsrc/src/helixstif.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,442 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: This file contains Hardcoded module implementation.
+*
+*/
+
+
+// [INCLUDE FILES] - do not remove
+#include <Stiftestinterface.h>
+#include "helixstif.h"
+#include <SettingServerClient.h>
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Chelixstif::Chelixstif
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+Chelixstif::Chelixstif()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::ConstructL
+// Symbian 2nd phase constructor can leave.
+//
+// Note: If OOM test case uses STIF Logger, then STIF Logger must be created
+// with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
+// allocates memory from heap and therefore causes error situations with OOM 
+// testing. For more information about STIF Logger construction, see STIF Users 
+// Guide.
+// -----------------------------------------------------------------------------
+//
+void Chelixstif::ConstructL()
+    {
+    //Read logger settings to check whether test case name is to be
+    //appended to log file name.
+    RSettingServer settingServer;
+    TInt ret = settingServer.Connect();
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        }
+    // Struct to StifLogger settigs.
+    TLoggerSettings loggerSettings; 
+    // Parse StifLogger defaults from STIF initialization file.
+    ret = settingServer.GetLoggerSettings(loggerSettings);
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        } 
+    // Close Setting server session
+    settingServer.Close();
+    iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle;
+
+    iStdLog = CStifLogger::NewL( KhelixstifLogPath, 
+                          KhelixstifLogFile);
+    iLog = iStdLog;
+
+    // Sample how to use logging
+    _LIT( KLogStart, "helixstif logging starts!" );
+    iLog->Log( KLogStart );
+
+    iVersionLogged = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+Chelixstif* Chelixstif::NewL()
+    {
+    Chelixstif* self = new (ELeave) Chelixstif;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+Chelixstif::~Chelixstif()
+    {
+    iLog = NULL;
+    delete iStdLog;
+    iStdLog = NULL;
+    delete iTCLog;
+    iTCLog = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::InitL
+// InitL is used to initialize the Test Module.
+// -----------------------------------------------------------------------------
+//
+TInt Chelixstif::InitL( 
+    TFileName& /*aIniFile*/, 
+    TBool /*aFirstTime*/ )
+    {
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::GetTestCasesL
+// GetTestCases is used to inquire test cases from the Test Module. Test
+// cases are stored to array of test cases. The Test Framework will be 
+// the owner of the data in the RPointerArray after GetTestCases return
+// and it does the memory deallocation. 
+// -----------------------------------------------------------------------------
+//
+TInt Chelixstif::GetTestCasesL( 
+    const TFileName& /*aConfig*/, 
+    RPointerArray<TTestCaseInfo>& aTestCases )
+    {
+
+    // Loop through all test cases and create new
+    // TTestCaseInfo items and append items to aTestCase array    
+    for( TInt i = 0; Case(i).iMethod != NULL; i++ )
+        {
+
+        // Allocate new TTestCaseInfo from heap for a testcase definition.
+        TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
+
+        // PushL TTestCaseInfo to CleanupStack.    
+        CleanupStack::PushL( newCase );
+
+        // Set number for the testcase.
+        // When the testcase is run, this comes as a parameter to RunTestCaseL.
+        newCase->iCaseNumber = i;
+
+        // Set title for the test case. This is shown in UI to user.
+        newCase->iTitle.Copy( Case(i).iCaseName );
+
+        // Append TTestCaseInfo to the testcase array. After appended 
+        // successfully the TTestCaseInfo object is owned (and freed) 
+        // by the TestServer. 
+        User::LeaveIfError(aTestCases.Append ( newCase ) );
+
+        // Pop TTestCaseInfo from the CleanupStack.
+        CleanupStack::Pop( newCase );
+
+        }
+
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::RunTestCaseL
+// RunTestCaseL is used to run an individual test case specified 
+// by aTestCase. Test cases that can be run may be requested from 
+// Test Module by GetTestCases method before calling RunTestCase.
+// -----------------------------------------------------------------------------
+//
+TInt Chelixstif::RunTestCaseL( 
+    const TInt aCaseNumber,   
+    const TFileName& /*aConfig*/,
+    TTestResult& aResult )
+    {
+    if(!iVersionLogged)
+    	{
+    	SendTestModuleVersion();
+    	iVersionLogged = ETrue;
+    	}
+    
+    // Return value
+    TInt execStatus = KErrNone;
+
+    // Get the pointer to test case function
+    TCaseInfo tmp = Case ( aCaseNumber );
+
+    _LIT( KLogStartTC, "Starting testcase [%S]" );
+    iLog->Log( KLogStartTC, &tmp.iCaseName);
+
+    // Check that case number was valid
+    if ( tmp.iMethod != NULL )
+        {
+        //Open new log file with test case title in file name
+        if(iAddTestCaseTitleToLogName)
+            {
+            //Delete test case logger if exists
+            if(iTCLog)
+                {
+                delete iTCLog;
+                iTCLog = NULL;
+                }
+
+            TFileName logFileName;
+            TName title;
+            TestModuleIf().GetTestCaseTitleL(title);
+        
+            logFileName.Format(KhelixstifLogFileWithTitle, &title);
+
+            iTCLog = CStifLogger::NewL(KhelixstifLogPath, 
+                                       logFileName);
+            iLog = iTCLog;                                       
+            }
+
+        // Valid case was found, call it via function pointer
+        iMethod = tmp.iMethod;        
+        //execStatus  = ( this->*iMethod )( aResult );
+        TRAPD(err, execStatus  = ( this->*iMethod )( aResult ));
+        if(iAddTestCaseTitleToLogName)
+            {
+            //Restore standard log and destroy test case logger
+            iLog = iStdLog;
+            delete iTCLog; //Close test case log
+            iTCLog = NULL;
+            }
+        User::LeaveIfError(err);
+        }
+    else
+        {
+        // Valid case was not found, return error.
+        execStatus = KErrNotFound;
+        }
+
+    // Return case execution status (not the result of the case execution)
+    return execStatus;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::OOMTestQueryL
+// Used to check if a particular test case should be run in OOM conditions and 
+// which memory allocations should fail.    
+// -----------------------------------------------------------------------------
+//
+TBool Chelixstif::OOMTestQueryL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt aCaseNumber, 
+                                TOOMFailureType& /* aFailureType */, 
+                                TInt& aFirstMemFailure, 
+                                TInt& aLastMemFailure ) 
+    {
+    _LIT( KLogOOMTestQueryL, "Chelixstif::OOMTestQueryL" );
+    iLog->Log( KLogOOMTestQueryL );     
+
+    aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
+    aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation;
+
+    return Case( aCaseNumber ).iIsOOMTest;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::OOMTestInitializeL
+// Used to perform the test environment setup for a particular OOM test case. 
+// Test Modules may use the initialization file to read parameters for Test 
+// Module initialization but they can also have their own configure file or 
+// some other routine to initialize themselves.  
+//
+// NOTE: User may add implementation for OOM test environment initialization.
+// Usually no implementation is required.
+// -----------------------------------------------------------------------------
+//
+void Chelixstif::OOMTestInitializeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::OOMHandleWarningL
+// In some cases the heap memory allocation should be skipped, either due to
+// problems in the OS code or components used by the code being tested, or even 
+// inside the tested components which are implemented this way on purpose (by 
+// design), so it is important to give the tester a way to bypass allocation 
+// failures.
+//
+// NOTE: User may add implementation for OOM test warning handling. Usually no
+// implementation is required.
+// -----------------------------------------------------------------------------
+//
+void Chelixstif::OOMHandleWarningL( 
+                                const TFileName& /* aTestCaseFile */,
+                                const TInt /* aCaseNumber */, 
+                                TInt& /* aFailNextValue */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::OOMTestFinalizeL
+// Used to perform the test environment cleanup for a particular OOM test case.
+//
+// NOTE: User may add implementation for OOM test environment finalization.
+// Usually no implementation is required.
+// -----------------------------------------------------------------------------
+//
+void Chelixstif::OOMTestFinalizeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+//-----------------------------------------------------------------------------
+// Chelixstif::SendTestModuleVersion
+// Method used to send version of test module
+//-----------------------------------------------------------------------------
+//
+void Chelixstif::SendTestModuleVersion()
+	{
+	TVersion moduleVersion;
+	moduleVersion.iMajor = TEST_MODULE_VERSION_MAJOR;
+	moduleVersion.iMinor = TEST_MODULE_VERSION_MINOR;
+	moduleVersion.iBuild = TEST_MODULE_VERSION_BUILD;
+	
+	TFileName moduleName;
+	moduleName = _L("helixstif.dll");
+
+	TBool newVersionOfMethod = ETrue;
+	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
+	}
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point
+// Returns: CTestModuleBase*: Pointer to Test Module object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTestModuleBase* LibEntryL()
+    {
+    return Chelixstif::NewL();
+
+    }
+
+// -----------------------------------------------------------------------------
+// SetRequirements handles test module parameters(implements evolution
+// version 1 for test module's heap and stack sizes configuring).
+// Returns: TInt: Symbian error code.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
+                                TUint32& /*aParameterValid*/ )
+    {
+
+    /* --------------------------------- NOTE ---------------------------------
+    USER PANICS occurs in test thread creation when:
+    1) "The panic occurs when the value of the stack size is negative."
+    2) "The panic occurs if the minimum heap size specified is less
+       than KMinHeapSize".
+       KMinHeapSize: "Functions that require a new heap to be allocated will
+       either panic, or will reset the required heap size to this value if
+       a smaller heap size is specified".
+    3) "The panic occurs if the minimum heap size specified is greater than
+       the maximum size to which the heap can grow".
+    Other:
+    1) Make sure that your hardware or Symbian OS is supporting given sizes.
+       e.g. Hardware might support only sizes that are divisible by four.
+    ------------------------------- NOTE end ------------------------------- */
+
+    // Normally STIF uses default heap and stack sizes for test thread, see:
+    // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
+    // If needed heap and stack sizes can be configured here by user. Remove
+    // comments and define sizes.
+
+/*
+    aParameterValid = KStifTestModuleParameterChanged;
+
+    CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
+    // Stack size
+    param->iTestThreadStackSize= 16384; // 16K stack
+    // Heap sizes
+    param->iTestThreadMinHeap = 4096;   // 4K heap min
+    param->iTestThreadMaxHeap = 1048576;// 1M heap max
+
+    aTestModuleParam = param;
+*/
+    return KErrNone;
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/tsrc/src/helixstifcases.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,265 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+* 
+* Description: This file contains hardcoded module implementation.
+*
+*/
+
+
+// [INCLUDE FILES] - do not remove
+#include <e32math.h>
+#include <e32base.h>
+#include <wmdrmaccess.h>
+#include "helixstif.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Chelixstif::Case
+// Returns a test case by number.
+//
+// This function contains an array of all available test cases 
+// i.e pair of case name and test function. If case specified by parameter
+// aCaseNumber is found from array, then that item is returned.
+// 
+// The reason for this rather complicated function is to specify all the
+// test cases only in one place. It is not necessary to understand how
+// function pointers to class member functions works when adding new test
+// cases. See function body for instructions how to add new test case.
+// -----------------------------------------------------------------------------
+//
+const TCaseInfo Chelixstif::Case ( 
+    const TInt aCaseNumber ) const 
+     {
+
+    /**
+    * To add new test cases, implement new test case function and add new 
+    * line to KCases array specify the name of the case and the function 
+    * doing the test case
+    * In practice, do following
+    * 1) Make copy of existing test case function and change its name
+    *    and functionality. Note that the function must be added to 
+    *    helixstif.cpp file and to helixstif.h 
+    *    header file.
+    *
+    * 2) Add entry to following KCases array either by using:
+    *
+    * 2.1: FUNCENTRY or ENTRY macro
+    * ENTRY macro takes two parameters: test case name and test case 
+    * function name.
+    *
+    * FUNCENTRY macro takes only test case function name as a parameter and
+    * uses that as a test case name and test case function name.
+    *
+    * Or
+    *
+    * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
+    * only with OOM (Out-Of-Memory) testing!
+    *
+    * OOM_ENTRY macro takes five parameters: test case name, test case 
+    * function name, TBool which specifies is method supposed to be run using
+    * OOM conditions, TInt value for first heap memory allocation failure and 
+    * TInt value for last heap memory allocation failure.
+    * 
+    * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
+    * that as a test case name, TBool which specifies is method supposed to be
+    * run using OOM conditions, TInt value for first heap memory allocation 
+    * failure and TInt value for last heap memory allocation failure. 
+    */ 
+
+    static TCaseInfoInternal const KCases[] =
+        {
+        // [test cases entries] - do not remove
+        
+        // NOTE: When compiled to GCCE, there must be Classname::
+        // declaration in front of the method name, e.g. 
+        // Chelixstif::PrintTest. Otherwise the compiler
+        // gives errors.
+        
+        ENTRY( "ConstructTtest", Chelixstif::ConstructTestL ),
+        ENTRY( "InitializeTest", Chelixstif::InitializeTestL ),
+        ENTRY( "DecryptTest", Chelixstif::DecryptTestL ),
+        ENTRY( "CloseTest", Chelixstif::CloseTestL )
+        
+        };
+
+    // Verify that case number is valid
+    if( (TUint) aCaseNumber >= sizeof( KCases ) / 
+                               sizeof( TCaseInfoInternal ) )
+        {
+        // Invalid case, construct empty object
+        TCaseInfo null( (const TText*) L"" );
+        null.iMethod = NULL;
+        null.iIsOOMTest = EFalse;
+        null.iFirstMemoryAllocation = 0;
+        null.iLastMemoryAllocation = 0;
+        return null;
+        } 
+
+    // Construct TCaseInfo object and return it
+    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
+    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
+    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
+    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
+    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
+    return tmp;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::ConstructTest
+// Constructor test, constructs CWmDrmAccess object
+// -----------------------------------------------------------------------------
+//
+TInt Chelixstif::ConstructTestL( TTestResult& aResult )
+    {
+
+    CWmDrmAccess* helixnewltest = CWmDrmAccess::NewL();
+    
+    _LIT( KState, "TestNewL" );
+    
+    iLog->Log( KState );
+    
+    // Sets test case result and description
+    
+    _LIT( KDescription, "ConstructTest passed" );
+    
+    // Check the condition
+    
+    TL( helixnewltest != NULL );
+    
+    aResult.SetResult( KErrNone, KDescription );
+
+    delete helixnewltest;
+    
+    // Case was executed
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::InitializeTest
+// Initialize test, check for the Initialize function
+// -----------------------------------------------------------------------------
+//
+TInt Chelixstif::InitializeTestL( TTestResult& aResult )
+    {
+    _LIT8(KEmpty,"abc");
+    
+    CWmDrmAccess* helixinitializetest = CWmDrmAccess::NewL();
+    
+    // Check the condition
+    
+    TL(KErrNone != helixinitializetest->Initialize( KEmpty() )) ;
+    
+    TL( helixinitializetest != NULL );
+    
+    _LIT( KState, "TestInitialize" );
+    
+    iLog->Log( KState );
+    
+    // Sets test case result and description
+    
+    _LIT( KDescription, "InitializeTest passed" );
+    
+    aResult.SetResult( KErrNone, KDescription );
+        
+    delete helixinitializetest;
+    
+    // Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// Chelixstif::DecryptTest
+// Decrypt test, check for the Decrypt function
+// -----------------------------------------------------------------------------
+//    
+    
+TInt Chelixstif::DecryptTestL( TTestResult& aResult )
+    {
+    
+    CWmDrmAccess* helixdecrypttest = CWmDrmAccess::NewLC();
+        
+    TPtr8 buffer(NULL,0);
+        
+    HBufC8* buf = HBufC8::NewMaxLC(5);
+        
+    buffer.Set( const_cast<TUint8*>(buf->Ptr()),0,5);
+    buffer.Append(_L8("abcde"));
+    
+    TInt retval;
+    
+    retval = helixdecrypttest->Decrypt( buffer );
+    
+    TL( KErrNone != retval ) ;
+        
+    _LIT( KState, "TestDecrypt" );
+    
+    iLog->Log( KState );
+    
+    // Sets test case result and description
+    
+    _LIT( KDescription, "DecryptTest passed" );
+    
+    // Check for the condition
+    
+    TL( helixdecrypttest != NULL );
+    TL( retval == KErrNotReady );
+    
+    aResult.SetResult( KErrNone, KDescription );
+
+    CleanupStack::PopAndDestroy(buf);
+    CleanupStack::PopAndDestroy(helixdecrypttest);
+       
+    // Case was executed
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Chelixstif::CloseTest
+// Close test, check for the Close function
+// -----------------------------------------------------------------------------
+//    
+TInt Chelixstif::CloseTestL( TTestResult& aResult )
+    {
+    CWmDrmAccess* helixclosetest = CWmDrmAccess::NewLC();
+        
+    _LIT( KState, "TestClose" );
+    
+    iLog->Log( KState );
+    
+    int retval;
+
+    TL( helixclosetest != NULL );
+    
+    retval = helixclosetest->Close();
+    
+    // Sets test case result and description
+    
+    _LIT( KDescription, "CloseTest passed" );
+    
+    // Check for the condition
+    
+    TL( retval == KErrNone );
+    
+    aResult.SetResult( KErrNone, KDescription );
+
+    CleanupStack::PopAndDestroy(helixclosetest);
+    
+    // Case was executed
+    return KErrNone;
+
+    }
+
+//  [End of File] - do not remove
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_access_api/wmdrm_access_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<api id="6d48dd3dc28a9a440c66082ef114909b" dataversion="2.0">
+  <name>WMDRM Access API</name>
+  <description>WMDRM Access API</description>
+  <type>c++</type>
+  <collection>wmdrm</collection>
+  <libs>
+    <lib name="wmdrmaccess.lib"/>
+  </libs>
+  <release category="platform" sinceversion="5.2"/>
+  <attributes>
+    <htmldocprovided>no</htmldocprovided>
+    <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_core_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project wmdrm_core_api
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+#if (defined __WINDOWS_MEDIA_DRM)
+../inc/wmdrmagent.h     MW_LAYER_PLATFORM_EXPORT_PATH(wmdrmagent.h)
+#endif // __WINDOWS_MEDIA_DRM
+
+PRJ_MMPFILES
+
+PRJ_TESTMMPFILES
+
+PRJ_TESTEXPORTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_core_api/inc/wmdrmagent.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,82 @@
+/*
+* 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:  Contains the WM DRM CAF Agent specific data types, commands
+*                and attributes
+*
+*/
+
+
+
+#ifndef WMDRMAGENT_H
+#define WMDRMAGENT_H
+
+//  INCLUDES
+#include <caf/caftypes.h>
+
+// CONSTANTS
+_LIT(KWmDrmAgentName, "WM DRM Agent");
+
+_LIT8(KWmTriggerContentType, "application/asf.wmdrm.roap-trigger+xml");
+_LIT8(KWmfImportContentType, "application/x-asf.drm.import");
+_LIT8(KWmfContentType, "application/vnd.drm.asf");
+_LIT8(KWmaContentType, "audio/x-ms-wma");
+_LIT8(KWmvContentType, "video/x-ms-wmv");
+_LIT8(KAsfFileType, "application/vnd.ms-asf" );
+
+_LIT(KWmDrmWmaExtension, ".wma");
+_LIT(KWmDrmWmvExtension, ".wmv");
+_LIT(KWmDrmAsfExtension, ".asf");
+
+
+// DATA TYPES
+
+namespace ContentAccess
+{
+// Agent specific attribute identifiers
+
+enum TWmDrmAgentStringAttribute
+    {
+    ERating = EAgentSpecificAttributeBase + 1,
+    EPicture,
+    EText,
+    EComposer,
+    EYear,
+    EOriginalArtist,
+    EWmTrackNumber,
+    EUniqueFileID,
+    EAudioFileUrl,
+    ESharedUserRating,
+    EDate
+    };
+
+// File types
+    
+enum
+    {
+    EAsf = 3, // next in line after OMA DRM file types
+    };
+    
+}
+
+namespace DRM
+    {
+    enum TWmDrmAgentManagerCommands
+        {
+        EWmDrmDeleteRights
+        };
+    }
+
+#endif      // WMDRMAGENT_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_plat/wmdrm_core_api/wmdrm_core_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="bd89e8a1cb6e1eab770e11ea45f6ff9a" dataversion="1.0">
+<name>wmdrm core api</name>
+<description>WMDRM Core functionality</description>
+<type>c++</type>
+<subsystem>WMDRM</subsystem>
+<libs><lib name="wmdrmagent.lib"/>
+<lib name="wmdrmpkclient.lib"/>
+<lib name="wmdrmota.lib"/>
+<lib name="wmdrmpd.lib"/>
+</libs>
+<release category="domain" sinceversion="5.1"/>
+<attributes>
+<htmldocprovided>no</htmldocprovided>
+<adaptation>no</adaptation>
+</attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/drm_helper_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="55bb51a038a2199b4ffb2e63815065d6" dataversion="1.0">
+  <name>DRM Helper API</name>
+  <description>Provides methods for DRM specific error handling and registering and unregistering DRM protected content as automated content</description>
+  <type>c++</type>
+  <subsystem>omadrm</subsystem>
+  <libs>
+    <lib name="DRMHelper.lib" />
+  </libs>
+  <release category="sdk" sinceversion="2.6"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,30 @@
+/*
+* 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:  File that exports the files belonging to 
+:                DRM Helper API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/DRMHelperServerInternalCRKeys.h     MW_LAYER_PUBLIC_EXPORT_PATH(DRMHelperServerInternalCRKeys.h)
+../inc/RDRMHelper.h     MW_LAYER_PUBLIC_EXPORT_PATH(rdrmhelper.h)
+../loc/DRMCommon.loc     MW_LAYER_LOC_EXPORT_PATH(drmcommon.loc)
+../inc/Drmhelper.h     MW_LAYER_PUBLIC_EXPORT_PATH(DRMHelper.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/inc/DRMHelperServerInternalCRKeys.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+#ifndef DRMHELPERSERVERINTERNALCRKEYS_H
+#define DRMHELPERSERVERINTERNALCRKEYS_H
+
+//#include <DRMHelperServerSDKCRKeys.h>
+
+const TUid KCRUidDRMHelperServer = {0x10205CA7};
+
+/* Key format for both KDRMHelperServerNotification and KDRMHelperServerNotificationPassive
+
+To inform the expiration event of automated usage to active clients. 
+The first Tuint8 is the times the content has been informed, the second
+ Tuint8 could either be 'E' or 'V', 'E' means expired and 'V' means 
+ valid but about to expire. The third is permission type (which is 
+ defined in caf.h, including EPlay, EExcute, EView, EPrint, EPeek). 
+ The rest of data is the content ID. So, the whole format of the 
+ values would be "<TUint8 aTimes><TUint8 aExpirationMark><TUint8
+  aPermissionType><TDesC8 aContentID>".
+  
+*/ 
+
+const TUint32 KDRMHelperServerNotification = 0x00000001;
+const TUint32 KDRMHelperServerNotificationPassive = 0x00000002;
+
+#endif      // DRMHELPERSERVERINTERNALCRKEYS_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/inc/Drmhelper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1594 @@
+/*
+* Copyright (c) 2003, 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:  Class to show miscellaneous DRM related error notes and 
+*                details about rights 
+*
+*/
+
+
+
+#ifndef __DRMHELPER_H__
+#define __DRMHELPER_H__
+
+//  INCLUDES
+#include <e32base.h>
+#include <ConeResLoader.h>
+#include <apparc.h>
+#include <rdrmhelper.h>
+#include <aknserverapp.h>
+#include <caf/caf.h>
+#include <caf/content.h>
+#include <caf/data.h>
+#include <eikdialg.h>
+
+using namespace ContentAccess;
+
+// CONSTANTS
+const TInt KDRMHelperDefaultCountThreshold = 3;
+const TInt KDRMHelperDefaultTimeThreshold = 7;
+const TInt KDRMHelperDefaultPercentageThreshold = 10;
+const TInt KDRMHelperNoteMaxSize ( 256 );  
+
+// MACROS
+
+// DATA TYPES
+enum TDRMHelperPreviewMediaType
+        {
+        EPreviewTypeAudio,
+        EPreviewTypeVideo
+        };
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+class DRMCommon;
+class CDRMRightsConstraints;
+class CDRMRights;
+class CStringResourceReader;
+class TDataType;
+class CCoeEnv;
+class CConsumeData;
+class CDRMPermission;
+class CDRMConstraint;
+class CAknGlobalNote;
+class CAknWaitDialog;
+class CDRMHelperInfoNoteWrapper;
+class CSchemeHandler;
+class CMediatorEventProvider;
+
+// CLASS DECLARATION
+
+/**
+*  Helper class for wrapping CDRMRightsConstraints.
+*
+*  @lib drmhelper.lib
+*  @since Series 60 2.1
+*/
+class CDRMHelperRightsConstraints : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDRMHelperRightsConstraints* NewL( 
+            CDRMRightsConstraints* aConstraints );
+        static CDRMHelperRightsConstraints* NewLC( 
+            CDRMRightsConstraints* aConstraints );
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C ~CDRMHelperRightsConstraints();
+
+    public: // New functions
+
+        /**
+        * checks if the object contains any restrictions 
+        * or if usage is unconstrained.        
+        * @return ETrue if usage is unconstrained
+        */
+        IMPORT_C TBool FullRights();
+
+        /**
+        * checks if the object contains only preview rights 
+        * @return ETrue if object contains only preview rights
+        */
+        IMPORT_C TBool IsPreview();
+
+        /**
+        * Gets number of counts left and number of original counts.
+        * Leaves with KErrNotFound if object doesn't have count based rights.
+        * @param aCounter: (out) counts left
+        * @param aOriginalCounter: (out) number of counts when stored to 
+        *                          rights db
+        * @return -
+        */
+        IMPORT_C void GetCountersL( TUint32& aCounter, 
+            TUint32& aOriginalCounter );
+
+        /**
+        * Gets start time of time based rights.
+        * Leaves with KErrNotFound if object doesn't have time based rights.
+        * @param aStartTime: (out) start time
+        * @return -
+        */
+        IMPORT_C void GetStartTimeL( TTime& aStartTime );
+
+        /**
+        * Gets end time of time based rights.
+        * Leaves with KErrNotFound if object doesn't have time based rights.
+        * @param aEndTime: (out) start time
+        * @return -
+        */
+        IMPORT_C void GetEndTimeL( TTime& aEndTime );
+
+        /**
+        * Gets interval time constraint.
+        * Leaves with KErrNotFound if object doesn't have interval constraint.
+        * @param aInterval: (out) interval
+        * @return -
+        */
+        IMPORT_C void GetIntervalL( TTimeIntervalSeconds& aInterval );
+
+        /**
+        * Gets start time of activated interval constraint.
+        * Leaves with KErrNotFound if interval has not been started yet.
+        * @param aStartTime: (out) start time of activated interval
+        * @return -
+        */
+
+        IMPORT_C void GetIntervalStartL( TTime& aStartTime );
+        /**
+        * Gets number of counts left, number of original counts and timer 
+        * value for timed-count constraint.
+        * Leaves with KErrNotFound if object doesn't have timed-count 
+        * constraint.
+        * @param aCounter: (out) counts left
+        * @param aOriginalCounter: Invalid, value returned same as aCounter
+        * @param aTimer: (out) timer value
+        * @return -
+        * @since Series 60 3.0
+        */
+        IMPORT_C void GetTimedCountL( TUint32& aCounter, 
+            TUint32& aOriginalCounter, TTimeIntervalSeconds& aTimer );
+
+        /**
+        * Gets accumulated time left.
+        * Leaves with KErrNotFound if object doesn't have accumulated time 
+        * constraint.
+        * @param aAccumulatedTime: (out) accumulated time left
+        * @return -
+        * @since Series 60 3.0
+        */
+        IMPORT_C void GetAccumulatedTimeL( TTimeIntervalSeconds& aAccumulatedTime );
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDRMHelperRightsConstraints( CDRMRightsConstraints* aConstrains );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    private:    // Data
+        // pointer to CDRMRightsConstraints object
+        CDRMRightsConstraints* iConstraints;
+    };
+
+
+/**
+*  Handles some error situations DRM-aware applications may encounter.
+*
+*  @lib drmhelper.lib
+*  @since Series 60 2.1
+*/
+class CDRMHelper : public CBase, public MAknServerAppExitObserver
+    {
+    public:     // Data
+    
+    enum TDRMHelperNotificationID
+        {
+        ETActivateTextId = 1,
+        ETCountBasedErrorTextId = 2 ,
+        ETCountUsageReduceId = 3,
+        ETCountUsageReduceMediaId = 4
+        };
+
+    enum TDRMHelperConsumeAction
+        {
+        EStart,
+        EFinish,
+        EPause, 
+        EContinue
+        };
+
+    enum TDRMHelperOMALevel
+        {
+        EOMA_None, 
+        EOMA_1_0,
+        EOMA_2_0
+        };
+        
+	enum TDRMHelperPreviewType 
+		{
+		ENoPreview, 
+		EEmbeddedPreview,
+		EPreviewRights
+		};
+
+    enum TDRMHelperAutomatedType
+        {
+        EAutomatedTypeRingingTone,
+        EAutomatedTypeMessageAlert,
+        EAutomatedTypeEmailAlert,
+        EAutomatedTypeIMAlert,
+        EAutomatedTypeCalendarAlarm,
+        EAutomatedTypeScreenSaver,
+        EAutomatedTypeWallpaper, 
+        EAutomatedTypeTheme,
+        EAutomatedTypeClockAlarm, 
+        EAutomatedTypeOther = KMaxTUint8
+        };
+
+    enum TDRMHelperDRMMethods
+        {
+        EForwardLock = 0x0001, 
+        ECombinedDelivery = 0x0002, 
+        ESeparateDelivery = 0x0004, 
+        ESuperDistribution = 0x0008
+        };
+
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CDRMHelper* NewL( CCoeEnv& aCoeEnv );
+        IMPORT_C static CDRMHelper* NewLC( CCoeEnv& aCoeEnv );
+
+        /**
+        * Two-phased constructor.
+        * @since Series 60 2.6
+        */
+        IMPORT_C static CDRMHelper* NewL();
+        IMPORT_C static CDRMHelper* NewLC();
+        
+        /**
+        * Two-phased constructor.
+        * @since Series 60 3.0
+        */
+        IMPORT_C static CDRMHelper* NewL( CCoeEnv& aCoeEnv, RFs& aFs );
+        IMPORT_C static CDRMHelper* NewLC( CCoeEnv& aCoeEnv, RFs& aFs );
+
+        /**
+        * Two-phased constructor.
+        * @since Series 60 3.0
+        */
+        IMPORT_C static CDRMHelper* NewL( RFs& aFs );
+        IMPORT_C static CDRMHelper* NewLC( RFs& aFs );
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C ~CDRMHelper();
+
+       
+    public: 
+
+        /**
+        * Displays appropriate error note depending on error code.
+        * @param aError: error code returned by DRM engine
+        * @param aURI: URI of the file
+        * @return 
+        * - Button code, if user selected "buy rights" or "launch rights 
+        *   manager" in query.
+        * - 0 if user selected "No", "Back" or "Cancel" (or whatever which 
+        *   just dismiss the query)
+        * - 0 if just a simple error note is displayed
+        */
+        IMPORT_C TInt HandleErrorL( TInt aError, 
+            const TDesC8& aURI );
+
+
+        /**
+        * Displays:
+        * Handles error situations 'rights expired', 'no rights' and
+        * 'rights database corrupted'.
+        * @param aError: error code returned by DRM engine
+        * @param aFileName: full path to file
+        * @return 
+        * - Button code, if user selected "buy rights" or "launch rights 
+        *   manager" in query.
+        * - 0 if user selected "No", "Back" or "Cancel" (or whatever which 
+        *   just dismiss the query)
+        * - 0 if just a simple error note is displayed
+        */
+        IMPORT_C TInt HandleErrorL( TInt aError, 
+            const TDesC& aFileName );
+
+
+        /**
+        * Displays:
+        * Handles error situations 'rights expired', 'no rights' and
+        * 'rights database corrupted'.
+        * @param aError: error code returned by DRM engine
+        * @param aFileHandle: file handle to the file
+        * @return 
+        * - Button code, if user selected "buy rights" or "launch rights 
+        *   manager" in query.
+        * - 0 if user selected "No", "Back" or "Cancel" (or anything that 
+        *   just dismisses the query)
+        * - 0 if just a simple error note is displayed
+        * @since  3.0
+        */
+        IMPORT_C TInt HandleErrorL( TInt aError, 
+            RFile& aFileHandle );
+
+       /**
+        * Handles DRM-specific error situations. Should be called instead of 
+        * HandleErrorL if user should be asked to play embedded preview or get 
+        * preview/silent rights if there is no valid rights and either embedded preview or
+        * preview rights are available.
+        * @param aError: error code to be handled.
+        * @param aFile: handle of file for which error was received.
+        * @param aEmbeddedPreviewUri: contain URI of embedded preview part 
+        * upon return if caller should play the embedded preview. If embedded
+        * preview should not be played this is NULL. Must be freed by caller.
+        * @return KErrNone if the content is now usable (e.g. silent rights or preview rights were gotten). If
+        *                  the return code is KErrNone and the aEmbeddedPreviewUri parameter is not NULL,
+        *                  the player should use embedded preview
+        *         KErrCancel if the user cancelled any of the actions within the function
+        *         KErrCANoRights and KErrCANoPermission if after the function call, still no rights exist
+        *         KErrCompletion if the user did launch the browser, but it is not clear whether the content
+        *                  was activated
+        * @since S60 3.1
+        */
+        IMPORT_C TInt HandleErrorOrPreviewL( 
+            TInt aError, 
+            RFile& aFile, 
+            HBufC8*& aEmbeddedPreviewUri );
+
+       /**
+        * Handles DRM specific error situations. Should be called instead of 
+        * HandleErrorL if user should be asked to play embedded preview or get 
+        * preview/silent rights if there is no valid rights and either embedded preview or
+        * preview rights are available.
+        * @param aError: error code to be handled.
+        * @param aFileName: name of file for which error was received.
+        * @param aEmbeddedPreviewUri: contain URI of embedded preview part 
+        * upon return if caller should play the embedded preview. If embedded
+        * preview should not be played this is NULL. Must be freed by caller.
+        * @return KErrNone if the content is now usable (e.g. silent rights or preview rights were gotten). If
+        *                  the return code is KErrNone and the aEmbeddedPreviewUri parameter is not NULL,
+        *                  the player should use embedded preview
+        *         KErrCancel if the user cancelled any of the actions within the function
+        *         KErrCANoRights and KErrCANoPermission if after the function call, still no rights exist
+        *         KErrCompletion if the user did launch the browser, but it is not clear whether the content
+        *                  was activated
+        * @since S60 3.1
+        */
+        IMPORT_C TInt HandleErrorOrPreviewL( 
+            TInt aError, 
+            const TDesC& aFileName, 
+            HBufC8*& aEmbeddedPreviewUri );
+
+        /**
+        * Check rights for the content. If there is less than given amount 
+        * of usage time/count left, appropriate note is displayed
+        * depending on situation.
+        * @param  aURI: URI of the file
+        * @return Button code
+        */
+        // causes conflict with other CheckRightsAmount method, removed for now...
+//        IMPORT_C TInt CheckRightsAmountL( const TDesC8& aURI );
+
+
+        /**
+        * Check rights for the file. If there is less than given amount 
+        * of usage time/count/percentage left, appropriate note is displayed
+        * depending on situation.
+        * @param  aFileName: Full path to file
+        * @return Button code
+        */
+        // causes conflict with other CheckRightsAmount method, removed for now...
+//        IMPORT_C TInt CheckRightsAmountL( const TDesC& aFileName );
+                
+
+        /**
+        * Check rights for the file. If there is less than given amount 
+        * of usage time/count/percentage left, appropriate note is displayed
+        * depending on situation.
+        * @param  aFileHandle: file handle to the file
+        * @return Button code
+        * @since  3.0
+        */
+        // causes conflict with other CheckRightsAmount method, removed for now...
+//        IMPORT_C TInt CheckRightsAmountL( RFile& aFileHandle );
+
+
+        /**
+        * Check rights for the file. If there is less than given amount 
+        * of usage time/count left, one of the following note is displayed
+        * depending on situation:
+        * 'Usage rights about to expire. View details?'
+        * 'Usage rights about to expire. %N days left. View details?'
+        * 'Usage rights about to expire. 1 day left. View details?'
+        * 'Usage rights about to expire. %N counts left. View details?'
+        * 'Usage rights about to expire. 1 count left. View details?'
+        * It also checks that rights are valid and displays appropriate note,
+        * if they are not.
+        * @param  aFileName: Full path to file
+        * @param  aCount: Threshold value for count limit
+        * @param  aDays: Threshold value for time limit in days
+        * @return Button code
+        */
+        IMPORT_C TInt CheckRightsAmountL( const TDesC& aFileName, 
+            TInt aCount = KDRMHelperDefaultCountThreshold, 
+            TInt aDays = KDRMHelperDefaultTimeThreshold );
+
+
+        /**
+        * Check rights for the file. If there is less than given amount 
+        * of usage time/count left, one of the following note is displayed
+        * depending on situation:
+        * 'Usage rights about to expire. View details?'
+        * 'Usage rights about to expire. %N days left. View details?'
+        * 'Usage rights about to expire. 1 day left. View details?'
+        * 'Usage rights about to expire. %N counts left. View details?'
+        * 'Usage rights about to expire. 1 count left. View details?'
+        * It also checks that rights are valid and displays appropriate note,
+        * if they are not.
+        * @param  aFileHandle: file handle to the file
+        * @param  aCount: Threshold value for count limit
+        * @param  aDays: Threshold value for time limit in days
+        * @return Button code
+        * @since  3.0
+        */
+        IMPORT_C TInt CheckRightsAmountL( RFile& aFileHandle, 
+            TInt aCount = KDRMHelperDefaultCountThreshold, 
+            TInt aDays = KDRMHelperDefaultTimeThreshold );
+
+
+        /**
+        * Check rights for the file. If there is less than given amount 
+        * of usage time/count left, one of the following note is displayed
+        * depending on situation:
+        * 'Usage rights about to expire. View details?'
+        * 'Usage rights about to expire. %N days left. View details?'
+        * 'Usage rights about to expire. 1 day left. View details?'
+        * 'Usage rights about to expire. %N counts left. View details?'
+        * 'Usage rights about to expire. 1 count left. View details?'
+        * It also checks that rights are valid and displays appropriate note,
+        * if they are not.
+        * @param  aUri: Content URI
+        * @param  aCount: Threshold value for count limit
+        * @param  aDays: Threshold value for time limit in days
+        * @return Button code
+        */
+        IMPORT_C TInt CheckRightsAmountL( const TDesC8& aUri, 
+            TInt aCount = KDRMHelperDefaultCountThreshold, 
+            TInt aDays = KDRMHelperDefaultTimeThreshold );
+
+
+        /**
+        * Check rights for the file. If there is less than aThreshold percent 
+        * of usage time/count left, one of the following note is displayed
+        * depending on situation:
+        * 'Usage rights about to expire. View details?'
+        * 'Usage rights about to expire. %N days left. View details?'
+        * 'Usage rights about to expire. 1 day left. View details?'
+        * 'Usage rights about to expire. %N counts left. View details?'
+        * 'Usage rights about to expire. 1 count left. View details?'
+        * It also checks that rights are valid and displays appropriate note,
+        * if they are not.
+        * @param  aFileName: Full path to file
+        * @param  aThreshold: Threshold value in percents for displaying the note
+        * @return Button code
+        */
+        IMPORT_C TInt CheckRightsPercentL( const TDesC& aFileName, 
+            TInt aThreshold = KDRMHelperDefaultPercentageThreshold );
+
+
+        /**
+        * Check rights for the file. If there is less than aThreshold percent 
+        * of usage time/count left, one of the following note is displayed
+        * depending on situation:
+        * 'Usage rights about to expire. View details?'
+        * 'Usage rights about to expire. %N days left. View details?'
+        * 'Usage rights about to expire. 1 day left. View details?'
+        * 'Usage rights about to expire. %N counts left. View details?'
+        * 'Usage rights about to expire. 1 count left. View details?'
+        * It also checks that rights are valid and displays appropriate note,
+        * if they are not.
+        * @param  aFileHandle: file handle to the file
+        * @param  aThreshold: Threshold value in percents for displaying the note
+        * @return Button code
+        * @since  3.0
+        */
+        IMPORT_C TInt CheckRightsPercentL( RFile& aFileHandle, 
+            TInt aThreshold = KDRMHelperDefaultPercentageThreshold );
+
+
+        /**
+        * Launches DRM Rights Manager UI embedded with details view related 
+        * to given content.
+        * @param aURI: URI of the file
+        * @return -
+        */
+        IMPORT_C void LaunchDetailsViewEmbeddedL( 
+            const TDesC8& aURI );
+
+		
+        /**
+        * Launches DRM Rights Manager UI embedded with details view related 
+        * to given file.
+        * @param aFileName: Full path to file
+        * @return -
+        */
+        IMPORT_C void LaunchDetailsViewEmbeddedL( 
+            const TDesC& aFileName );
+
+
+        /**
+        * Launches DRM Rights Manager UI embedded with details view related 
+        * to given file.    
+        * @param  aFileHandle: file handle to the file
+        * @return -
+        * @since  3.0
+        */
+        IMPORT_C void LaunchDetailsViewEmbeddedL( 
+            RFile& aFileHandle );
+
+
+        /**
+        * Launches DRM Rights Manager UI embedded with details view related 
+        * to given content.
+        * @param aContentURI: URI of the content
+        * @return -
+        */
+        IMPORT_C void LaunchDetailsViewEmbeddedL( 
+            const HBufC8* aContentURI );
+
+
+        /**
+        * Gets details of rights object associated of given file.
+        *
+        * @param[in]  aFileName Full path to file
+        * @param[in]  aIntent ContentAccess::EPlay, ContentAccess::EView,
+        * ContentAccess::EPrint or ContentAccess::EExecute 
+        * @param[out] aExpired ETrue if rights are not valid. If this is ETrue
+        * and some constraints are returned, rights will become valid in future
+        * @param[out] aSendingAllowed ETrue if content can be sent
+        * @param[out] aPlay play constraints, must be deleted by caller
+        * @param[out] aDisplay display constraints, must be deleted by caller
+        * @param[out] aExecute execute constraints, must be deleted by caller
+        * @param[out] aPrint print constraints, must be deleted by caller
+        *
+        * @leave KErrArgument file is not DRM-protected.
+        * @leave KErrCANoRights no rights
+        * @see caferr.h
+        * @see caftypes.h
+        */
+        IMPORT_C void GetRightsDetailsL( const TDesC& aFileName, 
+            TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed, 
+            CDRMHelperRightsConstraints*& aPlay, 
+            CDRMHelperRightsConstraints*& aDisplay, 
+            CDRMHelperRightsConstraints*& aExecute, 
+            CDRMHelperRightsConstraints*& aPrint );
+
+
+        /**
+        * Gets details of rights object associated of given file.
+        * 
+        * @param[in]  aFileHandle file handle to the file
+        * @param[in]  aIntent ContentAccess::EPlay, ContentAccess::EView,
+        * ContentAccess::EPrint or ContentAccess::EExecute 
+        * @param[out] aExpired ETrue if rights are not valid. If this is ETrue
+        * and some constraints are returned, rights will become valid in future
+        * @param[out] aSendingAllowed ETrue if content can be sent
+        * @param[out] aPlay play constraints, must be deleted by caller
+        * @param[out] aDisplay display constraints, must be deleted by caller
+        * @param[out] aExecute execute constraints, must be deleted by caller
+        * @param[out] aPrint print constraints, must be deleted by caller
+        *
+        * @leave KErrArgument file is not DRM-protected.
+        * @leave KErrCANoRights no rights
+        * @see caferr.h
+        * @see caftypes.h
+        *
+        * @since  3.0
+        */
+        IMPORT_C void GetRightsDetailsL( RFile& aFileHandle,  
+            TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed, 
+            CDRMHelperRightsConstraints*& aPlay, 
+            CDRMHelperRightsConstraints*& aDisplay, 
+            CDRMHelperRightsConstraints*& aExecute, 
+            CDRMHelperRightsConstraints*& aPrint );
+
+
+        /**
+        * Gets details of rights object associated of given file.
+        *
+        * @param[in]  aFileName Full path to file
+        * @param[in]  aIntent ContentAccess::EPlay, ContentAccess::EView,
+        * ContentAccess::EPrint or ContentAccess::EExecute 
+        * @param[out] aExpired ETrue if rights are not valid. If this is ETrue
+        * and some constraints are returned, rights will become valid in future
+        * @param[out] aSendingAllowed ETrue if content can be sent
+        * @param[out] aPlay play constraints, must be deleted by caller
+        * @param[out] aDisplay display constraints, must be deleted by caller
+        * @param[out] aExecute execute constraints, must be deleted by caller
+        * @param[out] aPrint print constraints, must be deleted by caller
+        *
+        * @leave KErrArgument file is not DRM-protected.
+        * @leave KErrCANoRights no rights
+        * @see caferr.h
+        * @see caftypes.h
+        */
+        IMPORT_C void GetRightsDetailsL( const TDesC& aFileName, 
+            TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed, 
+            CDRMRightsConstraints*& aPlay, 
+            CDRMRightsConstraints*& aDisplay, 
+            CDRMRightsConstraints*& aExecute, 
+            CDRMRightsConstraints*& aPrint ); 
+
+
+        /**
+        * Gets details of rights object associated of given file.
+        * 
+        * @param[in]  aFileHandle file handle to the file
+        * @param[in]  aIntent ContentAccess::EPlay, ContentAccess::EView,
+        * ContentAccess::EPrint or ContentAccess::EExecute 
+        * @param[out] aExpired ETrue if rights are not valid. If this is ETrue
+        * and some constraints are returned, rights will become valid in future
+        * @param[out] aSendingAllowed ETrue if content can be sent
+        * @param[out] aPlay play constraints, must be deleted by caller
+        * @param[out] aDisplay display constraints, must be deleted by caller
+        * @param[out] aExecute execute constraints, must be deleted by caller
+        * @param[out] aPrint print constraints, must be deleted by caller
+        *
+        * @leave KErrArgument file is not DRM-protected.
+        * @leave KErrCANoRights no rights
+        * @see caferr.h
+        * @see caftypes.h
+        *
+        * @since  3.0
+        */
+        IMPORT_C void GetRightsDetailsL( RFile& aFileHandle,  
+            TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed, 
+            CDRMRightsConstraints*& aPlay, 
+            CDRMRightsConstraints*& aDisplay, 
+            CDRMRightsConstraints*& aExecute, 
+            CDRMRightsConstraints*& aPrint ); 
+
+
+        /**
+        * Registers given content to be used as an automated content. This
+        * function is used when registering application listens expiry 
+        * notifications itself
+        * @param  aURI: content URI
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt SetAutomated( const TDesC8& aURI );
+
+
+        /**
+        * Registers given content to be used as an automated content. This
+        * function is used when registering application listens expiry 
+        * notifications itself.
+        * @param  aFileName: Full path to file
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt SetAutomated( const TDesC& aFilename );
+
+
+        /**
+        * Registers given content to be used as an automated content. This
+        * function is used when registering application listens expiry 
+        * @param  aFileHandle: file handle to the file
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since  3.0
+        */
+        IMPORT_C TInt SetAutomated( RFile& aFileHandle );
+
+
+        /**
+        * Displays the confirmation query about setting given content as an
+        * automated content. Note that this function does not actually
+        * register content, just displays the note
+        * @param  aURI: content URI
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt ShowAutomatedNote( const TDesC8& aURI );
+
+
+        /**
+        * Displays the confirmation query about setting given content as an
+        * automated content. Note that this function does not actually
+        * register content, just displays the note
+        * @param  aFileName: Full path to file
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt ShowAutomatedNote( const TDesC& aFilename );
+
+
+        /**
+        * Displays the confirmation query about setting given content as an
+        * automated content. Note that this function does not actually
+        * register content, just displays the note
+        * @param  aFileHandle: file handle to the file
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since  3.0
+        */
+        IMPORT_C TInt ShowAutomatedNote( RFile& aFileHandle );
+
+
+        /**
+        * Registers given content to be used as an automated content. This
+        * function is used when phone application listens to expiry notifications.
+        * @param  aURI: content URI
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt SetAutomatedPassive( const TDesC8& aURI );
+
+
+        /**
+        * Registers given content to be used as an automated content. This
+        * function is used when phone application listens to expiry notifications.
+        * @param  aFileName: Full path to file
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt SetAutomatedPassive( const TDesC& aFilename );
+
+
+        /**
+        * Registers given content to be used as an automated content. This
+        * function is used when phone application listens to expiry notifications.
+        * @param  aFileHandle: file handle to the file
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since  3.0
+        */
+        IMPORT_C TInt SetAutomatedPassive( RFile& aFileHandle );
+
+
+        /**
+        * Registers given content to be used as an automated content without
+        * confirmation query.
+        * @param aURI: content URI
+        * @param aActive: ETrue if registering application itself listens
+        *                 expiry notifications
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt SetAutomatedSilent( const TDesC8& aURI, TBool aActive );
+
+
+        /**
+        * Registers given content to be used as an automated content without
+        * confirmation query.
+        * @param  aFileName: Full path to file
+        * @param  aActive: ETrue if registering application itself listens
+        *                  expiry notifications
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt SetAutomatedSilent( const TDesC& aFilename, 
+            TBool aActive );
+
+
+        /**
+        * Registers given content to be used as an automated content without
+        * confirmation query.
+        * @param  aFileHandle: file handle to the file
+        * @param  aActive: ETrue if registering application itself listens
+        *                  expiry notifications
+        * @return System wide error code (KErrCancel if user pressed no to 
+        * query).
+        * @since  3.0
+        */
+        IMPORT_C TInt SetAutomatedSilent( RFile& aFileHandle,  
+            TBool aActive );
+
+
+        /**
+        * Unregisters given content to be used as an automated content.
+        * @param aURI: content URI
+        * @return System wide error code.
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt RemoveAutomated( const TDesC8& aURI );
+
+
+        /**
+        * Unregisters given content to be used as an automated content.
+        * @param  aFileName: Full path to file
+        * @return System wide error code.
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt RemoveAutomated( const TDesC& aFilename );
+
+
+        /**
+        * Unregisters given content to be used as an automated content.
+        * @param  aFileHandle: file handle to the file
+        * @return System wide error code.
+        * @since  3.0
+        */
+        IMPORT_C TInt RemoveAutomated( RFile& aFileHandle );
+
+
+        /**
+        * Unregisters given content to be used as an automated content.
+        * This function must be used when content was registered using 
+        * SetAutomatedPassive.
+        * @param  aURI: content URI
+        * @return System wide error code.
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt RemoveAutomatedPassive( const TDesC8& aURI );
+
+
+        /**
+        * Unregisters given content to be used as an automated content.
+        * This function must be used when content was registered using 
+        * SetAutomatedPassive.
+        * @param  aFileName: Full path to file
+        * @return System wide error code.
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt RemoveAutomatedPassive( const TDesC& aFilename );
+
+
+        /**
+        * Unregisters given content to be used as an automated content.
+        * This function must be used when content was registered using 
+        * SetAutomatedPassive.
+        * @param  aFileHandle: file handle to the file
+        * @return System wide error code.
+        * @since  3.0
+        */
+        IMPORT_C TInt RemoveAutomatedPassive( RFile& aFileHandle );
+
+
+        /**
+        * Checks if given content can be set as an automated content.
+        * @param  aURI: content URI
+        * @param  aValue: ETrue if content can be set as automated.
+        * @return System wide or DRM specific error code.
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt CanSetAutomated( const TDesC8& aURI, 
+            TBool& aValue );
+
+
+        /**
+        * Checks if given content can be set as an automated content.
+        * @param  aFileName: Full path to file
+        * @param  aValue: ETrue if content can be set as automated.
+        * @return System wide or DRM specific error code.
+        * @since Series 60 2.6
+        */
+        IMPORT_C TInt CanSetAutomated( const TDesC& aFilename, 
+            TBool& aValue );
+
+
+        /**
+        * Checks if given content can be set as an automated content.
+        * @param  aFileHandle: file handle to the file
+        * @param  aValue: ETrue if content can be set as automated.
+        * @return System wide or DRM specific error code.
+        * @since  3.0
+        */
+        IMPORT_C TInt CanSetAutomated( RFile& aFileHandle, 
+            TBool& aValue );
+
+
+        /**
+        * Informs DRMHelper that idle-screen has been activated.
+        * @return -
+        * @since Series 60 2.6
+        */
+        IMPORT_C void IndicateIdle();
+
+        /**
+        * Handle the general UI based error notes 
+        * @since  3.0
+        * @param aTextId The code for DRM general notification note.
+        * @param aURI The DRM files URI, that caused the DRM error.
+        * @return KErrnone if everything went ok, else wide scale of Symbian errors
+        */
+        IMPORT_C TInt ShowDRMUINotification2L( TDRMHelperNotificationID aTextId,
+            const TDesC8& aURI );
+
+
+        /**
+        * Handle the general UI based error notes 
+        * @since  3.0
+        * @param aTextId The code for DRM general notification note.
+        * @param aFileName The DRM file's name and path, that caused the DRM error.
+        * @return KErrnone if everything went ok, else wide scale of Symbian errors
+        */
+        IMPORT_C TInt ShowDRMUINotification2L( TDRMHelperNotificationID aTextId,
+            const TDesC& aFileName );
+
+
+        /**
+        * Set count limit for CheckRightsAmountL
+        * @param aCounts: new count limit for displaying the note.
+        * @return -
+        */
+        IMPORT_C void SetCountLimitL( TUint aCounts );
+
+        
+        /**
+        * Set time limit in days for CheckRightsAmountL
+        * @param aDays: new time limit for displaying the note.
+        * @return -
+        */
+        IMPORT_C void SetTimeLimitL( TUint aDays );
+
+
+        /**
+        * Set percentage limit for CheckRightsAmountL. Applies to both counts and time.
+        * @param aPercentage: new limit for displaying the note.
+        * @return -
+        */
+        IMPORT_C void SetPercentageLimitL( TUint aPercentage );
+
+
+        /**
+        * GetContentURIList
+        *
+        * Returns a list of all content URIs that have rights in the rights 
+        * database.
+        *
+        * @since  2.5
+        * @param  aURIList: Out parameter for the URI list.
+        * @return Ok if the URI list could be retreived.
+        */
+        IMPORT_C TInt GetContentURIList(
+            RPointerArray<HBufC8>*& aURIList);
+
+    
+        /**
+        * DataTypesCount
+        *
+        * Returns the number of previously registered datatypes which are
+        * supported by the DRM system and associated applications.
+        *
+        * @since  2.0
+        * @param  aCount: Out parameter for the datatype count
+        * @return EOk if the number of datatypes has been returned correctly
+        */
+        IMPORT_C TInt DataTypesCount(
+            TInt& aCount);
+
+    
+        /**
+        * SupportedDataType
+        *
+        * Returns a specific datatype which has been registered before by giving an index
+        *
+        * @since  2.0
+        * @param  aIndex: Number of the datatype to return
+        * @param  aDataType: Out parameter for the datatype
+        * @return EOk if the datatype was returned correctly
+        */
+        IMPORT_C TInt SupportedDataType(
+            const TInt aIndex, TDataType& aDataType);
+
+    
+        /**
+        * RegisterDataType
+        *
+        * Registers a datatype as a supported datatype.
+        *
+        * @since  2.0
+        * @param  aDataType: Datatype to register
+        * @return EOk if the datatype has been registered
+        */
+        IMPORT_C TInt RegisterDataType(
+            const TDataType& aDataType);
+
+    
+        /**
+        * UnRegisterDataType
+        *
+        * Unregisters a datatype via its index.
+        *
+        * @since  2.5
+        * @param  aIndex: Number of the datatype to unregister
+        * @return EOk if the datatype has been unregistered
+        */
+        IMPORT_C TInt UnRegisterDataType(
+            const TInt aIndex);
+
+
+        /**
+        * SupportedDRMMethods
+        *
+        * Returns the supported DRM protection methods and the OMA compliance
+        * level of the DRM engine
+        *
+        * @since  2.0
+        * @param  aDRMMethod: Out parameter, bit mask containing any 
+        *         combination of EForwardLock, ECombinedDelivery, 
+        *         ESeparateDelivery etc.
+        * @param  aOMALevel: OMA compliance of the DRM engine
+        * @return DRMCommon error code
+        */
+    
+        IMPORT_C TInt SupportedDRMMethods2(
+            TInt& aDRMMethod, TDRMHelperOMALevel& aOMALevel);
+
+    
+        /**
+        * Consume2
+        *
+        * Overrides any rights consumption. This function must only be used by
+        * applications with user interaction and not by intermediate components.
+        * The main use cases are signalling that content is to be installed
+        * (including thumbnail generation), or that content is to be consumed.
+        * They are characterized as calls to this function with the correct
+        * intent (i.e. EPlay or EInstall) and the corresponding action (i.e.
+        * telling whether the indicated intent is started or finished).
+        * Calls to this function must be the result of a user interaction or
+        * otherwise high level event.
+        *
+        * @since  3.0
+        * @param  aContentURI: URI of the content which will be consumed
+        * @param  aRightsSpec: the consumption intent (EPlay, EDisplay, EPrint,
+        *         EExecute or EInstall)
+        * @param  anAction: the consumption action, telling whether the
+        *         content consumption starts or finishes.
+        * @return EOk if consume action was successfully signalled to the engine.
+        */
+        IMPORT_C TInt Consume2(
+		    const TDesC8& aContentURI,
+		    TUint32 aRightsSpec,
+		    TDRMHelperConsumeAction anAction);
+
+
+        /**
+        * ConsumeFile2
+        *
+        * Overrides any rights consumption. This function must only be used by
+        * applications with user interaction and not by intermediate components.
+        * The main use cases are signalling that content is to be installed
+        * (including thumbnail generation), or that content is to be consumed.
+        * They are characterized as calls to this function with the correct
+        * intent (i.e. EPlay or EInstall) and the corresponding action (i.e.
+        * telling whether the indicated intent is started or finished).
+        * Calls to this function must be the result of a user interaction or
+        * otherwise high level event.
+        *
+        * @since  3.0
+        * @param  
+        * @param  aRightsSpec: the consumption intent (EPlay, EDisplay, EPrint,
+        *         EExecute or EInstall)
+        * @param  anAction: the consumption action, telling whether the
+        *         content consumption starts or finishes.
+        * @return EOk if consume action was successfully signalled to the engine.
+        */
+        IMPORT_C TInt ConsumeFile2(
+		    const TDesC& aFileName,
+		    TUint32 aRightsSpec,
+		    TDRMHelperConsumeAction anAction);
+
+
+        /**
+        * ConsumeFile2
+        *
+        * Overrides any rights consumption. This function must only be used by
+        * applications with user interaction and not by intermediate components.
+        * The main use cases are signalling that content is to be installed
+        * (including thumbnail generation), or that content is to be consumed.
+        * They are characterized as calls to this function with the correct
+        * intent (i.e. EPlay or EInstall) and the corresponding action (i.e.
+        * telling whether the indicated intent is started or finished).
+        * Calls to this function must be the result of a user interaction or
+        * otherwise high level event.
+        *
+        * @since  3.0
+        * @param  aFileHandle: file handle to the file
+        * @param  aRightsSpec: the consumption intent (EPlay, EDisplay, EPrint,
+        *         EExecute or EInstall)
+        * @param  anAction: the consumption action, telling whether the
+        *         content consumption starts or finishes.
+        * @return EOk if consume action was successfully signalled to the engine.
+        */
+        IMPORT_C TInt ConsumeFile2(
+		    RFile& aFileHandle, 
+		    TUint32 aRightsSpec,
+		    TDRMHelperConsumeAction anAction);
+
+		/**
+        * Acquires rights for given content if rights have been expired or rights are missing.
+		* If content already has valid or future rights, does nothing.
+		* This function should be called when user selects activate from options menu.
+		* Leaves with system-wide error code in case of error.
+        * @param aContent: Content object
+        */
+		IMPORT_C void ActivateContentL(CData& aContent);
+
+		/**
+        * Acquires rights for given content if rights have been expired or rights are missing.
+		* If content already has valid or future rights, does nothing.
+		* This function should be called when user selects activate from options menu.
+		* Leaves with system-wide error code in case of error.
+        * @param aFileName: Full path to file
+        */
+		IMPORT_C void ActivateContentL(TDesC& aFileName);
+
+		/**
+        * Checks if given content has embedded preview or if it is possible to get preview rights for it.
+		* Leaves with system-wide error code in case of error.
+        * @param aContent: Content object
+		* @param aPreviewUri: Out: URI of the embedded preview or PreviewRights URL. Must be freed by caller
+		* @return preview type
+        */
+		IMPORT_C TDRMHelperPreviewType HasPreviewL(CData& aContent, HBufC8*& aPreviewUri);
+
+		/**
+        * Checks if given content has embedded preview or if it is possible to get preview rights for it.
+		* Leaves with system-wide error code in case of error.
+        * @param aFileName: Full path to file.
+		* @param aPreviewUri: Out: URI of the embedded preview or PreviewRights URL. Must be freed by caller
+		* @return preview type
+        */
+		IMPORT_C TDRMHelperPreviewType HasPreviewL(TDesC& aFileName, HBufC8*& aPreviewUri);
+
+		/**
+        * Acquires preview rights for given content.
+		* Leaves with system-wide error code in case of error.
+        * @param aContent: Content object
+        */
+		IMPORT_C void GetPreviewRightsL(CData& aContent);
+
+		/**
+        * Acquires preview rights for given content.
+		* Leaves with system-wide error code in case of error.
+        * @param aFileName: Full path to file.
+        */
+		IMPORT_C void GetPreviewRightsL(TDesC& aFileName);
+
+		/**
+        * This method should be called after embedded preview has been played.
+		* It asks from user if he/she wants to buy rights and acquires those if user agrees.
+		* Leaves with system-wide error code in case of error.
+        * @param aContent: Content object.
+		* @return ETrue if user selects to buy rights.
+        */
+		IMPORT_C TBool EmbeddedPreviewCompletedL(CData& aContent);
+
+		/**
+        * This method should be called after embedded preview has been played.
+		* It asks from user if he/she wants to buy rights and acquires those if user agrees.
+		* Leaves with system-wide error code in case of error.
+        * @param aFileName: Full path to file.
+		* @return ETrue if user selects to buy rights.
+        */
+		IMPORT_C TBool EmbeddedPreviewCompletedL(TDesC& aFileName);
+
+		/**
+        * Checks if given content has InfoUrl.
+		* Leaves with system-wide error code in case of error.
+        * @param aContent: Content object.
+		* @param aInfoUrl: Out: InfoUrl. Must be freed by caller.
+		* @return ETrue if content has InfoUrl.
+        */
+		IMPORT_C TBool HasInfoUrlL(CData& aContent, HBufC8*& aInfoUrl);
+
+		/**
+        * Checks if given content has InfoUrl.
+		* Leaves with system-wide error code in case of error.
+        * @param aFileName: Full path to file.
+		* @param aInfoUrl: Out: InfoUrl. Must be freed by caller.
+		* @return ETrue if content has InfoUrl.
+        */
+		IMPORT_C TBool HasInfoUrlL(TDesC& aFileName, HBufC8*& aInfoUrl);
+
+		/**
+        * Opens browser with InfoUrl of the content.
+		* Leaves with system-wide error code in case of error.
+        * @param aContent: Content object.
+        */
+		IMPORT_C void OpenInfoUrlL(CData& aContent);
+
+		/**
+        * Opens browser with InfoUrl of the content.
+		* Leaves with system-wide error code in case of error.
+        * @param aFileName: Full path to file.
+        */
+		IMPORT_C void OpenInfoUrlL(TDesC& aFileName);
+
+        /**
+        * Sets the type of automated content to be registered. This method 
+        * should be called before calling any of SetAutomated* methods.
+        * @param  aAutomatedType: type of automated content
+        * @return System wide error code
+        * @since Series 60 3.0
+        */
+        IMPORT_C TInt SetAutomatedType( TDRMHelperAutomatedType aAutomatedType );
+        
+        /**
+        * Sets media type of content for preview. Should be called prior to 
+        * calling HandleErrorOrPreviewL or EmbeddedPreviewCompletedL. 
+        * @param aMediaType: media type of content.
+        * @return System wide error code
+        * @since S60 3.1u
+        */
+        IMPORT_C TInt SetPreviewMediaType( 
+            TDRMHelperPreviewMediaType aMediaType );
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since ?Series60_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDRMHelper( CCoeEnv& aCoeEnv );
+        CDRMHelper();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( RFs* aFs );
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // ?classname( const ?classname& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // ?classname& operator=( const ?classname& );
+
+        /**
+        * Display query dialog
+        */
+        TInt DisplayQueryWithIdL( TInt aTextResourceId, TInt aQueryResourceId );
+        TInt DisplayQueryWithIdValueL( TInt aTextResourceId, TInt aQueryResourceId, 
+                                       const TDesC& aString );
+        TInt DisplayQueryL( TInt aTextResourceId, TInt aValue );
+        TInt DisplayQueryL( TInt aTextResourceId, const TDesC& aString );
+        TInt DisplayQueryL( 
+        	TInt aTextResourceId, 
+        	const TDesC& aString, 
+            TInt aValue,
+        	TInt aStringPos = -1,
+        	TInt aValuePos = -1 );
+        TInt DisplayQueryL( TDesC& aPromptText, TInt aQueryResourceId );
+
+        /**
+        * Display information note
+        */
+        void DisplayInfoNoteL( TInt aTextResourceId );
+        void DisplayInfoNoteL( TInt aTextResourceId, const TDesC& aString );
+        void DisplayInfoNoteL( TInt aTextResourceId, TInt aValue );
+        void DisplayInfoNoteL( TDesC& aPromptText, TInt aResourceId, 
+                               const TDesC& aString = KNullDesC, TInt aValue = -1 );
+
+        /**
+        * Launch browser embedded
+        */
+        void LaunchBrowserL( HBufC8* aUrl );
+        void LaunchBrowserL( HBufC* aUrl );
+
+        /**
+        * Get rights-issuer URI from DCF file
+        */
+        void GetRightsIssuerL( const CData& aContent, HBufC*& aIssuer );
+
+        /**
+        * Get time and count based constraints
+        */
+        TInt GetCounts( CDRMRightsConstraints* aConstraint, 
+            TUint32& aOriginalCount, TTimeIntervalDays& aDuration );
+
+        TInt GetCounts( CDRMRightsConstraints* aConstraint,
+            TUint32& aCountLeft, TTime& aEndTime );
+            
+        TInt GetCounts( CDRMConstraint* aConstraint, 
+            TUint32& aOriginalCount, TTimeIntervalDays& aDuration );
+
+        TInt GetCounts( CDRMConstraint* aConstraint,
+            TUint32& aCountLeft, TTime& aEndTime );
+
+        /**
+        * Launch rights manager UI
+        */
+        void LaunchRightsManagerUiL( const TDesC& aParam16 );
+
+        /**
+        * Form string needed to launch rights manager UI embedded.
+        */
+        void CreateLaunchParamL( TUint32 aLocalId, const HBufC8* aUrl, 
+            HBufC*& aLaunchParam );
+
+        /**
+        * Strip path and extension from given filename.
+        * Caller is responsible for freeing returned buffer
+        */
+        TPtrC StripPathAndExtension( const TDesC& aFileName );
+
+        /**
+        * Get expiration details of file.
+        * Returns DRMCommon::ENoRights if no rights object found or
+        * CDRMRights::TExpiration value
+        */
+        TInt GetExpirationDetails( HBufC8* aContentUri, TInt aIntent, 
+                                   CDRMRights*& aRightsObject );
+
+        /**
+        * Get expiration time of given rights object
+        */
+        TInt CalculateEndTime( CDRMRights* aRights, TInt aIntent, 
+            TTime& aEndTime, TBool& aInactive );
+
+        /**
+        * Get end time of given constraint
+        */
+        TInt GetEndTime( CDRMRightsConstraints* aConstraint, 
+            TTime& aEndTime, TBool& aInactive );
+        
+        /**
+        * Register content as automated
+        */
+        TInt PerformSetAutomatedL( const CData& aContent, TBool aActive );
+        TInt DoSetAutomatedL( const TDesC8& aURI, TBool aActive, 
+            const HBufC* aMimeType );
+
+        /**
+        * Display confirmation query about setting as automated. Does not 
+        * actually register.
+        */
+        TInt PerformShowAutomatedNoteL( const CData& aContent );
+        TInt DoShowAutomatedNoteL( const TDesC8& aURI, 
+            const HBufC* aMimeType );
+
+        /**
+        * Register content as automated without showing any queries
+        */
+        TInt PerformSetAutomatedSilentL( const CData& aContent, TBool aActive );
+        TInt DoSetAutomatedSilent( const TDesC8& aURI, TBool aActive, TInt aIntent );
+
+        /**
+        * Returns default intent for the mimetype
+        */
+        TInt Intent( const HBufC* aMimeType );
+        
+        /**
+        * Checks if content can be used as automated content
+        */
+        TInt PerformCanSetAutomatedL( const CData& aContent,TBool& aValue );
+        TInt DoCanSetAutomated( const TDesC8& aURI, const HBufC* aMimeType, 
+            TBool& aValue );
+        TBool DoCheckSkinCanSetAutomated(CDRMRights* aRights);
+            
+        /**
+        * Gets mimetype based on content URI
+        */
+        HBufC* MimeTypeFromURIL( const TDesC8& aURI );
+        
+        /**
+        * Gets corresponding filename (including full path) based on content 
+        * URI
+        */
+        TInt GetFileHandleFromURIL( const TDesC8& aURI, RFile& aFileHandle );
+
+        /**
+        * Get start time of given rights object
+        */
+        TInt GetStartTime( CDRMRights* aRights, TInt aIntent, 
+            TTime& aStartTime );
+
+        /**
+        * Displays info note of rights that are not yet valid 
+        */
+        TInt ShowFutureNoteL( const HBufC* aMimeType, CDRMRights* aRightsObject );
+
+        /**
+        * Handles error by displaying appropriate note to user.
+        */
+        TInt DoHandleErrorL( TInt aError, HBufC8* aContentUri, HBufC* aMimeType, 
+            HBufC* aRIUrl, HBufC* aDomainRoUrl, HBufC* aEta, HBufC8* aRiId8,
+            HBufC8* aDomainId8, const TDesC& aFileName );
+            
+        /**
+        * Checks if rights are about to expire.
+        */
+        TInt DoCheckRightsPercentL( HBufC8* aContentUri, HBufC* aMimeType, 
+            HBufC* aRIUrl, const TDesC& aFileName, TInt aThreshold );
+
+        TInt DoCheckRightsAmountL( HBufC8* aContentUri, HBufC* aMimeType, 
+            HBufC* aRIUrl, const TDesC& aFileName, TInt aCount, TInt aDays );
+            
+        /**
+        * Gets rights details.
+        */
+        void DoGetRightsDetailsL( HBufC8* aContentUri, TUint32 aIntent,
+            TBool& aExpired, CDRMHelperRightsConstraints*& aPlay,
+            CDRMHelperRightsConstraints*& aDisplay, 
+            CDRMHelperRightsConstraints*& aExecute,
+            CDRMHelperRightsConstraints*& aPrint );
+
+        void DoGetRightsDetailsL( CData* aContent, TUint32 aIntent,
+            TBool& aExpired, TBool& aSendingAllowed, CDRMRightsConstraints*& aPlay,
+            CDRMRightsConstraints*& aDisplay, 
+            CDRMRightsConstraints*& aExecute,
+            CDRMRightsConstraints*& aPrint );
+		
+        /**
+        * Get constraints for given rights
+        */
+        void GetConstraintsL( 
+            CDRMRights& aRights, 
+            CDRMHelperRightsConstraints*& aPlay,
+            CDRMHelperRightsConstraints*& aDisplay,
+            CDRMHelperRightsConstraints*& aExecute,
+            CDRMHelperRightsConstraints*& aPrint );
+
+		/**
+		* Unregisters automated content.
+		*/
+		TInt PerformRemoveAutomatedL( const CData& aContent, TBool aActive );
+		
+		void HandleServerAppExit(TInt aReason);
+
+        void CheckPreviewUriL( 
+            const CData* aContent, 
+            HBufC*& aEmbeddedPreviewUri, 
+            TInt& aPreviewType );
+        
+        TInt DisplayPopupWindowsForPreviewL(TInt aPreviewType);
+
+        /**
+		* Returns correct resource id for automated content notes.
+		* If aExpired is ETrue, aSecondParameter indicates if RI URL exists
+		* If aExpired is EFalse, aSecondParameter indicates if there is one day left
+        * aRejectReason tells the constraints which are invalid.
+		*/
+		TInt AutomatedResIdL( TBool aExpired, TBool aSecondParameter, TUint32 aRejectReason );
+
+        /** 
+        * Returns the correct resource id for expired and no rights notes
+        */		    
+        TInt ErrorResIdL( const TDesC8& aContentUri, TInt aIntent, 
+            TBool aRightsIssuer, TBool aExpired );
+
+        /** 
+        * Returns the constraints which are invalid
+        */		    
+        TUint32 RejectReasonL( TInt aIntent, const TDesC8& aContentUri );
+        
+        /** 
+        * Prepares secondary display for DRM notes
+        */
+        void PrepareSecondaryDisplayL( CEikDialog& aDialog, TInt aResourceId,
+                                       const TDesC& aString = KNullDesC, TInt aValue = -1 ); 
+
+        /** 
+        * Cancels secondary display for DRM notes
+        */
+        void CancelSecondaryDisplayL( TInt aResourceId );
+                
+        /** 
+        * Check whether a file as a silent rights URL which can be used, i.e the URL is valid
+        * and on the white list.
+        */
+        HBufC8* HasSilentRightsUrlL( CData* aContent );
+        
+        /** 
+        * Get rights silently
+        */
+        TInt GetSilentRightsL( const TDesC8& aUrl );
+
+        /** 
+        * Check if the user has allowed silent rights
+        */
+        TBool SilentRightsAllowedL();
+
+        /** 
+        * Check if browser AP has been defined
+        */
+        TBool BrowserAPDefinedL();
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        CCoeEnv*                iCoeEnv;
+
+        // DRM engine
+        DRMCommon*              iDRMCommon;
+
+        // used to make launching rights manager ui synchronous
+        CActiveSchedulerWait    iWait;
+   
+        RDRMHelper              iHelperServer;
+        
+        // is CoeEnv used
+        TBool                   iUseCoeEnv;
+
+        // Used to read resources when CoeEnv is not available
+        CStringResourceReader*  iStringResourceReader;
+        
+        TBool                   iOma2;
+        	
+        RPointerArray<CConsumeData> iConsumeList;
+        
+        TInt                    iAutomatedType;
+   
+        RFs                     iFs;
+        
+        TBool                   iFsOwned;
+        
+        TInt                    iPreviewMediaType;
+        
+        // Used to queue up global notes
+        RPointerArray<CDRMHelperInfoNoteWrapper>      iNoteList;
+        
+        CSchemeHandler*         iSchemeHandler;
+
+        TBool                   iReturnCancel;
+
+        // Used to send cancel events to cover ui
+        CMediatorEventProvider* iEventProvider;
+
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+
+    };
+
+#endif      // __DRMHELPER_H__   
+            
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/inc/RDRMHelper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,135 @@
+/*
+* 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:  the client side class for DRMHelperServer
+*
+*/
+
+
+#ifndef RDRMHELPER_H
+#define RDRMHELPER_H
+
+// INCLUDES
+#include <e32base.h>
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+
+
+/**
+*  This class provides the client-side interface to the server session
+*
+*  @since Series 60 2.6
+*/
+
+class RDRMHelper : public RSessionBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * C++ default constructor.
+        */
+	    RDRMHelper();
+
+    public:  // New functions
+      
+        /**
+        * Connects to server.
+        * @return System-wide error code
+        */
+	    TInt Connect();
+
+        /**
+        * Gets the version number 
+        * @return version number
+        */
+	    TVersion Version() const;
+
+        /**
+        * Register the given content uri as an automated content.
+        * @param aUri: content URI
+        * @param aActive: active or passive registration
+        * @param aAutomatedType: type of automated content
+        * @param aIntent: intent how content is used
+        * @return System-wide error code
+        */
+        TInt SetAutomated( 
+            const TDesC8& aUri, 
+            TBool aActive, 
+            TInt aAutomatedType, 
+            TInt aIntent ) const;
+
+        /**
+        * Unregister the given content.
+        * @param aUri: content URI
+        * @param aActive: active or passive registration
+        * @param aAutomatedType: type of automated content
+        * @param aIntent: intent how content is used
+        * @return System-wide error code
+        */
+        TInt RemoveAutomated( 
+            const TDesC8& aUri, 
+            TBool aActive, 
+            TInt aAutomatedType, 
+            TInt aIntent ) const;
+
+        /**
+        * Unregister all instances of the given content.
+        * @param aUri: content URI
+        * @param aActive: active or passive registration
+        * @param aAutomatedType: type of automated content
+        * @param aIntent: intent how content is used
+        * @return System-wide error code
+        */
+        TInt RemoveAutomatedAll( 
+            const TDesC8& aUri, 
+            TBool aActive, 
+            TInt aAutomatedType, 
+            TInt aIntent ) const;
+
+        /**
+        * Indicate that idle-screen has been activated.
+        * @return System-wide error code
+        */
+        TInt IndicateIdle() const;       
+
+        /**
+        * Has given content been registered as automated content.
+        * @param aUri content URI of the content
+        * @param aAutomated (out) ETrue if registered as automated.
+        * @param aType (out) Tells whether content has been registered as active or passive.
+        * @return System-wide error code
+        */
+        TInt IsAutomated( 
+            const TDesC8& aUri,
+            TInt aAutomatedType, 
+            TInt aIntent, 
+            TBool& aAutomated, 
+            TInt& aType ) const;       
+
+    private:
+        
+        TInt StartServer();
+        TInt CreateServerProcess();
+    };
+
+
+
+#endif      // DRMHELPERCLIENT_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/loc/DRMCommon.loc	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1007 @@
+/*
+* Copyright (c) 2005 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     This is a localisation file for DRM common strings
+*  -------------------------------------------------------------------
+*
+*/
+
+
+//d: Text in information note for at least one protected item
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_fl_info_item_discard "Unable to show item(s). One or more items have been discarded."
+
+//d: Text in information note
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_not_allowed "Unable to select protected objects"
+
+//d: Text in information note
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_prev_rights_set "Unable to select. Object can only be viewed."
+
+
+//d: Text in information note
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_no_rights_for_some "1 or more objects locked"
+
+//d: Text in information note
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_gen_rights_exp "Licence expired for some of the selected objects"
+
+//d: Text in information note
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_prof_rights_missing "File is locked"
+
+//d: Text for details view
+//l: list_double_pane_t2_cp2
+//w:
+//r:
+//
+#define qtn_drm_mgr_det_exp "Licence expired"
+
+//d: Text in message query
+//d: %N is number of deleted objects
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_mos_deleted "%N protected objects deleted"
+
+//d: Text in message query
+//d: %U is name of the media object
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_mo_deleted "%U deleted"
+
+//d: Text in information note
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_preview_msg "Message contains an object that can only be viewed once"
+
+//d: Text in information note
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_forw_forbid "Unable to forward protected objects"
+
+//d: Text in confirmation query
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_query_send_forbid "Unable to send protected objects. Send unprotected objects only?"
+
+//d: Text in confirmation query for at least one protected item
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_fl_query_send_forbid "Protected items cannot be sent. Send unprotected?"
+
+//d: Text in information note for one protected item
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_send_forbid_1 "Unable to send copyright protected item"
+
+//d: Text in information note for several protected items
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_send_forbid "Unable to send protected objects"
+
+//d: Text in confirmation query for at least one protected item
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_send_wo_rights_misc "Recipient may not be able to use some objects. Continue?"
+
+//d: Text in confirmation query for one protected item
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_send_wo_rights_sd_1 "Recipient may not be able to use object. Continue?"
+
+//d: Text in confirmation query for several SD protected items
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_send_wo_rights_sd "Recipient may not be able to use objects. Continue?"
+
+//d: Text in information note
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_cnt_or_dt_exp_multi "Licence will expire for some of the selected objects"
+
+//d: Text in confirmation query
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_sd_rights_exp "Licence expired. Get new licence to unlock file?"
+
+//d: Text in confirmation query
+//d: %U is name of the media object
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_no_rights "File [%U] is locked. Unlock now?"
+
+//d: Note displayed when automated content with preview rights are tried to use.
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_prev_rights_use "Unable to use. Object can only be viewed."
+
+//d: Text in confirmation query when content with activated rights is set as automated content.
+//d: %U is expiration date of rights object
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_query_valid_rights_until "Licence for selected item valid until %U. Continue?"
+
+//d: Text in confirmation query when content with inactive interval rights is set as automated content.
+//d: %U is calculated expiration date of rights object, if rights are activated
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_query_active_rights_until "Selected item can be used until %U. Continue?"
+
+//d: Text in information note when non-superdistributable automated content has expired.
+//d: %U is name of the content
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_note_cd_ro_expired "Licence for %U expired"
+
+//d: Text in confirmation note when superdistributable automated content has expired.
+//d: %U is name of the content
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_note_sd_ro_expired "Licence for %U expired. Get new licence to unlock file?"
+
+//d: Text in information note when usage rights are not yet valid.
+//d: %U is start date of rights object
+//l: popup_note_window
+//w:
+//r: 2.6
+//
+#define qtn_drm_note_ro_valid_on_future "Licence valid from %U"
+
+//d:Possible second line for first entry of Details View listbox
+//l:list_double_pane_t2_cp2
+//w:
+//r:3.0
+//
+#define qtn_drm_mgr_det_valid "Licence is valid"
+
+//d: Text in information note shown when removing device from account failed.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_remove_fr_account_fail "Unable to deregister phone"
+
+//d: Text in wait note shown while device is being removed from account.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_wait_remove_fr_account "Deregistering phone"
+
+//d: Text in information note shown when device does not recognize account of DCF file.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_account_not_recognised "Account is not recognized"
+
+//d: Text in information note shown when rights object for DCF file is received to device.
+//d: %U is name of file to which received rights object is related.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_act_key_received "Licence received"
+
+//d: Text in information note shown when getting rights object has failed.
+//d: Reason is permanent device or server error and there is no possibility to retry.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_getting_key_failed "Unable to get licence"
+
+//d: Text in confirmation note shown when device has been succesfully removed from account.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_remove_fr_account "Phone deregistered"
+
+//d: Text in confirmation query shown when rights object has been received successfully and
+//d: related DCF file was also received successfully or was already in device.
+//d: %U refers to name of file to which received RO is related
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_query_key_received_open "File %U ready to use. Open now?"
+
+//d: Text in confirmation query when user is asked about updating account.
+//d: Device is already connected to network, but must upgrade the domain key before rendering,
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_query_activate_account "Registration will be updated. Continue?"
+
+//d: Menu entry in Options menu. This entry is present if DCF file includes preview URL and
+//d: Audio DCF has no valid rights.
+//d: Also as choice in "Activate or Preview" pop-up window that is shown when user selects Open
+//d: for DCF that has preview URL but no valid rights.
+//l: list_single_pane_t1_cp2
+//w:
+//r: 3.0
+//
+#define qtn_drm_options_get_preview "Get preview"
+
+//d: Menu entry in Options menu. This entry is present if DCF file includes preview URL and
+//d: Video DCF has no valid rights.
+//d: Also as choice in "Activate or Preview" pop-up window that is shown when user selects Open
+//d: for DCF that has preview URL but no valid rights.
+//l: list_single_pane_t1_cp2
+//w:
+//r: 3.1
+//
+#define qtn_drm_options_get_prev_video "Get preview"
+
+//d: Menu entry in Options menu. This entry is present if audio DCF file includes embedded preview.
+//l: list_single_pane_t1_cp2
+//w:
+//r: 3.0
+//
+#define qtn_drm_options_play_preview "Play preview"
+
+//d: Menu entry in Options menu. This entry is present if video DCF file includes embedded preview.
+//l: list_single_pane_t1_cp2
+//w:
+//r: 3.1
+//
+#define qtn_drm_options_play_prev_video "Play preview"
+
+//d: Menu entry in Options menu. This entry is present if InfoURL is included in DCF.
+//l: list_single_pane_t1_cp2
+//w:
+//r: 3.0
+//
+#define qtn_drm_options_more_info "More info online"
+
+//d: Text in information note shown when adding device to new account has failed since account is
+//d: full.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_account_is_full "Unable to register. Maximum number of devices already registered."
+
+//d: Text in confirmation query that is displayed when getting RO has failed due to temporary
+//d: server error.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_get_key_failed_retry "Licence not received. Try again?"
+
+//d: Text in wait note shown while device is acquiring RO and possibly completing registration
+//d: protocol with Rights Issuer.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_wait_getting_key "Processing"
+
+//d: Text in wait note shown while device registration is ongoing with Rights Issuer.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_wait_registering_device "Registering phone"
+
+//d: Text in information note shown when updating account has failed (domain key was being
+//d: upgraded or device was trying to join to new account).
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_update_domain_fail "Unable to update registration."
+
+//d: Text in confirmation note shown when account has been successfully updated (domain key has
+//d: been upgraded or device has joined to new account).
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_conf_account_updated "Registration updated"
+
+//d: Text in wait note shown while account is being updated (domain key is upgraded or device is
+//d: joining to new account).
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_wait_updating_account "Updating registration"
+
+// d: Text in information note for moving one protected item
+// l: popup_note_window
+// r: 2.6
+#define qtn_drm_info_move_one_forbid "Unable to move protected object to memory card"
+
+// d: Text in information note for moving several protected items
+// l: popup_note_window
+// r: 2.6
+#define qtn_drm_info_move_many_forbid "Unable to move protected objects to memory card"
+
+// d: Text in confirmation query for moving protected and unprotected items
+// l: popup_note_window
+// r: 2.6
+#define qtn_drm_query_move_forbidden "Unable to move protected objects. Move unprotected objects only?"
+
+// d: Text in information note for copying one protected item
+// l: popup_note_window
+// r: 2.6
+#define qtn_drm_info_copy_one_forbid "Unable to copy protected object to memory card"
+
+// d: Text in information note for copying several protected items
+// l: popup_note_window
+// r: 2.6
+#define qtn_drm_info_copy_many_forbid "Unable to copy protected objects to memory card"
+
+// d: Text in confirmation query for copying protected and unprotected items
+// l: popup_note_window
+// r: 2.6
+#define qtn_drm_query_copy_forbidden "Unable to copy protected objects. Copy unprotected objects only?"
+
+// d: Text in information note for moving folder containing protected items
+// l: popup_note_window
+// r: 2.6
+#define qtn_drm_info_move_folder_forbid "Unable to move folder containing protected objects to memory card"
+
+// d: Text in information note for copying folder containing protected items
+// l: popup_note_window
+// r: 2.6
+#define qtn_drm_info_copy_folder_forbid "Unable to copy folder containing protected objects to memory card"
+
+//d: Text in confirmation query that is displayed when user tries to render MO that is missing RO.
+//d: The waiting time of RO to arrive has not passed yet.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_query_waiting_for_ro "Waiting for licence. Try again later."
+
+//d: Text in confirmation query that is displayed when user tries to render MO that is missing RO.
+//d: The waiting time of RO to arrive has passed, and there is no possibility to get new RO (no rights
+//d: issuer url).
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_query_ro_late "Licence not yet received. Expected time of delivery elapsed."
+
+//d: Text in confirmation query that is displayed when user tries to render MO that is missing RO.
+//d: The waiting time of RO to arrive has passed, and there is possibility to get new RO (rights issuer url exists).
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_query_ro_late_activate "Licence not yet received. Expected time of delivery elapsed. Get new licence?"
+
+//d: Text in confirmation note that is displayed when device registration is complete.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_conf_device_registered "Phone registered"
+
+//d: Text in confirmation note that is displayed when device registration has failed.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_device_regist_fail "Unable to register"
+
+//d: Text in confirmation note that is displayed when user attempts to send one
+//d: non-superdistributable DRM protected media object.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_send_forbid_one "Unable to send protected object"
+
+//d: Text in confirmation note that is displayed when user has selected one or more DRM protected
+//d: MOs that cannot be sent and some unprotected MOs that can be sent,
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_send_forbid_some "Some objects protected. Unable to send protected objects."
+
+//d: Text in confirmation query that is displayed when rights for calendar alert tone have expired.
+//d: Query is shown when Idle is activated. Activation query is shown only for superdistributable
+//d: separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_cal_tone_exp_activate "Licence for calendar alert tone %U expired. Get new licence to unlock file?"
+
+//d: Text in information note that that is displayed when rights for calendar alert tone have expired.
+//d: Note is shown when Idle is activated. This info note is shown fore combined delivery object
+//d: and non-superdistributable separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_calendar_tone_exp "Licence for calendar alert tone %U expired"
+
+//d: Text in confirmation query that is displayed when rights for clock alarm tone have expired.
+//d: Query is shown when Idle is activated. Activation query is shown only for superdistributable
+//d: separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_clock_alrm_exp_activate "Licence for clock alarm tone %U expired. Get new licence to unlock file?"
+
+//d: Text in information note that that is displayed when rights for clock alarm tone have expired.
+//d: Note is shown when Idle is activated. This info note is shown fore combined delivery object
+//d: and non-superdistributable separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_clock_alarm_exp "Licence for clock alarm tone %U expired"
+
+//d: Text in confirmation query that is displayed when rights for e-mail alert tone have expired.
+//d: Query is shown when Idle is activated. Activation query is shown only for superdistributable
+//d: separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_email_tone_exp_activate "Licence for e-mail alert tone %U expired. Get new licence to unlock file?"
+
+//d: Text in information note that that is displayed when rights for e-mail alert tone have expired.
+//d: Note is shown when Idle is activated. This info note is shown fore combined delivery object
+//d: and non-superdistributable separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_email_tone_exp "Licence for e-mail alert tone %U expired"
+
+//d: Text in confirmation query that is displayed when rights for instant message alert tone have expired.
+//d: Query is shown when Idle is activated. Activation query is shown only for superdistributable
+//d: separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_im_tone_exp_activate "Licence for IM alert tone %U expired. Activate?"
+
+//d: Text in information note that that is displayed when rights for instant message alert tone have expired.
+//d: Note is shown when Idle is activated. This info note is shown fore combined delivery object
+//d: and non-superdistributable separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_im_alert_tone_exp "Licence for IM alert tone %U expired"
+
+//d: Text in confirmation query that is displayed when rights for message alert tone have expired.
+//d: Query is shown when Idle is activated. Activation query is shown only for superdistributable
+//d: separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_msg_tone_exp_activate "Licence for message alert tone %U expired. Get new licence to unlock file?"
+
+//d: Text in information note that that is displayed when rights for message alert tone have expired.
+//d: Note is shown when Idle is activated. This info note is shown fore combined delivery object
+//d: and non-superdistributable separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_msg_tone_exp "Licence for message alert tone %U expired"
+
+//d: Text in confirmation query that is displayed when rights for ringing tone have expired.
+//d: Query is shown when Idle is activated. Activation query is shown only for superdistributable
+//d: separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_ring_tone_exp_activate "Licence for ringing tone %U expired. Get new licence to unlock file?"
+
+//d: Text in information note that that is displayed when rights for ringing tone have expired.
+//d: Note is shown when Idle is activated. This info note is shown fore combined delivery object
+//d: and non-superdistributable separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_ring_tone_exp "Licence for ringing tone %U expired"
+
+//d: Text in confirmation query that is displayed when rights for screensaver have expired.
+//d: Query is shown when Idle is activated. Activation query is shown only for superdistributable
+//d: separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_screensave_exp_activate "Licence for power saver %U expired. Get new licence to unlock file?"
+
+//d: Text in information note that that is displayed when rights for screensaver have expired.
+//d: Note is shown when Idle is activated. This info note is shown fore combined delivery object
+//d: and non-superdistributable separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_screensaver_exp "License for power saver %U expired"
+
+//d: Text in confirmation query that is displayed when rights for wallpaper have expired.
+//d: Query is shown when Idle is activated. Activation query is shown only for superdistributable
+//d: separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_wallpaper_exp_activate "Licence for wallpaper %U expired. Get new licence to unlock file?"
+
+//d: Text in information note that that is displayed when rights for wallpaper have expired.
+//d: Note is shown when Idle is activated. This info note is shown fore combined delivery object
+//d: and non-superdistributable separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_wallpaper_exp "Licence for wallpaper %U expired"
+
+//d: Text in confirmation query that is displayed when rights for theme have expired.
+//d: Query is shown when Idle is activated. Activation query is shown only for superdistributable
+//d: separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_theme_exp_activate "Licence for theme %U expired. Get new licence to unlock file?"
+
+//d: Text in information note that that is displayed when rights for theme have expired.
+//d: Note is shown when Idle is activated. This info note is shown for combined delivery object
+//d: and non-superdistributable separate delivery object.
+//d: %U is the name of the file
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_theme_exp "Licence for theme %U expired"
+
+//d: Text in information note shown when updating account has failed
+//d: (device was trying to join to new account).
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_info_registration_failed "Registration failed"
+
+//d: Text in confirmation note shown when account has been successfully updated
+//d: (device has joined to new account).
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_conf_joined_to_domain "Registration complete"
+
+//d: Text in wait note shown while account is being updated
+//d: (device is joining to new account).
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_wait_joining_domain "Registering"
+
+//d: Confirmation query prompt.
+//d: To acquire a valid Rights Issuer context, a phone must complete Registration ROAP protocol.
+//d: Before initiating Registration ROAP protocol, user consent MUST be acquired.
+//d: %U is the <riAlias> element from the registration trigger.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_query_register_with_u "Registration with %U needed. Register phone?"
+
+//d: Confirmation query prompt.
+//d: To acquire a valid Rights Issuer context, a phone must complete Registration ROAP protocol.
+//d: Before initiating Registration ROAP protocol, user consent MUST be acquired.
+//l: popup_note_window
+//w:
+//r: 3.0
+//
+#define qtn_drm_query_register_with_cp "Registration with content provider needed. Register phone?"
+
+
+//d: Caption of ROAP Application (Title Pane text).
+//d: (ROAP Application handles DRM 2.0 digital rights acquisition,
+//d: via executing one or more ROAP protocols).
+//l: title_pane_t2/opt9
+//w:
+//r: 3.0
+//
+#define qtn_drm_roap_title "Licence download"
+
+//d: Text in information note
+//l: popup_note_window
+//w:
+//r:
+//
+#define qtn_drm_info_ro_expired "Licence expired"
+
+//d: Text in confirmation query shown when content cannot be rendered because of wrong SIM card in device
+//l: popup_note_window
+//w:
+//r: 3.1
+//
+#define qtn_drm_query_sim_not_allowed "File locked with current SIM card. Unlock for this SIM card?"
+
+//d: Text in confirmation query shown when calendar alert tone cannot be used
+//d: because of wrong SIM card in device
+//l: popup_note_window
+//w:
+//r: 3.1
+//
+#define qtn_drm_calendar_tone_wrong_sim "Calendar alert tone %U locked with current SIM card. Unlock for this SIM card?"
+
+//d: Text in confirmation query shown when clock alarm tone cannot be used
+//d: because of wrong SIM card in device
+//l: popup_note_window
+//w:
+//r: 3.1
+//
+#define qtn_drm_clock_alarm_wrong_sim "Clock alarm tone %U locked with current SIM card. Unlock for this SIM card?"
+
+//d: Text in confirmation query shown when e-mail alert tone cannot be used
+//d: because of wrong SIM card in device
+//l: popup_note_window
+//w:
+//r: 3.1
+//
+#define qtn_drm_email_alert_wrong_sim "E-mail alert tone %U locked with current SIM card. unlock for this SIM card?"
+
+//d: Text in confirmation query shown when message alert tone cannot be used
+//d: because of wrong SIM card in device
+//l: popup_note_window
+//w:
+//r: 3.1
+//
+#define qtn_drm_message_alert_wrong_sim "Message alert tone %U locked with current SIM card. Unlock for this SIM card?"
+
+//d: Text in confirmation query shown when ringing tone cannot be used
+//d: because of wrong SIM card in device
+//l: popup_note_window
+//w:
+//r: 3.1
+//
+#define qtn_drm_ringing_tone_wrong_sim "Ringing tone %U locked with current SIM card. Unlock for this SIM card?"
+
+//d: Text in confirmation query shown when theme cannot be used
+//d: because of wrong SIM card in device
+//l: popup_note_window
+//w:
+//r: 3.1
+//
+#define qtn_drm_theme_wrong_sim "Theme %U locked with current SIM card. Unlock for this SIM card?"
+
+//d: Text in confirmation query shown when wallpaper cannot be used
+//d: because of wrong SIM card in device
+//l: popup_note_window
+//w:
+//r: 3.1
+//
+#define qtn_drm_wallpaper_wrong_sim "Wallpaper %U locked with current SIM card. Unlock for this SIM card?"
+
+//d: Text in confirmation query shown when other type of automated content
+//d: cannot be used because of wrong SIM card in device
+//l: popup_note_window
+//w:
+//r: 3.1
+//
+#define qtn_drm_automated_wrong_sim "File %U locked with current SIM. Unlock for this SIM card?"
+
+
+//d: Text in information note shown when user tries to set a non-superdistributable file as automated content, but is not allowed with the current SIM
+//l: popup_info_list_pane_t1
+//w:
+//r: 3.1
+//
+#define qtn_drm_info_sim_not_allowed "File locked with current SIM card"
+
+//d: Text in info note if trying to use content with wrong SIM
+//d: %U Name of the IMSI bound DRM protected calendar alarm tone
+//l: popup_info_list_pane_t1
+//w:
+//r: 3.1
+//
+#define qtn_drm_non_sd_calend_wrong_sim "Calendar alarm tone %U locked with current SIM card. Default tone will be used."
+
+//d: Text in info note if trying to use content with wrong SIM
+//d: %U Name of the IMSI bound DRM protected clock alarm tone
+//l: popup_info_list_pane_t1
+//w:
+//r: 3.1
+//
+#define qtn_drm_non_sd_clock_wrong_sim "Clock alarm tone %U locked with current SIM card. Default tone will be used."
+
+//d: Text in info note if trying to use content with wrong SIM
+//d: %U Name of the IMSI bound DRM protected email alarm tone
+//l: popup_info_list_pane_t1
+//w:
+//r: 3.1
+//
+#define qtn_drm_non_sd_email_wrong_sim "E-mail alert tone %U locked with current SIM card. Default tone will be used."
+
+//d: Text in info note if trying to use content with wrong SIM
+//d: %U Name of the IMSI bound DRM protected message alarm tone
+//l: popup_info_list_pane_t1
+//w:
+//r: 3.1
+//
+#define qtn_drm_non_sd_msg_al_wrong_sim "Message alert tone %U locked with current SIM card. Default tone will be used."
+
+//d: Text in info note if trying to use content with wrong SIM
+//d: %U Name of the IMSI bound DRM protected ringing tone
+//l: popup_info_list_pane_t1
+//w:
+//r: 3.1
+//
+#define qtn_drm_non_sd_rtone_wrong_sim "Ringing tone %U locked with current SIM card. Default tone will be used."
+
+//d: Text in info note if trying to use content with wrong SIM
+//d: %U Name of the IMSI bound  DRM protected screensaver
+//l: popup_info_list_pane_t1
+//w:
+//r: 3.1
+//
+#define qtn_drm_non_sd_screen_wrong_sim "Power saver %U locked with current SIM card. Default power saver will be used."
+
+//d: Text in info note if trying to use content with wrong SIM
+//d: %U Name of the IMSI bound DRM protected theme
+//l: popup_info_list_pane_t1
+//w:
+//r: 3.1
+//
+#define qtn_drm_non_sd_theme_wrong_sim "Theme %U locked with current SIM card. Default theme will be used."
+
+//d: Text in info note if trying to use content with wrong SIM
+//d: %U Name of the IMSI bound DRM protected wallpaper
+//l:popup_info_list_pane_t1
+//w:
+//r: 3.1
+//
+#define qtn_drm_non_sd_wallp_wrong_sim "Wallpaper %U locked with current SIM card. Default wallpaper will be used."
+
+//d: Text in info note if trying to use content with wrong SIM
+//d: %U Name of the media object
+//l: popup_info_list_pane_t1
+//w:
+//r: 3.1
+//
+#define qtn_drm_non_sd_gener_wrong_sim "File %U locked with current SIM card."
+
+//Confirmation query text
+//d: Confirmation query for silent rights acquisition if not allowed in settings
+//l: popup_note_window
+//r: 3.2
+//
+#define qtn_drm_qry_connect_to_activate "File will be unlocked. Connection to internet is needed. Continue?"
+
+//Registration query title
+//d: Title fo registration query
+//l: heading_pane_t1
+//r: 3.2
+//
+#define qtn_drm_msq_qry_title_registrat "Registration"
+
+//Registration message query
+//d: Info query for reqistration before silent rights acquisition, if not yet reqistered
+//l: None
+//r: 3.2
+//
+#define qtn_drm_msq_query_registration "Registration with content provider is needed. After registration, licences for protected files can be downloaded automatically."
+
+//Link text for more info
+//d: String which contains the description for more info -link
+//l: None
+//r: 3.2
+//
+#define qtn_drm_msq_query_link_more_inf "More info"
+
+//SK1 string
+//d: String for SK1 to be used in registration message query
+//l: control_pane_t1/opt7
+//r: 3.2
+//
+#define qtn_drm_sk1_register "Register"
+
+//d:Progress note shown while rights are acquired silently
+//l:popup_note_wait_window
+//r:3.2
+//
+#define qtn_drm_progress_opening "Opening"
+
+//d: Information note shown when user tries to play content with a silent header and there is no
+//d: connection method defined on the phone.
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_warn_no_conn_defined "Unable to unlock file. Define at least one access point."
+
+//d: Information note shown when user tries to play content with a silent header and the server cannot
+//d: be contacted either because the access point is invalid, packet data context cannot be established,
+//d: or the access point is of wrong type.
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_warn_invalid_or_no_ap "Unable to unlock file. Connection failed with used access point."
+
+//d: Information note shown when user tries to play content with a silent header and there occurs a permanent
+//d: type of ROAP error.
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_err_opening_fail_perm  "Unable to unlock file."
+
+//d: Information note shown when user tries to play content with a silent header and there is no
+//d: network coverage.
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_err_no_coverage  "Unable to unlock file. No network coverage."
+
+//d: Confirmation query shown when user tries to play content with a silent header and there occurs a temporary
+//d: type of ROAP error. If user accepts the query Browser opens error url.
+//l: popup_note_window
+//r: 3.2
+//
+#define qtn_drm_query_open_error_url "Unable to unlock file. See more information online?"
+
+//d: Wait note shown while network connection is being established after user has selected a destination in
+//d: connection selection dialog.
+//l: popup_note_wait_window
+//w:
+//r: 3.2
+//
+#define qtn_netw_conset_wait_connecting_to "Connecting to:\n ’%U’"
+
+//d: Wait note shown while network connection is being established after user has selected a destination
+//d: and an explicit connection method in connection selection dialog.
+//l: popup_note_wait_window
+//w:
+//r: 3.2
+//
+#define qtn_netw_conset_wait_connecting_via "Connecting via:\n ’%U’"
+
+//d: Confirmation note shown after the connection has been successfully established.
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_netw_conset_conf_connected_to "Connected to\n ’%0U’ via\n ’%1U’"
+
+//d: Text in information note when cancelling phone registration
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_info_phone_not_register "Phone not registered with content provider."
+
+//d: Text in confirmation query
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_query_set_auto_interval "Selected item is valid for limited time. Continue?"
+
+//d: Text in confirmation note when trying to open file but usage reporting is not allowed.
+//l: popup_note_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_query_metering_disabled "Unable to open file. Change 'Allow usage reporting for' settings."
+
+//d: Text in wait note when usage reporting information is updated.
+//l: popup_note_wait_window
+//w:
+//r: 3.2
+//
+#define qtn_drm_wait_update_metering_info "Updating service information"
+
+//d: Heading in list query when more than one service is recognised in WMDRM direct license acquisition
+//d: and user is queried to make a selection.
+//l: heading_pane_t1
+//w:
+//r: 9.1
+//
+#define qtn_drm_select_service "Select service"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/tsrc/BWINS/drmhelpertestu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * LibEntryL(void)
+	?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int SetRequirements(class CTestModuleParam * &, unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/tsrc/EABI/drmhelpertestu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	_Z9LibEntryLv @ 1 NONAME
+	_Z15SetRequirementsRP16CTestModuleParamRm @ 2 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/tsrc/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project DrmHelperTest
+*
+*/
+
+
+
+
+PRJ_PLATFORMS
+WINSCW ARMV5
+
+//PRJ_TESTEXPORTS
+
+//PRJ_EXPORTS
+
+PRJ_TESTMMPFILES
+drmhelpertest.mmp
+
+//PRJ_MMPFILES
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/tsrc/group/drmhelpertest.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project DrmHelperTest
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          drmhelpertest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E7
+
+CAPABILITY      ALL -TCB
+//VENDORID        VID_DEFAULT
+
+//DEFFILE         drmhelpertest.def
+
+SOURCEPATH      ../src
+SOURCE          drmhelpertest.cpp
+SOURCE          drmhelpertestcases.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../../omadrm/drmengine/ro/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+//library under test
+LIBRARY         drmhelper.lib
+//other test related libraries
+LIBRARY         efsrv.lib
+LIBRARY         cone.lib
+LIBRARY         drmserverinterfaces.lib
+LIBRARY         drmparsers.lib
+LIBRARY         dcfrep.lib
+LIBRARY         apmime.lib
+LIBRARY         caf.lib
+LIBRARY         cafutils.lib
+LIBRARY         drmrights.lib
+
+SMPSAFE
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/tsrc/group/drmhelpertest.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,36 @@
+;
+; 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:  Package file for project DrmHelperTest
+;
+
+; -------- general --------
+
+; Languages
+&EN
+;01
+
+; Package header
+#{"DrmHelperTest"},(0x101FB3E7),1,0,1,TYPE=SISAPP
+
+;Localised Vendor name
+%{"Nokia-EN"}
+
+;Unique Vendor name
+:"Nokia"
+
+; -------- files --------
+
+;; engines
+
+"\epoc32\release\armv5\urel\drmhelpertest.dll"-"$:\sys\bin\drmhelpertest.dll"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/tsrc/inc/drmhelpertest.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,535 @@
+/*
+* 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:  DrmHelperTest test module.
+*
+*/
+
+
+#ifndef DRMHELPERTEST_H
+#define DRMHELPERTEST_H
+
+// INCLUDES
+#include <f32file.h>
+#include <stiflogger.h>
+#include "stiftestmodule.h"
+
+// CONSTANTS
+
+// MACROS
+
+// Logging path
+_LIT( KDrmHelperTestLogPath, "\\logs\\testframework\\drmhelpertest\\" );
+// Log file
+_LIT( KDrmHelperTestLogFile, "drmhelpertest.txt" );
+
+
+#define GETPTR &
+#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
+#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
+#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
+#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+class CDrmHelperTest;
+
+// DATA TYPES
+typedef TInt (CDrmHelperTest::* TestFunction)(TTestResult&);
+
+// CLASS DECLARATION
+
+/**
+*  An internal structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib drmhelpertest.lib
+*  @since S60 v3.2
+*/
+class TCaseInfoInternal
+    {
+    public:
+        const TText*    iCaseName;
+        TestFunction    iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+    };
+
+// CLASS DECLARATION
+
+/**
+*  A structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib drmhelpertest.lib
+*  @since S60 v3.2
+*/
+class TCaseInfo
+    {
+    public:
+        TPtrC iCaseName;
+        TestFunction iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+
+    TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
+        {
+        };
+
+    };
+
+
+// CLASS DECLARATION
+
+/**
+*  This a DrmHelperTest class.
+*
+*  @lib drmhelpertest.lib
+*  @since S60 v3.2
+*/
+NONSHARABLE_CLASS( CDrmHelperTest ) : public CTestModuleBase
+    {
+    public:  // Constructors and destructor
+
+
+        /**
+        * Two-phased constructor.
+        */
+        static CDrmHelperTest* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CDrmHelperTest();
+
+    public: // Functions from base classes
+
+        /**
+        * From CTestModuleBase InitL is used to initialize the
+        *       DrmHelperTest. It is called once for every instance of
+        *       TestModuleDrmHelperTest after its creation.
+        * @since S60 v3.2
+        * @param aIniFile Initialization file for the test module (optional)
+        * @param aFirstTime Flag is true when InitL is executed for first
+        *               created instance of DrmHelperTest.
+        * @return Symbian OS error code
+        */
+        TInt InitL( TFileName& aIniFile, TBool aFirstTime );
+
+        /**
+        * From CTestModuleBase GetTestCasesL is used to inquiry test cases
+        *   from DrmHelperTest.
+        * @since S60 v3.2
+        * @param aTestCaseFile Test case file (optional)
+        * @param aTestCases  Array of TestCases returned to test framework
+        * @return Symbian OS error code
+        */
+        TInt GetTestCasesL( const TFileName& aTestCaseFile,
+                            RPointerArray<TTestCaseInfo>& aTestCases );
+
+        /**
+        * From CTestModuleBase RunTestCaseL is used to run an individual
+        *   test case.
+        * @since S60 v3.2
+        * @param aCaseNumber Test case number
+        * @param aTestCaseFile Test case file (optional)
+        * @param aResult Test case result returned to test framework (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error, which is
+        *           not reported in aResult parameter as test case failure).
+        */
+        TInt RunTestCaseL( const TInt aCaseNumber,
+                           const TFileName& aTestCaseFile,
+                           TTestResult& aResult );
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDrmHelperTest();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CDrmHelperTest( const CDrmHelperTest& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CDrmHelperTest& operator=( const CDrmHelperTest& );
+
+        /**
+        * Function returning test case name and pointer to test case function.
+        * @since S60 v3.2
+        * @param aCaseNumber test case number
+        * @return TCaseInfo
+        */
+        const TCaseInfo Case ( const TInt aCaseNumber ) const;
+
+        /**
+        * Function for setting test case result.
+        * @since S60 v3.2
+        * @param aResult result structure of case under test
+        * @param aError (first seen) error code
+        */
+        void SetResult( TTestResult& aResult, TInt aError );
+
+        /**
+        * Actual Hardcoded test case functions are listed below.
+        */
+
+        /**
+        * CDRMHelper construct test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConstructTestL( TTestResult& aResult );
+
+        /**
+        * IndicateIdle test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt IndicateIdleTestL( TTestResult& aResult );
+
+
+        /**
+        * ActivateContentL test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ActivateContentLTestL( TTestResult& aResult );
+
+
+        /**
+        * CanSetAutomated test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt CanSetAutomatedTestL( TTestResult& aResult );
+
+
+        /**
+        * CheckRightsAmountL test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt CheckRightsAmountLTestL( TTestResult& aResult );
+
+
+        /**
+        * CheckRightsPercentL test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt CheckRightsPercentLTestL( TTestResult& aResult );
+
+
+        /**
+        * Consume2 test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt Consume2TestL( TTestResult& aResult );
+
+
+        /**
+        * ConsumeFile2 test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConsumeFile2TestL( TTestResult& aResult );
+
+
+        /**
+        * EmbeddedPreviewCompletedL test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt EmbeddedPreviewCompletedLTestL( TTestResult& aResult );
+
+
+        /**
+        * GetContentURIList test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetContentURIListTestL( TTestResult& aResult );
+
+
+        /**
+        * GetPreviewRightsL test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetPreviewRightsLTestL( TTestResult& aResult );
+
+
+        /**
+        * GetRightsDetailsL test case for CDRMRightsConstraints.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetRightsDetailsLTestL( TTestResult& aResult );
+
+
+        /**
+        * GetRightsDetailsL test case for CDRMHelperRightsConstraints.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt GetHlpRightsDetailsLTestL( TTestResult& aResult );
+
+
+        /**
+        * HandleErrorL test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt HandleErrorLTestL( TTestResult& aResult );
+
+
+        /**
+        * HandleErrorOrPreviewL test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt HandleErrorOrPreviewLTestL( TTestResult& aResult );
+
+
+        /**
+        * HasInfoUrlL test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt HasInfoUrlLTestL( TTestResult& aResult );
+
+
+        /**
+        * HasPreviewL test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt HasPreviewLTestL( TTestResult& aResult );
+
+
+        /**
+        * LaunchDetailsViewEmbeddedL test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt LaunchDetailsViewEmbeddedLTestL( TTestResult& aResult );
+
+
+        /**
+        * OpenInfoUrlL test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt OpenInfoUrlLTestL( TTestResult& aResult );
+
+
+        /**
+        * RemoveAutomated test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RemoveAutomatedTestL( TTestResult& aResult );
+
+
+        /**
+        * RemoveAutomatedPassive test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RemoveAutomatedPassiveTestL( TTestResult& aResult );
+
+
+        /**
+        * Test case for class CDRMHelperRightsConstraints.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt RightsConstraintsTestL( TTestResult& aResult );
+
+
+        /**
+        * SetAutomated test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt SetAutomatedTestL( TTestResult& aResult );
+
+
+        /**
+        * SetAutomatedPassive test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt SetAutomatedPassiveTestL( TTestResult& aResult );
+
+
+        /**
+        * SetAutomatedSilent test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt SetAutomatedSilentTestL( TTestResult& aResult );
+
+
+        /**
+        * SetAutomatedType test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt SetAutomatedTypeTestL( TTestResult& aResult );
+
+
+        /**
+        * Test case for testing empty set limits methods.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt SetLimitsTestL( TTestResult& aResult );
+
+
+        /**
+        * SetPreviewMediaType test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt SetPreviewMediaTypeTestL( TTestResult& aResult );
+
+
+        /**
+        * ShowAutomatedNote test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ShowAutomatedNoteTestL( TTestResult& aResult );
+
+
+        /**
+        * ShowDRMUINotification2L test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ShowDRMUINotification2LTestL( TTestResult& aResult );
+
+
+        /**
+        * SupportedDRMMethods2 test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt SupportedDRMMethods2TestL( TTestResult& aResult );
+
+
+        /**
+        * SupportedDataType test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt SupportedDataTypeTestL( TTestResult& aResult );
+
+
+        /**
+        * UnRegisterDataType test case.
+        * @since S60 v3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error
+        *   that is not returned as test case result in aResult)
+        */
+        TInt UpdateDataTypesTestL( TTestResult& aResult );
+
+    private:    // Data
+        // Pointer to test (function) to be executed
+        TestFunction iMethod;
+
+        // Pointer to logger
+        CStifLogger* iLog;
+
+        //Handle to RFs
+        RFs iFs;
+    };
+
+#endif      // DRMHELPERTEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/tsrc/inc/drmhelpertestdata.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,336 @@
+/*
+* 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:  test data for DrmHelperTest test module.
+*
+*/
+
+
+#ifndef DRMHELPERTESTDATA_H
+#define DRMHELPERTESTDATA_H
+#include <f32file.h>
+// -----------------------------------------------------------------------------
+// OMA DRM 1 SD image, no RI Url
+// -----------------------------------------------------------------------------
+//
+_LIT( KDcf1JpegFile, "C:\\jpg.dcf" );
+
+
+_LIT8( KDcf1JpegData,
+"\
+\001\012\057\151\155\141\147\145\057\152\160\145\147\143\151\144\
+\072\155\171\055\164\145\170\164\055\062\060\060\067\060\071\061\
+\070\062\060\061\071\062\061\055\062\060\064\061\066\063\061\062\
+\064\063\100\156\157\153\151\141\056\143\157\155\054\224\000\105\
+\156\143\162\171\160\164\151\157\156\055\115\145\164\150\157\144\
+\072\040\101\105\123\061\062\070\103\102\103\073\160\141\144\144\
+\151\156\147\075\122\106\103\062\066\063\060\257\173\160\346\212\
+\252\052\072\276\261\144\203\332\340\105\065\004\273\161\353\216\
+\264\266\045\001\373\373\342\102\223\050\205\316\352\046\015\031\
+\101\156\264\122\221\257\277\017\027\145\353\341\350\321\240\134\
+\245\273\207\064\145\130\047\275\345\027\206\106\010\274\060\106\
+\060\355\165\217\341\000\143\026\304\317\264\054\114\036\322\361\
+\254\222\273\267\103\054\026\207\025\315\037\123\060\003\044\006\
+\165\206\115\340\112\017\057\250\114\031\275\101\001\374\155\125\
+\142\141\131\364\143\170\044\355\057\134\320\312\314\257\062\105\
+\322\061\367\257\140\042\300\312\141\326\132\370\021\231\057\162\
+\155\111\010\223\266\305\330\110\247\322\070\357\021\144\155\134\
+\335\233\261\171\356\170\065\304\044\102\210\230\124\071\371\244\
+\230\147\332\145\324\361\213\302\010\176\164\260\332\132\345\206\
+\034\177\107\215\253\201\157\164\355\256\314\263\275\205\370\301\
+\357\112\276\056\353\060\277\040\340\036\277\033\164\010\335\350\
+\120\122\225\326\205\031\103\217\345\336\161\121\264\206\262\007\
+\306\123\267\103\340\313\245\014\307\042\045\273\005\170\001\207\
+\372\001\227\107\276\154\231\214\327\055\024\015\220\073\250\040\
+\142\020\223\353\031\345\110\010\076\303\015\345\177\074\244\254\
+\042\340\076\341\036\256\030\176\255\046\266\162\347\250\101\160\
+\240\372\260\161\254\221\307\335\341\221\000\213\002\370\215\207\
+\347\332\035\315\131\172\374\357\057\250\171\215\137\315\044\311\
+\252\122\056\031\034\144\034\363\346\236\307\073\312\103\332\267\
+\175\024\332\071\026\315\011\264\035\211\161\153\326\267\024\260\
+\005\057\320\257\321\146\256\245\225\007\242\321\050\011\051\232\
+\242\305\233\254\272\034\060\206\024\336\272\370\150\263\160\306\
+\042\127\143\160\154\010\233\112\042\025\366\044\212\321\137\017\
+\173\211\221\053\056\331\337\342\107\233\177\076\201\051\205\300\
+\131\336\166\026\374\263\011\112\027\055\067\126\302\165\146\205\
+\024\366\046\212\202\126\264\332\030\145\167\134\072\354\217\220\
+\035\154\344\301\147\064\156\340\001\353\371\300\141\337\150\015\
+\204\056\265\320\367\374\250\037\153\074\014\223\266\232\116\263\
+\206\016\273\015\121\375\226\010\343\223\351\313\004\122\012\047\
+\373\365\275\316\160\302\253\263\140\032\114\146\157\011\117\207\
+\110\173\264\266\116\036\344\352\023\135\360\243\337\255\140\275\
+\062\023\375\167\223\175\036\172\012\214\060\320\156\151\065\062\
+\357\337\275\172\335\057\164\240\115\372\164\370\057\104\255\334\
+\144\216\221\243\221\161\117\212\023\350\213\353\177\313\203\142\
+\213\157\213\045\065\041\262\301\242\207\305\332\167\352\111\164\
+\154\135\101\236\264\052\307\273\107\215\247\330\270\175\260\254\
+\105\030\000\057\163\217\031\002\215\365\017\130\340\134\200\217\
+\367\261\071\300\251\213\252\336\073\176\170\143\244\172\144\015\
+\054\345\342\166\224\237\362\350\033\167\312\133\271\324\176\374\
+\262\011\137\066\166\117\313\033\212\116\063\120\210\347\132\123\
+\146\275\173\320\102\372\256\237\303\260\247\320\066\205\142\252\
+\017\337\110\014\065\320\174\230\227\033\171\350\230\373\251\011\
+\006\274\305\136\332\206\377\316\064\115\072\245\342\003\150\003\
+\014\035\064\157\220\317\162\314\063\036\320\137\107\364\012\043\
+\076\036\271\061\234\312\122\005\240\116\363\217\336\026\151\102\
+\236\265\343\200\116\201\260\210\151\210\005\264\025\163\343\224\
+\054\030\136\045\217\312\360\312\313\124\271\240\065\202\073\031\
+\062\152\255\347\104\042\142\276\266\152\365\213\373\056\121\033\
+\112\145\343\005\271\113\275\353\116\163\234\100\230\240\230\035\
+\163\141\112\113\252\366\337\154\117\266\110\013\040\304\167\057\
+\267\260\136\245\305\172\017\057\325\371\041\126\171\271\270\137\
+\106\360\036\113\312\231\024\327\256\030\316\026\036\141\255\244\
+\153\123\363\060\021\057\124\127\025\316\227\117\172\276\336\075\
+\000\360\275\141\221\226\255\015\055\341\202\255\352\173\301\012\
+\234\102\161\317\160\337\134\044\223\177\064\323\102\041\015\326\
+\256\056\277\157\264\001\143\301\077\107\031\371\262\163\021\072\
+\223\270\072\234\152\236\225\164\262\023\106\356\202\022\102\145\
+\343\307\107\315\241\375\204\166\147\035\367\027\272\347\016\051\
+\017\353\141\326\237\123\271\101\045\272\254\314\111\103\124\342\
+\007\203\076\256\332\272\103\223\024\073\333\134\166\061\354\370\
+\212\233\357\047\355\311\241\161\222\127\065\046\351\374\231\230\
+\015\214\001\351\315\266\023\005\051\212\135\313\271\004\033\035\
+\334\210\224\005\235\262\307\172\160\136\327\166\036\326\362\173\
+\144\365\364\015\076\144\273\270\227\224\276\210\073\071\033\215\
+\354\135\063\107\115\060\202\340\305\003\025\112\335\130\123\034\
+\305\075\174\211\120\274\231\123\333\146\202\325\364\140\320\330\
+\060\245\310\143\137\307\241\226\057\015\102\365\240\277\340\157\
+\310\161\230\124\160\352\134\354\027\200\063\022\341\263\226\123\
+\343\143\246\345\311\310\131\265\076\205\173\134\377\176\010\327\
+\005\102\365\103\206\264\141\207\126\116\017\255\200\221\132\110\
+\014\165\340\151\150\336\043\267\071\027\215\251\022\106\102\314\
+\367\335\103\125\167\356\355\322\376\331\251\105\175\036\020\034\
+\277\313\157\047\265\051\300\316\212\247\212\314\022\350\040\216\
+\137\214\142\153\222\352\255\173\276\263\156\005\006\213\304\255\
+\232\277\350\261\143\156\116\352\210\301\230\065\270\366\050\114\
+\043\323\267\253\252\035\321\246\114\140\006\012\254\255\207\025\
+\230\245\352\120\243\137\030\116\346\145\026\351\134\031\135\334\
+\201\342\016\073\114\132\023\141\320\003\277\047\051\304\210\215\
+\024\226\241\227\050\167\046\333\052\154\223\167\236\065\203\323\
+\365\263\000\356\352\306\240\170\002\213\216\236\047\250\044\115\
+\332\162\033\216\126\050\010\315\030\301\340\275\357\240\124\204\
+\060\103\376\315\273\131\107\305\213\301\047\254\315\113\246\371\
+\046\112\360\050\114\207\102\240\323\061\001\311\275\344\211\220\
+\304\251\320\326\213\072\124\226\074\054\321\363\044\156\271\213\
+\256\241\236\227\001\020\204\256\041\223\051\150\244\177\071\112\
+\236\227\245\310\223\252\173\216\105\176\220\165\132\366\121\345\
+\207\102\173\256\231\035\353\364\367\015\361\055\133\230\102\351\
+\240\226\231\114\342\323\176\336\071\033\231\001\331\036\137\000\
+\117\222\265\163\052\257\174\200\015\264\306\015\274\300\014\163\
+\201\057\336\005\042\006\361\236\167\141\213\070\037\223\243\265\
+\244\253\117\275\012\275\101\111\112\072\306\004\316\252\245\061\
+\064\374\321\131\066\277\015\173\330\303\206\202\066\151\031\365\
+\054\364\352\250\204\250\226\175\042\123\057\363\265\302\043\361\
+\323\062\377\272\001\203\373\345\365\246\021\310\160\155\200\055\
+\216\205\231\057\177\360\242\351\030\023\100\030\107\274\354\211\
+\354\306\073\207\166\175\004\045\270\263\367\366\100\261\234\020\
+\125\003\220\351\355\114\267\343\120\077\002\030\222\201\067\340\
+\226\322\307\151\162\273\247\240\243\352\005\327\122\054\210\017\
+\104\237\071\273\005\044\323\057\352\361\351\253\007\373\133\240\
+\345\202\273\334\140\322\252\006\110\011\040\355\372\014\133\137\
+\205\212\142\150\222\050\027\201\031\011\135\154\206\022\114\073\
+\215\276\244\065\330\067\323\211\217\331\265\340\036\362\231\243\
+\071\165\233\006\265\063\072\213\346\030\262\035\326\012\277\004\
+\233\042\072\246\045\043\303\111\257\016\075\260\215\372\264\010\
+\234\313\241\216\142\351\145\371\171\010\037\020\307\334\347\074\
+\137\034\051\264\332\375\231\353\013\275\222\275\331\347\173\257\
+\022\313\010\330\323\002\262\073\264\267\163\356\162\052\375\307\
+\206\171\122\361\375\124\345\213\024\123\214\305\161\206\067\340\
+\137\261\232\354\105\010\235\005\325\153\027\270\123\152\203\115\
+\367\372\031\116\241\215\075\217\177\022\063\044\117\015\133\014\
+\335\275\035\314\050\344\214\242\350\017\254\226\340\312\114\377\
+\327\007\044\025\324\072\362\200\120\371\221\222\316\044\266\137\
+\173\214\337\043\032\124\354\357\062\267\151\110\241\305\030\056\
+\312\075\251\301\253\141\140\000\134\146\055\062\052\132\140\176\
+\123\161\256\065\100\152\110\311\045\110\034\347\202\056\012\072\
+\174\204\003\207\153\246\041\372\334\015\103\040\365\136\310\056\
+\353\230\022\075\227\136\370\160\373\346\040\371\166\261\251\044\
+\137\144\253\054\036\052\246\242\036\144\303\164\237\171\376\246\
+\067\171\034\205\057\300\224\165\260\365\050\152\306\262\346\054\
+\226\133\207\202\033\001\323\000\051\206\351\060\343\251\167\116\
+\144\041\073\125\276\362\155\336\065\266\350\067\163\100\256\124\
+\233\347\055\157\020\311\373\302\020\265\355\055\247\302\305\340\
+\006\020\271\324\133\175\174\016\073\176\374\123\071\350\300\066\
+\274\326\206\062\237\153\255\121\300\312\076\375\075\015\255\101\
+\333\366\155\274\217\357\267\166\066\326\012\326\107\162\115\175\
+\041\000\374\327\346\146\012\352\051\173\157\105\262\264\337\161\
+\203\251\147\052\010\300\372\213\127\264\165\113\000\323\334\304\
+\135\114\304\354\333\105\240\261\160\254\256\134\215\327\067\236\
+\364\314\212\115\360\336\026\013\274\165\131\363\323\072\336\322\
+\372\243\344\347\133\343\043\314\361\305\055\113\032\131\121\062\
+\217\022\047\062\301\341\317\212\374\270\050\233\023\313\106\245\
+\160\373\046\271\160\323\122\033\303\055\035\072\161\027\051\166\
+\234\216\372\161\106\114\376\151\135\024\213\217\173\221\343\371\
+\174\035\172\371\252\312\147\153\217\205\104\004\235\105\373\047\
+\316\055\016\300\260\053\177\246\062\307\273\032\245\116\252\363\
+\256\131\006\304\141\055\005\205\153\151\135\002\221\075\237\351\
+\311\032\150\341\344\341\211\361\335\133\252\210\075\200\224\137\
+\124\162\316\361\235\013\167\222\035\142\114\023\361\054\164\377\
+\007\371\124\043\266\156\067\121\006\316\033\312\213\175\224\072\
+\341\204\300\343\357\016\257\025\335\024\364\035\074\224\373\336\
+\370\246\130\167\177\112\251\222\241\265\237\232\270\355\340\114\
+\330\031\332\144\025\051\052\255\054\311\064\206\152\027\005\250\
+\260\251\371\327\232\300\223\153\236\214\004\377\373\020\036\162\
+\231\221\033\311\115\112\264\334\227\347\152\176\220\262\273\022\
+\107\170\043\102\241\132\315\375\251\156\157\347\242\007\275\273\
+\034\114\367\127\163\327\071\056\127\131\152\325\344\105\101\155\
+\346\006\362\255\027\161\051\266\377\174\117\037\074\230\335\047\
+\173\346\015\201\042\212\107\304\302\333\173\277\131\270\365\137\
+\312\035\351\261\147\011\334\150\317\142\004\172\051\213\077\141\
+\020\327\174\244\166\266\076\314\076\256\110\254\021\315\310\030\
+\206\334\071\252\363\127\117\052\212\142\316\050\261\135\152\036\
+\111\303\264\160\273\367\160\250\056\371\200\117\306\203\344\015\
+\226\356\231\073\236\202\217\227\043\042\361\025\166\230\266\065\
+\322\156\016\262\105\313\004\156\010\010\161\071\047\101\071\063\
+\164\214\213\120\026\255\210\151\263\231\251\300\306\300\344\031\
+\134\307\224\010\213\102\221\341\123\011\060\375\217\165\176\126\
+\023\375\211\217\034\106\135\137\376\261\327\
+"
+);
+
+_LIT8( KCid1Jpeg, "cid:my-text-20070918201921-2041631243@nokia.com" );
+_LIT8( KCek1Jpeg, "N+CIARh8CAcOBvc3if5sQA==" );
+
+// -----------------------------------------------------------------------------
+// Plain text
+// -----------------------------------------------------------------------------
+//
+_LIT( KPlainTextFile, "c:\\text.txt" );
+
+
+_LIT8( KPlainTextData,
+"\
+kokkokokookokoonkokokokkokokokokkokokokookokokokkokokoonkokoonkokokokon\r\n\
+sanonopeastimustankissanpaksutposket\r\n\
+katkatkatkara\
+" );
+
+// ----------------------------------------------------------------------------
+// DRM 2 audio file witn infourl and with contenturl
+// -----------------------------------------------------------------------------
+//
+_LIT( KDcf2MpegFile, "C:\\mp3.odf" );
+
+
+// ----------------------------------------------------------------------------
+// DRM 2 JPEG file without extra information
+// -----------------------------------------------------------------------------
+//
+_LIT( KDcf2JpegFile, "C:\\jpg.odf" );
+_LIT8( KDcf2JpegData, "" );
+
+// -----------------------------------------------------------------------------
+// nonexistent contentid
+// -----------------------------------------------------------------------------
+//
+_LIT8( KCidNotExist, "cid:cid-does-not-exist@nokia.com" );
+
+
+
+// -----------------------------------------------------------------------------
+// Rights objects
+// -----------------------------------------------------------------------------
+//
+
+// -----------------------------------------------------------------------------
+// Formatter for OMA 1 RO head
+// Use example
+// TDesC8 cid, cek, permissioins;
+// TDesC& RO
+// RO.AppendFormat( KRO1HeadFormatter, &cid, &cek &permissions);
+// -----------------------------------------------------------------------------
+//
+_LIT8( KRO1Formatter,
+"\
+<o-ex:rights\r\n\
+   xmlns:o-ex=\"http://odrl.net/1.1/ODRL-EX\"\r\n\
+   xmlns:o-dd=\"http://odrl.net/1.1/ODRL-DD\"\r\n\
+   xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#/\"\r\n\
+>\r\n\
+<o-ex:context>\r\n\
+<o-dd:version>1.0</o-dd:version>\r\n\
+</o-ex:context>\r\n\
+<o-ex:agreement>\r\n\
+<o-ex:asset>\r\n\
+<o-ex:context>\r\n\
+<o-dd:uid>%S</o-dd:uid>\r\n\
+</o-ex:context>\r\n\
+<ds:KeyInfo>\r\n\
+<ds:KeyValue>%S</ds:KeyValue>\r\n\
+</ds:KeyInfo>\r\n\
+</o-ex:asset>\r\n\
+<o-ex:permission>\r\n\
+%S\
+</o-ex:permission>\r\n\
+</o-ex:agreement>\r\n\
+</o-ex:rights>\r\n\
+\r\n\
+" );
+
+_LIT8( KDisplayCount1,
+"\
+<o-dd:display>\r\n\
+<o-ex:constraint>\r\n\
+<o-dd:count>1</o-dd:count>\r\n\
+</o-ex:constraint>\r\n\
+</o-dd:display>\r\n\
+" );
+
+_LIT8( KDisplayFull, "<o-dd:display/>\r\n" );
+
+_LIT8( KDisplayCount1PrintInterval1Second,
+"\
+<o-dd:display>\r\n\
+<o-ex:constraint>\r\n\
+<o-dd:count>1</o-dd:count>\r\n\
+</o-ex:constraint>\r\n\
+</o-dd:display>\r\n\
+<o-dd:print>\r\n\
+<o-ex:constraint>\r\n\
+<o-dd:interval>PT1S</o-dd:interval>\r\n\
+</o-ex:constraint>\r\n\
+</o-dd:print>\r\n\
+" );
+
+
+struct TFileDataMap
+    {
+public:
+    const TDesC& iFile;
+    const TDesC8& iData;
+    };
+
+void CreateDataFilesL( RFs& aFs )
+    {
+    const TFileDataMap files[] =
+        {
+            { KPlainTextFile, KPlainTextData },
+            { KDcf1JpegFile, KDcf1JpegData },
+            { KDcf2JpegFile, KDcf2JpegData },
+        };
+    const TInt numElements( sizeof ( files ) / sizeof( TFileDataMap ) );
+
+
+    for ( TInt i( 0 ); i < numElements; ++i )
+        {
+        RFile file;
+        User::LeaveIfError ( file.Replace( aFs, files[ i ].iFile, EFileWrite ) );
+        CleanupClosePushL( file );
+        User::LeaveIfError( file.Write( files[ i ].iData ) );
+        CleanupStack::PopAndDestroy( &file );
+        }
+    }
+
+#endif      // DRMHELPERTESTDATA_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/tsrc/src/drmhelpertest.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,259 @@
+/*
+* 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:  DrmHelperTest class member functions
+*
+*/
+
+
+
+
+// INCLUDE FILES
+#include <stiftestinterface.h>
+#include "drmhelpertest.h"
+
+// Forward declarations
+extern void CreateDataFilesL( RFs& aFs );
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::CDrmHelperTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDrmHelperTest::CDrmHelperTest()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+//
+// Note: If OOM test case uses STIF Logger, then STIF Logger must be created
+// with static buffer size parameter (aStaticBufferSize). Otherwise Logger
+// allocates memory from heap and therefore causes error situations with OOM
+// testing. For more information about STIF Logger construction, see STIF Users
+// Guide.
+// -----------------------------------------------------------------------------
+//
+void CDrmHelperTest::ConstructL()
+    {
+    iLog = CStifLogger::NewL( KDrmHelperTestLogPath,
+                              KDrmHelperTestLogFile);
+
+    // Sample how to use logging
+    _LIT( KLogStart, "DrmHelperTest logging starts!" );
+    iLog->Log( KLogStart );
+
+    User::LeaveIfError( iFs.Connect() );
+    _LIT( KFsConnected, "Connected to RFs.");
+    iLog->Log( KFsConnected );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDrmHelperTest* CDrmHelperTest::NewL()
+    {
+    CDrmHelperTest* self = new (ELeave) CDrmHelperTest;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+
+    }
+
+// Destructor
+CDrmHelperTest::~CDrmHelperTest()
+    {
+    delete iLog;
+    iFs.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::InitL
+// InitL is used to initialize the Test Module.
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::InitL(
+    TFileName& /*aIniFile*/,
+    TBool aFirstTime )
+    {
+    _LIT( KInitStart, "InitL" );
+    iLog->Log( KInitStart );
+
+    if ( aFirstTime )
+       {
+       _LIT( KFirstTime, "aFirstTime == ETrue" );
+       iLog->Log( KFirstTime );
+       CreateDataFilesL( iFs );
+       _LIT( KFilesCreated, "data files created" );
+       iLog->Log( KFilesCreated );
+       }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::GetTestCasesL
+// GetTestCases is used to inquire test cases from the Test Module. Test
+// cases are stored to array of test cases. The Test Framework will be
+// the owner of the data in the RPointerArray after GetTestCases return
+// and it does the memory deallocation.
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::GetTestCasesL(
+    const TFileName& /*aConfig*/,
+    RPointerArray<TTestCaseInfo>& aTestCases )
+    {
+
+    // Loop through all test cases and create new
+    // TTestCaseInfo items and append items to aTestCase array
+    for( TInt i = 0; Case(i).iMethod; i++ )
+        {
+
+        // Allocate new TTestCaseInfo from heap for a testcase definition.
+        TTestCaseInfo* newCase = new( ELeave ) TTestCaseInfo();
+
+        // PushL TTestCaseInfo to CleanupStack.
+        CleanupStack::PushL( newCase );
+
+        // Set number for the testcase.
+        // When the testcase is run, this comes as a parameter to RunTestCaseL.
+        newCase->iCaseNumber = i;
+
+        // Set title for the test case. This is shown in UI to user.
+        newCase->iTitle.Copy( Case(i).iCaseName );
+
+        // Append TTestCaseInfo to the testcase array. After appended
+        // successfully the TTestCaseInfo object is owned (and freed)
+        // by the TestServer.
+        User::LeaveIfError(aTestCases.Append ( newCase ) );
+
+        // Pop TTestCaseInfo from the CleanupStack.
+        CleanupStack::Pop( newCase );
+
+        }
+
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::RunTestCaseL
+// RunTestCaseL is used to run an individual test case specified
+// by aTestCase. Test cases that can be run may be requested from
+// Test Module by GetTestCases method before calling RunTestCase.
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::RunTestCaseL(
+    const TInt aCaseNumber,
+    const TFileName& /*aConfig*/,
+    TTestResult& aResult )
+    {
+
+    // Return value
+    TInt execStatus = KErrNone;
+
+    // Get the pointer to test case function
+    TCaseInfo tmp = Case ( aCaseNumber );
+
+    _LIT( KLogStartTC, "Starting testcase [%S]" );
+    iLog->Log( KLogStartTC, &tmp.iCaseName);
+
+    // Check that case number was valid
+    if ( tmp.iMethod )
+        {
+        // Valid case was found, call it via function pointer
+        iMethod = tmp.iMethod;
+        execStatus  = ( this->*iMethod )( aResult );
+        }
+    else
+        {
+        // Valid case was not found, return error.
+        execStatus = KErrNotFound;
+        }
+
+    // Return case execution status (not the result of the case execution)
+    return execStatus;
+
+    }
+
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point
+// Returns: CTestModuleBase*: Pointer to Test Module object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTestModuleBase* LibEntryL()
+    {
+    return CDrmHelperTest::NewL();
+
+    }
+
+// -----------------------------------------------------------------------------
+// SetRequirements handles test module parameters(implements evolution
+// version 1 for test module's heap and stack sizes configuring).
+// Returns: TInt: Symbian error code.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/,
+                               TUint32& /*aParameterValid*/ )
+    {
+
+    /* --------------------------------- NOTE ---------------------------------
+       USER PANICS occurs in test thread creation when:
+       1) "The panic occurs when the value of the stack size is negative."
+       2) "The panic occurs if the minimum heap size specified is less
+       than KMinHeapSize".
+KMinHeapSize: "Functions that require a new heap to be allocated will
+either panic, or will reset the required heap size to this value if
+a smaller heap size is specified".
+3) "The panic occurs if the minimum heap size specified is greater than
+the maximum size to which the heap can grow".
+Other:
+1) Make sure that your hardware or Symbian OS is supporting given sizes.
+e.g. Hardware might support only sizes that are divisible by four.
+------------------------------- NOTE end ------------------------------- */
+
+    // Normally STIF uses default heap and stack sizes for test thread, see:
+    // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
+    // If needed heap and stack sizes can be configured here by user. Remove
+    // comments and define sizes.
+
+    /*
+       aParameterValid = KStifTestModuleParameterChanged;
+
+       CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
+    // Stack size
+    param->iTestThreadStackSize= 16384; // 16K stack
+    // Heap sizes
+    param->iTestThreadMinHeap = 4096;   // 4K heap min
+    param->iTestThreadMaxHeap = 1048576;// 1M heap max
+
+    aTestModuleParam = param;
+    */
+    return KErrNone;
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_helper_api/tsrc/src/drmhelpertestcases.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,2055 @@
+/*
+* 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:  DrmHelperTest hard coded test cases
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <coemain.h>
+#include <apmstd.h> //TDataType
+#include <drmhelper.h>
+#include <drmrightsclient.h>
+#include <drmrights.h>
+#include <dcfrep.h>
+#include <dcfrepcli.h>
+#include <caf/caferr.h>
+#include <caf/data.h>
+#include <caf/virtualpathptr.h>
+#include "drmrightsparser.h"
+#include "drmhelpertest.h"
+#include "drmhelpertestdata.h"
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+_LIT( KPassed, "Passed" );
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// DoResetAndDestroyRightsArray
+// Does RPointerArray< >->ResetAndDestroy() for the given array aPtr.
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void DoResetAndDestroyRightsArray( TAny* aPtr )
+    {
+    ( reinterpret_cast< RPointerArray< CDRMRights >* >( aPtr ) )->
+        ResetAndDestroy();
+    }
+
+// -----------------------------------------------------------------------------
+// DeleteRODBL
+// Helper function with which test cases can delete RO DB
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void DeleteRODBL()
+    {
+    RDRMRightsClient client;
+    User::LeaveIfError( client.Connect() );
+    client.DeleteAll();
+    client.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// AddROL
+// Helper function with which test cases can add ROs
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void AddROL(
+    const TDesC8& aFormatter,
+    const TDesC8& aCID,
+    const TDesC8& aCEK,
+    const TDesC8& aPermissions )
+    {
+    TInt roSize(
+        aFormatter.Size() + aCID.Size() + aCEK.Size() + aPermissions.Size() );
+    HBufC8* buf( HBufC8::NewLC( roSize ) );
+    TPtr8 tmp( buf->Des() );
+
+    tmp.AppendFormat( aFormatter, &aCID, &aCEK, &aPermissions );
+
+    RPointerArray< CDRMRights > rights;
+    rights.Reset();
+    TCleanupItem cleanup( DoResetAndDestroyRightsArray, &rights );
+    CleanupStack::PushL( cleanup );
+
+    CDrmRightsParser* rp( CDrmRightsParser::NewL() );
+    CleanupStack::PushL( rp );
+
+    rp->ParseAndStoreL( *buf, rights );
+
+    CleanupStack::PopAndDestroy( rp );
+    CleanupStack::PopAndDestroy( &rights );
+    CleanupStack::PopAndDestroy( buf );
+    }
+
+// -----------------------------------------------------------------------------
+// Updates given file to DCFREpository
+// -----------------------------------------------------------------------------
+//
+void UpdateRepositoryEntryL( const TDesC& aFile )
+    {
+    //Remove old entries
+    CDcfRep* rep( CDcfRep::NewL() );
+    CleanupStack::PushL( rep );
+    rep->RemoveDcfFromDbL( aFile );
+    CleanupStack::PopAndDestroy( rep );
+    //And add new entry
+    RDcfRepCli cli;
+    User::LeaveIfError( cli.Connect() );
+    CleanupClosePushL( cli );
+    cli.AddFile( aFile );
+    CleanupStack::PopAndDestroy( &cli );
+    }
+
+// ----------------------------------------------------------------------------
+// CleanupPtrRPointerArrayHBufC8
+// Does RPointerArray< >->ResetAndDestroy() for the given ppointer
+// to RPointerArray deletes *aPtr and sets it to null.
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void CleanupPtrRPointerArrayHBufC8( TAny* aPtr )
+    {
+    RPointerArray< HBufC8 >** pPtr(
+        reinterpret_cast< RPointerArray< HBufC8 >** >( aPtr ) );
+    ( *pPtr )->ResetAndDestroy();
+    delete *pPtr;
+    *pPtr = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// some caller inlines for convenience
+// -----------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------------
+// CallHasInfoUrlForTDesc
+// -----------------------------------------------------------------------------
+//
+LOCAL_C inline void CallHasInfoUrlForTDesc(
+    CDRMHelper*& aHelper, TInt& aTrappedError, TBool& aHasUrl,
+    const TDesC& aFileName, HBufC8*& aInfoUrl )
+    {
+    TRAP( aTrappedError, aHasUrl = aHelper->HasInfoUrlL(
+            const_cast< TDesC& >( aFileName ), aInfoUrl ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CallHasInfoUrlForCDataL(
+// -----------------------------------------------------------------------------
+//
+LOCAL_C inline void CallHasInfoUrlForCDataL(
+    CDRMHelper*& aHelper, TInt& aTrappedError, TBool& aHasUrl,
+    const TDesC& aFileName, HBufC8*& aInfoUrl )
+    {
+    ContentAccess::TVirtualPathPtr virtualPath( aFileName );
+
+    ContentAccess::CData* content(
+        CData::NewLC( virtualPath, EPeek, EContentShareReadWrite ) );
+
+    TRAP( aTrappedError, aHasUrl = aHelper->HasInfoUrlL(
+            *content, aInfoUrl ) );
+    CleanupStack::PopAndDestroy( content );
+    }
+
+// -----------------------------------------------------------------------------
+// CallHasPreviewForTDesc
+// -----------------------------------------------------------------------------
+//
+LOCAL_C inline void CallHasPreviewForTDesc(
+    CDRMHelper*& aHelper, TInt& aTrappedError, TBool& aHasUrl,
+    const TDesC& aFileName, HBufC8*& aInfoUrl )
+    {
+    TRAP( aTrappedError, aHasUrl = aHelper->HasPreviewL(
+            const_cast< TDesC& >( aFileName ), aInfoUrl ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CallHasPreviewForCDataL
+// -----------------------------------------------------------------------------
+//
+LOCAL_C inline void CallHasPreviewForCDataL(
+    CDRMHelper*& aHelper, TInt& aTrappedError, TBool& aHasUrl,
+    const TDesC& aFileName, HBufC8*& aInfoUrl )
+    {
+    ContentAccess::TVirtualPathPtr virtualPath( aFileName );
+
+    ContentAccess::CData* content(
+        CData::NewLC( virtualPath, EPeek, EContentShareReadWrite ) );
+
+    TRAP( aTrappedError, aHasUrl = aHelper->HasPreviewL(
+            *content, aInfoUrl ) );
+    CleanupStack::PopAndDestroy( content );
+    }
+
+// -----------------------------------------------------------------------------
+// CallGetPreviewRightsForCDataL
+// -----------------------------------------------------------------------------
+//
+LOCAL_C inline void CallGetPreviewRightsForCDataL(
+    CDRMHelper*& aHelper, TInt& aTrappedError, const TDesC& aFileName )
+    {
+    ContentAccess::TVirtualPathPtr virtualPath( aFileName );
+
+    ContentAccess::CData* content(
+        CData::NewLC( virtualPath, EPeek, EContentShareReadWrite ) );
+
+    TRAP( aTrappedError, aHelper->GetPreviewRightsL( *content ) );
+    CleanupStack::PopAndDestroy( content );
+    }
+
+// -----------------------------------------------------------------------------
+// CallOpenInfoUrlForCDataL
+// -----------------------------------------------------------------------------
+//
+LOCAL_C inline void CallOpenInfoUrlForCDataL(
+    CDRMHelper*& aHelper, TInt& aTrappedError, const TDesC& aFileName )
+    {
+    ContentAccess::TVirtualPathPtr virtualPath( aFileName );
+
+    ContentAccess::CData* content(
+        CData::NewLC( virtualPath, EPeek, EContentShareReadWrite ) );
+
+    TRAP( aTrappedError, aHelper->OpenInfoUrlL( *content ) );
+    CleanupStack::PopAndDestroy( content );
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::Case
+// Returns a test case by number.
+//
+// This function contains an array of all available test cases
+// i.e pair of case name and test function. If case specified by parameter
+// aCaseNumber is found from array, then that item is returned.
+//
+// The reason for this rather complicated function is to specify all the
+// test cases only in one place. It is not necessary to understand how
+// function pointers to class member functions works when adding new test
+// cases. See function body for instructions how to add new test case.
+// -----------------------------------------------------------------------------
+//
+const TCaseInfo CDrmHelperTest::Case (
+    const TInt aCaseNumber ) const
+     {
+
+    /**
+    * To add new test cases, implement new test case function and add new
+    * line to KCases array specify the name of the case and the function
+    * doing the test case
+    * In practice, do following
+    * 1) Make copy of existing test case function and change its name
+    *    and functionality. Note that the function must be added to
+    *    DrmHelperTest.cpp file and to DrmHelperTest.h
+    *    header file.
+    *
+    * 2) Add entry to following KCases array either by using:
+    *
+    * 2.1: FUNCENTRY or ENTRY macro
+    * ENTRY macro takes two parameters: test case name and test case
+    * function name.
+    *
+    * FUNCENTRY macro takes only test case function name as a parameter and
+    * uses that as a test case name and test case function name.
+    *
+    * Or
+    *
+    * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
+    * only with OOM (Out-Of-Memory) testing!
+    *
+    * OOM_ENTRY macro takes five parameters: test case name, test case
+    * function name, TBool which specifies is method supposed to be run using
+    * OOM conditions, TInt value for first heap memory allocation failure and
+    * TInt value for last heap memory allocation failure.
+    *
+    * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
+    * that as a test case name, TBool which specifies is method supposed to be
+    * run using OOM conditions, TInt value for first heap memory allocation
+    * failure and TInt value for last heap memory allocation failure.
+    */
+
+    static TCaseInfoInternal const KCases[] =
+        {
+        // To add new test cases, add new items to this array
+
+        // NOTE: When compiled to GCCE, there must be Classname::
+        // declaration in front of the method name, e.g.
+        // CDrmHelperTest::PrintTest. Otherwise the compiler
+        // gives errors.
+
+        ENTRY( "Hlp::Construct", CDrmHelperTest::ConstructTestL ),
+        ENTRY( "Hlp::IndicateIdle", CDrmHelperTest::IndicateIdleTestL ),
+        ENTRY( "Hlp::ActivateContentL", CDrmHelperTest::ActivateContentLTestL ),
+        ENTRY( "Hlp::CanSetAutomated", CDrmHelperTest::CanSetAutomatedTestL ),
+        ENTRY( "Hlp::CheckRightsAmountL", CDrmHelperTest::CheckRightsAmountLTestL ),
+        ENTRY( "Hlp::CheckRightsPercentL", CDrmHelperTest::CheckRightsPercentLTestL ),
+        ENTRY( "Hlp::Consume2", CDrmHelperTest::Consume2TestL ),
+        ENTRY( "Hlp::ConsumeFile2", CDrmHelperTest::ConsumeFile2TestL ),
+        ENTRY( "Hlp::EmbeddedPreviewCompletedL", CDrmHelperTest::EmbeddedPreviewCompletedLTestL ),
+        ENTRY( "Hlp::GetContentURIList", CDrmHelperTest::GetContentURIListTestL ),
+        ENTRY( "Hlp::GetPreviewRightsL", CDrmHelperTest::GetPreviewRightsLTestL ),
+        ENTRY( "Hlp::GetRightsDetailsL", CDrmHelperTest::GetRightsDetailsLTestL ),
+        ENTRY( "Hlp::GetRightsDetailsL(hlpconstraints)", CDrmHelperTest::GetHlpRightsDetailsLTestL ),
+        ENTRY( "Hlp::HandleErrorL", CDrmHelperTest::HandleErrorLTestL ),
+        ENTRY( "Hlp::HandleErrorOrPreviewL", CDrmHelperTest::HandleErrorOrPreviewLTestL ),
+        ENTRY( "Hlp::HasInfoUrlL", CDrmHelperTest::HasInfoUrlLTestL ),
+        ENTRY( "Hlp::HasPreviewL", CDrmHelperTest::HasPreviewLTestL ),
+        ENTRY( "Hlp::LaunchDetailsViewEmbeddedL", CDrmHelperTest::LaunchDetailsViewEmbeddedLTestL ),
+        ENTRY( "Hlp::OpenInfoUrlL", CDrmHelperTest::OpenInfoUrlLTestL ),
+        ENTRY( "Hlp::RemoveAutomated", CDrmHelperTest::RemoveAutomatedTestL ),
+        ENTRY( "Hlp::RemoveAutomatedPassive", CDrmHelperTest::RemoveAutomatedPassiveTestL ),
+        ENTRY( "Hlp::RightsConstraintTestL", CDrmHelperTest::RightsConstraintsTestL),
+        ENTRY( "Hlp::SetAutomated", CDrmHelperTest::SetAutomatedTestL ),
+        ENTRY( "Hlp::SetAutomatedPassive", CDrmHelperTest::SetAutomatedPassiveTestL ),
+        ENTRY( "Hlp::SetAutomatedSilent", CDrmHelperTest::SetAutomatedSilentTestL ),
+        ENTRY( "Hlp::SetAutomatedType", CDrmHelperTest::SetAutomatedTypeTestL ),
+        ENTRY( "Hlp::SetLimitsTestL", CDrmHelperTest::SetLimitsTestL ),
+        ENTRY( "Hlp::SetPreviewMediaType", CDrmHelperTest::SetPreviewMediaTypeTestL ),
+        ENTRY( "Hlp::ShowAutomatedNote", CDrmHelperTest::ShowAutomatedNoteTestL ),
+        ENTRY( "Hlp::ShowDRMUINotification2L", CDrmHelperTest::ShowDRMUINotification2LTestL ),
+        ENTRY( "Hlp::SupportedDRMMethods2", CDrmHelperTest::SupportedDRMMethods2TestL ),
+        ENTRY( "Hlp::SupportedDataType", CDrmHelperTest::SupportedDataTypeTestL ),
+        ENTRY( "Hlp::UpdateDataTypes", CDrmHelperTest::UpdateDataTypesTestL ),
+        };
+
+    // Verify that case number is valid
+    if( (TUint) aCaseNumber >= sizeof( KCases ) /
+                               sizeof( TCaseInfoInternal ) )
+        {
+        // Invalid case, construct empty object
+        TCaseInfo null( (const TText*) L"" );
+        null.iMethod = NULL;
+        null.iIsOOMTest = EFalse;
+        null.iFirstMemoryAllocation = 0;
+        null.iLastMemoryAllocation = 0;
+        return null;
+        }
+
+    // Construct TCaseInfo object and return it
+    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
+    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
+    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
+    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
+    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
+    return tmp;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::SetResult
+// -----------------------------------------------------------------------------
+//
+void CDrmHelperTest::SetResult(
+    TTestResult& aResult,
+    TInt aError )
+    {
+
+    if ( aError != KErrNone )
+        {
+        TBuf<KMaxPath> text;
+        _LIT( KFormatString, "First error code: 0x%08x" );
+        text.AppendFormat( KFormatString, aError );
+        aResult.SetResult( KErrGeneral, text );
+        }
+    else
+        {
+        aResult.SetResult( KErrNone, KPassed );
+        }
+    }
+
+// ========== The cases ========================================================
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::ConstructTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::ConstructTestL( TTestResult& aResult )
+    {
+    CDRMHelper* helper( NULL );
+    _LIT( KStep1,
+        "Step1: DRMHelper::NewLC without arguments \
+        Expecting: initialised helper");
+    iLog->Log( KStep1 );
+    helper = CDRMHelper::NewLC();
+    CleanupStack::PopAndDestroy( helper );
+    helper = NULL;
+    iLog->Log( KPassed );
+
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::NewL without arguments \
+          Expecting: initialised helper");
+    iLog->Log( KStep2 );
+    helper = CDRMHelper::NewL();
+    delete helper;
+    helper = NULL;
+    iLog->Log( KPassed );
+
+    _LIT( KStep3,
+          "Step3: DRMHelper::NewLC arguments RFs \
+          Expecting: initiasised helper");
+    iLog->Log( KStep3 );
+    helper = CDRMHelper::NewLC( iFs );
+    CleanupStack::PopAndDestroy( helper );
+    helper = NULL;
+    iLog->Log( KPassed );
+
+    _LIT( KStep4,
+          "Step4: DRMHelper::NewL arguments RFs \
+          Expecting: initiasised helper");
+    iLog->Log( KStep4 );
+    helper = CDRMHelper::NewL( iFs );
+    delete helper;
+    helper = NULL;
+    iLog->Log( KPassed );
+
+    //preparations
+    CCoeEnv& env( *CCoeEnv::Static() );
+
+    _LIT( KStep5,
+          "Step5: DRMHelper::NewLC arguments CCoeEnv \
+          Expecting: initiasised helper");
+    iLog->Log( KStep5 );
+    helper = CDRMHelper::NewLC( env );
+    CleanupStack::PopAndDestroy( helper );
+    helper = NULL;
+    iLog->Log( KPassed );
+
+    _LIT( KStep6,
+          "Step6: DRMHelper::NewL arguments CCoeEnv \
+          Expecting: initiasised helper");
+    iLog->Log( KStep6 );
+    helper = CDRMHelper::NewL( env );
+    delete helper;
+    helper = NULL;
+    iLog->Log( KPassed );
+
+    _LIT( KStep7,
+          "Step7: DRMHelper::NewLC arguments RFs, CCoeEnv \
+          Expecting: initiasised helper");
+    iLog->Log( KStep7 );
+    helper = CDRMHelper::NewLC( env, iFs );
+    CleanupStack::PopAndDestroy( helper );
+    helper = NULL;
+    iLog->Log( KPassed );
+
+    _LIT( KStep8,
+          "Step8: DRMHelper::NewL arguments RFs, CCoeEnv \
+          Expecting: initiasised helper");
+    iLog->Log( KStep8 );
+    helper = CDRMHelper::NewL( env, iFs );
+    delete helper;
+    helper = NULL;
+    iLog->Log( KPassed );
+
+
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::IndicateIdleTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::IndicateIdleTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    _LIT( KStep1,
+          "Step1: DRMHelper::IndicateIdle \
+          Expecting: clecn return from function");
+    iLog->Log( KStep1 );
+
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    helper->IndicateIdle();
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::ActivateContentLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::ActivateContentLTestL( TTestResult& aResult )
+    {
+    // Note: no reasonable test doable before proper
+    // UI automatisation tool present
+    // Note2: this test calls both API methods of ActivateContentL
+    TInt r( KErrNone );
+    _LIT( KStep1,
+        "Step1: DRMHelper::ActivateContentL with TDesC file name \
+        of plain file \
+        Expecting: leave with either KErrArgument or with KErrNotSupported");
+    iLog->Log( KStep1 );
+
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+
+    TRAP( r, helper->ActivateContentL(
+        const_cast< TDesC& >( KPlainTextFile() ) ) );
+    T2L( r, KErrArgument, KErrNotSupported );
+    _LIT( KStep2,
+        "Step2: DRMHelper::ActivateContentL with CData object \
+        and full rights \
+        Expecting: leave with either KErrArgument or with KErrNotSupported");
+    iLog->Log( KStep2 );
+    ContentAccess::TVirtualPathPtr virtualPath( KPlainTextFile() );
+    ContentAccess::CData* data( NULL );
+    TRAP( r, data = CData::NewL(
+        virtualPath, EPeek, EContentShareReadWrite ) );
+    CleanupStack::PushL( data );
+    TRAP( r, helper->ActivateContentL( *data ) );
+    T2L( r, KErrArgument, KErrNotSupported );
+    CleanupStack::PopAndDestroy( data );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::CanSetAutomatedTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::CanSetAutomatedTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    DeleteRODBL();
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayCount1 );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    TBool canSetAutomated( ETrue );
+
+    _LIT( KStep1,
+        "Step1: DRMHelper::CanSetAutomated with TDesC name \
+         of OMA 1 File and count RO \
+         Expecting: EFalse" );
+    iLog->Log( KStep1 );
+
+    r = helper->CanSetAutomated(
+        const_cast< TDesC& >( KDcf1JpegFile() ), canSetAutomated );
+    TL( !canSetAutomated );
+    T1L( r, KErrNone );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::CanSetAutomated with RFile handle \
+            of OMA 1 File and full RO \
+          Expecting: ETrue" );
+    iLog->Log( KStep2 );
+
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayFull );
+    RFile file;
+    r = file.Open( iFs, KDcf1JpegFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+    r = helper->CanSetAutomated( file, canSetAutomated );
+    TL( canSetAutomated );
+    T1L( r, KErrNone );
+    CleanupStack::PopAndDestroy( &file );
+    _LIT( KStep3,
+        "Step3: DRMHelper::CanSetAutomated with TDesC8 cid \
+        of OMA 1 File and no RO \
+        Expecting: EFalse" );
+    iLog->Log( KStep3 );
+    DeleteRODBL();
+    UpdateRepositoryEntryL( KDcf1JpegFile() );
+    r = helper->CanSetAutomated( KCid1Jpeg(), canSetAutomated );
+    TL( !canSetAutomated );
+    T1L( r, KErrCANoRights );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::CheckRightsAmountLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::CheckRightsAmountLTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    TInt err( KErrNone );
+    DeleteRODBL();
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayCount1 );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    const TInt KcountTreshold( 2 );
+    const TInt KdaysTreshold( 1 );
+    const TInt KNegativeCountTreshold( -3 );
+
+    _LIT( KStep1,
+        "Step1: DRMHelper::CheckRightsAmountL with TDesC name \
+         of OMA 1 File and count RO \
+         Expecting: EFalse" );
+    iLog->Log( KStep1 );
+
+    r = helper->CheckRightsAmountL(
+        const_cast< TDesC& >( KDcf1JpegFile() ),
+        KcountTreshold, KdaysTreshold );
+    T1L( r, KErrNone );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::CheckRightsAmountL with RFile handle \
+            of OMA 1 File and full RO \
+          Expecting: ETrue" );
+    iLog->Log( KStep2 );
+
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayFull );
+    T1L( r, KErrNone );
+    RFile file;
+    r = file.Open( iFs, KDcf1JpegFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+    TRAP( err, r = helper->CheckRightsAmountL( file,
+        KcountTreshold, KdaysTreshold ) );
+
+    T1L( r, KErrNone );
+    T1L( err, KErrNone );
+    CleanupStack::PopAndDestroy( &file );
+    _LIT( KStep3,
+        "Step3: DRMHelper::CheckRightsAmountL with TDesC8 cid \
+        of OMA 1 File and with negative count treshold\
+        Expecting: leave with KErrArgument" );
+    iLog->Log( KStep3 );
+    DeleteRODBL();
+    UpdateRepositoryEntryL( KDcf1JpegFile() );
+    TRAP( err, r = helper->CheckRightsAmountL( KCid1Jpeg(),
+        KNegativeCountTreshold, KdaysTreshold ) );
+    T1L( err, KErrArgument );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::CheckRightsPercentLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::CheckRightsPercentLTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    TInt err( KErrNone );
+    const TInt KpercentTreshold( 20 );
+    const TInt KOverFlowTreshold( 200 );
+    const TInt KNegativeTreshold( -3 );
+
+    // preparations
+    DeleteRODBL();
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayFull );
+    UpdateRepositoryEntryL( KDcf1JpegFile() );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+
+    _LIT( KStep1,
+        "Step1: DRMHelper::CheckRightsPercentL with TDesC name \
+         of OMA 1 File and count RO \
+         Expecting: EFalse" );
+    iLog->Log( KStep1 );
+
+    TRAP( err, r = helper->CheckRightsPercentL(
+        const_cast< TDesC& >( KDcf1JpegFile() ),
+        KNegativeTreshold ) );
+    T1L( err, KErrArgument );
+    T1L( r, KErrNone );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::CheckRightsPercentL with RFile handle \
+            of OMA 1 File and full RO \
+          Expecting: ETrue" );
+    iLog->Log( KStep2 );
+
+    T1L( r, KErrNone );
+    RFile file;
+    r = file.Open( iFs, KDcf1JpegFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+    TRAP( err, r = helper->CheckRightsPercentL( file,
+        KpercentTreshold ) );
+
+    T1L( r, KErrNone );
+    T1L( err, KErrNone );
+    CleanupStack::PopAndDestroy( &file );
+    _LIT( KStep3,
+        "Step3: DRMHelper::CheckRightsPercentL with TDesC name \
+        of OMA 1 File and with negative count treshold\
+        Expecting: leave with KErrArgument" );
+    iLog->Log( KStep3 );
+    DeleteRODBL();
+    TRAP( err, r = helper->CheckRightsPercentL(
+        const_cast< TDesC& >( KDcf1JpegFile() ),
+        KOverFlowTreshold ) );
+    T1L( err, KErrArgument );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::Consume2TestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::Consume2TestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    TUint32 rightsSpec( CDRMRights::EDisplay );
+    CDRMHelper::TDRMHelperConsumeAction consumeAction( CDRMHelper::EStart );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    DeleteRODBL();
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayCount1 );
+
+    _LIT( KStep1,
+        "Step1: DRMHelper::Consume2 with TDesC8 cid \
+        of OMA 1 File and count 1 (consumestart) \
+        Expecting: success" );
+    iLog->Log( KStep1 );
+    r = helper->Consume2( KCid1Jpeg(), rightsSpec, consumeAction );
+    T1L( r, KErrNone );
+
+    _LIT( KStep2,
+        "Step2: DRMHelper::Consume2 with TDesC8 cid \
+        of OMA 1 File and count 1 (consumeStop) \
+        Expecting: success" );
+    iLog->Log( KStep2 );
+    consumeAction = CDRMHelper::EFinish;
+    r = helper->Consume2( KCid1Jpeg(), rightsSpec, consumeAction );
+    T1L( r, KErrNone );
+    CleanupStack::PopAndDestroy( helper );
+
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::ConsumeFile2TestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::ConsumeFile2TestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    TUint32 rightsSpec( CDRMRights::EDisplay );
+    CDRMHelper::TDRMHelperConsumeAction consumeAction( CDRMHelper::EFinish );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+
+    DeleteRODBL();
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayCount1 );
+
+    _LIT( KStep1,
+        "Step1: DRMHelper::ConsumeFile2 with TDesC filename \
+        of OMA 1 File and count 1 (consumestop) \
+        Expecting: KErrNotFound" );
+    iLog->Log( KStep1 );
+    r = helper->ConsumeFile2( KDcf1JpegFile(), rightsSpec, consumeAction );
+    T1L( r, KErrNotFound );
+
+    _LIT( KStep2,
+        "Step2: DRMHelper::ConsumeFile2 with RFile handle \
+        of OMA 1 File and count 1 (consumepause, no consumestart) \
+        Expecting: KErrNotFound" );
+    iLog->Log( KStep2 );
+    consumeAction = CDRMHelper::EPause;
+    r = helper->ConsumeFile2( KDcf1JpegFile(), rightsSpec, consumeAction );
+    T1L( r, KErrNotFound );
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::EmbeddedPreviewCompletedLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::EmbeddedPreviewCompletedLTestL( TTestResult& aResult )
+    {
+    // Note: reasonable case not doable, since
+    // all reasonable usage scenarios require user input from UI
+    TInt r( KErrNone );
+    _LIT( KStep1,
+          "Step1: DRMHelper::EmbeddedPreviewCompletedL with OMA 1 file \
+          Expecting: leave with error KErrNotSupported or \
+          with KErrCANotSupported" );
+    iLog->Log( KStep1 );
+
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    TRAPD( err, helper->EmbeddedPreviewCompletedL(
+        const_cast< TDesC& >( KDcf1JpegFile() ) ) );
+    T2L( err, KErrNotSupported, KErrCANotSupported );
+    //Just leaves with KErrNotSupported
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::GetContentURIListTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::GetContentURIListTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    RPointerArray< HBufC8 >* uriList( NULL );
+
+    DeleteRODBL();
+
+    _LIT( KStep1,
+          "Step1: DRMHelper::GetContentURIList, no rights present \
+          Expecting: empty list" );
+    iLog->Log( KStep1 );
+    r = helper->GetContentURIList( uriList );
+    // Check results
+    TL( uriList );
+    TCleanupItem item( CleanupPtrRPointerArrayHBufC8, &uriList );
+    CleanupStack::PushL( item );
+    T1L( r, KErrNone );
+    T1L( uriList->Count(), 0 );
+    // Cleanup
+    CleanupStack::PopAndDestroy( &uriList );
+    TL( !uriList );
+
+    // Preaparations for step 2
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayFull );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::GetContentURIList with 1 rights object present \
+          Expecting: correct contentUri" );
+    iLog->Log( KStep2 );
+    r = helper->GetContentURIList( uriList );
+    // Check results
+    TL( uriList );
+    TCleanupItem item2( CleanupPtrRPointerArrayHBufC8, &uriList );
+    CleanupStack::PushL( item2 );
+    T1L( r, KErrNone );
+    T1L( uriList->Count(), 1 );
+    const TPtrC8 comparisonValue( ( *uriList )[ 0 ]->Des() );
+    TL( comparisonValue == KCid1Jpeg() );
+    // Cleanup
+    CleanupStack::PopAndDestroy( &uriList );
+    TL( !uriList );
+    DeleteRODBL();
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::GetPreviewRightsLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::GetPreviewRightsLTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+
+    DeleteRODBL();
+    _LIT( KStep1,
+        "Step1: CDRMHelper::GetPreviewRightsL with \
+         TDesC name of plain text file \
+         Expecting: leave with KErrArgument" );
+    iLog->Log( KStep1 );
+    TRAP( r, helper->GetPreviewRightsL(
+           const_cast< TDesC& >( KPlainTextFile() ) ) );
+    T1L( r, KErrArgument );
+
+    _LIT( KStep2,
+        "Step2: CDRMHelper::GetPreviewRightsL with \
+         CData handle of DCF1 file \
+         Expecting: leave with KErrArgument" );
+    iLog->Log( KStep2 );
+    CallGetPreviewRightsForCDataL( helper, r, KDcf1JpegFile() );
+    T1L( r, KErrArgument );
+
+
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::GetRightsDetailsLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::GetRightsDetailsLTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    CDRMRightsConstraints* cPlay( NULL );
+    CDRMRightsConstraints* cView( NULL );
+    CDRMRightsConstraints* cExecute( NULL );
+    CDRMRightsConstraints* cPrint( NULL );
+    TBool expired( EFalse );
+        TBool sendingAllowed( ETrue );
+    // preparations
+    DeleteRODBL();
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayFull );
+    _LIT( KStep1,
+          "Step1: DRMHelper::GetRightsDetailsL with TDesC filename \
+           of OMA 1 file and full Rights \
+           and with pointers to CDRMRightsConstraints \
+          Expecting: correct rights details" );
+    iLog->Log( KStep1 );
+    //Step 1
+    TRAP(r, helper->GetRightsDetailsL(
+        KDcf1JpegFile(), ContentAccess::EView, expired, sendingAllowed,
+        cPlay, cView, cExecute, cPrint ) );
+    T1L( r, KErrNone );
+    TL( !sendingAllowed );
+    TL( !expired );
+
+    // Checks for play constraint
+    TL( !cPlay );
+    // Checks for view constraint
+    TL( cView );
+    CleanupStack::PushL( cView );
+    //Check correctness of permission
+    TL( cView->FullRights() );
+    TL( !cView->IsPreview() );
+    CleanupStack::PopAndDestroy( cView );
+    cView = NULL;
+    TL( !cExecute );
+    TL( !cPrint );
+
+    //Preperations for step 2
+    DeleteRODBL();
+    RFile file;
+    r = file.Open( iFs, KDcf1JpegFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::GetRightsDetailsL with TDesC filename \
+           of OMA 1 file and no Rights \
+           and with pointers to CDRMRightsConstraints \
+          Expecting: leave with error KErrCANoRights" );
+    iLog->Log( KStep2 );
+    TRAP(r, helper->GetRightsDetailsL(
+        KDcf1JpegFile(), ContentAccess::EView, expired, sendingAllowed,
+        cPlay, cView, cExecute, cPrint ) );
+    T1L( r, KErrCANoRights );
+    TL( !cPlay );
+    TL( !cView );
+    TL( !cExecute );
+    TL( !cPrint );
+
+    CleanupStack::PopAndDestroy( &file );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::GetHlpRightsDetailsLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::GetHlpRightsDetailsLTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    CDRMHelperRightsConstraints* hlpPlay( NULL );
+    CDRMHelperRightsConstraints* hlpView( NULL );
+    CDRMHelperRightsConstraints* hlpExecute( NULL );
+    CDRMHelperRightsConstraints* hlpPrint( NULL );
+    TBool expired( ETrue );
+    TBool sendingAllowed( ETrue );
+    // preparations
+    DeleteRODBL();
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayCount1 );
+    _LIT( KStep1,
+          "Step1: DRMHelper::GetRightsDetailsL with TDesC filename \
+           of OMA 1 file and count 1 display Rights \
+           and with pointers to CDRMHelperRightsConstraints \
+          Expecting: correct rights details" );
+    iLog->Log( KStep1 );
+    //Step 1
+    TRAP(r, helper->GetRightsDetailsL(
+        KDcf1JpegFile(), ContentAccess::EView, expired, sendingAllowed,
+        hlpPlay, hlpView, hlpExecute, hlpPrint ) );
+    T1L( r, KErrNone );
+    TL( !sendingAllowed );
+    TL( !expired );
+
+    // Checks for play constraint
+    TL( !hlpPlay );
+    // Checks for view constraint
+    TL( hlpView );
+    CleanupStack::PushL( hlpView );
+    //Check correctness of permission
+    TL( !hlpView->FullRights() );
+    TL( hlpView->IsPreview() );
+    TUint32 counter( 0 );
+    TUint32 origCounter( 0 );
+    TRAP( r, hlpView->GetCountersL( counter, origCounter ) );
+    T1L( r, KErrNone );
+    T1L( counter, 1 );
+    T1L( origCounter, 1 );
+    CleanupStack::PopAndDestroy( hlpView );
+    hlpView = NULL;
+    TL( !hlpExecute );
+    TL( !hlpPrint );
+
+    // preparations for step2
+    DeleteRODBL();
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg,
+        KDisplayCount1PrintInterval1Second );
+    RFile file;
+    r = file.Open( iFs, KDcf1JpegFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::GetRightsDetailsL with TDesC filename \
+           of OMA 1 file, count 1 display Rights, \
+           interval 1 second print rights \
+           and with pointers to CDRMHelperRightsConstraints \
+          Expecting: correct rights details" );
+    iLog->Log( KStep2 );
+
+    TRAP(r, helper->GetRightsDetailsL(
+        file, ContentAccess::EView, expired, sendingAllowed,
+        hlpPlay, hlpView, hlpExecute, hlpPrint ) );
+    T1L( r, KErrNone );
+    CleanupStack::PushL( hlpPrint );
+    CleanupStack::PushL( hlpView );
+    TL( !sendingAllowed );
+    TL( !expired );
+
+    // Checks for play constraint
+    TL( !hlpPlay );
+    // Checks for view constraint
+    TL( hlpView );
+    //Check correctness of display permission
+    TL( !hlpView->FullRights() );
+    TL( hlpView->IsPreview() );
+    counter =  0;
+    origCounter = 0 ;
+    TRAP( r, hlpView->GetCountersL( counter, origCounter ) );
+    T1L( r, KErrNone );
+    T1L( counter, 1 );
+    T1L( origCounter, 1 );
+    CleanupStack::PopAndDestroy( hlpView );
+    hlpView = NULL;
+    TL( !hlpExecute );
+    TL( hlpPrint );
+    //Check correctness of print permission
+    TL( !hlpPrint->FullRights() );
+    TL( !hlpPrint->IsPreview() );
+    TTimeIntervalSeconds interval( 0 );
+    const TTimeIntervalSeconds KSecond( 1 );
+    TRAP( r, hlpPrint->GetIntervalL( interval ) );
+    TL( interval == KSecond );
+
+    CleanupStack::PopAndDestroy( hlpPrint );
+
+    CleanupStack::PopAndDestroy( &file );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::HandleErrorLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::HandleErrorLTestL( TTestResult& aResult )
+    {
+    TInt r( KErrGeneral );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    DeleteRODBL();
+
+    _LIT( KStep1,
+          "Step1: DRMHelper::HandleErrorL with \
+          error code KErrGeneral and nonexistent TDesC8 CID \
+          Expecting: leave with KErrNotFound" );
+    iLog->Log( KStep1 );
+
+    TRAP( r, helper->HandleErrorL( KErrGeneral, KCidNotExist() ) );
+    T1L( r, KErrNotFound );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::HandleErrorL with error code KErrGeneral \
+           and TDesC name of plain text file \
+          Expecting: leave with KErrArgument" );
+    iLog->Log( KStep2 );
+    TRAP( r, helper->HandleErrorL( KErrGeneral, KPlainTextFile() ) );
+    T1L( r, KErrArgument );
+
+    // preparations for step3
+    RFile file;
+    r = file.Open( iFs, KPlainTextFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+
+    _LIT( KStep3,
+          "Step3: DRMHelper::HandleErrorL with error code KErrGeneral \
+           and RFile handle to plain text file \
+          Expecting: leave with KErrArgument" );
+    iLog->Log( KStep3 );
+    TRAP( r, helper->HandleErrorL( KErrNotSupported, file ) );
+    T1L( r, KErrArgument );
+    CleanupStack::PopAndDestroy( &file );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::HandleErrorOrPreviewLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::HandleErrorOrPreviewLTestL( TTestResult& aResult )
+    {
+    TInt r( KErrGeneral );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    DeleteRODBL();
+    HBufC8* previewUrl( NULL );
+
+    _LIT( KStep1,
+          "Step1: DRMHelper::HandleErrorL with error code KErrGeneral \
+           and TDesC name of plain text file \
+          Expecting: leave with KErrArgument" );
+    iLog->Log( KStep1 );
+    TRAP( r, helper->HandleErrorOrPreviewL(
+            KErrGeneral, KPlainTextFile(), previewUrl ) );
+    T1L( r, KErrArgument );
+
+    //Preperations for step 2
+    RFile file;
+    r = file.Open( iFs, KPlainTextFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::HandleErrorL with error code KErrGeneral \
+           and RFile handle to plain text file \
+          Expecting: leave with KErrArgument" );
+    iLog->Log( KStep2 );
+    TRAP( r, helper->HandleErrorOrPreviewL(
+            KErrGeneral, file, previewUrl ) );
+    T1L( r, KErrArgument );
+    CleanupStack::PopAndDestroy( &file );
+
+    CleanupStack::PopAndDestroy( helper );
+
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::HasInfoUrlLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::HasInfoUrlLTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    TBool hasInfoUrl( EFalse );
+    HBufC8* infoUrl( NULL );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    _LIT( KStep1,
+        "Step1: DRMHelper::HasInfoUrlL with plain file \
+        Expecting: error KErrNotSupported");
+    iLog->Log( KStep1 );
+    CallHasInfoUrlForTDesc(
+        helper, r, hasInfoUrl, KPlainTextFile(), infoUrl );
+    T1L( r, KErrNone );
+    TL( !hasInfoUrl );
+    TL( !infoUrl );
+
+    _LIT( KStep2,
+        "Step2: DRMHelper::HasInfoUrlL with plain CData \
+        Expecting: error KErrNotSupported");
+    iLog->Log( KStep2 );
+    CallHasInfoUrlForCDataL(
+        helper, r, hasInfoUrl, KPlainTextFile(), infoUrl );
+    T1L( r, KErrNone );
+    TL( !hasInfoUrl );
+    TL( !infoUrl );
+
+    _LIT( KStep3,
+        "Step3: DRMHelper::HasInfoUrlL with DCF1 file \
+        Expecting: error KErrNotSupported");
+    iLog->Log( KStep3 );
+    CallHasInfoUrlForTDesc(
+        helper, r, hasInfoUrl, KDcf1JpegFile(), infoUrl );
+    T1L( r, KErrNone );
+    TL( !hasInfoUrl );
+    TL( !infoUrl );
+
+    _LIT( KStep4,
+        "Step4: DRMHelper::HasInfoUrlL with DCF1 CData \
+        Expecting: error KErrNotSupported");
+    iLog->Log( KStep4 );
+    CallHasInfoUrlForCDataL( helper, r, hasInfoUrl, KDcf1JpegFile(), infoUrl );
+    T1L( r, KErrNone );
+    TL( !hasInfoUrl );
+    TL( !infoUrl );
+
+    _LIT( KStep5,
+        "Step5: DRMHelper::HasInfoUrlL with DCF2 file \
+        Expecting: error KErrNotSupported" );
+    iLog->Log( KStep5 );
+    CallHasInfoUrlForTDesc(
+        helper, r, hasInfoUrl, KDcf2JpegFile() , infoUrl );
+    T1L( r, KErrNone );
+    TL( !hasInfoUrl );
+    TL( !infoUrl );
+
+    _LIT( KStep6,
+        "Step6: DRMHelper::HasInfoUrlL with DCF2 CData \
+        Expecting: error KErrNotSupported" );
+    iLog->Log( KStep6 );
+    CallHasInfoUrlForCDataL(
+        helper, r, hasInfoUrl, KDcf2JpegFile() , infoUrl );
+    T1L( r, KErrNone );
+    TL( !hasInfoUrl );
+    TL( !infoUrl );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::HasPreviewLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::HasPreviewLTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    TBool hasPreview( EFalse );
+    HBufC8* previewUrl( NULL );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    _LIT( KStep1,
+        "Step1: DRMHelper::HasPreviewL with plain file \
+        Expecting: error KErrNotSupported");
+    iLog->Log( KStep1 );
+    CallHasPreviewForTDesc(
+        helper, r, hasPreview, KPlainTextFile(), previewUrl );
+    T1L( r, KErrNone );
+    TL( !hasPreview );
+    TL( !previewUrl );
+
+    _LIT( KStep2,
+        "Step2: DRMHelper::HasPreviewL with plain CData \
+        Expecting: error KErrNotSupported");
+    iLog->Log( KStep2 );
+    CallHasPreviewForCDataL(
+        helper, r, hasPreview, KPlainTextFile(), previewUrl );
+    T1L( r, KErrNone );
+    TL( !hasPreview );
+    TL( !previewUrl );
+
+    _LIT( KStep3,
+        "Step3: DRMHelper::HasPreviewL with DCF1 file \
+        Expecting: error KErrNotSupported");
+    iLog->Log( KStep3 );
+    CallHasPreviewForTDesc(
+        helper, r, hasPreview, KDcf1JpegFile(), previewUrl );
+    T1L( r, KErrNone );
+    TL( !hasPreview );
+    TL( !previewUrl );
+
+    _LIT( KStep4,
+        "Step4: DRMHelper::HasPreviewL with DCF1 CData \
+        Expecting: error KErrNotSupported");
+    iLog->Log( KStep4 );
+    CallHasPreviewForCDataL( helper, r, hasPreview, KDcf1JpegFile(), previewUrl );
+    T1L( r, KErrNone );
+    TL( !hasPreview );
+    TL( !previewUrl );
+
+    _LIT( KStep5,
+        "Step5: DRMHelper::HasPreviewL with DCF2 file \
+        Expecting: error KErrNotSupported" );
+    iLog->Log( KStep5 );
+    CallHasPreviewForTDesc(
+        helper, r, hasPreview, KDcf2JpegFile() , previewUrl );
+    T1L( r, KErrNone );
+    TL( !hasPreview );
+    TL( !previewUrl );
+
+    _LIT( KStep6,
+        "Step6: DRMHelper::HasPreviewL with DCF2 CData \
+        Expecting: error KErrNotSupported" );
+    iLog->Log( KStep6 );
+    CallHasPreviewForCDataL(
+        helper, r, hasPreview, KDcf2JpegFile() , previewUrl );
+    T1L( r, KErrNone );
+    TL( !hasPreview );
+    TL( !previewUrl );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::LaunchDetailsViewEmbeddedLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::LaunchDetailsViewEmbeddedLTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    DeleteRODBL();
+    HBufC8* uriBuf( HBufC8::NewMaxLC( KCid1Jpeg().Length() ) );
+
+    _LIT( KStep1,
+        "Step1: empty DRMHelper::LaunchDetailsViewEmbeddedL \
+        with nonexistent TDesC8 CID \
+        Expecting: no actions and  no errors" );
+    iLog->Log( KStep1 );
+    TRAP( r, helper->LaunchDetailsViewEmbeddedL( KCidNotExist() ) );
+    T1L( r, KErrNone );
+
+    _LIT( KStep2,
+        "Step2: DRMHelper::LaunchDetailsViewEmbeddedL \
+        with nonexistent HBufC8* CID and no rights \
+        Expecting: leave with KErrCANoRights" );
+    iLog->Log( KStep2 );
+    TRAP( r, helper->LaunchDetailsViewEmbeddedL( uriBuf ) );
+    T1L( r, KErrCANoRights );
+    CleanupStack::PopAndDestroy( uriBuf );
+
+    _LIT( KStep3,
+        "Step3: DRMHelper::LaunchDetailsViewEmbeddedL \
+        with TDesC name of plain text file \
+        Expecting: leave with KErrArgument" );
+    iLog->Log( KStep3 );
+    TRAP( r, helper->LaunchDetailsViewEmbeddedL( KPlainTextFile() ) );
+    T1L( r, KErrArgument );
+
+    RFile file;
+    r = file.Open( iFs, KPlainTextFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+
+    _LIT( KStep4,
+        "Step4: DRMHelper::LaunchDetailsViewEmbeddedL \
+        with RFile handle to plain text file \
+        Expecting: leave with KErrArgument" );
+    iLog->Log( KStep4 );
+    TRAP( r, helper->LaunchDetailsViewEmbeddedL( file ) );
+    T1L( r, KErrArgument );
+    CleanupStack::PopAndDestroy( &file );
+
+    CleanupStack::PopAndDestroy( helper );
+
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::OpenInfoUrlLTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::OpenInfoUrlLTestL( TTestResult& aResult )
+    {
+    TInt r( KErrGeneral );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+
+    DeleteRODBL();
+    _LIT( KStep1,
+        "Step1: CDRMHelper::OpenInfoUrlL with \
+         TDesC name of plain text file \
+         Expecting: leave with KErrArgument" );
+    iLog->Log( KStep1 );
+    TRAP( r, helper->OpenInfoUrlL(
+           const_cast< TDesC& >( KPlainTextFile() ) ) );
+    T1L( r, KErrArgument );
+
+    _LIT( KStep2,
+        "Step2: CDRMHelper::OpenInfoUrlL with \
+         CData handle of DCF1 file \
+         Expecting: leave with KErrArgument" );
+    iLog->Log( KStep2 );
+    CallOpenInfoUrlForCDataL( helper, r, KDcf1JpegFile() );
+    T1L( r, KErrArgument );
+
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::RemoveAutomatedTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::RemoveAutomatedTestL( TTestResult& aResult )
+    {
+    TInt r( KErrGeneral );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    _LIT( KStep1,
+        "Step1: DRMHelper::RemoveAutomated with TDesC name \
+         of plain File \
+         Expecting: KErrArgument" );
+    iLog->Log( KStep1 );
+
+    r = helper->RemoveAutomated( const_cast< TDesC& >( KPlainTextFile() ) );
+    T1L( r, KErrArgument );
+
+    RFile file;
+    r = file.Open( iFs, KPlainTextFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::RemoveAutomated with RFile handle \
+            of plain file \
+          Expecting: KErrArgument" );
+    iLog->Log( KStep2 );
+    r = helper->RemoveAutomated( file );
+    T1L( r, KErrArgument );
+    CleanupStack::PopAndDestroy( &file );
+
+
+    _LIT( KStep3,
+        "Step3: DRMHelper::RemoveAutomated with nonexistent TDesC8 cid \
+          Expecting: KErrNotFound" );
+    iLog->Log( KStep3 );
+    r = helper->RemoveAutomated( KCidNotExist() );
+    T1L( r, KErrNotFound );
+    CleanupStack::PopAndDestroy( helper );
+
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::RemoveAutomatedPassiveTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::RemoveAutomatedPassiveTestL( TTestResult& aResult )
+    {
+    TInt r( KErrGeneral );
+
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    _LIT( KStep1,
+        "Step1: DRMHelper::RemoveAutomatedPassive with TDesC name \
+         of plain File \
+         Expecting: KErrArgument" );
+    iLog->Log( KStep1 );
+
+    r = helper->RemoveAutomatedPassive(
+        const_cast< TDesC& >( KPlainTextFile() ) );
+    T1L( r, KErrArgument );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::RemoveAutomatedPassive with RFile handle \
+            of plain file \
+          Expecting: KErrArgument" );
+    iLog->Log( KStep2 );
+
+    RFile file;
+    r = file.Open( iFs, KPlainTextFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+    r = helper->RemoveAutomatedPassive( file );
+    T1L( r, KErrArgument );
+    CleanupStack::PopAndDestroy( &file );
+    _LIT( KStep3,
+        "Step3: DRMHelper::RemoveAutomatedPassive with nonexistent TDesC8 cid \
+          Expecting: KErrNotFound" );
+    iLog->Log( KStep3 );
+    r = helper->RemoveAutomatedPassive( KCidNotExist() );
+    T1L( r, KErrNotFound );
+    CleanupStack::PopAndDestroy( helper );
+
+
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::RightsConstraintsTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::RightsConstraintsTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+
+    CDRMHelperRightsConstraints* play( NULL );
+    CDRMHelperRightsConstraints* view( NULL );
+    CDRMHelperRightsConstraints* execute( NULL );
+    CDRMHelperRightsConstraints* print( NULL );
+    TBool expired( ETrue );
+    TBool sendingAllowed( ETrue );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    // preparations
+    DeleteRODBL();
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayCount1 );
+    TRAP(r, helper->GetRightsDetailsL(
+        KDcf1JpegFile(), ContentAccess::EView, expired, sendingAllowed,
+        play, view, execute, print ) );
+    TL( view );
+    CleanupStack::PushL( view );
+    T1L( r, KErrNone );
+    TL( !play );
+    TL( !execute );
+    TL( !print );
+
+    _LIT( KStep1,
+        "Step1: CDRMHelperRightsConstraints::FullRights \
+         of for count 1 RO \
+         Expecting: EFalse" );
+    iLog->Log( KStep1 );
+    TL( !view->FullRights() );
+
+    _LIT( KStep2,
+        "Step2: CDRMHelperRightsConstraints::IsPreview \
+         of for count 1 RO \
+         Expecting: ETrue" );
+    iLog->Log( KStep2 );
+    TL( view->IsPreview() );
+
+    _LIT( KStep3,
+        "Step3: CDRMHelperRightsConstraints::GetAccumulatedTimeL \
+         of for count 1 RO \
+         Expecting: Leave with error code" );
+    iLog->Log( KStep3 );
+    TTimeIntervalSeconds interval( -1 );
+    TTime time( Time::NullTTime() );
+    TRAP( r, view->GetAccumulatedTimeL( interval ) );
+    T1L( r, KErrNotFound );
+
+    _LIT( KStep4,
+        "Step4: CDRMHelperRightsConstraints::GetIntervalL \
+         of for count 1 RO \
+         Expecting: Leave with error code" );
+    iLog->Log( KStep4 );
+    TRAP( r, view->GetIntervalL( interval ) );
+    T1L( r, KErrNotFound );
+
+    _LIT( KStep5,
+        "Step5: CDRMHelperRightsConstraints::GetIntervalStartL \
+         of for count 1 RO \
+         Expecting: Leave with error code" );
+    iLog->Log( KStep5 );
+    TRAP( r, view->GetIntervalStartL( time ) );
+    T1L( r, KErrNotFound );
+
+    _LIT( KStep6,
+        "Step6: CDRMHelperRightsConstraints::GetStartTimeL \
+         of for count 1 RO \
+         Expecting: Leave with error code" );
+    iLog->Log( KStep6 );
+    TRAP( r, view->GetStartTimeL( time ) );
+    T1L( r, KErrNotFound );
+
+    _LIT( KStep7,
+        "Step7: CDRMHelperRightsConstraints::GetEndTimeL \
+         of for count 1 RO \
+         Expecting: Leave with error code" );
+    iLog->Log( KStep7 );
+    TRAP( r, view->GetEndTimeL( time ) );
+    T1L( r, KErrNotFound );
+
+    _LIT( KStep8,
+        "Step8: CDRMHelperRightsConstraints::GetTimedCountL \
+         of for count 1 RO \
+         Expecting: Leave with error code" );
+    iLog->Log( KStep8 );
+    TUint32 count( 0 );
+    TUint32 origCount( 0 );
+    TRAP( r, view->GetTimedCountL( count, origCount, interval ) );
+    T1L( r, KErrNotFound );
+
+    _LIT( KStep9,
+        "Step9: CDRMHelperRightsConstraints::GetCountL \
+         of for count 1 RO \
+         Expecting: Correct count" );
+    iLog->Log( KStep9 );
+    TRAP( r, view->GetCountersL( count, origCount ) );
+    T1L( r, KErrNone );
+    T1L( count, 1 );
+    T1L( origCount, 1 );
+
+    CleanupStack::PopAndDestroy( view );
+    CleanupStack::PopAndDestroy( helper );
+
+
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::SetAutomatedTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::SetAutomatedTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    // preparations
+    _LIT( KStep1,
+        "Step1: DRMHelper::SetAutomated with TDesC name \
+         of plain File \
+         Expecting: KErrNone" );
+    iLog->Log( KStep1 );
+
+    r = helper->SetAutomated( const_cast< TDesC& >( KPlainTextFile() ) );
+    T1L( r, KErrNone );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::SetAutomated with RFile handle \
+            of plain file \
+          Expecting: KErrNone" );
+    iLog->Log( KStep2 );
+
+    RFile file;
+    r = file.Open( iFs, KPlainTextFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+    r = helper->SetAutomated( file );
+    T1L( r, KErrNone );
+    CleanupStack::PopAndDestroy( &file );
+    _LIT( KStep3,
+        "Step3: DRMHelper::SetAutomated with nonexistent TDesC8 cid \
+          Expecting: KErrArgument" );
+    iLog->Log( KStep3 );
+    r = helper->SetAutomated( KCidNotExist() );
+    T1L( r, KErrNotFound );
+    CleanupStack::PopAndDestroy( helper );
+
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::SetAutomatedPassiveTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::SetAutomatedPassiveTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    _LIT( KStep1,
+        "Step1: DRMHelper::SetAutomatedPassive with TDesC name \
+         of plain File \
+         Expecting: KErrNone" );
+    iLog->Log( KStep1 );
+
+    r = helper->SetAutomatedPassive(
+        const_cast< TDesC& >( KPlainTextFile() ) );
+    T1L( r, KErrNone );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::SetAutomatedPassive with RFile handle \
+            of plain file \
+          Expecting: KErrNone" );
+    iLog->Log( KStep2 );
+
+    RFile file;
+    r = file.Open( iFs, KPlainTextFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+    r = helper->SetAutomatedPassive( file );
+    T1L( r, KErrNone );
+    CleanupStack::PopAndDestroy( &file );
+    _LIT( KStep3,
+        "Step3: DRMHelper::SetAutomatedPassive with nonexistent TDesC8 cid \
+          Expecting: KErrNotFound" );
+    iLog->Log( KStep3 );
+    r = helper->SetAutomatedPassive( KCidNotExist() );
+    T1L( r, KErrNotFound );
+    CleanupStack::PopAndDestroy( helper );
+
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::SetAutomatedSilentTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::SetAutomatedSilentTestL( TTestResult& aResult )
+    {
+    TInt r( KErrGeneral );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+
+    _LIT( KStep1,
+        "Step1: DRMHelper::SetAutomatedSilent with TDesC name \
+         of plain File and ETrue \
+         Expecting: KErrNone" );
+    iLog->Log( KStep1 );
+    r = helper->SetAutomatedSilent(
+        const_cast< TDesC& >( KPlainTextFile() ), ETrue );
+    T1L( r, KErrNone );
+
+    _LIT( KStep2,
+          "Step2: DRMHelper::SetAutomatedSilent with RFile handle \
+            of plain file and EFalse \
+          Expecting: KErrNone" );
+    iLog->Log( KStep2 );
+
+    RFile file;
+    r = file.Open( iFs, KPlainTextFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+    r = helper->SetAutomatedSilent( file, EFalse );
+    T1L( r, KErrNone );
+    CleanupStack::PopAndDestroy( &file );
+
+
+    _LIT( KStep3,
+        "Step3: DRMHelper::SetAutomatedSilent with nonexistent TDesC8 cid \
+          Expecting: KErrNotFound" );
+    iLog->Log( KStep3 );
+    r = helper->SetAutomatedSilent( KCidNotExist(), ETrue );
+    T1L( r, KErrNotFound );
+
+    CleanupStack::PopAndDestroy( helper );
+
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::SetAutomatedTypeTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::SetAutomatedTypeTestL( TTestResult& aResult )
+    {
+    TInt r( KErrGeneral );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    _LIT( KStep1,
+        "Step1: CDRMHelper::SetAutomatedType  to EAutomatedTypeOther \
+        Expecting: no errors");
+    iLog->Log( KStep1 );
+    r = helper->SetAutomatedType( CDRMHelper::EAutomatedTypeOther );
+    T1L( r, KErrNone );
+
+    _LIT( KStep2,
+        "Step2: CDRMHelper::SetAutomatedType to EAutomatedTypeRingingTone \
+        Expecting: no errors");
+    iLog->Log( KStep2 );
+    r = helper->SetAutomatedType( CDRMHelper::EAutomatedTypeRingingTone );
+    T1L( r, KErrNone );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::SetLimitsTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::SetLimitsTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    TUint limit( KErrNone );
+    CDRMHelper* helper( CDRMHelper::NewLC() );
+
+    _LIT( KStep3,
+        "Step3: CDRMHelper::SetTimeLimitL \
+        Expecting: no errors");
+    iLog->Log( KStep3 );
+    TRAP( r, helper->SetTimeLimitL( limit ) );
+    T1L( r, KErrNone );
+
+    _LIT( KStep1,
+        "Step1: CDRMHelper::SetCountLimitL \
+        Expecting: no errors");
+    iLog->Log( KStep1 );
+    TRAP( r, helper->SetCountLimitL( limit ) );
+    T1L( r, KErrNone );
+
+    _LIT( KStep2,
+        "Step2: CDRMHelper::SetPercentageLimitL \
+        Expecting: no errors");
+    iLog->Log( KStep2 );
+    TRAP( r, helper->SetPercentageLimitL( limit ) );
+    T1L( r, KErrNone );
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::SetPreviewMediaTypeTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::SetPreviewMediaTypeTestL( TTestResult& aResult )
+    {
+    TInt r( KErrGeneral );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    _LIT( KStep1,
+        "Step1: CDRMHelper::SetPreviewMediaType  to EPreviewTypeAudio \
+        Expecting: no errors");
+    iLog->Log( KStep1 );
+    r = helper->SetPreviewMediaType( EPreviewTypeAudio );
+    T1L( r, KErrNone );
+
+    _LIT( KStep2,
+        "Step2: CDRMHelper::SetPreviewMediaType to EPreviewTypeVideo \
+        Expecting: no errors");
+    iLog->Log( KStep2 );
+    r = helper->SetPreviewMediaType( EPreviewTypeVideo );
+    T1L( r, KErrNone );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::ShowAutomatedNoteTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::ShowAutomatedNoteTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    TEntry entry;
+    _LIT( KNonExistentFile , "C:\\nonexistent.txt");
+    r = iFs.Entry( KNonExistentFile, entry );
+    T2L( r, KErrNotFound , KErrPathNotFound );
+
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    _LIT( KStep1,
+        "Step1: DRMHelper::ShowAutomatedNote with TDesC name \
+         of nonexistent file \
+         Expecting: error KErrNotFound" );
+    iLog->Log( KStep1 );
+
+    r = helper->ShowAutomatedNote( KNonExistentFile );
+    T2L( r, KErrNotFound, KErrPathNotFound );
+
+    _LIT( KStep2,
+        "Step2: DRMHelper::ShowAutomatedNote with nonexistent TDesC8 CID\
+         Expecting: error KErrNotFound" );
+    iLog->Log( KStep2 );
+    r = helper->ShowAutomatedNote( KCidNotExist );
+    T1L( r, KErrNotFound );
+
+    // preparations for step 3
+    AddROL( KRO1Formatter, KCid1Jpeg, KCek1Jpeg, KDisplayFull );
+    RFile file;
+    r = file.Open( iFs, KDcf1JpegFile, EFileRead | EFileShareAny );
+    T1L( r, KErrNone );
+    CleanupClosePushL( file );
+    _LIT( KStep3,
+        "Step3: DRMHelper::ShowAutomatedNote with RFile handle \
+         of OMA 1 file with full rights \
+         Expecting: no errors and no notes shown" );
+    iLog->Log( KStep3 );
+    r = helper->ShowAutomatedNote( file );
+    T1L( r, KErrNone );
+
+    CleanupStack::PopAndDestroy( &file );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::ShowDRMUINotification2LTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::ShowDRMUINotification2LTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    CDRMHelper::TDRMHelperNotificationID
+        notificationId( CDRMHelper::ETCountBasedErrorTextId  );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+
+    _LIT( KStep1,
+        "Step1: legacy DRMHelper::ShowDRMUINotification2L \
+         with nonexistent TDesC8& CID \
+         Expecting: always error KErrNotSupported" );
+    iLog->Log( KStep1 );
+    r = helper->ShowDRMUINotification2L( notificationId, KCidNotExist );
+    T1L( r, KErrNotSupported );
+
+    _LIT( KStep2,
+        "Step2: legacy DRMHelper::ShowDRMUINotification2L \
+         with name of plain file \
+         Expecting: always error KErrNotSupported" );
+    iLog->Log( KStep2 );
+    r = helper->ShowDRMUINotification2L( notificationId, KPlainTextFile );
+    T1L( r, KErrNotSupported );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::SupportedDRMMethods2TestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::SupportedDRMMethods2TestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    TInt drmMethod( KErrNone );
+    CDRMHelper::TDRMHelperOMALevel omaLevel( CDRMHelper::EOMA_None );
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    r = helper->SupportedDRMMethods2( drmMethod, omaLevel );
+    T1L( drmMethod & CDRMHelper::EForwardLock, CDRMHelper::EForwardLock );
+    T2L(omaLevel, CDRMHelper::EOMA_1_0, CDRMHelper::EOMA_2_0 );
+    T1L( r, KErrNone );
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::SupportedDataTypeTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::SupportedDataTypeTestL( TTestResult& aResult )
+    {
+
+    TInt r( KErrNone );
+    TInt dataTypesCount( KErrNotFound );
+    const TInt KNegativeIndex( KErrNotFound );
+    _LIT8( KUnSupportedMimeType, "x-jalla/x-jallajalla");
+    TDataType dataType( KUnSupportedMimeType );
+    const TDataType compared( KUnSupportedMimeType );
+
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    //Step1 Querying data types count
+    r = helper->DataTypesCount( dataTypesCount );
+    TL( dataTypesCount > 0 );
+
+    //Step2 Querying first supported data type
+    r = helper->SupportedDataType( 0 , dataType );
+    T1L( r, KErrNone );
+    TL( dataType != compared );
+    //Step3 Querying last supported data type
+    r = helper->SupportedDataType( dataTypesCount - 1 , dataType );
+    T1L( r, KErrNone );
+    TL( dataType != compared );
+
+    //Step4 Querying supported data type from negative index
+    r = helper->SupportedDataType( KNegativeIndex , dataType );
+    T1L( r, KErrArgument );
+
+    //Step5 Querying supported data type from negative index
+    r = helper->SupportedDataType( dataTypesCount , dataType );
+    T1L( r, KErrArgument );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmHelperTest::UpdateDataTypesTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmHelperTest::UpdateDataTypesTestL( TTestResult& aResult )
+    {
+    TInt r( KErrNone );
+    _LIT8( KFirstMimeType, "x-jalla/x-ekajalla");
+    _LIT8( KSecondMimeType, "x-jalla/x-tokajalla");
+    _LIT8( KUnSupportedMimeType, "x-jalla/x-jallajalla");
+    const TDataType firstNewType( KFirstMimeType );
+    const TDataType secondNewType( KSecondMimeType );
+    TInt dataTypesCount( KErrNotFound );
+    TInt originalDataTypesCount( KErrNotFound );
+    TDataType queriedType( KUnSupportedMimeType );
+
+    CDRMHelper* helper( CDRMHelper::NewLC( iFs ) );
+    // preparations
+    r = helper->DataTypesCount( originalDataTypesCount );
+    T1L( r, KErrNone );
+
+    // Step 1: register first new data type
+    _LIT( KStep1,
+        "Step1: CDRMHelper::RegisterDataType \
+        Expecting: new registered datatype");
+    iLog->Log( KStep1 );
+    r = helper->RegisterDataType( firstNewType );
+    T1L( r, KErrNone );
+    r = helper->DataTypesCount( dataTypesCount );
+    T1L( r, KErrNone );
+    TL( dataTypesCount == originalDataTypesCount + 1 );
+    r = helper->SupportedDataType( originalDataTypesCount, queriedType );
+    T1L( r, KErrNone );
+    TL( queriedType == firstNewType );
+
+    _LIT( KStep2,
+        "Step2: CDRMHelper::RegisterDataType \
+        Expecting: second new registered datatype");
+    iLog->Log( KStep2 );
+    // Step 2: registering second data type
+    r = helper->RegisterDataType( secondNewType );
+    T1L( r, KErrNone );
+    r = helper->DataTypesCount( dataTypesCount );
+    T1L( r, KErrNone );
+    TL( dataTypesCount == originalDataTypesCount + 2 );
+    r = helper->SupportedDataType( originalDataTypesCount, queriedType );
+    T1L( r, KErrNone );
+    TL( queriedType == secondNewType );
+
+    _LIT( KStep3,
+        "Step3: CDRMHelper::UnRegisterDataType \
+        Expecting: First registered type unregistered");
+    iLog->Log( KStep3 );
+    // Step 3: unregistering first new type
+    r = helper->UnRegisterDataType( originalDataTypesCount + 1 );
+    T1L( r, KErrNone );
+    r = helper->DataTypesCount( dataTypesCount );
+    T1L( r, KErrNone );
+    TL( dataTypesCount == originalDataTypesCount + 1 );
+    r = helper->SupportedDataType( originalDataTypesCount, queriedType );
+    T1L( r, KErrNone );
+    TL( queriedType == secondNewType );
+
+    // Step 4: unregistering second new type
+    _LIT( KStep4,
+        "Step4: CDRMHelper::UnRegisterDataType \
+        Expecting: second registered type unregistered");
+    iLog->Log( KStep4 );
+    r = helper->UnRegisterDataType( originalDataTypesCount );
+    T1L( r, KErrNone );
+    r = helper->DataTypesCount( dataTypesCount );
+    T1L( r, KErrNone );
+    TL( dataTypesCount == originalDataTypesCount );
+
+    CleanupStack::PopAndDestroy( helper );
+    SetResult( aResult, r );
+    return KErrNone;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/drm_license_checker_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<api id="6f41993c2f8e19ec01b85b9c479f4caf" dataversion="1.0">
+  <name>DRM License Checker API</name>
+  <description>Protection of native applications and skins. License Checker is ment to be used by the protected applications themselves</description>
+  <type>c++</type>
+  <subsystem>omadrm</subsystem>
+  <libs>
+    <lib name="DRMLicenseChecker.lib" />
+  </libs>
+  <release category="sdk" sinceversion="2.6"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* 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:  File that exports the files belonging to 
+:                DRM License Checker API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/DRMLicenseChecker.h     MW_LAYER_PUBLIC_EXPORT_PATH(DRMLicenseChecker.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/inc/DRMLicenseChecker.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRM License Checker interface definition
+*
+*/
+
+
+#ifndef DRMLICENSECHECKER_H
+#define DRMLICENSECHECKER_H
+
+/**
+*  Check and decrypt protected data files encrypted by the license manager.
+*
+*  @lib DRMLicenseChecker.lib
+*  @since Series 60 2.5
+*/
+class CDRMLicenseChecker: public CBase
+    {
+    public:  // Local enumerations and types
+
+        enum
+            {
+            ENoRights = -100000,
+            ERightsExpired = -100001,
+            };
+
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CDRMLicenseChecker* NewL();
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CDRMLicenseChecker();
+
+    public: // New functions
+        
+        /**
+        * This function performs a license check by decrypting a data file and
+        * returning the decrypted contents of the data file. A license check
+        * can only succeed if a rights object associated with the calling
+        * application exists and sufficient rights are present. If the license
+        * check fails, an error is returned.
+        *
+        * @since Series 60 2.6
+        * @param aDataFile: the data file to be decrypted
+        * @param aDataBuffer: memory buffer which contains the decrypted
+        *        contents of the data file.
+        * @return ENoRights, ERightsExpired if the data file could not be opened
+        *         because of insufficient rights, Symbian-wide error codes or
+        *         KErrNone in case of success.
+        */
+        IMPORT_C TInt CheckLicense(
+            const TDesC& aDataFile,
+            HBufC8*& aDataBuffer);
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDRMLicenseChecker();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        /**
+        * Leaving version of CheckLicense
+        *
+        * @since Series 60 3.0
+        * @param aDataFile: the data file to be decrypted
+        * @param aDataBuffer: memory buffer which contains the decrypted
+        *        contents of the data file.
+        * @return ENoRights, ERightsExpired if the data file could not be opened
+        *         because of insufficient rights, Symbian-wide error codes or
+        *         KErrNone in case of success.
+        */
+        void CheckLicenseL(
+            const TDesC& aDataFile,
+            HBufC8*& aDataBuffer);
+
+    };
+
+#endif      // DRMLICENSECHECKER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/tsrc/Bmarm/DrmLicenseCheckerTestU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	LibEntryL__Fv @ 1 NONAME R3UNUSED ; LibEntryL(void)
+	SetRequirements__FRP16CTestModuleParamRUl @ 2 NONAME R3UNUSED ; SetRequirements(CTestModuleParam *&, unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/tsrc/Bwins/DrmLicenseCheckerTestU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	?LibEntryL@@YAPAVCTestModuleBase@@XZ @ 1 NONAME ; class CTestModuleBase * __cdecl LibEntryL(void)
+	?SetRequirements@@YAHAAPAVCTestModuleParam@@AAK@Z @ 2 NONAME ; int __cdecl SetRequirements(class CTestModuleParam * &,unsigned long &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/tsrc/EABI/DrmLicenseCheckerTestU.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+EXPORTS
+	_Z9LibEntryLv @ 1 NONAME
+	_Z15SetRequirementsRP16CTestModuleParamRm @ 2 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/tsrc/data/c/checker.txt	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,5 @@
+0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
+Test Data Test Data Test Data Test Data Test Data Test Data Test Data Test Data Test Data Test Data 
+Test Data Test Data Test Data Test Data Test Data Test Data Test Data Test Data Test Data Test Data 
+Test Data Test Data Test Data Test Data Test Data Test Data Test Data Test Data Test Data Test Data 
+0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/tsrc/group/DrmLicenseCheckerTest.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2007 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DrmLicenseCheckerTest.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E7
+
+CAPABILITY      ALL -TCB
+
+DEFFILE         DrmLicenseCheckerTest.def
+
+SOURCEPATH      ../src
+SOURCE          DrmLicenseCheckerTest.cpp
+SOURCE          DrmLicenseCheckerTestCases.cpp
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         drmlicensechecker.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/tsrc/group/DrmLicenseCheckerTest.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,36 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Languages
+; =========
+&EN
+
+; Name, UID for installation, Maj.Ver., Min.Ver., Variant, FLAG TO SPECIFY UNICODE, System component
+; ==================================================================================================
+#{"DRM license checker test"},(0x101FB3E7),1,0,1,TYPE=SA
+
+
+; Localised Vendor name
+%{"Nokia-EN"}
+
+; Unique Vendor name
+:"Nokia"
+
+"\epoc32\release\armv5\urel\DrmLicenseCheckerTest.dll"      -"$:\sys\bin\DrmLicenseCheckerTest.dll"
+"..\data\c\checker.txt"                                     -"c:\testing\data\checker.txt"
+
+
+; eof
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/tsrc/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file
+*
+*/
+
+
+
+PRJ_PLATFORMS
+WINSCW ARMV5
+
+PRJ_TESTEXPORTS
+../data/c/checker.txt /epoc32/winscw/c/testing/data/checker.txt
+
+PRJ_EXPORTS
+
+PRJ_TESTMMPFILES
+DrmLicenseCheckerTest.mmp
+
+PRJ_MMPFILES
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/tsrc/inc/DrmLicenseCheckerTest.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,236 @@
+/*
+* Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DrmLicenseCheckerTest test module.
+*
+*/
+
+
+
+#ifndef DRMLICENSECHECKERTEST_H
+#define DRMLICENSECHECKERTEST_H
+
+// INCLUDES
+#include <StifLogger.h>
+#include "StifTestModule.h"
+
+// Logging path
+_LIT( KDrmLicenseCheckerTestLogPath, "\\logs\\testframework\\DrmLicenseCheckerTest\\" ); 
+// Log file
+_LIT( KDrmLicenseCheckerTestLogFile, "DrmLicenseCheckerTest.txt" ); 
+
+#define GETPTR &
+#define ENTRY(str,func) {_S(str), GETPTR func,0,0,0}
+#define FUNCENTRY(func) {_S(#func), GETPTR func,0,0,0}
+#define OOM_ENTRY(str,func,a,b,c) {_S(str), GETPTR func,a,b,c}
+#define OOM_FUNCENTRY(func,a,b,c) {_S(#func), GETPTR func,a,b,c}
+
+// FORWARD DECLARATIONS
+class CDrmLicenseCheckerTest;
+
+typedef TInt (CDrmLicenseCheckerTest::* TestFunction)(TTestResult&);
+
+class TCaseInfoInternal
+    {
+    public:
+        const TText*    iCaseName;
+        TestFunction    iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+    };
+
+// CLASS DECLARATION
+
+/**
+*  A structure containing a test case name and
+*  the pointer to function doing the test
+*
+*  @lib DRMCommonTest.lib
+*  @since S60 3.2
+*/
+class TCaseInfo
+    {
+    public:
+        TPtrC iCaseName;
+        TestFunction iMethod;
+        TBool           iIsOOMTest;
+        TInt            iFirstMemoryAllocation;
+        TInt            iLastMemoryAllocation;
+
+    TCaseInfo( const TText* a ) : iCaseName( (TText*) a )
+        {
+        };
+
+    };
+
+// CLASS DECLARATION
+
+/**
+*  This a DrmLicenseCheckerTest class.
+*
+*  @lib DrmLicenseCheckerTest.lib
+*  @since S60 3.2
+*/
+NONSHARABLE_CLASS(CDrmLicenseCheckerTest) : public CTestModuleBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CDrmLicenseCheckerTest* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CDrmLicenseCheckerTest();
+
+    public: // Functions from base classes
+
+        /**
+        * From CTestModuleBase InitL is used to initialize the 
+        * DrmLicenseCheckerTest. 
+        * It is called once for every instance of DrmLicenseCheckerTest 
+        * after its creation.
+        * @since S60 3.2
+        * @param aIniFile Initialization file for the test module (optional)
+        * @param aFirstTime Flag is true when InitL is executed for first 
+        *               created instance of DrmLicenseCheckerTest.
+        * @return Symbian OS error code
+        */
+        TInt InitL( TFileName& aIniFile, TBool aFirstTime );
+
+        /**
+        * From CTestModuleBase GetTestCasesL is used to inquiry test cases 
+        *   from DrmLicenseCheckerTest. 
+        * @since S60 3.2
+        * @param aTestCaseFile Test case file (optional)
+        * @param aTestCases  Array of TestCases returned to test framework
+        * @return Symbian OS error code
+        */
+        TInt GetTestCasesL( const TFileName& aTestCaseFile, 
+                            RPointerArray<TTestCaseInfo>& aTestCases );
+
+        /**
+        * From CTestModuleBase RunTestCaseL is used to run an individual 
+        *   test case. 
+        * @since S60 3.2
+        * @param aCaseNumber Test case number
+        * @param aTestCaseFile Test case file (optional)
+        * @param aResult Test case result returned to test framework (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error, which is 
+        *           not reported in aResult parameter as test case failure).
+        */   
+        TInt RunTestCaseL( const TInt aCaseNumber, 
+                           const TFileName& aTestCaseFile,
+                           TTestResult& aResult );
+
+        /**
+        * From CTestModuleBase; OOMTestQueryL is used to specify is particular
+        * test case going to be executed using OOM conditions
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailureType OOM failure type (optional)
+        * @param aFirstMemFailure The first heap memory allocation failure value (optional)
+        * @param aLastMemFailure The last heap memory allocation failure value (optional)
+        * @return TBool
+        */
+        virtual TBool OOMTestQueryL( const TFileName& /* aTestCaseFile */, 
+                                     const TInt /* aCaseNumber */, 
+                                     TOOMFailureType& /* aFailureType */,
+                                     TInt& /* aFirstMemFailure */, 
+                                     TInt& /* aLastMemFailure */ );
+
+        /**
+        * From CTestModuleBase; User may add implementation for OOM test 
+        * environment initialization. Usually no implementation is required.
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestInitializeL( const TFileName& /* aTestCaseFile */, 
+                                    const TInt /* aCaseNumber */ ); 
+
+        /**
+        * From CTestModuleBase; OOMHandleWarningL. User may add implementation 
+        * for OOM test warning handling. Usually no implementation is required.
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @param aFailNextValue FailNextValue for OOM test execution (optional)
+        * @return None
+        */
+        virtual void OOMHandleWarningL( const TFileName& /* aTestCaseFile */,
+                                        const TInt /* aCaseNumber */, 
+                                        TInt& /* aFailNextValue */);
+
+        /**
+        * From CTestModuleBase; OOMTestFinalizeL may be used to finalize OOM
+        * test environment. Usually no implementation is required.
+        * @param aTestCaseFile Test case file (optional)
+        * @param aCaseNumber Test case number (optional)
+        * @return None
+        */
+        virtual void OOMTestFinalizeL( const TFileName& /* aTestCaseFile */, 
+                                       const TInt /* aCaseNumber */ );
+                                       
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDrmLicenseCheckerTest();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Function returning test case name and pointer to test case function.
+        * @since S60 3.2
+        * @param aCaseNumber test case number
+        * @return TCaseInfo 
+        */
+        const TCaseInfo Case( const TInt aCaseNumber ) const;
+        
+        /**
+        * Constructor tests
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt ConstructTestL( TTestResult& aResult );
+        
+        /**
+        * Check license tests
+        * @since S60 3.2
+        * @param aResult Test case result (PASS/FAIL)
+        * @return Symbian OS error code (test case execution error 
+        *   that is not returned as test case result in aResult)
+        */
+        TInt CheckLicenseTestL( TTestResult& aResult);
+
+    private:    // Data
+        // Pointer to test (function) to be executed
+        TestFunction iMethod;
+
+        // Pointer to logger
+        CStifLogger * iLog;
+
+    };
+
+#endif      // DRMLICENSECHECKERTEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/tsrc/src/DrmLicenseCheckerTest.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,309 @@
+/*
+* Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DrmLicenseCheckerTest class member functions
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <Stiftestinterface.h>
+#include "drmlicensecheckertest.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::CDrmLicenseCheckerTest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDrmLicenseCheckerTest::CDrmLicenseCheckerTest()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::ConstructL
+// Symbian 2nd phase constructor can leave.
+// Note: If OOM test case uses STIF Logger, then STIF Logger must be created
+// with static buffer size parameter (aStaticBufferSize). Otherwise Logger 
+// allocates memory from heap and therefore causes error situations with OOM 
+// testing. For more information about STIF Logger construction, see STIF Users 
+// Guide.
+// -----------------------------------------------------------------------------
+//
+void CDrmLicenseCheckerTest::ConstructL()
+    {
+    iLog = CStifLogger::NewL( KDrmLicenseCheckerTestLogPath, 
+                          KDrmLicenseCheckerTestLogFile);
+                          
+    // Logging started
+    _LIT( KLogStart, "DrmLicenseChecker logging started!" );
+    iLog->Log( KLogStart );
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDrmLicenseCheckerTest* CDrmLicenseCheckerTest::NewL()
+    {
+    CDrmLicenseCheckerTest* self = new (ELeave) CDrmLicenseCheckerTest;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+CDrmLicenseCheckerTest::~CDrmLicenseCheckerTest()
+    { 
+    delete iLog;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::InitL
+// InitL is used to initialize the Test Module.
+// -----------------------------------------------------------------------------
+//
+TInt CDrmLicenseCheckerTest::InitL( 
+    TFileName& /*aIniFile*/, 
+    TBool /*aFirstTime*/ )
+    {
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::GetTestCasesL
+// GetTestCases is used to inquire test cases from the Test Module. Test
+// cases are stored to array of test cases. The Test Framework will be 
+// the owner of the data in the RPointerArray after GetTestCases return
+// and it does the memory deallocation. 
+// -----------------------------------------------------------------------------
+//
+TInt CDrmLicenseCheckerTest::GetTestCasesL( 
+    const TFileName& /*aConfig*/, 
+    RPointerArray<TTestCaseInfo>& aTestCases )
+    {
+    
+    // Loop through all test cases and for every item found make
+    // a TTestCaseInfo object and append it into the aTestCases array. 
+    for ( TInt i = 0; Case(i).iMethod != NULL; i++ )
+        {
+        
+        // Allocate new TTestCaseInfo from heap.
+        TTestCaseInfo* testCase = new ( ELeave ) TTestCaseInfo();
+    
+        CleanupStack::PushL( testCase );
+
+        // Set number for the testcase.
+        // When the testcase is run, this comes as a parameter to RunTestCaseL.
+        testCase->iCaseNumber = i;
+
+        testCase->iTitle.Copy( Case(i).iCaseName );
+
+        // Append TTestCaseInfo to the testcase array. After appended 
+        // succesfully the TTestCaseInfo object is owned (and freed) 
+        // by the TestServer. 
+        User::LeaveIfError( aTestCases.Append( testCase ) );
+
+        CleanupStack::Pop( testCase );
+
+        }
+
+    return KErrNone;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::RunTestCaseL
+// RunTestCaseL is used to run an individual test case specified 
+// by aTestCase. Test cases that can be run may be requested from 
+// Test Module by GetTestCases method before calling RunTestCase.
+// -----------------------------------------------------------------------------
+//
+TInt CDrmLicenseCheckerTest::RunTestCaseL(
+    const TInt aCaseNumber,
+    const TFileName& /*aConfig*/,
+    TTestResult& aResult )
+    {
+    
+    // Return value
+    TInt execStatus = KErrNone;
+    
+    // Get the pointer to test case function
+    TCaseInfo tmp = Case ( aCaseNumber );
+
+    _LIT( KLogStartTC, "Starting testcase [%S]" );
+    iLog->Log( KLogStartTC, &tmp.iCaseName);
+    
+    // Check that case number was valid
+    if ( tmp.iMethod != NULL )
+        {
+        // Valid case was found, call it via function pointer
+        iMethod = tmp.iMethod;        
+        execStatus  = ( this->*iMethod )( aResult );
+        }
+    else
+        {
+        // Valid case was not found, return error.
+        execStatus = KErrNotFound;
+        }
+
+    // Return case execution status (not the result of the case execution)
+    return execStatus;
+      
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::OOMTestQueryL
+// Used to check if a particular test case should be run in OOM conditions and 
+// which memory allocations should fail.    
+// -----------------------------------------------------------------------------
+//
+TBool CDrmLicenseCheckerTest::OOMTestQueryL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt aCaseNumber /* aCaseNumber */, 
+                                TOOMFailureType& /* aFailureType */, 
+                                TInt& aFirstMemFailure, 
+                                TInt& aLastMemFailure ) 
+    {
+    _LIT( KOOMTestQueryL, "CDrmLicenseCheckerTest::OOMTestQueryL" );
+    iLog->Log( KOOMTestQueryL );
+    
+    aFirstMemFailure = Case( aCaseNumber ).iFirstMemoryAllocation;
+    aLastMemFailure = Case( aCaseNumber ).iLastMemoryAllocation; 
+
+    return Case( aCaseNumber ).iIsOOMTest;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::OOMTestInitializeL
+// Used to perform the test environment setup for a particular OOM test case. 
+// Test Modules may use the initialization file to read parameters for Test 
+// Module initialization but they can also have their own configure file or 
+// some other routine to initialize themselves.  
+//
+// NOTE: This method is virtual and must be implemented only if test case
+// should be executed using OOM conditions.  
+// -----------------------------------------------------------------------------
+//
+void CDrmLicenseCheckerTest::OOMTestInitializeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::OOMHandleWarningL
+// In some cases the heap memory allocation should be skipped, either due to
+// problems in the OS code or components used by the code being tested, or even 
+// inside the tested components which are implemented this way on purpose (by 
+// design), so it is important to give the tester a way to bypass allocation 
+// failures.
+//
+// NOTE: This method is virtual and must be implemented only if test case
+// should be executed using OOM conditions.  
+// -----------------------------------------------------------------------------
+//
+void CDrmLicenseCheckerTest::OOMHandleWarningL( 
+                                const TFileName& /* aTestCaseFile */,
+                                const TInt /* aCaseNumber */, 
+                                TInt& /* aFailNextValue */ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::OOMTestFinalizeL
+// Used to perform the test environment cleanup for a particular OOM test case.
+//
+// NOTE: This method is virtual and must be implemented only if test case
+// should be executed using OOM conditions.  
+// -----------------------------------------------------------------------------
+//                  
+void CDrmLicenseCheckerTest::OOMTestFinalizeL( 
+                                const TFileName& /* aTestCaseFile */, 
+                                const TInt /* aCaseNumber */ )
+    {
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point
+// Returns: CTestModuleBase*: Pointer to Test Module object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CTestModuleBase* LibEntryL()
+    {
+    return CDrmLicenseCheckerTest::NewL();
+
+    }
+
+// -----------------------------------------------------------------------------
+// SetRequirements handles test module parameters(implements evolution
+// version 1 for test module's heap and stack sizes configuring).
+// Returns: TInt: Symbian error code.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt SetRequirements( CTestModuleParam*& /*aTestModuleParam*/, 
+                                TUint32& /*aParameterValid*/ )
+    {
+
+    /* --------------------------------- NOTE ---------------------------------
+    USER PANICS occurs in test thread creation when:
+    1) "The panic occurs when the value of the stack size is negative."
+    2) "The panic occurs if the minimum heap size specified is less
+       than KMinHeapSize".
+       KMinHeapSize: "Functions that require a new heap to be allocated will
+       either panic, or will reset the required heap size to this value if
+       a smaller heap size is specified".
+    3) "The panic occurs if the minimum heap size specified is greater than
+       the maximum size to which the heap can grow".
+    Other:
+    1) Make sure that your hardware or Symbian OS is supporting given sizes.
+       e.g. Hardware might support only sizes that are divisible by four.
+    ------------------------------- NOTE end ------------------------------- */
+
+    // Normally STIF uses default heap and stack sizes for test thread, see:
+    // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize.
+    // If needed heap and stack sizes can be configured here by user. Remove
+    // comments and define sizes.
+
+/*
+    aParameterValid = KStifTestModuleParameterChanged;
+
+    CTestModuleParamVer01* param = CTestModuleParamVer01::NewL();
+    // Stack size
+    param->iTestThreadStackSize= 16384; // 16K stack
+    // Heap sizes
+    param->iTestThreadMinHeap = 4096;   // 4K heap min
+    param->iTestThreadMaxHeap = 1048576;// 1M heap max
+
+    aTestModuleParam = param;
+*/
+    return KErrNone;
+
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/drm_license_checker_api/tsrc/src/DrmLicenseCheckerTestCases.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,222 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRMLicenseCheckerTest hard coded test cases
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32base.h>
+#include <DRMLicenseChecker.h>
+#include "drmlicensecheckertest.h"
+
+// CONSTANTS
+//#ifdef __WINSCW__
+_LIT( KTestFile, "c:\\testing\\data\\checker.txt" );
+//#else
+//_LIT( KTestFile, "e:\\testing\\data\\checker.txt" );
+//#endif
+
+_LIT( KRunning, "Running" );
+_LIT( KFinished, "Finished" );
+_LIT( KPassed, "Passed" );
+
+// LOCAL FUNCTION PROTOTYPES
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseChecker::Case
+// Returns a test case by number.
+//
+// This function contains an array of all available test cases 
+// i.e pair of case name and test function. If case specified by parameter
+// aCaseNumber is found from array, then that item is returned.
+// 
+// The reason for this rather complicated function is to specify all the
+// test cases only in one place. It is not necessary to understand how
+// function pointers to class member functions works when adding new test
+// cases. See function body for instructions how to add new test case.
+// -----------------------------------------------------------------------------
+//
+const TCaseInfo CDrmLicenseCheckerTest::Case ( 
+    const TInt aCaseNumber ) const 
+     {
+
+    /**
+    * To add new test cases, implement new test case function and add new 
+    * line to KCases array specify the name of the case and the function 
+    * doing the test case
+    * In practice, do following
+    * 1) Make copy of existing test case function and change its name
+    *    and functionality. Note that the function must be added to 
+    *    DRMCommonTest.cpp file and to DRMCommonTest.h 
+    *    header file.
+    *
+    * 2) Add entry to following KCases array either by using:
+    *
+    * 2.1: FUNCENTRY or ENTRY macro
+    * ENTRY macro takes two parameters: test case name and test case 
+    * function name.
+    *
+    * FUNCENTRY macro takes only test case function name as a parameter and
+    * uses that as a test case name and test case function name.
+    *
+    * Or
+    *
+    * 2.2: OOM_FUNCENTRY or OOM_ENTRY macro. Note that these macros are used
+    * only with OOM (Out-Of-Memory) testing!
+    *
+    * OOM_ENTRY macro takes five parameters: test case name, test case 
+    * function name, TBool which specifies is method supposed to be run using
+    * OOM conditions, TInt value for first heap memory allocation failure and 
+    * TInt value for last heap memory allocation failure.
+    * 
+    * OOM_FUNCENTRY macro takes test case function name as a parameter and uses
+    * that as a test case name, TBool which specifies is method supposed to be
+    * run using OOM conditions, TInt value for first heap memory allocation 
+    * failure and TInt value for last heap memory allocation failure. 
+    */ 
+
+    static TCaseInfoInternal const KCases[] =
+        {
+        // To add new test cases, add new items to this array
+        
+        // NOTE: When compiled to GCCE, there must be Classname::
+        // declaration in front of the method name, e.g. 
+        // CDrmLicenceCheckerTest::PrintTest. Otherwise the compiler
+        // gives errors.
+        ENTRY( "Com::ConstructTestL", CDrmLicenseCheckerTest::ConstructTestL ),
+        ENTRY( "Com::CheckLicenseTestL", CDrmLicenseCheckerTest::CheckLicenseTestL )
+        };
+
+    // Verify that case number is valid
+    if( (TUint) aCaseNumber >= sizeof( KCases ) / 
+                               sizeof( TCaseInfoInternal ) )
+        {
+        // Invalid case, construct empty object
+        TCaseInfo null( (const TText*) L"" );
+        null.iMethod = NULL;
+        null.iIsOOMTest = EFalse;
+        null.iFirstMemoryAllocation = 0;
+        null.iLastMemoryAllocation = 0;
+        return null;
+        } 
+
+    // Construct TCaseInfo object and return it
+    TCaseInfo tmp ( KCases[ aCaseNumber ].iCaseName );
+    tmp.iMethod = KCases[ aCaseNumber ].iMethod;
+    tmp.iIsOOMTest = KCases[ aCaseNumber ].iIsOOMTest;
+    tmp.iFirstMemoryAllocation = KCases[ aCaseNumber ].iFirstMemoryAllocation;
+    tmp.iLastMemoryAllocation = KCases[ aCaseNumber ].iLastMemoryAllocation;
+    return tmp;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::ConstructTestL
+// -----------------------------------------------------------------------------
+//
+TInt CDrmLicenseCheckerTest::ConstructTestL( TTestResult& aResult )
+    {
+    _LIT( KData, "CDrmLicenseCheckerTest::ConstructTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+   
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase1, "TestCase1: Testing NewL of DrmLicenseChecker:");
+    iLog->Log( KTestCase1 );
+        
+    CDRMLicenseChecker* checker = CDRMLicenseChecker::NewL();
+    TL( checker );
+    delete checker;
+    
+    //Passed
+    iLog->Log( KPassed );
+
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDrmLicenseCheckerTest::ConstructTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDrmLicenseCheckerTest::CheckLicenseTestL
+// -----------------------------------------------------------------------------
+//    
+TInt CDrmLicenseCheckerTest::CheckLicenseTestL(TTestResult& aResult)
+    {
+    _LIT( KData, "CDrmLicenseCheckerTest::CheckLicenseTestL" );
+    TestModuleIf().Printf( 0, KRunning, KData );
+    iLog->Log( KData );
+    
+    HBufC8* buffer( NULL );
+    TInt ret( KErrNone );
+    
+    // Test Cases
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+
+    _LIT( KTestCase2, "TestCase2: Testing CheckLicense of DrmLicenseChecker:" );
+    iLog->Log( KTestCase2 );
+    
+    CDRMLicenseChecker* checker = CDRMLicenseChecker::NewL();
+    CleanupStack::PushL( checker );
+    
+    ret = checker->CheckLicense( KTestFile, buffer );
+    
+    T1L( ret, KErrNone );
+    
+    // Passed
+    CleanupStack::PopAndDestroy( checker );
+    iLog->Log( KPassed );
+    
+    // -----------------------------------------------------------------------------
+    // -----------------------------------------------------------------------------
+    // Test Cases End 
+    
+    TestModuleIf().Printf( 0, KFinished, KData);
+
+    //Test case passed
+    _LIT( KDescription, "CDrmLicenseCheckerTest::CheckLicenseTestL passed" );
+    iLog->Log( KDescription );
+    aResult.SetResult( KErrNone, KDescription );
+
+    //Case was executed
+    return KErrNone;
+    }
+
+// End of File
+
+    
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,23 @@
+/*
+* 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:  Includes all the SDK API specific bld.inf files, which 
+*                export files.
+*
+*/
+
+
+
+#include "../drm_helper_api/group/bld.inf"
+#include "../oma_drm_caf_agent_api/group/bld.inf"
+#include "../drm_license_checker_api/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* 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:  File that exports the files belonging to 
+:                OMA DRM CAF Agent API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/Oma2Agent.h     MW_LAYER_PUBLIC_EXPORT_PATH(Oma2Agent.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/inc/Oma2Agent.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,239 @@
+/*
+* Copyright (c) 2005 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Contains the OMA DRM CAF Agent specific data types, commands
+*                and attributes
+*
+*/
+
+
+
+#ifndef OMA2AGENT_H
+#define OMA2AGENT_H
+
+//  INCLUDES
+#include <caf/caftypes.h>
+
+// CONSTANTS
+_LIT(KOmaDrm2AgentName, "OMA DRM Agent");
+_LIT8(KOma1DrmMessageContentType, "application/vnd.oma.drm.message");
+_LIT8(KOma1XmlRoContentType, "application/vnd.oma.drm.rights+xml");
+_LIT8(KOma1WbxmlRoContentType, "application/vnd.oma.drm.rights+wbxml");
+_LIT8(KOma2RoContentType, "application/vnd.oma.drm.roap-pdu+xml");
+_LIT8(KOma2ProtectedRoType, "application/vnd.oma.drm.ro+xml");
+_LIT8(KOma2TriggerContentType, "application/vnd.oma.drm.roap-trigger+xml");
+_LIT8(KOma1DcfContentType, "application/vnd.oma.drm.content");
+_LIT8(KOma2DcfContentType, "application/vnd.oma.drm.dcf");
+_LIT8(KOmaImportContentType, "application/x-vnd.oma.drm.import");
+_LIT8(KOmaImportMimeTypeField, "Content-type");
+_LIT8(KOmaImportRightsField, "Rights");
+_LIT8(KOma2DcfRoBoxId, "cid:Oma2DcfRightsObjectBox@localhost");
+_LIT8(KOma2DcfTransactionBoxId, "cid:Oma2DcfTransactionBox@localhost");
+_LIT8(KOma2DcfBranding, "\000\000\000\024ftypodcf\000\000\000\002odcf");
+_LIT8(KCafMimeType, "application/x-caf");
+_LIT(KOma1DcfExtension, ".dcf");
+_LIT(KOma2DcfExtension, ".odf");
+_LIT(KOma2DcfExtensionAudio, ".o4a");
+_LIT(KOma2DcfExtensionVideo, ".o4v");
+
+// DATA TYPES
+
+// Transport scheme for encrypted rights objects
+
+enum TKeyTransportScheme
+    {
+    EOma,
+    ECmlaIp1,
+    ECmlaIp2,
+    ECmlaIp3,
+    ECmlaIp4,
+    ECmlaIp5,
+    ECmlaIp6,
+    ECmlaIp7,
+    };
+
+namespace ContentAccess
+{
+// Agent specific attribute identifiers
+
+enum TOma2AgentAttribute
+    {
+    EFileType = EAgentSpecificAttributeBase + 1,
+    EPreviewType,
+    ESilentRightsType,
+    EDeliveryMethod,
+    ERecordingYear
+    };
+
+enum TOma2AgentStringAttribute
+    {
+    EInstantPreviewUri = EAgentSpecificAttributeBase + 1,
+    EPreviewRightsUri,
+    ERightsIssuerUrl,
+    ESilentRightsUrl,
+    ETransactionTrackingId,
+    EEmbeddedRightsObject,
+    EGroupId,
+    EDomainRightsIssuerUrl,
+    EDomainId,
+    EDomainRightsIssuerId,
+    EContentVendor,
+    ECopyright,
+    EContentName,
+    EOmaDrmContentLocation,
+    EOmaDrmContentVersion,
+    EPerformer,
+    EOmaDrmGenre,
+    ERatingInfo,
+    EClassificationInfo,
+    EKeyword,
+    ELocInfoName,
+    ELocInfoAstronomicalBody,
+    ELocInfoAdditionalNotes,
+    EAlbumTitle,
+    EAlbumTrack,
+    ECoverUri,
+    ELyricsUrl,
+    EFileName
+    };
+
+// File types
+// EOma1DcfBased, The file type is derived from Oma1Dcf but has some extensions to it
+enum
+    {
+    ENoDcf = 0,
+    EOma1Dcf = 1,
+    EOma2Dcf = 2,
+    EOma1DcfBased = 4 
+    };
+
+// Delivery method
+
+enum TOmaDrmDeliveryMethod
+    {
+    EOmaDrm1LocalDataFile,
+    EOmaDrm1ForwardLock,
+    EOmaDrm1ForwardLockDcf,
+    EOmaDrm1CombinedDelivery,
+    EOmaDrm1CombinedDeliveryDcf,
+    EOmaDrm1SeparateDelivery,
+    EOmaDrm2
+    };
+
+// Encryption methods for OMA DRM 2 DCF files
+
+enum TEncryptionMethod
+    {
+    EMethodNULL = 0x00,
+    EMethodAES_128_CBC = 0x01,
+    EMethodAES_128_CTR = 0x02
+    };
+
+// Padding options
+
+enum TEncryptionPadding
+    {
+    EPaddingNone = 0x00,
+    EPaddingRFC_2630 = 0x01
+    };
+
+// Rights refresh and preview options
+
+enum TSilentRefresh
+    {
+    ENoSilentRefresh = 0x00,
+    EOnDemand = 0x01,
+    EInAdvance = 0x02
+    };
+
+enum TPreview
+    {
+    ENoPreview = 0x00,
+    EInstantPreview = 0x01,
+    EPreviewRights = 0x02
+    };
+
+// Rights Object version (stored in the iVersionMain field of the version)
+
+enum
+    {
+    EOma1Rights = 1,
+    EOma2Rights = 2,
+    ECmlaRights = 3
+    };
+
+// Agent specific commands
+
+enum
+    {
+    /**
+    * Embed any present domain RO into a CContent object
+    * Works as an agent specific command for CContent
+    * Input buffer: unused
+    * Output buffer: unused
+    */
+    EEmbedDomainRo,
+
+    /**
+    * Return the supported OMA DRM methods
+    * Works as an agent specific command for CManager
+    * Input buffer: unused
+    * Output buffer: String containing the following tokens
+    *                FL if OMA DRM 1.0 Forward Lock is supported
+    *                CD if OMA DRM 1.0 Combined Delivery is supported
+    *                SD if OMA DRM 1.0 Separate Delivery is supported
+    *                OMADRM2 if OMA DRM 2.0 is supported
+    */
+    EOmaDrmMethods,
+
+    /**
+    * Set the value of the x-oma header
+    * works as an agent specific command for CManager
+    * Input buffer: String containing the following data
+    *               4 bytes(TInt) | ContentURI
+    * Output buffer: unused
+    */
+    ESetPendingRightsETA,
+
+    /**
+    * Checks whether a memory buffer contains an OMA DRM 1.0 DCF
+    * Input buffer: Memory buffer to check
+    * Output buffer: unused
+    * Return value: KErrNone if the buffer contains a DCF
+    */
+    EBufferContainsOma1Dcf,
+
+    /**
+    * Decrypt an OMA DRM 1.0 DCF memory buffer
+    * Input buffer: Intent of the decryption (EPlay, ...) in the first byte,
+    *               followed by the memory buffer to decrypt
+    * Output buffer: Decrypted data
+    */
+    EDecryptOma1DcfBuffer,
+
+
+    /**
+    * Set the content name
+    * Input buffer: first memory buffer 4 bytes of length of the content name |
+    *               memory buffer of the new content name |
+    *               content id
+    * Output buffer: unused
+    */
+    ESetContentName,
+
+    };
+}
+
+#endif      // OMA2AGENT_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/oma_drm_caf_agent_api.metaxml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,17 @@
+<?xml version="1.0" ?>
+<api id="9c0dea2c69cb913afa3a93e40b3fe2a0" dataversion="1.0">
+  <name>OMA DRM CAF Agent API</name>
+  <description>Provides OMA DRM CAF Agent specific functions</description>
+  <type>c++</type>
+  <subsystem>omadrm</subsystem>
+  <libs>
+  </libs>
+  <release category="sdk" sinceversion="3.0"/>
+  <attributes>
+     <!-- This indicates wether the api provedes separate html documentation -->
+     <!-- or is the additional documentation generated from headers. -->
+     <!-- If you are unsuere then the value is "no" -->
+     <htmldocprovided>yes</htmldocprovided>
+     <adaptation>no</adaptation>
+  </attributes>
+</api>
Binary file drm_pub/oma_drm_caf_agent_api/tsrc/bc/BCDRMCAFCAPS_exe/group/BCDRMCAFCAPS_exe.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/BCDRMCAFCAPS_exe/group/BCDRMCAFCAPS_exe.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:       
+*
+*/
+
+#if defined(__S60_)
+        // To get the MW_LAYER_SYSTEMINCLUDE-definition
+        #include <platform_paths.hrh>
+#endif
+
+TARGET          BCDRMCAFCAPS.exe
+TARGETTYPE      exe
+
+UID             0 0x101FB3E8
+
+/* Specify the capabilities according to your test environment */
+CAPABILITY      None
+/* Remove comments and replace 0x00000000 with correct vendor id */
+// VENDORID     0x00000000
+/* Remove comments and replace 0x00000000 with correct secure id */
+// SECUREID     0x00000000
+
+#if defined(__S60_)
+    MW_LAYER_SYSTEMINCLUDE
+#else // __S60_ not defined
+    SYSTEMINCLUDE   /epoc32/include 
+    SYSTEMINCLUDE   /epoc32/include/internal
+#endif // __S60_
+
+/* Source files */
+SOURCEPATH      ../src
+
+SOURCE          BCDRMCAFCAPS_exe.cpp
+
+/* Used libraries */
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+
+EPOCSTACKSIZE   40960
+
+SMPSAFE
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/BCDRMCAFCAPS_exe/group/BCDRMCAFCAPS_exe.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,61 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+;
+; Installation file for STIF
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+"\epoc32\release\armv5\urel\BCDRMCAFCAPS.exe"   -   "!:\Sys\Bin\BCDRMCAFCAPS.exe"
+
+; Embedded SIS
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/BCDRMCAFCAPS_exe/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:       
+*
+*/
+
+
+
+
+
+
+
+
+/*
+-----------------------------------------------------------------------------
+
+    DESCRIPTION
+
+    bld.inf Toplevel build information for STIF Test Framework's
+    BCDRMCAFCAPS capability modifier module.
+
+-----------------------------------------------------------------------------
+*/
+
+PRJ_PLATFORMS
+// Specify the platforms your component needs to be built for here.
+// If not specified all platforms can be built.
+
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_TESTEXPORTS
+
+PRJ_MMPFILES
+BCDRMCAFCAPS_exe.mmp
+
+PRJ_TESTMMPFILES
+
+
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/BCDRMCAFCAPS_exe/src/BCDRMCAFCAPS_exe.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:       
+*
+*/
+
+
+
+
+
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <e32svr.h>
+#include <StifTestInterface.h>
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// ================= OTHER EXPORTED FUNCTIONS =================================
+
+/*
+-------------------------------------------------------------------------------
+
+    Class: -
+
+    Method: E32Main
+
+    Description: 
+
+    Parameters: None
+
+    Return Values: TInt: Symbian error code
+
+    Errors/Exceptions: None
+
+    Status: Draft
+
+-------------------------------------------------------------------------------
+*/
+GLDEF_C TInt E32Main()
+    {
+    _LIT( KProcessMsgStart, "New process starting" );
+    RDebug::Print( KProcessMsgStart );
+
+
+    // This starts a new session that get capabilites that is used in 
+    // BCDRMCAFCAPS_exe.mmp file.
+    TInt r = StartSession();
+
+    _LIT( KProcessMsgEnd, "New process ends" );
+    RDebug::Print( KProcessMsgEnd );
+
+    return r;
+
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/Bmarm/DRM_CAFU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	LibEntryL__FR13CTestModuleIf @ 1 NONAME R3UNUSED ; LibEntryL(CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/Bwins/DRM_CAFU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?LibEntryL@@YAPAVCScriptBase@@AAVCTestModuleIf@@@Z @ 1 NONAME ; class CScriptBase * __cdecl LibEntryL(class CTestModuleIf &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/EABI/DRM_CAFU.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z9LibEntryLR13CTestModuleIf @ 1 NONAME
+
Binary file drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/data/content-noenc-trunc.odf has changed
Binary file drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/data/content-noenc.odf has changed
Binary file drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/data/content.dcf has changed
Binary file drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/data/content.odf has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/data/content.txt	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4 @@
+01234567890123456789001234567890123456789012345678901234567890012345678901234567890
+01234567890123456789001234567890123456789012345678901234567890012345678901234567890
+01234567890123456789001234567890123456789012345678901234567890012345678901234567890
+01234567890123456789001234567890123456789012345678901234567890012345678901234567890
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/DRM_CAF.cfg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,365 @@
+[StifSettings]CapsModifier= BCDRMCAFCAPS.exe [EndStifSettings]
+
+[Test]
+title CSupplier_Oma1XmlRoL
+create DRM_CAF foobar
+foobar CSupplier_Oma1XmlRoL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CSupplier_Oma1WbxmlRoL
+create DRM_CAF foobar
+foobar CSupplier_Oma1WbxmlRoL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CData_NewL
+create DRM_CAF foobar
+foobar CData_NewL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CData_Read_DataSize_SeekL
+create DRM_CAF foobar
+foobar CData_Read_DataSize_SeekL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CData_Read2L
+create DRM_CAF foobar
+foobar CData_Read2L  
+delete foobar
+[Endtest] 
+
+[Test]
+title CData_SetPropertyL
+create DRM_CAF foobar
+foobar CData_SetPropertyL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CData_EvaluateIntentL
+create DRM_CAF foobar
+foobar CData_EvaluateIntentL
+delete foobar
+[Endtest] 
+
+[Test]
+title CData_ExecuteIntentL
+create DRM_CAF foobar
+foobar CData_ExecuteIntentL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CData_GetAttributeL
+create DRM_CAF foobar
+foobar CData_GetAttributeL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CData_GetAttributeSetL
+create DRM_CAF foobar
+foobar CData_GetAttributeSetL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CData_GetStringAttributeL
+create DRM_CAF foobar
+foobar CData_GetStringAttributeL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CData_GetStringAttributeSetL
+create DRM_CAF foobar
+foobar CData_GetStringAttributeSetL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_NewL
+create DRM_CAF foobar
+foobar CContent_NewL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_OpenCloseContainerL
+create DRM_CAF foobar
+foobar CContent_OpenCloseContainerL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_GetEmbeddedObjectsL
+create DRM_CAF foobar
+foobar CContent_GetEmbeddedObjectsL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_SearchL
+create DRM_CAF foobar
+foobar CContent_SearchL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_GetAttributeL
+create DRM_CAF foobar
+foobar CContent_GetAttributeL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_GetAttributeSetL
+create DRM_CAF foobar
+foobar CContent_GetAttributeSetL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_GetStringAttributeL
+create DRM_CAF foobar
+foobar CContent_GetStringAttributeL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_GetStringAttributeSetL
+create DRM_CAF foobar
+foobar CContent_GetStringAttributeSetL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_AgentSpecificCommandL
+create DRM_CAF foobar
+foobar CContent_AgentSpecificCommandL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_NotifyStatusChangeL
+create DRM_CAF foobar
+foobar CContent_NotifyStatusChangeL 
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_CancelNotifyStatusChangeL
+create DRM_CAF foobar
+foobar CContent_CancelNotifyStatusChangeL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_RequestRightsL
+create DRM_CAF foobar
+foobar CContent_RequestRightsL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_DisplayInfoL
+create DRM_CAF foobar
+foobar CContent_DisplayInfoL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_SetPropertyL
+create DRM_CAF foobar
+foobar CContent_SetPropertyL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CContent_OpenContentL
+create DRM_CAF foobar
+foobar CContent_OpenContentL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CManager_FileOperationsL
+create DRM_CAF foobar
+foobar CManager_FileOperationsL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CManager_GetAttributeL
+create DRM_CAF foobar
+foobar CManager_GetAttributeL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CManager_GetAttributeSetL
+create DRM_CAF foobar
+foobar CManager_GetAttributeSetL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CManager_GetStringAttributeL
+create DRM_CAF foobar
+foobar CManager_GetStringAttributeL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CManager_GetStringAttributeSetL
+create DRM_CAF foobar
+foobar CManager_GetStringAttributeSetL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CManager_SetPropertyL
+create DRM_CAF foobar
+foobar CManager_SetPropertyL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CManager_DisplayInfoL
+create DRM_CAF foobar
+foobar CManager_DisplayInfoL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CManager_ListAgentsL
+create DRM_CAF foobar
+foobar CManager_ListAgentsL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CManager_AgentSpecificCommandL
+create DRM_CAF foobar
+foobar CManager_AgentSpecificCommandL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CManager_CreateRightsManagerL
+create DRM_CAF foobar
+foobar CManager_CreateRightsManagerL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CSupplier_IsImportSupportedL
+create DRM_CAF foobar
+foobar CSupplier_IsImportSupportedL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CSupplier_PrepareHTTPRequestHeadersL
+create DRM_CAF foobar
+foobar CSupplier_PrepareHTTPRequestHeadersL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CSupplier_SetOutputDirectory_ImportFileL
+create DRM_CAF foobar
+foobar CSupplier_SetOutputDirectory_ImportFileL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CImportFile_WriteData_WriteDataComplete_OutputFileCountL
+create DRM_CAF foobar
+foobar CImportFile_WriteData_WriteDataComplete_OutputFileCountL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CImportFile_OutputFileL_GetImportStatusL
+create DRM_CAF foobar
+foobar CImportFile_OutputFileL_GetImportStatusL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CImportFile_GetSuggestedOutputFileExtensionL
+create DRM_CAF foobar
+foobar CImportFile_GetSuggestedOutputFileExtensionL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CImportFile_GetSuggestedOutputFileNameL
+create DRM_CAF foobar
+foobar CImportFile_GetSuggestedOutputFileNameL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CImportFile_ContinueWithNewOutputFileL
+create DRM_CAF foobar
+foobar CImportFile_ContinueWithNewOutputFileL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CRightsManager_ListRightsL
+create DRM_CAF foobar
+foobar CRightsManager_ListRightsL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CRightsManager_ListRightsL
+create DRM_CAF foobar
+foobar CRightsManager_ListRightsL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CRightsManager_ListAllRightsL
+create DRM_CAF foobar
+foobar CRightsManager_ListAllRightsL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CRightsManager_DeleteRightsObjectL
+create DRM_CAF foobar
+foobar CRightsManager_DeleteRightsObjectL
+delete foobar
+[Endtest] 
+
+[Test]
+title CRightsManager_DeleteAllRightsObjectsL
+create DRM_CAF foobar
+foobar CRightsManager_DeleteAllRightsObjectsL  
+delete foobar
+[Endtest] 
+
+[Test]
+title CRightsManager_SetPropertyL
+create DRM_CAF foobar
+foobar CRightsManager_SetPropertyL 
+delete foobar
+[Endtest]
+
+[Test]
+title CDRMLicenseChecker_CheckLicenseL
+create DRM_CAF foobar
+foobar CDRMLicenseChecker_CheckLicenseL 
+delete foobar
+[Endtest]
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/DRM_CAF.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,89 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#if defined(__S60_)
+        // To get the MW_LAYER_SYSTEMINCLUDE-definition
+        #include <platform_paths.hrh>
+#endif
+
+TARGET          DRM_CAF.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E3
+
+CAPABILITY      ALL -TCB
+// VENDORID     0x00000000
+// SECUREID     0x00000000
+
+DEFFILE         DRM_CAF.def
+
+USERINCLUDE     ../inc 
+
+#if defined(__S60_)
+    MW_LAYER_SYSTEMINCLUDE
+#else // __S60_ not defined
+    SYSTEMINCLUDE   /epoc32/include 
+    SYSTEMINCLUDE   /epoc32/include/internal
+#endif // __S60_
+
+SOURCEPATH      ../src
+
+SOURCE          DRM_CAF.cpp
+SOURCE          DRM_CAFBlocks.cpp
+
+//RESOURCE        resource_file
+//RESOURCE        resource_file2
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+
+LANG            SC
+
+
+SYSTEMINCLUDE /epoc32/include/libc
+SYSTEMINCLUDE /epoc32/include/ecom
+SYSTEMINCLUDE /epoc32/include/caf
+		
+LIBRARY         apparc.lib
+LIBRARY         avkon.lib
+LIBRARY         bafl.lib
+LIBRARY         cone.lib
+LIBRARY         eikcoctl.lib
+LIBRARY         eikcore.lib 
+LIBRARY         fbscli.lib
+LIBRARY         efsrv.lib
+LIBRARY         caf.lib 
+LIBRARY         cafutils.lib
+LIBRARY         XmlFramework.lib
+LIBRARY         apmime.lib
+LIBRARY         estor.lib
+LIBRARY         flogger.lib
+LIBRARY		    ecom.lib
+LIBRARY         x509.lib
+LIBRARY         pkixcert.lib
+LIBRARY         hash.lib
+LIBRARY         crypto.lib 
+LIBRARY         random.lib
+LIBRARY         asn1.lib
+LIBRARY         drmlicensechecker.lib
+
+LIBRARY         aknskins.lib //for skin sbackground
+LIBRARY         gdi.lib
+
+SMPSAFE
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/DRM_CAF.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,61 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+;
+; Installation file for STIF
+;
+
+; Languages
+&EN
+
+; Provide value for uid
+#{"STIF"},(0x00000000),1,1,0,TYPE=SA
+
+; Series60 product id for S60 3.0
+[0x101F7961], 0, 0, 0, {"Series60ProductID"}
+
+; Localised Vendor name
+%{"Nokia"}
+
+; Unique Vendor name
+:"Nokia"
+
+; Logo
+; None
+
+; Package signature - Optional
+; None
+
+; Start of Package body
+
+; Condition blocks
+; None
+
+; Options list
+; None
+
+; Install files
+"\epoc32\release\armv5\udeb\DRM_CAF.dll"   -   "!:\Sys\Bin\DRM_CAF.dll"
+
+; Embedded SIS
+; None
+
+; End of Package body
+
+; PKG dependencies
+; None
+
+; PKG capabilities
+; None
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/DRM_CAF_DoxyFile.txt	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,222 @@
+# Doxyfile 1.4.1
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME           = DRM_CAF
+PROJECT_NUMBER         = 
+OUTPUT_DIRECTORY       = y:\DRM_CAF\
+CREATE_SUBDIRS         = NO
+OUTPUT_LANGUAGE        = English
+USE_WINDOWS_ENCODING   = YES
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ABBREVIATE_BRIEF       = 
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES        = NO
+STRIP_FROM_PATH        = 
+STRIP_FROM_INC_PATH    = 
+SHORT_NAMES            = NO
+JAVADOC_AUTOBRIEF      = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP         = NO
+INHERIT_DOCS           = YES
+DISTRIBUTE_GROUP_DOC   = NO
+TAB_SIZE               = 8
+ALIASES                = 
+OPTIMIZE_OUTPUT_FOR_C  = YES
+OPTIMIZE_OUTPUT_JAVA   = NO
+SUBGROUPING            = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL            = YES
+EXTRACT_PRIVATE        = NO
+EXTRACT_STATIC         = NO
+EXTRACT_LOCAL_CLASSES  = NO
+EXTRACT_LOCAL_METHODS  = NO
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+INTERNAL_DOCS          = YES
+CASE_SENSE_NAMES       = YES
+HIDE_SCOPE_NAMES       = NO
+SHOW_INCLUDE_FILES     = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+SORT_BRIEF_DOCS        = NO
+SORT_BY_SCOPE_NAME     = NO
+GENERATE_TODOLIST      = NO
+GENERATE_TESTLIST      = NO
+GENERATE_BUGLIST       = NO
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS       = 
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES        = YES
+SHOW_DIRECTORIES       = YES
+FILE_VERSION_FILTER    = 
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_NO_PARAMDOC       = NO
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           = 
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = y:\DRM_CAF\
+FILE_PATTERNS          = *.h \
+                         *.rh \
+                         *.hrh
+RECURSIVE              = YES
+EXCLUDE                = 
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       = 
+EXAMPLE_PATH           = 
+EXAMPLE_PATTERNS       = 
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             = 
+INPUT_FILTER           = 
+FILTER_PATTERNS        = 
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = NO
+INLINE_SOURCES         = NO
+STRIP_CODE_COMMENTS    = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION    = YES
+VERBATIM_HEADERS       = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          = 
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = NO
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            = 
+HTML_FOOTER            = 
+HTML_STYLESHEET        = 
+HTML_ALIGN_MEMBERS     = YES
+GENERATE_HTMLHELP      = YES
+CHM_FILE               = 
+HHC_LOCATION           = 
+GENERATE_CHI           = NO
+BINARY_TOC             = YES
+TOC_EXPAND             = YES
+DISABLE_INDEX          = YES
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = YES
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         = 
+LATEX_HEADER           = 
+PDF_HYPERLINKS         = NO
+USE_PDFLATEX           = NO
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = YES
+RTF_OUTPUT             = Doc
+COMPACT_RTF            = YES
+RTF_HYPERLINKS         = YES
+RTF_STYLESHEET_FILE    = 
+RTF_EXTENSIONS_FILE    = 
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_SCHEMA             = 
+XML_DTD                = 
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX = 
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor   
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = YES
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           = 
+INCLUDE_FILE_PATTERNS  = 
+PREDEFINED             = NONSHARABLE_CLASS
+EXPAND_AS_DEFINED      = 
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references   
+#---------------------------------------------------------------------------
+TAGFILES               = 
+GENERATE_TAGFILE       = 
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool   
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS         = YES
+HIDE_UNDOC_RELATIONS   = YES
+HAVE_DOT               = NO
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+GROUP_GRAPHS           = YES
+UML_LOOK               = NO
+TEMPLATE_RELATIONS     = YES
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+CALL_GRAPH             = NO
+GRAPHICAL_HIERARCHY    = YES
+DIRECTORY_GRAPH        = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               = 
+DOTFILE_DIRS           = 
+MAX_DOT_GRAPH_WIDTH    = 1024
+MAX_DOT_GRAPH_HEIGHT   = 1024
+MAX_DOT_GRAPH_DEPTH    = 0
+DOT_TRANSPARENT        = NO
+DOT_MULTI_TARGETS      = NO
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine   
+#---------------------------------------------------------------------------
+SEARCHENGINE           = NO
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/DRM_CAF_nrm.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#if defined(__S60_)
+        // To get the OS_LAYER_SYSTEMINCLUDE-definition
+        #include <platform_paths.hrh>
+#endif
+
+TARGET          DRM_CAF.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101FB3E3
+
+CAPABILITY      ALL -TCB
+/* Remove comments and replace 0x00000000 with correct vendor id */
+// VENDORID     0x00000000
+/* Remove comments and replace 0x00000000 with correct secure id */
+// SECUREID     0x00000000
+
+//TARGETPATH      ?target_path
+DEFFILE         DRM_CAF.def
+
+USERINCLUDE     ../inc 
+
+#if defined(__S60_)
+    MW_LAYER_SYSTEMINCLUDE
+#else // __S60_ not defined
+    SYSTEMINCLUDE   /epoc32/include 
+    SYSTEMINCLUDE   /epoc32/include/internal
+#endif // __S60_
+
+SOURCEPATH      ../src
+
+SOURCE          DRM_CAF.cpp
+SOURCE          DRM_CAFBlocks.cpp
+
+//RESOURCE        resource_file
+//RESOURCE        resource_file2
+
+LIBRARY         euser.lib
+LIBRARY         stiftestinterface.lib
+LIBRARY         stiftestengine.lib
+
+LANG            SC
+
+/*
+START WINS      
+?wins_specific_information
+END
+
+START MARM
+?marm_specific_information
+END
+*/
+// Other possible keywords:
+ 
+// DOCUMENT     ?file, that is not compiled, but added to MSVC project workspace (i.e. release notes)
+/*
+START BITMAP ?target
+TARGETPATH   ?emulated_path_on_target_machine
+HEADER
+SOURCE       ?color_depth ?source_bitmap
+END
+*/
+// DEFFILE ?filename
+// AIF ?filename
+
+SMPSAFE
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/TestFramework.ini	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,201 @@
+#
+# This is STIF initialization file
+# Comment lines start with '#'-character.
+# See STIF TestFramework users guide.doc for instructions
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set following test engine settings:
+#	- Set Test Reporting mode. TestReportMode's possible values are:
+#		+ 'Summary': Summary of the tested test cases.
+#		+ 'Environment': Hardware and software info.
+#		+ 'TestCases': Test case report.
+#		+ 'FullReport': Set of all above ones.
+#		+ Example 'TestReportMode= Summary TestCases'
+#
+# 	- CreateTestReport setting controls report creation mode
+#		+ YES, Test report will created.
+#		+ NO, No Test report.
+#
+# 	- File path indicates the base path of the test report.
+# 	- File name indicates the name of the test report.
+#
+# 	- File format indicates the type of the test report.
+#		+ TXT, Test report file will be txt type, for example 'TestReport.txt'.
+#		+ HTML, Test report will be html type, for example 'TestReport.html'.
+#   + XML, Test report will be xml type, for example 'TestReport.xml'.
+#          Note, that xml format is available only when output is set to FILE.
+#
+# 	- File output indicates output source of the test report.
+#		+ FILE, Test report logging to file.
+#		+ RDEBUG, Test report logging to using rdebug.
+#
+# 	- File Creation Mode indicates test report overwriting if file exist.
+#		+ OVERWRITE, Overwrites if the Test report file exist.
+#		+ APPEND, Continue logging after the old Test report information if
+#                 report exist.
+# 	- Sets a device reset module's dll name(Reboot).
+#		+ If Nokia specific reset module is not available or it is not correct one
+#		  StifHWResetStub module may use as a template for user specific reset
+#		  module.
+# 	- Sets STIF test measurement disable options. e.g. pluging1 and pluging2 disablation
+#		DisableMeasurement= stifmeasurementplugin01 stifmeasurementplugin02
+#
+
+[Engine_Defaults]
+
+TestReportMode= FullReport    # Possible values are: 'Empty', 'Summary', 'Environment',
+                                                     'TestCases' or 'FullReport'
+
+CreateTestReport= YES         # Possible values: YES or NO
+
+TestReportFilePath= C:\LOGS\TestFramework\
+TestReportFileName= TestReport
+
+TestReportFormat= TXT         # Possible values: TXT, HTML or XML
+TestReportOutput= FILE        # Possible values: FILE or RDEBUG
+TestReportFileCreationMode= OVERWRITE # Possible values: OVERWRITE or APPEND
+
+DeviceResetDllName= StifResetForNokia.dll # e.g. 'StifHWResetStub.dll' for user specific reseting
+
+DisableMeasurement= stifmeasurementdisablenone  # Possible values are:
+              # 'stifmeasurementdisablenone', 'stifmeasurementdisableall'
+              # 'stifmeasurementplugin01', 'stifmeasurementplugin02',
+              # 'stifmeasurementplugin03', 'stifmeasurementplugin04',
+              # 'stifmeasurementplugin05' or 'stifbappeaprofiler'
+
+Timeout= 0                    # Default timeout value for each test case. In milliseconds
+UITestingSupport= YES        # Possible values: YES or NO
+SeparateProcesses= YES       # Possible values: YES or NO (default: NO)
+[End_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Module configurations start
+# Modules are added between module tags
+# tags. Module name is specified after ModuleName= tag, like
+# ModuleName= XXXXXXXXX
+# Modules might have initialisation file, specified as
+# IniFile= c:\testframework\YYYYYY
+# Modules might have several configuration files, like
+# TestCaseFile= c:\testframework\NormalCases.txt
+# TestCaseFile= c:\testframework\SmokeCases.txt
+# TestCaseFile= c:\testframework\ManualCases.txt
+
+# (TestCaseFile is synonym for old term ConfigFile)
+
+# Following case specifies demo module settings. Demo module
+# does not read any settings from file, so tags 
+# IniFile and TestCaseFile are not used.
+# In the simplest case it is enough to specify only the
+# name of the test module when adding new test module
+
+[New_Module]
+ModuleName= testscripter
+TestCaseFile= c:\testframework\DRM_CAF.cfg
+[End_Module]
+
+
+
+# Load testmoduleXXX, optionally with initialization file and/or test case files
+#[New_Module]
+#ModuleName= testmodulexxx
+
+#TestModuleXXX used initialization file
+#IniFile= c:\testframework\init.txt
+
+#TestModuleXXX used configuration file(s)
+#TestCaseFile= c:\testframework\testcases1.cfg
+#TestCaseFile= c:\testframework\testcases2.cfg
+#TestCaseFile= c:\testframework\manualtestcases.cfg
+
+#[End_Module]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+
+
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+# Set STIF logging overwrite parameters for Logger.
+# 	Hardware and emulator environment logging path and styles can
+# 	be configured from here to overwrite the Logger's implemented values.
+#	
+#	Settings description:
+#	- Indicates option for creation log directory/directories. If log directory/directories
+#         is/are not created by user they will make by software.
+#		+ YES, Create log directory/directories if not allready exist.
+#		+ NO, Log directory/directories not created. Only created one is used.
+#
+#	- Overwrite emulator path setting.
+#		+ Example: If 'EmulatorBasePath= C:\LOGS\TestFramework\' and in code is defined 
+#		           Logger's path 'D:\\LOGS\\Module\\' with those definition the path
+#		           will be 'C:\LOGS\TestFramework\LOGS\Module\'
+#
+#	- Overwrite emulator's logging format.
+#		+ TXT, Log file(s) will be txt type(s), for example 'Module.txt'.
+#		+ HTML, Log file(s) will be html type(s), for example 'Module.html'.
+#
+#	- Overwrited emulator logging output source.
+#		+ FILE, Logging to file(s).
+#		+ RDEBUG, Logging to using rdebug(s).
+#
+#	- Overwrite hardware path setting (Same description as above in emulator path).
+#	- Overwrite hardware's logging format(Same description as above in emulator format).
+#	- Overwrite hardware's logging output source(Same description as above in emulator output).
+#
+#	- File Creation Mode indicates file overwriting if file exist.
+#		+ OVERWRITE, Overwrites if file(s) exist.
+#		+ APPEND, Continue logging after the old logging information if file(s) exist.
+#
+#	- Will thread id include to the log filename.
+#		+ YES, Thread id to log file(s) name, Example filename 'Module_b9.txt'.
+#		+ NO, No thread id to log file(s), Example filename 'Module.txt'.
+#
+#	- Will time stamps include the to log file.
+#		+ YES, Time stamp added to each line in log file(s). Time stamp is 
+#                 for example'12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No time stamp(s).
+#
+#	- Will line breaks include to the log file.
+#		+ YES, Each logging event includes line break and next log event is in own line.
+#		+ NO, No line break(s).
+#
+#	- Will event ranking include to the log file.
+#		+ YES, Event ranking number added to each line in log file(s). Ranking number
+#                 depends on environment's tics, for example(includes time stamp also)
+#                 '012   12.Nov.2003 115958    LOGGING INFO'
+#		+ NO, No event ranking.
+#
+#	- Will write log file in unicode format.
+#		+ YES, Log file will be written in unicode format
+#		+ NO, Log will be written as normal, not unicode, file.
+#
+
+[Logger_Defaults]
+
+#NOTE: If you want to set Logger using next setting(s) remove comment(s)'#'
+#NOTE: TestEngine and TestServer logging settings cannot change here
+
+#CreateLogDirectories= YES    # Possible values: YES or NO
+
+#EmulatorBasePath= C:\LOGS\TestFramework\
+#EmulatorFormat= HTML         # Possible values: TXT or HTML
+#EmulatorOutput= FILE         # Possible values: FILE or RDEBUG
+
+#HardwareBasePath= D:\LOGS\TestFramework\
+#HardwareFormat= HTML         # Possible values: TXT or HTML
+#HardwareOutput= FILE         # Possible values: FILE or RDEBUG
+
+#FileCreationMode= OVERWRITE  # Possible values: OVERWRITE or APPEND
+
+#ThreadIdToLogFile= YES       # Possible values: YES or NO
+#WithTimeStamp= YES           # Possible values: YES or NO
+#WithLineBreak= YES           # Possible values: YES or NO
+#WithEventRanking= YES        # Possible values: YES or NO
+
+#FileUnicode= YES             # Possible values: YES or NO
+#AddTestCaseTitle= YES        # Possible values: YES or NO
+[End_Logger_Defaults]
+# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+
+# End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:        ?Description
+*
+*/
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_TESTEXPORTS
+
+PRJ_EXPORTS
+// Static testcontent for BC tests
+../data/content-noenc-trunc.odf /epoc32/winscw/c/content-noenc-trunc.odf
+../data/content.odf /epoc32/winscw/c/content.odf
+../data/content.txt /epoc32/winscw/c/content.txt
+../data/content-noenc.odf /epoc32/winscw/c/content-noenc.odf
+../data/content.dcf /epoc32/winscw/c/content.dcf
+
+drmcaf_z.bat		/epoc32/winscw/c/drmcaf_z.bat
+drmcaf_c.bat		/epoc32/winscw/c/drmcaf_c.bat
+drm_caf.cfg         /epoc32/winscw/c/testframework/drm_caf.cfg
+testframework.ini   /epoc32/winscw/c/testframework/testframework_drmcaf.ini
+
+PRJ_TESTMMPFILES
+
+PRJ_MMPFILES
+drm_caf.mmp
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/drmcaf_c.bat	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,23 @@
+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
+
+copy C:\TestFramework\TestFramework_DRMCAF.ini C:\TestFramework\TestFramework.ini
+md e:\BCTest
+md e:\BCTest\Results
+
+ATSINTERFACE.EXE -testmodule testscripter -config C:\TestFramework\DRM_CAF.cfg
+copy c:\Logs\TestFramework\TestReport.txt e:\BCTest\results\DRM_CAF.txt
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/group/drmcaf_z.bat	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+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
+
+copy z:\TestFramework\TestFramework_DRMCAF.ini C:\TestFramework\TestFramework.ini
+md e:\BCTest
+md e:\BCTest\Results
+
+ATSINTERFACE.EXE -testmodule testscripter -config C:\TestFramework\DRMCAF.cfg
+copy c:\Logs\TestFramework\TestReport.txt e:\BCTest\results\DRM_CAF.txt
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/inc/DRM_CAF.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,212 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+
+
+
+
+
+#ifndef DRM_CAF_H
+#define DRM_CAF_H
+
+//  INCLUDES
+#include <StifLogger.h>
+#include <TestScripterInternal.h>
+#include <StifTestModule.h>
+#include <TestclassAssert.h>
+
+
+#include <f32file.h>
+#include <e32test.h>
+#include <s32file.h>
+#include <e32std.h>
+#include <e32base.h>
+#include <data.h>
+//#include <caf.h>
+
+#include <Oma2Agent.h>
+#include <DRMLicenseChecker.h>
+
+
+
+// MACROS
+#define TEST_CLASS_VERSION_MAJOR 51
+#define TEST_CLASS_VERSION_MINOR 9
+#define TEST_CLASS_VERSION_BUILD 38
+
+
+// Logging path
+_LIT( KDRM_CAFLogPath, "\\logs\\testframework\\DRM_CAF\\" );
+// Log file
+_LIT( KDRM_CAFLogFile, "DRM_CAF.txt" );
+_LIT( KDRM_CAFLogFileWithTitle, "DRM_CAF_[%S].txt" );
+
+
+// FORWARD DECLARATIONS
+class CDRM_CAF;
+
+// CLASS DECLARATION
+
+/**
+*  CDRM_CAF test class for STIF Test Framework TestScripter.
+*/
+NONSHARABLE_CLASS(CDRM_CAF) : public CScriptBase
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CDRM_CAF* NewL( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CDRM_CAF();
+
+    public: // Functions from base classes
+
+        /**
+        * From CScriptBase Runs a script line.
+        * @param aItem Script line containing method name and parameters
+        * @return Symbian OS error code
+        */
+        virtual TInt RunMethodL( CStifItemParser& aItem );
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDRM_CAF( CTestModuleIf& aTestModuleIf );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Frees all resources allocated from test methods.
+        */
+        void Delete();
+
+
+        /**
+        * Test methods are listed below.
+        */
+
+        /**
+        *
+        * @param aItem Script line containing parameters.
+        * @return Symbian OS error code.
+        */
+        virtual TInt CSupplier_Oma1XmlRoL();
+
+        virtual TInt CSupplier_Oma1WbxmlRoL();
+
+        virtual TInt CData_NewL();
+
+        virtual TInt CData_Read_DataSize_SeekL();
+
+        virtual TInt CData_Read2L();
+        virtual TInt CData_SetPropertyL();
+        virtual TInt CData_EvaluateIntentL();
+        virtual TInt CData_ExecuteIntentL();
+        virtual TInt CData_GetAttributeL();
+        virtual TInt CData_GetAttributeSetL();
+        virtual TInt CData_GetStringAttributeL();
+        virtual TInt CData_GetStringAttributeSetL();
+        virtual TInt CContent_NewL();
+        virtual TInt CContent_OpenCloseContainerL();
+        virtual TInt CContent_GetEmbeddedObjectsL();
+        virtual TInt CContent_SearchL();
+        virtual TInt CContent_GetAttributeL();
+        virtual TInt CContent_GetAttributeSetL();
+        virtual TInt CContent_GetStringAttributeL();
+        virtual TInt CContent_GetStringAttributeSetL();
+        virtual TInt CContent_AgentSpecificCommandL();
+        virtual TInt CContent_NotifyStatusChangeL();
+        virtual TInt CContent_CancelNotifyStatusChangeL();
+        virtual TInt CContent_RequestRightsL();
+        virtual TInt CContent_DisplayInfoL();
+        virtual TInt CContent_SetPropertyL();
+        virtual TInt CContent_OpenContentL();
+        virtual TInt CManager_FileOperationsL();
+        virtual TInt CManager_GetAttributeL();
+        virtual TInt CManager_GetAttributeSetL();
+        virtual TInt CManager_GetStringAttributeL();
+        virtual TInt CManager_GetStringAttributeSetL();
+        virtual TInt CManager_SetPropertyL();
+        virtual TInt CManager_DisplayInfoL();
+        virtual TInt CManager_ListAgentsL();
+        virtual TInt CManager_AgentSpecificCommandL();
+        virtual TInt CManager_CreateRightsManagerL();
+        virtual TInt CSupplier_IsImportSupportedL();
+        virtual TInt CSupplier_PrepareHTTPRequestHeadersL();
+        virtual TInt CSupplier_SetOutputDirectory_ImportFileL();
+        virtual TInt CImportFile_WriteData_WriteDataComplete_OutputFileCountL();
+        virtual TInt CImportFile_OutputFileL_GetImportStatusL();
+        virtual TInt CImportFile_GetSuggestedOutputFileExtensionL();
+        virtual TInt CImportFile_GetSuggestedOutputFileNameL();
+        virtual TInt CImportFile_ContinueWithNewOutputFileL();
+        virtual TInt CImportFile_ContentMimeTypeL();
+        virtual TInt CRightsManager_ListRightsL();
+        virtual TInt CRightsManager_ListAllRightsL();
+        virtual TInt CRightsManager_ListContentL();
+        virtual TInt CRightsManager_DeleteRightsObjectL();
+        virtual TInt CRightsManager_DeleteAllRightsObjectsL();
+        virtual TInt CRightsManager_SetPropertyL();
+        virtual TInt CDRMLicenseChecker_CheckLicenseL();
+
+        /**
+         * Method used to log version of test class
+         */
+        void SendTestClassVersion();
+
+        void CreateDirL();
+        //ADD NEW METHOD DEC HERE
+        //[TestMethods] - Do not remove
+
+    public:     // Data
+
+        // MODULE DATA STRUCTURES
+        TInt GLastOk;
+        TInt GAllocatedCount;
+        TInt GAllocatedSize;
+        RFs iFs;
+
+    private:    // Data
+
+
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+        //TInt GLastOk;
+        //TInt GAllocatedCount;
+        //TInt GAllocatedSize;
+
+       // TBool flvariant;
+
+       // RTest test;
+
+    };
+
+#endif      // DRM_CAF_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/src/DRM_CAF.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,211 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+
+
+
+
+
+// INCLUDE FILES
+#include <stiftestinterface.h>
+#include <settingserverclient.h>
+
+// INCLUDE FILES
+#include "drm_caf.h"
+
+
+
+
+_LIT( KDrmDir, "c:\\drm\\" );
+_LIT( KMessagesDir, "c:\\drm\\messages\\");
+_LIT(KEncryptedDir, "c:\\");
+_LIT(KDecryptedDir, "c:\\");
+_LIT( KFilesDir, "c:\\drm\\messages\\files\\");
+_LIT(KRightsDir, "c:\\");
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRM_CAF::CDRM_CAF
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRM_CAF::CDRM_CAF(
+    CTestModuleIf& aTestModuleIf ):
+        CScriptBase( aTestModuleIf )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRM_CAF::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRM_CAF::ConstructL()
+    {
+    //Read logger settings to check whether test case name is to be
+    //appended to log file name.
+    User::LeaveIfError( iFs.Connect() );
+   // CleanupClosePushL( iFs );
+
+    CreateDirL();
+    RSettingServer settingServer;
+    TInt ret = settingServer.Connect();
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        }
+    // Struct to StifLogger settigs.
+    TLoggerSettings loggerSettings;
+    // Parse StifLogger defaults from STIF initialization file.
+    ret = settingServer.GetLoggerSettings(loggerSettings);
+    if(ret != KErrNone)
+        {
+        User::Leave(ret);
+        }
+    // Close Setting server session
+    settingServer.Close();
+
+    TFileName logFileName;
+
+    if(loggerSettings.iAddTestCaseTitle)
+        {
+        TName title;
+        TestModuleIf().GetTestCaseTitleL(title);
+        logFileName.Format(KDRM_CAFLogFileWithTitle, &title);
+        }
+    else
+        {
+        logFileName.Copy(KDRM_CAFLogFile);
+        }
+
+    iLog = CStifLogger::NewL( KDRM_CAFLogPath,
+                          logFileName,
+                          CStifLogger::ETxt,
+                          CStifLogger::EFile,
+                          EFalse );
+
+    SendTestClassVersion();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRM_CAF::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRM_CAF* CDRM_CAF::NewL(
+    CTestModuleIf& aTestModuleIf )
+    {
+    CDRM_CAF* self = new (ELeave) CDRM_CAF( aTestModuleIf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+
+    }
+
+// Destructor
+CDRM_CAF::~CDRM_CAF()
+    {
+    // Delete resources allocated from test methods
+    Delete();
+    iFs.Close();
+
+    // Delete logger
+    delete iLog;
+
+    }
+
+//-----------------------------------------------------------------------------
+// CDRM_CAF::SendTestClassVersion
+// Method used to send version of test class
+//-----------------------------------------------------------------------------
+//
+void CDRM_CAF::SendTestClassVersion()
+	{
+	TVersion moduleVersion;
+	moduleVersion.iMajor = TEST_CLASS_VERSION_MAJOR;
+	moduleVersion.iMinor = TEST_CLASS_VERSION_MINOR;
+	moduleVersion.iBuild = TEST_CLASS_VERSION_BUILD;
+
+	TFileName moduleName;
+	moduleName = _L("DRM_CAF.dll");
+
+	TBool newVersionOfMethod = ETrue;
+	TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod);
+	TestModuleIf().SetBehavior(CTestModuleIf::ETestLeaksHandles);
+	}
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// LibEntryL is a polymorphic Dll entry point.
+// Returns: CScriptBase: New CScriptBase derived object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CScriptBase* LibEntryL(CTestModuleIf& aTestModuleIf ) // Backpointer to STIF Test Framework
+    {
+
+    return ( CScriptBase* ) CDRM_CAF::NewL( aTestModuleIf );
+
+    }
+void CDRM_CAF::CreateDirL()
+    {
+    TInt error = iFs.MkDir(KDrmDir);
+    if (error == KErrAlreadyExists || error == KErrNone)
+        {
+        error = iFs.MkDir(KMessagesDir);
+        if (error == KErrAlreadyExists || error == KErrNone)
+            {
+            error = iFs.MkDir(KEncryptedDir);
+            }
+
+        if (error == KErrAlreadyExists || error == KErrNone)
+            {
+            error = iFs.MkDir(KFilesDir);
+            }
+
+        if (error == KErrAlreadyExists || error == KErrNone)
+            {
+            error = iFs.MkDir(KDecryptedDir);
+            }
+
+        if (error == KErrAlreadyExists || error == KErrNone)
+            {
+            error = iFs.MkDir(KRightsDir);
+            }
+
+        if (error != KErrAlreadyExists && error != KErrNone)
+            {
+            User::LeaveIfError(error);
+            }
+        }
+    else
+        {
+        User::LeaveIfError(error);
+        }
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/src/DRM_CAFBlocks.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,2712 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+
+
+
+
+
+
+// [INCLUDE FILES] - do not remove
+#include <e32svr.h>
+#include <StifParser.h>
+#include <Stiftestinterface.h>
+#include "DRM_CAF.h"
+#include <caf/caftypes.h>
+#include <caf/caf.h>
+#include <caf/data.h>
+#include <f32file.h>
+#include <bautils.h>
+#include <TestclassAssert.h>
+using namespace ContentAccess;
+// LOCAL CONSTANTS AND MACROS
+
+#define NUM_ELEMENTS(x) (sizeof(x) / sizeof(x[0]))
+
+const TInt KAttributes[] =
+    {
+    EIsProtected,
+    EIsForwardable,
+    EIsModifyable,
+    EIsCopyable,
+    ECanPlay,
+    ECanPrint,
+    ECanExecute,
+    ECanView,
+    ERightsNone,
+    ERightsPending,
+    ERightsHaveExpired,
+    EPreviewAvailable,
+    EContentCDataInUse,
+    ECanRewind,
+    ECopyPaste,
+    ERightsConsumable,
+    ERightsStateless,
+    ECanMove,
+    ECanRename,
+    ECanAutomaticConsume,
+    EFileType,
+    EPreviewType,
+    ESilentRightsType
+    };
+
+const TInt KStringAttributes[] =
+    {
+    EEmbeddedRightsObject,
+    EDomainRightsIssuerUrl,
+    EDescription,
+    EMimeType,
+    ETitle,
+    EAuthor,
+    EIconURI,
+    EPreviewURI,
+    EContentURI,
+    EContentID,
+    EInfoURL,
+    EPendingRightsETA,
+    EInstantPreviewUri,
+    EPreviewRightsUri,
+    ERightsIssuerUrl,
+    ESilentRightsUrl,
+    ETransactionTrackingId,
+    };
+
+// Test logging macros(we only want line numbers)
+//#undef test
+//#undef __test
+
+//#define __test(x, l) test(x, l)
+//#define test(x) __test(x, __LINE__)
+
+//#define FuncCount( a ) ( sizeof( a ) / sizeof( TBatTestFunc ) )
+
+
+
+#define RUNCHECKED(function) \
+    { \
+    TInt c = function; \
+    if (c != KErrNone) \
+        { \
+        STIF_ASSERT_TRUE(c); \
+        } \
+    else \
+        { \
+        GLastOk = __LINE__;\
+        } \
+    }
+
+#define RUNCHECKEDL(function) \
+    { \
+    TInt c = function; \
+    if (c != KErrNone) \
+        { \
+        STIF_ASSERT_TRUE(c); \
+        User::Leave(c); \
+        } \
+    else \
+        { \
+        GLastOk = __LINE__;\
+          } \
+    }
+
+
+#define RUN_TRAPPED(r, function) \
+    { \
+    r = KErrNone; TRAP(r, function); \
+    STIF_ASSERT_EQUALS( KErrNone, r )\
+    }
+
+//RTest test(_L("c:\\OMADRM2BC.log"));
+//#if 0
+//RTest test(_L("c:\\OMADRM2BC.log"));
+//TInt GLastOk;
+//TInt GAllocatedCount;
+//TInt GAllocatedSize;
+
+//TBool flvariant;
+//#endif
+
+_LIT8(KROSimple, "<o-ex:rights xmlns:o-ex = \"http://odrl.net/1.1/ODRL-EX\" \
+xmlns:o-dd = \"http://odrl.net/1.1/ODRL-DD\" \
+xmlns:ds = \"http://www.w3.org/2000/09/xmldsig#/\">\
+<o-ex:context><o-dd:version>1.0</o-dd:version></o-ex:context>\
+<o-ex:agreement><o-ex:asset><o-ex:context>\
+<o-dd:uid>cid:9999</o-dd:uid></o-ex:context></o-ex:asset><o-ex:permission>\
+<o-dd:display/><o-dd:play/><o-dd:execute/><o-dd:print/>\
+</o-ex:permission></o-ex:agreement></o-ex:rights>");
+
+_LIT8(KDRCSimple,
+"\003\016\152\000\305\005\205\006\206\007\207\001\106\107\003\061\056\060\000\001\
+\001\111\112\106\110\003\143\151\144\072\062\060\060\063\060\064\062\071\061\062\
+\060\067\065\063\055\063\064\064\067\060\071\066\063\066\060\100\167\167\167\056\
+\147\157\157\147\154\145\056\143\157\155\000\001\001\113\114\303\020\063\323\173\
+\130\367\145\145\367\077\137\105\057\120\076\265\377\001\001\001\115\116\122\123\
+\003\065\000\001\001\001\117\122\124\125\003\062\060\060\063\055\060\064\055\062\
+\071\124\061\062\072\060\064\072\064\067\000\001\126\003\062\060\060\063\055\060\
+\065\055\062\061\124\061\062\072\060\064\072\064\067\000\001\001\001\001\001\001\
+\001");
+_LIT8(KDMHead, "--boundary-1\r\nContent-Type: text/plain\r\n\
+Content-Transfer-Encoding: 8bit\r\n\
+\r\n");
+
+_LIT8(KDMTail, "\r\n--boundary-1--");
+
+_LIT8(KDMContent, "0123456789");
+
+
+_LIT8(KDMSimple, "--boundary-1\r\nContent-Type: text/plain\r\n\
+Content-Transfer-Encoding: 8bit\r\n\
+\r\n\
+012345678911234567892123456789312345678941234567895123456789\
+612345678971234567898123456789912345678901234567891123456789\
+212345678931234567894123456789512345678961234567897123456789\
+812345678991234567890123456789112345678921234567893123456789\
+412345678951234567896123456789712345678981234567899123456789\
+\r\n--boundary-1--\r\n");
+
+_LIT8(KDMCDCount, "--random78o6bP%[GB6b/8&/45&%*^'?vS\r\n\
+Content-Type: application/vnd.oma.drm.rights+xml\r\n\
+Content-Transfer-Encoding: binary\r\n\
+\r\n\
+<o-ex:rights\
+   xmlns:o-ex=\"http://odrl.net/1.1/ODRL-EX\"\
+   xmlns:o-dd=\"http://odrl.net/1.1/ODRL-DD\"\
+   xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#/\"\
+>\
+<o-ex:context><o-dd:version>1.0</o-dd:version>\
+</o-ex:context><o-ex:agreement><o-ex:asset>\
+<o-ex:context><o-dd:uid>cid:20031217123451-8428794033@www.nokia.com</o-dd:uid>\
+</o-ex:context></o-ex:asset>\
+<o-ex:permission>\
+<o-dd:display>\
+<o-ex:constraint>\
+<o-dd:count>3</o-dd:count>\
+</o-ex:constraint>\
+</o-dd:display>\
+<o-dd:display>\
+</o-ex:permission>\
+</o-ex:agreement>\
+</o-ex:rights>\r\n\
+\r\n\
+--random78o6bP%[GB6b/8&/45&%*^'?vS\r\n\
+Content-Type: text/plain\r\n\
+Content-ID: <20031217123451-8428794033@www.nokia.com>\r\n\
+Content-Transfer-Encoding: binary\r\n\
+\r\n\
+Check:\r\n\
+DbCnt: 109ms r:0\r\n\
+Fixes:\r\n\
+\r\n\
+--random78o6bP%[GB6b/8&/45&%*^'?vS--");
+
+_LIT(KOma1Content, "c:\\content.dcf");
+_LIT(KOma2Content, "c:\\content.odf");
+_LIT(KOma2ContentNoEnc, "c:\\content-noenc.odf");
+_LIT(KOma2ContentNoEncTruncated, "c:\\content-noenc-trunc.odf");
+
+_LIT(KEncryptedDir, "c:\\");
+_LIT(KTempDcfName, "test.dcf");
+_LIT(KTempDcfPathName, "c:\\test.dcf");
+_LIT(KFVariantFile,"c:\\DrmCAFVarFile.txt");
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+NONSHARABLE_CLASS( CActiveWaiter ): public CActive
+    {
+public:
+    static CActiveWaiter* NewL();
+
+    void StartWait();
+
+    TRequestStatus& GetStatus();
+
+    ~CActiveWaiter();
+protected:     // from CActive
+    /**
+    * part of active object framework, provide default implementation
+    */
+    void RunL();
+
+    /**
+    * part of active object framework, provide default implementation
+    */
+    void DoCancel();
+
+    /**
+    * part of active object framework, provide default implementation
+    */
+    TInt RunError(TInt aError);
+
+
+private:
+    CActiveWaiter();
+
+    void ConstructL();
+
+    CActiveSchedulerWait iWait;
+    };
+
+
+CActiveWaiter::CActiveWaiter() : CActive(EPriorityStandard)
+    {
+
+    }
+
+CActiveWaiter::~CActiveWaiter()
+    {
+    Deque();
+
+    if( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    }
+
+CActiveWaiter* CActiveWaiter::NewL() {
+    CActiveWaiter* self = new (ELeave) CActiveWaiter();
+    return self;
+}
+
+
+/**
+* part of active object framework, provide default implementation
+*/
+void CActiveWaiter::RunL() {
+    iWait.AsyncStop();
+}
+
+/**
+* part of active object framework, provide default implementation
+*/
+void CActiveWaiter::DoCancel(){
+}
+
+/**
+* part of active object framework, provide default implementation
+*/
+TInt CActiveWaiter::RunError(TInt /*aError*/){
+    return KErrNone;
+}
+
+void CActiveWaiter::StartWait() {
+    if(!IsAdded())
+        {
+        CActiveScheduler::Add(this);
+        }
+    if(!IsActive())
+        {
+        SetActive();
+        }
+
+    iStatus = KRequestPending;
+
+    iWait.Start();
+}
+
+TRequestStatus& CActiveWaiter::GetStatus()
+    {
+    return iStatus;
+    }
+
+
+
+LOCAL_C CRightsManager* GetOmaDrmRightsManagerL()
+    {
+    RArray<TAgent> agents;
+    CRightsManager* rm = NULL;
+    TInt i;
+    TInt r;
+
+    CManager* manager = CManager::NewLC();
+    //STIF_ASSERT_NOT_NULL( manager );
+    manager->ListAgentsL(agents);
+    for (i = 0; rm == NULL && i < agents.Count(); i++)
+        {
+        if (agents[i].Name().Compare(KOmaDrm2AgentName) == 0)
+            {
+            TRAP(r, rm = manager->CreateRightsManagerL(agents[i]));
+            }
+        }
+    agents.Close();
+    CleanupStack::PopAndDestroy();
+    return rm;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRM_CAF::Delete
+// Delete here all resources allocated and opened from test methods.
+// Called from destructor.
+// -----------------------------------------------------------------------------
+//
+void CDRM_CAF::Delete()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDRM_CAF::RunMethodL
+// Run specified method. Contains also table of test mothods and their names.
+// -----------------------------------------------------------------------------
+//
+TInt CDRM_CAF::RunMethodL(
+    CStifItemParser& aItem )
+    {
+
+    	TStifFunctionInfo const KFunctions[] =
+        {
+        // Copy this line for every implemented function.
+        // First string is the function name used in TestScripter script file.
+        // Second is the actual implementation member function.
+        ENTRY( "CSupplier_Oma1XmlRoL", CDRM_CAF::CSupplier_Oma1XmlRoL ),
+        ENTRY( "CSupplier_Oma1WbxmlRoL", CDRM_CAF::CSupplier_Oma1WbxmlRoL ),
+        ENTRY( "CData_NewL", CDRM_CAF::CData_NewL ),
+        ENTRY( "CData_Read_DataSize_SeekL", CDRM_CAF::CData_Read_DataSize_SeekL ),
+        ENTRY( "CData_Read2L", CDRM_CAF::CData_Read2L ),
+        ENTRY( "CData_SetPropertyL", CDRM_CAF::CData_SetPropertyL ),
+        ENTRY( "CData_EvaluateIntentL", CDRM_CAF::CData_EvaluateIntentL ),
+        ENTRY( "CData_ExecuteIntentL", CDRM_CAF::CData_ExecuteIntentL ),
+        ENTRY( "CData_GetAttributeL", CDRM_CAF::CData_GetAttributeL ),
+        ENTRY( "CData_GetAttributeSetL", CDRM_CAF::CData_GetAttributeSetL ),
+        ENTRY( "CData_GetStringAttributeL", CDRM_CAF::CData_GetStringAttributeL ),
+        ENTRY( "CData_GetStringAttributeSetL", CDRM_CAF::CData_GetStringAttributeSetL ),
+        ENTRY( "CContent_NewL", CDRM_CAF::CContent_NewL ),
+        ENTRY( "CContent_OpenCloseContainerL", CDRM_CAF::CContent_OpenCloseContainerL ),
+        ENTRY( "CContent_GetEmbeddedObjectsL", CDRM_CAF::CContent_GetEmbeddedObjectsL ),
+        ENTRY( "CContent_SearchL", CDRM_CAF::CContent_SearchL ),
+        ENTRY( "CContent_GetAttributeL", CDRM_CAF::CContent_GetAttributeL ),
+        ENTRY( "CContent_GetAttributeSetL", CDRM_CAF::CContent_GetAttributeSetL ),
+        ENTRY( "CContent_GetStringAttributeL", CDRM_CAF::CContent_GetStringAttributeL ),
+        ENTRY( "CContent_GetStringAttributeSetL", CDRM_CAF::CContent_GetStringAttributeL ),
+        ENTRY( "CContent_AgentSpecificCommandL", CDRM_CAF::CContent_AgentSpecificCommandL ),
+        ENTRY( "CContent_NotifyStatusChangeL", CDRM_CAF::CContent_NotifyStatusChangeL ),
+        ENTRY( "CContent_CancelNotifyStatusChangeL", CDRM_CAF::CContent_CancelNotifyStatusChangeL ),
+        ENTRY( "CContent_RequestRightsL", CDRM_CAF::CContent_RequestRightsL ),
+        ENTRY( "CContent_DisplayInfoL", CDRM_CAF::CContent_DisplayInfoL ),
+        ENTRY( "CContent_SetPropertyL", CDRM_CAF::CContent_SetPropertyL ),
+        ENTRY( "CContent_OpenContentL", CDRM_CAF::CContent_OpenContentL ),
+        ENTRY( "CManager_FileOperationsL", CDRM_CAF::CManager_FileOperationsL ),
+        ENTRY( "CManager_GetAttributeL", CDRM_CAF::CManager_GetAttributeL ),
+        ENTRY( "CManager_GetAttributeSetL", CDRM_CAF::CManager_GetAttributeSetL ),
+        ENTRY( "CManager_GetStringAttributeL", CDRM_CAF::CManager_GetStringAttributeL ),
+        ENTRY( "CManager_GetStringAttributeSetL", CDRM_CAF::CManager_GetStringAttributeSetL ),
+        ENTRY( "CManager_SetPropertyL", CDRM_CAF::CManager_SetPropertyL ),
+        ENTRY( "CManager_DisplayInfoL", CDRM_CAF::CManager_DisplayInfoL ),
+        ENTRY( "CManager_ListAgentsL", CDRM_CAF::CManager_ListAgentsL ),
+        ENTRY( "CManager_AgentSpecificCommandL", CDRM_CAF::CManager_AgentSpecificCommandL ),
+        ENTRY( "CManager_CreateRightsManagerL", CDRM_CAF::CManager_CreateRightsManagerL ),
+        ENTRY( "CSupplier_IsImportSupportedL", CDRM_CAF::CSupplier_IsImportSupportedL ),
+        ENTRY( "CSupplier_PrepareHTTPRequestHeadersL", CDRM_CAF::CSupplier_PrepareHTTPRequestHeadersL ),
+        ENTRY( "CSupplier_SetOutputDirectory_ImportFileL", CDRM_CAF::CSupplier_SetOutputDirectory_ImportFileL ),
+        ENTRY( "CImportFile_WriteData_WriteDataComplete_OutputFileCountL", CDRM_CAF::CImportFile_WriteData_WriteDataComplete_OutputFileCountL ),
+        ENTRY( "CImportFile_OutputFileL_GetImportStatusL", CDRM_CAF::CImportFile_OutputFileL_GetImportStatusL ),
+        ENTRY( "CImportFile_GetSuggestedOutputFileExtensionL", CDRM_CAF::CImportFile_GetSuggestedOutputFileExtensionL ),
+        ENTRY( "CImportFile_GetSuggestedOutputFileNameL", CDRM_CAF::CImportFile_GetSuggestedOutputFileNameL ),
+        ENTRY( "CImportFile_ContinueWithNewOutputFileL", CDRM_CAF::CImportFile_ContinueWithNewOutputFileL ),
+        ENTRY( "CImportFile_ContentMimeTypeL", CDRM_CAF::CImportFile_ContentMimeTypeL ),
+        ENTRY( "CRightsManager_ListRightsL", CDRM_CAF::CRightsManager_ListRightsL ),
+        ENTRY( "CRightsManager_ListAllRightsL", CDRM_CAF::CRightsManager_ListAllRightsL ),
+        ENTRY( "CRightsManager_ListContentL", CDRM_CAF::CRightsManager_ListContentL ),
+        ENTRY( "CRightsManager_DeleteRightsObjectL", CDRM_CAF::CRightsManager_DeleteRightsObjectL ),
+        ENTRY( "CRightsManager_DeleteAllRightsObjectsL", CDRM_CAF::CRightsManager_DeleteAllRightsObjectsL ),
+        ENTRY( "CRightsManager_SetPropertyL", CDRM_CAF::CRightsManager_SetPropertyL ),
+        ENTRY( "CDRMLicenseChecker_CheckLicenseL", CDRM_CAF::CDRMLicenseChecker_CheckLicenseL ),
+
+        //ADD NEW ENTRY HERE
+        // [test cases entries] - Do not remove
+
+        };
+
+    const TInt count = sizeof( KFunctions ) /
+                        sizeof( TStifFunctionInfo );
+
+    return RunInternalL( KFunctions, count, aItem );
+
+    }
+
+TInt CDRM_CAF::CSupplier_Oma1XmlRoL()
+    {
+
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    CImportFile* file = supplier->ImportFileL(KOma1XmlRoContentType,
+        *metaData);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    RUNCHECKEDL(file->WriteData(KROSimple));
+    RUNCHECKEDL(file->WriteDataComplete());
+    CleanupStack::PopAndDestroy(3);
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CSupplier_Oma1WbxmlRoL()
+    {
+
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    CImportFile* file = supplier->ImportFileL(KOma1WbxmlRoContentType,
+        *metaData);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    RUNCHECKEDL(file->WriteData(KDRCSimple));
+    RUNCHECKEDL(file->WriteDataComplete());
+    CleanupStack::PopAndDestroy(3);
+
+    return KErrNone;
+    }
+
+
+TInt CDRM_CAF::CData_NewL()
+    {
+    CData* data;
+    RFile file;
+
+    TVirtualPathPtr dcf1(KOma1Content, KDefaultContentObject);
+    TVirtualPathPtr dcf2(KOma2Content, KDefaultContentObject);
+    TVirtualPathPtr dcf3(KOma2ContentNoEnc, KDefaultContentObject);
+
+
+    data = CData::NewL(dcf1, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    delete data;
+
+
+
+    data = CData::NewL(dcf2, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    delete data;
+
+
+
+    data = CData::NewL(dcf3, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    delete data;
+
+
+
+    TInt err = file.Open(iFs, KOma1Content, EFileRead);
+    CleanupClosePushL(file);
+    data = CData::NewL(file, KDefaultContentObject, EPeek);
+    STIF_ASSERT_NOT_NULL( data );
+    delete data;
+    CleanupStack::PopAndDestroy();
+
+
+
+    err = file.Open(iFs, KOma2Content, EFileRead);
+    CleanupClosePushL(file);
+    data = CData::NewL(file, KDefaultContentObject, EPeek);
+    STIF_ASSERT_NOT_NULL( data );
+    delete data;
+    CleanupStack::PopAndDestroy();
+
+
+
+    err = file.Open(iFs, KOma2ContentNoEnc, EFileRead);
+    CleanupClosePushL(file);
+    data = CData::NewL(file, KDefaultContentObject, EPeek);
+    STIF_ASSERT_NOT_NULL( data );
+    delete data;
+    CleanupStack::PopAndDestroy();
+
+
+
+    err = file.Open(iFs, KOma2ContentNoEncTruncated, EFileRead);
+    CleanupClosePushL(file);
+    data = CData::NewL(file, KDefaultContentObject, EPeek);
+    STIF_ASSERT_NOT_NULL( data );
+    delete data;
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CData_Read_DataSize_SeekL()
+    {
+    CData* data = NULL;
+    TFileName fileName;
+    TBuf8<256> buffer;
+    TInt size;
+    TInt pos;
+    TInt64 size64;
+    TInt64 pos64;
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+    TRequestStatus status;
+    CActiveWaiter* waiter = CActiveWaiter::NewL();
+    CleanupStack::PushL(waiter);
+
+    TVirtualPathPtr dcf1(fileName, KDefaultContentObject);
+    TVirtualPathPtr dcf2(KOma2ContentNoEncTruncated, KDefaultContentObject);
+    TVirtualPathPtr dcf3(KOma2ContentNoEnc, KDefaultContentObject);
+
+
+    iFs.Delete(fileName);
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    CImportFile* file = supplier->ImportFileL(KOma1DrmMessageContentType,
+        *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    RUNCHECKEDL(file->WriteData(KDMSimple));
+    RUNCHECKEDL(file->WriteDataComplete());
+    STIF_ASSERT_EQUALS( 1, file->OutputFileCountL() );
+    CleanupStack::PopAndDestroy(3);
+
+
+
+    data = CData::NewLC(dcf1, EView, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    data->DataSizeL(size);
+    STIF_ASSERT_EQUALS( 300, size );
+
+    STIF_ASSERT_EQUALS( KErrAccessDenied, data->Read(buffer, 10) ); // Cannot decrypt with SDK
+    CleanupStack::PopAndDestroy( data );
+
+
+
+    data = CData::NewLC(dcf2, EPlay, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    data->DataSizeL(size);
+    CleanupStack::PopAndDestroy( data );
+
+
+
+    data = CData::NewLC(dcf3, EPlay, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    data->DataSizeL(size);
+
+    RUNCHECKED(data->ExecuteIntent(EPlay));
+    RUNCHECKED(data->Read(buffer, 8));
+    STIF_ASSERT_EQUALS( 0, buffer.Compare(_L8("34567890")));
+    pos = 100;
+    RUNCHECKED(data->Seek(ESeekStart, pos));
+
+    data->Read(buffer, 8, status);
+    User::WaitForRequest(status);
+
+    STIF_ASSERT_EQUALS( 0, buffer.Compare(_L8("00000000")));
+    data->Read(buffer, status);
+    User::WaitForRequest(status);
+
+    CleanupStack::PopAndDestroy( data );
+
+    data = CData::NewLC(dcf3, EPlay, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    data->DataSize64L(size64);
+
+    RUNCHECKED(data->ExecuteIntent(EPlay));
+    pos64 = 100;
+    RUNCHECKED(data->Seek64(ESeekStart, pos64));
+
+    data->Read(pos64, buffer, 8, waiter->GetStatus());
+    waiter->StartWait();
+
+    STIF_ASSERT_EQUALS( 0, buffer.Compare(_L8("00000000")));
+
+    CleanupStack::PopAndDestroy( data );
+    CleanupStack::PopAndDestroy( waiter );
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CData_Read2L()
+    {
+    CData* data = NULL;
+    TFileName fileName;
+    TBuf8<256> buffer;
+    TInt size;
+    TInt pos;
+    TInt r;
+    CSupplier* supplier = NULL;
+    CMetaDataArray* metaData = NULL;
+    CImportFile* file = NULL;
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+
+    TVirtualPathPtr dcf1(fileName, KDefaultContentObject);
+    TVirtualPathPtr dcf2(KOma2ContentNoEncTruncated, KDefaultContentObject);
+    TVirtualPathPtr dcf3(KOma2ContentNoEnc, KDefaultContentObject);
+
+
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS( KErrNone, r);
+    supplier = CSupplier::NewLC();
+    metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    file = supplier->ImportFileL(KOma1DrmMessageContentType,
+        *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    RUNCHECKEDL(file->WriteData(KDMHead));
+    for (pos = 0; pos < 500; pos++)
+        {
+        file->WriteData(KDMContent);
+        }
+    RUNCHECKEDL(file->WriteData(KDMTail));
+    RUNCHECKEDL(file->WriteDataComplete());
+    STIF_ASSERT_EQUALS( 1, file->OutputFileCountL());
+    CleanupStack::PopAndDestroy(3);
+
+
+
+    data = CData::NewLC(dcf1, EView, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    data->DataSizeL(size);
+    STIF_ASSERT_EQUALS( 5000, size);
+    STIF_ASSERT_EQUALS( KErrAccessDenied, data->ExecuteIntent(EView) ); // Cannot decrypt with SDK
+    //STIF_ASSERT_EQUALS( KErrNone, data->ExecuteIntent(EView) ); // we can decrypt just fine, it's omadrm1 content nokia VID
+    CleanupStack::PopAndDestroy(); // data
+
+
+
+    data = CData::NewLC(dcf1, EView, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    data->DataSizeL(size);
+    STIF_ASSERT_EQUALS( 5000, size);
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+TInt CDRM_CAF::CData_SetPropertyL()
+    {
+    CData* data;
+    TInt r;
+    TBool r1 = EFalse;
+
+    TVirtualPathPtr dcf2(KOma2Content, KDefaultContentObject);
+
+
+    data = CData::NewLC(dcf2, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    r = data->SetProperty(EAgentPropertyBufferSize, 1024);
+    if(r == KErrCANotSupported || r == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    r1 = EFalse;
+    r = data->SetProperty(EAgentPropertyAgentUI, 1);
+    if(r == KErrCANotSupported || r == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    r1 = EFalse;
+    r = data->SetProperty(EAgentPropertyMultipleSequence, 1);
+    if(r == KErrCANotSupported || r == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CData_EvaluateIntentL()
+    {
+    TFileName fileName;
+    TInt r;
+    TBool r1 = EFalse;
+    TInt i;
+
+
+    fileName.Copy(KFVariantFile);
+    // Clearing file before first testcase
+    iFs.Delete(fileName);
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS( KErrNone, r);
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    CImportFile* file = supplier->ImportFileL(KOma1DrmMessageContentType,
+        *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    r = file->WriteData(KDMCDCount);
+    if (r == KErrNotSupported)
+    {
+        // Forward lock variant
+        RFileWriteStream outFlV;
+        outFlV.Create(iFs, KFVariantFile, EFileWrite );
+        outFlV.Close();
+        CleanupStack::PopAndDestroy(3);
+        return KErrNone;
+    }
+    RUNCHECKEDL(file->WriteDataComplete());
+    STIF_ASSERT_EQUALS( 1, file->OutputFileCountL());
+    CleanupStack::PopAndDestroy(3);
+
+
+
+    TVirtualPathPtr dcf(fileName, KDefaultContentObject);
+    CData* data = CData::NewLC(dcf, EView, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    r = data->EvaluateIntent(EView);
+    STIF_ASSERT_EQUALS( KErrNone, r);
+    r = data->EvaluateIntent(EPause);
+    STIF_ASSERT_EQUALS( KErrNone, r);
+    r = data->EvaluateIntent(EContinue);
+    STIF_ASSERT_EQUALS( KErrNone, r);
+    r = data->EvaluateIntent(EStop);
+    STIF_ASSERT_EQUALS( KErrNone, r);
+    r = data->EvaluateIntent(EPeek);
+    STIF_ASSERT_EQUALS( KErrNone, r);
+    r = data->EvaluateIntent(EInstall);
+    STIF_ASSERT_EQUALS( KErrNone, r);
+    r = data->EvaluateIntent(EPlay);
+    STIF_ASSERT_EQUALS( KErrCANoPermission, r);
+    r = data->EvaluateIntent(EPrint);
+    STIF_ASSERT_EQUALS( KErrCANoPermission, r);
+    r = data->EvaluateIntent(EExecute);
+    STIF_ASSERT_EQUALS( KErrCANoPermission, r);
+    CleanupStack::PopAndDestroy();
+
+
+
+    data = CData::NewL(TVirtualPathPtr(KOma2ContentNoEnc, KDefaultContentObject),
+        EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    STIF_ASSERT_EQUALS( KErrNone, data->EvaluateIntent(EPlay));
+    STIF_ASSERT_NOT_EQUALS(KErrNone ,data->EvaluateIntent(EView) );
+    STIF_ASSERT_NOT_EQUALS(KErrNone ,data->EvaluateIntent(EPrint) );
+    STIF_ASSERT_NOT_EQUALS(KErrNone ,data->EvaluateIntent(EExecute) );
+    STIF_ASSERT_EQUALS(KErrNone ,data->EvaluateIntent(EPause) );
+    STIF_ASSERT_EQUALS(KErrNone ,data->EvaluateIntent(EStop) );
+    STIF_ASSERT_EQUALS(KErrNone ,data->EvaluateIntent(EContinue) );
+    delete data;
+
+
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS(KErrNone ,r);
+    supplier = CSupplier::NewLC();
+    metaData = CMetaDataArray::NewLC();
+    metaData->AddL(KOmaImportMimeTypeField, _L8("image/jpeg"));
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    file = supplier->ImportFileL(KOmaImportContentType, *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    for (i = 0; i < 10; i++)
+        {
+        RUNCHECKEDL(file->WriteData(KDMContent));
+        }
+    RUNCHECKEDL(file->WriteDataComplete());
+    STIF_ASSERT_EQUALS(1 ,file->OutputFileCountL());
+    CleanupStack::PopAndDestroy(3);
+
+
+
+    data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+        EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+
+    r = data->EvaluateIntent(EPlay);
+    iLog->Log(_L("    Evaluate intent returned: %d \r\n"), r);
+    STIF_ASSERT_NOT_EQUALS(KErrNone , r);
+
+
+    r = data->EvaluateIntent(EView);
+    iLog->Log(_L("    Evaluate intent returned: %d \r\n"), r);
+    if(r == -17452 || r == -17451 || r == 0)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    r1 = EFalse;
+    r = data->EvaluateIntent(EPrint);
+    iLog->Log(_L("    Evaluate intent returned: %d \r\n"), r);
+    if(r == -17452 || r == -17451 || r == 0)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+
+    r = data->EvaluateIntent(EExecute);
+    iLog->Log(_L("    Evaluate intent returned: %d \r\n"), r);
+    STIF_ASSERT_NOT_EQUALS(KErrNone , r);
+
+
+    delete data;
+
+
+
+    fileName.Copy(KEncryptedDir );
+    fileName.Append(KTempDcfName);
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS(KErrNone , r);
+    supplier = CSupplier::NewLC();
+    metaData = CMetaDataArray::NewLC();
+    metaData->AddL(KOmaImportMimeTypeField, _L8("audio/mpeg"));
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    file = supplier->ImportFileL(KOmaImportContentType, *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    for (i = 0; i < 10; i++)
+        {
+        RUNCHECKEDL(file->WriteData(KDMContent));
+        }
+    RUNCHECKEDL(file->WriteDataComplete());
+    STIF_ASSERT_EQUALS(1 , file->OutputFileCountL());
+    CleanupStack::PopAndDestroy(3);
+
+
+
+    data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+        EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    r1 = EFalse;
+    r = data->EvaluateIntent(EPlay);
+    iLog->Log(_L("    Evaluate intent returned: %d \r\n"), r);
+    if(r == -17452 || r == -17451 || r == 0)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+
+    STIF_ASSERT_NOT_EQUALS(KErrNone , data->EvaluateIntent(EView));
+    STIF_ASSERT_NOT_EQUALS(KErrNone , data->EvaluateIntent(EPrint));
+    STIF_ASSERT_NOT_EQUALS(KErrNone , data->EvaluateIntent(EExecute));
+    delete data;
+
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CData_ExecuteIntentL()
+    {
+    RFile fileFLV;
+
+    TInt err = fileFLV.Open(iFs,KFVariantFile, EFileRead);
+    if( err == 0 )
+    {
+        iLog->Log(_L("    Skipped in FL variant \r\n" ));
+        fileFLV.Close();
+        return KErrNone;
+    }
+    fileFLV.Close();
+
+    TFileName fileName;
+    TInt r;
+    TInt i;
+    TBool r1 = EFalse;
+
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS(KErrNone , r);
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    CImportFile* file = supplier->ImportFileL(KOma1DrmMessageContentType,
+        *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    RUNCHECKEDL(file->WriteData(KDMCDCount));
+    RUNCHECKEDL(file->WriteDataComplete());
+    STIF_ASSERT_EQUALS(1 , file->OutputFileCountL());
+    CleanupStack::PopAndDestroy(3);
+
+
+    // Start the tests
+
+    TVirtualPathPtr dcf(fileName, KDefaultContentObject);
+    CData* data = CData::NewLC(dcf, EView, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+
+
+     // illegal: let's start with EPause
+    r = data->ExecuteIntent(EPause);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrNotReady, r );
+
+    r = data->ExecuteIntent(EContinue);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrNotReady, r );
+
+    r = data->ExecuteIntent(EView);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrAccessDenied , r );
+
+    r = data->ExecuteIntent(EPause);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrNotReady , r);
+
+    r = data->ExecuteIntent(EContinue);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrNotReady, r);
+
+    r = data->ExecuteIntent(EStop);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrNone, r);
+
+    r = data->ExecuteIntent(EPeek);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrAccessDenied, r);
+
+    r = data->ExecuteIntent(EInstall);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrAccessDenied, r);
+
+    r = data->ExecuteIntent(EPlay);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrCANoPermission, r);
+
+    r = data->ExecuteIntent(EPrint);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrCANoPermission, r);
+
+    r = data->ExecuteIntent(EExecute);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrCANoPermission, r);
+
+    r = data->ExecuteIntent(EView);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    STIF_ASSERT_EQUALS( KErrAccessDenied, r);
+
+    CleanupStack::PopAndDestroy();
+
+
+
+    data = CData::NewL(TVirtualPathPtr(KOma2ContentNoEnc, KDefaultContentObject),
+        EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    STIF_ASSERT_EQUALS(KErrNone ,data->ExecuteIntent(EPlay) );
+    STIF_ASSERT_NOT_EQUALS(KErrNone ,data->ExecuteIntent(EView) );
+    STIF_ASSERT_NOT_EQUALS(KErrNone ,data->ExecuteIntent(EPrint) );
+    STIF_ASSERT_NOT_EQUALS(KErrNone ,data->ExecuteIntent(EExecute) );
+    STIF_ASSERT_EQUALS(KErrNone ,data->ExecuteIntent(EPause) );
+    STIF_ASSERT_EQUALS(KErrNone ,data->ExecuteIntent(EStop) );
+    STIF_ASSERT_EQUALS(KErrNone ,data->ExecuteIntent(EContinue) );
+    delete data;
+
+
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS(KErrNone ,r );
+    supplier = CSupplier::NewLC();
+    metaData = CMetaDataArray::NewLC();
+    metaData->AddL(KOmaImportMimeTypeField, _L8("image/jpeg"));
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    file = supplier->ImportFileL(KOmaImportContentType, *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    for (i = 0; i < 10; i++)
+        {
+        RUNCHECKEDL(file->WriteData(KDMContent));
+        }
+    RUNCHECKEDL(file->WriteDataComplete());
+    STIF_ASSERT_EQUALS(1 ,file->OutputFileCountL() );
+    CleanupStack::PopAndDestroy(3);
+
+
+
+    data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+        EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+
+    STIF_ASSERT_NOT_EQUALS( KErrNone, data->ExecuteIntent(EPlay));
+    r = data->ExecuteIntent(EView);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    if(r == -17452 || r == -17451 || r == -21 )
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+
+    r1 = EFalse;
+    r = data->ExecuteIntent(EPrint);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    if(r == -17452 || r == -17451 || r == -21 )
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+
+    STIF_ASSERT_NOT_EQUALS( KErrNone, data->ExecuteIntent(EExecute));
+    delete data;
+
+
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS( KErrNone, r);
+    supplier = CSupplier::NewLC();
+    metaData = CMetaDataArray::NewLC();
+    metaData->AddL(KOmaImportMimeTypeField, _L8("audio/mpeg"));
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    file = supplier->ImportFileL(KOmaImportContentType, *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    for (i = 0; i < 10; i++)
+        {
+        RUNCHECKEDL(file->WriteData(KDMContent));
+        }
+    RUNCHECKEDL(file->WriteDataComplete());
+    STIF_ASSERT_EQUALS( 1, file->OutputFileCountL());
+    CleanupStack::PopAndDestroy(3);
+
+
+
+    data = CData::NewL(TVirtualPathPtr(fileName, KDefaultContentObject),
+        EPeek, EContentShareReadOnly);
+
+    STIF_ASSERT_NOT_NULL( data );
+
+    r1 = EFalse;
+    r = data->ExecuteIntent(EPlay);
+    iLog->Log(_L("    Execute intent returned: %d \r\n"), r);
+    if(r == -17452 || r == -17451 || r == -21 )
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+
+    STIF_ASSERT_NOT_EQUALS( KErrNone, data->ExecuteIntent(EView));
+
+
+    STIF_ASSERT_NOT_EQUALS( KErrNone, data->ExecuteIntent(EPrint));
+
+
+    STIF_ASSERT_NOT_EQUALS( KErrNone, data->ExecuteIntent(EExecute));
+
+    delete data;
+
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CData_GetAttributeL()
+    {
+    CData* data = NULL;
+    TVirtualPathPtr dcf1(KOma1Content, KDefaultContentObject);
+    TVirtualPathPtr dcf2(KOma2Content, KDefaultContentObject);
+    TVirtualPathPtr dcf3(KOma2ContentNoEnc, KDefaultContentObject);
+    TInt value;
+    TInt i;
+
+
+    data = CData::NewLC(dcf1, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    RUNCHECKEDL(data->GetAttribute(EIsProtected, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    RUNCHECKEDL(data->GetAttribute(EFileType, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        data->GetAttribute(KAttributes[i], value);
+        }
+    CleanupStack::PopAndDestroy();
+
+
+
+    data = CData::NewLC(dcf2, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    RUNCHECKEDL(data->GetAttribute(EIsProtected, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    RUNCHECKEDL(data->GetAttribute(EFileType, value));
+    STIF_ASSERT_EQUALS( 2, value);
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        data->GetAttribute(KAttributes[i], value);
+        }
+    CleanupStack::PopAndDestroy();
+
+
+
+    data = CData::NewLC(dcf3, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    RUNCHECKEDL(data->GetAttribute(EIsProtected, value));
+    STIF_ASSERT_EQUALS( 0, value);
+    RUNCHECKEDL(data->GetAttribute(EFileType, value));
+    STIF_ASSERT_EQUALS( 2, value);
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        data->GetAttribute(KAttributes[i], value);
+        }
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CData_GetAttributeSetL()
+    {
+    CData* data = NULL;
+    TVirtualPathPtr dcf1(KOma1Content, KDefaultContentObject);
+    TVirtualPathPtr dcf2(KOma2Content, KDefaultContentObject);
+    RAttributeSet attributes;
+    TInt value;
+
+    attributes.AddL(EIsProtected);
+    attributes.AddL(EFileType);
+
+    data = CData::NewLC(dcf1, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    RUNCHECKEDL(data->GetAttributeSet(attributes));
+    RUNCHECKEDL(attributes.GetValue(EIsProtected, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    RUNCHECKED(attributes.GetValue(EFileType, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    CleanupStack::PopAndDestroy();
+
+
+
+    data = CData::NewLC(dcf2, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    RUNCHECKEDL(data->GetAttributeSet(attributes));
+    RUNCHECKEDL(attributes.GetValue(EIsProtected, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    RUNCHECKED(attributes.GetValue(EFileType, value));
+    STIF_ASSERT_EQUALS( 2, value);
+    CleanupStack::PopAndDestroy();
+
+    attributes.Close();
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CData_GetStringAttributeL()
+    {
+    TVirtualPathPtr dcf1(KOma1Content, KDefaultContentObject);
+    TVirtualPathPtr dcf2(KOma2Content, KDefaultContentObject);
+    TVirtualPathPtr dcf3(KOma2Content, KDefaultContentObject);
+    CData* data = NULL;
+    HBufC* buffer = HBufC::NewLC(256000);
+    TPtr value(NULL, 0);
+    TInt i;
+
+    value.Set(buffer->Des());
+
+    data = CData::NewLC(dcf1, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    RUNCHECKEDL(data->GetStringAttribute(EMimeType, value));
+    STIF_ASSERT_EQUALS( 0, value.Compare(_L("text/plain")));
+    for (i = 0; i < NUM_ELEMENTS(KStringAttributes); i++)
+        {
+        data->GetStringAttribute(KStringAttributes[i], value);
+        }
+    CleanupStack::PopAndDestroy();
+
+
+
+    data = CData::NewLC(dcf2, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    RUNCHECKEDL(data->GetStringAttribute(EMimeType, value));
+    STIF_ASSERT_EQUALS( 0, value.Compare(_L("audio/wav")));
+    for (i = 0; i < NUM_ELEMENTS(KStringAttributes); i++)
+        {
+        data->GetStringAttribute(KStringAttributes[i], value);
+        }
+    CleanupStack::PopAndDestroy();
+
+
+
+    data = CData::NewLC(dcf3, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    RUNCHECKEDL(data->GetStringAttribute(EMimeType, value));
+    STIF_ASSERT_EQUALS( 0, value.Compare(_L("audio/wav")));
+    for (i = 0; i < NUM_ELEMENTS(KStringAttributes); i++)
+        {
+        data->GetStringAttribute(KStringAttributes[i], value);
+        }
+    CleanupStack::PopAndDestroy();
+
+    CleanupStack::PopAndDestroy();
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CData_GetStringAttributeSetL()
+    {
+    RFile fileFLV;
+
+    TInt err = fileFLV.Open(iFs,KFVariantFile, EFileRead);
+    if( err == 0 )
+    {
+        iLog->Log(_L("    Skipped in FL variant \r\n" ));
+        fileFLV.Close();
+        return KErrNone;
+    }
+    fileFLV.Close();
+
+    TVirtualPathPtr dcf1(KOma1Content, KDefaultContentObject);
+    TVirtualPathPtr dcf2(KOma2Content, KDefaultContentObject);
+    CData* data = NULL;
+    RStringAttributeSet attributes;
+    HBufC* buffer = HBufC::NewLC(256000);
+    TPtr value(NULL, 0);
+    TBool r1 = EFalse;
+    value.Set(buffer->Des());
+    attributes.AddL(EMimeType);
+    attributes.AddL(ERightsIssuerUrl);
+    data = CData::NewLC(dcf1, EPeek, EContentShareReadOnly);
+    //CHECKL(data != NULL);
+    STIF_ASSERT_NOT_NULL( data );
+    RUNCHECKEDL(data->GetStringAttributeSet(attributes));
+    RUNCHECKEDL(attributes.GetValue(EMimeType, value));
+    STIF_ASSERT_EQUALS(0 , value.Compare(_L("text/plain")));
+    STIF_ASSERT_EQUALS(KErrCANotSupported , attributes.GetValue(ERightsIssuerUrl, value));
+    CleanupStack::PopAndDestroy();
+
+    data = CData::NewLC(dcf2, EPeek, EContentShareReadOnly);
+    STIF_ASSERT_NOT_NULL( data );
+    RUNCHECKEDL(data->GetStringAttributeSet(attributes));
+    RUNCHECKEDL(attributes.GetValue(EMimeType, value));
+    STIF_ASSERT_EQUALS( 0, value.Compare(_L("audio/wav")));
+    TInt rr = attributes.GetValue(ERightsIssuerUrl, value);
+    if(rr == KErrCANotSupported || rr == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    r1 = EFalse;
+    if(value.Length() > 0)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    CleanupStack::PopAndDestroy();
+    CleanupStack::PopAndDestroy();
+    attributes.Close();
+    return KErrNone;
+    }
+TInt  CDRM_CAF::CContent_NewL()
+    {
+    CContent* content = NULL;
+    RFile file;
+
+
+    content = CContent::NewL(KOma1Content);
+    STIF_ASSERT_NOT_NULL( content );
+    delete content;
+
+
+
+    content = CContent::NewL(KOma2Content);
+    STIF_ASSERT_NOT_NULL( content );
+    delete content;
+
+
+
+    content = CContent::NewL(KOma2ContentNoEnc);
+    STIF_ASSERT_NOT_NULL( content );
+    delete content;
+
+
+
+    TInt err = file.Open(iFs, KOma1Content, EFileRead);
+    CleanupClosePushL(file);
+    content = CContent::NewL(file);
+    STIF_ASSERT_NOT_NULL( content );
+    delete content;
+    CleanupStack::PopAndDestroy();
+
+
+
+    err = file.Open(iFs, KOma2Content, EFileRead);
+    CleanupClosePushL(file);
+    content = CContent::NewL(file);
+    STIF_ASSERT_NOT_NULL( content );
+    delete content;
+    CleanupStack::PopAndDestroy();
+
+
+
+    err = file.Open(iFs, KOma2ContentNoEnc, EFileRead);
+    err = err;
+    CleanupClosePushL(file);
+    content = CContent::NewL(file);
+    STIF_ASSERT_NOT_NULL( content );
+    delete content;
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_OpenCloseContainerL()
+    {
+    CContent* content = NULL;
+    TInt r;
+
+
+    content = CContent::NewLC(KOma1Content);
+    STIF_ASSERT_NOT_NULL( content );
+    RUNCHECKED(content->OpenContainer(KDefaultContentObject));
+    RUNCHECKED(content->CloseContainer());
+
+    RUNCHECKED(content->OpenContainer(KDefaultContentObject));
+    r = content->OpenContainer(KDefaultContentObject);
+    STIF_ASSERT_EQUALS( KErrNotFound, r);
+    RUNCHECKED(content->CloseContainer());
+
+    r = content->OpenContainer(_L("xyz"));
+    STIF_ASSERT_EQUALS( KErrNotFound, r);
+
+    r = content->CloseContainer();
+    STIF_ASSERT_EQUALS( KErrNotFound, r);
+
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_GetEmbeddedObjectsL()
+    {
+    CContent* content = NULL;
+    RStreamablePtrArray<CEmbeddedObject> objects;
+
+
+    content = CContent::NewLC(KOma1Content);
+    STIF_ASSERT_NOT_NULL( content );
+    content->GetEmbeddedObjectsL(objects);
+    STIF_ASSERT_EQUALS( 1, objects.Count());
+    objects.ResetAndDestroy();
+
+    content->GetEmbeddedObjectsL(objects, EContainerObject);
+    STIF_ASSERT_EQUALS( 0, objects.Count());
+
+    content->GetEmbeddedObjectsL(objects, EAgentSpecificObject);
+    STIF_ASSERT_EQUALS( 0, objects.Count());
+
+    content->GetEmbeddedObjectsL(objects, EContentObject);
+    STIF_ASSERT_EQUALS( 1, objects.Count());
+    objects.ResetAndDestroy();
+    objects.Close();
+    CleanupStack::PopAndDestroy();
+
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL( content );
+    content->GetEmbeddedObjectsL(objects);
+    STIF_ASSERT_EQUALS( 1, objects.Count());
+    objects.ResetAndDestroy();
+
+    content->GetEmbeddedObjectsL(objects, EContainerObject);
+    STIF_ASSERT_EQUALS( 0, objects.Count());
+
+    content->GetEmbeddedObjectsL(objects, EAgentSpecificObject);
+    STIF_ASSERT_EQUALS( 0, objects.Count());
+
+    content->GetEmbeddedObjectsL(objects, EContentObject);
+    STIF_ASSERT_EQUALS( 1, objects.Count());
+    objects.ResetAndDestroy();
+    objects.Close();
+
+    RUNCHECKEDL(content->OpenContainer(KDefaultContentObject))
+    content->GetEmbeddedObjectsL(objects, EContentObject);
+    STIF_ASSERT_EQUALS( 0, objects.Count());
+    objects.Close();
+    RUNCHECKED(content->CloseContainer())
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_SearchL()
+    {
+    CContent* content = NULL;
+    RStreamablePtrArray<CEmbeddedObject> objects;
+
+
+    content = CContent::NewLC(KOma1Content);
+    STIF_ASSERT_NOT_NULL( content );
+
+    RUNCHECKEDL(content->Search(objects, _L8("text/plain"), EFalse));
+    STIF_ASSERT_EQUALS( 1, objects.Count());
+    objects.ResetAndDestroy();
+
+    RUNCHECKEDL(content->Search(objects, _L8("audio/wav"), EFalse));
+    STIF_ASSERT_EQUALS( 0, objects.Count());
+    objects.ResetAndDestroy();
+
+    objects.Close();
+    CleanupStack::PopAndDestroy();
+
+
+
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL( content );
+
+    RUNCHECKEDL(content->Search(objects, _L8("text/plain"), EFalse));
+    STIF_ASSERT_EQUALS( 0, objects.Count());
+    objects.ResetAndDestroy();
+
+    RUNCHECKEDL(content->Search(objects, _L8("audio/wav"), EFalse));
+    STIF_ASSERT_EQUALS( 1, objects.Count());
+    objects.ResetAndDestroy();
+    objects.Close();
+
+    RUNCHECKEDL(content->OpenContainer(KDefaultContentObject))
+    RUNCHECKEDL(content->Search(objects, _L8("text/plain"), EFalse));
+    STIF_ASSERT_EQUALS( 0, objects.Count());
+    objects.Close();
+    RUNCHECKED(content->CloseContainer());
+
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_GetAttributeL()
+    {
+    CContent* content = NULL;
+    TInt value;
+    TInt i;
+    TInt re;
+    TBool r1 = EFalse;
+
+    content = CContent::NewLC(KOma1Content);
+    STIF_ASSERT_NOT_NULL( content );
+    RUNCHECKEDL(content->GetAttribute(EIsProtected, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    RUNCHECKEDL(content->GetAttribute(EFileType, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    re = content->GetAttribute(ECanPlay, value);
+    if(re == KErrCANotSupported || re == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    r1 = EFalse;
+    re = content->GetAttribute(ECanPlay, value);
+    if(re == KErrCANotSupported || re == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    r1 = EFalse;
+    re = content->GetAttribute(ECanView, value);
+    if(re == KErrCANotSupported || re == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    r1 = EFalse;
+    re = content->GetAttribute(ECanExecute, value);
+    if(re == KErrCANotSupported || re == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    r1 = EFalse;
+    re = content->GetAttribute(ECanPrint, value);
+    if(re == KErrCANotSupported || re == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        content->GetAttribute(KAttributes[i], value);
+        }
+    STIF_ASSERT_NOT_EQUALS( KErrNone, content->GetAttribute(EIsProtected, value, _L("xyz")));
+    CleanupStack::PopAndDestroy();
+
+
+
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL( content );
+    RUNCHECKEDL(content->GetAttribute(EIsProtected, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    RUNCHECKEDL(content->GetAttribute(EFileType, value));
+    STIF_ASSERT_EQUALS( 2, value);
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        content->GetAttribute(KAttributes[i], value);
+        }
+    STIF_ASSERT_NOT_EQUALS( KErrNone, content->GetAttribute(EIsProtected, value, _L("xyz")));
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_GetAttributeSetL()
+    {
+    CContent* content = NULL;
+    RAttributeSet attributes;
+    TInt value;
+
+    attributes.AddL(EIsProtected);
+    attributes.AddL(EFileType);
+
+    content = CContent::NewLC(KOma1Content);
+    STIF_ASSERT_NOT_NULL( content );
+    RUNCHECKEDL(content->GetAttributeSet(attributes));
+    RUNCHECKEDL(attributes.GetValue(EIsProtected, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    RUNCHECKED(attributes.GetValue(EFileType, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    CleanupStack::PopAndDestroy();
+
+
+
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL( content );
+    RUNCHECKEDL(content->GetAttributeSet(attributes));
+    RUNCHECKEDL(attributes.GetValue(EIsProtected, value));
+    STIF_ASSERT_EQUALS( 1, value);
+    RUNCHECKED(attributes.GetValue(EFileType, value));
+    STIF_ASSERT_EQUALS( 2, value);
+    CleanupStack::PopAndDestroy();
+
+    attributes.Close();
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_GetStringAttributeL()
+    {
+    CContent* content = NULL;
+    RStreamablePtrArray<CEmbeddedObject> objects;
+    HBufC* buffer = HBufC::NewLC(256000);
+    TPtr value(NULL, 0);
+    TInt i;
+
+    value.Set(buffer->Des());
+
+    content = CContent::NewLC(KOma1Content);
+    STIF_ASSERT_NOT_NULL( content );
+    RUNCHECKEDL(content->GetStringAttribute(EMimeType, value));
+    STIF_ASSERT_EQUALS( 0, value.Compare(_L("text/plain")));
+    for (i = 0; i < NUM_ELEMENTS(KStringAttributes); i++)
+        {
+        content->GetStringAttribute(KStringAttributes[i], value);
+        }
+    STIF_ASSERT_NOT_EQUALS(KErrNone, content->GetStringAttribute(EMimeType, value, _L("xyz")));
+    CleanupStack::PopAndDestroy();
+
+
+
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL( content );
+    RUNCHECKEDL(content->Search(objects, _L8("audio/wav"), EFalse));
+    STIF_ASSERT_EQUALS( 1, objects.Count());
+    RUNCHECKEDL(content->GetStringAttribute(EMimeType, value,
+        objects[0]->UniqueId()));
+    STIF_ASSERT_EQUALS( 0, value.Compare(_L("audio/wav")));
+    objects.ResetAndDestroy();
+    objects.Close();
+    for (i = 0; i < NUM_ELEMENTS(KStringAttributes); i++)
+        {
+        content->GetStringAttribute(KStringAttributes[i], value);
+        }
+    STIF_ASSERT_NOT_EQUALS( KErrNone,content->GetStringAttribute(EMimeType, value, _L("xyz")));
+    CleanupStack::PopAndDestroy();
+
+    CleanupStack::PopAndDestroy();
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_GetStringAttributeSetL()
+    {
+    RFile fileFLV;
+
+    TInt err = fileFLV.Open(iFs,KFVariantFile, EFileRead);
+    if( err == 0 )
+    {
+        iLog->Log(_L("    Skipped in FL variant \r\n" ));
+        fileFLV.Close();
+        TFileName fileFlVariant;
+        fileFlVariant.Copy(KFVariantFile);
+        // Clearing file after use
+            iFs.Delete(fileFlVariant);
+        return KErrNone;
+    }
+    fileFLV.Close();
+
+    CContent* content = NULL;
+    RStringAttributeSet attributes;
+    HBufC* buffer = HBufC::NewLC(256000);
+    TPtr value(NULL, 0);
+    TInt re;
+    TBool r1 = EFalse;
+    value.Set(buffer->Des());
+    attributes.AddL(EMimeType);
+    attributes.AddL(ERightsIssuerUrl);
+
+    content = CContent::NewLC(KOma1Content);
+    STIF_ASSERT_NOT_NULL( content );
+    RUNCHECKEDL(content->GetStringAttributeSet(attributes));
+    RUNCHECKEDL(attributes.GetValue(EMimeType, value));
+    STIF_ASSERT_EQUALS( 0,value.Compare(_L("text/plain")));
+    re = attributes.GetValue(ERightsIssuerUrl, value);
+    if(re == KErrCANotSupported || re == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    CleanupStack::PopAndDestroy();
+
+
+
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL( content );
+    RUNCHECKEDL(content->GetStringAttributeSet(attributes));
+    RUNCHECKEDL(attributes.GetValue(EMimeType, value));
+    STIF_ASSERT_EQUALS( 0,value.Compare(_L("audio/wav")));
+    RUNCHECKED(attributes.GetValue(ERightsIssuerUrl, value));
+    if(value.Length() > 0)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    CleanupStack::PopAndDestroy();
+
+    attributes.Close();
+    CleanupStack::PopAndDestroy();
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_AgentSpecificCommandL()
+    {
+    CContent* content = NULL;
+    TPtr8 ptr(NULL, 0, 0);
+    TRequestStatus status;
+
+
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL( content );
+    RUNCHECKED(content->AgentSpecificCommand(EEmbedDomainRo, KNullDesC8, ptr));
+    content->AgentSpecificCommand(EEmbedDomainRo, KNullDesC8, ptr, status);
+    User::WaitForRequest(status);
+    CleanupStack::PopAndDestroy();
+
+    content = CContent::NewLC(KOma1Content);
+    STIF_ASSERT_NOT_NULL( content );
+    STIF_ASSERT_EQUALS( KErrArgument,content->AgentSpecificCommand(EEmbedDomainRo, KNullDesC8, ptr));
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+TInt  CDRM_CAF::CContent_NotifyStatusChangeL()
+    {
+    _LIT(KSdkVersion31,"Z:\\System\\install\\Series60v3.1.sis");
+    _LIT(KSdkVersion50,"Z:\\System\\install\\Series60v5.0.sis");
+    RFs fs;
+    TBool found = EFalse;
+    User::LeaveIfError(fs.Connect ());
+    CleanupClosePushL (fs);
+    if(BaflUtils::FileExists (fs, KSdkVersion31))
+        {
+        found = ETrue;
+        }
+    else if(BaflUtils::FileExists (fs, KSdkVersion50))
+        {
+        found = ETrue;
+        }
+    CContent* content = NULL;
+    TRequestStatus status = KRequestPending;
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL(content);
+    content->NotifyStatusChange(ERightsAvailable, status);//ERightsAvailable
+    if(found)
+    	{
+    	User::After(10000);
+			content->CancelNotifyStatusChange(status);
+    	User::WaitForRequest(status);
+   		}
+   else
+   		{
+   	  User::WaitForRequest(status);
+  		}
+    CleanupStack::PopAndDestroy(2);
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_CancelNotifyStatusChangeL()
+    {
+    CContent* content = NULL;
+    TRequestStatus status;
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL(content);
+    content->CancelNotifyStatusChange(status);
+    User::WaitForRequest(status);
+    //r = status;
+    //STIF_ASSERT_EQUALS( KErrCANotSupported,r);
+    CleanupStack::PopAndDestroy();
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_RequestRightsL()
+    {
+    CContent* content = NULL;
+    TRequestStatus status;
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL(content);
+    content->RequestRights(status);
+    User::WaitForRequest(status);
+    //r = status;
+#ifdef __SERIES60_
+    //STIF_ASSERT_EQUALS( KErrNone,r);
+#else
+    //STIF_ASSERT_EQUALS( KErrCANotSupported,r);
+#endif
+    CleanupStack::PopAndDestroy(content);
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_DisplayInfoL()
+    {
+    CContent* content = NULL;
+    TInt r;
+    TBool r1 = EFalse;
+
+
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL( content );
+    TRAP(r, content->DisplayInfoL(EFileAndRights));
+    if(r == KErrCANotSupported || r == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_SetPropertyL()
+    {
+    CContent* content = NULL;
+    TInt r;
+    TBool r1 = EFalse;
+
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL( content );
+    r = content->SetProperty(EAgentPropertyBufferSize, 1024);
+    if(r == KErrCANotSupported || r == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    r = content->SetProperty(EAgentPropertyAgentUI, 1);
+    if(r == KErrCANotSupported || r == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+
+    r = content->SetProperty(EAgentPropertyMultipleSequence, 1);
+    if(r == KErrCANotSupported || r == KErrNone)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt  CDRM_CAF::CContent_OpenContentL()
+    {
+    CContent* content = NULL;
+    CData* data = NULL;
+    RStreamablePtrArray<CEmbeddedObject> objects;
+
+
+    content = CContent::NewLC(KOma1Content);
+    STIF_ASSERT_NOT_NULL( content );
+    data = content->OpenContentLC(EPeek);
+    STIF_ASSERT_NOT_NULL( data );
+    CleanupStack::PopAndDestroy(2);
+
+
+
+    content = CContent::NewLC(KOma2Content);
+    STIF_ASSERT_NOT_NULL( content );
+    RUNCHECKEDL(content->Search(objects, _L8("audio/wav"), EFalse));
+    STIF_ASSERT_EQUALS( 1,objects.Count());
+    data = content->OpenContentLC(EPeek, objects[0]->UniqueId());
+    STIF_ASSERT_NOT_NULL( data );
+    objects.ResetAndDestroy();
+    CleanupStack::PopAndDestroy(2);
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CManager_FileOperationsL()
+    {
+    _LIT(KFile1, "c:\\private\\OMA DRM Agent\\file1.odf");
+    _LIT(KFile2, "c:\\private\\OMA DRM Agent\\file2.odf");
+    _LIT(KDir, "c:\\private\\OMA DRM Agent\\");
+    _LIT(KDir1, "c:\\private\\OMA DRM Agent\\dir1\\");
+    _LIT(KDir12, "c:\\private\\OMA DRM Agent\\dir1\\dir2\\");
+    CDir* dir;
+    TInt r;
+
+
+    CManager* manager = CManager::NewL();
+    STIF_ASSERT_NOT_NULL( manager );
+    r = manager->CopyFile(KOma2Content, KFile1);
+    STIF_ASSERT_EQUALS( KErrPermissionDenied,r);
+    r = manager->RenameFile(KFile1, KFile2);
+    STIF_ASSERT_EQUALS( KErrPermissionDenied,r);
+    r = manager->DeleteFile(KFile2);
+    STIF_ASSERT_EQUALS( KErrPermissionDenied,r);
+    r = manager->MkDirAll(KDir12);
+    STIF_ASSERT_EQUALS( KErrPermissionDenied,r);
+    r = manager->MkDir(KDir1);
+    STIF_ASSERT_EQUALS( KErrPermissionDenied,r);
+    r = manager->GetDir(KDir, KEntryAttNormal, ESortByName, dir);
+    STIF_ASSERT_EQUALS( KErrPermissionDenied,r);
+    r = manager->GetDir(KDir, KNullUid, ESortByName, dir);
+    STIF_ASSERT_EQUALS( KErrPermissionDenied,r);
+    r = manager->GetDir(KDir, KEntryAttNormal, ESortByName, dir, dir);
+    STIF_ASSERT_EQUALS( KErrPermissionDenied,r);
+    r = manager->RmDir(KDir12);
+    STIF_ASSERT_EQUALS( KErrPermissionDenied,r);
+    //CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CManager_GetAttributeL()
+    {
+    TVirtualPathPtr dcf1(KOma1Content, KNullDesC);
+    TVirtualPathPtr dcf2(KOma2Content, KNullDesC);
+    TInt value;
+    TInt i;
+    RFile dcf1file;
+    RFile dcf2file;
+    TInt error( KErrNone );
+
+    CManager* manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    RUNCHECKEDL(manager->GetAttribute(EIsProtected, value, dcf1));
+    STIF_ASSERT_EQUALS( 0,value);
+    RUNCHECKEDL(manager->GetAttribute(EFileType, value, dcf1));
+    STIF_ASSERT_EQUALS( 1,value);
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        manager->GetAttribute(KAttributes[i], value, dcf1);
+        }
+    CleanupStack::PopAndDestroy( manager );
+
+
+
+    manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    RUNCHECKEDL(manager->GetAttribute(EIsProtected, value, dcf2));
+    STIF_ASSERT_EQUALS( 0,value);
+    RUNCHECKEDL(manager->GetAttribute(EFileType, value, dcf2));
+    STIF_ASSERT_EQUALS( 2,value);
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        manager->GetAttribute(KAttributes[i], value, dcf2);
+        }
+    CleanupStack::PopAndDestroy( manager );
+
+    User::LeaveIfError(dcf1file.Open(iFs, KOma1Content, EFileRead));
+    CleanupClosePushL(dcf1file);
+    User::LeaveIfError(dcf2file.Open(iFs, KOma2Content, EFileRead));
+    CleanupClosePushL(dcf2file);
+
+    manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    error = manager->GetAttribute(EIsProtected, value, dcf1file, KDefaultContentObject);
+    if ( !error )
+        {
+        STIF_ASSERT_EQUALS( 0, value );
+        }
+    else
+        {
+        STIF_ASSERT_EQUALS( KErrCANotSupported, error );
+        }
+
+    error = manager->GetAttribute(EFileType, value, dcf1file, KDefaultContentObject);
+    if ( !error )
+        {
+        STIF_ASSERT_EQUALS( 1, value );
+        }
+    else
+        {
+        STIF_ASSERT_EQUALS( KErrCANotSupported, error );
+        }
+
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        manager->GetAttribute(KAttributes[i], value, dcf1file, KDefaultContentObject);
+        }
+    CleanupStack::PopAndDestroy( manager );
+
+    manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    error = manager->GetAttribute(EIsProtected, value, dcf2file, KDefaultContentObject);
+    if ( !error )
+        {
+        STIF_ASSERT_EQUALS( 0, value );
+        }
+    else
+        {
+        STIF_ASSERT_EQUALS( KErrCANotSupported, error );
+        }
+
+    error = manager->GetAttribute(EFileType, value, dcf2file, KDefaultContentObject);
+    if ( !error )
+        {
+        STIF_ASSERT_EQUALS( 2, value );
+        }
+    else
+        {
+        STIF_ASSERT_EQUALS( KErrCANotSupported, error );
+        }
+
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        manager->GetAttribute(KAttributes[i], value, dcf2file, KDefaultContentObject);
+        }
+    CleanupStack::PopAndDestroy( manager );
+
+    // close files
+    CleanupStack::PopAndDestroy( 2 );
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CManager_GetAttributeSetL()
+    {
+    RAttributeSet attributes;
+    TInt value;
+    TVirtualPathPtr dcf2(KOma2Content, KNullDesC);
+    TInt error( KErrNone );
+    RFile dcf2file;
+
+    attributes.AddL(EIsProtected);
+    attributes.AddL(EFileType);
+    CleanupClosePushL(attributes);
+    CManager* manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    RUNCHECKEDL(manager->GetAttributeSet(attributes, dcf2));
+    RUNCHECKEDL(attributes.GetValue(EIsProtected, value));
+    STIF_ASSERT_EQUALS( 0,value);
+    RUNCHECKED(attributes.GetValue(EFileType, value));
+    STIF_ASSERT_EQUALS( 2,value);
+
+    User::LeaveIfError(dcf2file.Open(iFs, KOma2Content, EFileRead));
+    CleanupClosePushL(dcf2file);
+
+    error = manager->GetAttributeSet(attributes, dcf2file, KDefaultContentObject);
+    if ( !error )
+        {
+        RUNCHECKEDL(attributes.GetValue(EIsProtected, value));
+        STIF_ASSERT_EQUALS( 0,value);
+        RUNCHECKED(attributes.GetValue(EFileType, value));
+        STIF_ASSERT_EQUALS( 2,value);
+        }
+    else
+        {
+        STIF_ASSERT_EQUALS( KErrCANotSupported, error );
+        }
+
+    CleanupStack::PopAndDestroy(3);
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CManager_GetStringAttributeL()
+    {
+    TBuf<256> value;
+    TVirtualPathPtr dcf1(KOma1Content, KNullDesC);
+    TVirtualPathPtr dcf2(KOma2Content, KNullDesC);
+    TInt i;
+    TInt error( KErrNone );
+    RFile dcf1file;
+    RFile dcf2file;
+
+    CManager* manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    RUNCHECKED(manager->GetStringAttribute(EMimeType, value, dcf1));
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        manager->GetStringAttribute(KStringAttributes[i], value, dcf1);
+        }
+    CleanupStack::PopAndDestroy( manager );
+
+
+
+    manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    RUNCHECKED(manager->GetStringAttribute(EMimeType, value, dcf2));
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        manager->GetStringAttribute(KStringAttributes[i], value, dcf2);
+        }
+    CleanupStack::PopAndDestroy( manager );
+
+    User::LeaveIfError(dcf1file.Open(iFs, KOma1Content, EFileRead));
+    CleanupClosePushL(dcf1file);
+    User::LeaveIfError(dcf2file.Open(iFs, KOma2Content, EFileRead));
+    CleanupClosePushL(dcf2file);
+
+    manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    error = manager->GetStringAttribute(EMimeType, value, dcf1file, KDefaultContentObject);
+    if ( error == KErrCANotSupported )
+        {
+        error = KErrNone;
+        }
+    STIF_ASSERT_EQUALS( KErrNone, error );
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        manager->GetStringAttribute(KStringAttributes[i], value, dcf1file, KDefaultContentObject);
+        }
+    CleanupStack::PopAndDestroy( manager );
+
+
+
+    manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    error = manager->GetStringAttribute(EMimeType, value, dcf2file, KDefaultContentObject);
+    if ( error == KErrCANotSupported )
+        {
+        error = KErrNone;
+        }
+    STIF_ASSERT_EQUALS( KErrNone, error );
+    for (i = 0; i < NUM_ELEMENTS(KAttributes); i++)
+        {
+        manager->GetStringAttribute(KStringAttributes[i], value, dcf2file, KDefaultContentObject);
+        }
+    CleanupStack::PopAndDestroy( manager );
+
+    // close files
+    CleanupStack::PopAndDestroy( 2 );
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CManager_GetStringAttributeSetL()
+    {
+    RStringAttributeSet attributes;
+    TBuf<256> value;
+    TVirtualPathPtr dcf2(KOma2Content, KNullDesC);
+    RFile dcf2file;
+    TInt error( KErrNone );
+
+    attributes.AddL(EMimeType);
+    attributes.AddL(ERightsIssuerUrl);
+    CManager* manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    RUNCHECKEDL(manager->GetStringAttributeSet(attributes, dcf2));
+    RUNCHECKED(attributes.GetValue(EMimeType, value));
+    STIF_ASSERT_EQUALS( KErrCANotSupported,attributes.GetValue(ERightsIssuerUrl, value));
+    STIF_ASSERT_EQUALS( 0,value.Length());
+    CleanupStack::PopAndDestroy( manager );
+
+    User::LeaveIfError(dcf2file.Open(iFs, KOma2Content, EFileRead));
+    CleanupClosePushL(dcf2file);
+
+    manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    error = manager->GetStringAttributeSet(attributes, dcf2file, KDefaultContentObject);
+    if ( !error )
+        {
+        RUNCHECKED(attributes.GetValue(EMimeType, value));
+        STIF_ASSERT_EQUALS( KErrCANotSupported,attributes.GetValue(ERightsIssuerUrl, value));
+        STIF_ASSERT_EQUALS( 0,value.Length());
+        }
+    else
+        {
+        STIF_ASSERT_EQUALS( KErrCANotSupported, error );
+        }
+
+    CleanupStack::PopAndDestroy( 2 );
+
+    attributes.Close();
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CManager_SetPropertyL()
+    {
+    TInt r;
+
+    TVirtualPathPtr dcf2(KOma2Content, KDefaultContentObject);
+    CManager* manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    r = manager->SetProperty(EAgentPropertyBufferSize, 1024);
+    STIF_ASSERT_EQUALS( KErrCANotSupported,r);
+    r = manager->SetProperty(EAgentPropertyAgentUI, 1);
+    STIF_ASSERT_EQUALS( KErrCANotSupported,r);
+    r = manager->SetProperty(EAgentPropertyMultipleSequence, 1);
+    STIF_ASSERT_EQUALS( KErrCANotSupported,r);
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CManager_DisplayInfoL()
+    {
+    TInt r;
+    RFile file;
+
+    TVirtualPathPtr dcf2(KOma2Content, KDefaultContentObject);
+    CManager* manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    TRAP(r, manager->DisplayInfoL(EFileAndRights, dcf2));
+    STIF_ASSERT_EQUALS( KErrCANotSupported,r);
+
+    User::LeaveIfError(file.Open(iFs, KOma2Content, EFileRead));
+    TRAP(r, manager->DisplayInfoL(EFileAndRights, file, KDefaultContentObject));
+    STIF_ASSERT_EQUALS( KErrCANotSupported,r);
+
+    file.Close();
+    CleanupStack::PopAndDestroy( manager );
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CManager_ListAgentsL()
+    {
+    RArray<TAgent> agents;
+    TBool f = EFalse;
+    TInt i;
+
+
+    CManager* manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    manager->ListAgentsL(agents);
+    for (i = 0; i < agents.Count(); i++)
+        {
+        if (agents[i].Name().Compare(KOmaDrm2AgentName) == 0)
+            {
+            f = ETrue;
+            }
+        }
+    STIF_ASSERT_TRUE(f);
+    agents.Close();
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CManager_AgentSpecificCommandL()
+    {
+    TPtr8 ptr(NULL, 0, 0);
+    RArray<TAgent> agents;
+    TRequestStatus status;
+    TInt i;
+    TInt r;
+    HBufC8* data;
+    HBufC8* result;
+    HBufC8* buffer;
+
+    r = iFs.Delete(_L("c:\\test.dcf"));
+    STIF_ASSERT_EQUALS( KErrNone,r);
+
+    RFileWriteStream out;
+    out.Create(iFs, _L("c:\\test.dcf"), EFileWrite );
+
+
+    out.Close();
+
+
+    TInt size = 0;
+    RFile file;
+    User::LeaveIfError(file.Open(iFs, _L("c:\\test.dcf"), EFileRead));
+    CleanupClosePushL(file);
+    User::LeaveIfError(file.Size(size));
+    data = HBufC8::NewLC(size);
+    TPtr8 ptr1(data->Des());
+    User::LeaveIfError(file.Read(ptr1, size));
+    CleanupStack::Pop(); //data
+    CleanupStack::PopAndDestroy(); //file
+
+    buffer = HBufC8::NewL(data->Length() + 1);
+    ptr.Set(buffer->Des());
+    ptr.Append(EView);
+    ptr.Append(*data);
+    result = HBufC8::NewL(data->Length());
+    ptr.Set(result->Des());
+
+
+    TVirtualPathPtr dcf2(KOma2Content, KDefaultContentObject);
+    CManager* manager = CManager::NewLC();
+    STIF_ASSERT_NOT_NULL( manager );
+    manager->ListAgentsL(agents);
+    for (i = 0; i < agents.Count(); i++)
+        {
+        if (agents[i].Name().Compare(KOmaDrm2AgentName) == 0)
+            {
+            r = manager->AgentSpecificCommand(agents[i],
+                EEmbedDomainRo, KNullDesC8, ptr);
+            STIF_ASSERT_EQUALS( KErrCANotSupported,r);
+            manager->AgentSpecificCommand(agents[i],
+                EEmbedDomainRo, KNullDesC8, ptr, status);
+            User::WaitForRequest(status);
+            STIF_ASSERT_EQUALS( KErrCANotSupported,status.Int());
+
+            r = manager->AgentSpecificCommand(agents[i],
+                EBufferContainsOma1Dcf, KNullDesC8, ptr);
+            STIF_ASSERT_NOT_EQUALS( KErrNone,r);
+
+            r = manager->AgentSpecificCommand(agents[i],
+                EBufferContainsOma1Dcf, _L8("012345"), ptr);
+            STIF_ASSERT_NOT_EQUALS( KErrNone,r);
+
+            r = manager->AgentSpecificCommand(agents[i],
+                EDecryptOma1DcfBuffer, *buffer, ptr);
+            STIF_ASSERT_EQUALS( KErrArgument,r);
+
+            }
+        }
+    agents.Close();
+    CleanupStack::PopAndDestroy();
+
+
+    delete buffer;
+    delete result;
+    delete data;
+    return KErrNone;
+    }
+
+
+TInt CDRM_CAF::CManager_CreateRightsManagerL()
+    {
+    CRightsManager* rm = NULL;
+    rm = GetOmaDrmRightsManagerL();
+    STIF_ASSERT_NOT_NULL(rm);
+    delete rm;
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CSupplier_IsImportSupportedL()
+    {
+
+    CSupplier* supplier = CSupplier::NewLC();
+    STIF_ASSERT_TRUE(supplier->IsImportSupported(KOma1DrmMessageContentType));
+    STIF_ASSERT_TRUE(supplier->IsImportSupported(KOma1XmlRoContentType));
+    STIF_ASSERT_TRUE(supplier->IsImportSupported(KOma1WbxmlRoContentType));
+    STIF_ASSERT_TRUE(supplier->IsImportSupported(KOma2RoContentType));
+    STIF_ASSERT_FALSE(supplier->IsImportSupported(_L8("text/plain")));
+    CleanupStack::PopAndDestroy(1);
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CSupplier_PrepareHTTPRequestHeadersL()
+    {
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CSupplier_SetOutputDirectory_ImportFileL()
+    {
+
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    CImportFile* file = supplier->ImportFileL(KOma1DrmMessageContentType,
+        *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    CleanupStack::PopAndDestroy(3);
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CImportFile_WriteData_WriteDataComplete_OutputFileCountL()
+    {
+    TFileName fileName;
+    TRequestStatus status;
+    TInt i;
+    TInt r;
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS(KErrNone , r);
+
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    CImportFile* file = supplier->ImportFileL(KOma1DrmMessageContentType,
+        *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    RUNCHECKEDL(file->WriteData(KDMSimple));
+    RUNCHECKEDL(file->WriteDataComplete());
+    STIF_ASSERT_EQUALS(1 , file->OutputFileCountL());
+    CleanupStack::PopAndDestroy(3);
+
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS(KErrNone , r);
+
+    supplier = CSupplier::NewLC();
+    metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    file = supplier->ImportFileL(KOma1DrmMessageContentType,
+        *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    file->WriteData(KDMSimple, status);
+    User::WaitForRequest(status);
+    STIF_ASSERT_EQUALS(KErrNone , status.Int());
+    file->WriteDataComplete(status);
+    User::WaitForRequest(status);
+    STIF_ASSERT_EQUALS(KErrNone , status.Int());
+    STIF_ASSERT_EQUALS(1 , file->OutputFileCountL());
+    CleanupStack::PopAndDestroy(3);
+
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS(KErrNone , r);
+
+    supplier = CSupplier::NewLC();
+    metaData = CMetaDataArray::NewLC();
+    metaData->AddL(KOmaImportMimeTypeField, _L8("text/plain"));
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    file = supplier->ImportFileL(KOmaImportContentType,
+        *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    for (i = 0; i < 100; i++)
+        {
+        STIF_ASSERT_EQUALS(KErrNone , file->WriteData(KDMContent) );
+        }
+    STIF_ASSERT_EQUALS(KErrNone , file->WriteDataComplete());
+    STIF_ASSERT_EQUALS(1 , file->OutputFileCountL());
+    CleanupStack::PopAndDestroy(3);
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CImportFile_OutputFileL_GetImportStatusL()
+    {
+    TFileName fileName;
+    TInt r;
+
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS(KErrNone , r);
+
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    CImportFile* file = supplier->ImportFileL(KOma1DrmMessageContentType,
+        *metaData, KTempDcfName);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    RUNCHECKEDL(file->WriteData(KDMSimple));
+    RUNCHECKEDL(file->WriteDataComplete());
+    RUNCHECKED(file->GetImportStatus() == EComplete);
+    STIF_ASSERT_EQUALS(1 , file->OutputFileCountL());
+    CSupplierOutputFile& output = file->OutputFileL(0);
+    STIF_ASSERT_EQUALS(0 , output.MimeTypeL().CompareF(KOma1DcfContentType));
+    CleanupStack::PopAndDestroy(3);
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CImportFile_GetSuggestedOutputFileExtensionL()
+    {
+    TInt r;
+    TBuf<256> buffer;
+
+
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    CImportFile* file = supplier->ImportFileL(KOma1DrmMessageContentType,
+        *metaData);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    r = file->WriteData(KDMSimple);
+    STIF_ASSERT_EQUALS(KErrCANewFileHandleRequired , r);
+    RUNCHECKEDL(file->GetSuggestedOutputFileExtension(buffer));
+    STIF_ASSERT_EQUALS(0 , buffer.CompareF(_L(".dcf")));
+    CleanupStack::PopAndDestroy(3);
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CImportFile_GetSuggestedOutputFileNameL()
+    {
+    TInt r;
+    TBuf<256> buffer;
+
+
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    CImportFile* file = supplier->ImportFileL(KOma1DrmMessageContentType,
+        *metaData);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    r = file->WriteData(KDMSimple);
+    STIF_ASSERT_EQUALS(KErrCANewFileHandleRequired , r);
+    buffer.Copy(_L("test"));
+    RUNCHECKEDL(file->GetSuggestedOutputFileName(buffer));
+    STIF_ASSERT_EQUALS(0 , buffer.CompareF(_L("test.dcf")));
+    CleanupStack::PopAndDestroy(3);
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CImportFile_ContinueWithNewOutputFileL()
+    {
+    TFileName fileName;
+    RFile f;
+    TInt r;
+
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+    iFs.SetSessionPath(KEncryptedDir);
+    r = iFs.Delete(fileName);
+    STIF_ASSERT_EQUALS(KErrNone , r);
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    CImportFile* file = supplier->ImportFileL(KOma1DrmMessageContentType,
+        *metaData);
+    STIF_ASSERT_NOT_NULL( file );
+    CleanupStack::PushL(file);
+    r = file->WriteData(KDMSimple);
+    STIF_ASSERT_EQUALS(KErrCANewFileHandleRequired , r);
+    RUNCHECKEDL(f.Create(iFs, fileName, EFileWrite | EFileStream));
+    CleanupClosePushL(f);
+    file->ContinueWithNewOutputFile(f, fileName);
+    RUNCHECKEDL(file->WriteData(KDMSimple));
+    RUNCHECKEDL(file->WriteDataComplete());
+    CleanupStack::PopAndDestroy(4);
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CImportFile_ContentMimeTypeL()
+    {
+    TInt err( KErrNone );
+    CSupplier* supplier = CSupplier::NewLC();
+    CMetaDataArray* metaData = CMetaDataArray::NewLC();
+    supplier->SetOutputDirectoryL(KEncryptedDir);
+    CImportFile* file = supplier->ImportFileL(KOma1DrmMessageContentType,
+                                              *metaData);
+    CleanupStack::PushL( file );
+    err = file->WriteData(KDMSimple);
+    STIF_ASSERT_EQUALS(err, KErrCANewFileHandleRequired);
+    TBuf8<KMaxDataTypeLength> contentMime;
+    TRAP(err, file->ContentMimeTypeL( contentMime ));
+    STIF_ASSERT_EQUALS(KErrCANotSupported, err);
+    CleanupStack::PopAndDestroy( 3, supplier ); //file, metaData, supplier
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CRightsManager_ListRightsL()
+    {
+    CRightsManager* rm = NULL;
+    RStreamablePtrArray<CRightsInfo> rights;
+    RFile dcfFile;
+
+    rm = GetOmaDrmRightsManagerL();
+    STIF_ASSERT_NOT_NULL( rm );
+    CleanupStack::PushL(rm);
+    rm->ListRightsL(rights, KTempDcfPathName);
+    rights.ResetAndDestroy();
+    rights.Close();
+    CleanupStack::PopAndDestroy();
+
+    User::LeaveIfError(dcfFile.Open(iFs, KTempDcfPathName, EFileRead));
+    CleanupClosePushL(dcfFile);
+
+    rm = GetOmaDrmRightsManagerL();
+    STIF_ASSERT_NOT_NULL( rm );
+    CleanupStack::PushL(rm);
+    TRAPD( err, rm->ListRightsL(rights, dcfFile, KDefaultContentObject) );
+    if ( err != KErrCANotSupported )
+        {
+        User::LeaveIfError( err );
+        }
+    rights.ResetAndDestroy();
+    rights.Close();
+    CleanupStack::PopAndDestroy( 2 );
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CRightsManager_ListAllRightsL()
+    {
+    CRightsManager* rm = NULL;
+    RStreamablePtrArray<CRightsInfo> rights;
+    rm = GetOmaDrmRightsManagerL();
+    STIF_ASSERT_NOT_NULL( rm );
+    CleanupStack::PushL(rm);
+    rm->ListAllRightsL(rights);
+    rights.ResetAndDestroy();
+    rights.Close();
+    CleanupStack::PopAndDestroy();
+    return KErrNone;
+    }
+
+
+TInt CDRM_CAF::CRightsManager_ListContentL()
+    {
+    TInt r = 0;
+    CRightsManager* rm = NULL;
+    RStreamablePtrArray<CVirtualPath> files;
+    CData* data = NULL;
+    TBuf<256> id;
+    CRightsInfo* info = NULL;
+
+    TBool r1 = EFalse;
+    rm = GetOmaDrmRightsManagerL();
+    STIF_ASSERT_NOT_NULL( rm );
+    CleanupStack::PushL(rm);
+
+    data = CData::NewLC(TVirtualPathPtr(KOma1Content, KDefaultContentObject),
+        EPeek, EContentShareReadOnly);
+
+    RUNCHECKEDL(data->GetStringAttribute(EContentID, id));
+
+    info = CRightsInfo::NewL(KNullDesC, id, ERightsTypeStateless,
+        ERightsStatusValid);
+
+
+    CleanupStack::PushL(info);
+
+    TRAP(r, rm->ListContentL(files, *info));
+    if(r == KErrNone || r == KErrNotFound)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    files.ResetAndDestroy();
+    files.Close();
+    CleanupStack::PopAndDestroy(3); // rm, data, info
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CRightsManager_DeleteRightsObjectL()
+    {
+    CRightsManager* rm = NULL;
+    CData* data = NULL;
+    TBuf<256> id;
+    CRightsInfo* info = NULL;
+    TInt r;
+    TBool r1 = EFalse;
+    rm = GetOmaDrmRightsManagerL();
+
+    STIF_ASSERT_NOT_NULL( rm );
+    CleanupStack::PushL(rm);
+    data = CData::NewLC(TVirtualPathPtr(KOma1Content, KDefaultContentObject),
+        EPeek, EContentShareReadOnly);
+    RUNCHECKEDL(data->GetStringAttribute(EContentID, id));
+    info = CRightsInfo::NewL(KNullDesC, id, ERightsTypeStateless,
+        ERightsStatusValid);
+    CleanupStack::PushL(info);
+    r = rm->DeleteRightsObject(*info);
+    if(r == -21 || r == 0)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    CleanupStack::PopAndDestroy(3);
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CRightsManager_DeleteAllRightsObjectsL()
+    {
+    CRightsManager* rm = NULL;
+    TInt r;
+    TBool r1 = EFalse;
+    rm = GetOmaDrmRightsManagerL();
+    RFile file;
+
+    STIF_ASSERT_NOT_NULL( rm );
+    CleanupStack::PushL(rm);
+    r = rm->DeleteAllRightsObjects(TVirtualPathPtr(KOma1Content, KNullDesC));
+    if(r == -21 || r == -1)
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+
+    r1 = EFalse;
+    User::LeaveIfError(file.Open(iFs, KOma1Content, EFileRead));
+    r = rm->DeleteAllRightsObjects(file, KDefaultContentObject);
+    if(r == -21 || r == -1 || r == KErrCANotSupported )
+        {
+        r1 = ETrue;
+        }
+    STIF_ASSERT_TRUE(r1);
+    file.Close();
+    CleanupStack::PopAndDestroy( rm );
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CRightsManager_SetPropertyL()
+    {
+    CRightsManager* rm = NULL;
+    TInt r;
+    rm = GetOmaDrmRightsManagerL();
+
+    STIF_ASSERT_NOT_NULL( rm );
+    CleanupStack::PushL(rm);
+    r = rm->SetProperty(EAgentPropertyBufferSize, 1024);
+    STIF_ASSERT_EQUALS(KErrCANotSupported , r);
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+TInt CDRM_CAF::CDRMLicenseChecker_CheckLicenseL()
+    {
+    CDRMLicenseChecker* lc = NULL;
+    TInt r;
+    TFileName fileName;
+    HBufC8* data = NULL;
+
+    fileName.Copy(KEncryptedDir);
+    fileName.Append(KTempDcfName);
+
+
+    lc = CDRMLicenseChecker::NewL();
+    STIF_ASSERT_NOT_NULL( lc );
+    CleanupStack::PushL(lc);
+    r = lc->CheckLicense( fileName, data );
+    STIF_ASSERT_EQUALS(KErrAccessDenied , r); // this does not work in SDK
+    //STIF_ASSERT_EQUALS(KErrNone , r); // this works in the new SDK's
+    delete data;
+    CleanupStack::PopAndDestroy();
+
+    return KErrNone;
+    }
+
+
+//  [End of File] - Do not remove
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). 
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:       
+*
+*/
+
+/*
+-----------------------------------------------------------------------------
+
+    DESCRIPTION
+
+    bld.inf Toplevel build information for STIF Test Framework
+
+-----------------------------------------------------------------------------
+*/
+
+#if defined(__S60_)
+    // To get the MW_LAYER_PLATFORM_EXPORT_PATH macro definition
+    #include <platform_paths.hrh>
+#endif // __S60_
+
+PRJ_PLATFORMS
+DEFAULT
+
+
+PRJ_EXPORTS	
+	
+PRJ_TESTEXPORTS
+	
+PRJ_MMPFILES
+	
+// DRM_CAF
+#include "../DRM_CAF/group/bld.inf"
+	
+// BCDRMCAFCAPS_exe
+#include "../BCDRMCAFCAPS_exe/group/bld.inf"
+	
+	
+// End of File
Binary file drm_pub/oma_drm_caf_agent_api/tsrc/bc/sis/50_MM_DRMCAF.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/sis/50_MM_DRMCAF.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,43 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:      
+;
+&EN
+
+; Installation header
+; Only one component name as we only support English
+; UID is the main app's UID
+
+#{"MM_DRMCAF"},(0x20015B21),1,0,0,TYPE=SA
+[0x101F7961],3,*,*,{"Series60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; Files to install and to where
+"\epoc32\winscw\c\content-noenc-trunc.odf"-"!:\content-noenc-trunc.odf"
+"\Epoc32\winscw\c\content.odf"-"!:\content.odf"
+"\Epoc32\winscw\c\content.txt"-"!:\content.txt"
+"\Epoc32\winscw\c\content-noenc.odf"-"!:\content-noenc.odf"
+"\Epoc32\winscw\c\content.dcf"-"!:\content.dcf"
+
+
+"\Epoc32\Release\armv5\urel\DRM_CAF.dll"-"!:\sys\bin\DRM_CAF.dll"
+"\Epoc32\Release\armv5\urel\BCDRMCAFCAPS.exe"-"!:\sys\bin\BCDRMCAFCAPS.exe"
+"\Epoc32\winscw\c\testframework\TestFramework_DRMCAF.ini"-"!:\TestFramework\TestFramework_DRMCAF.ini"
+"\Epoc32\winscw\c\testframework\DRM_CAF.cfg"-"!:\TestFramework\DRM_CAF.cfg"
+"\epoc32\winscw\c\drmcaf_c.bat"-"!:\drmcaf.bat"
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drm_pub/oma_drm_caf_agent_api/tsrc/bc/sis/51_drm_drmcaf.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,45 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of the License "Symbian Foundation License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+; Languages
+; none -  English only by default
+&EN
+
+; Installation header
+; Only one component name as we only support English
+; UID is the main app's UID
+
+#{"MM_DRMCAF"},(0x20015B21),1,0,0,TYPE=SA
+[0x101F7961],3,*,*,{"Series60ProductID"}
+
+; Non-localised vendor name
+:"Nokia Corporation"
+
+; Localised vendor names
+%{"Nokia Corporation"}
+
+; Files to install and to where
+"\epoc32\winscw\c\content-noenc-trunc.odf"-"!:\content-noenc-trunc.odf"
+"\epoc32\winscw\c\content.odf"-"!:\content.odf"
+"\epoc32\winscw\c\content.txt"-"!:\content.txt"
+"\epoc32\winscw\c\content-noenc.odf"-"!:\content-noenc.odf"
+"\epoc32\winscw\c\content.dcf"-"!:\content.dcf"
+
+
+"\epoc32\release\armv5\urel\drm_caf.dll"-"!:\sys\bin\drm_caf.dll"
+"\epoc32\release\armv5\urel\bcdrmcafcaps.exe"-"!:\sys\bin\bcdrmcafcaps.exe"
+"\epoc32\winscw\c\testframework\testframework_drmcaf.ini"-"!:\testframework\testframework_drmcaf.ini"
+"\epoc32\winscw\c\testframework\drm_caf.cfg"-"!:\testframework\drm_caf.cfg"
+"\epoc32\winscw\c\drmcaf_c.bat"-"!:\drmcaf.bat"
Binary file drm_pub/oma_drm_caf_agent_api/tsrc/bc/sis/51_drm_drmcaf.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2006 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+#include "../drm_plat/group/bld.inf"
+#include "../drm_pub/group/bld.inf"
+
+#include "../commondrm/group/bld.inf"
+#include "../omadrm/group/bld.inf"
+
+#include "../wmdrm/group/bld.inf"
+
+
+
+PRJ_EXPORTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/Base64.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,32 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef BASE64_H
+#define BASE64_H
+
+// FUNCTION PROTOTYPES
+IMPORT_C HBufC8* Base64EncodeL(
+    const TDesC8& aInput);
+
+IMPORT_C HBufC8* Base64DecodeL(
+    const TDesC8& aInput);
+
+#endif      // BASE64_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/BitStream.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef BITSTREAM_H
+#define BITSTREAM_H
+
+#include <bigint.h>
+
+#define INLINE
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  TBitStream: Stream of bits
+*
+*  @lib    -
+*  @since  3.0
+*/
+template<TInt S>
+class TBitStream
+    {
+public: // New functions
+
+    INLINE void Clear();
+
+    INLINE void SetBit(
+        const TInt aBit);
+        
+    INLINE void SetBitValue(
+        const TInt aBit,
+        const TInt aValue);
+        
+    INLINE void ClearBit(
+        const TInt aBit);
+        
+    INLINE TInt GetBit(
+        const TInt aBit) const;
+        
+    INLINE void XorBit(
+        const TInt aBit,
+        const TInt aValue);
+        
+    INLINE TPtrC8 Des() const;
+    
+    INLINE void Set(
+        const TDesC8& aInput);
+    
+    INLINE void Copy(
+        TBitStream<S> aBitStream);
+        
+    INLINE void Or(
+        TBitStream<S> aBitStream);
+        
+    INLINE void Xor(
+        TBitStream<S> aBitStream);
+        
+    INLINE void And(
+        TBitStream<S> aBitStream);
+        
+    INLINE void Not();
+    
+    INLINE TInt operator[](
+        const TInt aBit) const;
+    
+protected: // New functions
+
+protected: // Data
+
+    // Buffer with the data
+    TBuf8<S / 8> iData;
+    };
+
+#include "BitStream.inl"
+
+#endif      // BITSTREAM_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/BitStream.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// -----------------------------------------------------------------------------
+// TBitStream::
+// 
+// -----------------------------------------------------------------------------
+//
+template<TInt S>
+void TBitStream<S>::Clear()
+    {
+    iData.SetLength(iData.MaxLength());
+    iData.FillZ();
+    }
+
+template<TInt S>
+void TBitStream<S>::SetBit(
+    const TInt aBit)
+    {
+    iData[aBit / 8] |= (1 << (7 - aBit % 8));
+    }
+    
+template<TInt S>
+void TBitStream<S>::ClearBit(
+    const TInt aBit)
+    {
+    iData[aBit / 8] &= ~(1 << (7 - aBit % 8));
+    }
+    
+template<TInt S>
+void TBitStream<S>::SetBitValue(
+    const TInt aBit,
+    const TInt aValue)
+    {
+    if (aValue)
+        {
+        SetBit(aBit);
+        }
+    else
+        {
+        ClearBit(aBit);
+        }
+    }
+    
+template<TInt S>
+TInt TBitStream<S>::GetBit(
+    const TInt aBit) const
+    {
+    return (iData[aBit / 8] & (1 << (7 - aBit % 8))) ? 1 : 0;
+    }
+    
+template<TInt S>
+void TBitStream<S>::XorBit(
+    const TInt aBit,
+    const TInt aValue)
+    {
+    iData[aBit / 8] ^= (1 << (7 - aBit % 8));
+    }
+    
+template<TInt S>
+TPtrC8 TBitStream<S>::Des() const
+    {
+    return TPtrC8(iData.Ptr(), iData.Length());
+    }
+
+template<TInt S>
+void TBitStream<S>::Set(
+    const TDesC8& aInput)
+    {
+    TInt i;
+    
+    iData.SetLength(aInput.Length());
+    for (i = 0; i < S / 8; i++)
+        {
+        iData[i] = aInput[i];
+        }
+    }
+
+template<TInt S>
+void TBitStream<S>::Copy(
+    TBitStream<S> aBitStream)
+    {
+    iData.Copy(aBitStream.Des());
+    }
+    
+template<TInt S>
+void TBitStream<S>::Xor(
+    TBitStream<S> aBitStream)
+    {
+    TPtrC8 des(aBitStream.Des());
+    TInt i;
+    
+    for (i = 0; i < S / 8; i++)
+        {
+        iData[i] ^= des[i];
+        }
+    }
+    
+template<TInt S>
+void TBitStream<S>::Or(
+    TBitStream<S> aBitStream)
+    {
+    TPtrC8 des(aBitStream.Des());
+    TInt i;
+    
+    for (i = 0; i < S / 8; i++)
+        {
+        iData[i] |= des[i];
+        }
+    }
+    
+template<TInt S>
+void TBitStream<S>::And(
+    TBitStream<S> aBitStream)
+    {
+    TPtrC8 des(aBitStream.Des());
+    TInt i;
+    
+    for (i = 0; i < S / 8; i++)
+        {
+        iData[i] &= des[i];
+        }
+    }
+    
+template<TInt S>
+void TBitStream<S>::Not()
+    {
+    TInt i;
+    
+    for (i = 0; i < S / 8; i++)
+        {
+        iData[i] = ~iData[i];
+        }
+    }
+    
+template<TInt S>
+TInt TBitStream<S>::operator[](
+    const TInt aBit) const
+    {
+    return GetBit(aBit);
+    }
+    
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/CmlaCrypto.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef CMLACRYPTO_H
+#define CMLACRYPTO_H
+
+#include <bigint.h>
+#include "Oma2Agent.h"
+#include "OmaCrypto.h"
+
+// FORWARD DECLARATIONS
+class MDrmKeyStorage;
+class CRSAPublicKey;
+
+// CLASS DECLARATION
+
+/**
+*  CmlaCrypto: Contains crypto operations for CMLA
+*
+*  @lib    -
+*  @since  3.0
+*/
+class CmlaCrypto: public OmaCrypto
+    {
+public: // Constants
+
+    static const TInt KDdtPermLength = 8;
+    static const TInt KDdtExpLength = 3;
+
+public: // New functions
+
+    IMPORT_C static TInt SupportedAlgorithmsL(
+        RArray<TPtrC8>& aAlgorithmList);
+
+    IMPORT_C static HBufC8* DdtPermL(
+        const TDesC8& aInput);
+
+    IMPORT_C static HBufC8* DdtPermInvL(
+        const TDesC8& aInput);
+
+    IMPORT_C static HBufC8* DdtExpL(
+        const TDesC8& aInput);
+
+    IMPORT_C static HBufC8* DdtExpInvL(
+        const TDesC8& aInput);
+        
+    IMPORT_C static HBufC8* WrapL(
+        const TDesC8& aKek,
+        const TDesC8& aKey);
+
+    IMPORT_C static HBufC8* UnwrapL(
+        const TDesC8& aKek,
+        const TDesC8& aKey);
+
+    IMPORT_C static HBufC8* KdfL(
+        const TDesC8& aInput);
+        
+    IMPORT_C static HBufC8* RsaDecryptCmlaL(
+        MDrmKeyStorage* aKeyStorage,
+        const TDesC8& aInput);
+
+    IMPORT_C static HBufC8* RsaEncryptCmlaL(
+        CRSAPublicKey* aKey,
+        const TDesC8& aInput);
+        
+    IMPORT_C static void CmlaIpDecryptL(
+        TKeyTransportScheme aTransportScheme,
+        MDrmKeyStorage* aKey,
+        const TDesC8& aInput,
+        TDes8& aRek,
+        TDes8& aMac);
+        
+    IMPORT_C static HBufC8* CmlaIpEncryptL(
+        TKeyTransportScheme aTransportScheme,
+        CRSAPublicKey* aKey,
+        const TDesC8& aRek,
+        const TDesC8& aMac);
+        
+    IMPORT_C static TKeyTransportScheme AlgorithmIdToTransportScheme(
+        const TDesC8& aAlgorithmId);
+
+    
+protected: // New functions
+    };
+
+#endif      // CMLACRYPTO_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/DRMClockClient.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,126 @@
+/*
+* 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:  This class is the client side handle of DRM Clock Server
+*
+*/
+
+
+
+#ifndef RDRMCLOCKCLIENT_H
+#define RDRMCLOCKCLIENT_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <DrmTypes.h>
+//#include "DRMClock.h"
+
+// CONSTANTS
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  This class is the client side interface for DRM Clock Server.
+*
+*  @lib DRM Core
+*  @since S60 Release 2.5
+*/
+NONSHARABLE_CLASS( RDRMClockClient ) : public RSessionBase
+    {
+    public:  // Constructor & destructor
+        /**
+         * C++ default constructor.
+         */
+        IMPORT_C RDRMClockClient();
+        
+        /** 
+         * Destructor.
+         */
+        IMPORT_C virtual ~RDRMClockClient();
+        
+        /** 
+         * This method opens the connection between the client and the server.
+         * @since 2.5
+         * @return Error code. KErrNone if the operation is successful.
+         */
+        IMPORT_C TInt Connect();
+        
+        /**
+         * This function closes the connection between the client and the server.
+         * It is safe to call this method even if connection is not established.
+         * @since S60Rel2.5
+         */ 
+        IMPORT_C void Close();
+        
+    public: // New functions
+        
+        /**
+         * Get the secure time.
+         * @since 2.6
+         * @param aTime           Output parameter containing the 
+         *                        secure time in UTC.
+         * @param aTimeZone       Time zone information including summer/winter time
+         *                        in +/- 15 minutes
+         * @param aSecurityLevel  Output parameter Securiry level.
+         * @return Symbian OS error code if any.
+         */
+        IMPORT_C TInt GetSecureTime( TTime& aTime, 
+                            TInt& aTimeZone,
+                            DRMClock::ESecurityLevel& aSecurityLevel ) const;
+                            
+        /**
+         * Update the secure time.
+         * @since 2.6
+         * @param aTime           Input parameter containing the 
+         *                        secure time in UTC.
+         * @param aTimeZone       Time zone information including summer/winter time
+         *                        in +/- 15 minutes         
+         * @return Symbian OS error code if any.
+         */
+        IMPORT_C TInt UpdateSecureTime( const TTime& aTime, const TInt& aTimeZone );
+                            
+        
+    public: // Functions from base classes
+        
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+        
+    private:
+        // Prohibit copy constructor if not deriving from CBase.
+        RDRMClockClient( const RDRMClockClient& );
+        // Prohibit assigment operator if not deriving from CBase.
+        RDRMClockClient& operator=( const RDRMClockClient& );
+        
+    public:     // Data
+        
+    protected:  // Data
+        
+    private:    // Data
+        
+    public:     // Friend classes
+        
+    protected:  // Friend classes
+        
+    private:    // Friend classes
+    };
+    
+#endif      // RDRMCLOCKCLIENT_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/DRMEventModify.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,176 @@
+/*
+* Copyright (c) 2004-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:  Rights object notification event
+*
+*/
+
+
+
+#ifndef CDRMEVENTMODIFY_H
+#define CDRMEVENTMODIFY_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <DRMEvent.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  DRM Rights Object notication event class
+*  Used as data structure in the notification service
+*
+*  @lib DRM Common
+*  @since S60Rel2.6
+*/
+
+class CDRMEventModify : public MDRMEvent, public CBase
+{
+public: // Constructors and destructor
+
+
+    /**
+    * NewLC
+    *
+    * Creates and instance of the CDRMEventModify class and
+    * returns a pointer to it Leaves the object in the cleanup
+    * stack
+    *
+    * @return A functional CDRMEventModify -object
+    * @since S60Rel3.0
+    */
+    IMPORT_C static CDRMEventModify* NewLC();
+
+    /**
+    * NewL
+    *
+    * Creates and instance of the CDRMEventModify class and
+    * returns a pointer to it
+    *
+    * @return A functional CDRMEventModify -object
+    * @since S60Rel3.0
+    */
+    IMPORT_C static CDRMEventModify* NewL();
+
+
+    /**
+    * Destructor
+    */   
+    IMPORT_C virtual ~CDRMEventModify();
+
+public: // new functions
+
+
+    /**
+    * SetContentIDL
+    *
+    * Sets the content id of the object and leaves if an error occurs
+    *
+    * @param aContentID : Descriptor containing the content id
+    * @since S60Rel2.6
+    */
+    IMPORT_C void SetContentIDL( const TDesC8& aContentID );
+
+    /**
+    * SetUniqueID
+    *
+    * Sets the content id of the related rights object
+    *
+    * @param aUniqueID : unique id of the rights object in question
+    * @since S60Rel2.6
+    */
+    IMPORT_C void SetUniqueID( const TUint32 aUniqueID );
+
+    /**
+    * UniqueID
+    *
+    * Returns the unique id of the rights object modified
+    *
+    * @since S60Rel2.6
+    */
+    IMPORT_C TUint32 UniqueID() const;
+
+    /**
+    * GetContentIDL
+    *
+    * Returns a pointer to newly reserved buffer that containts the
+    * content id. The caller must free the memory. 
+    *
+    * @since S60Rel2.6
+    */
+    IMPORT_C virtual HBufC8* GetContentIDL() const;
+
+
+public: // Functions from base classes
+    /**
+    * ExternalizeL
+    *
+    * Writes the objects data into a stream
+    *
+    * @param aOutput : an output stream where to write
+    * @since S60Rel2.6
+    */
+    IMPORT_C virtual void ExternalizeL(RWriteStream& aOutput);
+
+    /**
+    * InternalizeL
+    *
+    * Reads the objects data from a stream
+    *
+    * @param aInput : an input stream where to read from
+    * @since S60Rel2.6
+    */
+    IMPORT_C virtual void InternalizeL(RReadStream& aInput);
+
+private:
+    /**
+    * Constructor
+    */
+    CDRMEventModify(TUint32 aUniqueID);
+    
+    /**
+    * C++ default constructor.
+    */
+    CDRMEventModify( void );
+
+    /**
+    * First Phase constructor
+    */
+    void ConstructL();
+   
+    // Prohibit copy constructor 
+    CDRMEventModify( const CDRMEventModify& );
+
+    // Prohibit assigment operator 
+    CDRMEventModify& operator=( const CDRMEventModify& );
+
+    // The content identifier
+    HBufC8* iContentID;
+
+    // the unique id of the rights object in question
+    TUint32 iUniqueID;
+};
+
+#endif      // CDRMEVENTADDREMOVE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/DRMEventTimeChange.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,302 @@
+/*
+* 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:  Rights object notification event
+*
+*/
+
+
+
+#ifndef CDRMEVENTTIMECHANGE_H
+#define CDRMEVENTTIMECHANGE_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <DrmTypes.h>
+#include <DRMEvent.h>   
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  DRM Event notification class to notify about changes to
+*  secure time
+*
+*  @lib DRMCommon.dll
+*  @since S60Rel2.8
+*/
+
+class CDRMEventTimeChange : public MDRMEvent, public CBase 
+{
+public: // Constructors and destructor
+
+
+    /**
+    * NewLC
+    *
+    * Creates and instance of the CDRMEventTimeChange class and
+    * returns a pointer to it Leaves the object in the cleanup
+    * stack
+    *
+    * @return A functional CDRMEventTimeChange -object
+    * @since S60Rel3.0
+    */
+    IMPORT_C static CDRMEventTimeChange* NewLC();
+
+    /**
+    * NewL
+    *
+    * Creates and instance of the CDRMEventTimeChange class and
+    * returns a pointer to it
+    *
+    * @return A functional CDRMEventTimeChange -object
+    * @since S60Rel3.0
+    */
+    IMPORT_C static CDRMEventTimeChange* NewL();
+    
+    /**
+    * Destructor
+    */   
+    IMPORT_C virtual ~CDRMEventTimeChange();
+
+public: // new functions
+
+
+// Time
+    /**
+    * SetOldTime
+    *
+    * Sets the time before the change to the given value
+    *
+    * @param aTime : Old time
+    * @since S60Rel2.8
+    */
+    IMPORT_C void SetOldTime( const TTime& aTime );
+
+
+    /**
+    * GetOldTime
+    *
+    * Returns what the time was before the time changed 
+    *
+    * @since S60Rel2.8
+    */
+    IMPORT_C const TTime& GetOldTime() const;
+
+
+    /**
+    * SetNewTime
+    *
+    * Sets the time after the change to the given value
+    *
+    * @param aTime : New time
+    * @since S60Rel2.8
+    */
+    IMPORT_C void SetNewTime( const TTime& aTime );
+
+
+    /**
+    * GetNewTime
+    *
+    * Returns what the time is after the time changed 
+    *
+    * @since S60Rel2.8
+    */
+    IMPORT_C const TTime& GetNewTime() const;
+
+// Time zone
+    /**
+    * SetOldTimeZone
+    *
+    * Sets the timezone before the change to the given value
+    * in 15 minute intervals
+    *
+    * @param aTime : Old timezone
+    * @since S60Rel2.8
+    */
+    IMPORT_C void SetOldTimeZone( const TInt aTimeZone );
+
+
+    /**
+    * GetOldTimeZone
+    *
+    * Returns what the timezone was before the time changed
+    * in 15 minute intervals
+    *
+    * @since S60Rel2.8
+    */
+    IMPORT_C TInt GetOldTimeZone() const;
+
+
+    /**
+    * SetNewTimeZone
+    *
+    * Sets the timezone after the change to the given value
+    *
+    * @param aTimeZone : New timezone
+    * @since S60Rel2.8
+    */
+    IMPORT_C void SetNewTimeZone( const TInt aTimeZone );
+
+
+    /**
+    * GetNewTimeZone
+    *
+    * Returns what the timezone is after the time changed 
+    *
+    * @since S60Rel2.8
+    */
+    IMPORT_C TInt GetNewTimeZone() const;
+
+// Security level
+
+    /**
+    * SetOldSecurityLevel
+    *
+    * Sets the security level before the change to the given value
+    *
+    * @param aTime : Old security level
+    * @since S60Rel2.8
+    */
+    IMPORT_C void SetOldSecurityLevel( const DRMClock::ESecurityLevel aSecLevel );
+
+
+    /**
+    * GetOldSecurityLevel
+    *
+    * Returns what the security level was before the time changed
+    *
+    * @since S60Rel2.8
+    */
+    IMPORT_C DRMClock::ESecurityLevel GetOldSecurityLevel() const;
+
+
+    /**
+    * SetNewSecurityLevel
+    *
+    * Sets the security level after the change to the given value
+    *
+    * @param aSecLevel : New security level
+    * @since S60Rel2.8
+    */
+    IMPORT_C void SetNewSecurityLevel( const DRMClock::ESecurityLevel aSecLevel );
+
+
+    /**
+    * GetNewSecurityLevel
+    *
+    * Returns what the security level is after the time changed 
+    *
+    * @since S60Rel2.8
+    */
+    IMPORT_C DRMClock::ESecurityLevel GetNewSecurityLevel() const;
+
+public: // Functions from base classes
+
+    /**
+    * ExternalizeL
+    *
+    * Writes the objects data into a stream
+    *
+    * @param aOutput : an output stream where to write
+    * @since S60Rel2.8
+    */
+    IMPORT_C virtual void ExternalizeL(RWriteStream& aOutput);
+
+    /**
+    * InternalizeL
+    *
+    * Reads the objects data from a stream
+    *
+    * @param aInput : an input stream where to read from
+    * @since S60Rel2.8
+    */
+    IMPORT_C virtual void InternalizeL(RReadStream& aInput);
+
+
+    /**
+    * WriteInt64L
+    * 
+    * Writes the 64 bit integer to the stream
+    *
+    * @since    3.0
+    * @param    aWrite : the 64 bit integer to write
+    * @param    aStream : the output stream to write to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const;
+
+    /**
+    * ReadInt64L
+    * 
+    * Reads the 64 bit integer from the stream
+    *
+    * @since    3.0
+    * @param    aRead : the 64 bit integer read
+    * @param    aStream : the output stream to write to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void ReadInt64L( TInt64& aRead, RReadStream& aStream ); 
+
+private:
+    
+    /**
+    * C++ default constructor.
+    */
+    CDRMEventTimeChange( void );
+
+    /**
+    * First Phase constructor
+    */
+    void ConstructL();
+   
+    // Prohibit copy constructor
+    CDRMEventTimeChange( const CDRMEventTimeChange& );
+
+    // Prohibit assigment operator
+    CDRMEventTimeChange& operator=( const CDRMEventTimeChange& );
+
+    // The old time before the change
+    TTime iOldTime;
+
+    // The new time after the change
+    TTime iNewTime;
+    
+    // The old timezone before the change
+    TInt iOldTimeZone;
+    
+    // The new timezone after the change
+    TInt iNewTimeZone;
+    
+    // The old security level before the change
+    DRMClock::ESecurityLevel iOldSecurityLevel;
+    
+    // The new security level after the change
+    DRMClock::ESecurityLevel iNewSecurityLevel;
+    
+};
+
+#endif      // CDRMEVENTTIMECHANGE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/DRMHelperCommon.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  common file for both client and server
+*
+*/
+
+
+
+#ifndef DRMHELPERCOMMON_H
+#define DRMHELPERCOMMON_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// CONSTANTS
+
+//server name
+_LIT(KDRMHelperServerName,"CDRMHelperServer");
+_LIT( KDRMHSServerFileName , "DRMHelperServer" );
+_LIT(KDRMHelperServerSemaphoreName, "DRMHelperServerSemaphore");
+_LIT(KNullDate,"00000000:000000.000000");
+//interval for not endtime based rights
+const TInt KTimeIntervalYears = 10;
+
+//default value of informing interval
+const TInt KAboutToExpireInterval = 7;
+
+//the server version. A version must be specified when 
+//creating a session with the server
+const TUint KDRMHSMajorVersionNumber=0;
+const TUint KDRMHSMinorVersionNumber=1;
+const TUint KDRMHSBuildVersionNumber=1;
+
+
+// MACROS
+
+// DATA TYPES
+
+//opcodes used in message passing between client and server
+enum TDRMHelperServRqst
+    {
+    ERegister,
+    ERemove,
+    EIndicateIdle,
+    EIsRegistered,
+    };
+
+
+/** Panic Category */
+_LIT( KDRMHSServer, "CDRMHelperServer" );
+
+/**  panic codes */
+enum TDRMHelperServPanic
+    {
+    EBadDescriptor,
+    ESrvCreateServer,
+    ECreateTrapCleanup
+    };
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+
+#endif      // DRMHELPERCOMMON_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/DRMHelperServer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,392 @@
+/*
+* 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:  the server implementation of DRM Helper
+*
+*/
+
+
+#ifndef DRMHELPERSERVER_H
+#define DRMHELPERSERVER_H
+
+// INCLUDES
+#include <e32base.h>
+#include "DRMHelperCommon.h"
+#include <DRMEventObserver.h>
+#include <caf/caf.h>
+#include <DRMRightsClient.h> // RDRMRightsClient
+// DATA TYPES
+// FORWARD DECLARATIONS
+class CEndTimeBased;
+class CEndTimeFactory;
+class RWriteStream;
+class RReadStream;
+class CDRMNotifier;
+class CIdleObserver;
+class CDRMRights;
+class CConfigObserver;
+class CDRMPermission;
+class CEnvironmentChangeNotifier;
+
+// CLASS DECLARATION
+class TTimeBased
+    {
+    public:
+        void SetStart(const TTime& aStart) {iStartTime = aStart;};
+        void SetEnd(const TTime& aEnd) {iEndTime = aEnd;};
+        const TTime& StartTime(){return iStartTime;};
+        const TTime& EndTime(){return iEndTime;};
+    private:
+        TTime iStartTime;
+        TTime iEndTime;
+    };
+
+
+/**
+*  This class implements the DRM5 Helper Server functionality.
+*
+*  @lib DRMHelperServer.exe
+*  @since S60Rel3.0
+*/
+
+
+class CDRMHelperServer : public CServer2 , MDRMEventObserver
+    {
+    public:  // Constructors and destructor
+        
+         /**
+         * Two-phased constructor.
+         * @since S60Rel3.0
+         * @return Pointer to newly created server instance. And
+         *  push the oject into cleanup stack
+         */
+        static CDRMHelperServer* NewLC();
+
+        /**
+         * Destructor.
+         * @since S60Rel3.0
+         */
+        ~CDRMHelperServer();
+
+
+        
+    public: // New functions
+
+        /**
+         * Startup starts the actual DRM Helper server after initializing
+         * the cleanup stack and active scheduler.
+         * @since S60Rel3.0
+         * @return system error code if error happens
+         */
+        static TInt Startup();
+
+        /**
+         * HandleExpiredL handle expiration case for one item.
+         * @since S60Rel3.0
+         * @param aUri the specific content uri for this item.
+         * @param aTimes the times that this case has been informed .
+         */
+        void HandleExpiredL( CEndTimeBased*& aItem );
+
+        /**
+         * HandleIdleL inform all the cases that right is about to expire
+         * @since S60Rel3.0
+         */
+        void HandleIdleL();
+
+        /**
+         * UpdateL update items
+         * @since S60Rel3.0
+         * @param aUri the specific content uri for this item.
+         * @param aPermType permission type
+         * @param aRegType regist type
+         * @param aAutoType automatic type
+         */
+        void UpdateL();
+        void UpdateL( const TDesC8& aUri );
+        void UpdateL( const TDesC8& aUri , const TUint8& aPermType );
+        void UpdateL( const TDesC8& aUri , const TUint8& aPermType , const TUint8& aRegType );
+        void UpdateL( 
+                const TDesC8& aUri , 
+                const TUint8& aPermType , 
+                const TUint8& aRegType , 
+                const TUint8& aAutoType );
+
+        /**
+         * RegisterL register one item with specific content uri.
+         * @since S60Rel3.0
+         * @param aUri the specific content uri for this item.
+         * @param aPermType permission type
+         * @param aRegType regist type
+         * @param aAutoType automatic type
+         */
+        void RegisterL( 
+                        const TDesC8& aUri , 
+                        const TUint8& aPermType , 
+                        const TUint8& aRegType , 
+                        const TUint8& aAutoType );
+
+
+        /**
+         * IsRegistered register one item with specific content uri.
+         * @since S60Rel3.0
+         * @param aUri the specific content uri for this item.
+         * @param aPermType permission type
+         * @param aRegType regist type
+         * @param aAutoType automatic type
+         * @return ETrue if registered, otherwise EFalse
+         */
+        TBool IsRegistered(
+                        const TDesC8& aUri , 
+                        const TUint8& aPermType , 
+                        const TUint8& aRegType , 
+                        const TUint8& aAutoType );
+        /**
+         * IsRegistered register one item with specific content uri.
+         * @since S60Rel3.0
+         * @param aUri the specific content uri for this item.
+         * @param aPermType permission type
+         * @param aRegType regist type
+         * @return ETrue if registered, otherwise EFalse
+         */
+        TBool IsRegistered(
+                        const TDesC8& aUri , 
+                        const TUint8& aPermType , 
+                        const TUint8& aRegType  );                
+
+
+        /**
+         * IsRegistered register one item with specific content uri.
+         * @since S60Rel3.0
+         * @param aUri the specific content uri for this item.
+         * @param aRegType regist type
+         * @return ETrue if registered, otherwise EFalse
+         */
+        TBool IsRegistered2(
+                        const TDesC8& aUri , 
+                        const TUint8& aRegType,
+                        const TUint8& aAutoType  );
+
+        /**
+         * RemoveL remove one item with specific content uri. 
+         * @since S60Rel3.0
+         * @param aPermType permission type
+         * @param aRegType regist type
+         * @param aAutoType automatic type
+         * @param aUri the specific content uri for this item.
+         */
+        void RemoveL(
+                        const TDesC8& aUri , 
+                        const TUint8& aPermType , 
+                        const TUint8& aRegType , 
+                        const TUint8& aAutoType );
+
+        /**
+         * StoreL store the list into data file
+         * @since S60Rel3.0
+         */
+        void StoreL();
+
+        /**
+         * RestoreL restore the list from data file 
+         * @since S60Rel3.0
+         */
+        void RestoreL();
+
+        /**
+         * ExternalizeL externalize the list into data file
+         * @param aStream the data file stream.
+         * @since S60Rel3.0
+         */
+        void ExternalizeL(RWriteStream& aStream) const;
+
+        /**
+         * InternalizeL internalize the list from data file
+         * @param aStream the data file stream.
+         * @since S60Rel3.0
+         */
+        void InternalizeL(RReadStream& aStream);
+
+        /**
+         * RemoveAllL remove all the items in the list
+         * @since S60Rel3.0
+         */
+        void RemoveAllL();
+
+        /**
+         * GetNotificationL register one item to notifier in order to get notification if rights changed
+         * @since S60Rel3.0
+         * @param aUri the content uri for the item.
+         */
+        void GetNotificationL(const TDesC8& aUri);
+
+        /**
+         * RemoveNotificationL unregister item from notifier
+         * @since S60Rel3.0
+         * @param aUri the content uri for the item.
+         */
+        void RemoveNotificationL(const TDesC8& aUri);
+
+        /**
+         * UiTimeChanged 
+         * 
+         * callback function for CEnvironmentChangeNotifier when UI time is changed 
+         * @since S60Rel2.6
+         * @param aPointer a Helper Server instance
+         */        
+        static TInt UiTimeChanged(void* aPointer);
+
+    public: // Functions from base classes
+         /**
+         * HandleEventL from MDRMEventObserver
+         * @since S60Rel3.0
+         * @param aEvent an event from DRM notifier
+         */
+        void HandleEventL( MDRMEvent* aEvent ); 
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+        //class CServer
+        /**
+         * RunError.
+         * @since S60Rel3.0
+         * @param aError Error code from RunL function.
+         * @return An error is returned if RunError() cannot process the
+         * error.
+         */
+        TInt RunError( TInt aError );
+        
+    private:
+        /**
+         * C++ default constructor.
+         * @since S60Rel3.0
+         */
+        CDRMHelperServer();
+        
+        /**
+         * By default Symbian 2nd phase constructor is private.
+         * @since S60Rel3.0
+         */
+        void ConstructL();
+
+        /**
+         * @function PanicClient
+         * @semantics panic the client
+         * @param aMessage the message channel to the client
+         * @param aReason the reason code for the panic.
+         */
+        static void PanicClient(const RMessage2& aMessage, TDRMHelperServPanic aReason);
+
+        /*!
+         * @function PanicServer
+         * @semantics panic the server
+         * @param aReason the reason code for the panic.
+         */
+        static void PanicServer(TDRMHelperServPanic aReason);
+
+        /**
+         * StartupL called by StartUp
+         * @since S60Rel3.0 
+         */
+        static void StartupL();
+
+        /**
+         * CheckExpiration check the expiration info for one content uri
+         * @since S60Rel3.0
+         * @param aUri content uri.
+         * @param aEndTime end time for rights.
+         * @param aPermType permission type
+         * @param aRegType regist type
+         * @return CDRMRights::EFullRights or DRMCommon::ENoRights or EOk
+         */
+        void CheckExpirationL( 
+                const TDesC8& aUri , 
+                const TUint8& aPermType , 
+                const TUint8& aRegType , 
+                TTime& aEndTime );
+
+        /**
+         * SetKeyValueL set key value for CenRep structure
+         * @since S60Rel3.0
+         * @param aKeyValue key value.
+         */
+        void SetKeyValueL( const TDesC8& aKeyValue , const TUint8& aRegType );
+        
+        /**
+         * FormatKeyValueL format key value for CenRep structure
+         * 
+         * @since S60Rel3.0
+         * @param aBuf key value. it is pushed into cleanup stack
+         * @param aUri the specific content uri for this item.
+         * @param aTimes the times that this case has been informed.
+         * @param aMark 'E' if expired 'V' if about to expire
+         */
+        void FormatKeyValueLC( HBufC8*& aBuf , CEndTimeBased*& aItem , const TDesC8& aMark );
+
+        /**
+         * CheckPermission get time based info from permission
+         * 
+         * @since S60Rel3.0
+         * @param aPermission permission from DRM Rights database
+         * @param aPermType permission type
+         * @param aTime to store start and end time
+         * @param aInterval to store time interval
+         * @param aIndividual to check invididual constraints
+         * @return 
+         */        
+        void CheckPermission(
+                CDRMPermission* aPermission ,
+                const TUint8& aPermType , 
+                TTimeBased& aTime , 
+                TTimeIntervalSeconds& aInterval,
+                const RPointerArray<HBufC8>& aIndividual );
+        
+        ContentAccess::TIntent MapPermissionType(TUint8 aPermType);
+    private: // Functions from base classes
+        // Class CServer
+        /** 
+         * NewSessionL
+         * @since S60Rel3.0
+         */
+        CSession2* NewSessionL( const TVersion& aVersion,
+                                       const RMessage2& aMessage ) const;
+        
+    public:     // Data
+        //opcodes used in message passing between client and server
+        enum TDRMHSServiceType
+            {
+            EActive = 101,
+            EPassive = 102
+            };
+    protected:  // Data
+        
+    private:    // Data
+        CEndTimeFactory* iEndTimeFactory;  
+        CDRMNotifier* iNotifier;
+        CIdleObserver* iIdleObserver;
+        CEnvironmentChangeNotifier* iUiTimeNotifier;
+        RFs iFs;
+        RDRMRightsClient iDrm;
+    public:     // Friend classes
+        
+    protected:  // Friend classes
+        
+    private:    // Friend classes
+
+};
+
+
+
+#endif      // DRMHELPERSERVER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/DRMHelperSession.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,145 @@
+/*
+* 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:  the server session implementation of DRM Helper
+*
+*/
+
+
+#ifndef DRMHELPERSESSION_H
+#define DRMHELPERSESSION_H
+
+// INCLUDES
+#include <e32base.h>
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+
+
+/**
+*  Server session of DRM Helper
+*  This class is the server side instance of C/S communications of a certain
+*  session.
+*
+*  @lib DRMHelperServer.exe
+*  @since S60Rel2.6
+*/
+class CDRMHelperSession : public CSession2
+{
+    public:  // Constructors and destructor
+   
+        /**
+        * Two-phased constructor.
+        * @since S60Rel2.6
+        * @param aClient Associated client side thread.
+        * @return New session instance.
+        */
+        static CDRMHelperSession* NewL();
+   
+        /**
+        * Destructor.
+        * @since S60Rel2.6
+        */
+        virtual ~CDRMHelperSession();
+   
+    public: // New functions
+   
+    public: // Functions from base classes
+   
+        /**
+        * From CSession: Handles the service request event.
+        * @since S60Rel2.6
+        * @param aMessage The message related to the event.
+        * @exception Method leaves with appropriate exception value
+        *            if any errors occured.
+        */
+        void ServiceL( const RMessage2& aMessage );
+   
+    protected:  // New functions
+   
+    protected:  // Functions from base classes
+   
+    private:
+   
+        /**
+        * C++ constructor.
+        * @since S60Rel2.6
+        * @param aClient Client thread.
+        * 
+        */
+        CDRMHelperSession();
+   
+  
+        /** 
+        * ServiceL() runs DispatchL() under TRAP harness, so
+        * all errors can be catched properly. DispatchL() then calls
+        * appropriate private method depending on the request.
+        * @since S60Rel2.6
+        * @param aMessage The message associated to the event.
+        */
+        void DispatchL( const RMessage2& aMessage );
+   
+        /** 
+        * RegisterL register the automated content into server 
+        * @since S60Rel2.6
+        * @param aMessage The message associated to the event.
+        */
+        void RegisterL( const RMessage2& aMessage );
+
+
+        /** 
+        * IsRegisteredL check if the automated content is registered into server 
+        * @since S60Rel2.6
+        * @param aMessage The message associated to the event.
+        */
+        void IsRegisteredL( const RMessage2& aMessage );
+
+
+        /** 
+        * RemoveL remove the automated content from server 
+        * @since S60Rel2.6
+        * @param aMessage The message associated to the event.
+        */
+        void RemoveL( const RMessage2& aMessage );
+
+
+        /** 
+        * IndicateIdleL indicate the ilde time comes
+        * @since S60Rel2.6
+        * @param aMessage The message associated to the event.
+        */
+        void IndicateIdleL( const RMessage2& aMessage );
+
+        // Prohibit copy constructor.
+        CDRMHelperSession( const CDRMHelperSession& );
+        // Prohibit assigment operator.
+        CDRMHelperSession& operator=( const CDRMHelperSession& );
+   
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+   
+};
+
+
+
+#endif      // DRMHELPERSESSION_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/DrmKeyStorage.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef DRMKEYSTORAGE_H
+#define DRMKEYSTORAGE_H
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  CDrmKeyStorage: Contains key storage for OMA DRM 2.0
+*
+*  @lib    -
+*  @since  3.0
+*/
+class MDrmKeyStorage
+    {
+public:
+    static const TInt KDeviceSpecificKeyLength = 16;
+    static const TInt KRdbSerialNumberLength = 16;
+    
+public: // New functions
+
+    virtual ~MDrmKeyStorage() = 0;
+    
+    virtual TInt ModulusSize() = 0;
+
+    virtual void SelectTrustedRootL(
+        const TDesC8& aRootKeyHash) = 0;
+        
+    virtual TBool SelectedRootIsCmla() = 0;
+        
+    virtual void SelectDefaultRootL() = 0;
+        
+    virtual void GetTrustedRootsL(
+        RPointerArray<HBufC8>& aRootList) = 0;
+        
+    virtual void GetCertificateChainL(
+        RPointerArray<HBufC8>& aCertChain) = 0;
+        
+    virtual HBufC8* RsaSignL(
+        const TDesC8& aInput) = 0;
+    
+    virtual HBufC8* RsaDecryptL(
+        const TDesC8& aInput) = 0;
+        
+    virtual void ImportDataL(
+        const TDesC8& aPrivateKey,
+        const RArray<TPtrC8>& aCertificateChain) = 0;
+        
+    virtual void GetDeviceSpecificKeyL(
+        TBuf8<KDeviceSpecificKeyLength>& aKey) = 0;
+        
+    virtual void GetRdbSerialNumberL(
+    	TBuf8<KRdbSerialNumberLength>& aSerialNumber) = 0;
+    	
+   	virtual void GenerateNewRdbSerialNumberL() = 0;
+   	
+   	virtual HBufC8* UdtEncryptL(
+   	    const TDesC8& aInput) = 0;
+   	    
+   	virtual void GetRootCertificatesL(
+        RPointerArray<HBufC8>& aRootCerts) = 0; 
+
+    virtual void RandomDataGetL( 
+        TDes8& aData, 
+        const TInt aLength ) = 0; 
+
+    };
+    
+IMPORT_C MDrmKeyStorage* DrmKeyStorageNewL();
+
+#endif      // DRMKEYSTORAGE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/DrmUdtHandler.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,207 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#ifndef DRM_UDT_MODULE_H
+#define DRM_UDT_MODULE_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <http.h>
+#include <stringpool.h>
+#include <http/mhttpauthenticationcallback.h>
+#include "DrmUdtObserver.h"
+
+
+// FORWARD DECLARATIONS
+class CDrmUdtConn;
+class CPeriodic;
+class MDrmUdtObserver;
+
+// CLASS DECLARATION
+
+class CDrmUdtHandler: public CActive,
+                      public MHTTPTransactionCallback,
+                      public MHTTPDataSupplier
+    {
+    public:     // Constructors and destructor
+    
+        enum TUdtErrorCode
+            {
+            EUdtOk = KErrNone,
+            EUdtClientError = -100,
+            EUdtServerError = -101,
+            EUdtInvalidServerAddress = -102,
+            EUdtKeyRestoreFailed = -103
+            };
+  
+        /**
+        * Two-phased constructor
+        */
+        IMPORT_C static CDrmUdtHandler* NewL();
+
+        /**
+        * Destructor
+        */
+        IMPORT_C virtual ~CDrmUdtHandler();
+
+    public:     // new methods
+
+        /**
+        * DoUserDataTransferL
+        *
+        * 
+        * @since  3.0
+        * @param  aOneTimePassword:
+        * @param  aRdbFileName:
+        * @param  aServiceUrl:
+        * @param  aStatus:
+        *
+        *
+        * @leave  System wide error code
+        */  
+        EXPORT_C void DoUserDataTransferL( const TDesC8& aOneTimePassword,
+                                           const TDesC8& aServiceUrl,
+                                           MDrmUdtObserver* aObserver,
+                                           TRequestStatus& aStatus );
+                                                           
+        /**
+        * SetPreferredIap
+        * 
+        * 
+        * @since  3.0
+        * @param  aPreferredIap:
+        *                        
+        *
+        * @leave  System wide error code
+        */  
+        IMPORT_C void SetPreferredIap( TUint32 aPreferredIap );
+
+
+    protected:  // from CActive
+
+        virtual void DoCancel();
+
+        virtual void RunL();
+
+        virtual TInt RunError( TInt aError );
+
+    protected:  // from MHTTPTransactionCallback
+
+        virtual void MHFRunL( RHTTPTransaction aTransaction,
+                              const THTTPEvent& aEvent );
+
+        virtual TInt MHFRunError ( TInt aError,
+                                   RHTTPTransaction aTransaction,
+                                   const THTTPEvent& aEvent );
+
+    protected:  // from MHTTPDataSupplier
+
+        virtual TBool GetNextDataPart( TPtrC8& aDataPart );
+
+        virtual void ReleaseData();
+
+        virtual TInt OverallDataSize();
+
+        virtual TInt Reset();
+        
+    private:    // functions
+    
+    void ConnectL();
+    
+    void CreateSessionL();
+
+    void SendUdtMessageL();
+    
+    void ResponseReceivedL();
+   
+    void CreateUdtRequestL();
+    
+    void ReadUdtDataL( TDes8& aTargetSerialNumber,
+                       TInt& aUdtKeyVersion,
+                       TDes8& aEncryptedRdbData );
+                       
+    HBufC* SerialNumberL();
+ 
+    void CreateStatusNotificationL();
+    
+    void InstallHttpFiltersL();
+    
+    void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue);
+
+    void HandleResponseHeadersL( RHTTPResponse aHttpResponse );
+           
+    TBool CheckHttpCode( TInt aHttpStatus );
+
+    TInt AppendResponseData( const TDesC8& aDataChunk );
+    
+    void TimeOut();
+   
+    static TInt StaticTimeOut( TAny* aPointer );
+    
+    void SelfComplete( TInt aResult );
+    
+    void Complete();
+
+    private:    // types
+
+        enum TState
+            {
+            EInit,
+            EStart,
+            EConnect,
+            ESendMessage,
+            EResponseReceived,
+            EComplete
+            };
+            
+        enum TRequestType
+            {
+            EUdtRequest,
+            EStatusNotification
+            };
+
+    private:    // Constructors and destructor
+     
+        CDrmUdtHandler();
+    
+        void ConstructL();
+        
+    private:    // Data
+    
+        RHTTPSession iSession;
+        RHTTPTransaction iTransaction;
+        CDrmUdtConn* iConnection;
+        CPeriodic* iTimeout;
+        TState iState;
+        TRequestType iRequestType;
+        TRequestStatus* iParentStatus;
+        TInt iError;
+        TUint32 iPreferredIap;
+        TInt iUdtError;
+
+        HBufC8* iUri;
+        HBufC8* iOneTimePassword;
+        HBufC8* iUdtRequest;
+        HBufC8* iUdtResponse;
+        MDrmUdtObserver* iObserver;
+        TUdtStateInfo iStateInfo;
+        
+    };
+    
+#endif  // DRM_UDT_HANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/DrmUdtObserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#ifndef DRM_UDT_OBSERVER_H
+#define DRM_UDT_OBSERVER_H
+
+// INCLUDES
+// CLASS DECLARATION
+
+class TUdtStateInfo
+    {
+    public:
+    
+    enum TUdtState
+        {
+        EUdtNotStarted,
+        EUdtReguest,
+        EUdtStatusNotification,
+        EUdtRegistration,
+        EUdtDeleteConfirmation,
+        EUdtKeyRestore,
+        EUdtComplete
+        };
+        
+    TUdtState iState;
+    
+    TInt iProgress; // 0 - 100
+    
+    TInt iError;
+    };
+
+class MDrmUdtObserver
+    {
+    public:
+    
+    /**
+    * ConnectionStartedL
+    * 
+    * The function is called by DrmUdtModule when a network connection is to
+    * be established.
+    * 
+    * @since  3.0
+    *
+    * @leave  System wide error code */
+    virtual void ConnectionStartedL() = 0;
+
+    /**
+    * UdtProgressInfoL
+    * 
+    * The function is called by DrmUdtModule to provide UDT state information to the caller
+    * 
+    * @since  3.0
+    *
+    * @leave  System wide error code */
+    virtual void UdtProgressInfoL( TUdtStateInfo& aProgress ) = 0;
+    
+    };
+    
+#endif /* DRM_UDT_OBSERVER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/DrmUtilityInternalcrkeys.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handling DRM UTILITY entry visibility in Inbox
+*
+*/
+
+
+
+#ifndef DRMUTILITYOMABASEDINTERNALCRKEYS_H
+#define DRMUTILITYOMABASEDINTERNALCRKEYS_H
+
+const TUid KCRUidOmaBased = {0x20022D51};
+
+const TUint32 KDrmOmaBasedName =  0x00000001;
+
+const TUint32 KOmaBasedMimeType = 0x00000002;
+
+const TUint32 KDrmOmaBasedUID = 0x00000003;
+
+#endif      // DRMUTILITYOMABASEDINTERNALCRKEYS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/Oma1Dcf.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,173 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef OMA1DCF_H
+#define OMA1DCF_H
+
+//  INCLUDES
+#include "DcfCommon.h"
+
+// CONSTANTS
+const TUint KOma1DcfVersion = 0x00010000;
+_LIT8(KContentName, "Content-Name");
+_LIT8(KContentDescription, "Content-Description");
+_LIT8(KRightsIssuer, "Rights-Issuer");
+_LIT8(KContentVendor, "Content-Vendor");
+_LIT8(KIconURI, "Icon-URI");
+
+// FORWARD DECLARATIONS
+class RWriteStream;
+class RFile;
+
+// CLASS DECLARATION
+
+/**
+*  Encapsulates an OMA DRM 1 DCF content file
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series 60 3.0
+*/
+class COma1Dcf : public CDcfCommon
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static COma1Dcf* NewL(
+            const RFile& aFile);
+            
+        IMPORT_C static COma1Dcf* NewL(
+            const TDesC8& aMemoryBlock);
+
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~COma1Dcf();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        IMPORT_C static TBool IsValidDcf(
+            const TDesC8& aDcfFragment);
+
+        TInt ReadHeaderL(
+            const TDesC8& aMemoryBlock);
+
+        TInt ReadHeaderL(void);
+
+        TInt CreateHeaderL(
+            RWriteStream&); // use only when you know what you're doing! Writes only the header?
+            
+        TInt CheckUniqueId(
+            const TDesC& aUniqueId);
+            
+        TInt OpenPart(
+            const TDesC& aUniqueId);
+            
+        TInt OpenPart(
+            TInt aPart);
+            
+        void GetPartIdsL(
+            RPointerArray<HBufC8>& aPartList);
+            
+        void ReadHeaderValuesL(void);
+            
+        IMPORT_C TInt GetHeaderL(
+            const TDesC8& aHeaderName,
+            TPtrC8& aHeaderValue);
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        COma1Dcf();
+
+        void ConstructL(
+            const RFile& aFile);
+            
+        void ConstructL(
+            const TDesC8& aMemoryBlock);
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // COma1Dcf( const COma1Dcf& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // COma1Dcf& operator=( const COma1Dcf& );
+        
+        static HBufC8* FetchOmaBasedInfoL();
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        TUint iHeaderLength;
+
+        HBufC8* iHeaders;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+        
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+#endif      // OMA1DCF_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/OmaCrypto.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,116 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef OMACRYPTO_H
+#define OMACRYPTO_H
+
+#include <bigint.h>
+
+// FORWARD DECLARATIONS
+
+class CRSAPrivateKey;
+class CRSAPublicKey;
+class MDrmKeyStorage;
+
+// CLASS DECLARATION
+
+/**
+*  OmaCrypto: Contains crypto operations for OMA DRM 2.0
+*
+*  @lib    -
+*  @since  3.0
+*/
+class OmaCrypto
+    {
+public: // Constants    
+
+    static const TInt KKeySize = 16;
+    static const TInt KMacSize = 16;
+    static const TInt KWrapBlockSize = 8;
+    static const TInt KWrappedKeySize = KKeySize + KMacSize + KWrapBlockSize;
+    static const TInt KPssSaltLength = 20;
+
+public: // New functions
+
+    IMPORT_C static HBufC8* RsaDecryptL(
+        MDrmKeyStorage* aKeyStorage,
+        const TDesC8& aInput);
+
+    IMPORT_C static HBufC8* RsaEncryptL(
+        CRSAPublicKey* aKey,
+        const TDesC8& aInput);
+    
+    IMPORT_C static HBufC8* RsaVerifyL(
+        CRSAPublicKey* aKey,
+        const TDesC8& aInput);
+    
+    IMPORT_C static HBufC8* RsaKemKwsEncryptL(
+        CRSAPublicKey* aKey,
+        const TDesC8& aRek,
+        const TDesC8& aMac);
+
+    IMPORT_C static void RsaKemKwsDecryptL(
+        MDrmKeyStorage* aKeyStorage,
+        const TDesC8& aInput,
+        TDes8& aRek,
+        TDes8& aMac);
+
+    IMPORT_C static HBufC8* KdfL(
+        const TDesC8& aInput,
+        const TDesC8& aOtherData,
+        TInt aKLen);
+
+    IMPORT_C static HBufC8* AesWrapL(
+        const TDesC8& aKey,
+        const TDesC8& aInput);
+
+    IMPORT_C static HBufC8* AesUnwrapL(
+        const TDesC8& aKey,
+        const TDesC8& aInput);
+        
+    IMPORT_C static HBufC8* I2OSPL(
+        RInteger& aInt);
+
+    IMPORT_C static RInteger OS2IPL(
+        const TDesC8& aOctetStream);
+
+    IMPORT_C static HBufC8* Mgf1L(
+        const TDesC8& aMfgSeed,
+        TInt aMaskLen);
+        
+    IMPORT_C static HBufC8* RsaPssSignHashL(
+        MDrmKeyStorage* aKeyStorage,
+        const TDesC8& aMHash);
+
+    IMPORT_C static TBool RsaPssVerifyHashL(
+        CRSAPublicKey* aKey,
+        const TDesC8& aSignature,
+        const TDesC8& aMHash);
+        
+protected: // New functions
+
+    IMPORT_C static void WriteUint32ToBlock(
+        TUint32 aInt,
+        TDes8& aBlock,
+        TInt aOffset);
+    };
+
+#endif      // OMACRYPTO_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/RecDRM.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,43 @@
+/*
+* 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:  Symbian recognizer for DRM protected files
+*
+*/
+
+
+#if !defined(__RECDRM_H__)
+#define __RECDRM_H__
+
+#include <apmrec.h>
+
+#include <DRMCommon.h>
+
+class CApaDRMRecognizer : public CApaDataRecognizerType
+	{
+public: // from CApaDataRecognizerType
+	CApaDRMRecognizer();
+	~CApaDRMRecognizer();
+	static CApaDataRecognizerType* CreateRecognizerL();
+	TUint PreferredBufSize();
+	TDataType SupportedDataTypeL( TInt aIndex ) const;
+private: // from CApaDataRecognizerType
+	void DoRecognizeL( const TDesC& aName, const TDesC8& aBuffer );
+
+private:
+  	TBool RecognizeRoapTrigger( const TDesC8& aBuffer );
+  	TBool RecognizeODF( const TDesC8& aBuffer );
+	TBool iNameRecognized;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/RoapStorageClient.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,188 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client Class of ROAP Storage Server
+*
+*/
+
+
+
+#ifndef ROAPSTORAGECLIENT_H
+#define ROAPSTORAGECLIENT_H
+
+#include <Oma2Agent.h>
+
+//  INCLUDES
+
+class CRSAPrivateKey;
+class CRSAPublicKey;
+class CDRMRIContext;
+class CDRMDomainContext;
+
+namespace Roap
+    {
+
+    // CLASS DECLARATION
+
+    /**
+    *  RRoapStorageClient
+    *
+    *  @lib drmserverinterfaces.lib
+    *  @since Series 60 3.0
+    */
+    NONSHARABLE_CLASS( RRoapStorageClient ) : public RSessionBase
+        {
+    public:
+        // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C RRoapStorageClient();
+
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~RRoapStorageClient();
+
+    public:
+        // New functions
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        IMPORT_C TInt Connect();
+
+        IMPORT_C TInt GetDevicePublicKeyL( CRSAPublicKey*& aPublicKey );
+
+        IMPORT_C TInt GetDevicePublicKeyDerL( HBufC8*& aPublicKey );
+
+        IMPORT_C TInt GetDevicePublicKeyHashL( TDes8& aHash );
+
+        IMPORT_C TInt GetDeviceCertificateChainL(
+            RPointerArray<HBufC8>& aCertChain );
+
+        IMPORT_C TInt SignL( const TDesC8& aHash, HBufC8*& aSignature );
+
+        IMPORT_C TInt RsaSignL( const TDesC8& aHash, HBufC8*& aSignature );
+
+        IMPORT_C TBool VerifyL(
+            const TDesC8& aSignature,
+            const TDesC8& aHash,
+            const RPointerArray<HBufC8>& aCertificateChain );
+
+        IMPORT_C CDRMRIContext* GetRIContextL( const TDesC8& aRiID );
+
+        IMPORT_C CDRMDomainContext* GetDomainContextL(
+            const TDesC8& aDomainID );
+
+        IMPORT_C void AddRIContextL( const CDRMRIContext& aRiContext );
+
+        IMPORT_C void AddDomainContextL(
+            const CDRMDomainContext& aDomainContext,
+            const RPointerArray<HBufC8>& aMacs,
+            const RPointerArray<HBufC8>& aDomainKeyElements,
+            TKeyTransportScheme& aTransportScheme );
+
+        IMPORT_C void DeleteRiContextL( const TDesC8& aRiID );
+
+        IMPORT_C void DeleteDomainContextL( const TDesC8& aDomainID );
+
+        IMPORT_C void DeleteExpiredRIsL( const TTime& aTime );
+
+        IMPORT_C void DeleteExpiredDomainsL( const TTime& aTime );
+
+        IMPORT_C void DeleteExpiredContextsL( const TTime& aTime );
+
+        IMPORT_C void DeleteAllL();
+
+        /*
+        * WhiteListURLExistsL
+        * @param aURL, url to be searched in white lists
+        * @param (inout) aInPreconfiguredWhiteList
+        *     as in parameter: define whether or not to search from
+        *         pre-defined whitelist
+        *         ETrue: given URL is not searched from whitelistURL
+        *         EFalse: given URL is not searched from whitelistURL
+        *     as out parameter: define whether or not url has been
+        *         searched and found from pre-defined whitelist
+        *         ETrue: parameter was initially false,
+        *             hostname part of aURL does not match hostname part
+        *             in any RI URL of any existing RI conext,
+        *             and aURL matched at least one of pre-defined
+        *             whitelist URLs
+        *         EFalse otherwise
+        *         @note EFalse also if hostname part of aURL
+        *             matches any hostname part in any RI URLs
+        *             of any existing RI context
+        *
+        * @return
+        *     ETrue: aURL is in white list
+        *     EFalse: aURL is not in white list
+        */
+        IMPORT_C TBool WhiteListURLExistsL( const TDesC8& aURL,
+            TBool& aFromPreconfiguredWhiteList );
+
+        IMPORT_C TInt SelectTrustedRootL(
+            const RPointerArray<HBufC8>& aTrustedRoots,
+            TDes8& aSelectedRoot ) const;
+
+        IMPORT_C TInt SelectTrustedRootL( const TDesC8& aTrustedRoot ) const;
+
+        IMPORT_C void
+            GetTrustedRootsL( RPointerArray<HBufC8>& aTrustedRoots ) const;
+
+        IMPORT_C HBufC8* GetRootCertificateL( const TDesC& aSubject ) const;
+
+        IMPORT_C HBufC8* GetMeteringDataL(
+            TDesC8& aRiId,
+            TDes8& aMacKey,
+            TDes8& aEncKeyHash,
+            HBufC8*& aEncryptedMekAndMak );
+
+        IMPORT_C void DeleteMeteringDataL( const TDesC8& aRiId );
+
+        IMPORT_C void GetAllRIContextsL(
+            RPointerArray<CDRMRIContext>& aRiContexts );
+
+        IMPORT_C void UpdateRIContextL( const CDRMRIContext& aContext );
+
+        IMPORT_C TBool UpdateDrmTimeL(
+            const RPointerArray<HBufC8>& aCertChain,
+            const RPointerArray<HBufC8>& aOCSPResponses,
+            const TDesC8& aNonce );
+
+        IMPORT_C TBool VerifyOcspResponsesL(
+            const RPointerArray<HBufC8>& aOcspResponses,
+            const TDesC8& aRiCaCert,
+            const RPointerArray<HBufC8>& aCertSerialNums );
+
+        IMPORT_C HBufC8* GetOcspResponderIdL( const TDesC8& aRiID );
+
+
+    private:
+
+        // Prohibit copy constructor if not deriving from CBase.
+        RRoapStorageClient( const RRoapStorageClient& );
+        // Prohibit assignment operator if not deriving from CBase.
+        RRoapStorageClient& operator=( const RRoapStorageClient& );
+
+        };
+    }
+
+#endif // ROAPSTORAGECLIENT_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/cleanupresetanddestroy.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,51 @@
+/*
+* 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:  Utility class for putting to cleanup stack
+*                RPointerArray class which owns its members
+*
+*/
+
+#ifndef _TR1SIDO_1_CLEANUPRESETANDDESTROY_H
+#define _TR1SIDO_1_CLEANUPRESETANDDESTROY_H
+// ----------------------------------------------------------------------------
+// CleanupUtility for RpointerArrays
+// Does RPointerArray< >->ResetAndDestroy() for the given array aPtr.
+//
+// Note: when using this class ensure that you include the header <e32base.h>
+// and you link against euser.lib
+// ----------------------------------------------------------------------------
+//
+template<typename T>
+class CleanupResetAndDestroy
+    {
+public:
+    /**
+     Puts an item on the cleanup stack.
+
+     @param  aRef
+     The implementation information to be put on the cleanup stack.
+     */
+    inline static void PushL( T& aRef );
+private:
+    static void ResetAndDestroy( TAny *aPtr );
+    };
+
+#include "cleanupresetanddestroy.inl"
+//
+// ----------------------------------------------------------------------------
+// End of CleanupUtility for RpointerArrays
+// ----------------------------------------------------------------------------
+
+
+#endif // _TR1SIDO_1_CLEANUPRESETANDDESTROY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/cleanupresetanddestroy.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,52 @@
+/*
+* 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:  Utility class for putting to cleanup stack
+*                RPointerArray class which owns its members
+*
+*/
+
+#ifndef _TR1SIDO_1_CLEANUPRESETANDDESTROY_INL
+#define _TR1SIDO_1_CLEANUPRESETANDDESTROY_INL
+
+template<typename T>
+inline void CleanupResetAndDestroyPushL( T& aRef );
+
+// ---------------------------------------------------------------------------
+// CleanupResetAndDestroy::PushL
+// ---------------------------------------------------------------------------
+template<typename T>
+inline void CleanupResetAndDestroy<T>::PushL( T& aRef )
+    {
+    CleanupStack::PushL( TCleanupItem( &ResetAndDestroy, &aRef ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CleanupResetAndDestroy::ResetAndDestroy
+// ---------------------------------------------------------------------------
+template<typename T>
+void CleanupResetAndDestroy<T>::ResetAndDestroy( TAny *aPtr )
+    {
+    ( static_cast<T*> ( aPtr ) )->ResetAndDestroy();
+    }
+
+// ---------------------------------------------------------------------------
+// CleanupResetAndDestroyPushL
+// ---------------------------------------------------------------------------
+template<typename T>
+inline void CleanupResetAndDestroyPushL( T& aRef )
+    {
+    CleanupResetAndDestroy<T>::PushL( aRef );
+    }
+
+#endif // _TR1SIDO_1_CLEANUPRESETANDDESTROY_INL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/drmrightsdb.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,682 @@
+/*
+* 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:  Interface for the DRM Rights database
+*
+*/
+
+
+#ifndef DRMRIGHTSDB_H
+#define DRMRIGHTSDB_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <s32mem.h>
+#include "DRMBackupInterface.h"
+#include "DRMTypes.h"
+
+// CONSTANTS
+
+// Directory for temp files
+_LIT( KDRMDbTempPath, "c:\\system\\temp\\" );
+
+// The primary database temp file
+_LIT( KDRMDbTempFileName, "c:\\private\\101F51F2\\RightsServer.tmp" );
+
+// These are internally defined in the DRM Authenticated API
+// If they change they should be also changed here
+_LIT8( KFLKString, "flk:" );
+LOCAL_C const TInt KFLKStringLength = 4;
+
+_LIT8( KCIDString, "cid:" );
+LOCAL_C const TInt KCIDStringLength = 4;
+
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class CDRMPermission;
+class RFs;
+class CMD5;
+class RReadStream;
+class RWriteStream;
+class CLogFile;
+class CDRMRightsCleaner;
+class CDRMRightsServer;
+class CDcfRep;
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMRightsDB implements the rights database required by DRM Engine
+*
+*  @lib RightsServer.dll
+*  @since 2.5
+*/
+
+NONSHARABLE_CLASS( CDRMRightsDB ) : public CBase , 
+                                    public MDRMBackupInterface
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * NewLC
+        *
+        * Creates an instance of the CDRMRightDB class and returns a pointer 
+        * to it The function leaves the object into the cleanup stack
+        *
+        * @since  3.0
+        * @param  aFs : Open file server session
+        * @param  aDatabasePath : full pathname of the database path
+        * @param  aKey : content encryption key 16 bytes in length.
+        * @param  aImei: device serial number (used for UDT)
+        * @return Functional CDRMRightsDB object, Function leaves if an error 
+        *         occurs.
+        */
+        static CDRMRightsDB* NewLC( RFs& aFs,
+                                    const TDesC& aDatabasePath,
+                                    const TDesC8& aKey,
+                                    const TDesC& aImei );
+        
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMRightDB class and returns a pointer
+        * to it
+        *
+        * @since  3.0
+        * @param  aFs : Open file server session
+        * @param  aDatabasePath : full pathname of the database path
+        * @param  aKey : content encryption key 16 bytes in length.
+        * @param  aImei: device serial number (used for UDT)
+        * @return Functional CDRMRightsDB object, Function leaves if an error
+        *         occurs.
+        */
+        static CDRMRightsDB* NewL( RFs& aFs,
+                                   const TDesC& aDatabasePath,
+                                    const TDesC8& aKey,
+                                    const TDesC& aImei );
+          
+        /**
+        * Destructor
+        */
+        virtual ~CDRMRightsDB();
+
+    public: // New functions    
+        
+        /**
+        * GetDBEntryByContentIDL
+        *
+        * Gets all rights objects connected to aContentID and inserts them into
+        * the pointer array aRightsList
+        *
+        * @since  2.5
+        * @param  aContentID : content identifier
+        * @param  aRightsList : pointer array of the rights object to be filled
+        * @return none , Function leaves if an error occurs
+        */
+        void GetDBEntryByContentIDL( const TDesC8& aContentID, 
+                                     RPointerArray<CDRMPermission>& aRightsList);
+        
+        /**
+        * GetDBEntryByContentIDL
+        *
+        * Gets the rights object connected to aContentID with the unique
+        * identifier aUniqueID and returns a pointer to it, caller must free 
+        * the memory of the pointer
+        *
+        * @since  2.5
+        * @param  aContentID : content identifier
+        * @param  aUniqueID : unique identifier of the rights object
+        * @return CDRMPermission pointer, Function leaves if an error occurs
+        */
+        CDRMPermission* GetDBEntryByContentIDL( const TDesC8& aContentID, 
+                                               const TDRMUniqueID aUniqueID );
+                
+        /**
+        * AddDBEntryL
+        *
+        * Adds a new entry to the database connected with aContentID.
+        *
+        * @since  2.5
+        * @param  aContentID : content identifier
+        * @param  aRightsObject : the rights object to be added, all fields but
+        *                         the unique identifier must be set that need to
+        *                         be set
+        * @param  aEncryptionKey : the 16 byte key used to decrypt content
+        * @param  aUniqueID : the unique id of the added rights object, in/out
+        *                     parameter The function will try to use aUniqueID 
+        *                     as the unique id if it is not possible or 
+        *                     aUniqueID is 0 a new random unique id will be 
+        *                     generated
+        * @return None, Function leaves if an error occurs
+        */
+        void AddDBEntryL( const TDesC8& aContentID, 
+                          CDRMPermission& aRightsObject,
+                          const TDesC8& aEncryptionKey,
+                          TDRMUniqueID& aUniqueID );
+                
+        /**
+        * DeleteDBEntryL
+        *
+        * Deletes an entry from the database connected to aContentID with unique
+        * identifier aUniqueID 
+        *
+        * @since  2.5
+        * @param  aContentID : content identifier
+        * @param  aUniqueID : unique identifier of the rights object
+        * @return None, Function leaves if an error occurs
+        */
+        void DeleteDBEntryL( const TDesC8& aContentID, 
+            const TDRMUniqueID aUniqueID );
+               
+        /**
+        * DeleteDBEntryL
+        *
+        * Deletes all entries from the database connected to aContentID 
+        *
+        * @since  2.5
+        * @param  aContentID : content identifier
+        * @return None, Function leaves if an error occurs
+        */
+        void DeleteDBEntryL( const TDesC8& aContentID );
+               
+        /**
+        * UpdateDBEntryL
+        *
+        * Updates an entry from the database connected to aContentID with 
+        * unique identifier aUniqueID 
+        *
+        * @since  2.5
+        * @param  aContentID : content identifier
+        * @param  aRightsObject : the updated rights object
+        * @return None, Function leaves if an error occurs
+        */
+        void UpdateDBEntryL( const TDesC8& aContentID,  
+                             const CDRMPermission& aRightsObject);
+        
+        /**
+        * ExportContentIDListL
+        *
+        * Exports a list of content id:s to a file
+        *
+        * @since  2.5
+        * @param  aTempFile : return param full pathname of the temporary file
+        *                     to use
+        * @return None, Function leaves if an error occurs
+        */
+        void ExportContentIDListL( TFileName& aTempFile );
+                
+        /**
+        * BackupDBL
+        *
+        * Backups the database to aBackupDBFile and creates the warranty
+        * transfer file aWTFile and encrypts it with the aKey
+        *
+        * @since  2.5
+        * @param  aWTFile : full pathname of the warranty transfer file
+        * @param  aEncryptionKey : 16 byte encryption key
+        * @return None, Function leaves if an error occurs
+        */
+/*        void BackupDBL( const TDesC& aWTFile, 
+                        const TDesC8& aEncryptionKey );
+*/               
+        /**
+        * MergeDBL
+        *
+        * Merges the backup database into the current database
+        *
+        * @since  2.5
+        * @return None, Function leaves if an error occurs
+        */
+//        void MergeDBL();
+        
+        /**
+        * GetDecryptionKey
+        *
+        * Returns the decryption key for rights object connected to aContentID
+        *
+        * @since  2.5
+        * @param  aContentID content ID
+        * @return HBufC8 pointer or NULL if failed
+        */
+        HBufC8* GetDecryptionKeyL( const TDesC8& aContentID );
+                
+        /**
+        * DeleteDBL
+        *
+        * Deletes the rights database file and creates an empty file in it's
+        * place
+        *
+        * @since  2.5
+        * @return can leave with a symbian error code
+        */
+        void DeleteDBL( void );
+
+        /**
+        * GetAmountOfRightsObjects
+        *
+        * Returns the amount of unique content id's from in the rights database
+        *
+        * @since  2.5
+        * @return the amount of rights objects in the database
+        */
+        TInt32 GetAmountOfRightsObjectsL();
+        
+        
+        /**
+        * AddDomainROL
+        *
+        * Adds a domain rights object just the XML representation
+        *
+        * @since    3.0
+        * @param    aRoId : The Rights object identifier of the RO
+        * @param    aXmlData : The Xml data to be saved
+        * @return can leave with symbian on error code
+        */
+        void AddDomainROL( const TDesC8& aRoId, const TDesC8& aXmlData );
+        
+        /**
+        * GetDomainROL
+        *
+        * Gets a domain rights object just the XML representation
+        *
+        * @since    3.0
+        * @param    aRoId : The Rights object identifier of the RO
+        * @return   Domain RO Xml representation or NULL
+        *           can leave with symbian on error code
+        */
+        HBufC8* GetDomainROL( const TDesC8& aRoId );
+
+        /**
+        * DeleteDomainROL
+        *
+        * Deletes a domain rights objects XML representation
+        *
+        * @since    3.0
+        * @param    aRoId : The Rights object identifier of the RO
+        * @return can leave with symbian on error code
+        */
+        void DeleteDomainROL( const TDesC8& aRoId );
+
+        /**
+        * DeleteExpiredPermissionsL
+        * 
+        * Delete expired permissions.
+        *
+        * @since    3.0
+        * @param    aTime : current time
+        * @param    aStatus : request status for the asynchronous requrest
+        * @return   CDRMRightsCleaner object which is used to control the
+        *           expired permissions deletion process
+        */      
+        CDRMRightsCleaner* DeleteExpiredPermissionsL( const TTime& aTime,
+                                                      TRequestStatus& aStatus );
+        
+        /**
+        * NameContentL
+        * 
+        * Give a name to the content, if the name is empty the content name
+        * will be cleared
+        *
+        * @since    3.0
+        * @param    aContentId : content identifier
+        * @param    aName : the name for the content        
+        * @return   None
+        * @leave	Leaves with KErrNotFound if the content doesn't exist
+        */      
+        void NameContentL( const TDesC8& aContentId,
+        				   const TDesC& aName );
+
+        /**
+        * ContentNameL
+        * 
+        * Returns a pointer to the name of the content and leaves it in the
+        * cleanup stack
+        *
+        * @since    3.0
+        * @param    aContentId : content identifier       
+        * @return   the name of the content in a HBufC*
+        * @leave	Leaves with KErrNotFound if the content doesn't exist        
+        */          
+        HBufC* ContentNameLC( const TDesC8& aContentID );
+        
+        /**
+        * DeleteExpiredL
+        * 
+        * Delete expired from the current file store
+        *
+        * @since    3.0
+        * @param    aFileName : name of the permission file store
+        * @param    aTime : current time.
+        * @return   TBool : ETrue if the file can be deleted
+        *                   EFalse if the file can't be deleted
+        */         
+        TBool DeleteExpiredL( const TFileName& aFileName,
+                             const TTime& aTime );     
+  
+        /**
+        * GetUdtDataL
+        *
+        * Gets the udt data from a restore file if it exists
+        * if not it leaves with KErrNotFound
+        *
+        * @since    3.0
+        * @param    aStream : the stream to write to
+        * @return   HBufC8* with the UDT data encrypted with the udt public key
+        * @leave Can leave with a Symbian OS error code
+        */
+        HBufC8* GetUdtDataLC();  
+  
+        /**
+        * InitiateUdtL
+        *
+        * Initiates the User Data Transfer
+        *
+        * @since    3.0
+        * @param    aKey : the key used to encrypt the data encrypted with
+        *                  the device public key
+        * @return   none
+        * @leave Can leave with a Symbian OS error code
+        */
+        void InitiateUdtL( const TDesC8& aKey );    
+
+        /**
+        * CleanUdtData
+        *
+        * Deletes the restore file if it exists
+        *
+        * @since    3.0
+        * @return None
+        */ 
+        void CleanUdtData(); 
+        
+        /**
+        * GetContentIDListL
+        *
+        * Get a list of all the content id's in the database
+        *
+        * @since  2.5
+        * @param  aArray : The pointer array has all the content id's
+        *                  that have been added to the rights database
+        * @return None, Function leaves if an error occurs
+        */
+        void GetContentIDListL( RPointerArray<HBufC8>& aArray );
+
+        /**
+        * SetAuthenticationSeedL
+        * 
+        * Set the authentication seed for a content ID
+        *
+        * @since    3.0
+        * @param    aContentId : content identifier
+        * @param    aSeed : value for the seed
+        * @return   None
+        * @leave	Leaves with KErrNotFound if the content doesn't exist
+        */      
+        void SetAuthenticationSeedL( const TDesC8& aContentId,
+        				             const TDesC8& aSeed );
+
+        /**
+        * GetAuthenticationSeedL
+        * 
+        * Get the authentication seed for a content ID
+        *
+        * @since    3.0
+        * @param    aContentId : content identifier
+        * @return   value for the seed
+        * @leave	Leaves with KErrNotFound if the content doesn't exist
+        */      
+        HBufC8* GetAuthenticationSeedL( const TDesC8& aContentID );
+        				               
+        // test function
+        void CreateDummyUDTFileL();        
+           
+    public: // Inherited from MDRMBackupInterface
+    
+        /**
+        * BackupContentToFileL
+        *
+        * Backups content to file in encrypted format
+        *
+        * @since    3.0
+        * @param    aBackupFile : File handle to the backup file
+        * @param    aEncryptionKey : the key to use to encrypt the backup file
+        * @leave    Symbian OS error code if an error occurs 
+        */
+        virtual void BackupContentToFileL( RFile& aBackupFile,
+                                           const TDesC8& aEncryptionKey, 
+                                           const TInt aMode = KDRMNormalBackup );
+
+        /**
+        * RestoreContentFromFileL
+        *
+        * Restores the content file from encrypted format
+        *
+        * @since    3.0
+        * @param    aBackupFile : File handle to backup file
+        * @param    aEncryptionKey : the key to use to encrypt the backup file
+        * @leave    Symbian OS error code if an error occurs 
+        */                           
+        virtual void RestoreContentFromFileL( RFile& aBackupFile,
+                                              const TDesC8& aEncryptionKey,
+                                              const TInt aMode = KDRMNormalBackup );    
+        
+        
+        /**
+        * Updating
+        *
+        * Returns the ETrue if the database is being updated
+        *
+        * @since    3.0
+        * @param    aStream : the stream to write to
+        * @return   ETrue if files are currently modified in the DB
+        */
+        TBool Updating();
+
+        /**
+        * MarkAsCorrupted
+        *
+        * Marks the rights database as corrupted, to be deleted on reboot
+        *
+        * @since    3.0
+        */
+        void MarkAsCorrupted();
+
+    private:
+        /**
+        * Default Constructor - First phase. Prevented.
+        */
+        CDRMRightsDB(); 
+    
+        /**
+        * Default Constructor - First phase.
+        */
+        CDRMRightsDB( RFs& aFs ); 
+        
+        /**
+        * ConstructL
+        *
+        * Second phase constructor
+        *
+        * @since  2.5
+        * @param  aDatabasePath : full pathname of the database
+        * @param  aKey : database encryption key
+        * @param  aImei: device serial number (used for UDT)
+        * @return Leaves if an error occurs
+        */  
+        void ConstructL( const TDesC& aDatabasePath,
+                         const TDesC8& aKey,
+                         const TDesC& aImei );
+
+        /**
+        * Assignment operator - Prevented
+        */
+        CDRMRightsDB& operator =( const CDRMRightsDB& );    
+    
+        /**
+        * Copy constructor - Prevented
+        */
+        CDRMRightsDB( const CDRMRightsDB& );                
+       
+
+        /**
+        * InitializeDatabaseL
+        *
+        * Initializes the database for usage
+        *
+        * @since  2.5
+        * @return Leaves if an error occurs.
+        */  
+        void InitializeDatabaseL( void );
+    
+        /**
+        * HashContentID
+        *
+        * Fills the aRightsObject with the correct data from aData and checks if the
+        * rights object can be restored or not.
+        *
+        * @since    3.0  
+        * @param    aHashKey  : hashed key, out parameter
+        * @param    aContentID : the content id to be hashed
+        * @return   None
+        */      
+        void HashContentID( TPtrC8& aHashKey, const TDesC8& aContentID );
+
+            
+        /**
+        * GetRightsFileNameL
+        * 
+        * Gets the whole path of the permissions file
+        *
+        * @since    3.0
+        * @param    aContentID : the content id to look for
+        * @param    aPath : return parameter for the filename
+        * @return   None, leaves with SymbianOS error code or DRMCommon error
+        *           code if an error occurs
+        */      
+        void GetRightsFileNameL(
+            const TDesC8& aContentID,
+            TFileName& aPath);
+
+        /**
+        * GetXMLFileNameL
+        * 
+        * Gets the whole path of the domain rights object XML representation
+        *
+        * @since    3.0
+        * @param    aRoID : the rights object id to look for
+        * @param    aPath : return parameter for the filename
+        * @return   None, leaves with SymbianOS error code or DRMCommon error
+        *           code if an error occurs
+        */    
+        void GetXMLFileNameL(
+            const TDesC8& aRoID,
+            TFileName& aPath);
+            
+        /**
+        * ModifyKey
+        * 
+        * Encrypts or decrypts the key
+        *
+        * @since    3.0
+        * @param    aKey : the key to be encrypted or decrypted
+        * @return   None
+        */      
+        void ModifyKey( TDesC8& aKey );
+        
+        /**
+        * AddUDTDataL
+        *
+        * Adds user data transfer data to the header part of the backup
+        * file
+        *
+        * @since    3.0
+        * @param    aStream : the stream to write to
+        * @return None
+        * @leave Can leave with a Symbian OS error code
+        */
+        void AddUDTDataL( RWriteStream& aStream );         
+        
+        // Helper function to do encryption to the stream
+        void WriteEncryptedStreamL( RWriteStream& aStream,
+                                    const TDesC8& aMessageData,
+                                    TDes8& aIv, 
+                                    TDes8& aRemainder,
+                                    HBufC8*& aEncryptionBuffer,
+                                    TInt& aBytesWritten );       
+
+        // Helper function to do encryption to the stream
+        void FinalizeEncryptedStreamL( RWriteStream& aStream,
+                                       TDes8& aIv, 
+                                       TDes8& aRemainder,
+                                       HBufC8*& aEncryptionBuffer,
+                                       TInt& aBytesWritten ); 
+        
+        // Aes encryption                               
+        void EncryptL( const TDesC8& aIv, 
+                       TPtr8& aData, 
+                       TBool aAddPadding );
+                      
+        void DecryptL( const TDesC8& aIv, 
+                       TPtr8& aData, 
+                       TBool aRemovePadding,
+                       const TDesC8& aEncryptionKey );   
+                       
+        void CheckPaddingL( const TDesC8& aData );
+        
+        // Helper function to read and decrypt data and reserve memory
+        // for it if needed
+        void ReadDataL( RFile& aStream,
+                        TDes8& aEncIV,
+                        TPtr8& aReadData,
+                        HBufC8*& aDataBuffer,
+                        TInt& dataLeft,
+                        TInt size,
+                        TBool aStart,
+                        const TDesC8& aEncryptionKey );    
+        
+        // check if the file can be deleted:                
+        void CheckCleanup( const TDesC& aFileName );                                                                                      
+
+    private:
+        // fileserver session
+        RFs& iFileServer;
+    
+        // rights database file, fileserver subsession
+        HBufC* iDbPath;
+    
+        // The md5 hash algorithm implementation
+        CMD5 *iHasher;
+        
+        // The Rights database key
+        HBufC8* iKey;
+        
+        // mem stream for restore
+        RMemReadStream iMemStream;
+        
+        // device serial number (used for UDT)
+        HBufC* iImei;
+        
+        // Time stamp of the last update operation
+        TTime iLastUpdate;
+    };
+
+#endif      // DRMRIGHTSDB_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/drmrightsstoringlocation.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handling storing location of DRM rights
+*
+*/
+
+
+#ifndef DRMRIGHTSSTORINGLOCATION_H
+#define DRMRIGHTSSTORINGLOCATION_H
+
+#include "drmutilityinternaltypes.h"
+
+// CLASS DECLARATION
+/**
+*  DrmRightsStoringLocation
+*
+*  Collection of methods for the implementation of configurable 
+*  storing location of DRM rights
+*/
+class DrmRightsStoringLocation
+{
+    public:
+        /**
+        * Checks if the storing location of DRM Rights is configured in the
+        * Central Repository key. The function returns truth value based on
+        * the availability of the configuration information. If the configured 
+        * drive is not found, the function returns default system drive as the  
+        * storage drive for rights.  
+        * @param aFs               File server session
+        * @param aDrmScheme        The DRM scheme, e.g., OMA DRM or WM DRM    
+        * @param aChar             The drive letter from the Central Repository
+                                   or the default system drive if key is not found
+        * @return                  Truth value based on the availability of the 
+        *                          storage drive configuration information                 
+        */
+        IMPORT_C static TBool CheckDrmRightsStorageDriveL( RFs &aFs,
+            TDrmScheme& aDrmScheme, TChar& aChar );       
+                                       
+    private:
+                                     
+};
+
+#endif      // DRMRIGHTSSTORINGLOCATION_H
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/drmserviceapiwrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,194 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Definition for Dynamically loaded wrapper for Drm Service Api
+*
+*/
+
+
+#ifndef CDRMSERVICEAPIWRAPPER_H
+#define CDRMSERVICEAPIWRAPPER_H
+
+#include <e32base.h>
+#include "drmtypes.h"
+
+/**
+ * Environment gate function
+ *
+ * @since S60 3.2
+ * @return pointer to Drm Service API wrapper
+ */
+IMPORT_C TAny* GateFunctionDrmServiceApiWrapper();
+
+class MDrmServiceApiWrapper
+    {
+public:
+    /**
+     * Get the secure time
+     *
+     * @since   S60 v3.2
+     * @param   aTime           Output parameter containing the 
+     *                          secure time in UTC.
+     * @param   aTimeZone       Time zone information including summer/winter time
+     *                          in +/- 15 minutes
+     * @param   aSecurityLevel  Output parameter Securiry level.
+     * @return  Symbian OS error code if any.
+     */
+    virtual TInt GetSecureTime( TTime& aTime, 
+                                TInt& aTimeZone,
+                                DRMClock::ESecurityLevel& aSecurityLevel ) const = 0;
+                        
+    /**
+     * Update the secure time
+     *
+     * Requires DRM Capability
+     *
+     * @since   S60 v3.2
+     * @param   aTime           Input parameter containing the 
+     *                          secure time in UTC.
+     * @param   aTimeZone       Time zone information including 
+     *                          summer/winter time
+     *                          in +/- 15 minutes         
+     * @return  Symbian OS error code if any.
+     */
+    virtual TInt UpdateSecureTime( const TTime& aTime, const TInt& aTimeZone ) = 0;
+
+
+    /**
+     * Get the device public key in Der format
+     *
+     * @since   S60 v3.2
+     * @param   aPublicKey      Return parameter for the public key owned by
+     *                          the caller
+     * @return  none
+     * @leave Symbian OS error code
+     */
+    virtual void GetDevicePublicKeyDerL( HBufC8*& aPublicKey ) = 0;
+
+    /**
+     * Sign the value given
+     *
+     * @since   S60 v3.2
+     * @param   aHash           Value to be signed
+     * @param   aSignature      Return parameter for the signature, owned by
+     *                          the caller
+     * @return  none
+     * @leave Symbian OS error code
+     */
+    virtual void SignL( const TDesC8& aHash, HBufC8*& aSignature ) = 0;
+    };
+
+
+namespace DRM 
+    {
+
+// forward declaration
+class CDrmServiceApi;    
+    
+    
+/**
+ *  Class for connecting to the WmDrmServer
+ *
+ *  @lib WmDrmClientWrapper
+ *  @since S60 3.2
+ */
+NONSHARABLE_CLASS( CDrmServiceApiWrapper ): public CBase,
+                                            public MDrmServiceApiWrapper
+    {
+
+public:
+
+    static CDrmServiceApiWrapper* NewL();
+
+    static CDrmServiceApiWrapper* NewLC();
+
+    virtual ~CDrmServiceApiWrapper();
+
+    /**
+     * Get the secure time
+     *
+     * @since   S60 v3.2
+     * @param   aTime           Output parameter containing the 
+     *                          secure time in UTC.
+     * @param   aTimeZone       Time zone information including summer/winter time
+     *                          in +/- 15 minutes
+     * @param   aSecurityLevel  Output parameter Securiry level.
+     * @return  Symbian OS error code if any.
+     */
+    virtual TInt GetSecureTime( TTime& aTime, 
+                                TInt& aTimeZone,
+                                DRMClock::ESecurityLevel& aSecurityLevel ) const;
+                        
+    /**
+     * Update the secure time
+     *
+     * Requires DRM Capability
+     *
+     * @since   S60 v3.2
+     * @param   aTime           Input parameter containing the 
+     *                          secure time in UTC.
+     * @param   aTimeZone       Time zone information including 
+     *                          summer/winter time
+     *                          in +/- 15 minutes         
+     * @return  Symbian OS error code if any.
+     */
+    virtual TInt UpdateSecureTime( const TTime& aTime, const TInt& aTimeZone );
+
+
+    /**
+     * Get the device public key in Der format
+     *
+     * @since   S60 v3.2
+     * @param   aPublicKey      Return parameter for the public key owned by
+     *                          the caller
+     * @return  none
+     * @leave Symbian OS error code
+     */
+    virtual void GetDevicePublicKeyDerL( HBufC8*& aPublicKey );
+
+    /**
+     * Sign the value given
+     *
+     * @since   S60 v3.2
+     * @param   aHash           Value to be signed
+     * @param   aSignature      Return parameter for the signature, owned by
+     *                          the caller
+     * @return  none
+     * @leave Symbian OS error code
+     */
+    virtual void SignL( const TDesC8& aHash, HBufC8*& aSignature );
+    
+protected:
+
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CDrmServiceApiWrapper();
+
+    void ConstructL();
+
+
+private: // data
+
+    /**
+     * Download manager session
+     */
+    CDrmServiceApi* iServiceApi;
+    
+    };
+    
+    } // namespace DRM
+    
+#endif // CDRMSERVICEAPIWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/drmsettingsplugininternalcrkeys.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRMSettingsPlugin internal Central Repository keys.
+*
+*/
+
+
+#ifndef DRMSETTINGSPLUGININTERNALCRKEYS_H
+#define DRMSETTINGSPLUGININTERNALCRKEYS_H
+
+// INCLUDES
+#include <e32def.h>
+
+// CONSTANTS
+
+
+/**
+* Security settings CR UID
+*/
+const TUid KCRUidDRMSettings = {0x102823B4};
+
+/**
+* Transaction Tracking status
+* Possible values are:
+* 0 = disabled
+* 1 = enabled
+*/
+const TUint32 KDRMSettingsTransactionTracking = 0x00000001;
+
+/**
+* Silent Rights Acquisition status
+* Possible values are:
+* 0 = not allowed
+* 1 = allowed
+*/
+const TUint32 KDRMSettingsSilentRightsAcquisition = 0x00000002;
+
+#endif      // DRMSETTINGSINTERNALCRKEYS_H
+
+// End of file
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/drmutilityinternaltypes.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,57 @@
+/*
+* 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:  Internal type definitions for DRM Utility
+*
+*/
+
+
+#ifndef DRMUTILITYINTERNALTYPES_H
+#define DRMUTILITYINTERNALTYPES_H
+
+// DRM scheme of the file
+enum TDrmScheme
+    {
+    // Unknown
+    EDrmSchemeUnknownDrm = 0,
+            
+    // OMA DRM
+    EDrmSchemeOmaDrm,
+            
+    // WM DRM
+    EDrmSchemeWmDrm
+    };    
+
+// Launch types of DRM Rights Manager
+enum TDrmLaunchParam
+    {
+    // Embedded launch from DRM Helper
+    EDrmLaunchParamEmbeddedHelper = 1,
+    
+    // Standalone launch from DRM Helper
+    EDrmLaunchParamStandAloneHelper,
+    
+    // Embedded launch from DRM Utility with full file path included
+    // as a separate parameter
+    EDrmLaunchParamEmbeddedUtility,
+    
+    // Standalone launch from DRM Utility with full file path included
+    // as a separate parameter 
+    EDrmLaunchParamStandAloneUtility
+    
+    };
+
+    
+#endif      // DRMUTILITYINTERNALTYPES_H   
+            
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/drmutilitywmdrmutilities.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,97 @@
+/*
+* 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:  WM DRM specific methods for DRM Rights Manager
+*
+*/
+
+
+#ifndef DRMUTILITYWMDRMUTILITIES_H
+#define DRMUTILITYWMDRMUTILITIES_H
+
+// CONSTANTS
+
+// FORWARD DECLARATIONS
+class CDRMRightsConstraints;
+
+// CLASS DECLARATION
+/**
+*  DRMUtilityWmDrmUtilities
+*
+*  Collection of WM DRM specific methods
+*/
+class DrmUtilityWmDrmUtilities
+{
+    public:
+        /**
+        * Parse WM DRM time based rights
+        * @param aLex                 Lexicographic representation of a WM DRM 
+        *                             rights 
+        *                             string  
+        * @param aStartTime           Parsed start time from the string    
+        * @param aEndTime             Parsed end time from the string                         
+        */
+        IMPORT_C static void ParseWmDrmTimeRightsL( TLex& aLex, 
+                                                    TTime& aStartTime,
+                                                    TTime& aEndTime );       
+    
+        /**
+         * Parse WM DRM count based rights
+         * @param aLex                 Lexicographic representation of a WM DRM 
+         *                             rights string
+         * @param aCounts              The amount of count rights  
+         * @return                     Whether count information was found or not                         
+         */
+         IMPORT_C static TBool ParseWmDrmCountRightsL( TLex& aLex, 
+                                                       TUint32& aCounts );
+       
+        /**
+         * Parse WM DRM duration rights
+         * @param aLex                 Lexicographic representation of a WM DRM 
+         *                             rights string  
+         * @param aDuration            The duration of the rights
+         * @return                     Whether duration information was found 
+         *                             or not                       
+         */
+         IMPORT_C static TBool ParseWmDrmDurationRightsL( TLex& aLex,
+            TTimeIntervalSeconds& aDuration );
+    
+        /**
+         * Parse a WM DRM rights string to a rights constraint. Caller is responsible
+         * for freeing the memory reserved for the constraint.
+         * @param aRights              String to be parsed
+         * @param aRightsConstraint    Rights constraint containing parsed rights
+         */
+         IMPORT_C static void ParseWmDrmStringL( ContentAccess::CRightsInfo& aRights,
+            CDRMRightsConstraints*& aRightsConstraint );
+       
+        /** Checks the detailed rights of the WMDRM protected file from the
+         * given array parameter. The other function parameter values are updated
+         * based on the rights.
+         * @param aUnconstrained       Whether the file has unlimited rights or not
+         * @param aTime                Time left to use the file
+         * @param aCounts              Counts left to use the file
+         * @param aRights              WM DRM rights string which needs to parsed
+         */
+         IMPORT_C static void CheckWmDrmRightsL( TBool& aUnconstrained, 
+                                                 TTimeIntervalSeconds& aTime, 
+                                                 TInt& aCounts, 
+                                                 ContentAccess::CRightsInfo& aRights );
+                                           
+    private:
+                                     
+};
+
+#endif
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/wbxmlroaptriggerparser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,214 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Parser for Oma Drm 2.1 WBXML RoapTrigger messages
+*
+*/
+
+
+
+#ifndef WBXMLROAPTRIGGERPARSER_H
+#define WBXMLROAPTRIGGERPARSER_H
+
+//  INCLUDES
+#include <xml/parser.h>
+#include <xml/contenthandler.h>
+#include <xml/xmlparsererrors.h>
+
+namespace DRM
+{
+
+NONSHARABLE_CLASS( CWbxmlRoapTriggerParser ): public CBase, public Xml::MContentHandler
+    {
+
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CWbxmlRoapTriggerParser* NewL();
+
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CWbxmlRoapTriggerParser* NewLC();
+
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CWbxmlRoapTriggerParser();
+
+        /**
+        * Parses the WBXML RoapTrigger to XML
+        *
+        * @param aMessage WBXML RoapTrigger to be parsed
+        *
+        * @return parsed XML RoapTrigger in HBufC8
+        */
+        IMPORT_C HBufC8* ParseL( const TDesC8& aMessage );
+
+    public: // Functions from base classes
+
+        /**
+        * From MContentHandler
+        *
+        * @param aDocParam Specifies the various parameters of the document.
+        * @arg   aDocParam.iCharacterSetName The character encoding of the document.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartDocumentL( const Xml::RDocumentParameters& aDocParam,
+                               TInt aErrorCode );
+
+        /**
+        * From MContentHandler
+        *
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndDocumentL( TInt aErrorCode);
+
+        /**
+        * From MContentHandler
+        *
+        * @param aElement is a handle to the element's details.
+        * @param aAttributes contains the attributes for the element.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartElementL( const Xml::RTagInfo& aElement,
+                              const Xml::RAttributeArray& aAttributes,
+                              TInt aErrorCode );
+
+        /**
+        * From MContentHandler
+        *
+        * @param aElement is a handle to the element's details.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndElementL( const Xml::RTagInfo& aElement,
+                            TInt aErrorCode );
+
+        /**
+        * From MContentHandler
+        *
+        * @param aBytes is the raw content data for the element.
+        *        The client is responsible for converting the data to the
+        *        required character set if necessary.
+        *        In some instances the content may be binary and must not be converted.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnContentL( const TDesC8& aBytes,
+                         TInt aErrorCode );
+
+        /**
+        * From MContentHandler
+        *
+        * @param aPrefix is the Namespace prefix being declared.
+        * @param aUri is the Namespace URI the prefix is mapped to.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartPrefixMappingL( const RString& aPrefix,
+                                    const RString& aUri,
+                                    TInt aErrorCode );
+
+        /**
+        * From MContentHandler
+        *
+        * @param aPrefix is the Namespace prefix that was mapped.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndPrefixMappingL( const RString& aPrefix,
+                                  TInt aErrorCode );
+
+        /**
+        * From MContentHandler
+        *
+        * @param aBytes are the ignored bytes from the document being parsed.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnIgnorableWhiteSpaceL( const TDesC8& aBytes,
+                                     TInt aErrorCode );
+
+        /**
+        * From MContentHandler
+        *
+        * @param aName is the name of the skipped entity.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnSkippedEntityL( const RString& aName,
+                               TInt aErrorCode );
+
+        /**
+        * From MContentHandler
+        *
+        * @param aTarget is the processing instruction target.
+        * @param aData is the processing instruction data. If empty none was supplied.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnProcessingInstructionL( const TDesC8& aTarget,
+                                       const TDesC8& aData,
+                                       TInt aErrorCode );
+
+        /**
+        * From MContentHandler
+        */
+        void OnOutOfData();
+
+        /**
+        * From MContentHandler
+        *
+        * @param aError is the error code
+        */
+        void OnError( TInt aErrorCode );
+
+        /**
+        * From MContentHandler
+        *
+        * @param aUid the uid identifying the required interface.
+        *
+        * @return  0 if no interface matching the uid is found.
+        *          Otherwise, the this pointer cast to that interface.
+        */
+        TAny* GetExtendedInterface( const TInt32 aUid );
+
+    private: // Functions from base classes
+
+        /**
+        * C++ default constructor.
+        */
+        CWbxmlRoapTriggerParser();
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+    private:     // Data
+
+        Xml::CParser* iParser;
+        CBufFlat* iContent;
+
+    };
+}
+
+#endif // WBXMLROAPTRIGGERPARSER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/wmdrmclient.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,389 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client definitions
+*
+*/
+
+
+#ifndef __WMDRMCLIENT_H
+#define __WMDRMCLIENT_H
+
+#include <e32std.h>
+#include <f32file.h>
+
+// Name of the WMDRM server executable
+_LIT(KWmDrmServerName,"!wmdrmserver.exe");
+
+// Name of the WMDRM server
+_LIT(KWmDrmServerImg,"wmdrmserver");
+
+const TInt KWmDrmIdSize = 16;
+const TInt KMaxWmDrmNamespaceNameSize = 64;
+const TInt KMaxWmDrmStoreNameSize = 64;
+
+enum TWmDrmStoreState
+	{
+    EStoreSpaceOK,
+    EStoreSpaceLow,
+    EStoreSpaceFull
+    };
+
+/**
+* wmdrmclient.dll
+*
+* All methods may not be supported and will always
+* return KErrNotSupported
+*/
+class RWmDrmClient: public RSessionBase
+	{
+public:
+    /**
+    * Connect()
+    * Connect to the server
+    *
+    * @return KErrNone if successful    
+    *         Otherwise Symbian OS error codes
+    */
+	IMPORT_C TInt Connect();
+
+    /**
+    * InitStore
+    * Initialize a hds store
+    *
+    * @param aStoreName         Name of the store
+    * @param aCreateIfMissing   Boolean value to create 
+    *                           if the store is missing
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+    
+    IMPORT_C TInt InitStore(
+        const TDesC8& aStoreName,
+        TBool aCreateIfMissing );
+
+    /**
+    * RemoveStore
+    * Removes the store
+    *
+    * @param aStoreName         Name of the store
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+            
+    IMPORT_C TInt RemoveStore(
+        const TDesC8& aStoreName );
+
+    /**
+    * InitNamespace
+    * Initializes a namespace
+    *
+    * @param aStoreName         Name of the store
+    * @param aNamespace         Name of the namespace
+    * @param aCreateIfMissing   Boolean value to create 
+    *                           if the namespace is missing
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+    
+    IMPORT_C TInt InitNamespace(
+        const TDesC8& aStoreName,
+        const TDesC8& aNamespace,
+        TBool aCreateIfMissing );
+ 
+     /**
+    * RemoveNamespace
+    * Removes a namespace
+    *
+    * @param aStoreName         Name of the store
+    * @param aNamespace         Name of the namespace
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+       
+    IMPORT_C TInt RemoveNamespace(
+        const TDesC8& aStoreName,
+        const TDesC8& aNamespace );
+
+    /**
+    * SlotOpen
+    * Open a slot from the namespace
+    *
+    * @param aStoreName         Name of the store
+    * @param aNamespace         Name of the namespace
+    * @param aHashKey           Hash key part of the identifier         
+    * @param aUniqueKey         Unique key part of the identifier
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+    
+    IMPORT_C TInt SlotOpen(
+        const TDesC8& aStoreName,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey,
+        TInt& aSize );
+
+    /**
+    * SlotCreate
+    * Create a slot to the namespace
+    *
+    * @param aStoreName         Name of the store
+    * @param aNamespace         Name of the namespace
+    * @param aHashKey           Hash key part of the identifier         
+    * @param aUniqueKey         Unique key part of the identifier
+    * @param aSize              Size of the slot to be created
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+            
+    IMPORT_C TInt SlotCreate(
+        const TDesC8& aStoreName,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey,
+        TInt& aSize );
+
+    /**
+    * SlotSeek
+    * Seek within a slot
+    *
+    * @param aPos               Requested position
+    * @param aOrigin            Seekmode
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+            
+    IMPORT_C TInt SlotSeek(
+        TInt& aPos,
+        TSeek aOrigin );
+
+    /**
+    * SlotRead
+    * Read data from a slot
+    *
+    * @param aData              Slot data
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+            
+    IMPORT_C TInt SlotRead(
+        TDes8& aData );
+
+    /**
+    * SlotWrite
+    * Write data to the slot
+    *
+    * @param aData              Slot data
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+            
+    IMPORT_C TInt SlotWrite(
+        const TDesC8& aData );
+
+    /**
+    * SlotResize
+    * Resize the slot
+    *
+    * @param aSize              New size of the slot
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+            
+    IMPORT_C TInt SlotResize(
+        TInt aSize );
+
+    /**
+    * SlotDelete
+    * Delete the slot identified by the parameters
+    *
+    * @param aStoreName         Name of the store
+    * @param aNamespace         Name of the namespace
+    * @param aHashKey           Hash key part of the identifier         
+    * @param aUniqueKey         Unique key part of the identifier
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+            
+    IMPORT_C TInt SlotDelete(
+        const TDesC8& aStoreName,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey );
+
+    /**
+    * SlotClose
+    * Close the current slot in use
+    *
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+                
+    IMPORT_C TInt SlotClose();
+
+    /**
+    * EnumerateStart
+    * Initializes an enumeration
+    *
+    * @param aStoreName         Name of the store
+    * @param aNamespace         Name of the namespace
+    * @param aHashKey           Haskey to be used
+    *
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+        
+    IMPORT_C TInt EnumerateStart(
+        const TDesC8& aStoreName,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey );
+
+    /**
+    * EnumerateReload
+    * Reloads an enumeration
+    *
+    * @param aStoreName         Name of the store
+    * @param aNamespace         Name of the namespace
+    * @param aHashKey           Hash key part of the identifier         
+    * @param aUniqueKey         Unique key part of the identifier
+    *
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+            
+    IMPORT_C TInt EnumerateReload(
+        TDes8& aStoreName,
+        TDes8& aNamespace,
+        TDes8& aHashKey,
+        TDes8& aUniqueKey );
+
+    /**
+    * EnumerateNext
+    * Moves to the next enumeration part
+    *
+    * @param aStoreName         Name of the store
+    * @param aNamespace         Name of the namespace
+    * @param aHashKey           Hash key part of the identifier         
+    * @param aUniqueKey         Unique key part of the identifier
+    *
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+            
+    IMPORT_C TInt EnumerateNext(
+        TDes8& aStoreName,
+        TDes8& aNamespace,
+        TDes8& aHashKey,
+        TDes8& aUniqueKey );
+
+    /**
+    * EnumerateDeleteCurrent
+    * Deletes the current enumerated slot
+    *
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+            
+    IMPORT_C TInt EnumerateDeleteCurrent();
+
+    /**
+    * EnumerateEnd
+    * Finishes the enumeration session
+    *
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+        
+    IMPORT_C TInt EnumerateEnd();
+
+    /**
+    * LogStats
+    * Logs the stats of the server
+    *
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+    
+    IMPORT_C TInt LogStats();
+
+    /**
+    * EmptyCache
+    * Empties the cache used by the wmdrmserver
+    *
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+    
+    IMPORT_C TInt EmptyCache();
+
+    /**
+    * TimeValid
+    * returns the validity of the time
+    *
+    * @return ETrue if the time is Valid
+    *         EFalse if the time is Invalid
+    */
+        
+    IMPORT_C TBool TimeValid();
+
+    /**
+    * SetTimeAsValid
+    * Sets the time as valid
+    *
+    * @param aValid             Validity of the time
+    *                           ETrue if Valid
+    *                           EFalse if Invalid
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+    
+    IMPORT_C void SetTimeAsValid( TBool aValid );
+
+    /**
+    * DeleteRights
+    * Deletes allowed things from the rights database
+    * Requires Capabilities or SecureID:s    
+    *
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */    
+    // Requires Capabilities or SecureID:s
+    IMPORT_C TInt DeleteRights();
+
+    /**
+    * StoreState
+    * Get the store state
+    *
+    * @param aState        State of the store
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+        
+    IMPORT_C TInt StoreState( TWmDrmStoreState& aState );
+
+    /**
+    * GetTime
+    * Returns the time kept in the WMDRM server
+    *
+    * @param aTime              Time in UTC
+    * @param aValid             ETrue if the time is secure
+    *                           EFalse if the time is not secure
+    * @return KErrNone if successful
+    *         Otherwise Symbian OS error code
+    */
+        
+    IMPORT_C TInt GetTime( TTime& aTime, TBool& aValid );
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/wmdrmclientwrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,84 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef CWMDRMCLIENTWRAPPER_H
+#define CWMDRMCLIENTWRAPPER_H
+
+#include "wmdrmclient.h"
+
+/**
+ * Environment gate function
+ *
+ * @since S60 3.2
+ * @return pointer to DMgr handler
+ */
+IMPORT_C TAny* GateFunctionWmDrmClientWrapper();
+
+class MWmDrmClientWrapper
+    {
+public:
+    virtual TInt Connect() = 0;
+    };
+
+
+
+/**
+ *  Class for connecting to the WmDrmServer
+ *
+ *  @lib WmDrmClientWrapper
+ *  @since S60 3.2
+ */
+NONSHARABLE_CLASS( CWmDrmClientWrapper ): public CBase,
+                                          public MWmDrmClientWrapper
+    {
+
+public:
+
+    static CWmDrmClientWrapper* NewL();
+
+    static CWmDrmClientWrapper* NewLC();
+
+    virtual ~CWmDrmClientWrapper();
+
+    /**
+     * Start up the WmDrmServer
+     */
+    virtual TInt Connect();
+    
+protected:
+
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CWmDrmClientWrapper();
+
+    void ConstructL();
+
+
+private: // data
+
+    /**
+     * Download manager session
+     */
+    RWmDrmClient iClient;
+    
+    };
+
+#endif // CWMDRMCLIENTWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/wmdrmdlawrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,120 @@
+/*
+* 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:  Header file for WMDRM DLA Wrapper
+*
+*/
+
+
+#ifndef CWMDRMDLAWRAPPER_H
+#define CWMDRMDLAWRAPPER_H
+
+#include <e32base.h>
+#include <f32file.h>
+
+_LIT( KWmDrmDlaWrapperName, "\\system\\libs\\wmdrmdlawrapper.dll" );
+const TInt KWmDrmDlaNewL = 1;
+
+class CWmDrmDlaHandler;
+
+class MWmDrmDlaWrapper
+    {
+
+public:
+
+    virtual TBool SilentL( const RFile& aFile ) = 0;
+    
+    virtual void AcquireLicenseL( const RFile& aFile, 
+                                  HBufC*& aContentUrl, 
+                                  HBufC*& aHtmlData ) = 0;
+    
+    virtual void AcquireLicense( const RFile& aFile, 
+                                 HBufC*& aContentUrl, 
+                                 HBufC*& aHtmlData, 
+                                 TRequestStatus& aStatus ) = 0;
+    
+    virtual void AcquireLicenseFromDrmHeaderL( const TDesC8& aDrmHeader, 
+                                               HBufC* aErrorUrl, 
+                                               HBufC*& aContentUrl, 
+                                               HBufC*& aHtmlData ) = 0;
+    
+    virtual void AcquireLicenseFromDrmHeader( const TDesC8& aDrmHeader, 
+                                              HBufC* aErrorUrl,
+                                              HBufC*& aContentUrl,
+                                              HBufC*& aHtmlData, 
+                                              TRequestStatus& aStatus ) = 0;
+    
+    virtual void CancelLicenseAcquisition() = 0;
+    
+    virtual void ProcessMeteringCertificateL( const TDesC8& aCertificate ) = 0;
+    
+    virtual void ProcessMeteringCertificate( const TDesC8& aCertificate, 
+                                             TRequestStatus& aStatus ) = 0;
+    
+    virtual void CancelMetering() = 0;
+    
+    virtual void SetIapId( TInt aIapId ) = 0;
+    
+    };
+
+NONSHARABLE_CLASS( CWmDrmDlaWrapper ): public CBase,
+                                       public MWmDrmDlaWrapper
+    {
+
+public:
+
+    IMPORT_C static CWmDrmDlaWrapper* NewL();
+    virtual ~CWmDrmDlaWrapper();
+
+    TBool SilentL( const RFile& aFile );
+    
+    void AcquireLicenseL( const RFile& aFile, HBufC*& aContentUrl, 
+                          HBufC*& aHtmlData );
+    
+    void AcquireLicense( const RFile& aFile, HBufC*& aContentUrl, 
+                         HBufC*& aHtmlData, TRequestStatus& aStatus );
+    
+    void AcquireLicenseFromDrmHeaderL( const TDesC8& aDrmHeader, 
+                                       HBufC* aErrorUrl,
+                                       HBufC*& aContentUrl, 
+                                       HBufC*& aHtmlData );
+    
+    void AcquireLicenseFromDrmHeader( const TDesC8& aDrmHeader, 
+                                      HBufC* aErrorUrl,
+                                      HBufC*& aContentUrl, 
+                                      HBufC*& aHtmlData, 
+                                      TRequestStatus& aStatus );
+    
+    void CancelLicenseAcquisition();
+    
+    void ProcessMeteringCertificateL( const TDesC8& aCertificate );
+    
+    void ProcessMeteringCertificate( const TDesC8& aCertificate, 
+                                     TRequestStatus& aStatus );
+    
+    void CancelMetering();
+    
+    void SetIapId( TInt aIapId );
+    
+private:
+
+    CWmDrmDlaWrapper();
+    void ConstructL();
+
+private: // data
+
+    CWmDrmDlaHandler* iDlaHandler;
+    
+    };
+
+#endif // CWMDRMDLAWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/wmdrmfileserverclient.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,162 @@
+/*
+* 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:  Client definitions
+*
+*/
+
+
+#ifndef __WMDRMFILESERVERCLIENT_H
+#define __WMDRMFILESERVERCLIENT_H
+
+#include <e32std.h>
+
+// Name of the WMDRM file server executable
+_LIT( KWmDrmFileServerName, "!wmdrmfileserver.exe" );
+
+// Name of the WMDRM file server process
+_LIT( KWmDrmFileServerImg, "wmdrmfileserver" );
+
+// Location of the WMDRM file server root folder
+_LIT( KStoreRoot, "%c:\\sys\\private\\2000B180" );
+
+/* Interface to the WMDRM file server, which manages files in protected location.
+ * Clients need DRM capability to access all functions.
+ */
+
+class RWmDrmFileServerClient: public RSessionBase
+	{
+public:
+
+    /* Connect to the server.
+     *
+     * @capability DRM
+     * @return KErrNone if successful
+     */
+	IMPORT_C TInt Connect();
+    
+
+    /* Open the given file under the file server root.
+     *
+     * @capability DRM
+     * @param aFilename File to open
+     * @return  KErrNone if successful, KErrNotFound if the file does not exist,
+     *          KErrArgument if the file name is not valid
+     */
+    IMPORT_C TInt Open( const TDesC& aFilename );
+    
+
+    /* Closes an open file.
+     */
+    IMPORT_C void CloseFile();
+
+
+    /* Creates a file under the file server root and opens it.
+     *
+     * @capability DRM
+     * @param aFilename File to create
+     * @return KErrNone if successful, KErrArgument if the file name is not valid,
+     *         KErrDiskFull if system drive doesn't have enough free space
+     */
+    IMPORT_C TInt Create( const TDesC& aFilename );
+
+
+    /* Read the whole content of the file into a buffer
+     *
+     * @capability DRM
+     * @param aBuffer   Buffer for file content
+     * @return  KErrNone if successful, KErrNotReady if the file is not open,
+     *          KErrBadDescriptor if not enough space is available in the buffer.
+     */
+    IMPORT_C TInt Read( TDes8& aBuffer );
+
+    /* Replaces the file content with a buffer, truncating the file if needed.
+     *
+     * @capability DRM
+     * @param aBuffer   New file content
+     * @return  KErrNone if successful, KErrNotReady if the file is not open,
+     *          KErrDiskFull if system drive doesn't have enough free space
+     */
+    IMPORT_C TInt Write( const TDesC8& aBuffer );
+
+    /* Returns the size of the currently open file
+     *
+     * @capability DRM
+     * @param aSize Output parameter for the size
+     * @return KErrNone if successful, KErrNotReady if the file is not open
+     */
+    IMPORT_C TInt Size( TInt& aSize );
+
+    /* Deletes a given file under the store root.
+     *
+     * @capability DRM
+     * @param aFilename File to delete
+     * @return  KErrNone if successful, KErrArgument if the file name is not valid
+     */
+    IMPORT_C TInt Delete( const TDesC& aFilename );
+
+    /* Checks whether a file is currently opened for this session.
+     *
+     * @capability DRM
+     * @return  ETrue if a file is open, EFalse otherwise
+     */
+    IMPORT_C TBool IsOpen();
+
+
+    /* Creates a complete path under the file server root, including all path
+     * components.
+     *
+     * @capability DRM
+     * @param aPath             Path to create
+     * @param aCreateIfMissing  Flag indicating whether the path should be created if
+     *                          it doesn't exist
+     * @return KErrNone if successful, KErrArgument if the file name is not valid
+     *         KErrDiskFull if system drive doesn't have enough free space
+     */
+    IMPORT_C TInt MkDirAll( const TDesC& aPath, TBool aCreateIfMissing = ETrue );
+
+    /* Remove a complete path including all contents.
+     *
+     * @capability DRM
+     * @param aPath Path to remove
+     * @return KErrNone if successful, KErrArgument if the file name is not valid
+     */
+    IMPORT_C TInt RmDirAll( const TDesC& aPath );
+
+    /* Remove the last directory in a path, if the last directory is empty.
+     *
+     * @capability DRM
+     * @param aPath 
+     * @return KErrNone if successful, KErrArgument if the file name is not valid
+     */
+    IMPORT_C TInt RmDir( const TDesC& aPath );
+    
+    
+    /* Updates the secure time, only callable by DRM Rights Server
+     *
+     * @capability DRM
+     * @return  KErrNone if the operation succeeds
+     *          Symbian OS error code if an error occurs
+     */    
+    IMPORT_C TInt UpdateSecureTime( TTime& aHomeTime, TTime& aUTCTime );
+    
+    /* Delete all the rights
+     *
+     * @capability DRM
+     * @return  KErrNone if successful
+     */
+    IMPORT_C TInt DeleteRights();
+    
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/wmdrmpkclientwrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* 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:  Header file for WMDRM PK Client Wrapper
+*
+*/
+
+
+#ifndef CWMDRMPKCLIENTWRAPPER_H
+#define CWMDRMPKCLIENTWRAPPER_H
+
+#include <e32base.h>
+
+_LIT( KWmdrmPkClientWrapperName, "\\system\\libs\\wmdrmpkclientwrapper.dll" );
+const TInt KWmdrmPkClientNewL = 1;
+
+class RWmDrmPkClient;
+
+class MWmDrmPkClientWrapper
+    {
+
+public:
+
+    virtual TInt Connect() = 0;
+    
+    virtual void Close() = 0;
+    
+    virtual TInt DeleteRights() = 0;
+    
+    };
+
+NONSHARABLE_CLASS( CWmDrmPkClientWrapper ): public CBase,
+                                            public MWmDrmPkClientWrapper
+    {
+
+public:
+
+    IMPORT_C static CWmDrmPkClientWrapper* NewL();
+    
+    virtual ~CWmDrmPkClientWrapper();
+
+    TInt Connect();
+    
+    void Close();
+     
+    TInt DeleteRights();
+
+private:
+
+    CWmDrmPkClientWrapper();
+    void ConstructL();
+
+private: // data
+
+    RWmDrmPkClient* iClient;
+
+    TInt GenerateSyncChallengeL(TUint32 aMaxCount,
+                                TUint32 aMaxHours,
+                                TUint32 aStart,
+                                TUint32 aItemsToProcess,
+                                TUint32 &aNextStart,
+                                TUint32 &aProcessed,
+                                HBufC8*& aChallenge);
+                                
+    HBufC8* GetDeviceCertificateL();
+
+    
+    };
+
+#endif // CWMDRMPKCLIENTWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/inc/wmdrmserverinternalcrkeys.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handling storing location of Rights Objects
+*
+*/
+
+
+#ifndef WMDRMSERVERINTERNALCRKEYS_H
+#define WMDRMSERVERINTERNALCRKEYS_H
+
+const TUid KCRUidWmDrmServer = {0x2001FE55};
+
+/* Location (drive) for storing the rights objects as desired by the user */
+const TUint32 KWmDrmServerStoringLocation = 0x00000001;
+
+#endif      // DRMRIGHTSSERVERINTERNALCRKEYS_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layers.sysdef.xml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,19 @@
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
+  <!ENTITY layer_real_source_path "sf/mw/drm" >
+]>
+
+<SystemDefinition name="drm" schema="1.4.0">
+  <systemModel>
+    <layer name="mw_layer">
+      <module name="drm">
+        <unit unitID="sedo.drm" mrp="" bldFile="&layer_real_source_path;/group" name="drm" />
+      </module>
+    </layer>
+    <layer name="api_test_layer">
+      <module name="drm_test">
+        <unit unitID="sedo.drm_test" mrp="" bldFile="&layer_real_source_path;/tsrc/group" name="drm_test" />
+      </module>
+    </layer>
+  </systemModel>
+</SystemDefinition>
Binary file omadrm/cenrep/keys_drm5.xls has changed
Binary file omadrm/cenrep/keys_drmsettings.xls has changed
Binary file omadrm/conf/drm5.confml has changed
Binary file omadrm/conf/drm5_10205CA7.crml has changed
Binary file omadrm/conf/drm5_10205CBF.crml has changed
Binary file omadrm/conf/drm5_200195ad.crml has changed
Binary file omadrm/conf/drmsettings.confml has changed
Binary file omadrm/conf/drmsettings_102823B4.crml has changed
Binary file omadrm/conf/drmutility.confml has changed
Binary file omadrm/conf/drmutility_20022D51.crml has changed
Binary file omadrm/data/OmaDrm_Stub.SIS has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/data/OmaDrm_Stub.pkg	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,21 @@
+;
+; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+; All rights reserved.
+; This component and the accompanying materials are made available
+; under the terms of "Eclipse Public License v1.0"
+; which accompanies this distribution, and is available
+; at the URL "http://www.eclipse.org/legal/epl-v10.html".
+;
+; Initial Contributors:
+; Nokia Corporation - initial contribution.
+;
+; Contributors:
+;
+; Description:
+;
+
+&EN
+
+#{"OMA DRM Agent"},(0x10205CB2),5,0,1,TYPE=SA
+%{"Nokia"}
+:"Nokia"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/inc/DcfCache.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,266 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of the DCF cache class
+*
+*/
+
+
+
+#ifndef DCFCACHE_H
+#define DCFCACHE_H
+
+//  INCLUDES
+#include <dcfcommon.h>
+#include <mode.h>
+#include <symmetric.h>
+#include <rijndael.h>
+
+// enables async reading
+#define ASYNC_READ
+
+// FORWARD DECLARATIONS
+
+class RFile;
+class RDRMRightsClient;
+class CDcfCommon;
+
+// CLASS DECLARATION
+
+/**
+ *  Cache for reading decrypted or plain data from a DCF file
+ *
+ *  @lib OmaDrmAgent.dll
+ *  @since Series 60 3.0
+ */
+
+class CDcfCache : public
+#ifdef ASYNC_READ
+    CActive
+#else
+    CBase
+#endif
+    {
+
+public:
+    // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     */
+    static CDcfCache* NewL(
+        RDRMRightsClient& aRightsClient,
+        RFile& aFile,
+        CDcfCommon& aDcf,
+        TInt aPageSize = 2048,
+        TInt aPageCount = 32 );
+
+    /**
+     * Destructor.
+     */
+    virtual ~CDcfCache();
+
+public:
+    // New functions
+
+    /**
+     * Read data from the file via the cache. Depending on the decryption
+     * mode, the data is decrypted in the RightsServer or in the cache
+     * @since Series 60 3.0
+     * @param aPos Position from the start of the file where to read from
+     * @param aDes Descriptor holding the read data
+     * @param aLength Amount of data to read
+     * @return KErrNone if the data is read successfully
+     */
+    TInt Read(
+        TInt& aPos,
+        TDes8& aDes,
+        TInt aLength );
+
+    /**
+     * Set the decryption key to be used if decryption shall happen in the
+     * cache itself.
+     * @since Series 60 3.0
+     * @param aKey AES128 decryption key
+     * @return ?description
+     */
+    void SetKey(
+        const TDesC8& aKey );
+
+#ifdef ASYNC_READ
+
+    TInt Read(
+        TInt aPos,
+        TDes8& aDes,
+        TInt aLength,
+        TRequestStatus& aStatus );
+
+    void ReadCancel( TRequestStatus& aStatus );
+#endif
+
+protected:
+    // New functions
+
+    void CachedReadL(
+        TInt& aPos,
+        TDes8& aDes,
+        TInt aLength );
+
+    void UncachedReadL(
+        TInt& aPos,
+        TDes8& aDes,
+        TInt aLength );
+
+    /**
+     * Check if a file position is in the give cache page
+     * @since Series 60 3.0
+     * @param aPage Page to check
+     * @param aPosition Position to check
+     * @return ETrue if the position is in the cache page
+     */
+    TBool InPage( TInt aPage, TInt aPosition );
+
+    /**
+     * Return the index of a free cache page
+     * @since Series 60 3.0
+     * @return Index of a free cache page
+     */
+    TInt GetFreePage();
+
+    /**
+     * Read a page of plain data for a given file position into the cache
+     * @since Series 60 3.0
+     * @param aPage Page to read
+     * @param aPosition Position to read
+     */
+    void ReadPageL( TInt aPage, TInt aPosition );
+
+    /**
+     * Read a page of data for a given file position into the cache and
+     * decrypt it
+     * @since Series 60 3.0
+     * @param aPage Page to read
+     * @param aPosition Position to read
+     */
+    void ReadAndDecryptPageL( TInt aPage, TInt aPosition );
+
+    /**
+     * Copy data from a cache page into a descriptor
+     * @since Series 60 3.0
+     * @param aPage Page from which to read
+     * @param aDes Decscriptor where the data is stored
+     * @param aPosition Position in the file, updated with the new
+     *                  position after the data has been read
+     * @param aLength Amount of data to be read, updated with the actual
+     *                amount that was read
+     */
+    void CopyOut( TInt aPage, TDes8& aDes, TInt& aPosition, TInt& aLength );
+
+    /**
+     * Decrypt a memory buffer using either the stored key or the
+     * RightsServer.
+     * @since Series 60 3.0
+     * @param aIv AES CBC initialization vector
+     * @param aPtr Data to be decrypted
+     */
+    void DecryptL( const TDesC8& aIv, TPtr8& aPtr );
+
+#ifdef ASYNC_READ
+    void ReadAsyncL();
+#endif
+
+protected:
+    // Functions from base classes
+
+#ifdef ASYNC_READ
+
+    /**
+     * From CActive
+     * @since Series60 3.0
+     */
+    void RunL();
+
+    /**
+     * From CActive
+     * @since Series60 3.0
+     */
+    void DoCancel();
+
+    /**
+     * From CActive
+     */
+    TInt RunError( TInt aError );
+#endif
+
+private:
+
+    /**
+     * C++ default constructor.
+     */
+    CDcfCache(
+        RDRMRightsClient& aRightsClient,
+        RFile& aFile,
+        CDcfCommon& aDcf,
+        TInt aPageSize,
+        TInt aPageCount );
+
+    /**
+     * By default Symbian 2nd phase constructor is private.
+     */
+    void ConstructL();
+
+protected:
+    // Types and enumerations
+
+    enum TDecryptionMode
+        {
+        EServerSide,
+        EClientSide,
+        };
+
+#ifdef ASYNC_READ
+
+    enum TReadMode
+        {
+        ENonPosRead,
+        EPosRead,
+        };
+
+#endif
+protected:
+    // Data
+    RFile& iFile;
+    RDRMRightsClient& iRightsClient;
+    CDcfCommon& iDcf;
+    TInt iPageSize;
+    TInt iPageCount;
+    RPointerArray<TUint8> iPage;
+    RArray<TInt> iPageUsageCount;
+    RArray<TInt> iPagePosition;
+    TEncryptionMethod iEncryptionMethod;
+    TBuf8<KDCFKeySize> iKey;
+    TDecryptionMode iDecryptionMode;
+
+#ifdef ASYNC_READ
+    TRequestStatus* iAsyncStatus;
+    TInt iPos;
+    TDes8* iDes;
+    TInt iLength;
+    TReadMode iOperation;
+    TBool iAsyncReadingOngoing;
+    TInt iError;
+#endif
+    };
+
+#endif      // DCFCACHE_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/inc/Oma2AgentAttributes.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of the Oma2AgentAttributes class
+*
+*/
+
+
+
+#ifndef __Oma2AGENTATTRIBUTES_H__
+#define __Oma2AGENTATTRIBUTES_H__
+
+#include <caf/caftypes.h>
+#include <caf/virtualpathptr.h>
+#include <caf/AttributeSet.h>
+#include <caf/StringAttributeSet.h>
+#include "Oma2Agent.h"
+#include "Oma2Dcf.h"
+
+using namespace ContentAccess;
+
+class RDRMRightsClient;
+
+/**
+All attribute values are common between the CAgentData, CAgentContent and
+CAgentManager. The OMA DCF attributes are mostly fixed anyway so this class
+implements helper functions for all of the attribute functions
+*/
+
+class TOma2AgentAttributes
+	{
+public:
+	static TInt GetAttribute(
+	    CDcfCommon& aDcfFile,
+	    TInt aAttribute, 
+	    const TVirtualPathPtr& aVirtualPath,
+	    RDRMRightsClient* aRightsClient = NULL);
+	    
+	static TInt GetAttributeSet(
+	    CDcfCommon& aDcfFile,
+	    RAttributeSet& aAttributeSet,
+	    const TVirtualPathPtr& aVirtualPath,
+	    RDRMRightsClient* aRightsClient = NULL);
+	    
+	static TInt GetStringAttribute(
+	    CDcfCommon& aDcfFile,
+	    TInt aAttribute,
+	    TDes& aValue,
+	    const TVirtualPathPtr& aVirtualPath,
+	    RDRMRightsClient* aRightsClient = NULL);
+	    
+	static TInt GetStringAttributeSet(
+	    CDcfCommon& aDcfFile,
+	    RStringAttributeSet& aStringAttributeSet,
+	    const TVirtualPathPtr& aVirtualPath,
+	    RDRMRightsClient* aRightsClient = NULL);
+	};
+
+#endif // __Oma2AGENTATTRIBUTES_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/inc/Oma2AgentContent.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,189 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of the OMA DRM CAF Content Agent
+*
+*/
+
+
+#ifndef OMA2AGENTCONTENT_H
+#define OMA2AGENTCONTENT_H
+
+//  INCLUDES
+#include <f32file.h>
+#include <caf/caf.h>
+#include <caf/agentinterface.h>
+#include <dcfcommon.h>
+#include <drmnotifier.h>
+#include <drmrightsclient.h>
+
+// FORWARD DECLARATIONS
+class CAESDecryptor;
+
+// CLASS DECLARATION
+namespace ContentAccess
+{
+
+/**
+*  OMA DRM CAF Content Agent implementation
+*
+*  @lib OmaDrmAgent.lib
+*  @since Series 60 3.0
+*/
+class COma2AgentContent : public CAgentContent, public MDRMEventObserver
+{
+public:
+	static COma2AgentContent* NewL(
+	    const TDesC& aUri, 
+	    TContentShareMode aShareMode);
+	    
+	static COma2AgentContent* NewLC(
+	    const TDesC& aUri, 
+	    TContentShareMode aShareMode);
+		
+	static COma2AgentContent* NewL(
+	    RFile& aFile);
+	
+	static COma2AgentContent* NewLC(
+	    RFile& aFile);
+
+    void EmbedDomainRoL();
+    
+	virtual ~COma2AgentContent();
+
+public: 
+	// From CAgentContent
+	virtual TInt OpenContainer(
+	    const TDesC& aUniqueId);
+	    
+	virtual TInt CloseContainer();
+	
+	virtual void GetEmbeddedObjectsL(
+	    RStreamablePtrArray<CEmbeddedObject>& aArray);
+	    
+	virtual void GetEmbeddedObjectsL(
+	    RStreamablePtrArray<CEmbeddedObject>& aArray,
+	    TEmbeddedType aType);
+	    
+	virtual TInt Search(
+	    RStreamablePtrArray<CEmbeddedObject>& aArray,
+	    const TDesC8& aMimeType,
+	    TBool aRecursive);
+	    
+	virtual TInt GetAttribute(
+	    TInt aAttribute, 
+	    TInt& aValue, 
+	    const TDesC& aUniqueId);
+	    
+	virtual TInt GetAttributeSet(
+	    RAttributeSet& aAttributeSet, 
+	    const TDesC& aUniqueId);
+	    
+	virtual TInt GetStringAttribute(
+	    TInt aAttribute, 
+	    TDes& aValue, 
+	    const TDesC& aUniqueId);
+	    
+	virtual TInt GetStringAttributeSet(
+	    RStringAttributeSet& aStringAttributeSet, 
+	    const TDesC& aUniqueId);
+	    
+	virtual TInt AgentSpecificCommand(
+	    TInt aCommand, 
+	    const TDesC8& aInputBuffer, 
+	    TDes8& aOutputBuffer);
+	    
+	virtual void AgentSpecificCommand(
+	    TInt aCommand, 
+	    const TDesC8& aInputBuffer, 
+	    TDes8& aOutputBuffer, 
+	    TRequestStatus& aStatus);
+	    
+	virtual void NotifyStatusChange(
+	    TEventMask aMask, 
+	    TRequestStatus& aStatus, 
+	    const TDesC& aUniqueId);
+	    
+	virtual TInt CancelNotifyStatusChange(
+	    TRequestStatus& aStatus, 
+	    const TDesC& aUniqueId);
+	    
+	virtual void RequestRights(
+	    TRequestStatus& aStatus, 
+	    const TDesC& aUniqueId);
+	    
+	virtual TInt CancelRequestRights(
+	    TRequestStatus& aStatus, 
+	    const TDesC& aUniqueId);
+	    
+	virtual void DisplayInfoL(
+	    TDisplayInfo aInfo, 
+	    const TDesC& aUniqueId);
+	    
+	virtual TInt SetProperty(
+	    TAgentProperty aProperty, 
+	    TInt aValue);
+
+public: // From MDRMEventObserver
+    virtual void HandleEventL(
+        MDRMEvent* aEvent);
+   
+private:
+	COma2AgentContent();
+
+	void NotifyStatusChangeL(
+	    TEventMask aMask, 
+	    TRequestStatus& aStatus, 
+	    const TDesC& aUniqueId);
+
+	
+	void ConstructL(
+	    const TDesC& aUri, 
+	    TContentShareMode aShareMode);
+	    
+	void ConstructL(
+	    RFile& aFile);
+		
+    protected:  // Data
+        CDcfCommon* iDcf;
+        RFs iFs;
+        RFile iFile;
+        TInt iFilePosition;
+        TInt iDataPosition;
+        HBufC* iUri;
+        
+        // Content ID of the currently open container,
+        // NULL for the outermost file
+        HBufC* iCurrentContainer;
+        
+        // Request status for change notifications
+        TRequestStatus* iStatus;
+        
+        // Notifier for change notifications
+        CDRMNotifier* iNotifier;
+        
+        // Watched events
+        TEventMask iWatchedEvents;
+        
+        // Watched content ID
+        HBufC8* iWatchedId;
+        
+        // Rights client
+        RDRMRightsClient iRdb;
+    };
+
+}
+
+#endif      // OMA2AGENTCONTENT_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/inc/Oma2AgentData.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,127 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of the OMA DRM CAF Data Agent
+*
+*/
+
+
+
+#ifndef OMA2AGENTDATA_H
+#define OMA2AGENTDATA_H
+
+//  INCLUDES
+#include <f32file.h>
+#include <caf/caf.h>
+#include <caf/agentinterface.h>
+#include <dcfcommon.h>
+#include <drmrightsclient.h>
+
+//this header can be removed when ASYNC_READ flag is removed
+#include "dcfcache.h"
+
+// FORWARD DECLARATIONS
+
+class CDcfCache;
+
+// CLASS DECLARATION
+
+namespace ContentAccess
+    {
+
+    /**
+     *  OMA DRM CAF Data Agent
+     *  @lib omadrmagent.lib
+     */
+    class COma2AgentData : public CAgentData
+        {
+    public:
+        // Constructors and destructor
+
+        /**
+         * Two-phased constructor.
+         */
+        static COma2AgentData* NewL( const TVirtualPathPtr& aVirtualPath,
+            TContentShareMode aShareMode );
+        static COma2AgentData* NewLC( const TVirtualPathPtr& aVirtualPath,
+            TContentShareMode aShareMode );
+
+        static COma2AgentData* NewL( RFile& aFile, const TDesC& aUniqueId );
+        static COma2AgentData* NewLC( RFile& aFile, const TDesC& aUniqueId );
+
+        /**
+         * Destructor.
+         */
+        ~COma2AgentData();
+
+    public:
+        // From CAgentData
+        TInt Read( TDes8& aDes );
+        TInt Read( TDes8& aDes, TInt aLength );
+        void Read( TDes8& aDes, TRequestStatus& aStatus );
+        void Read( TDes8& aDes, TInt aLength, TRequestStatus& aStatus );
+        void DataSizeL( TInt& aSize );
+        TInt Seek( TSeek aMode, TInt& aPos );
+        TInt SetProperty( TAgentProperty aProperty, TInt aValue );
+        TInt EvaluateIntent( TIntent aIntent );
+        TInt ExecuteIntent( TIntent aIntent );
+        TInt GetAttribute( TInt aAttribute, TInt& aValue );
+        TInt GetAttributeSet( RAttributeSet& aAttributeSet );
+        TInt GetStringAttribute( TInt aAttribute, TDes& aValue );
+        TInt GetStringAttributeSet( RStringAttributeSet& aStringAttributeSet );
+#ifdef ASYNC_READ
+        void ReadCancel( TRequestStatus& aStatus );
+        TInt Read( TInt aPos, TDes8& aDes, TInt aLength,
+            TRequestStatus& aStatus );
+#endif
+
+    private:
+
+        /**
+         * C++ default constructor.
+         */
+        COma2AgentData();
+
+        /**
+         * By default Symbian 2nd phase constructor is private.
+         */
+        void ConstructL( const TVirtualPathPtr& aVirtualPath,
+            TContentShareMode aShareMode );
+        void ConstructL( RFile& aFile, const TDesC& aUniqueId );
+        void InitializeL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // COma2AgentData( const COma2AgentData& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // COma2AgentData& operator=( const COma2AgentData& );
+
+    protected:
+        // Data
+        CDcfCommon* iDcf;
+        RFs iFs;
+        RFile iFile;
+        TInt iDataPosition;
+        TInt iRightsStatus;
+        RDRMRightsClient iRdb;
+        TVirtualPathPtr iVirtualPath;
+        CDcfCache* iCache;
+        TBool iGroupKeyUsed;
+        TInt iLastFileSize;
+        HBufC* iUniqueId;
+
+        };
+
+    }
+
+#endif      // OMA2AGENTDATA_H
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/inc/Oma2AgentFactory.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,163 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef OMA2AGENTFACTORY_H
+#define OMA2AGENTFACTORY_H
+
+//  INCLUDES
+#include <caf/agentfactory.h>
+#include "oma2agentcontent.h"
+#include "oma2agentdata.h"
+#include "oma2agentmanager.h"
+#include "oma2agentrightsmanager.h"
+#include "oma2agentimportfile.h"
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+namespace ContentAccess
+{
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class COma2AgentFactory : public CAgentFactory
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static COma2AgentFactory* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~COma2AgentFactory();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+		CAgentContent* CreateContentBrowserL(const TDesC& aURI, TContentShareMode aShareMode);	
+		CAgentContent* CreateContentBrowserL(RFile& aFile);
+		CAgentData* CreateDataConsumerL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode);
+		CAgentData* CreateDataConsumerL(RFile& aFile, const TDesC& aUniqueId);
+		CAgentManager*  CreateManagerL();
+		CAgentImportFile* CreateImporterL(const TDesC8& aMimeType, const CMetaDataArray& aMetaDataArray, const TDesC& aOutputDirectory, const TDesC& aSuggestedFileName);
+		CAgentImportFile* CreateImporterL(const TDesC8& aMimeType, const CMetaDataArray& aMetaDataArray);
+		CAgentRightsManager* CreateRightsManagerL();	
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        COma2AgentFactory();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // COma2AgentFactory( const COma2AgentFactory& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // COma2AgentFactory& operator=( const COma2AgentFactory& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+}
+
+#endif      // OMA2AGENTFACTORY_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/inc/Oma2AgentImportFile.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,134 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of the Oma2AgentImportFile class
+*
+*/
+
+
+#ifndef __OMA2AGENTIMPORTFILE_H__
+#define __OMA2AGENTIMPORTFILE_H__
+
+#include <s32file.h>
+#include <caf/agentinterface.h>
+#include <oma2agent.h>
+
+using namespace ContentAccess;
+
+class CDRMMessageParser;
+class COma1DcfCreator;
+class CDRMRights;
+
+class COma2AgentImportFile : public CAgentImportFile
+    {
+public:
+
+    enum TImportType
+        {
+        EOma1DrmMessage,
+        EOma1XmlRo,
+        EOma1WbxmlRo,
+        EOma2Ro,
+        EPlainContent
+        };
+
+    static COma2AgentImportFile* NewL(
+        const TDesC8& aMimeType,
+        const CMetaDataArray& aMetaDataArray,
+        const TDesC& aOutputDirectory,
+        const TDesC& aSuggestedFileName);
+        
+    static COma2AgentImportFile* NewL(
+        const TDesC8& aMimeType,
+        const CMetaDataArray& aMetaDataArray);
+        
+    virtual ~COma2AgentImportFile();
+
+public:
+
+    // From CAgentImportFile
+    virtual TInt WriteData(
+        const TDesC8& aData);
+        
+    virtual void WriteData(
+        const TDesC8& aData,
+        TRequestStatus& aStatus);
+        
+    virtual TInt WriteDataComplete();
+    
+    virtual void WriteDataComplete(
+        TRequestStatus& aStatus);
+        
+    virtual TInt OutputFileCountL() const;
+    
+    virtual CSupplierOutputFile& OutputFileL(
+        TInt aIndex);
+        
+    virtual TImportStatus GetImportStatus() const;
+    
+    virtual TInt GetSuggestedOutputFileExtension(
+        TDes& aFileExtension);
+        
+    virtual TInt GetSuggestedOutputFileName(
+        TDes& aFileName);
+        
+    virtual TInt ContinueWithNewOutputFile(
+        RFile& aFile, 
+        const TDesC& aFileName);
+        
+    virtual void ContinueWithNewOutputFile(
+        RFile& aFile, 
+        const TDesC& aFileName, 
+        TRequestStatus& aStatus);
+        
+    virtual void NewMimePartL(
+        const TDesC8& aMimeType, 
+        const CMetaDataArray& aImportMetaData);
+        
+    virtual void EndMimePartL();
+
+private:
+
+    COma2AgentImportFile(
+        TBool aAgentCreatesOutputFiles);
+        
+    void ConstructL(
+        const TDesC8& aMimeType, 
+        const CMetaDataArray& aMetaDataArray, 
+        const TDesC& aOutputDirectory, 
+        const TDesC& aSuggestedFileName);
+        
+    TInt OpenOutputFile();
+    
+    void WriteDataL(const TDesC8& aData);
+    
+private:
+
+    TImportType iImportType;
+    HBufC *iOutputDirectory;
+    HBufC *iSuggestedFileName;
+    HBufC *iOutputFileName;
+    HBufC8 *iLastWriteData;
+    RFs iFs;
+    RFileWriteStream iFile;
+    RPointerArray<CSupplierOutputFile> iOutputFiles;
+    TImportStatus iImportStatus;
+    TBool iAgentCreatesOutputFiles;
+    TBool iFileOpen;
+    CDRMMessageParser* iMessageParser;
+    COma1DcfCreator* iDcfCreator;
+    CDRMRights* iDcfRights;
+    HBufC8* iDcfMimeType;
+    };
+    
+#endif // __OMA2AGENTIMPORTFILE_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/inc/Oma2AgentManager.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,145 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#ifndef OMA2AGENTMANAGER_H
+#define OMA2AGENTMANAGER_H
+
+//  INCLUDES
+#include <caf/caf.h>
+#include <caf/agentinterface.h>
+#include <drmnotifier.h>
+
+class CFileMan;
+
+namespace ContentAccess
+{
+
+// CLASS DECLARATION
+
+class COma2AgentManager : public CAgentManager, public MDRMEventObserver
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static COma2AgentManager* NewL();
+        static COma2AgentManager* NewLC();
+        
+        /**
+        * Destructor.
+        */
+        ~COma2AgentManager();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+
+		// From CAgentManagerBase
+		TInt DeleteFile(const TDesC &aFileName);
+		TInt CopyFile(const TDesC& aSource, const TDesC& aDestination);
+		TInt CopyFile(RFile& aSource, const TDesC& aDestination);		
+		TInt RenameFile(const TDesC& aSource, const TDesC& aDestination);
+		TInt MkDir(const TDesC& aPath);
+		TInt MkDirAll(const TDesC& aPath);
+		TInt RmDir(const TDesC& aPath);
+		TInt GetDir(const TDesC& aName,TUint anEntryAttMask,TUint anEntrySortKey, CDir*& anEntryList) const;
+		TInt GetDir(const TDesC& aName,TUint anEntryAttMask,TUint anEntrySortKey, CDir*& anEntryList,CDir*& aDirList) const;
+		TInt GetDir(const TDesC& aName,const TUidType& anEntryUid,TUint anEntrySortKey, CDir*& aFileList) const;
+		TInt GetAttribute(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath);
+		TInt GetAttributeSet(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath);
+		TInt GetStringAttributeSet(RStringAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath);
+		TInt GetStringAttribute(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath);
+		void NotifyStatusChange(const TDesC& aURI, TEventMask aMask, TRequestStatus& aStatus);
+		TInt CancelNotifyStatusChange(const TDesC& aURI, TRequestStatus& aStatus);
+		TInt SetProperty(TAgentProperty aProperty, TInt aValue);
+		void DisplayInfoL(TDisplayInfo aInfo, const TVirtualPathPtr& aVirtualPath);
+		
+		// From CAgentManager
+		TBool IsRecognizedL(const TDesC& aURI, TContentShareMode aShareMode) const;
+		TBool IsRecognizedL(RFile& aFile) const;
+		TBool RecognizeFileL(const TDesC& aFileName, const TDesC8& aBuffer, TDes8& aFileMimeType, TDes8& aContentMimeType) const;
+		TInt AgentSpecificCommand(TInt aCommand, const TDesC8& aInputBuffer, TDes8& aOutputBuffer);
+		void AgentSpecificCommand(TInt aCommand, const TDesC8& aInputBuffer, TDes8& aOutputBuffer, TRequestStatus& aStatus);
+        void PrepareHTTPRequestHeaders(RStringPool& aStringPool, RHTTPHeaders& aRequestHeaders) const;
+		void DisplayManagementInfoL();
+		
+public: // From MDRMEventObserver
+        virtual void HandleEventL(
+            MDRMEvent* aEvent);
+   
+	private:
+		RFs iFs;
+        
+        // File manager
+        CFileMan* iFileManager;
+        
+        // Oma based extensions
+        HBufC8* iOmaBasedMimeType;
+                
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        COma2AgentManager();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        void FetchOmaBasedInfoL();
+        void PrepareHTTPRequestHeadersL(RStringPool& aStringPool, RHTTPHeaders& aRequestHeaders) const;
+        
+
+    protected:  // Data
+        // Request status for change notifications
+        TRequestStatus* iStatus;
+        
+        // Notifier for change notifications
+        CDRMNotifier* iNotifier;
+        
+        // Watched events
+        TEventMask iWatchedEvents;
+        
+        // Watched content ID
+        HBufC8* iWatchedId;
+    };
+
+}
+
+#endif      // OMA2AGENTMANAGER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/inc/Oma2AgentRightsManager.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,163 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Class definition for OMA DRM CAF Agent Rights Manager
+*
+*/
+
+
+
+#ifndef OMA2AGENTRIGHTSMANAGER_H
+#define OMA2AGENTRIGHTSMANAGER_H
+
+//  INCLUDES
+#include <caf/caf.h>
+#include <caf/agentinterface.h>
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+namespace ContentAccess
+{
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class COma2AgentRightsManager : public CAgentRightsManager
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static COma2AgentRightsManager* NewL();
+        static COma2AgentRightsManager* NewLC();
+        
+        /**
+        * Destructor.
+        */
+        ~COma2AgentRightsManager();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+
+		// From CAgentRightsManager
+		void ListAllRightsL(RStreamablePtrArray<CRightsInfo>& aArray) const;
+		void ListRightsL(RStreamablePtrArray<CRightsInfo>& aArray, const TDesC& aUri) const;
+		void ListRightsL(RStreamablePtrArray<CRightsInfo>& aArray, TVirtualPathPtr& aVirtualPath) const;
+		void ListContentL(RStreamablePtrArray<CVirtualPath>& aArray, CRightsInfo& aRightsInfo) const;
+		MAgentRightsBase* GetRightsDataL(const CRightsInfo& aRightsInfo) const;
+		TInt DeleteRightsObject(const CRightsInfo& aRightsInfo);
+		TInt DeleteAllRightsObjects(const TVirtualPathPtr& aVirtualPath);
+        TInt SetProperty(TAgentProperty aProperty, TInt aValue);
+		
+	private:
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        COma2AgentRightsManager();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // COma2AgentRightsManager( const COma2AgentRightsManager& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // COma2AgentRightsManager& operator=( const COma2AgentRightsManager& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+}
+
+#endif      // OMA2AGENTRIGHTSMANAGER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/src/101F6DB4.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Resource file for OMA DRM CAF Agent
+*
+*/
+
+
+// 0x101F6DB4.RSS
+// Sample resource file for a CA agent
+
+// ECOM DLL UID:		0x101FC2CD
+// CA Agent interface UID:	0x10204740
+
+#include <ecom/registryinfo.rh>
+
+RESOURCE REGISTRY_INFO theInfo
+{
+        dll_uid = 0x101F6DB4;
+        interfaces =
+        {
+                INTERFACE_INFO
+                {
+                interface_uid = 0x10204740;
+                implementations = 
+                        {
+                        IMPLEMENTATION_INFO
+                                {
+                                implementation_uid = 0x101F6DB4;
+                                version_no = 1;
+                                display_name = "OMA DRM Agent";
+                                default_data = "512|application/vnd.oma.drm.message,application/vnd.oma.drm.rights+xml,application/vnd.oma.drm.rights+wbxml,application/vnd.oma.drm.roap-pdu+xml,application/x-vnd.oma.drm.import:application/vnd.oma.drm.content,application/vnd.oma.drm.dcf";
+                                opaque_data = "101F51F2"; // the agent's private directory
+                                }
+                        };
+                }
+        };
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/src/DcfCache.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,552 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the DCF cache class
+*
+*/
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <e32base.h>
+#include <symmetric.h>
+#include <rijndael.h>
+#include "DcfCache.h"
+#include "DcfCommon.h"
+#include "DrmRightsClient.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDcfCache::CDcfCache
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+#ifdef ASYNC_READ
+
+CDcfCache::CDcfCache(
+    RDRMRightsClient& aRightsClient,
+    RFile& aFile,
+    CDcfCommon& aDcf,
+    TInt aPageSize,
+    TInt aPageCount ) :
+CActive( CActive::EPriorityStandard ),
+iFile( aFile ),
+iRightsClient(aRightsClient ),
+iDcf( aDcf ),
+iPageSize( aPageSize ),
+iPageCount( aPageCount ),
+iDecryptionMode( EServerSide ),
+iDes( 0 ),
+iAsyncReadingOngoing( EFalse )
+    {
+    }
+
+#else
+
+CDcfCache::CDcfCache(
+    RDRMRightsClient& aRightsClient,
+    RFile& aFile,
+    CDcfCommon& aDcf,
+    TInt aPageSize,
+    TInt aPageCount ) :
+iFile( aFile ),
+iRightsClient( aRightsClient ),
+iDcf( aDcf ),
+iPageSize( aPageSize ),
+iPageCount( aPageCount ),
+iDecryptionMode( EServerSide )
+    {
+    }
+#endif
+// -----------------------------------------------------------------------------
+// CDcfCache::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDcfCache::ConstructL()
+    {
+    for ( TInt i = 0; i < iPageCount; i++ )
+        {
+        iPage.AppendL( new ( ELeave ) TUint8[iPageSize] );
+        iPageUsageCount.AppendL( -1 );
+        iPagePosition.AppendL( -1 );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDcfCache* CDcfCache::NewL( RDRMRightsClient& aRightsClient, RFile& aFile,
+    CDcfCommon& aDcf, TInt aPageSize, TInt aPageCount )
+    {
+    CDcfCache* self = new ( ELeave ) CDcfCache( aRightsClient, aFile, aDcf,
+        aPageSize, aPageCount );
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::~CDcfCache
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CDcfCache::~CDcfCache()
+    {
+
+#ifdef ASYNC_READ
+    if ( IsActive() )
+        {
+        if ( iAsyncReadingOngoing )
+            {
+            Cancel();
+            }
+        else
+            {
+            TRequestStatus* status = &iStatus;
+            User::RequestComplete( status, KErrNone );
+            Cancel();
+            }
+        }
+#endif
+
+    iPage.ResetAndDestroy();
+    iPage.Close();
+    iPagePosition.Close();
+    iPageUsageCount.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::Read
+// -----------------------------------------------------------------------------
+//
+TInt CDcfCache::Read( TInt& aPos, TDes8& aDes, TInt aLength )
+    {
+    TInt r = KErrNone;
+
+    // Check that the position is valid and the length is valid
+    if ( aPos < 0 || aLength < 0 )
+        {
+        return KErrArgument;
+        }
+
+    if ( iPageCount > 0 )
+        {
+        TRAP(r, CachedReadL(aPos, aDes, aLength));
+        }
+    else
+        {
+        TRAP(r, UncachedReadL(aPos, aDes, aLength));
+        }
+    if ( r != KErrNone )
+        {
+        RDebug::Printf( "CDcfCache::Read error: %d", r );
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::Read
+// -----------------------------------------------------------------------------
+//
+
+#ifdef ASYNC_READ
+
+TInt CDcfCache::Read( TInt aPos, TDes8& aDes, TInt aLength,
+    TRequestStatus& aStatus )
+    {
+
+    // Check that the position is valid and the length is valid
+    if ( aPos < 0 || aLength < 0 )
+        {
+        return KErrArgument;
+        }
+
+    if ( !IsAdded() )
+        {
+        CActiveScheduler::Add( this );
+        }
+
+    if ( iAsyncReadingOngoing )
+        {
+        return KErrInUse;
+        }
+
+    iError = KErrNone;
+
+    iAsyncReadingOngoing = ETrue;
+
+    iPos = aPos;
+    iLength = aLength;
+    iDes = &aDes;
+    iOperation = EPosRead;
+
+    iAsyncStatus = &aStatus;
+    *iAsyncStatus = KRequestPending;
+
+    TRequestStatus* ownStatus = &iStatus;
+    *ownStatus = KRequestPending;
+
+    SetActive();
+    User::RequestComplete( ownStatus, KErrNone );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::ReadCancel
+// -----------------------------------------------------------------------------
+//
+void CDcfCache::ReadCancel( TRequestStatus& aStatus )
+    {
+    // only cancel if needed
+    TRequestStatus* status( &aStatus );
+    if ( IsActive() && iAsyncStatus == status )
+        {
+        if ( iAsyncReadingOngoing )
+            {
+            Cancel();
+            iAsyncReadingOngoing = EFalse;
+            iAsyncStatus = NULL;
+            User::RequestComplete( status, KErrCancel );
+            }
+        }
+    }
+
+#endif
+
+// -----------------------------------------------------------------------------
+// CDcfCache::CachedReadL
+// -----------------------------------------------------------------------------
+//
+void CDcfCache::CachedReadL( TInt& aPos, TDes8& aDes, TInt aLength )
+    {
+    TInt i;
+
+    // Check that the position is valid and the length is valid
+    if ( aPos < 0 || aLength < 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    aDes.SetLength( 0 );
+    while ( aLength > 0 )
+        {
+        for ( i = 0; aLength > 0 && i < iPageCount; i++ )
+            {
+            if ( InPage( i, aPos ) )
+                {
+                CopyOut( i, aDes, aPos, aLength );
+                }
+            }
+        if ( i == iPageCount && aLength > 0 )
+            {
+            i = GetFreePage();
+            if ( iDcf.iEncryptionMethod == EMethodAES_128_CBC )
+                {
+                ReadAndDecryptPageL( i, aPos );
+                CopyOut( i, aDes, aPos, aLength );
+                }
+            else
+                {
+                ReadPageL( i, aPos );
+                CopyOut( i, aDes, aPos, aLength );
+                }
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::UncachedReadL
+// -----------------------------------------------------------------------------
+//
+void CDcfCache::UncachedReadL( TInt& aPos, TDes8& aDes, TInt aLength )
+    {
+    HBufC8* buffer = NULL;
+    TPtr8 ptr( NULL, 0 );
+    TBuf8<KDCFKeySize> iv;
+    TInt pos;
+    TInt length;
+
+    // Check that the position is valid and the length is valid
+    if ( aPos < 0 || aLength < 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    if ( aPos + aLength > iDcf.iPlainTextLength )
+        {
+        if ( aPos < iDcf.iPlainTextLength )
+            {
+            aLength = iDcf.iPlainTextLength - aPos;
+            }
+        else
+            {
+            aLength = 0;
+            }
+        }
+
+    if ( iDcf.iEncryptionMethod == EMethodAES_128_CBC )
+        {
+
+        // Nothing to read:
+        if ( aLength == 0 )
+            {
+            aDes.SetLength( aLength );
+            return;
+            }
+
+        buffer = HBufC8::NewLC( aLength + 2 * KDCFKeySize );
+        ptr.Set( buffer->Des() );
+        pos = ( ( aPos / KDCFKeySize ) * KDCFKeySize ) + iDcf.iOffset;
+        User::LeaveIfError( iFile.Read( pos, iv, KDCFKeySize ) );
+        length = ( ( aLength / KDCFKeySize ) * KDCFKeySize ) + 2
+            * KDCFKeySize;
+        User::LeaveIfError( iFile.Read( ptr, length ) );
+
+        // Make sure we have the correct amount of data
+        if ( ptr.Length() % KDCFKeySize )
+            {
+            length = ( ( ptr.Length() / KDCFKeySize ) * KDCFKeySize );
+            ptr.SetLength( length );
+            }
+
+        // If not enough was read to get any content return an empty descriptor
+        if ( ptr.Length() == 0 )
+            {
+            aDes.SetLength( 0 );
+            CleanupStack::PopAndDestroy( buffer );
+            return;
+            }
+
+        DecryptL( iv, ptr );
+        length = Min( aDes.MaxLength(), ptr.Length() - aPos % KDCFKeySize );
+        aDes.Copy( ptr.Mid( aPos % KDCFKeySize, length ) );
+        if ( aDes.Length() > aLength )
+            {
+            aDes.SetLength( aLength );
+            }
+        CleanupStack::PopAndDestroy( buffer );
+        }
+    else
+        {
+        User::LeaveIfError( iFile.Read( aPos + iDcf.iOffset, aDes, aLength ) );
+        }
+    aPos += aDes.Length();
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::GetFreePage
+// -----------------------------------------------------------------------------
+//
+TInt CDcfCache::GetFreePage()
+    {
+    TInt i;
+    TInt n = -1;
+    TUint c = KMaxTUint32;
+
+    for ( i = 0; i < iPageCount; i++ )
+        {
+        if ( iPageUsageCount[i] == -1 )
+            {
+            n = i;
+            break;
+            }
+        else if ( iPageUsageCount[i] < c )
+            {
+            c = iPageUsageCount[i];
+            n = i;
+            }
+        }
+    return n;
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::ReadPageL
+// -----------------------------------------------------------------------------
+//
+void CDcfCache::ReadPageL( TInt aPage, TInt aPosition )
+    {
+    TInt pos;
+    TBuf8<KDCFKeySize> iv;
+
+    iPageUsageCount[aPage] = 0;
+    iPagePosition[aPage] = ( aPosition / iPageSize ) * iPageSize;
+    pos = iPagePosition[aPage] + iDcf.iOffset;
+    iFile.Seek( ESeekStart, pos );
+    TPtr8 ptr( iPage[aPage], iPageSize );
+    User::LeaveIfError( iFile.Read( ptr ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::ReadAndDecryptPageL
+// -----------------------------------------------------------------------------
+//
+void CDcfCache::ReadAndDecryptPageL( TInt aPage, TInt aPosition )
+    {
+    TInt pos;
+    TBuf8<KDCFKeySize> iv;
+
+    iPageUsageCount[aPage] = 0;
+    iPagePosition[aPage] = ( aPosition / iPageSize ) * iPageSize;
+    pos = iPagePosition[aPage] + iDcf.iOffset;
+    User::LeaveIfError( iFile.Seek( ESeekStart, pos ) );
+    User::LeaveIfError( iFile.Read( iv ) );
+    TPtr8 ptr( iPage[aPage], iPageSize );
+    pos += KDCFKeySize;
+    User::LeaveIfError( iFile.Read( ptr ) );
+    ptr.SetLength( iPageSize );
+    DecryptL( iv, ptr );
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::CopyOut
+// -----------------------------------------------------------------------------
+//
+void CDcfCache::CopyOut( TInt aPage, TDes8& aDes, TInt& aPosition,
+    TInt& aLength )
+    {
+    TInt n;
+    TInt offset;
+
+    aLength = Min( aLength, iDcf.iPlainTextLength - aPosition );
+    aLength = Min( aLength, aDes.MaxLength() - aDes.Length() );
+    offset = aPosition - iPagePosition[aPage];
+    n = Min( aLength, iPageSize - offset );
+    aDes.Append( iPage[aPage] + offset, n );
+    aLength -= n;
+    aPosition += n;
+    iPageUsageCount[aPage]++;
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::InPage
+// -----------------------------------------------------------------------------
+//
+TBool CDcfCache::InPage( TInt aPage, TInt aPosition )
+    {
+    return iPagePosition[aPage] != -1 && iPagePosition[aPage] <= aPosition
+        && aPosition < iPagePosition[aPage] + iPageSize ? ETrue : EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::SetKey
+// -----------------------------------------------------------------------------
+//
+void CDcfCache::SetKey( const TDesC8& aKey )
+    {
+    iKey.Copy( aKey );
+    iDecryptionMode = EClientSide;
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::DecryptL
+// -----------------------------------------------------------------------------
+//
+void CDcfCache::DecryptL( const TDesC8& aIv, TPtr8& aPtr )
+    {
+    if ( iDecryptionMode == EClientSide )
+        {
+        CModeCBCDecryptor* cbc( NULL );
+        CAESDecryptor* aes( CAESDecryptor::NewLC( iKey ) );
+        cbc = CModeCBCDecryptor::NewL( aes, aIv );
+        CleanupStack::Pop( aes );
+        aes = NULL;
+        CleanupStack::PushL( cbc );
+        for ( TInt count = 0; count < aPtr.Length(); count += KDCFKeySize )
+            {
+            TPtr8 d( aPtr.MidTPtr( count, KDCFKeySize ) );
+            cbc->Transform( d );
+            }
+        CleanupStack::PopAndDestroy( cbc );
+        }
+    else
+        {
+        User::LeaveIfError( iRightsClient.Decrypt( aIv, aPtr ) );
+        }
+    }
+
+#ifdef ASYNC_READ
+
+// -----------------------------------------------------------------------------
+// CDcfCache::RunL
+// -----------------------------------------------------------------------------
+//
+void CDcfCache::RunL()
+    {
+
+    switch ( iOperation )
+        {
+        case ENonPosRead:
+            {
+            break;
+            }
+
+        case EPosRead:
+            {
+            ReadAsyncL();
+            iAsyncReadingOngoing = EFalse;
+            User::RequestComplete( iAsyncStatus, KErrNone );
+            iAsyncStatus = NULL;
+            break;
+            }
+
+        default:
+            {
+            break;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::DoCancel
+// -----------------------------------------------------------------------------
+//
+void CDcfCache::DoCancel()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::RunError
+// -----------------------------------------------------------------------------
+//
+TInt CDcfCache::RunError( TInt aError )
+    {
+    iError = aError;
+    User::RequestComplete( iAsyncStatus, iError );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCache::ReadAsyncL
+// -----------------------------------------------------------------------------
+//
+
+void CDcfCache::ReadAsyncL()
+    {
+    if ( iPageCount > 0 )
+        {
+        TRAP(iError, CachedReadL(iPos, *iDes, iLength));
+        }
+    else
+        {
+        TRAP(iError, UncachedReadL(iPos, *iDes, iLength));
+        }
+    }
+#endif //ASYNC_READ
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/src/Oma2Agent.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// INCLUDE FILES
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include "oma2agentfactory.h"
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+
+/** Implementation table is required by ECom. Allows alternative
+	New methods to be specified.
+*/
+
+const TImplementationProxy ImplementationTable[] =
+	{
+#ifdef __EABI__
+		IMPLEMENTATION_PROXY_ENTRY(0x101F6DB4,
+            ContentAccess::COma2AgentFactory::NewL)
+#else
+		{ {0x101F6DB4}, ContentAccess::COma2AgentFactory::NewL}
+#endif
+	}; 
+
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy: Lookup method required by ECom
+// Returns the ImplementationTable to the  ECom framework
+// -----------------------------------------------------------------------------
+//
+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/omadrm/drmengine/agentv2/src/Oma2AgentAttributes.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1219 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Access to content and data attributes
+*
+*/
+
+
+// Includes
+#include <apgcli.h>
+#include <f32file.h>
+#include <charconv.h>
+
+#include <caf/caf.h>
+#include <caf/attributeset.h>
+#include <caf/stringattributeset.h>
+#include <caf/virtualpath.h>
+#include <caf/caferr.h>
+#include <utf.h>
+#include <drmagents.h>
+#include "oma2agent.h"
+#include "oma2agentattributes.h"
+#include "oma1dcf.h"
+#include "oma2dcf.h"
+#include "drmrightsclient.h"
+#include "DrmProtectedRoParser.h"
+
+using namespace ContentAccess;
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C HBufC* CollectEmbeddedRosL(
+    COma2Dcf* aDcf);
+
+LOCAL_C HBufC* GetDomainRiUrlL(
+    COma2Dcf* aDcf);
+
+LOCAL_C HBufC* GetDomainIdL(
+    COma2Dcf* aDcf);
+
+LOCAL_C HBufC* GetDomainRiIdL(
+    COma2Dcf* aDcf);
+
+LOCAL_C TInt CheckIntentL(
+    const TDesC8& aContentId,
+    TIntent aIntent,
+    RDRMRightsClient* aRightsClient);
+
+LOCAL_C TInt GetEstimatedArrivalTime(
+    const TDesC8& aContentId,
+    RDRMRightsClient* aRightsClient);
+
+LOCAL_C TInt GetContentName(
+    const TDesC8& aContentId,
+    HBufC*& aContentName,
+    RDRMRightsClient* aRightsClient );
+
+// LOCAL CONSTANTS
+
+_LIT16(KOma1DcfContentType16, "application/vnd.oma.drm.content");
+_LIT16(KOma2DcfContentType16, "application/vnd.oma.drm.dcf");
+const TInt KMaxAlbumTrack = 3;
+const TInt KMaxRecordingYear = 6;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CollectEmbeddedRosL
+// Concatenate all rights objects embedded in a DCF into one buffer
+// -----------------------------------------------------------------------------
+//
+LOCAL_C HBufC* CollectEmbeddedRosL(
+    COma2Dcf* aDcf)
+    {
+    HBufC* r = NULL;
+    HBufC* ro = NULL;
+    TPtr ptr(NULL, 0);
+    TInt i;
+    TInt n;
+
+    if (aDcf != NULL && aDcf->iRightsObjects.Count() > 0)
+        {
+        n = 0;
+        for (i = 0; i < aDcf->iRightsObjects.Count(); i++)
+            {
+            n += aDcf->iRightsObjects[i]->Length();
+            }
+        r = HBufC::NewLC(n);
+        ptr.Set(r->Des());
+        for (i = 0; i < aDcf->iRightsObjects.Count(); i++)
+            {
+            ro = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+                *aDcf->iRightsObjects[i]);
+            ptr.Append(*ro);
+            delete ro;
+            }
+        CleanupStack::Pop(r);
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// GetDomainRiUrlL
+// Returns the RI URL from the last embedded domain RO, to be used for
+// automatically joining a domain
+// -----------------------------------------------------------------------------
+//
+LOCAL_C HBufC* GetDomainRiUrlL(
+    COma2Dcf* aDcf)
+    {
+    HBufC8* url = NULL;
+    HBufC* r = NULL;
+    CDrmProtectedRoParser* parser = NULL;
+
+    if (aDcf != NULL && aDcf->iRightsObjects.Count() > 0)
+        {
+        parser = CDrmProtectedRoParser::NewL();
+        CleanupStack::PushL(parser);
+        url = parser->GetRiUrlL(*aDcf->iRightsObjects[ 0 ]);
+        if (url != NULL)
+            {
+            CleanupStack::PushL(url);
+            r = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*url);
+            CleanupStack::PopAndDestroy(); // url
+            }
+        CleanupStack::PopAndDestroy(); // parser
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// GetDomainRiIdL
+// Returns the RI ID from the last embedded domain RO, to be used for
+// automatically joining a domain
+// -----------------------------------------------------------------------------
+//
+LOCAL_C HBufC* GetDomainRiIdL(
+    COma2Dcf* aDcf)
+    {
+    HBufC8* id = NULL;
+    HBufC* r = NULL;
+    CDrmProtectedRoParser* parser = NULL;
+    TInt i;
+    TPtr ptr(NULL, 0);
+
+    if (aDcf != NULL && aDcf->iRightsObjects.Count() > 0)
+        {
+        parser = CDrmProtectedRoParser::NewL();
+        CleanupStack::PushL(parser);
+        id = parser->GetRiIdL(*aDcf->iRightsObjects[ 0 ]);
+        if (id != NULL)
+            {
+            CleanupStack::PushL(id);
+            r = HBufC::NewL(id->Length() * 2);
+            ptr.Set(r->Des());
+            for (i = 0; i < id->Length(); i++)
+                {
+                ptr.Append((*id)[i]);
+                }
+            CleanupStack::PopAndDestroy(); // url
+            }
+        CleanupStack::PopAndDestroy(); // parser
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// GetDomainIdL
+// Returns the domain ID from the last embedded domain RO, to be used for
+// automatically joining a domain
+// -----------------------------------------------------------------------------
+//
+LOCAL_C HBufC* GetDomainIdL(
+    COma2Dcf* aDcf)
+    {
+    HBufC8* id = NULL;
+    HBufC* r = NULL;
+    CDrmProtectedRoParser* parser = NULL;
+
+    if (aDcf != NULL && aDcf->iRightsObjects.Count() > 0)
+        {
+        parser = CDrmProtectedRoParser::NewL();
+        CleanupStack::PushL(parser);
+        id = parser->GetDomainIdL(*aDcf->iRightsObjects[ 0 ]);
+        if (id != NULL)
+            {
+            CleanupStack::PushL(id);
+            r = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*id);
+            CleanupStack::PopAndDestroy(); // id
+            }
+        CleanupStack::PopAndDestroy(); // parser
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CheckIntentL
+// Check the intent for a content ID via the rights server
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt CheckIntentL(
+    const TDesC8& aContentId,
+    TIntent aIntent,
+    RDRMRightsClient* aRightsClient)
+    {
+    RDRMRightsClient client;
+    TInt r;
+    TBool retVal = EFalse;
+    TUint32 reason = 0;
+
+    if (aRightsClient == NULL)
+        {
+        User::LeaveIfError(client.Connect());
+        r = client.CheckRights(aIntent, aContentId, reason);
+        client.Close();
+        }
+    else
+        {
+        r = aRightsClient->CheckRights(aIntent, aContentId, reason);
+        }
+
+    // If the rights exist return ETrue
+    if( r == KErrNone )
+        {
+        retVal = ETrue;
+        }
+
+    return retVal;
+    }
+
+// -----------------------------------------------------------------------------
+// GetEstimatedArrivalTime
+// Get the estimated arrival time for the rights (value of the
+// X-OMA-Separate-Delivery header)
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt GetEstimatedArrivalTime(
+    const TDesC8& aContentId,
+    RDRMRightsClient* aRightsClient)
+    {
+    RDRMRightsClient client;
+    TInt r;
+    TTimeIntervalSeconds n;
+
+    if (aRightsClient == NULL)
+        {
+        r = client.Connect();
+        if (r != KErrNone)
+            {
+            return r;
+            }
+
+        r = client.GetEstimatedArrival(aContentId, n);
+        client.Close();
+        }
+    else
+        {
+        r = aRightsClient->GetEstimatedArrival(aContentId, n);
+        }
+    if (r == KErrNone)
+        {
+        r = n.Int();
+
+        // -1 is the special case when the arrival time has passed,
+        // the first caller gets the KErrCAPendingRights meaning
+        // the rights are still pending
+        if( r == -1 )
+            {
+            r = KErrCAPendingRights;
+            }
+        }
+
+    return r;
+    }
+
+
+// -----------------------------------------------------------------------------
+// GetContentName
+// Get the content name stored into the rights database
+// -----------------------------------------------------------------------------
+//
+
+LOCAL_C TInt GetContentName(
+    const TDesC8& aContentId,
+    HBufC*& aContentName,
+    RDRMRightsClient* aRightsClient )
+    {
+    RDRMRightsClient client;
+    TInt r;
+
+    if (aRightsClient == NULL)
+        {
+        r = client.Connect();
+        if( !r )
+            {
+            r = client.GetName(aContentId, aContentName);
+            }
+        client.Close();
+        }
+    else
+        {
+        r = aRightsClient->GetName(aContentId, aContentName);
+        }
+
+    return r;
+    };
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TOma2AgentAttributes::
+//
+// -----------------------------------------------------------------------------
+//
+TInt TOma2AgentAttributes::GetAttribute(
+    CDcfCommon& aDcfFile,
+    TInt aAttribute,
+    const TVirtualPathPtr& aVirtualPath,
+    RDRMRightsClient* aRightsClient)
+    {
+    RDRMRightsClient client;
+    TInt value = KErrCANotSupported;
+    COma2Dcf* dcf2 = NULL;
+    TBool protection = ETrue;
+    HBufC8* buffer;
+    TInt traperror = KErrNone;
+
+    if (aDcfFile.iVersion == 2)
+        {
+        dcf2 = static_cast<COma2Dcf*>(&aDcfFile);
+        if (dcf2->iEncryptionMethod == EMethodNULL)
+            {
+            protection = EFalse;
+            }
+        }
+    if(aVirtualPath.UniqueId().Length() == 0)
+        {
+        // The DCF file itself
+        switch(aAttribute)
+            {
+            case DRM::EDrmAgentUid:
+                value = DRM::EDrmOmaAgent;
+                break;
+            case EIsProtected:
+                value = EFalse;
+                break;
+            case EIsForwardable:
+                value = ETrue;
+                break;
+            case EIsModifyable:
+                value = EFalse;
+                break;
+            case EIsCopyable:
+                value = ETrue;
+                break;
+            case EContentCDataInUse:
+                value = KErrCANotSupported;
+                break;
+            case ECopyPaste:
+                value = ETrue;
+                break;
+            case ECanMove:
+                value = ETrue;
+                break;
+            case ECanRename:
+                value = ETrue;
+                break;
+            case EFileType:
+            case DRM::EDrmFileType:
+                value = aDcfFile.iVersion;
+                break;
+            case ESilentRightsType:
+                value = 0;
+                break;
+            case EDeliveryMethod:
+                if (aDcfFile.iVersion == 2)
+                    {
+                    value = EOmaDrm2;
+                    }
+                else
+                    {
+                    if (aDcfFile.iContentID->Left(4).Compare(_L8("flk:")) == 0)
+                        {
+                        if (aRightsClient == NULL)
+                            {
+                            value = client.Connect();
+                            if (value != KErrNone)
+                                {
+                                break;
+                                }
+                            if (client.ForwardLockURI(buffer) == KErrNone &&
+                                buffer != NULL)
+                                {
+                                if (aDcfFile.iContentID->Compare(*buffer) == 0)
+                                    {
+                                    value = EOmaDrm1ForwardLock;
+                                    }
+                                else
+                                    {
+                                    value = EOmaDrm1CombinedDelivery;
+                                    }
+                                delete buffer;
+                                }
+                            else
+                                {
+                                value = KErrGeneral;
+                                }
+                            client.Close();
+                            break;
+                            }
+                        else
+                            {
+                            if (aRightsClient->ForwardLockURI(buffer) == KErrNone &&
+                            buffer != NULL)
+                                {
+                                if (aDcfFile.iContentID->Compare(*buffer) == 0)
+                                    {
+                                    value = EOmaDrm1ForwardLock;
+                                    }
+                                else
+                                    {
+                                    value = EOmaDrm1CombinedDelivery;
+                                    }
+                                delete buffer;
+                                }
+                            else
+                                {
+                                value = KErrGeneral;
+                                }
+                            }
+                        }
+                    else if (aDcfFile.iContentID->Left(4).Compare(_L8("ldf:")) == 0)
+                        {
+                        value = EOmaDrm1LocalDataFile;
+                        }
+                    else
+                        {
+                        value = EOmaDrm1SeparateDelivery;
+                        }
+                    }
+                break;
+            case DRM::EDrmAllowedOutputs:
+                value = DRM::EDrmAllowAudioAnalog | DRM::EDrmAllowAudioBluetooth | DRM::EDrmAllowVideoMacroVision | DRM::EDrmAllowAudioFmTransmitter;
+                break;
+            default:
+                value = KErrCANotSupported;
+                break;
+            }
+        }
+    else
+        {
+        switch(aAttribute)
+            {
+            case DRM::EDrmAgentUid:
+                value = DRM::EDrmOmaAgent;
+                break;
+            case EIsProtected:
+                value = protection;
+                break;
+            case EIsForwardable:
+                if ((aDcfFile.iContentID->Left(4).Compare(_L8("flk:")) == 0)
+                    ||
+                    (aDcfFile.iContentID->Left(4).Compare(_L8("ldf:")) == 0))
+                    {
+                    value = EFalse;
+                    }
+                else
+                    {
+                    if (aDcfFile.iRightsIssuerURL == NULL )
+                        {
+                        value = EFalse;
+                        }
+                     else
+                        {
+                        value = ETrue;
+                        }
+                    }
+                break;
+            case EIsModifyable:
+                value = protection ? EFalse : ETrue;
+                break;
+            case EIsCopyable:
+                value = protection ? EFalse : ETrue;
+                break;
+            case ECanPlay:
+                if (!protection)
+                    {
+                    value = ETrue;
+                    }
+                else
+                    {
+
+                    TRAP(traperror, value = CheckIntentL(*aDcfFile.iContentID, EPlay,
+                        aRightsClient));
+                    if( traperror )
+                        {
+                        value = traperror;
+                        }
+                    }
+                break;
+            case ECanPrint:
+                if (!protection)
+                    {
+                    value = ETrue;
+                    }
+                else
+                    {
+                    TRAP(traperror, value = CheckIntentL(*aDcfFile.iContentID, EPrint,
+                        aRightsClient));
+                    if( traperror )
+                        {
+                        value = traperror;
+                        }
+                    }
+                break;
+            case ECanExecute:
+                if (!protection)
+                    {
+                    value = ETrue;
+                    }
+                else
+                    {
+                    TRAP(traperror, value = CheckIntentL(*aDcfFile.iContentID, EExecute,
+                        aRightsClient));
+                    if( traperror )
+                        {
+                        value = traperror;
+                        }
+                    }
+                break;
+            case ECanView:
+                if (!protection)
+                    {
+                    value = ETrue;
+                    }
+                else
+                    {
+                    TRAP(traperror, value = CheckIntentL(*aDcfFile.iContentID, EView,
+                        aRightsClient));
+                    if( traperror )
+                        {
+                        value = traperror;
+                        }
+                    }
+                break;
+            case EPreviewAvailable:
+                if (dcf2 != NULL && dcf2->iPreview != ENoPreview)
+                    {
+                    value = ETrue;
+                    }
+                else
+                    {
+                    value = EFalse;
+                    }
+                break;
+            case EPreviewType:
+                value = ENoPreview;
+                if ( dcf2 != NULL && dcf2->iSilentRefresh == ENoSilentRefresh )
+                    {
+                    value = dcf2->iPreview;
+                    }
+                else if ( dcf2 != NULL && dcf2->iPreviewOverridesSilentRefresh )
+                    {
+                    value = dcf2->iPreview;
+                    }
+                break;
+            case ESilentRightsType:
+                value = ENoSilentRefresh;
+                if( dcf2 != NULL && dcf2->iPreview == ENoPreview )
+                    {
+                    value = dcf2->iSilentRefresh;
+                    }
+                else if (dcf2 != NULL && !dcf2->iPreviewOverridesSilentRefresh)
+                    {
+                    value = dcf2->iSilentRefresh;
+                    }
+                break;
+            case EContentCDataInUse:
+                value = KErrCANotSupported;
+                break;
+            case ECanRewind:
+                value = ETrue;
+                break;
+            case ECopyPaste:
+                value = protection;
+                break;
+            case ECanMove:
+                value = ETrue;
+                break;
+            case ECanRename:
+                value = ETrue;
+                break;
+            case ECanAutomaticConsume:
+                value = ETrue;
+                break;
+            case EFileType:
+            case DRM::EDrmFileType:
+                value = aDcfFile.iVersion;
+                break;
+            case EDeliveryMethod:
+                if (aDcfFile.iVersion == 2)
+                    {
+                    value = EOmaDrm2;
+                    }
+                else
+                    {
+                    if (aDcfFile.iContentID->Left(4).Compare(_L8("flk:")) == 0)
+                        {
+                        if (aRightsClient == NULL)
+                            {
+                            value = client.Connect();
+                            if (value != KErrNone)
+                                {
+                                break;
+                                }
+                            if (client.ForwardLockURI(buffer) == KErrNone &&
+                                buffer != NULL)
+                                {
+                                if (aDcfFile.iContentID->Compare(*buffer) == 0)
+                                    {
+                                    value = EOmaDrm1ForwardLock;
+                                    }
+                                else
+                                    {
+                                    value = EOmaDrm1CombinedDelivery;
+                                    }
+                                delete buffer;
+                                }
+                            else
+                                {
+                                value = KErrGeneral;
+                                }
+                            client.Close();
+                            break;
+                            }
+                        else
+                            {
+                            if (aRightsClient->ForwardLockURI(buffer) == KErrNone &&
+                            buffer != NULL)
+                                {
+                                if (aDcfFile.iContentID->Compare(*buffer) == 0)
+                                    {
+                                    value = EOmaDrm1ForwardLock;
+                                    }
+                                else
+                                    {
+                                    value = EOmaDrm1CombinedDelivery;
+                                    }
+                                delete buffer;
+                                }
+                            else
+                                {
+                                value = KErrGeneral;
+                                }
+                            }
+                        }
+                    else if (aDcfFile.iContentID->Left(4).Compare(_L8("ldf:")) == 0)
+                        {
+                        value = EOmaDrm1LocalDataFile;
+                        }
+                    else
+                        {
+                        value = EOmaDrm1SeparateDelivery;
+                        }
+                    }
+                break;
+            case ERecordingYear:
+                value = KErrNotSupported;
+                 if (dcf2 != NULL && dcf2->iRecordingYear )
+                     {
+                     value = dcf2->iRecordingYear;
+                     }
+                break;
+            case DRM::EDrmAllowedOutputs:
+                value = DRM::EDrmAllowAudioAnalog | DRM::EDrmAllowAudioBluetooth | DRM::EDrmAllowVideoMacroVision;
+                break;
+            case ERightsNone:
+                if (aRightsClient == NULL)
+                    {
+                    value = client.Connect();
+                    if (value != KErrCANoRights)
+                        {
+                        break;
+                        }
+                    TUint32 reason = 0;
+                    value = client.CheckRights(EPeek, *aDcfFile.iContentID, reason);
+                    if(value == KErrCANoRights  || KErrCANoPermission)
+                        {
+                        value = ETrue;
+                        }
+                    client.Close();
+                    }
+                else
+                    {
+                    TUint32 reason = 0;
+                    value = aRightsClient->CheckRights(EPeek, *aDcfFile.iContentID, reason);
+                    if(value == KErrCANoRights  || KErrCANoPermission)
+                        {
+                        value = ETrue;
+                        }
+                    }
+                break;
+            case ERightsHaveExpired:
+                if (aRightsClient == NULL)
+                    {
+                    value = client.Connect();
+                    if (value != KErrNone)
+                        {
+                        break;
+                        }
+                    value = ETrue;
+                    TUint32 reason = 0;
+                    value = client.CheckRights(EPlay, *aDcfFile.iContentID, reason);
+                    if(value != KErrCANoRights  || KErrCANoPermission)
+                        {
+                        value = EFalse;
+                        }
+                    value = client.CheckRights(EView, *aDcfFile.iContentID, reason);
+                    if(value != KErrCANoRights  || KErrCANoPermission)
+                        {
+                        value = EFalse;
+                        }
+                    value = client.CheckRights(EExecute, *aDcfFile.iContentID, reason);
+                    if(value != KErrCANoRights  || KErrCANoPermission)
+                        {
+                        value = EFalse;
+                        }
+                    value = client.CheckRights(EPrint, *aDcfFile.iContentID, reason);
+                    if(value != KErrCANoRights  || KErrCANoPermission)
+                        {
+                        value = EFalse;
+                        }
+                    client.Close();
+                    }
+                else
+                    {
+                    value = ETrue;
+                    TUint32 reason = 0;
+                    value = aRightsClient->CheckRights(EPlay, *aDcfFile.iContentID, reason);
+                    if(value != KErrCANoRights  || KErrCANoPermission)
+                        {
+                        value = EFalse;
+                        }
+                    value = aRightsClient->CheckRights(EView, *aDcfFile.iContentID, reason);
+                    if(value != KErrCANoRights  || KErrCANoPermission)
+                        {
+                        value = EFalse;
+                        }
+                    value = aRightsClient->CheckRights(EExecute, *aDcfFile.iContentID, reason);
+                    if(value != KErrCANoRights  || KErrCANoPermission)
+                        {
+                        value = EFalse;
+                        }
+                    value = aRightsClient->CheckRights(EPrint, *aDcfFile.iContentID, reason);
+                    if(value != KErrCANoRights  || KErrCANoPermission)
+                        {
+                        value = EFalse;
+                        }
+
+                    }
+                break;
+            default:
+                value = KErrCANotSupported;
+                break;
+            };
+        }
+    return value;
+    }
+
+// -----------------------------------------------------------------------------
+// TOma2AgentAttributes::
+//
+// -----------------------------------------------------------------------------
+//
+TInt TOma2AgentAttributes::GetAttributeSet(
+    CDcfCommon& aDcfFile,
+    RAttributeSet& aAttributeSet,
+    const TVirtualPathPtr& aVirtualPath,
+    RDRMRightsClient* aRightsClient)
+    {
+    TInt i = 0;
+    TInt attribute = 0;
+    TInt value = 0;
+    TInt numAttributes = aAttributeSet.Count();
+
+    // loop through all the attriutes in the set and find their values
+    for(i = 0; i < numAttributes; i++)
+        {
+        attribute = aAttributeSet[i];
+        value = GetAttribute(aDcfFile, attribute, aVirtualPath, aRightsClient);
+        aAttributeSet.SetValue(attribute, value, KErrNone);
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// TOma2AgentAttributes::
+//
+// -----------------------------------------------------------------------------
+//
+TInt TOma2AgentAttributes::GetStringAttribute(
+    CDcfCommon& aDcfFile,
+    TInt aAttribute,
+    TDes& aValue,
+    const TVirtualPathPtr& aVirtualPath,
+    RDRMRightsClient* aRightsClient)
+    {
+    TInt err = KErrCANotSupported;
+    HBufC* b = NULL;
+    COma1Dcf* dcf1 = NULL;
+    COma2Dcf* dcf2 = NULL;
+    TPtrC8 ptr(NULL, 0);
+    TPtr ptr16(NULL, 0, 0);
+    TInt n;
+    HBufC* contentName = NULL;
+    TFileName fileName;
+
+    aValue.Copy(KNullDesC);
+    if (aDcfFile.iVersion == 2)
+        {
+        dcf2 = static_cast<COma2Dcf*>(&aDcfFile);
+        }
+    else
+        {
+        dcf1 = static_cast<COma1Dcf*>(&aDcfFile);
+        }
+    if (aVirtualPath.UniqueId().Length() == 0)
+        {
+        switch (aAttribute)
+            {
+            case DRM::EDrmAgentName:
+                TRAP(err, b = DRM::KDrmOmaAgentName().AllocL());
+                break;
+            case EMimeType:
+                if (aDcfFile.iVersion == 1)
+                    {
+                    TRAP(err, b = KOma1DcfContentType16().AllocL());
+                    }
+                else if (aDcfFile.iVersion == 2)
+                    {
+                    TRAP(err, b = KOma2DcfContentType16().AllocL());
+                    }
+                break;
+            case ETransactionTrackingId:
+                if (dcf2 != NULL && dcf2->iTransactionTracking)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iTransactionTracking));
+                    }
+                break;
+            case EEmbeddedRightsObject:
+                if (dcf2 != NULL)
+                    {
+                    TRAP(err, b = CollectEmbeddedRosL(dcf2));
+                    }
+                break;
+            case EDomainRightsIssuerUrl:
+                if (dcf2 != NULL)
+                    {
+                    TRAP(err, b = GetDomainRiUrlL(dcf2));
+                    }
+                break;
+            case EDomainRightsIssuerId:
+                if (dcf2 != NULL)
+                    {
+                    TRAP(err, b = GetDomainRiIdL(dcf2));
+                    }
+                break;
+            case EDomainId:
+                if (dcf2 != NULL)
+                    {
+                    TRAP(err, b = GetDomainIdL(dcf2));
+                    }
+                break;
+            case EFileName:
+            case DRM::EDrmFileName:
+                err = aDcfFile.iFile.Name(fileName);
+                if( aValue.MaxLength() < fileName.Length() )
+                    {
+                    return KErrOverflow;
+                    }
+                aValue.Copy(fileName);
+                break;
+            case EContentName:
+            case EDescription:
+            case ETitle:
+            case EAuthor:
+            case EIconURI:
+            case EPreviewURI:
+            case EInstantPreviewUri:
+            case EPreviewRightsUri:
+            case EContentURI:
+            case EContentID:
+            case EInfoURL:
+            case EPendingRightsETA:
+            case ERightsIssuerUrl:
+            case ESilentRightsUrl:
+            default:
+                break;
+            }
+        }
+    else
+        {
+        switch (aAttribute)
+            {
+            case DRM::EDrmAgentName:
+                TRAP(err, b = DRM::KDrmOmaAgentName().AllocL());
+                break;
+            case EMimeType:
+                TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*aDcfFile.iMimeType));
+                break;
+            case EDescription:
+                if (aDcfFile.iDescription)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*aDcfFile.iDescription));
+                    }
+                break;
+            case ETitle:
+                if (aDcfFile.iTitle)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*aDcfFile.iTitle));
+                    }
+                break;
+            case EAuthor:
+                if (dcf2 != NULL && dcf2->iAuthor)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iAuthor));
+                    }
+                break;
+            case EIconURI:
+                if (aDcfFile.iIconUri)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*aDcfFile.iIconUri));
+                    }
+                break;
+            case EPreviewURI:
+                if (dcf2 != NULL && dcf2->iPreviewParameter)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iPreviewParameter));
+                    }
+                break;
+            case EContentURI:
+                if (dcf2 != NULL && dcf2->iContentUrl)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iContentUrl));
+                    }
+                break;
+            case EContentID:
+                TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*aDcfFile.iContentID));
+                break;
+            case EInfoURL:
+                if (dcf2 != NULL && dcf2->iInfoUri)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iInfoUri));
+                    }
+                break;
+            case EInstantPreviewUri:
+                if (dcf2 != NULL && dcf2->iPreview == EInstantPreview &&
+                    dcf2->iPreviewParameter)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iPreviewParameter));
+                    }
+                break;
+            case EPreviewRightsUri:
+                if (dcf2 != NULL && dcf2->iPreview == EPreviewRights &&
+                    dcf2->iPreviewParameter)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iPreviewParameter));
+                    }
+                break;
+            case ESilentRightsUrl:
+                if (dcf2 != NULL && dcf2->iSilentParameter &&
+                    dcf2->iSilentParameter)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iSilentParameter));
+                    }
+                break;
+            case ERightsIssuerUrl:
+#ifndef __DRM_FULL
+                err = KErrNotSupported;
+#else
+                if (aDcfFile.iRightsIssuerURL != NULL)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*aDcfFile.iRightsIssuerURL));
+                    }
+#endif
+                break;
+            case ETransactionTrackingId:
+                if (dcf2 != NULL && dcf2->iTransactionTracking)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iTransactionTracking));
+                    }
+                break;
+            case EEmbeddedRightsObject:
+                if (dcf2 != NULL)
+                    {
+                    TRAP(err, b = CollectEmbeddedRosL(dcf2));
+                    }
+                break;
+            case EDomainRightsIssuerUrl:
+                if (dcf2 != NULL)
+                    {
+                    TRAP(err, b = GetDomainRiUrlL(dcf2));
+                    }
+                break;
+            case EDomainRightsIssuerId:
+                if (dcf2 != NULL)
+                    {
+                    TRAP(err, b = GetDomainRiIdL(dcf2));
+                    }
+                break;
+            case EDomainId:
+                if (dcf2 != NULL)
+                    {
+                    TRAP(err, b = GetDomainIdL(dcf2));
+                    }
+                break;
+            case EContentVendor:
+                if (dcf1 != NULL)
+                    {
+                    TRAP(err, dcf1->GetHeaderL(KContentVendor, ptr));
+                    if (ptr.Length() > 0 && err == KErrNone)
+                        {
+                        TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(ptr));
+                        }
+                    }
+                break;
+            case ECopyright:
+                if (dcf2 != NULL && dcf2->iCopyRight)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iCopyRight));
+                    }
+                break;
+            case EPendingRightsETA:
+                n = GetEstimatedArrivalTime(*aDcfFile.iContentID, aRightsClient);
+                TRAP(err, b = HBufC::NewL(16));
+                if( err == KErrNone )
+                    {
+                    ptr16.Set(b->Des());
+                    ptr16.AppendNum(n);
+                    }
+                break;
+            case EContentName:
+                contentName = NULL;
+                err = GetContentName( *aDcfFile.iContentID, contentName, aRightsClient );
+                if( !err )
+                    {
+                    b = contentName;
+                    }
+                break;
+
+            case EOmaDrmContentLocation:
+                break;
+            case EOmaDrmContentVersion:
+                break;
+            case EPerformer:
+            case DRM::EDrmOriginalArtist:
+                 if (dcf2 != NULL && dcf2->iPerformer)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iPerformer));
+                    }
+                break;
+            case EGenre: // flow through
+            case EOmaDrmGenre:
+                 if (dcf2 != NULL && dcf2->iGenre)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iGenre));
+                    }
+                break;
+            case ERatingInfo:
+            case DRM::EDrmRatingInfo:
+                 if (dcf2 != NULL && dcf2->iRatingInfo)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iRatingInfo));
+                    }
+                break;
+            case EClassificationInfo:
+                 if (dcf2 != NULL && dcf2->iClassificationInfo)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iClassificationInfo));
+                    }
+                break;
+            case EKeyword:
+                 if (dcf2 != NULL && dcf2->iKeyword)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iKeyword));
+                    }
+                break;
+            case ELocInfoName:
+                 if (dcf2 != NULL && dcf2->iLocInfoName)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iLocInfoName));
+                    }
+                break;
+            case ELocInfoAstronomicalBody:
+                 if (dcf2 != NULL && dcf2->iLocInfoAstronomicalBody)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iLocInfoAstronomicalBody));
+                    }
+                break;
+            case ELocInfoAdditionalNotes:
+                 if (dcf2 != NULL && dcf2->iLocInfoAdditionalNotes)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iLocInfoAdditionalNotes));
+                    }
+                break;
+            case EAlbumTitle:
+                 if (dcf2 != NULL && dcf2->iAlbumTitle)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iAlbumTitle));
+                    }
+                break;
+            case EAlbumTrack:
+            case DRM::EDrmTrackNumber:
+                if( dcf2 != NULL && dcf2->iAlbumTrack)
+                    {
+                    TRAP(err, b = HBufC::NewL(KMaxAlbumTrack));
+                    if( err == KErrNone )
+                        {
+                        b->Des().AppendNum( dcf2->iAlbumTrack );
+                        }
+                    }
+                break;
+            case ECoverUri:
+                 if (dcf2 != NULL && dcf2->iCoverUri)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iCoverUri));
+                    }
+                break;
+            case ELyricsUrl:
+                 if (dcf2 != NULL && dcf2->iLyricsURL)
+                    {
+                    TRAP(err, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(*dcf2->iLyricsURL));
+                    }
+                break;
+            case EFileName:
+            case DRM::EDrmFileName:
+                err = aDcfFile.iFile.Name(fileName);
+                if( aValue.MaxLength() < fileName.Length() )
+                    {
+                    return KErrOverflow;
+                    }
+                aValue.Copy(fileName);
+                break;
+            case DRM::EDrmFullName:
+                err = aDcfFile.iFile.FullName(fileName);
+                if ( aValue.MaxLength() < fileName.Length() )
+                    {
+                    return KErrOverflow;
+                    }
+                aValue.Copy(fileName);
+                break;
+            case DRM::EDrmRecordingYear:
+                if( dcf2 != NULL && dcf2->iRecordingYear)
+                    {
+                    TRAP(err, b = HBufC::NewL(KMaxRecordingYear));
+                    if( err == KErrNone )
+                        {
+                        b->Des().AppendNum( dcf2->iRecordingYear );
+                        }
+                    }
+                break;
+            default:
+                break;
+            }
+        }
+
+
+    if (b != NULL)
+        {
+        if( b->Length() > aValue.MaxLength() )
+            {
+            delete b;
+            return KErrOverflow;
+            }
+        err = KErrNone;
+        aValue.Copy(*b);
+        delete b;
+        }
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// TOma2AgentAttributes::
+//
+// -----------------------------------------------------------------------------
+//
+TInt TOma2AgentAttributes::GetStringAttributeSet(
+    CDcfCommon& aDcfFile,
+    RStringAttributeSet& aStringAttributeSet,
+    const TVirtualPathPtr& aVirtualPath,
+    RDRMRightsClient* aRightsClient)
+    {
+    TInt i = 0;
+    TInt attribute = 0;
+    TInt err = KErrNone;
+    TBuf<KMaxDataTypeLength> buf;
+    TInt numAttributes = aStringAttributeSet.Count();
+
+    for(i = 0; err == KErrNone && i < numAttributes; i++)
+        {
+        attribute = aStringAttributeSet[i];
+        err = GetStringAttribute(aDcfFile, attribute, buf, aVirtualPath,
+            aRightsClient);
+        err = aStringAttributeSet.SetValue(attribute, buf, err);
+        }
+    return err;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/src/Oma2AgentContent.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,742 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: OMA DRM ContentAccess::CContent implementation
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <caf/caf.h>
+#include <caf/bitset.h>
+#include <caf/attribute.h>
+#include <e32test.h>
+#include <utf.h>
+
+
+#include <schemehandler.h>
+
+
+#include "oma2agentcontent.h"
+#include "oma2agentattributes.h"
+#include "oma1dcf.h"
+#include "oma2dcf.h"
+#include "symmetric.h"
+#include "DrmRights.h"
+#include "Oma2DcfPartInfo.h"
+#include "DrmProtectedRoParser.h"
+
+using namespace ContentAccess;
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TInt MapContentShareMode(TContentShareMode aMode);
+template<class S>
+LOCAL_C void PointerArrayResetDestroyAndClose(TAny* aPtr);
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// MapContentShareMode
+// Maps the CAF specific file share mode to the RFs/RFile sharing mode
+// -----------------------------------------------------------------------------
+//
+TInt MapContentShareMode(TContentShareMode aMode)
+    {
+    TInt r = EFileRead | EFileShareAny;
+
+    switch (aMode)
+        {
+        case EContentShareReadOnly:
+            r = EFileRead | EFileShareReadersOnly;
+            break;
+        case EContentShareReadWrite:
+            r = EFileRead | EFileShareReadersOrWriters;
+            break;
+        case EContentShareExclusive:
+            r = EFileRead | EFileShareExclusive;
+            break;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// PointerArrayResetDestroyAndClose
+// Template method used to push RPointerArrays to the cleanup stack. Takes
+// care of deleting all pointers in the array.
+// -----------------------------------------------------------------------------
+//
+template<class S>
+void PointerArrayResetDestroyAndClose(TAny* aPtr)
+    {
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->ResetAndDestroy();
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->Close();
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::COma2AgentContent
+// Reset all member variables
+// -----------------------------------------------------------------------------
+//
+COma2AgentContent::COma2AgentContent(void):
+    iDcf(NULL),
+    iFilePosition(0),
+    iDataPosition(0),
+    iUri(NULL),
+    iCurrentContainer(NULL),
+    iNotifier(NULL),
+    iWatchedId(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::ConstructL
+// Initialize the agent from a URI (file name) and file mode, opens the
+// the file and takes membership of the handle
+// -----------------------------------------------------------------------------
+//
+void COma2AgentContent::ConstructL(
+    const TDesC& aUri,
+    TContentShareMode aShareMode)
+    {
+    iUri = aUri.AllocL();
+    User::LeaveIfError(iRdb.Connect());
+    User::LeaveIfError(iFs.Connect());
+    User::LeaveIfError(iFs.ShareAuto());
+    User::LeaveIfError(iFile.Open(iFs, aUri, MapContentShareMode(aShareMode)));
+    iDcf = CDcfCommon::NewL(iFile);
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::ConstructL
+// Initialize the agent from a file handle, duplicates the handle
+// -----------------------------------------------------------------------------
+//
+void COma2AgentContent::ConstructL(RFile& aFile)
+    {
+    TFileName name;
+    User::LeaveIfError(iRdb.Connect());
+    User::LeaveIfError(iFile.Duplicate(aFile));
+    User::LeaveIfError(iFs.Connect());
+    User::LeaveIfError(iFs.ShareAuto());
+    iFile.Name(name);
+    iUri = name.AllocL();
+    iDcf = CDcfCommon::NewL(iFile);
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::NewL
+// Two-phased constructors
+// -----------------------------------------------------------------------------
+//
+COma2AgentContent* COma2AgentContent::NewL(
+    const TDesC& aUri,
+    TContentShareMode aShareMode)
+    {
+    COma2AgentContent* self = NewLC(aUri, aShareMode);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+COma2AgentContent* COma2AgentContent::NewLC(
+    const TDesC& aUri,
+    TContentShareMode aShareMode)
+    {
+    COma2AgentContent* self=new(ELeave) COma2AgentContent();
+    CleanupStack::PushL(self);
+    self->ConstructL(aUri, aShareMode);
+    return self;
+    }
+
+COma2AgentContent* COma2AgentContent::NewL(RFile& aFile)
+    {
+    COma2AgentContent* self = NewLC(aFile);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+COma2AgentContent* COma2AgentContent::NewLC(RFile& aFile)
+    {
+    COma2AgentContent* self=new(ELeave) COma2AgentContent();
+    CleanupStack::PushL(self);
+    self->ConstructL(aFile);
+    return self;
+    }
+
+
+// Destructor
+COma2AgentContent::~COma2AgentContent()
+    {
+    iRdb.Close();
+    iFile.Close();
+    iFs.Close();
+    delete iDcf;
+    delete iUri;
+    delete iCurrentContainer;
+    if (iNotifier != NULL)
+        {
+        if( iWatchedId )
+            {
+
+            TRAP_IGNORE( iNotifier->UnRegisterEventObserverL(*this, KEventAddRemove, *iWatchedId) );
+            TRAP_IGNORE( iNotifier->UnRegisterEventObserverL(*this, KEventModify, *iWatchedId) );
+
+            }
+
+        delete iNotifier;
+        }
+    delete iWatchedId;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::OpenContainer
+// Checks if the part ID is valid and sets the current ID to the part ID
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentContent::OpenContainer(
+    const TDesC& aUniqueId)
+    {
+    TInt r = KErrNotFound;
+    TInt err = KErrNone;
+
+    // Only the outermost file can be opened, parts within the file don't have
+    // subparts, only attributes.
+    if (iCurrentContainer == NULL)
+        {
+        r = iDcf->CheckUniqueId(aUniqueId);
+        if (r == KErrNone)
+            {
+
+            TRAP(err, iCurrentContainer = aUniqueId.AllocL() );
+            if(err)
+                {
+                return err;
+                }
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::CloseContainer
+// Resets the current part ID
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentContent::CloseContainer()
+    {
+    TInt r = KErrNone;
+
+    if (iCurrentContainer != NULL)
+        {
+        delete iCurrentContainer;
+        iCurrentContainer = NULL;
+        }
+    else
+        {
+        r = KErrNotFound;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::GetEmbeddedObjectsL
+// Returns all parts embedded in the current part
+// -----------------------------------------------------------------------------
+//
+void COma2AgentContent::GetEmbeddedObjectsL(
+    RStreamablePtrArray<CEmbeddedObject>& aArray)
+    {
+    TInt i;
+    CEmbeddedObject* part = NULL;
+    HBufC* id = NULL;
+    COma2Dcf* dcf2 = NULL;
+
+    aArray.ResetAndDestroy();
+    if (iCurrentContainer == NULL)
+        {
+        if (iDcf->iVersion == EOma2Dcf)
+            {
+            dcf2 = static_cast<COma2Dcf*>(iDcf);
+            for (i = 0; i < dcf2->iParts.Count(); i++)
+                {
+                id = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+                    *dcf2->iParts[i]->iContentId);
+                CleanupStack::PushL(id);
+                part = CEmbeddedObject::NewL(*id, *dcf2->iParts[i]->iMimeType,
+                    EContentObject);
+                CleanupStack::PopAndDestroy(id);
+                aArray.AppendL(part);
+                }
+            }
+        else
+            {
+            id = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+                *iDcf->iContentID);
+            CleanupStack::PushL(id);
+            part = CEmbeddedObject::NewL(*id, *iDcf->iMimeType,
+                EContentObject);
+            CleanupStack::PopAndDestroy(id);
+            aArray.AppendL(part);
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::GetEmbeddedObjectsL
+// Returns all parts embedded in the current part, filtered by type
+// -----------------------------------------------------------------------------
+//
+void COma2AgentContent::GetEmbeddedObjectsL(
+    RStreamablePtrArray<CEmbeddedObject>& aArray,
+    TEmbeddedType aType)
+    {
+    if (aType == EContentObject)
+        {
+        GetEmbeddedObjectsL(aArray);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::Search
+//
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentContent::Search(
+    RStreamablePtrArray<CEmbeddedObject>& aArray,
+    const TDesC8& aMimeType,
+    TBool /*aRecursive*/)
+    {
+    TInt i;
+    TInt r = KErrNone;
+    RStreamablePtrArray<CEmbeddedObject> parts;
+    CEmbeddedObject* item = NULL;
+
+    TRAP(r, GetEmbeddedObjectsL(parts));
+    for (i = 0; r == KErrNone && i < parts.Count(); i++)
+        {
+        if (parts[i]->MimeType().CompareF(aMimeType) == 0)
+            {
+
+            TRAP_IGNORE( item = CEmbeddedObject::NewL(
+                parts[i]->UniqueId(), parts[i]->Name(),
+                parts[i]->MimeType(), parts[i]->Type()) );
+
+            TRAP(r, aArray.AppendL(item));
+            }
+        }
+    parts.ResetAndDestroy();
+    parts.Close();
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::GetAttribute
+//
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentContent::GetAttribute(
+    TInt aAttribute,
+    TInt& aValue,
+    const TDesC& aUniqueId)
+    {
+    TInt r;
+
+    r = iDcf->OpenPart(aUniqueId);
+    if (r == KErrNone)
+        {
+        TRAP(r,aValue = TOma2AgentAttributes::GetAttribute(*iDcf, aAttribute,
+            TVirtualPathPtr(*iUri, aUniqueId), &iRdb));
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::GetAttributeSet
+//
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentContent::GetAttributeSet(
+    RAttributeSet& aAttributeSet,
+    const TDesC& aUniqueId)
+    {
+    TInt r;
+    TInt err = KErrNone;
+
+    r = iDcf->OpenPart(aUniqueId);
+    if (r == KErrNone)
+        {
+        TRAP(err,r = TOma2AgentAttributes::GetAttributeSet(*iDcf, aAttributeSet,
+            TVirtualPathPtr(*iUri, aUniqueId), &iRdb));
+        if (err != KErrNone)
+            {
+            return err;
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::GetStringAttribute
+//
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentContent::GetStringAttribute(
+    TInt aAttribute,
+    TDes& aValue,
+    const TDesC& aUniqueId)
+    {
+    TInt r = KErrNone;
+    TInt err = KErrNone;
+
+    r = iDcf->OpenPart(aUniqueId);
+    if (r == KErrNone)
+        {
+        TRAP(err, r = TOma2AgentAttributes::GetStringAttribute(*iDcf, aAttribute,
+            aValue, TVirtualPathPtr(*iUri, aUniqueId), &iRdb));
+        if(err != KErrNone)
+            {
+            return err;
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::GetStringAttributeSet
+//
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentContent::GetStringAttributeSet(
+    RStringAttributeSet& aStringAttributeSet,
+    const TDesC& aUniqueId)
+    {
+    TInt r;
+    TInt err = KErrNone;
+
+    r = iDcf->OpenPart(aUniqueId);
+    if (r == KErrNone)
+        {
+        TRAP(err, r = TOma2AgentAttributes::GetStringAttributeSet(*iDcf,
+            aStringAttributeSet, TVirtualPathPtr(*iUri, aUniqueId), &iRdb));
+        if(err != KErrNone)
+            {
+            return err;
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::AgentSpecificCommand
+//
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentContent::AgentSpecificCommand(
+    TInt aCommand,
+    const TDesC8& /*aInputBuffer*/,
+    TDes8& /*aOutputBuffer*/)
+    {
+    TInt r = KErrCANotSupported;
+
+    if (aCommand == EEmbedDomainRo)
+        {
+        TRAP(r, EmbedDomainRoL());
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::AgentSpecificCommand
+//
+// -----------------------------------------------------------------------------
+//
+void COma2AgentContent::AgentSpecificCommand(
+    TInt aCommand,
+    const TDesC8& aInputBuffer,
+    TDes8& aOutputBuffer,
+    TRequestStatus& aStatus)
+    {
+    TRequestStatus *ptr = &aStatus;
+    User::RequestComplete(ptr, AgentSpecificCommand(aCommand, aInputBuffer,
+        aOutputBuffer));
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::NotifyStatusChange
+//
+// -----------------------------------------------------------------------------
+//
+void COma2AgentContent::NotifyStatusChangeL(
+    TEventMask aEventMask,
+    TRequestStatus& aStatus,
+    const TDesC& aUniqueId)
+    {
+    TInt r = KErrNone;
+    TInt i;
+    TInt part = KErrNotFound;
+    COma2Dcf* dcf2 = NULL;
+    HBufC8* uniqueId = NULL;
+
+    iStatus = &aStatus;
+    iWatchedEvents = aEventMask;
+    if (iWatchedId != NULL)
+        {
+        if( iNotifier )
+            {
+            iNotifier->UnRegisterEventObserverL(*this, KEventAddRemove, *iWatchedId);
+            iNotifier->UnRegisterEventObserverL(*this, KEventModify, *iWatchedId);
+            }
+        delete iWatchedId;
+        iWatchedId = NULL;
+        }
+    if (iDcf->iVersion == EOma1Dcf || aUniqueId.Compare(KDefaultContentObject) == 0)
+        {
+        iWatchedId = iDcf->iContentID->AllocL();
+        }
+    else
+        {
+        dcf2 = static_cast<COma2Dcf*>(iDcf);
+        uniqueId = CnvUtfConverter::ConvertFromUnicodeToUtf8L(aUniqueId);
+        CleanupStack::PushL(uniqueId);
+        for (i = 0; part == KErrNotFound && i < dcf2->iParts.Count(); i++)
+            {
+            if (dcf2->iParts[i]->iContentId->CompareF(*uniqueId) == 0)
+                {
+                iWatchedId = dcf2->iParts[i]->iContentId->AllocL();
+                }
+            }
+        CleanupStack::PopAndDestroy();
+        }
+    if (iWatchedId != NULL)
+        {
+        if (iNotifier == NULL)
+            {
+            iNotifier = CDRMNotifier::NewL();
+            }
+        if (iNotifier != NULL)
+            {
+            iNotifier->RegisterEventObserverL(*this, KEventAddRemove, *iWatchedId);
+            iNotifier->RegisterEventObserverL(*this, KEventModify, *iWatchedId);
+            *iStatus = KRequestPending;
+            }
+        else
+            {
+            User::Leave(r);
+            }
+        }
+    else
+        {
+        User::Leave(KErrNotFound);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::NotifyStatusChange
+//
+// -----------------------------------------------------------------------------
+// 
+void COma2AgentContent::NotifyStatusChange(
+    TEventMask aEventMask,
+    TRequestStatus& aStatus,
+    const TDesC& aUniqueId)
+    {
+    TInt err = KErrNone;
+    TRequestStatus *status = 0;
+    TRAP(err, NotifyStatusChangeL(  aEventMask,
+                                    aStatus,
+                                    aUniqueId ));
+    if(err)
+        {
+        status = &aStatus;
+        User::RequestComplete(status, err);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::CancelNotifyStatusChange
+//
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentContent::CancelNotifyStatusChange(
+    TRequestStatus& aStatus,
+    const TDesC& /*aUniqueId*/)
+    {
+    iStatus = &aStatus;
+    if(iNotifier == NULL)
+         {
+         User::RequestComplete(iStatus, KErrNotFound);
+         return KErrNotFound;
+         }
+
+    TRAP_IGNORE( iNotifier->UnRegisterEventObserverL(*this, KEventAddRemove, *iWatchedId) );
+    TRAP_IGNORE( iNotifier->UnRegisterEventObserverL(*this, KEventModify, *iWatchedId) );
+
+    if (iWatchedId != NULL)
+        {
+        delete iWatchedId;
+        iWatchedId = NULL;
+        }
+    User::RequestComplete(iStatus, KErrCancel);
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::RequestRights
+// Opens the browser with the rights issuer URL
+// -----------------------------------------------------------------------------
+//
+
+void COma2AgentContent::RequestRights(
+    TRequestStatus& aStatus,
+    const TDesC& aUniqueId)
+    {
+    TRequestStatus *ptr = &aStatus;
+    TInt r;
+    HBufC* b = NULL;
+    CSchemeHandler* handler = NULL;
+
+    r = iDcf->OpenPart(aUniqueId);
+    if (r == KErrNone && iDcf->iRightsIssuerURL != NULL)
+        {
+        TRAP(r, b = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+            *iDcf->iRightsIssuerURL));
+        if (b != NULL)
+            {
+            TRAP(r, handler = CSchemeHandler::NewL(*b));
+            if (handler != NULL)
+                {
+                TRAP(r, handler->HandleUrlStandaloneL());
+                delete handler;
+                }
+            delete b;
+            }
+        }
+    User::RequestComplete(ptr, r);
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::CancelRequestRights
+// Not supported, getting rights is handled outside the scope of the agent and
+// cannot be cancelled
+// -----------------------------------------------------------------------------
+//
+
+TInt COma2AgentContent::CancelRequestRights(
+    TRequestStatus& aStatus,
+    const TDesC& /*aUniqueId*/)
+    {
+    TRequestStatus *ptr = &aStatus;
+    User::RequestComplete(ptr, KErrNone);
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::DisplayInfoL
+//
+// -----------------------------------------------------------------------------
+//
+void COma2AgentContent::DisplayInfoL(
+    TDisplayInfo /*aDisplayInfo*/,
+    const TDesC& /*aUniqueId*/)
+    {
+    User::Leave(KErrCANotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::SetProperty
+//
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentContent::SetProperty(
+    TAgentProperty /*aProperty*/,
+    TInt /*aValue*/)
+    {
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::EmbedDomainRoL
+//
+// -----------------------------------------------------------------------------
+//
+void COma2AgentContent::EmbedDomainRoL()
+    {
+    RPointerArray<HBufC8> roList;
+    TCleanupItem listCleanup(PointerArrayResetDestroyAndClose<HBufC8>,
+        &roList);
+    COma2Dcf* dcf;
+    CDrmProtectedRoParser* parser = NULL;
+    RPointerArray<CDRMRights> rights;
+
+    if (iDcf->iVersion == EOma2Dcf)
+        {
+        dcf = static_cast<COma2Dcf*>(iDcf);
+
+        __UHEAP_MARK;
+        for (TInt i = 0; i < dcf->iRightsObjects.Count(); i++)
+            {
+            parser = CDrmProtectedRoParser::NewL();
+            CleanupStack::PushL(parser);
+            TRAP_IGNORE( parser->ParseAndStoreL(*dcf->iRightsObjects[i],
+                    rights));
+            CleanupStack::PopAndDestroy(); // parser
+            rights.ResetAndDestroy();
+            rights.Close();
+            }
+        __UHEAP_MARKEND;
+
+        iRdb.GetDomainRosForCidL(*dcf->iContentID, roList);
+        CleanupStack::PushL(listCleanup);
+        if(roList.Count())
+            {
+            // this is not replaceable in UHEAP_MARK delimiters
+            dcf->SetRightsObjectsL(roList);
+            }
+        CleanupStack::PopAndDestroy(); // listCleanup
+        }
+    else
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::HandleEventL
+// Handle notifier events here. Not much logic, consider all events as rights
+// changes.
+// -----------------------------------------------------------------------------
+//
+void COma2AgentContent::HandleEventL(
+    MDRMEvent* /*aEvent*/)
+    {
+    TInt r;
+    TUint32 reason = 0;
+
+    if ( iWatchedId != NULL)
+        {
+        r = iRdb.CheckRights(EUnknown, *iWatchedId, reason);
+        if (r == KErrNone && (iWatchedEvents & ERightsAvailable) ||
+            r != KErrNone && (iWatchedEvents & ERightsExpired))
+            {
+            iNotifier->UnRegisterEventObserverL(*this, KEventAddRemove, *iWatchedId);
+            iNotifier->UnRegisterEventObserverL(*this, KEventModify, *iWatchedId);
+            delete iWatchedId;
+            iWatchedId = NULL;
+            User::RequestComplete(iStatus, KErrNone);
+            }
+        }
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/src/Oma2AgentData.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,609 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the CAF Agent Data class
+*
+*/
+
+// INCLUDE FILES
+#include <caf/caf.h>
+#include <caf/bitset.h>
+#include <caf/attribute.h>
+#include <e32test.h>
+#include "drmcommon.h"
+#include "oma2agentdata.h"
+#include "oma2agentattributes.h"
+#include "oma1dcf.h"
+#include "oma2dcf.h"
+#include "symmetric.h"
+#include "drmrightsclient.h"
+#include "drmprotectedroparser.h"
+#include "dcfcache.h"
+#include "cleanupresetanddestroy.h"
+
+using namespace ContentAccess;
+//TRACE macros
+#ifdef _DEBUG
+#include <e32debug.h> // RDebug
+#define TRACE( x ) RDebug::Print( _L( x ) )
+#define TRACE2( x, y ) RDebug::Print( _L( x ), y )
+#define TRACE3( x, y, z ) RDebug::Print( _L( x ), y, z )
+#else
+#define TRACE( x )
+#define TRACE2( x, y )
+#define TRACE3( x, y, z )
+#endif
+// CONSTANTS
+_LIT8(KMimeAudio, "audio");
+_LIT8(KMimeImage, "image");
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TInt MapContentShareMode( TContentShareMode aMode );
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// MapContentShareMode
+// Maps the CAF specific file share mode to the RFs/RFile sharing mode
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt MapContentShareMode( TContentShareMode aMode )
+    {
+    TInt r = EFileRead | EFileShareAny;
+
+    switch ( aMode )
+        {
+        case EContentShareReadOnly:
+            r = EFileRead | EFileShareReadersOnly;
+            break;
+        case EContentShareReadWrite:
+            r = EFileRead | EFileShareReadersOrWriters;
+            break;
+        case EContentShareExclusive:
+            r = EFileRead | EFileShareExclusive;
+            break;
+        }
+    return r;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::COma2AgentData
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+COma2AgentData::COma2AgentData() :
+    iDcf( NULL ),
+    iDataPosition( 0 ),
+    iRightsStatus( KErrNone ),
+    iVirtualPath( KNullDesC ),
+    iCache( NULL ),
+    iGroupKeyUsed( EFalse ),
+    iLastFileSize( 0 )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void COma2AgentData::ConstructL(
+    const TVirtualPathPtr& aVirtualPath,
+    TContentShareMode aShareMode )
+    {
+    User::LeaveIfError( iRdb.Connect() );
+    User::LeaveIfError( iFs.Connect() );
+    User::LeaveIfError( iFs.ShareAuto() );
+    User::LeaveIfError( iFile.Open( iFs, aVirtualPath.URI(),
+        MapContentShareMode( aShareMode ) ) );
+    iDcf = CDcfCommon::NewL( iFile );
+    iVirtualPath = aVirtualPath;
+    User::LeaveIfError( iDcf->OpenPart( iVirtualPath.UniqueId() ) );
+    InitializeL();
+    }
+
+// -----------------------------------------------------------------------------
+//
+void COma2AgentData::ConstructL(
+    RFile& aFile,
+    const TDesC& aUniqueId )
+    {
+    User::LeaveIfError( iRdb.Connect() );
+    User::LeaveIfError( iFs.Connect() );
+    User::LeaveIfError( iFs.ShareAuto() );
+    User::LeaveIfError( iFile.Duplicate( aFile ) );
+    iDcf = CDcfCommon::NewL( iFile );
+    User::LeaveIfError( iDcf->OpenPart( aUniqueId ) );
+    InitializeL();
+    iUniqueId = aUniqueId.AllocL();
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::InitializeL
+// -----------------------------------------------------------------------------
+//
+void COma2AgentData::InitializeL()
+    {
+    TInt r = KErrNone;
+    TBuf8<KDCFKeySize * 2> blocks;
+    CDrmProtectedRoParser* parser;
+    TInt pos;
+    COma2Dcf* dcf2 = NULL;
+    TInt i;
+    TBool reinit = EFalse;
+    TInt error = KErrNone;
+
+    if ( iDcf->iVersion == EOma2Dcf )
+        {
+        dcf2 = static_cast<COma2Dcf*> ( iDcf );
+        // Encrypted images are not supported, but plain ones are:
+        if ( dcf2->iMimeType->Left( KMimeImage().Length() ).CompareF(
+            KMimeImage ) == 0 && iDcf->iEncryptionMethod != EMethodNULL )
+            {
+            User::Leave( KErrNotSupported );
+            }
+        }
+
+    // Set the session key for this file
+    if ( iDcf->iEncryptionMethod == EMethodAES_128_CBC )
+        {
+        // Check if we can use the group key first
+        if ( dcf2 && dcf2->iGroupId )
+            {
+            r = iRdb.InitializeGroupKey( *dcf2->iGroupId, *dcf2->iGroupKey,
+                dcf2->iGkEncryptionMethod );
+            if ( r == KErrNone )
+                {
+                iGroupKeyUsed = ETrue;
+                }
+            }
+        else
+            {
+            r = iRdb.InitializeKey( *iDcf->iContentID );
+            }
+
+        // If the DCF contains a domain RO, try to save and use it
+        if ( dcf2 && dcf2->iRightsObjects.Count() )
+            {
+            error = r;
+            __UHEAP_MARK;
+            for ( i = 0; i < dcf2->iRightsObjects.Count(); i++ )
+                {
+                RPointerArray<CDRMRights> rights;
+                CleanupResetAndDestroyPushL( rights );
+                parser = CDrmProtectedRoParser::NewL();
+                CleanupStack::PushL( parser );
+                // NOTE:
+                // This is trapped for a reason, the file opening must not fail
+                // even if the parsing of the embedded rights object fails
+                // for some reason it is possible that the rights are already
+                // put into the database and the leave occurs because of this,
+                // also it's possible that there are existing rights
+                // that work with the given content.
+                TRAP( r, parser->ParseAndStoreL( *dcf2->iRightsObjects[i],
+                    rights) );
+                CleanupStack::PopAndDestroy( parser );
+                CleanupStack::PopAndDestroy( &rights );
+                if ( r == KErrNone && !reinit )
+                    {
+                    reinit = ETrue;
+                    }
+                }
+            __UHEAP_MARKEND;
+            if ( reinit && !iGroupKeyUsed )
+                {
+                r = iRdb.InitializeKey( *iDcf->iContentID );
+                }
+            else
+                {
+                r = error;
+                }
+            }
+
+        if ( r != KErrCANoRights && r != KErrCANoPermission &&
+            r != KErrCAPendingRights && r != KErrNone )
+            {
+            User::Leave( r );
+            }
+        iRightsStatus = r;
+        }
+    else if ( iDcf->iEncryptionMethod != EMethodNULL )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    iCache = CDcfCache::NewL( iRdb, iFile, *iDcf, 0, 0 );
+    if ( iDcf->iPadding == -1 && iRightsStatus == KErrNone )
+        {
+        pos = iDcf->iOffset + iDcf->iDataLength - 2 * KDCFKeySize;
+        iFile.Seek( ESeekStart, pos );
+        iFile.Read( blocks );
+        iDcf->iPadding = iRdb.CalculatePadding( blocks );
+        if ( iDcf->iPadding >= 0 )
+            {
+            iDcf->iPlainTextLength -= iDcf->iPadding;
+            iDcf->iPlainTextLengthValid = ETrue;
+            }
+        }
+    User::LeaveIfError( iFile.Size( iLastFileSize ) );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+COma2AgentData* COma2AgentData::NewL(
+    const TVirtualPathPtr& aVirtualPath,
+    TContentShareMode aShareMode )
+    {
+    COma2AgentData* self = NewLC( aVirtualPath, aShareMode );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::NewLC
+// -----------------------------------------------------------------------------
+//
+COma2AgentData* COma2AgentData::NewLC(
+    const TVirtualPathPtr& aVirtualPath,
+    TContentShareMode aShareMode )
+    {
+    COma2AgentData* self = new ( ELeave ) COma2AgentData();
+    CleanupStack::PushL( self );
+    self->ConstructL( aVirtualPath, aShareMode );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::NewL
+// -----------------------------------------------------------------------------
+//
+COma2AgentData* COma2AgentData::NewL(
+    RFile& aFile,
+    const TDesC& aUniqueId )
+    {
+    COma2AgentData* self = COma2AgentData::NewLC( aFile, aUniqueId );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::NewLC
+// -----------------------------------------------------------------------------
+//
+COma2AgentData* COma2AgentData::NewLC(
+    RFile& aFile,
+    const TDesC& aUniqueId )
+    {
+    COma2AgentData* self = new ( ELeave ) COma2AgentData();
+    CleanupStack::PushL( self );
+    self->ConstructL( aFile, aUniqueId );
+    return self;
+    }
+
+// Destructor
+COma2AgentData::~COma2AgentData()
+    {
+    iRdb.Close();
+    iFile.Close();
+    iFs.Close();
+    delete iDcf;
+    delete iCache;
+    delete iUniqueId;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::DataSizeL
+// Re-create the DCF because it's size may have changed.
+// for progressive download etc.
+// -----------------------------------------------------------------------------
+//
+void COma2AgentData::DataSizeL( TInt &aSize )
+    {
+    TInt fileSize = 0;
+    TInt seekPos = 0;
+
+    User::LeaveIfError( iFile.Size( fileSize ) );
+
+    if ( iDcf )
+        {
+        // if the size of the file has changed update info:
+        if ( fileSize != iLastFileSize )
+            {
+            // Delete the old dcf
+            delete iDcf;
+            iDcf = NULL;
+
+            // seek the file to the beginning
+            iFile.Seek( ESeekStart, seekPos );
+
+            // Create new dcf as the size may have changed
+            iDcf = CDcfCommon::NewL( iFile );
+
+            // open the content part
+            if ( iUniqueId )
+                {
+                User::LeaveIfError( iDcf->OpenPart( iUniqueId->Des() ) );
+                }
+            else
+                {
+                User::LeaveIfError( iDcf->OpenPart( iVirtualPath.UniqueId() ) );
+                }
+            // re-initialize the dcf, this updates the iLastFileSize
+            InitializeL();
+            }
+
+        aSize = iDcf->iPlainTextLength;
+        }
+    else
+        {
+        User::Leave( KErrNotReady );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::EvaluateIntent
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentData::EvaluateIntent( TIntent aIntent )
+    {
+    TInt r = KErrNone;
+
+    // Check for a mismatch in the MIME type and the intent
+    if ( ( iDcf->iMimeType->Left(
+            KMimeAudio().Length() ).CompareF( KMimeAudio ) == 0 &&
+            ( aIntent == EView || aIntent == EPrint || aIntent == EExecute ) )
+        ||
+        ( iDcf->iMimeType->Left(
+            KMimeImage().Length() ).CompareF( KMimeImage ) == 0 &&
+            ( aIntent == EPlay || aIntent == EExecute ) ) )
+        {
+        r = KErrArgument;
+        }
+    else if ( iDcf->iEncryptionMethod )
+        {
+        if ( iGroupKeyUsed )
+            {
+            r = iRdb.CheckConsume( aIntent,
+                *( static_cast<COma2Dcf*> ( iDcf )->iGroupId ) );
+            }
+        else
+            {
+            r = iRdb.CheckConsume( aIntent, *iDcf->iContentID );
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::ExecuteIntent
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentData::ExecuteIntent( TIntent aIntent )
+    {
+    TInt r = KErrNone;
+    TBuf8<KDCFKeySize> key;
+
+    // Check for a mismatch in the MIME type and the intent
+    if ( ( iDcf->iMimeType->Left(
+            KMimeAudio().Length() ).CompareF( KMimeAudio ) == 0 &&
+            ( aIntent == EView || aIntent == EPrint || aIntent == EExecute ) )
+        ||
+        ( iDcf->iMimeType->Left(
+            KMimeImage().Length() ).CompareF( KMimeImage ) == 0 &&
+            ( aIntent == EPlay || aIntent == EExecute ) ) )
+        {
+        r = KErrArgument;
+        }
+    else if ( iDcf->iEncryptionMethod )
+        {
+        // If the MIME type allows it, do the consumption
+        if ( iGroupKeyUsed )
+            {
+            r = iRdb.Consume( aIntent,
+                *( static_cast<COma2Dcf*> ( iDcf )->iGroupId ) );
+            }
+        else
+            {
+            r = iRdb.Consume( aIntent, *iDcf->iContentID );
+            }
+
+        // If the consumption succeeded, try to get the decryption key.
+        // This is possible at this time because the permission is now known on
+        // the server side, and the server can return the key if the
+        // security level allows it. The decision is made based on the
+        // used permission and the caller identity.
+        if ( r == KErrNone && iRdb.GetDecryptionKey( aIntent,
+            *iDcf->iContentID, key ) == KErrNone && key.Length()
+            == KDCFKeySize )
+            {
+            iCache->SetKey( key );
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::Read
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentData::Read( TDes8& aDes )
+    {
+    return Read( aDes, aDes.MaxLength() );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::Read
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentData::Read(
+    TDes8& aDes,
+    TInt aLength )
+    {
+    return iCache->Read( iDataPosition, aDes, aLength );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::Read
+// -----------------------------------------------------------------------------
+//
+void COma2AgentData::Read(
+    TDes8& aDes,
+    TRequestStatus& aStatus )
+    {
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete( status, Read( aDes, aDes.MaxLength() ) );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::Read
+// asynchronous read
+// -----------------------------------------------------------------------------
+//
+void COma2AgentData::Read(
+    TDes8& aDes,
+    TInt aLength,
+    TRequestStatus& aStatus )
+    {
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete( status, Read( aDes, aLength ) );
+    }
+
+#ifdef ASYNC_READ
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::Read
+// asynchronous read (not really asynchronous)
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentData::Read(
+    TInt aPos,
+    TDes8& aDes,
+    TInt aLength,
+    TRequestStatus& aStatus )
+    {
+    return iCache->Read( aPos, aDes, aLength, aStatus );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::ReadCancel
+// -----------------------------------------------------------------------------
+//
+void COma2AgentData::ReadCancel( TRequestStatus& aStatus )
+    {
+    TRACE("+ COma2AgentData::ReadCancel");
+    iCache->ReadCancel( aStatus );
+    TRACE("- COma2AgentData::ReadCancel");
+    }
+#endif
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::Seek
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentData::Seek( TSeek aMode, TInt& aPos )
+    {
+    TInt r = KErrNone;
+
+    switch ( aMode )
+        {
+        case ESeekStart:
+            break;
+        case ESeekEnd:
+            aPos = iDcf->iPlainTextLength + aPos;
+            break;
+        case ESeekCurrent:
+            aPos = iDataPosition + aPos;
+            break;
+        default:
+            r = KErrNotSupported;
+            break;
+        }
+    aPos = Max( aPos, 0 );
+    aPos = Min( aPos, iDcf->iPlainTextLength );
+    iDataPosition = aPos;
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::SetProperty
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentData::SetProperty(
+    TAgentProperty /*aProperty*/,
+    TInt /*aValue*/)
+    {
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::GetAttribute
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentData::GetAttribute(
+    TInt aAttribute,
+    TInt& aValue )
+    {
+    TInt ret( KErrCANotSupported );
+    ret = TOma2AgentAttributes::GetAttribute( *iDcf, aAttribute,
+        iVirtualPath, &iRdb );
+    if ( ret >= KErrNone )
+        {
+        aValue = ret;
+        ret = KErrNone;
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::GetAttributeSet
+// -----------------------------------------------------------------------------
+//
+
+TInt COma2AgentData::GetAttributeSet(
+    RAttributeSet& aAttributeSet )
+    {
+    return TOma2AgentAttributes::GetAttributeSet( *iDcf, aAttributeSet,
+        iVirtualPath, &iRdb );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::GetStringAttribute
+// -----------------------------------------------------------------------------
+//
+
+TInt COma2AgentData::GetStringAttribute(
+    TInt aAttribute,
+    TDes& aValue )
+    {
+    return TOma2AgentAttributes::GetStringAttribute( *iDcf, aAttribute,
+        aValue, iVirtualPath, &iRdb );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentData::GetStringAttributeSet
+// -----------------------------------------------------------------------------
+//
+
+TInt COma2AgentData::GetStringAttributeSet(
+    RStringAttributeSet& aStringAttributeSet )
+    {
+    return TOma2AgentAttributes::GetStringAttributeSet( *iDcf,
+        aStringAttributeSet, iVirtualPath, &iRdb );
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/src/Oma2AgentFactory.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,164 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <caf/caf.h>
+#include "oma2agentfactory.h"
+
+using namespace ContentAccess;
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// COma2AgentFactory::COma2AgentFactory
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+COma2AgentFactory::COma2AgentFactory()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentFactory::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void COma2AgentFactory::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentFactory::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+COma2AgentFactory* COma2AgentFactory::NewL()
+    {
+    COma2AgentFactory* self = new( ELeave ) COma2AgentFactory;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+COma2AgentFactory::~COma2AgentFactory()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// COma2AgentFactory::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CAgentContent* COma2AgentFactory::CreateContentBrowserL(const TDesC& aURI, TContentShareMode aShareMode)
+	{
+	return COma2AgentContent::NewL(aURI, aShareMode);
+	}
+
+CAgentContent* COma2AgentFactory::CreateContentBrowserL(RFile& aFile)
+	{
+	return COma2AgentContent::NewL(aFile);
+	}
+
+CAgentData* COma2AgentFactory::CreateDataConsumerL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode)
+	{
+	return COma2AgentData::NewL(aVirtualPath, aShareMode);
+	}
+
+CAgentData* COma2AgentFactory::CreateDataConsumerL(RFile& aFile, const TDesC& aUniqueId)
+	{
+	return COma2AgentData::NewL(aFile, aUniqueId);
+	}
+
+CAgentManager*  COma2AgentFactory::CreateManagerL()
+	{
+	return COma2AgentManager::NewL();
+	}
+
+CAgentImportFile* COma2AgentFactory::CreateImporterL(const TDesC8& aMimeType, const CMetaDataArray& aMetaDataArray, const TDesC& aOutputDirectory, const TDesC& aSuggestedFileName)
+	{
+	return COma2AgentImportFile::NewL(aMimeType, aMetaDataArray, aOutputDirectory, aSuggestedFileName);
+	}
+
+CAgentImportFile* COma2AgentFactory::CreateImporterL(const TDesC8& aMimeType, const CMetaDataArray& aMetaDataArray)
+	{
+	return COma2AgentImportFile::NewL(aMimeType, aMetaDataArray);
+	}
+
+CAgentRightsManager* COma2AgentFactory::CreateRightsManagerL()
+	{
+	return COma2AgentRightsManager::NewL();
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/src/Oma2AgentImportFile.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,544 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <s32mem.h>
+#include <f32file.h>
+#include <caf/caf.h>
+#include <caf/caferr.h>
+#include <caf/SupplierOutputFile.h>
+#include "Oma2Agent.h"
+#include "Oma2AgentImportfile.h"
+#include "DcfCommon.h"
+#include "DrmRights.h"
+#include "DrmMessageParser.h"
+#include "Oma1DcfCreator.h"
+#include "DrmRightsParser.h"
+#include "DrmProtectedRoParser.h"
+
+using namespace ContentAccess;
+
+// LOCAL FUNCTION PROTOTYPES
+template<class S>
+LOCAL_C void PointerArrayResetDestroyAndClose(TAny* aPtr);
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+template<class S>
+void PointerArrayResetDestroyAndClose(TAny* aPtr)
+    {
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->ResetAndDestroy();
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->Close();
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+COma2AgentImportFile* COma2AgentImportFile::NewL(
+    const TDesC8& aMimeType,
+    const CMetaDataArray& aMetaDataArray,
+    const TDesC& aOutputDirectory,
+    const TDesC& aSuggestedFileName)
+	{
+	COma2AgentImportFile* self=new(ELeave) COma2AgentImportFile(EFalse);
+	CleanupStack::PushL(self);
+	self->ConstructL(aMimeType, aMetaDataArray, aOutputDirectory,
+	    aSuggestedFileName);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+COma2AgentImportFile* COma2AgentImportFile::NewL(
+    const TDesC8& aMimeType,
+    const CMetaDataArray& aMetaDataArray)
+	{
+	COma2AgentImportFile* self=new(ELeave) COma2AgentImportFile(EFalse);
+	CleanupStack::PushL(self);
+	self->ConstructL(aMimeType, aMetaDataArray, KNullDesC(), KNullDesC());
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+COma2AgentImportFile::COma2AgentImportFile(
+    TBool aAgentCreatesOutputFiles):
+    iOutputDirectory(NULL),
+    iSuggestedFileName(NULL),
+    iOutputFileName(NULL),
+    iLastWriteData(NULL),
+    iAgentCreatesOutputFiles(aAgentCreatesOutputFiles),
+    iMessageParser(NULL),
+    iDcfCreator(NULL),
+    iDcfRights(NULL),
+    iDcfMimeType(NULL)
+	{
+	iImportStatus = EInProgress;
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+COma2AgentImportFile::~COma2AgentImportFile()
+	{
+	if (iFileOpen)
+		{
+		iFile.Close();
+		iFileOpen = EFalse;
+		}
+	iFs.Close();
+	delete iOutputDirectory;
+	delete iSuggestedFileName;
+    delete iOutputFileName;
+	delete iLastWriteData;
+	iOutputFiles.ResetAndDestroy();
+	iOutputFiles.Close();
+	delete iMessageParser;
+	delete iDcfCreator;
+	delete iDcfRights;
+	delete iDcfMimeType;
+	}
+  
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void COma2AgentImportFile::ConstructL(
+    const TDesC8& aMimeType,
+    const CMetaDataArray& aMetaDataArray,
+    const TDesC& aOutputDirectory,
+    const TDesC& aSuggestedFileName)
+	{
+	RMemReadStream rights;
+	
+	if (aMimeType.CompareF(KOma1DrmMessageContentType) == 0 ||
+	    aMimeType.CompareF(KOmaImportContentType) == 0)
+	    {
+	    if (aMimeType.CompareF(KOma1DrmMessageContentType) == 0)
+	        {
+            iMessageParser = CDRMMessageParser::NewL();
+	        iImportType = EOma1DrmMessage;
+	        }
+	    else
+	        {
+	        iDcfCreator = COma1DcfCreator::NewL();
+    	    iImportType = EPlainContent;
+            const TDesC8& mimeDes = aMetaDataArray.SearchL(
+                KOmaImportMimeTypeField);
+            if (mimeDes.Length() == 0)
+                {
+                User::Leave(KErrArgument);
+                }
+    	    iDcfMimeType = mimeDes.AllocL();
+    	    const TDesC8& rightsDes = aMetaDataArray.SearchL(
+    	        KOmaImportRightsField);
+            if (rightsDes.Length() > 0)
+    	        {
+    	        rights.Open(rightsDes.Ptr(), rightsDes.Length());
+    	        CleanupClosePushL(rights);
+        	    iDcfRights = CDRMRights::NewL();
+    	        iDcfRights->InternalizeL(rights);
+    	        CleanupStack::PopAndDestroy(); // rights
+    	        }
+	        }
+    	iOutputDirectory = aOutputDirectory.AllocL();
+    	iSuggestedFileName = aSuggestedFileName.AllocL();
+    	iOutputFileName = HBufC::NewL(iOutputDirectory->Des().Length() +
+            iSuggestedFileName->Des().Length());
+	    iAgentCreatesOutputFiles = ETrue;
+	    }
+    else if (aMimeType.CompareF(KOma1XmlRoContentType) == 0)
+	    {
+	    iImportType = EOma1XmlRo;
+	    }
+    else if (aMimeType.CompareF(KOma1WbxmlRoContentType) == 0)
+	    {
+	    iImportType = EOma1WbxmlRo;
+	    }
+    else if (aMimeType.CompareF(KOma2RoContentType) == 0)
+	    {
+	    iImportType = EOma2Ro;
+	    }
+    else
+        {
+		User::Leave(KErrCANotSupported);
+		}
+	User::LeaveIfError(iFs.Connect());
+    User::LeaveIfError(iFs.ShareAuto());	
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentImportFile::OpenOutputFile()
+	{
+	TInt r = KErrNone;
+	TPtr fileNamePtr = iOutputFileName->Des();
+	
+	fileNamePtr.Copy(*iOutputDirectory);
+	fileNamePtr.Append(*iSuggestedFileName);
+
+	r = iFile.Create(iFs, fileNamePtr, EFileShareAny  | EFileStream |
+	    EFileWrite);
+	if (r == KErrNone)
+		{
+		iFileOpen = ETrue;
+		if (iImportType == EOma1DrmMessage)
+		    {
+		    TRAP(r, iMessageParser->InitializeMessageParserL(iFile));
+		    }
+		else
+		    {
+		    TRAP(r, iDcfCreator->EncryptInitializeL(iFile, *iDcfMimeType,
+		        iDcfRights));
+		    }
+		}
+    else
+        {
+        r = KErrCANewFileHandleRequired;
+        }
+    return r;
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void COma2AgentImportFile::WriteDataL(const TDesC8& aData)
+    {
+	CDrmRightsParser* oma1Parser = NULL;
+	CDrmProtectedRoParser* oma2Parser = NULL;
+	RPointerArray<CDRMRights> rights;
+    TCleanupItem listCleanup(PointerArrayResetDestroyAndClose<CDRMRights>,
+        &rights);
+	TInt r;
+	
+    switch (iImportType)
+        {
+        case EOma1DrmMessage:
+        	if (!iFileOpen)
+        		{
+        		r = OpenOutputFile();
+        		if (r == KErrNone)
+        		    {
+                    iMessageParser->ProcessMessageDataL(aData);
+        		    }
+        		else
+        		    {
+                    iLastWriteData = aData.AllocL();
+                    User::Leave(r);
+        		    }
+                }
+            else
+                {
+                iMessageParser->ProcessMessageDataL(aData);
+                }
+            break;
+        case EPlainContent:
+        	if (!iFileOpen)
+        		{
+        		r = OpenOutputFile();
+        		if (r == KErrNone)
+        		    {
+                    iDcfCreator->EncryptUpdateL(aData);
+        		    }
+        		else
+        		    {
+                    iLastWriteData = aData.AllocL();
+                    User::Leave(r);
+        		    }
+                }
+            else
+                {
+                iDcfCreator->EncryptUpdateL(aData);
+                }
+            break;
+        case EOma1XmlRo:
+        case EOma1WbxmlRo:
+            oma1Parser = CDrmRightsParser::NewL();
+            CleanupStack::PushL(oma1Parser);
+            CleanupStack::PushL(listCleanup);
+            oma1Parser->ParseAndStoreL(aData, rights);
+            CleanupStack::PopAndDestroy(2); // listCleanup, oma1Parser
+            break;
+        case EOma2Ro:
+            __UHEAP_MARK;
+            oma2Parser = CDrmProtectedRoParser::NewL();
+            CleanupStack::PushL(oma2Parser);
+            CleanupStack::PushL(listCleanup);
+            oma2Parser->ParseAndStoreL(aData, rights);
+            CleanupStack::PopAndDestroy(2); // listCleanup, oma2Parser
+            __UHEAP_MARKEND;
+            break;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentImportFile::WriteData(const TDesC8& aData)
+	{
+	TInt r = KErrNone;
+	TRAP(r, WriteDataL(aData));
+	return r;
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentImportFile::WriteDataComplete()
+	{
+	TInt r = KErrNone;
+	CSupplierOutputFile *temp = NULL;
+	TPtrC8 type(NULL, 0);
+	
+	if (iFileOpen)
+		{
+		if (iImportType == EOma1DrmMessage)
+		    {
+		    TRAP(r, iMessageParser->FinalizeMessageParserL());
+		    }
+		else
+		    {
+		    TRAP(r, iDcfCreator->EncryptFinalizeL());
+		    }
+		iFile.Close();
+		iFileOpen = EFalse;
+		}
+	if( r ) 
+	    {
+		  return r;
+      }
+	if (iOutputFileName)
+		{
+		switch (iImportType)
+		    {
+		    case EPlainContent:
+            case EOma1DrmMessage:
+                type.Set(KOma1DcfContentType());
+                break;
+            default:
+                return KErrGeneral;;
+		    }
+		TRAP(r, temp = CSupplierOutputFile::NewL(iOutputFileName->Des(),
+		    EContent, type));
+		if (r == KErrNone)
+			{
+			r = iOutputFiles.Append(temp);
+			if (r != KErrNone)
+				{
+				delete temp;
+				}
+			}
+		}
+	return r;
+	}
+		
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void COma2AgentImportFile::WriteData(
+    const TDesC8& aData,
+    TRequestStatus &aStatus)
+	{
+	TRequestStatus *ptr = &aStatus;
+	TInt r = WriteData(aData);
+	User::RequestComplete(ptr,r);
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void COma2AgentImportFile::WriteDataComplete(
+    TRequestStatus &aStatus)
+	{
+	TRequestStatus *ptr = &aStatus;
+	TInt r = WriteDataComplete();
+	User::RequestComplete(ptr,r);
+	}
+	
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentImportFile::OutputFileCountL() const
+	{
+	return iOutputFiles.Count();
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+CSupplierOutputFile& COma2AgentImportFile::OutputFileL(
+    TInt aIndex)
+	{
+	return *iOutputFiles[aIndex];
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TImportStatus COma2AgentImportFile::GetImportStatus() const
+	{
+	return iImportStatus;
+	}	
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentImportFile::GetSuggestedOutputFileExtension(
+    TDes& aFileExtension)
+	{
+	aFileExtension.Copy(_L(".dcf"));
+	return KErrNone;
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentImportFile::GetSuggestedOutputFileName(
+    TDes& aFileName)
+	{
+	aFileName.Append(_L(".dcf"));
+	return KErrNone;
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentImportFile::ContinueWithNewOutputFile(
+    RFile& aFile,
+    const TDesC& aFileName)
+	{
+	RFile file;
+	TInt r = KErrNone;
+
+	if (iOutputFileName != NULL)
+	    {
+	    delete iOutputFileName;
+	    iOutputFileName = NULL;
+	    }
+	TRAP(r, iOutputFileName = aFileName.AllocL());
+	if (r == KErrNone)
+	    {
+	    file.Duplicate(aFile);
+        iFile.Attach(file);
+        iFileOpen = ETrue;
+		if (iImportType == EOma1DrmMessage)
+		    {
+		    TRAP(r, iMessageParser->InitializeMessageParserL(iFile));
+		    }
+		else
+		    {
+		    TRAP(r, iDcfCreator->EncryptInitializeL(iFile, *iDcfMimeType,
+		        iDcfRights));
+		    }
+        if (r == KErrNone)
+            {
+            r = WriteData(*iLastWriteData);
+            }
+        delete iLastWriteData;
+        iLastWriteData = NULL;
+	    }
+	return r;
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void COma2AgentImportFile::ContinueWithNewOutputFile(
+    RFile& aFile,
+    const TDesC& aFileName,
+    TRequestStatus& aStatus)
+	{
+	TRequestStatus *ptr = &aStatus;
+	TInt r = ContinueWithNewOutputFile(aFile, aFileName);
+	User::RequestComplete(ptr,r);
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void COma2AgentImportFile::NewMimePartL(
+    const TDesC8& /*aMimeType*/,
+    const CMetaDataArray& /*aImportMetaData*/)
+	{
+	User::Leave(KErrCANotSupported);
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void COma2AgentImportFile::EndMimePartL()
+	{
+	User::Leave(KErrCANotSupported);
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/src/Oma2AgentManager.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,997 @@
+/*
+* Copyright (c) 2005 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the Manager Interface
+*
+*/
+
+
+// INCLUDE FILES
+#include <caf/caf.h>
+#include <http.h>
+#include <http/rhttpheaders.h>
+#include <stringpool.h>
+#include <utf.h>
+
+
+#include <w32std.h>
+#include <apparc.h>
+#include <apgtask.h>
+#include <apgcli.h>
+#include <apaserverapp.h>
+#include <sysutil.h>
+#include <centralrepository.h>
+
+#include "oma2agentmanager.h"
+#include "oma2agentattributes.h"
+#include "oma1dcf.h"
+#include "oma2dcf.h"
+#include "drmrightsclient.h"
+
+#include "drmutilityinternalcrkeys.h"      // Cenrep extension for OmaBased
+
+using namespace ContentAccess;
+
+
+const TInt KMinimumOma1DcfLength = 16;
+
+const TInt KCenRepDataLength( 50 );
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+LOCAL_C void DecryptL(
+    const TDesC8& aContent,
+    TDes8& aOutput)
+    {
+    COma1Dcf* dcf = NULL;
+    TBuf8<KDCFKeySize> iv;
+    TPtr8 input(NULL, 0);
+    RDRMRightsClient client;
+    TPtr8 ptr(NULL, 0);
+
+    dcf = COma1Dcf::NewL(aContent.Mid(1));
+    CleanupStack::PushL(dcf);
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+    User::LeaveIfError(client.Consume(aContent[0], *dcf->iContentID));
+    User::LeaveIfError(client.InitializeKey(*dcf->iContentID));
+
+    iv.Copy(aContent.Mid(dcf->iOffset + 1, KDCFKeySize));
+    aOutput.Copy(&aContent[dcf->iOffset + KDCFKeySize + 1], dcf->iDataLength -
+        KDCFKeySize);
+    ptr.Set(&aOutput[0], aOutput.Length(), aOutput.Length());
+    User::LeaveIfError(client.Decrypt(iv, ptr, ETrue));
+
+    dcf->iPlainTextLength = aOutput.Length();
+    dcf->iPadding = dcf->iDataLength - dcf->iPlainTextLength;
+    client.Consume(EStop, *dcf->iContentID);
+    CleanupStack::PopAndDestroy(2); // client, dcf
+    }
+
+LOCAL_C TInt SetName( const TDesC8& aContentUri,
+    const TDesC& aContentName )
+    {
+    RDRMRightsClient client;
+    TInt r = KErrNone;
+    r = client.Connect();
+    if( !r )
+        {
+        r = client.SetName( aContentUri, aContentName );
+        }
+    client.Close();
+    return r;
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::COma2AgentManager
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+COma2AgentManager::COma2AgentManager(void):
+    iNotifier(NULL),
+    iWatchedId(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void COma2AgentManager::ConstructL()
+    {
+    User::LeaveIfError(iFs.Connect());
+    User::LeaveIfError(iFs.ShareAuto());
+    iFileManager = CFileMan::NewL(iFs);
+    
+    TInt err( KErrNone );
+                
+    TRAP(err, FetchOmaBasedInfoL() );
+    if( err)
+        {
+        if( iOmaBasedMimeType )
+            {
+            delete iOmaBasedMimeType;
+            }
+        iOmaBasedMimeType = NULL;
+        }
+    
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::FetchOmaBasedInfoL
+// -----------------------------------------------------------------------------
+//
+void COma2AgentManager::FetchOmaBasedInfoL()
+    {
+    TInt err = KErrNone;
+    CRepository* repository( NULL );
+    RBuf bOmaBasedMimeType;
+    
+    CleanupClosePushL(bOmaBasedMimeType);
+    bOmaBasedMimeType.CreateL( KCenRepDataLength );
+ 
+    TRAP( err, repository = CRepository::NewL( KCRUidOmaBased ) );
+    if ( !err )
+        {
+        CleanupStack::PushL( repository );
+        
+        err = repository->Get( KOmaBasedMimeType, bOmaBasedMimeType );
+        if( !err )
+            {
+            iOmaBasedMimeType = CnvUtfConverter::ConvertFromUnicodeToUtf8L( bOmaBasedMimeType ); 
+            }
+        CleanupStack::PopAndDestroy( repository );
+        }
+    
+    CleanupStack::PopAndDestroy();
+    
+    User::LeaveIfError( err );    
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+COma2AgentManager* COma2AgentManager::NewL()
+    {
+    COma2AgentManager* self = NewLC();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+COma2AgentManager* COma2AgentManager::NewLC()
+    {
+    COma2AgentManager* self=new(ELeave) COma2AgentManager();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+COma2AgentManager::~COma2AgentManager()
+    {
+    delete iFileManager;
+    iFs.Close();
+    if (iNotifier != NULL)
+        {
+        if( iWatchedId )
+            {
+            TRAP_IGNORE(iNotifier->UnRegisterEventObserverL(*this, KEventAddRemove, *iWatchedId));
+            TRAP_IGNORE(iNotifier->UnRegisterEventObserverL(*this, KEventModify, *iWatchedId));
+            }
+        delete iNotifier;
+        }
+    delete iWatchedId;
+    
+    delete iOmaBasedMimeType;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::DeleteFile
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::DeleteFile(const TDesC& aFileName)
+    {
+    return iFs.Delete(aFileName);
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::CopyFile
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::CopyFile(
+    const TDesC& aSource,
+    const TDesC& aDestination)
+    {
+    TInt driveNumber = 0;
+    TChar drive( aDestination[0] );
+    RFile file;
+    TInt size = 0;
+    TInt result = KErrNone;
+
+    TInt err = KErrNone;
+    TBool retval = KErrNone;
+
+    
+    // Check the destination drive letter
+    result = iFs.CharToDrive(drive,driveNumber);      
+    
+    if( result )
+        {
+        return result;
+        }
+    
+    // open the file to read the size    
+    result = file.Open(iFs, aSource, EFileShareReadersOrWriters|EFileRead);
+                
+    if( result )
+        {
+        return result;
+        }       
+    
+    // read the size
+    result = file.Size( size );
+    
+    // close the file
+    file.Close();
+    
+    if( result )
+        {
+        return result;
+        }
+    
+    // check that the drive has enough space for the copy operation
+
+    TRAP( err, retval = SysUtil::DiskSpaceBelowCriticalLevelL( &iFs,
+                                                               size,
+                                                               driveNumber ) )
+    if( retval )
+        {
+        return KErrDiskFull;
+        }        	
+    	
+        
+    return iFileManager->Copy( aSource, aDestination);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::CopyFile
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::CopyFile(RFile& aSource, 
+    const TDesC& aDestination)
+	{
+    TInt driveNumber = 0;
+    TChar drive( aDestination[0] );
+    TInt size = 0;
+    TInt result = KErrNone;
+    RFile output;
+    TFileName fileName;
+
+    TInt err = KErrNone;
+    TBool retval = KErrNone;
+
+    
+    // Same file, do not even try to copy
+    // And since they are the same don't return an error  
+    aSource.FullName( fileName );
+    
+    if( !aDestination.CompareF( fileName ) )
+        {
+        return KErrNone;
+        }
+    
+    // Check the destination drive letter
+    result = iFs.CharToDrive(drive,driveNumber);      
+    
+    if( result )
+        {
+        return result;
+        }
+                
+    // read the size
+    result = aSource.Size( size );
+    
+    if( result )
+        {
+        return result;
+        }
+    
+    // check that the drive has enough space for the copy operation
+
+    TRAP( err, retval = SysUtil::DiskSpaceBelowCriticalLevelL( &iFs,
+                                                               size,
+                                                               driveNumber ) )
+    if( retval )
+
+        {
+        return KErrDiskFull;
+        }  
+
+    // Perform the copy:
+    
+    // Rewind just in case:
+    size = 0;
+    result = aSource.Seek(ESeekStart, size);
+    
+    if( !result )
+        {
+        result = iFileManager->Copy(aSource, aDestination);        
+        }
+            	
+    return result;
+	}
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::RenameFile
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::RenameFile(
+    const TDesC& aSource,
+    const TDesC& aDestination)
+    {
+    TInt driveNumber = 0;
+    TChar drive( aDestination[0] );
+    RFile file;
+    TInt size = 0;
+
+    TInt err = KErrNone;
+    TBool retval = KErrNone;
+
+    
+    TInt result( iFileManager->Rename(aSource, aDestination) );
+    // If the files are on a different drive, Rename will fail
+    // Therefore we simulate the Move by doing a Copy, followed by Delete
+    if ( result != KErrNone )
+        {
+        // Check the destination drive letter
+        result = iFs.CharToDrive(drive,driveNumber);      
+     
+        if( result )
+            {
+            return result;
+            }
+        
+        // open the file to read the size    
+        result = file.Open(iFs, aSource, EFileShareReadersOrWriters|EFileRead);
+                    
+        if( result )
+            {
+            return result;
+            }       
+        
+        // read the size
+        result = file.Size( size );
+        
+        // close the file
+        file.Close();
+        
+        if( result )
+            {
+            return result;
+            }
+        
+        // check that the drive has enough space for the copy operation
+
+        TRAP( err, retval = SysUtil::DiskSpaceBelowCriticalLevelL( &iFs,
+                                                                   size,
+                                                                   driveNumber ) )
+        if( retval )
+
+            {
+            return KErrDiskFull;
+            }        	
+        	
+        	
+        result = iFileManager->Copy(aSource,aDestination);
+        if (result == KErrNone)
+            {
+            // If the copy was successful try and delete the original
+            result = iFileManager->Delete(aSource);
+            if (result != KErrNone)
+                {
+                // Delete failed so try to cleanup the destination file
+                // as we're going to exit with an error
+                // We can safely ignore any error from this as the previous error
+                // is more important to propagate, since this is just cleanup
+                iFileManager->Delete(aDestination);
+                }
+            }
+        }
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::MkDir
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::MkDir(
+    const TDesC& aPath)
+    {
+    return iFs.MkDir( aPath );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::MkDirAll
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::MkDirAll(
+    const TDesC& aPath)
+    {
+    return iFs.MkDirAll( aPath );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::RmDir
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::RmDir(
+    const TDesC& aPath)
+    {
+    return iFileManager->RmDir( aPath );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::GetDir
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::GetDir(
+    const TDesC& aName,
+    TUint aEntryAttMask,
+    TUint aEntrySortKey,
+    CDir*& aEntryList) const
+    {
+    return iFs.GetDir( aName, aEntryAttMask, aEntrySortKey, aEntryList );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::GetDir
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::GetDir(
+    const TDesC& aName,
+    TUint aEntryAttMask,
+    TUint aEntrySortKey,
+    CDir*& aEntryList,
+    CDir*& aDirList) const
+    {
+    return iFs.GetDir( aName, aEntryAttMask, aEntrySortKey, aEntryList, aDirList );
+    }
+
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::GetDir
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::GetDir(
+    const TDesC& aName,
+    const TUidType& aEntryUid,
+    TUint aEntrySortKey,
+    CDir*& aFileList) const
+    {
+    return iFs.GetDir( aName, aEntryUid, aEntrySortKey, aFileList );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::GetAttribute
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::GetAttribute(
+    TInt aAttribute,
+    TInt& aValue,
+    const TVirtualPathPtr& aVirtualPath)
+    {
+    TInt r = KErrNone;
+    CDcfCommon* dcfFile = NULL;
+
+    TRAP(r, dcfFile = CDcfCommon::NewL(aVirtualPath.URI()));
+    if( r )
+        {
+        return r;
+        }
+    aValue = TOma2AgentAttributes::GetAttribute(*dcfFile, aAttribute, aVirtualPath);
+    delete dcfFile;
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::GetAttributeSet
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::GetAttributeSet(
+    RAttributeSet& aAttributeSet,
+    const TVirtualPathPtr& aVirtualPath)
+    {
+    TInt r = KErrNone;
+    CDcfCommon *dcfFile = NULL;
+
+    TRAP(r, dcfFile = CDcfCommon::NewL(aVirtualPath.URI()));
+    if( r )
+        {
+        return r;
+        }
+    r = TOma2AgentAttributes::GetAttributeSet(*dcfFile, aAttributeSet, aVirtualPath);
+    delete dcfFile;
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::GetStringAttributeSet
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::GetStringAttributeSet(
+    RStringAttributeSet& aAttributeSet,
+    const TVirtualPathPtr& aVirtualPath)
+    {
+    TInt r = KErrNone;
+    CDcfCommon *dcfFile = NULL;
+
+    TRAP(r, dcfFile = CDcfCommon::NewL(aVirtualPath.URI()));
+    if( r )
+        {
+        return r;
+        }
+    r = TOma2AgentAttributes::GetStringAttributeSet(
+        *dcfFile, aAttributeSet, aVirtualPath);
+    delete dcfFile;
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::GetStringAttribute
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::GetStringAttribute(
+    TInt aAttribute,
+    TDes& aValue,
+    const TVirtualPathPtr& aVirtualPath)
+    {
+    TInt r = KErrNone;
+    CDcfCommon *dcfFile = NULL;
+
+    TRAP(r, dcfFile = CDcfCommon::NewL(aVirtualPath.URI()));
+    if( r )
+        {
+        return r;
+        }
+    r = TOma2AgentAttributes::GetStringAttribute(
+        *dcfFile, aAttribute, aValue, aVirtualPath);
+    delete dcfFile;
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::NotifyStatusChange
+// -----------------------------------------------------------------------------
+//
+void COma2AgentManager::NotifyStatusChange(
+    const TDesC& aUri,
+    TEventMask aEventMask,
+    TRequestStatus& aStatus)
+    {
+    CDcfCommon* dcf = NULL;
+    TInt r = 0;
+
+    if( iWatchedId != NULL )
+        {
+        if( iNotifier )
+            {
+            TRAP_IGNORE(iNotifier->UnRegisterEventObserverL(*this, KEventAddRemove, *iWatchedId));
+            TRAP_IGNORE(iNotifier->UnRegisterEventObserverL(*this, KEventModify, *iWatchedId));
+            }
+        delete iWatchedId;
+        }
+    iWatchedEvents = TEventMask(0);
+
+    if (iNotifier == NULL)
+        {
+        TRAP(r, iNotifier = CDRMNotifier::NewL());
+        }
+    TRAP(r, dcf = CDcfCommon::NewL(aUri));
+    if (iNotifier != NULL && dcf != NULL)
+        {
+        iStatus = &aStatus;
+        iWatchedEvents = aEventMask;
+        TRAP_IGNORE( iWatchedId = dcf->iContentID->AllocL() ); 
+        TRAP(r, iNotifier->RegisterEventObserverL(*this, KEventAddRemove, *iWatchedId));
+        TRAP(r, iNotifier->RegisterEventObserverL(*this, KEventModify, *iWatchedId));
+        *iStatus = KRequestPending;
+        delete dcf;
+        }
+    if (r != KErrNone)
+        {
+        User::RequestComplete(iStatus, r);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::CancelNotifyStatusChange
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::CancelNotifyStatusChange(
+    const TDesC& /*aUri*/,
+    TRequestStatus& aStatus)
+    {
+    iStatus = &aStatus;
+    if (iWatchedId != NULL)
+        {
+        if( iNotifier )
+            {
+            TRAP_IGNORE(iNotifier->UnRegisterEventObserverL(*this, KEventAddRemove, *iWatchedId));
+            TRAP_IGNORE(iNotifier->UnRegisterEventObserverL(*this, KEventModify, *iWatchedId));
+            }
+        delete iWatchedId;
+        iWatchedId = NULL;
+        }
+    iWatchedEvents = TEventMask(0);
+    User::RequestComplete(iStatus, KErrCancel);
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::SetProperty
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::SetProperty(
+    TAgentProperty /*aProperty*/,
+    TInt /*aValue*/)
+    {
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::DisplayInfoL
+// -----------------------------------------------------------------------------
+//
+void COma2AgentManager::DisplayInfoL(
+    TDisplayInfo /*aInfo*/,
+    const TVirtualPathPtr& /*aVirtualPath*/)
+    {
+    User::Leave(KErrCANotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::IsRecognizedL
+// -----------------------------------------------------------------------------
+//
+TBool COma2AgentManager::IsRecognizedL(
+    const TDesC& aUri,
+    TContentShareMode /*aShareMode*/) const
+    {
+    TBuf8<40> buffer; // Size increased to 40
+    TBool r = EFalse;
+
+    User::LeaveIfError(iFs.ReadFileSection(aUri, 0, buffer, buffer.MaxLength()));
+    if (COma1Dcf::IsValidDcf(buffer) || COma2Dcf::IsValidDcf(buffer))
+        {
+        r = ETrue;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::IsRecognizedL
+// -----------------------------------------------------------------------------
+//
+TBool COma2AgentManager::IsRecognizedL(
+    RFile& aFile) const
+    {
+    TBuf8<40> buffer; // Size increased to 40
+    TBool r = EFalse;
+    TInt pos = 0;
+
+    User::LeaveIfError(aFile.Seek(ESeekStart, pos));
+    User::LeaveIfError(aFile.Read(buffer, buffer.MaxLength()));
+    if (COma1Dcf::IsValidDcf(buffer) || COma2Dcf::IsValidDcf(buffer))
+        {
+        r = ETrue;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::RecognizeFileL
+// Only check from the file in case the buffer is not large enough to give
+// a definitive answer.
+// -----------------------------------------------------------------------------
+//
+TBool COma2AgentManager::RecognizeFileL(
+    const TDesC& aFileName,
+    const TDesC8& aBuffer,
+    TDes8& aFileMimeType,
+    TDes8& aContentMimeType) const
+    {
+    TBool r = EFalse;
+    TInt err = KErrNone;
+    CDcfCommon* dcf = NULL;
+
+#ifdef __DRM_OMA2
+    if ( !aFileName.Right(4).CompareF( KOma2DcfExtension ) ||
+        !aFileName.Right(4).CompareF( KOma2DcfExtensionAudio ) ||
+        !aFileName.Right(4).CompareF( KOma2DcfExtensionVideo ) ||
+        COma2Dcf::IsValidDcf(aBuffer) )
+        {
+        aFileMimeType.Copy(KOma2DcfContentType);
+        aContentMimeType.Copy(KCafMimeType);
+        r = ETrue; // file was recognized as OMA2 DCF
+        }
+    else
+        {
+#endif
+        // Check if the given buffer if a valid buffer, or if it's too short:
+        if (COma1Dcf::IsValidDcf(aBuffer) ||
+            aBuffer.Length() < KMinimumOma1DcfLength )
+            {
+
+            // Check if we can get all the information we need from the buffer.
+            TRAP(err, dcf = COma1Dcf::NewL(aBuffer));
+
+            // if we can't and we have a filename check from the file
+            if (dcf == NULL && aFileName != KNullDesC)
+                {
+                dcf = CDcfCommon::NewL(aFileName);
+                }
+
+            // If the dcf object creation worked get the information needed and
+            // mark the file as recognized. Check for specific mimetypes
+            if (dcf != NULL)
+                {
+                CleanupStack::PushL(dcf);
+                if ((dcf->iMimeType->Des()).CompareF(*iOmaBasedMimeType))
+                    {
+                    aFileMimeType.Copy(KOma1DcfContentType);
+                    aContentMimeType.Copy(*dcf->iMimeType);
+                    r = ETrue; // file was recognized as OMA1 DCF
+                    }
+                CleanupStack::PopAndDestroy();    
+                }
+                
+            }
+#ifdef __DRM_OMA2
+        }
+#endif
+    return r;
+    }
+
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::AgentSpecificCommand
+// -----------------------------------------------------------------------------
+//
+TInt COma2AgentManager::AgentSpecificCommand(
+    TInt aCommand,
+    const TDesC8& aInputBuffer,
+    TDes8& aOutputBuffer)
+    {
+    TInt r = KErrCANotSupported;
+    RDRMRightsClient client;
+    TInt value = 0;
+    TInt size = 0;
+    TTimeIntervalSeconds interval;
+    TPtrC8 contentUri;
+    TPtrC16 contentName;
+
+    switch( aCommand )
+        {
+        case EOmaDrmMethods:
+                {
+                aOutputBuffer.Copy(_L8("FL CD SD"));
+#ifdef __DRM_OMA2
+                aOutputBuffer.Append(_L8(" OMADRM2"));
+#endif
+                }
+            break;
+        case ESetPendingRightsETA:
+                {
+                Mem::Copy( &value, aInputBuffer.Ptr(), sizeof(TInt) );
+                interval = value;
+                contentUri.Set( aInputBuffer.Ptr() + sizeof(TInt),
+                    aInputBuffer.Size()-sizeof(TInt) );
+
+                r = client.Connect();
+                if( !r )
+                    {
+                    r = client.SetEstimatedArrival( contentUri,
+                        interval );
+                    }
+                // close the handle:
+                client.Close();
+                }
+            break;
+        case EBufferContainsOma1Dcf:
+            if (COma1Dcf::IsValidDcf(aInputBuffer))
+                {
+                r = KErrNone;
+                }
+            else
+                {
+                r = KErrNotFound;
+                }
+            break;
+        case EDecryptOma1DcfBuffer:
+            r = KErrNone;
+            TRAP(r, DecryptL(aInputBuffer, aOutputBuffer));
+            break;
+        case ESetContentName:
+            Mem::Copy( &value, aInputBuffer.Ptr(), sizeof(TInt));
+            contentName.Set(
+                reinterpret_cast<TUint16*>(
+                    const_cast<TUint8*>(aInputBuffer.Ptr() + sizeof(TInt))),
+                value );
+
+            size = aInputBuffer.Size();
+            size -= value*2;
+            size -= sizeof(TInt);
+
+            contentUri.Set( aInputBuffer.Ptr() + sizeof(TInt) + value*2,
+                size );
+
+            r = SetName( contentUri, contentName );
+            break;
+        default:
+            break;
+        }
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::AgentSpecificCommand
+// -----------------------------------------------------------------------------
+//
+void COma2AgentManager::AgentSpecificCommand(
+    TInt aCommand,
+    const TDesC8& aInputBuffer,
+    TDes8& aOutputBuffer,
+    TRequestStatus& aStatus)
+    {
+    TRequestStatus *ptr = &aStatus;
+    User::RequestComplete(ptr, AgentSpecificCommand(aCommand, aInputBuffer,
+            aOutputBuffer));
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::PrepareHTTPRequestHeaders
+// -----------------------------------------------------------------------------
+//
+void COma2AgentManager::PrepareHTTPRequestHeaders(
+    RStringPool& aStringPool,
+    RHTTPHeaders& aRequestHeaders) const
+    {
+    TRAP_IGNORE( PrepareHTTPRequestHeadersL(aStringPool, aRequestHeaders) );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::PrepareHTTPRequestHeadersL
+// -----------------------------------------------------------------------------
+//
+void COma2AgentManager::PrepareHTTPRequestHeadersL(
+    RStringPool& aStringPool,
+    RHTTPHeaders& aRequestHeaders) const
+    {
+    TBuf8<KMaxDataTypeLength> mimeType;
+    RStringF string;
+    THTTPHdrVal header;
+
+    mimeType.Copy(KOma1DrmMessageContentType);
+    string = aStringPool.OpenFStringL(mimeType);
+    CleanupClosePushL(string);
+    header.SetStrF(string);
+    aRequestHeaders.SetFieldL(aStringPool.StringF(HTTP::EAccept,
+            RHTTPSession::GetTable()), header);
+    CleanupStack::PopAndDestroy();
+
+    mimeType.Copy(KOma1DcfContentType);
+    string = aStringPool.OpenFStringL(mimeType);
+    CleanupClosePushL(string);
+    header.SetStrF(string);
+    aRequestHeaders.SetFieldL(aStringPool.StringF(HTTP::EAccept,
+            RHTTPSession::GetTable()), header);
+    CleanupStack::PopAndDestroy();
+
+    mimeType.Copy(KOma2DcfContentType);
+    string = aStringPool.OpenFStringL(mimeType);
+    CleanupClosePushL(string);
+    header.SetStrF(string);
+    aRequestHeaders.SetFieldL(aStringPool.StringF(HTTP::EAccept,
+            RHTTPSession::GetTable()), header);
+    CleanupStack::PopAndDestroy();
+
+    mimeType.Copy(KOma2RoContentType);
+    string = aStringPool.OpenFStringL(mimeType);
+    CleanupClosePushL(string);
+    header.SetStrF(string);
+    aRequestHeaders.SetFieldL(aStringPool.StringF(HTTP::EAccept,
+            RHTTPSession::GetTable()), header);
+    CleanupStack::PopAndDestroy();
+
+    mimeType.Copy(KOma2TriggerContentType);
+    string = aStringPool.OpenFStringL(mimeType);
+    CleanupClosePushL(string);
+    header.SetStrF(string);
+    aRequestHeaders.SetFieldL(aStringPool.StringF(HTTP::EAccept,
+            RHTTPSession::GetTable()), header);
+    CleanupStack::PopAndDestroy();
+    }
+
+
+
+
+// -----------------------------------------------------------------------------
+// COma2AgentContent::HandleEventL
+// Handle notifier events here. Not much logic, consider all events as rights
+// changes.
+// -----------------------------------------------------------------------------
+//
+void COma2AgentManager::HandleEventL(
+    MDRMEvent* /*aEvent*/)
+    {
+    RDRMRightsClient client;
+    TInt r;
+    TUint32 reason = 0;
+
+    if (client.Connect() == KErrNone && iWatchedId != NULL)
+        {
+        r = client.CheckRights(EUnknown, *iWatchedId, reason);
+        if (r == KErrNone && (iWatchedEvents & ERightsAvailable) ||
+            r != KErrNone && (iWatchedEvents & ERightsExpired))
+            {
+            iNotifier->UnRegisterEventObserverL(*this, KEventAddRemove, *iWatchedId);
+            iNotifier->UnRegisterEventObserverL(*this, KEventModify, *iWatchedId);
+            delete iWatchedId;
+            iWatchedId = NULL;
+            iWatchedEvents = TEventMask(0);
+            User::RequestComplete(iStatus, KErrNone);
+            }
+        client.Close();
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// COma2AgentManager::DisplayManagementInfoL
+// -----------------------------------------------------------------------------
+//
+void COma2AgentManager::DisplayManagementInfoL()
+    {
+    TUid KRightsManagerUid = TUid::Uid(0x101F85C7);
+    RWsSession wsSession;
+    RApaLsSession appArcSession;
+    TThreadId id;
+
+    User::LeaveIfError(wsSession.Connect());
+    CleanupClosePushL(wsSession);
+    TApaTaskList tasklist(wsSession);
+    TApaTask task = tasklist.FindApp(KRightsManagerUid);
+    if (task.Exists())
+        {
+        task.SendMessage(TUid::Uid(KUidApaMessageSwitchOpenFileValue),
+            KNullDesC8);
+        }
+    else
+        {
+        User::LeaveIfError(appArcSession.Connect());
+        appArcSession.StartDocument(_L("0"), KRightsManagerUid, id);
+        appArcSession.Close();
+        }
+    CleanupStack::PopAndDestroy();
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/agentv2/src/Oma2AgentRightsManager.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,409 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the CAF rights manager
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <caf/caf.h>
+#include <utf.h>
+#include "drmrights.h"
+#include "oma2agentrightsmanager.h"
+#include "drmrightsclient.h"
+#include "dcfrep.h"
+#include "dcfentry.h"
+
+using namespace ContentAccess;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+void DoDeleteAllRightsObjectsL( const TVirtualPathPtr& aVirtualPath )
+    {
+    RDRMRightsClient client;
+    CDcfCommon* dcf = NULL;
+    RFs fs;
+
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+    User::LeaveIfError(fs.Connect());
+    User::LeaveIfError(fs.ShareAuto());    
+    CleanupClosePushL(fs);
+    dcf = CDcfCommon::NewL(aVirtualPath.URI(), &fs);
+    CleanupStack::PushL(dcf);
+    User::LeaveIfError( dcf->OpenPart(aVirtualPath.UniqueId()));
+    User::LeaveIfError( client.DeleteDbEntry(*dcf->iContentID));
+    CleanupStack::PopAndDestroy(3); // dcf, fs, client
+    }
+
+void DoDeleteAllRightsObjects( const TVirtualPathPtr& aVirtualPath )
+    {
+    TRAP_IGNORE( DoDeleteAllRightsObjectsL( aVirtualPath ) );    
+    }
+
+void DoDeleteRightsObjectL(
+    const CRightsInfo& aRightsInfo)
+    {
+    RDRMRightsClient client;
+    TInt uniqueId;
+    HBufC8* contentId = NULL;
+    TInt n;
+
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+    n = aRightsInfo.UniqueId().Locate(0);
+    if (n == KErrNotFound)
+        {
+        contentId = CnvUtfConverter::ConvertFromUnicodeToUtf8L(
+            aRightsInfo.UniqueId());
+        CleanupStack::PushL(contentId);
+        User::LeaveIfError( client.DeleteDbEntry(*contentId) );
+        }
+    else
+        {
+        contentId = CnvUtfConverter::ConvertFromUnicodeToUtf8L(
+            aRightsInfo.UniqueId().Left(n));
+        CleanupStack::PushL(contentId);
+        TLex lex(aRightsInfo.UniqueId().Right(
+            aRightsInfo.UniqueId().Length() - n - 1));
+        User::LeaveIfError( lex.Val(uniqueId) );
+        User::LeaveIfError( client.DeleteDbEntry(*contentId, uniqueId) );
+        }
+    CleanupStack::PopAndDestroy(2); // contentId, client
+    }
+    
+void DoDeleteRightsObject(
+    const CRightsInfo& aRightsInfo)
+    {
+    TRAP_IGNORE( DoDeleteRightsObjectL( aRightsInfo ) );    
+    }
+
+
+template<class S>
+void PointerArrayResetDestroyAndClose(TAny* aPtr)
+    {
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->ResetAndDestroy();
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->Close();
+    }
+
+TBool IsValid(
+    CDRMPermission* aPermission,
+    TIntent aIntent,
+    TTime aTime)
+    {
+    TBool r = EFalse;
+    CDRMConstraint* constraint;
+    
+    constraint = aPermission->ConstraintForIntent(aIntent);
+    if (constraint != NULL && !constraint->Expired(aTime))
+        {
+        r = ETrue;
+        }
+    return r;
+    }
+
+TRightsStatus PermissionStatus(
+    CDRMPermission* aPermission)
+    {
+    TRightsStatus r = ERightsStatusNone;
+    TTime time;
+    
+    time.HomeTime();
+    if ((!(aPermission->iAvailableRights & ERightsTopLevel) ||
+        !aPermission->iTopLevel->Expired(time))
+        
+        &&
+        
+        (IsValid(aPermission, EPlay, time) ||
+        IsValid(aPermission, EView, time) ||
+        IsValid(aPermission, EPrint, time) ||
+        IsValid(aPermission, EExecute, time)))
+        {
+        r = ERightsStatusValid;
+        }
+    return r;
+    }
+
+CRightsInfo* ConvertToRightsInfoL(
+    CDRMPermission* aPermission,
+    const TDesC8& aContentId)
+    {
+    TRightsTypeMask type;
+    TPtr ptr(NULL, 0);
+    HBufC* id = NULL;
+    CRightsInfo* r = NULL;
+    
+    id = HBufC::NewLC(aContentId.Length() + 20);
+    ptr.Set(id->Des());
+    ptr.Copy(aContentId);
+    ptr.SetLength(aContentId.Length());
+    ptr.Append(0);
+    ptr.AppendNum(aPermission->iUniqueID);
+    if (aPermission->Stateful())
+        {
+        type = ERightsTypeConsumable;
+        }
+    else
+        {
+        type = ERightsTypeStateless;
+        }
+    r = CRightsInfo::NewL(KNullDesC, *id, type, PermissionStatus(aPermission));
+    CleanupStack::PopAndDestroy(); // id
+    return r;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// COma2AgentRightsManager::COma2AgentRightsManager
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+COma2AgentRightsManager::COma2AgentRightsManager()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentRightsManager::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void COma2AgentRightsManager::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// COma2AgentRightsManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+COma2AgentRightsManager* COma2AgentRightsManager::NewL()
+    {
+    COma2AgentRightsManager* self = new( ELeave ) COma2AgentRightsManager;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+COma2AgentRightsManager::~COma2AgentRightsManager()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// COma2AgentRightsManager::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void COma2AgentRightsManager::ListAllRightsL(
+    RStreamablePtrArray<CRightsInfo>& aArray) const
+    {
+    RDRMRightsClient client;
+    RPointerArray<CDRMPermission> permissions;
+    RPointerArray<HBufC8> idList;
+    TCleanupItem permCleanup(PointerArrayResetDestroyAndClose<CDRMPermission>,
+        &permissions);
+    TCleanupItem idCleanup(PointerArrayResetDestroyAndClose<HBufC8>,
+        &idList);
+    TInt i;
+    TInt j;
+
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+    User::LeaveIfError(client.ExportContentIDList(idList));
+    CleanupStack::PushL(idCleanup);
+
+    for (j = 0; j < idList.Count(); j++)
+        {
+        client.GetDBEntriesL(*idList[j], permissions);
+        CleanupStack::PushL(permCleanup);
+        for (i = 0; i < permissions.Count(); i++)
+            {
+            aArray.AppendL(ConvertToRightsInfoL(permissions[i], *idList[j]));
+            }
+        
+        CleanupStack::PopAndDestroy(1); // permCleanup
+        }
+    CleanupStack::PopAndDestroy(2); // idCleanup, client
+    }
+    
+void COma2AgentRightsManager::ListRightsL(
+    RStreamablePtrArray<CRightsInfo>& aArray,
+    const TDesC& aUri) const
+    {
+    TVirtualPathPtr ptr(aUri, KDefaultContentObject);
+    ListRightsL(aArray, ptr);
+    }
+    
+void COma2AgentRightsManager::ListRightsL(
+    RStreamablePtrArray<CRightsInfo>& aArray, 
+    TVirtualPathPtr& aVirtualPath) const
+    {
+    RPointerArray<CDRMPermission> permissions;
+    RDRMRightsClient client;
+    TCleanupItem listCleanup(PointerArrayResetDestroyAndClose<CDRMPermission>,
+        &permissions);
+    CDcfCommon* dcf = NULL;
+    CDRMPermission* permission = NULL;
+    RFs fs;
+    TInt i;
+    TInt error;
+    TUint32 reason = 0;
+
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+    User::LeaveIfError(fs.Connect());
+    User::LeaveIfError(fs.ShareAuto());    
+    CleanupClosePushL(fs);
+    dcf = CDcfCommon::NewL(aVirtualPath.URI(), &fs);
+    if (dcf == NULL)
+        {
+        User::Leave(KErrArgument);
+        }
+    CleanupStack::PushL(dcf);
+    User::LeaveIfError(dcf->OpenPart(aVirtualPath.UniqueId()));
+    
+    TRAP(error, permission = client.GetActiveRightsL(EUnknown, *dcf->iContentID, reason));
+    if (permission != NULL)
+        {
+        CleanupStack::PushL(permission);
+        aArray.AppendL(ConvertToRightsInfoL(permission, *dcf->iContentID));
+        CleanupStack::PopAndDestroy(); // permission
+        }
+    
+    TRAP(error, client.GetDBEntriesL(*dcf->iContentID, permissions));
+    CleanupStack::PushL(listCleanup);
+
+    for (i = 0; i < permissions.Count(); i++)
+        {
+        aArray.AppendL(ConvertToRightsInfoL(permissions[i], *dcf->iContentID));
+        }
+    
+    CleanupStack::PopAndDestroy(4); // listCleanup, dcf, fs, client
+    }
+    
+void COma2AgentRightsManager::ListContentL(
+    RStreamablePtrArray<CVirtualPath>& aArray,
+    CRightsInfo& aRightsInfo) const
+    {
+    RDRMRightsClient client;
+    HBufC8* contentId = NULL;
+    CDcfRep* rep = NULL;
+    CDcfEntry* entry = NULL;
+    CVirtualPath* path = NULL;
+    TInt n;
+
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+    n = aRightsInfo.UniqueId().Locate(0);
+    if (n == KErrNotFound)
+        {
+        n = aRightsInfo.UniqueId().Length();
+        }
+    contentId = CnvUtfConverter::ConvertFromUnicodeToUtf8L(
+        aRightsInfo.UniqueId().Left(n));
+    CleanupStack::PushL(contentId);
+    rep = CDcfRep::NewL();
+    CleanupStack::PushL(rep);    
+    rep->OrderListL();
+    entry = rep->NextL();
+    while (entry != NULL)
+        {
+        CleanupStack::PushL(entry);
+        path = CVirtualPath::NewL(TVirtualPathPtr(entry->FileName(),
+            KDefaultContentObject));
+        aArray.AppendL(path);
+        CleanupStack::PopAndDestroy(); // entry
+        entry = rep->NextL();
+        }
+    
+    CleanupStack::PopAndDestroy(3); // rep, contentId, client
+    }
+    
+MAgentRightsBase* COma2AgentRightsManager::GetRightsDataL(
+    const CRightsInfo& aRightsInfo) const
+    {
+    RDRMRightsClient client;
+    CDRMPermission* permission = NULL;
+    TInt uniqueId;
+    HBufC8* contentId = NULL;
+    CDRMRights* rights = NULL;
+    CDRMAsset* asset = NULL;
+    TInt n;
+
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+    rights = CDRMRights::NewL();
+    CleanupStack::PushL(rights);
+    n = aRightsInfo.UniqueId().Locate(0);
+    contentId = CnvUtfConverter::ConvertFromUnicodeToUtf8L(
+        aRightsInfo.UniqueId().Left(n));
+    CleanupStack::PushL(contentId);
+    TLex lex(aRightsInfo.UniqueId().Right(
+        aRightsInfo.UniqueId().Length() - n - 1));
+    User::LeaveIfError(lex.Val(uniqueId));
+    permission = client.GetDbEntryL(*contentId, uniqueId);
+    if (permission != NULL)
+        {
+        CleanupStack::PushL(permission);
+        asset = CDRMAsset::NewL();
+        CleanupStack::PushL(asset);
+        asset->iUid = contentId->AllocL();
+        if (permission->iParentUID)
+            {
+            asset->iParentRights = permission->iParentUID->AllocL();
+            }
+        rights->SetPermissionL(*permission);
+        rights->SetAssetL(*asset);
+        CleanupStack::PopAndDestroy(2); // asset, permission
+        }
+    CleanupStack::Pop(); // rights
+    CleanupStack::PopAndDestroy(2); // contentId, client
+    
+    return rights;
+    }
+    
+TInt COma2AgentRightsManager::DeleteRightsObject(
+    const CRightsInfo& aRightsInfo)
+    {
+    TInt error = KErrNone;
+		TRAP( error, DoDeleteRightsObject(aRightsInfo));
+		return error;
+    }
+    
+TInt COma2AgentRightsManager::DeleteAllRightsObjects(
+    const TVirtualPathPtr& aVirtualPath)
+    {
+    TInt error = KErrNone;
+		TRAP( error, DoDeleteAllRightsObjectsL(aVirtualPath));
+		return error;
+    }
+    
+TInt COma2AgentRightsManager::SetProperty(
+    TAgentProperty /*aProperty*/,
+    TInt /*aValue*/)
+    {
+    return KErrCANotSupported;
+    }
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/DRMCommonU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,39 @@
+EXPORTS
+	??0DRMCommon@@IAE@XZ @ 1 NONAME ; DRMCommon::DRMCommon(void)
+	??1DRMCommon@@UAE@XZ @ 2 NONAME ; DRMCommon::~DRMCommon(void)
+	?CheckContentRights@DRMCommon@@QAEHABVTDesC8@@K@Z @ 3 NONAME ; int DRMCommon::CheckContentRights(class TDesC8 const &, unsigned long)
+	?CheckFileRights@DRMCommon@@QAEHAAVRFile@@K@Z @ 4 NONAME ; int DRMCommon::CheckFileRights(class RFile &, unsigned long)
+	?CheckFileRights@DRMCommon@@QAEHABVTDesC16@@K@Z @ 5 NONAME ; int DRMCommon::CheckFileRights(class TDesC16 const &, unsigned long)
+	?Connect@DRMCommon@@QAEHXZ @ 6 NONAME ; int DRMCommon::Connect(void)
+	?ConstructL@DRMCommon@@IAEXXZ @ 7 NONAME ; void DRMCommon::ConstructL(void)
+	?DataTypesCount@DRMCommon@@QAEHAAH@Z @ 8 NONAME ; int DRMCommon::DataTypesCount(int &)
+	?Disconnect@DRMCommon@@QAEHXZ @ 9 NONAME ; int DRMCommon::Disconnect(void)
+	?GetActiveRights@DRMCommon@@QAEHABVTDesC8@@KAAPAVCDRMRights@@@Z @ 10 NONAME ; int DRMCommon::GetActiveRights(class TDesC8 const &, unsigned long, class CDRMRights * &)
+	?GetContentHeader@DRMCommon@@QAEHABVTDesC8@@0AAPAVHBufC8@@@Z @ 11 NONAME ; int DRMCommon::GetContentHeader(class TDesC8 const &, class TDesC8 const &, class HBufC8 * &)
+	?GetContentInfo@DRMCommon@@QAEHABVTDesC8@@AAW4TContentProtection@1@AAPAVHBufC8@@2AAI@Z @ 12 NONAME ; int DRMCommon::GetContentInfo(class TDesC8 const &, enum DRMCommon::TContentProtection &, class HBufC8 * &, class HBufC8 * &, unsigned int &)
+	?GetContentURIList@DRMCommon@@QAEHAAPAV?$RPointerArray@VHBufC8@@@@@Z @ 13 NONAME ; int DRMCommon::GetContentURIList(class RPointerArray<class HBufC8> * &)
+	?GetDetailedContentRights@DRMCommon@@QAEHABVTDesC8@@AAPAV?$RPointerArray@VCDRMRights@@@@@Z @ 14 NONAME ; int DRMCommon::GetDetailedContentRights(class TDesC8 const &, class RPointerArray<class CDRMRights> * &)
+	?GetDetailedFileRights@DRMCommon@@QAEHAAVRFile@@AAPAV?$RPointerArray@VCDRMRights@@@@@Z @ 15 NONAME ; int DRMCommon::GetDetailedFileRights(class RFile &, class RPointerArray<class CDRMRights> * &)
+	?GetDetailedFileRights@DRMCommon@@QAEHABVTDesC16@@AAPAV?$RPointerArray@VCDRMRights@@@@@Z @ 16 NONAME ; int DRMCommon::GetDetailedFileRights(class TDesC16 const &, class RPointerArray<class CDRMRights> * &)
+	?GetFileHeader@DRMCommon@@QAEHAAVRFile@@ABVTDesC8@@AAPAVHBufC8@@@Z @ 17 NONAME ; int DRMCommon::GetFileHeader(class RFile &, class TDesC8 const &, class HBufC8 * &)
+	?GetFileHeader@DRMCommon@@QAEHABV?$TBuf@$0BAA@@@ABVTDesC8@@AAPAVHBufC8@@@Z @ 18 NONAME ; int DRMCommon::GetFileHeader(class TBuf<256> const &, class TDesC8 const &, class HBufC8 * &)
+	?GetFileInfo@DRMCommon@@QAEHAAVRFile@@AAW4TContentProtection@1@AAPAVHBufC8@@2AAI@Z @ 19 NONAME ; int DRMCommon::GetFileInfo(class RFile &, enum DRMCommon::TContentProtection &, class HBufC8 * &, class HBufC8 * &, unsigned int &)
+	?GetFileInfo@DRMCommon@@QAEHABVTDesC16@@AAW4TContentProtection@1@AAPAVHBufC8@@2AAI@Z @ 20 NONAME ; int DRMCommon::GetFileInfo(class TDesC16 const &, enum DRMCommon::TContentProtection &, class HBufC8 * &, class HBufC8 * &, unsigned int &)
+	?GetSingleRightsObject@DRMCommon@@QAEHABVTDesC8@@KAAPAVCDRMRights@@@Z @ 21 NONAME ; int DRMCommon::GetSingleRightsObject(class TDesC8 const &, unsigned long, class CDRMRights * &)
+	?IsProtectedContent@DRMCommon@@QAEHABVTDesC8@@AAH@Z @ 22 NONAME ; int DRMCommon::IsProtectedContent(class TDesC8 const &, int &)
+	?IsProtectedFile@DRMCommon@@QAEHAAVRFile@@AAH@Z @ 23 NONAME ; int DRMCommon::IsProtectedFile(class RFile &, int &)
+	?IsProtectedFile@DRMCommon@@QAEHABVTDesC16@@AAH@Z @ 24 NONAME ; int DRMCommon::IsProtectedFile(class TDesC16 const &, int &)
+	?MapErrorCode@DRMCommon@@IAEHH@Z @ 25 NONAME ; int DRMCommon::MapErrorCode(int)
+	?NewL@DRMCommon@@SAPAV1@XZ @ 26 NONAME ; class DRMCommon * DRMCommon::NewL(void)
+	?RegisterDataType@DRMCommon@@QAEHABVTDataType@@@Z @ 27 NONAME ; int DRMCommon::RegisterDataType(class TDataType const &)
+	?ServerVersion@DRMCommon@@SA?AVTVersion@@XZ @ 28 NONAME ; class TVersion DRMCommon::ServerVersion(void)
+	?SetContentHeader@DRMCommon@@QAEHAAPAVHBufC8@@ABVTDesC8@@1@Z @ 29 NONAME ; int DRMCommon::SetContentHeader(class HBufC8 * &, class TDesC8 const &, class TDesC8 const &)
+	?SetFileHeader@DRMCommon@@QAEHAAVRFile@@ABVTDesC8@@1@Z @ 30 NONAME ; int DRMCommon::SetFileHeader(class RFile &, class TDesC8 const &, class TDesC8 const &)
+	?SetFileHeader@DRMCommon@@QAEHABVTDesC16@@ABVTDesC8@@1@Z @ 31 NONAME ; int DRMCommon::SetFileHeader(class TDesC16 const &, class TDesC8 const &, class TDesC8 const &)
+	?StaticDataTypesCount@DRMCommon@@QAEHAAH@Z @ 32 NONAME ; int DRMCommon::StaticDataTypesCount(int &)
+	?SupportedDRMMethods@DRMCommon@@QAEHAAHAAW4TOMALevel@1@@Z @ 33 NONAME ; int DRMCommon::SupportedDRMMethods(int &, enum DRMCommon::TOMALevel &)
+	?SupportedDataType@DRMCommon@@QAEHHAAVTDataType@@@Z @ 34 NONAME ; int DRMCommon::SupportedDataType(int, class TDataType &)
+	?UnRegisterDataType@DRMCommon@@QAEHH@Z @ 35 NONAME ; int DRMCommon::UnRegisterDataType(int)
+	?Version@DRMCommon@@SA?AVTVersion@@XZ @ 36 NONAME ; class TVersion DRMCommon::Version(void)
+	?MergeParentAndChild@DRMCommon@@QAEXPAVCDRMRights@@@Z @ 37 NONAME ; void DRMCommon::MergeParentAndChild(class CDRMRights *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/DcfRepU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,35 @@
+EXPORTS
+	??1CDcfEntry@@UAE@XZ @ 1 NONAME ; CDcfEntry::~CDcfEntry(void)
+	??1CDcfRep@@UAE@XZ @ 2 NONAME ; CDcfRep::~CDcfRep(void)
+	?Cid@CDcfEntry@@QBEABVTDesC8@@XZ @ 3 NONAME ; class TDesC8 const & CDcfEntry::Cid(void) const
+	?FileName@CDcfEntry@@QBEABVTDesC16@@XZ @ 4 NONAME ; class TDesC16 const & CDcfEntry::FileName(void) const
+	?GetFileHandleL@CDcfRep@@QAEXABVTDesC8@@AAVRFile@@AAVRFs@@@Z @ 5 NONAME ; void CDcfRep::GetFileHandleL(class TDesC8 const &, class RFile &, class RFs &)
+	?GetTtidL@CDcfRep@@QAEXAAV?$RArray@UTPair@@@@@Z @ 6 NONAME ; void CDcfRep::GetTtidL(class RArray<struct TPair> &)
+	?GroupId@CDcfEntry@@QBEABVTDesC8@@XZ @ 7 NONAME ; class TDesC8 const & CDcfEntry::GroupId(void) const
+	?NewL@CDcfEntry@@SAPAV1@XZ @ 8 NONAME ; class CDcfEntry * CDcfEntry::NewL(void)
+	?NewL@CDcfRep@@SAPAV1@XZ @ 9 NONAME ; class CDcfRep * CDcfRep::NewL(void)
+	?NextL@CDcfRep@@QAEPAVCDcfEntry@@XZ @ 10 NONAME ; class CDcfEntry * CDcfRep::NextL(void)
+	?NotifyServerIdle@CDcfRep@@QAEXAAVTRequestStatus@@@Z @ 11 NONAME ; void CDcfRep::NotifyServerIdle(class TRequestStatus &)
+	?OrderListL@CDcfRep@@QAEXABVTDesC8@@@Z @ 12 NONAME ; void CDcfRep::OrderListL(class TDesC8 const &)
+	?OrderListL@CDcfRep@@QAEXXZ @ 13 NONAME ; void CDcfRep::OrderListL(void)
+	?Position@CDcfEntry@@QBEGXZ @ 14 NONAME ; unsigned short CDcfEntry::Position(void) const
+	?RefreshDcf@CDcfRep@@QAEXAAV?$RPointerArray@VHBufC8@@@@AAVTRequestStatus@@@Z @ 15 NONAME ; void CDcfRep::RefreshDcf(class RPointerArray<class HBufC8> &, class TRequestStatus &)
+	?RefreshDcf@CDcfRep@@QAEXAAVTRequestStatus@@@Z @ 16 NONAME ; void CDcfRep::RefreshDcf(class TRequestStatus &)
+	?RemoveDcfFromDbL@CDcfRep@@QAEXABVTDesC16@@@Z @ 17 NONAME ; void CDcfRep::RemoveDcfFromDbL(class TDesC16 const &)
+	?SetCidL@CDcfEntry@@QAEXABVTDesC8@@@Z @ 18 NONAME ; void CDcfEntry::SetCidL(class TDesC8 const &)
+	?SetGroupIdL@CDcfEntry@@QAEXABVTDesC8@@@Z @ 19 NONAME ; void CDcfEntry::SetGroupIdL(class TDesC8 const &)
+	?SetLocationL@CDcfEntry@@QAEXABVTDesC16@@ABG@Z @ 20 NONAME ; void CDcfEntry::SetLocationL(class TDesC16 const &, unsigned short const &)
+	?SetTtid@CDcfRep@@QAEXAAV?$RArray@UTPair@@@@AAVTRequestStatus@@H@Z @ 21 NONAME ; void CDcfRep::SetTtid(class RArray<struct TPair> &, class TRequestStatus &, int)
+	?UpdateL@CDcfRep@@QAEXPBVCDcfEntry@@@Z @ 22 NONAME ; void CDcfRep::UpdateL(class CDcfEntry const *)
+	??0RDcfRepCli@@QAE@XZ @ 23 NONAME ; RDcfRepCli::RDcfRepCli(void)
+	??1RDcfRepCli@@UAE@XZ @ 24 NONAME ; RDcfRepCli::~RDcfRepCli(void)
+	?AddFile@RDcfRepCli@@QAEHABVTDesC16@@@Z @ 25 NONAME ; int RDcfRepCli::AddFile(class TDesC16 const &)
+	?Close@RDcfRepCli@@QAEXXZ @ 26 NONAME ; void RDcfRepCli::Close(void)
+	?Connect@RDcfRepCli@@QAEHXZ @ 27 NONAME ; int RDcfRepCli::Connect(void)
+	?NotifyServerIdle@RDcfRepCli@@QAEXAAVTRequestStatus@@@Z @ 28 NONAME ; void RDcfRepCli::NotifyServerIdle(class TRequestStatus &)
+	?ScanDcf@RDcfRepCli@@QAEXAAV?$RPointerArray@VHBufC8@@@@AAVTRequestStatus@@@Z @ 29 NONAME ; void RDcfRepCli::ScanDcf(class RPointerArray<class HBufC8> &, class TRequestStatus &)
+	?ScanDcf@RDcfRepCli@@QAEXAAVTRequestStatus@@@Z @ 30 NONAME ; void RDcfRepCli::ScanDcf(class TRequestStatus &)
+	?SetTtid@RDcfRepCli@@QAEXAAV?$RArray@UTPair@@@@AAVTRequestStatus@@@Z @ 31 NONAME ; void RDcfRepCli::SetTtid(class RArray<struct TPair> &, class TRequestStatus &)
+	?StopWatching@RDcfRepCli@@QAEXXZ @ 32 NONAME ; void RDcfRepCli::StopWatching(void)
+	?Version@RDcfRepCli@@QBE?AVTVersion@@XZ @ 33 NONAME ; class TVersion RDcfRepCli::Version(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/DrmCryptoU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,32 @@
+EXPORTS
+	?AesUnwrapL@OmaCrypto@@SAPAVHBufC8@@ABVTDesC8@@0@Z @ 1 NONAME ; class HBufC8 * OmaCrypto::AesUnwrapL(class TDesC8 const &, class TDesC8 const &)
+	?AesWrapL@OmaCrypto@@SAPAVHBufC8@@ABVTDesC8@@0@Z @ 2 NONAME ; class HBufC8 * OmaCrypto::AesWrapL(class TDesC8 const &, class TDesC8 const &)
+	?AlgorithmIdToTransportScheme@CmlaCrypto@@SA?AW4TKeyTransportScheme@@ABVTDesC8@@@Z @ 3 NONAME ; enum TKeyTransportScheme CmlaCrypto::AlgorithmIdToTransportScheme(class TDesC8 const &)
+	?Base64DecodeL@@YAPAVHBufC8@@ABVTDesC8@@@Z @ 4 NONAME ; class HBufC8 * Base64DecodeL(class TDesC8 const &)
+	?Base64EncodeL@@YAPAVHBufC8@@ABVTDesC8@@@Z @ 5 NONAME ; class HBufC8 * Base64EncodeL(class TDesC8 const &)
+	?CmlaIpDecryptL@CmlaCrypto@@SAXW4TKeyTransportScheme@@PAVMDrmKeyStorage@@ABVTDesC8@@AAVTDes8@@3@Z @ 6 NONAME ; void CmlaCrypto::CmlaIpDecryptL(enum TKeyTransportScheme, class MDrmKeyStorage *, class TDesC8 const &, class TDes8 &, class TDes8 &)
+	?CmlaIpEncryptL@CmlaCrypto@@SAPAVHBufC8@@W4TKeyTransportScheme@@PAVCRSAPublicKey@@ABVTDesC8@@2@Z @ 7 NONAME ; class HBufC8 * CmlaCrypto::CmlaIpEncryptL(enum TKeyTransportScheme, class CRSAPublicKey *, class TDesC8 const &, class TDesC8 const &)
+	?DdtExpInvL@CmlaCrypto@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 8 NONAME ; class HBufC8 * CmlaCrypto::DdtExpInvL(class TDesC8 const &)
+	?DdtExpL@CmlaCrypto@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 9 NONAME ; class HBufC8 * CmlaCrypto::DdtExpL(class TDesC8 const &)
+	?DdtPermInvL@CmlaCrypto@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 10 NONAME ; class HBufC8 * CmlaCrypto::DdtPermInvL(class TDesC8 const &)
+	?DdtPermL@CmlaCrypto@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 11 NONAME ; class HBufC8 * CmlaCrypto::DdtPermL(class TDesC8 const &)
+	?I2OSPL@OmaCrypto@@SAPAVHBufC8@@AAVRInteger@@@Z @ 12 NONAME ; class HBufC8 * OmaCrypto::I2OSPL(class RInteger &)
+	?KdfL@CmlaCrypto@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 13 NONAME ; class HBufC8 * CmlaCrypto::KdfL(class TDesC8 const &)
+	?KdfL@OmaCrypto@@SAPAVHBufC8@@ABVTDesC8@@0H@Z @ 14 NONAME ; class HBufC8 * OmaCrypto::KdfL(class TDesC8 const &, class TDesC8 const &, int)
+	?Mgf1L@OmaCrypto@@SAPAVHBufC8@@ABVTDesC8@@H@Z @ 15 NONAME ; class HBufC8 * OmaCrypto::Mgf1L(class TDesC8 const &, int)
+	?OS2IPL@OmaCrypto@@SA?AVRInteger@@ABVTDesC8@@@Z @ 16 NONAME ; class RInteger OmaCrypto::OS2IPL(class TDesC8 const &)
+	?RsaDecryptCmlaL@CmlaCrypto@@SAPAVHBufC8@@PAVMDrmKeyStorage@@ABVTDesC8@@@Z @ 17 NONAME ; class HBufC8 * CmlaCrypto::RsaDecryptCmlaL(class MDrmKeyStorage *, class TDesC8 const &)
+	?RsaDecryptL@OmaCrypto@@SAPAVHBufC8@@PAVMDrmKeyStorage@@ABVTDesC8@@@Z @ 18 NONAME ; class HBufC8 * OmaCrypto::RsaDecryptL(class MDrmKeyStorage *, class TDesC8 const &)
+	?RsaEncryptCmlaL@CmlaCrypto@@SAPAVHBufC8@@PAVCRSAPublicKey@@ABVTDesC8@@@Z @ 19 NONAME ; class HBufC8 * CmlaCrypto::RsaEncryptCmlaL(class CRSAPublicKey *, class TDesC8 const &)
+	?RsaEncryptL@OmaCrypto@@SAPAVHBufC8@@PAVCRSAPublicKey@@ABVTDesC8@@@Z @ 20 NONAME ; class HBufC8 * OmaCrypto::RsaEncryptL(class CRSAPublicKey *, class TDesC8 const &)
+	?RsaKemKwsDecryptL@OmaCrypto@@SAXPAVMDrmKeyStorage@@ABVTDesC8@@AAVTDes8@@2@Z @ 21 NONAME ; void OmaCrypto::RsaKemKwsDecryptL(class MDrmKeyStorage *, class TDesC8 const &, class TDes8 &, class TDes8 &)
+	?RsaKemKwsEncryptL@OmaCrypto@@SAPAVHBufC8@@PAVCRSAPublicKey@@ABVTDesC8@@1@Z @ 22 NONAME ; class HBufC8 * OmaCrypto::RsaKemKwsEncryptL(class CRSAPublicKey *, class TDesC8 const &, class TDesC8 const &)
+	?RsaPssSignHashL@OmaCrypto@@SAPAVHBufC8@@PAVMDrmKeyStorage@@ABVTDesC8@@@Z @ 23 NONAME ; class HBufC8 * OmaCrypto::RsaPssSignHashL(class MDrmKeyStorage *, class TDesC8 const &)
+	?RsaPssVerifyHashL@OmaCrypto@@SAHPAVCRSAPublicKey@@ABVTDesC8@@1@Z @ 24 NONAME ; int OmaCrypto::RsaPssVerifyHashL(class CRSAPublicKey *, class TDesC8 const &, class TDesC8 const &)
+	?RsaVerifyL@OmaCrypto@@SAPAVHBufC8@@PAVCRSAPublicKey@@ABVTDesC8@@@Z @ 25 NONAME ; class HBufC8 * OmaCrypto::RsaVerifyL(class CRSAPublicKey *, class TDesC8 const &)
+	?SupportedAlgorithmsL@CmlaCrypto@@SAHAAV?$RArray@VTPtrC8@@@@@Z @ 26 NONAME ; int CmlaCrypto::SupportedAlgorithmsL(class RArray<class TPtrC8> &)
+	?UnwrapL@CmlaCrypto@@SAPAVHBufC8@@ABVTDesC8@@0@Z @ 27 NONAME ; class HBufC8 * CmlaCrypto::UnwrapL(class TDesC8 const &, class TDesC8 const &)
+	?WrapL@CmlaCrypto@@SAPAVHBufC8@@ABVTDesC8@@0@Z @ 28 NONAME ; class HBufC8 * CmlaCrypto::WrapL(class TDesC8 const &, class TDesC8 const &)
+	?WriteUint32ToBlock@OmaCrypto@@KAXKAAVTDes8@@H@Z @ 29 NONAME ; void OmaCrypto::WriteUint32ToBlock(unsigned long, class TDes8 &, int)
+	?DrmAesEncryptL@DrmAesCrypto@@SAPAVHBufC8@@ABVTDesC8@@0H0@Z @ 30 NONAME ; class HBufC8 * DrmAesCrypto::DrmAesEncryptL(class TDesC8 const &, class TDesC8 const &, int, class TDesC8 const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/DrmDcfU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,15 @@
+EXPORTS
+	??1CDcfCommon@@UAE@XZ @ 1 NONAME ; CDcfCommon::~CDcfCommon(void)
+	??1COma1Dcf@@UAE@XZ @ 2 NONAME ; COma1Dcf::~COma1Dcf(void)
+	??1COma2Dcf@@UAE@XZ @ 3 NONAME ; COma2Dcf::~COma2Dcf(void)
+	?IsValidDcf@COma1Dcf@@SAHABVTDesC8@@@Z @ 4 NONAME ; int COma1Dcf::IsValidDcf(class TDesC8 const &)
+	?IsValidDcf@COma2Dcf@@SAHABVTDesC8@@@Z @ 5 NONAME ; int COma2Dcf::IsValidDcf(class TDesC8 const &)
+	?NewL@CDcfCommon@@SAPAV1@ABVRFile@@@Z @ 6 NONAME ; class CDcfCommon * CDcfCommon::NewL(class RFile const &)
+	?NewL@CDcfCommon@@SAPAV1@ABVTDesC16@@PAVRFs@@@Z @ 7 NONAME ; class CDcfCommon * CDcfCommon::NewL(class TDesC16 const &, class RFs *)
+	?NewL@COma1Dcf@@SAPAV1@ABVRFile@@@Z @ 8 NONAME ; class COma1Dcf * COma1Dcf::NewL(class RFile const &)
+	?NewL@COma1Dcf@@SAPAV1@ABVTDesC8@@@Z @ 9 NONAME ; class COma1Dcf * COma1Dcf::NewL(class TDesC8 const &)
+	?NewL@COma2Dcf@@SAPAV1@ABVRFile@@H@Z @ 10 NONAME ; class COma2Dcf * COma2Dcf::NewL(class RFile const &, int)
+	?SetRightsObjectsL@COma2Dcf@@QAEXAAV?$RPointerArray@VHBufC8@@@@@Z @ 11 NONAME ; void COma2Dcf::SetRightsObjectsL(class RPointerArray<class HBufC8> &)
+	?SetTransactionIdL@COma2Dcf@@QAEXABVTDesC8@@@Z @ 12 NONAME ; void COma2Dcf::SetTransactionIdL(class TDesC8 const &)
+	?GetHeaderL@COma1Dcf@@QAEHABVTDesC8@@AAVTPtrC8@@@Z @ 13 NONAME ; int COma1Dcf::GetHeaderL(class TDesC8 const &, class TPtrC8 &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/DrmKeyStorageU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?DrmKeyStorageNewL@@YAPAVMDrmKeyStorage@@XZ @ 1 NONAME ; class MDrmKeyStorage * DrmKeyStorageNewL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/DrmParsersU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,29 @@
+EXPORTS
+	??0COma1DcfCreator@@IAE@XZ @ 1 NONAME ; COma1DcfCreator::COma1DcfCreator(void)
+	??1CDRMMessageParser@@UAE@XZ @ 2 NONAME ; CDRMMessageParser::~CDRMMessageParser(void)
+	??1CDrmProtectedRoParser@@UAE@XZ @ 3 NONAME ; CDrmProtectedRoParser::~CDrmProtectedRoParser(void)
+	??1CDrmRightsParser@@UAE@XZ @ 4 NONAME ; CDrmRightsParser::~CDrmRightsParser(void)
+	??1COma1DcfCreator@@UAE@XZ @ 5 NONAME ; COma1DcfCreator::~COma1DcfCreator(void)
+	?ConstructL@COma1DcfCreator@@AAEXXZ @ 6 NONAME ; void COma1DcfCreator::ConstructL(void)
+	?EncryptContentL@COma1DcfCreator@@QAEXAAPAVHBufC8@@ABVTDesC8@@PAVCDRMRights@@@Z @ 7 NONAME ; void COma1DcfCreator::EncryptContentL(class HBufC8 * &, class TDesC8 const &, class CDRMRights *)
+	?EncryptContentToFileL@COma1DcfCreator@@QAEXABVTDesC8@@ABVTDesC16@@0PAVCDRMRights@@@Z @ 8 NONAME ; void COma1DcfCreator::EncryptContentToFileL(class TDesC8 const &, class TDesC16 const &, class TDesC8 const &, class CDRMRights *)
+	?EncryptFileL@COma1DcfCreator@@QAEXABVTDesC16@@0ABVTDesC8@@PAVCDRMRights@@@Z @ 9 NONAME ; void COma1DcfCreator::EncryptFileL(class TDesC16 const &, class TDesC16 const &, class TDesC8 const &, class CDRMRights *)
+	?EncryptFinalizeL@COma1DcfCreator@@QAEXXZ @ 10 NONAME ; void COma1DcfCreator::EncryptFinalizeL(void)
+	?EncryptInitializeL@COma1DcfCreator@@QAEXAAVRWriteStream@@ABVTDesC8@@PAVCDRMRights@@@Z @ 11 NONAME ; void COma1DcfCreator::EncryptInitializeL(class RWriteStream &, class TDesC8 const &, class CDRMRights *)
+	?EncryptUpdateL@COma1DcfCreator@@QAEXABVTDesC8@@@Z @ 12 NONAME ; void COma1DcfCreator::EncryptUpdateL(class TDesC8 const &)
+	?FinalizeMessageParserL@CDRMMessageParser@@QAEXXZ @ 13 NONAME ; void CDRMMessageParser::FinalizeMessageParserL(void)
+	?InitializeMessageParserL@CDRMMessageParser@@QAEXAAVRWriteStream@@@Z @ 14 NONAME ; void CDRMMessageParser::InitializeMessageParserL(class RWriteStream &)
+	?NewL@CDRMMessageParser@@SAPAV1@XZ @ 15 NONAME ; class CDRMMessageParser * CDRMMessageParser::NewL(void)
+	?NewL@CDrmProtectedRoParser@@SAPAV1@XZ @ 16 NONAME ; class CDrmProtectedRoParser * CDrmProtectedRoParser::NewL(void)
+	?NewL@CDrmRightsParser@@SAPAV1@W4TParserType@1@@Z @ 17 NONAME ; class CDrmRightsParser * CDrmRightsParser::NewL(enum CDrmRightsParser::TParserType)
+	?NewL@COma1DcfCreator@@SAPAV1@XZ @ 18 NONAME ; class COma1DcfCreator * COma1DcfCreator::NewL(void)
+	?ParseAndStoreL@CDrmProtectedRoParser@@QAEXABVTDesC8@@AAV?$RPointerArray@VCDRMRights@@@@@Z @ 19 NONAME ; void CDrmProtectedRoParser::ParseAndStoreL(class TDesC8 const &, class RPointerArray<class CDRMRights> &)
+	?ParseAndStoreL@CDrmRightsParser@@QAEXABVTDesC8@@AAV?$RPointerArray@VCDRMRights@@@@@Z @ 20 NONAME ; void CDrmRightsParser::ParseAndStoreL(class TDesC8 const &, class RPointerArray<class CDRMRights> &)
+	?ProcessMessage@CDRMMessageParser@@QAEHAAPAVHBufC8@@@Z @ 21 NONAME ; int CDRMMessageParser::ProcessMessage(class HBufC8 * &)
+	?ProcessMessageDataL@CDRMMessageParser@@QAEXABVTDesC8@@@Z @ 22 NONAME ; void CDRMMessageParser::ProcessMessageDataL(class TDesC8 const &)
+	?ProcessRightsObject@CDRMMessageParser@@QAEHABVTDesC8@@AAV?$RPointerArray@VCDRMRights@@@@@Z @ 23 NONAME ; int CDRMMessageParser::ProcessRightsObject(class TDesC8 const &, class RPointerArray<class CDRMRights> &)
+	?GetRiUrlL@CDrmProtectedRoParser@@QAEPAVHBufC8@@ABVTDesC8@@@Z @ 24 NONAME ; class HBufC8 * CDrmProtectedRoParser::GetRiUrlL(class TDesC8 const &)
+	?GetDomainIdL@CDrmProtectedRoParser@@QAEPAVHBufC8@@ABVTDesC8@@@Z @ 25 NONAME ; class HBufC8 * CDrmProtectedRoParser::GetDomainIdL(class TDesC8 const &)
+	?GetRiIdL@CDrmProtectedRoParser@@QAEPAVHBufC8@@ABVTDesC8@@@Z @ 26 NONAME ; class HBufC8 * CDrmProtectedRoParser::GetRiIdL(class TDesC8 const &)
+	?ParseL@CDrmRightsParser@@QAEXABVTDesC8@@AAV?$RPointerArray@VCDRMRights@@@@@Z @ 27 NONAME ; void CDrmRightsParser::ParseL(class TDesC8 const &, class RPointerArray<class CDRMRights> &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/DrmRightsU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,92 @@
+EXPORTS
+	??0CDRMConstraint@@IAE@XZ @ 1 NONAME ; CDRMConstraint::CDRMConstraint(void)
+	??0CDRMPermission@@IAE@XZ @ 2 NONAME ; CDRMPermission::CDRMPermission(void)
+	??0CDRMRights@@IAE@XZ @ 3 NONAME ; CDRMRights::CDRMRights(void)
+	??0CDRMRightsConstraints@@IAE@XZ @ 4 NONAME ; CDRMRightsConstraints::CDRMRightsConstraints(void)
+	??1CDRMAsset@@UAE@XZ @ 5 NONAME ; CDRMAsset::~CDRMAsset(void)
+	??1CDRMConstraint@@UAE@XZ @ 6 NONAME ; CDRMConstraint::~CDRMConstraint(void)
+	??1CDRMPermission@@UAE@XZ @ 7 NONAME ; CDRMPermission::~CDRMPermission(void)
+	??1CDRMRights@@UAE@XZ @ 8 NONAME ; CDRMRights::~CDRMRights(void)
+	??1CDRMRightsConstraints@@UAE@XZ @ 9 NONAME ; CDRMRightsConstraints::~CDRMRightsConstraints(void)
+	??4CDRMRights@@QAEAAV0@AAV0@@Z @ 10 NONAME ; class CDRMRights & CDRMRights::operator=(class CDRMRights &)
+	??4CDRMRightsConstraints@@QAEAAV0@AAV0@@Z @ 11 NONAME ; class CDRMRightsConstraints & CDRMRightsConstraints::operator=(class CDRMRightsConstraints &)
+	?Child@CDRMPermission@@QBEHXZ @ 12 NONAME ; int CDRMPermission::Child(void) const
+	?ConstraintForIntent@CDRMPermission@@QAEPAVCDRMConstraint@@W4TIntent@ContentAccess@@@Z @ 13 NONAME ; class CDRMConstraint * CDRMPermission::ConstraintForIntent(enum ContentAccess::TIntent)
+	?ConstructL@CDRMRights@@IAEXXZ @ 14 NONAME ; void CDRMRights::ConstructL(void)
+	?ConstructL@CDRMRightsConstraints@@IAEXXZ @ 15 NONAME ; void CDRMRightsConstraints::ConstructL(void)
+	?Consume@CDRMConstraint@@QAEXABVTTime@@@Z @ 16 NONAME ; void CDRMConstraint::Consume(class TTime const &)
+	?ConsumeRights@CDRMPermission@@QAEXW4TIntent@ContentAccess@@ABVTTime@@@Z @ 17 NONAME ; void CDRMPermission::ConsumeRights(enum ContentAccess::TIntent, class TTime const &)
+	?DuplicateL@CDRMAsset@@QAEXAAV1@@Z @ 18 NONAME ; void CDRMAsset::DuplicateL(class CDRMAsset &)
+	?DuplicateL@CDRMConstraint@@QAEXABV1@@Z @ 19 NONAME ; void CDRMConstraint::DuplicateL(class CDRMConstraint const &)
+	?DuplicateL@CDRMPermission@@QAEXABV1@@Z @ 20 NONAME ; void CDRMPermission::DuplicateL(class CDRMPermission const &)
+	?Expired@CDRMConstraint@@QBEHABVTTime@@@Z @ 21 NONAME ; int CDRMConstraint::Expired(class TTime const &) const
+	?ExportL@CDRMPermission@@QBEPAVHBufC8@@XZ @ 22 NONAME ; class HBufC8 * CDRMPermission::ExportL(void) const
+	?ExternalizeL@CDRMAsset@@QAEXAAVRWriteStream@@@Z @ 23 NONAME ; void CDRMAsset::ExternalizeL(class RWriteStream &)
+	?ExternalizeL@CDRMConstraint@@QBEXAAVRWriteStream@@@Z @ 24 NONAME ; void CDRMConstraint::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CDRMPermission@@QBEXAAVRWriteStream@@@Z @ 25 NONAME ; void CDRMPermission::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CDRMRights@@UBEXAAVRWriteStream@@@Z @ 26 NONAME ; void CDRMRights::ExternalizeL(class RWriteStream &) const
+	?FullRights@CDRMRightsConstraints@@QAEHXZ @ 27 NONAME ; int CDRMRightsConstraints::FullRights(void)
+	?GetAddTime@CDRMRights@@QAEXAAVTTime@@@Z @ 28 NONAME ; void CDRMRights::GetAddTime(class TTime &)
+	?GetAsset@CDRMRights@@QAEAAVCDRMAsset@@XZ @ 29 NONAME ; class CDRMAsset & CDRMRights::GetAsset(void)
+	?GetConstraint@CDRMRightsConstraints@@QAEAAVCDRMConstraint@@XZ @ 30 NONAME ; class CDRMConstraint & CDRMRightsConstraints::GetConstraint(void)
+	?GetConstraintInfo@CDRMRightsConstraints@@QAEHAAK0@Z @ 31 NONAME ; int CDRMRightsConstraints::GetConstraintInfo(unsigned long &, unsigned long &)
+	?GetContentURI@CDRMRights@@QAEHAAPAVHBufC8@@@Z @ 32 NONAME ; int CDRMRights::GetContentURI(class HBufC8 * &)
+	?GetCounters@CDRMRightsConstraints@@QAEHAAK0@Z @ 33 NONAME ; int CDRMRightsConstraints::GetCounters(unsigned long &, unsigned long &)
+	?GetDisplayRight@CDRMRights@@QAEHAAPAVCDRMRightsConstraints@@@Z @ 34 NONAME ; int CDRMRights::GetDisplayRight(class CDRMRightsConstraints * &)
+	?GetEndTime@CDRMRightsConstraints@@QAEHAAVTTime@@@Z @ 35 NONAME ; int CDRMRightsConstraints::GetEndTime(class TTime &)
+	?GetExecuteRight@CDRMRights@@QAEHAAPAVCDRMRightsConstraints@@@Z @ 36 NONAME ; int CDRMRights::GetExecuteRight(class CDRMRightsConstraints * &)
+	?GetExpirationDetails@CDRMRights@@QAEHKAAVTTime@@AAH@Z @ 37 NONAME ; int CDRMRights::GetExpirationDetails(unsigned long, class TTime &, int &)
+	?GetExpirationDetails@CDRMRightsConstraints@@QAEHAAVTTime@@AAH@Z @ 38 NONAME ; int CDRMRightsConstraints::GetExpirationDetails(class TTime &, int &)
+	?GetInterval@CDRMRightsConstraints@@QAEHAAVTTimeIntervalSeconds@@@Z @ 39 NONAME ; int CDRMRightsConstraints::GetInterval(class TTimeIntervalSeconds &)
+	?GetIntervalStart@CDRMRightsConstraints@@QAEHAAVTTime@@@Z @ 40 NONAME ; int CDRMRightsConstraints::GetIntervalStart(class TTime &)
+	?GetLocalID@CDRMRights@@QAEKXZ @ 41 NONAME ; unsigned long CDRMRights::GetLocalID(void)
+	?GetPermission@CDRMRights@@QAEAAVCDRMPermission@@XZ @ 42 NONAME ; class CDRMPermission & CDRMRights::GetPermission(void)
+	?GetPlayRight@CDRMRights@@QAEHAAPAVCDRMRightsConstraints@@@Z @ 43 NONAME ; int CDRMRights::GetPlayRight(class CDRMRightsConstraints * &)
+	?GetPrintRight@CDRMRights@@QAEHAAPAVCDRMRightsConstraints@@@Z @ 44 NONAME ; int CDRMRights::GetPrintRight(class CDRMRightsConstraints * &)
+	?GetRightsInfo@CDRMRights@@QAEHKAAW4TRestriction@1@AAW4TExpiration@1@AAK@Z @ 45 NONAME ; int CDRMRights::GetRightsInfo(unsigned long, enum CDRMRights::TRestriction &, enum CDRMRights::TExpiration &, unsigned long &)
+	?GetStartTime@CDRMRightsConstraints@@QAEHAAVTTime@@@Z @ 46 NONAME ; int CDRMRightsConstraints::GetStartTime(class TTime &)
+	?ImportL@CDRMPermission@@QAEXABVTDesC8@@@Z @ 47 NONAME ; void CDRMPermission::ImportL(class TDesC8 const &)
+	?InternalizeL@CDRMAsset@@QAEXAAVRReadStream@@@Z @ 48 NONAME ; void CDRMAsset::InternalizeL(class RReadStream &)
+	?InternalizeL@CDRMConstraint@@QAEXAAVRReadStream@@@Z @ 49 NONAME ; void CDRMConstraint::InternalizeL(class RReadStream &)
+	?InternalizeL@CDRMPermission@@QAEXAAVRReadStream@@@Z @ 50 NONAME ; void CDRMPermission::InternalizeL(class RReadStream &)
+	?InternalizeL@CDRMRights@@UAEXAAVRReadStream@@@Z @ 51 NONAME ; void CDRMRights::InternalizeL(class RReadStream &)
+	?IsPreview@CDRMRightsConstraints@@QAEHXZ @ 52 NONAME ; int CDRMRightsConstraints::IsPreview(void)
+	?Merge@CDRMConstraint@@QAEXABV1@@Z @ 53 NONAME ; void CDRMConstraint::Merge(class CDRMConstraint const &)
+	?NewL@CDRMAsset@@SAPAV1@XZ @ 54 NONAME ; class CDRMAsset * CDRMAsset::NewL(void)
+	?NewL@CDRMConstraint@@SAPAV1@XZ @ 55 NONAME ; class CDRMConstraint * CDRMConstraint::NewL(void)
+	?NewL@CDRMPermission@@SAPAV1@XZ @ 56 NONAME ; class CDRMPermission * CDRMPermission::NewL(void)
+	?NewL@CDRMRights@@SAPAV1@XZ @ 57 NONAME ; class CDRMRights * CDRMRights::NewL(void)
+	?NewL@CDRMRightsConstraints@@SAPAV1@XZ @ 58 NONAME ; class CDRMRightsConstraints * CDRMRightsConstraints::NewL(void)
+	?NewLC@CDRMAsset@@SAPAV1@XZ @ 59 NONAME ; class CDRMAsset * CDRMAsset::NewLC(void)
+	?NewLC@CDRMConstraint@@SAPAV1@XZ @ 60 NONAME ; class CDRMConstraint * CDRMConstraint::NewLC(void)
+	?NewLC@CDRMPermission@@SAPAV1@XZ @ 61 NONAME ; class CDRMPermission * CDRMPermission::NewLC(void)
+	?SetAddTime@CDRMRights@@QAEXVTTime@@@Z @ 62 NONAME ; void CDRMRights::SetAddTime(class TTime)
+	?SetAssetL@CDRMRights@@QAEXAAVCDRMAsset@@@Z @ 63 NONAME ; void CDRMRights::SetAssetL(class CDRMAsset &)
+	?SetConstraint@CDRMRightsConstraints@@QAEXAAVCDRMConstraint@@@Z @ 64 NONAME ; void CDRMRightsConstraints::SetConstraint(class CDRMConstraint &)
+	?SetContentURI@CDRMRights@@QAEHPAVHBufC8@@@Z @ 65 NONAME ; int CDRMRights::SetContentURI(class HBufC8 *)
+	?SetContentURIAndLocalID@CDRMRights@@QAEHPAVHBufC8@@K@Z @ 66 NONAME ; int CDRMRights::SetContentURIAndLocalID(class HBufC8 *, unsigned long)
+	?SetCounters@CDRMRightsConstraints@@QAEHKK@Z @ 67 NONAME ; int CDRMRightsConstraints::SetCounters(unsigned long, unsigned long)
+	?SetDisplayRight@CDRMRights@@QAEHPAVCDRMRightsConstraints@@@Z @ 68 NONAME ; int CDRMRights::SetDisplayRight(class CDRMRightsConstraints *)
+	?SetEndTime@CDRMRightsConstraints@@QAEHVTTime@@@Z @ 69 NONAME ; int CDRMRightsConstraints::SetEndTime(class TTime)
+	?SetExecuteRight@CDRMRights@@QAEHPAVCDRMRightsConstraints@@@Z @ 70 NONAME ; int CDRMRights::SetExecuteRight(class CDRMRightsConstraints *)
+	?SetInterval@CDRMRightsConstraints@@QAEHVTTimeIntervalSeconds@@@Z @ 71 NONAME ; int CDRMRightsConstraints::SetInterval(class TTimeIntervalSeconds)
+	?SetIntervalStart@CDRMRightsConstraints@@QAEHVTTime@@@Z @ 72 NONAME ; int CDRMRightsConstraints::SetIntervalStart(class TTime)
+	?SetLocalID@CDRMRights@@QAEHK@Z @ 73 NONAME ; int CDRMRights::SetLocalID(unsigned long)
+	?SetPermissionL@CDRMRights@@QAEXAAVCDRMPermission@@@Z @ 74 NONAME ; void CDRMRights::SetPermissionL(class CDRMPermission &)
+	?SetPlayRight@CDRMRights@@QAEHPAVCDRMRightsConstraints@@@Z @ 75 NONAME ; int CDRMRights::SetPlayRight(class CDRMRightsConstraints *)
+	?SetPrintRight@CDRMRights@@QAEHPAVCDRMRightsConstraints@@@Z @ 76 NONAME ; int CDRMRights::SetPrintRight(class CDRMRightsConstraints *)
+	?SetStartTime@CDRMRightsConstraints@@QAEHVTTime@@@Z @ 77 NONAME ; int CDRMRightsConstraints::SetStartTime(class TTime)
+	?Size@CDRMConstraint@@QBEHXZ @ 78 NONAME ; int CDRMConstraint::Size(void) const
+	?Size@CDRMPermission@@QBEHXZ @ 79 NONAME ; int CDRMPermission::Size(void) const
+	?Stateful@CDRMConstraint@@QBEHXZ @ 80 NONAME ; int CDRMConstraint::Stateful(void) const
+	?Stateful@CDRMPermission@@QBEHXZ @ 81 NONAME ; int CDRMPermission::Stateful(void) const
+	?TopLevelConstraint@CDRMPermission@@QAEPAVCDRMConstraint@@XZ @ 82 NONAME ; class CDRMConstraint * CDRMPermission::TopLevelConstraint(void)
+	?Expired@CDRMPermission@@QAEHABVTTime@@@Z @ 83 NONAME ; int CDRMPermission::Expired(class TTime const &)
+	?Valid@CDRMConstraint@@QBEHABVTTime@@ABV?$RPointerArray@VHBufC8@@@@AAK@Z @ 84 NONAME ; int CDRMConstraint::Valid(class TTime const &, class RPointerArray<class HBufC8> const &, unsigned long &) const
+	?Valid@CDRMPermission@@QBEHABVTTime@@ABV?$RPointerArray@VHBufC8@@@@AAKW4TRightsType@@@Z @ 85 NONAME ; int CDRMPermission::Valid(class TTime const &, class RPointerArray<class HBufC8> const &, unsigned long &, enum TRightsType) const
+	?GetAccumulated@CDRMRightsConstraints@@QAEHAAVTTimeIntervalSeconds@@@Z @ 86 NONAME ; int CDRMRightsConstraints::GetAccumulated(class TTimeIntervalSeconds &)
+	?GetTimedCounters@CDRMRightsConstraints@@QAEHAAK0@Z @ 87 NONAME ; int CDRMRightsConstraints::GetTimedCounters(unsigned long &, unsigned long &)
+	?Merge@CDRMPermission@@QAEXABV1@@Z @ 88 NONAME ; void CDRMPermission::Merge(class CDRMPermission const &)
+	?Merge@CDRMRights@@QAEXABV1@@Z @ 89 NONAME ; void CDRMRights::Merge(class CDRMRights const &)
+	?SoftwareConstrained@CDRMPermission@@QBEHXZ @ 90 NONAME ; int CDRMPermission::SoftwareConstrained(void) const
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/DrmServerInterfacesU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,202 @@
+EXPORTS
+	??0CDRMDomainContext@@IAE@ABVTTime@@H@Z @ 1 NONAME ; CDRMDomainContext::CDRMDomainContext(class TTime const &, int)
+	??0MDRMEvent@@QAE@ABK@Z @ 2 NONAME ; MDRMEvent::MDRMEvent(unsigned long const &)
+	??0RDRMClockClient@@QAE@XZ @ 3 NONAME ; RDRMClockClient::RDRMClockClient(void)
+	??0RDRMRightsClient@@QAE@XZ @ 4 NONAME ; RDRMRightsClient::RDRMRightsClient(void)
+	??0RRoapStorageClient@Roap@@QAE@XZ @ 5 NONAME ; Roap::RRoapStorageClient::RRoapStorageClient(void)
+	??1CDRMDomainContext@@UAE@XZ @ 6 NONAME ; CDRMDomainContext::~CDRMDomainContext(void)
+	??1CDRMEventAddRemove@@UAE@XZ @ 7 NONAME ; CDRMEventAddRemove::~CDRMEventAddRemove(void)
+	??1CDRMEventModify@@UAE@XZ @ 8 NONAME ; CDRMEventModify::~CDRMEventModify(void)
+	??1CDRMEventTimeChange@@UAE@XZ @ 9 NONAME ; CDRMEventTimeChange::~CDRMEventTimeChange(void)
+	??1CDRMNotifier@@UAE@XZ @ 10 NONAME ; CDRMNotifier::~CDRMNotifier(void)
+	??1CDRMRIContext@@UAE@XZ @ 11 NONAME ; CDRMRIContext::~CDRMRIContext(void)
+	??1MDRMEvent@@UAE@XZ @ 12 NONAME ; MDRMEvent::~MDRMEvent(void)
+	??1RDRMClockClient@@UAE@XZ @ 13 NONAME ; RDRMClockClient::~RDRMClockClient(void)
+	??1RDRMRightsClient@@UAE@XZ @ 14 NONAME ; RDRMRightsClient::~RDRMRightsClient(void)
+	??1RRoapStorageClient@Roap@@UAE@XZ @ 15 NONAME ; Roap::RRoapStorageClient::~RRoapStorageClient(void)
+	?AddDomainContextL@RRoapStorageClient@Roap@@QAEXABVCDRMDomainContext@@ABV?$RPointerArray@VHBufC8@@@@1AAW4TKeyTransportScheme@@@Z @ 16 NONAME ; void Roap::RRoapStorageClient::AddDomainContextL(class CDRMDomainContext const &, class RPointerArray<class HBufC8> const &, class RPointerArray<class HBufC8> const &, enum TKeyTransportScheme &)
+	?AddDomainRO@RDRMRightsClient@@QAEHABVTDesC8@@0@Z @ 17 NONAME ; int RDRMRightsClient::AddDomainRO(class TDesC8 const &, class TDesC8 const &)
+	?AddProtectedRecord@RDRMRightsClient@@QAEHABVTDesC8@@HABVCDRMPermission@@0AAK@Z @ 18 NONAME ; int RDRMRightsClient::AddProtectedRecord(class TDesC8 const &, int, class CDRMPermission const &, class TDesC8 const &, unsigned long &)
+	?AddRIContextL@RRoapStorageClient@Roap@@QAEXABVCDRMRIContext@@@Z @ 19 NONAME ; void Roap::RRoapStorageClient::AddRIContextL(class CDRMRIContext const &)
+	?AddRecord@RDRMRightsClient@@QAEHABVTDesC8@@ABVCDRMPermission@@0AAK@Z @ 20 NONAME ; int RDRMRightsClient::AddRecord(class TDesC8 const &, class CDRMPermission const &, class TDesC8 const &, unsigned long &)
+	?AddToCache@RDRMRightsClient@@QAEHABVTDesC8@@@Z @ 21 NONAME ; int RDRMRightsClient::AddToCache(class TDesC8 const &)
+	?AddToCache@RDRMRightsClient@@QAEHABVTDesC8@@ABVTTime@@@Z @ 22 NONAME ; int RDRMRightsClient::AddToCache(class TDesC8 const &, class TTime const &)
+	?Algorithms@CDRMRIContext@@QBEABV?$RPointerArray@VHBufC8@@@@XZ @ 23 NONAME ; class RPointerArray<class HBufC8> const & CDRMRIContext::Algorithms(void) const
+	?CalculatePadding@RDRMRightsClient@@QAEHABVTDesC8@@@Z @ 24 NONAME ; int RDRMRightsClient::CalculatePadding(class TDesC8 const &)
+	?Cancel@RDRMRightsClient@@QAEXXZ @ 25 NONAME ; void RDRMRightsClient::Cancel(void)
+	?CertificateChain@CDRMRIContext@@QBEABV?$RPointerArray@VHBufC8@@@@XZ @ 26 NONAME ; class RPointerArray<class HBufC8> const & CDRMRIContext::CertificateChain(void) const
+	?CheckConsume@RDRMRightsClient@@QAEHHABVTDesC8@@@Z @ 27 NONAME ; int RDRMRightsClient::CheckConsume(int, class TDesC8 const &)
+	?CheckRights@RDRMRightsClient@@QAEHHABVTDesC8@@AAK@Z @ 28 NONAME ; int RDRMRightsClient::CheckRights(int, class TDesC8 const &, unsigned long &)
+	?Close@RDRMClockClient@@QAEXXZ @ 29 NONAME ; void RDRMClockClient::Close(void)
+	?Close@RDRMRightsClient@@QAEXXZ @ 30 NONAME ; void RDRMRightsClient::Close(void)
+	?Connect@RDRMClockClient@@QAEHXZ @ 31 NONAME ; int RDRMClockClient::Connect(void)
+	?Connect@RDRMRightsClient@@QAEHXZ @ 32 NONAME ; int RDRMRightsClient::Connect(void)
+	?Connect@RRoapStorageClient@Roap@@QAEHXZ @ 33 NONAME ; int Roap::RRoapStorageClient::Connect(void)
+	?Consume@RDRMRightsClient@@QAEHHABVTDesC8@@@Z @ 34 NONAME ; int RDRMRightsClient::Consume(int, class TDesC8 const &)
+	?Count@RDRMRightsClient@@QAEHXZ @ 35 NONAME ; int RDRMRightsClient::Count(void)
+	?DecodeRightsIssuerField@RDRMRightsClient@@QAEHABVTDesC8@@AAPAVHBufC8@@@Z @ 36 NONAME ; int RDRMRightsClient::DecodeRightsIssuerField(class TDesC8 const &, class HBufC8 * &)
+	?Decrypt@RDRMRightsClient@@QAEHABVTDesC8@@AAVTPtr8@@H@Z @ 37 NONAME ; int RDRMRightsClient::Decrypt(class TDesC8 const &, class TPtr8 &, int)
+	?DeleteAll@RDRMRightsClient@@QAEHXZ @ 38 NONAME ; int RDRMRightsClient::DeleteAll(void)
+	?DeleteAllL@RRoapStorageClient@Roap@@QAEXXZ @ 39 NONAME ; void Roap::RRoapStorageClient::DeleteAllL(void)
+	?DeleteDbEntry@RDRMRightsClient@@QAEHABVTDesC8@@@Z @ 40 NONAME ; int RDRMRightsClient::DeleteDbEntry(class TDesC8 const &)
+	?DeleteDbEntry@RDRMRightsClient@@QAEHABVTDesC8@@ABK@Z @ 41 NONAME ; int RDRMRightsClient::DeleteDbEntry(class TDesC8 const &, unsigned long const &)
+	?DeleteDomainContextL@RRoapStorageClient@Roap@@QAEXABVTDesC8@@@Z @ 42 NONAME ; void Roap::RRoapStorageClient::DeleteDomainContextL(class TDesC8 const &)
+	?DeleteDomainRO@RDRMRightsClient@@QAEHABVTDesC8@@@Z @ 43 NONAME ; int RDRMRightsClient::DeleteDomainRO(class TDesC8 const &)
+	?DeleteExpiredContextsL@RRoapStorageClient@Roap@@QAEXABVTTime@@@Z @ 44 NONAME ; void Roap::RRoapStorageClient::DeleteExpiredContextsL(class TTime const &)
+	?DeleteExpiredDomainsL@RRoapStorageClient@Roap@@QAEXABVTTime@@@Z @ 45 NONAME ; void Roap::RRoapStorageClient::DeleteExpiredDomainsL(class TTime const &)
+	?DeleteExpiredPermissions@RDRMRightsClient@@QAEXAAVTRequestStatus@@@Z @ 46 NONAME ; void RDRMRightsClient::DeleteExpiredPermissions(class TRequestStatus &)
+	?DeleteExpiredRIsL@RRoapStorageClient@Roap@@QAEXABVTTime@@@Z @ 47 NONAME ; void Roap::RRoapStorageClient::DeleteExpiredRIsL(class TTime const &)
+	?DeleteRiContextL@RRoapStorageClient@Roap@@QAEXABVTDesC8@@@Z @ 48 NONAME ; void Roap::RRoapStorageClient::DeleteRiContextL(class TDesC8 const &)
+	?DeviceCertCached@CDRMRIContext@@QBEEXZ @ 49 NONAME ; unsigned char CDRMRIContext::DeviceCertCached(void) const
+	?DomainGeneration@CDRMDomainContext@@QBEHXZ @ 50 NONAME ; int CDRMDomainContext::DomainGeneration(void) const
+	?DomainID@CDRMDomainContext@@QBE?BVTPtrC8@@XZ @ 51 NONAME ; class TPtrC8 const CDRMDomainContext::DomainID(void) const
+	?DomainKeyL@CDRMDomainContext@@QBEPAVHBufC8@@H@Z @ 52 NONAME ; class HBufC8 * CDRMDomainContext::DomainKeyL(int) const
+	?DomainKeys@CDRMDomainContext@@QBEABV?$RPointerArray@VHBufC8@@@@XZ @ 53 NONAME ; class RPointerArray<class HBufC8> const & CDRMDomainContext::DomainKeys(void) const
+	?EncodeRightsIssuerField@RDRMRightsClient@@QAEHABVTDesC8@@AAPAVHBufC8@@@Z @ 54 NONAME ; int RDRMRightsClient::EncodeRightsIssuerField(class TDesC8 const &, class HBufC8 * &)
+	?Encrypt@RDRMRightsClient@@QAEHABVTDesC8@@AAVTPtr8@@H@Z @ 55 NONAME ; int RDRMRightsClient::Encrypt(class TDesC8 const &, class TPtr8 &, int)
+	?ExpiryTime@CDRMDomainContext@@QBE?BVTTime@@XZ @ 56 NONAME ; class TTime const CDRMDomainContext::ExpiryTime(void) const
+	?ExpiryTime@CDRMRIContext@@QBE?BVTTime@@XZ @ 57 NONAME ; class TTime const CDRMRIContext::ExpiryTime(void) const
+	?ExportContentIDList@RDRMRightsClient@@QAEHAAV?$RPointerArray@VHBufC8@@@@@Z @ 58 NONAME ; int RDRMRightsClient::ExportContentIDList(class RPointerArray<class HBufC8> &)
+	?ExportContentIDList@RDRMRightsClient@@QAEHAAVTDes16@@@Z @ 59 NONAME ; int RDRMRightsClient::ExportContentIDList(class TDes16 &)
+	?ExportL@CDRMDomainContext@@QBEPAVHBufC8@@XZ @ 60 NONAME ; class HBufC8 * CDRMDomainContext::ExportL(void) const
+	?ExportL@CDRMRIContext@@QBEPAVHBufC8@@XZ @ 61 NONAME ; class HBufC8 * CDRMRIContext::ExportL(void) const
+	?ExportOrphanedContentIdList@RDRMRightsClient@@QAEHAAV?$RPointerArray@VHBufC8@@@@@Z @ 62 NONAME ; int RDRMRightsClient::ExportOrphanedContentIdList(class RPointerArray<class HBufC8> &)
+	?ExportOrphanedContentIdList@RDRMRightsClient@@QAEHAAVTDes16@@@Z @ 63 NONAME ; int RDRMRightsClient::ExportOrphanedContentIdList(class TDes16 &)
+	?ExternalizeL@CDRMDomainContext@@QBEXAAVRWriteStream@@@Z @ 64 NONAME ; void CDRMDomainContext::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CDRMEventAddRemove@@UAEXAAVRWriteStream@@@Z @ 65 NONAME ; void CDRMEventAddRemove::ExternalizeL(class RWriteStream &)
+	?ExternalizeL@CDRMEventModify@@UAEXAAVRWriteStream@@@Z @ 66 NONAME ; void CDRMEventModify::ExternalizeL(class RWriteStream &)
+	?ExternalizeL@CDRMEventTimeChange@@UAEXAAVRWriteStream@@@Z @ 67 NONAME ; void CDRMEventTimeChange::ExternalizeL(class RWriteStream &)
+	?ExternalizeL@CDRMRIContext@@QBEXAAVRWriteStream@@@Z @ 68 NONAME ; void CDRMRIContext::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@MDRMEvent@@UAEXAAVRWriteStream@@@Z @ 69 NONAME ; void MDRMEvent::ExternalizeL(class RWriteStream &)
+	?ForwardLockURI@RDRMRightsClient@@QAEHAAPAVHBufC8@@@Z @ 70 NONAME ; int RDRMRightsClient::ForwardLockURI(class HBufC8 * &)
+	?GetActiveRightsL@RDRMRightsClient@@QAEPAVCDRMPermission@@HABVTDesC8@@AAK@Z @ 71 NONAME ; class CDRMPermission * RDRMRightsClient::GetActiveRightsL(int, class TDesC8 const &, unsigned long &)
+	?GetAuthenticationSeed@RDRMRightsClient@@QAEHABVTDesC8@@AAVTDes8@@@Z @ 72 NONAME ; int RDRMRightsClient::GetAuthenticationSeed(class TDesC8 const &, class TDes8 &)
+	?GetContentIDL@CDRMEventAddRemove@@UBEPAVHBufC8@@XZ @ 73 NONAME ; class HBufC8 * CDRMEventAddRemove::GetContentIDL(void) const
+	?GetContentIDL@CDRMEventModify@@UBEPAVHBufC8@@XZ @ 74 NONAME ; class HBufC8 * CDRMEventModify::GetContentIDL(void) const
+	?GetDBEntriesL@RDRMRightsClient@@QAEXABVTDesC8@@AAV?$RPointerArray@VCDRMPermission@@@@@Z @ 75 NONAME ; void RDRMRightsClient::GetDBEntriesL(class TDesC8 const &, class RPointerArray<class CDRMPermission> &)
+	?GetDbEntryL@RDRMRightsClient@@QAEPAVCDRMPermission@@ABVTDesC8@@ABK@Z @ 76 NONAME ; class CDRMPermission * RDRMRightsClient::GetDbEntryL(class TDesC8 const &, unsigned long const &)
+	?GetDecryptionKey@RDRMRightsClient@@QAEHHABVTDesC8@@AAVTDes8@@@Z @ 77 NONAME ; int RDRMRightsClient::GetDecryptionKey(int, class TDesC8 const &, class TDes8 &)
+	?GetDeviceCertificateChainL@RRoapStorageClient@Roap@@QAEHAAV?$RPointerArray@VHBufC8@@@@@Z @ 78 NONAME ; int Roap::RRoapStorageClient::GetDeviceCertificateChainL(class RPointerArray<class HBufC8> &)
+	?GetDevicePublicKeyDerL@RRoapStorageClient@Roap@@QAEHAAPAVHBufC8@@@Z @ 79 NONAME ; int Roap::RRoapStorageClient::GetDevicePublicKeyDerL(class HBufC8 * &)
+	?GetDevicePublicKeyHashL@RRoapStorageClient@Roap@@QAEHAAVTDes8@@@Z @ 80 NONAME ; int Roap::RRoapStorageClient::GetDevicePublicKeyHashL(class TDes8 &)
+	?GetDevicePublicKeyL@RRoapStorageClient@Roap@@QAEHAAPAVCRSAPublicKey@@@Z @ 81 NONAME ; int Roap::RRoapStorageClient::GetDevicePublicKeyL(class CRSAPublicKey * &)
+	?GetDomainContextL@RRoapStorageClient@Roap@@QAEPAVCDRMDomainContext@@ABVTDesC8@@@Z @ 82 NONAME ; class CDRMDomainContext * Roap::RRoapStorageClient::GetDomainContextL(class TDesC8 const &)
+	?GetDomainROL@RDRMRightsClient@@QAEPAVHBufC8@@ABVTDesC8@@@Z @ 83 NONAME ; class HBufC8 * RDRMRightsClient::GetDomainROL(class TDesC8 const &)
+	?GetDomainRosForCidL@RDRMRightsClient@@QAEXABVTDesC8@@AAV?$RPointerArray@VHBufC8@@@@@Z @ 84 NONAME ; void RDRMRightsClient::GetDomainRosForCidL(class TDesC8 const &, class RPointerArray<class HBufC8> &)
+	?GetEstimatedArrival@RDRMRightsClient@@QAEHABVTDesC8@@AAVTTimeIntervalSeconds@@@Z @ 85 NONAME ; int RDRMRightsClient::GetEstimatedArrival(class TDesC8 const &, class TTimeIntervalSeconds &)
+	?GetEventType@MDRMEvent@@QBEXAAK@Z @ 86 NONAME ; void MDRMEvent::GetEventType(unsigned long &) const
+	?GetName@RDRMRightsClient@@QAEHABVTDesC8@@AAPAVHBufC16@@@Z @ 87 NONAME ; int RDRMRightsClient::GetName(class TDesC8 const &, class HBufC16 * &)
+	?GetNewSecurityLevel@CDRMEventTimeChange@@QBE?AW4ESecurityLevel@DRMClock@@XZ @ 88 NONAME ; enum DRMClock::ESecurityLevel CDRMEventTimeChange::GetNewSecurityLevel(void) const
+	?GetNewTime@CDRMEventTimeChange@@QBEABVTTime@@XZ @ 89 NONAME ; class TTime const & CDRMEventTimeChange::GetNewTime(void) const
+	?GetNewTimeZone@CDRMEventTimeChange@@QBEHXZ @ 90 NONAME ; int CDRMEventTimeChange::GetNewTimeZone(void) const
+	?GetOldSecurityLevel@CDRMEventTimeChange@@QBE?AW4ESecurityLevel@DRMClock@@XZ @ 91 NONAME ; enum DRMClock::ESecurityLevel CDRMEventTimeChange::GetOldSecurityLevel(void) const
+	?GetOldTime@CDRMEventTimeChange@@QBEABVTTime@@XZ @ 92 NONAME ; class TTime const & CDRMEventTimeChange::GetOldTime(void) const
+	?GetOldTimeZone@CDRMEventTimeChange@@QBEHXZ @ 93 NONAME ; int CDRMEventTimeChange::GetOldTimeZone(void) const
+	?GetRIContextL@RRoapStorageClient@Roap@@QAEPAVCDRMRIContext@@ABVTDesC8@@@Z @ 94 NONAME ; class CDRMRIContext * Roap::RRoapStorageClient::GetRIContextL(class TDesC8 const &)
+	?GetRandomDataL@RDRMRightsClient@@QBEXAAVTDes8@@@Z @ 95 NONAME ; void RDRMRightsClient::GetRandomDataL(class TDes8 &) const
+	?GetRootCertificateL@RRoapStorageClient@Roap@@QBEPAVHBufC8@@ABVTDesC16@@@Z @ 96 NONAME ; class HBufC8 * Roap::RRoapStorageClient::GetRootCertificateL(class TDesC16 const &) const
+	?GetSecureTime@RDRMClockClient@@QBEHAAVTTime@@AAHAAW4ESecurityLevel@DRMClock@@@Z @ 97 NONAME ; int RDRMClockClient::GetSecureTime(class TTime &, int &, enum DRMClock::ESecurityLevel &) const
+	?GetSupportedIndividualsL@RDRMRightsClient@@QBEHAAV?$RPointerArray@VHBufC8@@@@@Z @ 98 NONAME ; int RDRMRightsClient::GetSupportedIndividualsL(class RPointerArray<class HBufC8> &) const
+	?GetTrustedRootsL@RRoapStorageClient@Roap@@QBEXAAV?$RPointerArray@VHBufC8@@@@@Z @ 99 NONAME ; void Roap::RRoapStorageClient::GetTrustedRootsL(class RPointerArray<class HBufC8> &) const
+	?GetUdtData@RDRMRightsClient@@QAEHAAVTDes8@@@Z @ 100 NONAME ; int RDRMRightsClient::GetUdtData(class TDes8 &)
+	?HashChained@CDRMDomainContext@@QBEHXZ @ 101 NONAME ; int CDRMDomainContext::HashChained(void) const
+	?ImportL@CDRMDomainContext@@QAEXABVTDesC8@@@Z @ 102 NONAME ; void CDRMDomainContext::ImportL(class TDesC8 const &)
+	?ImportL@CDRMRIContext@@QAEXABVTDesC8@@@Z @ 103 NONAME ; void CDRMRIContext::ImportL(class TDesC8 const &)
+	?InitOrphanedContentIdList@RDRMRightsClient@@QAEXHAAVTRequestStatus@@@Z @ 104 NONAME ; void RDRMRightsClient::InitOrphanedContentIdList(int, class TRequestStatus &)
+	?InitializeGroupKey@RDRMRightsClient@@QAEHABVTDesC8@@0W4TEncryptionMethod@ContentAccess@@@Z @ 105 NONAME ; int RDRMRightsClient::InitializeGroupKey(class TDesC8 const &, class TDesC8 const &, enum ContentAccess::TEncryptionMethod)
+	?InitializeKey@RDRMRightsClient@@QAEHABVTDesC8@@@Z @ 106 NONAME ; int RDRMRightsClient::InitializeKey(class TDesC8 const &)
+	?InitiateUdt@RDRMRightsClient@@QAEHABVTDesC8@@@Z @ 107 NONAME ; int RDRMRightsClient::InitiateUdt(class TDesC8 const &)
+	?InternalizeL@CDRMDomainContext@@QAEXAAVRReadStream@@@Z @ 108 NONAME ; void CDRMDomainContext::InternalizeL(class RReadStream &)
+	?InternalizeL@CDRMEventAddRemove@@UAEXAAVRReadStream@@@Z @ 109 NONAME ; void CDRMEventAddRemove::InternalizeL(class RReadStream &)
+	?InternalizeL@CDRMEventModify@@UAEXAAVRReadStream@@@Z @ 110 NONAME ; void CDRMEventModify::InternalizeL(class RReadStream &)
+	?InternalizeL@CDRMEventTimeChange@@UAEXAAVRReadStream@@@Z @ 111 NONAME ; void CDRMEventTimeChange::InternalizeL(class RReadStream &)
+	?InternalizeL@CDRMRIContext@@QAEXAAVRReadStream@@@Z @ 112 NONAME ; void CDRMRIContext::InternalizeL(class RReadStream &)
+	?InternalizeL@MDRMEvent@@UAEXAAVRReadStream@@@Z @ 113 NONAME ; void MDRMEvent::InternalizeL(class RReadStream &)
+	?IsInCache@RDRMRightsClient@@QAEHABVTDesC8@@AAH@Z @ 114 NONAME ; int RDRMRightsClient::IsInCache(class TDesC8 const &, int &)
+	?IsInCache@RDRMRightsClient@@QAEHABVTDesC8@@ABVTTime@@AAH@Z @ 115 NONAME ; int RDRMRightsClient::IsInCache(class TDesC8 const &, class TTime const &, int &)
+	?NewL@CDRMDomainContext@@SAPAV1@ABVTDesC8@@ABVTTime@@HABV?$RPointerArray@VHBufC8@@@@00@Z @ 116 NONAME ; class CDRMDomainContext * CDRMDomainContext::NewL(class TDesC8 const &, class TTime const &, int, class RPointerArray<class HBufC8> const &, class TDesC8 const &, class TDesC8 const &)
+	?NewL@CDRMDomainContext@@SAPAV1@XZ @ 117 NONAME ; class CDRMDomainContext * CDRMDomainContext::NewL(void)
+	?NewL@CDRMEventAddRemove@@SAPAV1@W4TAddRemoveEventStatus@@@Z @ 118 NONAME ; class CDRMEventAddRemove * CDRMEventAddRemove::NewL(enum TAddRemoveEventStatus)
+	?NewL@CDRMEventModify@@SAPAV1@XZ @ 119 NONAME ; class CDRMEventModify * CDRMEventModify::NewL(void)
+	?NewL@CDRMEventTimeChange@@SAPAV1@XZ @ 120 NONAME ; class CDRMEventTimeChange * CDRMEventTimeChange::NewL(void)
+	?NewL@CDRMNotifier@@SAPAV1@XZ @ 121 NONAME ; class CDRMNotifier * CDRMNotifier::NewL(void)
+	?NewL@CDRMRIContext@@SAPAV1@ABVTDesC8@@00ABV?$RPointerArray@VHBufC8@@@@10ABVTTime@@11E0E@Z @ 122 NONAME ; class CDRMRIContext * CDRMRIContext::NewL(class TDesC8 const &, class TDesC8 const &, class TDesC8 const &, class RPointerArray<class HBufC8> const &, class RPointerArray<class HBufC8> const &, class TDesC8 const &, class TTime const &, class RPointerArray<class HBufC8> const &, class RPointerArray<class HBufC8> const &, unsigned char, class TDesC8 const &, unsigned char)
+	?NewL@CDRMRIContext@@SAPAV1@XZ @ 123 NONAME ; class CDRMRIContext * CDRMRIContext::NewL(void)
+	?NewLC@CDRMDomainContext@@SAPAV1@ABVTDesC8@@ABVTTime@@HABV?$RPointerArray@VHBufC8@@@@00@Z @ 124 NONAME ; class CDRMDomainContext * CDRMDomainContext::NewLC(class TDesC8 const &, class TTime const &, int, class RPointerArray<class HBufC8> const &, class TDesC8 const &, class TDesC8 const &)
+	?NewLC@CDRMDomainContext@@SAPAV1@XZ @ 125 NONAME ; class CDRMDomainContext * CDRMDomainContext::NewLC(void)
+	?NewLC@CDRMEventAddRemove@@SAPAV1@W4TAddRemoveEventStatus@@@Z @ 126 NONAME ; class CDRMEventAddRemove * CDRMEventAddRemove::NewLC(enum TAddRemoveEventStatus)
+	?NewLC@CDRMEventModify@@SAPAV1@XZ @ 127 NONAME ; class CDRMEventModify * CDRMEventModify::NewLC(void)
+	?NewLC@CDRMEventTimeChange@@SAPAV1@XZ @ 128 NONAME ; class CDRMEventTimeChange * CDRMEventTimeChange::NewLC(void)
+	?NewLC@CDRMNotifier@@SAPAV1@XZ @ 129 NONAME ; class CDRMNotifier * CDRMNotifier::NewLC(void)
+	?NewLC@CDRMRIContext@@SAPAV1@ABVTDesC8@@00ABV?$RPointerArray@VHBufC8@@@@10ABVTTime@@11E0E@Z @ 130 NONAME ; class CDRMRIContext * CDRMRIContext::NewLC(class TDesC8 const &, class TDesC8 const &, class TDesC8 const &, class RPointerArray<class HBufC8> const &, class RPointerArray<class HBufC8> const &, class TDesC8 const &, class TTime const &, class RPointerArray<class HBufC8> const &, class RPointerArray<class HBufC8> const &, unsigned char, class TDesC8 const &, unsigned char)
+	?NewLC@CDRMRIContext@@SAPAV1@XZ @ 131 NONAME ; class CDRMRIContext * CDRMRIContext::NewLC(void)
+	?OCSPResponse@CDRMRIContext@@QBEABV?$RPointerArray@VHBufC8@@@@XZ @ 132 NONAME ; class RPointerArray<class HBufC8> const & CDRMRIContext::OCSPResponse(void) const
+	?RIID@CDRMRIContext@@QBEABVTDesC8@@XZ @ 133 NONAME ; class TDesC8 const & CDRMRIContext::RIID(void) const
+	?RIURLs@CDRMRIContext@@QBEABV?$RPointerArray@VHBufC8@@@@XZ @ 134 NONAME ; class RPointerArray<class HBufC8> const & CDRMRIContext::RIURLs(void) const
+	?RegisterEventObserverL@CDRMNotifier@@QAEXAAVMDRMEventObserver@@ABK@Z @ 135 NONAME ; void CDRMNotifier::RegisterEventObserverL(class MDRMEventObserver &, unsigned long const &)
+	?RegisterEventObserverL@CDRMNotifier@@QAEXAAVMDRMEventObserver@@ABKABVTDesC8@@@Z @ 136 NONAME ; void CDRMNotifier::RegisterEventObserverL(class MDRMEventObserver &, unsigned long const &, class TDesC8 const &)
+	?RightsIssuerID@CDRMDomainContext@@QBEABVTDesC8@@XZ @ 137 NONAME ; class TDesC8 const & CDRMDomainContext::RightsIssuerID(void) const
+	?RightsIssuerURL@CDRMDomainContext@@QBEABVTDesC8@@XZ @ 138 NONAME ; class TDesC8 const & CDRMDomainContext::RightsIssuerURL(void) const
+	?RightsIssuerURL@CDRMRIContext@@QBEABVTDesC8@@XZ @ 139 NONAME ; class TDesC8 const & CDRMRIContext::RightsIssuerURL(void) const
+	?RsaSignL@RRoapStorageClient@Roap@@QAEHABVTDesC8@@AAPAVHBufC8@@@Z @ 140 NONAME ; int Roap::RRoapStorageClient::RsaSignL(class TDesC8 const &, class HBufC8 * &)
+	?SelectTrustedRootL@RRoapStorageClient@Roap@@QBEHABV?$RPointerArray@VHBufC8@@@@AAVTDes8@@@Z @ 141 NONAME ; int Roap::RRoapStorageClient::SelectTrustedRootL(class RPointerArray<class HBufC8> const &, class TDes8 &) const
+	?SelectTrustedRootL@RRoapStorageClient@Roap@@QBEHABVTDesC8@@@Z @ 142 NONAME ; int Roap::RRoapStorageClient::SelectTrustedRootL(class TDesC8 const &) const
+	?SelectedDeviceRoot@CDRMRIContext@@QBEABVTDesC8@@XZ @ 143 NONAME ; class TDesC8 const & CDRMRIContext::SelectedDeviceRoot(void) const
+	?SendEventL@CDRMNotifier@@QAEXAAVMDRMEvent@@AAVTRequestStatus@@@Z @ 144 NONAME ; void CDRMNotifier::SendEventL(class MDRMEvent &, class TRequestStatus &)
+	?SetAlgorithmsL@CDRMRIContext@@QAEXABV?$RPointerArray@VHBufC8@@@@@Z @ 145 NONAME ; void CDRMRIContext::SetAlgorithmsL(class RPointerArray<class HBufC8> const &)
+	?SetAuthenticationSeed@RDRMRightsClient@@QAEHABVTDesC8@@0@Z @ 146 NONAME ; int RDRMRightsClient::SetAuthenticationSeed(class TDesC8 const &, class TDesC8 const &)
+	?SetCertificateChainL@CDRMRIContext@@QAEXABV?$RPointerArray@VHBufC8@@@@@Z @ 147 NONAME ; void CDRMRIContext::SetCertificateChainL(class RPointerArray<class HBufC8> const &)
+	?SetContentIDL@CDRMEventAddRemove@@UAEXABVTDesC8@@@Z @ 148 NONAME ; void CDRMEventAddRemove::SetContentIDL(class TDesC8 const &)
+	?SetContentIDL@CDRMEventModify@@QAEXABVTDesC8@@@Z @ 149 NONAME ; void CDRMEventModify::SetContentIDL(class TDesC8 const &)
+	?SetDeviceCertCached@CDRMRIContext@@QAEXAAE@Z @ 150 NONAME ; void CDRMRIContext::SetDeviceCertCached(unsigned char &)
+	?SetDomainIDL@CDRMDomainContext@@QAEXABVTDesC8@@@Z @ 151 NONAME ; void CDRMDomainContext::SetDomainIDL(class TDesC8 const &)
+	?SetDomainKeysL@CDRMDomainContext@@QAEXABV?$RPointerArray@VHBufC8@@@@@Z @ 152 NONAME ; void CDRMDomainContext::SetDomainKeysL(class RPointerArray<class HBufC8> const &)
+	?SetEstimatedArrival@RDRMRightsClient@@QAEHABVTDesC8@@VTTimeIntervalSeconds@@@Z @ 153 NONAME ; int RDRMRightsClient::SetEstimatedArrival(class TDesC8 const &, class TTimeIntervalSeconds)
+	?SetExpiryTimeL@CDRMDomainContext@@QAEXABVTTime@@@Z @ 154 NONAME ; void CDRMDomainContext::SetExpiryTimeL(class TTime const &)
+	?SetExpiryTimeL@CDRMRIContext@@QAEXABVTTime@@@Z @ 155 NONAME ; void CDRMRIContext::SetExpiryTimeL(class TTime const &)
+	?SetHashChainedL@CDRMDomainContext@@QAEXABH@Z @ 156 NONAME ; void CDRMDomainContext::SetHashChainedL(int const &)
+	?SetName@RDRMRightsClient@@QAEHABVTDesC8@@ABVTDesC16@@@Z @ 157 NONAME ; int RDRMRightsClient::SetName(class TDesC8 const &, class TDesC16 const &)
+	?SetNewSecurityLevel@CDRMEventTimeChange@@QAEXW4ESecurityLevel@DRMClock@@@Z @ 158 NONAME ; void CDRMEventTimeChange::SetNewSecurityLevel(enum DRMClock::ESecurityLevel)
+	?SetNewTime@CDRMEventTimeChange@@QAEXABVTTime@@@Z @ 159 NONAME ; void CDRMEventTimeChange::SetNewTime(class TTime const &)
+	?SetNewTimeZone@CDRMEventTimeChange@@QAEXH@Z @ 160 NONAME ; void CDRMEventTimeChange::SetNewTimeZone(int)
+	?SetOCSPResponseL@CDRMRIContext@@QAEXABV?$RPointerArray@VHBufC8@@@@@Z @ 161 NONAME ; void CDRMRIContext::SetOCSPResponseL(class RPointerArray<class HBufC8> const &)
+	?SetOldSecurityLevel@CDRMEventTimeChange@@QAEXW4ESecurityLevel@DRMClock@@@Z @ 162 NONAME ; void CDRMEventTimeChange::SetOldSecurityLevel(enum DRMClock::ESecurityLevel)
+	?SetOldTime@CDRMEventTimeChange@@QAEXABVTTime@@@Z @ 163 NONAME ; void CDRMEventTimeChange::SetOldTime(class TTime const &)
+	?SetOldTimeZone@CDRMEventTimeChange@@QAEXH@Z @ 164 NONAME ; void CDRMEventTimeChange::SetOldTimeZone(int)
+	?SetRIIDL@CDRMRIContext@@QAEXABVTDesC8@@@Z @ 165 NONAME ; void CDRMRIContext::SetRIIDL(class TDesC8 const &)
+	?SetRIURLsL@CDRMRIContext@@QAEXABV?$RPointerArray@VHBufC8@@@@@Z @ 166 NONAME ; void CDRMRIContext::SetRIURLsL(class RPointerArray<class HBufC8> const &)
+	?SetRightsIssuerIDL@CDRMDomainContext@@QAEXABVTDesC8@@@Z @ 167 NONAME ; void CDRMDomainContext::SetRightsIssuerIDL(class TDesC8 const &)
+	?SetRightsIssuerURLL@CDRMDomainContext@@QAEXABVTDesC8@@@Z @ 168 NONAME ; void CDRMDomainContext::SetRightsIssuerURLL(class TDesC8 const &)
+	?SetRightsIssuerURLL@CDRMRIContext@@QAEXABVTDesC8@@@Z @ 169 NONAME ; void CDRMRIContext::SetRightsIssuerURLL(class TDesC8 const &)
+	?SetSelectedDeviceRoot@CDRMRIContext@@QAEXABVTDesC8@@@Z @ 170 NONAME ; void CDRMRIContext::SetSelectedDeviceRoot(class TDesC8 const &)
+	?SetUniqueID@CDRMEventModify@@QAEXK@Z @ 171 NONAME ; void CDRMEventModify::SetUniqueID(unsigned long)
+	?SetVersionL@CDRMRIContext@@QAEXABVTDesC8@@@Z @ 172 NONAME ; void CDRMRIContext::SetVersionL(class TDesC8 const &)
+	?SignL@RRoapStorageClient@Roap@@QAEHABVTDesC8@@AAPAVHBufC8@@@Z @ 173 NONAME ; int Roap::RRoapStorageClient::SignL(class TDesC8 const &, class HBufC8 * &)
+	?Size@CDRMDomainContext@@QBEHXZ @ 174 NONAME ; int CDRMDomainContext::Size(void) const
+	?Size@CDRMRIContext@@QBEHXZ @ 175 NONAME ; int CDRMRIContext::Size(void) const
+	?StartServer@RDRMRightsClient@@SAHXZ @ 176 NONAME ; int RDRMRightsClient::StartServer(void)
+	?Status@CDRMEventAddRemove@@UBE?AW4TAddRemoveEventStatus@@XZ @ 177 NONAME ; enum TAddRemoveEventStatus CDRMEventAddRemove::Status(void) const
+	?StopWatching@RDRMRightsClient@@QBEXXZ @ 178 NONAME ; void RDRMRightsClient::StopWatching(void) const
+	?UnRegisterEventObserverL@CDRMNotifier@@QAEXAAVMDRMEventObserver@@ABK@Z @ 179 NONAME ; void CDRMNotifier::UnRegisterEventObserverL(class MDRMEventObserver &, unsigned long const &)
+	?UnRegisterEventObserverL@CDRMNotifier@@QAEXAAVMDRMEventObserver@@ABKABVTDesC8@@@Z @ 180 NONAME ; void CDRMNotifier::UnRegisterEventObserverL(class MDRMEventObserver &, unsigned long const &, class TDesC8 const &)
+	?UniqueID@CDRMEventModify@@QBEKXZ @ 181 NONAME ; unsigned long CDRMEventModify::UniqueID(void) const
+	?UnwrapMacAndRek@RDRMRightsClient@@QBEHABVTDesC8@@W4TKeyTransportScheme@@00@Z @ 182 NONAME ; int RDRMRightsClient::UnwrapMacAndRek(class TDesC8 const &, enum TKeyTransportScheme, class TDesC8 const &, class TDesC8 const &) const
+	?UpdateSecureTime@RDRMClockClient@@QAEHABVTTime@@ABH@Z @ 183 NONAME ; int RDRMClockClient::UpdateSecureTime(class TTime const &, int const &)
+	?VerifyL@RRoapStorageClient@Roap@@QAEHABVTDesC8@@0ABV?$RPointerArray@VHBufC8@@@@@Z @ 184 NONAME ; int Roap::RRoapStorageClient::VerifyL(class TDesC8 const &, class TDesC8 const &, class RPointerArray<class HBufC8> const &)
+	?VerifyMacL@RDRMRightsClient@@QBEHABVTDesC8@@0@Z @ 185 NONAME ; int RDRMRightsClient::VerifyMacL(class TDesC8 const &, class TDesC8 const &) const
+	?Version@CDRMRIContext@@QBEABVTDesC8@@XZ @ 186 NONAME ; class TDesC8 const & CDRMRIContext::Version(void) const
+	?WhiteListURLExistsL@CDRMRIContext@@QBEHABVTDesC8@@@Z @ 187 NONAME ; int CDRMRIContext::WhiteListURLExistsL(class TDesC8 const &) const
+	?WhiteListURLExistsL@RRoapStorageClient@Roap@@QAEHABVTDesC8@@AAH@Z @ 188  NONAME ; int Roap::RRoapStorageClient::WhiteListURLExistsL(class TDesC8 const &, int &)
+	?DeleteMeteringDataL@RDRMRightsClient@@QAEHABVTDesC8@@@Z @ 189 NONAME ; int RDRMRightsClient::DeleteMeteringDataL(class TDesC8 const &)
+	?DeleteMeteringDataL@RRoapStorageClient@Roap@@QAEXABVTDesC8@@@Z @ 190 NONAME ; void Roap::RRoapStorageClient::DeleteMeteringDataL(class TDesC8 const &)
+	?GetMeteringDataL@RDRMRightsClient@@QAEPAVHBufC8@@ABVTDesC8@@@Z @ 191 NONAME ; class HBufC8 * RDRMRightsClient::GetMeteringDataL(class TDesC8 const &)
+	?GetMeteringDataL@RRoapStorageClient@Roap@@QAEPAVHBufC8@@AAVTDesC8@@AAVTDes8@@1AAPAV3@@Z @ 192 NONAME ; class HBufC8 * Roap::RRoapStorageClient::GetMeteringDataL(class TDesC8 &, class TDes8 &, class TDes8 &, class HBufC8 * &)
+	?IsMeteringAllowed@CDRMRIContext@@QBEEXZ @ 193 NONAME ; unsigned char CDRMRIContext::IsMeteringAllowed(void) const
+	?SetMeteringStatus@CDRMRIContext@@QAEXH@Z @ 194 NONAME ; void CDRMRIContext::SetMeteringStatus(int)
+	?GetAllRIContextsL@RRoapStorageClient@Roap@@QAEXAAV?$RPointerArray@VCDRMRIContext@@@@@Z @ 195 NONAME ; void Roap::RRoapStorageClient::GetAllRIContextsL(class RPointerArray<class CDRMRIContext> &)
+	?UpdateRIContextL@RRoapStorageClient@Roap@@QAEXABVCDRMRIContext@@@Z @ 196 NONAME ; void Roap::RRoapStorageClient::UpdateRIContextL(class CDRMRIContext const &)
+	?RIAlias@CDRMRIContext@@QBEABVTDesC8@@XZ @ 197 NONAME ; class TDesC8 const & CDRMRIContext::RIAlias(void) const
+	?GetOcspResponderIdL@RRoapStorageClient@Roap@@QAEPAVHBufC8@@ABVTDesC8@@@Z @ 198 NONAME ; class HBufC8 * Roap::RRoapStorageClient::GetOcspResponderIdL(class TDesC8 const &)
+	?UpdateDrmTimeL@RRoapStorageClient@Roap@@QAEHABV?$RPointerArray@VHBufC8@@@@0ABVTDesC8@@@Z @ 199 NONAME ; int Roap::RRoapStorageClient::UpdateDrmTimeL(class RPointerArray<class HBufC8> const &, class RPointerArray<class HBufC8> const &, class TDesC8 const &)
+	?VerifyOcspResponsesL@RRoapStorageClient@Roap@@QAEHABV?$RPointerArray@VHBufC8@@@@ABVTDesC8@@0@Z @ 200 NONAME ; int Roap::RRoapStorageClient::VerifyOcspResponsesL(class RPointerArray<class HBufC8> const &, class TDesC8 const &, class RPointerArray<class HBufC8> const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/DrmServiceAPIu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,8 @@
+EXPORTS
+	?GetDevicePublicKeyDerL@CDrmServiceApi@DRM@@QAEXAAPAVHBufC8@@@Z @ 1 NONAME ; void DRM::CDrmServiceApi::GetDevicePublicKeyDerL(class HBufC8 * &)
+	?GetSecureTime@CDrmServiceApi@DRM@@QBEHAAVTTime@@AAHAAW4ESecurityLevel@DRMClock@@@Z @ 2 NONAME ; int DRM::CDrmServiceApi::GetSecureTime(class TTime &, int &, enum DRMClock::ESecurityLevel &) const
+	?NewL@CDrmServiceApi@DRM@@SAPAV12@XZ @ 3 NONAME ; class DRM::CDrmServiceApi * DRM::CDrmServiceApi::NewL(void)
+	?NewLC@CDrmServiceApi@DRM@@SAPAV12@XZ @ 4 NONAME ; class DRM::CDrmServiceApi * DRM::CDrmServiceApi::NewLC(void)
+	?SignL@CDrmServiceApi@DRM@@QAEXABVTDesC8@@AAPAVHBufC8@@@Z @ 5 NONAME ; void DRM::CDrmServiceApi::SignL(class TDesC8 const &, class HBufC8 * &)
+	?UpdateSecureTime@CDrmServiceApi@DRM@@QAEHABVTTime@@ABH@Z @ 6 NONAME ; int DRM::CDrmServiceApi::UpdateSecureTime(class TTime const &, int const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/DrmStdKeyStorageU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewL@CDrmStdKeyStorage@@SAPAV1@VRLibrary@@@Z @ 1 NONAME ; class CDrmStdKeyStorage * CDrmStdKeyStorage::NewL(class RLibrary)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/OMADRM2AgentU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/ROAPHandlerU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,22 @@
+EXPORTS
+	??1CRoapEng@Roap@@UAE@XZ @ 1 NONAME ; Roap::CRoapEng::~CRoapEng(void)
+	??1CRoapEngBase@Roap@@UAE@XZ @ 2 NONAME ; Roap::CRoapEngBase::~CRoapEngBase(void)
+	??1CRoapTrigger@Roap@@UAE@XZ @ 3 NONAME ; Roap::CRoapTrigger::~CRoapTrigger(void)
+	?AcceptL@CRoapEngBase@Roap@@QAEXPAVMRoapObserver@2@PAVTRequestStatus@@@Z @ 4 NONAME ; void Roap::CRoapEngBase::AcceptL(class Roap::MRoapObserver *, class TRequestStatus *)
+	?DoCleanup@CRoapEngBase@Roap@@QAEHXZ @ 5 NONAME ; int Roap::CRoapEngBase::DoCleanup(void)
+	?HandleRoReponseL@CRoapEngBase@Roap@@QAEXABVTDesC8@@AAV?$RPointerArray@VCDRMRights@@@@@Z @ 6 NONAME ; void Roap::CRoapEngBase::HandleRoReponseL(class TDesC8 const &, class RPointerArray<class CDRMRights> &)
+	?MessageAsXmlL@CRoapTrigger@Roap@@UAEPAVHBufC8@@XZ @ 7 NONAME ; class HBufC8 * Roap::CRoapTrigger::MessageAsXmlL(void)
+	?NewL@CRoapEng@Roap@@SAPAV12@XZ @ 8 NONAME ; class Roap::CRoapEng * Roap::CRoapEng::NewL(void)
+	?NewL@CRoapTrigger@Roap@@SAPAV12@ABW4TTriggerType@2@ABVTDesC8@@11ABV?$RPointerArray@VHBufC8@@@@2@Z @ 9 NONAME ; class Roap::CRoapTrigger * Roap::CRoapTrigger::NewL(enum Roap::TTriggerType const &, class TDesC8 const &, class TDesC8 const &, class TDesC8 const &, class RPointerArray<class HBufC8> const &, class RPointerArray<class HBufC8> const &)
+	?NewL@CRoapTrigger@Roap@@SAPAV12@XZ @ 10 NONAME ; class Roap::CRoapTrigger * Roap::CRoapTrigger::NewL(void)
+	?Reject@CRoapEngBase@Roap@@QAEXXZ @ 11 NONAME ; void Roap::CRoapEngBase::Reject(void)
+	?SetTriggerL@CRoapEngBase@Roap@@QAEXABVTDesC8@@PBVCAiwGenericParamList@@AAW4TTriggerType@2@AAW4TRiContextStatus@2@AAW4TDomainOperation@2@AAV?$RPointerArray@VHBufC8@@@@@Z @ 12 NONAME ; void Roap::CRoapEngBase::SetTriggerL(class TDesC8 const &, class CAiwGenericParamList const *, enum Roap::TTriggerType &, enum Roap::TRiContextStatus &, enum Roap::TDomainOperation &, class RPointerArray<class HBufC8> &)
+	?ValidTrigger@CRoapTrigger@Roap@@QAEHXZ @ 13 NONAME ; int Roap::CRoapTrigger::ValidTrigger(void)
+	?Trigger@CRoapEngBase@Roap@@QBEABVCRoapTrigger@2@XZ @ 14 NONAME ; class Roap::CRoapTrigger const & Roap::CRoapEngBase::Trigger(void) const
+	??1CRoapSyncWrapper@@UAE@XZ @ 15 NONAME ; CRoapSyncWrapper::~CRoapSyncWrapper(void)
+	?HandleTriggerL@CRoapSyncWrapper@@QAEXABVTDesC8@@@Z @ 16 NONAME ; void CRoapSyncWrapper::HandleTriggerL(class TDesC8 const &)
+	?NewL@CRoapSyncWrapper@@SAPAV1@XZ @ 17 NONAME ; class CRoapSyncWrapper * CRoapSyncWrapper::NewL(void)
+	?HandleTriggerSilentlyL@CRoapSyncWrapper@@QAEHABVTDesC8@@@Z @ 18 NONAME ; int CRoapSyncWrapper::HandleTriggerSilentlyL(class TDesC8 const &)
+	?GetErrorUrlL@CRoapSyncWrapper@@QAEPAVHBufC8@@HAAH@Z @ 19 NONAME ; class HBufC8 * CRoapSyncWrapper::GetErrorUrlL(int, int &)
+	?GetPostResponseUrlL@CRoapSyncWrapper@@QAEPAVHBufC8@@XZ @ 20 NONAME ; class HBufC8 * CRoapSyncWrapper::GetPostResponseUrlL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/bwinscw/RightsServerU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?WinsMain@@YAHXZ @ 1 NONAME ; int WinsMain(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcf/inc/Oma2DcfPartInfo.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,140 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef OMA2DCFPARTINFO_H
+#define OMA2DCFPARTINFO_H
+
+//  INCLUDES
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+NONSHARABLE_CLASS(COma2DcfPartInfo): public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static COma2DcfPartInfo* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~COma2DcfPartInfo();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function(?type ?arg1);
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function(?type ?arg1);
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+        
+    private: // New functions 
+    	    
+    protected:
+
+        /**
+        * C++ default constructor.
+        */
+        COma2DcfPartInfo();
+
+    public:     // Data
+
+        HBufC8* iContentId;
+        HBufC8* iMimeType;
+        TUint32 iType;
+        TInt iSize;
+        TInt iOffset;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+#endif      // OMA2DCF_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcf/src/DcfCommon.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,174 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <f32file.h>
+#include "DcfCommon.h"
+#include "Oma1Dcf.h"
+#include "Oma2Dcf.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDcfCommon::CDcfCommon
+// 
+// -----------------------------------------------------------------------------
+//
+CDcfCommon::CDcfCommon():
+    iData(NULL),
+    iMimeType(NULL),
+    iContentID(NULL),
+    iRightsIssuerURL(NULL),
+    iPadding(-1),
+    iEncryptionMethod(EMethodAES_128_CBC),
+    iTitle(NULL),
+    iDescription(NULL),
+    iIconUri(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCommon::ConstructL
+// 
+// -----------------------------------------------------------------------------
+//
+void CDcfCommon::ConstructL(
+    const RFile& aFile)
+    {
+    iFile.Duplicate(aFile);
+    iFile.Size(iLength);
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCommon::NewL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDcfCommon* CDcfCommon::NewL(
+    const RFile& aFile)
+    {
+    TBuf8<256> buffer;
+    TInt pos = 0;
+    CDcfCommon* self = NULL;
+
+    User::LeaveIfError(aFile.Seek(ESeekStart, pos));
+    User::LeaveIfError(aFile.Read(buffer));
+    if (COma1Dcf::IsValidDcf(buffer))
+        {
+        self = COma1Dcf::NewL(aFile);
+        }
+    else if (COma2Dcf::IsValidDcf(buffer))
+        {
+        self = COma2Dcf::NewL(aFile);
+        }
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCommon::NewL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDcfCommon* CDcfCommon::NewL(
+    const TDesC& aFileName,
+    RFs* aFs)
+    {
+    RFs* fs = NULL;
+    RFile file;
+    TInt r = KErrNone;
+    CDcfCommon* self = NULL;
+    
+    if (aFs == NULL)
+        {
+        fs = new RFs();
+        User::LeaveIfNull(fs);
+        CleanupStack::PushL(fs);
+        User::LeaveIfError(fs->Connect());
+        }
+    else 
+        {
+        fs = aFs;
+        }
+    
+	r = file.Open(*fs, aFileName, EFileStream | EFileRead | EFileShareReadersOrWriters );
+    if( r == KErrInUse )
+        {
+    	r = file.Open(*fs, aFileName, EFileStream | EFileRead | EFileShareAny);        
+
+	    if (r == KErrInUse)
+	        {
+    	    r = file.Open(*fs, aFileName, EFileStream | EFileRead |
+    	        EFileShareReadersOnly);
+	        }
+        }
+	if(r == KErrNone)
+	    {
+	    CleanupClosePushL(file);
+	    self = NewL(file);
+	    CleanupStack::PopAndDestroy();
+	    }
+
+    if (aFs == NULL)
+        {
+        fs->Close();
+        CleanupStack::PopAndDestroy();
+        }
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCommon::NewL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDcfCommon::~CDcfCommon()
+    {
+    delete iData;
+    delete iMimeType;
+    delete iContentID;
+    delete iRightsIssuerURL;
+    delete iTitle;
+    delete iDescription;
+    delete iIconUri;
+    if (iFile.SubSessionHandle() != KNullHandle)
+        {
+        iFile.Close();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfCommon::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CDcfCommon::CheckUniqueId(const TDesC& aUniqueId)
+	{
+	if (aUniqueId.Compare(KDefaultContentObject) == 0)
+	    {
+	    return 0;
+	    }
+	else
+	    {
+	    return KErrNotFound;
+	    }
+	}
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcf/src/Oma1Dcf.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,570 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <f32file.h>
+#include <utf.h>
+#include <WSPDecoder.h>
+#include "Oma1Dcf.h"
+#include "DRMRightsClient.h"
+#include <centralrepository.h>
+#include <UTF.h>
+
+#include "DrmUtilityInternalcrkeys.h"      // Cenrep extension for OmaBased
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KMimeApplication, "application");
+_LIT8(KMimeText, "text");
+_LIT8(KMimeAudio, "audio");
+_LIT8(KMimeImage, "image");
+_LIT8(KMimeVideo, "video");
+_LIT8(KMimeModel, "model");
+_LIT8(KMimeMessage, "message");
+_LIT8(KMimeMultipart, "multipart");
+_LIT8(KXHeader, "x-");
+_LIT8(KColon, ":");
+//_LIT8(KSemiColon, ";");
+//_LIT8(KNewLine, "\n");
+_LIT8(KEndLine, "\r\n");
+
+const TInt KCenRepDataLength( 50 );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// COma1Dcf::COma1Dcf
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+COma1Dcf::COma1Dcf():
+    iHeaders(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// COma1Dcf::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void COma1Dcf::ConstructL(const RFile& aFile)
+    {
+    CDcfCommon::ConstructL(aFile);
+    User::LeaveIfError(ReadHeaderL());
+    }
+
+void COma1Dcf::ConstructL(const TDesC8& aMemoryBlock)
+    {
+    User::LeaveIfError(ReadHeaderL(aMemoryBlock));
+    iData = aMemoryBlock.AllocL();
+    }
+
+// -----------------------------------------------------------------------------
+// COma1Dcf::FetchOmaBasedInfoL
+// -----------------------------------------------------------------------------
+//
+HBufC8* COma1Dcf::FetchOmaBasedInfoL()
+    {
+    CRepository* repository( NULL );
+    RBuf bOmaBasedMimeType;
+    HBufC8* mimetype = NULL;
+
+    CleanupClosePushL(bOmaBasedMimeType);
+    bOmaBasedMimeType.CreateL( KCenRepDataLength );    
+    
+    repository = CRepository::NewL( KCRUidOmaBased );
+
+    CleanupStack::PushL( repository );
+
+    User::LeaveIfError(repository->Get( KOmaBasedMimeType, bOmaBasedMimeType ));
+    mimetype = CnvUtfConverter::ConvertFromUnicodeToUtf8L( bOmaBasedMimeType );
+    CleanupStack::PopAndDestroy( repository );
+    
+    CleanupStack::PopAndDestroy();
+    
+    return mimetype;
+    
+    }
+
+// -----------------------------------------------------------------------------
+// COma1Dcf::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C COma1Dcf* COma1Dcf::NewL(const RFile& aFile)
+    {
+    COma1Dcf* self = new(ELeave) COma1Dcf;
+    
+    CleanupStack::PushL(self);
+    self->ConstructL(aFile);
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// COma1Dcf::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C COma1Dcf* COma1Dcf::NewL(const TDesC8& aMemoryBlock)
+    {
+    COma1Dcf* self = new(ELeave) COma1Dcf;
+    
+    CleanupStack::PushL(self);
+    self->ConstructL(aMemoryBlock);
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// COma1Dcf::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C COma1Dcf::~COma1Dcf()
+    {
+    delete iHeaders;
+    }
+
+// -----------------------------------------------------------------------------
+// COma1Dcf::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma1Dcf::ReadHeaderL(const TDesC8& aMemoryBlock)
+    {
+    TInt r = KErrNone;
+    TInt cidLength = 0;
+    TInt mimeLength = 0;
+    TInt fieldLength = 0;
+    TBuf8<10> lengthFields;
+    TUint32 length;
+    TPtr8 ptr(NULL,0,0);
+    
+    if (aMemoryBlock.Length()<3)
+        {
+        User::Leave(KErrArgument);
+        }
+        
+    iVersion = aMemoryBlock[0];
+    
+    if (iVersion!=1)
+        {
+        // for OMA Version 1, DCF version must be 1
+        User::Leave(KErrArgument);
+        }
+        
+    mimeLength = aMemoryBlock[1];
+    cidLength = aMemoryBlock[2];
+    
+    if (mimeLength + cidLength + 3 + 5 + 5 > aMemoryBlock.Length())
+        {
+        User::Leave(KErrArgument);
+        }
+
+    
+    if (mimeLength!=0)
+        {
+        iMimeType = aMemoryBlock.Mid(3, mimeLength).AllocL();
+        ptr.Set(iMimeType->Des());
+        r = ptr.FindF(_L8("/"));
+        if (r==KErrNotFound)
+            {
+            User::Leave(KErrArgument);
+            }
+        }
+    else
+        {
+        User::Leave(KErrArgument);
+        }
+    
+    
+    if (cidLength!=0)
+        {
+        iContentID = aMemoryBlock.Mid(3 + mimeLength, cidLength).AllocL();
+        }
+    else
+        {
+        User::Leave(KErrArgument);    
+        }
+
+
+    lengthFields.Copy(aMemoryBlock.Mid(3 + mimeLength + cidLength, 10));
+    TWspPrimitiveDecoder decoder(lengthFields);
+    fieldLength = decoder.UintVar(length);
+    if( fieldLength < 0 ) 
+        {
+        User::Leave(KErrArgument);
+        }
+    iHeaderLength = length;
+    fieldLength += decoder.UintVar(length);
+    if( fieldLength < 0 )
+        {
+        User::Leave(KErrArgument);
+        }
+    
+    iDataLength = length;
+    iOffset = 3 + mimeLength + cidLength + fieldLength + iHeaderLength;
+    if (iDataLength == 0)
+        {
+        iDataLength = aMemoryBlock.Length() - iOffset;
+        }
+    iPlainTextLength = iDataLength - KDCFKeySize;
+    iPlainTextLengthValid = EFalse;
+
+    if (mimeLength + cidLength + 3 + 5 + 5 + iHeaderLength <=
+        aMemoryBlock.Length())
+        {
+        iHeaders = aMemoryBlock.Mid(3 + mimeLength + cidLength +
+                                    fieldLength, iHeaderLength).AllocL();
+
+        ReadHeaderValuesL();
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma1Dcf::ReadHeaderValuesL
+// 
+// -----------------------------------------------------------------------------
+//
+void COma1Dcf::ReadHeaderValuesL(void)
+    {
+    TPtrC8 ptr(NULL, 0);
+    
+    if (GetHeaderL(KRightsIssuer, ptr) == KErrNone)
+        {
+        if( iRightsIssuerURL )
+            {
+            delete iRightsIssuerURL;
+            iRightsIssuerURL = NULL;
+            }
+        iRightsIssuerURL = ptr.AllocL();
+        }
+    if (GetHeaderL(KContentName, ptr) == KErrNone)
+        {
+        if( iTitle ) 
+            {
+            delete iTitle;
+            iTitle = NULL;
+            }        
+        iTitle = ptr.AllocL();
+        }
+    if (GetHeaderL(KContentDescription, ptr) == KErrNone)
+        {
+        if( iDescription )
+            {
+            delete iDescription;
+            iDescription = NULL;
+            }          
+        iDescription = ptr.AllocL();
+        }
+    if (GetHeaderL(KIconURI, ptr) == KErrNone)
+        {
+        if( iIconUri )
+            {
+            delete iIconUri;
+            iIconUri = NULL;
+            }         
+        iIconUri = ptr.AllocL();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma1Dcf::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma1Dcf::ReadHeaderL(void)
+    {
+    TInt r = KErrNone;
+    TInt pos = 0;
+    TUint8 v = 0;
+    TPtr8 p(&v, 1, 1);
+    TInt cidLength = 0;
+    TInt mimeLength = 0;
+    TInt fieldLength = 0;
+    TBuf8<10> lengthFields;
+    TUint32 length;
+    TInt size;
+
+    iFile.Size(size);
+    if (size<3)
+        {
+        User::Leave(KErrArgument);
+        }
+    iFile.Seek(ESeekStart, pos);
+
+    iFile.Read(p);
+    iVersion = v;
+    if (iVersion!=1)
+        {
+        // for OMA Version 1, DCF version must be 1
+        User::Leave(KErrArgument);
+        }
+
+    iFile.Read(p);
+    mimeLength = v;
+    if (mimeLength==0)
+        {
+        User::Leave(KErrArgument);
+        }
+
+    iFile.Read(p);
+    cidLength = v;
+    if (cidLength==0)
+        {
+        User::Leave(KErrArgument);
+        }
+
+    iMimeType = HBufC8::NewMax(mimeLength);
+    User::LeaveIfNull(iMimeType);
+    p.Set(iMimeType->Des());
+    iFile.Read(p, mimeLength);
+    p.Set(iMimeType->Des());
+    r = p.FindF(_L8("/"));
+    if (r==KErrNotFound)
+        {
+        User::Leave(KErrArgument);
+        }
+
+    iContentID = HBufC8::NewMax(cidLength);
+    User::LeaveIfNull(iContentID);
+    p.Set(iContentID->Des());
+    iFile.Read(p, cidLength);
+    
+    pos = 0;
+    iFile.Seek(ESeekCurrent, pos);
+    iFile.Read(lengthFields);
+    TWspPrimitiveDecoder decoder(lengthFields);
+    fieldLength = decoder.UintVar(length);
+    if( fieldLength < 0 )
+        {
+        User::Leave(KErrArgument);
+        }
+    iHeaderLength = length;
+    fieldLength += decoder.UintVar(length);
+    if( fieldLength < 0 )
+        {
+        User::Leave(KErrArgument);
+        }
+    
+    iDataLength = length;
+    iOffset = pos + fieldLength + iHeaderLength;
+    if (iDataLength == 0)
+        {
+        iDataLength = size - iOffset;
+        }
+    iPlainTextLength = iDataLength - KDCFKeySize;
+    iPlainTextLengthValid = EFalse;
+
+    pos = pos + fieldLength;
+    iFile.Seek(ESeekStart, pos);
+    iHeaders = HBufC8::NewL(iHeaderLength);
+    p.Set(iHeaders->Des());
+    iFile.Read(p, iHeaderLength);
+
+    ReadHeaderValuesL();
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma1Dcf::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool COma1Dcf::IsValidDcf(const TDesC8& aDcfFragment)
+    {
+    TPtrC8 mimeType;
+    TInt i;
+    TBool r = EFalse;
+    TInt error = KErrNone;
+    HBufC8* omaBasedBuf = NULL;
+
+    if (aDcfFragment.Length() > 15)
+        {
+        i = aDcfFragment.Right(aDcfFragment.Length() - 3).Locate('/');
+        if (aDcfFragment[0] == 1 && i != KErrNotFound)
+            {
+            mimeType.Set(aDcfFragment.Mid(3, i));
+            if (mimeType.CompareF(KMimeImage) == 0 ||
+                mimeType.CompareF(KMimeAudio) == 0 ||
+                mimeType.CompareF(KMimeApplication) == 0 ||
+                mimeType.CompareF(KMimeText) == 0 ||
+                mimeType.CompareF(KMimeModel) == 0 ||
+                mimeType.CompareF(KMimeMessage) == 0 ||
+                mimeType.CompareF(KMimeVideo) == 0 ||
+                mimeType.CompareF(KMimeMultipart) == 0 ||
+                aDcfFragment.Mid(3, 2).CompareF(KXHeader) == 0)
+                {
+                r = ETrue;
+                // Check for specific mimetype
+                
+                TRAP( error, omaBasedBuf = FetchOmaBasedInfoL() );
+                
+                if( !error )
+                    {
+                    mimeType.Set(aDcfFragment.Mid(3, 
+                            omaBasedBuf->Length()));
+                    
+                
+                    if (mimeType.CompareF( *omaBasedBuf ) == 0)
+                        {
+                        r = EFalse;
+                        }
+                    }
+                delete omaBasedBuf;
+                }
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma1Dcf::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma1Dcf::CheckUniqueId(const TDesC& aUniqueId)
+	{
+	TInt r = CDcfCommon::CheckUniqueId(aUniqueId);
+	
+	if (r == KErrNotFound)
+	    {
+	    HBufC8* id = NULL;
+    	TRAPD(err, id = CnvUtfConverter::ConvertFromUnicodeToUtf8L(aUniqueId));
+    	if (err == KErrNone)
+    	    {
+    	    if (iContentID->Compare(*id) == 0)
+    		    {
+    		    r = 0;
+    		    }
+            }
+        else
+            {
+            r = err;
+            }
+    	delete id;
+    	}
+	return r;
+	}
+	
+// -----------------------------------------------------------------------------
+// COma1Dcf::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma1Dcf::OpenPart(const TDesC& aUniqueId)
+	{
+	return OpenPart(CheckUniqueId(aUniqueId));
+	}
+	
+// -----------------------------------------------------------------------------
+// COma1Dcf::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt COma1Dcf::OpenPart(TInt aPart)
+	{
+	if (aPart == 0)
+		{
+		return KErrNone;
+		}
+	else
+		{
+		return KErrNotFound;
+		}
+	}
+	
+// -----------------------------------------------------------------------------
+// COma1Dcf::
+// 
+// -----------------------------------------------------------------------------
+//
+void COma1Dcf::GetPartIdsL(RPointerArray<HBufC8>& aPartList)
+    {
+    aPartList.ResetAndDestroy();
+    aPartList.AppendL(iContentID->Des().AllocL());
+    }
+	
+// -----------------------------------------------------------------------------
+// COma1Dcf::GetHeaderL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt COma1Dcf::GetHeaderL(
+    const TDesC8& aHeaderName,
+    TPtrC8& aHeaderValue)
+    {
+    TInt i;
+    TInt j;
+    TPtrC8 ptr( iHeaders->Des() );
+    
+    // Add Room for CRLF and Semicolon:
+    HBufC8* buffer = HBufC8::NewMaxLC( aHeaderName.Length() + 3 );  
+    TPtr8 searchBuf( const_cast<TUint8*>(buffer->Ptr()), 0, buffer->Des().MaxSize() );  
+
+    searchBuf.Copy(aHeaderName);
+    searchBuf.Append(KColon);
+    
+    // First see if the     
+    i = ptr.Find(searchBuf);
+    if( i < 0 )
+        {
+        CleanupStack::PopAndDestroy(); // buffer
+        return KErrNotFound; 
+        }
+        
+   if( i > 0 )
+        {
+        // if it's not the first one, use the search buffer:
+        // Create the search buffer
+        searchBuf.Copy(KEndLine);
+        searchBuf.Append(aHeaderName);
+        searchBuf.Append(KColon);
+    
+        // First see if the     
+        i = ptr.Find(searchBuf);
+        if ( i < 0 )
+            {
+            CleanupStack::PopAndDestroy(); // buffer            
+            return KErrNotFound;
+            }        
+        }
+    // Move search buffer    
+    i += searchBuf.Length();  
+    
+    j = ptr.Mid(i).Find(KEndLine);
+    if( j < 0 )
+        {
+        CleanupStack::PopAndDestroy(); // buffer        
+        return KErrNotFound;
+        }
+        
+    aHeaderValue.Set( ptr.Mid(i, j) );  
+    
+    CleanupStack::PopAndDestroy(); // buffer
+    return KErrNone;
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcf/src/Oma2Dcf.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1591 @@
+/*
+* Copyright (c) 2002 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of class representeting discrete OMA2 DCF
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32const.h> // KMaxTUint32
+#include <e32cmn.h> // Max, Min
+#include <e32base.h>
+#include <f32file.h>
+#include <utf.h>
+#include <caf/caf.h>
+#include "Oma2Agent.h"
+#include "Oma2Dcf.h"
+#include "Oma2DcfPartInfo.h"
+
+// LOCAL CONSTANTS AND MACROS
+
+#define M4CC( a ) ( ( a[ 0 ] << 24 ) + ( a[ 1 ] << 16 ) + ( a[ 2 ] << 8 ) + a[ 3 ] )
+
+const TUint32 KDiscreteMediaHeaders( M4CC( "odhe" ) );
+const TUint32 KContainer( M4CC( "odrm" ) );
+const TUint32 KContentObject( M4CC( "odda" ) );
+const TUint32 KCommonHeaders( M4CC( "ohdr" ) );
+const TUint32 KMutableInfo( M4CC( "mdri" ) );
+const TUint32 KTransactionTracking( M4CC( "odtt" ) );
+const TUint32 KRightsObject( M4CC( "odrb" ) );
+const TUint32 KGroupId( M4CC( "grpi" ) );
+const TUint32 KUserData( M4CC( "udta" ) );
+
+// supported user data boxes
+_LIT8( KTitle, "titl" );
+_LIT8( KDescription, "dscp" );
+_LIT8( KCopyright, "cprt" );
+_LIT8( KAuthor, "auth" );
+_LIT8( KIconUri, "icnu" );
+_LIT8( KInfoURL, "infu" );
+_LIT8( KPerformer, "perf" );
+_LIT8( KGenre, "gnre" );
+_LIT8( KRating, "rtng" );
+_LIT8( KClassification, "clsf" );
+_LIT8( KKeyword, "kywd" );
+_LIT8( KLocationInformation, "loci" );
+_LIT8( KAlbum, "albm" );
+_LIT8( KRecordingYear, "yrrc" );
+_LIT8( KCoverUri, "cvru" );
+_LIT8( KLyricsURL, "lrcu" );
+
+
+_LIT8( KMdri, "mdri" );
+_LIT8( KOdtt, "odtt" );
+_LIT8( KOdrb, "odrb" );
+
+// textual headers
+_LIT8( KSilentHeader, "Silent" );
+_LIT8( KPreviewHeader, "Preview" );
+_LIT8( KContentURLHeader, "ContentURL" );
+_LIT8( KContentVersionHeader, "ContentVersion" );
+_LIT8( KContentLocationHeader, "Content-Location" );
+
+// supported custom textual headers
+_LIT8( KIconUriHeader, "IconURI" );
+_LIT8( KTitleHeader, "Title" );
+_LIT8( KDescriptionHeader, "Description" );
+_LIT8( KAuthorHeader, "Author" );
+_LIT8( KCopyrightHeader, "Copyright" );
+_LIT8( KInfoURLHeader, "InfoURL" );
+
+// textual headers, methods
+_LIT8( KSilentMethodOnDemand, "on-demand" );
+_LIT8( KSilentMethodInAdvance, "in-advance" );
+_LIT8( KPreviewMethodInstant, "instant" );
+_LIT8( KPreviewMethodPreviewRights, "preview-rights" );
+_LIT8( KEmptyTransactionId, "0000000000000000" );
+
+_LIT8( KTerminator, "\0" );
+_LIT8( KSeparator, ":" );
+_LIT8( KParamSeparator, ";" );
+
+const TInt KBrandingSize( 20 );
+const TInt KMaxBoxHeaderSize( 16 );
+const TInt KLengthBoxSize( 4 );
+const TInt KLengthBoxType( 4 );
+const TInt KLengthBoxSize64( 8 );
+const TInt KLengthVersion( 1 );
+const TInt KLengthFlags( 3 );
+const TInt KLengthEncMethod( 1 );
+const TInt KLengthPadType( 1 );
+const TInt KLengthPlainTextSize( 8 );
+const TInt KLengthDataLengthSize( 8 );
+const TInt KLengthContentIdSize( 2 );
+const TInt KLengthRiUrlSize( 2 );
+const TInt KLengthTextHeadersSize( 2 );
+const TInt KLengthTerminator( 1 );
+
+// Smallest possible ISO based media box size
+// See ISO/IEC 14496-12 and DRM-DCF-CLI-12 in OMA-TS-DRM-DCF-V2_1
+const TUint32 KMinBoxSize( KLengthBoxSize + KLengthBoxType );
+// Largest supported ISO based media box size
+const TUint32 KMaxBoxSize( KMaxTUint32 );
+
+const TUint KUserDataBoxMask( 0x000001 );
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ReadUint32FromBlock
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TUint32 ReadUint32FromBlock( const TDesC8& aBlock, TInt aOffset )
+    {
+    return ( aBlock[ aOffset ] << 24 ) +
+        ( aBlock[ aOffset + 1 ] << 16 ) +
+        ( aBlock[ aOffset + 2 ] << 8 ) +
+        aBlock[ aOffset + 3 ];
+    }
+
+// -----------------------------------------------------------------------------
+// ReadUint16FromBlock
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TUint16 ReadUint16FromBlock( const TDesC8& aBlock, TInt aOffset )
+    {
+    return ( ( aBlock[ aOffset ] << 8 ) + aBlock[ aOffset + 1 ] );
+    }
+
+// -----------------------------------------------------------------------------
+// WriteIntToBlock
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void WriteIntToBlock( TInt aValue, TDes8& aBlock, TInt aOffset )
+    {
+    aBlock.SetLength( 4 );
+    aBlock[ aOffset ] =     ( aValue & 0xff000000 ) >> 24;
+    aBlock[ aOffset + 1 ] = ( aValue & 0x00ff0000 ) >> 16;
+    aBlock[ aOffset + 2 ] = ( aValue & 0x0000ff00 ) >> 8;
+    aBlock[ aOffset + 3 ] = ( aValue & 0x000000ff );
+    }
+
+// -----------------------------------------------------------------------------
+// ValidateBoxSizeL
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void ValidateBoxSizeL(
+    const TUint32 aSize,
+    const TUint32 aMinSize = KMinBoxSize,
+    const TUint32 aMaxSize = KMaxBoxSize )
+    {
+    TUint32 minSize( Max( aMinSize, KMinBoxSize) );
+    TUint32 maxSize( Min( aMaxSize, KMaxBoxSize ) );
+    if ( aSize < minSize )
+        {
+        User::Leave( KErrArgument );
+        }
+    if ( aSize > maxSize )
+        {
+        User::Leave( KErrArgument );
+        }
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::COma2Dcf
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+COma2Dcf::COma2Dcf():
+    iEncrytionPadding( EPaddingNone ),
+    iSilentRefresh( ENoSilentRefresh ),
+    iPreview( ENoPreview ),
+    iPreviewParameter( NULL ),
+    iSilentParameter( NULL ),
+    iTextualHeaders( NULL ),
+    iContentUrl( NULL ),
+    iContentVersion( NULL ),
+    iContentLocation( NULL ),
+    iTransactionTracking( NULL ),
+    iUserData( NULL ),
+    iAuthor( NULL ),
+    iCopyRight( NULL ),
+    iInfoUri( NULL ),
+    iGroupId( NULL ),
+    iGroupKey( NULL ),
+    iGkEncryptionMethod( EMethodNULL ),
+    iMutablePart( NULL ),
+    iPerformer( NULL ),
+    iGenre( NULL ),
+    iRatingInfo( NULL ),
+    iClassificationInfo( NULL ),
+    iKeyword( NULL ),
+    iLocInfoName( NULL ),
+    iLocInfoAstronomicalBody( NULL ),
+    iLocInfoAdditionalNotes( NULL ),
+    iAlbumTitle( NULL ),
+    iCoverUri( NULL ),
+    iLyricsURL( NULL ),
+    iRecordingYear( 0 ),
+    iAlbumTrack( 0 )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ConstructL(
+    const RFile& aFile,
+    TInt aPart )
+    {
+    CDcfCommon::ConstructL( aFile );
+    ReadPartsL();
+    User::LeaveIfError( OpenPart( aPart ) );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C COma2Dcf* COma2Dcf::NewL(
+    const RFile& aFile,
+    TInt aPart )
+    {
+    COma2Dcf* self( new ( ELeave ) COma2Dcf );
+
+    CleanupStack::PushL( self );
+    self->ConstructL( aFile, aPart );
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// Destructor
+EXPORT_C COma2Dcf::~COma2Dcf()
+    {
+    delete iPreviewParameter;
+    delete iSilentParameter;
+    delete iTextualHeaders;
+    delete iContentUrl;
+    delete iContentVersion;
+    delete iContentLocation;
+    delete iTransactionTracking;
+    delete iUserData;
+    delete iAuthor;
+    delete iCopyRight;
+    delete iInfoUri;
+    delete iGroupId;
+    delete iGroupKey;
+    delete iPerformer;
+    delete iGenre;
+    delete iRatingInfo;
+    delete iClassificationInfo;
+    delete iKeyword;
+    delete iLocInfoName;
+    delete iLocInfoAstronomicalBody;
+    delete iLocInfoAdditionalNotes;
+    delete iAlbumTitle;
+    delete iCoverUri;
+    delete iLyricsURL;
+    delete iMutablePart;
+
+    iRightsObjects.ResetAndDestroy();
+    iRightsObjects.Close();
+    iParts.ResetAndDestroy();
+    iParts.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::IsValidDcf
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool COma2Dcf::IsValidDcf(
+    const TDesC8& aDcfFragment )
+    {
+    TBool r( EFalse );
+
+    if ( aDcfFragment.Length() >= KBrandingSize &&
+        aDcfFragment.Left( KBrandingSize ).Compare( KOma2DcfBranding ) == 0 )
+        {
+        r = ETrue;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadPartsL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ReadPartsL( void )
+    {
+    TBuf8<KBrandingSize> buffer;
+    TInt size;
+    TUint32 type;
+    TInt offset;
+    TInt headerSize;
+    COma2DcfPartInfo* part;
+
+    User::LeaveIfError( iFile.Read( 0, buffer, KBrandingSize ) );
+    if ( !IsValidDcf( buffer ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    iVersion = ReadUint32FromBlock( buffer, 12 );
+    offset = KBrandingSize;
+    iParts.Reset();
+    do
+        {
+        ReadBoxSizeAndTypeL( offset, size, type, headerSize );
+        if ( headerSize > 0 )
+            {
+            part = COma2DcfPartInfo::NewL();
+            part->iType = type;
+            part->iSize = size;
+            part->iOffset = offset;
+            CleanupStack::PushL( part );
+            if ( type == KContainer )
+                {
+                ReadPartInfoL( part, offset );
+                iParts.Append( part );
+                CleanupStack::Pop( part );
+                }
+            else if ( type == KMutableInfo )
+                {
+                iMutablePart = part;
+                CleanupStack::Pop( part );
+                ReadMutableInfoL( offset, size );
+                }
+            else
+                {
+                CleanupStack::PopAndDestroy( part );
+                }
+            }
+        offset += size;
+        }
+    while ( offset < iLength && headerSize > 0 );
+
+    delete iContentID;
+    iContentID = NULL;
+    delete iMimeType;
+    iMimeType = NULL;
+
+    if ( iParts.Count() == 0 ||
+        iParts[ 0 ]->iContentId == NULL ||
+        iParts[ 0 ]->iMimeType == NULL )
+        {
+        User::LeaveIfError( KErrArgument );
+        }
+    iContentID = iParts[ 0 ]->iContentId->AllocL();
+    iMimeType = iParts[ 0 ]->iMimeType->AllocL();
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::CheckUniqueId
+// -----------------------------------------------------------------------------
+//
+TInt COma2Dcf::CheckUniqueId( const TDesC& aUniqueId )
+    {
+    TInt r( CDcfCommon::CheckUniqueId( aUniqueId ) );
+
+    if ( r == KErrNotFound )
+        {
+        HBufC8* id( NULL );
+        TRAPD( err,
+            id = CnvUtfConverter::ConvertFromUnicodeToUtf8L( aUniqueId ) );
+        if ( err == KErrNone )
+            {
+            r = KErrNotFound;
+            for ( TInt i( 0 );
+                i < iParts.Count() && r == KErrNotFound;
+                i++ )
+                {
+                if ( !id->Compare( *iParts[ i ]->iContentId ) )
+                    {
+                    r = i;
+                    }
+                }
+            delete id;
+            }
+        else
+            {
+            r = err;
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::OpenPart
+// -----------------------------------------------------------------------------
+//
+TInt COma2Dcf::OpenPart(
+    const TDesC& aUniqueId )
+    {
+    return OpenPart( CheckUniqueId( aUniqueId ) );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::OpenPart
+// -----------------------------------------------------------------------------
+//
+TInt COma2Dcf::OpenPart(
+    TInt aPart )
+    {
+    TInt r( KErrNone );
+    TInt size( 0 );
+
+    if ( aPart >= 0 && aPart < iParts.Count() )
+        {
+        TRAP( r, ReadContainerL( iParts[ aPart ]->iOffset, size ) );
+        }
+    else
+        {
+        r = KErrNotFound;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::GetPartIdsL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::GetPartIdsL( RPointerArray<HBufC8>& aPartList )
+    {
+    aPartList.ResetAndDestroy();
+    for ( TInt i( 0 ); i < iParts.Count(); i++ )
+        {
+        aPartList.Append( iParts[ i ]->iContentId->AllocL() );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadContainerL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ReadContainerL(
+    TInt aOffset,
+    TInt& aSize )
+    {
+    TUint32 type( 0 );
+    TInt size( 0 );
+
+    ReadBoxSizeAndTypeL( aOffset, aSize, type, size );
+    VerifyTypeL( type, KContainer );
+    aOffset += size + KLengthVersion + KLengthFlags;
+    ReadDiscreteMediaHeaderL( aOffset, size );
+    aOffset += size;
+    ReadContentObjectL( aOffset, size );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadDiscreteMediaHeaderL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ReadDiscreteMediaHeaderL(
+    TInt aOffset,
+    TInt& aSize )
+    {
+    TBuf8<1> valBuf;
+    TBuf8<4> udtaBuf;
+    TInt size( 0 );
+    TUint32 type( 0 );
+    TUint8 length( 0 );
+    TPtr8 ptr( 0, 0 );
+
+    TBuf8< KLengthVersion + KLengthFlags > buffer;
+    TUint32 version_and_flags( 0 );
+
+    ReadBoxSizeAndTypeL( aOffset, aSize, type, size );
+    VerifyTypeL( type, KDiscreteMediaHeaders );
+
+    // read flags and version
+    aOffset += size;
+    User::LeaveIfError( iFile.Read( aOffset, buffer ) );
+    version_and_flags = ReadUint32FromBlock( buffer, 0 );
+    aOffset += KLengthVersion + KLengthFlags;
+
+    // read ContentType
+    delete iMimeType;
+    iMimeType = NULL;
+
+    // input validation
+    if ( aOffset < 0 )
+        {
+        // RFile::Read will panic if offset is negative
+        User::Leave( KErrArgument );
+        }
+
+    User::LeaveIfError( iFile.Read( aOffset, valBuf, 1 ) );
+    length = valBuf[ 0 ];
+    aOffset += 1;
+    iMimeType = HBufC8::NewMax( length );
+    User::LeaveIfNull( iMimeType );
+    ptr.Set( iMimeType->Des() );
+    User::LeaveIfError( iFile.Read( ptr, length ) );
+    aOffset += length;
+
+    // read Common headers
+    ReadCommonHeadersL( aOffset, size );
+
+    // user data box would follow here
+    if ( version_and_flags & KUserDataBoxMask )
+        {
+        aOffset += size;
+        User::LeaveIfError( iFile.Read( aOffset, udtaBuf, 4 ) );
+        size = ReadUint32FromBlock( udtaBuf, 0 );
+        ReadUserDataL( aOffset, size );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadContentObjectL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ReadContentObjectL(
+    TInt aOffset,
+    TInt& aSize )
+    {
+    TBuf8<KMaxBoxHeaderSize> valBuf;
+    TInt size( 0 );
+    TUint32 type( 0 );
+
+    ReadBoxSizeAndTypeL( aOffset, aSize, type, size );
+    VerifyTypeL( type, KContentObject );
+    aOffset += size + KLengthVersion + KLengthFlags;
+
+    // read data length
+
+    // input validation
+    if ( aOffset < 0 )
+        {
+        // RFile::Read will panic if offset is negative
+        User::Leave( KErrArgument );
+        }
+
+    User::LeaveIfError( iFile.Read( aOffset, valBuf, KLengthDataLengthSize ) );
+    if ( ReadUint32FromBlock( valBuf, 0 ) != 0 )
+        {
+        // the size is larger than 2^32-1, we can't handle this.
+        User::Leave( KErrOverflow );
+        }
+    else
+        {
+        iDataLength = ReadUint32FromBlock( valBuf, KLengthDataLengthSize / 2 );
+        if ( iPlainTextLengthValid )
+            {
+            iPadding = iDataLength - iPlainTextLength;
+            }
+        }
+    iOffset = aOffset + KLengthDataLengthSize;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadCommonHeadersL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ReadCommonHeadersL(
+    TInt aOffset,
+    TInt& aSize )
+    {
+    TBuf8< KMaxBoxHeaderSize > valBuf;
+    TInt size( 0 );
+    TInt boxEnd( 0 );
+    TUint32 type( 0 );
+    TInt offset( 0 );
+    TUint16 riURLLength( 0 );
+    TUint16 contentIdLength( 0 );
+    TUint16 textualHeadersLength( 0 );
+    TUint16 length( 0 );
+    HBufC8* buf( NULL );
+    TPtr8 ptr( 0, 0 );
+
+    ReadBoxSizeAndTypeL( aOffset, aSize, type, size );
+    VerifyTypeL( type, KCommonHeaders );
+    boxEnd = aOffset + aSize;
+    aOffset += size + KLengthVersion + KLengthFlags;
+
+    length = KLengthEncMethod + KLengthPadType + KLengthPlainTextSize
+        + KLengthContentIdSize + KLengthRiUrlSize + KLengthTextHeadersSize;
+    buf = HBufC8::NewLC( length );
+    ptr.Set( buf->Des() );
+
+    // input validation
+    if ( aOffset < 0 )
+        {
+        // RFile::Read will panic if offset is negative
+        User::Leave( KErrArgument );
+        }
+    User::LeaveIfError( iFile.Read( aOffset, ptr, length ) );
+
+    offset = 0;
+    iEncryptionMethod = static_cast< TEncryptionMethod >( ( *buf )[ 0 ] );
+    offset += KLengthEncMethod;
+    iEncrytionPadding = static_cast< TEncryptionPadding >( ( *buf )[ 1 ] );
+    offset += KLengthPadType;
+
+    iPlainTextLength = ReadUint32FromBlock( ptr, offset );
+    offset +=  KLengthPlainTextSize / 2;
+    if ( iPlainTextLength != 0 )
+        {
+        User::Leave( KErrOverflow );
+        }
+    else
+        {
+        iPlainTextLength = ReadUint32FromBlock( ptr, offset );
+        if ( iPlainTextLength > 0 )
+            {
+            iPlainTextLengthValid = ETrue;
+            }
+        else
+            {
+            iPlainTextLengthValid = EFalse;
+            }
+        offset +=  KLengthPlainTextSize / 2;
+        }
+
+    contentIdLength = ReadUint16FromBlock( ptr, offset );
+    offset += KLengthContentIdSize;
+    riURLLength = ReadUint16FromBlock( ptr, offset );
+    offset += KLengthRiUrlSize;
+    textualHeadersLength  = ReadUint16FromBlock( ptr, offset );
+    offset += KLengthTextHeadersSize;
+    CleanupStack::PopAndDestroy( buf );
+    buf = NULL;
+
+    aOffset += offset;
+    delete iContentID;
+    iContentID = NULL;
+    iContentID = HBufC8::NewMax( contentIdLength );
+    User::LeaveIfNull( iContentID );
+    ptr.Set( iContentID->Des() );
+    User::LeaveIfError( iFile.Read( aOffset, ptr, contentIdLength ) );
+    aOffset += contentIdLength;
+
+    delete iRightsIssuerURL;
+    iRightsIssuerURL = NULL;
+    if ( riURLLength > 0 )
+        {
+        iRightsIssuerURL = HBufC8::NewL( riURLLength );
+        ptr.Set( iRightsIssuerURL->Des() );
+        User::LeaveIfError( iFile.Read( aOffset, ptr, riURLLength ) );
+        aOffset += riURLLength;
+        }
+
+    delete iTextualHeaders;
+    iTextualHeaders = NULL;
+    if ( textualHeadersLength > 0 )
+        {
+        iTextualHeaders = HBufC8::NewL( textualHeadersLength );
+        ptr.Set( iTextualHeaders->Des() );
+        User::LeaveIfError( iFile.Read( aOffset, ptr, textualHeadersLength ) );
+        aOffset += textualHeadersLength;
+        ParseTextualHeadersL( ptr );
+        }
+
+    ReadExtendedHeadersL( aOffset, boxEnd );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ParseTextualHeadersL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ParseTextualHeadersL(
+    const TDesC8& aMemoryBlock )
+    {
+    HBufC8* buf1( NULL );
+    HBufC8* method( NULL );
+    TInt r( KErrNone );
+    TInt silentOffset( 0 );
+    TInt previewOffset( 0 );
+
+    silentOffset = ReadOneTextualHeaderL(
+        aMemoryBlock, KSilentHeader, buf1, r );
+    if ( r != KErrNotFound && buf1 )
+        {
+        CleanupStack::PushL( buf1 );
+        SetHeaderWithParameterL( *buf1, method, iSilentParameter );
+        CleanupStack::PopAndDestroy( buf1 );
+        buf1 = NULL;
+        if ( method )
+            {
+            if ( !method->Compare( KSilentMethodOnDemand ) )
+                {
+                iSilentRefresh = EOnDemand;
+                }
+            else if ( !method->Compare( KSilentMethodInAdvance ) )
+                {
+                iSilentRefresh = EInAdvance;
+                }
+            else
+                {
+                delete method;
+                User::Leave( KErrArgument );
+                }
+            delete method;
+            method = NULL;
+            }
+        }
+    else
+        {
+        iSilentRefresh = ENoSilentRefresh;
+        delete iSilentParameter;
+        iSilentParameter = 0;
+        }
+
+    previewOffset = ReadOneTextualHeaderL(
+        aMemoryBlock, KPreviewHeader, buf1, r );
+    if ( r != KErrNotFound && buf1 )
+        {
+        CleanupStack::PushL( buf1 );
+        SetHeaderWithParameterL( *buf1, method, iPreviewParameter );
+        CleanupStack::PopAndDestroy( buf1 );
+        buf1 = NULL;
+        if ( method )
+            {
+            if ( !method->CompareF( KPreviewMethodInstant ) )
+                {
+                iPreview = EInstantPreview;
+                }
+            else if ( !method->CompareF( KPreviewMethodPreviewRights ) )
+                {
+                iPreview = EPreviewRights;
+                }
+            else
+                {
+                delete method;
+                User::Leave( KErrArgument );
+                }
+            delete method;
+            method = NULL;
+            }
+        }
+    else
+        {
+        iPreview = ENoPreview;
+        delete iPreviewParameter;
+        iPreviewParameter = NULL;
+        }
+
+    iPreviewOverridesSilentRefresh = EFalse;
+    if ( iSilentRefresh != ENoSilentRefresh && iPreview != ENoPreview )
+        {
+        if ( previewOffset < silentOffset )
+            {
+            iPreviewOverridesSilentRefresh = ETrue;
+            }
+        }
+
+    ReadOneTextualHeaderL(
+        aMemoryBlock, KContentLocationHeader, iContentLocation, r );
+    if ( r == KErrNotFound )
+        {
+        delete iContentLocation;
+        iContentLocation = NULL;
+        }
+
+    ReadOneTextualHeaderL( aMemoryBlock, KContentURLHeader, iContentUrl, r );
+    if ( r == KErrNotFound )
+        {
+        delete iContentUrl;
+        iContentUrl = NULL;
+        }
+
+    ReadOneTextualHeaderL(
+        aMemoryBlock, KContentVersionHeader, iContentVersion, r );
+    if ( r == KErrNotFound )
+        {
+        delete iContentVersion;
+        iContentVersion = NULL;
+        }
+
+    // custom headers ->
+    ReadOneTextualHeaderL( aMemoryBlock, KInfoURLHeader, iInfoUri, r );
+    if ( r == KErrNotFound )
+        {
+        delete iInfoUri;
+        iInfoUri = NULL;
+        }
+
+    // custom header
+    ReadOneTextualHeaderL( aMemoryBlock, KTitleHeader, iTitle, r );
+    if ( r == KErrNotFound )
+        {
+        delete iTitle;
+        iTitle = NULL;
+        }
+
+    ReadOneTextualHeaderL( aMemoryBlock, KIconUriHeader, iIconUri, r );
+    if ( r == KErrNotFound )
+        {
+        delete iIconUri;
+        iIconUri = NULL;
+        }
+
+    ReadOneTextualHeaderL( aMemoryBlock, KAuthorHeader, iAuthor, r );
+    if ( r == KErrNotFound )
+        {
+        delete iAuthor;
+        iAuthor = NULL;
+        }
+
+    ReadOneTextualHeaderL( aMemoryBlock, KDescriptionHeader, iDescription, r );
+    if ( r == KErrNotFound )
+        {
+        delete iDescription;
+        iDescription = NULL;
+        }
+
+    ReadOneTextualHeaderL( aMemoryBlock, KCopyrightHeader, iCopyRight, r );
+    if ( r == KErrNotFound )
+        {
+        delete iCopyRight;
+        iCopyRight = NULL;
+        }
+
+
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::SetHeaderWithParameterL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::SetHeaderWithParameterL(
+    const TDesC8& aValue,
+    HBufC8*& aMethod,
+    HBufC8*& aParameter )
+    {
+    TInt offset( 0 );
+
+    delete aMethod;
+    aMethod = NULL;
+    delete aParameter;
+    aParameter = NULL;
+
+    offset = aValue.Find( KParamSeparator );
+    if ( offset == KErrNotFound || offset == 0 )
+        {
+        aMethod = aValue.AllocL();
+        }
+    else
+        {
+        aMethod = aValue.Left( offset ).AllocLC();
+        aParameter = aValue.Mid( offset + 1 ).AllocL();
+        CleanupStack::Pop( aMethod );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadOneTextualHeaderL
+// -----------------------------------------------------------------------------
+//
+TInt COma2Dcf::ReadOneTextualHeaderL(
+    const TDesC8& aBlock,
+    const TDesC8& aName,
+    HBufC8*& aBuf,
+    TInt& aError )
+    {
+    TInt offset( aBlock.Find( aName ) );
+
+    delete aBuf;
+    aBuf = NULL;
+    if ( offset == KErrNotFound )
+        {
+        aError = KErrNotFound;
+        return offset;
+        }
+    else
+        {
+        if ( offset + aName.Length() < aBlock.Length() &&
+            aBlock.Mid( offset + aName.Length(), 1 ) == KSeparator )
+            {
+            TInt length( 0 );
+            length =
+                aBlock.Mid( offset + aName.Length() + 1 ).Find( KTerminator );
+            if ( length == KErrNotFound )
+                {
+                User::Leave( KErrArgument );
+                }
+            else
+                {
+                aBuf = HBufC8::NewL( length );
+                *aBuf = aBlock.Mid( offset + aName.Length() + 1, length );
+                }
+            }
+        }
+    aError = KErrNone;
+    return offset;
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadExtendedHeadersL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ReadExtendedHeadersL(
+    TInt aOffset,
+    TInt aEndOfBox )
+    {
+    TInt size( 1 );
+    TInt groupIdSize( 0 );
+    TInt groupKeySize( 0 );
+    TUint32 type( 0 );
+    TInt headerSize( 0 );
+    TInt dataSize( 0 );
+    TInt offset( 0 );
+    TPtr8 ptr( 0, 0 );
+    HBufC8* buffer( NULL );
+
+    delete iGroupId;
+    iGroupId = NULL;
+    delete iGroupKey;
+    iGroupKey = NULL;
+
+    while ( size > 0 && aOffset < aEndOfBox && iGroupId == NULL )
+        {
+        size = 0;
+        ReadBoxSizeAndTypeL( aOffset, size, type, headerSize );
+        if ( type == KGroupId )
+            {
+            dataSize = size - headerSize - KLengthVersion - KLengthFlags;
+            offset = aOffset + headerSize + KLengthVersion + KLengthFlags;
+            // input validation
+            if ( dataSize < 0 || dataSize > KMaxTInt / 2 )
+                {
+                User::Leave( KErrArgument );
+                }
+            buffer = HBufC8::NewLC( dataSize );
+            ptr.Set( buffer->Des() );
+            User::LeaveIfError( iFile.Read( offset, ptr, dataSize ) );
+            // input validation
+            if ( ptr.Length() == 0 )
+                {
+                User::Leave( KErrArgument );
+                }
+            iGkEncryptionMethod = static_cast< TEncryptionMethod >( ptr[ 2 ] );
+            groupIdSize = ReadUint16FromBlock( ptr, 0 );
+            if ( 5 + groupIdSize > ptr.Length() )
+                {
+                User::Leave( KErrArgument );
+                }
+            iGroupId = ptr.Mid( 5, groupIdSize ).AllocL();
+            groupKeySize = ReadUint16FromBlock( ptr, 3 );
+            if ( 5 + groupIdSize + groupKeySize > ptr.Length() )
+                {
+                User::Leave( KErrArgument );
+                }
+            iGroupKey = ptr.Mid( 5 + groupIdSize, groupKeySize ).AllocL();
+
+            // Set the content ID of this file to the group ID
+            delete iContentID;
+            iContentID = NULL;
+            iContentID = iGroupId->AllocL();
+
+            CleanupStack::PopAndDestroy( buffer );
+            }
+        aOffset += size;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadMutableInfoL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ReadMutableInfoL(
+    TInt aOffset,
+    TInt& aSize )
+    {
+    TInt size( 0 );
+    TInt dataSize( 0 );
+    TUint32 type( 0 );
+    TInt headerSize( 0 );
+    TPtr8 ptr( 0, 0 );
+    HBufC8* buffer1( NULL );
+    TInt boxEnd( 0 );
+    TInt offset( 0 );
+
+    delete iTransactionTracking;
+    iTransactionTracking = NULL;
+    iRightsObjects.ResetAndDestroy();
+
+    ReadBoxSizeAndTypeL( aOffset, aSize, type, headerSize );
+    VerifyTypeL( type, KMutableInfo );
+
+    if ( !iMutablePart )
+        {
+        iMutablePart = COma2DcfPartInfo::NewL();
+        iMutablePart->iType = type;
+        iMutablePart->iSize = aSize;
+        iMutablePart->iOffset = aOffset;
+        }
+
+
+    boxEnd = aOffset + aSize;
+    aOffset += headerSize;
+
+    do
+        {
+        ReadBoxSizeAndTypeL( aOffset, size, type, headerSize );
+        if ( headerSize > 0 )
+            {
+            dataSize = size - headerSize - KLengthVersion - KLengthFlags;
+            offset = aOffset + headerSize + KLengthVersion + KLengthFlags;
+            // input validation
+            if ( dataSize < 0 || dataSize > KMaxTInt / 2 )
+                {
+                User::Leave( KErrArgument );
+                }
+            if ( type == KTransactionTracking && !iTransactionTracking )
+                {
+                buffer1 = HBufC8::NewLC( dataSize );
+                ptr.Set( buffer1->Des() );
+                User::LeaveIfError( iFile.Read( offset, ptr, dataSize ) );
+                CleanupStack::Pop( buffer1 );
+                iTransactionTracking = buffer1;
+                }
+            else if ( type == KRightsObject )
+                {
+                buffer1 = HBufC8::NewLC( dataSize );
+                ptr.Set( buffer1->Des() );
+                User::LeaveIfError( iFile.Read( offset, ptr, dataSize ) );
+                CleanupStack::Pop( buffer1 );
+                iRightsObjects.Append( buffer1 );
+                }
+            }
+        aOffset += size;
+
+        }
+    while ( headerSize > 0 && aOffset < boxEnd && offset <= iLength );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadBoxSizeAndTypeL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ReadBoxSizeAndTypeL(
+    TInt aOffset,
+    TInt& aSize,
+    TUint32& aType,
+    TInt& aHeaderSize )
+    {
+    TBuf8< KLengthBoxSize + KLengthBoxType > buffer;
+
+    aHeaderSize = 0;
+    // input validation
+    if ( aOffset < 0 || aOffset > iLength )
+        {
+        // Valid offset can never be negative
+        // or greater than length of the opened file.
+        User::Leave( KErrArgument );
+        }
+    User::LeaveIfError( iFile.Read( aOffset, buffer ) );
+    if ( buffer.Length() == KLengthBoxSize + KLengthBoxType )
+        {
+        aSize = ReadUint32FromBlock( buffer, 0 );
+        aType = ReadUint32FromBlock( buffer, 4 );
+        aHeaderSize = KLengthBoxSize + KLengthBoxType;
+
+        if ( aSize == 1 )
+            {
+            buffer.SetLength( 0 );
+            User::LeaveIfError( iFile.Read( buffer ) );
+            if ( buffer.Length() < KLengthBoxSize + KLengthBoxType )
+                {
+                User::Leave( KErrArgument );
+                }
+            if ( ReadUint32FromBlock( buffer, 0 ) > 0 )
+                {
+                User::Leave( KErrOverflow );
+                }
+            aSize = ReadUint32FromBlock( buffer, 4 );
+            aHeaderSize += KLengthBoxSize64;
+            }
+        else if ( aSize == 0 )
+            {
+            aSize = iLength - aOffset;
+            }
+        else if ( aType == KContainer )
+            {
+            // oma drm container box must always have large length field set
+            // See DRM-DCF-CLI-15 in OMA-TS-DRM-DCF-V2_1.
+            User::Leave( KErrArgument );
+            }
+        }
+    // Valid box size can never be smaller than discovered header size.
+    // Nor can it be larger than largest supported ISO based media box size.
+    ValidateBoxSizeL( aSize, aHeaderSize, KMaxBoxSize - aOffset );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::VerifyTypeL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::VerifyTypeL( TUint32 aType, TUint32 aRefType )
+    {
+    if ( aRefType != aType )
+        {
+        User::Leave( KErrArgument );
+        };
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::SetTransactionIdL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void COma2Dcf::SetTransactionIdL(
+    const TDesC8& aTransactionId )
+    {
+    // Overwrite existing ID, otherwise, recreate the whole MDRI box
+    if ( iTransactionTracking )
+        {
+        TInt size( 0 );
+        TUint32 type( 0 );
+        TInt headerSize( 0 );
+        TInt offset( 0 );
+
+        offset = iMutablePart->iOffset;
+        // Read mutable box headers and skip them
+        ReadBoxSizeAndTypeL( offset, size, type, headerSize );
+        offset += headerSize;
+        do
+            {
+            ReadBoxSizeAndTypeL( offset, size, type, headerSize );
+            if ( type != KTransactionTracking )
+                {
+                offset += size;
+                }
+            }
+        while ( headerSize > 0 &&
+            type != KTransactionTracking && offset <= iLength );
+
+
+        if ( type == KTransactionTracking )
+            {
+            offset += headerSize + KLengthVersion + KLengthFlags;
+            User::LeaveIfError( iFile.Write( offset, aTransactionId ) );
+            }
+        }
+    else
+        {
+        RewriteMutableInfoL( aTransactionId, iRightsObjects );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::SetRightsObjectsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void COma2Dcf::SetRightsObjectsL(
+    RPointerArray<HBufC8>& aRoList )
+    {
+    // Always recreate the whole MDRI box, it's simpler
+    if ( iTransactionTracking )
+        {
+        RewriteMutableInfoL( *iTransactionTracking, aRoList );
+        }
+    else
+        {
+        RewriteMutableInfoL( KNullDesC8, aRoList );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::RewriteMutableInfoL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::RewriteMutableInfoL(
+    const TDesC8& aTransactionId,
+    RPointerArray<HBufC8>& aRoList )
+    {
+    TInt offset( 0 );
+    TBuf8<4> buffer;
+    TInt sizeOfRoBoxes( 0 );
+    TInt roBoxSize( 0 );
+    TInt tidBoxSize( 0 );
+    TInt mutableBoxSize( 0 );
+
+    // Remove the existing box
+    if ( iMutablePart )
+        {
+        User::LeaveIfError( iFile.SetSize( iMutablePart->iOffset ) );
+        }
+
+    // Append the box to the end of the file
+    User::LeaveIfError( iFile.Size( offset ) );
+
+    for ( TInt i( 0 ); i < aRoList.Count(); i++ )
+        {
+        sizeOfRoBoxes += aRoList[ i ]->Size() +
+            KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags;
+        }
+    tidBoxSize = 16 +
+        KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags;
+    mutableBoxSize =
+        KLengthBoxSize + KLengthBoxType + tidBoxSize + sizeOfRoBoxes;
+
+    // MDRI box
+    WriteIntToBlock( mutableBoxSize, buffer, 0 );
+    User::LeaveIfError( iFile.Write( offset, buffer ) );
+    User::LeaveIfError( iFile.Write( KMdri ) );
+
+    // ODTT box ( always written )
+    WriteIntToBlock( tidBoxSize, buffer, 0 );
+    User::LeaveIfError( iFile.Write( buffer ) );
+    User::LeaveIfError( iFile.Write( KOdtt ) );
+    buffer.FillZ();
+    User::LeaveIfError( iFile.Write( buffer ) );
+    if ( aTransactionId.Size() > 0 )
+        {
+        User::LeaveIfError( iFile.Write( aTransactionId ) );
+        }
+    else
+        {
+        User::LeaveIfError( iFile.Write( KEmptyTransactionId ) );
+        }
+
+    // ODRB box
+    if ( sizeOfRoBoxes > 0 )
+        {
+        for ( TInt i( 0 ); i < aRoList.Count(); i++ )
+            {
+            roBoxSize = aRoList[ i ]->Size() +
+                KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags;
+            WriteIntToBlock( roBoxSize, buffer, 0 );
+            User::LeaveIfError( iFile.Write( buffer ) );
+            User::LeaveIfError( iFile.Write( KOdrb ) );
+            buffer.FillZ();
+            User::LeaveIfError( iFile.Write( buffer ) );
+            User::LeaveIfError( iFile.Write( *aRoList[ i ] ) );
+            }
+        }
+
+    // Reread the MDRI box
+    User::LeaveIfError( iFile.Size( iLength ) );
+    ReadMutableInfoL( offset, mutableBoxSize );
+    }
+
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadPartInfoL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ReadPartInfoL(
+    COma2DcfPartInfo* aPart,
+    TInt aOffset )
+    {
+    TBuf8<4> buffer;
+    TUint32 size( 0 );
+    TPtr8 ptr( NULL, 0 );
+
+    // ODRM box header
+    buffer.SetLength( 0 );
+
+    // input validation
+    if ( aOffset < 0 )
+        {
+        // RFile::Read will panic if offset is negative
+        User::Leave( KErrArgument );
+        }
+
+    iFile.Read( aOffset, buffer, 4 );
+    size = ReadUint32FromBlock( buffer, 0 );
+    aOffset += KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags;
+    if ( size == 1 )
+        {
+        aOffset += KLengthBoxSize64;
+        }
+
+    // Discrete headers box header
+    buffer.SetLength( 0 );
+    iFile.Read( aOffset, buffer, 4 );
+    if ( buffer.Length() < 4 )
+        {
+        User::Leave( KErrArgument );
+        }
+    size = ReadUint32FromBlock( buffer, 0 );
+    aOffset += KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags;
+    if ( size == 1 )
+        {
+        aOffset += KLengthBoxSize64;
+        }
+
+    // Content type
+    buffer.SetLength( 0 );
+    iFile.Read( aOffset, buffer, 1 );
+    if ( buffer.Length() < 1 )
+        {
+        User::Leave( KErrArgument );
+        }
+    aPart->iMimeType = HBufC8::NewL( buffer[ 0 ] );
+    ptr.Set( aPart->iMimeType->Des() );
+    iFile.Read( ptr, buffer[ 0 ] );
+    aOffset += 1 + buffer[ 0 ];
+
+    // Common headers box header
+    buffer.SetLength( 0 );
+    iFile.Read( aOffset, buffer, 4 );
+    if ( buffer.Length() < 4 )
+        {
+        User::Leave( KErrArgument );
+        }
+    size = ReadUint32FromBlock( buffer, 0 );
+    aOffset += KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags;
+    if ( size == 1 )
+        {
+        aOffset += KLengthBoxSize64;
+        }
+
+    // Content ID
+    aOffset += KLengthEncMethod + KLengthPadType + KLengthPlainTextSize;
+    buffer.SetLength( 0 );
+    iFile.Read( aOffset, buffer, 2 );
+    if ( buffer.Length() < 2 )
+        {
+        User::Leave( KErrArgument );
+        }
+    aPart->iContentId = HBufC8::NewL( ReadUint16FromBlock( buffer, 0 ) );
+    ptr.Set( aPart->iContentId->Des() );
+    aOffset += KLengthContentIdSize + KLengthRiUrlSize + KLengthTextHeadersSize;
+    iFile.Read( aOffset, ptr, ReadUint16FromBlock( buffer, 0 ) );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadUserDataL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ReadUserDataL(
+    TInt aOffset,
+    TInt& aSize )
+    {
+    TInt size( 0 );
+    TUint32 type( 0 );
+    TPtr8 ptr( 0, 0 );
+
+    ReadBoxSizeAndTypeL( aOffset, aSize, type, size );
+    VerifyTypeL( type, KUserData );
+    aOffset += size;
+
+    delete iUserData;
+    iUserData = NULL;
+    iUserData = HBufC8::NewL( aSize );
+    User::LeaveIfNull( iUserData );
+
+    ptr.Set( iUserData->Des() );
+    User::LeaveIfError( iFile.Read( aOffset, ptr, aSize ) );
+    aOffset += aSize;
+
+    ParseUserDataSubBoxesL( ptr );
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ParseUserDataSubBoxesL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ParseUserDataSubBoxesL(
+    const TDesC8& aMemoryBlock )
+    {
+
+    // there MAY be zero to several boxes
+    // depending on language definition.
+    // here only the first boxes are read out.
+
+    iUserDataLanguageDefined = ETrue;
+
+    // if not found from textual custom headers, try to read out from udta
+    if ( !iTitle )
+        {
+        ReadOneUserDataBoxL( aMemoryBlock, KTitle, iTitle );
+        }
+
+    // if not found from textual custom headers, try to read out from udta
+    if ( !iDescription )
+        {
+        ReadOneUserDataBoxL( aMemoryBlock, KDescription, iDescription );
+        }
+
+    // if not found from textual custom headers, try to read out from udta
+    if ( !iCopyRight )
+        {
+        ReadOneUserDataBoxL( aMemoryBlock, KCopyright, iCopyRight );
+        }
+
+    // if not found from textual custom headers, try to read out from udta
+    if ( !iAuthor )
+        {
+        ReadOneUserDataBoxL( aMemoryBlock, KAuthor, iAuthor );
+        }
+
+    ReadOneUserDataBoxL( aMemoryBlock, KPerformer, iPerformer );
+
+    ReadOneUserDataBoxL( aMemoryBlock, KGenre, iGenre );
+
+    ReadOneUserDataBoxL( aMemoryBlock, KRating, iRatingInfo );
+
+    ReadOneUserDataBoxL( aMemoryBlock, KClassification, iClassificationInfo );
+
+    ReadOneUserDataBoxL( aMemoryBlock, KKeyword, iKeyword );
+
+    ReadOneUserDataBoxL( aMemoryBlock, KLocationInformation, iLocInfoName );
+
+    ReadOneUserDataBoxL( aMemoryBlock, KAlbum, iAlbumTitle );
+
+
+    // These boxes do not contain language information ->
+
+    iUserDataLanguageDefined = EFalse;
+
+    // if not found from textual custom headers, try to read out from udta
+    if ( !iIconUri )
+        {
+        ReadOneUserDataBoxL( aMemoryBlock, KIconUri, iIconUri );
+        }
+
+    ReadOneUserDataBoxL( aMemoryBlock, KInfoURL, iInfoUri );
+
+    ReadOneUserDataBoxL( aMemoryBlock, KCoverUri, iCoverUri );
+
+    ReadOneUserDataBoxL( aMemoryBlock, KLyricsURL, iLyricsURL );
+
+
+    TInt yearOffset( iUserData->Find( KRecordingYear ) );
+    if ( yearOffset != KErrNotFound )
+        {
+        yearOffset += sizeof( tBoxHeaderStr ) - KLengthBoxSize;
+        iRecordingYear = ReadUint16FromBlock( iUserData->Des(), yearOffset );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::ReadOneUserDataBoxL
+// -----------------------------------------------------------------------------
+//
+void COma2Dcf::ReadOneUserDataBoxL(
+    const TDesC8& aBlock,
+    const TDesC8& aName,
+    HBufC8*& aBuffer )
+    {
+
+    TInt offset( aBlock.Find( aName ) );
+    TUint32 length( 0 );
+    HBufC8* subBlock( NULL );
+    TInt subOffset( 0 );
+    TBuf8<12> buffer;
+
+    delete aBuffer;
+    aBuffer = NULL;
+
+    if ( offset == KErrNotFound )
+        {
+        return;
+        }
+    else
+        {
+
+        TUint8* pData( const_cast< TUint8* >( aBlock.Ptr() ) );
+        offset -= KLengthBoxSize;
+        pData += offset;
+
+        buffer.SetLength( 0 );
+        buffer.Copy( pData, 12 );
+
+        tBoxHeaderStr* SubBox = ( tBoxHeaderStr* ) buffer.Ptr();
+        length = SWAP32( SubBox->size );
+
+        subBlock = aBlock.Mid( offset, length ).AllocLC();
+
+        subOffset += sizeof( tBoxHeaderStr );
+
+        if ( aName == KClassification )
+            {
+            TUint32 classificationEntity(
+                ReadUint32FromBlock( subBlock->Des(), subOffset ) );
+            subOffset += sizeof( classificationEntity );
+
+            TUint16 classificationTable(
+                ReadUint16FromBlock( subBlock->Des(), subOffset ) );
+            subOffset += sizeof( classificationTable );
+            }
+
+        if ( aName == KRating )
+            {
+            TUint32 ratingEntity(
+                ReadUint32FromBlock( subBlock->Des(), subOffset ) );
+            subOffset += sizeof( ratingEntity );
+
+            TUint32 ratingCriteria(
+                ReadUint32FromBlock( subBlock->Des(), subOffset ) );
+            subOffset += sizeof( ratingCriteria );
+            }
+
+        if ( iUserDataLanguageDefined )
+            {
+            TUint16 PadAndLanguage(
+                ReadUint16FromBlock( subBlock->Des(), subOffset ) );
+            subOffset += sizeof( PadAndLanguage );
+            }
+
+
+        if ( aName == KKeyword )
+            {
+            // we return all keywords here
+            aBuffer = HBufC8::NewL( length );
+            TUint8 keywordCnt( subBlock->Des()[ subOffset ] );
+            TUint8 keywordSize( 0 );
+
+            subOffset += sizeof( keywordCnt );
+
+            for ( TInt count( 0 ); count < keywordCnt; count++ )
+                {
+                keywordSize = subBlock->Des()[ subOffset ];
+                subOffset += sizeof( keywordSize );
+                aBuffer->Des().Append(
+                    subBlock->Des().Mid( subOffset, keywordSize ) );
+                subOffset += keywordSize;
+                keywordSize = 0;
+                }
+            }
+
+        else if ( aName == KAlbum )
+            {
+            TInt tracknbrFound(
+                subBlock->Des().Mid( subOffset ).Find( KTerminator ) );
+
+            if ( ( tracknbrFound == KErrNotFound ) ||
+                ( tracknbrFound ==
+                  ( subBlock->Des().Length()-subOffset ) - 1 ) )
+                {
+                aBuffer = subBlock->Des().Mid( subOffset ).AllocL();
+                iAlbumTrack = NULL;
+                }
+            else
+                {
+                aBuffer =
+                    subBlock->Des().Mid( subOffset, tracknbrFound ).AllocL();
+                subOffset += tracknbrFound + KLengthTerminator;
+                iAlbumTrack = subBlock->Des()[ subOffset ];
+                }
+            }
+
+        else if ( aName == KLocationInformation )
+            {
+            TInt found( subBlock->Des().Mid( subOffset ).Find( KTerminator ) );
+            aBuffer = subBlock->Des().Mid( subOffset, found ).AllocL();
+            subOffset += found + KLengthTerminator;
+
+            TUint8 role( subBlock->Des()[ subOffset ] );
+            subOffset += sizeof( role );
+            TUint32 longitude(
+                ReadUint32FromBlock( subBlock->Des(), subOffset ) );
+            subOffset += sizeof( longitude );
+            TUint32 latitude(
+                ReadUint32FromBlock( subBlock->Des(), subOffset ) );
+            subOffset += sizeof( latitude );
+            TUint32 altitude(
+                ReadUint32FromBlock( subBlock->Des(), subOffset ) );
+            subOffset += sizeof( altitude );
+
+            found = subBlock->Des().Mid( subOffset ).Find( KTerminator );
+
+            // iLocInfoAstronomicalBody =
+            //    subBlock->Des().Mid( subOffset, found ).AllocL();
+            subOffset += found + KLengthTerminator;
+
+            found = subBlock->Des().Mid( subOffset ).Find( KTerminator );
+            // iLocInfoAdditionalNotes =
+            //    subBlock->Des().Mid( subOffset, found ).AllocL();
+            }
+        else
+            {
+            aBuffer = subBlock->Des().Mid( subOffset ).AllocL();
+            }
+        CleanupStack::PopAndDestroy( subBlock );
+        }
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcf/src/Oma2DcfPartInfo.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <f32file.h>
+#include <utf.h>
+#include <caf/caf.h>
+#include "Oma2Agent.h"
+#include "Oma2Dcf.h"
+#include "Oma2DcfPartInfo.h"
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type);
+
+// CONSTANTS
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+/*
+?type ?function_name(
+    ?arg_type arg,  // ?description
+    ?arg_type arg)  // ?description
+    {
+
+    ?code  // ?comment
+
+    // ?comment
+    ?code
+    }
+*/
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::COma2Dcf
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+COma2DcfPartInfo::COma2DcfPartInfo():
+    iContentId(NULL),
+    iMimeType(NULL),
+    iType(0),
+    iSize(0),
+    iOffset(0)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// COma2Dcf::NewL
+// 
+// -----------------------------------------------------------------------------
+//
+COma2DcfPartInfo* COma2DcfPartInfo::NewL()
+    {
+    COma2DcfPartInfo* self = new(ELeave) COma2DcfPartInfo;
+    return self;
+    }
+
+
+// Destructor
+COma2DcfPartInfo::~COma2DcfPartInfo()
+    {
+    delete iContentId;
+    delete iMimeType;
+    }
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/client/src/DcfEntry.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,209 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "DcfEntry.h"
+#include    <e32std.h>
+#include    <e32base.h>
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDcfEntry::CDcfEntry
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDcfEntry::CDcfEntry():iCid(NULL),iFileName(NULL),iPosition(0),iGroupId(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfEntry::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDcfEntry::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfEntry::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDcfEntry* CDcfEntry::NewL()
+    {
+    CDcfEntry* self = new( ELeave ) CDcfEntry;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+    
+// Destructor
+EXPORT_C CDcfEntry::~CDcfEntry()
+    {
+    delete iGroupId;
+    delete iCid;    
+    delete iFileName;    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDcfEntry::SetCidL
+// Set content ID
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDcfEntry::SetCidL(const TDesC8& aCid)
+    {
+    if(iCid)
+        {
+        delete iCid; 
+        iCid = NULL;   
+        }
+    iCid = HBufC8::NewL(aCid.Length());
+    TPtr8 ptr(iCid->Des());
+    ptr.Copy(aCid);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDcfEntry::SetGroupIdL
+// Set group ID
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDcfEntry::SetGroupIdL(const TDesC8& aGroupId)
+    {
+    if(iGroupId)
+        {
+        delete iGroupId;    
+        iGroupId = NULL;
+        }
+    iGroupId = HBufC8::NewL(aGroupId.Length());
+    TPtr8 ptr(iGroupId->Des());
+    ptr.Copy(aGroupId);
+    }
+
+    
+// -----------------------------------------------------------------------------
+// CDcfEntry::SetLocationL
+// Set file name and position inside the file
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDcfEntry::SetLocationL(const TDesC& aFile, const TUint16& aPos)
+    {
+    if(iFileName)
+        {
+        delete iFileName;    
+        iFileName = NULL;
+        }
+    iFileName = HBufC::NewL(aFile.Length());
+    TPtr ptr(iFileName->Des());
+    ptr.Copy(aFile);
+    iPosition = aPos;    
+    }    
+    
+// -----------------------------------------------------------------------------
+// CDcfEntry::FileName
+// return filename
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC16& CDcfEntry::FileName() const
+    {
+    if (iFileName)
+        {
+        return *iFileName;    
+        }
+    else
+        {
+        return KNullDesC;        
+        }
+    }   
+    
+// -----------------------------------------------------------------------------
+// CDcfEntry::Position
+// return position inside the file
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TUint16 CDcfEntry::Position() const
+    {
+    return iPosition;
+    }     
+
+// -----------------------------------------------------------------------------
+// CDcfEntry::Cid
+// return content ID
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CDcfEntry::Cid() const
+    {
+    if (iCid)
+        {
+        return *iCid;  
+        }
+    else
+        {
+        return KNullDesC8;        
+        }
+    
+    } 
+    
+    
+// -----------------------------------------------------------------------------
+// CDcfEntry::GroupId
+// return group ID
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CDcfEntry::GroupId() const
+    {
+    if (iGroupId)
+        {
+        return *iGroupId;  
+        }
+    else
+        {
+        return KNullDesC8;        
+        }
+    
+    } 
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/client/src/DcfRep.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,797 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  API wrapper side implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include    "DcfRep.h"
+#include    "DcfEntry.h"
+#include    "DcfRepCommon.h"
+#include    <e32std.h>
+#include    <e32base.h>
+#include    <DRMRightsClient.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES
+// CONSTANTS
+_LIT(KSqlOrderList , "select filename,position,cid,group from dcf");
+_LIT(KSqlOrderListStart , "select filename,position,cid,group from dcf where cid = '");
+_LIT(KSqlOrderListEnd , "' order by filename");
+_LIT(KSqlOrderListGroupStart , "select filename,position,cid,group from dcf where group = '");
+_LIT(KSqlOrderListGroupEnd , "' order by filename");
+_LIT(KSqlGetTtidStart , "select ttid from dcf where cid = '");
+_LIT(KSqlGetTtidEnd , "' order by ttid");
+_LIT(KSqlGetFileStart , "select filename from dcf where cid = '");
+_LIT(KSqlGetFileEnd , "' order by filename");
+_LIT(KSqlGetCidStart , "select cid from dcf where filename = '");
+_LIT(KSqlGetCidEnd , "' order by cid");
+_LIT(KSqlDeleteStart , "delete from dcf where filename = '");
+_LIT(KSqlDeleteEnd , "'");
+_LIT8(KFlkString, "flk:");
+_LIT8(KCidString, "cid:");
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+static const TInt KDcfRepExtra( 100 );
+#ifdef RD_MULTIPLE_DRIVE
+_LIT( KDbFileLoc, "%c:\\system\\data\\DcfRepDb" );
+#endif
+
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// From8To16
+//
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt From8To16( const TDesC8& a8 , HBufC16*& a16 )
+    {
+    TInt err = KErrNone;
+    a16 = HBufC::NewMax( a8.Length() );
+    if ( a16 )
+        {
+        TPtr ptr( a16->Des() );
+        ptr.SetLength( a8.Length() );
+        for (TInt i = 0 ; i<a8.Length() ; i++ )
+            {
+            ptr[i] = ( unsigned char ) a8[i];
+            }
+        }
+    else
+        {
+        err = KErrNoMemory;
+        }
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// From16To8
+//
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt From16To8( const TDesC& a16 , HBufC8*& a8 )
+    {
+    TInt err = KErrNone;
+    a8 = HBufC8::NewMax( a16.Length() );
+    if ( a8 )
+        {
+        TPtr8 ptr( a8->Des() );
+        ptr.SetLength(a16.Length());
+        for (TInt i = 0 ; i<a16.Length() ; i++ )
+            {
+            ptr[i] = ( unsigned char ) a16[i];
+            }
+        }
+    else
+        {
+        err = KErrNoMemory;
+        }
+    return err;
+    }
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDcfRep::CDcfRep
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDcfRep::CDcfRep()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDcfRep::ConstructL()
+    {
+    User::LeaveIfError(iClient.Connect());
+    OpenDatabaseL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDcfRep* CDcfRep::NewL()
+    {
+    CDcfRep* self = new( ELeave ) CDcfRep;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+
+// Destructor
+EXPORT_C CDcfRep::~CDcfRep()
+    {
+    iClient.Close();
+    iView.Close();
+    iDb.Close();
+    iDbs.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::UpdateL
+// Add new entry to database
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDcfRep::UpdateL( const CDcfEntry* aEntry)
+    {
+    if ( !aEntry || ( aEntry->FileName().Length() <= 0 && aEntry->Cid().Length() <= 0 ) )
+        {
+        User::Leave(KErrArgument);
+        }
+    else if ( aEntry->FileName().Length() > 0)
+        {
+        // Filename is defined. If content ID is defined as well, we igore content ID
+        TInt err = 0;
+        HBufC8* buf8 = NULL;
+        RPointerArray<HBufC8> list8;
+        CleanupClosePushL(list8);
+        User::LeaveIfError(iClient.AddFile(aEntry->FileName()));
+        GetCidL(aEntry->FileName(),list8);
+        for (TInt i = 0 ; i<list8.Count() && (!err) ; i++ )
+            {
+            TParse p;
+            err = p.Set(aEntry->FileName(),NULL,NULL);
+            if (!err)
+                {
+                buf8 = list8[i];
+                err = SetName(*buf8,p.NameAndExt());
+                }
+            }
+        // clean list first then leave if errors occured
+        list8.ResetAndDestroy();
+        User::LeaveIfError(err);
+        CleanupStack::PopAndDestroy(&list8);
+        }
+    else
+        {
+        // only content ID is defined
+        TInt err = 0;
+        HBufC* buf16 = NULL;
+        RPointerArray<HBufC> list16;
+        CleanupClosePushL(list16);
+        GetFilenameL(aEntry->Cid(),list16);
+        for (TInt i = 0 ; i<list16.Count() && (!err) ; i++ )
+            {
+            if (i==0)
+                {
+                // set name with the first found file. the name is set only when there is no name set before
+                TParse p;
+                err = p.Set(*(list16[i]),NULL,NULL);
+                if (!err)
+                    {
+                    err = SetName(aEntry->Cid(),p.NameAndExt());
+                    }
+                }
+            buf16 = list16[i];
+            if (!err)
+                {
+                err = iClient.AddFile(*buf16);
+                }
+            }
+        // clean list first then leave if errors occured
+        list16.ResetAndDestroy();
+        User::LeaveIfError(err);
+        CleanupStack::PopAndDestroy(&list16);
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDcfRep::GetTtid
+// Get transaction ID from database
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDcfRep::GetTtidL(RArray<TPair>& aList)
+    {
+    TInt i = 0;
+    for (;i<aList.Count();i++)
+        {
+        if ( !(aList[i].iCid) )
+            {
+            User::Leave(KErrArgument);
+            }
+        GetTtidL( *(aList[i].iCid) , aList[i].iTtid);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::GetTtidL
+// Get transaction ID from database
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDcfRep::GetTtidL(const TDesC8& aCid , HBufC8*& aTtid)
+    {
+    TBool flag = ETrue;
+    HBufC* temp = NULL;
+    RDbView view;
+    CleanupClosePushL(view);
+    HBufC* buf = HBufC::NewLC(aCid.Length()+KDcfRepExtra);
+    TPtr ptr(buf->Des());
+    ptr.SetLength(0);
+
+
+    User::LeaveIfError(From8To16(aCid,temp));
+    CleanupStack::PushL(temp);
+    ptr.Append(KSqlGetTtidStart);
+    ptr.Append(*temp);
+    ptr.Append(KSqlGetTtidEnd);
+    CleanupStack::PopAndDestroy(temp); //temp
+
+    User::LeaveIfError(view.Prepare(iDb,TDbQuery(ptr,EDbCompareNormal),TDbWindow::EUnlimited));
+    User::LeaveIfError(view.EvaluateAll());
+    CleanupStack::PopAndDestroy(buf); //buf
+    flag = view.FirstL();
+    if (!flag)
+        {
+        aTtid = NULL;
+        }
+    else
+        {
+        view.GetL();
+        buf = HBufC::NewL(view.ColLength(1));
+        *buf = view.ColDes(1);
+        CleanupStack::PushL(buf);
+        User::LeaveIfError(From16To8(*buf,aTtid));
+        CleanupStack::PopAndDestroy(buf); //buf
+        }
+    CleanupStack::PopAndDestroy(&view);
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::GetFileHandle
+// Get File Handle for a Dcf associated with a specific CID
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDcfRep::GetFileHandleL(
+            const TDesC8& aCid ,
+            RFile& aFile , RFs& aFs )
+    {
+    TInt error = KErrNone;
+    TPtr8 data(NULL,0);
+
+
+    // Try to find the file and get a handle to it with the given string
+    TRAP(error, DoGetFileHandleL( aCid, aFile, aFs ));
+
+
+    // If we can't find a filehandle and the contentid starts with "cid:"
+    // We may have a FL + SD content, so change the "cid:" to flk and search
+    // again
+    if( error == KErrNotFound &&
+        !(aCid.Left(KCidString().Length()).Compare(KCidString()) ) )
+        {
+        HBufC8* url( aCid.AllocLC() );
+        data.Set( const_cast<TUint8*>(url->Ptr()), url->Length(), url->Length() );
+        data.Replace( 0, KCidString().Length(), KFlkString );
+
+        DoGetFileHandleL( data, aFile, aFs );
+        CleanupStack::PopAndDestroy( url );
+        }
+    else
+        {
+        User::LeaveIfError( error );
+        }
+    }
+
+
+
+void CDcfRep::DoGetFileHandleL(
+            const TDesC8& aCid ,
+            RFile& aFile , RFs& aFs )
+    {
+    TBool flag = ETrue;
+    HBufC* temp = NULL;
+    RDbView view;
+    CleanupClosePushL(view);
+    HBufC* buf = HBufC::NewLC(aCid.Length()+KDcfRepExtra);
+    TPtr ptr(buf->Des());
+    ptr.SetLength(0);
+
+
+    User::LeaveIfError(From8To16(aCid,temp));
+    CleanupStack::PushL(temp);
+    ptr.Append(KSqlGetFileStart);
+    ptr.Append(*temp);
+    ptr.Append(KSqlGetFileEnd);
+    CleanupStack::PopAndDestroy(temp); //temp
+    User::LeaveIfError(view.Prepare(iDb,TDbQuery(ptr,EDbCompareNormal),TDbWindow::EUnlimited));
+    User::LeaveIfError(view.EvaluateAll());
+    CleanupStack::PopAndDestroy(buf); //buf
+    flag = view.FirstL();
+    if (!flag)
+        {
+        User::Leave(KErrNotFound);
+        }
+    else
+        {
+        RDbColReadStream strm;
+        TInt err = 0;
+        TBool flag = ETrue;
+        TUint len = 0;
+        while (flag&&view.AtRow())
+            {
+            view.GetL();
+            len = view.ColLength(1);
+            temp = HBufC::NewLC(len);
+            ptr.Set(temp->Des());
+            strm.OpenLC(view,1);
+            strm.ReadL(ptr,len);
+            CleanupStack::PopAndDestroy(&strm);
+            err = aFile.Open(aFs, ptr, EFileRead|EFileShareReadersOrWriters);
+            CleanupStack::PopAndDestroy(temp); // temp
+            if(err == KErrNotFound || err == KErrAccessDenied)
+                {
+                view.NextL();
+                }
+            else
+                {
+                flag = EFalse;
+                }
+            }
+        User::LeaveIfError(err);
+        }
+    CleanupStack::PopAndDestroy(&view);
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDcfRep::NextL
+// Return entries as iteration.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDcfEntry* CDcfRep::NextL()
+    {
+    CDcfEntry* entry = NULL;
+    HBufC16* buf = NULL;
+    HBufC8* temp = NULL;
+    if (iView.AtRow())
+        {
+        TInt len = 0;
+        TUint position = 0;
+        TPtr ptr(NULL,0,0);
+        RDbColReadStream strm;
+
+        entry = CDcfEntry::NewL();
+        CleanupStack::PushL(entry);
+        iView.GetL();
+
+        //Set filename and postion
+        len = iView.ColLength(KOrdFilename);
+        buf = HBufC::NewLC(len);
+        ptr.Set(buf->Des());
+        strm.OpenLC(iView,KOrdFilename);
+        strm.ReadL(ptr,len);
+        position = iView.ColUint16(KOrdPosition);
+        entry->SetLocationL(ptr,position);
+        CleanupStack::PopAndDestroy(&strm);
+        CleanupStack::PopAndDestroy(buf);
+
+
+        // Set content ID
+        len = iView.ColLength(KOrdCid);
+        buf = HBufC::NewLC(len);
+        ptr.Set(buf->Des());
+        strm.OpenLC(iView,KOrdCid);
+        strm.ReadL(ptr,len);
+        CleanupStack::PopAndDestroy(&strm);
+        User::LeaveIfError(From16To8(*buf,temp));
+        CleanupStack::PopAndDestroy(buf); // buf
+        CleanupStack::PushL(temp);
+        entry->SetCidL(*temp);
+        CleanupStack::PopAndDestroy(temp);
+
+
+        //Set Group Id
+        len = iView.ColLength(KOrdGroupId);
+        buf = HBufC::NewLC(len);
+        ptr.Set(buf->Des());
+        if (len>0)
+            {
+            strm.OpenLC(iView,KOrdGroupId);
+            strm.ReadL(ptr,len);
+            CleanupStack::PopAndDestroy(&strm);
+            }
+        else
+            {
+            ptr.SetLength(0);
+            }
+        User::LeaveIfError(From16To8(*buf,temp));
+        CleanupStack::PopAndDestroy(buf); // buf
+        CleanupStack::PushL(temp);
+        entry->SetGroupIdL(*temp);
+        CleanupStack::PopAndDestroy(temp); // temp
+
+        iView.NextL();
+        CleanupStack::Pop(entry); //entry
+        }
+    else
+        {
+        iView.Reset();
+        iView.Close();
+        }
+    return entry;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDcfRep::OrderListL
+// Order all entries from DB.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void  CDcfRep::OrderListL()
+    {
+    TBool flag = ETrue;
+
+    iView.Close();
+
+    User::LeaveIfError(iView.Prepare(
+        iDb,TDbQuery(KSqlOrderList(),EDbCompareNormal),
+        TDbWindow::EUnlimited));
+    User::LeaveIfError(iView.EvaluateAll());
+    flag = iView.FirstL();
+    if (!flag)
+        {
+        iView.Reset();
+        iView.Close();
+        User::Leave(KErrNotFound);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::OrderListL
+// Order all entries with specific CID from DB.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void  CDcfRep::OrderListL(const TDesC8& aCid)
+    {
+    TBool flag = ETrue;
+    HBufC* temp = NULL;
+    HBufC* buf = NULL;
+    TPtr ptr(NULL,0,0);
+
+    iView.Close();
+
+    User::LeaveIfError(From8To16(aCid,temp));
+    CleanupStack::PushL(temp);
+    buf = HBufC::NewLC(aCid.Length()+KDcfRepExtra);
+    ptr.Set(buf->Des());
+    ptr.SetLength(0);
+    ptr.Append(KSqlOrderListStart);
+    ptr.Append(*temp);
+    ptr.Append(KSqlOrderListEnd);
+    User::LeaveIfError(iView.Prepare(
+        iDb,TDbQuery(ptr,EDbCompareNormal),
+        TDbWindow::EUnlimited));
+    User::LeaveIfError(iView.EvaluateAll());
+    flag = iView.FirstL();
+    if (!flag)
+        {
+        // try group id
+        iView.Reset();
+        iView.Close();
+        CleanupStack::PopAndDestroy(buf);
+        buf = HBufC::NewLC(aCid.Length()+KDcfRepExtra);
+        ptr.Set(buf->Des());
+        ptr.SetLength(0);
+        ptr.Append(KSqlOrderListGroupStart);
+        ptr.Append(*temp);
+        ptr.Append(KSqlOrderListGroupEnd);
+        User::LeaveIfError(iView.Prepare(
+            iDb,TDbQuery(ptr,EDbCompareNormal),
+            TDbWindow::EUnlimited));
+        User::LeaveIfError(iView.EvaluateAll());
+        flag = iView.FirstL();
+        if (!flag)
+            {
+            // not group id
+            iView.Reset();
+            iView.Close();
+            CleanupStack::PopAndDestroy( buf );
+            CleanupStack::PopAndDestroy( temp );
+            User::Leave(KErrNotFound);
+            }
+        }
+    CleanupStack::PopAndDestroy( buf );
+    CleanupStack::PopAndDestroy( temp );
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::RemoveDcfFromDbL
+// Remove all the entries that have the filename in database.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDcfRep::RemoveDcfFromDbL( const TDesC& aFileName )
+    {
+
+    TPtr ptr(NULL,0,0);
+    HBufC* sql = NULL;
+    sql= HBufC16::NewLC(KSqlDeleteStart().Length()+aFileName.Length()+KSqlDeleteEnd().Length());
+    *sql = KNullDesC;
+    ptr.Set(sql->Des());
+    ptr.Append(KSqlDeleteStart);
+    ptr.Append(aFileName);
+    ptr.Append(KSqlDeleteEnd);
+    TInt err =iDb.Execute(ptr);
+    CleanupStack::PopAndDestroy(sql); // sql
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::RefreshDcf
+// let server scan file system for Dcfs
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDcfRep::RefreshDcf( TRequestStatus& aStatus )
+    {
+    iClient.ScanDcf(aStatus);
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::RefreshDcf
+// let server scan file system for Dcfs
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDcfRep::RefreshDcf( RPointerArray<HBufC8>& aList , TRequestStatus& aStatus )
+    {
+    iClient.ScanDcf( aList , aStatus );
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::SetTtid
+// Set transaction ID to all Dcfs associated with a specific CID
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDcfRep::SetTtid(
+            RArray<TPair>& aList ,
+            TRequestStatus& aStatus,
+            TBool aRefresh)
+    {
+    if (aRefresh)
+        {
+        iClient.SetTtid( aList , aStatus );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDcfRep::NotifyServerIdle
+// notify if server is in idle.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDcfRep::NotifyServerIdle( TRequestStatus& aStatus )
+    {
+    iClient.NotifyServerIdle( aStatus );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDcfRep::OpenDatabaseL
+// connect database server and open session for it
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDcfRep::OpenDatabaseL()
+    {
+    User::LeaveIfError(iDbs.Connect());
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    User::LeaveIfError(iDb.Open(iDbs,KDbFileLocation()));
+
+#else //RD_MULTIPLE_DRIVE
+
+    RFs fs;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+
+    User::LeaveIfError( fs.Connect() );
+    fs.DriveToChar( driveNumber, driveLetter );
+    fs.Close();
+
+    TFileName dbFile;
+    dbFile.Format( KDbFileLoc, (TUint)driveLetter );
+
+    User::LeaveIfError( iDb.Open( iDbs, dbFile ) );
+
+#endif
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::SetName
+// set name of CID into rights DB
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CDcfRep::SetName(const TDesC8& aCid , const TDesC16& aName)
+    {
+    RDRMRightsClient r;
+    TInt err = 0;
+    err = r.Connect();
+    if (!err)
+        {
+        HBufC* buf = NULL;
+        err = r.GetName(aCid,buf);
+        if ( !err && buf->Des().Length()==0 )
+            {
+            err = r.SetName(aCid,aName);
+            }
+        if (err == KErrNotFound)
+            {
+            err = KErrNone; // if there is no cid, then just ignore adding name to it.
+            }
+        delete buf;
+        }
+    r.Close();
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::GetCidL
+// get cid list for a filename from repository DB
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDcfRep::GetCidL(const TDesC16& aName , RPointerArray<HBufC8>& aList)
+    {
+    TBool flag = EFalse;
+    HBufC8* temp8 = NULL;
+    HBufC* temp16 = NULL;
+    RDbView view;
+    TInt len = 0;
+    CleanupClosePushL(view);
+    HBufC* buf = HBufC::NewLC(aName.Length()+KDcfRepExtra);
+    TPtr ptr(buf->Des());
+    ptr.SetLength(0);
+    ptr.Append(KSqlGetCidStart);
+    ptr.Append(aName);
+    ptr.Append(KSqlGetCidEnd);
+    User::LeaveIfError(view.Prepare(iDb,TDbQuery(ptr,EDbCompareNormal),TDbWindow::EUnlimited));
+    User::LeaveIfError(view.EvaluateAll());
+    CleanupStack::PopAndDestroy(buf); //buf
+    flag = view.FirstL();
+    if (!flag)
+        {
+        User::Leave(KErrNotFound);
+        }
+    else
+        {
+        while (view.AtRow())
+            {
+            view.GetL();
+            len = view.ColLength(1);
+            temp16 = HBufC::NewLC(len);
+            ptr.Set(temp16->Des());
+
+            RDbColReadStream strm;
+            strm.OpenLC(view,1);
+            strm.ReadL(ptr,len);
+            CleanupStack::PopAndDestroy(&strm);
+
+            User::LeaveIfError(From16To8(*temp16,temp8));
+            CleanupStack::PopAndDestroy(temp16); // temp16
+            CleanupStack::PushL(temp8);
+            User::LeaveIfError(aList.Append(temp8));
+            CleanupStack::Pop(temp8); // temp8
+            view.NextL();
+            }
+        }
+    CleanupStack::PopAndDestroy(&view);
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRep::GetFilenameL
+// get filename list for a cid from repository DB
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDcfRep::GetFilenameL(const TDesC8& aCid , RPointerArray<HBufC>& aList)
+    {
+    TBool flag = EFalse;
+    HBufC* temp = NULL;
+    RDbView view;
+    TInt len = 0;
+    CleanupClosePushL(view);
+    HBufC* buf = HBufC::NewLC(aCid.Length()+KDcfRepExtra);
+    TPtr ptr(buf->Des());
+    ptr.SetLength(0);
+    User::LeaveIfError(From8To16(aCid,temp));
+    CleanupStack::PushL(temp);
+    ptr.Append(KSqlGetFileStart);
+    ptr.Append(*temp);
+    ptr.Append(KSqlGetFileEnd);
+    CleanupStack::PopAndDestroy(temp); //temp
+    User::LeaveIfError(view.Prepare(iDb,TDbQuery(ptr,EDbCompareNormal),TDbWindow::EUnlimited));
+    User::LeaveIfError(view.EvaluateAll());
+    CleanupStack::PopAndDestroy(buf); //buf
+    flag = view.FirstL();
+    if (!flag)
+        {
+        User::Leave(KErrNotFound);
+        }
+    else
+        {
+        while (view.AtRow())
+            {
+            RDbColReadStream strm;
+            view.GetL();
+            len = view.ColLength(1);
+            temp = HBufC::NewLC(len);
+            ptr.Set(temp->Des());
+            strm.OpenLC(view,1);
+            strm.ReadL(ptr,len);
+            CleanupStack::PopAndDestroy(&strm);
+            User::LeaveIfError(aList.Append(temp));
+            CleanupStack::Pop(temp); // temp
+            view.NextL();
+            }
+        }
+    CleanupStack::PopAndDestroy(&view);
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/client/src/DcfRepCli.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,458 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client implementation
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "DcfRepCli.h"
+#include    "DcfRepCommon.h"
+#include    <e32std.h>
+#include    <e32base.h>
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+LOCAL_C const TUint KDefaultMessageSlots = 4;
+LOCAL_C const TInt32 KServerUid3 = 0x10205CA8;
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+
+//#define _DRM_TESTING
+
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+// ============================ LOCAL FUNCTIONS ===============================
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs );
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName );
+LOCAL_C void CreateLogL();
+LOCAL_C void WriteL( const TDesC8& aText );
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr );
+LOCAL_C void WriteCurrentTimeL();
+#endif
+
+// -----------------------------------------------------------------------------
+// Testing stuff
+// -----------------------------------------------------------------------------
+//
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
+    {
+    _LIT( KLogFile , "c:\\RDcfRepCli.txt" );
+    WriteFileL( text , aFs , KLogFile );
+    }
+
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
+    {
+    RFile file;
+    TInt size;
+    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy(&file); //file
+    }
+
+LOCAL_C void CreateLogL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    User::LeaveIfError( file.Replace( fs , _L("c:\\RDcfRepCli.txt") , EFileWrite ) );
+    file.Close();
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8("\r\n") );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    WriteCurrentTimeL();
+    }
+    
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr )
+    {
+    _LIT8(KErr,": %d");
+    HBufC8* text = HBufC8::NewLC(1000+20);
+    TBuf8<20> num;
+    TPtr8 textptr(text->Des());
+    textptr.Append(aText);
+    num.Format(KErr(),aErr);
+    textptr.Append(num);
+    WriteL(textptr);
+    CleanupStack::PopAndDestroy(text);
+    }
+
+LOCAL_C void WriteCurrentTimeL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+// Date and Time display
+    TTime time;
+    time.HomeTime();
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    time.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    time.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+#endif
+
+
+
+
+
+
+LOCAL_C TInt StartServer();
+LOCAL_C TInt CreateServerProcess();
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDcfRepCli::RDcfRepCli
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RDcfRepCli::RDcfRepCli()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,CreateLogL());
+#endif
+    }
+
+    
+// Destructor
+EXPORT_C RDcfRepCli::~RDcfRepCli()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("~RDcfRepCli")));
+#endif
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDcfRepCli::AddFile
+// add an entry into database
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDcfRepCli::AddFile(const TDesC& aFile)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("AddFile")));
+#endif
+
+    TInt err = 0;
+    err = SendReceive( EAddFile,TIpcArgs( &aFile ) );
+    return err;    
+    }
+
+// -----------------------------------------------------------------------------
+// RDcfRepCli::Connect
+// Connect to DCF Repository Server
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDcfRepCli::Connect()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("Connect")));
+#endif
+
+    TInt error = StartServer();
+
+    if (KErrNone == error)
+        {
+
+        error = CreateSession(KDcfRepSrvName,
+                              Version(),
+                              KDefaultMessageSlots);
+        }
+    return error;
+    }
+    
+// -----------------------------------------------------------------------------
+// RDcfRepCli::Close
+// Close session to server
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDcfRepCli::Close()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("Close")));
+#endif
+
+    RHandleBase::Close();    
+    }
+
+// -----------------------------------------------------------------------------
+// RDcfRepCli::Version
+// 
+// return server version
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TVersion RDcfRepCli::Version() const
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("Version")));
+#endif
+
+    return(TVersion(KDcfRepMajorVersionNumber,
+                    KDcfRepMinorVersionNumber,
+                    KDcfRepBuildVersionNumber));
+    }
+
+// -----------------------------------------------------------------------------
+// RDcfRepCli::ScanDcf
+// triger scaning for file system
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDcfRepCli::ScanDcf(TRequestStatus& aStatus)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("ScanDcf(1)")));
+#endif
+
+    SendReceive( EFullScan , aStatus );    
+    }
+    
+// -----------------------------------------------------------------------------
+// RDcfRepCli::ScanDcf
+// triger scaning for file system
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDcfRepCli::ScanDcf(RPointerArray<HBufC8>& aList , TRequestStatus& aStatus)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("ScanDcf(2)")));
+#endif
+
+    TInt err = 0;
+    TInt i = 0;
+    TRequestStatus* status = &aStatus;
+    err = SendReceive( EScanStart );
+    if (err)
+        {
+        User::RequestComplete( status , err );
+        return;
+        }
+    for (;i<aList.Count();i++)
+        {
+        err = SendReceive( EScanAdd,TIpcArgs(aList[i]) );
+        if (err)
+            {
+            User::RequestComplete( status , err );
+            return;
+            }    
+        }
+    SendReceive(EScanEnd , aStatus);
+    }    
+// -----------------------------------------------------------------------------
+// RDcfRepCli::SetTtid
+// Set transaction ID to all Dcfs associated with a specific CID
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDcfRepCli::SetTtid( 
+            RArray<TPair>& aList ,
+            TRequestStatus& aStatus
+            )
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("SetTtid")));
+#endif
+
+    TInt err = 0;
+    TInt i = 0;
+    TRequestStatus* status = &aStatus;
+    err = SendReceive( ESetTtidStart );
+    if (err)
+        {
+        User::RequestComplete( status , err );
+        return;
+        }
+    for (;i<aList.Count();i++)
+        {
+        if ( aList[i].iCid && aList[i].iTtid != NULL )
+            {
+            err = SendReceive( ESetTtidAdd,TIpcArgs(aList[i].iCid,aList[i].iTtid) );    
+            }
+        if (err)
+            {
+            User::RequestComplete( status , err );
+            return;
+            }
+        }
+    SendReceive(ESetTtidEnd , aStatus);
+    }
+
+// -----------------------------------------------------------------------------
+// RDcfRepCli::NotifyServerIdle
+// notify if server is in idle.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDcfRepCli::NotifyServerIdle( TRequestStatus& aStatus )
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("NotifyServerIdle")));
+#endif
+
+    SendReceive( ENotifyIdle , aStatus );        
+    }
+
+// -----------------------------------------------------------------------------
+// RDcfRepCli::NotifyServerIdle
+// notify if server is in idle.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDcfRepCli::StopWatching()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("StopWatchingL")));
+#endif
+
+    SendReceive( EStopWatching );
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// StartServer
+// Start the server 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt StartServer()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("StartServer")));
+#endif    
+    
+    TInt result = 0;
+
+    TFindServer findDcfRepSrv(KDcfRepSrvName);
+    TFullName name;
+
+    result = findDcfRepSrv.Next(name);
+    if (result == KErrNone)
+        {
+        
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("StartServer->Server already running")));
+#endif  
+        // Server already running
+        return KErrNone;
+        }
+
+    RSemaphore semaphore;       
+    result = semaphore.CreateGlobal(KDcfRepSemaphoreName, 0);
+    if (result != KErrNone)
+        {
+        
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("StartServer->CreateSemaphore"),result));
+#endif
+
+        return  result;
+        }
+
+    result = CreateServerProcess();
+    if (result != KErrNone)
+        {
+        
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("StartServer->CreateServerProcess"),result));
+#endif
+
+        semaphore.Close(); 
+        return  result;
+        }
+
+    semaphore.Wait();
+    semaphore.Close();       
+
+    return  KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CreateServerProcess
+// Create server process 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt CreateServerProcess()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("CreateServerProcess")));
+#endif    
+    TInt result;
+    TUid id;
+    id.iUid = KServerUid3;
+    const TUidType serverUid(KNullUid, KNullUid, id );
+
+
+    RProcess server;
+    result = server.Create( KDcfRepSrvFileName, KNullDesC, serverUid);
+    if (result != KErrNone)
+        {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("CreateServerProcess->server.Create:"),result));
+#endif 
+        return  result;
+        }
+    server.Resume();
+    server.Close();
+
+    return  KErrNone;
+    }
+
+
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/common/DcfRepCommon.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client side header
+*
+*/
+
+
+
+#ifndef DCFREPCOMMON_H
+#define DCFREPCOMMON_H
+
+//  INCLUDES
+
+// CONSTANTS
+//the server version. A version must be specified when
+//creating a session with the server
+const TUint KDcfRepMajorVersionNumber=0;
+const TUint KDcfRepMinorVersionNumber=1;
+const TUint KDcfRepBuildVersionNumber=1;
+const TUint KTtidLen = 16;
+const TUint KOrdFilename = 1;
+const TUint KOrdPosition = 2;
+const TUint KOrdCid = 3;
+const TUint KOrdGroupId = 4;
+const TUint KOrdTtid = 5;
+const TUint KMaxLength =65536;
+const TUint KStartPosition = 0;
+
+_LIT( KDbFileLocation , "c:\\system\\data\\DcfRepDb" );
+_LIT( KDcfRepSrvName ,"CDcfRepSrv" ); // server name
+_LIT( KDcfRepSrvFileName ,"DcfRepSrv.exe" ); // for client to search for server
+_LIT( KDcfRepSrv , "CDCFREPSRV" ); //panic info
+_LIT( KDcfRepSemaphoreName , "DcfRepSemaphore" ); //Semaphore
+_LIT(KDb , "DcfRepDb");
+_LIT(KTable , "dcf");
+_LIT(KColCid , "cid");
+_LIT(KColGroupId , "group");
+_LIT(KColFilename , "filename");
+_LIT(KColPosition , "position");
+_LIT(KColTtid , "ttid");
+
+
+//opcodes used in message passing between client and server
+enum TDcfRepSrvRqst
+    {
+    EScanStart = 201,
+    EScanAdd,
+    EScanEnd,
+    EFullScan,
+    ESetTtidStart,
+    ESetTtidAdd,
+    ESetTtidEnd,
+    EGetFileHandle,
+    EAddFile,
+    ENotifyIdle,
+    EStopWatching
+    };
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+
+
+// CLASS DECLARATION
+
+
+
+#endif      // DCFREPCOMMON_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/server/inc/DcfRepSrv.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,314 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Server declaration
+*
+*/
+
+
+
+#ifndef CDCFREPSRV_H
+#define CDCFREPSRV_H
+
+//  INCLUDES
+#include    <D32DBMS.H>
+#include <e32base.h>
+#include "Pair.h"
+#include "procwatcher.h"
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+enum TDcfRepSrvPanic
+    {
+    ESrvCreateServer = 1000,
+    ECreateTrapCleanup
+    };
+
+enum TServerState
+    {
+    EStateIdle = 0,
+    EStateSetTtid,
+    EStateFullScan,
+    EStateScan   
+    };
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CFileScan;
+class COma2Dcf;
+// CLASS DECLARATION
+
+/**
+*  Server implementation.
+*  DCF Repository
+*
+*  @lib 
+*  @since Series 60 3.0 
+*/
+class CDcfRepSrv : public CServer2, public MWatcherObserver
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDcfRepSrv* NewLC();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CDcfRepSrv();
+
+    public: // New functions
+        
+        /**
+        * Startup starts the actual server after initializing
+        * the cleanup stack and active scheduler.
+        * @since S60Rel3.0
+        * @return system error code if error happens
+        */
+        static TInt Startup(void);
+
+        /**
+        * AddFileL
+        * @since Series 60 3.0
+        * @param aFile file name
+        * @KErrNotSupported if file is not protected file
+        */        
+        void AddFileL( const TDesC& aFile );
+        
+        /**
+        * ProcessFile
+        * @since Series 60 3.0
+        * @param aFile file name
+        * @param aFlag ETrue if the file satisfy to criteria of scanning target
+        * @return system error
+        */
+        TInt ProcessFile( const TDesC& aFile , TInt& aType );
+
+        /**
+        * State
+        * @since Series 60 3.0
+        * @return state of the server
+        */
+        TInt State() const;
+        
+        /**
+        * SetState
+        * @since Series 60 3.0
+        * @param aMode server state
+        * @return 
+        */
+        void SetState(TServerState aMode);
+        
+        /**
+        * CompleteScanning
+        * @since Series 60 3.0
+        * @param aRet return code
+        */
+        void CompleteScanning(TInt err);  
+        
+        
+        /**
+        * SetMessage
+        * @since Series 60 3.0
+        * @param aMessage Message from client
+        */
+        RMessage2* SetMessageL(const RMessage2& aMessage);  
+        
+        /**
+        * Scan
+        * @since Series 60 3.0
+        * @return error code
+        */            
+        TInt Scan();
+ 
+        /**
+        * SetCidList
+        * @since Series 60 3.0
+        * @param aList content ID list
+        */
+        void SetCidList(RPointerArray<HBufC8>*& aList);
+        
+        
+        /**
+        * SetPairList
+        * @since Series 60 3.0
+        * @param aList list of pairs for content ID and transaction ID
+        */
+        void SetPairList(RPointerArray<CPair>*& aList);
+        
+        /**
+        * Stop watching the Rights Server
+        * @since Series 60 3.1
+        */
+        void StopWatchingL();
+        
+        /**
+        * RemoveMessageL
+        * Called by destructor of the session class
+        */
+        void RemoveMessageL( const RMessage2* aMessage );
+    
+            
+    public: // Functions from base classes
+        
+        //class MWatcherObserver
+        
+        /** 
+         * Called when the peer process died
+         *
+         * @since S60 3.0
+         * @param aObject Changed object
+         */
+        void WatchedObjectChangedL( const TDesC& aObject );
+        
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+        
+        // Class CServer
+        /** 
+        * NewSessionL
+        * @since S60Rel3.0
+        */
+        CSession2* NewSessionL( const TVersion& aVersion,
+                                       const RMessage2& aMessage ) const;
+        
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDcfRepSrv();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * StartupL called by StartUp
+        * @since S60 Rel 3.0 
+        */
+        static void StartupL();
+
+        /**
+        * PanicServer will panic with panic code
+        * @since S60 Rel 3.0 
+        */
+        static void PanicServer(TDcfRepSrvPanic aPanic);
+        
+        /**
+        * CleanScanInternal will clean list for Scan
+        * @since S60 Rel 3.0 
+        */        
+        void CleanScanInternal();
+
+        /**
+        * CleanDatabase will close database connection
+        * @since S60 Rel 3.0 
+        */        
+        void CleanDatabase();
+
+        /**
+        * OpenDatabaseL will open database connection
+        * @since S60 Rel 3.0 
+        */          
+        void OpenDatabaseL();
+
+        /**
+        * CleanTableL will clean all items in the table
+        * @since S60 Rel 3.0 
+        */           
+        void CleanTableL();
+
+        /**
+        * AddDomainRoL will add domain RO into file if there is any.
+        * @since S60 Rel 3.0 
+        */         
+        void AddDomainRoL( const TDesC& aFile );
+
+        /**
+        * CheckFileL will check the file type: dcf1,dcf2,plain
+        * @since S60 Rel 3.0 
+        */             
+        void CheckFileL(const TDesC& aFile , TInt& aType);
+
+        /**
+        * StoreFileL will store file info
+        * @since S60 Rel 3.0 
+        */          
+        void StoreFileL(const TDesC& aFile , TInt aType);
+        
+        /**
+        * UpdateDatabaseL will store info into database
+        * @since S60 Rel 3.0 
+        */         
+        void UpdateDatabaseL(
+            const TDesC& aFile, 
+            TInt aPos, 
+            const TDesC& aCid ,
+            const TDesC& aGroupId ,  
+            const TDesC& aTtid);
+
+        /**
+        * ResetTtidL will write new ttid into file
+        * @since S60 Rel 3.0 
+        */
+        void ResetTtidL(
+            const TDesC& aFile, 
+            const TDesC8& aTtid
+            );
+
+        /**
+        * ResetTtidL will write new ttid into file
+        * @since S60 Rel 3.0 
+        */
+        void ResetTtidL(
+            COma2Dcf* aDcf, 
+            const TDesC8& aTtid
+            );        
+        // Prohibit copy constructor if not deriving from CBase.
+        CDcfRepSrv( const CDcfRepSrv& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CDcfRepSrv& operator=( const CDcfRepSrv& );
+
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+        RDbs iDbs;
+        RDbNamedDatabase iDb;
+        RDbView iView;
+        RFs iFs;
+        CFileScan* iScan;
+        RPointerArray<HBufC8>* iCidList;
+        RPointerArray<CPair>* iPairList;
+        RPointerArray<RMessage2> iMessageList;
+        TInt iState;
+        CProcWatcher* iProcWatcher;
+        TBool iArmed;
+        
+        // Reserved pointer for future extension
+        TAny* iReserved;
+
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+
+    };
+
+#endif      // CDCFREPSRV_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/server/inc/DcfRepSrvSes.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,186 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Server Session implementation
+*
+*/
+
+
+
+#ifndef CDCFREPSRVSES_H
+#define CDCFREPSRVSES_H
+
+//  INCLUDES
+#include <e32base.h>
+
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CPair;
+
+// CLASS DECLARATION
+
+
+/**
+*  Server Session implementation.
+*  DCF Repository
+*
+*  @lib 
+*  @since Series 60 3.0 
+*/
+class CDcfRepSrvSes : public CSession2
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDcfRepSrvSes* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CDcfRepSrvSes();
+
+    public: // New functions
+    public: // Functions from base classes
+
+        /**
+        * From CSession2: Handles the service request event.
+        * @since S60Rel3.0
+        * @param aMessage The message related to the event.
+        * @exception Method leaves with appropriate exception value
+        *            if any errors occured.
+        */
+        void ServiceL( const RMessage2& aMessage );
+        
+    protected:  // New functions
+    protected:  // Functions from base classes
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDcfRepSrvSes();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+        
+        /** 
+        * AddFileL() will add a file info into database
+        * @since S60Rel3.0
+        * @param aMessage The message associated to the event.
+        * @Leave with KErrNotSupported if file is not protected file
+        */        
+        void AddFileL( const RMessage2& aMessage );        
+
+        /** 
+        * ServiceL() runs DispatchL() under TRAP harness, so
+        * all errors can be catched properly. DispatchL() then calls
+        * appropriate private method depending on the request.
+        * @since S60Rel3.0
+        * @param aMessage The message associated to the event.
+        */
+        void DispatchL( const RMessage2& aMessage );
+        
+        /** 
+        * FullScanL() will triger the file scan for all DCFs
+        * @since S60Rel3.0
+        * @param aMessage The message associated to the event.
+        */        
+        void FullScanL( const RMessage2& aMessage );
+        
+        
+        /** 
+        * ScanStartL() will initialize scanning dcfs for a list of content ID 
+        * @since S60Rel3.0
+        * @param aMessage The message associated to the event.
+        */        
+        void ScanStartL( const RMessage2& aMessage );
+
+        /** 
+        * ScanAddL() will add content ID into CID list for scanning
+        * @since S60Rel3.0
+        * @param aMessage The message associated to the event.
+        */        
+        void ScanAddL( const RMessage2& aMessage );
+        
+        /** 
+        * ScanEndL() will finnally triger scanning dcfs for a list of content ID 
+        * @since S60Rel3.0
+        * @param aMessage The message associated to the event.
+        */        
+        void ScanEndL( const RMessage2& aMessage );
+        
+        
+        /** 
+        * SetTtidStartL() will initialize Ttid reset for a list of content ID 
+        * @since S60Rel3.0
+        * @param aMessage The message associated to the event.
+        */        
+        void SetTtidStartL( const RMessage2& aMessage );
+
+        /** 
+        * SetTtidAddL() will add a pair of content ID and transaction ID (ttid) into list for reset
+        * @since S60Rel3.0
+        * @param aMessage The message associated to the event.
+        */        
+        void SetTtidAddL( const RMessage2& aMessage );
+        
+        /** 
+        * SetTtidEndL() will finnally triger scanning dcfs in order to reset them
+        * @since S60Rel3.0
+        * @param aMessage The message associated to the event.
+        */        
+        void SetTtidEndL( const RMessage2& aMessage );
+
+        /** 
+        * NotifyIdleL() will notify if server becomes idle
+        * @since S60Rel3.0
+        * @param aMessage The message associated to the event.
+        */            
+        void NotifyIdleL( const RMessage2& aMessage );
+        
+        /** 
+        * Stop watching the RightsServer
+        * @since S60Rel3.1
+        * @param aMessage The message associated to the event.
+        */            
+        void StopWatchingL( const RMessage2& aMessage );
+        
+        // Prohibit copy constructor if not deriving from CBase.
+        CDcfRepSrvSes( const CDcfRepSrvSes& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CDcfRepSrvSes& operator=( const CDcfRepSrvSes& );
+
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+        TInt iPreviousAction;
+        RPointerArray<HBufC8>* iCidList;
+        RPointerArray<CPair>* iPairList;
+        RMessage2* iMessage;
+
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+    };
+
+#endif      // CDCFREPSRVSES_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/server/inc/FileScan.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,161 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Server common implementation
+*
+*/
+
+
+#ifndef CFILESCAN_H
+#define CFILESCAN_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+class RFs;
+class CDcfRepSrv;
+class CDir;
+class CSearchLeaf;
+/**
+*  CFileScan
+*
+*  @lib DcfRepSrv.exe
+*  @since 3.0
+*/
+class CFileScan : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CFileScan* NewL( RFs& aFs );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CFileScan();
+
+    public: // New functions
+        
+
+		
+		
+		/**
+		*
+        * SearchContent
+		*
+		* Function starts the active objects to search protected file through whole file system 
+		*
+        * @since 2.5
+        * @return KErrNone if correctly done
+        */
+		TInt SearchContent(CDcfRepSrv* aServer);
+
+
+    public: // Functions from base classes
+
+		/**
+		*
+		* From CActive
+		*
+        * DoCancel
+		*
+		* Function is called by Cancel() and set all status to initial status.
+		*
+        * @since 2.5
+		*/
+		void DoCancel();
+		
+		/**
+		*
+		* From CActive
+		*
+        * DoCancel
+		*
+		* Function is called when the request is completed
+		*
+        * @since 2.5
+		*/
+		void RunL();
+        
+    protected:  // New functions
+    protected:  // Functions from base classes
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CFileScan( RFs& aFs );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+		TInt SearchDrive();
+
+		TInt SearchFolder( CDir*& aFolderList );
+
+		TInt SearchFile( CDir*& aFileList );
+
+		TInt SearchNext();
+
+		TInt CheckDrive();
+
+		TInt CheckFolder();
+		
+		TInt IsProtected( const TDesC& aFileName , TBool& aIsDCF );
+
+		TInt ToNextLeaf();
+
+		TInt UpFolder();
+
+		void CleanInternal();
+		
+		CSearchLeaf* GetRootLeaf();
+
+    public:     // Data
+    
+    protected:  // Data
+
+    private:    // Data
+        CDcfRepSrv* iServer; //server
+		RFs* iFs;
+		TFileName iLastPosition;
+		CSearchLeaf* iCurrentLeaf;
+		TBool iSearching;
+		TBool iDeeper;
+		
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+
+
+#endif      // CFILESCAN_H 
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/server/inc/Pair.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Server common implementation
+*
+*/
+
+
+
+#ifndef CPAIR_H
+#define CPAIR_H
+
+//  INCLUDES
+#include <e32base.h>
+
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+// CLASS DECLARATION
+
+
+/**
+*  Server Session implementation.
+*  DCF Repository
+*
+*  @lib 
+*  @since Series 60 3.0 
+*/
+class CPair : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CPair* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CPair();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CPair();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        CPair( const CPair& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CPair& operator=( const CPair& );
+
+    public:     // Data
+        HBufC8* iCid;
+        HBufC8* iTtid;
+
+    };
+
+#endif      // CPAIR_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/server/inc/SearchLeaf.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Server common implementation
+*
+*/
+
+
+
+#ifndef CSEARCHLEAF_H
+#define CSEARCHLEAF_H
+
+//  INCLUDES
+#include <e32base.h>
+
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CDir;
+
+// CLASS DECLARATION
+
+
+/**
+*  Server Session implementation.
+*  DCF Repository
+*
+*  @lib 
+*  @since Series 60 3.0 
+*/
+class CSearchLeaf : public CBase
+	{
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CSearchLeaf* NewL( CSearchLeaf*& aRoot , const TDesC& aFolderName );
+        static CSearchLeaf* NewLC( CSearchLeaf*& aRoot , const TDesC& aFolderName );      
+
+        /**
+        * Destructor.
+        */
+        virtual ~CSearchLeaf();	
+
+		const TDesC& FolderName();
+	
+		CSearchLeaf*& Root();
+		
+		RPointerArray<CSearchLeaf>& LeafList();
+
+		void SetLeafL( CDir*& aLeaf );
+
+		void RemoveLeaf( CSearchLeaf*& aLeaf );
+	
+	protected:
+
+	private:
+       /**
+        * C++ default constructor.
+        */
+        CSearchLeaf( CSearchLeaf*& aRoot );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( const TDesC& aFolderName );
+
+
+	public:     // Data
+    protected:  // Data
+    private:    // Data
+		CSearchLeaf* iRoot;
+		RPointerArray<CSearchLeaf> iLeafList;
+		HBufC* iFolderName;
+	};
+
+
+#endif      // CSEARCHLEAF_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/server/inc/drmlog.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,63 @@
+/*
+* 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:  Debug log macro definitions
+*
+*/
+
+
+
+#ifndef DRMLOG_H
+#define DRMLOG_H
+
+//  INCLUDES
+#if (defined _DEBUG || defined _LOGGING)
+#include <E32SVR.H>
+#include <flogger.h>
+
+// CONSTANTS
+// MACROS
+
+#ifndef DRMFLOGFILE
+#define DRMFLOGFILE _L("DcfRepSrv.log")
+#endif
+
+#define DRMLOG( a ) \
+    RFileLogger::Write(_L("drm"), DRMFLOGFILE, EFileLoggingModeAppend, a); \
+    RDebug::Print( a );
+    
+#define DRMLOG2( a, b ) \
+    RFileLogger::WriteFormat(_L("drm"), DRMFLOGFILE, EFileLoggingModeAppend, a, b); \
+    RDebug::Print( a, b );
+     
+#define DRMLOGHEX( a ) \
+    RFileLogger::HexDump(_L("drm"), DRMFLOGFILE, EFileLoggingModeAppend, _S(""), _S(""), (a).Ptr(), (a).Size());
+
+#else
+
+#define DRMLOG( a ) 
+#define DRMLOG2( a, b ) 
+#define DRMLOGHEX( a )
+
+#endif // _DEBUG
+
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+// CLASS DECLARATION
+
+#endif      // DRMLOG_H   
+            
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/server/src/DcfRepSrv.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1254 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  server implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include    "DcfRepSrv.h"
+#include    "DcfRepSrvSes.h"
+#include    "DcfRepCommon.h"
+#include    "Pair.h"
+#include    "FileScan.h"
+#include    <e32std.h>
+#include    <e32base.h>
+#include    <f32file.h>
+#include    <caf/data.h>
+#include    <caf/content.h>
+#include    <Oma2Agent.h> // oma2agent
+#include    "Oma2Dcf.h"
+#include    "Oma1Dcf.h"
+#include    "drmlog.h"
+#include <starterclient.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include    <DriveInfo.h>
+#endif
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES
+// CONSTANTS
+_LIT(KSqlUpdate1 , "select filename,position,cid,group,ttid from dcf where filename = '");
+_LIT(KSqlUpdate2 , "' and position = ");
+_LIT(KSqlInsert , "select filename,position,cid,group,ttid from dcf");
+_LIT(KSqlDeleteAll , "delete from dcf");
+_LIT(KGroupIdReplacement, "cid:group@localhost");
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT( KDbFileLoc, "%c:\\system\\data\\DcfRepDb" );
+#endif
+
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TInt CreateDataBase(RFs& aFs);
+
+#ifndef RD_MULTIPLE_DRIVE
+LOCAL_C TParse DataFile();
+#else // RD_MULTIPLE_DRIVE
+LOCAL_C TParse DataFile( RFs& aFs );
+#endif
+
+LOCAL_C void CreateTablesL(RDbDatabase& aDatabase);
+LOCAL_C TInt CreateDataBasePath(RFs& aFs);
+// FORWARD DECLARATIONS
+
+//#define _DRM_TESTING
+//#define _MEM_HEAP_USAGE
+
+// ============================ LOCAL FUNCTIONS ===============================
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs );
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName );
+LOCAL_C void CreateLogL();
+LOCAL_C void WriteL( const TDesC8& aText );
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr );
+LOCAL_C void WriteCurrentTimeL();
+
+#ifdef _MEM_HEAP_USAGE
+LOCAL_C void WriteHeapAllocL();
+#endif //_MEM_HEAP_USAGE
+
+#endif //_DRM_TESTING
+
+// -----------------------------------------------------------------------------
+// Testing stuff
+// -----------------------------------------------------------------------------
+//
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
+    {
+    _LIT( KLogFile , "c:\\CDcfRepSrv.txt" );
+    WriteFileL( text , aFs , KLogFile );
+    }
+
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
+    {
+    RFile file;
+    TInt size;
+    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy(&file); //file
+    }
+
+LOCAL_C void CreateLogL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    User::LeaveIfError( file.Replace( fs , _L("c:\\CDcfRepSrv.txt") , EFileWrite ) );
+    file.Close();
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8("\r\n") );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    WriteCurrentTimeL();
+#ifdef _MEM_HEAP_USAGE
+    WriteHeapAllocL();
+#endif //_MEM_HEAP_USAGE
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr )
+    {
+    _LIT8(KErr,": %d");
+    HBufC8* text = HBufC8::NewLC(1000+20);
+    TBuf8<20> num;
+    TPtr8 textptr(text->Des());
+    textptr.Append(aText);
+    num.Format(KErr(),aErr);
+    textptr.Append(num);
+    WriteL(textptr);
+    CleanupStack::PopAndDestroy(text);
+    }
+
+LOCAL_C void WriteCurrentTimeL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+    // Date and Time display
+    TTime time;
+    time.HomeTime();
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    time.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    time.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+#ifdef _MEM_HEAP_USAGE
+LOCAL_C void WriteHeapAllocL()
+    {
+    _LIT8(KHeapUsage,"\r\n***** Heap cells allocated: %d *****\r\n");
+    TBuf8<256> string;
+    TInt size = 0;
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    User::Heap().AllocSize(size);
+    string.Format(KHeapUsage(),size);
+    WriteLogL(string , fs);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+#endif //_MEM_HEAP_USAGE
+
+
+#endif //_DRM_TESTING
+
+// -----------------------------------------------------------------------------
+// DataFile
+// Return TParse which contain database file name
+// -----------------------------------------------------------------------------
+//
+#ifdef RD_MULTIPLE_DRIVE
+LOCAL_C TParse DataFile( RFs& aFs )
+#else
+LOCAL_C TParse DataFile()
+#endif
+    {
+#ifdef _DRM_TESTING
+    TRAP_IGNORE( WriteL(_L8("DataFile")) ); 
+#endif
+
+    TParse p;
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    p.Set(KDbFileLocation,NULL,NULL);
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+
+    aFs.DriveToChar( driveNumber, driveLetter );
+
+    TFileName dbFile;
+    dbFile.Format( KDbFileLoc, (TUint)driveLetter );
+
+    p.Set(dbFile,NULL,NULL);
+
+#endif
+
+    return p;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CreateTablesL
+// Create table through database session
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void CreateTablesL(RDbDatabase& aDatabase)
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("CreateTablesL"));
+#endif
+
+    CDbColSet* columns = CDbColSet::NewLC();
+
+    //filename columns
+    TDbCol filename(KColFilename,EDbColLongText16);
+    filename.iAttributes = TDbCol::ENotNull;
+    columns->AddL(filename);
+
+    //position columns
+    TDbCol position(KColPosition,EDbColUint16);
+    position.iAttributes = TDbCol::ENotNull;
+    columns->AddL(position);
+
+    //content id columns
+    TDbCol cid(KColCid,EDbColLongText16);
+    cid.iAttributes = TDbCol::ENotNull;
+    columns->AddL(cid);
+
+    //content group id columns
+    TDbCol group(KColGroupId,EDbColLongText16);
+    columns->AddL(group);
+
+    //transaction id columns
+    TDbCol ttid(KColTtid,EDbColText16,KTtidLen);
+    columns->AddL(ttid);
+
+    aDatabase.CreateTable( KTable,*columns);
+    CleanupStack::PopAndDestroy(columns); //columns
+
+    }
+
+// -----------------------------------------------------------------------------
+// CreateDataBasePath
+// Create database with client side database access
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt CreateDataBasePath(RFs& aFs)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("CreateDataBasePath")));
+#endif
+
+    TInt err = 0;
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    err = aFs.MkDirAll( DataFile(). DriveAndPath() );
+
+#else //RD_MULTIPLE_DRIVE
+
+    err = aFs.MkDirAll( DataFile( aFs ). DriveAndPath() );
+
+#endif
+
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CreateDataBase
+// Create database with client side database access
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt CreateDataBase(RFs& aFs)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("CreateDataBase")));
+#endif
+
+    RDbNamedDatabase database;
+    TInt err = 0;
+    TFileName file;
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    file = DataFile().FullName();
+
+
+#else // RD_MULTIPLE_DRIVE
+
+    file = DataFile( aFs ).FullName();
+
+#endif
+
+    if (!err)
+        {
+#ifdef _DRM_TESTING
+        TRAP(r,WriteL(_L8("CreateDataBase->DataFile"),err));
+#endif
+        err = CreateDataBasePath(aFs);
+
+        err = database.Create(aFs,file);
+        if (!err)
+            {
+#ifdef _DRM_TESTING
+            TRAP(r,WriteL(_L8("CreateDataBase->database.Create"),err));
+#endif
+            TRAP( err , CreateTablesL(database) );
+#ifdef _DRM_TESTING
+            TRAP(r,WriteL(_L8("CreateDataBase->CreateTablesL"),err));
+#endif
+            }
+        database.Close();
+        }
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// From8To16
+// transfer buf from 8 bit to 16 bit
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt From8To16( const TDesC8& a8 , HBufC16*& a16 )
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("From8To16")));
+#endif
+
+    TInt err = KErrNone;
+    a16 = HBufC::NewMax( a8.Length() );
+    if ( a16 )
+        {
+        TPtr ptr( a16->Des() );
+        ptr.SetLength( a8.Length() );
+        for (TInt i = 0 ; i<a8.Length() ; i++ )
+            {
+            ptr[i] = ( unsigned char ) a8[i];
+            }
+        }
+    else err = KErrNoMemory;
+    return err;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrv::CDcfRepSrv
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDcfRepSrv::CDcfRepSrv():CServer2( EPriorityStandard ),
+    iScan(NULL),
+    iCidList(NULL),
+    iPairList(NULL),
+    iState(EStateIdle),
+    iArmed( EFalse )
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrv::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::ConstructL()
+    {
+#ifdef _DRM_TESTING
+    CreateLogL();
+    WriteL(_L8("ConstructL"));
+#endif
+    StartL(KDcfRepSrvName);
+    User::LeaveIfError(iFs.Connect());
+    iScan = CFileScan::NewL(iFs);
+    OpenDatabaseL();
+
+    User::RenameThread(KDcfRepSrvName);
+
+    iProcWatcher = CProcWatcher::NewL( *this, _L( "*RightsServer*" ), _L( "RightsServer" ) );
+    iProcWatcher->StartWatching();
+    iArmed = ETrue;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrv::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDcfRepSrv* CDcfRepSrv::NewLC()
+    {
+    CDcfRepSrv* self = new( ELeave ) CDcfRepSrv;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// Destructor
+CDcfRepSrv::~CDcfRepSrv()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("~CDcfRepSrv")));
+#endif
+
+    delete iScan;
+    CleanScanInternal();
+    CleanDatabase();
+    iFs.Close();
+    for (TInt i = 0 ; i < iMessageList.Count() ; i++ )
+        {
+        if ( iMessageList[i]!=NULL && !(iMessageList[i]->IsNull()) )
+            {
+            iMessageList[i]->Complete(KErrCancel);
+            }
+
+        }
+    iMessageList.ResetAndDestroy();
+    iMessageList.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrv::NewSessionL
+// Called when a client requires a new instance.
+// -----------------------------------------------------------------------------
+CSession2* CDcfRepSrv::NewSessionL(const TVersion &aVersion,
+    const RMessage2& /*aMessage*/ ) const
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("NewSessionL"));
+#endif
+    // check we're the right version
+    if (!User::QueryVersionSupported(TVersion(KDcfRepMajorVersionNumber,
+                KDcfRepMinorVersionNumber,
+                KDcfRepBuildVersionNumber),
+            aVersion))
+        {
+        User::Leave(KErrNotSupported);
+        }
+
+    // make new session
+    return CDcfRepSrvSes::NewL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// Startup().
+// This function starts the actual DCF Repository server after initializing
+// the cleanup stack and active scheduler.
+// Returns: TInt: Symbian OS error code.
+// -----------------------------------------------------------------------------
+//
+
+TInt CDcfRepSrv::Startup( void )
+    {
+    TInt err = 0;
+    TBool clientIsWaiting = EFalse;
+    RSemaphore semaphore;
+
+    CTrapCleanup* cleanupStack = CTrapCleanup::New();
+
+    if (cleanupStack == NULL)
+        {
+        PanicServer(ECreateTrapCleanup);
+        }
+
+    // check if the client wants to be signaled that we are ready
+    if ( semaphore.OpenGlobal(KDcfRepSemaphoreName) == KErrNone )
+        {
+        clientIsWaiting = ETrue;
+        }
+
+    TRAP(err, StartupL());
+
+    // release client side waiting
+    if (clientIsWaiting)
+        {
+        semaphore.Signal();
+        semaphore.Close();
+        }
+
+    if (err != KErrNone)
+        {
+        PanicServer(ESrvCreateServer);
+        }
+
+    delete cleanupStack;
+    cleanupStack = NULL;
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// StartupL().
+// This function starts the actual DCF Repository after initializing scheduler
+// -----------------------------------------------------------------------------
+//
+
+void CDcfRepSrv::StartupL()
+    {
+    // Construct active scheduler
+    CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler;
+    CleanupStack::PushL(activeScheduler) ;
+
+    // Install active scheduler
+    // We don't need to check whether an active scheduler is already installed
+    // as this is a new thread, so there won't be one
+    CActiveScheduler::Install(activeScheduler);
+
+    // Construct our server
+    CDcfRepSrv::NewLC();
+
+    // Start handling requests
+    CActiveScheduler::Start();
+
+    CleanupStack::PopAndDestroy(2);    //  activeScheduler and anonymous CDcfRepSrv
+    }
+
+void CDcfRepSrv::PanicServer(TDcfRepSrvPanic aPanic)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("PanicServer")));
+    r =  0;
+#endif
+
+    User::Panic(KDcfRepSrv, aPanic);
+    }
+
+
+// -----------------------------------------------------------------------------
+// AddFileL()
+// The function will add a file info into database
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::AddFileL( const TDesC& aFile )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("AddFileL"));
+#endif
+
+    TInt err = 0;
+    TInt state = iState;
+    TBool flag = EFalse;
+
+    // to process the file as doing scanning fully for file system
+    iState = EStateFullScan;
+    err = ProcessFile(aFile , flag);
+    // change the state back
+    iState = state;
+    User::LeaveIfError(err);
+    if ( flag == ENoDcf )
+        {
+        User::Leave(KErrNotSupported);
+        }
+    else if (flag == EOma2Dcf)
+        {
+        AddDomainRoL(aFile);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// AddDomainRoL()
+// The function will add a file info into database
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::AddDomainRoL( const TDesC& aFile )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("AddDomainRoL"));
+#endif
+
+    __UHEAP_MARK;
+    RFile file;
+    TPtr8 ptr(NULL,0,0);
+    CContent* content =NULL;
+    User::LeaveIfError(file.Open(iFs, aFile, EFileShareReadersOrWriters | EFileWrite ) );
+    CleanupClosePushL(file);
+    content = CContent::NewL(file);
+    CleanupStack::PushL(content);
+    User::LeaveIfError(content->AgentSpecificCommand(EEmbedDomainRo,
+            KNullDesC8, ptr ));
+    CleanupStack::PopAndDestroy(2); // content, file
+    __UHEAP_MARKEND;
+    }
+
+
+// -----------------------------------------------------------------------------
+// OpenDatabaseL()
+// The function will open database
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::OpenDatabaseL()
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("OpenDatabaseL"));
+#endif
+
+
+    TInt err = CreateDataBase(iFs);
+    if ( err==KErrAlreadyExists )
+        {
+        err = KErrNone;
+        }
+
+    User::LeaveIfError(iDbs.Connect());
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    User::LeaveIfError(iDb.Open(iDbs,DataFile().FullName()));
+
+#else // RD_MULTIPLE_DRIVE
+
+    User::LeaveIfError(iDb.Open(iDbs,DataFile(iFs).FullName()));
+
+#endif
+    }
+
+
+// -----------------------------------------------------------------------------
+// CleanTableL()
+// The function will empty the talbe
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::CleanTableL()
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("CleanTableL"));
+#endif
+
+    User::LeaveIfError(iDb.Execute(KSqlDeleteAll()));
+    }
+
+// -----------------------------------------------------------------------------
+// ProcessFile()
+// This function check if the file is DRM protected and add it into database.
+// -----------------------------------------------------------------------------
+//
+TInt CDcfRepSrv::ProcessFile(const TDesC& aFile , TInt& aType)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("ProcessFile")));
+#endif
+
+    TInt err = 0;
+    aType = ENoDcf;
+
+    TRAP(err , CheckFileL(aFile , aType));
+    if (aType)
+        {
+        TRAP(err , StoreFileL(aFile,aType));
+        }
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CheckFileL()
+// check if it is target file
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::CheckFileL(const TDesC& aFile , TInt& aType)
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("CheckFileL"));
+#endif
+
+    RFile f;
+    TInt pos = 0;
+    TBuf8<256> buf;
+
+    switch(iState)
+        {
+        case EStateFullScan:
+        case EStateScan:
+                {
+                User::LeaveIfError(f.Open(iFs,aFile,EFileRead|EFileShareReadersOrWriters));
+                CleanupClosePushL(f);
+                User::LeaveIfError(f.Seek(ESeekStart,pos));
+                User::LeaveIfError(f.Read(0,buf));
+                CleanupStack::PopAndDestroy(&f);
+                if (COma1Dcf::IsValidDcf(buf))
+                    {
+                    aType = EOma1Dcf;
+                    }
+#ifdef __DRM_OMA2
+                else if (COma2Dcf::IsValidDcf(buf))
+                    {
+                    aType = EOma2Dcf;
+                    }
+#endif
+                else
+                    {
+                    aType = ENoDcf;
+                    }
+
+                }
+            break;
+        case EStateSetTtid:
+                {
+                TParse p;
+                User::LeaveIfError(p.Set(aFile,NULL,NULL));
+                if ( !p.Ext().Compare( KOma2DcfExtension ) ||
+                    !p.Ext().Compare( KOma2DcfExtensionAudio ) ||
+                    !p.Ext().Compare( KOma2DcfExtensionVideo ) )
+                    {
+                    User::LeaveIfError(f.Open(iFs,aFile,EFileRead|EFileShareReadersOrWriters));
+                    CleanupClosePushL(f);
+                    User::LeaveIfError(f.Seek(ESeekStart,pos));
+                    User::LeaveIfError(f.Read(0,buf));
+                    CleanupStack::PopAndDestroy(&f);
+                    if (COma1Dcf::IsValidDcf(buf))
+                        {
+                        aType = EOma1Dcf;
+                        }
+#ifdef __DRM_OMA2
+                    else if (COma2Dcf::IsValidDcf(buf))
+                        {
+                        aType = EOma2Dcf;
+                        }
+#endif
+                    else
+                        {
+                        aType = ENoDcf;
+                        }
+                    }
+                }
+            break;
+        default:
+            ;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// StoreFile()
+// save file info into database
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::StoreFileL(const TDesC& aFile , TInt aType)
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("StoreFileL"));
+#endif
+
+    RFile f;
+    User::LeaveIfError(f.Open(iFs,aFile,EFileRead|EFileShareReadersOrWriters));
+    CleanupClosePushL(f);
+    TInt i = 0;
+    TInt setTtid = -1;
+    HBufC16* cid = NULL;
+    HBufC16* ttid = NULL;
+    HBufC16* group = NULL;
+
+    if (aType == EOma1Dcf)
+        {
+        COma1Dcf* d = COma1Dcf::NewL(f);
+        CleanupStack::PushL(d);
+        User::LeaveIfError( From8To16( *(d->iContentID) , cid ) );
+        CleanupStack::PopAndDestroy(d);
+        CleanupStack::PushL(cid);
+        ttid = HBufC::NewMaxLC(16);
+        *ttid = KNullDesC16;
+        UpdateDatabaseL(aFile , KStartPosition , *cid , KNullDesC() , *ttid);
+        if (iCidList)
+            {
+            for (i = 0; i<iCidList->Count(); i++)
+                {
+                HBufC* temp = NULL;
+                User::LeaveIfError( From8To16(*((*iCidList)[i]) , temp ) );
+                CleanupStack::PushL(temp);
+                if (!temp->Compare(*cid))
+                    {
+                    delete (*iCidList)[i];
+                    iCidList->Remove(i);
+                    CleanupStack::PopAndDestroy(temp);
+                    break;
+                    }
+                CleanupStack::PopAndDestroy(temp); //temp
+                }
+            if (iCidList->Count()<=0)
+                {
+                CompleteScanning(KErrNone);
+                }
+            }
+        CleanupStack::PopAndDestroy(2); //cid,ttid
+        }
+    else if (aType == EOma2Dcf)
+        {
+        COma2Dcf* d = COma2Dcf::NewL(f);
+        CleanupStack::PushL(d);
+
+        // Set group ID and content ID for this entry
+        if (d->iGroupId)
+            {
+            User::LeaveIfError( From8To16( *(d->iGroupId) , group ) );
+
+            // replace the content ID for this entry with a placeholder to prevent
+            // that the file is listed wrongly under the group ID
+            cid = KGroupIdReplacement().AllocL();
+            }
+        else
+            {
+            User::LeaveIfError( From8To16( *(d->iContentID) , cid ) );
+            group = HBufC::NewMaxL(16);
+            *group = KNullDesC16;
+            }
+        CleanupStack::PushL(cid);
+        CleanupStack::PushL(group);
+
+        if (iState == EStateSetTtid)
+            {
+            for (i = 0; iPairList && i<iPairList->Count() && !ttid; i++)
+                {
+                HBufC* temp = NULL;
+                User::LeaveIfError( From8To16(*((*iPairList)[i]->iCid) , temp ) );
+                CleanupStack::PushL(temp);
+                if (!temp->Compare(*cid))
+                    {
+                    User::LeaveIfError( From8To16(*((*iPairList)[i]->iTtid) , ttid ) );
+
+                    // EFileWrite is needed for this case
+                    // So we cannot do it here. we must close the file
+                    setTtid = i;
+                    }
+                CleanupStack::PopAndDestroy(temp); //temp
+                }
+            }
+        if (!ttid)
+            {
+            if (d->iTransactionTracking)
+                {
+                User::LeaveIfError( From8To16( *(d->iTransactionTracking) , ttid ) );
+                }
+            else
+                {
+                ttid = HBufC::NewMaxL(16);
+                *ttid = KNullDesC16;
+                }
+            }
+        CleanupStack::PushL(ttid);
+
+        UpdateDatabaseL(aFile , KStartPosition , *cid , *group , *ttid);
+        if (iCidList)
+            {
+            for (i = 0; i<iCidList->Count(); i++)
+                {
+                HBufC* temp = NULL;
+                User::LeaveIfError( From8To16(*((*iCidList)[i]) , temp ) );
+                CleanupStack::PushL(temp);
+                if (!temp->Compare(*cid))
+                    {
+                    delete (*iCidList)[i];
+                    iCidList->Remove(i);
+                    CleanupStack::PopAndDestroy(temp);
+                    break;
+                    }
+                CleanupStack::PopAndDestroy(temp); //temp
+                }
+            if (iCidList->Count()<=0)
+                {
+                CompleteScanning(KErrNone);
+                }
+            }
+        CleanupStack::PopAndDestroy(4); // group,ttid,cid,d
+        }
+
+    CleanupStack::PopAndDestroy(&f); // f
+
+    if (setTtid>=0)
+        {
+        ResetTtidL( aFile , *((*iPairList)[setTtid]->iTtid));
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// ResetTtidL()
+// save new ttid into file
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::ResetTtidL(
+    const TDesC& aFile,
+    const TDesC8& aTtid
+    )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("ResetTtidL"));
+#endif
+
+    RFile f;
+    User::LeaveIfError(f.Open(iFs,aFile, EFileWrite|EFileShareReadersOrWriters ));
+    CleanupClosePushL(f);
+    COma2Dcf* d = COma2Dcf::NewL(f);
+    CleanupStack::PushL(d);
+    ResetTtidL(d,aTtid);
+    CleanupStack::PopAndDestroy(2); // f,d
+    }
+
+// -----------------------------------------------------------------------------
+// ResetTtidL()
+// save new ttid into file
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::ResetTtidL(
+    COma2Dcf* aDcf,
+    const TDesC8& aTtid
+    )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("ResetTtidL"));
+#endif
+
+    aDcf->SetTransactionIdL(aTtid);
+    }
+
+// -----------------------------------------------------------------------------
+// UpdateDatabaseL()
+// save info into database
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::UpdateDatabaseL(
+    const TDesC& aFile,
+    TInt aPos,
+    const TDesC& aCid ,
+    const TDesC& aGroupId ,
+    const TDesC& aTtid)
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("UpdateDatabaseL"));
+#endif
+
+    HBufC* sql = NULL;
+    TPtr ptr(NULL,0,0);
+    TBuf<4> num;
+    sql = HBufC::NewMaxLC(aFile.Length()+200);
+    ptr.Set(sql->Des());
+    ptr.SetLength(0);
+    ptr.Append(KSqlUpdate1);
+    ptr.Append(aFile);
+    ptr.Append(KSqlUpdate2);
+    num.Num(aPos);
+    ptr.Append(num);
+
+    iView.Close();
+
+    User::LeaveIfError(
+        iView.Prepare(
+            iDb,TDbQuery(ptr),
+            TDbWindow::EUnlimited,
+            RDbView::EUpdatable
+            )
+        );
+    User::LeaveIfError(iView.EvaluateAll());
+    if (iView.FirstL())
+        {
+        iView.UpdateL();
+        iView.SetColL(KOrdCid,aCid);
+        iView.SetColL(KOrdGroupId,aGroupId);
+        iView.SetColL(KOrdTtid,aTtid);
+        iView.PutL();
+        }
+    else
+        {
+        iView.Reset();
+        iView.Close();
+        iView.Prepare(
+            iDb,TDbQuery(KSqlInsert),
+            TDbWindow::EUnlimited,
+            RDbView::EInsertOnly
+            );
+        iView.InsertL();
+        iView.SetColL(KOrdFilename,aFile);
+        iView.SetColL(KOrdPosition,aPos);
+        iView.SetColL(KOrdCid,aCid);
+        iView.SetColL(KOrdGroupId,aGroupId);
+        iView.SetColL(KOrdTtid,aTtid);
+        iView.PutL();
+        }
+    iView.Reset();
+    iView.Close();
+    CleanupStack::PopAndDestroy(sql); //sql
+    }
+
+// -----------------------------------------------------------------------------
+// State()
+// This function returns the state of the Server
+// -----------------------------------------------------------------------------
+//
+TInt CDcfRepSrv::State() const
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("State")));
+#endif
+
+    return iState;
+    }
+
+// -----------------------------------------------------------------------------
+// SetState()
+// This function set the state of the Server
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::SetState(TServerState aMode)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("SetState")));
+#endif
+
+    iState = aMode;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CompleteScanning().
+// This function complete request from client
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::CompleteScanning(TInt aRet)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("CompleteScanning")));
+#endif
+
+    for (TInt i = 0 ; i<iMessageList.Count() ; i++ )
+        {
+        if ( iMessageList[i] && !(iMessageList[i]->IsNull()) )
+            {
+            iMessageList[i]->Complete(aRet);
+            }
+        }
+    iMessageList.ResetAndDestroy();
+
+    CleanScanInternal();
+    iState = EStateIdle;
+    }
+
+// -----------------------------------------------------------------------------
+// SetMessage().
+// This function save the incomplete message to server
+// -----------------------------------------------------------------------------
+//
+RMessage2* CDcfRepSrv::SetMessageL(const RMessage2& aMessage)
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("SetMessageL"));
+#endif
+    RMessage2* m = NULL;
+    m = new (ELeave) RMessage2(aMessage);
+    iMessageList.AppendL(m);
+    return m;
+    }
+
+
+// -----------------------------------------------------------------------------
+// RemoveMessage().
+// This function to remove the imcomplete message from server if it is still there
+// when session is deleted
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::RemoveMessageL( const RMessage2* aMessage )
+    {
+    for (TInt i = 0 ; i<iMessageList.Count() ; i++ )
+        {
+        if ( iMessageList[i] == aMessage )
+            {
+            delete iMessageList[i];
+            iMessageList[i] = NULL;
+            iMessageList.Remove( i );
+            return;
+            }
+        }
+    return;
+    };
+
+
+// -----------------------------------------------------------------------------
+// SetCidList().
+// This function set content ID List
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::SetCidList(RPointerArray<HBufC8>*& aList)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("SetCidList")));
+#endif
+
+    if (iCidList)
+        {
+        iCidList->ResetAndDestroy();
+        iCidList->Close();
+        delete iCidList;
+        }
+    iCidList = aList;
+    }
+
+// -----------------------------------------------------------------------------
+// SetPairList().
+// This function set list of pairs for content ID and transation ID
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::SetPairList(RPointerArray<CPair>*& aList)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("SetPairList")));
+#endif
+
+    if (iPairList)
+        {
+        iPairList->ResetAndDestroy();
+        iPairList->Close();
+        delete iPairList;
+        }
+    iPairList = aList;
+    }
+
+
+// -----------------------------------------------------------------------------
+// Scan()
+// This function scan the file system
+// -----------------------------------------------------------------------------
+//
+TInt CDcfRepSrv::Scan()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("Scan")));
+#endif
+
+    TInt err = 0;
+    if (iState == EStateFullScan)
+        {
+        TRAP(err,CleanTableL());
+        }
+    err = iScan->SearchContent(this);
+    if (err)
+        {
+        CleanScanInternal();
+        iState = EStateIdle;
+        }
+    return err;
+    }
+
+void CDcfRepSrv::CleanScanInternal()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("CleanScanInternal")));
+#endif
+
+    if (iCidList)
+        {
+        iCidList->ResetAndDestroy();
+        iCidList->Close();
+        delete iCidList;
+        iCidList = NULL;
+        }
+    if (iPairList)
+        {
+        iPairList->ResetAndDestroy();
+        iPairList->Close();
+        delete iPairList;
+        iPairList = NULL;
+        }
+    }
+
+void CDcfRepSrv::CleanDatabase()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("CleanDatabase")));
+#endif
+
+    iView.Close();
+    iDb.Close();
+    iDbs.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrv::WatchedObjectChangedL
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::WatchedObjectChangedL( const TDesC& aObject )
+    {
+    DRMLOG( _L( "CDcfRepSrv::WatchedObjectChangedL ->" ) );
+    DRMLOG( aObject );
+
+    if ( aObject.Left( KProcIdentifier().Length() ) == KProcIdentifier && iArmed )
+        {
+#ifdef _DEBUG
+        DRMLOG( _L( "Peer process killed (DEBUG mode, not rebooting)" ) );
+#else
+        DRMLOG( _L( "Peer process killed, rebooting" ) );
+        RStarterSession starter;
+        User::LeaveIfError( starter.Connect() );
+        starter.Shutdown();
+        starter.Close();
+#endif
+        }
+
+    DRMLOG( _L( "CDRMRightsServer::WatchedObjectChangedL <-" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrv::StopWatchingL
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrv::StopWatchingL()
+    {
+    DRMLOG( _L( "CDcfRepSrv::StopWatchingL ->" ) );
+    iArmed = EFalse;
+    DRMLOG( _L( "CDRMRightsServer::StopWatchingL <-" ) );
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// E32 Entry for Executable
+// -----------------------------------------------------------------------------
+
+TInt E32Main()
+    {
+    return CDcfRepSrv::Startup();
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/server/src/DcfRepSrvSes.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,572 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  server session implementation
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "DcfRepSrv.h"
+#include    "DcfRepSrvSes.h"
+#include    "DcfRepCommon.h"
+#include    "Pair.h"
+#include    <e32std.h>
+#include    <e32base.h>
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+const TUint32 KTrustedShutdownClient = 0x10205CB5;
+
+// MACROS
+#define SERVER const_cast< CDcfRepSrv* >( \
+    reinterpret_cast< const CDcfRepSrv* >( Server() ) )
+
+// LOCAL CONSTANTS AND MACROS
+const TInt KSanityDataLengthLow = 0;
+const TInt KSanityDataLengthHigh = 32768;
+
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// #define _DRM_TESTING
+// ============================= LOCAL FUNCTIONS ===============================
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs );
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName );
+LOCAL_C void CreateLogL();
+LOCAL_C void WriteL( const TDesC8& aText );
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr );
+LOCAL_C void WriteCurrentTimeL();
+#endif
+
+// -----------------------------------------------------------------------------
+// SanitizeL
+// Performs a sanity check on length parameters
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void SanitizeL( TInt aParam )
+    {
+    if( aParam <= KSanityDataLengthLow || aParam > KSanityDataLengthHigh )
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// Testing stuff
+// -----------------------------------------------------------------------------
+//
+#ifdef _DRM_TESTING
+
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
+    {
+    _LIT( KLogFile , "c:\\CDcfRepSrvSes.txt" );
+    WriteFileL( text , aFs , KLogFile );
+    }
+
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
+    {
+    RFile file;
+    TInt size;
+    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy(&file); //file
+    }
+
+LOCAL_C void CreateLogL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    User::LeaveIfError( file.Replace( fs , _L("c:\\CDcfRepSrvSes.txt") , EFileWrite ) );
+    file.Close();
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8("\r\n") );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    WriteCurrentTimeL();
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr )
+    {
+    _LIT8(KErr,": %d");
+    HBufC8* text = HBufC8::NewLC(1000+20);
+    TBuf8<20> num;
+    TPtr8 textptr(text->Des());
+    textptr.Append(aText);
+    num.Format(KErr(),aErr);
+    textptr.Append(num);
+    WriteL(textptr);
+    CleanupStack::PopAndDestroy(text);
+    }
+
+LOCAL_C void WriteCurrentTimeL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+// Date and Time display
+    TTime time;
+    time.HomeTime();
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    time.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    time.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+#endif
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::CDcfRepSrvSes
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDcfRepSrvSes::CDcfRepSrvSes()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrvSes::ConstructL()
+    {
+#ifdef _DRM_TESTING
+    CreateLogL();
+    WriteL(_L8("ConstructL"));
+#endif
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDcfRepSrvSes* CDcfRepSrvSes::NewL()
+    {
+    CDcfRepSrvSes* self = new( ELeave ) CDcfRepSrvSes;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    return self;
+    }
+
+    
+// Destructor
+CDcfRepSrvSes::~CDcfRepSrvSes()
+    {
+#ifdef _DRM_TESTING
+    TRAPD(err,WriteL(_L8("~CDcfRepSrvSes")));
+#endif
+
+    SERVER->RemoveMessageL( iMessage );
+
+
+    if (iCidList)
+        {
+        iCidList->ResetAndDestroy();
+        iCidList->Close();
+        delete iCidList;    
+        }
+        
+    if (iPairList)
+        {
+        iPairList->ResetAndDestroy();
+        iPairList->Close();
+        delete iPairList;    
+        }    
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::ServiceL
+// This method runs DispatchL() under TRAP harness, since every error case
+// can be handled ==> no need to let this function leave.
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrvSes::ServiceL( const RMessage2& aMessage )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("ServiceL"));
+#endif
+    // Trap possible errors...
+    TRAPD( error, DispatchL( aMessage ) );
+    
+    if ( error )
+        {
+#ifdef _DRM_TESTING
+    WriteL(_L8("ServiceL->error"),error);
+#endif
+        aMessage.Complete( error );
+        return;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::DispatchL
+// Checks which command the user requested, and forwards the request to 
+// appropriate private method. This helps to keep the code more readable.
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrvSes::DispatchL( const RMessage2& aMessage ) 
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("DispatchL"));
+#endif
+
+    TBool complete = ETrue;
+    switch ( aMessage.Function() )
+        {
+        case EAddFile:
+            AddFileL( aMessage );
+            break;
+        case EFullScan:
+            FullScanL( aMessage );
+            complete = EFalse;
+            break;
+        case EScanAdd:
+            ScanAddL( aMessage );
+            break;
+        case EScanEnd:
+            ScanEndL( aMessage );
+            complete = EFalse;
+            break;
+        case EScanStart:
+            ScanStartL( aMessage );
+            break;
+        case ESetTtidStart:
+            SetTtidStartL( aMessage );
+            break;
+        case ESetTtidAdd:
+            SetTtidAddL( aMessage );
+            break;                    
+        case ESetTtidEnd:
+            SetTtidEndL( aMessage );
+            complete = EFalse;
+            break;
+        case ENotifyIdle:
+            NotifyIdleL( aMessage );
+            complete = EFalse;
+            break;
+        case EStopWatching:
+            StopWatchingL( aMessage );
+            break;
+        default:
+            User::Leave( KErrNotSupported );
+        }
+    if (complete)
+        {
+        aMessage.Complete(KErrNone);
+        }
+    }
+    
+    
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::AddFileL
+// -----------------------------------------------------------------------------
+//    
+void CDcfRepSrvSes::AddFileL( const RMessage2& aMessage )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("AddFileL"));
+#endif
+
+    TFileName file;
+    aMessage.ReadL( 0, file );
+    SERVER->AddFileL(file);    
+    }
+    
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::FullScanL
+// -----------------------------------------------------------------------------
+//    
+void CDcfRepSrvSes::FullScanL( const RMessage2& aMessage )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("FullScanL"));
+#endif
+
+    TInt err = SERVER->State();
+    if (err!=EStateIdle)
+        {
+        User::Leave(KErrServerBusy);    
+        }
+    else
+        {
+        iMessage = SERVER->SetMessageL(aMessage);
+        SERVER->SetState(EStateFullScan);   
+        User::LeaveIfError(SERVER->Scan());
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::ScanSingleL
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrvSes::ScanAddL( const RMessage2& aMessage )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("ScanAddL"));
+#endif   
+ 
+    TInt size = 0;
+    HBufC8* cid = NULL;
+    TPtr8 data(NULL,0,0);
+    if (iPreviousAction == EScanStart || iPreviousAction == EScanAdd)
+        {
+        size = aMessage.GetDesLength( 0 );
+        SanitizeL(size);
+        cid = HBufC8::NewMaxLC( size );
+        data.Set( cid->Des() );
+        data.SetLength(size);
+        aMessage.ReadL( 0, data );
+        User::LeaveIfError(iCidList->Append(cid));
+        CleanupStack::Pop(cid);    
+        iPreviousAction = EScanAdd;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::ScanEndL
+// -----------------------------------------------------------------------------
+//    
+void CDcfRepSrvSes::ScanEndL( const RMessage2& aMessage )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("ScanEndL"));
+#endif  
+
+    TInt err = 0;
+    if (iPreviousAction == EScanAdd)
+        {
+        err = SERVER->State();
+        if (err!=EStateIdle)
+            {
+            User::Leave(KErrServerBusy);    
+            }
+        else
+            {
+            iMessage = SERVER->SetMessageL(aMessage);
+            SERVER->SetCidList(iCidList);
+            iCidList = NULL;
+            SERVER->SetState(EStateScan);
+            User::LeaveIfError(SERVER->Scan());
+            } 
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::ScanStartL
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrvSes::ScanStartL( const RMessage2& /*aMessage*/ )
+    {
+    TInt err = SERVER->State();
+    
+    if (err!=EStateIdle)
+        {
+        User::Leave(KErrServerBusy);    
+        }
+    else
+        {
+        if (iCidList)
+            {
+            // clean list
+            iCidList->ResetAndDestroy();    
+            }
+        else
+            {
+            // initilize list
+            iCidList = new (ELeave) RPointerArray<HBufC8>();        
+            }
+        
+        } 
+    iPreviousAction = EScanStart;  
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::SetTtidStartL
+// -----------------------------------------------------------------------------
+//    
+void CDcfRepSrvSes::SetTtidStartL( const RMessage2& /*aMessage*/ )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("SetTtidStartL"));
+#endif    
+    
+    TInt err = SERVER->State();
+    if (err!=EStateIdle)
+        {
+        User::Leave(KErrServerBusy);    
+        }    
+    else
+        {
+        if (iPairList)
+            {
+            // clean list
+            iPairList->ResetAndDestroy();    
+            }
+        else
+            {
+            // initilize list
+            iPairList = new (ELeave) RPointerArray<CPair>();        
+            }        
+        }
+    iPreviousAction = ESetTtidStart;  
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::SetTtidAddL
+// -----------------------------------------------------------------------------
+//
+void CDcfRepSrvSes::SetTtidAddL( const RMessage2& aMessage )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("SetTtidAddL"));
+#endif 
+
+    TInt size = 0;
+    TPtr8 data(NULL,0,0);
+    if (iPreviousAction == ESetTtidStart || iPreviousAction == ESetTtidAdd)
+        {
+        CPair* pair = CPair::NewL();
+        CleanupStack::PushL(pair);
+        
+        size = aMessage.GetDesLength( 0 );
+        SanitizeL( size );
+        pair->iCid = HBufC8::NewMaxL( size );
+        data.Set( pair->iCid->Des() );
+        data.SetLength(size);
+        aMessage.ReadL( 0, data );
+        
+        
+        size = aMessage.GetDesLength( 1 );
+        SanitizeL( size );
+        pair->iTtid = HBufC8::NewMaxL( size );
+        data.Set( pair->iTtid->Des() );
+        data.SetLength(size);
+        aMessage.ReadL( 1, data );
+        
+        User::LeaveIfError(iPairList->Append(pair));
+        CleanupStack::Pop(pair);
+            
+        iPreviousAction = ESetTtidAdd;
+        }    
+    }
+
+
+    
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::SetTtidEndL
+// -----------------------------------------------------------------------------
+//    
+void CDcfRepSrvSes::SetTtidEndL( const RMessage2& aMessage )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("SetTtidEndL"));
+#endif 
+
+    TInt err = 0;
+    if (iPreviousAction == ESetTtidAdd)
+        {
+        err = SERVER->State();
+        if (err!=EStateIdle)
+            {
+            User::Leave(KErrServerBusy);    
+            }
+        else
+            {
+            iMessage = SERVER->SetMessageL(aMessage);
+            SERVER->SetPairList(iPairList);
+            iPairList = NULL;
+            SERVER->SetState(EStateSetTtid);
+            User::LeaveIfError(SERVER->Scan());
+            } 
+        }   
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::NotifyIdleL
+// -----------------------------------------------------------------------------
+//    
+void CDcfRepSrvSes::NotifyIdleL( const RMessage2& aMessage )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("NotifyIdleL"));
+#endif
+
+    TInt err = SERVER->State();
+    if (err==EStateIdle)
+        {
+#ifdef _DRM_TESTING
+    WriteL(_L8("NotifyIdleL->Idle"));
+#endif
+        aMessage.Complete(KErrNone);
+        }
+    else
+        {
+        iMessage = SERVER->SetMessageL(aMessage);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDcfRepSrvSes::StopWatchingL
+// -----------------------------------------------------------------------------
+//    
+void CDcfRepSrvSes::StopWatchingL( const RMessage2& aMessage )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("StopWatchingL"));
+#endif
+    _LIT_SECURITY_POLICY_S0( sidCheck, KTrustedShutdownClient );
+    if ( sidCheck.CheckPolicy( aMessage ) )
+        {
+        SERVER->StopWatchingL();
+        }
+    }
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/server/src/FileScan.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,526 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  server implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include	<e32std.h>
+#include	<e32base.h>
+#include	<f32file.h>
+#include    <drmcommon.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include    <DriveInfo.h>
+#endif
+
+#include    "DcfRepSrv.h"
+#include    "SearchLeaf.h"
+#include	"FileScan.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+_LIT( KWma, ".wma" );
+_LIT( KWmv, ".wmv" );
+_LIT( KAsf, ".asf" );
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT( KIgnoreDir1, "%c:\\sys" );
+_LIT( KIgnoreDir2, "%c:\\private\\101F51F2" );
+#else
+_LIT( KIgnoreDir1, "c:\\sys" );
+_LIT( KIgnoreDir2, "c:\\private\\101F51F2" );
+#endif
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+#ifndef RD_MULTIPLE_DRIVE
+LOCAL_C TBool IgnoreDir( TFileName& aDir );
+#else // RD_MULTIPLE_DRIVE
+LOCAL_C TBool IgnoreDir( RFs& aFs, TFileName& aDir );
+#endif
+// FORWARD DECLARATIONS
+
+// ============================ LOCAL FUNCTIONS =================================
+
+// ------------------------------------------------------------------------------
+// Returns whether directory should be ignored or not
+// ------------------------------------------------------------------------------
+ #ifndef RD_MULTIPLE_DRIVE
+LOCAL_C TBool IgnoreDir( TFileName& aDir )
+    {
+    if ( !aDir.CompareF( KIgnoreDir1 ) || 
+         !aDir.CompareF( KIgnoreDir2 ) )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+#else // RD_MULTIPLE_DRIVE
+LOCAL_C TBool IgnoreDir( RFs& aFs, TFileName& aDir )
+    {
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	aFs.DriveToChar( driveNumber, driveLetter );
+	
+	TFileName ignore1;
+	TFileName ignore2;
+	
+	ignore1.Format( KIgnoreDir1, (TUint)driveLetter );
+    ignore2.Format( KIgnoreDir2, (TUint)driveLetter );
+    
+    if ( !aDir.CompareF( ignore1 ) || 
+         !aDir.CompareF( ignore2 ) )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+#endif
+    
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CFileScan::CFileScan
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CFileScan::CFileScan( RFs& aFs ) : 
+CActive( CActive::EPriorityStandard ),iServer(NULL),iFs(&aFs),iCurrentLeaf(NULL)
+	{
+	CleanInternal();
+    }
+
+// -----------------------------------------------------------------------------
+// CFileScan::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CFileScan::ConstructL()
+    {
+	TInt err = 0;
+	if ( !iFs )
+		{
+		err = KErrArgument;
+		}
+	else
+		{
+		err = KErrNone;
+		}
+	User::LeaveIfError( err );
+	}
+
+// -----------------------------------------------------------------------------
+// CFileScan::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CFileScan* CFileScan::NewL( RFs& aFs )
+    {
+    CFileScan* self = new( ELeave ) CFileScan( aFs ); 
+	CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+    
+// Destructor
+CFileScan::~CFileScan()
+    {
+	CleanInternal();
+	iServer = NULL;
+	iFs = NULL;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CFileScan::DoCancel
+// Function is called when the request is completed
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CFileScan::DoCancel()
+	{
+	CleanInternal();
+	}
+
+
+// -----------------------------------------------------------------------------
+// CFileScan::IsProtected
+// Function returns whether the specific file is protected or not 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CFileScan::IsProtected( const TDesC& aFileName , TBool& aIsDCF )
+	{
+	TInt err = KErrNone;
+	aIsDCF = EFalse;
+	err = iServer->ProcessFile( aFileName , aIsDCF );
+	if ( err && err != KErrNoMemory )
+		{
+		err = KErrNone;
+		}
+	return err;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CFileScan::RunL
+// Function is called when the request is completed
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CFileScan::RunL()
+	{
+	TInt err = KErrNone;
+	if ( iSearching && iServer->State()!=EStateIdle )
+		{
+		err = SearchNext();
+		if ( err == KErrCancel )
+			{
+			err = KErrNone;
+			}
+		if ( !err )
+			{
+			SetActive();			
+			TRequestStatus* status = &iStatus;
+			User::RequestComplete( status , err );			
+			}
+		}
+	else 
+		{
+		CleanInternal();
+		iServer->CompleteScanning(err);
+		Deque();
+		}
+	if ( err )
+		{
+		CleanInternal();
+		iServer->CompleteScanning(err);
+		Deque();
+		}
+	}
+
+
+
+// -----------------------------------------------------------------------------
+// CFileScan::SearchContent
+// Function starts the active objects to search protected file through whole file system 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CFileScan::SearchContent( CDcfRepSrv* aServer )
+	{
+    TInt err = KErrNone;
+	
+	iServer = aServer;
+	CActiveScheduler::Add( this );
+	
+	iSearching = ETrue;
+	err = SearchNext();
+	if ( err )
+		{
+		return err;
+		}
+	SetActive();
+	TRequestStatus* status = &iStatus;
+	User::RequestComplete( status , KErrNone );
+	return err;
+	}
+
+// -----------------------------------------------------------------------------
+// CFileScan::SearchDrive
+// This function searches for the DCF files on target device
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CFileScan::SearchDrive()
+	{
+	_LIT( KDrive, "%c:");
+	TDriveList drivelist;
+	TChar driveLetter;
+	TInt driveNumber = EDriveA - 1;
+	TInt err = KErrNone;
+
+#ifdef RD_MULTIPLE_DRIVE
+	
+	TInt ramDrive( -1 );
+    TInt romDrive( -1 );
+
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRam, ramDrive );
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, romDrive );
+
+#endif
+
+	err = iFs->DriveList( drivelist ); 
+
+	if ( iLastPosition != KNullDesC )
+		{
+		driveLetter = iLastPosition[0];
+		err = iFs->CharToDrive( driveLetter, driveNumber );
+		}
+	
+	driveNumber++;
+	
+    for ( ; driveNumber < KMaxDrives ; driveNumber++ )
+        {
+        
+#ifndef RD_MULTIPLE_DRIVE
+	    
+	    if ( driveNumber == EDriveD || driveNumber == EDriveZ )
+		    {
+		    }
+	    		
+#else // RD_MULTIPLE_DRIVE
+
+		if ( driveNumber == ramDrive || driveNumber == romDrive )
+		    {
+			}
+
+#endif
+		
+		else if ( drivelist[driveNumber] ) 
+				{
+				err = iFs->DriveToChar( driveNumber, driveLetter );
+				iLastPosition.Format( KDrive, (TUint)driveLetter );
+				iDeeper = ETrue;
+				return err;
+				}
+        }
+	CleanInternal();
+	return err;
+	}
+
+
+
+// -----------------------------------------------------------------------------
+// CFileScan::SearchFolder
+// This function create Leaves for the current leaf
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CFileScan::SearchFolder( CDir*& aFolderList )
+	{
+	TInt err = KErrNone;
+	TRAP( err , iCurrentLeaf->SetLeafL( aFolderList ) );
+	return err;
+	}
+
+// -----------------------------------------------------------------------------
+// CFileScan::SearchFile
+// This function searches for the DCF files under specific folder 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CFileScan::SearchFile( CDir*& aFileList )
+	{
+	TInt err = KErrNone;
+	TInt i = 0;
+	TBool isDCF;
+	_LIT ( KFullFileName , "%S\\%S");
+	TFileName fileName;
+
+	for ( ; i < aFileList->Count() && !err ; i++ )
+		{
+		if (!( *aFileList )[i].IsDir())
+		    {
+    		TPtrC extension = (*aFileList)[i].iName.Right( 4 );
+    		if( !extension.CompareF( KWma ) || 
+    		    !extension.CompareF( KWmv ) ||
+    		    !extension.CompareF( KAsf ) )
+    		    {
+    		    
+    		    }
+    		else
+    		    {
+    		    fileName.Format( KFullFileName , &iLastPosition , &( *aFileList )[i].iName );
+    		    err = IsProtected( fileName , isDCF );
+		        }
+    		}
+		}
+	return err;
+	}
+
+// -----------------------------------------------------------------------------
+// CFileScan::SearchNext
+// This function searches for the DCF files under specific folder or drive
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CFileScan::SearchNext()
+	{
+	TInt err = KErrNone;
+
+	err = CheckDrive();
+	if ( !err && iSearching )
+		{
+		if ( iDeeper )
+			{
+			err = CheckFolder();
+			}
+		if ( !err && iSearching )
+			{
+			err = ToNextLeaf();
+			}
+		}
+	return err;
+	}
+
+TInt CFileScan::CheckDrive()
+	{
+	// check if current drive is end of searching
+	TInt err = KErrNone;
+
+	if( !iCurrentLeaf )
+		{
+		err = SearchDrive();
+		if ( err || !iSearching )
+			{
+			return err;
+			}
+		CSearchLeaf* root = NULL;
+		TRAP( err , iCurrentLeaf = CSearchLeaf::NewL( root , iLastPosition ) );
+		}	
+	return err;
+	}
+
+TInt CFileScan::CheckFolder()	
+	{
+	// check current folder
+	_LIT ( KSearchDir , "%S\\*");
+
+	TInt err = KErrNone;
+	CDir* fileList = NULL;
+	CDir* dirList = NULL;
+	TFileName temp;
+    
+#ifndef RD_MULTIPLE_DRIVE
+    if ( IgnoreDir( iLastPosition ) )
+#else // RD_MULTIPLE_DRIVE
+    if ( IgnoreDir( *iFs, iLastPosition ) )    
+#endif
+        {
+        return err;
+        }
+    
+    if( iLastPosition.Length() + KSearchDir().Length() < iLastPosition.MaxLength() )
+        {
+	    temp.Format( KSearchDir , &iLastPosition );
+	    err = iFs->GetDir( temp  
+		    , KEntryAttMaskSupported
+		    , ESortByName 
+		    , fileList , dirList );
+	
+	    if ( !err )
+		    {
+		    err = SearchFolder( dirList );
+		    if ( !err )
+			    {
+			    err = SearchFile( fileList );
+			    }
+		    }
+	    delete fileList;
+	    fileList = NULL;
+	    delete dirList;
+	    dirList = NULL;        
+        }
+	return err;
+	}
+
+TInt CFileScan::ToNextLeaf()
+	{
+	_LIT ( KChildDir , "%S\\%S");
+	TInt err = KErrNone;
+	TFileName file;
+	CSearchLeaf* temp = NULL;
+
+	file.Format( iLastPosition );
+
+	if ( iCurrentLeaf->LeafList().Count() > 0 )
+		{
+		iDeeper = ETrue;
+		iCurrentLeaf = iCurrentLeaf->LeafList()[0];
+		iLastPosition.Format( KChildDir , &file , &iCurrentLeaf->FolderName() );
+		}
+	else
+		{
+		iDeeper = EFalse;
+		temp = iCurrentLeaf;
+		iCurrentLeaf = iCurrentLeaf->Root();
+		if ( iCurrentLeaf )
+			{
+			iCurrentLeaf->RemoveLeaf( temp );			
+			}
+		delete temp;
+		temp = NULL;
+		err = UpFolder();
+		}
+	return err;
+	}
+
+TInt CFileScan::UpFolder()
+	{
+	TInt err = KErrNone;
+	TParse file;
+	if ( iLastPosition.Length()<3 )
+		{
+		return err;
+		}
+	err = file.Set( iLastPosition , NULL , NULL );
+	iLastPosition.Format( file.DriveAndPath() );
+	iLastPosition.SetLength( iLastPosition.Length() - 1 );
+	return err;
+	}
+
+
+void CFileScan::CleanInternal()
+	{
+	CSearchLeaf* root = iCurrentLeaf;
+	iLastPosition = KNullDesC;
+	iSearching = EFalse;
+	root = GetRootLeaf();
+	delete root;
+	root = NULL;
+	iCurrentLeaf = NULL;
+	iDeeper = ETrue;
+	}
+
+CSearchLeaf* CFileScan::GetRootLeaf()
+	{
+	CSearchLeaf* root = iCurrentLeaf;
+	if ( iCurrentLeaf )
+		{
+		while ( root->Root() )
+			{
+			root = root->Root();
+			}	
+		}
+	return root;
+	}
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/server/src/Pair.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,97 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  server common implementation
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "Pair.h"
+#include    <e32std.h>
+#include    <e32base.h>
+
+// EXTERNAL DATA STRUCTURES
+
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+
+// CONSTANTS
+
+
+// MACROS
+
+
+// LOCAL CONSTANTS AND MACROS
+
+
+// MODULE DATA STRUCTURES
+
+
+// LOCAL FUNCTION PROTOTYPES
+
+
+// FORWARD DECLARATIONS
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CPair::CPair
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CPair::CPair():iCid(NULL),iTtid(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CPair::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CPair::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CPair::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CPair* CPair::NewL()
+    {
+    CPair* self = new( ELeave ) CPair;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+    
+// Destructor
+CPair::~CPair()
+    {
+    delete iCid;
+    delete iTtid;
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dcfrepository/server/src/SearchLeaf.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,170 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  server common implementation
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "SearchLeaf.h"
+#include    <e32std.h>
+#include    <e32base.h>
+#include    <f32file.h>
+
+// EXTERNAL DATA STRUCTURES
+
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+
+// CONSTANTS
+
+
+// MACROS
+
+
+// LOCAL CONSTANTS AND MACROS
+
+
+// MODULE DATA STRUCTURES
+
+
+// LOCAL FUNCTION PROTOTYPES
+
+
+// FORWARD DECLARATIONS
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CSearchLeaf::CSearchLeaf
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//    
+CSearchLeaf::CSearchLeaf( CSearchLeaf*& aRoot ) : iRoot(aRoot) 
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CPair::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CSearchLeaf::ConstructL( const TDesC& aFolderName )
+	{
+	iFolderName = aFolderName.AllocL();
+	}
+	
+// Destructor
+CSearchLeaf::~CSearchLeaf( void )
+	{
+	delete iFolderName;
+	iFolderName = NULL;
+	iRoot = NULL;
+    iLeafList.ResetAndDestroy();
+	iLeafList.Close();	    
+	}
+
+// -----------------------------------------------------------------------------
+// CSearchLeaf::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSearchLeaf* CSearchLeaf::NewL(  CSearchLeaf*& aRoot , const TDesC& aFolderName )
+	{
+	CSearchLeaf* self = NewLC( aRoot , aFolderName );
+    CleanupStack::Pop(self);
+    return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CSearchLeaf::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CSearchLeaf* CSearchLeaf::NewLC(  CSearchLeaf*& aRoot , const TDesC& aFolderName )
+	{
+    CSearchLeaf* self = new ( ELeave ) CSearchLeaf( aRoot );
+    CleanupStack::PushL( self );
+    self->ConstructL( aFolderName );
+    return self; 
+	}
+
+// -----------------------------------------------------------------------------
+// CSearchLeaf::SetLeafL
+// -----------------------------------------------------------------------------
+//
+void CSearchLeaf::SetLeafL( CDir*& aLeaf )
+	{
+	CSearchLeaf* leaf = NULL;
+	CSearchLeaf* root = this;
+	TInt i = 0;
+	for ( ; i < aLeaf->Count() ; i++ )
+		{
+		leaf = CSearchLeaf::NewL( root , ( *aLeaf )[i].iName );
+		CleanupStack::PushL( leaf );
+		User::LeaveIfError( iLeafList.Append( leaf ) );
+		CleanupStack::Pop(leaf); //leaf
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CSearchLeaf::RemoveLeaf
+// -----------------------------------------------------------------------------
+//
+void CSearchLeaf::RemoveLeaf( CSearchLeaf*& aLeaf )
+	{
+	TInt index = 0;
+	index = iLeafList.Find( aLeaf );
+	iLeafList.Remove( index );
+	iLeafList.Compress();
+	}
+	
+// -----------------------------------------------------------------------------
+// CSearchLeaf::FolderName
+// -----------------------------------------------------------------------------
+//
+const TDesC& CSearchLeaf::FolderName()
+	{
+	return (*iFolderName);
+	}
+
+// -----------------------------------------------------------------------------
+// CSearchLeaf::Root
+// -----------------------------------------------------------------------------
+//
+CSearchLeaf*& CSearchLeaf::Root()
+	{
+	return iRoot;
+	}
+
+// -----------------------------------------------------------------------------
+// CSearchLeaf::LeafList
+// -----------------------------------------------------------------------------
+//
+RPointerArray<CSearchLeaf>& CSearchLeaf::LeafList()
+	{
+	return iLeafList;
+	}
+
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dm/inc/b64.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class implements the base64 en/decoding.
+*
+*/
+
+
+#ifndef __BASE64_H_
+#define __BASE64_H_
+
+TInt b64decode(TUint8 *source, TUint32 length, TUint8 *destination, TUint32 *destination_length);
+
+#endif // __BASE64_H_
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dm/src/DRMMessageParser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1883 @@
+/*
+* 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:  This class implements the BbB-functionality.
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <e32base.h>
+#include <s32file.h>
+#include <s32mem.h>
+#include <caf/caftypes.h>
+#include <wspdecoder.h>
+#include <wspencoder.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "DrmRights.h"
+#include "Oma1DcfCreator.h"
+#include "b64.h"
+#include "DRMMessageParser.h"
+#include "DRMRightsParser.h"
+#include "DRMRightsClient.h"
+#include "DrmKeyStorage.h"
+
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+LOCAL_C const TInt KDefaultInputBufferSize = 2048;
+LOCAL_C const TInt KDRMMessageMalformed = KErrGeneral;
+
+_LIT8( KCIDString, "cid:" );
+LOCAL_C const TInt KCIDStringLength = 4;
+
+_LIT8( KFLPrefix, "flk:");
+LOCAL_C const TInt KFLKPrefixLength = 4;
+
+_LIT8( KFLSuffix, "@localhost");
+LOCAL_C const TUint8 KCDContentIDLength = 25; // 4 + 11 + 10
+LOCAL_C const TUint8 KCDPlainIDLength = 11; 
+
+LOCAL_C const TInt KInputBufferSize = 2048;
+LOCAL_C const TInt KBoundaryMarkLength = 2;
+
+LOCAL_C const TUint KInitialDCFBufferSize = 4096;
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT( KTempPath, "%c:\\system\\temp\\" );
+#else
+_LIT( KTempPath, "c:\\system\\temp\\" );
+#endif
+
+_LIT8( KColon, ":" );
+_LIT8( KSemiColon, ";" );
+_LIT8( KNewLine, "\n" );
+_LIT8( KEndLine, "\r\n" );
+LOCAL_C const TUint8 KEndLineLength = 2;
+
+_LIT8( KBoundaryMark, "--" );
+_LIT8( KContentType, "Content-Type" );
+_LIT8( KContentTransferEncoding, "Content-Transfer-Encoding" );
+_LIT8( KEncodingBase64, "base64" );
+_LIT8( KEncoding7bit, "7bit" );
+_LIT8( KEncoding8bit, "8bit" );
+_LIT8( KEncodingBinary, "binary" );
+_LIT8( KDRMXMLRightsType, "application/vnd.oma.drm.rights+xml");
+_LIT8( KDRMWBXMLRightsType, "application/vnd.oma.drm.rights+wbxml" );
+_LIT8( KDRMContentType, "application/vnd.oma.drm.content" );
+_LIT8( KRightsIssuer, "Rights-Issuer" );
+
+_LIT8( KRightsStartTag, "<o-ex:rights");
+
+_LIT8( KROPart1, "Content-Type: application/vnd.oma.drm.rights+xml\r\n\
+Content-Transfer-Encoding: binary\r\n\r\n\
+<o-ex:rights xmlns:o-ex=\"http://odrl.net/1.1/ODRL-EX\" \
+xmlns:o-dd=\"http://odrl.net/1.1/ODRL-DD\" \
+xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#/\">\
+<o-ex:context><o-dd:version>1.0</o-dd:version></o-ex:context>\
+<o-ex:agreement><o-ex:asset><o-ex:context>\
+<o-dd:uid>");
+
+_LIT8( KROPart2, "</o-dd:uid></o-ex:context></o-ex:asset><o-ex:permission>\
+<o-dd:display/><o-dd:play/><o-dd:execute/><o-dd:print/>\
+</o-ex:permission></o-ex:agreement></o-ex:rights>");
+
+const TInt KFLROSize = sizeof(KROPart1) + sizeof(KROPart2);
+
+// MODULE DATA STRUCTURES
+struct TDeleteFileData
+    {
+    RFs aFs;
+    TFileName aName;
+    };
+    
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C void DoResetAndDestroy( TAny* aPtr );
+LOCAL_C void DoResetAndDestroy2( TAny* aPtr );
+LOCAL_C void DoDeleteFile( TAny* aPtr );
+LOCAL_C void ConvertPermissionL( CDRMRights*& aRights,
+                                 CDRMPermission& aPermission,
+                                 const TDesC8& aURI );
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// DoResetAndDestroy
+// Does ResetAndDestroy() to given RPointerArray< CDRMRights >
+// -----------------------------------------------------------------------------
+void DoResetAndDestroy( TAny* aPtr )
+    {
+    __ASSERT_DEBUG( aPtr, User::Invariant() );
+    
+    reinterpret_cast< RPointerArray< CDRMRights >* >( aPtr )->ResetAndDestroy();
+    }
+
+void DoResetAndDestroy2( TAny* aPtr )
+    {
+    __ASSERT_DEBUG( aPtr, User::Invariant() );
+    
+    reinterpret_cast< RPointerArray< CDRMPermission >* >( aPtr )->ResetAndDestroy();
+    }
+// -----------------------------------------------------------------------------
+// DoDeleteFile
+// Delete the file presented by TDeleteFileData pointer.
+// -----------------------------------------------------------------------------
+void DoDeleteFile( TAny* aPtr )
+    {
+    __ASSERT_DEBUG( aPtr, User::Invariant() );
+    TDeleteFileData* data = reinterpret_cast< TDeleteFileData* >( aPtr );
+    data->aFs.Delete( data->aName );
+    }
+
+void ConvertPermissionL( CDRMRights*& aRights,
+                         CDRMPermission& aPermission,
+                         const TDesC8& aURI )
+    {
+    CDRMAsset* asset( NULL );
+    CDRMRights* rights( NULL );
+    
+    aRights = NULL;
+    
+    rights = CDRMRights::NewL();
+    CleanupStack::PushL( rights );
+    
+    asset = CDRMAsset::NewL();
+    CleanupStack::PushL( asset );
+    
+    asset->iUid = aURI.AllocL();
+    
+    if ( aPermission.iParentUID )
+        {
+        asset->iParentRights = aPermission.iParentUID->AllocL();
+        }
+    
+    rights->SetPermissionL( aPermission );
+    rights->SetAssetL( *asset );
+    
+    CleanupStack::PopAndDestroy(); // asset
+    CleanupStack::Pop(), // rights
+    
+    aRights = rights;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMMessageParser* CDRMMessageParser::NewL( void )
+    {
+    CDRMMessageParser* self = new( ELeave ) CDRMMessageParser();
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::CDRMMessageParser
+// Constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMMessageParser::CDRMMessageParser() :
+    iDcfCreator( NULL ),
+    iBoundary( NULL ),
+    iContentType( NULL ),
+    iState( ESearchingBoundary ),
+    iInputBuffer( NULL, 0, 0 )
+    {
+    iDCFHeaderSize[ 0 ] = KMaxTUint32;
+    iDCFHeaderSize[ 1 ] = KMaxTUint32;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMMessageParser::~CDRMMessageParser()
+    {
+    TInt error = KErrNone;
+    TRAP( error, FinalizeMessageParserL() );
+    
+    Reset();
+    
+    User::Free( const_cast< TUint8* >( iInputBuffer.Ptr() ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMMessageParser::InitializeMessageParserL( RWriteStream& aStream )
+    {
+    Reset();
+    
+    iDcfCreator = COma1DcfCreator::NewL();
+    
+    iOutputStream = aStream;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::ProcessDataL
+// Choose which operation is required.
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMMessageParser::ProcessMessageDataL( const TDesC8& aMessageData )
+    {
+    /*
+    * What happens here is:
+    *   - a boundary string is located and extracted
+    *   - MIME header is read, and based on content-type field the internal
+    *     state is set to either EReadingRightsPart or EReadingContentPart.
+    *   - after processing the MIME part, internal state is updated again to 
+    *     EReadingHeaderPart if there are several MIME parts in the DRM 
+    *     message.
+    *   - data is consumed from iInputData in each phase.
+    *   - after everything is done, internal state is set to EAllDone.
+    */
+    if ( iState & EBroken )
+        {
+        User::Leave( KErrNotReady );
+        }
+    
+    if ( iState & EAllDone )
+        {
+        return;
+        }
+    
+    iInputData.Set( aMessageData );
+    
+    while( iInputData.Length() )
+        {
+        if ( iState & EReadingHeaderPart )
+            {
+            ReadHeaderL();
+            }
+        else
+            {
+            if ( iState & EReadingContentPart )
+                {
+                HandleContentDataL();
+                }
+            else
+                {
+                if ( iState & EReadingRightsPart )
+                    {
+                    HandleRightsDataL();
+                    }
+                else
+                    {
+                    FindBoundaryL();
+                    }
+                }
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::FinalizeL
+// Finalize the message parser.
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMMessageParser::FinalizeMessageParserL()
+    {
+    TInt error( KErrNone );
+    
+    if ( iState & EEncryptStreamOk )
+        {
+        if ( iInputBuffer.Length() )
+            {
+            // Message is not parsed fully ==> error.
+            // Try to delete the RO if it is possible.
+            DeletePermission();
+            error = KDRMMessageMalformed;
+            }
+            
+        ClearBit( EEncryptStreamOk );
+        iDcfCreator->EncryptFinalizeL();
+        
+        iOutputStream.CommitL();
+        }
+
+    Reset();
+    
+    User::LeaveIfError( error );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageParser::ConstructL()
+    {
+    // Make some extra room for crazy b64decode().
+    iInputBuffer.Set( reinterpret_cast< TUint8* >( 
+                        User::AllocL( KInputBufferSize + 2 ) ), 
+                      0, 
+                      KInputBufferSize );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::HandleContentDataL
+// Process the content data:
+// - base64 decoding
+// - boundary checks
+// - forward the processed data to ProcessContentDataL
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageParser::HandleContentDataL()
+    {
+   TPtrC8 res( NULL, 0 );
+    TBool cont( ETrue );
+    TInt remainder( 0 );
+    
+    // Loop until 
+    // - PrepareContentDataL leaves
+    // - boundary end marker is found
+    // - iInputBuffer is not updated anymore.
+    for ( PrepareContentDataL(); 
+          iInputBuffer.Length() && 
+              ( remainder != iInputBuffer.Length() ) && 
+              cont;
+          PrepareContentDataL() )
+        {
+        TInt pos = iInputBuffer.Find( *iBoundary );
+        
+        if ( pos >= 0 )
+            {
+            if ( pos < KBoundaryMarkLength + 1 ) 
+                {
+                SetBrokenStateL( KDRMMessageMalformed );
+                }
+            
+            res.Set( iInputBuffer.Left( pos - KBoundaryMarkLength ) );
+            
+            StripEndLineL( res );
+            
+            cont = EFalse;
+            }
+        else
+            {
+            // All the data cannot be processed immediately, because
+            // there may be only a part of boundary string in this buffer
+            // and the rest is got from the next input descriptor.
+            remainder = iBoundary->Length() + KBoundaryMarkLength + 1;
+            
+            if ( iInputBuffer.Length() <= remainder )
+                {
+                return;
+                }
+            
+            res.Set( iInputBuffer.Left( iInputBuffer.Length() - 
+                                        remainder ) );
+            }
+        
+        if ( iState & EBase64 )
+            {
+            iUsedFromInput = HandleBase64DataL( res );
+            }
+        
+        else
+            {
+            iUsedFromInput = res.Length();
+            }
+        
+        ProcessContentDataL( res );
+        
+        CompressInputBuffer();
+
+        remainder = iInputBuffer.Length(); 
+        }
+    
+    if ( !cont )
+        {
+        // Discard all the remaining data.
+        ClearBit( EReadingContentPart );
+        SetBit( EAllDone );
+        iInputBuffer.SetLength( 0 );
+        iInputData.Set( NULL, 0 );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::HandleRightsDataL
+// - check if the boundary is reached
+// - check if the whole rights part is read, and allocate memory && copy the RO
+//   if so
+// - save the rights object
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageParser::HandleRightsDataL()
+    {
+    TPtrC8 res( NULL, 0 );
+    
+    do
+        {
+        res.Set( GetLineL() );
+        
+        TInt pos = res.Find( *iBoundary );
+        
+        if ( pos >= KBoundaryMarkLength )
+            {
+            if ( res.Left( KBoundaryMarkLength ) == KBoundaryMark )
+                {
+                // Allow empty RO here. If it is not allowed by 
+                // HandleRightsMessagePart(), an error is thrown.
+                TBool last = EFalse;
+                
+                // Returns always true.
+                IsBoundary( res, last );
+                
+                if ( last )
+                    {
+                    TInt error( KErrNone );
+                    RPointerArray< CDRMRights > rights;
+                    TPtrC8 ptr( iInputBuffer.Ptr(),         
+                                pos - KBoundaryMarkLength );
+                    
+                    error = ProcessRightsObject(ptr, rights);
+                    rights.ResetAndDestroy();
+                    
+                    if ( !error )
+                        {
+                        SetBit( EAllDone );
+                        }
+                    else
+                        {
+                        SetBrokenStateL( error );
+                        }
+                    }
+                else
+                    {
+                    // Save the RO since the CID needs to be either changed 
+                    // or created.
+                    iRightsData = iInputBuffer.Left( iUsedFromInput - 
+                                                     res.Length() ).AllocL();
+                    }
+                
+                CompressInputBuffer();
+                
+                ClearBit( EReadingRightsPart );
+                ClearBit( EGotContentType );
+                ClearBit( EGotContentEncoding );
+
+                SetBit( EGotRightsPart );
+                SetBit( EReadingHeaderPart );
+                
+                res.Set( NULL, 0 );
+#ifndef __DRM_FULL
+                User::Leave(KErrNotSupported);
+#endif                
+                }
+            else
+                {
+                SetBrokenStateL( KDRMMessageMalformed );
+                }
+            }
+        else
+            {
+            if ( pos >= 0 )
+                {
+                SetBrokenStateL( KDRMMessageMalformed );
+                }
+            }
+        } while ( res.Length() );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::FindBoundaryL
+// Tries to locate the boundary string from the available data in iInputBuffer.
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageParser::FindBoundaryL()
+    {
+    TPtrC8 line( NULL, 0 );
+    
+    FOREVER
+        {
+        line.Set( GetLineL() );
+        
+        if ( line.Length() > KBoundaryMarkLength )
+            {
+            TInt size = 0;
+            
+            if ( line.Left( KBoundaryMarkLength ) == KBoundaryMark )
+                {
+                size = line.Length() - KBoundaryMarkLength - 1;
+                
+                if ( line[ line.Length() - 2 ] == '\r' )
+                    {
+                    --size;
+                    }
+                
+                iBoundary = line.Mid( KBoundaryMarkLength, size ).AllocL();
+                
+                SetBit( EGotBoundary );
+                SetBit( EReadingHeaderPart );
+                
+                CompressInputBuffer();
+                
+                return;
+                }
+            }
+        else
+            {
+            if ( line.Length() == 0 )
+                {
+                return;
+                }
+            }
+        
+        // Something else, not interested.
+        CompressInputBuffer();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMMessageParser::ReadHeaderL
+// The boundary is read and the following part is (should be) either a RO part
+// or content part. The data is kept in iInputBuffer until the whole header 
+// part of the MIME header part is received. After plain "\r\n" line is 
+// received and content-type is defined, iState is updated.
+// ----------------------------------------------------------------------------
+//
+void CDRMMessageParser::ReadHeaderL()
+    {
+    TPtrC8 line( NULL, 0 );
+    TPtrC8 ptr( NULL, 0 );
+    
+    FOREVER
+        {
+        ///////////////////////////////////////////////////////////////////
+        // Process the MIME header line-by-line. Process the lines if they
+        // contain some information that is found useful. Update the 
+        // internal state according to findings.
+        ///////////////////////////////////////////////////////////////////
+        line.Set( GetLineL() );
+        
+        if ( line.Length() )
+            {
+            if ( line == KEndLine || line == KNewLine )
+                {
+                ///////////////////////////////////////////////
+                // MIME header is read. Check what to do next.
+                ///////////////////////////////////////////////
+                if ( iState & EGotContentType )
+                    {
+                    // Sanity check: Either EReadingRightsPart or 
+                    // EReadingContentPart must defined.
+                    __ASSERT_DEBUG( ( iState & EReadingRightsPart ) ||
+                        ( iState & EReadingContentPart ), 
+                        User::Invariant() );
+                    
+                    ClearBit( EReadingHeaderPart );
+                    
+                    CompressInputBuffer();
+                    
+                    // Check which part was read.
+                    // If content part is being processed, some checkings 
+                    // need to be made.
+                    if ( iState & EReadingContentPart )
+                        {
+                        if ( iContentType->CompareF( KDRMContentType ) == 0 )
+                            {
+                            if ( iState & EGotRightsPart )
+                                {
+                                // CD DCF.
+                                SetBrokenStateL( KErrCANotSupported );
+                                }
+                            
+                            InitDCFBufferL();
+
+                            SetBit( EDCFFile );
+                            }
+                        else
+                            {
+                            // Non-DCF FL content or normal CD content. 
+                            // Create or modify the CID, save the RO.
+                            HandleFlContentL();
+                            
+                             iDcfCreator->EncryptInitializeL(
+                                iOutputStream,
+                                *iContentType,
+                                iRightsObject );
+                            SetBit( EEncryptStreamOk );
+                            
+                            // The RO handle iRightsObject is kept in order 
+                            // to delete the rights in case of content 
+                            // encryption error. In that case, this will 
+                            // generate unnecessary "RO Added / RO Deleted"
+                            // notifications, but so what. "More correct"
+                            // way of doing would be modifying 
+                            // EncryptInitialize not to 
+                            // save the RO, but then the key would have to
+                            // be given to it by other means. Since we are
+                            // not their "friend" class, we cannot access 
+                            // their members, and making them to ask our
+                            // members when doing EncryptInitialize/Finalize
+                            // might cause some problems perhaps.
+                            }
+                        
+                        delete iContentType;
+                        iContentType = NULL;
+                        }
+                    
+                    return;
+                    }
+                
+                // Empty MIME header.
+                SetBrokenStateL( KDRMMessageMalformed );
+                }
+            
+            ///////////////////////////////////
+            // Check the line for content-type.
+            ///////////////////////////////////
+            if ( line.Length() > KContentType().Length()  &&  
+                !( line.Left( KContentType().Length() ).CompareF( KContentType ) ) )
+                {
+                if ( iState & EGotContentType )
+                    {
+                    // Content-type given twice.
+                    SetBrokenStateL( KDRMMessageMalformed );
+                    }
+                
+                ptr.Set( HeaderValueL( line ) );
+                
+                SetBit( EGotContentType );
+                
+                // Which part this is: rights or the actual content?
+                if ( ( ptr.CompareF( KDRMXMLRightsType ) == 0 ) ||
+                    ( ptr.CompareF( KDRMWBXMLRightsType ) == 0 ) )
+                    {
+                    if ( iState & EGotRightsPart )
+                        {
+                        // Rights are given twice.
+                        SetBrokenStateL( KDRMMessageMalformed );
+                        }
+                    
+                    SetBit( EReadingRightsPart );
+                    }
+                else
+                    {
+                    if ( iState & EGotContentPart )
+                        {
+                        SetBrokenStateL( KDRMMessageMalformed );
+                        }
+                    
+                    SetBit( EReadingContentPart );
+                    
+                    // Content-type is saved for future use.
+                    iContentType = ptr.AllocL();
+                    }
+                }
+            else
+                {
+                ////////////////////////////////////////////////
+                // Check the line for content-transfer-encoding.
+                ////////////////////////////////////////////////
+                if ( line.Length() > KContentTransferEncoding().Length() &&
+                    !( line.Left( KContentTransferEncoding().Length() ).
+                    CompareF( KContentTransferEncoding ) ) )
+                    {
+                    if ( iState & EGotContentEncoding )
+                        {
+                        // Double line.
+                        SetBrokenStateL( KDRMMessageMalformed );
+                        }
+                    
+                    ptr.Set( HeaderValueL( line ) );
+                    
+                    SetBit( EGotContentEncoding );
+
+                    // Throw an error if content-transfer-encoding 
+                    // is something we don't support.
+                    if ( ptr.CompareF( KEncoding8bit ) &&
+                        ptr.CompareF( KEncoding7bit) &&
+                        ptr.CompareF( KEncodingBinary ) )
+                        {
+                        if ( ptr.CompareF( KEncodingBase64 ) )
+                            {
+                            SetBrokenStateL( KErrCANotSupported );
+                            }
+                        
+                        // So it has to be Base64.
+                        SetBit( EBase64 );
+                        }
+                    }
+                else
+                    {
+                    //////////////////////////////////////////
+                    // Check the line for end boundary marker.
+                    //////////////////////////////////////////
+                    TBool final( EFalse );
+                    
+                    if ( IsBoundary( line, final ) )
+                        {
+                        SetBrokenStateL( KDRMMessageMalformed );
+                        }
+                    
+                    // Else: some X-field, parameter or something else. 
+                    // The line is ignored.
+                    }
+                }
+            
+            CompressInputBuffer();
+            }
+            
+        else
+            {
+            // No line available yet.
+            return;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::GetLineL
+// Return a descriptor representing a single line ending to \n in iInputBuffer.
+// -----------------------------------------------------------------------------
+//
+TPtrC8 CDRMMessageParser::GetLineL()
+    {
+    TInt pos = 0;
+    TPtrC8 res( NULL, 0 );
+    
+    if ( iInputBuffer.Length() > iUsedFromInput )
+        {
+        pos = iInputBuffer.Mid( iUsedFromInput ).Find( KNewLine );
+        
+        if ( pos >= 0 )
+            {
+            res.Set( iInputBuffer.Mid( iUsedFromInput, pos - iUsedFromInput + 1 ) );
+            iUsedFromInput = pos + 1;
+            }
+        }
+    
+    if ( res.Length() == 0 )
+        {
+        if ( iInputData.Length() )
+            {
+            pos = iInputData.Find( KNewLine );
+            
+            if ( pos < 0 )
+                {
+                if ( iInputBuffer.MaxSize() - iInputBuffer.Length() < 
+                    iInputData.Length() )
+                    {
+                    SetBrokenStateL( KDRMMessageMalformed );
+                    }
+                
+                iInputBuffer.Append( iInputData );
+                iInputData.Set( NULL, 0 );
+                }
+            else
+                {
+                if ( iInputBuffer.MaxSize() - iInputBuffer.Length() <
+                    pos + 1 )
+                    {
+                    SetBrokenStateL( KDRMMessageMalformed );
+                    }
+                
+                iInputBuffer.Append( iInputData.Left( pos + 1 ) );
+                res.Set( iInputBuffer.Mid( iUsedFromInput ) );
+                iUsedFromInput = iInputBuffer.Length();
+                
+                iInputData.Set( iInputData.Mid( pos + 1 ) );
+                }
+            }
+        }
+    
+    return res;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::HeaderValueL
+// Return a descriptor representing a header value in aLine.
+// -----------------------------------------------------------------------------
+//
+TPtrC8 CDRMMessageParser::HeaderValueL( const TDesC8& aLine )
+    {
+    TInt pos( 0 );
+    TPtrC8 res( NULL, 0 );
+    
+    pos = aLine.Find( KColon );
+    
+    if ( pos <= 0 )
+        {
+        SetBrokenStateL( KDRMMessageMalformed );
+        }
+    
+    pos += 1;
+    
+    while ( pos < aLine.Length() && 
+            TChar( aLine[ pos ] ).IsSpace() )
+        {
+        ++pos;
+        }
+
+    // Don't overindex.   
+    if ( pos == aLine.Length() )
+        {
+        // Full of whitespaces.
+        SetBrokenStateL( KDRMMessageMalformed );
+        }
+
+    // Drop possible parameters.
+    res.Set( aLine.Mid( pos ) );
+    pos = res.Find( KSemiColon );
+    
+    if ( pos >= 0 )
+        {
+        res.Set( res.Left( pos ) );
+        }
+    
+    pos = res.Length();
+    
+    if ( !pos )
+        {
+        // Just parameters, no actual value.
+        SetBrokenStateL( KDRMMessageMalformed );
+        }
+
+    // This can't underflow, since otherwise there would be only 
+    // semicolon & parameters (checked earlier).
+    while( TChar( res[ pos - 1 ] ).IsSpace() )
+        {
+        --pos;
+        }
+    
+    return res.Left( pos );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::CompressInputBuffer
+// Compress iInputBuffer.
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageParser::CompressInputBuffer()
+    {
+    if ( iUsedFromInput )
+        {
+        const TInt size = iInputBuffer.Length() - iUsedFromInput;
+        
+        Mem::Copy( const_cast< TUint8* >( iInputBuffer.Ptr() ),
+            iInputBuffer.Ptr() + iUsedFromInput,
+            size );
+        
+        iInputBuffer.SetLength( size );
+        iUsedFromInput = 0;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::PrepareContentDataL
+// Fills the iInputBuffer from iInputData.
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageParser::PrepareContentDataL()
+    {
+    if ( iInputData.Length() )
+        {
+        if ( iInputBuffer.Length() == iInputBuffer.MaxSize() )
+            {
+            SetBrokenStateL( KDRMMessageMalformed );
+            }
+        
+        const TInt size = Min( iInputBuffer.MaxSize() - iInputBuffer.Length(), 
+                               iInputData.Length() );
+        
+        iInputBuffer.Append( iInputData.Left( size ) );
+        
+        iInputData.Set( iInputData.Mid( size ) );
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::HandleBase64DataL
+// Decode base64 encoded data from and to aData descriptor.
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CDRMMessageParser::HandleBase64DataL( TPtrC8& aData )
+    {
+    TUint8* consumed = const_cast< TUint8* >( aData.Ptr() );
+    TUint32 temp1 = 0;
+    TUint8 temp2 = 0;
+
+    for ( temp1 = 0, temp2 = 0; ( TInt )temp1 < aData.Length(); ++temp1 )
+        {
+        if ( ValidB64CharL( *( aData.Ptr() + temp1 ) ) )
+            {
+            ++temp2;
+            if ( temp2 == 4 )
+                {
+                consumed = const_cast< TUint8* >( aData.Ptr() ) + temp1;
+                temp2 = 0;
+                }
+            }
+        }
+    
+    if ( consumed != aData.Ptr() )
+        {
+        User::LeaveIfError( b64decode( const_cast< TUint8* >( aData.Ptr() ), 
+                                       consumed - aData.Ptr() + 1,
+                                       const_cast< TUint8* >( aData.Ptr() ), 
+                                       &temp1 ) );
+        
+        aData.Set( aData.Ptr(), temp1 );
+
+        temp1 = consumed - aData.Ptr() + 1;
+        }
+        
+    else
+        {
+        aData.Set( aData.Ptr(), 0 );
+        temp1 = 0;
+        }
+
+    return static_cast< TInt >( temp1 );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::StripEndLineL
+// Remove \r\n from the end of the line. Update aBuf accordingly.
+// It is allowed that only \n exists, since some WAP gateways used to
+// strip \r's.
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageParser::StripEndLineL( TPtrC8& aBuf )
+    {
+    TInt newSize( aBuf.Length() );
+    
+    if ( aBuf.Right( 1 ) == KNewLine )
+        {
+        --newSize;
+        
+        if ( ( aBuf.Length() > 1 ) && 
+            ( aBuf.Right( 2 ) == KEndLine ) )
+            {
+            --newSize;
+            }
+        
+        aBuf.Set( aBuf.Left( newSize ) );
+        }
+    else
+        {
+        SetBrokenStateL( KDRMMessageMalformed );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::IsBoundary
+// Check if the given line is a boundary line. Also check if the line is
+// the end boundary.
+// -----------------------------------------------------------------------------
+//
+TBool CDRMMessageParser::IsBoundary( const TDesC8& aLine, TBool& aLast ) const 
+    {
+    TBool res = EFalse;
+    
+    __ASSERT_DEBUG( iBoundary, User::Invariant() );
+    
+    if ( iState & EGotBoundary )
+        {
+        if ( aLine.Length() > KBoundaryMarkLength + iBoundary->Length() )
+            {
+            TPtrC8 tmp( NULL, 0 );
+            
+            if ( ( aLine.Left( KBoundaryMarkLength ) == KBoundaryMark ) &&
+                ( aLine.Mid( KBoundaryMarkLength, iBoundary->Length() ).
+                Compare( *iBoundary ) == 0 ) )
+                {
+                res = ETrue;
+                
+                tmp.Set( aLine.Right( aLine.Length() - 
+                    KBoundaryMarkLength - 
+                    iBoundary->Length() ) );
+                
+                if ( ( tmp.Length() >= KBoundaryMarkLength ) &&
+                    ( tmp.Left( KBoundaryMarkLength ) == KBoundaryMark ) )
+                    {
+                    aLast = ETrue;
+                    }
+                }
+            }
+        }
+    
+    return res;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::HandleFlContentL
+// Process FL/CD rights object.
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageParser::HandleFlContentL()
+    {
+    __ASSERT_DEBUG( !( iState & EDCFFile ), User::Invariant() );
+    
+    if ( iRightsData )
+        {
+        HBufC8* cid( NULL );
+        HBufC8* buf( NULL );
+        
+        // RO was found from DRM message.
+        CreateCDCIDL( cid );
+        CleanupStack::PushL( cid );
+      
+        buf = iRightsData;
+        CleanupStack::PushL( buf );
+        iRightsData = NULL;
+        
+        ProcessRightsDataL( *cid, 
+                            *buf );
+        
+        CleanupStack::PopAndDestroy(); // buf
+        CleanupStack::PopAndDestroy(); // cid
+        }
+    else
+        {
+        TInt error = RetrieveFlRights();
+        if ( error )
+            {
+            SetBrokenStateL( error );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::ProcessRightsData
+// Process DRM message -style rights object and fetch it to iRightsObject if 
+// necessary.
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageParser::ProcessRightsDataL( 
+                            const TDesC8& aCID,
+                            const TDesC8& aData )
+    {
+    __ASSERT_DEBUG( !iRightsObject, User::Invariant() );
+    
+    TInt start = aData.Find(KRightsStartTag);
+    TInt end = aData.LocateReverse('>');
+    
+    if ( start >= 0 && end > start )
+        {
+        TDRMUniqueID localID( 0 );
+        CDrmRightsParser* parser( NULL );
+        CDRMAsset* asset( NULL );
+        RDRMRightsClient client;
+        TPtrC8 ptr( &aData[start], end - start + 1 );
+        TBuf8< KDCFKeySize > key;
+        key.SetLength(KDCFKeySize);
+        RPointerArray< CDRMRights > rights;
+        
+        TCleanupItem cleanup( DoResetAndDestroy, &rights );
+        CleanupStack::PushL( cleanup );
+        
+        User::LeaveIfError( client.Connect() );
+        CleanupClosePushL( client );
+        
+        parser = CDrmRightsParser::NewL();
+        CleanupStack::PushL( parser );
+        
+        parser->ParseL( ptr, rights );
+        
+        if (rights.Count()==0)
+        	{
+        	User::Leave(KErrCorrupt);
+        	}
+        
+        client.GetRandomDataL(key);
+
+        User::LeaveIfError( client.AddRecord(
+                            key, 
+                            rights[0]->GetPermission(), 
+                            aCID, 
+                            localID) );
+        
+        iRightsObject = CDRMRights::NewL();
+        
+        asset = CDRMAsset::NewLC();
+        asset->iUid = aCID.AllocL();
+        
+        iRightsObject->SetAssetL(*asset);
+        iRightsObject->SetPermissionL(rights[0]->GetPermission());
+        
+        CleanupStack::PopAndDestroy( 4 ); // asset, parser, client, rights
+        }
+    else
+        {
+        SetBrokenStateL( KErrArgument );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::ProcessContentDataL
+// Handle DCF file's CID manipulation in "DCF in DRM message" case. 
+// Send the data to EncryptUpdateL if encryption is needed.
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageParser::ProcessContentDataL( TPtrC8& aData )
+    {
+    // First, check if the content is DCF stuff.
+    if ( iState & EDCFFile )
+        {
+        // Sanity check: DCF File with RO is illegal.
+        __ASSERT_DEBUG( !iRightsObject, User::Invariant() );
+
+        ProcessDCFDataL( aData );
+        }
+    else
+        {
+        // No, plain FL content.
+        iDcfCreator->EncryptUpdateL( aData );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageParser::ValidB64CharL
+// Determine if the given character is valid base64 character, and leave
+// if it is not.
+// -----------------------------------------------------------------------------
+//
+TBool CDRMMessageParser::ValidB64CharL( const TUint8 aChar )
+    {
+    // Allowed characters are '0'...'9', 'A'...'Z', 'a'...'z', '+', '/', '='
+    if ( ( aChar >= 48 && aChar <= 57 ) || 
+         ( aChar >= 65 && aChar <= 90 ) ||
+         ( aChar >= 97 && aChar <= 122 ) || 
+         ( aChar == 43 ) ||
+         ( aChar == 47 ) ||
+         ( aChar == 61 ) )
+        {
+        return ETrue;
+        }
+
+    if ( ( aChar != 0x0D ) && ( aChar != 0x0A ) )
+        {
+        SetBrokenStateL( KDRMMessageMalformed );        
+        }
+
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::ProcessMessage
+// 
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMMessageParser::ProcessMessage(
+    HBufC8*& aDRMMessage)
+    {
+    TInt error( KErrNone );
+    TRAP( error, DoProcessMessageL( aDRMMessage ) );
+    
+    return error;
+    }
+    
+// -----------------------------------------------------------------------------
+// DRMCommon::ProcessRightsObject
+// Processes a rights objects and saves it in the rights database.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMMessageParser::ProcessRightsObject(
+    const TDesC8& aRightsObject, 
+    RPointerArray<CDRMRights>& aRightsDetail)
+    {
+    TInt error( KErrNone );
+    TRAP( error, DoProcessRightsObjectL( aRightsObject,
+                                         aRightsDetail ) );
+                                         
+    return error;
+    }
+
+void CDRMMessageParser::SetBit( TUint32 aBit )
+    {
+    iState |= aBit;
+    }
+    
+void CDRMMessageParser::ClearBit( TUint32 aBit )
+    {
+    iState &= ~aBit;
+    }
+
+void CDRMMessageParser::Reset()
+    {
+    delete iDCFBuffer;
+    iDCFBuffer = NULL;
+    
+    delete iDcfCreator;
+    iDcfCreator = NULL;
+    
+    delete iRightsData;
+    iRightsData = NULL;
+    
+    delete iRightsObject;
+    iRightsObject = NULL;
+    
+    delete iBoundary;
+    iBoundary = NULL;
+    
+    delete iContentType;
+    iContentType = NULL;
+    
+    iInputBuffer.SetLength( 0 );
+    
+    iState = ESearchingBoundary;
+    iDCFHeaderSize[ 0 ] = KMaxTUint32;
+    iDCFHeaderSize[ 1 ] = KMaxTUint32;
+    }
+
+void CDRMMessageParser::DoProcessMessageL( HBufC8*& aDRMMessage )
+    {
+    TDeleteFileData fileData;
+    RFileWriteStream output;
+    RFile file;
+    TInt size( 0 );
+    
+    User::LeaveIfError( fileData.aFs.Connect() );
+    CleanupClosePushL( fileData.aFs );
+
+    TCleanupItem cleanup( DoDeleteFile, &fileData );
+    CleanupStack::PushL( cleanup );
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    User::LeaveIfError( output.Temp( fileData.aFs, 
+                                     KTempPath, 
+                                     fileData.aName, 
+                                     EFileWrite ) );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	fileData.aFs.DriveToChar( driveNumber, driveLetter );
+    
+	TFileName tempPath;
+	tempPath.Format( KTempPath, (TUint)driveLetter );
+
+    User::LeaveIfError( output.Temp( fileData.aFs, 
+                                   tempPath, 
+                                   fileData.aName, 
+                                   EFileWrite ) );
+    
+#endif
+    
+    CleanupClosePushL( output );
+    
+    InitializeMessageParserL( output );
+    ProcessMessageDataL( *aDRMMessage );
+    FinalizeMessageParserL();
+    
+    CleanupStack::PopAndDestroy(); // output
+    
+    User::LeaveIfError( file.Open( fileData.aFs, fileData.aName, EFileRead ) );
+    CleanupClosePushL( file );
+    
+    User::LeaveIfError( file.Size( size ) );
+    
+    if ( size > aDRMMessage->Des().MaxSize() )
+        {
+        HBufC8* tmp( NULL );
+        
+        delete aDRMMessage; 
+        aDRMMessage = NULL;
+        
+        tmp = HBufC8::NewLC( size );
+        TPtr8 data( tmp->Des() );
+        
+        User::LeaveIfError( file.Read( data ) );
+        CleanupStack::Pop(); // tmp
+        
+        aDRMMessage = tmp;
+        }
+    else
+        {
+        TPtr8 data( aDRMMessage->Des() );
+        User::LeaveIfError( file.Read( data ) );
+        }
+    
+    CleanupStack::PopAndDestroy( 3 ); // file, cleanup, fileData.aFs
+    }
+
+void CDRMMessageParser::DoProcessRightsObjectL( 
+    const TDesC8& aRightsObject, 
+    RPointerArray<CDRMRights>& aRightsDetail )
+    {
+    CDrmRightsParser* parser = NULL;
+    TInt start;
+    TInt end;
+    TPtrC8 ptr(0, 0);
+    
+    start = aRightsObject.Find(KRightsStartTag);
+    end = aRightsObject.LocateReverse('>');
+    
+    TCleanupItem cleanup( DoResetAndDestroy, &aRightsDetail );
+    CleanupStack::PushL( cleanup );
+
+    if ( start != KErrNotFound && end != KErrNotFound )
+        {
+        // xml
+        parser = CDrmRightsParser::NewL();
+        CleanupStack::PushL(parser);
+        
+        ptr.Set(&aRightsObject[start], end - start + 1);    
+        
+        parser->ParseAndStoreL(ptr, aRightsDetail);
+        
+        if (aRightsDetail.Count() == 0)
+            {
+            User::Leave( KErrArgument );
+            }
+        
+        CleanupStack::PopAndDestroy(); // parser
+        }
+    else if (start == KErrNotFound )
+        {
+        // wbxml
+        parser = CDrmRightsParser::NewL(CDrmRightsParser::EWbxmlParser);
+        CleanupStack::PushL(parser);
+        
+        parser->ParseAndStoreL(aRightsObject, aRightsDetail);
+        if (aRightsDetail.Count() == 0)
+            {
+            User::Leave( KErrArgument );
+            }
+        
+        CleanupStack::PopAndDestroy(); // parser
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    CleanupStack::Pop(); // cleanup
+    }
+    
+void CDRMMessageParser::DeletePermission()
+    {
+    if ( iRightsObject )
+        {
+        if ( !( iState & EFLContent ) )
+            {
+            HBufC8* URI = NULL;
+            
+            if ( !( iRightsObject->GetContentURI( URI ) ) )
+                {
+                __ASSERT_DEBUG( URI, User::Invariant() );
+                
+                RDRMRightsClient client;
+                
+                TInt error = client.Connect();
+                
+                if ( !error )
+                    {
+                    // Don't care if it fails.
+                    client.DeleteDbEntry( *URI, iRightsObject->GetLocalID() );
+                    
+                    client.Close();
+                    }
+                
+                delete URI;
+                URI = NULL;
+                }
+            }
+        
+        delete iRightsObject;
+        iRightsObject = NULL;
+        }
+    }
+
+void CDRMMessageParser::SetBrokenStateL( const TInt aError )
+    {
+    SetBit( EBroken );
+    DeletePermission();
+    
+    User::Leave( aError );
+    }
+
+void CDRMMessageParser::InitDCFBufferL()
+    {
+    iDCFBuffer = HBufC8::New( KInitialDCFBufferSize );
+
+    if ( !iDCFBuffer )
+        {
+        SetBrokenStateL( KErrNoMemory );
+        }
+    }
+
+void CDRMMessageParser::CreateCDCIDL( HBufC8*& aCID )
+    {
+    aCID = HBufC8::NewL( KCDContentIDLength );
+    TPtr8 des( aCID->Des() );
+    TBuf8<KCDPlainIDLength> id;
+    id.SetLength(KCDPlainIDLength);
+
+    RDRMRightsClient client;
+    CleanupClosePushL(client);
+    User::LeaveIfError( client.Connect() );
+    client.GetRandomDataL(id);
+    CleanupStack::PopAndDestroy();
+
+    des = KFLPrefix;
+    
+    for (TInt i = 0; i < KCDPlainIDLength; i++)
+        {
+        des.AppendNumFixedWidth( id[i], EDecimal, 1 );
+        }
+
+    des.Append( KFLSuffix );
+    }
+    
+TInt CDRMMessageParser::RetrieveFlRights()
+    {
+    __ASSERT_DEBUG( !iRightsObject, User::Invariant() );
+    
+    RDRMRightsClient client;
+    TInt error( client.Connect() );
+    
+    if ( !error )
+        {
+        TRAP( error, EnsureFLRightsExistL( client, &iRightsObject ) );
+                
+        client.Close();
+        }
+        
+    return error;
+    }
+
+void CDRMMessageParser::ProcessDCFDataL( TPtrC8& aDCFData )
+    {
+    TBool doCommit( EFalse );
+    
+    // Loop until all available data is either cached or processed.
+    // What happens is
+    // - modify Content-URI
+    // - modify DCF header part
+    // - dump the rest of the available data to output.
+    while ( iDCFBuffer->Length() || aDCFData.Length() )
+        {
+        if ( !( iState & EDCFURIModified ) )
+            {
+            //////////////////////////////////////////////////////////////////
+            // Modify ContentURI.
+            //////////////////////////////////////////////////////////////////
+            FillDCFBufferL( aDCFData );
+        
+            if ( iDCFBuffer->Length() > 3 )
+                {
+                TInt pos = 0;
+                TUint8* data = const_cast< TUint8* > ( iDCFBuffer->Ptr() );
+                
+                if ( data[ 0 ] != 1 )
+                    {
+                    SetBrokenStateL( KDRMMessageMalformed );
+                    }
+                
+                // Cache the data until 
+                // - version, 
+                // - ContentTypeLen, 
+                // - ContentURILen, 
+                // - ContentType and 
+                // - ContentURI 
+                // have been received.
+                pos = data[ 1 ] + 3;
+                if ( iDCFBuffer->Length() < pos + data[ 2 ] )
+                    {
+                    return;
+                    }
+                
+                // Sanity check. URI has to be more than four ("cid:") octets.
+                if ( data[ 2 ] < 5 )
+                    {
+                    SetBrokenStateL( KDRMMessageMalformed );
+                    }
+                
+                if ( Mem::CompareF( &data[ pos ], 
+                                    KCIDStringLength,
+                                    KCIDString().Ptr(), 
+                                    KCIDStringLength ) == 0 )
+                    {
+                    // The data length doesn't change, so Mem::Copy() is safe.
+                    Mem::Copy( &data[ pos ], 
+                               KFLPrefix().Ptr(), 
+                               KFLKPrefixLength );
+                    
+                    iOutputStream.WriteL( iDCFBuffer->Left( pos + data[ 2 ] ) );
+                    
+                    doCommit = ETrue;
+
+                    CompressDCFBuffer( pos + data[ 2 ] );
+                    
+                    SetBit( EDCFURIModified );
+                    }
+                else
+                    {
+                    // Discard the broken DCF
+                    SetBrokenStateL( KDRMMessageMalformed );
+                    }
+                }
+            else
+                {
+                // Not enough data yet.
+                return;
+                }
+            }
+        else
+            {
+            //////////////////////////////////////////////////////////////////
+            // URI is now modified. Modify DCF headers if necessary.
+            //////////////////////////////////////////////////////////////////
+            if ( !( iState & EDCFHeadersModified ) )
+                {
+                FillDCFBufferL( aDCFData );
+                
+                // Figure out how much data there is in the header part and/or
+                // in the data part.
+                if ( ( iDCFHeaderSize[ 0 ] == KMaxTUint32 ) &&
+                     ( iDCFHeaderSize[ 1 ] == KMaxTUint32 ) )
+                    {
+                    TUint8 used( 0 );
+                    
+                    // uintvar has 1...5 octets and we need two uintvars before
+                    // anything can be done. Still, there has to be at least 
+                    // 12 octets of data in total to make the DCF legal. But here
+                    // we just check the two uintvars.
+                    if ( iDCFBuffer->Length() < 10 )
+                        {
+                        // Not enough data yet.
+                        // No need to flush aDCFData at this point, since it 
+                        // simply cannot contain anything at this point.
+                        __ASSERT_DEBUG( !aDCFData.Length(), User::Invariant() );
+                        break;
+                        }
+                    
+                    // Read header field length & data length.
+                    for ( TUint8 count = 0; count < 2; ++count )
+                        {
+                        TInt size( 0 );
+                        
+                        TWspPrimitiveDecoder decoder( 
+                                iDCFBuffer->Mid( used ) );
+                        size = decoder.UintVar( iDCFHeaderSize[ count ] );
+                        
+                        // Sanity check.
+                        if ( size < 1 || iDCFHeaderSize[ count ] >= KMaxTInt )
+                            {
+                            SetBrokenStateL( KDRMMessageMalformed );
+                            }
+                        
+                        used += size;
+                        }
+                    
+                    CompressDCFBuffer( used );
+                    }
+                else
+                    {
+                    // We know the original header size now.
+                    // Wait until the whole header is read.
+                    if ( static_cast< TUint32 >( iDCFBuffer->Length() ) < 
+                         iDCFHeaderSize[ 0 ] )
+                        {
+                        if ( !aDCFData.Length() )
+                            {
+                            // All available data is now processed.
+                            break;
+                            }
+                        }
+                    else
+                        {
+                        TUint offset( 0 );
+                        TUint length( 0 );
+                        HBufC8* newHeader = NULL;
+
+                        if ( FindDCFHeader( KRightsIssuer, 
+                                            offset, 
+                                            length ) )
+                            {
+                            // The header field exists.
+                            TInt pos( 0 );
+                            TPtr8 trim( const_cast< TUint8* >( 
+                                            iDCFBuffer->Ptr() ) + offset,
+                                            length, 
+                                            length );
+
+                            iDCFHeaderSize[ 0 ] -= length; // remove old data.
+                            
+                            // No colon, no header value. 
+                            pos = trim.Find( KColon );
+                            if ( pos > 0 )
+                                {
+                                trim.Set( const_cast< TUint8* >( trim.Ptr() ) + pos + 1, 
+                                          trim.Length() - pos - 1,
+                                          trim.Length() - pos - 1 );
+
+                                // Skip whitespaces
+                                trim.TrimLeft();
+                                trim.TrimRight();
+                                
+                                if ( trim.Length() )
+                                    {
+                                    // Something to process
+                                    newHeader = EncryptDCFFieldLC( trim );
+                                    
+                                    iDCFHeaderSize[ 0 ] += KRightsIssuer().Length();
+                                    iDCFHeaderSize[ 0 ] += newHeader->Length();
+                                    iDCFHeaderSize[ 0 ] += 3; // ":" and CRLF
+                                    }
+                                }
+                            }
+                        
+                        // Write the uintvars to output.
+                        for ( TUint8 loop = 0; loop < 2; ++loop )
+                            {
+                            TWspPrimitiveEncoder encoder;
+                            HBufC8* var( encoder.UintVarL( iDCFHeaderSize[ loop ] ) );
+                            
+                            CleanupStack::PushL( var );
+                            
+                            iOutputStream.WriteL( *var );
+                            
+                            CleanupStack::PopAndDestroy(); // var
+                            }
+                        
+                        // Dump the header data to output stream.
+                        iOutputStream.WriteL( iDCFBuffer->Left( offset ) );
+                        
+                        if ( newHeader )
+                            {
+                            iOutputStream.WriteL( KRightsIssuer );
+                            iOutputStream.WriteL( KColon );
+                            iOutputStream.WriteL( *newHeader );
+                            
+                            CleanupStack::PopAndDestroy(); // newHeader
+                            newHeader = NULL;
+                            
+                            iOutputStream.WriteL( KEndLine );
+                            }
+
+                        iOutputStream.WriteL( 
+                            iDCFBuffer->Right( iDCFBuffer->Length() - 
+                                                offset - 
+                                                length ) );
+                        
+                        doCommit = ETrue;
+                        
+                        CompressDCFBuffer( iDCFBuffer->Length() );
+                        SetBit( EDCFHeadersModified );
+                        }
+                    }
+                }
+            else
+                {
+                // Dump the rest of the data.
+                __ASSERT_DEBUG( !( iDCFBuffer->Length() ), User::Invariant() );
+
+                iOutputStream.WriteL( aDCFData );
+                
+                aDCFData.Set( NULL, 0 );
+                
+                doCommit = ETrue;
+                }
+            }
+        }
+
+    if ( doCommit )
+        {
+        iOutputStream.CommitL();
+        }
+    }
+
+void CDRMMessageParser::FillDCFBufferL( TPtrC8& aData )
+    {
+    if ( aData.Length() )
+        {
+        TInt size( 0 );
+
+        if ( iDCFBuffer->Length() == iDCFBuffer->Des().MaxSize() )
+            {
+            HBufC8* ptr = iDCFBuffer->ReAlloc( iDCFBuffer->Length() + 
+                            KDefaultInputBufferSize );
+
+            if ( !ptr )
+                {
+                SetBrokenStateL( KErrNoMemory );
+                }
+
+            iDCFBuffer = ptr;
+            }
+        
+        size = Min( iDCFBuffer->Des().MaxSize() - iDCFBuffer->Length(), 
+                    aData.Length() );
+        
+        iDCFBuffer->Des().Append( aData.Left( size ) );
+        
+        aData.Set( aData.Right( aData.Length() - size ) );
+        }
+    }
+    
+void CDRMMessageParser::CompressDCFBuffer( const TInt aHowMuch )
+    {
+    __ASSERT_DEBUG( aHowMuch <= iDCFBuffer->Des().MaxSize(), User::Invariant() );
+
+    *iDCFBuffer = iDCFBuffer->Des().Mid( aHowMuch );
+    }
+    TBool CDRMMessageParser::FindDCFHeader( const TDesC8& aString,
+                                        TUint& aOffset,
+                                        TUint& aLength )
+    {
+    TPtrC8 des( const_cast< TUint8* >( iDCFBuffer->Ptr() ),  
+                Min( iDCFBuffer->Length(), iDCFHeaderSize[ 0 ] ) );
+
+    aOffset = 0;
+    aLength = 0;
+
+    while ( des.Length() )
+        {
+        TInt pos = des.Find( KEndLine );
+        if ( pos < 0 )
+            {
+            // Last header doesn't end to "\r\n"
+            pos = des.Length();
+            if ( pos < 0 )
+                {
+                return EFalse;
+                }
+            }
+        else
+            {
+            pos += KEndLineLength;
+            }
+            
+        if ( ( pos < aString.Length() ) || 
+             ( des.Left( aString.Length() ).CompareF( aString ) != 0 ) )
+             {
+            // Skip the line, since this can't be the one we're looking for.
+            des.Set( des.Right( des.Length() - 
+                                pos ) );
+            }
+        else
+            {
+            aOffset = des.Ptr() - iDCFBuffer->Ptr();
+            aLength = pos;
+            
+            return ETrue;
+            }
+        }
+    
+    // Never reached.
+    return EFalse;
+    }
+    
+void CDRMMessageParser::EnsureFLRightsExistL( 
+    RDRMRightsClient& aClient, 
+    CDRMRights** aOutput )
+    {
+    HBufC8* cid( NULL );
+    CDRMRights* perm( NULL );
+    RPointerArray< CDRMPermission > rights( 1 );
+    
+    TCleanupItem cleanup( DoResetAndDestroy2, &rights );
+    CleanupStack::PushL( cleanup );
+    
+    User::LeaveIfError( aClient.ForwardLockURI( cid ) );
+    CleanupStack::PushL( cid );
+    
+    TRAPD( error, aClient.GetDBEntriesL( *cid, rights ) );
+    
+    if ( !error )
+        {
+        ConvertPermissionL( perm, *( rights[ 0 ] ), *cid );
+        // No need to pushl 'perm' into cleanup stack.
+        }
+    else if ( error == KErrCANoRights )
+        {
+        HBufC8* fl( NULL );
+        RPointerArray< CDRMRights > rightslist( 1 );
+        
+        TCleanupItem cleanup2( DoResetAndDestroy, &rightslist );
+        CleanupStack::PushL( cleanup2 );
+        
+        fl = HBufC8::NewLC( KFLROSize + cid->Length() );
+        
+        *fl = KROPart1;
+        fl->Des().Append( *cid );
+        fl->Des().Append( KROPart2 );
+            
+        User::LeaveIfError( ProcessRightsObject( *fl, rightslist ) );
+    
+        CleanupStack::PopAndDestroy(); // fl
+
+        perm = rightslist[ 0 ];
+        rightslist.Remove( 0 );
+        
+        CleanupStack::PopAndDestroy(); // cleanup2
+        
+        error = KErrNone;
+        }
+        
+    CleanupStack::PopAndDestroy(); // cid
+
+    if ( !error )
+        {
+        // There is something.
+        if ( aOutput )
+            {
+            *aOutput = perm;
+            }
+        else
+            {
+            delete perm; perm = NULL;
+            }
+        }
+        
+    CleanupStack::PopAndDestroy(); // cleanup
+    }
+
+
+HBufC8* CDRMMessageParser::EncryptDCFFieldLC( const TDesC8& aOldHeader )
+    {
+    HBufC8* res = NULL;
+    RDRMRightsClient client;
+    
+    User::LeaveIfError( client.Connect() );
+    CleanupClosePushL( client );
+
+    // Make sure FL rights exists.
+    EnsureFLRightsExistL( client, NULL );
+
+    User::LeaveIfError( 
+        client.EncodeRightsIssuerField( aOldHeader, res ) );
+    
+    CleanupStack::PopAndDestroy(); // client
+
+    CleanupStack::PushL( res );
+
+    return res;
+    }
+    
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dm/src/Oma1DcfCreator.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,366 @@
+/*
+* Copyright (c) 2002, 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:  Implementation of the DRM access functions that are available
+*                to authenticated clients.
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <e32base.h>
+#include <e32std.h>
+#include <e32math.h>
+#include <e32test.h>
+#include <f32file.h>
+#include <s32file.h>
+#include <s32mem.h>
+#include <apmstd.h>
+#include <symmetric.h>
+#include "Oma1DcfCreator.h"
+#include "DRMRightsClient.h"
+#include "DRMPermission.h"
+#include "DRMConstraint.h"
+#include "DRMCommon.h"
+#include "DrmKeyStorage.h"
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+static const TInt KMaxEncryptionSize = 2048;    
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+_LIT8(KLDContentURI, "ldf:31415926535@localhost");
+_LIT8(KLDFHeader, "Encryption-Method:AES128CBC;padding=RFC2630\x0d\x0a");
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// COma1DcfCreator::COma1DcfCreator
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+EXPORT_C COma1DcfCreator::COma1DcfCreator(void)
+    {
+    iEncryptionStream = NULL;
+    iEncryptionBuffer = NULL;
+    } 
+
+// -----------------------------------------------------------------------------
+// COma1DcfCreator::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void COma1DcfCreator::ConstructL()
+    {
+    iEncryptionBuffer = HBufC8::NewL(KMaxEncryptionSize);
+    }
+
+// -----------------------------------------------------------------------------
+// COma1DcfCreator::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+EXPORT_C COma1DcfCreator* COma1DcfCreator::NewL()
+    {
+    COma1DcfCreator* self = new COma1DcfCreator();
+    
+    User::LeaveIfNull(self);
+    
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    
+    return self;
+    }
+
+
+// Destructor
+EXPORT_C COma1DcfCreator::~COma1DcfCreator()
+    {
+    delete iEncryptionBuffer;
+    iRdb.Close();
+    }
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// COma1DcfCreator::
+// 
+// -----------------------------------------------------------------------------
+EXPORT_C void COma1DcfCreator::EncryptInitializeL(
+    RWriteStream& anOutput,
+    const TDesC8& aMIMEType, 
+    CDRMRights* aRightsObject)
+    {
+    const TUint KVersion = 1;
+    CDRMPermission *rights = CDRMPermission::NewLC();
+    TInt err = 0;
+    TDRMUniqueID id = 0;
+    TBuf8<KDCFKeySize> key;
+    TPtrC8 uri(0, 0);
+
+    User::LeaveIfError(iRdb.Connect());
+    iBytesWritten = 0;
+
+    // generate rights
+    if (aRightsObject)
+        {
+        uri.Set(aRightsObject->GetAsset().iUid->Des());
+        err = iRdb.InitializeKey(uri);
+        if (err == KErrCANoRights)
+            {
+            key.SetLength(KDCFKeySize);
+            iRdb.GetRandomDataL(key);    
+            User::LeaveIfError(iRdb.AddRecord(key, aRightsObject->GetPermission(),
+                uri, id));
+            User::LeaveIfError(iRdb.InitializeKey(uri));
+            }
+        else
+            {
+            User::LeaveIfError(err);
+            }
+        }
+    else
+        {
+        uri.Set(KLDContentURI);
+        err = iRdb.InitializeKey(uri);
+        if (err == KErrCANoRights)
+            {
+            rights->iAvailableRights = ERightsAll;
+            rights->iTopLevel->iActiveConstraints = EConstraintNone;
+            rights->iPlay->iActiveConstraints = EConstraintNone;
+            rights->iDisplay->iActiveConstraints = EConstraintNone;
+            rights->iPrint->iActiveConstraints = EConstraintNone;
+            rights->iExecute->iActiveConstraints = EConstraintNone;
+            rights->iUniqueID = 0;
+            key.SetLength(KDCFKeySize);
+            iRdb.GetRandomDataL(key);
+            User::LeaveIfError(iRdb.AddRecord(key, *rights, uri, id));
+            User::LeaveIfError(iRdb.InitializeKey(uri));
+            }
+        else
+            {
+            User::LeaveIfError(err);
+            }
+        }
+
+    iIv.SetLength(KDCFKeySize);
+    iRdb.GetRandomDataL(iIv);
+
+    iEncryptionStream = &anOutput;
+
+    anOutput.WriteUint8L(KVersion);
+    anOutput.WriteUint8L(aMIMEType.Length());
+    anOutput.WriteUint8L(uri.Length());
+    anOutput.WriteL(aMIMEType);
+    anOutput.WriteL(uri);
+    anOutput.WriteUint8L(KLDFHeader().Size());
+    anOutput.WriteUint8L(0);
+    anOutput.WriteL(KLDFHeader);
+    anOutput.WriteL(iIv);
+    anOutput.CommitL();
+    iBytesWritten += 3 + aMIMEType.Size() + 2 + KLDFHeader().Size() +
+        iIv.Size();
+    
+    CleanupStack::PopAndDestroy(); // rights
+    } 
+
+// -----------------------------------------------------------------------------
+// COma1DcfCreator::EncryptUpdateL
+// update the encryption
+// -----------------------------------------------------------------------------
+EXPORT_C void COma1DcfCreator::EncryptUpdateL(const TDesC8& aMessageData)
+    {
+    TInt i;
+    TInt n;
+    TInt size;
+    TPtr8 ptr(iEncryptionBuffer->Des());
+    TPtrC8 data;
+    
+    data.Set(aMessageData);
+    if (iRemainder.Size() > 0 && iRemainder.Size() + data.Size() >= KDCFKeySize)
+        {
+        ptr.Copy(iRemainder);
+        n = Min(KDCFKeySize - iRemainder.Size(), data.Size());
+        ptr.Append(data.Left(n));
+        iRdb.Encrypt(iIv, ptr);
+        iEncryptionStream->WriteL(ptr);
+        iBytesWritten += ptr.Size();
+        iIv.Copy(ptr.Right(KDCFKeySize));
+        data.Set(data.Right(data.Size() - n));
+        iRemainder.SetLength(0);
+        }
+    
+    size = data.Size();
+    for (i = 0; size > KDCFKeySize; i += KMaxEncryptionSize)
+        {
+        n = Min(KMaxEncryptionSize, ((size / KDCFKeySize) * KDCFKeySize));
+        ptr.Copy(data.Mid(i, n));
+        iRdb.Encrypt(iIv, ptr);
+        iEncryptionStream->WriteL(ptr);
+        iBytesWritten += ptr.Size();
+        iIv.Copy(ptr.Right(KDCFKeySize));
+        size -= n;
+        }
+    iRemainder.Append(data.Right(size));
+    }
+
+
+// -----------------------------------------------------------------------------
+// COma1DcfCreator::EncryptFinalizeL
+// finalize the encryption
+// -----------------------------------------------------------------------------
+EXPORT_C void COma1DcfCreator::EncryptFinalizeL()
+    {
+    TPtr8 ptr(iEncryptionBuffer->Des());
+    
+    ptr.Copy(iRemainder);
+    iRdb.Encrypt(iIv, ptr, ETrue);
+    iEncryptionStream->WriteL(ptr);
+    iEncryptionStream->CommitL();
+
+    iBytesWritten += ptr.Size();
+    iRdb.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// COma1DcfCreator::EncryptContent
+// Encrypt plain content to a DCF. Replaces the input buffer with the plain
+// content with the DCF.
+// -----------------------------------------------------------------------------
+EXPORT_C void COma1DcfCreator::EncryptContentL(
+    HBufC8*& aContent, 
+    const TDesC8& aMIMEType, 
+    CDRMRights* aRightsObject)
+    {
+    RMemWriteStream output;
+    TAny* buffer;
+    TInt size;
+
+    size = aContent->Length() +
+        aMIMEType.Length() +
+        KLDContentURI().Length() + 
+        KLDFHeader().Length() + 256;
+    buffer = User::Alloc(size);
+    User::LeaveIfNull(buffer);
+    CleanupStack::PushL(buffer);
+    output.Open(buffer, size);
+    CleanupClosePushL(output);
+    EncryptInitializeL(output, aMIMEType, aRightsObject);
+    EncryptUpdateL(*aContent);
+    EncryptFinalizeL();
+    delete aContent;
+    aContent = HBufC8::NewMax(size);
+    User::LeaveIfNull(aContent);
+    size = iBytesWritten;
+    *aContent = TPtr8(static_cast<TUint8*>(buffer), size, size);
+    CleanupStack::PopAndDestroy(2); // output, buffer
+    }
+
+// -----------------------------------------------------------------------------
+// COma1DcfCreator::EncryptFileL
+// Turn a plain content file into a DCF.
+// -----------------------------------------------------------------------------
+EXPORT_C void COma1DcfCreator::EncryptFileL(
+    const TDesC& aFileName, 
+    const TDesC& aDCFFileName, 
+    const TDesC8& aMIMEType, 
+    CDRMRights* aRightsObject)
+    {
+    TInt r = KErrNone;    
+    RFs fs;
+    RFile input;
+    RFileWriteStream output;
+    HBufC8* buf = HBufC8::NewLC(8000);
+    TPtr8 buffer(const_cast<TUint8*>(buf->Ptr()),0,8000);
+   
+
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+
+    r = input.Open(fs, aFileName, EFileRead|EFileShareReadersOrWriters);
+    if(r == KErrInUse)
+        {
+        r = input.Open(fs, aFileName, EFileRead | EFileShareAny);
+                                                      
+        if(r == KErrInUse)
+            {
+            User::LeaveIfError(input.Open(fs, aFileName, EFileRead | 
+                                                         EFileShareReadersOnly));
+            r = KErrNone;                                             
+            }
+        }
+        
+    User::LeaveIfError( r );        
+    
+    CleanupClosePushL(input);
+    
+    User::LeaveIfError(output.Replace(fs, aDCFFileName, EFileWrite));
+    CleanupClosePushL(output);    
+    
+   
+    EncryptInitializeL(output, aMIMEType, aRightsObject);
+
+    
+    do
+        {
+        input.Read(buffer, buffer.MaxSize());
+        if (buffer.Size() > 0)
+            {
+
+            EncryptUpdateL(buffer);
+
+            }
+        }
+    while (buffer.Size() > 0);
+ 
+    EncryptFinalizeL();
+
+    CleanupStack::PopAndDestroy(4); // output, input, fs, buf
+    }
+
+// -----------------------------------------------------------------------------
+// COma1DcfCreator::EncryptContentToFile
+// Encrypt plain content to a DCF and stores it in a file.
+// -----------------------------------------------------------------------------
+EXPORT_C void COma1DcfCreator::EncryptContentToFileL(
+    const TDesC8& aContent, 
+    const TDesC& aFileName, 
+    const TDesC8& aMIMEType, 
+    CDRMRights* aRightsObject)
+    {
+    RFs fs;
+    RFileWriteStream output;
+
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    fs.Delete(aFileName);
+    User::LeaveIfError(output.Create(fs, aFileName, EFileWrite));
+    CleanupClosePushL(output);
+    EncryptInitializeL(output, aMIMEType, aRightsObject);
+    EncryptUpdateL(aContent);
+    EncryptFinalizeL();
+    CleanupStack::PopAndDestroy(2); // output, fs
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/dm/src/b64.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,307 @@
+/*
+* 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:  This class implements the base64 en/decoding.
+*
+*/
+
+
+#include <e32base.h>
+#include "base64.h"
+
+/*  6    LOCAL DEFINITIONS */
+
+/*  6.1    Local include files */
+
+/*  6.2    Local constants */
+
+LOCAL_C const TUint8 pBase64[] = 
+	{                   
+	0x3e, 0x7f, 0x7f, 0x7f, 0x3f, 0x34, 0x35, 0x36,
+	0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x7f,
+	0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x00, 0x01,
+	0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
+	0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11,
+	0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
+	0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f, 0x1a, 0x1b,
+	0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
+	0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
+	0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33
+	};
+
+/*  6.3    Local macros */
+#define b64blocks(l) (((l) + 2) / 3 * 4)
+/* #define b64octets(l)  ((l) / 4  * 3) */
+
+/*  6.4    Local data types */
+
+/*  6.5    Local data structures */
+
+/*  6.6    Local function prototypes */
+
+LOCAL_C TInt b64valid(TUint8 *);
+
+/*  7    MODULE CODE */
+
+/* ========================================================================= */
+
+/*  7.2 */
+
+/* Functional description
+ *
+ * This function does base64 decoding. As the outputted buffer is always 33% shorter than 
+ * the input buffer, the caller may want to reallocate the buffer after calling this function.
+ *
+ * Parameters
+ *
+ * Pointer to source containing data to decode
+ *
+ source
+ *
+ * Length of source buffer
+ *
+ length
+ *
+ * pointer to the destination buffer
+ * Note: the user must allocate memory for this buffer that its length at least can not be shorter than
+ *       the length of source. The user also can use same buffer for both source and destination.
+ *
+ destination
+ *
+ * length of the buffer allocated
+ *
+ destination_length
+ *
+ * Return values
+ *
+ *	byte 0 if OK else > 0
+ */
+
+/* ---------------------------------------------------------------------- */
+
+TInt b64decode(TUint8 *source, TUint32 length, TUint8 *destination, TUint32 *destination_length)
+	{
+	/* Data structures */
+
+	/*  Code  */
+    
+	TUint8   *buf/*, *pbuf*/;     /* Decoding buffer pointers. */
+	register TUint32 x = 0;          /* General purpose integers. */
+	TUint32 buf_index = 0;  /* current index in destination buffer */
+
+	
+	/* buffer to avoid allocating wholly new buffer for output */
+	TUint8 localBuffer[4] = {0,0,0,0}; 
+	TUint8* pLocalBufferOutPointer = 0;
+	
+	register TUint32 i = 0;
+	TUint32 num;
+
+    TUint8   c = 0;          /* Character to decode. */
+    TUint8 localBufferIndex = 0;
+
+    /*	int32 buf_length = 0; */ /* new length of destination buf */
+	const TUint8 pad = 0x3d; /* '=' */
+
+	if(!source || length == 0 || !destination || !destination_length)
+		{
+		return KErrArgument;
+		}
+
+	/* Collating sequence independant "===". */
+
+	/* Calculate the amount of '=' in the end of the source */
+	for(x=0, buf=source + (length-1); *buf == pad; buf --)
+		{
+		x++;
+		}
+
+	/* max allow 3 "===" in the end of content */
+	if (x > 3)
+		{                                       
+		return KErrArgument;
+		}
+
+	/* Save the encoded string pointer. */
+	// pbuf = destination; 
+
+	/* save address for first output block */
+	pLocalBufferOutPointer = destination;
+	x = 0; /* Initialize index. */
+
+	localBufferIndex = 0;
+
+
+	Mem::Copy(localBuffer, source, 4);
+
+	for (i = length; i != 0; i-- ) /* Decode every byte of the base 64 string */
+		{
+		/* c = *pbuf++; */
+		c = localBuffer[localBufferIndex++];
+
+		if(localBufferIndex == 4)
+			{
+			localBufferIndex = 0;
+			
+			source = source + 4;
+
+			/* INPUT: copy next input block to local buffer */
+			num = i > 4 ? 4 : i - 1;
+			if(num > 0)
+				{
+				Mem::Copy(localBuffer, source, num);
+				}
+			}
+
+		/* Ignore "=". */
+		if  (c == pad)
+			{
+			break; /* this must be the end of the buffer, or else ve have a invalid character */
+			}
+		
+		if  (c == '\n' || c == '\r' || c == '\t') /* ignore linefeed tab and cr */
+			{
+			continue;
+			}
+		
+		/* Valid Base64 Index? */
+		if (!b64valid(&c))
+			{
+			/* b64free(buf); */
+			return KErrArgument;
+			}
+        
+		/* Decode 4 byte words into 3 byte octets.*/
+		switch(x % 4)
+			{
+			case 0: /* Byte 0 of word.*/
+				pLocalBufferOutPointer[buf_index] = (TInt8)(c << 2);
+				break;                          
+			case 1: /* Byte 1 of word. */
+				pLocalBufferOutPointer[buf_index] |= c >> 4;
+				buf_index ++;
+				pLocalBufferOutPointer[buf_index] = (TInt8)( (c & 0x0f) << 4 );
+				break;
+			case 2: /* Byte 2 of word. */
+				pLocalBufferOutPointer[buf_index] |= c >> 2;
+				buf_index ++;
+				pLocalBufferOutPointer[buf_index] = (TInt8)( (c & 0x03) << 6 );
+				break;
+			case 3: /* Byte 3 of word. */
+				pLocalBufferOutPointer[buf_index] |= c;
+				buf_index ++;
+				break;
+			default: /* useless, just to depress warnings */
+				break;
+			}
+		
+		x++; /* Increment word byte. */
+		
+
+		} /* while */
+
+
+	/* make sure that there is zero at the end of the buffer
+	   though buf[buf_index] shoule be zero after decoding
+	*/
+
+	
+	/* pbuf[buf_index+1] = 0; */
+
+	/*buf[buf_index+1]=0*/
+	/* don't return the size of the buffer (buf_length), but the data size we put in (buf_index)*/
+	*destination_length = buf_index; 
+	return KErrNone;
+	}
+
+/*  7.3 */
+
+/* Functional description
+ *
+ * This function validates the character according to the base64 rules,
+ * and changes it to the corresponding value in the table.
+ *
+ * Parameters
+ *
+ * Pointer to character to validate
+ *
+ c
+ *
+ * Return values
+ *
+ *	TRUE if character is valid else FALSE.
+ */
+
+/* ---------------------------------------------------------------------- */
+
+LOCAL_C TInt b64valid(TUint8 *c)
+	{
+	/* Data structures */
+
+	/*  Code  */
+
+	/* If not within the range of the table, return false. */
+	if ((*c < 0x2b) || (*c > 0x7a))
+		{
+		return 0;
+		}
+	/* If it falls within one of the gaps, return false. */
+	if ((*c = pBase64[*c - 0x2b]) == 0x7f)
+		{
+		return 0;
+		}
+	
+	return 1; /* Otherwise, return true. */
+	}
+
+/*  7.4 */
+
+/* Functional description
+ *
+ * This function allocates a buffer in the size of the parameter.
+ *
+ * Parameters
+ *
+ * Size of buffer to allocate
+ *
+ length
+ *
+ * Return values
+ *
+ *	pointer to buffer
+ */
+
+/* ---------------------------------------------------------------------- */
+#ifdef BUILD_BASE64_ENCODE
+
+LOCAL TUint8 *b64buffer(TUint32 length)
+	{
+	/* Data structures */
+
+	/*  Code  */
+
+	TUint8 *buf; /* buffer pointers. */
+	
+	if  (!length) /* dont allow buf size  0 */
+		{
+		return  NULL;
+		}
+	
+	buf = (TUint8 *) DRM_BLOCK_ALLOC(length); 
+	
+	return buf; /* Return the pointer or null. */
+	}
+#endif /* #ifdef BUILD_BASE64_ENCODE */
+
+/* End of File */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmbackup/inc/DRMBackup.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,341 @@
+/*
+* 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:  Interface for the DRMBackup service
+*
+*/
+
+
+#ifndef DRMBACKUP_H
+#define DRMBACKUP_H
+
+// INCLUDES
+
+#include <e32base.h>	// CBase
+#include <abclient.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+class CDRMContextDB;
+class CDRMRightsDB;
+
+// CLASS DECLARATION
+
+/**
+*   CDRMBackup implements the Active Backup required by
+*   - DRM Rights Database
+*   - ROAP  
+*
+*
+*
+*  @lib rightsserver.exe
+*  @since 3.0
+*/
+
+class CDRMBackup : public CBase, 
+                   public conn::MActiveBackupDataClient
+    {
+    public:
+
+        /**
+        * NewLC
+        *
+        * Creates an instance of the CDRMBackup class and returns a pointer to it
+        * The function leaves the object into the cleanup stack
+        *
+        * @since    3.0
+        * @param    aRightsDatabase : CDRMRightsDB object for backing it up
+        * @param    aContextDatabase : CDRMContextDB object for backing it up
+        * @param    aFileServer : file server instance
+        * @return   Functional CDRMClock object, Function leaves if an error occurs.
+        */
+        static CDRMBackup* NewLC( CDRMRightsDB* aRightsDatabase,
+                                  RFs& aFileServer );
+
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMBackup class and returns a pointer to it
+        *
+        * @since    3.0
+        * @param    aRightsDatabase : CDRMRightsDB object for backing it up
+        * @param    aContextDatabase : CDRMContextDB object for backing it up
+        * @param    aFileServer : file server instance        
+        * @return   Functional CDRMClock object, Function leaves if an error occurs.
+        */
+        static CDRMBackup* NewL( CDRMRightsDB* aDRMRightsDB,
+                                 RFs& aFileServer );
+  
+        /**
+        * Destructor
+        */
+        virtual ~CDRMBackup();
+
+
+
+    public: // Inherited from MActiveBackupDataClient
+    
+
+
+        /**
+        This method informs the active backup data client that all snapshots have
+        been supplied. If the client has not received a snapshot then it should
+        perform a base backup.
+        */
+        virtual void AllSnapshotsSuppliedL();
+        
+        /**
+        This method receives all or part of a snapshot of data to allow calculation of an
+        incremental backup.  The snapshot is one that was previously supplied by the data
+        owner.  The snapshot data should be read from the location supplied.
+        The snapshot data may be larger than the location supplied in which case the routine will
+        be called repeatedly until all data has been supplied.
+
+        Snapshot data will also be supplied as part of a restore operation.
+        
+        @param aDrive the drive being backed up
+        @param aBuffer a pointer to the base of the location from whence data can be copied.
+        @param aLastSection ETrue if this is the last section of snapshot data, else EFalse.
+        @leave KErrNotSupported if the data owner does not support incremental backups.
+        */
+        virtual void ReceiveSnapshotDataL(TDriveNumber aDrive, TDesC8& aBuffer, TBool aLastSection);
+
+        /**
+        This method returns the expected size of backup data that will be supplied.   If an
+        incremental backup is underway then this method will not be called until after
+        ReceiveSnapshotDataL().  The size data will be used for the purpose of tracking progess
+        during a backup.  If it is inaccurate then the user may see irregular progress but the
+        actual backup data will not be affected so it is acceptable to return an estimated
+        value.
+
+        @param aDrive the drive being backed up.
+        @return the size of the data that will be returned
+        */
+        virtual TUint GetExpectedDataSize(TDriveNumber aDrive);
+
+        /**
+        This method returns a snapshot of data to accompany a backup.  The snapshot is expected
+        to contain details on files / data being backed up.  The format of the snapshot is only
+        meaningful to the data owner.  The snapshot will be supplied if the data owner is asked
+        for an incremental backup and for a restore operation.  The snapshot data should be
+        copied to the location supplied.
+        The snapshot data may be larger than the location supplied in which case the routine will
+        be called repeatedly until all data has been retrieved.
+        
+        @param aDrive the drive being backed up
+        @param aBuffer a pointer to the base of the location where data can be copied.
+        @param aFinished on return ETrue if all data has been returned for this drive, else EFalse.
+        @leave KErrNotSupported if the data owner does not support  incremental backups.
+        */
+        virtual void GetSnapshotDataL(TDriveNumber aDrive, TPtr8& aBuffer, TBool& aFinished);
+
+        /**
+        This method prepares the implementor to return backup data.  It will be followed by a
+        sequence of calls to request the actual data.
+        
+        @param aDrive the drive being backed up.
+        */
+        virtual void InitialiseGetBackupDataL(TDriveNumber aDrive);
+
+        /**
+        This method requests a section of backup data.  InitialiseGetBackupDataL() will have been
+        called prevously to specify the drive concerned.  The data returned may be base or
+        incremental depending on the type of backup and the capability of the data owner.
+
+        @param aBuffer a pointer to the base of the location where data can be copied.
+        @param aFinished on return ETrue if all data has been returned for this drive, else EFalse.
+        */
+        virtual void GetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished);
+        
+        ///// Restore Methods /////
+        
+        /**
+        This method prepares the implementor to receive base restore data for a drive.
+        It will be followed by a sequence of calls to supply the actual data.
+        
+        @param aDrive the drive being restored.
+        */
+        virtual void InitialiseRestoreBaseDataL(TDriveNumber aDrive);
+
+        /**
+        This method receives a section of base restore data.
+        InitialiseRestoreBaseDataL() will have been called prevously to specify the drive concerned.
+        
+        @param aBuffer a pointer to the base of the location whence data can be read.
+        @param aFinished ETrue if all data has been returned for this drive, else EFalse.
+        */
+        virtual void RestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished);
+
+        /**
+        This method prepares the implementor to receive incremental restore data for a drive.
+        It will be followed by a sequence of calls to supply the actual data.  If multiple
+        increments are supplied then this methid will be called before each increment.
+        
+        @param aDrive the drive being restored.
+        */
+        virtual void InitialiseRestoreIncrementDataL(TDriveNumber aDrive);
+
+        /**
+        This method receives a section of increment restore data.
+        InitialiseRestoreIncrementDataL() will have been called prevously to specify the 
+        drive concerned.
+        
+        @param aBuffer a pointer to the base of the location whence data can be read.
+        @param aFinished ETrue if all data has been returned for this increment, else EFalse.
+        */
+        virtual void RestoreIncrementDataSectionL(TDesC8& aBuffer, TBool aFinished);
+
+        /**
+        This method is called when all data to be restored has been supplied.
+        
+        @param aDrive the drive being restored.
+        */
+        virtual void RestoreComplete(TDriveNumber aDrive);
+        
+        ///// General Methods /////
+        
+        /**
+        This method is called if copying of data is terminated prematurely to allow the 
+        implementor to tidy up.  The same method applies to all types of data and to backup
+        and restore
+        */
+        virtual void TerminateMultiStageOperation();
+        
+        ///// Test Methods /////
+        /**
+        Gets a 32-bit checksum for its private data.
+        This routine is for test purposes.  It must be implemented but an invariant checksum 
+        value can be provided.  Some tests may cause checksum values to be compared.
+        
+        @param aDrive the drive containing data being checksummed
+        @return the 32-bit checksum
+        */
+        virtual TUint GetDataChecksum(TDriveNumber aDrive);
+    
+        /**
+        * PerformCleanup
+        *
+        * Delete the backup files and free other relevant resources
+        *
+        * @since  3.0
+        * @return none
+        */	 
+        void PerformCleanup( TBool aUdt = EFalse );
+    
+    
+    private:
+        /**
+        * Default Constructor - First phase
+        */
+        CDRMBackup( CDRMRightsDB* aRightsDatabase,
+                    RFs& aFileServer );
+
+        /**
+        * ConstructL
+        *
+        * Second phase constructor
+        *
+        * @since  3.0
+        * @return Leaves if an error occurs
+        */	   
+        void ConstructL();
+
+        /**
+        * CreateRightsBackupFile
+        *
+        * Create the encrypted rights db backup file
+        *
+        * @since  3.0
+        * @return return a Symbian OS error code if an error occurs
+        */	 
+        void CreateRightsBackupFileL();
+        
+        /**
+        * CreateContextBackupFile
+        *
+        * Create the encrypted context db backup file
+        *
+        * @since  3.0
+        * @return returns a Symbian OS error code if an error occurs
+        */	 
+        void CreateContextBackupFileL();
+
+        /**
+        * PerformRightsMerge
+        *
+        * Merge in the encrypted rights db backup file
+        *
+        * @since  3.0
+        * @return return a Symbian OS error code if an error occurs
+        */	 
+        void PerformRightsMergeL();
+        
+        /**
+        * PerformContextMerge();
+        *
+        * Merge in the encrypted context db backup file
+        *
+        * @since  3.0
+        * @return returns a Symbian OS error code if an error occurs
+        */	 
+        void PerformContextMergeL();
+
+    private: // Variables
+        
+        // File server session
+        RFs& iFileServer;
+        
+        // Rights database instance
+        CDRMRightsDB* iDRMRightsDB;     
+        
+        // file handle of the file used for rights db backup
+        RFile iRightsBackupFile;
+        
+        // name of the file used for rights db backup
+        TFileName iRightsFileName;
+        
+        // size of the file
+        TInt iRightsFileSize;
+        
+        // file handle of the file used for context db backup
+        RFile iContextBackupFile;
+
+        // name of the file used for context db backup
+        TFileName iContextFileName;
+                
+        // size of the file
+        TInt iContextFileSize;
+        
+        // the position in the file
+        TInt iPosition;
+        
+        // buffer to read the size of data
+        TBuf8<4> iSizeBuffer;
+        
+        // how much data has been read to the iSizeBuffer
+        TInt8 iReadData;
+        
+        // internal status of the object
+        TInt iStatus;
+        
+    };
+#endif      // DRMBACKUP_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmbackup/inc/DRMBackupInterface.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,89 @@
+/*
+* 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:  Interface for the DRMBackup service
+*
+*/
+
+
+#ifndef DRMBACKUPINTERFACE_H
+#define DRMBACKUPINTERFACE_H
+
+// INCLUDES
+
+// CONSTANTS
+const TInt KDRMNormalBackup    = 0;
+const TInt KDRMUDTBackup       = 1;
+
+// Backup Directory
+_LIT(KBackupDirectory, "C:\\private\\101F51F2\\backup\\");
+
+// Filename of the rights database
+_LIT( KRightsDbBackupFile, "rightsdb.bak" );
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+class RFile;
+class TDesC8;
+// CLASS DECLARATION
+
+/**
+*  MDRMBackupInterface is the interface required to be
+*  implemented by components in DRM wanting to use
+*  active backup
+*
+*  @lib rightsserver.exe
+*  @since 3.0
+*/
+
+class MDRMBackupInterface
+    {
+    public:
+
+    /**
+    * BackupContentToFileL
+    *
+    * Backups content to file in encrypted format
+    *
+    * @since    3.0
+    * @param    aBackupFile : File handle to the backup file
+    * @param    aEncryptionKey : the key to use to encrypt the backup file
+    * @leave    Symbian OS error code if an error occurs 
+    */
+    virtual void BackupContentToFileL( RFile& aBackupFile,
+                                       const TDesC8& aEncryptionKey, 
+                                       const TInt aMode ) = 0;
+
+    /**
+    * RestoreContentFromFileL
+    *
+    * Restores the content file from encrypted format
+    *
+    * @since    3.0
+    * @param    aBackupFile : File handle to backup file
+    * @param    aEncryptionKey : the key to use to encrypt the backup file
+    * @leave    Symbian OS error code if an error occurs 
+    */                           
+    virtual void RestoreContentFromFileL( RFile& aBackupFile,
+                                          const TDesC8& aEncryptionKey,
+                                          const TInt aMode ) = 0;
+        
+    };
+#endif      // DRMBACKUPINTERFACE_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmbackup/inc/DRMBackupObserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,122 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  observe system idle event
+*
+*/
+
+
+
+#ifndef DRMBACKUPOBSERVER_H
+#define DRMBACKUPOBSERVER_H
+
+//  INCLUDES
+#include <e32property.h>
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CDRMRightsServer;
+
+
+// CLASS DECLARATION
+
+/**
+*  End time based rights storage class
+*  
+*  @lib rightsserver.exe
+*  @since Series60 2.6
+*/
+class CDRMBackupObserver : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDRMBackupObserver* NewL(CDRMRightsServer& aServer);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CDRMBackupObserver();
+
+
+    public: // New functions
+        /**
+        * StartL starts the system agent and listen to the event
+        * @since Series60 3.0
+        * @param
+        * @return 
+        */
+        void Start();
+    public: // Functions from base classes
+    protected:  // New functions
+        
+        /**
+        * From CActive
+        * @since Series60 3.0
+        */
+        void RunL();
+
+        /**
+        * From CActive
+        * @since Series60 3.0
+        */
+        void DoCancel();
+        
+        /**
+        * From CActive
+        */
+        TInt RunError(TInt aError);
+
+
+    protected:  // Functions from base classes
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDRMBackupObserver( CDRMRightsServer& aServer );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        CDRMBackupObserver( const CDRMBackupObserver& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CDRMBackupObserver& operator=( const CDRMBackupObserver& );
+        
+
+        
+
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+        // helper server reference
+        CDRMRightsServer& iServer;
+        // For getting notify on idle screen available event.
+        RProperty iProperty;
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+        
+
+    };
+
+#endif      // IDLEOBSERVER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmbackup/src/DRMBackup.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,779 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the Active Backup in DRM
+*
+*/
+
+
+// INCLUDE FILES
+#include <s32mem.h>
+
+#include <sysutil.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "DRMBackup.h"
+#include "DRMLog.h"
+#include "RoapStorageClient.h"
+#include "DRMRightsDB.h"
+#include "drmbackupinterface.h"
+/*
+#include "flogger.h"
+
+
+_LIT( KLogDir, "drm");
+_LIT( KLogName, "backup.log");
+*/
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+const TInt KDoBackup        =   0x00000001;
+const TInt KRightsFileOpen  =   0x00000002;
+const TInt KContextFileOpen =   0x00000004;
+const TInt KRightsSizeRead  =   0x00000008;
+const TInt KContextSizeRead =   0x00000010;
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+#ifdef RD_MULTIPLE_DRIVE
+// Backup Directory
+_LIT( KBackupDir, "%c:\\private\\101F51F2\\backup\\" );
+#endif
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C void CleanupData( TAny* aPtr );
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CleanupData
+// Used to catch errors and delete the file if it's needed
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void CleanupData( TAny* aPtr )
+    {
+    CDRMBackup* backup = reinterpret_cast<CDRMBackup*>( aPtr );
+    
+    backup->PerformCleanup();
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CDRMBackup::CDRMBackup
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMBackup::CDRMBackup( CDRMRightsDB* aRightsDatabase, 
+                        RFs& aFileServer ) :
+    iFileServer( aFileServer ),                        
+    iDRMRightsDB( aRightsDatabase ),
+    iRightsFileSize( 0 ),
+    iContextFileSize( 0 ),
+    iPosition( 0 ),
+    iReadData( 0 ),
+    iStatus( 0 )
+    {      
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMBackup::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMBackup::ConstructL()
+    {
+    TInt error = KErrNone;
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    // Create the backup directory if needed
+    error = iFileServer.MkDirAll( KBackupDirectory );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	iFileServer.DriveToChar( driveNumber, driveLetter );
+    
+	TFileName backupDir;
+	backupDir.Format( KBackupDir, (TUint)driveLetter );
+    
+    // Create the backup directory if needed
+    error = iFileServer.MkDirAll( backupDir );
+    
+#endif
+    
+    if( error != KErrAlreadyExists )
+        {
+        User::LeaveIfError( error );
+        }
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    iRightsFileName.Copy( KBackupDirectory );
+    
+#else //RD_MULTIPLE_DRIVE
+
+    iRightsFileName.Copy( backupDir );
+    
+#endif
+    
+    iRightsFileName.Append( KRightsDbBackupFile );
+    iSizeBuffer.SetLength( 4 );    
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMBackup::NewLC
+// Two-phased constructor
+// -----------------------------------------------------------------------------
+//
+CDRMBackup* CDRMBackup::NewLC( CDRMRightsDB* aRightsDatabase, 
+                               RFs& aFileServer )
+    {
+    CDRMBackup* self = new(ELeave) CDRMBackup( aRightsDatabase, 
+                                               aFileServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    return self;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMBackup::NewL
+// Two-phased constructor
+// -----------------------------------------------------------------------------
+//
+CDRMBackup* CDRMBackup::NewL( CDRMRightsDB* aRightsDatabase, 
+                              RFs& aFileServer )
+    {
+    CDRMBackup* self = NewLC( aRightsDatabase, 
+                              aFileServer );
+    CleanupStack::Pop();
+
+    return self;
+    };
+  
+// ---------------------------------------------------------
+// CDRMBackup::~CDRMBackup
+// Destructor
+// ---------------------------------------------------------
+//  
+CDRMBackup::~CDRMBackup()
+    {
+    };
+
+
+// ---------------------------------------------------------
+// CDRMBackup::AllSnapshotsSuppliedL
+// ---------------------------------------------------------
+// 
+void CDRMBackup::AllSnapshotsSuppliedL()
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("AllSnapshotsSuppliedL\n\r"));      
+    return;
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::ReceiveSnapshotDataL
+// ---------------------------------------------------------
+// 
+void CDRMBackup::ReceiveSnapshotDataL(TDriveNumber /* aDrive */, 
+                                      TDesC8& /* aBuffer */, 
+                                      TBool /* aLastSection */)
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RecieveSnapshotdataL\n\r"));   
+    User::Leave( KErrNotSupported );
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::GetExpectedDataSize
+// ---------------------------------------------------------
+// 
+TUint CDRMBackup::GetExpectedDataSize(TDriveNumber /* aDrive */)
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("GetExpectedDataSize\n\r"));       
+    return 0;
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::GetSnapshotDataL
+// ---------------------------------------------------------
+// 
+void CDRMBackup::GetSnapshotDataL(TDriveNumber /* aDrive */, 
+                                  TPtr8& /* aBuffer */, 
+                                  TBool& /* aFinished */)
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("GetSnapShopDataL\n\r"));       
+    User::Leave( KErrNotSupported );
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::InitialiseGetBackupDataL
+// ---------------------------------------------------------
+// 
+void CDRMBackup::InitialiseGetBackupDataL(TDriveNumber aDrive)
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Init backup data\n\r"));    
+    // Clean up existing data:
+    PerformCleanup();
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    // Only do a backup when backing up drive C
+    if( aDrive == EDriveC )
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	
+	// Only do a backup when backing up system drive
+    if( aDrive == driveNumber )
+    
+#endif
+        {
+        iStatus |= KDoBackup;
+        }
+    else
+        {
+        iStatus &= ~KDoBackup;
+        return;
+        }
+    
+    // Add the cleanup item to the cleanup stack    
+    TCleanupItem resetAndDestroy( CleanupData, reinterpret_cast<TAny*>(this) );
+    CleanupStack::PushL( resetAndDestroy );
+    
+    // This function needs to write the two files required to be backed up.
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Init: create rights file\n\r"));     
+    // create the rights database backup file
+    CreateRightsBackupFileL();
+    
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Init: create context file\n\r"));     
+    // create the context database backup file
+    CreateContextBackupFileL();
+    
+    // If everything went properly, pop
+    CleanupStack::Pop();
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::GetBackupDataSectionL
+// ---------------------------------------------------------
+// 
+void CDRMBackup::GetBackupDataSectionL(TPtr8& aBuffer, TBool& aFinished)
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("GetBackupDataSectionL\n\r"));       
+    TInt seekAmount = 0;
+    
+    // if we are not supposed to do anything, just return
+    if( !(iStatus & KDoBackup ) )
+        {
+        // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("GetBackupDataSectionL: no Do Backup\n\r"));          
+        aFinished = ETrue;
+        return;
+        }
+    
+    // Make sure that the buffer is empty and starts from the beginning
+    aBuffer.SetLength(0);
+        
+     // Add the cleanup item to the cleanup stack    
+    TCleanupItem resetAndDestroy( CleanupData, reinterpret_cast<TAny*>(this) );
+    CleanupStack::PushL( resetAndDestroy );
+       
+    if( iPosition < iRightsFileSize )
+        {        
+        // Find the right position    
+        iRightsBackupFile.Seek( ESeekStart,iPosition );
+
+        // Read data
+        User::LeaveIfError( iRightsBackupFile.Read( aBuffer ) );
+        
+        iPosition += aBuffer.Length();
+        
+        if( iPosition == iRightsFileSize )
+            {
+            aFinished = ETrue;
+            }
+        else
+            {                
+            aFinished = EFalse;         
+            }        
+            
+        }
+    else if( iPosition < iRightsFileSize + iContextFileSize )
+        {   
+        // Find the right position
+        seekAmount = iPosition-iRightsFileSize;  
+        iContextBackupFile.Seek( ESeekStart, seekAmount );
+        
+        // Read data
+        User::LeaveIfError( iContextBackupFile.Read( aBuffer ) );
+        
+        iPosition += aBuffer.Length();
+        
+        if( iPosition-iRightsFileSize == iContextFileSize )
+            {
+            aFinished = ETrue;
+            }
+        else
+            {                
+            aFinished = EFalse;         
+            }
+        }
+    else
+        {
+        // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("GetBackupDataSectionL - Error\n\r"));         
+        User::Leave( KErrGeneral );
+        }
+    
+    // if we are finished, we can clean up the stuff otherwise not     
+    if( aFinished )
+        {
+        // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("GetBackupDataSectionL - Finished\n\r"));        
+        CleanupStack::PopAndDestroy();           
+        }
+    else
+        {
+        // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("GetBackupDataSectionL - Continues\n\r"));        
+        CleanupStack::Pop();   
+        }              
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::InitialiseRestoreBaseDataL
+// ---------------------------------------------------------
+// 
+void CDRMBackup::InitialiseRestoreBaseDataL(TDriveNumber aDrive)
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("InitializeRestoreBaseDataL\n\r")); 
+        
+    // Clean up existing data:
+    PerformCleanup();
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    // Only do a restore when restoring drive C
+    if( aDrive == EDriveC )
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	
+    // Only do a restore when restoring drive C
+    if( aDrive == driveNumber )
+    
+#endif
+        {
+        iStatus |= KDoBackup;
+        }
+    else
+        {
+        iStatus &= ~KDoBackup;
+        }
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::RestoreBaseDataSectionL
+// Create the files where the restore is performed from
+// ---------------------------------------------------------
+// 
+void CDRMBackup::RestoreBaseDataSectionL(TDesC8& aBuffer, TBool aFinished)
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreBaseDataSectionL\n\r")); 
+        
+    TInt seekAmount = 0;
+    Roap::RRoapStorageClient client;
+    TFileName tempFileName;
+    TPtrC8 buffer( aBuffer );
+        
+    if( !(iStatus & KDoBackup ) )
+        {
+        return;
+        }
+        
+     // Add the cleanup item to the cleanup stack    
+    TCleanupItem resetAndDestroy( CleanupData, reinterpret_cast<TAny*>(this) );
+    CleanupStack::PushL( resetAndDestroy );        
+        
+    // Read the size of the first file, even if it comes in one byte chunks
+    if( iPosition == 0 && iReadData < 4 && !( iStatus & KRightsSizeRead ) )
+        {
+        if( iReadData + buffer.Length() >= 4 )
+            {
+            Mem::Copy( const_cast<TUint8*>( iSizeBuffer.Ptr() ) + iReadData,
+                       buffer.Ptr(), 4-iReadData );
+            RMemReadStream stream( iSizeBuffer.Ptr(), 4 );
+            CleanupClosePushL( stream );
+            iRightsFileSize = stream.ReadInt32L();
+            CleanupStack::PopAndDestroy();
+            
+            // Remove the 'used' data from the beginning of the data block
+            buffer.Set( buffer.Mid( 4-iReadData ) );
+            
+            iStatus |= KRightsSizeRead;
+             
+            iReadData = 0;
+            }
+        else
+            {
+            if( aFinished )
+                {
+                CleanupStack::PopAndDestroy();
+                return;
+                }               
+            // copy the data to the temp buffer
+            Mem::Copy( const_cast<TUint8*>( iSizeBuffer.Ptr() ) + iReadData,
+                       buffer.Ptr(), buffer.Length() );
+            iReadData += buffer.Length();
+            CleanupStack::Pop();          
+            return;           
+            }
+        }
+    
+    // Read the size of the 2nd file when it's needed:    
+    if( iPosition == iRightsFileSize && iReadData < 4 && !(iStatus & KContextSizeRead) )
+        {
+        if( iReadData + buffer.Length() >= 4 )
+            {
+            Mem::Copy( const_cast<TUint8*>( iSizeBuffer.Ptr() ) + iReadData,
+                       buffer.Ptr(), 4-iReadData );
+            RMemReadStream stream( iSizeBuffer.Ptr(), 4 );
+            CleanupClosePushL( stream );
+            iContextFileSize = stream.ReadInt32L();
+            CleanupStack::PopAndDestroy();
+            
+            // Remove the 'used' data from the beginning of the data block
+            buffer.Set( buffer.Mid( 4-iReadData ) );
+            
+            iStatus |= KContextSizeRead;
+            iReadData = 0;
+
+            }
+        else
+            {
+            if( aFinished )
+                {
+                // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreBaseDataSectionL : buggy file(1)\n\r"));                
+                CleanupStack::PopAndDestroy();
+                return;
+                }             
+            // copy the data to the temp buffer
+            Mem::Copy( const_cast<TUint8*>( iSizeBuffer.Ptr()) + iReadData,
+                       buffer.Ptr(), buffer.Length() );
+            iReadData += buffer.Length();
+            CleanupStack::Pop();           
+            return;           
+            }       
+        }
+        
+    // Restore the two files:
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreBaseDataSectionL : before restore\n\r"));
+        
+    if( iPosition < iRightsFileSize )
+        {
+        // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreBaseDataSectionL : restore starts\n\r"));
+        if( !( iStatus & KRightsFileOpen ) )
+            {
+            // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreBaseDataSectionL : replace the file\n\r"));            
+            User::LeaveIfError( iRightsBackupFile.Replace( iFileServer,
+                                                           iRightsFileName,
+                                                           EFileRead|EFileWrite ) );
+            iStatus |= KRightsFileOpen;
+            // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreBaseDataSectionL : write startn\r"));                                            
+            iRightsBackupFile.Write( iSizeBuffer, 4 );
+            // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreBaseDataSectionL : write end\n\r"));            
+            iPosition += 4;
+            }
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreBaseDataSectionL : before seek\n\r"));            
+        // Find the right position    
+        User::LeaveIfError( iRightsBackupFile.Seek( ESeekStart,iPosition ) );
+        
+        
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreBaseDataSectionL : after seek\n\r"));        
+        // Read data
+        User::LeaveIfError( iRightsBackupFile.Write( buffer ) );
+        
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreBaseDataSectionL : after write\n\r"));        
+        iPosition += buffer.Length();
+        }
+    else if( iPosition < iRightsFileSize + iContextFileSize )
+        {
+               
+        // Open the file if it's not open
+        if( !( iStatus & KContextFileOpen ) )
+            {
+            User::LeaveIfError( iContextBackupFile.Replace( iFileServer,
+                                                            iContextFileName, 
+                                                            EFileRead|EFileWrite ) );
+            iStatus |= KContextFileOpen;                                                             
+            iContextBackupFile.Write( iSizeBuffer, 4 );
+            iPosition += 4;
+            }
+            
+        // Find the right position
+        seekAmount = iPosition-iRightsFileSize;  
+        iContextBackupFile.Seek( ESeekStart, seekAmount );
+        
+        // Read data
+        User::LeaveIfError( iContextBackupFile.Write( buffer ) );
+        
+        iPosition += buffer.Length();
+        }
+    else
+        {
+        // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreBaseDataSectionL : error\n\r"));        
+        User::Leave( KErrGeneral );
+        }
+  
+    CleanupStack::Pop();         
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::InitialiseRestoreIncrementDataL
+// ---------------------------------------------------------
+// 
+void CDRMBackup::InitialiseRestoreIncrementDataL(TDriveNumber /* aDrive */)
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("init incremental restore\n\r"));        
+    User::Leave( KErrNotSupported );
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::RestoreIncrementDataSectionL
+// ---------------------------------------------------------
+//
+void CDRMBackup::RestoreIncrementDataSectionL(TDesC8& /* aBuffer */, TBool /* aFinished */)
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("restore incremenetal\n\r"));        
+    User::Leave( KErrNotSupported );
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::RestoreComplete
+// This function performs the actual restoring
+// ---------------------------------------------------------
+// 
+void CDRMBackup::RestoreComplete(TDriveNumber aDrive)
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreComplete\n\r"));     
+    TInt error = KErrNone;
+    TBool doUdt = EFalse;
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    // Only do a backup when backing up drive C
+    if( aDrive != EDriveC )
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	
+    // Only do a backup when backing up drive C
+    if( aDrive != driveNumber )
+    
+#endif
+        {
+        // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreComplete : not Drive C\n\r"));         
+        return;
+        }
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("PerformRightsMergeL\n\r")); 
+
+    
+
+    // Merge the rights    
+    TRAP( error, PerformRightsMergeL() );
+    if( error )
+        {
+        if( error == KErrPermissionDenied )
+            {
+            doUdt = ETrue;                 
+            }
+        // Log some error
+        error = KErrNone;
+        }
+    
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("PerformContextMergeL\n\r"));     
+
+    // Merge the Contexts
+    TRAP( error, PerformContextMergeL() );
+    if( error )
+        {
+        // Log some error
+        error = KErrNone;        
+        }
+        
+    PerformCleanup( doUdt );                
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::TerminateMultiStageOperation
+// ---------------------------------------------------------
+// 
+void CDRMBackup::TerminateMultiStageOperation()
+    {
+    PerformCleanup();
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::GetDataChecksum
+// ---------------------------------------------------------
+// 
+TUint CDRMBackup::GetDataChecksum(TDriveNumber /* aDrive */)
+    {
+    return 0;
+    };
+       
+// ---------------------------------------------------------
+// CDRMBackup::CreateRightsBackupFileL
+// ---------------------------------------------------------
+// 
+void CDRMBackup::CreateRightsBackupFileL()
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Create backup file\n\r"));    
+     
+    // Open the file and get the filename
+    User::LeaveIfError( iRightsBackupFile.Replace( iFileServer,
+                                                   iRightsFileName,
+                                                   EFileRead|EFileWrite ) );                                        
+    iStatus |= KRightsFileOpen; 
+                                                        
+    iDRMRightsDB->BackupContentToFileL( iRightsBackupFile, KNullDesC8 );
+    
+    User::LeaveIfError( iRightsBackupFile.Size( iRightsFileSize ) );
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::CreateContextBackupFileL
+// ---------------------------------------------------------
+// 
+void CDRMBackup::CreateContextBackupFileL()
+    {
+    //Roap::RRoapStorageClient client;
+
+    // Open the file and get the filename
+/*    User::LeaveIfError( iContextBackupFile.Replace( iFileServer,
+                                                    iContextFileName,
+                                                    EFileRead|EFileWrite ) );  
+
+    iStatus |= KContextFileOpen;
+*/        
+    // Connect to the roap storage server                               
+    //User::LeaveIfError( client.Connect() );
+    //CleanupClosePushL( client );
+    
+    //client.BackupContentToFileL( iContextBackupFile, KNullDesC8 );
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::PerformRightsMergeL
+// ---------------------------------------------------------
+// 
+void CDRMBackup::PerformRightsMergeL()
+    {
+    if( iStatus & KRightsFileOpen )
+        {
+        iDRMRightsDB->RestoreContentFromFileL( iRightsBackupFile, KNullDesC8, 
+                                               KDRMNormalBackup );
+        }
+    else 
+        {
+        User::Leave(KErrNotReady);    
+        }
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::PerformContextMergeL
+// ---------------------------------------------------------
+// 
+void CDRMBackup::PerformContextMergeL()
+    {
+    //Roap::RRoapStorageClient client;
+                                      
+    // Connect to the roap storage server 
+    //User::LeaveIfError( client.Connect() );
+    //CleanupClosePushL( client );
+
+    //client.RestoreContentFromFileL( iContextBackupFile, KNullDesC8 );
+    
+    //CleanupStack::PopAndDestroy();// client
+    };
+
+// ---------------------------------------------------------
+// CDRMBackup::PerformCleanup
+// ---------------------------------------------------------
+// 
+void CDRMBackup::PerformCleanup( TBool aUdt )
+    {
+    iRightsFileSize = 0;
+    iContextFileSize = 0;
+    
+    if( iStatus & KRightsFileOpen ) 
+        {
+        if( !aUdt ) 
+            {
+            iRightsBackupFile.SetSize(0);                
+            }
+
+        iRightsBackupFile.Close();
+        
+        if( !aUdt )
+            {
+            iFileServer.Delete( iRightsFileName );                 
+            }
+        }
+        
+    if( iStatus & KContextFileOpen ) 
+        {
+        if( !aUdt )
+            {
+            iContextBackupFile.SetSize(0);                
+            }
+
+        iContextBackupFile.Close();   
+             
+        if( !aUdt )
+            {
+            iFileServer.Delete( iContextFileName );                          
+            } 
+        }
+
+    iPosition = 0;
+    Mem::FillZ(const_cast<TUint8*>(iSizeBuffer.Ptr()), 4);
+    iReadData = 0;
+    iStatus = 0;
+    return;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmbackup/src/DRMBackupObserver.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,178 @@
+/*
+* 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:  observe the backup restore status event
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    <e32base.h>
+#include    <e32std.h>
+#include    <f32file.h>
+#include    <sbdefs.h> //for KUidBackupRestoreStatus
+#include    "DRMBackupObserver.h"
+#include    "DRMRightsServer.h"
+/*
+#include    <flogger.h>
+
+_LIT( KLogDir, "drm");
+_LIT( KLogName, "backup.log");
+*/
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMBackupObserver::CDRMBackupObserver
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMBackupObserver::CDRMBackupObserver( CDRMRightsServer& aServer ):
+                    CActive(CActive::EPriorityStandard),
+                        iServer( aServer )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMBackupObserver::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMBackupObserver::ConstructL()
+    {
+    User::LeaveIfError( iProperty.Attach( KUidSystemCategory, conn::KUidBackupRestoreKey ) );
+    }
+                    
+// -----------------------------------------------------------------------------
+// CDRMBackupObserver::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMBackupObserver* CDRMBackupObserver::NewL(CDRMRightsServer& aServer)
+    {
+    CDRMBackupObserver* self = new( ELeave ) CDRMBackupObserver(aServer);
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CDRMBackupObserver::~CDRMBackupObserver()
+    {
+    Cancel();
+    iProperty.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMBackupObserver::Start
+// Start the system agent to listen to the event
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDRMBackupObserver::Start()
+    {
+    Cancel();
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    }
+
+
+// -----------------------------------------------------------------------------                        
+// CDRMBackupObserver::RunError
+// -----------------------------------------------------------------------------
+//  
+TInt CDRMBackupObserver::RunError(TInt aError)
+    {
+    if( aError != KErrCancel )
+        {
+        Start();           
+        }
+    else 
+        {
+        Cancel();
+        iProperty.Close();    
+        }
+    return KErrNone;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMBackupObserver::RunL
+// from CActive
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+
+void CDRMBackupObserver::RunL()
+    {
+	//RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RunL Observer Called\n\r"));     
+    // Resubscribe before processing new value to prevent missing updates
+    TInt backupStatus = 0;
+    TInt err( iStatus.Int() );
+    if (err == KErrNone)
+        {
+	    //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RunL Observer Called: Ok\n\r"));    
+                    
+        
+        Start();
+        User::LeaveIfError( iProperty.Get( 
+                KUidSystemCategory, 
+                conn::KUidBackupRestoreKey, backupStatus ) );
+        // Do stuff according to the backup status
+        iServer.HandleBackupEventL( backupStatus );
+        }
+    else if ( err != KErrCancel ) // Ignore all errors except cancel
+        {
+	    //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RunL Observer Called: Error\n\r"));         
+        Start();
+        }
+    else // When cancel occurs, stop everything
+        {
+        User::Leave(KErrCancel);    
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMBackupObserver::DoCancel
+// From CActive
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDRMBackupObserver::DoCancel()
+    {
+    iProperty.Cancel();
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmclock/Inc/DRMClock.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,146 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface for the DRMClock
+*
+*/
+
+
+#ifndef DRMCLOCK_H
+#define DRMCLOCK_H
+
+// INCLUDES
+
+#include <e32base.h>	// CBase
+#include <e32std.h>
+#include <e32def.h>		// Type definitions
+#include <bacntf.h>
+#include <etelmm.h>
+#include <DrmTypes.h>
+#include <e32property.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+class CDRMNitzObserver;
+class CDRMNotifier;
+
+// CLASS DECLARATION
+
+/**
+*  CDRMClock implements the drm clock required by DRM Engine
+*
+*  @lib unipertar.exe
+*  @since 2.8
+*/
+NONSHARABLE_CLASS( CDRMClock )
+    {
+    public:
+
+        /**
+        * NewLC
+        *
+        * Creates an instance of the CDRMClock class and returns a pointer to it
+        * The function leaves the object into the cleanup stack
+        *
+        * @since  2.8
+        * @return Functional CDRMClock object, Function leaves if an error occurs.
+        */
+        static CDRMClock* NewLC();
+
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMClock class and returns a pointer to it
+        *
+        * @since  2.8
+        * @return Functional CDRMClock object, Function leaves if an error occurs.
+        */
+        static CDRMClock* NewL();
+  
+        /**
+        * Destructor
+        */
+        virtual ~CDRMClock();
+
+        /**
+        * GetSecureTime
+        * 
+        * Return the current time and the security of the current time
+        *
+        * @since 2.8
+        * @param aTime : return parameter for time in UTC
+        * @param aTimeZone : return parameter for the timezone in +/-15 minutes
+        * @param aSecurityLevel : return parameter for security level
+        * @return none
+        */
+        void GetSecureTime(TTime& aTime, TInt& aTimeZone, 
+                           DRMClock::ESecurityLevel& aSecurityLevel);
+
+        /**
+        * ResetSecureTimeL
+        *
+        * Resets the secure time source and recalculates the offsets
+        *
+        * @since 2.8 
+        * @param aSecureTime, the new secure time in UTC
+        * @param aTimeZone, the time zone of the new secure time in +/- 15 minutes 
+        * @return none, Function leaves with Symbian OS error code if an
+        *         error occurs
+        */
+        void ResetSecureTimeL( const TTime& aSecureTime, const TInt& aTimeZone );
+        
+    protected:    
+    private:
+        /**
+        * Default Constructor - First phase
+        */
+        CDRMClock();
+
+         /**
+        * ConstructL
+        *
+        * Second phase constructor
+        *
+        * @since  2.8
+        * @return Leaves if an error occurs
+        */	   
+        void ConstructL();
+ 
+        /**
+        * ConnectToPhoneL
+        *
+        * Connects to the phone services
+        *
+        * @since 2.8
+        * @return Leaves with symbian os error codes if an error occurs
+        */
+        void ConnectToPhoneL();
+        
+        // Variables
+        CDRMNotifier* iNotifier;   
+        
+        // Nitz information handles      
+        RTelServer iEtelServer;
+        RMobilePhone iPhone;
+        CDRMNitzObserver* iObserver;
+    };
+#endif      // DRMCLOCK_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmclock/Inc/DRMClockServer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,119 @@
+/*
+* 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:  DRMClockServer manages the DRMTime in the System
+*
+*/
+
+
+
+#ifndef CDRMCLOCKSERVER_H
+#define CDRMCLOCKSERVER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include "DRMClock.h"
+// #include "DRMClientServer.h"
+#include "DRMClockSession.h"
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+TInt StartupClock( TAny* ); 
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+/**
+*  This class implements the DRM Clock Server functionality.
+*
+*  @lib unipertar.exe
+*  @since S60Rel2.6
+*/
+NONSHARABLE_CLASS( CDRMClockServer ) : public CServer2
+    {
+    public:  // Constructors and destructor
+        
+        /**
+         * Two-phased constructor.
+         * @since S60Rel2.6
+         * @return Pointer to newly created server instance.
+         */
+        static CDRMClockServer* NewL();
+        
+        /**
+         * Destructor.
+         * @since S60Rel2.6
+         */
+        ~CDRMClockServer();
+        
+    public: // Functions from base classes
+
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+        //class CServer
+        /**
+         * RunError.
+         * @since S60Rel2.6
+         * @param aError Error code from RunL function.
+         * @return An error is returned if RunError() cannot process the
+         * error.
+         */
+        TInt RunError( TInt aError );
+        
+    private:
+        /**
+         * C++ default constructor.
+         * @since S60Rel2.6
+         */
+        CDRMClockServer();
+        
+        /**
+         * By default Symbian 2nd phase constructor is private.
+         * @since S60Rel2.6
+         */
+        void ConstructL();
+        
+    private: // Functions from base classes
+        // Class CServer
+        /** 
+         * NewSessionL
+         * @since S60Rel2.6
+         */
+
+        CSession2* NewSessionL( const TVersion& aVersion,
+                                const RMessage2& aMessage) const;
+
+    public:     // Data
+        
+    protected:  // Data
+        
+    private:    // Data
+        CDRMClock* iDRMClock;
+        
+    public:     // Friend classes
+        
+    protected:  // Friend classes
+        
+    private:    // Friend classes
+        
+};
+
+#endif      // CDRMCLOCKSERVER_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmclock/Inc/DRMClockSession.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,130 @@
+/*
+* 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:  This class declares the interface of class CDRMClockSession and
+*                passes the calls to the DRMClock
+*
+*/
+
+
+#ifndef CDRMCLOCKSESSION_H
+#define CDRMCLOCKSESSION_H
+
+//  INCLUDES
+#include <e32base.h>
+#include "DRMClock.h"
+
+// CONSTANTS
+// MACROS
+// FUNCTION PROTOTYPES
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+class RMessage2;
+
+/**
+*  Server side instance of DRM Clock session.
+*  This class is the server side instance of C/S communications of a certain
+*  session.
+*
+*  @lib DRMCommon.dll
+*  @since S60Rel2.6
+*/
+NONSHARABLE_CLASS( CDRMClockSession ) : public CSession2 
+{
+  public:  // Constructors and destructor
+  
+   /**
+    * Two-phased constructor.
+    *
+    * @since S60Rel2.6
+    * @param aClock  a pointer to an instance of CDRMClock
+    * @return New session instance.
+    */
+   static CDRMClockSession* NewL( CDRMClock* aClock );
+
+   /**
+    * Destructor.
+    * @since S60Rel2.6
+    */
+   virtual ~CDRMClockSession();
+   
+  public: // New functions
+   
+  
+  public: // Functions from base classes
+   
+   /**
+    * From CSession: Handles the service request event.
+    * @since S60Rel2.6
+    * @param aMessage The message related to the event.
+    * @exception Method leaves with appropriate exception value
+    *            if any errors occured.
+    */
+   void ServiceL( const RMessage2& aMessage );
+   
+  private:
+
+   /**
+    * C++ constructor.
+    * @since S60Rel2.6
+    * @param aClock  a pointer to an instance of CDRMClock
+    */
+   CDRMClockSession( CDRMClock* aClock);   
+
+   /**
+    * Second phase constructor.
+    * @since S60Rel2.6
+    */ 
+   void ConstructL();
+   
+   /** 
+    * ServiceL() runs DispatchL() under TRAP harness, so
+    * all errors can be catched properly. DispatchL() then calls
+    * appropriate private method depending on the request.
+    * @since S60Rel2.6
+    * @param aMessage The message associated to the event.
+    */
+   void DispatchL( const RMessage2& aMessage );
+   
+   /** 
+    * Helper function for DispatchL(). 
+    * @since S60Rel2.6
+    * @param aMessage The message associated to the event.
+    */
+   void GetDRMTimeL( const RMessage2& aMessage );
+   
+
+   /** 
+    * Helper function for DispatchL(). 
+    * @since S60Rel2.6
+    * @param aMessage The message associated to the event.
+    */
+   void UpdateDRMTimeL( const RMessage2& aMessage );
+   
+
+   // Prohibit copy constructor.
+   CDRMClockSession( const CDRMClockSession& );
+   // Prohibit assigment operator.
+   CDRMClockSession& operator=( const CDRMClockSession& );
+
+  private:    // Data
+      CDRMClock* iDRMClock;
+};
+
+
+#endif      // CDRMCLOCKSESSION_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmclock/Inc/DRMNitzObserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,133 @@
+/*
+* 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:  Nitz information observer used by DRMClock
+*
+*/
+
+
+#ifndef DRMNITZOBSERVER_H
+#define DRMNITZOBSERVER_H
+
+// INCLUDES
+
+#include <e32base.h>	// CBase
+#include <e32std.h>
+#include <e32def.h>		// Type definitions
+#include <bacntf.h>
+#include <etelmm.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+class CDRMClock;
+
+/**
+*  CDRMNitzObserver implements the NITZ observer
+*  required by DRM Clock
+*
+*  @lib unipertar.exe
+*  @since 2.8
+*/
+NONSHARABLE_CLASS( CDRMNitzObserver ) : public CActive
+    {
+    public:
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMNitzObserver class and returns a pointer to it
+        *
+        * @since  2.8
+        * @param aMobilePhone : connected handle to RMobilePhone
+        * @param aDRMClock : pointer to an instance of CDRMClock
+        * @return Functional CDRMNitzObserver object, Function leaves if an error occurs.
+        */    
+        static CDRMNitzObserver* NewL( RMobilePhone& aMobilePhone, 
+                                       CDRMClock* aDRMClock);
+        
+        /**
+        * Start
+        *
+        * Adds the instance to the active scheduler unless it's already there and
+        * completes a request so RunL() gets called.
+        *
+        * @since  2.8
+        * @return none
+        */  
+        void Start();  
+         
+        /**
+        * From CActive: RunL catches events from The phone server
+        */
+        void RunL();
+                  
+        void DoCancel();
+        
+        // Destructor
+        virtual ~CDRMNitzObserver();
+
+    protected:
+          
+        /**
+        * From CActive: RunError checks the errors from RunL.
+        */
+        TInt RunError( TInt aError );   
+    
+    private:
+        /* constructor */
+        CDRMNitzObserver( RMobilePhone& aMobilePhone, CDRMClock* aDRMClock);
+        
+        /* secondary constructor */
+        void ConstructL();
+            
+        /**
+        * CheckDateTimeVal
+        *
+        * Validates the given datetime
+        *
+        * @since 2.8
+        * @param aDateTime : the time to be validated
+        * @return System wide error code
+        */
+        TInt CheckDateTimeVal(const TDateTime& aDateTime);
+
+        /**
+        * GetNitzTime
+        *
+        * Gets the NITZ time
+        *
+        * @since 2.8
+        * @param aNitzTime : the requested NITZ time in UTC 
+        * @param aTimeZone : the timezone in +/- 15 minutes 
+        * @return ETrue if NITZ is available a
+        *         EFalse if NITZ is not available
+        */
+        TBool GetNitzTime(TTime& aNitzTime, TInt& aTimeZone);
+               
+        CDRMClock* iDRMClock;
+        RMobilePhone* iMobilePhone;
+        RMobilePhone::TMobilePhoneNITZ iNitzInfo;
+        TInt iError;
+    };
+    
+#endif // DRMNITZOBSERVER_H
+
+// End of File
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmclock/Src/DRMClock.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,366 @@
+/*
+* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the DRM Clock
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <mmtsy_names.h>
+
+#include "DRMClock.h"
+#include "DRMLog.h"
+#include "DRMEventTimeChange.h"
+#include "wmdrmfileserverclient.h"
+
+#include <DRMNotifier.h>
+#include <s32strm.h>
+#include <s32file.h>
+#include <e32property.h>
+#include <e32keys.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "DRMNitzObserver.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+const TInt KMinuteInMicroseconds = 60000000;
+const TInt KTimeZoneIncrement = 15;
+ 
+// The time zones sanity check values, not sure if -13 hours exists
+// But atleast +13 does in: Nuku'Alofa
+const TInt KTimeZoneLow = -52; // -13 hours
+const TInt KTimeZoneHigh = 55; // +13 hours 45 minutes Some NZ owned island
+
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::CDRMRightsDB
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//    
+CDRMClock::CDRMClock()
+    {      
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMClock::ConstructL()
+    {
+    DRMLOG( _L( "DRM Clock Starting: " ) );
+
+    // Create a notifier instance
+    iNotifier = CDRMNotifier::NewL();
+        
+#ifndef __WINS__
+    ConnectToPhoneL();            
+            
+    iObserver = CDRMNitzObserver::NewL( iPhone, const_cast<CDRMClock*>(this));
+
+    iObserver->Start();
+#endif
+
+
+    DRMLOG( _L( "DRM Clock started" ) );		    
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMClock::NewLC
+// Two-phased constructor
+// -----------------------------------------------------------------------------
+//
+CDRMClock* CDRMClock::NewLC()
+    {
+    DRMLOG( _L( "CDRMClock::NewLC" ) );
+    
+    CDRMClock* self = new(ELeave) CDRMClock;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    DRMLOG( _L( "CDRMClock::NewLC ok" ) );
+    
+    return self;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMClock::NewL
+// Two-phased constructor
+// -----------------------------------------------------------------------------
+//
+CDRMClock* CDRMClock::NewL()
+    {
+    DRMLOG( _L( "CDRMClock::NewL" ) );
+    
+    CDRMClock* self = NewLC();
+    CleanupStack::Pop();
+
+    DRMLOG( _L( "CDRMClock::NewL ok" ) );
+    
+    return self;
+    };
+  
+// ---------------------------------------------------------
+// CDRMClock::~CDRMClock
+// Destructor
+// ---------------------------------------------------------
+//
+CDRMClock::~CDRMClock()
+    { 
+    DRMLOG( _L( "CDRMClock::~CDRMClock" ) );
+       
+    if( iNotifier )
+        {
+        delete iNotifier;
+        iNotifier = 0;
+        }
+        
+#ifndef __WINS__
+    if(iObserver)            
+        {
+        iObserver->Cancel();
+        delete iObserver;
+        iObserver = 0;
+        }  
+#endif // __WINS__        
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMClock::GetSecureTime
+// returns time and security level
+// -----------------------------------------------------------------------------
+//
+void CDRMClock::GetSecureTime(TTime& aTime, TInt& aTimeZone, 
+                              DRMClock::ESecurityLevel& aSecurityLevel)
+    {
+    DRMLOG( _L( "CDRMClock::GetSecureTime" ) );
+    
+    TTime currentUniversal;
+    TTime currentHome;
+    TInt error = KErrNone;
+    
+    // if there is an error it's not initialized
+    error = aTime.UniversalTimeSecure();
+    
+    if( error == KErrNoSecureTime )
+        {
+        currentHome.HomeTime();               
+        currentUniversal.UniversalTime();         
+        
+        aTimeZone = ( currentHome.Int64() - currentUniversal.Int64() ) / 
+                   ( KMinuteInMicroseconds* KTimeZoneIncrement );
+        
+        
+        aTime.UniversalTime();
+
+        aSecurityLevel = DRMClock::KInsecure;
+       
+        DRMLOG( _L( "CDRMClock::GetSecureTime: DRMClock is Insecure" ) );        
+        }
+    else 
+        {
+        currentHome.HomeTimeSecure();        
+        currentUniversal.UniversalTimeSecure();
+        
+        aTimeZone = ( currentHome.Int64() - currentUniversal.Int64() ) / 
+                   ( KMinuteInMicroseconds* KTimeZoneIncrement );
+        
+        aSecurityLevel = DRMClock::KSecure;     
+        DRMLOG( _L( "CDRMClock::GetSecureTime: DRMClock is Secure" ) );  
+        }    
+
+    DRMLOG( _L( "CDRMClock::GetSecureTime ok" ) );
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMClock::ResetSecureTimeL
+// resets the secure time and recalculates the offsets
+// should not reset to 0
+// -----------------------------------------------------------------------------
+//
+// Do not reset the timezone, use whatever has been set or retrieved from the UI time
+// However check that the timezone is a valid one just in case
+void CDRMClock::ResetSecureTimeL( const TTime& aTime, const TInt& aTimeZone )
+    {
+    DRMLOG( _L( "CDRMClock::ResetSecureTimeL" ) );
+   
+    TRequestStatus status;  
+    TInt error = KErrNone;  
+    CDRMEventTimeChange* change = CDRMEventTimeChange::NewLC();
+	TTime previousTime;
+	TTime previousTimeLocal;
+	TTime newTime;
+	TInt timezone = 0;
+	TDateTime temppi; // Only for logging
+
+    // check for param that the time is even reasonably valid:
+    if( aTime.Int64() == 0 )
+        {
+        DRMLOG( _L("Trying to reset to zero time") );             
+    	User::Leave( KErrArgument );
+        }
+    
+    // Sanity check: Time zone has to be +/- certail hours
+    // for this check -13h to +13.75h
+    if( aTimeZone < KTimeZoneLow || aTimeZone > KTimeZoneHigh )
+        {
+        DRMLOG2( _L("TimeZone invalid, time may be as well, aborting change: %d"), aTimeZone  );
+        User::Leave( KErrArgument );
+        }
+    
+    
+    // Get the current secure time with timezone
+    // Ask the hometime first so that rounding of any divider goes correctly
+    error = previousTimeLocal.HomeTimeSecure(); 
+    
+    // If there is an error, the secure hometime has not been set
+    // Which means that the UI clock has the valid data
+    if( error )
+        {
+        previousTimeLocal.HomeTime();
+        previousTime.UniversalTime();
+        timezone = ( previousTimeLocal.Int64() - previousTime.Int64() ) / 
+                   ( KMinuteInMicroseconds* KTimeZoneIncrement );
+		change->SetOldSecurityLevel( DRMClock::KInsecure );
+		}
+	else
+		{
+		previousTime.UniversalTimeSecure();		                   
+        
+        timezone = ( previousTimeLocal.Int64() - previousTime.Int64() ) / 
+                   ( KMinuteInMicroseconds* KTimeZoneIncrement );
+
+		change->SetOldSecurityLevel( DRMClock::KSecure );
+		change->SetNewSecurityLevel( DRMClock::KSecure );
+		}
+    
+    // Since it's not important to get the timezone we keep what is set or reset it:
+    previousTimeLocal = aTime.Int64() + ( timezone * ( KMinuteInMicroseconds* KTimeZoneIncrement ) );
+
+    // Do the actual updating:
+    // Update using the wmdrm fileserver since it has TCB capability
+    RWmDrmFileServerClient resetclient;
+    User::LeaveIfError( resetclient.Connect() );
+    CleanupClosePushL( resetclient );
+    
+    newTime = aTime;
+    User::LeaveIfError( resetclient.UpdateSecureTime( previousTimeLocal, newTime ) );
+       
+    CleanupStack::PopAndDestroy();
+
+
+    DRMLOG( _L( "CDRMClock::ResetSecureTimeL: AFTER RESET." ));	
+
+    // DRM Notifier data:
+    // send info about the change:
+
+    change->SetNewSecurityLevel( DRMClock::KSecure );
+    
+    change->SetOldTime( previousTime );
+    change->SetOldTimeZone( timezone );
+
+    change->SetNewTime( aTime );
+    change->SetNewTimeZone( timezone );
+    
+    // Notify clients
+
+    iNotifier->SendEventL(*change,status);
+    User::WaitForRequest(status);
+    CleanupStack::PopAndDestroy();    
+    
+    DRMLOG( _L( "CDRMClock::ResetSecureTimeL ok" ) );
+    };
+
+
+// ---------------------------------------------------------
+// CDRMClock::ConnectToPhoneL(const TDateTime& aDateTime)
+// Gets the nitz time from iNitzInfo
+// ---------------------------------------------------------
+//
+void CDRMClock::ConnectToPhoneL()
+    {
+    DRMLOG( _L( "CDRMClock::ConnectToPhoneL" ) );
+    
+    const TInt KTriesToConnectServer(10);
+    const TInt KTimeBeforeRetryingServerConnection(100000);
+    TInt thisTry(0);
+    TInt err(KErrNone);
+    TInt numPhone;
+    TName tsyName;
+    RTelServer::TPhoneInfo phoneInfo;
+    RMobilePhone::TMobilePhoneSubscriberId imsi;
+    TRequestStatus status;
+    
+
+    while ((err = iEtelServer.Connect()) != KErrNone &&
+                            (thisTry++) <= KTriesToConnectServer)
+        {
+        User::After(KTimeBeforeRetryingServerConnection);
+        }
+    User::LeaveIfError(err);
+
+    User::LeaveIfError(iEtelServer.LoadPhoneModule(KMmTsyModuleName));
+    User::LeaveIfError(iEtelServer.EnumeratePhones(numPhone));
+
+    for (TInt i(0); i < numPhone; i++)
+        {
+        User::LeaveIfError(iEtelServer.GetPhoneInfo(i, phoneInfo));
+        User::LeaveIfError(iEtelServer.GetTsyName(i,tsyName));
+
+        if (tsyName.CompareF(KMmTsyModuleName) == 0)
+            {
+            break;
+            }
+        }
+
+    User::LeaveIfError(iPhone.Open(iEtelServer, phoneInfo.iName));   
+    
+    iPhone.GetSubscriberId( status, imsi );
+    User::WaitForRequest( status );
+    
+    DRMLOG( imsi );    
+    DRMLOG( _L( "CDRMClock::ConnectToPhoneL ok" ) );
+    };
+
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmclock/Src/DRMClockClient.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,174 @@
+/*
+* 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:  Client side class implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "DRMClockClient.h"
+#include "DRMClientServer.h"
+
+#include "DRMLog.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+// To initialize C/S parameters.
+#define PARAMS TAny* params[ KMaxMessageArguments ]; \
+for ( TUint8 i = 0; i < KMaxMessageArguments; ++i ) { params[ i ] = NULL; }
+#define CLEARPARAM Mem::FillZ( params, \
+KMaxMessageArguments * sizeof( TAny* ) );
+
+// Maximum number of message slots that we use
+const TInt KMaxMessageSlots = 3;
+
+
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDRMClockClient::RDRMClockClient
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RDRMClockClient::RDRMClockClient()
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMClockClient::~RDRMClockClient
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RDRMClockClient::~RDRMClockClient()
+    {
+    }    
+
+// -----------------------------------------------------------------------------
+// RDRMClockClient::Connect
+// Opens connection to the server.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMClockClient::Connect()
+    {
+    TInt ret = KErrNone;
+    
+    DRMLOG( _L( "RDRMClockClient::Connect" ) );
+
+    const TVersion requiredVersion( 
+        DRMClock::KServerMajorVersion,
+        DRMClock::KServerMinorVersion,
+        DRMClock::KServerBuildVersion );
+    
+    DRMLOG( _L("RDRMClockClient: Create a new session" ) );
+    ret = CreateSession( DRMClock::KDRMServerName,
+                         requiredVersion, 
+                         KMaxMessageSlots );
+
+    DRMLOG2( _L( "Result: %d") , ret );
+    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMClockClient::Close
+// Closes the connection to the server.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDRMClockClient::Close() 
+    {
+    DRMLOG( _L( "RDRMClockClient::Close" ) );
+
+    RHandleBase::Close();
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMClockClient::GetSecureTime
+// Gets the secure time from the DRMClockServer
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMClockClient::GetSecureTime( TTime& aTime, TInt& aTimeZone,
+                                     DRMClock::ESecurityLevel& aSecurityLevel )
+    {
+    TPckg<TTime> package(aTime);
+    TPckg<TInt> package2(aTimeZone);
+    TPckg<DRMClock::ESecurityLevel> package3(aSecurityLevel);
+                    
+    DRMLOG( _L( "RDRMClockClient::GetSecureTime" ) );
+    TInt error = KErrNone;
+    
+    // For C/S communications.
+    PARAMS;
+    
+    // Set the parameters.
+    params[ 0 ] = reinterpret_cast< TAny* >( &package );
+    params[ 1 ] = reinterpret_cast< TAny* >( &package2 );
+    params[ 2 ] = reinterpret_cast< TAny* >( &package3 );
+    
+    // Send the message.
+    error = SendReceive( DRMClock::EGetDRMTime, params );
+    
+    // Reset
+    CLEARPARAM;
+    
+    DRMLOG2( _L( "RDRMClockClient::GetSecureTime: %d" ), error );
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMClockClient::UpdateSecureTime
+// Updates the secure time on the DRMClockServer
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMClockClient::UpdateSecureTime( const TTime& aTime, const TInt& aTimeZone )
+    {
+    TInt error = KErrNone;
+    TPckg<TTime> package(aTime);
+    TPckg<TInt> package2(aTimeZone);
+    
+    DRMLOG( _L( "RDRMClockClient::UpdateSecureTime" ) );
+    
+    // For C/S communications.
+    PARAMS;
+    
+    params[ 0 ] = reinterpret_cast< TAny* >( &package );
+    params[ 1 ] = reinterpret_cast< TAny* >( &package2 );
+    
+    error = SendReceive( DRMClock::EUpdateDRMTime, params );
+    
+    CLEARPARAM;
+    
+    DRMLOG2( _L( "RDRMClockClient::UpdateSecureTime: " ), error );
+
+    // All done.
+    return error;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmclock/Src/DRMClockClient2.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,180 @@
+/*
+* 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:  Client side class implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "DRMClockClient.h"
+#include "DRMclockClientServer.h"
+#include "DRMTypes.h"
+
+#include "DRMLog.h"
+
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// Maximum number of message slots that we use
+LOCAL_C const TInt KMaxMessageSlots = 3;
+
+#ifndef __DRM_CLOCK
+LOCAL_C const TInt KMinuteInMicroseconds = 60000000;
+LOCAL_C const TInt KTimeZoneIncrement = 15;
+#endif
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDRMClockClient::RDRMClockClient
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RDRMClockClient::RDRMClockClient()
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMClockClient::~RDRMClockClient
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RDRMClockClient::~RDRMClockClient()
+    {
+    }    
+
+// -----------------------------------------------------------------------------
+// RDRMClockClient::Connect
+// Opens connection to the server.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMClockClient::Connect()
+    {
+    TInt ret = KErrNone;
+#ifdef __DRM_CLOCK    
+    DRMLOG( _L( "RDRMClockClient::Connect" ) );
+
+    const TVersion requiredVersion( 
+        DRMClock::KServerMajorVersion,
+        DRMClock::KServerMinorVersion,
+        DRMClock::KServerBuildVersion );
+    
+    DRMLOG( _L("RDRMClockClient: Create a new session" ) );
+    ret = CreateSession( DRMClock::KServerName,
+                         requiredVersion, 
+                         KMaxMessageSlots );
+    DRMLOG2( _L( "Result: %d") , ret );
+#else
+    DRMLOG( _L( "RDRMClockClient: No Session Created, DRMClock is off") );
+#endif // __DRM_CLOCK
+    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMClockClient::Close
+// Closes the connection to the server.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDRMClockClient::Close() 
+    {
+    DRMLOG( _L( "RDRMClockClient::Close" ) );
+
+    RHandleBase::Close();
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMClockClient::GetSecureTime
+// Gets the secure time from the DRMClockServer
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMClockClient::GetSecureTime( TTime& aTime, TInt& aTimeZone,
+                                     DRMClock::ESecurityLevel& aSecurityLevel ) const
+    {
+#ifdef __DRM_CLOCK    	
+    TPckg<TTime> package(aTime);
+    TPckg<TInt> package2(aTimeZone);
+    TPckg<DRMClock::ESecurityLevel> package3(aSecurityLevel);
+                
+    DRMLOG( _L( "RDRMClockClient::GetSecureTime" ) );
+    TInt error = KErrNone;
+    
+    // Send the message.
+    error = SendReceive( DRMClock::EGetDRMTime, TIpcArgs( &package, &package2, &package3 ) );
+    
+    DRMLOG2( _L( "RDRMClockClient::GetSecureTime: %d" ), error );
+    return error;
+#else
+    DRMLOG( _L( "RDRMClockClient::GetSecureTime, UI Time is returned, DRMClock is off" ) );
+	  TTime currentLocal;
+    TInt64 result = 0;
+    	  
+	  // aTime:
+	  aTime.UniversalTime();
+	  currentLocal.HomeTime();
+    
+    result = currentLocal.Int64() - aTime.Int64();
+    result /= KMinuteInMicroseconds;
+    result /= KTimeZoneIncrement;
+    
+    // aTimeZone:
+    aTimeZone = I64INT(result);
+
+	  // aSecurityLevel:
+	  aSecurityLevel = DRMClock::KSecure;
+	  return KErrNone;
+#endif // __DRM_CLOCK
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMClockClient::UpdateSecureTime
+// Updates the secure time on the DRMClockServer
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMClockClient::UpdateSecureTime( const TTime& aTime, const TInt& aTimeZone )
+    {
+    TInt error = KErrNone;
+#ifdef __DRM_CLOCK
+    TPckg<TTime> package(aTime);
+    TPckg<TInt> package2(aTimeZone);
+    
+    DRMLOG( _L( "RDRMClockClient::UpdateSecureTime" ) );
+        
+    error = SendReceive( DRMClock::EUpdateDRMTime, TIpcArgs( &package, &package2 ) );
+    
+    DRMLOG2( _L( "RDRMClockClient::UpdateSecureTime: " ), error );
+#else
+    DRMLOG( _L("RDRMClockClient::UpdateSecureTime, Did nothing DRMClock is off") );
+#endif
+    // All done.
+    return error;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmclock/Src/DRMClockServer.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,272 @@
+/*
+* 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:  DRMClockServer manages the all operation to the DRMClock
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "DRMClockServer.h"
+#include "drmlog.h"
+#include "drmclockclientserver.h"
+#include "drmcommonclientserver.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+
+
+// LOCAL CONSTANTS AND MACROS
+const TUint8 KMaxStartTries = 3;
+const TInt KWaitingTime = 100000; // 1 secs
+_LIT( KClockThread, "DRMClockServer" );
+
+// MODULE DATA STRUCTURES
+using DRMClock::KServerMajorVersion;
+using DRMClock::KServerMinorVersion;
+using DRMClock::KServerBuildVersion;
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TInt StartClockServer( RSemaphore& aClientSem );
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// Function StartClockServer().
+// This function starts the actual server under TRAP harness and starts
+// waiting for connections. This function returns only if there has been
+// errors during server startup or the server is stopped for some reason.
+// 
+// Returns: TInt: Symbian OS error code.
+// -----------------------------------------------------------------------------
+LOCAL_C TInt StartClockServer( RSemaphore& aClientSem ) 
+
+    {
+    TInt error = KErrNone;
+    CDRMClockServer* server = NULL;
+
+    TUint8 count = 0;
+
+    do 
+    {
+       DRMLOG2( _L( "unipertar.exe: StartClockServer: %d" ), error );
+       
+       ++count;
+       
+       TRAP( error, ( server = CDRMClockServer::NewL() ) );
+       
+       if ( error ) 
+       {
+          User::After( TTimeIntervalMicroSeconds32(KWaitingTime) );
+       }
+       
+    } while( error && ( count <= KMaxStartTries ) );
+    
+    if( error ) 
+    {
+        // Failed
+        return error;
+        }
+       
+    // Release the semaphore...
+    aClientSem.Signal();
+    
+    // and close it. Otherwise there will be an unused handle to the semaphore
+    // until the phone is switched off.
+    aClientSem.Close();
+    
+    DRMLOG( _L( "unipertar.exe: StartClockServer: starting..." ) );
+
+    // Start waiting for connections
+    CActiveScheduler::Start();
+    
+    // Dying.
+    
+    DRMLOG( _L( "unipertar.exe: StartClockServer: dying" ) );
+
+    delete server;
+    
+    return KErrNone;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMClockServer::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMClockServer* CDRMClockServer::NewL()
+    {
+    CDRMClockServer* self = new( ELeave ) CDRMClockServer();
+    
+    CleanupStack::PushL( self );
+    
+    self->ConstructL();
+    
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CDRMClockServer::~CDRMClockServer() 
+    {
+    if( iDRMClock )
+        {
+        delete iDRMClock;
+        iDRMClock = 0;
+        }   
+    
+    DRMLOG( _L( "CDRMClockServer::~" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMClockServer::RunErrorL
+// From CActive. Complete the request and restart the scheduler.
+// -----------------------------------------------------------------------------
+//
+TInt CDRMClockServer::RunError( TInt aError ) 
+    {
+    DRMLOG2( _L( "CDRMClockServer::RunError: %d" ), aError );
+
+    // Inform the client.
+    Message().Complete( aError );
+    
+    // Restart the scheduler.
+    ReStart();
+    
+    // Error handled.
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMClockServer::NewSessionL
+// Called when a client requires a new instance.
+// -----------------------------------------------------------------------------
+CSession2* CDRMClockServer::NewSessionL( 
+    const TVersion& aVersion,
+    const RMessage2& /*aMessage*/ ) const 
+    {
+    DRMLOG( _L( "CDRMClockServer::NewSessionL" ) );
+    
+    // Check that the versions are compatible.
+    if ( ! User::QueryVersionSupported( TVersion( KServerMajorVersion,
+                                                  KServerMinorVersion,
+                                                  KServerBuildVersion ), 
+                                        aVersion ) ) 
+        {
+        // Sorry, no can do.
+        User::Leave( KErrNotSupported );
+        }
+    
+    DRMLOG( _L( "CDRMClockServer::NewSessionL: Creating a new session" ) );
+    
+    return CDRMClockSession::NewL( iDRMClock );    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMClockServer::CDRMClockServer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMClockServer::CDRMClockServer() : 
+    CServer2( EPriorityStandard )
+    {
+    // Nothing
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMClockServer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMClockServer::ConstructL() 
+    {
+    DRMLOG( _L( "CDRMClockServer::ConstructL" ) );
+
+    // Ignore errors
+    User::LeaveIfError( User::RenameThread( KClockThread ) );
+
+    iDRMClock = CDRMClock::NewL();
+    
+    DRMLOG( _L( "CDRMClockServer::clock Server started." ) );
+    
+    // Add the server to the scheduler.
+    StartL( DRMClock::KServerName );
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// -----------------------------------------------------------------------------
+// Function StartupClock().
+// This function starts the actual DRM Notifier
+// the cleanup stack and active scheduler.
+// Returns: TInt: Symbian OS error code.
+// -----------------------------------------------------------------------------
+//
+
+TInt StartupClock( TAny* ) 
+    {
+    DRMLOG( _L( "unipertar.exe: StartupClock" ) );
+    TInt error = KErrNone;
+    CTrapCleanup* trap = CTrapCleanup::New();
+    
+    // Check that memory allocation was successful.
+    __ASSERT_ALWAYS( trap, User::Invariant() );
+    
+    DRMLOG( _L( "unipertar.exe: StartupClock: active scheduler" ) );
+
+    CActiveScheduler* scheduler = new CActiveScheduler();
+    
+    __ASSERT_ALWAYS( scheduler, User::Invariant() );
+    
+    CActiveScheduler::Install( scheduler );
+    
+    // Reusing semaphore
+    RSemaphore clientSem;
+    __ASSERT_ALWAYS( !( clientSem.OpenGlobal( KDRMEngCommonSemaphore ) ), 
+        User::Invariant() );
+    
+    error = StartClockServer( clientSem );
+    
+    if ( error ) {
+        // Server creation failed. Release the semaphore.
+        // In case of successful startup, CDRMClockServer
+        // releases the semaphore.
+        clientSem.Signal();
+        clientSem.Close();
+        }
+    
+    delete scheduler; 
+    scheduler = NULL;
+    
+    delete trap;
+    trap = NULL;
+    
+    DRMLOG2( _L( "unipertar.exe: StartupClock exits with %d" ), error );
+    
+    return error;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmclock/Src/DRMClockSession.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,215 @@
+/*
+* 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:  This class handles all client requests.
+*
+*/
+
+
+// INCLUDE FILES
+#include <s32file.h>
+#include <f32file.h>
+#include "drmcommon.h"
+#include "DRMClockSession.h"
+#include "drmclockclientserver.h"
+#include "DRMClockServer.h"
+#include <DrmTypes.h>
+
+#include <e32test.h>
+
+#include "drmlog.h"
+
+// NAMESPACES
+using namespace DRMClock;
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+
+
+// MACROS
+
+#define IPCREAD0L( a ) aMessage.ReadL( 0, a )
+#define IPCREAD1L( a ) aMessage.ReadL( 1, a )
+#define IPCREAD2L( a ) aMessage.ReadL( 2, a )
+#define IPCWRITE0L( a ) aMessage.WriteL( 0, a )
+#define IPCWRITE1L( a ) aMessage.WriteL( 1, a )
+#define IPCWRITE2L( a ) aMessage.WriteL( 2, a )
+
+
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// DATA TYPES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+// ============================ MEMBER FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// CDRMClockSession::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMClockSession* CDRMClockSession::NewL( CDRMClock* aClock) 
+    {
+    CDRMClockSession* self = new( ELeave ) CDRMClockSession( aClock );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); // self
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMClockSession::~CDRMClockSession
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CDRMClockSession::~CDRMClockSession()
+    {
+    DRMLOG(  _L( "CDRMClockSession::Notifier session closed." ) );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMClockSession::ServiceL
+// This method runs DispatchL() under TRAP harness, since every error case
+// can be handled ==> no need to let this function leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMClockSession::ServiceL( const RMessage2& aMessage )
+    {
+    DRMLOG(  _L( "CDRMClockSession::ServiceL called" ) );
+    // Trap possible errors...
+    
+    TRAPD( error, DispatchL( aMessage ) );
+    
+    if ( error )
+        {
+        DRMLOG2(  _L( "CDRMClockSession::DispatcL threw an exception %d" ), error );
+        // ...and complete the request in case of an error.
+        aMessage.Complete( error );
+        return;
+        }
+
+    // The message has already completed successfully.
+    DRMLOG(  _L( "CDRMClockSession::DispatchL completed successfully" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMClockSession::CDRMClockSession
+// Default constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMClockSession::CDRMClockSession( CDRMClock* aClock ) : 
+    // Base class' constructor is called first.
+    iDRMClock( aClock )
+    {
+    // Nothing.
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMClockSession::ConstructL
+// Second phase constructor. Initializes the log tool in DRM internal testing.
+// -----------------------------------------------------------------------------
+//
+void CDRMClockSession::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMClockSession::DispatchL
+// Checks which command the user requested, and forwards the request to 
+// appropriate private method. This helps to keep the code more readable.
+// -----------------------------------------------------------------------------
+//
+void CDRMClockSession::DispatchL( const RMessage2& aMessage ) 
+    {
+    switch ( aMessage.Function() )
+        {
+        case EGetDRMTime:
+            GetDRMTimeL( aMessage );
+            break;
+        case EUpdateDRMTime:
+            UpdateDRMTimeL( aMessage );
+            break;
+        default:
+            DRMLOG(  _L( "CDRMClockSession::DispatchL: Invalid command" ) );
+            User::Leave( KErrNotSupported );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMClockSession::GetDRMTimeL
+// -----------------------------------------------------------------------------
+//
+void CDRMClockSession::GetDRMTimeL( const RMessage2& aMessage )
+    {
+    DRMLOG(  _L( "CDRMClockSession::GetDRMTimeL" ) );
+    TTime drmTime;
+    TInt timeZone;
+    DRMClock::ESecurityLevel level;
+    
+    iDRMClock->GetSecureTime( drmTime, timeZone, level );
+
+    TPckg<TTime> package(drmTime);
+    TPckg<TInt> package2(timeZone);    
+    TPckg<DRMClock::ESecurityLevel> package3(level);
+    
+    IPCWRITE0L( package );
+    IPCWRITE1L( package2 );
+    IPCWRITE2L( package3 );
+
+    aMessage.Complete( KErrNone );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMClockSession::UpdateDRMTimeL
+// -----------------------------------------------------------------------------
+//
+void CDRMClockSession::UpdateDRMTimeL( const RMessage2& aMessage )
+    {
+    DRMLOG(  _L( "CDRMClockSession::UpdateDRMTimeL" ) );
+    TInt error = KErrNone;
+    TTime drmTime;    
+    TInt timeZone;
+    TPckg<TTime> package( drmTime );
+    TPckg<TInt> package2( timeZone );
+    TInt r = KErrAccessDenied;
+    
+    // Add a check for the vendor id
+	_LIT_SECURITY_POLICY_V0(vidCheck, VID_DEFAULT); // Check Default VID    
+	_LIT_SECURITY_POLICY_C1(drmCheck, ECapabilityDRM);
+    RThread client;
+    
+    aMessage.ClientL( client );    
+    
+    if( vidCheck.CheckPolicy( client ) || drmCheck().CheckPolicy(client) )
+        {
+        r = KErrNone;
+        }
+
+    client.Close();
+    User::LeaveIfError( r );
+    
+    IPCREAD0L( package );
+    IPCREAD1L( package2 );
+
+    TRAP( error, iDRMClock->ResetSecureTimeL( drmTime, timeZone ) );
+
+    // All done.
+    aMessage.Complete( error );
+    }
+
+
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+//  End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmclock/Src/DRMNitzObserver.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,283 @@
+/*
+* 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:  Implementation of the DRM Nitz Observer
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "DRMNitzObserver.h"
+#include "DRMClock.h"
+#include "DRMLog.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+const TInt KTimeZoneValidBit(0x3F);     // Time zone difference
+const TInt KTimeZoneSignBit(0x80);      // Sign of time zone difference
+const TInt KNitzYearOffset(2000);       // Adjusting the year value received
+const TInt KMaximumTwoDigitValue(99);
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// ---------------------------------------------------------
+// CDRMNitzObserver::CDRMNitzObserver
+// Default Constructor
+// ---------------------------------------------------------
+//  
+CDRMNitzObserver::CDRMNitzObserver( RMobilePhone& aMobilePhone, CDRMClock* aDRMClock) :
+    CActive(EPriorityNormal) ,iDRMClock( aDRMClock ), iMobilePhone( &aMobilePhone ),
+    iError( KErrNone )
+    {    
+    }
+
+// ---------------------------------------------------------
+// CDRMNitzObserver::~CDRMNitzObserver
+// Destructor
+// ---------------------------------------------------------
+//        
+CDRMNitzObserver::~CDRMNitzObserver()
+    {
+    Cancel();	
+    };      
+      
+      
+// ---------------------------------------------------------
+// CDRMNitzObserver::ConstructL
+// Two-phase Constructor
+// ---------------------------------------------------------
+//   
+void CDRMNitzObserver::ConstructL()
+    {
+    DRMLOG( _L("ConstructL "));
+    
+    // Get the NITZ info on the creation, might not be available yet
+    iError = iMobilePhone->GetNITZInfo(iNitzInfo);
+    
+    
+    DRMLOG2( _L("ConstructL: Error = %d"), iError );
+    
+    }
+ 
+
+// ---------------------------------------------------------
+// CDRMNitzObserver::NewL
+// Two-phase constructor
+// ---------------------------------------------------------
+//  
+CDRMNitzObserver* CDRMNitzObserver::NewL( RMobilePhone& aMobilePhone,
+                                         CDRMClock* aDRMClock)
+    {
+    CDRMNitzObserver* self = new(ELeave) CDRMNitzObserver(aMobilePhone,aDRMClock);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+ 
+// ---------------------------------------------------------
+// CDRMNitzObserver::Start
+// Adds the active object into the ActiveScheduler
+// and sets the object active, makes sure RunL is called
+// atleast once
+// ---------------------------------------------------------
+//        
+void CDRMNitzObserver::Start() 
+    {
+    TRequestStatus* status = 0;
+    
+    DRMLOG2( _L("iError == %d "), iError );  
+ 
+    if( iError == KErrNotSupported ) 
+        {
+        // NITZ never supported, kill the observer
+        if( IsAdded() )
+            {
+            Deque();
+            return;
+            }
+        return;
+        }     
+    
+    if( !IsAdded() ) 
+        {
+        CActiveScheduler::Add(this);        
+        }
+    if ( !IsActive() ) 
+        {
+        SetActive();        
+        }
+    status = &iStatus;
+    User::RequestComplete(status,KErrNone);
+    }
+    
+    
+// Ignore the error:    
+TInt CDRMNitzObserver::RunError( TInt /*aError*/ )
+    {
+    SetActive();
+    return KErrNone;
+    }
+    
+    
+// ---------------------------------------------------------
+// CDRMNitzObserver::RunL
+// Active object RunL
+// ---------------------------------------------------------
+//  
+void CDRMNitzObserver::RunL()
+    {
+    TTime timeData;
+    TInt timeZone( 0 );
+    
+    // Check if the nitz has changed and is available, if so call update
+    // otherwise just wait
+    
+    DRMLOG( _L("ObserverRunL Called\n\r ") ); 
+
+    iStatus = KRequestPending;
+    
+    iMobilePhone->NotifyNITZInfoChange(iStatus, iNitzInfo);
+    
+    DRMLOG( _L("NotifyNITZInfoChange:"));             
+    if( GetNitzTime( timeData, timeZone ) )
+        {
+        DRMLOG( _L("Resetting secure time from NITZ observer:"));          
+        TRAPD(error, iDRMClock->ResetSecureTimeL( timeData, timeZone ) );
+        if( error )
+            {
+            DRMLOG( _L("Resetting secure time from NITZ observer returned an error."));   
+            }
+        DRMLOG( _L("Resetting secure time from NITZ observer successful."));     
+          
+        if( error != KErrArgument )
+            {
+            if( error )
+                {
+                DRMLOG( _L("ObserverRunL Called error \n\r ") );                
+                }
+            User::LeaveIfError( error );
+            }
+        }
+
+    SetActive();
+    };
+
+
+// ---------------------------------------------------------
+// CDRMNitzObserver::DoCancel
+// Cancels the active object
+// ---------------------------------------------------------
+//        
+void CDRMNitzObserver::DoCancel()
+    {
+    // cancel the notify change
+    iMobilePhone->CancelAsyncRequest(EMobilePhoneNotifyNITZInfoChange);
+    };
+
+
+// ---------------------------------------------------------
+// CDRMNitzObserver::CheckDateTimeVal(const TDateTime& aDateTime)
+// Check the date time value is valid.
+// ---------------------------------------------------------
+//
+TInt CDRMNitzObserver::CheckDateTimeVal(const TDateTime& aDateTime)
+    {
+    TDateTime tmp;
+    return tmp.Set(aDateTime.Year(),
+                   aDateTime.Month(),
+                   aDateTime.Day(),
+                   aDateTime.Hour(),
+                   aDateTime.Minute(),
+                   aDateTime.Second(),
+                   aDateTime.MicroSecond());
+    }
+
+// ---------------------------------------------------------
+// CDRMNitzObserver::GetNitzTime(const TDateTime& aDateTime)
+// Gets the nitz time from iNitzInfo
+// ---------------------------------------------------------
+//
+TBool CDRMNitzObserver::GetNitzTime(TTime& aNitzTime, TInt& aTimeZone)
+    {
+    TInt32 nitzCaps(iNitzInfo.iNitzFieldsUsed);
+    
+    if (nitzCaps & RMobilePhone::KCapsTimezoneAvailable)    
+        {
+        TInt timezone(iNitzInfo.iTimeZone & KTimeZoneValidBit);
+
+        if (iNitzInfo.iTimeZone & KTimeZoneSignBit)
+            {
+            // Changes sign
+            timezone = - timezone;
+            }
+        
+        // TimeZone info
+        aTimeZone = timezone;
+        }
+    
+    if (nitzCaps & RMobilePhone::KCapsTimeAvailable)  
+        {
+        TDateTime dateTime;
+        TInt fourDigitYear(iNitzInfo.Year());
+
+        //Check if our TSY returns 2 digits in stead of 4 digits for the year value
+        if (fourDigitYear <= KMaximumTwoDigitValue)        // The maximum year value in UI applications is 2060 
+		    {
+           //The year received from TSY is 2 digits we make it 4 digits
+            fourDigitYear = fourDigitYear + KNitzYearOffset;  // 2000   
+		    }
+
+        dateTime.Set(fourDigitYear,
+		            TMonth(iNitzInfo.Month()),
+					iNitzInfo.Day(),
+					iNitzInfo.Hour(),
+					iNitzInfo.Minute(),
+					iNitzInfo.Second(),
+					iNitzInfo.MicroSecond());
+
+        DRMLOG2( _L( "CDRMNitzObserver::GetNitzTime: DateTime: %d" ), fourDigitYear );
+        DRMLOG2( _L( ":%d" ), iNitzInfo.Month() );
+        DRMLOG2( _L( ":%d" ), iNitzInfo.Day() );
+        DRMLOG2( _L( ":%d" ), iNitzInfo.Hour() );
+        DRMLOG2( _L( ":%d" ), iNitzInfo.Minute() );
+        DRMLOG2( _L( ":%d" ), iNitzInfo.Second() );
+
+        if (KErrNone != CheckDateTimeVal(dateTime))
+            {
+            return EFalse;
+            }
+        // Transfer the time into a TTime object, UTC    
+        aNitzTime = dateTime;
+        return ETrue;
+        }
+    
+    return EFalse;
+           
+    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmcrypto/inc/CmlaCrypto.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef CMLACRYPTO_H
+#define CMLACRYPTO_H
+
+#include <bigint.h>
+#include "Oma2Agent.h"
+#include "OmaCrypto.h"
+
+// FORWARD DECLARATIONS
+class MDrmKeyStorage;
+class CRSAPublicKey;
+
+// CLASS DECLARATION
+
+/**
+*  CmlaCrypto: Contains crypto operations for CMLA
+*
+*  @lib    -
+*  @since  3.0
+*/
+class CmlaCrypto: public OmaCrypto
+    {
+public: // Constants
+
+    static const TInt KDdtPermLength = 8;
+    static const TInt KDdtExpLength = 3;
+
+public: // New functions
+
+    IMPORT_C static TInt SupportedAlgorithmsL(
+        RArray<TPtrC8>& aAlgorithmList);
+
+    IMPORT_C static HBufC8* DdtPermL(
+        const TDesC8& aInput);
+
+    IMPORT_C static HBufC8* DdtPermInvL(
+        const TDesC8& aInput);
+
+    IMPORT_C static HBufC8* DdtExpL(
+        const TDesC8& aInput);
+
+    IMPORT_C static HBufC8* DdtExpInvL(
+        const TDesC8& aInput);
+        
+    IMPORT_C static HBufC8* WrapL(
+        const TDesC8& aKek,
+        const TDesC8& aKey);
+
+    IMPORT_C static HBufC8* UnwrapL(
+        const TDesC8& aKek,
+        const TDesC8& aKey);
+
+    IMPORT_C static HBufC8* KdfL(
+        const TDesC8& aInput);
+        
+    IMPORT_C static HBufC8* RsaDecryptCmlaL(
+        MDrmKeyStorage* aKeyStorage,
+        const TDesC8& aInput);
+
+    IMPORT_C static HBufC8* RsaEncryptCmlaL(
+        CRSAPublicKey* aKey,
+        const TDesC8& aInput);
+        
+    IMPORT_C static void CmlaIpDecryptL(
+        TKeyTransportScheme aTransportScheme,
+        MDrmKeyStorage* aKey,
+        const TDesC8& aInput,
+        TDes8& aRek,
+        TDes8& aMac);
+        
+    IMPORT_C static HBufC8* CmlaIpEncryptL(
+        TKeyTransportScheme aTransportScheme,
+        CRSAPublicKey* aKey,
+        const TDesC8& aRek,
+        const TDesC8& aMac);
+        
+    IMPORT_C static TKeyTransportScheme AlgorithmIdToTransportScheme(
+        const TDesC8& aAlgorithmId);
+
+    
+protected: // New functions
+    };
+
+#endif      // CMLACRYPTO_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmcrypto/src/OmaCrypto.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,635 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OMA DRM 2.x Crypto Algorithms
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <asymmetric.h>
+#include <symmetric.h>
+#include <hash.h>
+#include "OmaCrypto.h"
+#include "DrmKeyStorage.h"
+
+#ifdef _DEBUG
+#define LOGGING
+#endif
+
+#ifdef LOGGING
+_LIT(KLogDir, "DRM");
+_LIT(KLogName, "Crypto.log");
+#include "flogger.h"
+#define LOG(string) \
+    RFileLogger::Write(KLogDir, KLogName, \
+        EFileLoggingModeAppend, string);
+#define LOGHEX(buffer) \
+    RFileLogger::HexDump(KLogDir, KLogName, \
+        EFileLoggingModeAppend, _S(""), _S(""), \
+        buffer.Ptr(), buffer.Length());
+#define LOGFMT(string, value) \
+    RFileLogger::WriteFormat(KLogDir, KLogName, \
+        EFileLoggingModeAppend, string, value);
+#else
+#define LOG
+#define LOGHEX
+#define LOGFMT
+#endif
+
+// LOCAL CONSTANTS AND MACROS
+
+_LIT8(KWrapIv, "\xA6\xA6\xA6\xA6\xA6\xA6\xA6\xA6");
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C void DeleteObject( TAny* aObject );
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ----------------------------------------------------------------------------
+// DeleteObject
+// Deletes the file by TFileName presented by aHandle
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void DeleteObject( TAny* aObject )
+    {
+    __ASSERT_DEBUG( aObject, User::Panic( _L( "DeleteObject" ), KErrArgument ) );
+    MDrmKeyStorage* object = reinterpret_cast< MDrmKeyStorage* >( aObject );
+    delete object;
+    object = NULL;
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void OmaCrypto::WriteUint32ToBlock(
+    TUint32 aInt,
+    TDes8& aBlock,
+    TInt aOffset)
+    {
+    aBlock[aOffset] =  (aInt & 0xff000000) >> 24;
+    aBlock[aOffset + 1] = (aInt & 0x00ff0000) >> 16;
+    aBlock[aOffset + 2] = (aInt & 0x0000ff00) >> 8;
+    aBlock[aOffset + 3] = (aInt & 0x000000ff);
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* OmaCrypto::RsaDecryptL(
+    MDrmKeyStorage* aKeyStorage,
+    const TDesC8& aInput)
+    {
+    return aKeyStorage->RsaDecryptL(aInput);
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* OmaCrypto::RsaEncryptL(
+    CRSAPublicKey* aKey,
+    const TDesC8& aInput)
+    {
+    RInteger result;
+    RInteger input;
+    HBufC8* output;
+
+    input = OS2IPL(aInput);
+    CleanupClosePushL(input);
+    result = TInteger::ModularExponentiateL(input, aKey->E(), aKey->N());
+    CleanupClosePushL(result);
+    output = I2OSPL(result);
+
+#ifdef LOGGING
+    HBufC8* buffer = NULL;
+    LOG(_L8("RsaEncryptL"));
+    LOG(_L8("Input"));
+    LOGHEX(aInput);
+    buffer = aKey->E().BufferLC();
+    LOG(_L8("E"));
+    LOGHEX((*buffer));
+    CleanupStack::PopAndDestroy(buffer);
+    buffer = aKey->N().BufferLC();
+    LOG(_L8("N"));
+    LOGHEX((*buffer));
+    CleanupStack::PopAndDestroy(buffer);
+    LOG(_L8("Result"));
+    LOGHEX((*output));
+#endif
+
+    CleanupStack::PopAndDestroy(2); // result, input
+    return output;
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* OmaCrypto::RsaVerifyL(
+    CRSAPublicKey* aKey,
+    const TDesC8& aInput)
+    {
+    RInteger result;
+    RInteger input;
+    HBufC8* output;
+
+    input = OS2IPL(aInput);
+    CleanupClosePushL(input);
+    result = TInteger::ModularExponentiateL(input, aKey->E(), aKey->N());
+    CleanupClosePushL(result);
+    output = I2OSPL(result);
+    CleanupStack::PopAndDestroy(2); // result, input
+    return output;
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* OmaCrypto::RsaKemKwsEncryptL(
+    CRSAPublicKey* aKey,
+    const TDesC8& aRek,
+    const TDesC8& aMac)
+    {
+    HBufC8* C1 = NULL;
+    HBufC8* C2 = NULL;
+    HBufC8* C;
+    TPtr8 c(0, 0);
+    TBuf8<128> Z;
+    TBuf8<KKeySize + KMacSize> keyAndMac;
+    HBufC8* kek = NULL;
+    const TUint8 KFirstBitMask( 0x7f );
+
+    Z.SetLength(128);
+    MDrmKeyStorage* storage = DrmKeyStorageNewL();
+    TCleanupItem storageCleanup( DeleteObject, storage );
+    CleanupStack::PushL(storageCleanup);
+    storage->RandomDataGetL(Z,Z.Size());
+    CleanupStack::PopAndDestroy( storage );
+
+    Z[0] &= KFirstBitMask;
+
+#ifdef LOGGING
+    LOG(_L("RsaKemKwsEncryptL"));
+    LOG(_L("random Z"));
+    LOGHEX(Z);
+#endif
+    C1 = RsaEncryptL(aKey, Z);
+    CleanupStack::PushL(C1);
+    kek = KdfL(Z, KNullDesC8, KKeySize);
+    CleanupStack::PushL(kek);
+    keyAndMac.Copy(aMac);
+    keyAndMac.Append(aRek);
+    C2 = AesWrapL(*kek, keyAndMac);
+    CleanupStack::PushL(C2);
+    C = HBufC8::NewL(C1->Length() + C2->Length());
+    c.Set(C->Des());
+    c.Copy(*C1);
+    c.Append(*C2);
+
+#ifdef LOGGING
+    LOG(_L("RsaKemKwsEncryptL"));
+    LOG(_L("Z"));
+    LOGHEX(Z);
+    LOG(_L("C1"));
+    LOGHEX((*C1));
+    LOG(_L("C2"));
+    LOGHEX((*C2));
+#endif
+
+    CleanupStack::PopAndDestroy(3); // C2, kek, C1
+    return C;
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void OmaCrypto::RsaKemKwsDecryptL(
+    MDrmKeyStorage* aKeyStorage,
+    const TDesC8& aInput,
+    TDes8& aRek,
+    TDes8& aMac)
+    {
+    HBufC8* C1 = NULL;
+    HBufC8* C2 = NULL;
+    HBufC8* Z = NULL;
+    HBufC8* keyAndMac = NULL;
+    HBufC8* kek = NULL;
+
+    C1 = aInput.Left(aInput.Length() - KWrappedKeySize).AllocL();
+    CleanupStack::PushL(C1);
+    C2 = aInput.Right(KWrappedKeySize).AllocL();
+    CleanupStack::PushL(C2);
+    Z = aKeyStorage->RsaDecryptL(*C1);
+    CleanupStack::PushL(Z);
+    kek = KdfL(*Z, KNullDesC8, KKeySize);
+    CleanupStack::PushL(kek);
+    keyAndMac = AesUnwrapL(*kek, *C2);
+    aMac.Copy(keyAndMac->Left(KKeySize));
+    aRek.Copy(keyAndMac->Right(KMacSize));
+
+#ifdef LOGGING
+    LOG(_L("RsaKemKwsDecryptL"));
+    LOG(_L("Z"));
+    LOGHEX((*Z));
+    LOG(_L("C1"));
+    LOGHEX((*C1));
+    LOG(_L("C2"));
+    LOGHEX((*C2));
+    LOG(_L("REK + MAC"));
+    LOGHEX((*keyAndMac));
+    LOG(_L("KEK"));
+    LOGHEX((*kek));
+#endif
+
+    delete keyAndMac;
+    CleanupStack::PopAndDestroy(4); // kek, Z, C2, C1
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* OmaCrypto::KdfL(
+    const TDesC8& aInput,
+    const TDesC8& aOtherData,
+    TInt aKLen)
+    {
+    TUint32 d;
+    CSHA1* h = NULL;
+    TBuf8<sizeof(d)> c;
+    HBufC8* t = NULL;
+    HBufC8* r = NULL;
+    TPtr8 T(0, 0);
+
+    h = CSHA1::NewL();
+    CleanupStack::PushL(h);
+    t = HBufC8::NewL(aKLen + SHA1_HASH);
+    CleanupStack::PushL(t);
+    T.Set(t->Des());
+    c.SetLength(sizeof(d));
+    d = 1;
+    do
+        {
+        WriteUint32ToBlock(d, c, 0);
+        h->Hash(aInput);
+        h->Hash(c);
+        if (aOtherData.Length() > 0)
+            {
+            h->Hash(aOtherData);
+            }
+        T.Append(h->Final());
+        d++;
+        }
+    while (d < SHA1_HASH / aKLen);
+    r = t->Left(aKLen).AllocL();
+    CleanupStack::PopAndDestroy(2); // Tbuf, h
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* OmaCrypto::I2OSPL(
+    RInteger& aInt)
+    {
+    HBufC8* r = aInt.BufferLC();
+    CleanupStack::Pop(r);
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RInteger OmaCrypto::OS2IPL(
+    const TDesC8& aOctetStream)
+    {
+    RInteger r;
+    TInt i;
+
+    r = RInteger::NewL(0);
+    for (i = 0; i < aOctetStream.Length(); i++)
+        {
+        r *= 256;
+        r += aOctetStream[i];
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* OmaCrypto::AesWrapL(
+    const TDesC8& aKey,
+    const TDesC8& aInput)
+    {
+    HBufC8* ret = NULL;
+    TBuf8<KWrapBlockSize> A;
+    TBuf8<2 * KWrapBlockSize> B;
+    TInt i;
+    TInt j;
+    TPtr8 R(0, 0);
+    TPtr8 Rn(0, 0);
+    TInt t;
+    TInt n;
+    CAESEncryptor* e;
+
+    e = CAESEncryptor::NewL(aKey);
+    User::LeaveIfNull(e);
+    CleanupStack::PushL(e);
+    n = aInput.Length() / KWrapBlockSize;
+    ret = HBufC8::NewMax((n + 1) * KWrapBlockSize);
+    User::LeaveIfNull(ret);
+    R.Set(ret->Des());
+    A.Copy(KWrapIv);
+    R.Copy(A);
+    R.Append(aInput);
+    for (j = 0; j <= 5; j++)
+        {
+        for (i = 1; i <= n; i++)
+            {
+            t = (n * j) + i;
+            Rn.Set(const_cast<TUint8*>(R.Ptr()) + KWrapBlockSize * i,
+                KWrapBlockSize, KWrapBlockSize);
+            B.Copy(A);
+            B.Append(Rn);
+            e->Transform(B);
+            A.Copy(B.Left(KWrapBlockSize));
+            A[KWrapBlockSize - 1] ^= t;
+            Rn.Copy(B.Right(KWrapBlockSize));
+            }
+        }
+    Rn.Set(const_cast<TUint8*>(R.Ptr()), KWrapBlockSize, KWrapBlockSize);
+    Rn.Copy(A);
+    CleanupStack::PopAndDestroy(); // e
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* OmaCrypto::AesUnwrapL(
+    const TDesC8& aKey,
+    const TDesC8& aInput)
+    {
+    HBufC8* ret = NULL;
+    TBuf8<KWrapBlockSize> A;
+    TBuf8<2 * KWrapBlockSize> B;
+    TInt i;
+    TInt j;
+    TPtr8 R(0, 0);
+    TPtr8 Rn(0, 0);
+    TInt t;
+    TInt n;
+    CAESDecryptor* d;
+
+    d = CAESDecryptor::NewL(aKey);
+    User::LeaveIfNull(d);
+    CleanupStack::PushL(d);
+    n = (aInput.Length() / KWrapBlockSize) - 1;
+    ret = HBufC8::NewMax((n + 1) * KWrapBlockSize);
+    User::LeaveIfNull(ret);
+    R.Set(ret->Des());
+    A.Copy(aInput.Left(KWrapBlockSize));
+    R.Copy(aInput);
+    for (j = 5; j >= 0; j--)
+        {
+        for (i = n; i >= 1; i--)
+            {
+            t = (n * j) + i;
+            Rn.Set(const_cast<TUint8*>(R.Ptr()) + KWrapBlockSize * i,
+                KWrapBlockSize, KWrapBlockSize);
+            A[KWrapBlockSize - 1] ^= t;
+            B.Copy(A);
+            B.Append(Rn);
+            d->Transform(B);
+            A.Copy(B.Left(KWrapBlockSize));
+            Rn.Copy(B.Right(KWrapBlockSize));
+            }
+        }
+    R.Delete(0, KWrapBlockSize);
+    CleanupStack::PopAndDestroy(); // e
+
+#ifdef LOGGING
+    LOG(_L("OmaCrypto::AesUnwrapL"));
+    LOG(_L("Key:"));
+    LOGHEX(aKey);
+    LOG(_L("Input:"));
+    LOGHEX(aInput);
+    LOG(_L("Ret:"));
+    LOGHEX((*ret));
+#endif
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* OmaCrypto::Mgf1L(
+    const TDesC8& aMfgSeed,
+    TInt aMaskLen)
+    {
+    TUint32 c;
+    CSHA1* h = NULL;
+    TBuf8<4> counter;
+    HBufC8* t = NULL;
+    TPtr8 T(0, 0);
+    TInt n;
+
+    n = aMaskLen / SHA1_HASH + (aMaskLen % SHA1_HASH ? 1 : 0);
+    h = CSHA1::NewL();
+    CleanupStack::PushL(h);
+    t = HBufC8::NewL(aMaskLen + 2 * SHA1_HASH + 1);
+    CleanupStack::PushL(t);
+    T.Set(t->Des());
+    counter.SetLength(4);
+    c = 0;
+    do
+        {
+        WriteUint32ToBlock(c, counter, 0);
+        h->Hash(aMfgSeed);
+        h->Hash(counter);
+        T.Append(h->Final());
+        c++;
+        }
+    while (c < n);
+    T.SetLength(aMaskLen);
+    CleanupStack::Pop(); // t
+    CleanupStack::PopAndDestroy(); // h
+    return t;
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::RsaPssSignHashL
+// Sign a hash (not a message!) using RSASSA-PSS.
+// NOTE: The implementation is only correct for a private key modulus divisible
+// by eight!
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* OmaCrypto::RsaPssSignHashL(
+    MDrmKeyStorage* aKeyStorage,
+    const TDesC8& aMHash)
+    {
+    CSHA1* hasher = NULL;
+    HBufC8* em = NULL;
+    HBufC8* S = NULL;
+    TPtr8 EM(0, 0);
+    TInt modBits;
+    TInt emLen;
+    TBuf8<KPssSaltLength> salt;
+    TBuf8<SHA1_HASH> H;
+    _LIT8(KMNullVector, "\0\0\0\0\0\0\0\0");
+    HBufC8* db = NULL;
+    TPtr8 DB(0, 0);
+    HBufC8* dbMask = NULL;
+    TInt i;
+
+    modBits = aKeyStorage->ModulusSize();
+
+    if( modBits < 0)
+        {
+        User::LeaveIfError( modBits );
+        }
+    emLen = modBits / 8;
+    hasher = CSHA1::NewL();
+    CleanupStack::PushL(hasher);
+
+    salt.SetLength(KPssSaltLength);
+
+    aKeyStorage->RandomDataGetL(salt,salt.Size());
+
+#ifdef LOGGING
+    LOG(_L("RsaKemKwsEncryptL"));
+    LOG(_L("salt"));
+    LOGHEX(salt);
+#endif
+
+    hasher->Hash(KMNullVector);
+    hasher->Hash(aMHash);
+    hasher->Hash(salt);
+    H.Copy(hasher->Final());
+
+    db = HBufC8::NewL(emLen - SHA1_HASH - 1);
+    CleanupStack::PushL(db);
+    DB.Set(db->Des());
+    DB.FillZ(emLen - KPssSaltLength - SHA1_HASH - 2);
+    DB.Append(0x01);
+    DB.Append(salt);
+
+    dbMask = Mgf1L(H, emLen - SHA1_HASH - 1);
+    CleanupStack::PushL(dbMask);
+
+    for (i = 0; i < emLen - SHA1_HASH - 1; i++)
+        {
+        DB[i] = DB[i] ^ (*dbMask)[i];
+        }
+
+    em = HBufC8::NewL(emLen);
+    CleanupStack::PushL(em);
+    EM.Set(em->Des());
+    EM.Copy(DB);
+    EM[0] &= 0x7f;
+    EM.Append(H);
+    EM.Append(0xbc);
+    S = aKeyStorage->RsaSignL(EM);
+
+    CleanupStack::PopAndDestroy(4); // em, dbMask, db, hasher
+    return S;
+    }
+
+// -----------------------------------------------------------------------------
+// OmaCrypto::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool OmaCrypto::RsaPssVerifyHashL(
+    CRSAPublicKey* aKey,
+    const TDesC8& aSignature,
+    const TDesC8& aMHash)
+    {
+    TBool r = EFalse;
+    CSHA1* hasher = NULL;
+    HBufC8* EM = NULL;
+    TInt emLen;
+    TBuf8<KPssSaltLength> salt;
+    TBuf8<SHA1_HASH> H;
+    _LIT8(KMNullVector, "\0\0\0\0\0\0\0\0");
+    HBufC8* db = NULL;
+    TPtr8 DB(0, 0);
+    HBufC8* dbMask = NULL;
+    TInt i;
+
+    EM = RsaVerifyL(aKey, aSignature);
+    CleanupStack::PushL(EM);
+    emLen = EM->Size();
+
+    hasher = CSHA1::NewL();
+    CleanupStack::PushL(hasher);
+
+    db = EM->Left(emLen - SHA1_HASH - 1).AllocL();
+    CleanupStack::PushL(db);
+    DB.Set(db->Des());
+    H.Copy(EM->Mid(emLen - SHA1_HASH - 1, SHA1_HASH));
+
+    dbMask = Mgf1L(H, emLen - SHA1_HASH - 1);
+    CleanupStack::PushL(dbMask);
+
+    for (i = 0; i < emLen - SHA1_HASH - 1; i++)
+        {
+        DB[i] = DB[i] ^ (*dbMask)[i];
+        }
+
+    salt.Copy(DB.Right(KPssSaltLength));
+
+    hasher->Hash(KMNullVector);
+    hasher->Hash(aMHash);
+    hasher->Hash(salt);
+    if (hasher->Final().Compare(H) == 0)
+        {
+        r = ETrue;
+        }
+
+    CleanupStack::PopAndDestroy(4); // dbMask, db, hasher, EM
+    return r;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmcrypto/stub/CmlaCryptoStub.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <asymmetric.h>
+#include <symmetric.h>
+#include <hash.h>
+#include "OmaCrypto.h"
+#include "CmlaCrypto.h"
+#include "BitStream.h"
+
+// LOCAL CONSTANTS AND MACROS
+
+_LIT8(KOma, "http://www.rsasecurity.com/rsalabs/pkcs/schemas/pkcs-1#rsaes-kem-kdf2-kw-aes128");
+_LIT8(KCmlaIp1, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-1");
+_LIT8(KCmlaIp2, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-2");
+_LIT8(KCmlaIp3, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-3");
+_LIT8(KCmlaIp4, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-4");
+_LIT8(KCmlaIp5, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-5");
+_LIT8(KCmlaIp6, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-6");
+_LIT8(KCmlaIp7, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-7");
+
+// ==================== LOCAL FUNCTIONS ====================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CmlaCrypto::
+// 
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+// CmlaCrypto::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CmlaCrypto::SupportedAlgorithmsL(
+    RArray<TPtrC8>& /*aAlgorithmList*/)
+    {
+    return KErrNotSupported;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::DdtPermL(
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::DdtPermInvL(
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::DdtExpL(
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::DdtExpInvL(
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::WrapL(
+    const TDesC8& /*aKek*/,
+    const TDesC8& /*aKey*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::UnwrapL(
+    const TDesC8& /*aKek*/,
+    const TDesC8& /*aWrap*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::KdfL(
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::RsaDecryptCmlaL(
+    MDrmKeyStorage* /*aKeyStorage*/,
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::RsaEncryptCmlaL(
+    CRSAPublicKey* /*aKey*/,
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C void CmlaCrypto::CmlaIpDecryptL(
+    TKeyTransportScheme /*aTransportScheme*/,
+    MDrmKeyStorage* /*aKeyStorage*/,
+    const TDesC8& /*aInput*/,
+    TDes8& /*aRek*/,
+    TDes8& /*aMac*/)
+    {
+    User::Leave(KErrNotSupported);
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::CmlaIpEncryptL(
+    TKeyTransportScheme /*aTransportScheme*/,
+    CRSAPublicKey* /*aKey*/,
+    const TDesC8& /*aRek*/,
+    const TDesC8& /*aMac*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C TKeyTransportScheme CmlaCrypto::AlgorithmIdToTransportScheme(
+    const TDesC8& aAlgorithmId)
+    {
+    if (aAlgorithmId.CompareF(KOma) == 0)
+        {
+        return EOma;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp1) == 0)
+        {
+        return ECmlaIp1;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp2) == 0)
+        {
+        return ECmlaIp2;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp3) == 0)
+        {
+        return ECmlaIp3;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp4) == 0)
+        {
+        return ECmlaIp4;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp5) == 0)
+        {
+        return ECmlaIp5;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp6) == 0)
+        {
+        return ECmlaIp6;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp7) == 0)
+        {
+        return ECmlaIp7;
+        }
+    return EOma;
+    }
+    
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/drmserviceapi/src/drmserviceapi.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,144 @@
+/*
+* 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:  Implementation class for DrmServiceAPI.dll
+*
+*/
+
+
+
+#include <drmserviceapi.h>
+
+#include "roapstorageclient.h"
+#include "drmclockclient.h"
+
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// two-phase costructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmServiceApi* DRM::CDrmServiceApi::NewL()
+    {
+    CDrmServiceApi* self = CDrmServiceApi::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// two-phase costructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C DRM::CDrmServiceApi* DRM::CDrmServiceApi::NewLC()
+    {
+    CDrmServiceApi* self = new( ELeave ) CDrmServiceApi;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+DRM::CDrmServiceApi::~CDrmServiceApi()
+    {
+    // Clock client
+    if( iClockClient )
+        {
+        iClockClient->Close();
+        delete iClockClient;
+        iClockClient = NULL;
+        }
+    
+    // Roap storage client
+    if( iRoapStorageClient )
+        {
+        iRoapStorageClient->Close();
+        delete iRoapStorageClient;
+        iRoapStorageClient = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CDrmServiceApi::GetSecureTime
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmServiceApi::GetSecureTime( 
+    TTime& aTime, 
+    TInt& aTimeZone,
+    DRMClock::ESecurityLevel& aSecurityLevel ) const
+    {
+    return iClockClient->GetSecureTime( aTime, aTimeZone, aSecurityLevel);    
+    };
+                        
+// ---------------------------------------------------------------------------
+// CDrmServiceApi::UpdateSecureTime
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt DRM::CDrmServiceApi::UpdateSecureTime( const TTime& aTime, const TInt& aTimeZone )
+    {
+    return iClockClient->UpdateSecureTime( aTime, aTimeZone );
+    };
+
+
+// ---------------------------------------------------------------------------
+// CDrmServiceApi::GetDevicePublicKeyDerL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmServiceApi::GetDevicePublicKeyDerL( HBufC8*& aPublicKey )
+    {
+    iRoapStorageClient->GetDevicePublicKeyDerL( aPublicKey );
+    };
+
+// ---------------------------------------------------------------------------
+// CDrmServiceApi::SignL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void DRM::CDrmServiceApi::SignL( const TDesC8& aHash, HBufC8*& aSignature )
+    {
+    iRoapStorageClient->SignL( aHash, aSignature );
+    };
+
+
+// ---------------------------------------------------------------------------
+// Constructor
+// ---------------------------------------------------------------------------
+//
+DRM::CDrmServiceApi::CDrmServiceApi()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// 2nd phase constructor
+// ---------------------------------------------------------------------------
+//
+void DRM::CDrmServiceApi::ConstructL()
+    {
+    // Create an instance of the clock client
+    iClockClient = new (ELeave) RDRMClockClient;
+    
+    // Connect to the server
+    User::LeaveIfError( iClockClient->Connect() );
+    
+    // Create and instance of the roap storage client
+    iRoapStorageClient = new (ELeave) Roap::RRoapStorageClient;
+
+    // Connect to the server
+    User::LeaveIfError( iRoapStorageClient->Connect() );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/eabi/DRMCommonU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,44 @@
+EXPORTS
+	_ZN9DRMCommon10ConstructLEv @ 1 NONAME
+	_ZN9DRMCommon10DisconnectEv @ 2 NONAME
+	_ZN9DRMCommon11GetFileInfoER5RFileRNS_18TContentProtectionERP6HBufC8S6_Rj @ 3 NONAME
+	_ZN9DRMCommon11GetFileInfoERK7TDesC16RNS_18TContentProtectionERP6HBufC8S7_Rj @ 4 NONAME
+	_ZN9DRMCommon12MapErrorCodeEi @ 5 NONAME
+	_ZN9DRMCommon13GetFileHeaderER5RFileRK6TDesC8RP6HBufC8 @ 6 NONAME
+	_ZN9DRMCommon13GetFileHeaderERK4TBufILi256EERK6TDesC8RP6HBufC8 @ 7 NONAME
+	_ZN9DRMCommon13ServerVersionEv @ 8 NONAME
+	_ZN9DRMCommon13SetFileHeaderER5RFileRK6TDesC8S4_ @ 9 NONAME
+	_ZN9DRMCommon13SetFileHeaderERK7TDesC16RK6TDesC8S5_ @ 10 NONAME
+	_ZN9DRMCommon14DataTypesCountERi @ 11 NONAME
+	_ZN9DRMCommon14GetContentInfoERK6TDesC8RNS_18TContentProtectionERP6HBufC8S7_Rj @ 12 NONAME
+	_ZN9DRMCommon15CheckFileRightsER5RFilem @ 13 NONAME
+	_ZN9DRMCommon15CheckFileRightsERK7TDesC16m @ 14 NONAME
+	_ZN9DRMCommon15GetActiveRightsERK6TDesC8mRP10CDRMRights @ 15 NONAME
+	_ZN9DRMCommon15IsProtectedFileER5RFileRi @ 16 NONAME
+	_ZN9DRMCommon15IsProtectedFileERK7TDesC16Ri @ 17 NONAME
+	_ZN9DRMCommon16GetContentHeaderERK6TDesC8S2_RP6HBufC8 @ 18 NONAME
+	_ZN9DRMCommon16RegisterDataTypeERK9TDataType @ 19 NONAME
+	_ZN9DRMCommon16SetContentHeaderERP6HBufC8RK6TDesC8S5_ @ 20 NONAME
+	_ZN9DRMCommon17GetContentURIListERP13RPointerArrayI6HBufC8E @ 21 NONAME
+	_ZN9DRMCommon17SupportedDataTypeEiR9TDataType @ 22 NONAME
+	_ZN9DRMCommon18CheckContentRightsERK6TDesC8m @ 23 NONAME
+	_ZN9DRMCommon18IsProtectedContentERK6TDesC8Ri @ 24 NONAME
+	_ZN9DRMCommon18UnRegisterDataTypeEi @ 25 NONAME
+	_ZN9DRMCommon19SupportedDRMMethodsERiRNS_9TOMALevelE @ 26 NONAME
+	_ZN9DRMCommon20StaticDataTypesCountERi @ 27 NONAME
+	_ZN9DRMCommon21GetDetailedFileRightsER5RFileRP13RPointerArrayI10CDRMRightsE @ 28 NONAME
+	_ZN9DRMCommon21GetDetailedFileRightsERK7TDesC16RP13RPointerArrayI10CDRMRightsE @ 29 NONAME
+	_ZN9DRMCommon21GetSingleRightsObjectERK6TDesC8mRP10CDRMRights @ 30 NONAME
+	_ZN9DRMCommon24GetDetailedContentRightsERK6TDesC8RP13RPointerArrayI10CDRMRightsE @ 31 NONAME
+	_ZN9DRMCommon4NewLEv @ 32 NONAME
+	_ZN9DRMCommon7ConnectEv @ 33 NONAME
+	_ZN9DRMCommon7VersionEv @ 34 NONAME
+	_ZN9DRMCommonC1Ev @ 35 NONAME
+	_ZN9DRMCommonC2Ev @ 36 NONAME
+	_ZN9DRMCommonD0Ev @ 37 NONAME
+	_ZN9DRMCommonD1Ev @ 38 NONAME
+	_ZN9DRMCommonD2Ev @ 39 NONAME
+	_ZTI9DRMCommon @ 40 NONAME ; #<TI>#
+	_ZTV9DRMCommon @ 41 NONAME ; #<VT>#
+	_ZN9DRMCommon19MergeParentAndChildEP10CDRMRights @ 42 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/eabi/DcfRepU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,48 @@
+EXPORTS
+	_ZN7CDcfRep10OrderListLERK6TDesC8 @ 1 NONAME
+	_ZN7CDcfRep10OrderListLEv @ 2 NONAME
+	_ZN7CDcfRep10RefreshDcfER13RPointerArrayI6HBufC8ER14TRequestStatus @ 3 NONAME
+	_ZN7CDcfRep10RefreshDcfER14TRequestStatus @ 4 NONAME
+	_ZN7CDcfRep14GetFileHandleLERK6TDesC8R5RFileR3RFs @ 5 NONAME
+	_ZN7CDcfRep16NotifyServerIdleER14TRequestStatus @ 6 NONAME
+	_ZN7CDcfRep16RemoveDcfFromDbLERK7TDesC16 @ 7 NONAME
+	_ZN7CDcfRep4NewLEv @ 8 NONAME
+	_ZN7CDcfRep5NextLEv @ 9 NONAME
+	_ZN7CDcfRep7SetTtidER6RArrayI5TPairER14TRequestStatusi @ 10 NONAME
+	_ZN7CDcfRep7UpdateLEPK9CDcfEntry @ 11 NONAME
+	_ZN7CDcfRep8GetTtidLER6RArrayI5TPairE @ 12 NONAME
+	_ZN7CDcfRepD0Ev @ 13 NONAME
+	_ZN7CDcfRepD1Ev @ 14 NONAME
+	_ZN7CDcfRepD2Ev @ 15 NONAME
+	_ZN9CDcfEntry11SetGroupIdLERK6TDesC8 @ 16 NONAME
+	_ZN9CDcfEntry12SetLocationLERK7TDesC16RKt @ 17 NONAME
+	_ZN9CDcfEntry4NewLEv @ 18 NONAME
+	_ZN9CDcfEntry7SetCidLERK6TDesC8 @ 19 NONAME
+	_ZN9CDcfEntryD0Ev @ 20 NONAME
+	_ZN9CDcfEntryD1Ev @ 21 NONAME
+	_ZN9CDcfEntryD2Ev @ 22 NONAME
+	_ZNK9CDcfEntry3CidEv @ 23 NONAME
+	_ZNK9CDcfEntry7GroupIdEv @ 24 NONAME
+	_ZNK9CDcfEntry8FileNameEv @ 25 NONAME
+	_ZNK9CDcfEntry8PositionEv @ 26 NONAME
+	_ZTI10RDcfRepCli @ 27 NONAME ; #<TI>#
+	_ZTI7CDcfRep @ 28 NONAME ; #<TI>#
+	_ZTI9CDcfEntry @ 29 NONAME ; #<TI>#
+	_ZTV10RDcfRepCli @ 30 NONAME ; #<VT>#
+	_ZTV7CDcfRep @ 31 NONAME ; #<VT>#
+	_ZTV9CDcfEntry @ 32 NONAME ; #<VT>#
+	_ZN10RDcfRepCli12StopWatchingEv @ 33 NONAME
+	_ZN10RDcfRepCli16NotifyServerIdleER14TRequestStatus @ 34 NONAME
+	_ZN10RDcfRepCli5CloseEv @ 35 NONAME
+	_ZN10RDcfRepCli7AddFileERK7TDesC16 @ 36 NONAME
+	_ZN10RDcfRepCli7ConnectEv @ 37 NONAME
+	_ZN10RDcfRepCli7ScanDcfER13RPointerArrayI6HBufC8ER14TRequestStatus @ 38 NONAME
+	_ZN10RDcfRepCli7ScanDcfER14TRequestStatus @ 39 NONAME
+	_ZN10RDcfRepCli7SetTtidER6RArrayI5TPairER14TRequestStatus @ 40 NONAME
+	_ZN10RDcfRepCliC1Ev @ 41 NONAME
+	_ZN10RDcfRepCliC2Ev @ 42 NONAME
+	_ZN10RDcfRepCliD0Ev @ 43 NONAME
+	_ZN10RDcfRepCliD1Ev @ 44 NONAME
+	_ZN10RDcfRepCliD2Ev @ 45 NONAME
+	_ZNK10RDcfRepCli7VersionEv @ 46 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/eabi/DrmCryptoU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,32 @@
+EXPORTS
+	_Z13Base64DecodeLRK6TDesC8 @ 1 NONAME
+	_Z13Base64EncodeLRK6TDesC8 @ 2 NONAME
+	_ZN10CmlaCrypto10DdtExpInvLERK6TDesC8 @ 3 NONAME
+	_ZN10CmlaCrypto11DdtPermInvLERK6TDesC8 @ 4 NONAME
+	_ZN10CmlaCrypto14CmlaIpDecryptLE19TKeyTransportSchemeP14MDrmKeyStorageRK6TDesC8R5TDes8S7_ @ 5 NONAME
+	_ZN10CmlaCrypto14CmlaIpEncryptLE19TKeyTransportSchemeP13CRSAPublicKeyRK6TDesC8S5_ @ 6 NONAME
+	_ZN10CmlaCrypto15RsaDecryptCmlaLEP14MDrmKeyStorageRK6TDesC8 @ 7 NONAME
+	_ZN10CmlaCrypto15RsaEncryptCmlaLEP13CRSAPublicKeyRK6TDesC8 @ 8 NONAME
+	_ZN10CmlaCrypto20SupportedAlgorithmsLER6RArrayI6TPtrC8E @ 9 NONAME
+	_ZN10CmlaCrypto28AlgorithmIdToTransportSchemeERK6TDesC8 @ 10 NONAME
+	_ZN10CmlaCrypto4KdfLERK6TDesC8 @ 11 NONAME
+	_ZN10CmlaCrypto5WrapLERK6TDesC8S2_ @ 12 NONAME
+	_ZN10CmlaCrypto7DdtExpLERK6TDesC8 @ 13 NONAME
+	_ZN10CmlaCrypto7UnwrapLERK6TDesC8S2_ @ 14 NONAME
+	_ZN10CmlaCrypto8DdtPermLERK6TDesC8 @ 15 NONAME
+	_ZN9OmaCrypto10AesUnwrapLERK6TDesC8S2_ @ 16 NONAME
+	_ZN9OmaCrypto10RsaVerifyLEP13CRSAPublicKeyRK6TDesC8 @ 17 NONAME
+	_ZN9OmaCrypto11RsaDecryptLEP14MDrmKeyStorageRK6TDesC8 @ 18 NONAME
+	_ZN9OmaCrypto11RsaEncryptLEP13CRSAPublicKeyRK6TDesC8 @ 19 NONAME
+	_ZN9OmaCrypto15RsaPssSignHashLEP14MDrmKeyStorageRK6TDesC8 @ 20 NONAME
+	_ZN9OmaCrypto17RsaKemKwsDecryptLEP14MDrmKeyStorageRK6TDesC8R5TDes8S6_ @ 21 NONAME
+	_ZN9OmaCrypto17RsaKemKwsEncryptLEP13CRSAPublicKeyRK6TDesC8S4_ @ 22 NONAME
+	_ZN9OmaCrypto17RsaPssVerifyHashLEP13CRSAPublicKeyRK6TDesC8S4_ @ 23 NONAME
+	_ZN9OmaCrypto18WriteUint32ToBlockEmR5TDes8i @ 24 NONAME
+	_ZN9OmaCrypto4KdfLERK6TDesC8S2_i @ 25 NONAME
+	_ZN9OmaCrypto5Mgf1LERK6TDesC8i @ 26 NONAME
+	_ZN9OmaCrypto6I2OSPLER8RInteger @ 27 NONAME
+	_ZN9OmaCrypto6OS2IPLERK6TDesC8 @ 28 NONAME
+	_ZN9OmaCrypto8AesWrapLERK6TDesC8S2_ @ 29 NONAME
+	_ZN12DrmAesCrypto14DrmAesEncryptLERK6TDesC8S2_iS2_ @ 30 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/eabi/DrmDcfU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+EXPORTS
+	_ZN10CDcfCommon4NewLERK5RFile @ 1 NONAME
+	_ZN10CDcfCommon4NewLERK7TDesC16P3RFs @ 2 NONAME
+	_ZN10CDcfCommonD0Ev @ 3 NONAME
+	_ZN10CDcfCommonD1Ev @ 4 NONAME
+	_ZN10CDcfCommonD2Ev @ 5 NONAME
+	_ZN8COma1Dcf10IsValidDcfERK6TDesC8 @ 6 NONAME
+	_ZN8COma1Dcf4NewLERK5RFile @ 7 NONAME
+	_ZN8COma1Dcf4NewLERK6TDesC8 @ 8 NONAME
+	_ZN8COma1DcfD0Ev @ 9 NONAME
+	_ZN8COma1DcfD1Ev @ 10 NONAME
+	_ZN8COma1DcfD2Ev @ 11 NONAME
+	_ZN8COma2Dcf10IsValidDcfERK6TDesC8 @ 12 NONAME
+	_ZN8COma2Dcf17SetRightsObjectsLER13RPointerArrayI6HBufC8E @ 13 NONAME
+	_ZN8COma2Dcf17SetTransactionIdLERK6TDesC8 @ 14 NONAME
+	_ZN8COma2Dcf4NewLERK5RFilei @ 15 NONAME
+	_ZN8COma2DcfD0Ev @ 16 NONAME
+	_ZN8COma2DcfD1Ev @ 17 NONAME
+	_ZN8COma2DcfD2Ev @ 18 NONAME
+	_ZTI10CDcfCommon @ 19 NONAME ; #<TI>#
+	_ZTI8COma1Dcf @ 20 NONAME ; #<TI>#
+	_ZTI8COma2Dcf @ 21 NONAME ; #<TI>#
+	_ZTV10CDcfCommon @ 22 NONAME ; #<VT>#
+	_ZTV8COma1Dcf @ 23 NONAME ; #<VT>#
+	_ZTV8COma2Dcf @ 24 NONAME ; #<VT>#
+	_ZN8COma1Dcf10GetHeaderLERK6TDesC8R6TPtrC8 @ 25 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/eabi/DrmKeyStorageU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z17DrmKeyStorageNewLv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/eabi/DrmParsersU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,38 @@
+EXPORTS
+	_ZN15COma1DcfCreator10ConstructLEv @ 1 NONAME
+	_ZN15COma1DcfCreator12EncryptFileLERK7TDesC16S2_RK6TDesC8P10CDRMRights @ 2 NONAME
+	_ZN15COma1DcfCreator14EncryptUpdateLERK6TDesC8 @ 3 NONAME
+	_ZN15COma1DcfCreator15EncryptContentLERP6HBufC8RK6TDesC8P10CDRMRights @ 4 NONAME
+	_ZN15COma1DcfCreator16EncryptFinalizeLEv @ 5 NONAME
+	_ZN15COma1DcfCreator18EncryptInitializeLER12RWriteStreamRK6TDesC8P10CDRMRights @ 6 NONAME
+	_ZN15COma1DcfCreator21EncryptContentToFileLERK6TDesC8RK7TDesC16S2_P10CDRMRights @ 7 NONAME
+	_ZN15COma1DcfCreator4NewLEv @ 8 NONAME
+	_ZN15COma1DcfCreatorC1Ev @ 9 NONAME
+	_ZN15COma1DcfCreatorC2Ev @ 10 NONAME
+	_ZN15COma1DcfCreatorD0Ev @ 11 NONAME
+	_ZN15COma1DcfCreatorD1Ev @ 12 NONAME
+	_ZN15COma1DcfCreatorD2Ev @ 13 NONAME
+	_ZN16CDrmRightsParser14ParseAndStoreLERK6TDesC8R13RPointerArrayI10CDRMRightsE @ 14 NONAME
+	_ZN16CDrmRightsParser4NewLENS_11TParserTypeE @ 15 NONAME
+	_ZN16CDrmRightsParserD0Ev @ 16 NONAME
+	_ZN16CDrmRightsParserD1Ev @ 17 NONAME
+	_ZN16CDrmRightsParserD2Ev @ 18 NONAME
+	_ZN17CDRMMessageParser14ProcessMessageERP6HBufC8 @ 19 NONAME
+	_ZN17CDRMMessageParser19ProcessMessageDataLERK6TDesC8 @ 20 NONAME
+	_ZN17CDRMMessageParser19ProcessRightsObjectERK6TDesC8R13RPointerArrayI10CDRMRightsE @ 21 NONAME
+	_ZN17CDRMMessageParser22FinalizeMessageParserLEv @ 22 NONAME
+	_ZN17CDRMMessageParser24InitializeMessageParserLER12RWriteStream @ 23 NONAME
+	_ZN17CDRMMessageParser4NewLEv @ 24 NONAME
+	_ZN17CDRMMessageParserD0Ev @ 25 NONAME
+	_ZN17CDRMMessageParserD1Ev @ 26 NONAME
+	_ZN17CDRMMessageParserD2Ev @ 27 NONAME
+	_ZN21CDrmProtectedRoParser14ParseAndStoreLERK6TDesC8R13RPointerArrayI10CDRMRightsE @ 28 NONAME
+	_ZN21CDrmProtectedRoParser4NewLEv @ 29 NONAME
+	_ZN21CDrmProtectedRoParserD0Ev @ 30 NONAME
+	_ZN21CDrmProtectedRoParserD1Ev @ 31 NONAME
+	_ZN21CDrmProtectedRoParserD2Ev @ 32 NONAME
+	_ZN21CDrmProtectedRoParser9GetRiUrlLERK6TDesC8 @ 33 NONAME
+	_ZN21CDrmProtectedRoParser12GetDomainIdLERK6TDesC8 @ 34 NONAME
+	_ZN21CDrmProtectedRoParser8GetRiIdLERK6TDesC8 @ 35 NONAME
+	_ZN16CDrmRightsParser6ParseLERK6TDesC8R13RPointerArrayI10CDRMRightsE @ 36 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/eabi/DrmRightsU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,116 @@
+EXPORTS
+	_ZN10CDRMRights10ConstructLEv @ 1 NONAME
+	_ZN10CDRMRights10GetAddTimeER5TTime @ 2 NONAME
+	_ZN10CDRMRights10GetLocalIDEv @ 3 NONAME
+	_ZN10CDRMRights10SetAddTimeE5TTime @ 4 NONAME
+	_ZN10CDRMRights10SetLocalIDEm @ 5 NONAME
+	_ZN10CDRMRights12GetPlayRightERP21CDRMRightsConstraints @ 6 NONAME
+	_ZN10CDRMRights12InternalizeLER11RReadStream @ 7 NONAME
+	_ZN10CDRMRights12SetPlayRightEP21CDRMRightsConstraints @ 8 NONAME
+	_ZN10CDRMRights13GetContentURIERP6HBufC8 @ 9 NONAME
+	_ZN10CDRMRights13GetPermissionEv @ 10 NONAME
+	_ZN10CDRMRights13GetPrintRightERP21CDRMRightsConstraints @ 11 NONAME
+	_ZN10CDRMRights13GetRightsInfoEmRNS_12TRestrictionERNS_11TExpirationERm @ 12 NONAME
+	_ZN10CDRMRights13SetContentURIEP6HBufC8 @ 13 NONAME
+	_ZN10CDRMRights13SetPrintRightEP21CDRMRightsConstraints @ 14 NONAME
+	_ZN10CDRMRights14SetPermissionLER14CDRMPermission @ 15 NONAME
+	_ZN10CDRMRights15GetDisplayRightERP21CDRMRightsConstraints @ 16 NONAME
+	_ZN10CDRMRights15GetExecuteRightERP21CDRMRightsConstraints @ 17 NONAME
+	_ZN10CDRMRights15SetDisplayRightEP21CDRMRightsConstraints @ 18 NONAME
+	_ZN10CDRMRights15SetExecuteRightEP21CDRMRightsConstraints @ 19 NONAME
+	_ZN10CDRMRights20GetExpirationDetailsEmR5TTimeRi @ 20 NONAME
+	_ZN10CDRMRights23SetContentURIAndLocalIDEP6HBufC8m @ 21 NONAME
+	_ZN10CDRMRights4NewLEv @ 22 NONAME
+	_ZN10CDRMRights8GetAssetEv @ 23 NONAME
+	_ZN10CDRMRights9SetAssetLER9CDRMAsset @ 24 NONAME
+	_ZN10CDRMRightsC1Ev @ 25 NONAME
+	_ZN10CDRMRightsC2Ev @ 26 NONAME
+	_ZN10CDRMRightsD0Ev @ 27 NONAME
+	_ZN10CDRMRightsD1Ev @ 28 NONAME
+	_ZN10CDRMRightsD2Ev @ 29 NONAME
+	_ZN10CDRMRightsaSERS_ @ 30 NONAME
+	_ZN14CDRMConstraint10DuplicateLERKS_ @ 31 NONAME
+	_ZN14CDRMConstraint12InternalizeLER11RReadStream @ 32 NONAME
+	_ZN14CDRMConstraint4NewLEv @ 33 NONAME
+	_ZN14CDRMConstraint5MergeERKS_ @ 34 NONAME
+	_ZN14CDRMConstraint5NewLCEv @ 35 NONAME
+	_ZN14CDRMConstraint7ConsumeERK5TTime @ 36 NONAME
+	_ZN14CDRMConstraintC1Ev @ 37 NONAME
+	_ZN14CDRMConstraintC2Ev @ 38 NONAME
+	_ZN14CDRMConstraintD0Ev @ 39 NONAME
+	_ZN14CDRMConstraintD1Ev @ 40 NONAME
+	_ZN14CDRMConstraintD2Ev @ 41 NONAME
+	_ZN14CDRMPermission10DuplicateLERKS_ @ 42 NONAME
+	_ZN14CDRMPermission12InternalizeLER11RReadStream @ 43 NONAME
+	_ZN14CDRMPermission13ConsumeRightsEN13ContentAccess7TIntentERK5TTime @ 44 NONAME
+	_ZN14CDRMPermission18TopLevelConstraintEv @ 45 NONAME
+	_ZN14CDRMPermission19ConstraintForIntentEN13ContentAccess7TIntentE @ 46 NONAME
+	_ZN14CDRMPermission4NewLEv @ 47 NONAME
+	_ZN14CDRMPermission5NewLCEv @ 48 NONAME
+	_ZN14CDRMPermission7ImportLERK6TDesC8 @ 49 NONAME
+	_ZN14CDRMPermissionD0Ev @ 50 NONAME
+	_ZN14CDRMPermissionD1Ev @ 51 NONAME
+	_ZN14CDRMPermissionD2Ev @ 52 NONAME
+	_ZN21CDRMRightsConstraints10ConstructLEv @ 53 NONAME
+	_ZN21CDRMRightsConstraints10FullRightsEv @ 54 NONAME
+	_ZN21CDRMRightsConstraints10GetEndTimeER5TTime @ 55 NONAME
+	_ZN21CDRMRightsConstraints10SetEndTimeE5TTime @ 56 NONAME
+	_ZN21CDRMRightsConstraints11GetCountersERmS0_ @ 57 NONAME
+	_ZN21CDRMRightsConstraints11GetIntervalER20TTimeIntervalSeconds @ 58 NONAME
+	_ZN21CDRMRightsConstraints11SetCountersEmm @ 59 NONAME
+	_ZN21CDRMRightsConstraints11SetIntervalE20TTimeIntervalSeconds @ 60 NONAME
+	_ZN21CDRMRightsConstraints12GetStartTimeER5TTime @ 61 NONAME
+	_ZN21CDRMRightsConstraints12SetStartTimeE5TTime @ 62 NONAME
+	_ZN21CDRMRightsConstraints13GetConstraintEv @ 63 NONAME
+	_ZN21CDRMRightsConstraints13SetConstraintER14CDRMConstraint @ 64 NONAME
+	_ZN21CDRMRightsConstraints16GetIntervalStartER5TTime @ 65 NONAME
+	_ZN21CDRMRightsConstraints16SetIntervalStartE5TTime @ 66 NONAME
+	_ZN21CDRMRightsConstraints17GetConstraintInfoERmS0_ @ 67 NONAME
+	_ZN21CDRMRightsConstraints20GetExpirationDetailsER5TTimeRi @ 68 NONAME
+	_ZN21CDRMRightsConstraints4NewLEv @ 69 NONAME
+	_ZN21CDRMRightsConstraints9IsPreviewEv @ 70 NONAME
+	_ZN21CDRMRightsConstraintsC1Ev @ 71 NONAME
+	_ZN21CDRMRightsConstraintsC2Ev @ 72 NONAME
+	_ZN21CDRMRightsConstraintsD0Ev @ 73 NONAME
+	_ZN21CDRMRightsConstraintsD1Ev @ 74 NONAME
+	_ZN21CDRMRightsConstraintsD2Ev @ 75 NONAME
+	_ZN21CDRMRightsConstraintsaSERS_ @ 76 NONAME
+	_ZN9CDRMAsset10DuplicateLERS_ @ 77 NONAME
+	_ZN9CDRMAsset12ExternalizeLER12RWriteStream @ 78 NONAME
+	_ZN9CDRMAsset12InternalizeLER11RReadStream @ 79 NONAME
+	_ZN9CDRMAsset4NewLEv @ 80 NONAME
+	_ZN9CDRMAsset5NewLCEv @ 81 NONAME
+	_ZN9CDRMAssetD0Ev @ 82 NONAME
+	_ZN9CDRMAssetD1Ev @ 83 NONAME
+	_ZN9CDRMAssetD2Ev @ 84 NONAME
+	_ZNK10CDRMRights12ExternalizeLER12RWriteStream @ 85 NONAME
+	_ZNK14CDRMConstraint12ExternalizeLER12RWriteStream @ 86 NONAME
+	_ZNK14CDRMConstraint4SizeEv @ 87 NONAME
+	_ZNK14CDRMConstraint7ExpiredERK5TTime @ 88 NONAME
+	_ZNK14CDRMConstraint8StatefulEv @ 89 NONAME
+	_ZNK14CDRMPermission12ExternalizeLER12RWriteStream @ 90 NONAME
+	_ZNK14CDRMPermission4SizeEv @ 91 NONAME
+	_ZNK14CDRMPermission5ChildEv @ 92 NONAME
+	_ZNK14CDRMPermission7ExportLEv @ 93 NONAME
+	_ZNK14CDRMPermission8StatefulEv @ 94 NONAME
+	_ZTI10CDRMRights @ 95 NONAME ; #<TI>#
+	_ZTI14CDRMConstraint @ 96 NONAME ; #<TI>#
+	_ZTI14CDRMPermission @ 97 NONAME ; #<TI>#
+	_ZTI21CDRMRightsConstraints @ 98 NONAME ; #<TI>#
+	_ZTI9CDRMAsset @ 99 NONAME ; #<TI>#
+	_ZTV10CDRMRights @ 100 NONAME ; #<VT>#
+	_ZTV14CDRMConstraint @ 101 NONAME ; #<VT>#
+	_ZTV14CDRMPermission @ 102 NONAME ; #<VT>#
+	_ZTV21CDRMRightsConstraints @ 103 NONAME ; #<VT>#
+	_ZTV9CDRMAsset @ 104 NONAME ; #<VT>#
+	_ZThn4_N10CDRMRights12InternalizeLER11RReadStream @ 105 NONAME ; #<thunk>#
+	_ZThn4_NK10CDRMRights12ExternalizeLER12RWriteStream @ 106 NONAME ; #<thunk>#
+	_ZN14CDRMPermission7ExpiredERK5TTime @ 107 NONAME
+	_ZNK14CDRMConstraint5ValidERK5TTimeRK13RPointerArrayI6HBufC8ERm @ 108 NONAME
+	_ZNK14CDRMPermission5ValidERK5TTimeRK13RPointerArrayI6HBufC8ERm11TRightsType @ 109 NONAME
+	_ZN21CDRMRightsConstraints14GetAccumulatedER20TTimeIntervalSeconds @ 110 NONAME
+	_ZN21CDRMRightsConstraints16GetTimedCountersERmS0_ @ 111 NONAME
+	_ZN10CDRMRights5MergeERKS_ @ 112 NONAME
+	_ZN14CDRMPermission5MergeERKS_ @ 113 NONAME
+	_ZNK14CDRMPermission19SoftwareConstrainedEv @ 114 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/eabi/DrmServerInterfacesU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,253 @@
+EXPORTS
+	_ZN12CDRMNotifier10SendEventLER9MDRMEventR14TRequestStatus @ 1 NONAME
+	_ZN12CDRMNotifier22RegisterEventObserverLER17MDRMEventObserverRKm @ 2 NONAME
+	_ZN12CDRMNotifier22RegisterEventObserverLER17MDRMEventObserverRKmRK6TDesC8 @ 3 NONAME
+	_ZN12CDRMNotifier24UnRegisterEventObserverLER17MDRMEventObserverRKm @ 4 NONAME
+	_ZN12CDRMNotifier24UnRegisterEventObserverLER17MDRMEventObserverRKmRK6TDesC8 @ 5 NONAME
+	_ZN12CDRMNotifier4NewLEv @ 6 NONAME
+	_ZN12CDRMNotifier5NewLCEv @ 7 NONAME
+	_ZN12CDRMNotifierD0Ev @ 8 NONAME
+	_ZN12CDRMNotifierD1Ev @ 9 NONAME
+	_ZN12CDRMNotifierD2Ev @ 10 NONAME
+	_ZN13CDRMRIContext10SetRIURLsLERK13RPointerArrayI6HBufC8E @ 11 NONAME
+	_ZN13CDRMRIContext11SetVersionLERK6TDesC8 @ 12 NONAME
+	_ZN13CDRMRIContext12InternalizeLER11RReadStream @ 13 NONAME
+	_ZN13CDRMRIContext14SetAlgorithmsLERK13RPointerArrayI6HBufC8E @ 14 NONAME
+	_ZN13CDRMRIContext14SetExpiryTimeLERK5TTime @ 15 NONAME
+	_ZN13CDRMRIContext16SetOCSPResponseLERK13RPointerArrayI6HBufC8E @ 16 NONAME
+	_ZN13CDRMRIContext19SetDeviceCertCachedERh @ 17 NONAME
+	_ZN13CDRMRIContext19SetRightsIssuerURLLERK6TDesC8 @ 18 NONAME
+	_ZN13CDRMRIContext20SetCertificateChainLERK13RPointerArrayI6HBufC8E @ 19 NONAME
+	_ZN13CDRMRIContext21SetSelectedDeviceRootERK6TDesC8 @ 20 NONAME
+	_ZN13CDRMRIContext4NewLERK6TDesC8S2_S2_RK13RPointerArrayI6HBufC8ES7_S2_RK5TTimeS7_S7_hS2_h @ 21 NONAME
+	_ZN13CDRMRIContext4NewLEv @ 22 NONAME
+	_ZN13CDRMRIContext5NewLCERK6TDesC8S2_S2_RK13RPointerArrayI6HBufC8ES7_S2_RK5TTimeS7_S7_hS2_h @ 23 NONAME
+	_ZN13CDRMRIContext5NewLCEv @ 24 NONAME
+	_ZN13CDRMRIContext7ImportLERK6TDesC8 @ 25 NONAME
+	_ZN13CDRMRIContext8SetRIIDLERK6TDesC8 @ 26 NONAME
+	_ZN13CDRMRIContextD0Ev @ 27 NONAME
+	_ZN13CDRMRIContextD1Ev @ 28 NONAME
+	_ZN13CDRMRIContextD2Ev @ 29 NONAME
+	_ZN15CDRMEventModify11SetUniqueIDEm @ 30 NONAME
+	_ZN15CDRMEventModify12ExternalizeLER12RWriteStream @ 31 NONAME
+	_ZN15CDRMEventModify12InternalizeLER11RReadStream @ 32 NONAME
+	_ZN15CDRMEventModify13SetContentIDLERK6TDesC8 @ 33 NONAME
+	_ZN15CDRMEventModify4NewLEv @ 34 NONAME
+	_ZN15CDRMEventModify5NewLCEv @ 35 NONAME
+	_ZN15CDRMEventModifyD0Ev @ 36 NONAME
+	_ZN15CDRMEventModifyD1Ev @ 37 NONAME
+	_ZN15CDRMEventModifyD2Ev @ 38 NONAME
+	_ZN15RDRMClockClient16UpdateSecureTimeERK5TTimeRKi @ 39 NONAME
+	_ZN15RDRMClockClient5CloseEv @ 40 NONAME
+	_ZN15RDRMClockClient7ConnectEv @ 41 NONAME
+	_ZN15RDRMClockClientC1Ev @ 42 NONAME
+	_ZN15RDRMClockClientC2Ev @ 43 NONAME
+	_ZN15RDRMClockClientD0Ev @ 44 NONAME
+	_ZN15RDRMClockClientD1Ev @ 45 NONAME
+	_ZN15RDRMClockClientD2Ev @ 46 NONAME
+	_ZN16RDRMRightsClient10AddToCacheERK6TDesC8 @ 47 NONAME
+	_ZN16RDRMRightsClient10AddToCacheERK6TDesC8RK5TTime @ 48 NONAME
+	_ZN16RDRMRightsClient10GetUdtDataER5TDes8 @ 49 NONAME
+	_ZN16RDRMRightsClient11AddDomainROERK6TDesC8S2_ @ 50 NONAME
+	_ZN16RDRMRightsClient11CheckRightsEiRK6TDesC8Rm @ 51 NONAME
+	_ZN16RDRMRightsClient11GetDbEntryLERK6TDesC8RKm @ 52 NONAME
+	_ZN16RDRMRightsClient11InitiateUdtERK6TDesC8 @ 53 NONAME
+	_ZN16RDRMRightsClient11StartServerEv @ 54 NONAME
+	_ZN16RDRMRightsClient12CheckConsumeEiRK6TDesC8 @ 55 NONAME
+	_ZN16RDRMRightsClient12GetDomainROLERK6TDesC8 @ 56 NONAME
+	_ZN16RDRMRightsClient13DeleteDbEntryERK6TDesC8 @ 57 NONAME
+	_ZN16RDRMRightsClient13DeleteDbEntryERK6TDesC8RKm @ 58 NONAME
+	_ZN16RDRMRightsClient13GetDBEntriesLERK6TDesC8R13RPointerArrayI14CDRMPermissionE @ 59 NONAME
+	_ZN16RDRMRightsClient13InitializeKeyERK6TDesC8 @ 60 NONAME
+	_ZN16RDRMRightsClient14DeleteDomainROERK6TDesC8 @ 61 NONAME
+	_ZN16RDRMRightsClient14ForwardLockURIERP6HBufC8 @ 62 NONAME
+	_ZN16RDRMRightsClient16CalculatePaddingERK6TDesC8 @ 63 NONAME
+	_ZN16RDRMRightsClient16GetActiveRightsLEiRK6TDesC8Rm @ 64 NONAME
+	_ZN16RDRMRightsClient16GetDecryptionKeyEiRK6TDesC8R5TDes8 @ 65 NONAME
+	_ZN16RDRMRightsClient18AddProtectedRecordERK6TDesC8iRK14CDRMPermissionS2_Rm @ 66 NONAME
+	_ZN16RDRMRightsClient18InitializeGroupKeyERK6TDesC8S2_N13ContentAccess17TEncryptionMethodE @ 67 NONAME
+	_ZN16RDRMRightsClient19ExportContentIDListER13RPointerArrayI6HBufC8E @ 68 NONAME
+	_ZN16RDRMRightsClient19ExportContentIDListER6TDes16 @ 69 NONAME
+	_ZN16RDRMRightsClient19GetDomainRosForCidLERK6TDesC8R13RPointerArrayI6HBufC8E @ 70 NONAME
+	_ZN16RDRMRightsClient19GetEstimatedArrivalERK6TDesC8R20TTimeIntervalSeconds @ 71 NONAME
+	_ZN16RDRMRightsClient19SetEstimatedArrivalERK6TDesC820TTimeIntervalSeconds @ 72 NONAME
+	_ZN16RDRMRightsClient21GetAuthenticationSeedERK6TDesC8R5TDes8 @ 73 NONAME
+	_ZN16RDRMRightsClient21SetAuthenticationSeedERK6TDesC8S2_ @ 74 NONAME
+	_ZN16RDRMRightsClient23DecodeRightsIssuerFieldERK6TDesC8RP6HBufC8 @ 75 NONAME
+	_ZN16RDRMRightsClient23EncodeRightsIssuerFieldERK6TDesC8RP6HBufC8 @ 76 NONAME
+	_ZN16RDRMRightsClient24DeleteExpiredPermissionsER14TRequestStatus @ 77 NONAME
+	_ZN16RDRMRightsClient25InitOrphanedContentIdListEiR14TRequestStatus @ 78 NONAME
+	_ZN16RDRMRightsClient27ExportOrphanedContentIdListER13RPointerArrayI6HBufC8E @ 79 NONAME
+	_ZN16RDRMRightsClient27ExportOrphanedContentIdListER6TDes16 @ 80 NONAME
+	_ZN16RDRMRightsClient5CloseEv @ 81 NONAME
+	_ZN16RDRMRightsClient5CountEv @ 82 NONAME
+	_ZN16RDRMRightsClient6CancelEv @ 83 NONAME
+	_ZN16RDRMRightsClient7ConnectEv @ 84 NONAME
+	_ZN16RDRMRightsClient7ConsumeEiRK6TDesC8 @ 85 NONAME
+	_ZN16RDRMRightsClient7DecryptERK6TDesC8R5TPtr8i @ 86 NONAME
+	_ZN16RDRMRightsClient7EncryptERK6TDesC8R5TPtr8i @ 87 NONAME
+	_ZN16RDRMRightsClient7GetNameERK6TDesC8RP7HBufC16 @ 88 NONAME
+	_ZN16RDRMRightsClient7SetNameERK6TDesC8RK7TDesC16 @ 89 NONAME
+	_ZN16RDRMRightsClient9AddRecordERK6TDesC8RK14CDRMPermissionS2_Rm @ 90 NONAME
+	_ZN16RDRMRightsClient9DeleteAllEv @ 91 NONAME
+	_ZN16RDRMRightsClient9IsInCacheERK6TDesC8RK5TTimeRi @ 92 NONAME
+	_ZN16RDRMRightsClient9IsInCacheERK6TDesC8Ri @ 93 NONAME
+	_ZN16RDRMRightsClientC1Ev @ 94 NONAME
+	_ZN16RDRMRightsClientC2Ev @ 95 NONAME
+	_ZN16RDRMRightsClientD0Ev @ 96 NONAME
+	_ZN16RDRMRightsClientD1Ev @ 97 NONAME
+	_ZN16RDRMRightsClientD2Ev @ 98 NONAME
+	_ZN17CDRMDomainContext12InternalizeLER11RReadStream @ 99 NONAME
+	_ZN17CDRMDomainContext12SetDomainIDLERK6TDesC8 @ 100 NONAME
+	_ZN17CDRMDomainContext14SetDomainKeysLERK13RPointerArrayI6HBufC8E @ 101 NONAME
+	_ZN17CDRMDomainContext14SetExpiryTimeLERK5TTime @ 102 NONAME
+	_ZN17CDRMDomainContext15SetHashChainedLERKi @ 103 NONAME
+	_ZN17CDRMDomainContext18SetRightsIssuerIDLERK6TDesC8 @ 104 NONAME
+	_ZN17CDRMDomainContext19SetRightsIssuerURLLERK6TDesC8 @ 105 NONAME
+	_ZN17CDRMDomainContext4NewLERK6TDesC8RK5TTimeiRK13RPointerArrayI6HBufC8ES2_S2_ @ 106 NONAME
+	_ZN17CDRMDomainContext4NewLEv @ 107 NONAME
+	_ZN17CDRMDomainContext5NewLCERK6TDesC8RK5TTimeiRK13RPointerArrayI6HBufC8ES2_S2_ @ 108 NONAME
+	_ZN17CDRMDomainContext5NewLCEv @ 109 NONAME
+	_ZN17CDRMDomainContext7ImportLERK6TDesC8 @ 110 NONAME
+	_ZN17CDRMDomainContextC1ERK5TTimei @ 111 NONAME
+	_ZN17CDRMDomainContextC2ERK5TTimei @ 112 NONAME
+	_ZN17CDRMDomainContextD0Ev @ 113 NONAME
+	_ZN17CDRMDomainContextD1Ev @ 114 NONAME
+	_ZN17CDRMDomainContextD2Ev @ 115 NONAME
+	_ZN18CDRMEventAddRemove12ExternalizeLER12RWriteStream @ 116 NONAME
+	_ZN18CDRMEventAddRemove12InternalizeLER11RReadStream @ 117 NONAME
+	_ZN18CDRMEventAddRemove13SetContentIDLERK6TDesC8 @ 118 NONAME
+	_ZN18CDRMEventAddRemove4NewLE21TAddRemoveEventStatus @ 119 NONAME
+	_ZN18CDRMEventAddRemove5NewLCE21TAddRemoveEventStatus @ 120 NONAME
+	_ZN18CDRMEventAddRemoveD0Ev @ 121 NONAME
+	_ZN18CDRMEventAddRemoveD1Ev @ 122 NONAME
+	_ZN18CDRMEventAddRemoveD2Ev @ 123 NONAME
+	_ZN19CDRMEventTimeChange10SetNewTimeERK5TTime @ 124 NONAME
+	_ZN19CDRMEventTimeChange10SetOldTimeERK5TTime @ 125 NONAME
+	_ZN19CDRMEventTimeChange12ExternalizeLER12RWriteStream @ 126 NONAME
+	_ZN19CDRMEventTimeChange12InternalizeLER11RReadStream @ 127 NONAME
+	_ZN19CDRMEventTimeChange14SetNewTimeZoneEi @ 128 NONAME
+	_ZN19CDRMEventTimeChange14SetOldTimeZoneEi @ 129 NONAME
+	_ZN19CDRMEventTimeChange19SetNewSecurityLevelEN8DRMClock14ESecurityLevelE @ 130 NONAME
+	_ZN19CDRMEventTimeChange19SetOldSecurityLevelEN8DRMClock14ESecurityLevelE @ 131 NONAME
+	_ZN19CDRMEventTimeChange4NewLEv @ 132 NONAME
+	_ZN19CDRMEventTimeChange5NewLCEv @ 133 NONAME
+	_ZN19CDRMEventTimeChangeD0Ev @ 134 NONAME
+	_ZN19CDRMEventTimeChangeD1Ev @ 135 NONAME
+	_ZN19CDRMEventTimeChangeD2Ev @ 136 NONAME
+	_ZN4Roap18RRoapStorageClient10DeleteAllLEv @ 137 NONAME
+	_ZN4Roap18RRoapStorageClient13AddRIContextLERK13CDRMRIContext @ 138 NONAME
+	_ZN4Roap18RRoapStorageClient13GetRIContextLERK6TDesC8 @ 139 NONAME
+	_ZN4Roap18RRoapStorageClient16DeleteRiContextLERK6TDesC8 @ 140 NONAME
+	_ZN4Roap18RRoapStorageClient17AddDomainContextLERK17CDRMDomainContextRK13RPointerArrayI6HBufC8ES8_R19TKeyTransportScheme @ 141 NONAME
+	_ZN4Roap18RRoapStorageClient17DeleteExpiredRIsLERK5TTime @ 142 NONAME
+	_ZN4Roap18RRoapStorageClient17GetDomainContextLERK6TDesC8 @ 143 NONAME
+	_ZN4Roap18RRoapStorageClient19GetDevicePublicKeyLERP13CRSAPublicKey @ 144 NONAME
+	_ZN4Roap18RRoapStorageClient19WhiteListURLExistsLERK6TDesC8Ri @ 145 NONAME
+	_ZN4Roap18RRoapStorageClient20DeleteDomainContextLERK6TDesC8 @ 146 NONAME
+	_ZN4Roap18RRoapStorageClient21DeleteExpiredDomainsLERK5TTime @ 147 NONAME
+	_ZN4Roap18RRoapStorageClient22DeleteExpiredContextsLERK5TTime @ 148 NONAME
+	_ZN4Roap18RRoapStorageClient22GetDevicePublicKeyDerLERP6HBufC8 @ 149 NONAME
+	_ZN4Roap18RRoapStorageClient23GetDevicePublicKeyHashLER5TDes8 @ 150 NONAME
+	_ZN4Roap18RRoapStorageClient26GetDeviceCertificateChainLER13RPointerArrayI6HBufC8E @ 151 NONAME
+	_ZN4Roap18RRoapStorageClient5SignLERK6TDesC8RP6HBufC8 @ 152 NONAME
+	_ZN4Roap18RRoapStorageClient7ConnectEv @ 153 NONAME
+	_ZN4Roap18RRoapStorageClient7VerifyLERK6TDesC8S3_RK13RPointerArrayI6HBufC8E @ 154 NONAME
+	_ZN4Roap18RRoapStorageClient8RsaSignLERK6TDesC8RP6HBufC8 @ 155 NONAME
+	_ZN4Roap18RRoapStorageClientC1Ev @ 156 NONAME
+	_ZN4Roap18RRoapStorageClientC2Ev @ 157 NONAME
+	_ZN4Roap18RRoapStorageClientD0Ev @ 158 NONAME
+	_ZN4Roap18RRoapStorageClientD1Ev @ 159 NONAME
+	_ZN4Roap18RRoapStorageClientD2Ev @ 160 NONAME
+	_ZN9MDRMEvent12ExternalizeLER12RWriteStream @ 161 NONAME
+	_ZN9MDRMEvent12InternalizeLER11RReadStream @ 162 NONAME
+	_ZN9MDRMEventC1ERKm @ 163 NONAME
+	_ZN9MDRMEventC2ERKm @ 164 NONAME
+	_ZN9MDRMEventD0Ev @ 165 NONAME
+	_ZN9MDRMEventD1Ev @ 166 NONAME
+	_ZN9MDRMEventD2Ev @ 167 NONAME
+	_ZNK13CDRMRIContext10AlgorithmsEv @ 168 NONAME
+	_ZNK13CDRMRIContext10ExpiryTimeEv @ 169 NONAME
+	_ZNK13CDRMRIContext12ExternalizeLER12RWriteStream @ 170 NONAME
+	_ZNK13CDRMRIContext12OCSPResponseEv @ 171 NONAME
+	_ZNK13CDRMRIContext15RightsIssuerURLEv @ 172 NONAME
+	_ZNK13CDRMRIContext16CertificateChainEv @ 173 NONAME
+	_ZNK13CDRMRIContext16DeviceCertCachedEv @ 174 NONAME
+	_ZNK13CDRMRIContext18SelectedDeviceRootEv @ 175 NONAME
+	_ZNK13CDRMRIContext19WhiteListURLExistsLERK6TDesC8 @ 176 NONAME
+	_ZNK13CDRMRIContext4RIIDEv @ 177 NONAME
+	_ZNK13CDRMRIContext4SizeEv @ 178 NONAME
+	_ZNK13CDRMRIContext6RIURLsEv @ 179 NONAME
+	_ZNK13CDRMRIContext7ExportLEv @ 180 NONAME
+	_ZNK13CDRMRIContext7VersionEv @ 181 NONAME
+	_ZNK15CDRMEventModify13GetContentIDLEv @ 182 NONAME
+	_ZNK15CDRMEventModify8UniqueIDEv @ 183 NONAME
+	_ZNK15RDRMClockClient13GetSecureTimeER5TTimeRiRN8DRMClock14ESecurityLevelE @ 184 NONAME
+	_ZNK16RDRMRightsClient10VerifyMacLERK6TDesC8S2_ @ 185 NONAME
+	_ZNK16RDRMRightsClient12StopWatchingEv @ 186 NONAME
+	_ZNK16RDRMRightsClient14GetRandomDataLER5TDes8 @ 187 NONAME
+	_ZNK16RDRMRightsClient15UnwrapMacAndRekERK6TDesC819TKeyTransportSchemeS2_S2_ @ 188 NONAME
+	_ZNK16RDRMRightsClient24GetSupportedIndividualsLER13RPointerArrayI6HBufC8E @ 189 NONAME
+	_ZNK17CDRMDomainContext10DomainKeyLEi @ 190 NONAME
+	_ZNK17CDRMDomainContext10DomainKeysEv @ 191 NONAME
+	_ZNK17CDRMDomainContext10ExpiryTimeEv @ 192 NONAME
+	_ZNK17CDRMDomainContext11HashChainedEv @ 193 NONAME
+	_ZNK17CDRMDomainContext12ExternalizeLER12RWriteStream @ 194 NONAME
+	_ZNK17CDRMDomainContext14RightsIssuerIDEv @ 195 NONAME
+	_ZNK17CDRMDomainContext15RightsIssuerURLEv @ 196 NONAME
+	_ZNK17CDRMDomainContext16DomainGenerationEv @ 197 NONAME
+	_ZNK17CDRMDomainContext4SizeEv @ 198 NONAME
+	_ZNK17CDRMDomainContext7ExportLEv @ 199 NONAME
+	_ZNK17CDRMDomainContext8DomainIDEv @ 200 NONAME
+	_ZNK18CDRMEventAddRemove13GetContentIDLEv @ 201 NONAME
+	_ZNK18CDRMEventAddRemove6StatusEv @ 202 NONAME
+	_ZNK19CDRMEventTimeChange10GetNewTimeEv @ 203 NONAME
+	_ZNK19CDRMEventTimeChange10GetOldTimeEv @ 204 NONAME
+	_ZNK19CDRMEventTimeChange14GetNewTimeZoneEv @ 205 NONAME
+	_ZNK19CDRMEventTimeChange14GetOldTimeZoneEv @ 206 NONAME
+	_ZNK19CDRMEventTimeChange19GetNewSecurityLevelEv @ 207 NONAME
+	_ZNK19CDRMEventTimeChange19GetOldSecurityLevelEv @ 208 NONAME
+	_ZNK4Roap18RRoapStorageClient16GetTrustedRootsLER13RPointerArrayI6HBufC8E @ 209 NONAME
+	_ZNK4Roap18RRoapStorageClient18SelectTrustedRootLERK13RPointerArrayI6HBufC8ER5TDes8 @ 210 NONAME
+	_ZNK4Roap18RRoapStorageClient18SelectTrustedRootLERK6TDesC8 @ 211 NONAME
+	_ZNK4Roap18RRoapStorageClient19GetRootCertificateLERK7TDesC16 @ 212 NONAME
+	_ZNK9MDRMEvent12GetEventTypeERm @ 213 NONAME
+	_ZTI12CDRMNotifier @ 214 NONAME ; #<TI>#
+	_ZTI13CDRMRIContext @ 215 NONAME ; #<TI>#
+	_ZTI15CDRMEventModify @ 216 NONAME ; #<TI>#
+	_ZTI16CDRMEventHandler @ 217 NONAME ; #<TI>#
+	_ZTI16RDRMRightsClient @ 218 NONAME ; #<TI>#
+	_ZTI17CDRMDomainContext @ 219 NONAME ; #<TI>#
+	_ZTI18CDRMEventAddRemove @ 220 NONAME ; #<TI>#
+	_ZTI18RDRMNotifierClient @ 221 NONAME ; #<TI>#
+	_ZTI19CDRMEventTimeChange @ 222 NONAME ; #<TI>#
+	_ZTI9MDRMEvent @ 223 NONAME ; #<TI>#
+	_ZTV12CDRMNotifier @ 224 NONAME ; #<VT>#
+	_ZTV13CDRMRIContext @ 225 NONAME ; #<VT>#
+	_ZTV15CDRMEventModify @ 226 NONAME ; #<VT>#
+	_ZTV16CDRMEventHandler @ 227 NONAME ; #<VT>#
+	_ZTV16RDRMRightsClient @ 228 NONAME ; #<VT>#
+	_ZTV17CDRMDomainContext @ 229 NONAME ; #<VT>#
+	_ZTV18CDRMEventAddRemove @ 230 NONAME ; #<VT>#
+	_ZTV18RDRMNotifierClient @ 231 NONAME ; #<VT>#
+	_ZTV19CDRMEventTimeChange @ 232 NONAME ; #<VT>#
+	_ZTV9MDRMEvent @ 233 NONAME ; #<VT>#
+	_ZThn8_N15CDRMEventModifyD0Ev @ 234 NONAME ; #<thunk>#
+	_ZThn8_N15CDRMEventModifyD1Ev @ 235 NONAME ; #<thunk>#
+	_ZThn8_N18CDRMEventAddRemoveD0Ev @ 236 NONAME ; #<thunk>#
+	_ZThn8_N18CDRMEventAddRemoveD1Ev @ 237 NONAME ; #<thunk>#
+	_ZThn8_N19CDRMEventTimeChangeD0Ev @ 238 NONAME ; #<thunk>#
+	_ZThn8_N19CDRMEventTimeChangeD1Ev @ 239 NONAME ; #<thunk>#
+	_ZN13CDRMRIContext17SetMeteringStatusEi @ 240 NONAME
+	_ZN16RDRMRightsClient16GetMeteringDataLERK6TDesC8 @ 241 NONAME
+	_ZN16RDRMRightsClient19DeleteMeteringDataLERK6TDesC8 @ 242 NONAME
+	_ZN4Roap18RRoapStorageClient19DeleteMeteringDataLERK6TDesC8 @ 243 NONAME
+	_ZNK13CDRMRIContext17IsMeteringAllowedEv @ 244 NONAME
+	_ZN4Roap18RRoapStorageClient16GetMeteringDataLER6TDesC8R5TDes8S4_RP6HBufC8 @ 245 NONAME
+	_ZN4Roap18RRoapStorageClient16UpdateRIContextLERK13CDRMRIContext @ 246 NONAME
+	_ZN4Roap18RRoapStorageClient17GetAllRIContextsLER13RPointerArrayI13CDRMRIContextE @ 247 NONAME
+	_ZNK13CDRMRIContext7RIAliasEv @ 248 NONAME
+	_ZN4Roap18RRoapStorageClient14UpdateDrmTimeLERK13RPointerArrayI6HBufC8ES5_RK6TDesC8 @ 249 NONAME
+	_ZN4Roap18RRoapStorageClient20VerifyOcspResponsesLERK13RPointerArrayI6HBufC8ERK6TDesC8S5_ @ 250 NONAME
+	_ZN4Roap18RRoapStorageClient19GetOcspResponderIdLERK6TDesC8 @ 251 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/eabi/DrmServiceAPIu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,8 @@
+EXPORTS
+	_ZN3DRM14CDrmServiceApi16UpdateSecureTimeERK5TTimeRKi @ 1 NONAME
+	_ZN3DRM14CDrmServiceApi22GetDevicePublicKeyDerLERP6HBufC8 @ 2 NONAME
+	_ZN3DRM14CDrmServiceApi4NewLEv @ 3 NONAME
+	_ZN3DRM14CDrmServiceApi5NewLCEv @ 4 NONAME
+	_ZN3DRM14CDrmServiceApi5SignLERK6TDesC8RP6HBufC8 @ 5 NONAME
+	_ZNK3DRM14CDrmServiceApi13GetSecureTimeER5TTimeRiRN8DRMClock14ESecurityLevelE @ 6 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/eabi/DrmStdKeyStorageU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	_ZN17CDrmStdKeyStorage4NewLE8RLibrary @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/eabi/ROAPHandlerU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,88 @@
+EXPORTS
+	_ZN4Roap12CRoapEngBase11SetTriggerLERK6TDesC8PK20CAiwGenericParamListRNS_12TTriggerTypeERNS_16TRiContextStatusERNS_16TDomainOperationER13RPointerArrayI6HBufC8E @ 1 NONAME
+	_ZN4Roap12CRoapEngBase16HandleRoReponseLERK6TDesC8R13RPointerArrayI10CDRMRightsE @ 2 NONAME
+	_ZN4Roap12CRoapEngBase6RejectEv @ 3 NONAME
+	_ZN4Roap12CRoapEngBase7AcceptLEPNS_13MRoapObserverEP14TRequestStatus @ 4 NONAME
+	_ZN4Roap12CRoapEngBase9DoCleanupEv @ 5 NONAME
+	_ZN4Roap12CRoapEngBaseD0Ev @ 6 NONAME
+	_ZN4Roap12CRoapEngBaseD1Ev @ 7 NONAME
+	_ZN4Roap12CRoapEngBaseD2Ev @ 8 NONAME
+	_ZN4Roap12CRoapTrigger12ValidTriggerEv @ 9 NONAME
+	_ZN4Roap12CRoapTrigger13MessageAsXmlLEv @ 10 NONAME
+	_ZN4Roap12CRoapTrigger4NewLERKNS_12TTriggerTypeERK6TDesC8S6_S6_RK13RPointerArrayI6HBufC8ESB_ @ 11 NONAME
+	_ZN4Roap12CRoapTrigger4NewLEv @ 12 NONAME
+	_ZN4Roap12CRoapTriggerD0Ev @ 13 NONAME
+	_ZN4Roap12CRoapTriggerD1Ev @ 14 NONAME
+	_ZN4Roap12CRoapTriggerD2Ev @ 15 NONAME
+	_ZN4Roap8CRoapEng4NewLEv @ 16 NONAME
+	_ZN4Roap8CRoapEngD0Ev @ 17 NONAME
+	_ZN4Roap8CRoapEngD1Ev @ 18 NONAME
+	_ZN4Roap8CRoapEngD2Ev @ 19 NONAME
+	_ZTI13COCSPResponse @ 20 NONAME ; #<TI>#
+	_ZTI17TMultipartHandler @ 21 NONAME ; #<TI>#
+	_ZTI21COCSPResponseCertInfo @ 22 NONAME ; #<TI>#
+	_ZTIN4Roap10CRightsReqE @ 23 NONAME ; #<TI>#
+	_ZTIN4Roap11CRightsRespE @ 24 NONAME ; #<TI>#
+	_ZTIN4Roap11CRoapParserE @ 25 NONAME ; #<TI>#
+	_ZTIN4Roap11CRoapSignerE @ 26 NONAME ; #<TI>#
+	_ZTIN4Roap12CDeviceHelloE @ 27 NONAME ; #<TI>#
+	_ZTIN4Roap12CRoapEngBaseE @ 28 NONAME ; #<TI>#
+	_ZTIN4Roap12CRoapMessageE @ 29 NONAME ; #<TI>#
+	_ZTIN4Roap12CRoapTriggerE @ 30 NONAME ; #<TI>#
+	_ZTIN4Roap13CRoapResponseE @ 31 NONAME ; #<TI>#
+	_ZTIN4Roap14CJoinDomainReqE @ 32 NONAME ; #<TI>#
+	_ZTIN4Roap14TRIHelloParserE @ 33 NONAME ; #<TI>#
+	_ZTIN4Roap15CJoinDomainRespE @ 34 NONAME ; #<TI>#
+	_ZTIN4Roap15CLeaveDomainReqE @ 35 NONAME ; #<TI>#
+	_ZTIN4Roap15CRoapConnectionE @ 36 NONAME ; #<TI>#
+	_ZTIN4Roap16CLeaveDomainRespE @ 37 NONAME ; #<TI>#
+	_ZTIN4Roap16CRegistrationReqE @ 38 NONAME ; #<TI>#
+	_ZTIN4Roap16CRoapHttpHandlerE @ 39 NONAME ; #<TI>#
+	_ZTIN4Roap17CRegistrationRespE @ 40 NONAME ; #<TI>#
+	_ZTIN4Roap17TRightsRespParserE @ 41 NONAME ; #<TI>#
+	_ZTIN4Roap18TRoapTriggerParserE @ 42 NONAME ; #<TI>#
+	_ZTIN4Roap21TJoinDomainRespParserE @ 43 NONAME ; #<TI>#
+	_ZTIN4Roap22TLeaveDomainRespParserE @ 44 NONAME ; #<TI>#
+	_ZTIN4Roap23TRegistrationRespParserE @ 45 NONAME ; #<TI>#
+	_ZTIN4Roap8CRIHelloE @ 46 NONAME ; #<TI>#
+	_ZTIN4Roap8CRoapEngE @ 47 NONAME ; #<TI>#
+	_ZTV13COCSPResponse @ 48 NONAME ; #<VT>#
+	_ZTV17TMultipartHandler @ 49 NONAME ; #<VT>#
+	_ZTV21COCSPResponseCertInfo @ 50 NONAME ; #<VT>#
+	_ZTVN4Roap10CRightsReqE @ 51 NONAME ; #<VT>#
+	_ZTVN4Roap11CRightsRespE @ 52 NONAME ; #<VT>#
+	_ZTVN4Roap11CRoapParserE @ 53 NONAME ; #<VT>#
+	_ZTVN4Roap11CRoapSignerE @ 54 NONAME ; #<VT>#
+	_ZTVN4Roap12CDeviceHelloE @ 55 NONAME ; #<VT>#
+	_ZTVN4Roap12CRoapEngBaseE @ 56 NONAME ; #<VT>#
+	_ZTVN4Roap12CRoapMessageE @ 57 NONAME ; #<VT>#
+	_ZTVN4Roap12CRoapTriggerE @ 58 NONAME ; #<VT>#
+	_ZTVN4Roap13CRoapResponseE @ 59 NONAME ; #<VT>#
+	_ZTVN4Roap14CJoinDomainReqE @ 60 NONAME ; #<VT>#
+	_ZTVN4Roap14TRIHelloParserE @ 61 NONAME ; #<VT>#
+	_ZTVN4Roap15CJoinDomainRespE @ 62 NONAME ; #<VT>#
+	_ZTVN4Roap15CLeaveDomainReqE @ 63 NONAME ; #<VT>#
+	_ZTVN4Roap15CRoapConnectionE @ 64 NONAME ; #<VT>#
+	_ZTVN4Roap16CLeaveDomainRespE @ 65 NONAME ; #<VT>#
+	_ZTVN4Roap16CRegistrationReqE @ 66 NONAME ; #<VT>#
+	_ZTVN4Roap16CRoapHttpHandlerE @ 67 NONAME ; #<VT>#
+	_ZTVN4Roap17CRegistrationRespE @ 68 NONAME ; #<VT>#
+	_ZTVN4Roap17TRightsRespParserE @ 69 NONAME ; #<VT>#
+	_ZTVN4Roap18TRoapTriggerParserE @ 70 NONAME ; #<VT>#
+	_ZTVN4Roap21TJoinDomainRespParserE @ 71 NONAME ; #<VT>#
+	_ZTVN4Roap22TLeaveDomainRespParserE @ 72 NONAME ; #<VT>#
+	_ZTVN4Roap23TRegistrationRespParserE @ 73 NONAME ; #<VT>#
+	_ZTVN4Roap8CRIHelloE @ 74 NONAME ; #<VT>#
+	_ZTVN4Roap8CRoapEngE @ 75 NONAME ; #<VT>#
+	_ZNK4Roap12CRoapEngBase7TriggerEv @ 76 NONAME
+	_ZN16CRoapSyncWrapper14HandleTriggerLERK6TDesC8 @ 77 NONAME
+	_ZN16CRoapSyncWrapper4NewLEv @ 78 NONAME
+	_ZN16CRoapSyncWrapperD0Ev @ 79 NONAME
+	_ZN16CRoapSyncWrapperD1Ev @ 80 NONAME
+	_ZN16CRoapSyncWrapperD2Ev @ 81 NONAME
+	_ZN16CRoapSyncWrapper22HandleTriggerSilentlyLERK6TDesC8 @ 82 NONAME
+	_ZN16CRoapSyncWrapper12GetErrorUrlLEiRi @ 83 NONAME
+	_ZTIN4Roap28CWbxmlRoapTriggerToXmlParserE @ 84 NONAME ; #<TI>#
+	_ZTVN4Roap28CWbxmlRoapTriggerToXmlParserE @ 85 NONAME ; #<VT>#
+	_ZN16CRoapSyncWrapper19GetPostResponseUrlLEv @ 86 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/CryptoPrep.flm	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,38 @@
+# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the License "Symbian Foundation License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: DRM Crypto Library build configuration
+#
+
+TMPROOT:=$(subst \,/,$(EPOCROOT))
+EPOCROOT:=$(patsubst %/,%,$(TMPROOT))/
+
+CREATABLEPATH:=$(EXTENSION_ROOT)/../drmengine/drmcrypto/build
+CLEANTARGETS:=$(CREATABLEPATH)/cmlacrypto.cpp $(CREATABLEPATH)/omacrypto.cpp
+
+crypto_files:=$(wildcard $(EXTENSION_ROOT)/../drmengine/drmcrypto/CMLA/*.cpp)
+
+BITMAP :: $(CREATABLEPATH)
+
+ifeq ($(crypto_files),)
+	$(GNUCP) $(CREATABLEPATH)/../stub/CmlaCryptoStub.cpp $(CREATABLEPATH)/cmlacrypto.cpp
+else
+	$(GNUCP) $(CREATABLEPATH)/../CMLA/CmlaCrypto.cpp $(CREATABLEPATH)/cmlacrypto.cpp
+endif
+	$(GNUCP) $(CREATABLEPATH)/../src/OmaCrypto.cpp $(CREATABLEPATH)/omacrypto.cpp
+
+# Create dirs
+$(call makepath,$(CREATABLEPATH))
+
+## Clean up
+$(eval $(call GenerateStandardCleanTarget,$(CLEANTARGETS)))
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/CryptoPrep.mak	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,53 @@
+# Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+# All rights reserved.
+# This component and the accompanying materials are made available
+# under the terms of the License "Symbian Foundation License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description: DRM Crypto Library build configuration
+#
+TMPROOT:=$(subst \,/,$(EPOCROOT))
+EPOCROOT:=$(patsubst %/,%,$(TMPROOT))/
+
+include $(EPOCROOT)epoc32/tools/shell/$(notdir $(basename $(SHELL))).mk
+
+crypto_files = $(wildcard ../DrmCrypto/CMLA/*.cpp)
+do_nothing:
+	
+
+#
+# The targets invoked by bld...
+#
+MAKMAKE :
+	$(call createdir,"../drmcrypto/build")
+ifeq ($(crypto_files),)
+	perl $(EPOCROOT)epoc32/tools/ecopyfile.pl ../DrmCrypto/stub/CmlaCryptoStub.cpp ../drmcrypto/build/cmlacrypto.cpp
+else
+	perl $(EPOCROOT)epoc32/tools/ecopyfile.pl ../DrmCrypto/CMLA/CmlaCrypto.cpp ../drmcrypto/build/cmlacrypto.cpp
+endif
+	perl $(EPOCROOT)epoc32/tools/ecopyfile.pl ../DrmCrypto/src/OmaCrypto.cpp ../drmcrypto/build/omacrypto.cpp
+BLD : MAKMAKE
+
+SAVESPACE : do_nothing
+
+CLEAN :
+	perl $(EPOCROOT)epoc32/tools/ermdir.pl ../drmcrypto/build/omacrypto.cpp
+	perl $(EPOCROOT)epoc32/tools/ermdir.pl ../drmcrypto/build/cmlacrypto.cpp
+
+FREEZE : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : do_nothing
+
+FINAL : do_nothing
+
+RELEASABLES : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/CryptoPrep.xml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<build xmlns="http://symbian.com/xml/build" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symbian.com/xml/build ../../schema/build/2_0.xsd">
+    <interface name="s60.cryptoprep" extends="Symbian.UserFLM" flm="CryptoPrep.flm">
+    <param name='GNUCP' default="" />
+    </interface>
+</build>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DRMCommon.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,74 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client side API build configuration
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DRMCommon.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x101F51F3
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+MACRO           CLIENT_STARTS_SERVER
+
+USERINCLUDE     ../AgentV2/inc
+USERINCLUDE     ../RO/inc
+USERINCLUDE     ../DCF/inc
+USERINCLUDE     ../Server/inc
+USERINCLUDE     ../Utils/inc
+USERINCLUDE     ../legacy/inc
+USERINCLUDE     ../legacy/src
+USERINCLUDE	    ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/caf
+SYSTEMINCLUDE   /epoc32/include/libc
+
+SOURCEPATH      ../legacy/src
+SOURCE          DRMCommon.cpp
+
+START RESOURCE DRMCommon.rss
+HEADER
+TARGET          DRMCommon.rsc
+TARGETPATH      resource 
+
+END
+
+LIBRARY         drmdcf.lib
+LIBRARY         drmrights.lib
+LIBRARY         drmserverinterfaces.lib
+LIBRARY         euser.lib efsrv.lib charconv.lib
+LIBRARY         apmime.lib bafl.lib estor.lib InetProtUtil.lib
+LIBRARY         caf.lib
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY         platformenv.lib
+#endif
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DRM_BAT.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client side API Basic Acceptance Test tool
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET        DRM_BAT.exe
+TARGETTYPE    exe
+MACRO         CLIENT_STARTS_SERVER
+CAPABILITY    CAP_APPLICATION DRM
+VENDORID      VID_DEFAULT
+
+
+USERINCLUDE     ../agentv2/inc
+USERINCLUDE     ../dcf/inc
+USERINCLUDE     ../dm/inc
+USERINCLUDE     ../server/inc
+USERINCLUDE     ../roap/inc
+USERINCLUDE     ../ro/inc
+USERINCLUDE     ../legacy/inc
+USERINCLUDE     ../tsrc
+USERINCLUDE     ../utils/inc
+USERINCLUDE	    ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE /epoc32/include/libc
+SYSTEMINCLUDE /epoc32/include/ecom
+SYSTEMINCLUDE /epoc32/include/caf
+ 
+SOURCEPATH    ../tsrc
+SOURCE        DRM_BAT.cpp
+SOURCE        RTest.cpp
+
+LIBRARY         DrmParsers.lib
+LIBRARY         DrmDcf.lib
+LIBRARY         DrmRights.lib
+LIBRARY         DrmServerInterfaces.lib
+LIBRARY         DRMCommon.lib
+LIBRARY       efsrv.lib euser.lib apmime.lib XmlFramework.lib
+LIBRARY       estor.lib bafl.lib
+LIBRARY       caf.lib cafutils.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DcfRep.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client side implementation
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DcfRep.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x10205CA9
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+
+//macro _DRM_TESTING
+
+SOURCEPATH      ../DcfRepository/client/src
+SOURCE          DcfRepCli.cpp
+SOURCE          DcfRep.cpp
+SOURCE          DcfEntry.cpp
+
+
+USERINCLUDE     ../DcfRepository/client/inc
+USERINCLUDE     ../DcfRepository/common
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib //RFile
+LIBRARY         estor.lib // for RDbColReadStream
+LIBRARY         edbms.lib //database
+LIBRARY         DrmServerInterfaces.lib // RDRMRightsClient
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY       platformenv.lib
+#endif
+
+
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DcfRepSrv.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,63 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Server side implementation
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DcfRepSrv.exe
+TARGETTYPE      EXE
+
+UID             0x1000008d 0x10205CA8
+CAPABILITY      CAP_SERVER ALLFILES PowerMgmt
+VENDORID        VID_DEFAULT
+
+//macro _DRM_TESTING
+
+SOURCEPATH      ../DcfRepository/server/src
+SOURCE          DcfRepSrv.cpp
+SOURCE          DcfRepSrvSes.cpp
+SOURCE          FileScan.cpp
+SOURCE          Pair.cpp
+SOURCE          SearchLeaf.cpp
+
+SOURCEPATH      ../utils/src
+SOURCE          procwatcher.cpp
+
+
+USERINCLUDE     ../DcfRepository/server/inc
+USERINCLUDE     ../DcfRepository/common
+USERINCLUDE     ../utils/inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         caf.lib //caf
+LIBRARY         euser.lib
+LIBRARY         estor.lib
+LIBRARY         efsrv.lib
+LIBRARY         edbms.lib //database
+LIBRARY         drmdcf.lib // Oma2Dcf
+LIBRARY         cafutils.lib
+LIBRARY         flogger.lib // debug logging
+LIBRARY         StarterClient.lib // shutdown
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY         platformenv.lib
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmCrypto.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,68 @@
+/*
+* Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRM Crypto Library build configuration, CMLA stubs only
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DrmCrypto.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x101F6DB9
+CAPABILITY      CAP_GENERAL_DLL DRM CommDD
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../Utils/inc
+USERINCLUDE     ../DrmCrypto/inc
+USERINCLUDE     ../KeyStorage/inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+SOURCEPATH      ../Utils/src
+SOURCE          Base64.cpp
+
+SOURCE          DrmAesCrypto.cpp
+
+SOURCEPATH      ../DrmCrypto/build
+SOURCE          OmaCrypto.cpp
+SOURCE          CmlaCrypto.cpp
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         asn1.lib
+LIBRARY         cryptography.lib
+LIBRARY         crypto.lib
+LIBRARY         x509.lib
+LIBRARY         pkixcert.lib
+LIBRARY         random.lib
+LIBRARY         hash.lib
+LIBRARY         flogger.lib
+LIBRARY         DrmKeyStorage.lib
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmDcf.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DCF file handling component build configuration
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DrmDcf.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x10205CAC
+CAPABILITY      CAP_GENERAL_DLL DRM CommDD
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../DCF/inc
+USERINCLUDE     ../RO/inc
+USERINCLUDE     ../ROAP/inc
+USERINCLUDE     ../Utils/inc
+USERINCLUDE     ../DM/inc
+USERINCLUDE     ../Legacy/inc
+USERINCLUDE     ../AgentV2/inc
+USERINCLUDE     ../Server/inc
+USERINCLUDE     ../Notifier/inc
+USERINCLUDE     ../RoapStorage/inc
+USERINCLUDE	    ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../DCF/src
+SOURCE          DcfCommon.cpp
+SOURCE          Oma1Dcf.cpp
+SOURCE          Oma2Dcf.cpp
+SOURCE          Oma2DcfPartInfo.cpp
+
+LIBRARY		    drmcrypto.lib
+LIBRARY         euser.lib XmlFramework.lib hash.lib
+LIBRARY         estor.lib efsrv.lib apmime.lib InetProtUtil.lib bnf.lib
+LIBRARY         cryptography.lib random.lib bafl.lib charconv.lib
+LIBRARY         centralrepository.lib
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmKeyStorage.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,61 @@
+/*
+* Copyright (c) 2004-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:  DRM Key Storage Module
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DrmKeyStorage.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x10205CAA
+CAPABILITY      CAP_GENERAL_DLL DRM CommDD
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../KeyStorage/inc
+USERINCLUDE     ../Utils/inc
+USERINCLUDE	    ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+SOURCEPATH      ../KeyStorage/src
+SOURCE          DrmKeyStorage.cpp
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib    
+LIBRARY         asn1.lib
+LIBRARY         cryptography.lib 
+LIBRARY         crypto.lib 
+LIBRARY         x500.lib
+LIBRARY         x509.lib
+LIBRARY         pkixcert.lib
+LIBRARY         random.lib
+LIBRARY         hash.lib
+LIBRARY         flogger.lib
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmParsers.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRM parsers t build configuration
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DrmParsers.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x10205CAD
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../DCF/inc
+USERINCLUDE     ../RO/inc
+USERINCLUDE     ../ROAP/inc
+USERINCLUDE     ../Utils/inc
+USERINCLUDE     ../DM/inc
+USERINCLUDE     ../Legacy/inc
+USERINCLUDE     ../AgentV2/inc
+USERINCLUDE     ../Server/inc
+USERINCLUDE     ../Notifier/inc
+USERINCLUDE     ../RoapStorage/inc
+USERINCLUDE     ../DcfRepository/client/inc
+USERINCLUDE     ../KeyStorage/inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/caf
+
+SOURCEPATH      ../DM/src
+SOURCE          Oma1DcfCreator.cpp
+SOURCE          DRMMessageParser.cpp
+SOURCE          b64.cpp
+
+SOURCEPATH      ../RO/src
+SOURCE          DrmRightsParser.cpp
+SOURCE          DrmProtectedRoParser.cpp
+
+LIBRARY         drmcrypto.lib drmserverinterfaces.lib drmrights.lib dcfrep.lib
+LIBRARY         drmdcf.lib euser.lib XmlFramework.lib hash.lib
+LIBRARY         estor.lib efsrv.lib apmime.lib InetProtUtil.lib bnf.lib
+LIBRARY         cryptography.lib bafl.lib charconv.lib drmkeystorage.lib
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY       platformenv.lib
+#endif
+
+LIBRARY    flogger.lib
+
+#if defined( ARMCC )
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmRel1_0StringDict00.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRM parser strings
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET         DrmRel1_0StringDict00.dll
+TARGETTYPE     PLUGIN
+CAPABILITY     CAP_ECOM_PLUGIN DRM
+VENDORID       VID_DEFAULT
+
+// ECom Plugin Dll UID followed by the unique UID for this dll
+// Assigned to UID2 and UID3 respectively
+
+UID             0x10009D8D 0x101F6DB6
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../RO/inc
+USERINCLUDE	    ../../../inc   // ADo level inc dir
+
+SOURCEPATH     ../RO/src
+SOURCE         DrmRel1_0StringDict00TagTable.cpp 
+SOURCE         DrmRel1_0StringDict00AttributeTable.cpp 
+SOURCE         DrmRel1_0StringDict00AttributeValueTable.cpp 
+SOURCE         DrmRel1_0StringDict00.cpp
+
+START RESOURCE 101F6DB6.RSS
+TARGET         DrmRel1_0StringDict00
+END
+
+LIBRARY        euser.lib
+LIBRARY        bafl.lib // for RStringPool
+LIBRARY        XmlFramework.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmRel1_0StringDict00AttributeTable.mak	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,37 @@
+BUILD_DIR=$(EPOCROOT)epoc32\build\generated\Xml
+GENERATED_FILES= \
+	$(BUILD_DIR)\DrmRel1_0StringDict00AttributeTable.cpp
+SOURCE_DIR=..\RO\src\
+
+$(BUILD_DIR)\DrmRel1_0StringDict00AttributeTable.cpp : $(SOURCE_DIR)\DrmRel1_0StringDict00AttributeTable.st
+	perl -S emkdir.pl $(BUILD_DIR)
+	perl -S ecopyfile.pl $(SOURCE_DIR)\DrmRel1_0StringDict00AttributeTable.st $(BUILD_DIR)\DrmRel1_0StringDict00AttributeTable.st
+	perl -S stringtable.pl $(BUILD_DIR)\DrmRel1_0StringDict00AttributeTable.st
+
+do_nothing:
+	@rem do nothing
+
+#
+# The targets invoked by bld...
+#
+
+MAKMAKE : $(GENERATED_FILES)
+
+BLD : MAKMAKE
+
+SAVESPACE : MAKMAKE
+
+CLEAN : 
+	perl -S ermdir.pl $(BUILD_DIR)
+
+FREEZE : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : do_nothing
+
+FINAL : do_nothing
+
+RELEASABLES : $(GENERATED_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmRel1_0StringDict00AttributeValueTable.mak	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,37 @@
+BUILD_DIR=$(EPOCROOT)epoc32\build\generated\Xml
+GENERATED_FILES= \
+	$(BUILD_DIR)\DrmRel1_0StringDict00AttributeValueTable.cpp
+SOURCE_DIR=..\RO\src\
+
+$(BUILD_DIR)\DrmRel1_0StringDict00AttributeValueTable.cpp : $(SOURCE_DIR)\DrmRel1_0StringDict00AttributeValueTable.st
+	perl -S emkdir.pl $(BUILD_DIR)
+	perl -S ecopyfile.pl $(SOURCE_DIR)\DrmRel1_0StringDict00AttributeValueTable.st $(BUILD_DIR)\DrmRel1_0StringDict00AttributeValueTable.st
+	perl -S stringtable.pl $(BUILD_DIR)\DrmRel1_0StringDict00AttributeValueTable.st
+
+do_nothing:
+	@rem do nothing
+
+#
+# The targets invoked by bld...
+#
+
+MAKMAKE : $(GENERATED_FILES)
+
+BLD : MAKMAKE
+
+SAVESPACE : MAKMAKE
+
+CLEAN : 
+	perl -S ermdir.pl $(BUILD_DIR)
+
+FREEZE : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : do_nothing
+
+FINAL : do_nothing
+
+RELEASABLES : $(GENERATED_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmRel1_0StringDict00TagTable.mak	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,37 @@
+BUILD_DIR=$(EPOCROOT)epoc32\build\generated\Xml
+GENERATED_FILES= \
+	$(BUILD_DIR)\DrmRel1_0StringDict00TagTable.cpp
+SOURCE_DIR=..\RO\src\
+
+$(BUILD_DIR)\DrmRel1_0StringDict00TagTable.cpp : $(SOURCE_DIR)\DrmRel1_0StringDict00TagTable.st
+	perl -S emkdir.pl $(BUILD_DIR)
+	perl -S ecopyfile.pl $(SOURCE_DIR)\DrmRel1_0StringDict00TagTable.st $(BUILD_DIR)\DrmRel1_0StringDict00TagTable.st
+	perl -S stringtable.pl $(BUILD_DIR)\DrmRel1_0StringDict00TagTable.st
+
+do_nothing:
+	@rem do nothing
+
+#
+# The targets invoked by bld...
+#
+
+MAKMAKE : $(GENERATED_FILES)
+
+BLD : MAKMAKE
+
+SAVESPACE : MAKMAKE
+
+CLEAN : 
+	perl -S ermdir.pl $(BUILD_DIR)
+
+FREEZE : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : do_nothing
+
+FINAL : do_nothing
+
+RELEASABLES : $(GENERATED_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmRel2_1StringDict00.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for Oma Drm 2.1 String Dictionary
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET        DrmRel2_1StringDict00.dll
+TARGETTYPE    PLUGIN
+UID           0x10009D8D 0x2000B48A
+
+CAPABILITY    ALL -TCB
+VENDORID      VID_DEFAULT
+
+SOURCEPATH    ../utils/src           
+SOURCE        DrmRel2_1StringDict00.cpp
+SOURCE        DrmRel2_1StringDict00TagTable.cpp
+SOURCE        DrmRel2_1StringDict00AttributeTable.cpp
+SOURCE        DrmRel2_1StringDict00AttributeValueTable.cpp
+
+MW_LAYER_SYSTEMINCLUDE
+USERINCLUDE      ../utils/inc
+
+START RESOURCE    200B48A.rss
+TARGET            DrmRel2_1StringDict00
+END
+
+LIBRARY        euser.lib
+LIBRARY        bafl.lib // for RStringPool
+LIBRARY        xmlframework.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmRights.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,66 @@
+/*
+* 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:  Rights classes build configuration
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DrmRights.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x10205CAE
+CAPABILITY      CAP_GENERAL_DLL DRM CommDD
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../DCF/inc
+USERINCLUDE     ../RO/inc
+USERINCLUDE     ../ROAP/inc
+USERINCLUDE     ../Utils/inc
+USERINCLUDE     ../DM/inc
+USERINCLUDE     ../Legacy/inc
+USERINCLUDE     ../AgentV2/inc
+USERINCLUDE     ../Server/inc
+USERINCLUDE     ../Notifier/inc
+USERINCLUDE     ../RoapStorage/inc
+USERINCLUDE	    ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/caf
+
+SOURCEPATH      ../RO/src
+SOURCE          DrmRights.cpp
+SOURCE	        DrmPermission.cpp
+SOURCE          DrmConstraint.cpp
+SOURCE          DrmAsset.cpp
+
+LIBRARY		    drmcrypto.lib
+LIBRARY         euser.lib XmlFramework.lib hash.lib
+LIBRARY         estor.lib efsrv.lib apmime.lib InetProtUtil.lib bnf.lib
+LIBRARY         cryptography.lib random.lib bafl.lib charconv.lib
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmServerInterfaces.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,90 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Server interfaces build configuration
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DrmServerInterfaces.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x101F6DB5
+CAPABILITY      CAP_GENERAL_DLL DRM CommDD
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../DCF/inc
+USERINCLUDE     ../RO/inc
+USERINCLUDE     ../ROAP/inc
+USERINCLUDE     ../Utils/inc
+USERINCLUDE     ../DM/inc
+USERINCLUDE     ../Legacy/inc
+USERINCLUDE     ../AgentV2/inc
+USERINCLUDE     ../Server/inc
+USERINCLUDE     ../Notifier/inc
+USERINCLUDE     ../RoapStorage/inc
+USERINCLUDE     ../DrmClock/inc
+#ifdef __DRM_FULL
+USERINCLUDE		../../DRMHelper/inc
+#endif
+USERINCLUDE	    ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/ecom
+SYSTEMINCLUDE   /epoc32/include/caf
+
+SOURCEPATH      ../Server/src
+SOURCE          DRMRightsClient.cpp
+
+SOURCEPATH      ../Notifier/src
+SOURCE          DRMEvent.cpp
+SOURCE          DRMEventAddRemove.cpp
+SOURCE          DRMEventModify.cpp
+SOURCE		    DRMEventTimeChange.cpp
+SOURCE          DRMNotifier.cpp
+SOURCE          DRMEventHandler.cpp
+SOURCE          DRMNotifierClient.cpp
+
+SOURCEPATH      ../RoapStorage/src
+SOURCE          DrmDomainContext.cpp
+SOURCE          DrmRiContext.cpp
+SOURCE          RoapStorageClient.cpp
+
+SOURCEPATH      ../DRMClock/src
+SOURCE          DRMClockClient2.cpp
+
+#ifdef __DRM_FULL
+SOURCEPATH			../../DRMHelper/src
+SOURCE					RDRMHelper.cpp
+#endif
+
+LIBRARY         x509.lib asn1.lib ecom.lib x500.lib crypto.lib
+LIBRARY		    drmcrypto.lib drmrights.lib flogger.lib
+LIBRARY         euser.lib XmlFramework.lib hash.lib
+LIBRARY         estor.lib efsrv.lib apmime.lib InetProtUtil.lib bnf.lib
+LIBRARY         cryptography.lib random.lib bafl.lib charconv.lib
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmServiceAPI.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,48 @@
+/*
+* 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:  Services needed to be exposed as a Domain API
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DrmServiceAPI.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x10282CB1
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+USERINCLUDE	    ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../drmserviceapi/src
+SOURCE          drmserviceapi.cpp
+
+LIBRARY         drmserverinterfaces.lib
+LIBRARY         euser.lib
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/DrmStdKeyStorage.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2004-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:  DRM Std Key Storage Module
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DrmStdKeyStorage.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x10205CAF
+CAPABILITY      CAP_GENERAL_DLL DRM CommDD
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../KeyStorage/inc
+USERINCLUDE     ../Utils/inc
+USERINCLUDE	    ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+SOURCEPATH      ../KeyStorage/src
+SOURCE          DrmStdKeyStorage.cpp
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib    
+LIBRARY         asn1.lib
+LIBRARY         cryptography.lib 
+LIBRARY         crypto.lib 
+LIBRARY         x500.lib
+LIBRARY         x509.lib
+LIBRARY         pkixcert.lib
+LIBRARY         random.lib
+LIBRARY         hash.lib
+LIBRARY         etel.lib
+LIBRARY	        etelmm.lib
+LIBRARY         flogger.lib
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY       platformenv.lib
+#endif
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/OmaDrmAgent.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OMA DRM agent build configuration
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          OmaDrmAgent.dll
+TARGETTYPE      PLUGIN
+UID             0x10009D8D 0x101F6DB4
+CAPABILITY      CAP_ECOM_PLUGIN DRM
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../DCF/inc
+USERINCLUDE     ../RO/inc
+USERINCLUDE     ../DM/inc
+USERINCLUDE     ../AgentV2/inc
+USERINCLUDE     ../Server/inc
+USERINCLUDE     ../Utils/inc
+USERINCLUDE     ../Notifier/inc
+USERINCLUDE     ../DcfRepository/client/inc
+USERINCLUDE	    ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE  	/epoc32/include/ecom
+
+SOURCEPATH      ../AgentV2/src
+SOURCE          Oma2Agent.cpp
+SOURCE          Oma2AgentFactory.cpp
+SOURCE          Oma2AgentContent.cpp
+SOURCE          Oma2AgentData.cpp
+SOURCE          Oma2AgentManager.cpp
+SOURCE          Oma2AgentAttributes.cpp
+SOURCE          Oma2AgentImportFile.cpp
+SOURCE          Oma2AgentRightsManager.cpp
+SOURCE          DcfCache.cpp
+
+START RESOURCE 101F6DB4.RSS
+TARGET         OmaDrmAgent
+END
+
+LIBRARY	        euser.lib 
+LIBRARY         drmparsers.lib
+LIBRARY         drmdcf.lib
+LIBRARY         drmrights.lib
+LIBRARY         drmserverinterfaces.lib
+LIBRARY         caf.lib
+LIBRARY         cafutils.lib
+LIBRARY         efsrv.lib
+LIBRARY         estor.lib
+LIBRARY         apmime.lib
+LIBRARY         cryptography.lib
+LIBRARY         random.lib
+LIBRARY         bafl.lib
+LIBRARY         charconv.lib
+LIBRARY         http.lib
+LIBRARY         ecom.lib
+LIBRARY         dcfrep.lib
+LIBRARY         avkon.lib
+LIBRARY			apparc.lib
+LIBRARY         aknnotify.lib
+LIBRARY         apgrfx.lib
+LIBRARY			ws32.lib
+LIBRARY			sysutil.lib
+LIBRARY         centralrepository.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/ROAPHandler.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,140 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ROAP Handler build configuration
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          ROAPHandler.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x101F6DB5
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../DCF/inc
+USERINCLUDE     ../DM/inc
+USERINCLUDE     ../AgentV2/inc
+USERINCLUDE     ../RO/inc
+USERINCLUDE     ../ROAP/inc
+USERINCLUDE     ../Utils/inc
+USERINCLUDE     ../Server/inc
+USERINCLUDE     ../RoapStorage/inc
+USERINCLUDE     ../DRMClock/inc
+USERINCLUDE     ../DcfRepository/client/inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+SOURCEPATH  ../roap/src
+
+SOURCE      RoapEngBase.cpp
+SOURCE      RoapEng.cpp
+SOURCE      RoapTrigger.cpp
+SOURCE      RoapHttpHandler.cpp
+SOURCE      RoapConnection.cpp
+SOURCE      RoapResponse.cpp
+SOURCE      RoapSyncWrapper.cpp
+
+SOURCE      RoapSigner.cpp
+
+SOURCE      RoapParser.cpp
+SOURCE      JoinDomainRespParser.cpp
+SOURCE      LeaveDomainRespParser.cpp
+SOURCE      RegistrationRespParser.cpp
+SOURCE      RightsRespParser.cpp
+SOURCE      RIHelloParser.cpp
+SOURCE      RoapTriggerParser.cpp
+
+SOURCE      RoapMessage.cpp
+SOURCE      DeviceHello.cpp
+SOURCE      RIHello.cpp
+SOURCE      RegistrationReq.cpp
+SOURCE      RegistrationResp.cpp
+SOURCE      RightsReq.cpp
+SOURCE      RightsResp.cpp
+SOURCE      JoinDomainReq.cpp
+SOURCE      JoinDomainResp.cpp
+SOURCE      LeaveDomainReq.cpp
+SOURCE      LeaveDomainResp.cpp
+
+#ifdef RD_DRM_METERING
+SOURCE      MeteringReportReq.cpp
+SOURCE      MeteringReportResp.cpp
+SOURCE      MeteringReportRespParser.cpp
+#endif
+
+SOURCEPATH  ../Utils/src
+SOURCE      MultipartHandler.cpp
+
+LIBRARY     euser.lib
+LIBRARY     estor.lib
+LIBRARY     efsrv.lib
+LIBRARY     commdb.lib
+LIBRARY     bafl.lib
+LIBRARY     esock.lib
+LIBRARY     http.lib
+LIBRARY     inetprotutil.lib
+LIBRARY     XmlFramework.lib
+LIBRARY     apmime.lib
+LIBRARY     asn1.lib
+LIBRARY     cryptography.lib
+LIBRARY     crypto.lib
+LIBRARY     ecom.lib
+LIBRARY     x509.lib
+LIBRARY     x500.lib
+LIBRARY     pkixcert.lib
+LIBRARY     random.lib
+LIBRARY     hash.lib
+LIBRARY     etel.lib
+LIBRARY     etelmm.lib
+LIBRARY     CharConv.lib
+LIBRARY     drmcrypto.lib
+LIBRARY     DrmParsers.lib
+LIBRARY     DrmDcf.lib
+LIBRARY     DrmRights.lib
+LIBRARY     DrmServerInterfaces.lib
+LIBRARY     DcfRep.lib
+LIBRARY     caf.lib                     // Embedding domain ROs
+LIBRARY     cafutils.lib                // Embedding domain ROs
+LIBRARY     centralrepository.lib       // Browser default AP
+LIBRARY     cmmanager.lib
+
+LIBRARY     SysUtil.lib
+LIBRARY     HttpFilterCommon.lib
+LIBRARY     CommonUI.lib
+LIBRARY     PlatformEnv.lib
+LIBRARY     drmroapwbxmlparser.lib
+
+
+// Uncomment the following lines to enable internal logging.
+macro      _ROAP_TESTING
+LIBRARY    flogger.lib
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/RightsServer.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,182 @@
+/*
+* Copyright (c) 2003-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:  Makefile of DRM Engine & DRM Rights Database
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          RightsServer.exe
+TARGETTYPE      EXE
+
+UID             0x1000008d 0x101F51F2
+CAPABILITY      CAP_SERVER DRM CommDD ProtServ PowerMgmt
+VENDORID        VID_DEFAULT
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/connect
+
+USERINCLUDE     ../Server/inc
+USERINCLUDE     ../AgentV2/inc
+USERINCLUDE     ../RO/inc
+USERINCLUDE     ../DCF/inc
+USERINCLUDE     ../Notifier/inc
+USERINCLUDE     ../Utils/inc
+USERINCLUDE     ../ROAP/inc
+USERINCLUDE     ../RoapStorage/inc
+USERINCLUDE     ../DRMClock/inc
+USERINCLUDE     ../KeyStorage/inc
+USERINCLUDE     ../DRMBackup/inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+SOURCEPATH      ../Server/src
+
+// DRM Engine (server side)
+SOURCE          DRMRightsServer.cpp
+SOURCE          DRMDbSession.cpp
+// SOURCE       drmpermissionlist.cpp
+SOURCE          drmparentstorage.cpp
+// SOURCE       drmpermissionitem.cpp
+SOURCE          drmreplaycache.cpp
+SOURCE          drmxoma.cpp
+SOURCE          DRMActiveOperation.cpp
+SOURCE          DRMObsoleteFinder.cpp
+SOURCE          drmconsume.cpp
+
+// DRM Rights Database
+SOURCE          DRMRightsDB.cpp
+SOURCE          DRMRightsData.cpp
+SOURCE          DRMCommonData.cpp
+SOURCE          DRMRightsCleaner.cpp
+
+// DRM Metering
+#ifdef RD_DRM_METERING
+SOURCE          drmmeteringdbdata.cpp
+#endif
+SOURCE          drmmeteringdb.cpp
+
+// DRM Backup implementation
+SOURCEPATH      ../DRMBackup/src
+SOURCE          DRMBackup.cpp
+SOURCE          DRMBackupObserver.cpp
+
+// DRM Notifier
+SOURCEPATH      ../Notifier/src
+
+SOURCE          DRMMessageStorage.cpp
+SOURCE          DRMNotifierServer.cpp
+SOURCE          DRMNotifierSession.cpp
+
+// RoapStorage
+SOURCEPATH      ../RoapStorage/src
+
+SOURCE          RoapStorageClient.cpp
+SOURCE          RoapStorageServer.cpp
+SOURCE          RoapStorageSession.cpp
+SOURCE          DRMContextDB.cpp
+// OCSP cert classes
+SOURCE          responsedecoder.cpp
+SOURCE          response.cpp
+SOURCE          responsecertinfo.cpp
+SOURCE          certid.cpp
+
+
+// DRM Clock
+#ifdef __DRM_CLOCK
+SOURCEPATH      ../DRMClock/src
+SOURCE          DRMClock.cpp
+SOURCE          DRMClockServer.cpp
+SOURCE          DRMClockSession.cpp
+
+SOURCE          DRMNitzObserver.cpp
+#else
+#ifdef __DRM_OMA2
+SOURCEPATH      ../DRMClock/src
+SOURCE          OMA2NotSupportedWithoutDRMClock:define__DRM_CLOCKvariation.cpp
+#endif // __DRM_OMA2
+#endif // __DRM_CLOCK
+
+// RDB and Process Watcher
+SOURCEPATH      ../utils/src
+SOURCE          dbwatcher.cpp
+SOURCE          dirwatcher.cpp
+SOURCE          procwatcher.cpp
+
+LIBRARY         drmdcf.lib
+LIBRARY         drmrights.lib
+LIBRARY         drmserverinterfaces.lib
+LIBRARY         euser.lib
+LIBRARY         estor.lib
+LIBRARY         efsrv.lib
+LIBRARY         hash.lib
+LIBRARY         cryptography.lib
+LIBRARY         crypto.lib
+LIBRARY         asn1.lib
+LIBRARY         x509.lib
+LIBRARY         x500.lib
+LIBRARY         pkixcert.lib
+LIBRARY         drmcrypto.lib
+LIBRARY         drmkeystorage.lib
+LIBRARY         edbms.lib
+LIBRARY         bafl.lib
+LIBRARY         etel.lib
+LIBRARY         etelmm.lib
+LIBRARY         abclient.lib
+LIBRARY         charconv.lib
+LIBRARY         dcfrep.lib
+LIBRARY         drmparsers.lib              // DRM message parser for RO import
+LIBRARY         centralrepository.lib       // Browser default AP
+LIBRARY         InetProtUtil.lib            // URI parser
+LIBRARY         flogger.lib
+LIBRARY         featmgr.lib                 // Feature Manager
+LIBRARY         wmdrmfileserverclient.lib
+#ifdef RD_DRM_METERING
+LIBRARY         random.lib
+#endif
+
+LIBRARY StarterClient.lib // reset
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY         platformenv.lib
+#endif
+
+LIBRARY         SysUtil.lib
+// LIBRARY      commonengine.lib // Backup
+
+/*
+#if !defined(WINS)
+MACRO           DRM_USE_SERIALNUMBER
+LIBRARY         etel.lib
+#endif
+*/
+// Uncomment the following lines to enable internal logging.
+/*
+macro _DRM_TESTING
+USERINCLUDE     ../internal/tsrc_internal
+SOURCEPATH      ../internal/tsrc_internal
+LIBRARY         drmdebugtools.lib
+LIBRARY         HAL.lib
+LIBRARY         charconv.lib
+*/
+
+#if defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#endif
+
+//SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/group/backup_registration.xml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,7 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+    <active_backup process_name = "RIGHTSSERVER"
+                   supports_incremental = "no"
+			 requires_delay_to_prepare_data = "yes">
+    </active_backup>
+</backup_registration>
Binary file omadrm/drmengine/keystorage/data/CM/DeviceCert.der has changed
Binary file omadrm/drmengine/keystorage/data/CM/DevicePrivateKey.der has changed
Binary file omadrm/drmengine/keystorage/data/CM/SigningCert00.der has changed
Binary file omadrm/drmengine/keystorage/data/CM/SigningCert01.der has changed
Binary file omadrm/drmengine/keystorage/data/CMLA/DeviceCert.der has changed
Binary file omadrm/drmengine/keystorage/data/CMLA/DevicePrivateKey.der has changed
Binary file omadrm/drmengine/keystorage/data/CMLA/SigningCert00.der has changed
Binary file omadrm/drmengine/keystorage/data/CMLA/SigningCert01.der has changed
Binary file omadrm/drmengine/keystorage/data/DeviceCert.der has changed
Binary file omadrm/drmengine/keystorage/data/DevicePrivateKey.der has changed
Binary file omadrm/drmengine/keystorage/data/SigningCert00.der has changed
Binary file omadrm/drmengine/keystorage/data/SigningCert01.der has changed
Binary file omadrm/drmengine/keystorage/data/UdtCertificate.der has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/keystorage/inc/DrmStdKeyStorage.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef DRMSTDKEYSTORAGE_H
+#define DRMSTDKEYSTORAGE_H
+
+// FORWARD DECLARATIONS
+
+class CRSAPrivateKeyStandard;
+
+// CLASS DECLARATION
+
+/**
+*  CDrmKeyStorage: Contains key storage for OMA DRM 2.0
+*
+*  @lib    -
+*  @since  3.0
+*/
+NONSHARABLE_CLASS(CDrmStdKeyStorage): public MDrmKeyStorage, public CBase
+    {
+public: // New functions
+
+    IMPORT_C static CDrmStdKeyStorage* NewL(RLibrary aLibrary);
+    
+    virtual ~CDrmStdKeyStorage();
+    
+public: // From MDrmKeyStorage
+
+    TInt ModulusSize();
+
+    void SelectTrustedRootL(
+        const TDesC8& aRootKeyHash);
+        
+    void SelectDefaultRootL();
+        
+    TBool SelectedRootIsCmla();
+        
+    void GetTrustedRootsL(
+        RPointerArray<HBufC8>& aRootList);
+        
+    void GetCertificateChainL(
+        RPointerArray<HBufC8>& aCertChain);
+        
+    HBufC8* RsaSignL(
+        const TDesC8& aInput);
+    
+    HBufC8* RsaDecryptL(
+        const TDesC8& aInput);
+        
+    void ImportDataL(
+        const TDesC8& aPrivateKey,
+        const RArray<TPtrC8>& aCertificateChain);
+        
+    void GetDeviceSpecificKeyL(
+        TBuf8<KDeviceSpecificKeyLength>& aKey);
+
+    void GetRdbSerialNumberL(
+    	TBuf8<KRdbSerialNumberLength>& aSerialNumber);
+    	
+	void GenerateNewRdbSerialNumberL();
+	
+	HBufC8* UdtEncryptL(
+	    const TDesC8& aInput);
+	    
+    void GetRootCertificatesL(
+        RPointerArray<HBufC8>& aRootCerts);
+     
+    void RandomDataGetL( 
+        TDes8& aData, 
+        const TInt aLength ); 
+    	
+protected: // New functions
+
+    void ConstructL();
+    
+    CDrmStdKeyStorage(RLibrary aLibrary);
+    
+    HBufC8* ModularExponentiateWithKeyL(
+        const TDesC8& aInput);
+        
+    void InitializeKeyL();
+    
+    void CheckRootForCmlaL();
+    
+    const TDesC& GetImeiL();
+    
+protected: // Data
+
+    RFs iFs;
+    CFileMan* iFileMan;    
+    TBool iRootSelected;
+    TBool iRootIsCmla;
+    CRSAPrivateKeyStandard* iKey;
+    TBuf8<KDeviceSpecificKeyLength> iDeviceSpecificKey;
+    HBufC* iImei;
+    RLibrary iLibrary;
+
+    };
+
+#endif      // DRMSTDKEYSTORAGE_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/keystorage/src/DrmKeyStorage.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,87 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OMA DRM 2.0 Key Storage
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <asymmetric.h>
+#include <symmetric.h>
+#include <hash.h>
+#include <asn1dec.h>
+#include <x509cert.h>
+#include "DrmKeyStorage.h"
+
+#ifdef _DEBUG
+#define LOGGING
+#endif
+/*
+#ifdef LOGGING
+_LIT(KLogDir, "DRM");
+_LIT(KLogName, "KeyStorage.log");
+#include "flogger.h"
+#define LOG(string) \
+    RFileLogger::Write(KLogDir, KLogName, \
+        EFileLoggingModeAppend, string);
+#define LOGHEX(buffer) \
+    RFileLogger::HexDump(KLogDir, KLogName, \
+        EFileLoggingModeAppend, _S(""), _S(""), \
+        buffer.Ptr(), buffer.Length());
+#else
+#define LOG(string)
+#define LOGHEX(buffer)      
+#endif
+*/
+typedef MDrmKeyStorage*(*TStorageConstructor)(RLibrary);
+
+_LIT(KStdKeyStorageName, "drmstdkeystorage.dll");
+_LIT(KBb5KeyStorageName, "drmbb5keystorage.dll");
+static const TInt KConstructorOrdinal = 1;
+
+// -----------------------------------------------------------------------------
+// MDrmKeyStorage::
+// 
+// -----------------------------------------------------------------------------
+//
+MDrmKeyStorage::~MDrmKeyStorage()
+    {
+    }
+
+EXPORT_C MDrmKeyStorage* DrmKeyStorageNewL()
+    {
+    RLibrary library;
+    MDrmKeyStorage* storage;
+    TInt r;
+    TStorageConstructor constructor;
+    
+    r = library.Load(KBb5KeyStorageName);
+    if (r != KErrNone)
+        {
+        r = library.Load(KStdKeyStorageName);
+        }
+    User::LeaveIfError(r);
+    constructor = reinterpret_cast<TStorageConstructor>(
+        library.Lookup(KConstructorOrdinal));
+    if (constructor == NULL)
+        {
+        User::Leave(KErrNotFound);
+        }
+    storage = reinterpret_cast<MDrmKeyStorage*>(constructor(library));
+    return storage;
+    }
+
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/keystorage/src/DrmStdKeyStorage.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1178 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OMA DRM 2.0 Key Storage
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <asymmetric.h>
+#include <symmetric.h>
+#include <hash.h>
+#include <asn1dec.h>
+#include <x509cert.h>
+#include <etelmm.h>
+#include <mmtsy_names.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "DrmKeyStorage.h"
+#include "DrmStdKeyStorage.h"
+
+#ifdef _DEBUG
+#define LOGGING
+#endif
+
+#ifdef LOGGING
+_LIT(KLogDir, "DRM");
+_LIT(KLogName, "KeyStorage.log");
+#include "flogger.h"
+#define LOG(string) \
+    RFileLogger::Write(KLogDir, KLogName, \
+        EFileLoggingModeAppend, string);
+#define LOGHEX(buffer) \
+    RFileLogger::HexDump(KLogDir, KLogName, \
+        EFileLoggingModeAppend, _S(""), _S(""), \
+        buffer.Ptr(), buffer.Length());
+#else
+#define LOG(string)
+#define LOGHEX(buffer)       
+#endif
+
+#pragma message("Compiling DRM Std KeyStorage..")
+
+
+// LOCAL CONSTANTS AND MACROS
+
+const TInt KKeyLength = 128;
+const TInt KWaitingTime = 2000000; // 2 sec
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT(KKeyStoragePath, "%c:\\private\\101F51F2\\PKI\\");
+_LIT(KRomKeyStoragePath, "%c:\\private\\101F51F2\\PKI\\");
+
+#else
+_LIT(KKeyStoragePath, "c:\\private\\101F51F2\\PKI\\");
+_LIT(KRomKeyStoragePath, "z:\\private\\101F51F2\\PKI\\");
+#endif
+
+_LIT(KDeviceKeyFileName, "DevicePrivateKey.der");
+_LIT(KDeviceCertFileName, "DeviceCert.der");
+_LIT(KSingingCertFmt, "SigningCert%02d.der");
+_LIT(KSingingCertPattern, "SigningCert*");
+_LIT8(KDefaultKey, "0000000000000000");
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT(KSerialNumberFile, "%c:\\private\\101F51F2\\rdbserial.dat");
+_LIT(KUdtCertFileName, "%c:\\private\\101F51F2\\PKI\\UdtCertificate.der");
+#else
+_LIT(KSerialNumberFile, "c:\\private\\101F51F2\\rdbserial.dat");
+_LIT(KUdtCertFileName, "z:\\private\\101F51F2\\PKI\\UdtCertificate.der");
+#endif
+
+_LIT(KCmla, "CMLA");
+_LIT(KPadding, "\x0");
+
+NONSHARABLE_STRUCT( TUnloadModule )
+    {
+    RTelServer* iServer;
+    const TDesC* iName;
+    };
+
+
+// ============================ LOCAL FUNCTIONS ================================
+LOCAL_C void DoUnloadPhoneModule( TAny* aAny );
+
+LOCAL_C void WriteFileL(RFs& aFs, const TDesC& aName, const TDesC8& aData)
+    {
+    RFile file;
+    
+    User::LeaveIfError(file.Replace(aFs, aName, EFileWrite));
+    User::LeaveIfError(file.Write(aData));
+    file.Close();
+    }
+    
+LOCAL_C void ReadFileL(RFs& aFs, const TDesC& aName, HBufC8*& aContent)
+    {   
+    RFile file;
+    TInt size = 0;
+    
+    User::LeaveIfError(file.Open(aFs, aName, EFileRead));
+    CleanupClosePushL(file);
+    User::LeaveIfError(file.Size(size));
+    aContent = HBufC8::NewLC(size);
+    TPtr8 ptr(aContent->Des());
+    User::LeaveIfError(file.Read(ptr, size));
+    CleanupStack::Pop(); //aContent
+    CleanupStack::PopAndDestroy(); // file
+    }
+
+HBufC8* I2OSPL(
+    RInteger& aInt, TInt& aKeySize )
+    {
+    HBufC8* integer = aInt.BufferLC();
+    if (integer->Length() < aKeySize)
+        {
+        HBufC8* r = HBufC8::NewLC(aKeySize);
+        TPtr8 ptr(r->Des());
+        for(TInt i = integer->Length(); i < aKeySize; i++)
+            {
+            ptr.Append(KPadding());
+            }
+        ptr.Append(*integer);
+        CleanupStack::Pop(r);
+        CleanupStack::PopAndDestroy(integer);
+        return r;
+        }
+    else
+        {
+        CleanupStack::Pop(integer);
+        return integer;
+        }
+    }
+
+RInteger OS2IPL(
+    const TDesC8& aOctetStream)
+    {
+    RInteger r;
+    TInt i;
+    
+    r = RInteger::NewL(0);
+    for (i = 0; i < aOctetStream.Length(); i++)
+        {
+        r *= 256;
+        r += aOctetStream[i];
+        }
+    return r;
+    }
+
+void DoUnloadPhoneModule( TAny* aAny )
+    {
+    __ASSERT_DEBUG( aAny, User::Invariant() );
+    TUnloadModule* module = ( TUnloadModule* ) aAny;
+    module->iServer->UnloadPhoneModule( *( module->iName ) );
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage* CDrmStdKeyStorage::NewL
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDrmStdKeyStorage* CDrmStdKeyStorage::NewL(RLibrary aLibrary)
+    {
+    CDrmStdKeyStorage* self = new (ELeave) CDrmStdKeyStorage(aLibrary);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::CDrmStdKeyStorage
+// 
+// -----------------------------------------------------------------------------
+//    
+CDrmStdKeyStorage::CDrmStdKeyStorage(RLibrary aLibrary):
+    iFileMan(NULL),
+    iRootSelected(EFalse),
+    iKey(NULL),
+    iImei(NULL),
+    iLibrary(aLibrary)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::ConstructL
+// 
+// -----------------------------------------------------------------------------
+//   
+void CDrmStdKeyStorage::ConstructL()
+    {
+   
+    LOG(_L("CDrmStdKeyStorage::ConstructL ->"));
+    User::LeaveIfError(iFs.Connect());
+    iFileMan = CFileMan::NewL(iFs);
+
+#ifdef __DRM_OMA2 
+	SelectDefaultRootL();
+#endif
+
+    iDeviceSpecificKey.Copy(KDefaultKey);
+
+    LOG(_L("CDrmStdKeyStorage::ConstructL <-"));
+    }
+
+// -----------------------------------------------------------------------------
+// MDrmKeyStorage::~MDrmKeyStorage
+// 
+// -----------------------------------------------------------------------------
+//
+
+MDrmKeyStorage::~MDrmKeyStorage()
+    {
+    }
+// -----------------------------------------------------------------------------
+// DrmStdKeyStorage::~CDrmStdKeyStorage
+// 
+// -----------------------------------------------------------------------------
+//
+
+CDrmStdKeyStorage::~CDrmStdKeyStorage()
+    {
+    LOG(_L("CDrmStdKeyStorage::~CDrmStdKeyStorage ->"));
+    delete iFileMan;
+    delete iKey;
+    delete iImei; iImei = NULL;
+    iFs.Close();
+    //iLibrary.Close();
+    LOG(_L("CDrmStdKeyStorage::~CDrmStdKeyStorage <-"));
+    }
+
+// -----------------------------------------------------------------------------
+// DrmStdKeyStorage::ModulusSize
+// 
+// -----------------------------------------------------------------------------
+//
+    
+TInt CDrmStdKeyStorage::ModulusSize()
+    {
+    LOG(_L("CDrmStdKeyStorage::ModulusSize ->"));
+
+    if(iKey == NULL)
+        {
+        return KErrGeneral;
+        }
+    LOG(_L("CDrmStdKeyStorage::ModulusSize <-"));
+    return iKey->N().BitCount();
+    }
+
+// -----------------------------------------------------------------------------
+// DrmStdKeyStorage::SelectTrustedRootL
+// 
+// -----------------------------------------------------------------------------
+//
+void CDrmStdKeyStorage::SelectTrustedRootL(
+    const TDesC8& aRootKeyHash)
+    {
+    TFileName fileName;
+    TEntry entry;
+    TInt i;
+    
+    LOG(_L("CDrmStdKeyStorage::SelectTrustedRootL ->"));
+    LOG(aRootKeyHash);
+    if (aRootKeyHash.Length() != 0)
+        {
+        
+#ifndef RD_MULTIPLE_DRIVE
+        
+        fileName.Copy(KKeyStoragePath);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+        TFileName tempPath;
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    	iFs.DriveToChar( driveNumber, driveLetter );
+    
+    	tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
+        
+        fileName.Copy(tempPath);
+    
+#endif
+        
+        for (i = 0; i < SHA1_HASH; i++)
+            {
+            fileName.AppendNumFixedWidth(aRootKeyHash[i], EHex, 2);
+            }
+        fileName.Append('\\');
+        if (iFs.Entry(fileName, entry) != KErrNone)
+            {
+            
+#ifndef RD_MULTIPLE_DRIVE
+            
+            fileName.Copy(KRomKeyStoragePath);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+            DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+    	    iFs.DriveToChar( driveNumber, driveLetter );
+    	    
+    	    tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
+            
+            fileName.Copy(tempPath);
+    
+#endif
+            
+            for (i = 0; i < SHA1_HASH; i++)
+                {
+                fileName.AppendNumFixedWidth(aRootKeyHash[i], EHex, 2);
+                }
+            fileName.Append('\\');
+            // check that the path exists
+            User::LeaveIfError(iFs.Entry(fileName, entry));
+            }
+        User::LeaveIfError(iFs.SetSessionPath(fileName));
+        InitializeKeyL();
+        CheckRootForCmlaL();
+        iRootSelected = ETrue;  
+        }
+    else
+        {
+        SelectDefaultRootL();
+        }
+    LOG(_L("CDrmStdKeyStorage::SelectTrustedRootL <-"));
+    }
+    
+// -----------------------------------------------------------------------------
+// DrmStdKeyStorage::SelectDefaultRootL
+// 
+// -----------------------------------------------------------------------------
+//
+void CDrmStdKeyStorage::SelectDefaultRootL()
+    {
+    CDir* dir = NULL;
+    TFileName dirName;
+    TBool found = EFalse;
+    
+    LOG(_L("CDrmStdKeyStorage::SelectDefaultRootL ->"));
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    if (iFs.GetDir(KKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TFileName tempPath;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+    
+    tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
+    
+    if (iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#endif
+    
+        {
+        __UHEAP_MARK;
+        LOG(_L("  Checking keys on C:"));
+        CleanupStack::PushL(dir);
+        if (dir->Count() >= 1)
+            {
+            
+#ifndef RD_MULTIPLE_DRIVE
+            
+            dirName.Copy(KKeyStoragePath);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+            dirName.Copy(tempPath);
+    
+#endif
+            
+            dirName.Append((*dir)[0].iName);
+            dirName.Append('\\');
+            User::LeaveIfError(iFs.SetSessionPath(dirName));
+            found = ETrue;
+            }
+        CleanupStack::PopAndDestroy(dir);
+        __UHEAP_MARKEND;
+        }
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    if (!found && iFs.GetDir(KRomKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+    
+    tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
+    
+    if (!found && iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#endif
+        {
+    	LOG(_L("  Checking keys on Z:"));
+        CleanupStack::PushL(dir);
+        if (dir->Count() < 1)
+            {
+            User::Leave(KErrGeneral);
+            }
+        
+#ifndef RD_MULTIPLE_DRIVE
+        
+        dirName.Copy(KRomKeyStoragePath);
+        
+#else //RD_MULTIPLE_DRIVE
+    
+        dirName.Copy(tempPath);
+        
+#endif
+        
+        dirName.Append((*dir)[0].iName);
+        dirName.Append('\\');
+        User::LeaveIfError(iFs.SetSessionPath(dirName));
+        CleanupStack::PopAndDestroy(dir);
+        found = ETrue;
+        }
+    if (!found)
+        {
+        User::Leave(KErrGeneral); 
+        }
+    InitializeKeyL();
+    CheckRootForCmlaL();
+    iRootSelected = ETrue;
+    LOG(_L("CDrmStdKeyStorage::SelectDefaultRootL <-"));
+    }
+    
+TBool CDrmStdKeyStorage::SelectedRootIsCmla()
+    {
+    return iRootIsCmla;
+    }
+
+// -----------------------------------------------------------------------------
+// DrmStdKeyStorage::GetTrustedRootsL
+// 
+// -----------------------------------------------------------------------------
+//
+    
+void CDrmStdKeyStorage::GetTrustedRootsL(
+    RPointerArray<HBufC8>& aRootList)
+    {
+    CDir* dir = NULL;
+    TInt i;
+    TInt j;
+    TBuf8<SHA1_HASH> hash;
+    TEntry entry;
+    TUint8 c;
+    TInt r = KErrNone;
+    
+    LOG(_L("CDrmStdKeyStorage::GetTrustedRootsL ->"));
+    aRootList.ResetAndDestroy();
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    if (iFs.GetDir(KKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TFileName tempPath;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+    
+    tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
+    
+    if (iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#endif
+        {
+        LOG(_L("  Getting roots on C:"));
+        CleanupStack::PushL(dir);
+        for (i = 0; i < dir->Count(); i++)
+            {
+            entry = (*dir)[i];
+            hash.SetLength(0);
+            LOG(entry.iName);
+            r = KErrNone;
+            for (j = 0; r == KErrNone && j < SHA1_HASH; j++)
+                {
+                TLex lex(entry.iName.Mid(j * 2, 2));
+                r = lex.Val(c, EHex);
+                hash.Append(c);
+                }
+            if (r == KErrNone)
+                {
+                aRootList.Append(hash.AllocL());
+                }
+            }
+        CleanupStack::PopAndDestroy(dir);
+        }
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    if (iFs.GetDir(KRomKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+    
+    tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
+    
+    if (iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#endif
+        {
+        LOG(_L("  Getting roots on Z:"));
+        CleanupStack::PushL(dir);
+        for (i = 0; i < dir->Count(); i++)
+            {
+            LOG(entry.iName);
+            entry = (*dir)[i];
+            hash.SetLength(0);
+            r = KErrNone;
+            for (j = 0; r == KErrNone && j < SHA1_HASH; j++)
+                {
+                TLex lex(entry.iName.Mid(j * 2, 2));
+                r = lex.Val(c, EHex);
+                hash.Append(c);
+                }
+            if (r == KErrNone)
+                {
+                aRootList.Append(hash.AllocL());
+                }
+            }
+        CleanupStack::PopAndDestroy(dir);
+        }
+    LOG(_L("CDrmStdKeyStorage::GetTrustedRootsL <-"));
+    }
+
+// -----------------------------------------------------------------------------
+// DrmStdKeyStorage::GetCertificateChainL
+// 
+// -----------------------------------------------------------------------------
+//
+void CDrmStdKeyStorage::GetCertificateChainL(
+    RPointerArray<HBufC8>& aCertChain)
+    {
+    TFileName fileName;
+    TInt i;
+    CDir* dir = NULL;
+    HBufC8* cert = NULL;
+    
+    LOG(_L("CDrmStdKeyStorage::GetCertificateChainL ->"));
+    if (!iRootSelected)
+        {
+        User::Leave(KErrGeneral);
+        }
+    aCertChain.ResetAndDestroy();
+    ReadFileL(iFs, KDeviceCertFileName, cert);
+    aCertChain.Append(cert);
+    iFs.GetDir(KSingingCertPattern, KEntryAttNormal, ESortByName, dir);
+    CleanupStack::PushL(dir);
+    for (i = 0; i < dir->Count(); i++)
+        {
+        ReadFileL(iFs, (*dir)[i].iName, cert);
+        aCertChain.AppendL(cert);
+        }
+    CleanupStack::PopAndDestroy(); // dir
+    LOG(_L("CDrmStdKeyStorage::GetCertificateChainL <-"));
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::RsaSignL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDrmStdKeyStorage::RsaSignL(
+    const TDesC8& aInput)
+    {
+    return ModularExponentiateWithKeyL(aInput);
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::RsaDecryptL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDrmStdKeyStorage::RsaDecryptL(
+    const TDesC8& aInput)
+    {
+    return ModularExponentiateWithKeyL(aInput);
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::ImportDataL
+// -----------------------------------------------------------------------------
+//
+void CDrmStdKeyStorage::ImportDataL(
+    const TDesC8& aPrivateKey,
+    const RArray<TPtrC8>& aCertificateChain)
+    {
+    TInt i;
+    TInt n;
+    HBufC8* publicKey = NULL;
+    CX509Certificate* cert = NULL;
+    CSHA1* hasher = NULL;
+    TBuf8<SHA1_HASH> publicKeyHash;
+    TFileName fileName;
+    
+    LOG(_L("CDrmStdKeyStorage::ImportDataL ->"));
+    n = aCertificateChain.Count();
+    cert = CX509Certificate::NewLC(aCertificateChain[n - 1]);
+    publicKey = cert->DataElementEncoding(
+        CX509Certificate::ESubjectPublicKeyInfo)->AllocL();
+    CleanupStack::PushL(publicKey);
+    hasher = CSHA1::NewL();
+    CleanupStack::PushL(hasher);
+    hasher->Update(*publicKey);
+    publicKeyHash.Copy(hasher->Final());
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    fileName.Copy(KKeyStoragePath);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+    
+    TFileName keyStorageDir;
+    keyStorageDir.Format( KKeyStoragePath, (TUint)driveLetter );
+    
+    fileName.Copy(keyStorageDir);
+    
+#endif
+    
+    for (i = 0; i < SHA1_HASH; i++)
+        {
+        fileName.AppendNumFixedWidth(publicKeyHash[i], EHex, 2);
+        }
+    fileName.Append('\\');
+    iFileMan->Delete(fileName, CFileMan::ERecurse);
+    iFs.MkDirAll(fileName);
+    iFs.SetSessionPath(fileName);
+    WriteFileL(iFs, KDeviceKeyFileName, aPrivateKey);
+    fileName.Copy(fileName);
+    WriteFileL(iFs, KDeviceCertFileName, aCertificateChain[0]);
+    for (i = 1; i < n; i++)
+        {
+        fileName.SetLength(0);
+        fileName.AppendFormat(KSingingCertFmt, i - 1);
+        WriteFileL(iFs, fileName, aCertificateChain[i]);
+        }
+    CleanupStack::PopAndDestroy(3); // hasher, publicKey, cert
+    LOG(_L("CDrmStdKeyStorage::ImportDataL <-"));
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::GetDeviceSpecificKeyL
+// -----------------------------------------------------------------------------
+//
+void CDrmStdKeyStorage::GetDeviceSpecificKeyL(
+    TBuf8<KDeviceSpecificKeyLength>& aKey)
+    {
+    
+    HBufC8* key = NULL;
+    TInt n;    
+    CSHA1* hasher = NULL;  
+    TBuf8<SHA1_HASH> hash;
+    
+    if (iDeviceSpecificKey.Compare(KDefaultKey) == 0)
+        {
+        
+        GetImeiL();
+        
+        HBufC8* buf = HBufC8::NewLC( iImei->Size() + sizeof(VID_DEFAULT) );
+        TPtr8 ptr( buf->Des() );
+        ptr.Copy( *iImei );
+        ptr.Append(VID_DEFAULT);
+
+        hasher = CSHA1::NewL();
+        CleanupStack::PushL(hasher);
+        hasher->Update(ptr);
+        hash.Copy(hasher->Final());
+        key=hash.AllocL();
+        CleanupStack::PopAndDestroy(2,buf); // hasher,buf;
+
+        n = Min(key->Length(), KDeviceSpecificKeyLength);
+        iDeviceSpecificKey.Copy(key->Right(n));
+        delete key;
+        n = KDeviceSpecificKeyLength - n;
+        while (n > 0)
+            {
+            iDeviceSpecificKey.Append(0);
+            n--;
+            }
+        }
+    
+    aKey.Copy(iDeviceSpecificKey);
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::InitializeKeyL
+// -----------------------------------------------------------------------------
+//
+void CDrmStdKeyStorage::InitializeKeyL()
+    {
+    HBufC8* key = NULL;
+    TASN1DecInteger encInt;
+    TInt pos = 0;
+
+    LOG(_L("CDrmStdKeyStorage::InitializeKeyL ->"));
+    delete iKey;
+    iKey = NULL;
+    ReadFileL(iFs, KDeviceKeyFileName, key);
+    CleanupStack::PushL(key);
+    TASN1DecGeneric gen(*key);
+    gen.InitL();
+    pos += gen.LengthDERHeader();
+    if (gen.Tag() != EASN1Sequence)
+        {
+        User::Leave(KErrArgument);
+        }
+    encInt.DecodeDERShortL(*key, pos); // version
+    RInteger modulus = encInt.DecodeDERLongL(*key, pos);
+    CleanupStack::PushL(modulus);
+    RInteger publicExponent = encInt.DecodeDERLongL(*key, pos);
+    CleanupStack::PushL(publicExponent);
+    RInteger privateExponent = encInt.DecodeDERLongL(*key, pos);
+    CleanupStack::PushL(privateExponent);
+    iKey = CRSAPrivateKeyStandard::NewL(modulus, privateExponent);
+    CleanupStack::Pop(); // privateExponent
+    CleanupStack::PopAndDestroy();// publicExponent
+    CleanupStack::Pop(); // modulus
+    CleanupStack::PopAndDestroy(); // key
+    LOG(_L("CDrmStdKeyStorage::InitializeKeyL <-"));
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::ModularExponentiateWithKeyL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDrmStdKeyStorage::ModularExponentiateWithKeyL(
+    const TDesC8& aInput)
+    {
+    RInteger result;
+    RInteger input;
+    HBufC8* output;
+    TInt keyLength = KKeyLength;
+    
+    LOG(_L("CDrmStdKeyStorage::ModularExponentiateWithKeyL ->"));
+    input = OS2IPL(aInput);
+    CleanupClosePushL(input);
+    result = TInteger::ModularExponentiateL(input,iKey->D(), iKey->N());
+    CleanupClosePushL(result);
+    output = I2OSPL(result,  keyLength);
+    CleanupStack::PopAndDestroy(2); // result, input
+    LOG(_L("CDrmStdKeyStorage::ModularExponentiateWithKeyL <-"));
+    return output;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::CheckRootForCmlaL
+// -----------------------------------------------------------------------------
+//
+void CDrmStdKeyStorage::CheckRootForCmlaL()
+    {
+    CDir* dir = NULL;
+    HBufC8* buffer = NULL;
+    HBufC* name = NULL;
+    CX509Certificate* cert = NULL;
+    
+    LOG(_L("CDrmStdKeyStorage::CheckRootForCmlaL ->"));
+    __UHEAP_MARK;
+    iFs.GetDir(KSingingCertPattern, KEntryAttNormal, ESortByName, dir);
+    CleanupStack::PushL(dir);
+    ReadFileL(iFs, (*dir)[dir->Count() - 1].iName, buffer);
+    CleanupStack::PushL(buffer);
+    cert = CX509Certificate::NewL(*buffer);
+    CleanupStack::PushL(cert);
+    name = cert->SubjectName().DisplayNameL();
+    CleanupStack::PushL(name);
+    if (name->Find(KCmla) != KErrNotFound)
+        {
+        iRootIsCmla = ETrue;
+        }
+    else
+        {
+        iRootIsCmla = EFalse;
+        }
+    CleanupStack::PopAndDestroy(4); // name, cert, buffer, dir
+    LOG(_L("CDrmStdKeyStorage::CheckRootForCmlaL <-"));
+    __UHEAP_MARKEND;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::GetRdbSerialNumberL
+// -----------------------------------------------------------------------------
+//
+void CDrmStdKeyStorage::GetRdbSerialNumberL(
+    TBuf8<KRdbSerialNumberLength>& aSerialNumber)
+    {
+    HBufC8* buffer = NULL;
+    TUint att;
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    if (iFs.Att(KSerialNumberFile, att) != KErrNone)
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+    
+    TFileName serialNoFile;
+    serialNoFile.Format( KSerialNumberFile, (TUint)driveLetter );
+    
+    if (iFs.Att(serialNoFile, att) != KErrNone)
+    
+#endif
+        {
+        GenerateNewRdbSerialNumberL();
+        }
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    ReadFileL(iFs, KSerialNumberFile, buffer);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    ReadFileL(iFs, serialNoFile, buffer);
+    
+#endif
+    
+    aSerialNumber.Copy(*buffer);
+    delete buffer;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::GenerateNewRdbSerialNumberL
+// -----------------------------------------------------------------------------
+//
+void CDrmStdKeyStorage::GenerateNewRdbSerialNumberL()
+    {
+    TBuf8<KRdbSerialNumberLength> serialNumber;
+    TPtr8 random( const_cast<TUint8*>(serialNumber.Ptr()),
+                  KRdbSerialNumberLength,
+                  KRdbSerialNumberLength );
+    
+    RandomDataGetL(random,KRdbSerialNumberLength);
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    WriteFileL(iFs, KSerialNumberFile, random);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+    
+    TFileName serialNoFile;
+    serialNoFile.Format( KSerialNumberFile, (TUint)driveLetter );
+    
+    WriteFileL(iFs, serialNoFile, random);
+    
+#endif
+    
+    }
+    
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::UdtEncryptL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDrmStdKeyStorage::UdtEncryptL(
+    const TDesC8& aInput)
+    {
+    HBufC8* buffer = NULL;
+    HBufC8* output = HBufC8::NewMaxLC( 256 );
+    CX509Certificate* cert = NULL;
+    CRSAPublicKey* key = NULL;
+    TX509KeyFactory factory;
+    CRSAPKCS1v15Encryptor* encryptor = NULL;
+    TPtr8 result(const_cast<TUint8*>(output->Ptr()), 0, 256);
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    ReadFileL(iFs, KUdtCertFileName, buffer);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+    
+    TFileName udtCertFile;
+    udtCertFile.Format( KUdtCertFileName, (TUint)driveLetter );
+    
+    ReadFileL(iFs, udtCertFile, buffer);
+    
+#endif
+    
+    CleanupStack::PushL(buffer);
+    cert = CX509Certificate::NewL(*buffer);
+    CleanupStack::PushL(cert);
+    key = factory.RSAPublicKeyL(cert->PublicKey().KeyData());
+    CleanupStack::PushL(key);
+       
+    encryptor = CRSAPKCS1v15Encryptor::NewLC(*key);
+    encryptor->EncryptL(aInput, result);
+
+    CleanupStack::PopAndDestroy(4); // encryptor, key, cert, buffer
+    CleanupStack::Pop();// output
+    return output;
+    };
+
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::GetRootCertificatesL
+// -----------------------------------------------------------------------------
+//
+void CDrmStdKeyStorage::GetRootCertificatesL(
+          RPointerArray<HBufC8>& aRootCerts)
+    {
+    CDir* dir = NULL;
+    CDir* rootCerts = NULL;
+    TFileName dirName;
+    HBufC8* cert = NULL;
+    TInt i = 0;
+    TBuf<256> path;
+
+    iFs.SessionPath( path );
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    if (iFs.GetDir(KKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TFileName tempPath;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+    
+    tempPath.Format( KKeyStoragePath, (TUint)driveLetter );
+    
+    if (iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#endif
+        {
+        CleanupStack::PushL(dir);
+        for(i = 0; i < dir->Count(); i++)
+            {
+            if ((*dir)[i].IsDir())
+                {
+                
+#ifndef RD_MULTIPLE_DRIVE
+                
+                dirName.Copy(KKeyStoragePath);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+                dirName.Copy(tempPath);
+    
+#endif
+                
+                dirName.Append((*dir)[i].iName);
+                dirName.Append('\\');
+                User::LeaveIfError(iFs.SetSessionPath(dirName));
+                User::LeaveIfError(iFs.GetDir(KSingingCertPattern, KEntryAttNormal, ESortByName, rootCerts));
+                CleanupStack::PushL(rootCerts);
+                ReadFileL(iFs, (*rootCerts)[rootCerts->Count() - 1].iName, cert);
+                CleanupStack::PushL(cert);
+                aRootCerts.AppendL(cert);
+                CleanupStack::Pop(cert);
+                CleanupStack::PopAndDestroy(); // rootCerts
+                }
+            }
+        CleanupStack::PopAndDestroy(dir);
+        }
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    if (iFs.GetDir(KRomKeyStoragePath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+    
+    tempPath.Format( KRomKeyStoragePath, (TUint)driveLetter );
+    
+    if (iFs.GetDir(tempPath, KEntryAttDir, ESortByName, dir) == KErrNone)
+    
+#endif
+        {
+        CleanupStack::PushL(dir);
+        for(i = 0; i < dir->Count(); i++)
+            {
+            if ((*dir)[i].IsDir())
+                {
+                
+#ifndef RD_MULTIPLE_DRIVE
+                
+                dirName.Copy(KRomKeyStoragePath);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+                dirName.Copy(tempPath);
+    
+#endif
+                
+                dirName.Append((*dir)[i].iName);
+                dirName.Append('\\');
+                User::LeaveIfError(iFs.SetSessionPath(dirName));
+                User::LeaveIfError(iFs.GetDir(KSingingCertPattern, KEntryAttNormal, ESortByName, rootCerts));
+                CleanupStack::PushL(rootCerts);
+                ReadFileL(iFs, (*rootCerts)[rootCerts->Count() - 1].iName, cert);
+                CleanupStack::PushL(cert);
+                aRootCerts.AppendL(cert);
+                CleanupStack::Pop(cert);
+                CleanupStack::PopAndDestroy(); // rootCerts
+                }
+            }
+        CleanupStack::PopAndDestroy(dir);
+        }
+    iFs.SetSessionPath( path );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::GetIMEIL
+// -----------------------------------------------------------------------------
+//
+const TDesC& CDrmStdKeyStorage::GetImeiL()
+    {
+    if ( iImei )
+        {
+        return *iImei;
+        }
+
+#if (defined __WINS__ || defined WINSCW)
+    // Default IMEI used for emulator   
+    _LIT( KDefaultSerialNumber, "123456789123456789" );
+    iImei = KDefaultSerialNumber().AllocL();
+        
+    return *iImei;
+#else
+ 
+    TInt error( KErrNone );
+    TInt count( 0 );
+    TInt count2( 0 );
+    TUint32 caps( 0 );
+    TBool found (EFalse);
+    
+    RTelServer etelServer;
+    RMobilePhone phone;
+    
+    TUint KMaxImeiTries = 5;
+    
+    for ( TUint8 i = 0; i < KMaxImeiTries; ++i )
+        {
+        error = etelServer.Connect();
+        if ( error )
+            {
+            User::After( TTimeIntervalMicroSeconds32( KWaitingTime ) );
+            }
+        else 
+            {
+            break;
+            }
+        }
+    
+    User::LeaveIfError( error );
+    CleanupClosePushL( etelServer );
+    
+    User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) );  
+    
+    TUnloadModule unload;
+    unload.iServer = &etelServer;
+    unload.iName = &KMmTsyModuleName;
+    
+    TCleanupItem item( DoUnloadPhoneModule, &unload );
+    CleanupStack::PushL( item );
+    User::LeaveIfError( etelServer.EnumeratePhones( count ) );
+        
+    for ( count2 = 0; count2 < count && !found; ++count2 )
+        {
+        RTelServer::TPhoneInfo phoneInfo;
+        User::LeaveIfError( etelServer.GetTsyName( count2, phoneInfo.iName ) );
+        
+        if ( phoneInfo.iName.CompareF(KMmTsyModuleName()) == 0 )   
+           {
+            User::LeaveIfError( etelServer.GetPhoneInfo( count2, phoneInfo ) );
+            User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) );
+            CleanupClosePushL( phone );
+            found = ETrue;
+            }
+        }
+
+    if ( !found )
+        {
+        // Not found.
+        User::Leave( KErrNotFound );
+        }
+   
+    User::LeaveIfError( phone.GetIdentityCaps( caps ) );
+    if (!( caps & RMobilePhone::KCapsGetSerialNumber ))
+        {
+         User::Leave( KErrNotFound );
+        }
+        
+    RMobilePhone::TMobilePhoneIdentityV1 id;
+    TRequestStatus status;
+    
+    phone.GetPhoneId( status, id );
+       
+    User::WaitForRequest( status );
+        
+    User::LeaveIfError( status.Int() );
+        
+    iImei = id.iSerialNumber.AllocL();
+        
+    CleanupStack::PopAndDestroy( 3 ); // phone, item, etelServer
+        
+    HBufC8* buf = HBufC8::NewL( iImei->Size() );
+    TPtr8 ptr( buf->Des() );
+    ptr.Copy( *iImei );
+        
+    LOG(_L("IMEI:"));
+    LOGHEX(ptr);
+    delete buf;
+    
+    return *iImei;
+#endif /* __WINS__ , WINSCW */ 
+       
+    }
+    
+    
+// -----------------------------------------------------------------------------
+// CDrmStdKeyStorage::RandomDataGetL
+// -----------------------------------------------------------------------------
+//
+    
+void CDrmStdKeyStorage::RandomDataGetL( TDes8& aData, const TInt aLength )
+    {
+    if ( aLength <= 0 )
+        {
+         User::Leave(KErrArgument);
+        }
+
+    TInt size = aData.MaxSize();
+
+    if( size < aLength )
+        {
+        User::Leave(KErrOverflow);
+        }
+
+    TRandom::Random( aData );
+    }
+
+// end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/legacy/inc/DRMCommon.rh	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+// ---------------------------------------------------------
+//    MIMEARRAY
+//    stores mimetype list 
+// ---------------------------------------------------------
+//
+STRUCT MIMEARRAY
+    {
+    BYTE num = 0;     // total number of the list
+	STRUCT items[];	  // list of mimetype
+    }
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/legacy/src/DRMCommon.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,2608 @@
+/*
+* Copyright (c) 2002, 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:  Implementation of common DRM operations
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <f32file.h>
+#include <s32file.h> 
+#include <apmstd.h>
+#include <WSPDecoder.h>
+#include <WSPEncoder.h>
+
+#include <barsc.h>
+#include <barsread.h> 
+
+#include <DRMCommon.rsg>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "DRMCommon.h"
+#include "DRMRightsClient.h"
+#include "DcfCommon.h"
+#include "Oma1Dcf.h"
+#include "Oma2Dcf.h"
+#include "DRMPermission.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+const TInt KBufferSize = 1024;
+_LIT8(KRiUrl, "Rights-Issuer");
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+_LIT8(KFLPrefix, "flk:");
+_LIT8(KLDPrefix, "ldf:");
+_LIT8(KHeaderNameEnding, ":");
+_LIT8(KHeaderEnding, "\r\n");
+
+ #ifdef RD_MULTIPLE_DRIVE
+_LIT(KDataTypesFile, "%c:\\system\\data\\DataType.dat");
+_LIT(KResourceFile, "%c:\\resource\\drmcommon.rsc");
+_LIT(KTempFile, "%c:\\system\\temp\\DataType.tmp");
+#else
+_LIT(KDataTypesFile, "c:\\system\\data\\DataType.dat");
+_LIT(KResourceFile, "z:\\resource\\drmcommon.rsc");
+_LIT(KTempFile, "c:\\system\\temp\\DataType.tmp");
+#endif
+
+
+// Version of the client
+
+const TUint8 KClientVersionMajor = 1;
+const TUint8 KClientVersionMinor = 1;
+const TUint16 KClientVersionBuild = 2;
+
+// Which lowest server version is supported
+
+const TUint8 KServerVersionMajor = 1;
+const TUint8 KServerVersionMinor = 2;
+const TUint16 KServerVersionBuild = 1;
+
+//_LIT(KNullDate,"00000000:000000.000000");
+
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+/*
+LOCAL_C TInt CheckContentRightsL(
+    const TDesC8& aContentURI, 
+    TUint32 aRightsSpec);
+
+LOCAL_C TInt IsProtectedContentL(
+    const TDesC8& aContent, 
+    TBool& aProtection);
+
+LOCAL_C TInt GetNewHeaderBuffer(
+    HBufC8*& aOldHeaderBuf, 
+    const TDesC8& aHeaderName, 
+    const TDesC8& aHeaderValue, 
+    HBufC8*& aNewHeaderBuf
+    );
+
+LOCAL_C TInt WriteNewFile(
+    TFileName aFileName, 
+    HBufC8*& aHeaderBuf, 
+    TUint32& aFirstPartLength, 
+    TUint32& aDataLength, 
+    TUint32& aDataPartPos
+    );
+
+LOCAL_C TInt GetContentURIListL(
+    RPointerArray<HBufC8>*& aURIList);
+
+LOCAL_C TInt DataTypesCountL(
+    TInt& aCount);
+
+LOCAL_C TInt SupportedDataTypeL(
+    const TInt aIndex, TDataType& aDataType);
+
+LOCAL_C TInt StaticDataTypesCountL(
+    TInt& aCount);
+
+LOCAL_C TInt RegisterDataTypeL(
+    const TDataType& aDataType);
+
+LOCAL_C TInt UnRegisterDataTypeL(
+    const TInt aIndex);
+
+*/
+
+LOCAL_C void GetActiveRightsL(
+    const TDesC8& aContentURI, 
+    TUint32 aRightsSpec, 
+    CDRMRights*& aRightsObject);
+
+LOCAL_C TInt CheckFileRightsL(
+    const TDesC& aFileName, 
+    TUint32 aRightsSpec);
+
+LOCAL_C TInt CheckFileRightsL(
+    RFile& aFileHandle, 
+    TUint32 aRightsSpec);
+
+LOCAL_C TInt IsProtectedFileL(
+    const TDesC& aFileName, 
+    TBool& aProtection);
+
+LOCAL_C TInt IsProtectedFileL(
+    RFile& aFileHandle, 
+    TBool& aProtection);
+
+LOCAL_C TInt GetContentInfoL(
+    const TDesC8& aContent, 
+    DRMCommon::TContentProtection& aProtection, 
+    HBufC8*& aMIMEType, 
+    HBufC8*& aContentURI, 
+    TUint& aDataLength);
+
+LOCAL_C TInt GetFileInfoL(
+    const TDesC& aFileName, 
+    DRMCommon::TContentProtection& aProtection, 
+    HBufC8*& aMIMEType, 
+    HBufC8*& aContentURI, 
+    TUint& aDataLength);
+
+LOCAL_C TInt GetFileInfoL(
+    RFile& aFileHandle, 
+    DRMCommon::TContentProtection& aProtection, 
+    HBufC8*& aMIMEType, 
+    HBufC8*& aContentURI, 
+    TUint& aDataLength);
+
+LOCAL_C void GetContentHeaderL(
+    const TDesC8& aContent, 
+    const TDesC8& aHeaderName, 
+    HBufC8*& aHeaderValue);
+
+LOCAL_C void GetFileHeaderL(
+    const TFileName& aFileName, 
+    const TDesC8& aHeaderName, 
+    HBufC8*& aHeaderValue);
+
+LOCAL_C void GetFileHeaderL(
+    RFile& aFileHandle, 
+    const TDesC8& aHeaderName, 
+    HBufC8*& aHeaderValue);
+
+LOCAL_C void SetContentHeaderL(
+    HBufC8*& aContent, 
+    const TDesC8& aHeaderName, 
+    const TDesC8& aHeaderValue);
+
+LOCAL_C void SetFileHeaderL(
+    const TDesC16& aFileName, 
+    const TDesC8& aHeaderName, 
+    const TDesC8& aHeaderValue);
+
+LOCAL_C void SetFileHeaderL(
+    RFile& aFileHandle, 
+    const TDesC8& aHeaderName, 
+    const TDesC8& aHeaderValue);
+
+LOCAL_C void GetSingleRightsObjectL(
+    const TDesC8& aContentURI, 
+    TUint32 aLocalID, 
+    CDRMRights*& aRightsObject);
+
+LOCAL_C void GetDetailedContentRightsL(
+    const TDesC8& aContentURI, 
+    RPointerArray<CDRMRights>*& aRightsList);
+
+LOCAL_C void GetDetailedFileRightsL(
+    const TDesC& aFileName, 
+    RPointerArray<CDRMRights>*& aRightsList);
+
+LOCAL_C void GetDetailedFileRightsL(
+    RFile& aFileHandle, 
+    RPointerArray<CDRMRights>*& aRightsList);
+
+LOCAL_C TInt RegisterDynamicDataTypeL(
+    const TDataType& aDataType);
+
+LOCAL_C TInt UnRegisterDynamicDataTypeL(
+    const TInt aIndex);
+
+LOCAL_C TInt CalculatePaddingL(
+    COma1Dcf* dcf);
+
+LOCAL_C void DoResetAndDestroy( TAny* aPtr );  
+
+
+LOCAL_C TInt GetFileHandleRead(
+    RFs& aFileServer, 
+    RFile& aFile, 
+    const TDesC& aFileName );
+
+LOCAL_C void AddParents( 
+    DRMCommon* aDrmCommon, 
+    RPointerArray<CDRMRights>& aRights );
+	
+// FORWARD DECLARATIONS
+
+using namespace ContentAccess;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ----------------------------------------------------------------------------
+// DoResetAndDestroy
+// Does RPointerArray< >->ResetAndDestroy() for the given array aPtr.
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void DoResetAndDestroy( TAny* aPtr )
+    {
+    ( reinterpret_cast< RPointerArray< CDRMPermission >* >( aPtr ) )->
+        ResetAndDestroy();
+    }
+    
+    
+// -----------------------------------------------------------------------------
+// GetPermission
+// -----------------------------------------------------------------------------
+LOCAL_C void GetPermission(
+    RDRMRightsClient& aClient, 
+    const TDesC8& aUri,
+    TIntent aIntent,
+    CDRMPermission*& aPermission )
+    {
+    TInt r = KErrNone;
+    CDRMPermission* permission = NULL;
+    TUint32 reason = 0;
+    
+    TRAP( r, permission = aClient.GetActiveRightsL( aIntent, aUri, reason ) );
+    if ( permission != NULL )
+        {
+        if ( aPermission == NULL )
+            {
+            TRAP_IGNORE( aPermission = CDRMPermission::NewL() ); 
+            }
+        aPermission->Merge( *permission );
+        delete permission;
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// GetActiveRightsL
+// Returns a possible active rights object. Adopts to broken callers who still
+// use a bitmask for intent.
+// -----------------------------------------------------------------------------
+void GetActiveRightsL(
+    const TDesC8& aContentURI,
+    TUint32 aConstraints,
+    CDRMRights*& aRightsObject)
+    {
+    CDRMPermission* permission = NULL;
+    RDRMRightsClient client;
+    HBufC8* uri = NULL;
+        
+    User::LeaveIfError( client.Connect() );
+    CleanupClosePushL( client );
+
+    if ( aConstraints == 0 )
+        {
+        GetPermission( client, aContentURI, EView, permission );
+        GetPermission( client, aContentURI, EPlay, permission );
+        GetPermission( client, aContentURI, EExecute, permission );
+        GetPermission( client, aContentURI, EPrint, permission );
+        }
+    else
+        {
+        GetPermission( client, aContentURI, static_cast<TIntent>( aConstraints ), permission );
+        }
+
+    if ( permission != NULL )
+        {
+        CleanupStack::PushL( permission );
+        aRightsObject = CDRMRights::NewL();
+        CleanupStack::PushL( aRightsObject );
+        uri = aContentURI.AllocL();
+        CleanupStack::PushL( uri );
+        aRightsObject->SetPermissionL( *permission );
+        aRightsObject->SetContentURI( uri );
+        CleanupStack::Pop( uri );
+        CleanupStack::Pop( aRightsObject );
+        CleanupStack::PopAndDestroy( permission );
+        }
+    else
+        {
+        aRightsObject = NULL;
+        User::Leave( KErrCANoRights );
+        }
+    CleanupStack::PopAndDestroy(); // client
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+LOCAL_C TInt IsProtectedFileL(
+    const TDesC& aFileName, 
+    TBool& aProtection)
+    {
+    RFs fs;
+    RFile file;
+    TInt r = KErrNone;
+    CDcfCommon* dcf = NULL;
+
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    
+    
+    r = GetFileHandleRead( fs, file, aFileName );
+    User::LeaveIfError(r);
+    
+    CleanupClosePushL(file);
+    dcf = CDcfCommon::NewL(file);
+    if (dcf != NULL)
+        {
+        aProtection = ETrue;
+        delete dcf;
+        }
+    else
+        {
+        aProtection = EFalse;
+        }
+    CleanupStack::PopAndDestroy(2); // file, fs
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+LOCAL_C TInt IsProtectedFileL(
+    RFile& aFileHandle, 
+    TBool& aProtection)
+    {
+    TInt r = KErrNone;
+    CDcfCommon* dcf = NULL;
+
+    dcf = CDcfCommon::NewL(aFileHandle);
+    if (dcf != NULL)
+        {
+        aProtection = ETrue;
+        delete dcf;
+        }
+    else
+        {
+        aProtection = EFalse;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+TInt GetContentInfoL(
+    const TDesC8& aContent, 
+    DRMCommon::TContentProtection& aProtection, 
+    HBufC8*& aMIMEType, 
+    HBufC8*& aContentURI, 
+    TUint& aDataLength)
+    {
+    TInt r = KErrNone;
+    COma1Dcf* dcf = NULL;
+    TRAP(r, dcf = COma1Dcf::NewL(aContent));
+    if (dcf != NULL)
+        {
+        CleanupStack::PushL( dcf );
+            
+        if (dcf->iContentID->Left(4).Compare(KLDPrefix) == 0 ||
+            dcf->iContentID->Left(4).Compare(KFLPrefix) == 0 ||
+            dcf->iRightsIssuerURL == NULL)
+            {
+            aProtection = DRMCommon::EForwardLocked;
+            }
+        else
+            {
+            aProtection = DRMCommon::ESuperDistributable;
+            }
+        if (dcf->iContentID != NULL)
+            {
+            aContentURI = dcf->iContentID->AllocL();
+            }
+        else
+            {
+            aContentURI = NULL;
+            }
+        if (dcf->iMimeType != NULL)
+            {
+            aMIMEType = dcf->iMimeType->AllocL();
+            }
+        else
+            {
+            aMIMEType = NULL;
+            }
+
+        CalculatePaddingL(dcf);
+        aDataLength = dcf->iPlainTextLength;
+        CleanupStack::PopAndDestroy();
+        }
+    else
+        {
+        aProtection = DRMCommon::ENoDCFFile;
+        if (r == KErrArgument)
+            {
+            r = KErrNone;
+            }
+        User::LeaveIfError(r);
+        }
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+TInt GetFileInfoL(
+    const TDesC& aFileName, 
+    DRMCommon::TContentProtection& aProtection, 
+    HBufC8*& aMIMEType, 
+    HBufC8*& aContentURI, 
+    TUint& aDataLength)
+    {
+    RFs fs;
+    RFile file;
+    TInt r = KErrNone;
+    CDcfCommon* dcf = NULL;
+    COma2Dcf* dcf2 = NULL;
+    CData* data = NULL;
+
+    aProtection = DRMCommon::ENoDCFFile;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    
+    r = GetFileHandleRead( fs, file, aFileName );
+    User::LeaveIfError(r);
+    CleanupClosePushL(file);
+    
+    dcf = CDcfCommon::NewL(file);
+    if (dcf != NULL)
+        {
+        CleanupStack::PushL(dcf);
+        if (dcf->iVersion == EOma2Dcf)
+            {
+            dcf2 = static_cast<COma2Dcf*>(dcf);
+            }
+            
+        if (dcf->iContentID->Left(4).Compare(KLDPrefix) == 0 ||
+            dcf->iContentID->Left(4).Compare(KFLPrefix) == 0 ||
+            dcf->iRightsIssuerURL == NULL)
+            {
+            aProtection = DRMCommon::EForwardLocked;
+            }
+        else
+            {
+            aProtection = DRMCommon::ESuperDistributable;
+            }
+        if (dcf->iContentID != NULL)
+            {
+            aContentURI = dcf->iContentID->AllocL();
+            }
+        else
+            {
+            aContentURI = NULL;
+            }
+        if (dcf->iMimeType != NULL)
+            {
+            aMIMEType = dcf->iMimeType->AllocL();
+            }
+        else
+            {
+            aMIMEType = NULL;
+            }
+        
+        // Insert domain RO if it exists
+        if (dcf2 != NULL && dcf2->iRightsObjects.Count() > 0)
+            {
+            // Creating a CData object will insert the domain RO into the RDB
+            data = CData::NewL(file, KDefaultContentObject);
+            delete data;
+            }
+            
+        if (dcf->iVersion == EOma1Dcf && !dcf->iPlainTextLengthValid)
+            {
+            CalculatePaddingL(static_cast<COma1Dcf*>(dcf));
+            }
+
+        aDataLength = dcf->iPlainTextLength;
+        CleanupStack::PopAndDestroy(); // dcf
+        }
+    CleanupStack::PopAndDestroy(2); // file, fs
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+TInt GetFileInfoL(
+    RFile& aFileHandle, 
+    DRMCommon::TContentProtection& aProtection, 
+    HBufC8*& aMIMEType, 
+    HBufC8*& aContentURI, 
+    TUint& aDataLength)
+    {
+    TInt r = KErrNone;
+    CDcfCommon* dcf = NULL;
+    COma2Dcf* dcf2 = NULL;
+    CData* data = NULL;
+    TInt initialPos = 0;
+
+    // Store the initial filePos
+    User::LeaveIfError(aFileHandle.Seek(ESeekCurrent, initialPos)); 
+
+    aProtection = DRMCommon::ENoDCFFile;
+
+    dcf = CDcfCommon::NewL(aFileHandle);
+    if (dcf != NULL)
+        {
+        CleanupStack::PushL(dcf);
+        if (dcf->iVersion == EOma2Dcf)
+            {
+            dcf2 = static_cast<COma2Dcf*>(dcf);
+            }
+
+        if (dcf->iContentID->Left(4).Compare(KLDPrefix) == 0 ||
+            dcf->iContentID->Left(4).Compare(KFLPrefix) == 0 ||
+            dcf->iRightsIssuerURL == NULL)
+            {
+            aProtection = DRMCommon::EForwardLocked;
+            }
+        else
+            {
+            aProtection = DRMCommon::ESuperDistributable;
+            }
+        if (dcf->iContentID != NULL)
+            {
+            aContentURI = dcf->iContentID->AllocL();
+            }
+        else
+            {
+            aContentURI = NULL;
+            }
+        if (dcf->iMimeType != NULL)
+            {
+            aMIMEType = dcf->iMimeType->AllocL();
+            }
+        else
+            {
+            aMIMEType = NULL;
+            }
+
+        // Insert domain RO if it exists
+        if (dcf2 != NULL && dcf2->iRightsObjects.Count() > 0)
+            {
+            // Creating a CData object will insert the domain RO into the RDB
+            data = CData::NewL(aFileHandle, KDefaultContentObject);
+            delete data;
+            }
+            
+        if (dcf->iVersion == EOma1Dcf && !dcf->iPlainTextLengthValid)
+            {
+            CalculatePaddingL(static_cast<COma1Dcf*>(dcf));
+            }
+
+        aDataLength = dcf->iPlainTextLength;
+        CleanupStack::PopAndDestroy(); // dcf
+        }
+    // Restore filePos
+    User::LeaveIfError(aFileHandle.Seek(ESeekStart, initialPos));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+TInt CheckFileRightsL(
+    const TDesC& aFileName, 
+    TUint32 aRightsSpec)
+    {
+    RFs fs;
+    RFile file;
+    CDcfCommon* dcf = NULL;
+    TInt r = DRMCommon::ENoRights;
+    RDRMRightsClient client;
+    TUint32 reason = 0;
+    
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    
+    r = GetFileHandleRead(fs, file, aFileName);
+    User::LeaveIfError(r);
+    CleanupClosePushL(file);
+    
+    dcf = CDcfCommon::NewL(file);
+    if ( dcf == NULL )
+        {
+        User::Leave(KErrArgument);
+        }
+    CleanupStack::PushL(dcf);
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+    r = client.CheckRights(aRightsSpec, *dcf->iContentID, reason);
+    CleanupStack::PopAndDestroy(4); // dcf, file, client, fs
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+TInt CheckFileRightsL(
+    RFile& aFileHandle, 
+    TUint32 aRightsSpec)
+    {
+    CDcfCommon* dcf = NULL;
+    TInt r = DRMCommon::ENoRights;
+    RDRMRightsClient client;
+    TUint32 reason = 0;
+    
+    dcf = CDcfCommon::NewL(aFileHandle);
+    if ( dcf == NULL )
+        {
+        User::Leave(KErrArgument);
+        }
+    CleanupStack::PushL(dcf);
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+    r = client.CheckRights(aRightsSpec, *dcf->iContentID, reason);
+    CleanupStack::PopAndDestroy(2); // dcf, file
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+void GetSingleRightsObjectL(
+    const TDesC8& aContentURI, 
+    TUint32 aLocalID, 
+    CDRMRights*& aRightsObject)
+    {
+    RDRMRightsClient client;
+    CDRMPermission* p = NULL;
+    CDRMAsset* a = NULL;
+    
+    aRightsObject = NULL;
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+    
+    aRightsObject = CDRMRights::NewL(); 
+    CleanupStack::PushL(aRightsObject);
+    
+    p = client.GetDbEntryL(aContentURI, aLocalID);
+    CleanupStack::PushL(p);
+    aRightsObject->SetPermissionL(*p);
+    CleanupStack::PopAndDestroy(); // p
+
+    a = CDRMAsset::NewLC();
+    aRightsObject->SetAssetL(*a);
+    CleanupStack::PopAndDestroy();
+    
+    aRightsObject->SetContentURIAndLocalID(aContentURI.AllocL(), aLocalID);
+    CleanupStack::Pop(); // aRightsObject
+    CleanupStack::PopAndDestroy(); // client
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+void GetDetailedContentRightsL(
+    const TDesC8& aContentURI, 
+    RPointerArray<CDRMRights>*& aRightsList)
+    {
+    RDRMRightsClient client;
+    RPointerArray<CDRMPermission> rights;
+    CDRMRights* ro = NULL;
+    CDRMAsset* a  = NULL;
+    TInt i;
+    // Need a temporary pointer
+    HBufC8* contentId = NULL;
+    
+    aRightsList = NULL;
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+
+    client.GetDBEntriesL(aContentURI, rights);
+
+    TCleanupItem cleanup( DoResetAndDestroy, &rights );
+    CleanupStack::PushL( cleanup );
+
+    aRightsList = new(ELeave) RPointerArray<CDRMRights>(rights.Count());
+
+    // Push the actual pointer reserved with NewL in
+    CleanupStack::PushL( aRightsList );
+
+    // Push the cleanup of the items as well into the cleanup stack
+    TCleanupItem cleanup2( DoResetAndDestroy, aRightsList );
+    CleanupStack::PushL( cleanup2 );
+
+    for (i = 0; i < rights.Count(); i++)
+        {
+        // Needs to be pushed to the cleanup stack
+        ro = CDRMRights::NewL();
+        CleanupStack::PushL(ro);
+
+        // Push to cleanp stack
+        a = CDRMAsset::NewLC();
+
+        // Set asset
+        ro->SetAssetL(*a);
+
+        // Destroy asset
+        CleanupStack::PopAndDestroy(); // Asset
+
+        // Set the permission, copies the object
+        ro->SetPermissionL(*rights[i]);
+
+        // take a copy of the content id
+        contentId = aContentURI.AllocL();
+
+        // set content uri and local id
+        ro->SetContentURIAndLocalID(contentId, rights[i]->iUniqueID);
+
+        // Append the ro to the rights list
+        aRightsList->AppendL(ro);
+
+        // Take the ro out of the cleanup stack
+        CleanupStack::Pop(ro);
+        }
+
+    CleanupStack::Pop(2); // aRightsList ( two items )
+    CleanupStack::PopAndDestroy(2); // rights, client
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+void GetDetailedFileRightsL(
+    const TDesC& aFileName, 
+    RPointerArray<CDRMRights>*& aRightsList)
+    {
+    
+    CDcfCommon* dcf = NULL;
+    RFile file;
+    RFs fs;
+    TInt r = KErrNone;
+    
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+
+    r = GetFileHandleRead( fs, file, aFileName );
+    User::LeaveIfError(r);
+    CleanupClosePushL(file);
+    
+    
+    dcf = CDcfCommon::NewL(file);
+    if (dcf == NULL)
+        {
+        User::Leave(KErrArgument);
+        }
+    CleanupStack::PushL(dcf);
+    GetDetailedContentRightsL(*dcf->iContentID, aRightsList);
+    CleanupStack::PopAndDestroy(3); // dcf, file, client
+   
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+void GetDetailedFileRightsL(
+    RFile& aFileHandle, 
+    RPointerArray<CDRMRights>*& aRightsList)
+    {
+    CDcfCommon* dcf = NULL;
+    
+    dcf = CDcfCommon::NewL(aFileHandle);
+    if (dcf == NULL)
+        {
+        User::Leave(KErrArgument);
+        }
+    CleanupStack::PushL(dcf);
+    GetDetailedContentRightsL(*dcf->iContentID, aRightsList);
+    CleanupStack::PopAndDestroy(); // dcf
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+LOCAL_C void  GetNewHeaderBufferL(
+    HBufC8*& aOldHeaderBuf, 
+    const TDesC8& aHeaderName, 
+    const TDesC8& aHeaderValue, 
+    HBufC8*& aNewHeaderBuf
+    )
+    {
+    TInt oldHeaderValueLength = 0;
+    TInt offset = 0;
+    TPtr8 headerPtr(aOldHeaderBuf->Des());
+    TPtr8 headerNamePtr(NULL, 0, 0);
+    TPtr8 newHeaderPtr(NULL, 0, 0);
+    
+    HBufC8* headerName = HBufC8::NewL(aHeaderName.Length() + 1);
+    // Find the position of the text in the header
+    headerNamePtr.Set(headerName->Des());
+    headerNamePtr.Copy(aHeaderName);
+    headerNamePtr.Append(KHeaderNameEnding);
+    offset = headerPtr.FindF(headerNamePtr);
+    delete headerName;
+    headerName = NULL;
+    if (offset != KErrNotFound)
+        {
+        // All fields end with CRLF, search for the end of the field and if it is not found
+        // return KErrArgument
+        oldHeaderValueLength = headerPtr.Right(headerPtr.Length() -
+            (offset + aHeaderName.Length() + 1)).Find(KHeaderEnding);
+        User::LeaveIfError(oldHeaderValueLength);
+        // reserve new buffer for the header, might be useless if the lengths are the same
+        aNewHeaderBuf = HBufC8::NewL(headerPtr.Length() - oldHeaderValueLength +
+            aHeaderValue.Length());
+        newHeaderPtr.Set(aNewHeaderBuf->Des());
+        newHeaderPtr.Copy(headerPtr.Left(offset + aHeaderName.Length() + 1));
+        newHeaderPtr.Append(aHeaderValue);
+        newHeaderPtr.Append(headerPtr.Right(headerPtr.Length() -
+            (offset + aHeaderName.Length() + 1 + oldHeaderValueLength)));                        
+        }
+    else
+        {
+        aNewHeaderBuf = HBufC8::NewL(headerPtr.Length() + aHeaderName.Length() +
+            aHeaderValue.Length() + 3);
+        newHeaderPtr.Set(aNewHeaderBuf->Des());
+        newHeaderPtr.Copy(headerPtr);
+        newHeaderPtr.Append(aHeaderName);
+        newHeaderPtr.Append(KHeaderNameEnding);
+        newHeaderPtr.Append(aHeaderValue);
+        newHeaderPtr.Append(KHeaderEnding);
+        }        
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+LOCAL_C void WriteNewFileL(
+    RFs& aFs,
+    RFile& aOriginalFile,
+    const TDesC& aOriginalFileName,
+    COma1Dcf& aDcf,
+    TFileName& aTempFileName )
+    {
+    TPtrC tempFilePath;
+    HBufC8* buffer = NULL;
+    RFileWriteStream temp;
+    TPtr8 ptr(NULL, 0, 0);
+    TInt offset = 0;
+    
+    // Find the path of the file to be modified and put the tempfile
+    // into that directory
+    tempFilePath.Set(aOriginalFileName.Left(
+        aOriginalFileName.LocateReverse('\\') + 1));
+    User::LeaveIfError(temp.Temp(aFs, tempFilePath, aTempFileName, EFileWrite));
+    CleanupClosePushL( temp );
+    
+    temp.WriteUint8L(1);
+    temp.WriteUint8L(aDcf.iMimeType->Length());
+    temp.WriteUint8L(aDcf.iContentID->Length());
+    temp.WriteL(*aDcf.iMimeType);
+    temp.WriteL(*aDcf.iContentID);
+    buffer = TWspPrimitiveEncoder::UintVarL(aDcf.iHeaders->Length());
+    CleanupStack::PushL(buffer);
+    temp.WriteL(*buffer);
+    CleanupStack::PopAndDestroy(buffer);
+    buffer = TWspPrimitiveEncoder::UintVarL(aDcf.iDataLength);
+    CleanupStack::PushL(buffer);
+    temp.WriteL(*buffer);
+    CleanupStack::PopAndDestroy(buffer);
+    temp.WriteL(*aDcf.iHeaders);
+
+    offset = aDcf.iOffset;
+    User::LeaveIfError(aOriginalFile.Seek(ESeekStart, offset));
+    buffer = HBufC8::NewLC(KBufferSize);
+    do
+        {
+        ptr.Set(buffer->Des());
+        ptr.SetLength(0);
+        aOriginalFile.Read(ptr);         
+        if (ptr.Length() > 0)
+            {
+            temp.WriteL(ptr);
+            }
+        }
+    while (ptr.Length() > 0);
+    temp.CommitL();           
+    CleanupStack::PopAndDestroy(); // temp
+    CleanupStack::PopAndDestroy(); //buffer
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+LOCAL_C void WriteNewFileL(
+    RFs& aFs,
+    RFile& aOriginalFile,
+    COma1Dcf& aDcf)
+    {
+    TPtrC tempFilePath;
+    HBufC8* buffer = NULL;
+    RFile tempFileHandle;
+    RFileWriteStream temp;
+    RFileWriteStream orig;
+    TFileName tempFile;
+    TPtr8 ptr(NULL, 0, 0);
+    TInt offset = 0;
+    TInt fileSize = 0;
+    
+    // Find the path of the file to be modified and put the tempfile
+    // into that directory
+    tempFilePath.Set(_L("C:\\"));
+    User::LeaveIfError( temp.Temp( aFs, tempFilePath, tempFile, 
+                        EFileWrite));
+    CleanupClosePushL( temp );
+    
+    temp.WriteUint8L(1);
+    temp.WriteUint8L(aDcf.iMimeType->Length());
+    temp.WriteUint8L(aDcf.iContentID->Length());
+    temp.WriteL(*aDcf.iMimeType);
+    temp.WriteL(*aDcf.iContentID);
+    buffer = TWspPrimitiveEncoder::UintVarL(aDcf.iHeaders->Length());
+    CleanupStack::PushL(buffer);
+    temp.WriteL(*buffer);
+    CleanupStack::PopAndDestroy(buffer);
+    buffer = TWspPrimitiveEncoder::UintVarL(aDcf.iDataLength);
+    CleanupStack::PushL(buffer);
+    temp.WriteL(*buffer);
+    CleanupStack::PopAndDestroy(buffer);
+    temp.WriteL(*aDcf.iHeaders);
+
+    offset = aDcf.iOffset;
+    User::LeaveIfError(aOriginalFile.Seek(ESeekStart, offset));
+    buffer = HBufC8::NewLC(KBufferSize);
+    do
+        {
+        ptr.Set(buffer->Des());
+        ptr.SetLength(0);
+        aOriginalFile.Read(ptr);         
+        if (ptr.Length() > 0)
+            {
+            temp.WriteL(ptr);
+            }
+        }
+    while (ptr.Length() > 0);
+    temp.CommitL();
+    
+    CleanupStack::PopAndDestroy(2); //buffer, temp
+    // Get the size of the temp file
+
+
+    User::LeaveIfError( tempFileHandle.Open( aFs, tempFile, EFileRead ));
+    CleanupClosePushL( tempFileHandle );    
+    tempFileHandle.Size( fileSize );               
+    
+    
+    // Set the fileSize of the original file
+    User::LeaveIfError( aOriginalFile.SetSize( fileSize ) );
+    offset = 0;
+    User::LeaveIfError( tempFileHandle.Seek( ESeekStart, offset ) );
+    orig.Attach( aOriginalFile );
+    CleanupClosePushL( orig );
+     
+    buffer = HBufC8::NewLC(KBufferSize);    
+    // Copy the file over because we can't use other copy things:
+    do
+        {
+        ptr.Set(buffer->Des());
+        ptr.SetLength(0);
+        tempFileHandle.Read(ptr);         
+        if (ptr.Length() > 0)
+            {
+            orig.WriteL(ptr);
+            }
+        }
+    while (ptr.Length() > 0);
+    
+    // Write the changes    
+    orig.CommitL();
+    
+    // close the tempfile
+    CleanupStack::PopAndDestroy(3); // buffer, tempFileHandle, orig
+    
+    // Delete the temp file
+    User::LeaveIfError( aFs.Delete( tempFile ) );
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+LOCAL_C void SetFileHeaderL(
+    const TDesC16& aFileName, 
+    const TDesC8& aHeaderName, 
+    const TDesC8& aHeaderValue)
+    {
+    __UHEAP_MARK;
+    TFileName tempFileName;
+    HBufC8* newHeaderBuf = NULL;
+    COma1Dcf* dcf = NULL;
+    RFs fs;
+    RFile file;
+
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    User::LeaveIfError( GetFileHandleRead( fs, file, aFileName ) );
+
+    CleanupClosePushL(file);
+    dcf = COma1Dcf::NewL(file);
+    
+    CleanupStack::PushL(dcf);
+    GetNewHeaderBufferL(dcf->iHeaders, aHeaderName, aHeaderValue, newHeaderBuf);
+    delete dcf->iHeaders;
+    dcf->iHeaders = newHeaderBuf;
+    dcf->iHeaderLength = newHeaderBuf->Length();
+    WriteNewFileL( fs, file, aFileName, *dcf, tempFileName );
+    CleanupStack::PopAndDestroy(2); // file, dcf
+    User::LeaveIfError( fs.Replace( tempFileName, aFileName ) );
+    CleanupStack::PopAndDestroy(); // fs
+    
+    __UHEAP_MARKEND;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+LOCAL_C void SetFileHeaderL(
+    RFile& aFileHandle, 
+    const TDesC8& aHeaderName, 
+    const TDesC8& aHeaderValue)
+    {
+    HBufC8* newHeaderBuf = NULL;
+    COma1Dcf* dcf = NULL;
+    RFs fs;
+    
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL( fs );
+    
+    dcf = COma1Dcf::NewL(aFileHandle);
+    if (dcf == NULL)
+        {
+        User::Leave(KErrArgument);
+        }
+    CleanupStack::PushL(dcf);
+    GetNewHeaderBufferL(dcf->iHeaders, aHeaderName, aHeaderValue, newHeaderBuf);
+    delete dcf->iHeaders;
+    dcf->iHeaders = newHeaderBuf;
+    dcf->iHeaderLength = newHeaderBuf->Length();
+    WriteNewFileL(fs, aFileHandle, *dcf);
+    CleanupStack::PopAndDestroy(2); // dcf, fs
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+void SetContentHeaderL(
+    HBufC8*& aContent, 
+    const TDesC8& aHeaderName, 
+    const TDesC8& aHeaderValue)
+    {
+    HBufC8* newHeaderBuf = NULL;
+    HBufC8* newContent = NULL;
+    HBufC8* buffer;
+    COma1Dcf* dcf = NULL;
+    TPtr8 ptr(0, 0);
+
+    dcf = COma1Dcf::NewL(*aContent);
+    if (dcf == NULL)
+        {
+        User::Leave(KErrArgument);
+        }
+    CleanupStack::PushL(dcf);
+    GetNewHeaderBufferL(dcf->iHeaders, aHeaderName, aHeaderValue, newHeaderBuf);
+    delete dcf->iHeaders;
+    dcf->iHeaders = newHeaderBuf;
+    dcf->iHeaderLength = newHeaderBuf->Length();
+    newContent = HBufC8::NewLC(3 +
+        dcf->iContentID->Length() + dcf->iMimeType->Length() + 2 * 5 +
+        dcf->iHeaderLength + dcf->iDataLength);
+    ptr.Set(newContent->Des());
+    ptr.Append(1);
+    ptr.Append(dcf->iMimeType->Length());
+    ptr.Append(dcf->iContentID->Length());
+    ptr.Append(*dcf->iMimeType);
+    ptr.Append(*dcf->iContentID);
+    buffer = TWspPrimitiveEncoder::UintVarL(dcf->iHeaders->Length());
+    CleanupStack::PushL(buffer);
+    ptr.Append(*buffer);
+    CleanupStack::PopAndDestroy(buffer);
+    buffer = TWspPrimitiveEncoder::UintVarL(dcf->iDataLength);
+    CleanupStack::PushL(buffer);
+    ptr.Append(*buffer);
+    CleanupStack::PopAndDestroy(buffer);
+    ptr.Append(*dcf->iHeaders);
+    ptr.Append(aContent->Right(dcf->iDataLength));
+    CleanupStack::Pop(newContent);
+    CleanupStack::PopAndDestroy(dcf);
+    delete aContent;
+    aContent = newContent;
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+void GetHeaderL(
+    const TDesC8& aContent, 
+    const TDesC8& aHeaderName, 
+    HBufC8*& aHeaderValue)
+    {
+    
+    TInt i;
+    TInt j;
+    TPtrC8 ptr( aContent );
+    
+    // Add Room for CRLF and Semicolon:
+    HBufC8* buffer = HBufC8::NewMaxLC( aHeaderName.Length() + 3 );  
+    TPtr8 searchBuf( const_cast<TUint8*>(buffer->Ptr()), 0, buffer->Des().MaxSize() );  
+
+    searchBuf.Copy(aHeaderName);
+    searchBuf.Append(KHeaderNameEnding);
+    
+    // First see if the     
+    i = ptr.Find(searchBuf);
+    User::LeaveIfError( i );
+        
+    if( i > 0 )
+        {
+        // if it's not the first one, use the search buffer:
+        // Create the search buffer
+        searchBuf.Copy(KHeaderEnding);
+        searchBuf.Append(aHeaderName);
+        searchBuf.Append(KHeaderNameEnding);
+    
+        // First see if the     
+        i = ptr.Find(searchBuf);
+        User::LeaveIfError( i );      
+        }
+    // Move search buffer    
+    i += searchBuf.Length();  
+    
+    j = ptr.Mid(i).Find(KHeaderEnding);
+    User::LeaveIfError( j );
+            
+    aHeaderValue = ptr.Mid(i, j).AllocL();  
+    CleanupStack::PopAndDestroy(); // buffer  
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+void GetContentHeaderL(
+    const TDesC8& aContent, 
+    const TDesC8& aHeaderName, 
+    HBufC8*& aHeaderValue)
+    {
+    COma1Dcf* dcf = NULL;
+
+    dcf = COma1Dcf::NewL(aContent);
+    CleanupStack::PushL(dcf);
+    GetHeaderL(*dcf->iHeaders, aHeaderName, aHeaderValue);
+    CleanupStack::PopAndDestroy(); // dcf
+    }
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+void GetFileHeaderL(
+    const TFileName& aFileName, 
+    const TDesC8& aHeaderName, 
+    HBufC8*& aHeaderValue)
+    {
+    RFs fs;
+    RFile file;
+
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    User::LeaveIfError( GetFileHandleRead( fs, file, aFileName ) );
+
+    CleanupClosePushL(file);
+    GetFileHeaderL(file, aHeaderName, aHeaderValue);
+    CleanupStack::PopAndDestroy(2); // fs, file
+    }
+
+// -----------------------------------------------------------------------------
+// 
+//
+// Parameters:
+//
+// Returns:
+// -----------------------------------------------------------------------------
+void GetFileHeaderL(
+    RFile& aFileHandle, 
+    const TDesC8& aHeaderName, 
+    HBufC8*& aHeaderValue)
+    {
+    CDcfCommon* dcf = NULL;
+
+    aHeaderValue = NULL;
+    dcf = CDcfCommon::NewL(aFileHandle);
+    if (dcf == NULL)
+        {
+        User::Leave(KErrArgument);
+        }
+    CleanupStack::PushL(dcf);
+    if (dcf->iVersion == EOma1Dcf)
+        {
+        GetHeaderL(*static_cast<COma1Dcf*>(dcf)->iHeaders, aHeaderName,
+            aHeaderValue);
+        }
+    else
+        {
+        if (aHeaderName.Compare(KRiUrl) == 0 && dcf->iRightsIssuerURL != NULL)
+            {
+            aHeaderValue = dcf->iRightsIssuerURL->AllocL();
+            }
+        }
+    CleanupStack::PopAndDestroy(); // dcf
+    }
+
+// -----------------------------------------------------------------------------
+// DynamicDataTypesCount: Returns the number of supported dynamic datatypes
+//
+// Parameters:
+//      aCount: out parameter for the number of dynamically registered data
+//          types
+//
+// Returns:
+//      DRMCommon::EOk: Count returned successfully
+// -----------------------------------------------------------------------------
+LOCAL_C TInt DynamicDataTypesCount(
+    TInt& aCount)
+    {
+    TInt err = 0;
+    TDataType type;
+    RFs fs;
+    RFileReadStream reader;    
+    
+    aCount = 0;
+    err = fs.Connect();
+    if (!err) 
+        {
+        
+#ifndef RD_MULTIPLE_DRIVE
+        
+    err = reader.Open(fs, KDataTypesFile, EFileRead);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    fs.DriveToChar( driveNumber, driveLetter );
+    
+    TFileName dataTypesFile;
+	dataTypesFile.Format( KDataTypesFile, (TUint)driveLetter );
+          
+    err = reader.Open(fs, dataTypesFile, EFileRead);
+    
+#endif
+        
+        if (err == KErrNotFound)
+            {
+            err = DRMCommon::EOk;
+            }
+        else
+            {
+            while (err == KErrNone)
+                {
+                TRAP(err, (reader >> type));
+                if (err == KErrNone) aCount++;
+                }
+            
+            if (err == KErrEof)
+                {
+                err = DRMCommon::EOk;
+                }
+            
+            reader.Release();
+            reader.Close();
+            }
+        }
+    
+    fs.Close();
+    
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// SupportedDynamicDataType: Returns a registered dynamic datatype
+//
+// Parameters:
+//      aIndex: index of the dynamic data type
+//      aDataType: out parameter for the data type
+//
+// Returns:
+//      DRMCommon::EOk: Data type returned successfully
+//      KErrEof: Data type not found
+// -----------------------------------------------------------------------------
+LOCAL_C TInt SupportedDynamicDataType(
+    const TInt aIndex, 
+    TDataType& aDataType)
+    {
+    TInt err = KErrNone;
+    TInt i;
+    RFs fs;
+    TDataType type;
+    RFileReadStream reader;
+    
+    err = fs.Connect();
+    if (!err) 
+        {
+        
+#ifndef RD_MULTIPLE_DRIVE
+        
+        err = reader.Open(fs, KDataTypesFile, EFileRead);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    	fs.DriveToChar( driveNumber, driveLetter );
+        
+    	TFileName dataTypesFile;
+	    dataTypesFile.Format( KDataTypesFile, (TUint)driveLetter );
+        
+        err = reader.Open(fs, dataTypesFile, EFileRead);
+    
+#endif
+        
+        if (!err) 
+            {
+            i = -1;
+            while (err == 0 && i != aIndex) 
+                {
+                TRAP(err, (reader >> type));
+                i++;
+                }
+            
+            if (!err)
+                {
+                aDataType = type;  
+                }
+            
+            reader.Release();
+            reader.Close();
+            }
+        }
+    
+    fs.Close();
+    
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// SupportedStaticDataType: Returns a static DRM datatype
+//
+// Parameters:
+//      aIndex: index of the dynamic data type
+//      aDataType: out parameter for the data type
+//
+// Returns:
+//      DRMCommon::EOk: Data type returned successfully
+//      KErrEof: Data type not found
+// -----------------------------------------------------------------------------
+LOCAL_C TInt SupportedStaticDataType(
+    const TInt aIndex, 
+    TDataType& aDataType)
+    {
+    TInt err = 0;
+    TInt index = 0;
+    TInt length = 0;
+    TInt i = 0;
+    RFs fs;
+    RResourceFile resourceFile;
+    HBufC8* res = NULL;
+    TResourceReader theReader;
+    
+    err = fs.Connect();
+    if (err)
+        {
+        fs.Close();
+        return err;
+        }
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    TRAP(err, resourceFile.OpenL(fs, KResourceFile));
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+    fs.DriveToChar( driveNumber, driveLetter );
+    
+    TFileName resFile;
+	resFile.Format( KResourceFile, (TUint)driveLetter );
+    
+    TRAP(err, resourceFile.OpenL(fs, resFile));
+    
+#endif
+    if (err)
+        {
+        fs.Close();
+        return err;
+        }
+    
+    TRAP(err, (res = resourceFile.AllocReadL(DATATYPE))); 
+    if (err)
+        {
+        resourceFile.Close();
+        fs.Close();
+        return err;
+        }
+    
+    theReader.SetBuffer(res);
+    index = aIndex + 1;
+    TPtrC temp16(theReader.ReadTPtrC(index, res));
+    length = temp16.Length();
+    HBufC8* temp = NULL;
+    temp = HBufC8::NewMax(length); 
+    if (temp)
+        {
+        TPtr8 ptr(temp->Des());
+        ptr.SetLength(length);
+        for (i = 0; i < length; i++)
+            {
+            ptr[i] = (unsigned char) temp16[i];
+            }
+        aDataType = TDataType(ptr);
+        }
+    else
+        {
+        err = KErrNoMemory;
+        }
+    
+    if (temp) 
+        {
+        delete temp;
+        }
+    
+    temp = NULL;
+    resourceFile.Close();
+    if (res) 
+        {
+        delete res;
+        }
+    
+    res = NULL;
+    fs.Close();
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// UnRegisterDynamicDataTypeL: Unregister one of the dynamically addable data
+//      types
+//
+// Parameters:
+//      aIndex: index of the data type in the list of dynamic types
+//
+// Returns:
+//      DRMCommon::EOK: Data type removed successfully
+// -----------------------------------------------------------------------------
+LOCAL_C TInt UnRegisterDynamicDataTypeL(
+    const TInt aIndex)
+    {
+    TInt r;
+    TInt i;
+    TDataType type;
+    RFileWriteStream writer;
+    RFileReadStream reader;
+    RFs fs;
+    
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    
+    // Open the data types file
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    User::LeaveIfError(reader.Open(fs, KDataTypesFile, EFileRead));
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    fs.DriveToChar( driveNumber, driveLetter );
+    
+    TFileName dataTypesFile;
+	dataTypesFile.Format( KDataTypesFile, (TUint)driveLetter );
+    
+    User::LeaveIfError(reader.Open(fs, dataTypesFile, EFileRead));
+    
+#endif
+    
+    CleanupReleasePushL(reader);
+    
+    // Create and open a replacement file
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    User::LeaveIfError(writer.Replace(fs, KTempFile, EFileWrite));
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TFileName tempFile;
+    tempFile.Format( KTempFile, (TUint)driveLetter );
+    
+    User::LeaveIfError(writer.Replace(fs, tempFile, EFileWrite));
+    
+#endif
+    
+    CleanupReleasePushL(writer);
+    
+    // Write all dynamic types into the replacement file, excluding the
+    // data type to be removed
+    
+    r = KErrNone;
+    for (i = 0; r == KErrNone; i++)
+        {
+        TRAP(r, reader >> type);
+        if (r == KErrNone && i != aIndex)
+            {
+            writer << type;
+            writer.CommitL();
+            }
+        }
+    CleanupStack::PopAndDestroy();
+    CleanupStack::PopAndDestroy();
+    
+    // Replace the data type file with the replacement file
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    fs.Replace(KTempFile, KDataTypesFile);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    fs.Replace(tempFile, dataTypesFile);
+    
+#endif
+    
+    
+    CleanupStack::PopAndDestroy();
+    
+    return DRMCommon::EOk;
+    }
+
+// -----------------------------------------------------------------------------
+// RegisterDynamicDataTypeL: Register a new dynamically addable data type
+//
+// Parameters:
+//      aDataType: new type to be added
+//
+// Returns:
+//      DRMCommon::EOK: Data type removed successfully
+// -----------------------------------------------------------------------------
+LOCAL_C TInt RegisterDynamicDataTypeL(const TDataType& aDataType)
+    {
+    TInt err = KErrNone;
+    TDataType type;
+    RFileWriteStream writer;
+    RFileReadStream reader;
+    RFs fs;
+    
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    
+    // Create and open a replacement file
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    User::LeaveIfError(writer.Replace(fs, KTempFile, EFileWrite));
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    fs.DriveToChar( driveNumber, driveLetter );
+    
+    TFileName tempFile;
+	tempFile.Format( KTempFile, (TUint)driveLetter );
+    
+    User::LeaveIfError(writer.Replace(fs, tempFile, EFileWrite));
+    
+#endif
+    
+    CleanupReleasePushL(writer);
+    
+    // Write the new data type into the replacement file
+    
+    writer << aDataType;
+    writer.CommitL();
+    
+    // Write all other dynamic types into the replacement file
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    err = reader.Open(fs, KDataTypesFile, EFileRead);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TFileName dataTypesFile;
+    dataTypesFile.Format( KDataTypesFile, (TUint)driveLetter );
+    
+    err = reader.Open(fs, dataTypesFile, EFileRead);
+    
+#endif
+    
+    if (err == KErrNone)
+        {
+        CleanupReleasePushL(reader);
+        while (err == KErrNone)
+            {
+            TRAP(err, (reader >> type, writer << type, writer.CommitL()));
+            }
+        CleanupStack::PopAndDestroy();
+        }
+    
+    CleanupStack::PopAndDestroy();
+    
+    // Replace the data type file with the replacement file
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    fs.Replace(KTempFile, KDataTypesFile);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    fs.Replace(tempFile, dataTypesFile);
+    
+#endif
+    
+    CleanupStack::PopAndDestroy();
+    
+    return DRMCommon::EOk;
+    }
+
+TInt CalculatePaddingL(COma1Dcf* dcf)
+    {
+    RDRMRightsClient rdb;
+    TBuf8<KDCFKeySize * 2> blocks;
+    TInt pos;
+    TBool blocksValid = ETrue;
+
+    if (!dcf->iPlainTextLengthValid)
+        {
+        User::LeaveIfError(rdb.Connect());
+        CleanupClosePushL(rdb);
+        if (dcf->iFile.SubSessionHandle() != KNullHandle)
+            {
+            pos = dcf->iOffset + dcf->iDataLength - 2 * KDCFKeySize;
+            dcf->iFile.Seek(ESeekStart, pos);
+            dcf->iFile.Read(blocks);
+            }
+        else if (dcf->iData->Length() >= dcf->iOffset + dcf->iDataLength)
+            {
+            blocks.Copy(&(dcf->iData->Des())[dcf->iOffset +
+                dcf->iDataLength - 2 * KDCFKeySize],
+                KDCFKeySize * 2);
+            }
+        else
+            {
+            blocksValid = EFalse;
+            }
+
+        if (blocksValid && rdb.InitializeKey(*dcf->iContentID) == KErrNone)
+            {
+            dcf->iPadding = rdb.CalculatePadding(blocks);
+            if (dcf->iPadding >= 0)
+                {
+                dcf->iPlainTextLength -= dcf->iPadding;
+                dcf->iPlainTextLengthValid = ETrue;
+                }
+            }
+        CleanupStack::PopAndDestroy(); // rdb
+        }
+
+    return dcf->iPadding;
+    }
+    
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// DRMCommon::DRMCommon
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+EXPORT_C DRMCommon::DRMCommon(void)
+    {
+    } 
+
+// -----------------------------------------------------------------------------
+// DRMCommon::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+EXPORT_C void DRMCommon::ConstructL()
+    {
+    } 
+
+// -----------------------------------------------------------------------------
+// DRMCommon::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+EXPORT_C DRMCommon* DRMCommon::NewL()
+    {
+    DRMCommon* self = new(ELeave) DRMCommon();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(); // self
+    return self;
+    }
+
+
+// Destructor
+EXPORT_C DRMCommon::~DRMCommon()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::CheckContentRights
+// Checks if the give rights for a specific content URI are available.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::CheckContentRights(
+    const TDesC8& aContentID, 
+    TUint32 aRightsSpec)
+    {
+    TInt r = ENoRights;
+    RDRMRightsClient client;
+    TUint32 reason = 0;
+    
+    if (client.Connect() == KErrNone)
+        {
+        r = client.CheckRights(aRightsSpec, aContentID, reason);
+        client.Close();
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::CheckFileRights
+// Checks if the give rights for a specific content URI are available by
+// opening a given file and reading the content URI from there.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::CheckFileRights(
+    const TDesC& aFileName, 
+    TUint32 aRightsSpec)
+    {
+    TInt r = KErrNone;
+    TInt retValue = KErrNone;
+    TRAP(r, retValue = CheckFileRightsL(aFileName, aRightsSpec));
+    if (r != KErrNone)
+        {
+        return r;
+        }
+    return retValue;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::CheckFileRights
+// Checks if the give rights for a specific content URI are available by
+// opening a given file and reading the content URI from there.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::CheckFileRights(
+    RFile& aFileHandle, 
+    TUint32 aRightsSpec)
+    {
+    TInt r = KErrNone;
+    TInt retValue = KErrNone;
+    TRAP(r, retValue = CheckFileRightsL(aFileHandle, aRightsSpec));
+    if (r != KErrNone)
+        {
+        return r;
+        }
+    return retValue;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::IsProtectedContent
+// Check if a memory buffer contains DRM proteced content by looking for a
+// predefined header string.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::IsProtectedContent(
+    const TDesC8& aContent, 
+    TBool& aProtection)
+    {
+    if (COma1Dcf::IsValidDcf(aContent) || COma2Dcf::IsValidDcf(aContent))
+        {
+        aProtection = ETrue;
+        }
+    else
+        {
+        aProtection = EFalse;
+        }
+    return EOk;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::IsProtectedFile
+// Check if a file contains DRM proteced content by looking for a
+// predefined header string.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::IsProtectedFile(
+    const TDesC& aFileName, 
+    TBool& aProtection)
+    {
+    TInt r = KErrNone;
+    TRAP(r, IsProtectedFileL(aFileName, aProtection));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::IsProtectedFile
+// Check if a file contains DRM proteced content by looking for a
+// predefined header string.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::IsProtectedFile(
+    RFile& aFileHandle, 
+    TBool& aProtection)
+    {
+    TInt r = KErrNone;
+    TRAP(r, IsProtectedFileL(aFileHandle, aProtection));
+    return r;
+    }
+    
+// -----------------------------------------------------------------------------
+// DRMCommon::GetContentInfo
+// Returns DRM information about a memory buffer.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetContentInfo(
+    const TDesC8& aContent, 
+    TContentProtection& aProtection, 
+    HBufC8*& aMIMEType, 
+    HBufC8*& aContentURI, 
+    TUint& aDataLength)
+    {
+    TInt r = KErrNone;
+    TRAP(r, GetContentInfoL(aContent, aProtection, aMIMEType, aContentURI, 
+        aDataLength));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::GetFileInfo
+// Returns DRM information about a file.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetFileInfo(
+    const TDesC& aFileName, 
+    TContentProtection& aProtection, 
+    HBufC8*& aMIMEType, 
+    HBufC8*& aContentURI, 
+    TUint& aDataLength)
+    {
+    TInt r = KErrNone;
+    TRAP(r, GetFileInfoL(aFileName, aProtection, aMIMEType, aContentURI, 
+        aDataLength));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::GetFileInfo
+// Returns DRM information about a file.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetFileInfo(
+    RFile& aFileHandle, 
+    TContentProtection& aProtection, 
+    HBufC8*& aMIMEType, 
+    HBufC8*& aContentURI, 
+    TUint& aDataLength)
+    {
+    TInt r = KErrNone;
+    TRAP(r, GetFileInfoL(aFileHandle, aProtection, aMIMEType, aContentURI, 
+        aDataLength));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::GetContentHeader
+// Returns an optional header from a memory buffer containing encrypted content.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetContentHeader(
+    const TDesC8& aContent, 
+    const TDesC8& aHeaderName, 
+    HBufC8*& aHeaderValue)
+    {
+    TInt r = KErrNone;
+
+    TRAP(r, GetContentHeaderL(aContent, aHeaderName, aHeaderValue));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::GetFileHeader
+// Returns an optional header from a file containing encrypted content.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetFileHeader(
+    const TFileName& aFileName, 
+    const TDesC8& aHeaderName, 
+    HBufC8*& aHeaderValue)
+    {
+    TInt r = KErrNone;
+
+    TRAP(r, GetFileHeaderL(aFileName, aHeaderName, aHeaderValue));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::GetFileHeader
+// Returns an optional header from a file containing encrypted content.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetFileHeader(
+    RFile& aFileHandle, 
+    const TDesC8& aHeaderName, 
+    HBufC8*& aHeaderValue)
+    {
+    TInt r = KErrNone;
+
+    TRAP(r, GetFileHeaderL(aFileHandle, aHeaderName, aHeaderValue));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMAuthenticated::SetContentHeader
+// Sets the specified optional header field of a DCF buffer.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::SetContentHeader(
+    HBufC8*& aContent, 
+    const TDesC8& aHeaderName, 
+    const TDesC8& aHeaderValue)
+    {
+    TInt r = KErrNone;
+
+    TRAP(r, SetContentHeaderL(aContent, aHeaderName, aHeaderValue));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::SetContentHeader
+// Sets the specified optional header field of a DCF buffer.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::SetFileHeader(
+    const TDesC16& aFileName, 
+    const TDesC8& aHeaderName, 
+    const TDesC8& aHeaderValue)
+    {
+    TInt r = KErrNone;
+
+    TRAP(r, SetFileHeaderL(aFileName, aHeaderName, aHeaderValue));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::SetContentHeader
+// Sets the specified optional header field of a DCF buffer.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::SetFileHeader(
+    RFile& aFileHandle, 
+    const TDesC8& aHeaderName, 
+    const TDesC8& aHeaderValue)
+    {
+    TInt r = KErrNone;
+
+    TRAP(r, SetFileHeaderL(aFileHandle, aHeaderName, aHeaderValue));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::GetSingleRightsObject
+// Looks up the rights object using the content URI and the local ID.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetSingleRightsObject(
+    const TDesC8& aContentURI, 
+    TUint32 aLocalID, 
+    CDRMRights*& aRightsObject)
+    {
+    TInt r = KErrNone;
+    TRAP(r, GetSingleRightsObjectL(aContentURI, aLocalID, aRightsObject));
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::GetDetailedContentRights
+// Returns all rights objects for a content URI
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetDetailedContentRights(
+    const TDesC8& aContentURI, 
+    RPointerArray<CDRMRights>*& aRightsList)
+    {
+    TInt r = KErrNone;
+
+    TRAP(r, GetDetailedContentRightsL(aContentURI, aRightsList));
+    if (r == KErrNone)
+        {
+        AddParents( const_cast<DRMCommon*>(this), *aRightsList );
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::GetDetailedFileRights
+// Returns all rights objects for a content URI from a given file
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetDetailedFileRights(
+    const TDesC& aFileName, 
+    RPointerArray<CDRMRights>*& aRightsList)
+    {
+    TInt r = KErrNone;
+
+    TRAP(r, GetDetailedFileRightsL(aFileName, aRightsList));
+    if (r == KErrNone)
+        {
+        AddParents( const_cast<DRMCommon*>(this), *aRightsList );
+        }
+    return r;
+    }
+    
+// -----------------------------------------------------------------------------
+// DRMCommon::GetDetailedFileRights
+// Returns all rights objects for a content URI from a given file
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetDetailedFileRights(
+    RFile& aFileHandle, 
+    RPointerArray<CDRMRights>*& aRightsList)
+    {
+    TInt r = KErrNone;
+
+    TRAP(r, GetDetailedFileRightsL(aFileHandle, aRightsList));
+    if (r == KErrNone)
+        {
+        AddParents( const_cast<DRMCommon*>(this), *aRightsList );
+        }
+    return r;
+    }    
+
+// -----------------------------------------------------------------------------
+// DRMCommon::GetActiveRights
+// Returns a possible active rights object
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetActiveRights(
+    const TDesC8& aContentURI,
+    TUint32 aConstraints,
+    CDRMRights*& aRightsObject)
+    {
+    TInt r = KErrNone;
+    
+    TRAP( r, GetActiveRightsL( aContentURI, aConstraints, aRightsObject ) );
+    if(r != KErrNone)
+        {
+        return DRMCommon::ENoRights;    
+        }
+    else 
+        {
+        CDRMRights::TRestriction restriction;
+        CDRMRights::TExpiration expiration;
+        TUint32 constType(0);
+        aRightsObject->GetRightsInfo(aConstraints, restriction, expiration, constType);
+        return restriction;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::GetContentURIList
+// Returns a list of all content URIs that have rights in the rights database.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::GetContentURIList(
+    RPointerArray<HBufC8>*& aURIList)
+    {
+    RDRMRightsClient client;
+    TInt error = client.Connect();
+    
+    aURIList = NULL;
+    if (!error)
+        {
+        aURIList = new RPointerArray<HBufC8>(10);
+        if (aURIList)
+            {
+            error = client.ExportContentIDList(*aURIList);
+            if (error)
+                {
+                aURIList->ResetAndDestroy();
+                aURIList->Close();
+                delete aURIList;
+                aURIList = NULL;
+                }
+            }
+        else
+            {
+            error = KErrNoMemory;
+            }
+        client.Close();
+        }
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::Connect
+// Does nothing
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::Connect()
+    {
+    RDRMRightsClient client; // Used to start RightsServer in bootup
+    TInt ignore = 0;				 // error will be ignored, if it fails to start the
+                             // rights server there is nothing we can really
+                             // do about it, and normally this would work and
+                             // return AOk, just used because of the SkinSrv
+                             // Bootup thing
+    ignore = client.Connect();        // Called by SkinSrv during bootup
+		if( ignore ) 
+		    {
+		    // The error shouldn't matter since it will be retried	
+		    }
+    client.Close();
+    return EOk;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::Disconnect
+// Does nothing
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::Disconnect()
+    {
+    return EOk;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::SupportedDRMMethods
+// Returns the implementation level of the DRM system.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::SupportedDRMMethods(
+    TInt& aDRMMethod, TOMALevel& aOMALevel)
+    {
+    aDRMMethod =
+        DRMCommon::EForwardLock |
+        DRMCommon::ECombinedDelivery |
+        DRMCommon::ESeparateDelivery |
+        DRMCommon::ESuperDistribution;
+#ifdef __DRM_OMA2
+    aOMALevel = EOMA_2_0;
+#else
+    aOMALevel = EOMA_1_0;
+#endif
+    return EOk;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::Version
+// Returns the client side API version.
+// -----------------------------------------------------------------------------
+EXPORT_C TVersion DRMCommon::Version()
+    {
+    return TVersion(KClientVersionMajor, 
+        KClientVersionMinor, 
+        KClientVersionBuild);
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::ServerVersion
+// Returns the version of the DRM engine.
+// -----------------------------------------------------------------------------
+EXPORT_C TVersion DRMCommon::ServerVersion()
+    {
+    return TVersion(KServerVersionMajor, 
+        KServerVersionMinor, 
+        KServerVersionBuild);
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::DataTypesCount
+// Returns the number of MIME types the DRM system understands.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::DataTypesCount(
+    TInt& aCount)
+    {
+    TInt err = 0;
+    TInt staticTotal = 0;
+    TInt dynamicTotal = 0;
+    
+    err = StaticDataTypesCount(staticTotal);    
+    if (err)
+        {
+        return err;  
+        }
+    
+    err = DynamicDataTypesCount(dynamicTotal);
+    if (err)
+        {
+        return err;  
+        }
+    
+    aCount = staticTotal + dynamicTotal;
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::SupportedDataType
+// Returns a specific DRM enabled MIME type.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::SupportedDataType(
+    const TInt aIndex, 
+    TDataType& aDataType)
+    {
+    TInt err = KErrNone;
+    TInt total = 0;
+    TInt stat = 0;
+    
+    err = DataTypesCount(total);
+    if (!err) err = StaticDataTypesCount(stat);
+    if (!err)
+        {
+        if (0 <= aIndex && aIndex < stat)
+            {
+            err = SupportedStaticDataType(aIndex, aDataType);
+            }
+        else if (stat <= aIndex && aIndex < total)
+            {
+            err = SupportedDynamicDataType(aIndex - stat, aDataType);
+            }
+        else
+            {
+            err = KErrArgument;
+            }
+        }
+    
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::StaticDataTypesCount
+// Returns the number of supported built-in datatypes.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::StaticDataTypesCount(
+    TInt& aCount)
+    {
+    TInt err = 0;
+    RFs fs;
+    RResourceFile resourceFile;
+    TResourceReader theReader;
+    
+    err = fs.Connect();
+    
+    if (err)
+        {
+        fs.Close();
+        return err;
+        }
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    TRAP(err, resourceFile.OpenL(fs, KResourceFile));
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+    fs.DriveToChar( driveNumber, driveLetter );
+    
+    TFileName resFile;
+	resFile.Format( KResourceFile, (TUint)driveLetter );
+    
+    TRAP(err, resourceFile.OpenL(fs, resFile));
+    
+#endif
+    if (err)
+        {
+        fs.Close();
+        return err;
+        }
+    
+    HBufC8* res = NULL;
+    TRAP(err, (res = resourceFile.AllocReadL(DATATYPE))); 
+    if (err)
+        {
+        resourceFile.Close();
+        fs.Close();
+        return err;
+        }
+    
+    
+    theReader.SetBuffer(res);
+    aCount = theReader.ReadInt8();
+    
+    delete res;
+    res = NULL;
+    resourceFile.Close();
+    fs.Close();
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::RegisterDataType
+// Register a MIME type as being handled by the DRM system.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::RegisterDataType(
+    const TDataType& aDataType)
+    {
+    TInt total = 0;
+    TInt err = KErrNone;
+    TInt i;
+    TDataType type;
+    
+    if (aDataType.Des().Length() > 0)
+        {
+        err = DataTypesCount(total);
+        for (i = 0 ; err == KErrNone && i < total ; i++)
+            {
+            err = SupportedDataType(i, type);
+            if (type == aDataType)
+                {
+                err = KErrAlreadyExists;   
+                }
+            }
+        
+        if (!err)
+            {
+            TRAP(err, RegisterDynamicDataTypeL(aDataType));
+            }
+        }
+    else
+        {
+        err = KErrArgument;  
+        }
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::UnRegisterDataType
+// Unregister a MIME type as being handled by the DRM system.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::UnRegisterDataType(
+    const TInt aIndex)
+    {
+    TInt r;
+    TInt count;
+    TInt total;
+    
+    StaticDataTypesCount(count);
+    r = DataTypesCount(total);
+    if (r == KErrNone && aIndex >= count && aIndex < total)
+        {
+        TRAP(r, UnRegisterDynamicDataTypeL(aIndex - count));
+        }
+    else
+        {
+        r = KErrArgument;
+        }
+    return r;
+    }
+
+
+// -----------------------------------------------------------------------------
+// DRMCommon::MergeParentAndChild
+// Merge rights with their parent rights
+// -----------------------------------------------------------------------------
+EXPORT_C void DRMCommon::MergeParentAndChild(CDRMRights* /*aRights*/)
+    {
+    return;
+    /*
+    HBufC8* parent = aRights->GetPermission().iParentUID;
+    if (parent != NULL)
+        {
+        RPointerArray<CDRMRights>* parents;
+        if (GetDetailedContentRights(*parent, parents) == KErrNone &&
+            parents->Count() > 0)
+            {
+            TBool merged = EFalse;
+            for (TInt i = 0; !merged && i < parents->Count(); i++)
+                {
+                CDRMRights::TRestriction restriction;
+                CDRMRights::TExpiration expiration;
+                TUint32 constraints;
+                aRights->GetRightsInfo(EUnknown, restriction, expiration, 
+                    constraints);
+                if ( expiration == CDRMRights::EValidRights)
+                    {
+                    aRights->Merge(*(*parents)[i]);
+                    merged = ETrue;
+                    }
+                }
+            parents->ResetAndDestroy();
+            delete parents;
+            }
+        }
+    */    
+    }
+ 
+ 
+ 
+
+// -----------------------------------------------------------------------------
+// GetFileHandle
+// Get a file name trying to open it in the order required, which is:
+// 1)  EFileShareReadersOrWriters
+// 2)  EFileShareAny
+// 3)  EFileShareReadersOnly
+// -----------------------------------------------------------------------------
+LOCAL_C TInt GetFileHandleRead(
+    RFs& aFileServer, 
+    RFile& aFile, 
+    const TDesC& aFileName )
+    {
+    TInt error = KErrNone;
+
+    // 1) Try to open in EFileShareReadersOrWriters
+    error = aFile.Open( aFileServer, aFileName, EFileRead | EFileShareReadersOrWriters );
+    if( error != KErrNone )
+        {
+        // 2) Try to open in EFileShareAny
+        error = aFile.Open( aFileServer, aFileName, EFileRead | EFileShareAny );
+        if( error != KErrNone )
+            {
+            // 3) Try to open in EFileShareReadersOnly
+            error = aFile.Open( aFileServer, aFileName, EFileRead | EFileShareReadersOnly );            
+            }
+        }
+    return error;   
+    };
+
+// -----------------------------------------------------------------------------
+// GetFileHandle
+// Get a file name trying to open it in the order required, which is:
+// 1)  EFileShareReadersOrWriters
+// 2)  EFileShareAny
+// 3)  EFileShareReadersOnly
+// -----------------------------------------------------------------------------
+LOCAL_C void AddParents( DRMCommon* aDrmCommon, 
+                         RPointerArray<CDRMRights>& aRights ) 
+    {
+    HBufC8* parent = NULL;
+    RPointerArray<CDRMRights>* parents = NULL;
+    TInt error = KErrNone;
+    RPointerArray<HBufC8> usedParents;
+    
+    
+    for( TInt i = 0; i < aRights.Count(); i++ )
+        {
+        parent = aRights[i]->GetPermission().iParentUID;
+        
+        for(TInt counter = 0; counter < usedParents.Count(); counter++ )
+            {
+            if( parent && !usedParents[counter]->Compare( *parent ) )
+                {
+                parent = NULL;
+                }
+            }
+        
+        if( parent != NULL )
+            {
+            TRAP( error, usedParents.AppendL( parent ) );
+            
+            if( aDrmCommon->GetDetailedContentRights(parent->Des(), parents) == KErrNone )
+                {
+                for( TInt j = parents->Count()-1; j >= 0;j-- )
+                    { 
+                    TRAP( error, aRights.AppendL( (*parents)[j] ) );
+                    (*parents)[j] = NULL;
+                    parents->Remove(j);
+                    }
+                parents->ResetAndDestroy();    
+                delete parents;
+                parents = NULL;    
+                }
+            
+            }
+        }
+    usedParents.Reset();
+    usedParents.Close();        
+    }
+
+// -----------------------------------------------------------------------------
+// DRMCommon::MapErrorCode
+// Remaps DRM core specific error codes to DRM API error codes.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt DRMCommon::MapErrorCode(
+    const TInt /* aCode */)
+    {
+    return EUnsupported;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/legacy/src/drmcommon.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -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:
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+//NAME    TYPE
+
+//  INCLUDES
+#include <badef.rh>
+#include "DRMCommon.rh"
+//RESOURCE RSS_SIGNATURE { }
+
+//RESOURCE TBUF16 { buf=""; }
+
+//  CONSTANTS  
+//#define ?constant   ?value
+
+
+//  MACROS  
+//#define ?macro
+
+
+//  RESOURCE DEFINITIONS 
+// ---------------------------------------------------------
+//   
+//    Data Type
+//    for capability checking
+//
+// ---------------------------------------------------------
+//
+
+
+RESOURCE MIMEARRAY datatype
+{
+	num = 49;
+	items=
+    {
+		// Note: To optimize performance, prioritize mime-types bases on frequency of usage
+
+		LBUF { txt="image/jpg"; },
+		LBUF { txt="image/gif"; },
+		LBUF { txt="image/png"; },
+		LBUF { txt="audio/amr"; },
+		LBUF { txt="image/jpeg"; },
+		LBUF { txt="audio/midi"; },
+		LBUF { txt="audio/x-ms-wma"; },
+		LBUF { txt="audio/basic"; },
+		LBUF { txt="audio/aac"; },
+		LBUF { txt="audio/wav"; },
+		LBUF { txt="application/java"; },
+		LBUF { txt="application/java-archive"; },
+		LBUF { txt="application/vnd.nokia.ringing-tone"; },
+		LBUF { txt="video/3gpp"; },
+		LBUF { txt="video/3gpp2"; },
+    LBUF { txt="video/3gp"; },
+    LBUF { txt="video/mp4"; },
+    LBUF { txt="video/mp4v-es"; },
+		LBUF { txt="audio/mpeg"; },
+		LBUF { txt="audio/mp4"; },
+		LBUF { txt="audio/3gpp"; },
+		LBUF { txt="audio/rmf"; },
+		LBUF { txt="application/vnd.symbian.install"; },
+		LBUF { txt="audio/x-rmf"; },
+		LBUF { txt="audio/x-midi"; },
+		LBUF { txt="audio/amr-wb"; },
+		LBUF { txt="audio/sp-midi"; },
+		LBUF { txt="audio/x-beatnik-rmf"; },
+		LBUF { txt="audio/x-wav"; },
+		LBUF { txt="application/x-java-archive"; },
+    LBUF { txt="image/svg+xml"; },
+		LBUF { txt="image/svg"; },
+    LBUF { txt="x-epoc/x-sisx-app"; },
+    LBUF { txt="audio/3gpp2"; },                
+    LBUF { txt="audio/mp3"; },
+		LBUF { txt="audio/x-mpeg"; },
+		LBUF { txt="image/vnd.wap.wbmp"; },
+		LBUF { txt="image/bmp"; },
+		LBUF { txt="audio/mid"; },
+		
+		// DRM License Manager Install Package
+		LBUF { txt="application/x-pip"; }, 
+
+		// OMA related mime-types. Do not remove!
+		LBUF { txt="application/vnd.oma.drm.message"; },
+		LBUF { txt="application/vnd.oma.drm.content"; }, 
+
+		LBUF { txt="audio/vnd.rn-realaudio"; },        	
+		LBUF { txt="application/x-pn-realmedia"; },
+		LBUF { txt="application/x-shockwave-flash"; },
+		LBUF { txt="audio/x-realaudio"; },
+		LBUF { txt="audio/x-pn-realaudio"; },
+		LBUF { txt="video/x-pn-realvideo"; },
+    LBUF { txt="application/vnd.rn-realmedia"; }
+    };
+}
+
+            
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/inc/DRMEventHandler.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,239 @@
+/*
+* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class handles registering and unregistering of
+*                DRM event observers to DRM notifier, and sending
+*                DRM notifications to other registered observers.
+*
+*/
+
+
+
+#ifndef CDRMEVENTHANDLER_H
+#define CDRMEVENTHANDLER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <DRMEvent.h>
+#include <DRMEventAddRemove.h>
+#include <DRMEventObserver.h>
+#include "DRMEventModify.h"
+#include "DRMEventTimeChange.h"
+#include "DRMNotifierClient.h"
+
+// CONSTANTS
+const TInt KOperationNone             = 0;
+const TInt KRegisterOperation         = 1;
+const TInt KRegisterURIOperation      = 2;
+const TInt KUnRegisterOperation       = 3;
+const TInt KUnRegisterURIOperation    = 4;
+
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class MDRMEventObserver;
+
+// CLASS DECLARATION
+
+/**
+ *  CDRMEventHandler
+ *  Performs the required operations between the client and the server
+ *  Handles the handles for the observers
+ *
+ *  @lib DRMCommon.dll
+ *  @since S60Rel2.6
+ */
+class CDRMEventHandler : public CActive
+    {
+public:  // Constructors and destructor
+        
+    /**
+    * Two-phased constructor.
+    */
+    static CDRMEventHandler* NewL();
+        
+    /**
+    * Destructor.
+    */
+    virtual ~CDRMEventHandler();
+
+public: // New functions
+
+    /**
+    * RegisterEventObserverL
+    *
+    * Registers a new event observer to DRM Notifier. Listens to all events
+    * of the given type
+    *
+    * @since S60Rel2.6
+    * @param aObserver Observer.
+    * @param aEvent the type of event to listen to
+    * @return none, leaves with Symbian OS error code if an error occurs
+    */
+    void RegisterEventObserverL( MDRMEventObserver& aObserver , 
+                                          const TDRMEventType& aEvent);   
+    /**
+    * UnRegisterEventObserverL
+    *
+    * Unregisters existing event observer from DRM Notifier.
+    *
+    * @since S60Rel2.6
+    * @param aObserver Observer.
+    * @param aEvent the type of event to unregister
+    * @return none, leaves with Symbian OS error code if an error occurs
+    */
+    void UnRegisterEventObserverL( MDRMEventObserver& aObserver, 
+                                            const TDRMEventType& aEvent);
+    /**
+    * RegisterEventObserverL
+    *
+    * Registers a new event observer to DRM Notifier. Only recieves
+    * notification when the rights accociated with the given content id
+    * are handled
+    *
+    * @since S60Rel2.6
+    * @param aObserver Observer
+    * @param aEvent the type of event to listen to
+    * @param aContentID the specific content id to listen to
+    * @return none, leaves with Symbian OS error code if an error occurs
+    */
+    void RegisterEventObserverL( MDRMEventObserver& aObserver , 
+                                          const TDRMEventType& aEvent,
+                                          const TDesC8& aContentID);
+    /**
+    * UnRegisterEventObserverL
+    *
+    * Unregisters existing event observer from DRM Notifier.
+    *
+    * @since S60Rel2.6
+    * @param aObserver Observer.
+    * @param aEvent the type of event to listen to
+    * @param aContentID the specific content id to listen to
+    * @return none, leaves with Symbian OS error code if an error occurs
+    */
+    void UnRegisterEventObserverL( MDRMEventObserver& aObserver, 
+                                            const TDRMEventType& aEvent,
+                                            const TDesC8& aContentID);
+    /**
+    * SendEventL
+    *
+    * Sends a notification to registered observers, asyncronous
+    *
+    * @since S60Rel2.6
+    * @param aEvent the event to send
+    * @param aStatus the request status of the event
+    */
+    void SendEventL( MDRMEvent& aEvent, TRequestStatus& aStatus );
+           
+public: // Functions from base classes
+        
+protected:  // New functions
+    CDRMEventHandler();
+
+    /**
+    * 2nd phase constructor.
+    */
+    void ConstructL();
+
+    protected:  // Functions from base classes
+        
+    /**
+    * From CActive: RunL catches events from DRM server.
+    */
+    void RunL();
+        
+    void DoCancel();
+
+    private:
+
+    /**
+    * GetEventObjectLC
+    *
+    * Reserves memory for an object specified in the internal structure
+    * and leaves it in the cleanup stack
+    *
+    * @return a base class pointer to the requested object
+    *         The function leaves if an error occurs with a Symbian OS
+    *         error code
+    */
+    MDRMEvent* GetEventObjectLC();
+        
+    /**
+    * HandleRunL
+    * 
+    * Helper function for RunL that does the actual callbacks to
+    * registered clients
+    * 
+    * @return none
+    */
+    void HandleRunL();
+
+    // Prohibit copy constructor if not deriving from CBase.
+    CDRMEventHandler( const CDRMEventHandler& );
+    // Prohibit assigment operator if not deriving from CBase.
+    CDRMEventHandler& operator=( const CDRMEventHandler& );
+
+public:     // Data
+    
+protected:  // Data
+
+private:    // Data
+    struct TObserverData 
+        {
+        MDRMEventObserver* iObserver;
+        HBufC8* iContentID;
+        };
+
+    struct TDelayedObserverData
+        {
+        TInt iRequest;
+        MDRMEventObserver* iObserver;
+        TDRMEventType iEventType;
+        HBufC8* iContentID;
+        };
+
+    // Instance of c/s communications.
+    RDRMNotifierClient* iHandler;
+        
+    // List of observers
+    CArrayPtrSeg< TObserverData >* iAddRemoveObservers;
+    CArrayPtrSeg< TObserverData >* iModifyObservers;
+    CArrayPtrSeg< TObserverData >* iTimeChangeObservers;
+    CArrayPtrSeg< TDelayedObserverData >* iDelayedObservers;
+
+    // variable to tell if calls are being delayed
+    TBool iIsDelayed;
+
+    // Status of Client
+    TBool iIsOpen;
+
+    // Client Server Communication
+    TUint8* iDataBuffer;
+    TDRMEventType* iEventType;
+    TPtr8* iData;
+
+    TUint8* iWaitDataBuffer;
+    TDRMEventType* iEventTypeWait;
+    TPtr8* iWaitData;
+
+public:     // Friend classes
+
+protected:  // Friend classes
+
+private:    // Friend classes
+    };
+
+#endif      // DRMEVENTHANDLER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/inc/DRMMessageStorage.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,162 @@
+/*
+* Copyright (c) 2004-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:  DRM Message storage handles all the messages and stores them
+*                when needed
+*
+*/
+
+
+
+#ifndef CDRMMESSAGESTORAGE_H
+#define CDRMMESSAGESTORAGE_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <DRMEvent.h>
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CDRMNotifierSession;
+class CLogFile;
+
+// CLASS DECLARATION
+
+/**
+*  This class implements the DRM3 Message Storage
+*
+*  @lib RightsServer.exe
+*  @since S60Rel2.6
+*/
+NONSHARABLE_CLASS( CDRMMessageStorage ) : public CBase
+    {
+    public: // User defined types
+        struct TMessageData
+            {
+            TInt iRefCount;
+            TDRMEventType iEventType;
+            HBufC8* iData;
+            TUint8* iMessageData;
+            };
+
+    public:  // Constructors and destructor
+        
+        /**
+         * Two-phased constructor.
+         * @since S60Rel2.6
+         * @return Pointer to newly created server instance.
+         */
+        static CDRMMessageStorage* NewL();
+        
+        /**
+         * Destructor.
+         * @since S60Rel2.6
+         */
+        ~CDRMMessageStorage();
+        
+    public: // New functions
+        /**
+        *  AddSession
+        *
+        *  Adds a session to the session list
+        *
+        *  @since S60Rel2.6
+        *  @param : aSession - The notifier session to recieve callbacks
+        *  @param : aMessage - Message related to the reques
+        *  @return None
+        */
+        void AddSession( CDRMNotifierSession* aSession );
+
+        /**
+        *  UpdateMessage
+        *
+        *  Updates a message in the message list, if the reference
+        *  counter is reduced to 0 it removes it from the list
+        *
+        *  @since S60Rel2.6
+        *  @param : aMessage - message to be updated
+        *  @return None
+        */
+        void UpdateMessage( struct TMessageData* aMessage );
+
+        /**
+        *  GetEventObjectLC
+        *  
+        *  Creates an event object, adds it to the cleanup stack and
+        *  returns a pointer to it
+        *
+        *  @since S60Rel2.6
+        *  @param aEventType the type of event object needed
+        *  @return pointer to the proper event object
+        */
+        MDRMEvent* GetEventObjectLC( TDRMEventType aEventType );
+
+        /**
+        *  NotifyL
+        *
+        *  Calls the SendNotificationL function from all registered sessions 
+        *
+        *  @since S60Rel2.6
+        *  @param : aEventType - The event type of the message
+        *  @param : aMessage - Message related to the request
+        *  @return None, Leaves with symbian OS error code if an error occurs
+        */
+        void NotifyL( TDRMEventType& aEventType, const RMessage2& aMessage );  
+
+        /**
+        *  CancelL
+        *
+        *  Removes the object(s) related to the given session from the lists 
+        *
+        *  @since S60Rel2.6
+        *  @param : aSession - Session connected to a client
+        *  @return None, Leaves with symbian OS error code if an error occurs
+        */
+        void CancelL( CDRMNotifierSession* aSession );
+
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+        
+    private:
+        /**
+         * C++ default constructor.
+         * @since S60Rel2.6
+         */
+        CDRMMessageStorage();
+        
+        /**
+         * By default Symbian 2nd phase constructor is private.
+         * @since S60Rel2.6
+         */
+        void ConstructL();
+        
+    private:    // Data
+        RPointerArray<CDRMNotifierSession> iSessions;
+        RPointerArray<TMessageData> iMessages;
+        
+        
+    public:     // Friend classes
+        
+    protected:  // Friend classes
+        
+    private:    // Friend classes
+        
+};
+
+#endif      // CDRMMESSAGESTORAGE_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/inc/DRMNotifierClient.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,164 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class handles communications between a notifier client & 
+*                DRM server in DRM notifier.
+*
+*/
+
+
+
+#ifndef RDRMNOTIFIERCLIENT_H
+#define RDRMNOTIFIERCLIENT_H
+
+//  INCLUDES
+#include <E32STD.H>
+#include <DRMEvent.h>
+
+// CONSTANTS
+const TInt KMaxMessageSlots = 2;
+
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+// CLASS DECLARATION
+
+/**
+*  This class handles all client/server communications.
+*  
+*  @lib DRMCommon.dll
+*  @since S60Rel2.6
+*/
+class RDRMNotifierClient : public RSessionBase
+    {
+    public:  // Constructors and destructor
+       /**
+        * C++ default constructor.
+        */
+       RDRMNotifierClient(TDRMEventType* aEventType, TDRMEventType* aEventTypeWait, 
+                          TPtr8* aPtr, TPtr8* aWaitPtr);
+       
+       /**
+        * Destructor.
+        */
+       virtual ~RDRMNotifierClient();
+       
+    public: // New functions
+        
+       /**
+       * This method opens a connection to the server.
+       * @since S60Rel2.6
+       * Return Symbian OS / DRM Engine specific error code.
+       */
+       TInt Connect( void );
+
+       /**
+       * WaitForCompletion
+       *
+       * Waits for notifications. When the status is completed a notification
+       * has been received.
+       *
+       * @since S60Rel2.6
+       * @param aStatus  the status will be updated when the a notification
+       *                 has been received
+       * @return none 
+       */
+       void WaitForCompletion( TRequestStatus& aStatus );
+
+
+       /**
+       * SendEvent
+       *
+       * Sends an event to the notifier server, the request status is updated
+       * when all the notifications have been forwarded
+       *
+       * @since S60Rel2.6
+       * @param aStatus  the status will be updated when all notifications have
+       *                 been forwarded
+       * @return none 
+       */
+       void SendEvent( TRequestStatus& aStatus );
+
+       /**
+       * RegisterForType
+       *
+       * Register to the server to listen to specific event types, if a URI
+       * is provided notifications of the type that have that URI as affected
+       * URI will get notified
+       *
+       * @since S60Rel2.6
+       * @param aEventType  the event type to listen to
+       * @param aURI  optional URI to limit the C/S communication
+       * @return none 
+       */
+       void RegisterForType( TDRMEventType aEventType, HBufC8* aURI = 0 );
+
+
+       /**
+       * UnRegisterFromType
+       *
+       * Unregister from the server from listening to specific event types, 
+       * if a URI is provided notifications of the type that have that URI 
+       * as affected URI will get unregistered
+       *
+       * @since S60Rel2.6
+       * @param aEventType  the event type to listen to
+       * @param aURI  optional URI to limit the C/S communication
+       * @return none 
+       */
+       void UnRegisterFromType( TDRMEventType aEventType, HBufC8* aURI = 0 );
+
+       /**
+       * CancelRequest()
+       *
+       * Used when the object is being destroyed. All calls are cancelled and
+       * the server side will get a notification to remove all notifications
+       * from their lists
+       *
+       * @since S60Rel2.6
+       * @return none
+       */
+       void CancelRequest();
+
+       
+    public: // Functions from base classes
+        void Close();      
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+        
+    private:
+
+        // Prohibit copy constructor
+        RDRMNotifierClient( const RDRMNotifierClient& );
+        // Prohibit assigment operator
+        RDRMNotifierClient& operator=( const RDRMNotifierClient& );
+
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+        TDRMEventType* iEventType;
+        TDRMEventType* iEventTypeWait;
+        TPtr8* iData;
+        TPtr8* iWaitData;
+        TPckg<TInt> numdata;
+        
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+    };
+
+#endif      // RDRMNOTIFIERCLIENT_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/inc/DRMNotifierServer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,119 @@
+/*
+* 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:  DRM3 Notifier manages all notifications out of the system.
+*
+*/
+
+
+
+#ifndef CDRMNOTIFIERSERVER_H
+#define CDRMNOTIFIERSERVER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include "DRMMessageStorage.h"
+// #include "DRMClientServer.h"
+#include "DRMNotifierSession.h"
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+TInt StartupNotifier( TAny* );
+ 
+// FORWARD DECLARATIONS
+class CLogFile;
+
+// CLASS DECLARATION
+
+/**
+*  This class implements the DRM3 Notifier Server functionality.
+*
+*  @lib RightsServer.exe
+*  @since S60Rel2.6
+*/
+NONSHARABLE_CLASS( CDRMNotifierServer ) : public CServer2
+    {
+    public:  // Constructors and destructor
+        
+        /**
+         * Two-phased constructor.
+         * @since S60Rel2.6
+         * @return Pointer to newly created server instance.
+         */
+        static CDRMNotifierServer* NewL();
+        
+        /**
+         * Destructor.
+         * @since S60Rel2.6
+         */
+        ~CDRMNotifierServer();
+        
+    public: // Functions from base classes
+
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+        //class CServer
+        /**
+         * RunError.
+         * @since S60Rel2.6
+         * @param aError Error code from RunL function.
+         * @return An error is returned if RunError() cannot process the
+         * error.
+         */
+        TInt RunError( TInt aError );
+        
+    private:
+        /**
+         * C++ default constructor.
+         * @since S60Rel2.6
+         */
+        CDRMNotifierServer();
+        
+        /**
+         * By default Symbian 2nd phase constructor is private.
+         * @since S60Rel2.6
+         */
+        void ConstructL();
+        
+    private: // Functions from base classes
+        // Class CServer
+        /** 
+         * NewSessionL
+         * @since S60Rel2.6
+         */
+        CSession2* NewSessionL( const TVersion& aVersion,
+                                const RMessage2& aMessage) const;
+        
+    public:     // Data
+        
+    protected:  // Data
+        
+    private:    // Data
+        CDRMMessageStorage* iStorage;
+
+        
+    public:     // Friend classes
+        
+    protected:  // Friend classes
+        
+    private:    // Friend classes
+        
+};
+
+#endif      // CDRMRIGHTSSERVER_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/inc/DRMNotifierSession.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,216 @@
+/*
+* 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:  This class declares the interface of class CDRMNotifierSession.
+*                handles the queues for notification events
+*
+*/
+
+
+#ifndef CDRMNOTIFIERSESSION_H
+#define CDRMNOTIFIERSESSION_H
+
+//  INCLUDES
+#include <e32base.h>
+#include "DRMMessageStorage.h"
+
+// CONSTANTS
+// MACROS
+// FUNCTION PROTOTYPES
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class RMessage2;
+class RRPointerArray;
+
+// CLASS DECLARATION
+
+/**
+*  Server side instance of DRM Notifier session.
+*  This class is the server side instance of C/S communications of a certain
+*  session.
+*
+*  @lib DRMCommon.dll
+*  @since S60Rel2.6
+*/
+NONSHARABLE_CLASS( CDRMNotifierSession ) : public CSession2
+{
+  public:  // Constructors and destructor
+   
+   /**
+    * Two-phased constructor.
+    *
+    * @since S60Rel2.6
+    * @param aClient Associated client side thread.
+    * @param aStorage  a pointer to an instance of CDRMMessageStorage
+    * @return New session instance.
+    */
+   static CDRMNotifierSession* NewL( CDRMMessageStorage* aStorage );
+   
+   /**
+    * Destructor.
+    * @since S60Rel2.6
+    */
+   virtual ~CDRMNotifierSession();
+   
+  public: // New functions
+   
+   /**
+    * SendNotificationL
+    * 
+    * Sends a notification to a client or adds it to the queue, depending on if
+    * the client is active or not
+    *
+    * @since S60Rel2.6
+    * @param aMessage The message that needs to be sent
+    * @exception Method leaves with appropriate exception value
+    *            if any errors occured.
+    * @return ETrue if the message was put into queue
+    *         EFalse if it was run normally
+    */
+    TBool SendNotificationL( CDRMMessageStorage::TMessageData* aMessage );
+  
+  public: // Functions from base classes
+   
+   /**
+    * From CSession: Handles the service request event.
+    * @since S60Rel2.6
+    * @param aMessage The message related to the event.
+    * @exception Method leaves with appropriate exception value
+    *            if any errors occured.
+    */
+   void ServiceL( const RMessage2& aMessage );
+   
+  private:
+   
+   /**
+    * C++ constructor.
+    * @since S60Rel2.6
+    * @param aClient Client thread.
+    * @param aStorage  a pointer to an instance of CDRMMessageStorage
+    */
+   CDRMNotifierSession( CDRMMessageStorage* aStorage);
+   
+   /**
+    * Second phase constructor.
+    * @since S60Rel2.6
+    */ 
+   void ConstructL();
+   
+   /** 
+    * ServiceL() runs DispatchL() under TRAP harness, so
+    * all errors can be catched properly. DispatchL() then calls
+    * appropriate private method depending on the request.
+    * @since S60Rel2.6
+    * @param aMessage The message associated to the event.
+    */
+   void DispatchL( const RMessage2& aMessage );
+   
+   /** 
+    * Helper function for DispatchL(). 
+    * @since S60Rel2.6
+    * @param aMessage The message associated to the event.
+    */
+   void NotifyClientsL( const RMessage2& aMessage );
+   
+
+   /** 
+    * Helper function for DispatchL(). 
+    * @since S60Rel2.6
+    * @param aMessage The message associated to the event.
+    */
+   void RecieveNotificationL( const RMessage2& aMessage );
+   
+   /** 
+    * Helper function for DispatchL(). 
+    * @since S60Rel2.6
+    * @param aMessage The message associated to the event.
+    */  
+   void CancelNotificationL( const RMessage2& aMessage );
+
+   /** 
+    * Helper function for DispatchL(). 
+    * @since S60Rel2.6
+    * @param aMessage The message associated to the event.
+    */  
+   void RegisterL( const RMessage2& aMessage );
+
+   /** 
+    * Helper function for DispatchL(). 
+    * @since S60Rel2.6
+    * @param aMessage The message associated to the event.
+    */  
+   void UnRegisterL( const RMessage2& aMessage );
+
+   /** 
+    * Helper function for DispatchL(). 
+    * @since S60Rel2.6
+    * @param aMessage The message associated to the event.
+    */  
+   void RegisterURIL( const RMessage2& aMessage );
+
+   /** 
+    * Helper function for DispatchL(). 
+    * @since S60Rel2.6
+    * @param aMessage The message associated to the event.
+    */  
+   void UnRegisterURIL( const RMessage2& aMessage );
+
+   /**
+    * NotifyL
+    *
+    * Helper function for sending a notification
+    *
+    * @since S60Rel2.6
+    * @param aMessage - The message to be sent
+    * @param aFromQueue - ETrue if the message parameter is from the queue,
+                          EFalse if the message parameter is not from the queue
+    */
+   void NotifyL(CDRMMessageStorage::TMessageData *aMessage, TBool aFromQueue );
+
+   /**
+    * CanNotify
+    *
+    * Helper function for determining if we need to handle the notification
+    *
+    * @since S60Rel2.6
+    * @param aMessage - the message data of the message to be sent
+    * @return ETrue if it can be sent, EFalse if it can't be send
+    */
+   TBool CanNotify( CDRMMessageStorage::TMessageData *aMessage );
+
+   // Prohibit copy constructor.
+   CDRMNotifierSession( const CDRMNotifierSession& );
+   // Prohibit assigment operator.
+   CDRMNotifierSession& operator=( const CDRMNotifierSession& );
+
+  private:    // Data
+      NONSHARABLE_STRUCT( TContentData )
+          {
+          HBufC8* iContentID;
+          TDRMEventType iEventType;
+          };
+
+      CDRMMessageStorage* iStorage;
+      RPointerArray<TContentData> iContentIDList;
+      RPointerArray<CDRMMessageStorage::TMessageData> iMessageQueue;
+      TBool iIsListening;
+      RMessage2 iListener;
+      TBool iIsInStorage;
+   
+};
+
+
+#endif      // CDRMNOTIFIERSESSION_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/src/DRMEvent.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2004-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:  Notification Event object base class
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    <DRMEvent.h>
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// MDRMEvent::MDRMEvent
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C MDRMEvent::MDRMEvent( 
+    const TDRMEventType& aEvent ) : iType( aEvent ) 
+    {
+    };
+    
+// Destructor
+EXPORT_C MDRMEvent::~MDRMEvent()
+    {
+    };
+
+
+// -----------------------------------------------------------------------------
+// MDRMEvent::ExternalizeL
+// Writes the data of the object into the given stream
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void MDRMEvent::ExternalizeL(
+    RWriteStream& aOutput)
+    {
+    // this implementation may need to be changed if the type of the internal
+    // data is changed
+    aOutput.WriteUint32L(iType);
+    };
+
+
+// -----------------------------------------------------------------------------
+// MDRMEvent::InternalizeL
+// Reads the data of the object from the given stream
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void MDRMEvent::InternalizeL(
+    RReadStream& aInput) 
+    {
+    // this implementation may need to be changed if the type of the internal
+    // data is changed
+    iType = aInput.ReadUint32L();
+    };
+
+// -----------------------------------------------------------------------------
+// MDRMEvent::GetEventType
+// Returns the event type of the object a return parameter
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void MDRMEvent::GetEventType(
+    TDRMEventType& aEventType) const 
+    {
+    aEventType = iType;
+    };
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/src/DRMEventAddRemove.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,188 @@
+/*
+* 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:  Notification Event object base class
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "DRMEventAddRemove.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventAddRemove::NewLC
+// two phased constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMEventAddRemove* CDRMEventAddRemove::NewLC( TAddRemoveEventStatus aStatus )
+    {
+    CDRMEventAddRemove* self = new (ELeave) CDRMEventAddRemove( aStatus );
+    CleanupStack::PushL( self );
+    return self; 
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventAddRemove::NewL
+// two phased constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMEventAddRemove* CDRMEventAddRemove::NewL( TAddRemoveEventStatus aStatus )
+    {
+    CDRMEventAddRemove* self = NewLC( aStatus );
+    CleanupStack::Pop();
+    return self;
+    };
+
+
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventAddRemove::CDRMEventAddRemove
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMEventAddRemove::CDRMEventAddRemove(
+    TAddRemoveEventStatus aStatus ) : MDRMEvent( KEventAddRemove ), 
+                                      iContentID( NULL ),
+                                      iStatus( aStatus )
+    {
+    };
+
+// Destructor
+EXPORT_C CDRMEventAddRemove::~CDRMEventAddRemove()
+    {
+    if( iContentID )
+        {
+        delete iContentID;
+        }
+    };
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventAddRemove::SetContentIDL
+// Reserves memory for a copy of the content id and releases the old memory
+// from the object if it already exists
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventAddRemove::SetContentIDL( const TDesC8& aContentID )
+    {
+    if( iContentID )
+        {
+        delete iContentID;
+        iContentID = NULL;
+        }
+    iContentID = aContentID.AllocL();
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventAddRemove::Status
+// Returns the status of the object
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TAddRemoveEventStatus CDRMEventAddRemove::Status() const
+    {
+    return iStatus;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventAddRemove::GetContentIDL
+// reserves memory and returns a pointer to this new object
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* CDRMEventAddRemove::GetContentIDL() const 
+    {
+    return iContentID->AllocL();
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMEventAddRemove::ExternalizeL
+// Writes the data of the object into the given stream
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventAddRemove::ExternalizeL(
+    RWriteStream& aOutput)
+    {
+    TInt outputLength = 0;
+
+    MDRMEvent::ExternalizeL(aOutput);
+
+    // get the output length of the HBufC8*
+    outputLength = iContentID->Size();
+    aOutput.WriteInt32L(outputLength);
+
+    // write out the HBufC8*
+    aOutput.WriteL(*iContentID);
+
+    // this implementation may need to be changed if the size of the enum changes
+    aOutput.WriteInt8L(iStatus);
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventAddRemove::Internalize
+// Reads the data of the object from the given stream
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventAddRemove::InternalizeL(
+    RReadStream& aInput) 
+    {
+    TInt inputLength = 0;
+
+    MDRMEvent::InternalizeL(aInput);
+
+    // Read the length of the HBufC8*
+    inputLength = aInput.ReadInt32L();
+
+    // Reserve the HBufC8*
+    if( !iContentID )
+        {
+        iContentID = HBufC8::NewL(inputLength);
+        }
+    else
+        {
+        iContentID->ReAllocL(inputLength);
+        }
+
+    TPtr8 inRead(iContentID->Des());
+
+    // Read the HBufC8*
+    aInput.ReadL(inRead, inputLength); 
+
+    // this implementation may need to be changed if the size of the enum changes
+    iStatus = static_cast<TAddRemoveEventStatus>(aInput.ReadInt8L());
+    };
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/src/DRMEventHandler.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,982 @@
+/*
+* 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:  Implementation of class CDRMEventHandler
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32mem.h> 
+#include "DRMEventHandler.h"
+#include "drmnotifierclientserver.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMEventHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMEventHandler* CDRMEventHandler::NewL()
+    {
+    CDRMEventHandler* self = new( ELeave ) CDRMEventHandler;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEventHandler::~CDRMEventHandler
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CDRMEventHandler::~CDRMEventHandler()
+{
+    if( iHandler )
+        {
+        Cancel();
+        }
+
+    if( iData )
+        {
+        delete iData;
+        iData = NULL;
+        }
+    if( iDataBuffer )
+        {
+        delete iDataBuffer;
+        iDataBuffer = NULL;
+        }
+    if( iEventType )
+        {
+        delete iEventType;
+        iEventType = NULL;
+        }
+
+    if( iWaitData )
+        {
+        delete iWaitData;
+        iWaitData = NULL;
+        }
+    if( iWaitDataBuffer )
+        {
+        delete iWaitDataBuffer;
+        iWaitDataBuffer = NULL;
+        }
+    if( iEventTypeWait )
+        {
+        delete iEventTypeWait;
+        iEventTypeWait = NULL;
+        }
+
+    if ( iAddRemoveObservers ) 
+        {
+        for( TInt i = 0; i < iAddRemoveObservers->Count();i++)
+            {
+            delete (*iAddRemoveObservers)[i]->iContentID;
+            (*iAddRemoveObservers)[i]->iContentID = NULL;
+            }
+        iAddRemoveObservers->Reset();
+        delete iAddRemoveObservers;
+        iAddRemoveObservers = NULL;
+        }
+    if ( iModifyObservers ) 
+        {
+        for( TInt i = 0; i < iModifyObservers->Count();i++)
+            {
+            delete (*iModifyObservers)[i]->iContentID;
+            (*iModifyObservers)[i]->iContentID = NULL;
+            }
+        iModifyObservers->Reset();
+        delete iModifyObservers;
+        iModifyObservers = NULL;
+        }
+        
+    if ( iTimeChangeObservers ) 
+        {
+        iTimeChangeObservers->Reset();
+        delete iTimeChangeObservers;
+        iTimeChangeObservers = NULL;
+        }
+                
+    if ( iDelayedObservers )
+        {
+        for( TInt i = 0; i < iDelayedObservers->Count();i++)
+            {
+            delete (*iDelayedObservers)[i]->iContentID;
+            (*iDelayedObservers)[i]->iContentID = NULL;
+            }
+        iDelayedObservers->Reset();
+        delete iDelayedObservers;
+        iDelayedObservers = NULL;
+        }
+
+    if( iHandler )
+        {
+        iHandler->Close();
+        delete iHandler;
+        iHandler = NULL;
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventHandler::RegisterEventObserverL
+// Adds the new handler to the list of handlers.
+// Checks if the handler is already in the list
+// Sets the active object active if it is not active yet.
+// -----------------------------------------------------------------------------
+//
+void CDRMEventHandler::RegisterEventObserverL(
+    MDRMEventObserver& aObserver,
+    const TDRMEventType& aEvent )
+    {
+
+    TInt count = 0;
+    TBool addToServer = ETrue;
+    
+    
+    if( iIsDelayed )
+        {
+        TDelayedObserverData* delayData = new (ELeave) TDelayedObserverData;
+        CleanupStack::PushL( delayData);
+        delayData->iRequest = KRegisterOperation;
+        delayData->iObserver = &aObserver;
+        delayData->iEventType = aEvent;
+        delayData->iContentID = NULL;
+        iDelayedObservers->AppendL( delayData );
+        CleanupStack::Pop();    // delayData;
+        return;
+        }
+
+    switch ( aEvent )
+        {
+        case KEventAddRemove:
+            if ( iAddRemoveObservers )
+                {
+                for ( count = 0; count < iAddRemoveObservers->Count(); ++count )
+                    {
+                    if ( ( *iAddRemoveObservers )[ count ]->iObserver == &aObserver &&
+                         !( *iAddRemoveObservers )[ count ]->iContentID )
+                        {
+                        return;
+                        }
+                    else if( addToServer && !( *iAddRemoveObservers)[ count ]->iContentID ) 
+                        {
+                        addToServer = EFalse;
+                        }
+                    }
+                }
+            break;
+        case KEventModify:
+            if ( iModifyObservers )
+                {
+                for ( count = 0; count < iModifyObservers->Count(); ++count )
+                    {
+                    if ( ( *iModifyObservers )[ count ]->iObserver == &aObserver &&
+                         !( *iModifyObservers )[ count ]->iContentID )
+                        {
+                        return;
+                        }
+                    else if( addToServer && !( *iModifyObservers)[ count ]->iContentID ) 
+                        {
+                        addToServer = EFalse;
+                        }
+                    }
+                }
+            break;
+        case KEventTimeChange:
+            if ( iTimeChangeObservers )        
+                {
+                for ( count = 0; count < iTimeChangeObservers->Count(); ++count )
+                    {
+                    if ( ( *iTimeChangeObservers )[ count ]->iObserver == &aObserver )
+                        {
+                        return;
+                        }
+                    }
+                }      
+            break;
+        default:
+            User::Leave(KErrArgument);
+            break;
+        }  
+
+    struct TObserverData* observer = new (ELeave) TObserverData;
+    CleanupStack::PushL(observer);
+
+    observer->iObserver = &aObserver;
+    observer->iContentID = NULL;
+
+    switch( aEvent )
+        {
+        case KEventAddRemove:
+            iAddRemoveObservers->AppendL( observer );
+            break;
+        case KEventModify:
+            iModifyObservers->AppendL( observer );
+            break;
+        case KEventTimeChange:
+            iTimeChangeObservers->AppendL( observer );
+            break;
+        default:
+            User::Leave(KErrArgument);
+            break;
+        }
+   
+    if ( !IsAdded() )
+        {
+        CActiveScheduler::Add( this );
+        }
+
+    if ( !IsActive() )
+        {
+        if( iStatus != KRequestPending )
+            {
+            iStatus = KRequestPending;
+            iHandler->WaitForCompletion(iStatus);
+            }
+        SetActive();
+        }
+
+    // Register the type to the server
+    if( addToServer )
+        {
+        iHandler->RegisterForType(aEvent);
+        }
+
+    CleanupStack::Pop(); // observer
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEventHandler::UnRegisterEventObserverL
+// Removes the observer from the list of handlers.
+// -----------------------------------------------------------------------------
+//
+void CDRMEventHandler::UnRegisterEventObserverL( 
+    MDRMEventObserver& aObserver,
+    const TDRMEventType& aEvent)
+    {
+    TInt count = 0;
+    TBool removeFromServer = ETrue;
+
+    if( iIsDelayed )
+        {
+        TDelayedObserverData* delayData = new (ELeave) TDelayedObserverData;
+        CleanupStack::PushL( delayData);
+        delayData->iRequest = KUnRegisterOperation;
+        delayData->iObserver = &aObserver;
+        delayData->iEventType = aEvent;
+        delayData->iContentID = NULL;
+        iDelayedObservers->AppendL( delayData );
+        CleanupStack::Pop();    // delayData;
+        return;
+        }
+
+    // Check if something else uses the registration for this event type, if something
+    // Does set removeFromServer to EFalse so the registration is not removed from the
+    // server
+    switch ( aEvent )
+        {
+        case KEventAddRemove:
+            if ( iAddRemoveObservers )
+                {
+                for ( count = 0; count < iAddRemoveObservers->Count(); ++count )
+                    {
+                    if( removeFromServer && !( *iAddRemoveObservers)[ count ]->iContentID &&
+                        ( *iAddRemoveObservers)[ count ]->iObserver != &aObserver ) 
+                        {
+                        removeFromServer = EFalse;
+                        }
+                    }
+                }
+            break;
+        case KEventModify:
+            if ( iModifyObservers )
+                {
+                for ( count = 0; count < iModifyObservers->Count(); ++count )
+                    {
+                    if( removeFromServer && !( *iModifyObservers)[ count ]->iContentID &&
+                        ( *iModifyObservers)[ count ]->iObserver != &aObserver ) 
+                        {
+                        removeFromServer = EFalse;
+                        }
+                    }
+                }
+            break;
+        case KEventTimeChange:
+            if ( iTimeChangeObservers )
+                {
+                for ( count = 0; count < iTimeChangeObservers->Count(); ++count )
+                    {
+                    if( ( *iTimeChangeObservers)[ count ]->iObserver != &aObserver ) 
+                        {
+                        removeFromServer = EFalse;
+                        }
+                    }
+                }
+            break;        
+        default:
+            User::Leave(KErrArgument);
+            break;
+        }  
+
+
+    // Remove the registrations from internal lists and possibly from the server
+    switch ( aEvent )
+        {
+        case KEventAddRemove:
+            if ( iAddRemoveObservers )
+                {
+                for ( count = 0; count < iAddRemoveObservers->Count(); ++count )
+                    {
+                    if ( ( *iAddRemoveObservers )[ count ]->iObserver == &aObserver &&
+                         !( *iAddRemoveObservers )[ count ]->iContentID )
+                        {
+                        if( removeFromServer )
+                            {
+                            // Unregister the type from the server
+                            iHandler->UnRegisterFromType(aEvent);
+                            }
+
+                        // Free Memory
+                        delete ( *iAddRemoveObservers )[ count ];
+                        ( *iAddRemoveObservers )[ count ] = NULL;
+
+                        // Delete the element from the table
+                        iAddRemoveObservers->Delete( count );
+                        iAddRemoveObservers->Compress();
+                        return;
+                        }
+                    }
+                }
+            User::Leave(KErrNotFound);
+            break;
+        case KEventModify:
+            if ( iModifyObservers )
+                {
+                for ( count = 0; count < iModifyObservers->Count(); ++count )
+                    {
+                    if ( ( *iModifyObservers )[ count ]->iObserver == &aObserver &&
+                         !( *iModifyObservers )[ count ]->iContentID )
+                        {
+                        if( removeFromServer )
+                            {
+                            // Unregister the type from the server
+                            iHandler->UnRegisterFromType(aEvent);
+                            }
+
+                        // Free Memory
+                        delete ( *iModifyObservers )[ count ];
+                        ( *iModifyObservers )[ count ] = NULL;
+
+                        // Delete the element from the table
+                        iModifyObservers->Delete( count );
+                        iModifyObservers->Compress();
+                        return;
+                        }
+                    }
+                }
+            User::Leave(KErrNotFound);
+            break;
+        case KEventTimeChange:
+            if ( iTimeChangeObservers )
+                {
+                for ( count = 0; count < iTimeChangeObservers->Count(); ++count )
+                    {
+                    if ( ( *iTimeChangeObservers )[ count ]->iObserver == &aObserver )
+                        {
+                        if( removeFromServer )
+                            {
+                            // Unregister the type from the server
+                            iHandler->UnRegisterFromType(aEvent);
+                            }
+
+                        // Free Memory
+                        delete ( *iTimeChangeObservers )[ count ];
+                        ( *iTimeChangeObservers )[ count ] = NULL;
+
+                        // Delete the element from the table
+                        iTimeChangeObservers->Delete( count );
+                        iTimeChangeObservers->Compress();
+                        return;
+                        }
+                    }
+                }
+            User::Leave(KErrNotFound);        
+            break;
+        default:
+            User::Leave(KErrArgument);
+            break;
+        }  
+    // Should never get here
+    User::Leave( KErrGeneral );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEventHandler::RegisterEventObserverL
+// Adds the new handler to the list of handlers.
+// Checks is the handler is already in the list
+// Sets the active object active if it is not active yet.
+// -----------------------------------------------------------------------------
+//
+void CDRMEventHandler::RegisterEventObserverL(
+    MDRMEventObserver& aObserver,
+    const TDRMEventType& aEvent,
+    const TDesC8& aContentID )
+    {
+    TInt count = 0;
+    TBool addToServer = ETrue;
+
+    if( iIsDelayed )
+        {
+        TDelayedObserverData* delayData = new (ELeave) TDelayedObserverData;
+        CleanupStack::PushL( delayData);
+        delayData->iRequest = KRegisterURIOperation;
+        delayData->iObserver = &aObserver;
+        delayData->iEventType = aEvent;
+        delayData->iContentID = aContentID.AllocLC();
+        iDelayedObservers->AppendL( delayData );
+        CleanupStack::Pop();    // iContentID;
+        CleanupStack::Pop();    // delayData;
+        return;
+        }
+
+    switch ( aEvent )
+        {
+        case KEventAddRemove:
+            if ( iAddRemoveObservers )
+                {
+                for ( count = 0; count < iAddRemoveObservers->Count(); ++count )
+                    {
+                    if ( ( *iAddRemoveObservers )[ count ]->iObserver == &aObserver &&
+                         ( *iAddRemoveObservers )[ count ]->iContentID &&
+                         !( *iAddRemoveObservers )[ count ]->iContentID->Compare( aContentID ) )
+                        {
+                        return;
+                        }
+                    else if( addToServer && 
+                        !( *iAddRemoveObservers)[ count ]->iContentID->Compare( aContentID ) ) 
+                        {
+                        addToServer = EFalse;
+                        }
+                    }
+                }
+            break;
+        case KEventModify:
+            if ( iModifyObservers )
+                {
+                for ( count = 0; count < iModifyObservers->Count(); ++count )
+                    {
+                    if ( ( *iModifyObservers )[ count ]->iObserver == &aObserver &&
+                         ( *iModifyObservers )[ count ]->iContentID &&
+                         !( *iModifyObservers )[ count ]->iContentID->Compare( aContentID ) )
+                        {
+                        return;
+                        }
+                    else if( addToServer && 
+                        !( *iModifyObservers)[ count ]->iContentID->Compare( aContentID ) ) 
+                        {
+                        addToServer = EFalse;
+                        }
+                    }
+                }
+            break;
+        default:
+            User::Leave(KErrArgument);
+            break;
+        }  
+
+    HBufC8* contentID = aContentID.AllocLC();
+    struct TObserverData* observer = new (ELeave) TObserverData;
+    CleanupStack::PushL(observer);
+
+    observer->iObserver = &aObserver;
+    observer->iContentID = contentID;
+
+    switch( aEvent )
+        {
+        case KEventAddRemove:
+            iAddRemoveObservers->AppendL( observer );
+            break;
+        case KEventModify:
+            iModifyObservers->AppendL( observer );
+            break;
+        default:
+            User::Leave(KErrArgument);
+            break;
+        }
+   
+    if ( !IsAdded() )
+        {
+        CActiveScheduler::Add( this );
+        }
+
+    if ( !IsActive() )
+        {
+        if( iStatus != KRequestPending )
+            {
+            iStatus = KRequestPending;
+            iHandler->WaitForCompletion(iStatus);
+            }
+        SetActive();
+        }
+
+    // Register the type to the server
+    if ( addToServer )
+        {
+        iHandler->RegisterForType(aEvent,contentID);
+        }
+
+    CleanupStack::Pop(); // contentID
+    CleanupStack::Pop(); // observer;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEventHandler::UnRegisterEventObserverL
+// Removes the observer from the list of handlers.
+// -----------------------------------------------------------------------------
+//
+void CDRMEventHandler::UnRegisterEventObserverL( 
+    MDRMEventObserver& aObserver,
+    const TDRMEventType& aEvent,
+    const TDesC8& aContentID )
+    {
+    TInt count = 0;
+    TBool removeFromServer = ETrue;
+
+    if( iIsDelayed )
+        {
+        TDelayedObserverData* delayData = new (ELeave) TDelayedObserverData;
+        CleanupStack::PushL( delayData);
+        delayData->iRequest = KUnRegisterURIOperation;
+        delayData->iObserver = &aObserver;
+        delayData->iEventType = aEvent;
+        delayData->iContentID = aContentID.AllocLC();
+        iDelayedObservers->AppendL( delayData );
+        CleanupStack::Pop();    // iContentID;
+        CleanupStack::Pop();    // delayData;
+        return;
+        }
+
+    // Check if something else uses the registration for this event type, if something
+    // Does set removeFromServer to EFalse so the registration is not removed from the
+    // server
+    switch ( aEvent )
+        {
+        case KEventAddRemove:
+            if ( iAddRemoveObservers )
+                {
+                for ( count = 0; count < iAddRemoveObservers->Count(); ++count )
+                    {
+                    if( removeFromServer && 
+                        !( *iAddRemoveObservers )[ count ]->iContentID->Compare( aContentID ) &&
+                        ( *iAddRemoveObservers )[ count ]->iObserver != &aObserver ) 
+                        {
+                        removeFromServer = EFalse;
+                        }
+                    }
+                }
+            break;
+        case KEventModify:
+            if ( iModifyObservers )
+                {
+                for ( count = 0; count < iModifyObservers->Count(); ++count )
+                    {
+                    if( removeFromServer && 
+                        !( *iModifyObservers )[ count ]->iContentID->Compare( aContentID ) &&
+                        ( *iModifyObservers )[ count ]->iObserver != &aObserver ) 
+                        {
+                        removeFromServer = EFalse;
+                        }
+                    }
+                }
+            break;
+        default:
+            User::Leave(KErrArgument);
+            break;
+        }  
+
+
+    // Remove the registrations from internal lists and possibly from the server
+    switch ( aEvent )
+        {
+        case KEventAddRemove:
+            if ( iAddRemoveObservers )
+                {
+                for ( count = 0; count < iAddRemoveObservers->Count(); ++count )
+                    {
+                    if ( ( *iAddRemoveObservers )[ count ]->iObserver == &aObserver &&
+                         ( *iAddRemoveObservers )[ count ]->iContentID &&
+                         !( *iAddRemoveObservers )[ count ]->iContentID->Compare( aContentID ) )
+                        {
+                        if ( removeFromServer )
+                            {
+                            // Unregister the type from the server
+                            iHandler->UnRegisterFromType(aEvent,(*iAddRemoveObservers)[ count ]->iContentID);
+                            }
+
+                        // Free Memory
+                        delete ( *iAddRemoveObservers )[ count ]->iContentID;
+                        ( *iAddRemoveObservers )[ count ]->iContentID = NULL;
+                        delete ( *iAddRemoveObservers )[ count ];
+                        ( *iAddRemoveObservers )[ count ] = NULL;
+
+                        // Delete the element from the table
+                        iAddRemoveObservers->Delete( count );
+                        iAddRemoveObservers->Compress();
+                        return;
+                        }
+                    }
+                }
+            User::Leave(KErrNotFound);
+            break;
+        case KEventModify:
+            if ( iModifyObservers )
+                {
+                for ( count = 0; count < iModifyObservers->Count(); ++count )
+                    {
+                    if ( ( *iModifyObservers )[ count ]->iObserver == &aObserver &&
+                         ( *iModifyObservers )[ count ]->iContentID &&
+                         !( *iModifyObservers )[ count ]->iContentID->Compare( aContentID ) )
+                        {
+
+                        if( removeFromServer )
+                            {
+                            // Unregister the type from the server
+                            iHandler->UnRegisterFromType(aEvent,(*iModifyObservers)[ count ]->iContentID);
+                            }
+
+                        // Free Memory
+                        delete ( *iModifyObservers )[ count ]->iContentID;
+                        ( *iModifyObservers )[ count ]->iContentID = NULL;
+                        delete ( *iModifyObservers )[ count ];
+                        ( *iModifyObservers )[ count ] = NULL;
+
+                        // Delete the element from the table
+                        iModifyObservers->Delete( count );
+                        iModifyObservers->Compress();
+                        return;
+                        }
+                    }
+                }
+            User::Leave(KErrNotFound);
+            break;
+        default:
+            User::Leave(KErrArgument);
+            break;
+        }  
+    // Should never get here
+    User::Leave( KErrGeneral );
+    }
+// -----------------------------------------------------------------------------
+// CDRMEventHandler::SendEventL
+// Sends the event to the client that sends it to the server
+// Opens connection if it's not already open
+// -----------------------------------------------------------------------------
+//
+void CDRMEventHandler::SendEventL( MDRMEvent& aEvent, TRequestStatus& aStatus )
+    {
+    RMemWriteStream output(iDataBuffer,DRMNotifier::KDRMSizeOfMessage);
+    CleanupClosePushL( output );
+    
+    Mem::FillZ(iDataBuffer,DRMNotifier::KDRMSizeOfMessage);
+
+    if(!iIsOpen)
+        {
+		if(!iHandler)
+            {
+            iHandler = new (ELeave) RDRMNotifierClient(iEventType,iEventTypeWait,iData,iWaitData);
+            }
+        User::LeaveIfError(iHandler->Connect());
+        iIsOpen = ETrue;            
+        }
+
+    aEvent.ExternalizeL(output);
+    aEvent.GetEventType(*iEventType);
+    
+    iHandler->SendEvent(aStatus);
+    CleanupStack::PopAndDestroy();
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventHandler::CDRMEventHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMEventHandler::CDRMEventHandler() :
+   CActive( EPriorityUserInput ), iIsOpen( EFalse )
+{
+   // Nothing
+}
+
+// -----------------------------------------------------------------------------
+// CDRMNotificationHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMEventHandler::ConstructL()
+{
+    iDataBuffer = static_cast<TUint8*>(User::AllocL(DRMNotifier::KDRMSizeOfMessage));
+    iEventType = static_cast<TDRMEventType*>(User::AllocL(sizeof(TDRMEventType*)));
+    iWaitDataBuffer = static_cast<TUint8*>(User::AllocL(DRMNotifier::KDRMSizeOfMessage));
+    iEventTypeWait = static_cast<TDRMEventType*>(User::AllocL(sizeof(TDRMEventType*)));
+
+    iData = new( ELeave ) TPtr8(iDataBuffer,DRMNotifier::KDRMSizeOfMessage,DRMNotifier::KDRMSizeOfMessage);
+    iWaitData = new( ELeave) TPtr8(iWaitDataBuffer,DRMNotifier::KDRMSizeOfMessage,DRMNotifier::KDRMSizeOfMessage);
+
+    iHandler = new (ELeave) RDRMNotifierClient(iEventType,iEventTypeWait,iData,iWaitData);
+
+    User::LeaveIfError( iHandler->Connect() );
+    iIsOpen = ETrue;
+
+    iAddRemoveObservers = new( ELeave ) CArrayPtrSeg< TObserverData >( 4 );
+    iModifyObservers = new( ELeave ) CArrayPtrSeg< TObserverData >( 4 );
+    iTimeChangeObservers = new( ELeave ) CArrayPtrSeg< TObserverData >( 4 );    
+    iDelayedObservers = new( ELeave ) CArrayPtrSeg< TDelayedObserverData >( 4 );
+
+    Mem::FillZ(iDataBuffer,DRMNotifier::KDRMSizeOfMessage);
+    Mem::FillZ(iDataBuffer,DRMNotifier::KDRMSizeOfMessage);
+    Mem::FillZ(iEventType,sizeof(TDRMEventType));
+    Mem::FillZ(iEventTypeWait,sizeof(TDRMEventType));
+}
+
+// -----------------------------------------------------------------------------
+// CDRMNotificationHandler::RunL
+// Inherited from CActive
+// -----------------------------------------------------------------------------
+//
+void CDRMEventHandler::RunL()
+{
+   __ASSERT_DEBUG( iAddRemoveObservers, User::Invariant() );
+   __ASSERT_DEBUG( iModifyObservers, User::Invariant() );
+
+   if ( iStatus == KErrCancel )
+       {
+       return;
+       }
+
+   TRAPD( error, HandleRunL() );
+   
+   if( error && iIsDelayed )
+       {
+       iIsDelayed = EFalse;
+       }
+
+   // Discard all errors except this one.
+   if ( error == KErrServerTerminated )
+   {
+      User::Leave( KErrServerTerminated );
+   }  
+   SetActive();   
+}
+
+void CDRMEventHandler::DoCancel()
+{
+   iHandler->CancelRequest();
+}
+
+// -----------------------------------------------------------------------------
+// CDRMEventHandler::GetEventObjectLC
+// -----------------------------------------------------------------------------
+//
+MDRMEvent* CDRMEventHandler::GetEventObjectLC()
+    {
+    MDRMEvent* event = NULL;
+    switch(*iEventTypeWait)
+        {
+        case KEventAddRemove:
+            event = CDRMEventAddRemove::NewLC( ERightsObjectRecieved );
+            break;
+        case KEventModify:
+            event = CDRMEventModify::NewLC();
+            break;
+        case KEventTimeChange:
+            event = CDRMEventTimeChange::NewLC();
+            break;
+        }           
+    return event;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMEventHandler::HandleRunL
+// -----------------------------------------------------------------------------
+//
+void CDRMEventHandler::HandleRunL()
+{
+    MDRMEvent* object = NULL;
+    TDRMEventType event = 0;
+    TInt count = 0;
+    HBufC8* contentID = NULL;
+    TInt error = KErrNone;
+    
+    RMemReadStream input(iWaitDataBuffer,DRMNotifier::KDRMSizeOfMessage);
+    CleanupClosePushL( input );
+    
+    if(!iIsOpen)
+        {
+		if(!iHandler)
+            {
+            iHandler = new (ELeave) RDRMNotifierClient(iEventType,iEventTypeWait,iData,iWaitData);
+            }
+        User::LeaveIfError(iHandler->Connect());
+        iIsOpen = ETrue;            
+        }
+
+    object = GetEventObjectLC();
+    if(!object)
+        {
+        User::Leave(KErrGeneral);
+        }
+
+    object->InternalizeL(input);
+
+    object->GetEventType(event);
+
+    iIsDelayed = ETrue;
+
+    switch ( event )
+        {
+        case KEventAddRemove:
+            if ( iAddRemoveObservers )
+                {
+                TRAPD( error_mem, contentID = (reinterpret_cast<CDRMEventAddRemove*>(object))->GetContentIDL());
+                if ( error_mem )
+                    {
+                    iIsDelayed = EFalse;
+                    User::Leave( error_mem );
+                    }                
+                CleanupStack::PushL(contentID);
+
+                for ( count = 0; count < iAddRemoveObservers->Count(); ++count )
+                    {
+                    if( !( *iAddRemoveObservers )[ count ]->iContentID ||
+                        !( *iAddRemoveObservers )[ count ]->iContentID->Compare( contentID->Des() ) )
+                        {
+                        TRAP( error, ( *iAddRemoveObservers )[ count ]->iObserver->HandleEventL( object ) );
+                        }
+                    }
+                CleanupStack::PopAndDestroy();
+                }
+            break;
+        case KEventModify:
+            if ( iModifyObservers )
+                {
+                TRAPD(error_mem, contentID = (reinterpret_cast<CDRMEventModify*>(object))->GetContentIDL());
+                if( error_mem )
+                    {
+                    iIsDelayed = EFalse;
+                    User::Leave( error_mem );
+                    }                
+                CleanupStack::PushL(contentID);
+ 
+                for ( count = 0; count < iModifyObservers->Count(); ++count )
+                    {
+                    if( !( *iModifyObservers )[ count ]->iContentID ||
+                        !( *iModifyObservers )[ count ]->iContentID->Compare( contentID->Des() ) )
+                        {
+                        TRAP( error, ( *iModifyObservers )[ count ]->iObserver->HandleEventL( object ) );
+                        }
+                    }
+                CleanupStack::PopAndDestroy();
+                }
+            break;
+        case KEventTimeChange:
+             if ( iTimeChangeObservers )
+                {
+                for ( count = 0; count < iTimeChangeObservers->Count(); ++count )
+                    {
+                    TRAP( error, ( *iTimeChangeObservers )[ count ]->iObserver->HandleEventL( object ) );
+                    }
+                }      
+            break;
+        default:
+            iIsDelayed = EFalse;
+            User::Leave(KErrArgument);
+            break;
+        }
+        
+    // Ignore errors   
+    if( error )
+        {
+        // Do nothing
+        }
+    if( iStatus != KRequestPending )
+        {
+        iStatus = KRequestPending;
+        iHandler->WaitForCompletion(iStatus);
+        }
+    CleanupStack::PopAndDestroy(); // object
+    CleanupStack::PopAndDestroy(); // input
+    iIsDelayed = EFalse;
+
+    // Run delayed the adding and removing events in order
+    while ( iDelayedObservers->Count() )
+        {
+        TInt ignore_error = KErrNone;
+
+        switch( ( *iDelayedObservers )[ 0 ]->iRequest )
+            {
+            case KRegisterOperation:
+                TRAP(ignore_error, 
+                    RegisterEventObserverL( *( *iDelayedObservers )[ 0 ]->iObserver,
+                                            ( *iDelayedObservers )[ 0 ]->iEventType ) );
+                break;
+            case KRegisterURIOperation:
+                TRAP(ignore_error, 
+                    RegisterEventObserverL( *( *iDelayedObservers )[ 0 ]->iObserver,
+                                            ( *iDelayedObservers )[ 0 ]->iEventType,
+                                            ( *iDelayedObservers )[ 0 ]->iContentID->Des() ) );
+                break;
+            case KUnRegisterOperation:
+                TRAP(ignore_error, 
+                    UnRegisterEventObserverL( *( *iDelayedObservers )[ 0 ]->iObserver,
+                                              ( *iDelayedObservers )[ 0 ]->iEventType ) );
+                break;
+            case KUnRegisterURIOperation:
+                TRAP(ignore_error, 
+                    UnRegisterEventObserverL( *( *iDelayedObservers )[ 0 ]->iObserver,
+                                              ( *iDelayedObservers )[ 0 ]->iEventType,
+                                              ( *iDelayedObservers )[ 0 ]->iContentID->Des() ) );
+                break;
+            default:
+                break;
+            }
+        if ( ( *iDelayedObservers )[ 0 ]->iContentID )
+            {
+            delete ( *iDelayedObservers )[ 0 ]->iContentID;
+            ( *iDelayedObservers )[ 0 ]->iContentID = NULL;
+            }
+        delete ( *iDelayedObservers )[ 0 ];
+        ( *iDelayedObservers )[ 0 ] = NULL;
+        iDelayedObservers->Delete( 0 );
+        iDelayedObservers->Compress();
+        }
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/src/DRMEventModify.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,190 @@
+/*
+* 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:  Notification Event object base class
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "DRMEventModify.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventModify::NewLC
+// Two phased constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMEventModify* CDRMEventModify::NewLC()
+    {
+    CDRMEventModify* self = new (ELeave) CDRMEventModify( 0 );
+    CleanupStack::PushL( self );
+    return self;     
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventModify::NewL
+// Two phased constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMEventModify* CDRMEventModify::NewL()
+    {
+    CDRMEventModify* self = NewLC();
+    CleanupStack::Pop();
+    return self;    
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventModify::CDRMEventModify
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMEventModify::CDRMEventModify( TUint32 aUniqueID ) : 
+    MDRMEvent( KEventModify ), 
+    iContentID( NULL ),
+    iUniqueID( aUniqueID )
+    {
+    };
+
+// Destructor
+EXPORT_C CDRMEventModify::~CDRMEventModify()
+    {
+    if( iContentID )
+        {
+        delete iContentID;
+        }
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventModify::SetContentIDL
+// Reserves memory for the content id, if one has been defined it is freed
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventModify::SetContentIDL( const TDesC8& aContentID )
+    {
+    if ( iContentID )
+        {
+        delete iContentID;
+        iContentID = NULL;
+        }
+    iContentID = aContentID.AllocL();
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventModify::SetUniqueID
+// sets the unique id variable
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventModify::SetUniqueID( const TUint32 aUniqueID )
+    {
+    iUniqueID = aUniqueID;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventModify::Status
+// returns the unique id variable
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TUint32 CDRMEventModify::UniqueID() const
+    {
+    return iUniqueID;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventModify::GetContentIDL
+// returns the content id as parameter
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* CDRMEventModify::GetContentIDL() const 
+    {
+    return iContentID->AllocL();
+    };            
+    
+// -----------------------------------------------------------------------------
+// CDRMEventModify::ExternalizeL
+// Writes the data of the object into the given stream
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventModify::ExternalizeL(
+    RWriteStream& aOutput)
+    {
+    TInt outputLength = 0;
+
+    MDRMEvent::ExternalizeL(aOutput);
+
+    // get the output length of the HBufC8*
+    outputLength = iContentID->Size();
+    aOutput.WriteInt32L(outputLength);
+
+    // write out the HBufC8*
+    aOutput.WriteL(*iContentID);
+
+    // this implementation may need to be changed if the size of the enum changes
+    aOutput.WriteUint32L(iUniqueID);
+    };
+
+
+// --------------------------------------------------------------------------- --
+// CDRMEventModify::Internalize
+// Reads the data of the object from the given stream
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventModify::InternalizeL(
+    RReadStream& aInput) 
+    {
+    TInt inputLength = 0;
+
+    MDRMEvent::InternalizeL(aInput);
+
+    // Read the length of the HBufC8*
+    inputLength = aInput.ReadInt32L();
+
+    // Reserve the HBufC8*
+    if( !iContentID )
+        {
+        iContentID = HBufC8::NewL(inputLength);
+        }
+    else 
+        {
+        iContentID->ReAllocL(inputLength);
+        }
+
+    // Read the HBufC8*
+    TPtr8 inRead(iContentID->Des());
+    aInput.ReadL(inRead,inputLength); 
+
+    // this implementation may need to be changed if the size of the enum changes
+    iUniqueID = aInput.ReadUint32L();
+    };
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/src/DRMEventTimeChange.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,304 @@
+/*
+* 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:  Notification Event object base class
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "DRMEventTimeChange.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::NewLC
+// two phased constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMEventTimeChange* CDRMEventTimeChange::NewLC()
+    {
+    CDRMEventTimeChange* self = new (ELeave) CDRMEventTimeChange();
+    CleanupStack::PushL( self );
+    return self; 
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::NewL
+// two phased constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMEventTimeChange* CDRMEventTimeChange::NewL()
+    {
+    CDRMEventTimeChange* self = NewLC();
+    CleanupStack::Pop();
+    return self;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::CDRMEventTimeChange
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMEventTimeChange::CDRMEventTimeChange() : 
+    MDRMEvent( KEventTimeChange ), 
+    iOldTime( Time::NullTTime() ),
+    iNewTime( Time::NullTTime() ),
+    iOldTimeZone( 0 ),
+    iNewTimeZone( 0 ),
+    iOldSecurityLevel( DRMClock::KInsecure ),
+    iNewSecurityLevel( DRMClock::KInsecure )
+    {       
+    };
+
+// Destructor
+EXPORT_C CDRMEventTimeChange::~CDRMEventTimeChange()
+    {
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::SetOldTime
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventTimeChange::SetOldTime( const TTime& aTime )
+    {
+    iOldTime = aTime;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::GetOldTime
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TTime& CDRMEventTimeChange::GetOldTime() const
+    {
+    return iOldTime;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::SetNewTime
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventTimeChange::SetNewTime( const TTime& aTime )
+    {
+    iNewTime = aTime;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::GetNewTime
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TTime& CDRMEventTimeChange::GetNewTime() const
+    {
+    return iNewTime;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::SetOldTimeZone
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventTimeChange::SetOldTimeZone( const TInt aTimeZone )
+    {
+    iOldTimeZone = aTimeZone;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::GetOldTimeZone
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMEventTimeChange::GetOldTimeZone() const
+    {
+    return iOldTimeZone;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::SetNewTimeZone
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventTimeChange::SetNewTimeZone( const TInt aTimeZone )
+    {
+    iNewTimeZone = aTimeZone;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::GetNewTimeZone
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMEventTimeChange::GetNewTimeZone() const
+    {
+    return iNewTimeZone;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::SetOldSecurityLevel
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventTimeChange::SetOldSecurityLevel( 
+    const DRMClock::ESecurityLevel aSecLevel )
+    {
+    iOldSecurityLevel = aSecLevel;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::GetOldSecurityLevel
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRMClock::ESecurityLevel CDRMEventTimeChange::GetOldSecurityLevel() const
+    {
+    return iOldSecurityLevel;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::SetNewSecurityLevel
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventTimeChange::SetNewSecurityLevel( 
+    const DRMClock::ESecurityLevel aSecLevel )
+    {
+    iNewSecurityLevel = aSecLevel;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::GetNewSecurityLevel
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRMClock::ESecurityLevel CDRMEventTimeChange::GetNewSecurityLevel() const
+    {
+    return iNewSecurityLevel;
+    };
+   
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::ExternalizeL
+// Writes the data of the object into the given stream
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventTimeChange::ExternalizeL(
+    RWriteStream& aOutput)
+    {
+    TInt8 securityLevel = 0;
+
+    MDRMEvent::ExternalizeL(aOutput);
+
+    // output the old time
+    WriteInt64L( iOldTime.Int64(), aOutput );
+    
+    // output the new time
+    WriteInt64L( iNewTime.Int64(), aOutput );
+    
+    // output the old timezone 
+    aOutput.WriteInt32L( iOldTimeZone );
+    
+    // output the new timezone
+    aOutput.WriteInt32L( iNewTimeZone );
+    
+    // output the old security level
+    securityLevel = iOldSecurityLevel;
+    aOutput.WriteInt8L( securityLevel );    
+            
+    // output the new security level
+    securityLevel = iNewSecurityLevel;
+    aOutput.WriteInt8L( securityLevel ); 
+    
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::Internalize
+// Reads the data of the object from the given stream
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMEventTimeChange::InternalizeL(
+    RReadStream& aInput) 
+    {
+    TInt8 securityLevel = 0;
+    TInt64 timeData = 0;
+
+    MDRMEvent::InternalizeL(aInput);
+
+    // input the old time
+    ReadInt64L( timeData, aInput );
+    iOldTime = timeData;
+    
+    // input the new time
+    ReadInt64L( timeData, aInput );    
+    iNewTime = timeData;
+    
+    // input the old time zone
+    iOldTimeZone = aInput.ReadInt32L();
+    
+    // input the new time zone
+    iNewTimeZone = aInput.ReadInt32L();
+    
+    // input the old security level
+    securityLevel = aInput.ReadInt8L();
+    iOldSecurityLevel = static_cast<DRMClock::ESecurityLevel>(securityLevel);
+    
+    // input the new security level
+    securityLevel = aInput.ReadInt8L();
+    iNewSecurityLevel = static_cast<DRMClock::ESecurityLevel>(securityLevel);    
+    
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::WriteInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMEventTimeChange::WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const
+    {
+    TPtr8 output(NULL,0,0);
+    
+    output.Set( reinterpret_cast<TUint8*>(const_cast<TInt64*>(&aWrite)), 
+                sizeof(TInt64), sizeof(TInt64) );
+    
+    aStream.WriteL( output, sizeof(TInt64) );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMEventTimeChange::ReadInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMEventTimeChange::ReadInt64L( TInt64& aRead, RReadStream& aStream )
+    {
+    TPtr8 input(NULL,0,0);
+    
+    input.Set( reinterpret_cast<TUint8*>(&aRead), 0, sizeof(TInt64) );
+    
+    aStream.ReadL( input, sizeof(TInt64) );    
+    };    
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/src/DRMMessageStorage.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,292 @@
+/*
+* 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:  DRM3 Engine manages all DRM related database operations.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <s32mem.h> 
+#include "DRMNotifierSession.h"
+#include "DRMEventAddRemove.h"
+#include "DRMEventModify.h"
+#include "DRMEventTimeChange.h"
+#include "drmnotifierclientserver.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+
+#ifdef _DRM_TESTING
+_LIT( KDateTimeFormat, "%F%Y%M%D%H%T%S%C" );
+#define _LOGBUFNUM( a, b ) { TBuf8< 64 > __b( a ); __b.AppendNum( b ); file.Write( __b ); }
+#define LOGBUFNUM( a, b ) { TBuf8< 64 > __b( a ); __b.AppendNum( b ); Log( __b ); }
+#define LOG( a ) Log( a )
+
+#else
+#define _LOGBUFNUM( a, b )
+#define LOGBUFNUM( a, b )
+#define LOG( a )
+#endif
+
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMMessageStorage::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMMessageStorage* CDRMMessageStorage::NewL()
+    {
+    CDRMMessageStorage* self = new( ELeave ) CDRMMessageStorage();
+    
+    CleanupStack::PushL( self );
+    
+    self->ConstructL();
+    
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CDRMMessageStorage::~CDRMMessageStorage() 
+    {
+    for ( TInt i = 0; i < iMessages.Count();i++ )
+        {
+        delete iMessages[i]->iData;
+        delete iMessages[i]->iMessageData;
+        }
+    iMessages.ResetAndDestroy();
+    iSessions.Reset();
+    
+    LOG( _L8( "Dying..." ) );
+    
+#ifdef _DRM_TESTING
+    delete iLog;
+#endif
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageStorage::AddSession
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageStorage::AddSession( CDRMNotifierSession* aSession ) 
+    {
+    iSessions.Append( aSession );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMMessageStorage::UpdateMessage
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageStorage::UpdateMessage( TMessageData* aMessage )
+    {
+    TInt count = 0;
+
+    aMessage->iRefCount = aMessage->iRefCount - 1;
+
+    if(aMessage->iRefCount == 0)
+        {
+        for( count = 0; count < iMessages.Count(); count++ )
+            {
+            if( iMessages[count] == aMessage )
+                {
+                delete iMessages[count]->iMessageData;
+                delete iMessages[count]->iData;
+                iMessages[count]->iMessageData = 0;
+                iMessages[count]->iData = 0;
+                }
+            iMessages.Remove(count);
+            count = iMessages.Count();
+            }
+        }
+    }
+// -----------------------------------------------------------------------------
+// CDRMMessageStorage::GetEventObjectLC
+// -----------------------------------------------------------------------------
+//
+MDRMEvent* CDRMMessageStorage::GetEventObjectLC( TDRMEventType aEventType )
+    {
+    MDRMEvent* event = NULL;
+
+    switch( aEventType)
+        {
+        case KEventAddRemove:
+            event = CDRMEventAddRemove::NewLC(ERightsObjectRecieved);
+            break;
+        case KEventModify:
+            event = CDRMEventModify::NewLC();
+            break;
+        case KEventTimeChange:
+            event = CDRMEventTimeChange::NewLC();
+            break;
+	    default:
+	        User::Leave(KErrArgument);
+	        break;
+        }           
+    return event;
+    }
+        
+// -----------------------------------------------------------------------------
+// CDRMMessageStorage::NotifyL
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageStorage::NotifyL(TDRMEventType& aEventType, const RMessage2& aMessage) 
+    {
+    TInt queued = EFalse;
+    TMessageData* message = new (ELeave) TMessageData;
+    CleanupStack::PushL(message);
+    TUint8* eventBuf = static_cast<TUint8*>(User::AllocLC(DRMNotifier::KDRMSizeOfMessage));
+    TPtr8 event( eventBuf,0,DRMNotifier::KDRMSizeOfMessage );
+
+    message->iRefCount = 0;
+    message->iEventType = aEventType;
+    message->iData = 0;
+    message->iMessageData = eventBuf;
+
+
+    // Read the buffer:
+    aMessage.ReadL( 0, event);
+
+    RMemReadStream input(eventBuf, DRMNotifier::KDRMSizeOfMessage);
+    MDRMEvent* eventobj = GetEventObjectLC(aEventType);
+    eventobj->InternalizeL(input);
+
+    // We need to extract the uri from the message
+    // for those that it is needed
+    switch( aEventType )
+        {
+        case KEventAddRemove:
+            message->iData = static_cast<CDRMEventAddRemove*>(eventobj)->GetContentIDL();
+            break;
+        case KEventModify:
+            message->iData = static_cast<CDRMEventModify*>(eventobj)->GetContentIDL();
+            break;
+        case KEventTimeChange:
+            break;
+        default:
+            User::Leave(KErrArgument);
+            break;
+        }
+    CleanupStack::PopAndDestroy(); // eventobj
+    CleanupStack::PushL(message->iData);
+
+    for( TInt i = 0; i < iSessions.Count();i++ )
+        {
+        queued = EFalse;
+
+        TRAPD(error, queued = iSessions[i]->SendNotificationL( message ) );
+        if( error && error != KErrNotFound )
+            {
+            User::LeaveIfError(error);
+            }
+        else if( queued )
+            {
+            message->iRefCount++;
+            }
+        }
+
+    if( !message->iRefCount ) 
+        {
+        CleanupStack::PopAndDestroy(); // message->iData;
+        CleanupStack::PopAndDestroy(); // eventBuf;
+        CleanupStack::PopAndDestroy(); // message
+        }
+    else
+        {
+        iMessages.Append( message );
+        CleanupStack::Pop(); // message->iData;
+        CleanupStack::Pop(); // eventBuf
+        CleanupStack::Pop(); // message
+        }
+    };
+// -----------------------------------------------------------------------------
+// CDRMMessageStorage::CancelL
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageStorage::CancelL(CDRMNotifierSession* aSession)
+    {
+    TInt count = 0;
+
+    for ( count = 0; count < iSessions.Count(); count++ )
+        {
+        if( iSessions[count] == aSession)
+            {
+            iSessions.Remove(count);
+            return;
+            }
+        } 
+    User::Leave(KErrNotFound);
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageStorage::CDRMMessageStorage
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMMessageStorage::CDRMMessageStorage() : iSessions(4), iMessages(4)
+    {
+    // Nothing
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMMessageStorage::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageStorage::ConstructL() 
+    {
+    }
+
+
+#ifdef _DRM_TESTING
+
+// -----------------------------------------------------------------------------
+// CDRMMessageStorage::Log
+// Logging operation.
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageStorage::Log( const TDesC8& aLog ) const
+    {
+    iLog->Log( aLog );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMMessageStorage::Log
+// Logging operation.
+// -----------------------------------------------------------------------------
+//
+void CDRMMessageStorage::Log( const TDesC& aLog ) const
+    {
+    iLog->Log( aLog );
+    }
+#endif
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/src/DRMNotifier.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,163 @@
+/*
+* 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:  This class handles registering and unregistering of
+*                DRM event observers to DRM notifier, and sending
+*                DRM notifications to other registered observers.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "DRMNotifier.h"
+#include    "DRMEventHandler.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMNotifier::CDRMNotifier
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMNotifier::CDRMNotifier( void ) : iEventHandler( NULL )
+    {
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMNotifier::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifier::ConstructL()
+    {
+    iEventHandler = CDRMEventHandler::NewL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMNotifier::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMNotifier* CDRMNotifier::NewL()
+    {
+    CDRMNotifier* self = NewLC();
+    CleanupStack::Pop();
+
+    return self;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMNotifier::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMNotifier* CDRMNotifier::NewLC()
+    {
+    CDRMNotifier* self = new( ELeave ) CDRMNotifier;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+
+    return self;
+    };
+
+
+
+// Destructor
+EXPORT_C CDRMNotifier::~CDRMNotifier()
+    {
+    if ( iEventHandler )
+        {
+        delete iEventHandler;
+        }
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMNotifier::RegisterEventObserverL
+// Registers the observer to the event handler
+// (other items were commented in a header)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMNotifier::RegisterEventObserverL(
+    MDRMEventObserver& aObserver,
+    const TDRMEventType& aEvent )
+    {
+    iEventHandler->RegisterEventObserverL( aObserver,aEvent );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifier::UnRegisterEventObserverL
+// Unregisters the observer from the event handler 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMNotifier::UnRegisterEventObserverL(
+    MDRMEventObserver& aObserver,
+    const TDRMEventType& aEvent )
+    {
+    iEventHandler->UnRegisterEventObserverL( aObserver, aEvent );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifier::RegisterEventObserverL
+// Registers the observer to the event handler
+// (other items were commented in a header)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMNotifier::RegisterEventObserverL(
+    MDRMEventObserver& aObserver,
+    const TDRMEventType& aEvent,
+    const TDesC8& aContentID )
+    {
+    iEventHandler->RegisterEventObserverL( aObserver, aEvent, aContentID );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifier::UnRegisterEventObserverL
+// Unregisters the observer from the event handler 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMNotifier::UnRegisterEventObserverL(
+    MDRMEventObserver& aObserver,
+    const TDRMEventType& aEvent,
+    const TDesC8& aContentID )
+    {
+    iEventHandler->UnRegisterEventObserverL( aObserver, aEvent, aContentID );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifier::UnRegisterEventObserverL
+// Unregisters the observer from the event handler 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMNotifier::SendEventL( MDRMEvent& aEvent, TRequestStatus& aStatus )
+    {
+    iEventHandler->SendEventL( aEvent, aStatus );
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/src/DRMNotifierClient.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,205 @@
+/*
+* 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:  This file contains implementation of RDRMNotifierClient class.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "DRMNotifierClient.h"
+#include "drmnotifierclientserver.h"
+#include "drmrightsclient.h"
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDRMNotifierClient::RDRMNotifierClient
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+RDRMNotifierClient::RDRMNotifierClient(TDRMEventType* aEventType, TDRMEventType* aEventTypeWait, 
+                                       TPtr8* aPtr, TPtr8* aWaitPtr) :
+    iEventType( aEventType ),
+    iEventTypeWait( aEventTypeWait ),
+    iData( aPtr ),
+    iWaitData( aWaitPtr ),
+    numdata( 0 )
+    {
+   // Nothing
+    }
+    
+// Destructor
+RDRMNotifierClient::~RDRMNotifierClient()
+    {
+    Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMNotifierClient::Connect
+// Connects to the server
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt RDRMNotifierClient::Connect( void )
+    {
+    const TVersion requiredVersion( 
+        DRMNotifier::KServerMajorVersion,
+        DRMNotifier::KServerMinorVersion,
+        DRMNotifier::KServerBuildVersion );
+    
+    TInt ret = KErrNotFound;
+    TUint8 count( 0 );
+    TUint8 cont( 1 );
+    
+    do
+        {
+        ret = CreateSession( DRMNotifier::KServerName,
+                             requiredVersion,
+                             KMaxMessageSlots );
+        if ( !ret )
+            {
+            cont = 0;
+            }
+        else
+            {
+            if ( ( count++ == 0 ) && ( ret == KErrNotFound ) )
+                {
+                ret = RDRMRightsClient::StartServer();
+                }
+            }
+        }
+    while ( cont && ( count < 2 ) );
+    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMNotifierClient::Close
+// Closes the connection to the server
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void RDRMNotifierClient::Close() 
+    {
+    RHandleBase::Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMNotifierClient::SendEvent
+// Sends an event to the client, asynchronous
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void RDRMNotifierClient::SendEvent(TRequestStatus& aStatus) 
+    {
+    // Send the message.
+    SendReceive( DRMNotifier::ENotifyClients, TIpcArgs(iData, *iEventType),
+		aStatus );
+    };
+
+// -----------------------------------------------------------------------------
+// RDRMNotifierClient::WaitForCompletion
+// Waits for the notifications from the server, asynchronous
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void RDRMNotifierClient::WaitForCompletion(TRequestStatus& aStatus) 
+    {   
+    numdata.Set(reinterpret_cast<TUint8*>(iEventTypeWait),sizeof(TDRMEventType),sizeof(TDRMEventType));
+        
+    // Send the message.
+    SendReceive( DRMNotifier::ERecieveNotification, TIpcArgs(iWaitData, &numdata),
+		aStatus );
+    };
+
+// -----------------------------------------------------------------------------
+// RDRMNotifierClient::RegisterForType
+// Registeres a type to the server, synchronous
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void RDRMNotifierClient::RegisterForType( TDRMEventType aEventType, 
+                                          HBufC8* aURI )
+    {
+    TPckg<TInt> eventType(0);
+    eventType.Set(reinterpret_cast<TUint8*>(&aEventType),sizeof(TDRMEventType),sizeof(TDRMEventType));
+
+    if( aURI )
+        {
+        TUint8* dataptr = const_cast<TUint8*>(aURI->Ptr());
+        TPtr8 uriPkg(dataptr,aURI->Size(),aURI->Size());
+
+        // Send the message.
+        SendReceive( DRMNotifier::ERegisterURI, TIpcArgs(&uriPkg, &eventType));
+        }
+    else 
+        {
+        // Send the message.
+        SendReceive( DRMNotifier::ERegister, TIpcArgs(&eventType));
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMNotifierClient::UnRegisterFromType
+// Unregisteres a type from the server, synchronous
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void RDRMNotifierClient::UnRegisterFromType( TDRMEventType aEventType, 
+                                             HBufC8* aURI)
+    {
+    TPckg<TInt> eventType(0);
+    eventType.Set(reinterpret_cast<TUint8*>(&aEventType),sizeof(TDRMEventType),sizeof(TDRMEventType));
+
+    if( aURI )
+        {
+        TUint8* dataptr = const_cast<TUint8*>(aURI->Ptr());
+        TPtr8 uriPkg(dataptr,aURI->Size(),aURI->Size());
+
+        // Send the message.
+        SendReceive( DRMNotifier::EUnRegisterURI, TIpcArgs(&uriPkg, &eventType));
+        }
+    else 
+        {
+        // Send the message.
+        SendReceive( DRMNotifier::EUnRegister, TIpcArgs(&eventType));
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMNotifierClient::CancelRequest
+// Cancels the request from the server, synchronous
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void RDRMNotifierClient::CancelRequest()
+    {
+    // Send the message.
+    SendReceive( DRMNotifier::ECancelNotification);
+    };
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/src/DRMNotifierServer.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,343 @@
+/*
+* 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:  DRM3 Engine manages all DRM related database operations.
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "DRMNotifierServer.h"
+#include "drmnotifierclientserver.h"
+#include "drmcommonclientserver.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+
+#define _LOGBUFNUM( a, b )
+#define LOGBUFNUM( a, b )
+#define LOG( a )
+
+// LOCAL CONSTANTS AND MACROS
+LOCAL_C const TUint8 KMaxStartTries = 5;
+LOCAL_C const TInt KWaitingTime = 1000000; // 10 secs
+_LIT( KNotifierThread, "drmnotifier" );
+
+// MODULE DATA STRUCTURES
+using DRMNotifier::KServerMajorVersion;
+using DRMNotifier::KServerMinorVersion;
+using DRMNotifier::KServerBuildVersion;
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TInt StartNotifierServer( RSemaphore& aClientSem );
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// Function StartNotifierServer().
+// This function starts the actual server under TRAP harness and starts
+// waiting for connections. This function returns only if there has been
+// errors during server startup or the server is stopped for some reason.
+// 
+// Returns: TInt: Symbian OS error code.
+// -----------------------------------------------------------------------------
+TInt StartNotifierServer( RSemaphore& aClientSem ) 
+
+    {
+    TInt error = KErrNone;
+    CDRMNotifierServer* server = NULL;
+
+    TUint8 count = 0;
+
+#ifdef _DRM_TESTING
+    TTime time;
+    _LIT8( KDRMErrorDebugText, "Error: " );
+    RFs fs;
+    RFile file;
+
+    TFileName filename;
+
+    time.UniversalTime();
+    
+    TRAPD( error2, time.FormatL( filename, KDateTimeFormat ) );
+    filename.Append( _L( "DRMNotifier.txt " ) );
+    
+    error = fs.Connect();
+    if ( error )
+        {
+        return error;
+        }
+
+    file.Replace( fs, filename, EFileStreamText | EFileWrite );
+    file.Write( _L8( "Started." ) );
+#endif
+
+    do 
+    {
+       _LOGBUFNUM( KDRMErrorDebugText, error );
+       
+       ++count;
+       
+       TRAP( error, ( server = CDRMNotifierServer::NewL() ) );
+       
+       if ( error ) 
+       {
+          User::After( TTimeIntervalMicroSeconds32(KWaitingTime) );
+       }
+       
+    } while( error && ( count <= KMaxStartTries ) );
+    
+    if( error ) 
+    {
+       
+#ifdef _DRM_TESTING
+       _LOGBUFNUM( _L8( "Failed: " ), error );
+        file.Close();
+        fs.Close();
+#endif
+        // Failed
+        return error;
+        }
+
+#ifdef _DRM_TESTING
+    file.Write( _L8( "OK!" ) );
+    file.Close();
+    fs.Close();
+#endif
+
+#ifdef __WINS__
+    
+    //UserSvr::ServerStarted();
+#endif        
+    // Release the semaphore...
+    aClientSem.Signal();
+    aClientSem.Close();
+    
+    // Start waiting for connections
+    CActiveScheduler::Start();
+    
+    // Dying.
+    // Delete CDRMRigntsServer
+    delete server;
+    
+    return KErrNone;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierServer::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMNotifierServer* CDRMNotifierServer::NewL()
+    {
+    CDRMNotifierServer* self = new( ELeave ) CDRMNotifierServer();
+    
+    CleanupStack::PushL( self );
+    
+    self->ConstructL();
+    
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CDRMNotifierServer::~CDRMNotifierServer() 
+    {
+    if( iStorage )
+        {
+        delete iStorage;
+        iStorage = 0;
+        }   
+    
+    LOG( _L8( "Dying..." ) );
+    
+#ifdef _DRM_TESTING
+    delete iLog;
+#endif
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierServer::RunErrorL
+// From CActive. Complete the request and restart the scheduler.
+// -----------------------------------------------------------------------------
+//
+TInt CDRMNotifierServer::RunError( TInt aError ) 
+    {
+    // Inform the client.
+    Message().Complete( aError );
+    
+    // Restart the scheduler.
+    ReStart();
+    
+    // Error handled.
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierServer::NewSessionL
+// Called when a client requires a new instance.
+// -----------------------------------------------------------------------------
+CSession2* CDRMNotifierServer::NewSessionL(
+    const TVersion& aVersion,
+    const RMessage2& /*aMessage*/) const
+    {
+    RThread client;
+    LOG( _L8( "NewSessionL" ) );
+    
+    // Check that the versions are compatible.
+    if ( ! User::QueryVersionSupported( TVersion( KServerMajorVersion,
+                                                  KServerMinorVersion,
+                                                  KServerBuildVersion ), 
+                                        aVersion ) ) 
+        {
+        // Sorry, no can do.
+        User::Leave( KErrNotSupported );
+        }
+    
+    LOG( _L8( "NewSessionL: Creating a new session" ) );
+    
+    return CDRMNotifierSession::NewL( iStorage );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierServer::CDRMNotifierServer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMNotifierServer::CDRMNotifierServer() : 
+    CServer2( EPriorityStandard )
+    {
+    // Nothing
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMNotifierServer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierServer::ConstructL() 
+    {
+    RFs fs;
+
+    // Ignore errors
+    User::RenameThread( KNotifierThread );
+    
+    User::LeaveIfError( fs.Connect() );
+    
+    fs.Close();
+
+#ifdef _DRM_TESTING
+    _LIT( KLogFile, "notifier.txt" );
+    TFileName logFile( KLogFile );
+    TTime time;
+    time.UniversalTime();
+    
+    time.FormatL( logFile, KDateTimeFormat );
+    logFile.Append( KLogFile );
+
+    iLog = CLogFile::NewL( logFile, ETrue );
+    iLog->SetAutoFlush( ETrue );
+    iLog->SetAutoNewline( ETrue );
+    
+    LOG( _L8( "DRM Server starting..." ) );
+#endif
+    iStorage = CDRMMessageStorage::NewL();
+    
+    LOG( _L8( "Notification Server started." ) );
+    
+    // Add the server to the scheduler.
+    StartL( DRMNotifier::KServerName );
+    }
+
+
+#ifdef _DRM_TESTING
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierServer::Log
+// Logging operation.
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierServer::Log( const TDesC8& aLog ) const
+    {
+    iLog->Log( aLog );
+    }
+
+
+void CDRMNotifierServer::Log( const TDesC& aLog ) const
+    {
+    iLog->Log( aLog );
+    }
+#endif
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// -----------------------------------------------------------------------------
+// Function StartupNotifier().
+// This function starts the actual DRM Notifier
+// the cleanup stack and active scheduler.
+// Returns: TInt: Symbian OS error code.
+// -----------------------------------------------------------------------------
+//
+
+TInt StartupNotifier( TAny* ) 
+    {
+    TInt error = KErrNone;
+    CTrapCleanup* trap = CTrapCleanup::New();
+    
+    // Check that memory allocation was successful.
+    __ASSERT_ALWAYS( trap, User::Invariant() );
+    
+    CActiveScheduler* scheduler = new CActiveScheduler();
+    
+    __ASSERT_ALWAYS( scheduler, User::Invariant() );
+    
+    CActiveScheduler::Install( scheduler );
+    
+    RSemaphore clientSem;
+    error = clientSem.OpenGlobal( KDRMEngCommonSemaphore );
+    if( error ) 
+        {
+    	  return error;
+        }
+    error = StartNotifierServer( clientSem );
+    
+    if ( error ) {
+        // If errors didn't occur, signal has been sent.
+        clientSem.Signal();
+        clientSem.Close();
+        }
+    
+    delete scheduler; 
+    scheduler = NULL;
+    
+    delete trap;
+    trap = NULL;
+    
+    // __ASSERT_ALWAYS( !error, User::Invariant() );
+    
+    return KErrNone;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/notifier/src/DRMNotifierSession.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,521 @@
+/*
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class handles all client requests.
+*
+*/
+
+
+// INCLUDE FILES
+#include <s32file.h>
+#include <f32file.h>
+#include "drmcommon.h"
+#include "DRMNotifierSession.h"
+#include "DRMNotifierServer.h"
+#include "drmnotifierclientserver.h"
+#include <e32test.h>
+
+// NAMESPACES
+using namespace DRMNotifier;
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+
+
+// MACROS
+#ifdef _DRM_TESTING
+#define LOG( a ) ( ( CDRMNotifierServer* )( Server() ) )->Log( a )
+#else
+#define LOG( a )
+#endif
+
+// LOCAL CONSTANTS AND MACROS
+
+const TInt KSanityDataLengthLow = 0;
+const TInt KSanityDataLengthHigh = 32768;
+
+// MODULE DATA STRUCTURES
+// DATA TYPES
+// LOCAL FUNCTIONS
+
+
+// -----------------------------------------------------------------------------
+// SanitizeL
+// Performs a sanity check on length parameters
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void SanitizeL( TInt aParam )
+    {
+    if( aParam <= KSanityDataLengthLow || aParam > KSanityDataLengthHigh )
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+
+// FORWARD DECLARATIONS
+// ============================ MEMBER FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMNotifierSession* CDRMNotifierSession::NewL( CDRMMessageStorage* aStorage) 
+    {
+    CDRMNotifierSession* self = new( ELeave ) CDRMNotifierSession( aStorage );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(); // self
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::~CDRMNotifierSession
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CDRMNotifierSession::~CDRMNotifierSession()
+    {
+    TInt error = KErrNone;
+    TInt i = 0;
+
+    if( iStorage )
+        {
+        TRAP(error, iStorage->CancelL( this ) );
+        }
+
+    if(error)
+        {
+        LOG( _L8( " Something went wrong with Cancelling the notifications " ) );
+        }
+
+    for( i = 0; i < iMessageQueue.Count(); i++ )
+        {
+        iStorage->UpdateMessage(iMessageQueue[i]);
+        }
+
+    iMessageQueue.Reset();
+
+    for( i = 0; i < iContentIDList.Count(); i++ )
+        {
+        if( iContentIDList[i]->iContentID )
+            {
+            delete iContentIDList[i]->iContentID;
+            iContentIDList[i]->iContentID = NULL;
+            }
+        delete iContentIDList[i];
+        iContentIDList[i] = NULL;
+        }
+    iContentIDList.Reset();
+
+    LOG( _L8( "Notifier session closed." ) );
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::SendNotificationL
+// This method sends a notification to the client or if it's not active adds it
+// to the queue and the next time a registration happens the client will get
+// notified.
+// -----------------------------------------------------------------------------
+//
+TBool CDRMNotifierSession::SendNotificationL( CDRMMessageStorage::TMessageData* aMessage )
+    {
+    if( !CanNotify( aMessage ) )
+        {
+        User::Leave(KErrNotFound);
+        }
+
+    if( !iIsListening || iMessageQueue.Count() )
+        {
+        iMessageQueue.Append( aMessage );
+        return ETrue;
+        }
+    NotifyL( aMessage, EFalse );
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::ServiceL
+// This method runs DispatchL() under TRAP harness, since every error case
+// can be handled ==> no need to let this function leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierSession::ServiceL( const RMessage2& aMessage )
+    {
+    LOG( _L8( "ServiceL called" ) );
+    // Trap possible errors...
+    
+    TRAPD( error, DispatchL( aMessage ) );
+    
+    if ( error )
+        {
+        LOG( _L8( "DispatcL threw an exception" ) );
+        // ...and complete the request in case of an error.
+        aMessage.Complete( error );
+        return;
+        }
+
+    // The message has already completed successfully.
+    LOG( _L8( "DispatchL completed successfully" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::CDRMNotifierSession
+// Default constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMNotifierSession::CDRMNotifierSession( CDRMMessageStorage* aStorage ) : 
+    // Base class' constructor is called first.
+    iStorage( aStorage )
+    {
+    // Nothing.
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::ConstructL
+// Second phase constructor. Initializes the log tool in DRM internal testing.
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierSession::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::DispatchL
+// Checks which command the user requested, and forwards the request to 
+// appropriate private method. This helps to keep the code more readable.
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierSession::DispatchL( const RMessage2& aMessage ) 
+    {
+		RDebug::Printf(">>> [%s] %d", _S8(__PRETTY_FUNCTION__), aMessage.Function());
+    switch ( aMessage.Function() )
+        {
+        case ENotifyClients:
+            NotifyClientsL( aMessage );
+            break;
+        case ERecieveNotification:
+            RecieveNotificationL( aMessage );
+            break;
+        case ECancelNotification:
+            CancelNotificationL( aMessage );
+            break;
+        case ERegister:
+            RegisterL( aMessage );
+            break;
+        case EUnRegister:
+            UnRegisterL( aMessage );
+            break;
+        case ERegisterURI:
+            RegisterURIL( aMessage );
+            break;
+        case EUnRegisterURI:
+            UnRegisterURIL( aMessage );
+            break;
+        default:
+            LOG( _L8( "DispatchL: Invalid command" ) );
+            User::Leave( KErrNotSupported );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::NotifyClientsL
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierSession::NotifyClientsL( const RMessage2& aMessage )
+    {
+    LOG( _L8( "NotifyClientsL" ) );
+    TDRMEventType eventType;
+
+    eventType = aMessage.Int1();
+
+    iStorage->NotifyL(eventType,aMessage);
+
+    aMessage.Complete( KErrNone );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::RecieveNotificationL
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierSession::RecieveNotificationL( const RMessage2& aMessage )
+    {
+    LOG( _L8( "RecieveNotificationL" ) );
+    TInt error = KErrNone;
+    TPckg<TInt> package(0);
+    TDRMEventType eventType;
+
+    package.Set(reinterpret_cast<TUint8*>(&eventType),sizeof(TDRMEventType),sizeof(TDRMEventType));
+    TRAP(error, aMessage.ReadL(1, package));
+
+    // Set the status of listening
+    iIsListening = ETrue;
+
+    // Set this to message as listener
+    iListener = aMessage;
+
+    if( !iIsInStorage )
+        {
+        iIsInStorage = ETrue;
+        iStorage->AddSession( this );
+        }
+
+    // Check if there are any notifications in queue if so process first one
+    if( iMessageQueue.Count() )
+        {
+        NotifyL( iMessageQueue[0], ETrue );
+        }
+ 
+    // Message complete will be set elsewhere.
+    // All done.
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::CancelNotificationL
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierSession::CancelNotificationL( const RMessage2& aMessage )
+    {
+    LOG( _L8( "CancelNotificationL" ) );
+    TInt error = KErrNone;
+    TInt i = 0;
+
+    TRAP(error, iStorage->CancelL( this ) );
+    if( error && error != KErrNotFound )
+        {
+        LOG(  _L8( "CDRMNotifierSession:: Something went wrong with Cancelling the notifications " ) );
+        }
+
+    for( i = 0; i < iMessageQueue.Count(); i++ )
+        {
+        iStorage->UpdateMessage(iMessageQueue[i]);
+        }
+    iMessageQueue.Reset();
+
+    for( i = 0; i < iContentIDList.Count(); i++ )
+        {
+        if( iContentIDList[i]->iContentID )
+            {
+            delete iContentIDList[i]->iContentID;
+            iContentIDList[i]->iContentID = NULL;
+            }
+        delete iContentIDList[i];
+        iContentIDList[i] = NULL;
+        }
+    iContentIDList.Reset();
+
+    iIsInStorage = EFalse;
+
+	iIsListening = EFalse;
+	
+	if ( !iListener.IsNull() )
+		{
+		iListener.Complete( KErrCancel );
+		}
+	
+    aMessage.Complete( KErrNone );
+    }
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::RegisterURIL
+// Get the information from the client, construct a rights object, and add 
+// it to the database.
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierSession::RegisterL( const RMessage2& aMessage )
+    {
+    LOG( _L8( "RegisterL" ) );
+    TPckg<TInt> package(0);
+    TDRMEventType eventType = 0;
+    TContentData* content = 0;
+
+    package.Set(reinterpret_cast<TUint8*>(&eventType),sizeof(TDRMEventType),sizeof(TDRMEventType));
+    aMessage.ReadL(0, package);
+
+    content = new (ELeave) TContentData;
+
+    content->iContentID = NULL;
+    content->iEventType = eventType;
+
+    iContentIDList.Append( content );
+
+    aMessage.Complete( KErrNone );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::UnRegisterURIL
+// Get the information from the client, construct a rights object, and add 
+// it to the database.
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierSession::UnRegisterL( const RMessage2& aMessage )
+    {
+    LOG( _L8( "UnRegisterL" ) );
+    TPckg<TInt> package(0);
+    TDRMEventType eventType = 0;
+
+    package.Set(reinterpret_cast<TUint8*>(&eventType),sizeof(TDRMEventType),sizeof(TDRMEventType));
+    aMessage.ReadL(0, package);
+
+    for( TInt i = 0; i < iContentIDList.Count(); i++ )
+        {
+        if( !iContentIDList[i]->iContentID &&
+            iContentIDList[i]->iEventType == eventType )
+            {
+            delete iContentIDList[i];
+            iContentIDList[i] = NULL;
+
+            iContentIDList.Remove(i);
+            break;
+            }
+        }
+
+    aMessage.Complete( KErrNone );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::RegisterURIL
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierSession::RegisterURIL( const RMessage2& aMessage )
+    {
+    LOG( _L8( "RegisterURIL" ) );
+    TPckg<TInt> package(0);
+    TDRMEventType eventType = 0;
+    TContentData* content = 0;
+    TInt length = 0;
+
+    HBufC8* contentID = 0;
+    TPtr8 packageData(NULL,0);
+
+    length = aMessage.GetDesLength(0);
+
+    SanitizeL( length );
+
+    contentID = HBufC8::NewLC(length);
+    packageData.Set(contentID->Des());
+
+    aMessage.ReadL(0, packageData);
+
+    package.Set(reinterpret_cast<TUint8*>(&eventType),sizeof(TDRMEventType),sizeof(TDRMEventType));
+    aMessage.ReadL(1, package);
+
+    content = new (ELeave) TContentData;
+
+    content->iContentID = contentID;
+    content->iEventType = eventType;
+
+    iContentIDList.Append( content );
+
+    CleanupStack::Pop();
+    aMessage.Complete( KErrNone );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::UnRegisterURIL
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierSession::UnRegisterURIL( const RMessage2& aMessage )
+    {
+    LOG( _L8( "UnRegisterURIL" ) );
+    TPckg<TInt> package(0);
+    TDRMEventType eventType = 0;
+    TInt length = 0;
+
+    HBufC8* contentID = 0;
+    TPtr8 packageData(NULL,0);
+
+    length = aMessage.GetDesLength(0);
+
+    SanitizeL( length );
+
+    contentID = HBufC8::NewLC(length);
+    packageData.Set(contentID->Des());
+
+    aMessage.ReadL(0, packageData);
+
+    package.Set(reinterpret_cast<TUint8*>(&eventType),sizeof(TDRMEventType),sizeof(TDRMEventType));
+    aMessage.ReadL(1, package);
+
+    for( TInt i = 0; i < iContentIDList.Count(); i++ )
+        {
+        if( iContentIDList[i]->iContentID &&
+            iContentIDList[i]->iEventType == eventType &&
+            !iContentIDList[i]->iContentID->Compare( contentID->Des() ) )
+            {
+            if( iContentIDList[i]->iContentID )
+                {
+                delete iContentIDList[i]->iContentID;
+                iContentIDList[i]->iContentID = NULL;
+                }
+            delete iContentIDList[i];
+            iContentIDList[i] = NULL;
+
+            iContentIDList.Remove(i);
+            break;
+            }
+        }
+    CleanupStack::PopAndDestroy();
+    aMessage.Complete( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::NotifyL
+// -----------------------------------------------------------------------------
+//
+void CDRMNotifierSession::NotifyL( CDRMMessageStorage::TMessageData *aMessage, TBool aFromQueue )
+    {
+    LOG( _L8( "NotifyL" ) );
+    TPtr8 data( reinterpret_cast<TUint8*>(&aMessage->iEventType),
+                sizeof(TDRMEventType),
+                sizeof(TDRMEventType));
+    TPtr8 event( aMessage->iMessageData, DRMNotifier::KDRMSizeOfMessage, 
+                 DRMNotifier::KDRMSizeOfMessage );
+
+    iListener.WriteL(0, event);
+    iListener.WriteL(1, data);
+
+    iListener.Complete( KErrNone );
+
+    // Remove the message from the queue
+    if( aFromQueue )
+        {
+        // Reduce the counter and release the message if needed
+        iStorage->UpdateMessage( aMessage );
+
+        iMessageQueue.Remove(0);
+        }
+    iIsListening = EFalse;
+    }
+// -----------------------------------------------------------------------------
+// CDRMNotifierSession::CanNotifyL
+// -----------------------------------------------------------------------------
+//
+TBool CDRMNotifierSession::CanNotify( CDRMMessageStorage::TMessageData *aMessage )
+    {
+    for( TInt i = 0; i < iContentIDList.Count(); i++ )
+        {
+        if( iContentIDList[i]->iEventType == aMessage->iEventType &&
+            (!iContentIDList[i]->iContentID ||
+            !iContentIDList[i]->iContentID->Compare( aMessage->iData->Des() ) ) )
+            {
+            return ETrue;
+            }
+        }
+    return EFalse;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/inc/DRMProtectedRoParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,317 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef DRMPROTECTEDROPARSER_H
+#define DRMPROTECTEDROPARSER_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <Xml/Parser.h>
+#include <Xml/ContentHandler.h>
+#include <Xml/XmlParserErrors.h>
+#include <Xml/Attribute.h>
+#include "DrmRightsClient.h"
+
+using namespace Xml;
+
+// FORWARD DECLARATIONS
+class CDRMRights;
+
+// CLASS DECLARATION
+
+/**
+*  Parser for protected rights objects
+*
+*  @lib DrmParsers.dll
+*  @since Series 60 3.0
+*/
+NONSHARABLE_CLASS(CDrmProtectedRoParser): public CBase, public MContentHandler
+    {
+    public:
+
+        class CParsedProtectedRo;
+
+        enum TParserType
+            {
+            EXmlParser,
+            EWbxmlParser
+            };
+            
+        static const TInt KMaxElementCount = 40;
+        static const TInt KMaxElementNesting = 16;
+        
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CDrmProtectedRoParser* NewL();
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C ~CDrmProtectedRoParser();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        void ParseL(
+            const TDesC8& aProtectedRo,
+            CParsedProtectedRo*& aResultRights);
+
+        IMPORT_C void ParseAndStoreL(
+            const TDesC8& aProtectedRo,
+            RPointerArray<CDRMRights>& aResultRights);
+            
+        IMPORT_C HBufC8* GetRiUrlL(
+            const TDesC8& aProtectedRo);
+
+        IMPORT_C HBufC8* GetDomainIdL(
+            const TDesC8& aProtectedRo);
+
+        IMPORT_C HBufC8* GetRiIdL(
+            const TDesC8& aProtectedRo);
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aDocParam Specifies the various parameters of the document.
+        * @arg   aDocParam.iCharacterSetName The character encoding of the document.
+        * @param aErrorCode is the error code. 
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartDocumentL(
+            const RDocumentParameters& aDocParam,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aErrorCode is the error code. 
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndDocumentL(
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aElement is a handle to the element's details.
+        * @param aAttributes contains the attributes for the element.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartElementL(
+            const RTagInfo& aElement,
+            const RAttributeArray& aAttributes, 
+			TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aElement is a handle to the element's details.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndElementL(
+            const RTagInfo& aElement,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aBytes is the raw content data for the element. 
+        *        The client is responsible for converting the data to the 
+        *        required character set if necessary.
+        *        In some instances the content may be binary and must not be converted.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnContentL(
+            const TDesC8& aBytes,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aPrefix is the Namespace prefix being declared.
+        * @param aUri is the Namespace URI the prefix is mapped to.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartPrefixMappingL(
+            const RString& aPrefix,
+            const RString& aUri, 
+			TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aPrefix is the Namespace prefix that was mapped.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndPrefixMappingL(
+            const RString& aPrefix,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aBytes are the ignored bytes from the document being parsed.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnIgnorableWhiteSpaceL(
+            const TDesC8& aBytes,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aName is the name of the skipped entity.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnSkippedEntityL(
+            const RString& aName,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aTarget is the processing instruction target.
+        * @param aData is the processing instruction data. If empty none was supplied.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnProcessingInstructionL(
+            const TDesC8& aTarget,
+            const TDesC8& aData, 
+			TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        */
+        void OnOutOfData();
+
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aError is the error code
+        */
+        void OnError(
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @return				0 if no interface matching the uid is found.
+                Otherwise, the this pointer cast to that interface.
+        * @param aUid the uid identifying the required interface.
+        */
+        TAny* GetExtendedInterface(
+            const TInt32 aUid);
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        TInt MatchStackState(void);
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        HBufC8* GetAttributeValueL(
+            const RAttributeArray& aAttrList,
+            const TDesC8& aAttrName);
+
+        /**
+        * Find the next start and end position of an XML element
+        * in the given data
+        * @since Series 60 3.0
+        * @param aElement Element to look for
+        * @param aData Input data
+        * @param aStart return parameter for the beginning of the element
+        * @param aEnd return parameter for the end of the element
+        * @return EFalse if no element could be found, ETrue otherwise
+        */
+        TBool GetElementStartEnd(
+            const TDesC8& aElement,
+            const TDesC8& aData,
+            TInt& aStart,
+            TInt& aEnd);
+            
+        /**
+        * Handle a parsed domain RO which could not be added to the rights DB
+        * because the device is not part of the domain.
+        * @since Series 60 3.0
+        * @param aDomainRoData domain RO as XML data
+        * @param aDomainRo parsed domain RO
+        */
+        void HandleUnregisteredDomainRoL(
+            const TDesC8& aContentId,
+            const TDesC8& aDomainRoData,
+            CParsedProtectedRo* aDomainRo);
+            
+        /**
+        * Adds ROAP namespace URI to aProtectedRo if not already present
+        * @since Series 60 3.0
+        * @param aProtectedRo protected RO element
+        * @return protected RO element, if namespace was not added NULL
+        */    
+        HBufC8* CDrmProtectedRoParser::AddRoapNamespaceL(
+            TDesC8& aProtectedRo ) const;
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDrmProtectedRoParser(void);
+
+        void ConstructL(void);
+
+    private:  // Data
+        // The XML parser
+        CParser* iParser;
+        
+        // Result of parsing the protected RO element
+        CParsedProtectedRo* iRights;
+        
+        // Expected element names
+        RString iElements[KMaxElementCount];
+        
+        // Parsing stack
+        TInt iElementStack[KMaxElementNesting];
+        
+        // Depth of the parsing stack
+        TInt iElementStackDepth;
+        
+        // Content between elements
+        HBufC8* iContent;
+
+    };
+
+#endif      // DRMPROTECTEDROPARSER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/inc/DrmRel1_0StringDict00.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,184 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// Plugin interface
+
+
+#ifndef __SISTRINGDICT00_H__
+#define __SISTRINGDICT00_H__
+
+#include <e32std.h>
+#include <stringpool.h>
+#include <Xml/Plugins/StringDictionary.h>
+
+
+class CDrmRel1_0StringDict00 : public CBase, public Xml::MStringDictionary
+/**
+The DrmRel1_0StringDict00 class is a derived class defining the API of a single string dictionary. 
+
+Derived classes must add all elements, attributes names, and attribute values that belong
+to this string dictionary as static string tables to the StringPool. WBXML token mappings between 
+strings and WBXML tokens should also be maintained.
+
+@internalTechnology
+@interim This is the first drop of this component.
+*/
+	{
+public:
+	static Xml::MStringDictionary* NewL(TAny* aStringPool);
+	virtual ~CDrmRel1_0StringDict00();
+	void ConstructL();
+
+	void ElementL(TInt aToken, RString& aElement) const;
+	void AttributeL(TInt aToken, RString& aAttribute) const;
+	void AttributeValuePairL(TInt aToken, RString& aAttribute, RString& aValue) const;
+	void AttributeValueL(TInt aToken, RString& aValue) const;
+
+	TBool CompareThisDictionary(const RString& aDictionaryDescription) const;
+
+	TInt SwitchCodePage(TInt aCodePage);
+	void PublicIdentifier(RString& aPubId);
+	void NamespaceUri(RString& aUri);
+
+	void Release();
+
+public:
+
+	// CodePage tokens.
+	//
+	// Note: There will be correlation between these token values and their
+	// strings via the CDictionaryCodePage using the RStringPool.
+
+	enum TTagToken
+        {
+		// CodePage 00
+		// -//OMA//DTD DRMREL 1.0//EN
+        ERights = 0x05,
+        EContext = 0x06,
+        EVersion = 0x07,
+        EUid = 0x08,
+        EAgreement = 0x09,
+        EAsset = 0x0a,
+        EKeyInfo = 0x0b,
+        EKeyValue = 0x0c,
+        EPermission = 0x0d,
+        EPlay = 0x0e,
+        EDisplay = 0x0f,
+        EExecute = 0x10,
+        EPrint = 0x11,
+        EConstraint = 0x12,
+        ECount = 0x13,
+        EDateTime = 0x14,
+        EStart = 0x15,
+        EEnd = 0x16,
+        EInterval = 0x17
+    	};
+
+
+	enum TAttributeToken
+        {
+		// CodePage 00
+		// -//OMA//DTD DRMREL 1.0//EN
+        EXmlnsOEx = 0x05,
+        EXmlnsODd = 0x06,
+        EXmlnsDs = 0x07
+    	};
+
+
+
+	enum TAttributeValueToken
+        {
+		// CodePage 00
+		// -//OMA//DTD DRMREL 1.0//EN
+        EValueXmlnsOEx = 0x05,
+        EValueXmlnsODd = 0x06,
+        EValueXmlnsDs = 0x07,
+        EOdrlEx = 0x85,
+        EOdrlDd = 0x86,
+        EXmlDsig = 0x87
+	    };
+
+
+
+private:
+
+	CDrmRel1_0StringDict00(RStringPool* aStringPool);
+
+private:
+
+/**
+The StringPool for this string dictionary.
+We don't own this.
+*/
+	RStringPool				iStringPool;
+
+	Xml::CDictionaryCodePage*	iCodepage00Table;
+
+	TInt					iCodePage;
+
+	};
+
+
+const TInt iTagCodePage00[] = 
+	{
+    CDrmRel1_0StringDict00::ERights,
+    CDrmRel1_0StringDict00::EContext,
+    CDrmRel1_0StringDict00::EVersion,
+    CDrmRel1_0StringDict00::EUid,
+    CDrmRel1_0StringDict00::EAgreement,
+    CDrmRel1_0StringDict00::EAsset,
+    CDrmRel1_0StringDict00::EKeyInfo,
+    CDrmRel1_0StringDict00::EKeyValue,
+    CDrmRel1_0StringDict00::EPermission,
+    CDrmRel1_0StringDict00::EPlay,
+    CDrmRel1_0StringDict00::EDisplay,
+    CDrmRel1_0StringDict00::EExecute,
+    CDrmRel1_0StringDict00::EPrint,
+    CDrmRel1_0StringDict00::EConstraint,
+    CDrmRel1_0StringDict00::ECount,
+    CDrmRel1_0StringDict00::EDateTime,
+    CDrmRel1_0StringDict00::EStart,
+    CDrmRel1_0StringDict00::EEnd,
+    CDrmRel1_0StringDict00::EInterval,
+	0 // ok to end with zero as this is used by a global token
+    }; 
+
+
+const TInt iAttributeCodePage00[] = 
+	{
+    CDrmRel1_0StringDict00::EXmlnsOEx,
+    CDrmRel1_0StringDict00::EXmlnsODd,
+    CDrmRel1_0StringDict00::EXmlnsDs,
+	0  // ok to end with zero as this is used by a global token
+    };
+
+
+
+const TInt iAttributeValueCodePage00[] = 
+	{
+    CDrmRel1_0StringDict00::EXmlnsOEx,
+    CDrmRel1_0StringDict00::EXmlnsODd,
+    CDrmRel1_0StringDict00::EXmlnsDs,
+    CDrmRel1_0StringDict00::EOdrlEx,
+    CDrmRel1_0StringDict00::EOdrlDd,
+    CDrmRel1_0StringDict00::EXmlDsig,
+	0 // ok to end with zero as this is used by a global token
+    }; 
+
+
+#endif //__SISTRINGDICT00_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/inc/DrmRel1_0StringDict00AttributeTable.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// Autogenerated from \epoc32\build\generated\Xml\DrmRel1_0StringDict00AttributeTable.st by the stringtable tool - Do not edit
+
+#ifndef STRINGTABLE_DrmRel1_0StringDict00AttributeTable
+#define STRINGTABLE_DrmRel1_0StringDict00AttributeTable
+
+#include "StringPool.h"
+
+struct TStringTable;
+
+/** A String table */
+class DrmRel1_0StringDict00AttributeTable 
+	{
+public:
+	enum TStrings
+		{
+		// Element names
+		// CodePage 00
+		/** xmlns:o-ex */
+		EXmlnsOEx,
+		/** xmlns:o-dd */
+		EXmlnsODd,
+		/** xmlns:ds */
+		EXmlnsDs
+		};
+	static const TStringTable Table;	
+	};
+
+#endif // STRINGTABLE_DrmRel1_0StringDict00AttributeTable
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/inc/DrmRel1_0StringDict00AttributeValueTable.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// Autogenerated from \epoc32\build\generated\Xml\DrmRel1_0StringDict00AttributeValueTable.st by the stringtable tool - Do not edit
+
+#ifndef STRINGTABLE_DrmRel1_0StringDict00AttributeValueTable
+#define STRINGTABLE_DrmRel1_0StringDict00AttributeValueTable
+
+#include "StringPool.h"
+
+struct TStringTable;
+
+/** A String table */
+class DrmRel1_0StringDict00AttributeValueTable 
+	{
+public:
+	enum TStrings
+		{
+		/**  */
+		EXmlnsOEx,
+		/**  */
+		EXmlnsODd,
+		/**  */
+		EXmlnsDs,
+		/** http://odrl.net/1.1/ODRL-EX */
+		EOdrlEx,
+		/** http://odrl.net/1.1/ODRL-DD */
+		EOdrlDd,
+		/** http://www.w3.org/2000/09/xmldsig/ */
+		EXmlDsig
+		};
+	static const TStringTable Table;	
+	};
+
+#endif // STRINGTABLE_DrmRel1_0StringDict00AttributeValueTable
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/inc/DrmRel1_0StringDict00TagTable.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// Autogenerated from \epoc32\build\generated\Xml\DrmRel1_0StringDict00TagTable.st by the stringtable tool - Do not edit
+
+#ifndef STRINGTABLE_DrmRel1_0StringDict00TagTable
+#define STRINGTABLE_DrmRel1_0StringDict00TagTable
+
+#include "StringPool.h"
+
+struct TStringTable;
+
+/** A String table */
+class DrmRel1_0StringDict00TagTable 
+	{
+public:
+	enum TStrings
+		{
+		// Element names
+		// CodePage 00
+		/** rights */
+		ERights,
+		/** context */
+		EContext,
+		/** version */
+		EVersion,
+		/** uid */
+		EUid,
+		/** agreement */
+		EAgreement,
+		/** asset */
+		EAsset,
+		/** KeyInfo */
+		EKeyInfo,
+		/** KeyValue */
+		EKeyValue,
+		/** permission */
+		EPermission,
+		/** play */
+		EPlay,
+		/** display */
+		EDisplay,
+		/** execute */
+		EExecute,
+		/** print */
+		EPrint,
+		/** constraint */
+		EConstraint,
+		/** count */
+		ECount,
+		/** datetime */
+		EDateTime,
+		/** start */
+		EStart,
+		/** end */
+		EEnd,
+		/** interval */
+		EInterval,
+		/** -//OMA//DTD DRMREL 1.0//EN */
+		EUri,
+		/** 14~0 */
+		EPublicId,
+		/** -//OMA//DTD DRMREL 1.0//EN~0 */
+		EFormalPublicId
+		};
+	static const TStringTable Table;	
+	};
+
+#endif // STRINGTABLE_DrmRel1_0StringDict00TagTable
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/inc/DrmRightsParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,332 @@
+/*
+* 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:  Declaration of the OMA DRM rigths parser
+*
+*/
+
+
+#ifndef DRMRIGHTSPARSER_H
+#define DRMRIGHTSPARSER_H
+
+//  INCLUDES
+#include <Xml/Parser.h>
+#include <Xml/ContentHandler.h>
+#include <Xml/XmlParserErrors.h>
+
+using namespace Xml;
+
+// FORWARD DECLARATIONS
+class CDRMRights;
+
+// CLASS DECLARATION
+
+/**
+*  Parser for OMA DRM rights objects (verion 1.0 and 2.0)
+*
+*  @lib DrmParsers.dll
+*  @since Series 60 3.0
+*/
+NONSHARABLE_CLASS(CDrmRightsParser): public CBase, public MContentHandler
+    {
+    public:
+
+        class CParsedRightsObject;
+        class CParsedAsset;
+        class CParsedPermission;
+
+        enum TParserType
+            {
+            EXmlParser,
+            EWbxmlParser
+            };
+            
+        enum TSoftwareSchemaType
+            {
+            ESymbianSid,
+            ESymbianVid
+            };
+
+        static const TInt KMaxElementCount = 40;
+        static const TInt KMaxElementNesting = 16;
+
+    public:  // Constructors and destructor
+        
+        /**
+        * Create a parser object
+        * @since Series 60 3.0
+        * @param Type of the parser (XML or WBXML)
+        * @return Allocated parser
+        */
+        IMPORT_C static CDrmRightsParser* NewL(
+            TParserType aType = EXmlParser);
+        
+        /**
+        * Destructor.
+        */
+        IMPORT_C ~CDrmRightsParser();
+
+    public: // New functions
+        
+        /**
+        * Parse one rights object
+        * @since Series 60 3.0
+        * @param aRightsObject XML or WBXML representation of the rights
+        * @param aResultRigths Parsed rights
+        */
+        IMPORT_C void ParseL(
+            const TDesC8& aRightsObject,
+            RPointerArray<CDRMRights>& aResultRights);
+
+        /**
+        * Parse one rights object and store it in the rights database
+        * @since Series 60 3.0
+        * @param aRightsObject XML or WBXML representation of the rights
+        * @param aResultRigths Parsed rights
+        */
+        IMPORT_C void ParseAndStoreL(
+            const TDesC8& aRightsObject,
+            RPointerArray<CDRMRights>& aResultRights);
+
+    protected: // Functions from base classes
+
+        /**
+        * From MContentHandler
+        * @param aDocParam Specifies the various parameters of the document.
+        * @arg   aDocParam.iCharacterSetName The character encoding of the document.
+        * @param aErrorCode is the error code. 
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartDocumentL(
+            const RDocumentParameters& aDocParam,
+            TInt aErrorCode);
+
+        /**
+        * From MContentHandler
+        * @param aErrorCode is the error code. 
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndDocumentL(
+            TInt aErrorCode);
+
+        /**
+        * From MContentHandler
+        * @param aElement is a handle to the element's details.
+        * @param aAttributes contains the attributes for the element.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartElementL(
+            const RTagInfo& aElement,
+            const RAttributeArray& aAttributes, 
+			TInt aErrorCode);
+
+        /**
+        * From MContentHandler
+        * @param aElement is a handle to the element's details.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndElementL(
+            const RTagInfo& aElement,
+            TInt aErrorCode);
+
+        /**
+        * From MContentHandler
+        * @param aBytes is the raw content data for the element. 
+        *        The client is responsible for converting the data to the 
+        *        required character set if necessary.
+        *        In some instances the content may be binary and must not be converted.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnContentL(
+            const TDesC8& aBytes,
+            TInt aErrorCode);
+
+        /**
+        * From MContentHandler
+        * @param aPrefix is the Namespace prefix being declared.
+        * @param aUri is the Namespace URI the prefix is mapped to.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartPrefixMappingL(
+            const RString& aPrefix,
+            const RString& aUri, 
+			TInt aErrorCode);
+
+        /**
+        * From MContentHandler
+        * @param aPrefix is the Namespace prefix that was mapped.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndPrefixMappingL(
+            const RString& aPrefix,
+            TInt aErrorCode);
+
+        /**
+        * From MContentHandler
+        * @param aBytes are the ignored bytes from the document being parsed.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnIgnorableWhiteSpaceL(
+            const TDesC8& aBytes,
+            TInt aErrorCode);
+
+        /**
+        * From MContentHandler
+        * @param aName is the name of the skipped entity.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnSkippedEntityL(
+            const RString& aName,
+            TInt aErrorCode);
+
+        /**
+        * From MContentHandler
+        * @param aTarget is the processing instruction target.
+        * @param aData is the processing instruction data. If empty none was supplied.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnProcessingInstructionL(
+            const TDesC8& aTarget,
+            const TDesC8& aData, 
+			TInt aErrorCode);
+
+        /**
+        * From MContentHandler
+        */
+        void OnOutOfData();
+
+
+        /**
+        * From MContentHandler
+        * @param aError is the error code
+        */
+        void OnError(
+            TInt aErrorCode);
+
+
+        /**
+        * From MContentHandler
+        * @return 0 if no interface matching the uid is found.
+        *         Otherwise, the this pointer cast to that interface.
+        * @param aUid the uid identifying the required interface.
+        */
+        TAny* GetExtendedInterface(
+            const TInt32 aUid);
+
+    protected:  // New functions
+        
+        /**
+        * Match the state of the current stack to the predefined states
+        * @since Series 60 3.0
+        * @return KErrNotFound if no state is matched, otherwise the number
+        *         of the state
+        */
+        TInt MatchStackState(void);
+
+        /**
+        * Transform the result of the parsing into an API level rights object
+        * @since Series 60 3.0
+        * @param aResult Out parameter for the resul
+        */
+        void TransformRightsObjectL(
+            RPointerArray<CDRMRights>& aResult);
+            
+        /**
+        * Return the value of an attribute as a buffer
+        * @since Series 60 3.0
+        * @param aAttrList Atrribute list
+        * @param aAttrName Name of the attribute
+        * @return value of the attribute or NULL
+        */
+        HBufC8* GetAttributeValueL(
+            const RAttributeArray& aAttrList,
+            const TDesC8& aAttrName);
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDrmRightsParser();
+
+        void ConstructL(
+            TParserType aType);
+
+
+        /**
+        * Parse the time string and return the TTime
+        */
+        TTime ParseRelTimeL(TDesC8& aRelTimeString);
+        
+        /**
+        * Parse the interval string and return the interval
+        */        
+        TTimeIntervalSeconds ParseRelInterval(TDesC8& aRelTimeString);
+
+
+        /**
+        * Validate time string variables
+        */
+        TBool ValidTimeValues( TInt aYear, TMonth aMonth, TInt aDay, TInt aHour,
+                               TInt aMinute, TInt aSecond, TInt aMicrosecond );
+
+        /**
+        * Validate day
+        */
+        TBool ValidateDay( TInt aYear, TMonth aMonth, TInt aDay );
+
+
+
+    protected:  // Data
+        // XML Parser
+        CParser* iParser;
+        
+        // Parsed rigths object
+        CParsedRightsObject* iRights;
+        
+        // Predefined XML element names
+        RString iElements[KMaxElementCount];
+        
+        // Current parsing stack
+        TInt iElementStack[KMaxElementNesting];
+        
+        // Depth of the current parsing stack
+        TInt iElementStackDepth;
+        
+        // Content between elements
+        HBufC8* iContent;
+        
+        // Determines if the input is XML or WBXML
+        TParserType iParserType;
+        
+        // Determines what kind of software constraint the RO contains
+        TSoftwareSchemaType iSoftwareSchemeType;
+
+        // In increments of +- 15 minutes
+        TInt iTimeZone;
+
+        // Tagname of unkown tag
+        HBufC8* iUnknownTag;
+    };
+
+#endif      // DRMRIGHTSPARSER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/101F6DB6.RSS	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* 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:  Registry file for XML Framework Plugin OMA DRM String Dictionary CodePage 00
+*
+*/
+
+
+
+#include "Ecom/RegistryInfo.rh"
+
+RESOURCE REGISTRY_INFO DrmRel1_0StringDict00Info
+	{
+	dll_uid = 0x101F6DB6;
+	interfaces = 
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x101FA94F;
+			implementations = 
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x101F6DB7;
+					version_no = 1;
+					display_name = "XML Framework Plugin OMA DRM String Dictionary for CodePage 00||Copyright © 2004 Nokia. All Rights Reserved.";
+					default_data = "E~0||-//OMA//DTD DRMREL 1.0//EN~0";
+					opaque_data = "";
+					}
+				};
+			}
+		};
+	}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DRMConstraint.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1174 @@
+/*
+* 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:  Datatype implementation for Rights Constraint
+*
+*/
+
+
+// INCLUDE FILES
+#include <s32strm.h>
+#include <s32mem.h>
+#include "DRMConstraint.h"
+
+// CONSTANTS
+
+// Synchronizing marker in the beginning of the stream in order to synchronize
+// to an externalized Constraint object having the new structure.  
+const TInt32 KSyncMark = 0xAFCE;
+
+// Old and new version number of the Constraint object
+const TInt8 KVersion3_2_0 = 0;
+const TInt8 KVersion3_2_1 = 1; 
+   
+const TInt KSanityDataLengthLow = 0;
+const TInt KSanityDataLengthHigh = 32768;
+
+
+// ============================ LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// SanitizeL
+// Performs a sanity check on length parameters
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void SanitizeL( TInt aParam )
+    {
+    if( aParam < KSanityDataLengthLow || aParam > KSanityDataLengthHigh )
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// AppendToArrayL
+// Appends the strings of array aFrom to array aTo
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void AppendToArrayL( RPointerArray<HBufC8>& aTo, 
+                             const RPointerArray<HBufC8>& aFrom )
+    {
+    HBufC8* addData = NULL;
+    
+    for( TInt i = 0; i < aFrom.Count(); i++ )
+        {
+        addData = aFrom[i]->AllocLC();
+        aTo.AppendL( addData );
+        CleanupStack::Pop( addData ); 
+        }    
+    }
+
+// -----------------------------------------------------------------------------
+// CountArrayStoreSize
+// Returns the size in bytes how much the array needs for storing
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt CountArrayStoreSize( const RPointerArray<HBufC8>& aArray )
+    {
+    TInt size = 0;
+    
+    for(TInt i = 0; i < aArray.Count(); i++ )
+        {
+        size += sizeof(TInt);
+        size += aArray[i]->Size();
+        }
+    return size;    
+    }
+// -----------------------------------------------------------------------------
+// WriteArrayToStreamL
+// Write the array to the stream
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void WriteArrayToStreamL( RWriteStream& aStream,
+                                  const RPointerArray<HBufC8>& aArray )
+    {
+    for(TInt i = 0; i < aArray.Count(); i++ )
+        {
+        aStream.WriteInt32L( aArray[i]->Size() );
+        aStream.WriteL( aArray[i]->Des() );
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// ReadArrayFromStringL
+// Reads the array from the string
+// -----------------------------------------------------------------------------
+//    
+LOCAL_C void ReadArrayFromStringL( const TDesC8& aString,
+                                   RPointerArray<HBufC8>& aArray )
+    {
+    RMemReadStream inRead( static_cast<const TAny*>( aString.Ptr() ), aString.Size() );
+    TInt size = 0;
+    HBufC8* addData = NULL;
+    TPtr8 dataBuffer(NULL,0,0);
+    CleanupClosePushL( inRead );
+    
+    
+    aArray.ResetAndDestroy();
+    
+    
+    for( TInt i = 0; i < aString.Size();)
+        {
+        // If there is not enough data to read the integer 
+        // it means that it's an old version and the whole thing is the
+        // string since in previous versions only one string is stored        
+        if(( aString.Size() - i) < sizeof(TInt) )
+            {
+            aArray.ResetAndDestroy();
+            addData = aString.AllocLC();
+            aArray.AppendL( addData );
+            CleanupStack::Pop();
+            CleanupStack::PopAndDestroy(); // inRead              
+            return;            
+            }
+        
+        size = inRead.ReadInt32L();
+        i += sizeof(TInt);
+        
+        // If the size is negative or the size left is not large enough
+        // it means that it's an old version and the whole thing is the
+        // string since in previous versions only one string is stored.
+        if( size < 0 || size > ( aString.Size() - i ) )
+            {
+            aArray.ResetAndDestroy();
+            addData = aString.AllocLC();
+            aArray.AppendL( addData );
+            CleanupStack::Pop();
+            CleanupStack::PopAndDestroy(); // inRead            
+            return;
+            }
+        addData = HBufC8::NewMaxLC( size );    
+
+        // Set the read buffer:
+        dataBuffer.Set(const_cast<TUint8*>(addData->Ptr()), 0, size);
+        
+        // Read the data:
+        inRead.ReadL( dataBuffer );
+        
+        aArray.AppendL( addData );
+        CleanupStack::Pop( addData );
+
+        i += size;
+        }
+    CleanupStack::PopAndDestroy();    
+    return;
+    }
+    
+// -----------------------------------------------------------------------------
+// IsIndividualConstraintValid
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TBool IsIndividualConstraintValid( const RPointerArray<HBufC8>& aConstraint, 
+                                           const RPointerArray<HBufC8>& aValidConstraints)
+    {
+    TInt retVal = 0;
+    
+    for( TInt i = 0; i < aConstraint.Count(); i++ )
+        {
+        for( TInt j = 0; j < aValidConstraints.Count(); j++ )
+            {
+            retVal = aConstraint[i]->Des().Compare( aValidConstraints[j]->Des() );
+            if( !retVal )
+                {
+                return ETrue;
+                }
+            }
+        }
+    return EFalse;    
+    };
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CDRMConstraint::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMConstraint* CDRMConstraint::NewLC()
+    {
+    CDRMConstraint* self = new( ELeave ) CDRMConstraint();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    return self;    
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMConstraint::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMConstraint* CDRMConstraint::NewL()
+    {
+    CDRMConstraint* self = NewLC();
+    CleanupStack::Pop();
+    
+    return self;
+    }; 
+
+// -----------------------------------------------------------------------------
+// Default Constructor - First phase.
+// Can be used by itself to generate an empty object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMConstraint::CDRMConstraint() :
+    iSyncMark( KSyncMark ),
+    iVersion( KVersion3_2_1 ), // Version number for differentiation 
+                               // in InternalizeL. 
+    iStartTime( Time::NullTTime() ),
+    iEndTime( Time::NullTTime() ),
+    iIntervalStart( Time::NullTTime() ),
+    iInterval( 0 ),
+    iCounter( 0 ),
+    iOriginalCounter( 0 ),
+    iTimedCounter( 0 ),
+	iTimedInterval( 0 ),
+	iAccumulatedTime( 0 ),
+	iVendorId( TUid::Null() ),
+	iSecureId( TUid::Null() ),
+    iActiveConstraints( 0 ),
+    iDrmMeteringInfo( NULL ),
+    iOriginalTimedCounter( 0 ) 
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+// 
+EXPORT_C CDRMConstraint::~CDRMConstraint()
+    {
+
+    iIndividual.ResetAndDestroy();
+    iIndividual.Close();
+    
+    iSystem.ResetAndDestroy();
+    iSystem.Close(); 
+            
+#ifdef RD_DRM_METERING       
+    if( iDrmMeteringInfo )
+        {
+        delete iDrmMeteringInfo;
+        iDrmMeteringInfo = NULL;
+        }
+#endif
+        
+    }; 
+
+// -----------------------------------------------------------------------------
+// CDRMConstraint::ExternalizeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMConstraint::ExternalizeL( RWriteStream& aStream ) const
+    {
+    
+    // used for the buffers
+    TInt32 dataLength = 0;
+    
+    // write the synchronizing marker
+    aStream.WriteInt32L( iSyncMark );
+    
+    // Write the version number
+    aStream.WriteInt32L( iVersion );
+    
+    // Write the start time
+    WriteInt64L( iStartTime.Int64(), aStream );
+    
+    // Write the end time
+    WriteInt64L( iEndTime.Int64(), aStream );
+    
+    // Write the interval start time
+    WriteInt64L( iIntervalStart.Int64(), aStream ); 
+    
+    // Write the interval   
+    aStream.WriteInt32L( iInterval.Int() );
+    
+    // Write the counter
+    aStream.WriteInt32L( iCounter );
+    
+    // Write the original counter
+    aStream.WriteInt32L( iOriginalCounter );
+    
+    // Write the timed counter
+    aStream.WriteInt32L( iTimedCounter );
+
+    // Write the timed interval
+    aStream.WriteInt32L( iTimedInterval.Int() );
+    
+    // Write the accumulated time
+    aStream.WriteInt32L( iAccumulatedTime.Int() );
+    
+    // Write the individual
+    dataLength = 0;
+    if ( iIndividual.Count() )
+        {
+        dataLength = CountArrayStoreSize( iIndividual );
+        }
+    aStream.WriteInt32L( dataLength );
+
+    if ( dataLength )
+        {
+        WriteArrayToStreamL( aStream, iIndividual );       
+        }         
+    
+    // Software Vendor Id
+    aStream.WriteInt32L( iVendorId.iUid );
+    
+    // Secure Id of the allowed application
+    aStream.WriteInt32L( iSecureId.iUid );
+    
+    // Active constraints
+    aStream.WriteUint32L( iActiveConstraints );
+    
+    // Metering info
+#ifdef RD_DRM_METERING    
+    dataLength = 0;
+    if ( iDrmMeteringInfo )
+        {
+        dataLength = sizeof( TTimeIntervalSeconds ) + sizeof( TUint8 );
+        }
+    
+    aStream.WriteInt32L( dataLength );
+    
+    if ( dataLength )
+        {
+        aStream.WriteInt32L( iDrmMeteringInfo->iGraceTime.Int() );
+        aStream.WriteInt8L( iDrmMeteringInfo->iAllowUseWithoutMetering );
+        }
+   
+#endif
+    
+    // Write the system
+    dataLength = 0;
+    if ( iSystem.Count() )
+        {
+        dataLength = CountArrayStoreSize( iSystem );
+        }
+    
+    aStream.WriteInt32L( dataLength );
+        
+    if ( dataLength )
+        {
+        WriteArrayToStreamL( aStream, iSystem );
+        }
+            
+    // write the original timed counter
+    aStream.WriteInt32L( iOriginalTimedCounter );
+        
+    // For future use
+    aStream.WriteInt32L( 0 );
+    
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMConstraint::InternalizeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMConstraint::InternalizeL( RReadStream& aStream )
+    {
+
+    TInt64 timeData = 0;
+    TInt32 temp = 0;
+    
+    // used for the buffers
+    TInt dataLength = 0;
+    HBufC8* dataPart = NULL;
+    TPtr8 dataBuffer(NULL,0,0);
+    
+    // Read the (possible) synchronizing marker.
+    iSyncMark = aStream.ReadInt32L();
+    
+    if ( iSyncMark != KSyncMark )
+        {
+         
+        // The structure of the externalized Permission object is the old one.
+        // The first four bytes constitute half of the eight bytes of Start time.
+        // Read another four bytes from the stream (and apply bit modifications) 
+        // in order to reconstruct the Start time (iStartTime).
+        temp = aStream.ReadInt32L();
+        
+        timeData = temp;
+        timeData <<= 32;
+        
+        Mem::Copy( &timeData, &iSyncMark, sizeof(TInt32) );
+        
+        iStartTime = timeData;
+        timeData = 0;
+         
+        // The version is marked as old version for differentiation in 
+        // InternalizeL.
+        iVersion = KVersion3_2_0;
+                             
+        }
+    else 
+        {
+        // The structure of the externalized Permission object is the new one.
+        // Read the version and Start time.    
+        iVersion = aStream.ReadInt32L();
+        
+        // Read the start time
+        ReadInt64L( timeData, aStream );
+        iStartTime = timeData;
+        
+        }
+     
+    // Read the end time
+    ReadInt64L( timeData, aStream );
+    iEndTime = timeData;
+    
+    // Read the interval start time
+    ReadInt64L( timeData, aStream ); 
+    iIntervalStart = timeData;
+    
+    // Read the interval   
+    iInterval = aStream.ReadInt32L();
+    
+    // Read the counter
+    iCounter = aStream.ReadInt32L();
+    
+    // Read the original counter
+    iOriginalCounter = aStream.ReadInt32L();
+    
+    // Read the timed counter
+    iTimedCounter = aStream.ReadInt32L();
+
+    // Read the timed interval
+    iTimedInterval = aStream.ReadInt32L();
+    
+    // Read the accumulated time
+    iAccumulatedTime = aStream.ReadInt32L();
+    
+    // Read the individual
+    dataLength = aStream.ReadInt32L();
+    
+    SanitizeL( dataLength );
+    
+    if( dataLength > 0 )
+        {
+        // Reserve a new buffer:
+        dataPart = HBufC8::NewMaxLC( dataLength );
+        
+        // Set the read buffer:
+        dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+        // Read the data:
+        aStream.ReadL( dataBuffer );
+        
+        
+        // Fill the array from the string
+        ReadArrayFromStringL( dataBuffer, iIndividual);
+        
+        // Pop the buffer 
+        CleanupStack::PopAndDestroy(); // dataPart
+                    
+        }
+    else
+        {
+        iIndividual.ResetAndDestroy();       
+        }           
+    
+    
+    // Read the system 
+    if ( iVersion == KVersion3_2_0 ) // Constraint has the old structure.
+        {
+        
+        dataLength = aStream.ReadInt32L();
+        
+        SanitizeL( dataLength );
+        
+        if( dataLength > 0 )
+            {
+            // Reserve a new buffer:
+            dataPart = HBufC8::NewMaxLC( dataLength );
+        
+            // Set the read buffer:
+            dataBuffer.Set( const_cast<TUint8*>(dataPart->Ptr()), 0, 
+                            dataLength );
+        
+            // Read the data:
+            aStream.ReadL( dataBuffer );
+        
+            // Pop the buffer 
+            CleanupStack::Pop(); // dataPart
+                
+            // If an old content identifier exists delete it        
+            if ( iSystem.Count() )
+                {
+                iSystem.ResetAndDestroy();
+                }
+        
+            // assign the new content id
+            iSystem.AppendL( dataPart );    
+            }
+        else
+            {
+            // If an old system exists delete it 
+            if ( iSystem.Count() )
+                {
+                iSystem.ResetAndDestroy();
+                }        
+            }  
+        }
+    
+    // Software Vendor Id
+    iVendorId.iUid = aStream.ReadInt32L();
+    
+    // Secure Id of the allowed application
+    iSecureId.iUid = aStream.ReadInt32L(); 
+    
+    // Active constraints
+    iActiveConstraints = aStream.ReadUint32L();    
+
+#ifdef RD_DRM_METERING    
+    
+    // Do not read metering information if the version
+    // is the old one because Metering is not activated in it.
+    if ( iVersion == KVersion3_2_1 )
+        {
+        
+        // Metering info
+        dataLength = aStream.ReadInt32L();
+    
+        SanitizeL( dataLength );
+        
+        if( dataLength > 0 )
+            {
+        
+            if( !iDrmMeteringInfo )
+                {
+                // Reserve a new metering information instance
+                iDrmMeteringInfo = new (ELeave)TDrmMeteringInfo;
+                }
+            else 
+                {
+                iDrmMeteringInfo->iGraceTime = 0;
+                iDrmMeteringInfo->iAllowUseWithoutMetering = EFalse;
+                }
+        
+            // Read grace time 
+            iDrmMeteringInfo->iGraceTime = aStream.ReadInt32L();
+        
+            // Read whether content can be consumed without 
+            // metering being used
+            iDrmMeteringInfo->iAllowUseWithoutMetering = 
+                aStream.ReadInt8L();
+           
+            }
+        else
+            {
+        
+            // If old metering information exists delete it 
+            if( iDrmMeteringInfo )
+                {
+                delete iDrmMeteringInfo;
+                iDrmMeteringInfo = NULL;
+                }        
+            }
+        }
+    
+#endif //RD_DRM_METERING
+
+    // Read the system and original timed counter
+    // according to the new structure.
+    if ( iVersion == KVersion3_2_1 )
+        {
+        
+        dataLength = aStream.ReadInt32L();
+        
+        SanitizeL( dataLength );
+            
+        if( dataLength > 0 )
+            {
+            // Reserve a new buffer:
+            dataPart = HBufC8::NewMaxLC( dataLength );
+        
+            // Set the read buffer:
+            dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+            // Read the data:
+            aStream.ReadL( dataBuffer );
+        
+            // Fill the array from the string
+            ReadArrayFromStringL( dataBuffer, iSystem);
+        
+            // Pop the buffer 
+            CleanupStack::PopAndDestroy(); // dataPart
+                    
+            }
+        else
+            {
+            iSystem.ResetAndDestroy();       
+            }         
+    
+        // Read the original timed counter
+        iOriginalTimedCounter = aStream.ReadInt32L();
+    
+        // For future use or development, reads the data at the end of the stream
+        dataLength = aStream.ReadInt32L();
+        
+        SanitizeL( dataLength );
+        
+        if ( dataLength > 0 )
+            {
+      
+            // Reserve a new buffer:
+            dataPart = HBufC8::NewMaxLC( dataLength );
+        
+            // Set the read buffer:
+            dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+            // Read the data:
+            aStream.ReadL( dataBuffer );
+        
+            // Pop the buffer 
+            CleanupStack::PopAndDestroy( dataPart );
+            }
+        }
+    
+    // Constraint can be considered to have the new structure from now on. 
+    if ( iVersion == KVersion3_2_0 ) 
+        {
+        iSyncMark = KSyncMark;
+        iVersion = KVersion3_2_1; 
+        }
+    
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMConstraint::Stateful
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMConstraint::Stateful() const
+    {
+    // counters, timed counters and accumulated are stateful
+    if ( iActiveConstraints &  (EConstraintCounter |
+                               EConstraintTimedCounter |
+                               EConstraintAccumulated ) ) 
+        {
+        return ETrue;
+        }
+        
+     // Non-Activated interval is stateful
+    if ( ( iActiveConstraints & EConstraintInterval ) &&
+        iIntervalStart == Time::NullTTime() ) 
+        {
+        return ETrue;
+        }
+        
+    return EFalse;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMConstraint::Size
+// -----------------------------------------------------------------------------
+//   
+EXPORT_C TInt CDRMConstraint::Size() const
+    {
+    TInt size = 0;
+    
+    // synchronizing marker
+    size += sizeof(TInt32);
+    
+    // version number
+    size += sizeof(TInt32);
+    
+    // usage start time
+    size += sizeof(TTime);
+
+    // usage end time
+    size += sizeof(TTime);
+
+    // interval start time
+    size += sizeof(TTime);
+
+    // interval duration
+    size += sizeof(TTimeIntervalSeconds);
+
+    // counter
+    size += sizeof(TDRMCounter);
+
+    // original counter value
+    size += sizeof(TDRMCounter);
+
+    // timed counter
+	size += sizeof(TDRMCounter);
+
+    // Interval of the timed counter constraint
+	size += sizeof(TTimeIntervalSeconds);
+
+    // accumulated time
+	size += sizeof(TTimeIntervalSeconds);
+
+    // individual allowed usage
+    size += sizeof(TInt32);
+    size += CountArrayStoreSize( iIndividual );
+
+    // Software Vendor Id
+    size += sizeof(TUid);
+    
+    // Secure Id of the allowed application
+    size += sizeof(TUid);
+	
+	// Bitmask of active constraints
+    size += sizeof(TUint32);
+    
+#ifdef RD_DRM_METERING    
+    // Metering information
+    size += sizeof(TInt32);
+    
+    if (iDrmMeteringInfo)
+        {
+        size += sizeof(TTimeIntervalSeconds); 
+        size += sizeof(TUint8);
+        }
+    
+#endif //RD_DRM_METERING
+    
+    // system allowed usage
+    size += sizeof(TInt32);
+    size += CountArrayStoreSize(iSystem);
+    
+    // original timed counter value
+    size += sizeof(TDRMCounter);
+    
+    // For future use
+    size += sizeof(TInt32);
+    
+    return size;
+       
+    };    
+
+// -----------------------------------------------------------------------------
+// CDRMConstraint::Expired
+// -----------------------------------------------------------------------------
+//      
+EXPORT_C TBool CDRMConstraint::Expired( const TTime& aTime ) const
+    {
+	// Full Rights do not expire
+	if ( iActiveConstraints == EConstraintNone )
+		{
+		return EFalse;
+		}
+
+	// First check counters, accumulated time and timed counters
+	// if any of these is expired the whole thing is expired regardless of the
+	// actual time based constrants or future rights
+	
+    // Counters
+    if ( ( iActiveConstraints & EConstraintCounter ) && iCounter < 1 ) 
+    	{
+    	return ETrue;	
+    	}
+    		
+    // Accumulated time	
+    if ( ( iActiveConstraints & EConstraintAccumulated ) && iAccumulatedTime.Int() == 0 )
+    	{
+    	return ETrue;
+    	}
+    		
+     // Timed Counters
+    if ( ( iActiveConstraints & EConstraintTimedCounter ) && iTimedCounter < 1 ) 
+    	{
+    	return ETrue;	
+    	} 
+    		
+
+    // Dont check time based rights
+    if ( aTime != Time::NullTTime() )
+    	{	
+    	
+    	// Check for activated intervals
+    	if ( ( iActiveConstraints & EConstraintInterval) && iIntervalStart != Time::NullTTime() )
+    		{
+        	TTimeIntervalSeconds current;
+        
+        	aTime.SecondsFrom( iIntervalStart, current );
+        
+        	if ( current >= iInterval )
+            	{
+            	return ETrue;
+            	}    			
+    		}
+    	
+    	// Check for end time
+    	if ( ( iActiveConstraints & EConstraintEndTime ) && aTime >= iEndTime )
+    		{
+    		return ETrue;	
+    		}	
+    		
+    	// Check for start time, future rights	
+    	if ( ( iActiveConstraints & EConstraintStartTime ) && aTime < iStartTime )
+    		{
+    		return EFalse;	
+    		}
+    	}
+
+    return EFalse;
+    }
+// -----------------------------------------------------------------------------
+// CDRMConstraint::Merge
+// -----------------------------------------------------------------------------
+//      
+EXPORT_C void CDRMConstraint::Merge( const CDRMConstraint& aConstraint )
+    {
+    TInt error = KErrNone;
+    
+    if ( this != &aConstraint )
+        {
+        if ( aConstraint.iActiveConstraints & EConstraintStartTime )
+            {
+            if ( iActiveConstraints & EConstraintStartTime )
+                {
+                iStartTime = Max( iStartTime, aConstraint.iStartTime );
+                }
+            else
+                {
+                iStartTime = aConstraint.iStartTime;
+                iActiveConstraints |= EConstraintStartTime;
+                }
+            }
+            
+        if ( aConstraint.iActiveConstraints & EConstraintEndTime )
+            {
+            if ( iActiveConstraints & EConstraintEndTime )
+                {
+                iEndTime = Min( aConstraint.iEndTime, iEndTime );
+                }
+            else
+                {
+                iEndTime = aConstraint.iEndTime;
+                iActiveConstraints |= EConstraintEndTime;
+                }
+            }
+            
+        if ( aConstraint.iActiveConstraints & EConstraintCounter )
+            {
+            if ( iActiveConstraints & EConstraintCounter )
+                {
+                iCounter = Min( iCounter, aConstraint.iCounter );
+                iOriginalCounter = Min( iOriginalCounter, aConstraint.iOriginalCounter );
+                }
+            else
+                {
+                iCounter = aConstraint.iCounter;
+                iOriginalCounter = aConstraint.iOriginalCounter;
+                iActiveConstraints |= EConstraintCounter;
+                }
+            }
+        
+        if ( aConstraint.iActiveConstraints & EConstraintInterval )
+            {
+            if ( iActiveConstraints & EConstraintInterval )
+                {
+                iIntervalStart = Max( iIntervalStart, aConstraint.iIntervalStart );
+                iInterval = Min( iInterval, aConstraint.iInterval );
+                }
+            else
+                {
+                iIntervalStart = aConstraint.iIntervalStart;
+                iInterval = aConstraint.iInterval;
+                iActiveConstraints |= EConstraintInterval;
+                }
+            }
+            
+        if ( aConstraint.iActiveConstraints & EConstraintTimedCounter )
+            {
+            if ( iActiveConstraints & EConstraintTimedCounter )
+                {
+                if ( aConstraint.iTimedCounter < iTimedCounter )
+                    {
+                    iTimedCounter = aConstraint.iTimedCounter;
+                    iTimedInterval = aConstraint.iTimedInterval;
+                    }
+                }
+            else
+                {
+                iTimedCounter = aConstraint.iTimedCounter;
+                iTimedInterval = aConstraint.iTimedInterval;
+                iActiveConstraints |= EConstraintTimedCounter;
+                }
+            }
+        
+        if ( aConstraint.iActiveConstraints & EConstraintAccumulated )
+            {
+            if ( iActiveConstraints & EConstraintAccumulated )
+                {
+                iAccumulatedTime = Min( iAccumulatedTime, aConstraint.iAccumulatedTime );
+                }
+            else
+                {
+                iAccumulatedTime = aConstraint.iAccumulatedTime;
+                iActiveConstraints |= EConstraintAccumulated;
+                }
+            }
+             
+        if( aConstraint.iActiveConstraints & EConstraintIndividual )
+            {
+            // Ignore the error since we don't return an error code or leave
+            TRAP( error, AppendToArrayL( iIndividual, aConstraint.iIndividual ) );
+            }
+            
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMConstraint::Consume  
+// -----------------------------------------------------------------------------
+//  
+EXPORT_C void CDRMConstraint::Consume( const TTime& aCurrentTime )
+    {
+    if ( ( iActiveConstraints & EConstraintInterval ) &&
+        iIntervalStart == Time::NullTTime() )
+        {
+        iIntervalStart = aCurrentTime;
+        }
+        
+    if ( iActiveConstraints & EConstraintCounter )
+        {
+        --iCounter;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMConstraint::DuplicateL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMConstraint::DuplicateL( const CDRMConstraint& aConstraint )
+    {
+    
+    // synchronizing marker
+    iSyncMark = aConstraint.iSyncMark;
+    
+    // version number
+    iVersion = aConstraint.iVersion;
+    
+    // usage start time
+    iStartTime = aConstraint.iStartTime;
+
+    // usage end time
+    iEndTime = aConstraint.iEndTime;
+
+    // interval start time
+    iIntervalStart = aConstraint.iIntervalStart;
+
+    // interval duration
+    iInterval = aConstraint.iInterval;
+
+    // counter
+    iCounter = aConstraint.iCounter;
+
+    // original counter value
+    iOriginalCounter = aConstraint.iOriginalCounter;
+
+    // timed counter
+	iTimedCounter = aConstraint.iTimedCounter;
+
+    // Interval of the timed counter constraint
+	iTimedInterval = aConstraint.iTimedInterval;
+
+    // accumulated time
+	iAccumulatedTime = aConstraint.iAccumulatedTime;
+
+    // individual allowed usage
+    iIndividual.ResetAndDestroy();
+    
+    AppendToArrayL( iIndividual, aConstraint.iIndividual );
+	
+    // Software Vendor Id
+    iVendorId = aConstraint.iVendorId;
+	
+    // Secure Id of the allowed application
+    iSecureId = aConstraint.iSecureId;
+	
+	// Bitmask of active constraints
+    iActiveConstraints = aConstraint.iActiveConstraints;	// Bitmask
+
+#ifdef RD_DRM_METERING    
+    // Metering information
+    if ( aConstraint.iDrmMeteringInfo )
+        {
+        
+        if( !iDrmMeteringInfo )
+            {
+            iDrmMeteringInfo = new (ELeave) TDrmMeteringInfo;
+            }
+    
+        iDrmMeteringInfo->iGraceTime = aConstraint.iDrmMeteringInfo->iGraceTime;
+        iDrmMeteringInfo->iAllowUseWithoutMetering = aConstraint.iDrmMeteringInfo->iAllowUseWithoutMetering; 
+        }
+#endif
+    
+    // system allowed usage
+    iSystem.ResetAndDestroy();
+    AppendToArrayL( iSystem, aConstraint.iSystem );
+    
+    // original timed counter value
+    iOriginalTimedCounter = aConstraint.iOriginalTimedCounter;
+    
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMConstraint::Valid
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMConstraint::Valid( const TTime& aTime,
+                                      const RPointerArray<HBufC8>& aIndividual,
+                                      TUint32& aRejection ) const
+	{
+	TBool drmTime = EFalse;
+	// Null the rejection requirement:
+	aRejection = EConstraintNone;
+	
+	// Full Rights are always valid
+	if ( iActiveConstraints == EConstraintNone )
+		{
+		return ETrue;
+		}
+
+	// First check counters, accumulated time and timed counters
+	// if any of these are invalid the whole thing is invalid regardless of the
+	// actual time based constraints
+	
+    // Counters
+    if ( ( iActiveConstraints & EConstraintCounter ) && iCounter < 1 ) 
+    	{
+    	aRejection |= EConstraintCounter;
+    	}
+    		
+    // Accumulated time	
+    if ( ( iActiveConstraints & EConstraintAccumulated ) && iAccumulatedTime.Int() == 0 )
+    	{
+    	aRejection |= EConstraintAccumulated;
+    	}
+    		
+     // Timed Counters
+    if ( ( iActiveConstraints & EConstraintTimedCounter ) && iTimedCounter < 1 ) 
+    	{
+    	aRejection |= EConstraintTimedCounter;	
+    	} 
+    		
+    // Dont check time based rights
+    if ( aTime != Time::NullTTime() )
+    	{	
+    	drmTime = ETrue;
+    	// Check for activated intervals
+    	if ( (iActiveConstraints & EConstraintInterval) && iIntervalStart != Time::NullTTime() )
+    		{
+        	TTimeIntervalSeconds current;
+        
+        	aTime.SecondsFrom( iIntervalStart, current );
+        
+        	if ( ( current >= iInterval ) || ( aTime < iIntervalStart ) )
+            	{
+            	aRejection |= EConstraintInterval;
+            	}    			
+    		}
+    	
+    	// Check for end time
+    	if ( ( iActiveConstraints & EConstraintEndTime ) && aTime >= iEndTime ) 
+    	    {
+    	    aRejection |= EConstraintEndTime;
+    	    }
+    	    
+    	if ( ( iActiveConstraints & EConstraintStartTime ) && aTime < iStartTime )     
+    		{
+    		aRejection |= EConstraintStartTime;	
+    		}	
+    	}
+    else
+        {
+        drmTime = EFalse;
+        
+    	// Check for activated intervals
+    	if ( (iActiveConstraints & EConstraintInterval) )
+    		{
+            aRejection |= EConstraintInterval; 			
+    		}
+    	
+    	// Check for end time
+    	if ( ( iActiveConstraints & EConstraintEndTime ) ) 
+    	    {
+    	    aRejection |= EConstraintEndTime;
+    	    }
+    	    
+    	if( ( iActiveConstraints & EConstraintStartTime ) )     
+    		{
+    		aRejection |= EConstraintStartTime;	
+    		}
+        }	
+
+    // IMSI Checking:
+    if( iActiveConstraints & EConstraintIndividual )
+        {
+        if ( !aIndividual.Count() && !iIndividual.Count() )
+            {
+            aRejection |= EConstraintIndividual;
+            }
+        else if( !IsIndividualConstraintValid( iIndividual, aIndividual ) )
+            {
+            aRejection |= EConstraintIndividual;
+            }
+        }        
+
+    if( aRejection )
+        {
+        // drmTime is null, so some constraints may have been discarded because of that
+        if( !drmTime )
+            {
+            aRejection |= EConstraintNullDrmTime;
+            }       
+        return EFalse;        
+        }
+
+    return ETrue;		
+	};
+
+
+// -----------------------------------------------------------------------------
+// CDRMConstraint::ConstructL
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+//
+void CDRMConstraint::ConstructL()
+    {
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMConstraint::WriteInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMConstraint::WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const
+    {
+    TPtr8 output(NULL,0,0);
+    
+    output.Set( reinterpret_cast<TUint8*>(const_cast<TInt64*>(&aWrite)), 
+                sizeof(TInt64), sizeof(TInt64) );
+    
+    aStream.WriteL( output, sizeof(TInt64) );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMConstraint::ReadInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMConstraint::ReadInt64L( TInt64& aRead, RReadStream& aStream )
+    {
+    TPtr8 input(NULL,0,0);
+    
+    input.Set( reinterpret_cast<TUint8*>(&aRead), 0, sizeof(TInt64) );
+    
+    aStream.ReadL( input, sizeof(TInt64) );    
+    };        
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DRMPermission.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1268 @@
+/*
+* 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:  Part of the Implementation of the DRM Rights Database
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32strm.h>
+#include <s32mem.h>
+#include <caf/caf.h>
+#include "DRMPermission.h"
+#include "DRMConstraint.h"
+#include "drmlog.h"
+#include "OMA2Agent.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// Synchronizing marker in the beginning of the stream in order to synchronize
+// to externalized Permission object having the new structure.  
+const TInt32 KSyncMark = 0xAFCE;
+
+// Old and new version number of the Permission object
+const TInt8 KVersion3_2_0 = 0;
+const TInt8 KVersion3_2_1 = 1;   
+
+
+const TInt KSanityDataLengthLow = 0;
+const TInt KSanityDataLengthHigh = 32768;
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// SanitizeL
+// Performs a sanity check on length parameters
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void SanitizeL( TInt aParam )
+    {
+    if( aParam < KSanityDataLengthLow || aParam > KSanityDataLengthHigh )
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMPermission* CDRMPermission::NewLC()
+    {
+    CDRMPermission* self = new( ELeave ) CDRMPermission();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    return self;    
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMPermission* CDRMPermission::NewL()
+    {
+    CDRMPermission* self = NewLC();
+    CleanupStack::Pop();
+    
+    return self;
+    };
+
+// -----------------------------------------------------------------------------
+// Default constructor
+// -----------------------------------------------------------------------------
+//
+CDRMPermission::CDRMPermission() :
+    iSyncMark( KSyncMark ),
+    iVersion( KVersion3_2_1 ), // Version number for differentiation in 
+                               // InternalizeL.
+    iUniqueID( 0 ),
+    iOriginalInsertTime( Time::NullTTime() ),
+    iTopLevel( NULL ),
+    iPlay( NULL ),
+    iDisplay( NULL ),
+    iExecute(NULL ),
+    iPrint( NULL ),
+    iExportMode( ECopy ),
+    iParentUID( NULL ),
+    iRoID( NULL ),
+    iDomainID( NULL ),
+    iAvailableRights( 0 ),
+    iInfoBits( 0 ),
+    iOnExpiredUrl( NULL )
+    {
+    iRiId.SetLength( KRiIdSize );
+    iRiId.Fill( 0 );
+    };
+    
+    
+    
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMPermission::~CDRMPermission()
+    {
+    if( iTopLevel )
+        {
+        delete iTopLevel;
+        iTopLevel = NULL;
+        }
+
+    if( iPlay )
+        {
+        delete iPlay;
+        iPlay = NULL;
+        }
+        
+    if( iDisplay )
+        {
+        delete iDisplay;
+        iDisplay = NULL;
+        }
+        
+    if( iExecute )
+        {
+        delete iExecute;
+        iExecute = NULL;
+        }
+        
+    if( iExport )
+        {
+        delete iExport;
+        iExport = NULL;
+        }
+        
+    if( iPrint )
+        {
+        delete iPrint;
+        iPrint = NULL;
+        }
+       
+    if( iParentUID )
+        {
+        delete iParentUID;
+        iParentUID = NULL;
+        }
+
+    if( iRoID )
+        {
+        delete iRoID;
+        iRoID = NULL;
+        }
+
+    if( iDomainID )
+        {
+        delete iDomainID;
+        iDomainID = NULL;
+        }
+        
+    if( iOnExpiredUrl )
+        {
+        delete iOnExpiredUrl;
+        iOnExpiredUrl = NULL;
+        }
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMPermission::ExternalizeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMPermission::ExternalizeL( RWriteStream& aStream ) const
+    {
+    
+    // used for the buffers
+    TInt dataLength = 0;
+    
+    // Used for mode
+    TUint8 exportMode = 0;
+    
+    // Write the synchronizing marker
+    aStream.WriteInt32L( iSyncMark );
+    
+    // Write the version number
+    aStream.WriteInt32L( iVersion );
+    
+    // Unique ID of the permission
+    aStream.WriteUint32L( iUniqueID );
+    
+    // The original insertion time
+    WriteInt64L( iOriginalInsertTime.Int64(), aStream );
+    
+    // Top level constraint
+    if( !iTopLevel ) 
+        {
+        User::Leave( KErrNotReady );
+        }
+    iTopLevel->ExternalizeL( aStream );
+    
+    // Play constraint
+    if( !iPlay )
+        {
+        User::Leave( KErrNotReady );
+        }
+    iPlay->ExternalizeL( aStream );
+    
+    // Display constraint
+    if( !iDisplay )
+        {
+        User::Leave( KErrNotReady );
+        }
+    iDisplay->ExternalizeL( aStream );
+    
+    // Execute constraint
+    if( !iExecute )
+        {
+        User::Leave( KErrNotReady );
+        }
+    iExecute->ExternalizeL( aStream );
+    
+    // Print constraint
+    if( !iPrint )
+        {
+        User::Leave( KErrNotReady );
+        }
+    iPrint->ExternalizeL( aStream );
+    
+    // Export constraint
+    if( !iExport )
+        {
+        User::Leave( KErrNotReady );
+        }
+    iExport->ExternalizeL( aStream );
+    
+    // Export mode
+    exportMode = iExportMode;
+    aStream.WriteUint8L( exportMode );
+    
+    // Content id of the parent rights object
+    dataLength = 0;
+    if( iParentUID ) 
+        {
+        dataLength = iParentUID->Length();
+        }
+    aStream.WriteInt32L( dataLength );
+
+    if( dataLength )
+        {
+        aStream.WriteL( iParentUID->Des() );        
+        }             
+    
+    // Rights Object if of the rights delivery container
+    dataLength = 0;    
+    if( iRoID )
+        {
+        dataLength = iRoID->Length();
+        }
+    aStream.WriteInt32L( dataLength );
+    
+    if( dataLength )
+        {
+        aStream.WriteL( iRoID->Des() );        
+        }
+    
+    // Domain identifier
+    dataLength = 0;    
+    if( iDomainID )
+        {
+        dataLength = iDomainID->Length();
+        }
+    aStream.WriteInt32L( dataLength );
+    
+    if( dataLength )
+        {
+        aStream.WriteL( iDomainID->Des() );        
+        }    
+       
+    // Available rights    
+    aStream.WriteUint16L( iAvailableRights );
+
+    // Version number of the rights object    
+    aStream.WriteUint16L( iRightsObjectVersion.iVersionMain );
+    aStream.WriteUint16L( iRightsObjectVersion.iVersionSub );
+    
+    // Info bits
+    aStream.WriteInt32L( iInfoBits );
+    
+    aStream.WriteL( iRiId );
+     
+    // OnExpiredUrl
+    dataLength = 0;
+    if ( iOnExpiredUrl )
+        {
+        dataLength = iOnExpiredUrl->Length();
+        }
+    aStream.WriteInt32L( dataLength );
+    
+    if ( dataLength )
+        {
+        aStream.WriteL( iOnExpiredUrl->Des() );
+        }
+    
+    // For future use
+    aStream.WriteInt32L( 0 );
+    
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMPermission::InternalizeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMPermission::InternalizeL( RReadStream& aStream )
+    {    
+    
+    TInt64 timeData = 0;
+    
+    // used for the buffers
+    TInt dataLength = 0;
+    TPtr8 dataBuffer(NULL,0,0);
+    HBufC8* dataPart = NULL;
+    
+    // (Possible) synchronizing marker
+    iSyncMark = aStream.ReadInt32L();
+    
+    if ( iSyncMark == KSyncMark )
+        {
+        
+        // The internalized Permission object has the new structure if the
+        // synchronizing marker is found in the beginning of the stream. In that
+        // case read version number and Unique ID.
+        iVersion = aStream.ReadInt32L();
+
+        // Unique ID of the permission
+        iUniqueID = aStream.ReadUint32L();
+
+        }
+    else 
+        {
+        
+        // The internalized Permission object has the old structure. The
+        // stream information that was read to iSyncMark is actually the
+        // Unique ID.
+        iUniqueID = (TDRMUniqueID)iSyncMark;
+        iVersion = KVersion3_2_0; // Old version, needed for differentation
+        
+        }
+            
+    // The original insertion time
+    ReadInt64L( timeData, aStream );
+    iOriginalInsertTime = timeData;
+    
+    // Top level constraint
+    if( !iTopLevel )
+        {
+        iTopLevel = CDRMConstraint::NewL();
+        }
+        
+    iTopLevel->InternalizeL( aStream );
+    
+    // Play constraint
+    if( !iPlay )
+        {
+        iPlay = CDRMConstraint::NewL();
+        }
+         
+    iPlay->InternalizeL( aStream );
+    
+    // Display constraint
+    if( !iDisplay )
+        {
+        iDisplay = CDRMConstraint::NewL();
+        }
+        
+    iDisplay->InternalizeL( aStream );
+    
+    // Execute constraint
+    if( !iExecute )
+        {
+        iExecute = CDRMConstraint::NewL();
+        }
+         
+    iExecute->InternalizeL( aStream );
+    
+    // Print constraint
+    if( !iPrint)
+        {
+        iPrint = CDRMConstraint::NewL();
+        }
+         
+    iPrint->InternalizeL( aStream );
+    
+    // Export constraint
+     
+    iExport->InternalizeL( aStream );
+    
+    // Export mode
+    iExportMode = static_cast<TExportMode>(aStream.ReadUint8L());
+    
+    // Content id of the parent rights object
+    dataLength = aStream.ReadInt32L();
+    
+    SanitizeL( dataLength );
+    
+    if( dataLength > 0 )
+        {
+        // Reserve a new buffer:
+        dataPart = HBufC8::NewMaxLC( dataLength );
+        
+        // Set the read buffer:
+        dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+        // Read the data:
+        aStream.ReadL( dataBuffer );
+        
+        // Pop the buffer 
+        CleanupStack::Pop(); // dataPart
+                
+        // If an old content identifier exists delete it        
+        if( iParentUID )
+            {
+            delete iParentUID;
+            iParentUID = NULL;
+            }
+        
+        // assign the new content id
+        iParentUID = dataPart;    
+        }
+    else
+        {
+        // If an old individual exists delete it 
+        if( iParentUID )
+            {
+            delete iParentUID;
+            iParentUID = NULL;
+            }        
+        }           
+    
+    
+    // Rights Object if of the rights delivery container
+    // Read the individual
+    dataLength = aStream.ReadInt32L();
+
+    SanitizeL( dataLength );
+        
+    if( dataLength > 0 )
+        {
+        // Reserve a new buffer:
+        dataPart = HBufC8::NewMaxLC( dataLength );
+        
+        // Set the read buffer:
+        dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+        // Read the data:
+        aStream.ReadL( dataBuffer );
+        
+        // Pop the buffer 
+        CleanupStack::Pop(); // dataPart
+                
+        // If an old content identifier exists delete it        
+        if( iRoID )
+            {
+            delete iRoID;
+            iRoID = NULL;
+            }
+        
+        // assign the new content id
+        iRoID = dataPart;    
+        }
+    else
+        {
+        // If an old individual exists delete it 
+        if( iRoID )
+            {
+            delete iRoID;
+            iRoID = NULL;
+            }        
+        }           
+    
+    // Domain identifier
+    dataLength = aStream.ReadInt32L();
+
+    SanitizeL( dataLength );
+        
+    if( dataLength > 0 )
+        {
+        // Reserve a new buffer:
+        dataPart = HBufC8::NewMaxLC( dataLength );
+        
+        // Set the read buffer:
+        dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+        // Read the data:
+        aStream.ReadL( dataBuffer );
+        
+        // Pop the buffer 
+        CleanupStack::Pop(); // dataPart
+                
+        // If an old content identifier exists delete it        
+        if( iDomainID )
+            {
+            delete iDomainID;
+            iDomainID = NULL;
+            }
+        
+        // assign the new content id
+        iDomainID = dataPart;    
+        }
+    else
+        {
+        // If an old individual exists delete it 
+        if( iDomainID )
+            {
+            delete iDomainID;
+            iDomainID = NULL;
+            }        
+        }           
+    
+
+    // Available rights    
+    iAvailableRights = aStream.ReadUint16L();
+
+    // Version number of the rights object    
+    iRightsObjectVersion.iVersionMain = aStream.ReadUint16L();
+    iRightsObjectVersion.iVersionSub = aStream.ReadUint16L();
+    
+    // Information bits
+    iInfoBits = aStream.ReadInt32L();
+    
+    aStream.ReadL( iRiId );
+    
+    // New structure of Permission object
+    if ( iVersion == KVersion3_2_1 )
+        {
+        
+        // OnExpiredUrl
+        dataLength = aStream.ReadInt32L();
+    
+        SanitizeL( dataLength );
+        
+        if( dataLength > 0 )
+            {
+            
+            // Reserve a new buffer:
+            dataPart = HBufC8::NewMaxLC( dataLength );
+        
+            // Set the read buffer:
+            dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, 
+                           dataLength);
+        
+            // Read the data:
+            aStream.ReadL( dataBuffer );
+        
+            // Pop the buffer 
+            CleanupStack::Pop(); // dataPart
+                
+            // If an old OnExpiredUrl exists delete it        
+            if( iOnExpiredUrl )
+                {
+                delete iOnExpiredUrl;
+                iOnExpiredUrl = NULL;
+                }
+        
+            // assign the new OnExpiredUrl
+            iOnExpiredUrl = dataPart;    
+            }
+            else
+            {
+            // If an old OnExpiredUrl exists delete it 
+            if( iOnExpiredUrl )
+                {
+                delete iOnExpiredUrl;
+                iOnExpiredUrl = NULL;
+                }        
+            }           
+      
+        // For future use or development, reads the data at the end of the stream
+        dataLength = aStream.ReadInt32L();
+    
+        SanitizeL( dataLength );
+        
+        if ( dataLength > 0 )
+            {
+            // Reserve a new buffer:
+            dataPart = HBufC8::NewMaxLC( dataLength );
+        
+            // Set the read buffer:
+            dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+            // Read the data:
+            aStream.ReadL( dataBuffer );
+        
+            // Delete the buffer 
+            CleanupStack::PopAndDestroy( dataPart );
+            }
+        }
+    
+    // Permission can be considered to have the new structure after 
+    // internalization. 
+    if ( iVersion == KVersion3_2_0 ) 
+        {
+        iSyncMark = KSyncMark;
+        iVersion = KVersion3_2_1; 
+        }
+        
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMPermission::Stateful
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMPermission::Stateful() const
+    {
+    if( ( (iAvailableRights & ERightsTopLevel) &&  iTopLevel->Stateful() ) )
+        {
+        return ETrue;
+        }
+    else if( (iAvailableRights & ERightsPlay) &&  iPlay->Stateful() )
+        {
+        return ETrue;
+        }
+    else if( (iAvailableRights & ERightsDisplay) &&  iDisplay->Stateful() )
+        {
+        return ETrue;    
+        }
+    else if( (iAvailableRights & ERightsExecute) &&  iExecute->Stateful() )
+        {
+        return ETrue;    
+        }
+    else if( (iAvailableRights & ERightsPrint) &&  iPrint->Stateful() )
+        {
+        return ETrue;
+        }
+    return EFalse;        
+    };
+	
+// -----------------------------------------------------------------------------
+// CDRMPermission::SoftwareConstrained
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMPermission::SoftwareConstrained() const
+    {
+    if ( (iAvailableRights & ERightsTopLevel) &&
+        iTopLevel->iActiveConstraints & ( EConstraintVendor | EConstraintSoftware ) )
+        {
+        return ETrue;
+        }
+    else if ( (iAvailableRights & ERightsPlay) &&
+        iPlay->iActiveConstraints & ( EConstraintVendor | EConstraintSoftware ) )
+        {
+        return ETrue;
+        }
+    else if ( (iAvailableRights & ERightsDisplay) &&
+        iDisplay->iActiveConstraints & ( EConstraintVendor | EConstraintSoftware ) )
+        {
+        return ETrue;    
+        }
+    else if ( (iAvailableRights & ERightsExecute) &&
+        iExecute->iActiveConstraints & ( EConstraintVendor | EConstraintSoftware ) )
+        {
+        return ETrue;    
+        }
+    else if ( (iAvailableRights & ERightsPrint) &&
+        iPrint->iActiveConstraints & ( EConstraintVendor | EConstraintSoftware ) )
+        {
+        return ETrue;
+        }
+    return EFalse;        
+    };
+	
+// -----------------------------------------------------------------------------
+// CDRMPermission::Child
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C TBool CDRMPermission::Child() const
+    {
+    return iParentUID ? ETrue : EFalse;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::Size
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C TInt CDRMPermission::Size() const
+    {
+    TInt size = 0;
+    
+    // synchronizing marker
+    size += sizeof(TInt32);
+    
+    // Version number
+    size += sizeof(TInt32);
+    
+    // Unique ID of the permission
+    size += sizeof(TDRMUniqueID);
+    
+    // The original insertion time
+    size += sizeof(TTime);
+    
+    // Top level constraint
+    size += iTopLevel->Size();
+    
+    // Play constraint
+    size += iPlay->Size();
+    
+    // Display constraint
+    size += iDisplay->Size();
+    
+    // Execute constraint
+    size += iExecute->Size();
+    
+    // Print constraint
+    size += iPrint->Size();
+    
+    // Export constraint
+    size += iExport->Size();
+    
+    // Export mode
+    size += sizeof(TUint8);
+    
+    // Content id of the parent rights object
+    size += sizeof(TInt32);
+    
+    if( iParentUID )
+        {
+        size += iParentUID->Size();
+        }
+    
+    // Rights Object if of the rights delivery container
+    size += sizeof(TInt32);
+    
+    if( iRoID )
+        {
+        size += iRoID->Size();
+        }
+    
+    // Domain identifier
+    size += sizeof(TInt32);
+        
+    if( iDomainID )
+        {
+        size += iDomainID->Size();
+        }
+    
+    // Available rights
+    size += sizeof(TUint16);
+    
+    // Version number of the rights object
+    size += sizeof(TUint16);
+    size += sizeof(TUint16);
+    
+    // infobits
+    size += sizeof(TInt32);
+    
+    // RI ID
+    size += KRiIdSize;
+      
+    // OnExpiredUrl
+    size += sizeof(TInt32);
+    
+    if ( iOnExpiredUrl )
+        {
+        size += iOnExpiredUrl->Size();
+        }
+    
+    // For future use
+    size += sizeof(TInt32);
+    
+    return size;
+    
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::ConstraintForIntent
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C CDRMConstraint* CDRMPermission::ConstraintForIntent( 
+    const ContentAccess::TIntent aIntent )
+    {
+    CDRMConstraint* r = NULL;
+    
+    switch ( aIntent )
+        {
+        case ContentAccess::EPlay:
+            if ( iAvailableRights & ERightsPlay )
+                {
+                r = iPlay;
+                }
+            break;
+        case ContentAccess::EView:
+            if ( iAvailableRights & ERightsDisplay )
+                {
+                r = iDisplay;
+                }
+            break;
+        case ContentAccess::EExecute:
+            if ( iAvailableRights & ERightsExecute )
+                {
+                r = iExecute;
+                }
+            break;
+        case ContentAccess::EPrint:
+            if ( iAvailableRights & ERightsPrint )
+                {
+                r = iPrint;
+                }
+            break;
+        }
+        
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::ConstraintForIntent
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C CDRMConstraint* CDRMPermission::TopLevelConstraint()
+    {
+    if ( iAvailableRights & ERightsTopLevel )
+        {
+        return iTopLevel;
+        }
+    else
+        {
+        return NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::ConsumeRights
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C void CDRMPermission::ConsumeRights( const TIntent aIntent, const TTime& aCurrentTime )
+    {
+    //__ASSERT_DEBUG( !( aIntent == ERightsTopLevel ), User::Leave( KErrArgument ) ); 
+    
+    CDRMConstraint* constraint( TopLevelConstraint() );
+    
+    if ( constraint )
+        {
+        constraint->Consume( aCurrentTime );
+        }
+    
+    constraint = ConstraintForIntent( aIntent );
+    if ( constraint )
+        {
+        constraint->Consume( aCurrentTime );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::ImportL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMPermission::ImportL( const TDesC8& aBuffer )
+    {
+    TInt size = aBuffer.Size();
+    RMemReadStream stream( (TAny*)( aBuffer.Ptr() ), size );
+    CleanupClosePushL( stream );
+
+    InternalizeL( stream );
+    
+    CleanupStack::PopAndDestroy(); // Stream   
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::ExportL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* CDRMPermission::ExportL() const
+    {
+    TInt size = Size();
+    HBufC8* data = HBufC8::NewMaxLC( size );
+
+    RMemWriteStream stream( (TAny*)( data->Ptr() ), size );
+    CleanupClosePushL( stream );
+
+    ExternalizeL( stream );
+    
+    CleanupStack::PopAndDestroy(); // Stream
+    CleanupStack::Pop();
+    return data;    
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::DuplicateL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMPermission::DuplicateL( const CDRMPermission& aPermission )
+    {
+    
+    // Synchronizing marker
+    iSyncMark = aPermission.iSyncMark;
+    
+    // Version number
+    iVersion = aPermission.iVersion;
+    
+    // Unique ID of the permission
+    iUniqueID = aPermission.iUniqueID;
+    
+    // The original insertion time
+    iOriginalInsertTime = aPermission.iOriginalInsertTime;
+    
+    // Top level constraint
+    if( !iTopLevel )
+        {
+        iTopLevel = CDRMConstraint::NewL();
+        }
+    iTopLevel->DuplicateL( *(aPermission.iTopLevel ) );
+    
+    // Play constraint
+    if( !iPlay )
+        {
+        iPlay = CDRMConstraint::NewL();
+        }
+    iPlay->DuplicateL( *(aPermission.iPlay ) );
+    
+    // Display constraint
+    if( !iDisplay )
+        {
+        iDisplay = CDRMConstraint::NewL();
+        }
+    iDisplay->DuplicateL( *(aPermission.iDisplay ) );
+    
+    // Execute constraint
+    if( !iExecute )
+        {
+        iExecute = CDRMConstraint::NewL();
+        }
+    iExecute->DuplicateL( *(aPermission.iExecute ) );
+    
+    // Print constraint
+    if( !iPrint )
+        {
+        iPrint = CDRMConstraint::NewL();
+        }
+    iPrint->DuplicateL( *(aPermission.iPrint ) );
+    
+    // Export constraint
+    if( !iExport )
+        {
+        iExport = CDRMConstraint::NewL();
+        }
+    iExport->DuplicateL( *(aPermission.iExport ) ); 
+    
+    // Export mode
+    iExportMode = aPermission.iExportMode;
+    
+    // Content id of the parent rights object
+    if( iParentUID )
+        {
+        delete iParentUID;
+        iParentUID = NULL;
+        }
+
+    if( aPermission.iParentUID )
+        {
+        iParentUID = aPermission.iParentUID->AllocL();
+        }
+        
+    // Rights Object if of the rights delivery container
+    if( iRoID )
+        {
+        delete iRoID;
+        iRoID = NULL;
+        }
+        
+    if( aPermission.iRoID )
+        {
+        iRoID = aPermission.iRoID->AllocL();
+        }
+        
+    // Domain identifier
+    if( iDomainID )
+        {
+        delete iDomainID;
+        iDomainID = NULL;
+        }
+        
+    if( aPermission.iDomainID )   
+        {
+        iDomainID = aPermission.iDomainID->AllocL();
+        }
+    // Available rights
+    iAvailableRights  = aPermission.iAvailableRights;	// Bitmask
+    
+    // Version number of the rights object
+    iRightsObjectVersion.iVersionMain = aPermission.iRightsObjectVersion.iVersionMain;
+    iRightsObjectVersion.iVersionSub = aPermission.iRightsObjectVersion.iVersionSub;
+    
+    // info bits
+    iInfoBits = aPermission.iInfoBits;
+    
+    // OnExpiredUrl
+    if ( iOnExpiredUrl )
+        {
+        delete iOnExpiredUrl;
+        iOnExpiredUrl = NULL;
+        }
+        
+    if ( aPermission.iOnExpiredUrl )    
+        {
+        iOnExpiredUrl = aPermission.iOnExpiredUrl->AllocL();
+        }
+    
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::Expired
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMPermission::Expired( const TTime& aTime )
+	{
+	if( iTopLevel && iAvailableRights & ERightsTopLevel )
+		{
+		if( iTopLevel->Expired( aTime ) )
+			{
+			return ETrue;	
+			}	
+		}
+
+	if( iPlay && iAvailableRights & ERightsPlay)
+		{
+		if( !iPlay->Expired( aTime ) )
+			{
+			return EFalse;
+			}	
+		}
+
+	if( iDisplay && iAvailableRights & ERightsDisplay )
+		{
+		if( !iDisplay->Expired( aTime ) )
+			{
+			return EFalse;	
+			}	
+		}
+
+	if( iExecute && iAvailableRights & ERightsExecute )
+		{
+		if( !iExecute->Expired( aTime ) )
+			{
+			return EFalse;
+			}	
+		}
+
+	if( iPrint && iAvailableRights & ERightsPrint )
+		{
+		if( !iPrint->Expired( aTime ) )
+			{
+			return EFalse;	
+			}	
+		}
+
+	if( iExport && iAvailableRights & ERightsExport )
+		{
+		if( !iExport->Expired( aTime ) )
+			{
+			return EFalse;	
+			}	
+		}
+		
+	return ETrue;									
+	};
+
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::Expired
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMPermission::Valid( const TTime& aTime,
+                                      const RPointerArray<HBufC8>& aIndividual,
+                                      TUint32& aRejection, 
+                                      const TRightsType aType ) const
+	{
+	// Always check that if the top level rights are present
+	// that they are valid
+    if( iTopLevel && !iTopLevel->Valid( aTime, aIndividual, aRejection ) )
+        {
+        aRejection |= aRejection;
+        return EFalse;	
+        }
+
+    switch( aType )
+        {
+        case ERightsTopLevel:
+            if( !iTopLevel )
+                {
+                return EFalse;	
+                }
+            break;            
+        case ERightsPlay:
+            if( !iPlay )
+                {
+                return EFalse;	
+                }
+    		else if( iPlay && !iPlay->Valid( aTime, aIndividual, aRejection ) )
+    			{
+    			return EFalse;	
+    			}	
+    		break;    	
+    	case ERightsDisplay:
+    	    if( !iDisplay )
+    	    	{
+    	    	return EFalse;	
+    	    	}
+    		else if( iDisplay && !iDisplay->Valid( aTime, aIndividual, aRejection ) )
+    			{
+    			return EFalse;
+    		    }
+    		break;      	
+    	case ERightsExecute:
+    	    if( !iExecute )
+    	    	{
+    	    	return EFalse;	
+    	        }
+    		else if( iExecute && !iExecute->Valid( aTime, aIndividual, aRejection ) )
+    			{
+    			return EFalse;	
+    			}
+    		break;      	
+    	case ERightsPrint:
+    	    if( !iPrint )
+    	    	{
+    	    	return EFalse;	
+    	    	}
+    		else if( iPrint && !iPrint->Valid( aTime, aIndividual, aRejection ) )
+    			{
+    			return EFalse;	
+    			}
+    		break;      	
+    	case ERightsExport:
+    	    if( !iExport )
+    	    	{
+    	    	return EFalse;	
+    	    	}
+    		else if( iExport && !iExport->Valid( aTime, aIndividual, aRejection ) )
+    			{
+    			return EFalse;	
+    			}
+    		break;      	
+        default:
+    	  	// No constraints are defined, top level doesn't work
+    	  	// on it's own, the permission is invalid
+    	  	if( !iPrint && !iDisplay && !iExecute && !iPrint )
+    	  		{
+    	  		return EFalse;	
+    	  		}
+			else if( iPlay && !iPlay->Valid( aTime, aIndividual, aRejection ) )
+    			{
+    			return EFalse;	
+    			}
+    		else if( iDisplay && !iDisplay->Valid( aTime, aIndividual, aRejection ) )
+    			{
+    			return EFalse;	
+    			}    			   	  		    	
+			else if( iPrint && !iPrint->Valid( aTime, aIndividual, aRejection ) )
+    			{
+    			return EFalse;	
+    			}
+    		else if( iExecute && !iExecute->Valid( aTime, aIndividual, aRejection ) )
+    			{
+    			return EFalse;	
+    			}
+    		else if( iExport && !iExport->Valid( aTime, aIndividual, aRejection ) )
+    			{
+    			return EFalse;	
+    			}
+    		break;		    			   	  
+    	}
+    return ETrue;                                  		
+    }; 
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::ConstructL
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+//
+void CDRMPermission::ConstructL()
+    {
+    iTopLevel = CDRMConstraint::NewL();
+    iPlay = CDRMConstraint::NewL();
+    iDisplay = CDRMConstraint::NewL();
+    iExecute = CDRMConstraint::NewL();
+    iPrint = CDRMConstraint::NewL();                
+    iExport = CDRMConstraint::NewL();
+    
+    iRightsObjectVersion.iVersionMain = EOma1Rights;
+    iRightsObjectVersion.iVersionSub = 0;                
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::WriteInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMPermission::WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const
+    {
+    TPtr8 output( reinterpret_cast<TUint8*>(const_cast<TInt64*>(&aWrite)), 
+                  sizeof(TInt64), sizeof(TInt64) );
+        
+    aStream.WriteL( output, sizeof(TInt64) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::ReadInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMPermission::ReadInt64L( TInt64& aRead, RReadStream& aStream )
+    {
+    TPtr8 input( reinterpret_cast<TUint8*>(&aRead), 0, sizeof(TInt64) );
+    
+    aStream.ReadL( input, sizeof(TInt64) );    
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMPermission::Merge
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMPermission::Merge( const CDRMPermission& aPermission )
+	{
+	iTopLevel->Merge( *( aPermission.iTopLevel ) );
+	iPlay->Merge( *( aPermission.iPlay ) );
+	iDisplay->Merge( *( aPermission.iDisplay ) );
+	iExecute->Merge( *( aPermission.iExecute ) );
+	iPrint->Merge( *( aPermission.iPrint ) );
+	iExport->Merge( *( aPermission.iExport ) );
+	iAvailableRights |= aPermission.iAvailableRights;
+	iInfoBits |= aPermission.iInfoBits;
+	}
+	
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DrmAsset.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "DrmAsset.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+EXPORT_C CDRMAsset* CDRMAsset::NewL(void)
+    {
+    CDRMAsset* self;
+
+    self = new (ELeave) CDRMAsset;
+    return self;
+    }
+
+EXPORT_C CDRMAsset* CDRMAsset::NewLC(void)
+    {
+    CDRMAsset* self;
+
+    self = new (ELeave) CDRMAsset;
+    CleanupStack::PushL(self);
+    return self;
+    }
+
+EXPORT_C CDRMAsset::~CDRMAsset(void)
+    {
+    delete iUid;
+    delete iParentRights;
+    }
+
+CDRMAsset::CDRMAsset(void):
+    iUid(NULL),
+    iParentRights(NULL)
+    {
+    }
+
+EXPORT_C void CDRMAsset::DuplicateL(CDRMAsset& aAsset)
+    {
+    delete iUid;
+    iUid = NULL;
+    if (aAsset.iUid != NULL)
+        {
+        iUid = aAsset.iUid->AllocL();
+        }
+        
+    delete iParentRights;
+    iParentRights = NULL;
+    if (aAsset.iParentRights != NULL)
+        {
+        iParentRights = aAsset.iParentRights->AllocL();
+        }
+        
+    iKey.Copy(aAsset.iKey);
+    iProtectedKey.Copy(aAsset.iProtectedKey);
+    iDigest.Copy(aAsset.iDigest);
+    iAuthenticationSeed.Copy(aAsset.iAuthenticationSeed);
+    iProtectedAuthSeed.Copy(aAsset.iProtectedAuthSeed);
+    }
+    
+EXPORT_C void CDRMAsset::ExternalizeL(RWriteStream& aStream)
+    {
+    if (iUid != NULL)
+        {
+        aStream.WriteInt32L(iUid->Length());
+        aStream.WriteL(*iUid);
+        }
+    else
+        {
+        aStream.WriteUint32L(0);
+        }
+        
+    if (iParentRights != NULL)
+        {
+        aStream.WriteInt32L(iParentRights->Length());
+        aStream.WriteL(*iParentRights);
+        }
+    else
+        {
+        aStream.WriteUint32L(0);
+        }
+    
+    aStream.WriteInt32L(iKey.Length());
+    aStream.WriteL(iKey);
+    aStream.WriteInt32L(iProtectedKey.Length());
+    aStream.WriteL(iProtectedKey);
+    aStream.WriteInt32L(iDigest.Length());
+    aStream.WriteL(iDigest);
+    aStream.WriteInt32L(iAuthenticationSeed.Length());
+    aStream.WriteL(iAuthenticationSeed);
+    aStream.WriteInt32L(iProtectedAuthSeed.Length());
+    aStream.WriteL(iProtectedAuthSeed);
+    }
+    
+EXPORT_C void CDRMAsset::InternalizeL(RReadStream& aStream)
+    {
+    TInt32 length;
+    
+    delete iUid;
+    iUid = NULL;
+    
+    delete iParentRights;
+    iParentRights = NULL;
+    
+    TPtr8 inRead(NULL,NULL);
+       
+    length = aStream.ReadInt32L();
+    if (length != 0)
+        {
+        iUid = HBufC8::NewMaxL(length);
+        inRead.Set(const_cast<TUint8*>(iUid->Ptr()), 0, length);
+        aStream.ReadL(inRead);
+        }
+
+    length = aStream.ReadInt32L();
+    if (length != 0)
+        {
+        iParentRights = HBufC8::NewMaxL(length);
+        inRead.Set(const_cast<TUint8*>(iParentRights->Ptr()), 0, length);
+        aStream.ReadL(inRead);       
+        }
+
+    length = aStream.ReadInt32L();
+    iKey.SetLength(0);
+    aStream.ReadL(iKey, length);
+
+    length = aStream.ReadInt32L();
+    iProtectedKey.SetLength(0);
+    aStream.ReadL(iProtectedKey, length);
+
+    length = aStream.ReadInt32L();
+    iDigest.SetLength(0);
+    aStream.ReadL(iDigest, length);
+
+    length = aStream.ReadInt32L();
+    iAuthenticationSeed.SetLength(0);
+    aStream.ReadL(iAuthenticationSeed, length);
+
+    length = aStream.ReadInt32L();
+    iProtectedAuthSeed.SetLength(0);
+    aStream.ReadL(iProtectedAuthSeed, length);
+
+    }
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DrmProtectedRoParser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1297 @@
+/*
+* Copyright (c) 2005 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of a parser for protected OMA DRM rights
+ *
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <e32math.h>
+#include <apmstd.h>
+#include <utf.h>
+#include <stringpool.h>
+#include <xml/ParserFeature.h>
+
+#ifdef _DEBUG
+#include <flogger.h>
+#endif // _DEBUG
+#include "base64.h"
+#include "DcfCommon.h"
+#include "DrmRightsParser.h"
+#include "DrmProtectedRoParser.h"
+#include "DrmRightsClient.h"
+#include "hash.h"
+#include "DRMCommon.h"
+#include "OmaCrypto.h"
+#include "CmlaCrypto.h"
+#include "DrmPermission.h"
+#include "RoapMessage.h"
+#include "DcfRep.h"
+#include "DcfEntry.h"
+#include "Oma2Dcf.h"
+
+using namespace Roap;
+using namespace Xml;
+
+// MODULE DATA STRUCTURES
+NONSHARABLE_CLASS(CDrmProtectedRoParser::CParsedProtectedRo): public CBase
+    {
+public:
+    static CParsedProtectedRo* NewL();
+    ~CParsedProtectedRo();
+
+protected:
+    CParsedProtectedRo();
+
+public:
+    TKeyTransportScheme iTransportScheme;
+    HBufC8* iKey;
+    TBool iDomainRo;
+    HBufC8* iId;
+    HBufC8* iRiUrl;
+    HBufC8* iDomainId;
+    HBufC8* iRightsIssuerId;
+    TTime iTimeStamp;
+    HBufC8* iMac;
+    HBufC8* iMacDigest;
+    };
+
+enum TElementEnum
+    {
+    EProtectedRo = 0,
+    ERo,
+    EDomainRo,
+    EId,
+    EStateful,
+    EVersion,
+    ERiId,
+    EKeyIdentifier,
+    EHash,
+    ETimeStamp,
+    EEncKey,
+    EEncryptionMethod,
+    EKeyInfo,
+    EX509SPKIHash,
+    ECipherData,
+    ECipherValue,
+    EMac,
+    ESignedInfo,
+    ECanonicalizationMethod,
+    ESignatureMethod,
+    EReference,
+    EDigestMethod,
+    EDigestValue,
+    ESignatureValue,
+    ERetreivalMethod,
+    ERoapDomainId,
+    EDomainIdentifier,
+    ERoapDomainIdentifier,
+    ERoResponse,
+    ELast,
+    };
+
+enum TParserStackState
+    {
+    ERoState,
+    ECipherValueState,
+    EDomainIdentifierState,
+    EEncryptionMethodState,
+    ERightsIssuerIdState,
+    ETimeStampState,
+    EMacValueState,
+    EMacDigestValueState,
+    EUnknownState = -1,
+    };
+
+struct TElements
+    {
+    const TText8* iString;
+    TInt iNumber;
+    };
+
+// MACROS
+#define ELEMENT_COUNT(x) static_cast<TInt>((sizeof(x) / sizeof (x[0])))
+
+#ifdef _DEBUG
+_LIT(KParseLogDir, "DRM");
+_LIT(KParseLogFile, "Parse.log");
+#define DEBUGLOG( a ) { _LIT(KDebugString, a); RFileLogger::Write( KParseLogDir(), KParseLogFile(), EFileLoggingModeAppend, KDebugString() ); }
+#define DEBUGLOGHEX( ptr, len ) RFileLogger::HexDump( KParseLogDir(), KParseLogFile(), EFileLoggingModeAppend, _S(""), _S(""), ptr, len );
+#else
+#define DEBUGLOG( a )
+#define DEBUGLOGHEX( ptr, len )
+#endif // _DEBUG
+
+// LOCAL CONSTANTS AND MACROS
+const TInt KParserChunkSize = 512;
+const TInt KMaxElementNesting = 24;
+const TInt KMaxElementLen = 80;
+
+_LIT8(KXmlParserMimeType, "text/xml");
+_LIT8(KIdAttr, "id");
+_LIT8(KDomainRoAttr, "domainRO");
+_LIT8(KRiUrlAttr, "riURL");
+_LIT8(KAlgorithmAttr, "Algorithm");
+_LIT8(KProtectedRoElement, "protectedRO");
+_LIT8(KRoapPrefix, "roap:");
+_LIT8(KStartElementStart, "<");
+_LIT8(KEndElementStart, "</");
+_LIT8(KRoElement, "roap:ro");
+_LIT8( KElementEnd, ">" );
+_LIT8(KQualifiedProtectedRo, "roap:protectedRO");
+_LIT8(KSignedInfoElement, "ds:SignedInfo");
+_LIT8(KRoapXmlNs, " xmlns:roap=\"urn:oma:bac:dldrm:roap-1.0\"");
+_LIT8(KRoapXmlNsUri, "urn:oma:bac:dldrm:roap-1.0");
+_LIT8(KMacStart, "<mac");
+
+static const TElements KElements[] =
+    {
+        {
+        _S8("roResponse"), ERoResponse
+        },
+        {
+        _S8("protectedRo"), EProtectedRo
+        },
+        {
+        _S8("ro"), ERo
+        },
+        {
+        _S8("domainRo"), EDomainRo
+        },
+        {
+        _S8("id"), EId
+        },
+        {
+        _S8("stateful"), EStateful
+        },
+        {
+        _S8("version"), EVersion
+        },
+        {
+        _S8("riID"), ERiId
+        },
+        {
+        _S8("keyIdentifier"), EKeyIdentifier
+        },
+        {
+        _S8("hash"), EHash
+        },
+        {
+        _S8("timeStamp"), ETimeStamp
+        },
+        {
+        _S8("encKey"), EEncKey
+        },
+        {
+        _S8("EncryptionMethod"), EEncryptionMethod
+        },
+        {
+        _S8("KeyInfo"), EKeyInfo
+        },
+        {
+        _S8("roap:X509SPKIHash"), EX509SPKIHash
+        },
+        {
+        _S8("CipherData"), ECipherData
+        },
+        {
+        _S8("CipherValue"), ECipherValue
+        },
+        {
+        _S8("mac"), EMac
+        },
+        {
+        _S8("SignedInfo"), ESignedInfo
+        },
+        {
+        _S8("CanonicalizationMethod"), ECanonicalizationMethod
+        },
+        {
+        _S8("SignatureMethod"), ESignatureMethod
+        },
+        {
+        _S8("Reference"), EReference
+        },
+        {
+        _S8("DigestMethod"), EDigestMethod
+        },
+        {
+        _S8("DigestValue"), EDigestValue
+        },
+        {
+        _S8("SignatureValue"), ESignatureValue
+        },
+        {
+        _S8("RetreivalMethod"), ERetreivalMethod
+        },
+        {
+        _S8("domainID"), ERoapDomainId
+        },
+        {
+        _S8("DomainIdentifier"), EDomainIdentifier
+        },
+        {
+        _S8("roap:DomainIdentifier"), ERoapDomainIdentifier
+        }
+    };
+
+struct TStackState
+    {
+    TParserStackState iState;
+    TElementEnum iStack[KMaxElementNesting];
+    };
+
+static const TStackState KParserStackStates[] =
+    {
+        {
+        ERightsIssuerIdState,
+            {
+            EHash, EKeyIdentifier, ERiId, ERo, ELast
+            }
+        },
+        {
+        EDomainIdentifierState,
+            {
+            ERoapDomainId, EKeyInfo, EEncKey, ERo, ELast
+            }
+        },
+        {
+        EDomainIdentifierState,
+            {
+            EDomainIdentifier, EKeyInfo, EEncKey, ERo, ELast
+            }
+        },
+        {
+        EDomainIdentifierState,
+            {
+            ERoapDomainIdentifier, EKeyInfo, EEncKey, ERo, ELast
+            }
+        },
+        {
+        ECipherValueState,
+            {
+            ECipherValue, ECipherData, EEncKey, ERo, ELast
+            }
+        },
+        {
+        EEncryptionMethodState,
+            {
+            EEncryptionMethod, EEncKey, ERo, ELast
+            }
+        },
+        {
+        ETimeStampState,
+            {
+            ETimeStamp, ERo, ELast
+            }
+        },
+        {
+        EMacValueState,
+            {
+            ESignatureValue, EMac, ELast
+            }
+        },
+        {
+        EMacDigestValueState,
+            {
+            EDigestValue, EReference, ESignedInfo, EMac, ELast
+            }
+        },
+        {
+        ERoState,
+            {
+            ERo, ELast
+            }
+        }
+    };
+
+// LOCAL FUNCTION PROTOTYPES
+TTime Iso8601ToTime(TDesC8& aTimeString);
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// Iso8601ToTime
+// -----------------------------------------------------------------------------
+//
+TTime Iso8601ToTime(TDesC8& aTimeString)
+    {
+    TLex8 lex;
+    TInt year = 0;
+    TInt month = 0;
+    TInt day = 0;
+    TInt hour = 0;
+    TInt minute = 0;
+    TInt second = 0;
+    TTime r = Time::NullTTime();
+    TLocale l;
+    TTimeIntervalSeconds offset(l.UniversalTimeOffset());
+
+    if (aTimeString.Length() > 0)
+        {
+        lex = aTimeString;
+        lex.Val(year);
+        lex.Inc();
+        lex.Val(month);
+        lex.Inc();
+        lex.Val(day);
+        lex.Inc();
+        lex.Val(hour);
+        lex.Inc();
+        lex.Val(minute);
+        lex.Inc();
+        lex.Val(second);
+        r = TTime(TDateTime(year, static_cast<TMonth>(month - 1), day - 1,
+                hour, minute, second, 0));
+        if (lex.Get() != 'Z')
+            {
+            r += offset;
+            }
+        }
+    return r;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRo::NewL
+// Allocate a new protected RO object
+// -----------------------------------------------------------------------------
+//
+CDrmProtectedRoParser::CParsedProtectedRo* CDrmProtectedRoParser::CParsedProtectedRo::NewL()
+    {
+    CParsedProtectedRo* self = new(ELeave) CParsedProtectedRo;
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CParsedProtectedRo::~CParsedProtectedRo
+// Release all data
+// -----------------------------------------------------------------------------
+//
+CDrmProtectedRoParser::CParsedProtectedRo::~CParsedProtectedRo()
+    {
+    delete iKey;
+    delete iId;
+    delete iRiUrl;
+    delete iDomainId;
+    delete iRightsIssuerId;
+    delete iMac;
+    delete iMacDigest;
+    }
+
+// -----------------------------------------------------------------------------
+// CParsedProtectedRo::CParsedProtectedRo
+// Initialize all member data
+// -----------------------------------------------------------------------------
+//
+CDrmProtectedRoParser::CParsedProtectedRo::CParsedProtectedRo() :
+    iTransportScheme(EOma), iKey(NULL), iDomainRo(EFalse), iId(NULL),
+            iRiUrl(NULL), iDomainId(NULL), iRightsIssuerId(NULL), iMac(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::CDrmProtectedRoParser
+// Reset all member variables
+// -----------------------------------------------------------------------------
+//
+CDrmProtectedRoParser::CDrmProtectedRoParser() :
+    iParser(NULL), iRights(NULL), iContent(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::ConstructL
+// Initialize the string pool elements
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::ConstructL()
+    {
+    iParser = CParser::NewL(KXmlParserMimeType, *this);
+    for (TInt i = 0; i < ELEMENT_COUNT(KElements); i++)
+        {
+        TPtrC8 ptr(KElements[i].iString,
+                User::StringLength(KElements[i].iString));
+        iElements[KElements[i].iNumber] = iParser->StringPool().OpenStringL(ptr);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDrmProtectedRoParser* CDrmProtectedRoParser::NewL()
+    {
+    CDrmProtectedRoParser* self = new(ELeave) CDrmProtectedRoParser;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::~CDrmProtectedRoParser
+// Release the allocated strings
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDrmProtectedRoParser::~CDrmProtectedRoParser()
+    {
+    for (TInt i = 0; i < ELEMENT_COUNT(KElements); i++)
+        {
+        iElements[KElements[i].iNumber].Close();
+        }
+    delete iParser;
+    delete iRights;
+    delete iContent;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::ParseL
+// Parses one <protectedRo> element
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::ParseL(const TDesC8& aProtectedRo,
+        CParsedProtectedRo*& aResultRights)
+    {
+    TInt i( 0 );
+
+    iElementStackDepth = 0;
+    delete iRights;
+    delete iContent;
+    iContent = NULL;
+    iRights = NULL;
+    iRights = CParsedProtectedRo::NewL();
+    iParser->ParseBeginL();
+
+    i = aProtectedRo.Find( KRoapXmlNsUri );
+
+    if ( i == KErrNotFound )
+        {
+        // Feed in the ROAP XML namespace declaration
+        i = aProtectedRo.Find(KProtectedRoElement);
+        if ( i == KErrNotFound )
+            {
+            User::Leave(KErrCorrupt);
+            }
+        i += KProtectedRoElement().Length();
+        iParser->ParseL( aProtectedRo.Left( i ) );
+        iParser->ParseL( KRoapXmlNs() );
+        }
+    else
+        {
+        i = 0;
+        }
+
+    while ( i < aProtectedRo.Length() )
+        {
+        TInt n( Min( aProtectedRo.Length() - i, KParserChunkSize ) );
+        iParser->ParseL( aProtectedRo.Mid( i, n ) );
+        i += n;
+        }
+    iParser->ParseEndL();
+    aResultRights = iRights;
+    iRights = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::GetRiUrlL
+// Parse the RO and return the RI URL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* CDrmProtectedRoParser::GetRiUrlL(
+        const TDesC8& aProtectedRo)
+    {
+    TInt i( 0 );
+    HBufC8* r( NULL );
+
+    iElementStackDepth = 0;
+    delete iRights;
+    delete iContent;
+    iRights = NULL;
+    iContent = NULL;
+    iRights = CParsedProtectedRo::NewL();
+    iParser->ParseBeginL();
+    while (i < aProtectedRo.Length())
+        {
+        TInt n( Min( aProtectedRo.Length() - i, KParserChunkSize ) );
+        iParser->ParseL( aProtectedRo.Mid( i, n ) );
+        i += n;
+        }
+    iParser->ParseEndL();
+    if ( iRights->iRiUrl )
+        {
+        r = iRights->iRiUrl->AllocL();
+        }
+    delete iRights;
+    iRights = NULL;
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::GetRiUrlL
+// Parse the RO and return the RI ID
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* CDrmProtectedRoParser::GetRiIdL(
+        const TDesC8& aProtectedRo)
+    {
+    HBufC8* r = NULL;
+
+    iElementStackDepth = 0;
+    delete iRights;
+    delete iContent;
+    iRights = NULL;
+    iContent = NULL;
+    iRights = CParsedProtectedRo::NewL();
+    iParser->ParseBeginL();
+    TInt i( 0 );
+    while (i < aProtectedRo.Length())
+        {
+        TInt n( Min( aProtectedRo.Length() - i, KParserChunkSize ) );
+        iParser->ParseL(aProtectedRo.Mid(i, n));
+        i += n;
+        }
+    iParser->ParseEndL();
+    if ( iRights->iRightsIssuerId )
+        {
+        r = iRights->iRightsIssuerId->AllocL();
+        }
+    delete iRights;
+    iRights = NULL;
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::GetDomainIdL
+// Parse the RO and return the domain ID
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* CDrmProtectedRoParser::GetDomainIdL(
+        const TDesC8& aProtectedRo)
+    {
+    HBufC8* r = NULL;
+
+    iElementStackDepth = 0;
+    delete iRights;
+    iRights = NULL;
+    delete iContent;
+    iContent = NULL;
+    iRights = CParsedProtectedRo::NewL();
+    iParser->ParseBeginL();
+    TInt i( 0 );
+    while (i < aProtectedRo.Length())
+        {
+        TInt n( Min(aProtectedRo.Length() - i, KParserChunkSize) );
+        iParser->ParseL(aProtectedRo.Mid(i, n));
+        i += n;
+        }
+    iParser->ParseEndL();
+    if ( iRights->iDomainId )
+        {
+        r = iRights->iDomainId->AllocL();
+        }
+    delete iRights;
+    iRights = NULL;
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::ParseAndStoreL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDrmProtectedRoParser::ParseAndStoreL(
+        const TDesC8& aRightsObject,
+        RPointerArray<CDRMRights>& aResultRights)
+    {
+    RDRMRightsClient client;
+    CDrmRightsParser* parser = NULL;
+    CDRMRights* rights = NULL;
+    CParsedProtectedRo* parsedRo = NULL;
+    TDRMUniqueID id = 0;
+    HBufC8 *cid = NULL;
+    TPtr8 ptr(0, 0);
+    TBool domain = EFalse;
+    TPtrC8 riId(0, 0);
+    TInt start = 0;
+    TInt end = 0;
+    TInt roStart = 0;
+    TInt roEnd = 0;
+    TInt signedInfoStart = 0;
+    TInt signedInfoEnd = 0;
+    TInt n( 0 );
+    TInt r( 0 );
+    TBool inCache = EFalse;
+    CSHA1* sha1 = NULL;
+    TBool integrityCheck = ETrue;
+    HBufC8* roWithNs = NULL;
+    TPtr8 roWithNsPtr(NULL, NULL);
+
+    User::LeaveIfError(client.Connect());
+    CleanupClosePushL(client);
+
+    // Loop through the complete roResponse and find all embedded protected
+    // rights objects
+    while (GetElementStartEnd(KProtectedRoElement, aRightsObject, start, end))
+        {
+        TPtrC8 protectedRo = aRightsObject.Mid(start, end - start);
+        if (GetElementStartEnd(KRoElement, protectedRo, roStart, roEnd) == EFalse)
+            {
+            User::Leave(KErrCorrupt);
+            }
+        TPtrC8 ro = protectedRo.Mid(roStart, roEnd - roStart);
+
+        ParseL(protectedRo, parsedRo);
+        User::LeaveIfNull(parsedRo);
+        CleanupStack::PushL(parsedRo);
+
+        parser = CDrmRightsParser::NewL();
+        CleanupStack::PushL(parser);
+        parser->ParseL(protectedRo, aResultRights);
+        CleanupStack::PopAndDestroy( parser );
+
+        //////////////////////////
+        // Replay protection
+        //////////////////////////
+
+        if (parsedRo->iTimeStamp == Time::NullTTime())
+            {
+            User::LeaveIfError(client.IsInCache(*parsedRo->iId, inCache));
+            if (inCache)
+                {
+                User::Leave(KErrAlreadyExists);
+                }
+            }
+        else
+            {
+            User::LeaveIfError(client.IsInCache(*parsedRo->iId, parsedRo->iTimeStamp, inCache));
+            if (inCache)
+                {
+                User::Leave(KErrAlreadyExists);
+                }
+            }
+
+        ///////////////////////////////////////////////////////
+        // Unwrap MAC and REK
+        // The plain keys are stored on the server side session
+        ///////////////////////////////////////////////////////
+        if (parsedRo->iDomainRo)
+            {
+            User::LeaveIfError( client.UnwrapMacAndRek(*parsedRo->iKey,
+                            parsedRo->iTransportScheme,
+                            *parsedRo->iRightsIssuerId,
+                            *parsedRo->iDomainId) );
+            }
+        else
+            {
+            User::LeaveIfError( client.UnwrapMacAndRek(*parsedRo->iKey,
+                            parsedRo->iTransportScheme,
+                            *parsedRo->iRightsIssuerId,
+                            KNullDesC8) );
+            }
+
+        //////////////////////////
+        // Validate digest and MAC
+        //////////////////////////
+        roWithNs = AddRoapNamespaceL(ro);
+        if (roWithNs)
+            {
+            CleanupStack::PushL(roWithNs);
+            roWithNsPtr.Set(roWithNs->Des());
+            }
+
+        // Validate RO digest
+        sha1 = CSHA1::NewL();
+        if (roWithNs)
+            {
+            DEBUGLOGHEX( roWithNsPtr.Ptr(), roWithNsPtr.Length() );
+            sha1->Update(roWithNsPtr);
+            CleanupStack::PopAndDestroy(roWithNs);
+            }
+        else
+            {
+            DEBUGLOGHEX( ro.Ptr(), ro.Length() );
+            sha1->Update(ro);
+            }
+
+        CleanupStack::PushL(sha1);
+        HBufC8* calculatedHash( sha1->Final().AllocL() );
+        CleanupStack::PopAndDestroy( sha1 );
+        sha1 = NULL;
+        CleanupStack::PushL( calculatedHash );
+
+        if (calculatedHash->Compare(*parsedRo->iMacDigest) == KErrNone)
+            {
+            // Digest OK -> now verify the MAC
+            signedInfoStart = protectedRo.Find(KMacStart());
+
+            if (signedInfoStart < KErrNone)
+                {
+                integrityCheck = EFalse;
+                r = KErrCorrupt;
+                }
+
+            if (integrityCheck && GetElementStartEnd(KSignedInfoElement, protectedRo, signedInfoStart, signedInfoEnd) == EFalse)
+                {
+                integrityCheck = EFalse;
+                r = KErrCorrupt;
+                }
+
+            if(integrityCheck)
+                {
+                TPtrC8 signedInfo = protectedRo.Mid(signedInfoStart, signedInfoEnd - signedInfoStart);
+                r = client.VerifyMacL(signedInfo, *parsedRo->iMac);
+
+                if (r == KErrNone)
+                    {
+                    // MAC validation OK
+                    // If we parsed a domain RO, store it in its original form as well
+                    if (parsedRo->iDomainRo)
+                        {
+                        HBufC8* protRoWithNs = NULL;
+                        protRoWithNs = AddRoapNamespaceL(protectedRo);
+                        if(protRoWithNs)
+                            {
+                            client.AddDomainRO(*parsedRo->iId, *protRoWithNs);
+                            delete protRoWithNs;
+                            protRoWithNs = NULL;
+                            }
+                        else
+                            {
+                            client.AddDomainRO(*parsedRo->iId, protectedRo);
+                            }
+                        }
+
+                    // Add RO to replay cache
+                    if (parsedRo->iTimeStamp == Time::NullTTime())
+                        {
+                        User::LeaveIfError(client.AddToCache(*parsedRo->iId));
+                        }
+                    else
+                        {
+                        User::LeaveIfError(client.AddToCache(*parsedRo->iId, parsedRo->iTimeStamp));
+                        }
+                    }
+                else
+                    {
+                    integrityCheck = EFalse;
+                    }
+                }
+            }
+        else
+            {
+            integrityCheck = EFalse;
+            r = KErrCorrupt;
+            }
+        CleanupStack::PopAndDestroy( calculatedHash );
+        calculatedHash = NULL;
+
+        if ( integrityCheck && !r )
+            {
+            // Only add the rigths which were parsed in this loop
+    
+            for ( TInt i( n ); i < aResultRights.Count(); i++)
+                {
+                cid = NULL;
+                rights = aResultRights[i];
+                rights->GetContentURI(cid);
+                CleanupStack::PushL(cid);
+                rights->GetPermission().iOriginalInsertTime =
+                parsedRo->iTimeStamp;
+                rights->GetPermission().iRoID = (*parsedRo->iId).AllocL();
+                rights->GetPermission().iRiId.Copy(*parsedRo->iRightsIssuerId);
+                if (parsedRo->iDomainRo)
+                    {
+                    domain = ETrue;
+                    rights->GetPermission().iDomainID =
+                    parsedRo->iDomainId->AllocL();
+                    }
+                if (parsedRo->iRightsIssuerId)
+                    {
+                    riId.Set(*parsedRo->iRightsIssuerId);
+                    }
+                if (parsedRo->iTransportScheme == EOma)
+                    {
+                    rights->GetPermission().iRightsObjectVersion.iVersionMain =
+                    EOma2Rights;
+                    }
+                else
+                    {
+                    rights->GetPermission().iRightsObjectVersion.iVersionMain =
+                    ECmlaRights;
+                    }
+                r = client.AddProtectedRecord( rights->GetAsset().iProtectedKey,
+                        domain, rights->GetPermission(),
+                        *cid, id );
+                if (!r)
+                    {
+                    if (rights->GetAsset().iProtectedAuthSeed.Length()> 0)
+                        {
+                        r = client.SetAuthenticationSeed(*cid,
+                                rights->GetAsset().iProtectedAuthSeed);
+                        }
+                    }
+
+                User::LeaveIfError(r);
+                rights->SetLocalID(id);
+                CleanupStack::PopAndDestroy(cid);
+                }
+            }
+        else
+            {
+            User::Leave(KErrCorrupt);
+            }
+
+        start = end;
+        n = aResultRights.Count();
+        CleanupStack::PopAndDestroy(parsedRo);
+        parsedRo = NULL;
+        }
+    CleanupStack::PopAndDestroy( &client );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnStartDocumentL
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnStartDocumentL(
+        const RDocumentParameters& /*aDocParam*/, TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnEndDocumentL
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnEndDocumentL(TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnStartElementL
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnStartElementL(const RTagInfo& aElement,
+        const RAttributeArray& aAttributes, TInt /*aErrorCode*/)
+    {
+    HBufC8* b= NULL;
+
+    if (iContent)
+        {
+        delete iContent;
+        iContent = NULL;
+        iContent = HBufC8::NewL(0);
+        }
+
+    for (TInt i = 0; i < KMaxElementCount; i++)
+        {
+        if (aElement.LocalName() == iElements[i])
+            {
+            iElementStack[iElementStackDepth] = static_cast<TElementEnum>(i);
+            iElementStackDepth++;
+            if (iElementStackDepth == KMaxElementNesting)
+                {
+                User::Leave(EXmlUnexpectedState);
+                }
+            TInt state( MatchStackState() );
+            if (state == ERoState)
+                {
+                _LIT8( KTrue, "true" );
+                iRights->iId = GetAttributeValueL(aAttributes, KIdAttr);
+                iRights->iRiUrl = GetAttributeValueL(aAttributes, KRiUrlAttr);
+                b = GetAttributeValueL(aAttributes, KDomainRoAttr);
+                if ( b && b->Compare( KTrue() ) == 0 )
+                    {
+                    iRights->iDomainRo = ETrue;
+                    }
+                else
+                    {
+                    iRights->iDomainRo = EFalse;
+                    }
+                delete b;
+                }
+            else
+                if (state == EEncryptionMethodState)
+                    {
+                    b = GetAttributeValueL(aAttributes, KAlgorithmAttr);
+                    if ( b )
+                        {
+                        iRights->iTransportScheme
+                                = CmlaCrypto::AlgorithmIdToTransportScheme(*b);
+                        delete b;
+                        }
+                    }
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnEndElementL
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnEndElementL(const RTagInfo& aElement, TInt /*aErrorCode*/)
+    {
+    for (TInt i = 0; i < KMaxElementCount; i++)
+        {
+        if (aElement.LocalName() == iElements[i])
+            {
+            switch (MatchStackState())
+                {
+                case ECipherValueState:
+                    iRights->iKey = Base64DecodeL(iContent->Des());
+                    break;
+                case EDomainIdentifierState:
+                    iRights->iDomainId = iContent->AllocL();
+                    break;
+                case ERightsIssuerIdState:
+                    iRights->iRightsIssuerId = Base64DecodeL(iContent->Des());
+                    break;
+                case ETimeStampState:
+                    iRights->iTimeStamp = Iso8601ToTime(*iContent);
+                    break;
+                case EMacValueState:
+                    iRights->iMac = Base64DecodeL(iContent->Des());
+                    break;
+                case EMacDigestValueState:
+                    iRights->iMacDigest = Base64DecodeL(iContent->Des());
+                    break;
+                }
+            iElementStackDepth--;
+            if (iElementStackDepth < 0)
+                {
+                User::Leave(EXmlUnexpectedState);
+                }
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnContentL
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnContentL(const TDesC8& aBytes, TInt /*aErrorCode*/)
+    {
+    if ( !iContent )
+        {
+        iContent = HBufC8::NewL(aBytes.Size());
+        *iContent = aBytes;
+        }
+    else
+        {
+        iContent = iContent->ReAllocL(iContent->Size() + aBytes.Size());
+        TPtr8 c(iContent->Des());
+        c.Append(aBytes);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnStartPrefixMappingL
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnStartPrefixMappingL(const RString& /*aPrefix*/,
+        const RString& /*aUri*/, TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnEndPrefixMappingL
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnEndPrefixMappingL(const RString& /*aPrefix*/,
+        TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnIgnorableWhiteSpaceL
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnIgnorableWhiteSpaceL(const TDesC8& /*aBytes*/,
+        TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnSkippedEntityL
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnSkippedEntityL(const RString& /*aName*/, TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnProcessingInstructionL
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnProcessingInstructionL(
+        const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnOutOfData
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnOutOfData()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::OnError
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::OnError(TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::GetExtendedInterface
+// -----------------------------------------------------------------------------
+//
+TAny* CDrmProtectedRoParser::GetExtendedInterface(const TInt32 /*aUid*/)
+    {
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::MatchStackState
+// -----------------------------------------------------------------------------
+//
+TInt CDrmProtectedRoParser::MatchStackState()
+    {
+    TInt i( 0 );
+    TInt j( 0 );
+    TInt k( 0 );
+    TParserStackState r = EUnknownState;
+
+    for (i = 0; r == EUnknownState && i < ELEMENT_COUNT(KParserStackStates); i++)
+        {
+        for (j = iElementStackDepth - 1, k = 0; j > 0
+                && KParserStackStates[i].iStack[k] != ELast; j--, k++)
+            {
+            if (iElementStack[j] != KParserStackStates[i].iStack[k])
+                {
+                break;
+                }
+            }
+        if ((j == 0 && iElementStack[j] == KParserStackStates[i].iStack[k])
+                || KParserStackStates[i].iStack[k] == ELast)
+            {
+            r = KParserStackStates[i].iState;
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::GetAttributeValueL
+// Allocate the attribute value as a buffer if it is found, otherwise it's NULL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDrmProtectedRoParser::GetAttributeValueL(
+        const RAttributeArray& aAttrList, const TDesC8& aAttrName)
+    {
+    HBufC8* r( NULL );
+
+    for ( TInt i(0); !r && i < aAttrList.Count(); i++ )
+        {
+        const RAttribute& a( aAttrList[i] );
+        if ( a.Attribute().LocalName().DesC().Compare( aAttrName ) == 0 )
+            {
+            r = a.Value().DesC().AllocL();
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::GetElementStartEnd
+// Search for the element as a string
+// -----------------------------------------------------------------------------
+//
+TBool CDrmProtectedRoParser::GetElementStartEnd(const TDesC8& aElement,
+        const TDesC8& aData, TInt& aStart, TInt& aEnd)
+    {
+    TInt i( 0 );
+    TInt j( 0 );
+    TBool r( EFalse );
+    TBuf8<KMaxElementLen> element;
+
+    DEBUGLOG( "CDrmProtectedRoParser::GetElementStartEnd ->" );
+
+    DEBUGLOG( "aElement" );
+    DEBUGLOGHEX( aElement.Ptr(), aElement.Length() );
+    DEBUGLOG( "aData" );
+    DEBUGLOGHEX( aData.Ptr(), aData.Length() );
+    element.Copy(KStartElementStart);
+    element.Append(aElement);
+    // Find the start tag, which has to end with a "<" or whitespace
+    i = aData.Mid(aStart).Find(element);
+
+    if (i == KErrNotFound)
+        {
+        // try the same thing with ROAP prefix
+        element.Copy(KStartElementStart);
+        element.Append(KRoapPrefix);
+        element.Append(aElement);
+        i = aData.Mid(aStart).Find(element);
+        }
+
+    while (i != KErrNotFound && !(aData[aStart + i + element.Length()] == '>' || aData[aStart + i + element.Length()] <= ' '))
+        {
+        aStart += i;
+        i = aData.Mid(aStart + element.Length() + 1).Find(element);
+        }
+
+    if (i != KErrNotFound)
+        {
+        aStart += i;
+        i = aStart;
+        element.Copy(KEndElementStart);
+        element.Append(aElement);
+        element.Append(KElementEnd);
+        j = aData.Mid(i + 1).Find(element);
+        if (j == KErrNotFound)
+            {
+            // try the same thing with ROAP prefix
+            element.Copy(KEndElementStart);
+            element.Append(KRoapPrefix);
+            element.Append(aElement);
+            element.Append(KElementEnd);
+            j = aData.Mid(i + 1).Find(element);
+            }
+        if (j != KErrNotFound)
+            {
+            aEnd = i + 1 + j + element.Length();
+            r = ETrue;
+            }
+        }
+#ifdef _DEBUG
+    if ( r )
+        {
+        TPtrC8 extracted( aData.Mid( aStart, aEnd - aStart ) );
+        DEBUGLOG( "got element: " );
+        DEBUGLOGHEX( extracted.Ptr(), extracted.Length() );
+        }
+#endif
+    DEBUGLOG( "-> CDrmProtectedRoParser::GetElementStartEnd" );
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::HandleUnregisteredDomainRoL
+// Embed the domain RO into all matching DCF files
+// -----------------------------------------------------------------------------
+//
+void CDrmProtectedRoParser::HandleUnregisteredDomainRoL(
+        const TDesC8& aContentId, const TDesC8& aDomainRoData,
+        CParsedProtectedRo* /*aDomainRo*/)
+    {
+    CDcfRep* rep( NULL );
+    COma2Dcf* dcf( NULL );
+    CDcfEntry* entry( NULL );
+    RFile file;
+    RFs fs;
+    TBool exists( EFalse );
+    TInt r( KErrNone );
+
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    rep = CDcfRep::NewL();
+    CleanupStack::PushL( rep );
+    TRAP( r, rep->OrderListL( aContentId ) );
+    if ( r == KErrNone )
+        {
+        entry = rep->NextL();
+        }
+    while ( r == KErrNone && entry )
+        {
+        CleanupStack::PushL( entry );
+
+        r = file.Open( fs, entry->FileName(), EFileWrite
+                | EFileShareReadersOrWriters );
+        if ( r == KErrInUse )
+            {
+            r = file.Open(fs, entry->FileName(), EFileWrite | EFileShareAny);
+            }
+
+        if ( r == KErrNone )
+            {
+            CleanupClosePushL( file );
+            dcf = COma2Dcf::NewL( file );
+            CleanupStack::PushL( dcf );
+            for ( TInt i = 0; !exists && i < dcf->iRightsObjects.Count(); i++ )
+                {
+                if ( dcf->iRightsObjects[i]->Compare(aDomainRoData) == 0 )
+                    {
+                    exists = ETrue;
+                    }
+                }
+            if ( !exists )
+                {
+                dcf->iRightsObjects.Append( aDomainRoData.AllocL() );
+                dcf->SetRightsObjectsL( dcf->iRightsObjects );
+                }
+            CleanupStack::PopAndDestroy( dcf );
+            CleanupStack::PopAndDestroy( &file );
+            }
+        CleanupStack::PopAndDestroy( entry );
+        entry = rep->NextL();
+        }
+    CleanupStack::PopAndDestroy( rep );
+    CleanupStack::PopAndDestroy( &fs );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmProtectedRoParser::AddRoapNamespaceL
+// Add ROAP namespace declaration if needed
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDrmProtectedRoParser::AddRoapNamespaceL(TDesC8& aProtectedRo) const
+    {
+    TInt index = 0;
+    HBufC8* roWithNs= NULL;
+    TPtr8 roWithNsPtr(NULL, NULL);
+
+    if (aProtectedRo.Find(KRoapXmlNsUri) == KErrNotFound)
+        {
+        roWithNs = HBufC8::NewLC(aProtectedRo.Length() + KRoapXmlNs().Length());
+        roWithNsPtr.Set(roWithNs->Des());
+        index = aProtectedRo.Find(KQualifiedProtectedRo);
+        if (index == KErrNotFound)
+            {
+            index = aProtectedRo.Find(KRoElement);
+            if (index == KErrNotFound)
+                {
+                User::Leave(KErrCorrupt);
+                }
+            index += KRoElement().Length();
+            }
+        else
+            {
+            index += KQualifiedProtectedRo().Length();
+            }
+        roWithNsPtr.Copy(aProtectedRo.Left(index));
+        roWithNsPtr.Append(KRoapXmlNs());
+        roWithNsPtr.Append(aProtectedRo.Right(aProtectedRo.Length() - index));
+        CleanupStack::Pop(roWithNs);
+        }
+    return roWithNs;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DrmRel1_0StringDict00.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,223 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of a parser for protected OMA DRM rights
+*
+*/
+
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+#include <xml/xmlframeworkerrors.h>
+
+#include <xml/plugins/dictionarycodepage.h>
+#include "DrmRel1_0StringDict00.h"
+#include "DrmRel1_0StringDict00TagTable.h"
+#include "DrmRel1_0StringDict00AttributeTable.h"
+#include "DrmRel1_0StringDict00AttributeValueTable.h"
+
+using namespace Xml;
+
+MStringDictionary* CDrmRel1_0StringDict00::NewL(TAny* aStringPool)
+	{
+	CDrmRel1_0StringDict00* self = new(ELeave) CDrmRel1_0StringDict00(
+        reinterpret_cast<RStringPool*>(aStringPool));
+	CleanupStack::PushL(self);
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return (static_cast<MStringDictionary*>(self));
+	}
+
+
+
+CDrmRel1_0StringDict00::CDrmRel1_0StringDict00(RStringPool* aStringPool)
+:	iStringPool(*aStringPool),
+	iCodePage(0)
+	{
+	// do nothing;
+	}
+
+
+void CDrmRel1_0StringDict00::ConstructL()
+	{
+	// we don't own this stringpool
+	iStringPool.OpenL(DrmRel1_0StringDict00TagTable::Table);
+	iStringPool.OpenL(DrmRel1_0StringDict00AttributeTable::Table);
+	iStringPool.OpenL(DrmRel1_0StringDict00AttributeValueTable::Table);
+
+	iCodepage00Table = CDictionaryCodePage::NewL(
+		&DrmRel1_0StringDict00TagTable::Table, 
+		&DrmRel1_0StringDict00AttributeTable::Table, 
+		&DrmRel1_0StringDict00AttributeValueTable::Table, 
+		0); // codepage
+
+	// Construct the correlation mapping
+	iCodepage00Table->ConstructIndexMappingL(iTagCodePage00,
+        CDictionaryCodePage::EStringTypeElement);
+	iCodepage00Table->ConstructIndexMappingL(iAttributeCodePage00,
+        CDictionaryCodePage::EStringTypeAttribute);
+	iCodepage00Table->ConstructIndexMappingL(iAttributeValueCodePage00,
+        CDictionaryCodePage::EStringTypeAttributeValue);
+	}
+
+void CDrmRel1_0StringDict00::Release()
+	{
+	delete (this);
+	}
+
+CDrmRel1_0StringDict00::~CDrmRel1_0StringDict00()
+	{
+	if (iCodepage00Table)
+		{
+		delete iCodepage00Table;
+		}
+	}
+
+
+
+void CDrmRel1_0StringDict00::ElementL(TInt aToken, RString& aElement) const
+	{
+	TInt index = iCodepage00Table->StringPoolIndexFromToken(
+	    aToken, CDictionaryCodePage::EStringTypeElement);
+
+	if (index == KErrXmlStringPoolTableNotFound)
+		{
+		User::Leave(KErrXmlUnsupportedElement);
+		}
+
+	// when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable()
+	aElement = iStringPool.String(
+		index,
+		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
+	}
+
+
+
+void CDrmRel1_0StringDict00::AttributeL(TInt aToken, RString& aAttribute) const
+	{
+	TInt index = iCodepage00Table->StringPoolIndexFromToken(
+		aToken, CDictionaryCodePage::EStringTypeAttribute);
+
+	if (index == KErrXmlStringPoolTableNotFound)
+		{
+		User::Leave(KErrXmlUnsupportedAttribute);
+		}
+
+	// when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable()
+	aAttribute = iStringPool.String(
+		index,
+		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeAttribute)));
+	};
+
+
+
+void CDrmRel1_0StringDict00::AttributeValuePairL(TInt aToken, RString& aAttribute, RString& aValue) const
+	{
+	AttributeL(aToken, aAttribute);
+	AttributeValueL(aToken, aValue);
+	};
+	
+
+
+void CDrmRel1_0StringDict00::AttributeValueL(TInt aToken, RString& aValue) const
+	{
+	TInt index = iCodepage00Table->StringPoolIndexFromToken(
+					aToken, CDictionaryCodePage::EStringTypeAttributeValue);
+
+	if (index == KErrXmlStringPoolTableNotFound)
+		{
+		User::Leave(KErrXmlUnsupportedAttributeValue);
+		}
+
+	// when we have multiple codepages per string dictionary we'd do something like iCodepageTable[n]->StringTable()
+	aValue = iStringPool.String(
+		index,
+		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeAttributeValue)));
+	};
+
+TBool CDrmRel1_0StringDict00::CompareThisDictionary(const RString& aDictionaryDescription) const
+	{
+	// If this string dictionary has many codepages then all these comparisons should go here.
+	// Remember, the string dictionary loads up all the RStringTables into its RStringPool
+	// on construction. So if the comparison fails we do not have it.
+	return (
+		(aDictionaryDescription == iStringPool.String(
+            DrmRel1_0StringDict00TagTable::EUri, DrmRel1_0StringDict00TagTable::Table))		||
+		(aDictionaryDescription == iStringPool.String(
+            DrmRel1_0StringDict00TagTable::EPublicId, DrmRel1_0StringDict00TagTable::Table))||
+		(aDictionaryDescription == iStringPool.String(
+            DrmRel1_0StringDict00TagTable::EFormalPublicId, DrmRel1_0StringDict00TagTable::Table)));
+	}
+
+TInt CDrmRel1_0StringDict00::SwitchCodePage(TInt aCodePage)
+	{
+	// We only have one codepage sp can't switch
+	if (aCodePage != iCodePage)
+		{
+		return KErrXmlMissingStringDictionary;
+		}
+	return iCodePage;
+	}
+		
+/**
+This method obtains the public identifier from the StringTable.
+Either the formal or non formal public id will do.
+The stringDictionary .rss files must list both these as wbxml
+documents have one or the other.
+
+@param				aPubId The public identifier for this string 
+					dictionary.
+*/
+
+void CDrmRel1_0StringDict00::PublicIdentifier(RString& aPubId)
+	{
+	aPubId = iStringPool.String(
+		DrmRel1_0StringDict00TagTable::EFormalPublicId,
+		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
+	}
+
+/**
+The element types in the Device Information DTD are defined within
+a namespace associated with the Uri/Urn available from the StringTable.
+The RString need not be closed, but closing is harmless. 
+
+@param				aUri The associated namespace for this string 
+					dictionary.
+*/
+
+void CDrmRel1_0StringDict00::NamespaceUri(RString& aUri)
+	{
+	aUri = iStringPool.String(
+		DrmRel1_0StringDict00TagTable::EUri,
+		*(iCodepage00Table->StringTable(CDictionaryCodePage::EStringTypeElement)));
+	}
+
+// __________________________________________________________________________
+// Exported proxy for instantiation method resolution
+// Define the interface UIDs
+const TImplementationProxy ImplementationTable[] =
+    {
+#ifdef __EABI__
+	IMPLEMENTATION_PROXY_ENTRY(0x101F6DB7,CDrmRel1_0StringDict00::NewL)
+#else
+    {{0x101F6DB7}, CDrmRel1_0StringDict00::NewL}
+#endif
+    };
+
+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/omadrm/drmengine/ro/src/DrmRel1_0StringDict00AttributeTable.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Implementation of a parser for protected OMA DRM rights
+*
+*/
+
+
+// Autogenerated from \epoc32\build\generated\Xml\DrmRel1_0StringDict00AttributeTable.st by the stringtable tool - Do not edit
+#include <e32std.h>
+#include "StringPool.h"
+#include "StringTableSupport.h"
+#include "DrmRel1_0StringDict00AttributeTable.h"
+#ifdef _DEBUG
+#undef _DEBUG
+#endif
+
+_STLIT8(K1, "xmlns:o-ex");
+_STLIT8(K2, "xmlns:o-dd");
+_STLIT8(K3, "xmlns:ds");
+
+// Intermediate
+const void * const KStringPointers[] =
+	{
+	(const void*)&K1,
+	(const void*)&K2,
+	(const void*)&K3
+	};
+
+const TStringTable DrmRel1_0StringDict00AttributeTable::Table = {3, KStringPointers, ETrue};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DrmRel1_0StringDict00AttributeTable.st	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,6 @@
+stringtable DrmRel1_0StringDict00AttributeTable
+!// Element names
+!// CodePage 00
+EXmlnsOEx   xmlns:o-ex
+EXmlnsODd   xmlns:o-dd
+EXmlnsDs    xmlns:ds
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DrmRel1_0StringDict00AttributeValueTable.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Implementation of a parser for protected OMA DRM rights
+*
+*/
+
+
+// Autogenerated from \epoc32\build\generated\Xml\DrmRel1_0StringDict00AttributeValueTable.st by the stringtable tool - Do not edit
+#include <e32std.h>
+#include "StringPool.h"
+#include "StringTableSupport.h"
+#include "DrmRel1_0StringDict00AttributeValueTable.h"
+#ifdef _DEBUG
+#undef _DEBUG
+#endif
+
+_STLIT8(K1, "");
+_STLIT8(K2, "");
+_STLIT8(K3, "");
+_STLIT8(K4, "http://odrl.net/1.1/ODRL-EX");
+_STLIT8(K5, "http://odrl.net/1.1/ODRL-DD");
+_STLIT8(K6, "http://www.w3.org/2000/09/xmldsig/");
+
+// Intermediate
+const void * const KStringPointers[] =
+	{
+	(const void*)&K1,
+	(const void*)&K2,
+	(const void*)&K3,
+	(const void*)&K4,
+	(const void*)&K5,
+	(const void*)&K6
+	};
+
+const TStringTable DrmRel1_0StringDict00AttributeValueTable::Table = {6, KStringPointers, ETrue};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DrmRel1_0StringDict00AttributeValueTable.st	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,7 @@
+stringtable DrmRel1_0StringDict00AttributeValueTable
+EXmlnsOEx
+EXmlnsODd
+EXmlnsDs
+EOdrlEx     http://odrl.net/1.1/ODRL-EX
+EOdrlDd     http://odrl.net/1.1/ODRL-DD
+EXmlDsig    http://www.w3.org/2000/09/xmldsig/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DrmRel1_0StringDict00TagTable.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Implementation of a parser for protected OMA DRM rights
+*
+*/
+
+
+// Autogenerated from \epoc32\build\generated\Xml\DrmRel1_0StringDict00TagTable.st by the stringtable tool - Do not edit
+#include <e32std.h>
+#include "StringPool.h"
+#include "StringTableSupport.h"
+#include "DrmRel1_0StringDict00TagTable.h"
+#ifdef _DEBUG
+#undef _DEBUG
+#endif
+
+_STLIT8(K1, "rights");
+_STLIT8(K2, "context");
+_STLIT8(K3, "version");
+_STLIT8(K4, "uid");
+_STLIT8(K5, "agreement");
+_STLIT8(K6, "asset");
+_STLIT8(K7, "KeyInfo");
+_STLIT8(K8, "KeyValue");
+_STLIT8(K9, "permission");
+_STLIT8(K10, "play");
+_STLIT8(K11, "display");
+_STLIT8(K12, "execute");
+_STLIT8(K13, "print");
+_STLIT8(K14, "constraint");
+_STLIT8(K15, "count");
+_STLIT8(K16, "datetime");
+_STLIT8(K17, "start");
+_STLIT8(K18, "end");
+_STLIT8(K19, "interval");
+_STLIT8(K20, "-//OMA//DTD DRMREL 1.0//EN");
+_STLIT8(K21, "14~0");
+_STLIT8(K22, "-//OMA//DTD DRMREL 1.0//EN~0");
+
+// Intermediate
+const void * const KStringPointers[] =
+	{
+	(const void*)&K1,
+	(const void*)&K2,
+	(const void*)&K3,
+	(const void*)&K4,
+	(const void*)&K5,
+	(const void*)&K6,
+	(const void*)&K7,
+	(const void*)&K8,
+	(const void*)&K9,
+	(const void*)&K10,
+	(const void*)&K11,
+	(const void*)&K12,
+	(const void*)&K13,
+	(const void*)&K14,
+	(const void*)&K15,
+	(const void*)&K16,
+	(const void*)&K17,
+	(const void*)&K18,
+	(const void*)&K19,
+	(const void*)&K20,
+	(const void*)&K21,
+	(const void*)&K22
+	};
+
+const TStringTable DrmRel1_0StringDict00TagTable::Table = {22, KStringPointers, ETrue};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DrmRel1_0StringDict00TagTable.st	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+stringtable DrmRel1_0StringDict00TagTable
+# //////////////////////////////////////////////////////////////////////
+!// Element names
+!// CodePage 00
+# //////////////////////////////////////////////////////////////////////
+ERights rights
+EContext context
+EVersion version
+EUid uid
+EAgreement agreement
+EAsset asset
+EKeyInfo KeyInfo
+EKeyValue KeyValue
+EPermission permission
+EPlay play
+EDisplay display
+EExecute execute
+EPrint print
+EConstraint constraint
+ECount count
+EDateTime datetime
+EStart start
+EEnd end
+EInterval interval
+EUri						-//OMA//DTD DRMREL 1.0//EN
+EPublicId					E~0
+EFormalPublicId				-//OMA//DTD DRMREL 1.0//EN~0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DrmRights.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1519 @@
+/*
+* Copyright (c) 2002 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of common DRM operations
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "DrmAsset.h"
+#include "DrmRights.h"
+#include "DrmPermission.h"
+#include "DrmConstraint.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+_LIT(KNullDate,"00000000:000000.000000");
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::CDRMRightsConstraints
+// Default constructor
+// -----------------------------------------------------------------------------
+EXPORT_C CDRMRightsConstraints::CDRMRightsConstraints(void)
+    {
+    iConstraint = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMRightsConstraints::ConstructL(void)
+    {
+    iConstraint = CDRMConstraint::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+EXPORT_C CDRMRightsConstraints* CDRMRightsConstraints::NewL(void)
+    {
+    CDRMRightsConstraints* self = new (ELeave) CDRMRightsConstraints;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// Destructor
+EXPORT_C CDRMRightsConstraints::~CDRMRightsConstraints(void)
+    {
+    if (iConstraint) delete iConstraint;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::FullRights
+// The FullRights function checks if the object contains any restrictions
+// or if usage is unconstrained.
+// -----------------------------------------------------------------------------
+EXPORT_C TBool CDRMRightsConstraints::FullRights(void)
+    {
+    return iConstraint->iActiveConstraints == EConstraintNone ? ETrue : EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::IsPreview
+// The function checks if the object represents a preview constraint.
+// -----------------------------------------------------------------------------
+EXPORT_C TBool CDRMRightsConstraints::IsPreview(void)
+    {
+    if ((iConstraint->iActiveConstraints & EConstraintCounter) &&
+        iConstraint->iOriginalCounter == 1)
+        {
+        return ETrue;
+        }
+    else
+        {
+        return EFalse;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetConstraintInfo
+// This function checks the expiration and the constraints of the object and
+// returns the prioryty value.
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMRightsConstraints::SetConstraint(CDRMConstraint& aConstraint)
+    {
+    TInt error = KErrNone;
+    if( !iConstraint )
+        {
+        TRAP( error, iConstraint = CDRMConstraint::NewL());
+        if( error )
+            {
+            return;
+            }
+        }
+    TRAP( error, iConstraint->DuplicateL( aConstraint ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetConstraintInfo
+// This function checks the expiration and the constraints of the object and
+// returns the prioryty value.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::GetConstraintInfo(
+    TUint32& aExpiration,
+    TUint32& aConstType)
+    {
+    TTime currentTime;
+    TTime time;
+    TTimeIntervalSeconds interval;
+    TTimeIntervalSeconds diff;
+    TInt result = KErrNone;
+    currentTime.HomeTime();
+    TUint32 counter = 0;
+    TUint32 originalCounter = 0;
+    TInt priorValue = 0;
+    aConstType = NULL;
+
+    aExpiration = CDRMRights::EValidRights;
+
+    if ( FullRights() )
+        {
+        aConstType = CDRMRights::ENoConstraints;
+        return ENoConstraints * aExpiration;
+        }
+
+    result = GetEndTime(time);
+    if (result == KErrNone)
+        {
+        aConstType |= CDRMRights::ETimeBased;
+        if ( time < currentTime )
+            {
+            aExpiration = CDRMRights::EExpiredRights;
+            }
+        }
+
+    result = GetStartTime(time);
+    if (result == KErrNone && aExpiration != CDRMRights::EExpiredRights)
+        {
+        aConstType |= CDRMRights::ETimeBased;
+        if ( time > currentTime )
+            {
+            aExpiration = CDRMRights::EFutureRights;
+            }
+        }
+
+    result = GetInterval(interval);
+    if(result == KErrNone && aExpiration != CDRMRights::EExpiredRights)
+        {
+        result = GetIntervalStart(time);
+        if(result == KErrNone)
+            {
+            aConstType |= CDRMRights::ETimeBased;
+            currentTime.SecondsFrom(time, diff);
+            if (diff.Int() < 0)
+                {
+                aExpiration = CDRMRights::EFutureRights;
+                }
+            else if ( interval < diff )
+                {
+                aExpiration = CDRMRights::EExpiredRights;
+                }
+            }
+        else
+            {
+            aConstType |= CDRMRights::EInActiveInterval;
+            }
+        }
+    result = GetCounters( counter , originalCounter );
+    if (result == KErrNone)
+        {
+        aConstType |= CDRMRights::ECountBased;
+        if ( counter == 0 )
+            {
+            aExpiration = CDRMRights::EExpiredRights;
+            }
+        }
+    result = GetTimedCounters( counter , originalCounter );
+    if (result == KErrNone)
+        {
+        aConstType |= CDRMRights::ECountBased;
+        if ( counter == 0 )
+            {
+            aExpiration = CDRMRights::EExpiredRights;
+            }
+        }
+    result = GetAccumulated(interval);
+    if(result == KErrNone && aExpiration != CDRMRights::EExpiredRights)
+        {
+        aConstType |= CDRMRights::ETimeBased | CDRMRights::ETimeIsAccumulatedTime;
+        if (interval.Int() == 0)
+            {
+            aExpiration = CDRMRights::EExpiredRights;
+            }
+        }
+    if (!aConstType)
+        {
+        return CDRMRights::EInvalidRights;
+        }
+
+    if ( (aConstType & CDRMRights::ECountBased) &&
+        !(aConstType & CDRMRights::EInActiveInterval) &&
+        !(aConstType & CDRMRights::ETimeBased) )
+        {
+        priorValue = ECount * aExpiration;
+        }
+    else if ( (aConstType & CDRMRights::ECountBased) &&
+        (aConstType & CDRMRights::EInActiveInterval) &&
+        !(aConstType & CDRMRights::ETimeBased) )
+        {
+        priorValue = EIntervalCount * aExpiration;
+        }
+    else if ( (aConstType & CDRMRights::ECountBased) &&
+        (aConstType & CDRMRights::EInActiveInterval) &&
+        (aConstType & CDRMRights::ETimeBased) )
+        {
+        priorValue = ETimeIntervalCount * aExpiration;
+        }
+    else if ( (aConstType & CDRMRights::ECountBased) &&
+        !(aConstType & CDRMRights::EInActiveInterval) &&
+        (aConstType & CDRMRights::ETimeBased) )
+        {
+        priorValue = ETimeCount * aExpiration;
+        }
+    else if ( !(aConstType & CDRMRights::ECountBased) &&
+        (aConstType & CDRMRights::EInActiveInterval) &&
+        !(aConstType & CDRMRights::ETimeBased) )
+        {
+        priorValue = EInterval * aExpiration;
+        }
+    else if ( !(aConstType & CDRMRights::ECountBased) &&
+        (aConstType & CDRMRights::EInActiveInterval) &&
+        (aConstType & CDRMRights::ETimeBased) )
+        {
+        priorValue = ETimeInterval * aExpiration;
+        }
+    else if ( !(aConstType & CDRMRights::ECountBased) &&
+        !(aConstType & CDRMRights::EInActiveInterval) &&
+        (aConstType & CDRMRights::ETimeBased) )
+        {
+        priorValue = ETime * aExpiration;
+        }
+
+    return priorValue;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetExpirationDetails
+// The function returns the end time and amount of counts left of the object.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::GetExpirationDetails(
+    TTime& aEndTime,
+    TInt& aCountsLeft)
+    {
+    TTime endTime;
+    endTime.Set(KNullDate);
+    TTimeIntervalSeconds interval;
+    TTime intervalStart;
+    intervalStart.Set(KNullDate);
+    TTime intervalEnd;
+    intervalEnd.Set(KNullDate);
+
+    TUint32 counter = 0;
+    TUint32 originalCounter = 0;
+
+    TBool isEndTime = EFalse;
+    TBool isInterval = EFalse;
+    TBool isCount = EFalse;
+
+    if (GetCounters(counter, originalCounter) == KErrNone)
+        {
+        isCount = ETrue;
+        aCountsLeft = counter;
+        }
+    else
+        {
+        aCountsLeft = -1;
+        }
+    if (GetEndTime(endTime) == KErrNone)
+        {
+        isEndTime = ETrue;
+        }
+    if (GetIntervalStart(intervalStart) == KErrNone)
+        {
+        isInterval = ETrue;
+        GetInterval(interval);
+        intervalEnd = intervalStart + interval;
+        }
+    if (isInterval && isEndTime)
+        {
+        if (intervalEnd > endTime)
+            {
+            aEndTime = endTime;
+            }
+        else
+            {
+            aEndTime = intervalEnd;
+            }
+        }
+    else if (isInterval)
+        {
+        aEndTime = intervalEnd;
+        }
+    else if (isEndTime)
+        {
+        aEndTime = endTime;
+        }
+    else if (!isCount)
+        {
+        // The object contains either a full or an inactive interval rights
+        aEndTime.Set(KNullDate);
+        aCountsLeft = -1;
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetCounters
+// This function returns the current value of the count restriction and
+// original value of the count restriction.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::GetCounters(
+    TUint32& aCounter,
+    TUint32& aOriginalCounter)
+    {
+    if (iConstraint->iActiveConstraints & EConstraintCounter)
+        {
+        aCounter = iConstraint->iCounter;
+        aOriginalCounter = iConstraint->iOriginalCounter;
+        return KErrNone;
+        }
+    else
+        {
+        return CDRMRights::ENoRights;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetCounters
+// This function returns the current value of the count restriction and
+// original value of the count restriction.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::GetTimedCounters(
+    TUint32& aCounter,
+    TUint32& aOriginalCounter)
+    {
+    if (iConstraint->iActiveConstraints & EConstraintTimedCounter)
+        {
+        aCounter = iConstraint->iTimedCounter;
+        aOriginalCounter = iConstraint->iOriginalCounter;
+        return KErrNone;
+        }
+    else
+        {
+        return CDRMRights::ENoRights;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetStartTime
+//
+// This function returns the time when the constraint becomes valid or has
+// become valid.
+//
+// Cases:
+// 1. If an active interval is present, that time is always the correct start
+//    time
+// 2. If start time is defined that is the start time
+// 3. No active interval or start time defined CDRMRights::ENoRights
+//
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::GetStartTime(
+    TTime& aStartTime)
+    {
+    // Activated interval is always the same or later than
+    // the start time of the start-end
+
+    if (iConstraint->iActiveConstraints & EConstraintInterval &&
+        (iConstraint->iIntervalStart != Time::NullTTime() ) )
+        {
+        aStartTime = iConstraint->iIntervalStart;
+        }
+    else if (iConstraint->iActiveConstraints & EConstraintStartTime)
+        {
+        aStartTime = iConstraint->iStartTime;
+        }
+    else
+        {
+        return CDRMRights::ENoRights;
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetEndTime
+//
+// This function returns the time when the constraint will become invalid
+//
+// Cases:
+// 1. If both end time and activated interval is present the one which is closer
+//    to the present time will be chosen
+// 2. If only end time is available, that is returned
+// 3. If only activated interval is available, that is returned
+// 4. Otherwise CDRMRights::ENoRights
+//
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::GetEndTime(
+    TTime& aEndTime)
+    {
+    // If both end time and interval have been activated
+    // take the one which is closer
+
+    if ((iConstraint->iActiveConstraints & EConstraintEndTime) &&
+        (iConstraint->iActiveConstraints & EConstraintInterval) &&
+        (iConstraint->iIntervalStart != Time::NullTTime() ) )
+        {
+        if( iConstraint->iEndTime <= (iConstraint->iIntervalStart +
+                                      iConstraint->iInterval) )
+            {
+            aEndTime = iConstraint->iEndTime;
+            }
+        else
+            {
+            aEndTime = (iConstraint->iIntervalStart +
+                        iConstraint->iInterval);
+            }
+        }
+    else if (iConstraint->iActiveConstraints & EConstraintEndTime)
+        {
+        aEndTime = iConstraint->iEndTime;
+        }
+    else if (iConstraint->iActiveConstraints & EConstraintInterval &&
+             (iConstraint->iIntervalStart != Time::NullTTime() ) )
+        {
+        aEndTime = (iConstraint->iIntervalStart +
+                    iConstraint->iInterval);
+        }
+    else
+        {
+        return CDRMRights::ENoRights;
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetInterval
+// This function returns the interval time constraint
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::GetInterval(
+    TTimeIntervalSeconds& aInterval)
+    {
+    if (iConstraint->iActiveConstraints & EConstraintInterval)
+        {
+        aInterval = iConstraint->iInterval;
+        return KErrNone;
+        }
+    else
+        {
+        return CDRMRights::ENoRights;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetIntervalStart
+// This function returns the start of the interval time constraint
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::GetIntervalStart(
+    TTime& aIntervalStart)
+    {
+    if (iConstraint->iActiveConstraints & EConstraintInterval &&
+        iConstraint->iIntervalStart != Time::NullTTime())
+        {
+        aIntervalStart = iConstraint->iIntervalStart;
+        return KErrNone;
+        }
+    else
+        {
+        return CDRMRights::ENoRights;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetAccumulated
+// This function returns the accumulated time constraint
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::GetAccumulated(
+    TTimeIntervalSeconds& aAccumulated)
+    {
+    if (iConstraint->iActiveConstraints & EConstraintAccumulated)
+        {
+        aAccumulated = iConstraint->iAccumulatedTime;
+        return KErrNone;
+        }
+    else
+        {
+        return CDRMRights::ENoRights;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetCounters
+// This function returns the current value of the count restriction and
+// original value of the count restriction.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::SetCounters(
+    TUint32 aCounter,
+    TUint32 aOriginalCounter)
+    {
+    iConstraint->iCounter = aCounter;
+    iConstraint->iOriginalCounter = aOriginalCounter;
+    iConstraint->iActiveConstraints |= EConstraintCounter;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::SetStartTime
+// This function sets the start time constraint
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::SetStartTime(
+    TTime aStartTime)
+    {
+    iConstraint->iStartTime = aStartTime;
+    iConstraint->iActiveConstraints |= EConstraintStartTime;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::SetEndTime
+// This function sets the end time constraint
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::SetEndTime(
+    TTime aEndTime)
+    {
+    iConstraint->iEndTime = aEndTime;
+    iConstraint->iActiveConstraints |= EConstraintEndTime;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::SetInterval
+// This function sets the interval time constraint
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::SetInterval(
+    TTimeIntervalSeconds aInterval)
+    {
+    iConstraint->iInterval = aInterval;
+    iConstraint->iActiveConstraints |= EConstraintInterval;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::SetIntervalStart
+// This function sets the start of the interval time constraint
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRightsConstraints::SetIntervalStart(
+    TTime aStartTime)
+    {
+    iConstraint->iIntervalStart = aStartTime;
+    iConstraint->iActiveConstraints |= EConstraintInterval;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::GetConstraint
+// -----------------------------------------------------------------------------
+EXPORT_C CDRMConstraint& CDRMRightsConstraints::GetConstraint(void)
+    {
+    return *iConstraint;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsConstraints::operator=
+// Assignment operator.
+// -----------------------------------------------------------------------------
+EXPORT_C CDRMRightsConstraints& CDRMRightsConstraints::operator=(
+    CDRMRightsConstraints& aConstraint)
+    {
+    if (iConstraint)
+        {
+        delete iConstraint;
+        iConstraint = NULL;
+        }
+    TRAP_IGNORE( iConstraint = CDRMConstraint::NewL() );
+    if (iConstraint)
+        {
+        TRAP_IGNORE( iConstraint->DuplicateL( aConstraint.GetConstraint() ) );
+        }
+
+    return *this;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::CDRMRights
+// Default constructor.
+// -----------------------------------------------------------------------------
+EXPORT_C CDRMRights::CDRMRights(void):
+    iAsset(NULL),
+    iPermission(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMRights::ConstructL(void)
+    {
+    iPermission = CDRMPermission::NewL();
+    iAsset = CDRMAsset::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+EXPORT_C CDRMRights* CDRMRights::NewL(void)
+    {
+    CDRMRights* self = new (ELeave) CDRMRights;
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// Destructor
+EXPORT_C CDRMRights::~CDRMRights(void)
+    {
+    delete iAsset;
+    delete iPermission;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetContentURI
+// This function returns the content URI of the object
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::GetContentURI(HBufC8*& aContentURI)
+    {
+    TInt r;
+
+    r = KErrNone;
+    if (iAsset && iAsset->iUid)
+        {
+        aContentURI = HBufC8::NewMax(iAsset->iUid->Size());
+        if (aContentURI)
+            {
+            *aContentURI = *iAsset->iUid;
+            }
+        else r = KErrNoMemory;
+        }
+    else
+        {
+        aContentURI = NULL;
+        }
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetLocalID
+// This function returns the local ID of the object
+// -----------------------------------------------------------------------------
+EXPORT_C TUint32 CDRMRights::GetLocalID(void)
+    {
+    return iPermission->iUniqueID;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetAddTime
+// This function returns the time when the rights object was added to the
+// rights database.
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMRights::GetAddTime(TTime& aTime)
+    {
+    aTime = iPermission->iOriginalInsertTime;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetRightsInfo
+// This function checks the expiration and the constraints of the object and
+// retunrs the best constraint priority value.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::GetRightsInfo(
+    TUint32 aConstraintSpec,
+    TRestriction& aRestriction,
+    TExpiration& aExpiration,
+    TUint32& aConstType)
+    {
+    TInt r = 0;
+    TBool noRights = ETrue;
+
+    TUint32 playConst = NULL;
+    TUint32 displayConst = NULL;
+    TUint32 exeConst = NULL;
+    TUint32 printConst = NULL;
+
+    TUint32 playExpir = EExpiredRights;
+    TUint32 displayExpir = EExpiredRights;
+    TUint32 printExpir = EExpiredRights;
+    TUint32 exeExpir = EExpiredRights;
+
+    TInt playValue = NULL;
+    TInt displayValue = NULL;
+    TInt exeValue = NULL;
+    TInt printValue = NULL;
+    TInt compareValue = NULL;
+
+    CDRMRightsConstraints* constraint = NULL;
+
+    r = GetPlayRight(constraint);
+    if (r && r != ENoRights)
+        {
+        return KErrNoMemory;
+        }
+    if (r == KErrNone &&
+       (aConstraintSpec == CDRMRights::EPlay || aConstraintSpec == 0 ) )
+        {
+        noRights = EFalse;
+        if (constraint->FullRights())
+            {
+            delete constraint;
+            constraint = NULL;
+            aExpiration = EValidRights;
+            aConstType = ENoConstraints;
+            aRestriction = EFullRights;
+            return EFullRights;
+            }
+        else
+            {
+            playValue = constraint->GetConstraintInfo(playExpir, playConst);
+            if (playValue > compareValue)
+                {
+                compareValue = playValue;
+                if(constraint->IsPreview())
+                    {
+                    aRestriction = EPreviewRights;
+                    }
+                else
+                    {
+                    aRestriction = ERestrictedRights;
+                    }
+                }
+            }
+        }
+
+    delete constraint;
+    constraint = NULL;
+
+    r = GetDisplayRight(constraint);
+    if (r && r != ENoRights)
+        {
+        return KErrNoMemory;
+        }
+    if (r == KErrNone &&
+       (aConstraintSpec == CDRMRights::EDisplay || aConstraintSpec == 0 ) )
+        {
+        noRights = EFalse;
+        if (constraint->FullRights())
+            {
+            delete constraint;
+            constraint = NULL;
+            aExpiration = EValidRights;
+            aConstType = ENoConstraints;
+            aRestriction = EFullRights;
+            return EFullRights;
+            }
+        else
+            {
+            displayValue = constraint->GetConstraintInfo(displayExpir, displayConst);
+            if (displayValue > compareValue)
+                {
+                compareValue = displayValue;
+                if(constraint->IsPreview())
+                    {
+                    aRestriction = EPreviewRights;
+                    }
+                else
+                    {
+                    aRestriction = ERestrictedRights;
+                    }
+                }
+            }
+        }
+
+    delete constraint;
+    constraint = NULL;
+
+    r = GetExecuteRight(constraint);
+    if (r && r != ENoRights)
+        {
+        return KErrNoMemory;
+        }
+    if (r == KErrNone &&
+       (aConstraintSpec == CDRMRights::EExecute || aConstraintSpec == 0 ) )
+        {
+        noRights = EFalse;
+        if (constraint->FullRights())
+            {
+            delete constraint;
+            constraint = NULL;
+            aExpiration = EValidRights;
+            aConstType = ENoConstraints;
+            aRestriction = EFullRights;
+            return EFullRights;
+            }
+        else
+            {
+            exeValue = constraint->GetConstraintInfo(exeExpir, exeConst);
+            if (exeValue > compareValue)
+                {
+                compareValue = exeValue;
+                if(constraint->IsPreview())
+                    {
+                    aRestriction = EPreviewRights;
+                    }
+                else
+                    {
+                    aRestriction = ERestrictedRights;
+                    }
+                }
+            }
+        }
+
+    delete constraint;
+    constraint = NULL;
+
+    r = GetPrintRight(constraint);
+    if (r && r != ENoRights)
+        {
+        return KErrNoMemory;
+        }
+    if (r == KErrNone &&
+       (aConstraintSpec == CDRMRights::EPrint || aConstraintSpec == 0 ) )
+        {
+        noRights = EFalse;
+        if (constraint->FullRights())
+            {
+            delete constraint;
+            constraint = NULL;
+            aExpiration = EValidRights;
+            aConstType = ENoConstraints;
+            aRestriction = EFullRights;
+            return EFullRights;
+            }
+        else
+            {
+            printValue = constraint->GetConstraintInfo(printExpir, printConst);
+            if (printValue > compareValue)
+                {
+                compareValue = exeValue;
+                if(constraint->IsPreview())
+                    {
+                    aRestriction = EPreviewRights;
+                    }
+                else
+                    {
+                    aRestriction = ERestrictedRights;
+                    }
+                }
+            }
+        }
+
+    delete constraint;
+    constraint = NULL;
+
+    if (noRights)
+        {
+        delete constraint;
+        constraint = NULL;
+        aExpiration = EExpiredRights;
+        return ENoRights;
+        }
+
+    if (aRestriction != ERestrictedRights)
+        {
+        aRestriction = EPreviewRights;
+        }
+
+    if (playExpir == EExpiredRights &&
+        displayExpir == EExpiredRights &&
+        printExpir == EExpiredRights &&
+        exeExpir == EExpiredRights)
+        {
+        aExpiration = EExpiredRights;
+        }
+
+    if (playExpir == EFutureRights ||
+        displayExpir == EFutureRights ||
+        printExpir == EFutureRights ||
+        exeExpir == EFutureRights)
+        {
+        aExpiration = EFutureRights;
+        }
+
+    if (playExpir == EValidRights ||
+        displayExpir == EValidRights ||
+        printExpir == EValidRights ||
+        exeExpir == EValidRights)
+        {
+        aExpiration = EValidRights;
+        }
+
+    if (compareValue == playValue) aConstType = playConst;
+    if (compareValue == displayValue) aConstType = displayConst;
+    if (compareValue == exeValue) aConstType = exeConst;
+    if (compareValue == printValue) aConstType = printConst;
+
+    return compareValue;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetExpirationDetails
+// The function returns the end time and amount of counts left of the object.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::GetExpirationDetails(
+    TUint32 aConstraintSpec,
+    TTime& aEndTime,
+    TInt& aCountsLeft)
+    {
+    TInt r = 0;
+    CDRMRightsConstraints* constraint = NULL;
+
+    TTime playEndTime;
+    playEndTime.Set(KNullDate);
+    TTime displayEndTime;
+    displayEndTime.Set(KNullDate);
+    TTime executeEndTime;
+    executeEndTime.Set(KNullDate);
+    TTime printEndTime;
+    printEndTime.Set(KNullDate);
+    TTime compareTime;
+    compareTime.Set(KNullDate);
+
+    TInt playCounter = 0;
+    TInt displayCounter = 0;
+    TInt executeCounter = 0;
+    TInt printCounter = 0;
+
+    TBool noRights = ETrue;
+
+    aEndTime.Set(KNullDate);
+    aCountsLeft  = 0;
+
+    r = GetPlayRight(constraint);
+    if (r == KErrNone &&
+       (aConstraintSpec == CDRMRights::EPlay || aConstraintSpec == 0 ) )
+        {
+        noRights = EFalse;
+        if (constraint->FullRights())
+            {
+            delete constraint;
+            constraint = NULL;
+            aEndTime.Set(KNullDate);
+            aCountsLeft = -1;
+            return KErrNone;
+            }
+        else
+            {
+            r = constraint->GetExpirationDetails(playEndTime, playCounter);
+            if(playEndTime == compareTime && playCounter == -1)
+                {
+                delete constraint;
+                constraint = NULL;
+                return KErrNone;
+                }
+            }
+        }
+
+    delete constraint;
+    constraint = NULL;
+
+    r = GetDisplayRight(constraint);
+    if (r == KErrNone &&
+       (aConstraintSpec == CDRMRights::EDisplay || aConstraintSpec == 0 ) )
+        {
+        noRights = EFalse;
+        if (constraint->FullRights())
+            {
+            delete constraint;
+            constraint = NULL;
+            aEndTime.Set(KNullDate);
+            aCountsLeft = -1;
+            return KErrNone;
+            }
+        else
+            {
+            r = constraint->GetExpirationDetails(displayEndTime, displayCounter);
+            if(displayEndTime == compareTime && displayCounter == -1)
+                {
+                delete constraint;
+                constraint = NULL;
+                return KErrNone;
+                }
+            }
+        }
+
+    delete constraint;
+    constraint = NULL;
+
+    r = GetExecuteRight(constraint);
+    if (r == KErrNone &&
+       (aConstraintSpec == CDRMRights::EExecute || aConstraintSpec == 0 ) )
+        {
+        noRights = EFalse;
+        if (constraint->FullRights())
+            {
+            delete constraint;
+            constraint = NULL;
+            aEndTime.Set(KNullDate);
+            aCountsLeft = -1;
+            return KErrNone;
+            }
+        else
+            {
+            r = constraint->GetExpirationDetails(executeEndTime, executeCounter);
+            if(executeEndTime == compareTime && executeCounter == -1)
+                {
+                delete constraint;
+                constraint = NULL;
+                return KErrNone;
+                }
+            }
+        }
+
+    delete constraint;
+    constraint = NULL;
+
+    r = GetPrintRight(constraint);
+    if (r == KErrNone &&
+       (aConstraintSpec == CDRMRights::EPrint || aConstraintSpec == 0 ) )
+        {
+        noRights = EFalse;
+        if (constraint->FullRights())
+            {
+            delete constraint;
+            constraint = NULL;
+            aEndTime.Set(KNullDate);
+            aCountsLeft = -1;
+            return KErrNone;
+            }
+        else
+            {
+            r = constraint->GetExpirationDetails(printEndTime, printCounter);
+            if(printEndTime == compareTime && printCounter == -1)
+                {
+                delete constraint;
+                constraint = NULL;
+                return KErrNone;
+                }
+            }
+        }
+
+    delete constraint;
+    constraint = NULL;
+
+    if (noRights)
+        {
+        aEndTime.Set(KNullDate);
+        aCountsLeft = -1;
+        return ENoRights;
+        }
+
+    compareTime.HomeTime();
+
+    if (playCounter > aCountsLeft)
+        {
+        aEndTime = playEndTime;
+        aCountsLeft = playCounter;
+        }
+    if (displayCounter > aCountsLeft)
+        {
+        aEndTime = displayEndTime;
+        aCountsLeft = displayCounter;
+        }
+    if (executeCounter > aCountsLeft)
+        {
+        aEndTime = executeEndTime;
+        aCountsLeft = executeCounter;
+        }
+    if (printCounter > aCountsLeft)
+        {
+        aEndTime = printEndTime;
+        aCountsLeft = printCounter;
+        }
+
+    if (aCountsLeft > 0 &&
+        playEndTime < compareTime && displayEndTime < compareTime &&
+        executeEndTime < compareTime && printEndTime < compareTime)
+        {
+        return KErrNone;
+        }
+
+    if (playEndTime > aEndTime)
+        {
+        aEndTime = playEndTime;
+        aCountsLeft  = playCounter;
+        }
+    if (displayEndTime > aEndTime)
+        {
+        aEndTime = displayEndTime;
+        aCountsLeft  = displayCounter;
+        }
+    if (executeEndTime > aEndTime)
+        {
+        aEndTime = executeEndTime;
+        aCountsLeft  = executeCounter;
+        }
+    if (printEndTime > aEndTime)
+        {
+        aEndTime = printEndTime;
+        aCountsLeft  = printCounter;
+        }
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetPlayRight
+// This function returns the constraints associated with the play right.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::GetPlayRight(
+    CDRMRightsConstraints*& aConstraint)
+    {
+    TInt r = ENoRights;
+
+    aConstraint = NULL;
+    if (iPermission->iAvailableRights & ERightsPlay)
+        {
+        TRAP(r, aConstraint = CDRMRightsConstraints::NewL());
+        if (r == KErrNone)
+            {
+            aConstraint->SetConstraint(*iPermission->iPlay);
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetDisplayRight
+// This function returns the constraints associated with the display right.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::GetDisplayRight(
+    CDRMRightsConstraints*& aConstraint)
+    {
+    TInt r = ENoRights;
+
+    aConstraint = NULL;
+    if (iPermission->iAvailableRights & ERightsDisplay)
+        {
+        TRAP(r, aConstraint = CDRMRightsConstraints::NewL());
+        if (r == KErrNone)
+            {
+            aConstraint->SetConstraint(*iPermission->iDisplay);
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetPrintRight
+// This function returns the constraints associated with the print right.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::GetPrintRight(
+    CDRMRightsConstraints*& aConstraint)
+    {
+    TInt r = ENoRights;
+
+    aConstraint = NULL;
+    if (iPermission->iAvailableRights & ERightsPrint)
+        {
+        TRAP(r, aConstraint = CDRMRightsConstraints::NewL());
+        if (r == KErrNone)
+            {
+            aConstraint->SetConstraint(*iPermission->iPrint);
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetExecuteRight
+// This function returns the constraints associated with the execute right.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::GetExecuteRight(
+    CDRMRightsConstraints*& aConstraint)
+    {
+    TInt r = ENoRights;
+
+    aConstraint = NULL;
+    if (iPermission->iAvailableRights & ERightsExecute)
+        {
+        TRAP(r, aConstraint = CDRMRightsConstraints::NewL());
+        if (r == KErrNone)
+            {
+            aConstraint->SetConstraint(*iPermission->iExecute);
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::SetContentURIAndLocalID
+// This function sets the content URI and local ID of the object
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::SetContentURIAndLocalID(
+    HBufC8* aContentURI,
+    TUint32 aLocalID)
+    {
+    TInt r = KErrNone;
+
+    if (!iAsset)
+        {
+        TRAP(r, iAsset = CDRMAsset::NewL());
+        }
+
+    if (iAsset)
+        {
+        if( iAsset->iUid )
+            {
+            delete iAsset->iUid;
+            }
+        iAsset->iUid = aContentURI;
+
+        if ( !iPermission )
+            {
+            TRAP(r, iPermission = CDRMPermission::NewL());
+            }
+
+        if ( iPermission )
+            {
+            iPermission->iUniqueID = aLocalID;
+            }
+        }
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::SetContentURI
+// This function sets the content URI of the object
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::SetContentURI(
+    HBufC8* aContentURI)
+    {
+    if (iAsset)
+        {
+        delete iAsset->iUid;
+        iAsset->iUid = aContentURI;
+        }
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::SetLocalID
+// This function sets the content URI and local ID of the object
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::SetLocalID(
+    TUint32 aLocalID)
+    {
+    iPermission->iUniqueID = aLocalID;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetAddTime
+// This function sets the time when the rights object was added to the
+// rights database.
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMRights::SetAddTime(
+    TTime aTime)
+    {
+    iPermission->iOriginalInsertTime = aTime;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::SetPlayRight
+// This function sets the constraints associated with the play right.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::SetPlayRight(
+    CDRMRightsConstraints* aConstraint)
+    {
+    TInt error = KErrNone;
+
+    if( !iPermission )
+        {
+        TRAP( error, iPermission = CDRMPermission::NewL());
+        if( error )
+            {
+            return error;
+            }
+        }
+    else if( !iPermission->iPlay )
+        {
+        TRAP( error, iPermission->iPlay = CDRMConstraint::NewL() );
+        if( error )
+            {
+            return error;
+            }
+        }
+
+    TRAP( error, iPermission->iPlay->DuplicateL( aConstraint->GetConstraint() ) );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::SetDisplayRight
+// This function sets the constraints associated with the display right.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::SetDisplayRight(
+    CDRMRightsConstraints* aConstraint)
+    {
+    TInt error = KErrNone;
+
+    if( !iPermission )
+        {
+        TRAP( error, iPermission = CDRMPermission::NewL());
+        if( error )
+            {
+            return error;
+            }
+        }
+    else if( !iPermission->iDisplay )
+        {
+        TRAP( error, iPermission->iDisplay = CDRMConstraint::NewL() );
+        if( error )
+            {
+            return error;
+            }
+        }
+
+    TRAP( error, iPermission->iDisplay->DuplicateL( aConstraint->GetConstraint() ) );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::SetPrintRight
+// This function sets the constraints associated with the print right.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::SetPrintRight(
+    CDRMRightsConstraints* aConstraint)
+    {
+    TInt error = KErrNone;
+
+    if( !iPermission )
+        {
+        TRAP( error, iPermission = CDRMPermission::NewL());
+        if( error )
+            {
+            return error;
+            }
+        }
+    else if( !iPermission->iPrint )
+        {
+        TRAP( error, iPermission->iPrint = CDRMConstraint::NewL() );
+        if( error )
+            {
+            return error;
+            }
+        }
+
+    TRAP( error, iPermission->iPrint->DuplicateL( aConstraint->GetConstraint() ) );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::SetExecuteRight
+// This function sets the constraints associated with the execute right.
+// -----------------------------------------------------------------------------
+EXPORT_C TInt CDRMRights::SetExecuteRight(
+    CDRMRightsConstraints* aConstraint)
+    {
+    TInt error = KErrNone;
+
+    if( !iPermission )
+        {
+        TRAP( error, iPermission = CDRMPermission::NewL());
+        if( error )
+            {
+            return error;
+            }
+        }
+    else if( !iPermission->iExecute )
+        {
+        TRAP( error, iPermission->iExecute = CDRMConstraint::NewL() );
+        if( error )
+            {
+            return error;
+            }
+        }
+
+    TRAP( error, iPermission->iExecute->DuplicateL( aConstraint->GetConstraint() ) );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetPermission
+// -----------------------------------------------------------------------------
+EXPORT_C CDRMPermission& CDRMRights::GetPermission(void)
+    {
+    return *iPermission;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::SetPermissionL
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMRights::SetPermissionL(CDRMPermission& aRO)
+    {
+    delete iPermission;
+    iPermission = NULL;
+    iPermission = CDRMPermission::NewL();
+    iPermission->DuplicateL(aRO);
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::GetAsset
+// -----------------------------------------------------------------------------
+EXPORT_C CDRMAsset& CDRMRights::GetAsset(void)
+    {
+    return *iAsset;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::SetAssetL
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMRights::SetAssetL(CDRMAsset& aAsset)
+    {
+    delete iAsset;
+    iAsset = NULL;
+    iAsset = CDRMAsset::NewL();
+    iAsset->DuplicateL(aAsset);
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::operator=
+// Assignment operator.
+// -----------------------------------------------------------------------------
+EXPORT_C CDRMRights& CDRMRights::operator=(
+    CDRMRights& aRight)
+    {
+    TInt r = KErrNone;
+
+    if (this == &aRight)
+        {
+        return *this;
+        }
+
+    TRAP(r, SetAssetL(aRight.GetAsset()));
+    TRAP(r, SetPermissionL(aRight.GetPermission()));
+
+    return* this;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMRights::ExternalizeL
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMRights::ExternalizeL(RWriteStream& aStream) const
+    {
+    iAsset->ExternalizeL(aStream);
+    iPermission->ExternalizeL(aStream);
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::InternalizeL
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMRights::InternalizeL(RReadStream& aStream)
+    {
+    delete iAsset;
+    iAsset = NULL;
+    delete iPermission;
+    iPermission=NULL;
+
+    iAsset = CDRMAsset::NewL();
+    iPermission = CDRMPermission::NewL();
+
+    iAsset->InternalizeL(aStream);
+    iPermission->InternalizeL(aStream);
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRights::Merge
+// -----------------------------------------------------------------------------
+EXPORT_C void CDRMRights::Merge(const CDRMRights& aRights)
+    {
+    iPermission->Merge(*aRights.iPermission);
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/ro/src/DrmRightsParser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1835 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OMA DRM rights parser
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <e32math.h>
+#include <apmstd.h>
+#include <utf.h>
+#include <stringpool.h>
+#include <xml/parserfeature.h>
+#include "DrmRights.h"
+#include "DcfCommon.h"
+#include "DrmRightsParser.h"
+#include "DrmRightsClient.h"
+#include "hash.h"
+#include "base64.h"
+#include "DRMPermission.h"
+#include "DRMConstraint.h"
+#include "DRMClockClient.h"
+
+// MODULE DATA STRUCTURES
+enum TElementEnum
+    {
+    ERights = 0,
+    EContext,
+    EVersion,
+    EUid,
+    EAgreement,
+    EAsset,
+    EInherit,
+    EDigest,
+    EDigestMethod,
+    EDigestValue,
+    EKeyInfo,
+    EEncryptedKey,
+    EEncryptionMethod,
+    ECipherData,
+    ECipherValue,
+    ERetreivalMethod,
+    EPermission,
+    EPlay,
+    EDisplay,
+    EPrint,
+    EExecute,
+    EConstraint,
+    ECount,
+    ETimedCount,
+    EDateTime,
+    EStart,
+    EEnd,
+    EInterval,
+    EAccumulated,
+    EIndividual,
+    EExport,
+    ESystem,
+    EKeyValue,
+    EId,
+    EIdRef,
+    EProperty,
+    ESoftware,
+    EContainer,
+#ifdef RD_DRM_METERING
+    ERequirement,
+    ETracked,
+#endif
+    ELast,
+    };
+
+struct TElements
+    {
+    const TText8* iString;
+    TInt iNumber;
+    };
+
+NONSHARABLE_CLASS( CDrmRightsParser::CParsedAsset ): public CBase
+    {
+public:
+    static CParsedAsset* NewL();
+    ~CParsedAsset();
+    void ConstructL();
+
+private:
+    CParsedAsset();
+
+public:
+    HBufC8* iUid;
+    TBuf8< KDCFKeySize > iKey;
+    TBuf8< KProtectedDCFKeySize > iProtectedKey;
+    TBuf8< KDCFKeySize > iAuthenticationSeed;
+    TBuf8< KProtectedDCFKeySize > iProtectedAuthSeed;
+    TBuf8< SHA1_HASH > iDigest;
+
+    HBufC8* iId;
+    HBufC8* iIdRef;
+
+    HBufC8* iInherit;
+    };
+
+// Note the class CDrmRightsParser::CParsedPermission maps to
+// OMA DRM2 permission container element <permission>
+// CDRMConstraint reperesents indivdual permissions as constraint container
+// (except Toplevel constraint really represents
+//  constraint container <constraint>)
+NONSHARABLE_CLASS( CDrmRightsParser::CParsedPermission ): public CBase
+    {
+public:
+    static CParsedPermission* NewL();
+    ~CParsedPermission();
+    // Removes invalidated permissions, and marks the total permission invalid,
+    // if all constraint containers are invalid, or toplevel container
+    // is invalid
+    void RemoveInvalidL();
+    // Sets current constraint and updates available rights ( iAvailableRights )
+    void SetCurrentConstraint ( TRightsType aCurrentConstraint );
+
+    RPointerArray< CParsedAsset > iAssets;
+    TUint8 iAvailableRights;
+
+    CDRMConstraint *iTopLevel;
+    CDRMConstraint *iPlay;
+    CDRMConstraint *iDisplay;
+    CDRMConstraint *iPrint;
+    CDRMConstraint *iExecute;
+    CDRMConstraint *iExport;
+
+    //2.1 addition:
+    // URL to send HTTP GET on expiration of permission
+    HBufC8* iOnExpiredUrl;
+
+    // if constraint has unknown tags, this is ored with iCurrentConstraint
+    TUint8 iInvalidConstraints;
+
+    // maintained during parsing. possible values: TRightsType enumerations
+    TUint8 iCurrentConstraint;
+
+    // if top level constraint is invalid or all other constraints ate invalid
+    // permission will become invalid
+    TBool iInvalid;
+    // count of not_owned_assets, (updated in transform...)
+    TInt iNotOwned;
+
+private:
+    CParsedPermission();
+    void ConstructL();
+    void ResetConstraintL( CDRMConstraint*& aConstraint );
+    };
+
+NONSHARABLE_CLASS( CDrmRightsParser::CParsedRightsObject ): public CBase
+    {
+public:
+    CParsedRightsObject();
+    ~CParsedRightsObject();
+
+    // Removes invalidated permission containers
+    // (of type CParsedPermission ), and marks the whole rights object
+    // invalid, if all permission containers are invalid
+    void RemoveInvalid();
+
+    HBufC8* iRightsObjectId;
+    RPointerArray< CParsedAsset > iAssets;
+    RPointerArray< CParsedPermission > iPermissions;
+
+    CParsedAsset* iCurrentAsset;
+    CParsedPermission* iCurrentPermission;
+    CDRMConstraint* iCurrentConstraint;
+    TBool iKeyIsCek;
+    TBool iInvalid;
+    };
+
+// CONSTANTS
+#define ELEMENT_COUNT( x ) static_cast< TInt >( ( sizeof( x ) / sizeof( x[ 0 ] ) ) )
+
+// LOCAL CONSTANTS AND MACROS
+const TInt KParserChunkSize = 512;
+const TInt KMaxElementNesting = 24;
+
+// 15 minutes per time zone, 60 seconds per minute
+const TInt KSecondsPerTimeZone = 900;
+const TInt KMinuteInMicroseconds = 60000000;
+const TInt KTimeZoneIncrement = 15;
+
+_LIT8( KXmlParserMimeType, "text/xml" );
+_LIT8( KWbxmlParserMimeType, "text/wbxml" );
+_LIT8( KSchemaAttribute, "schema" );
+_LIT8( KSchemeAttribute, "scheme" );
+_LIT8( KSchemaSymbianSid, "symbiansid" );
+_LIT8( KSchemaSymbianVid, "symbianvid" );
+_LIT8( KTimerAttribute, "timer" );
+_LIT8( KIdAttribute, "id" );
+_LIT8( KIdAttrUpperCase, "Id" );
+_LIT8( KIdRefAttribute, "idref" );
+_LIT8( KAuthSeed, "authSeed" );
+// OMA DRM 2.1 additions
+_LIT8( KOnExpiredUrlAttribute, "onExpiredURL" ); //requested on premission expiry if present
+#ifdef RD_DRM_METERING
+_LIT8( KTimedAttribute, "timed" );
+_LIT8( KContentAccessGrantedAttribute, "contentAccessGranted" );
+_LIT8( KContentAccessGrantedValueTrue, "true" );
+#endif // RD_DRM_METERING
+
+static const TElements KElements[] =
+    {
+    { _S8( "rights" ),             ::ERights },
+    { _S8( "context" ),            EContext },
+    { _S8( "version" ),            EVersion },
+    { _S8( "uid" ),                EUid },
+    { _S8( "agreement" ),          EAgreement },
+    { _S8( "asset" ),              EAsset },
+    { _S8( "inherit" ),            EInherit },
+    { _S8( "digest" ),             EDigest },
+    { _S8( "DigestMethod" ),       EDigestMethod },
+    { _S8( "DigestValue" ),        EDigestValue },
+    { _S8( "KeyInfo" ),            EKeyInfo },
+    { _S8( "EncryptedKey" ),       EEncryptedKey },
+    { _S8( "EncryptionMethod" ),   EEncryptionMethod },
+    { _S8( "CipherData" ),         ECipherData },
+    { _S8( "CipherValue" ),        ECipherValue },
+    { _S8( "RetrievalMethod" ),    ERetreivalMethod },
+    { _S8( "permission" ),         EPermission },
+    { _S8( "play" ),               ::EPlay },
+    { _S8( "display" ),            ::EDisplay },
+    { _S8( "execute" ),            ::EExecute },
+    { _S8( "print" ),              ::EPrint },
+    { _S8( "constraint" ),         EConstraint },
+    { _S8( "count" ),              ECount },
+    { _S8( "timed-count" ),        ETimedCount },
+    { _S8( "datetime" ),           EDateTime },
+    { _S8( "start" ),              EStart },
+    { _S8( "end" ),                EEnd },
+    { _S8( "interval" ),           EInterval },
+    { _S8( "accumulated" ),        EAccumulated },
+    { _S8( "individual" ),         EIndividual },
+    { _S8( "export" ),             EExport },
+    { _S8( "system" ),             ESystem },
+    { _S8( "KeyValue" ),           EKeyValue },
+    { _S8( "software" ),           ESoftware },
+    { _S8( "property" ),           EProperty },
+    { _S8( "container" ),          EContainer },
+#ifdef RD_DRM_METERING
+    { _S8( "requirement" ),        ERequirement },
+    { _S8( "tracked" ),            ETracked },
+#endif //RD_DRM_METERING
+    };
+
+enum TParserStackState
+    {
+    EUnknownState = -1,
+    ERoUidState = 0,
+    ETopLevelConstraintState,
+    EDisplayConstraintState,
+    EPlayConstraintState,
+    EPrintConstraintState,
+    EExecuteConstraintState,
+    EDateTimeStartState,
+    EDateTimeEndState,
+    EIntervalState,
+    ECountState,
+    ETimedCountState,
+    EIndividualState,
+    EAgreementAssetState,
+    EPermissionAssetState,
+    EAssetUidState,
+    EAssetDigestState,
+    EAssetKeyState,
+    EEncryptedKeyState,
+    EAssetInheritUidState,
+    EPermissionState,
+    ESoftwareState,
+    EAccumulatedState,
+    EKeyInfoState,
+    ESystemState,
+    EExportConstraintState,
+#ifdef RD_DRM_METERING
+    ETrackRequirementState,
+#endif // RD_DRM_METERING
+    };
+
+struct TStackState
+    {
+    TParserStackState iState;
+    TElementEnum iStack[ KMaxElementNesting ];
+    };
+
+// Keep these sorted by the number of elements in the stack
+static const TStackState KParserStackStates[] =
+    {
+    // 5 elements
+    { EEncryptedKeyState, { ECipherValue, ECipherData, EEncryptedKey,
+                          EKeyInfo, EAsset, ELast } },
+    // 4 elements
+    { EAssetInheritUidState, { EUid, EContext, EInherit, EAsset, ELast } },
+    { EPermissionAssetState, { EAsset, EPermission, EAgreement, ::ERights,
+                             ELast } },
+    { ESoftwareState, { EProperty, EContext, ESoftware, EContainer, ELast } },
+    // 3 elements
+    { EAgreementAssetState, { EAsset, EAgreement, ::ERights, ELast } },
+    { EIndividualState, { EUid, EContext, EIndividual, ELast } },
+    { ESystemState, { EUid, EContext, ESystem, ELast } },
+    { ERoUidState, { EUid, EContext, ::ERights, ELast } },
+    { EAssetUidState, { EUid, EContext, EAsset, ELast } },
+    { EAssetDigestState, { EDigestValue, EDigest, EAsset, ELast } },
+    { EAssetKeyState, { EKeyValue, EKeyInfo, EAsset, ELast } },
+    // 2 elements
+    { EKeyInfoState, { EKeyInfo, EAsset, ELast } },
+    { ETopLevelConstraintState, { EConstraint, EPermission, ELast } },
+    { EDisplayConstraintState, { ::EDisplay, EPermission, ELast } },
+    { EPlayConstraintState, { ::EPlay, EPermission, ELast } },
+    { EPrintConstraintState, { ::EPrint, EPermission, ELast } },
+    { EExecuteConstraintState, { ::EExecute, EPermission, ELast } },
+    { EExportConstraintState, { EExport, EPermission, ELast } },
+#ifdef RD_DRM_METERING
+    { ETrackRequirementState, { ETracked, ERequirement, ELast } },
+#endif // RD_DRM_METERING
+    //1 element
+    { EDateTimeStartState, { EStart, ELast } },
+    { EDateTimeEndState, { EEnd, ELast } },
+    { EIntervalState, { EInterval, ELast } },
+    { ECountState, { ECount, ELast } },
+    { ETimedCountState, { ETimedCount, ELast } },
+    { EAccumulatedState, { EAccumulated, ELast } },
+    { EPermissionState, { EPermission, ELast } },
+    };
+
+// LOCAL FUNCTION PROTOTYPES
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::ValidateDay
+// Returns ETrue if the day is valid
+//         EFalse if the day is not valid
+//
+// If the month is January, March, May, July, August, October, December
+// - Check that the day is between 1 and 31
+// If the month is April, June, September, November
+// - Check that the day is between 1 and 30
+// If the month is February
+// - Check that the day is between 1 and 29,
+// - if it is 29 check that the following conditions are met in that order:
+//   * The year is dividable by 400 it's valid
+//   * The year is dividable by 100 it is not valid
+//   * The year is dividable by 4 it is valid
+// -----------------------------------------------------------------------------
+//
+
+TBool CDrmRightsParser::ValidateDay( TInt aYear, TMonth aMonth, TInt aDay )
+    {
+    TBool retVal = ETrue;
+
+    switch ( aMonth )
+        {
+        case EJanuary:
+        case EMarch:
+        case EMay:
+        case EJuly:
+        case EAugust:
+        case EOctober:
+        case EDecember:
+            {
+            if ( aDay < 0 || aDay > 30 )
+                {
+                retVal = EFalse;
+                }
+            }
+            break;
+        case EApril:
+        case EJune:
+        case ESeptember:
+        case ENovember:
+            {
+            if ( aDay < 0 || aDay > 29 )
+                {
+                retVal = EFalse;
+                }
+            }
+            break;
+        case EFebruary:
+            {
+            if ( aDay < 0 || aDay > 28 )
+                {
+                retVal = EFalse;
+                }
+            else
+                {
+                // If we are at day 29, it is possible that it is valid:
+                if ( aDay == 28 )
+                    {
+                    // if the year is dividable by 400 it is valid
+                    if ( ( aYear % 400 ) )
+                        {
+                        // if the year is dividable by 100 it is not valid
+                        if ( aYear % 100 )
+                            {
+                            // if the year is dividable by 4 it is valid
+                            if ( aYear % 4 )
+                                {
+                                retVal = EFalse;
+                                }
+                            }
+                        else
+                            {
+                            retVal = EFalse;
+                            }
+                        }
+                    }
+                }
+            }
+            break;
+        default:
+            retVal = EFalse;
+            break;
+        }
+    return retVal;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::ValidTimeValues
+// Returns ETrue if the time values are valid
+//         EFalse if any of them are valid
+// Checks done as per symbian documentations
+// -----------------------------------------------------------------------------
+//
+TBool CDrmRightsParser::ValidTimeValues( TInt aYear, TMonth aMonth,
+        TInt aDay, TInt aHour,
+        TInt aMinute, TInt aSecond,
+        TInt aMicrosecond )
+    {
+    // No check for Year
+
+    // check Month
+    if ( aMonth < EJanuary || aMonth > EDecember )
+        {
+        return EFalse;
+        }
+
+    // check Day
+    if ( !ValidateDay( aYear, aMonth, aDay ) )
+        {
+        return EFalse;
+        }
+
+    // check Hour
+    if ( aHour < 0 || aHour > 23 )
+        {
+        return EFalse;
+        }
+
+    // check Minute
+    if ( aMinute < 0 || aMinute > 59 )
+        {
+        return EFalse;
+        }
+
+    // check Second
+    if ( aSecond < 0 || aSecond > 59 )
+        {
+        return EFalse;
+        }
+
+    // check Microsecond
+    if ( aMicrosecond < 0 || aMicrosecond > 9999999 )
+        {
+        return EFalse;
+        }
+
+    return ETrue;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::ParseRelTime
+// Parses a ISO8601 relative time string
+// -----------------------------------------------------------------------------
+//
+TTime CDrmRightsParser::ParseRelTimeL( TDesC8& aRelTimeString )
+    {
+    TLex8 lex;
+    TInt year( 0 );
+    TInt month( 0 );
+    TInt day( 0 );
+    TInt hour( 0 );
+    TInt minute( 0 );
+    TInt second( 0 );
+    TTime r;
+    TTimeIntervalSeconds offset( 0 );
+
+    lex = aRelTimeString;
+    lex.Val( year );
+    lex.Inc();
+    lex.Val( month );
+    lex.Inc();
+    lex.Val( day );
+    lex.Inc();
+    lex.Val( hour );
+    lex.Inc();
+    lex.Val( minute );
+    lex.Inc();
+    lex.Val( second );
+
+
+    // The time needs to be validated before
+    if ( !ValidTimeValues( year, static_cast< TMonth >( month - 1 ), day - 1,
+                hour, minute, second, 0 ) )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    r = TTime( TDateTime( year, static_cast< TMonth >( month - 1 ), day - 1,
+                hour, minute, second, 0 ) );
+    if ( lex.Get() != 'Z' )
+        {
+        offset = iTimeZone * KSecondsPerTimeZone;
+        r -= offset;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::ParseRelInterval
+// Parses a ISO8601 relative interval string
+// -----------------------------------------------------------------------------
+//
+TTimeIntervalSeconds CDrmRightsParser::ParseRelInterval(
+        TDesC8& aRelTimeString )
+    {
+    TLex8 lex;
+    TInt year( 0 );
+    TInt month( 0 );
+    TInt day( 0 );
+    TInt hour( 0 );
+    TInt minute( 0 );
+    TInt second( 0 );
+    TInt n( 0 );
+    TTimeIntervalSeconds r( 0 );
+    TBool done( EFalse );
+    TBool inDate( ETrue );
+
+    lex = aRelTimeString;
+    lex.Inc();
+    while ( !done )
+        {
+        if ( lex.Peek() == 'T' )
+            {
+            lex.Inc();
+            inDate = EFalse;
+            }
+
+        lex.Val( n );
+        switch ( lex.Get() )
+            {
+            case 'Y':
+                year = n;
+                break;
+            case 'D':
+                day = n;
+                break;
+            case 'M':
+                if ( inDate )
+                    {
+                    month = n;
+                    }
+                else
+                    {
+                    minute = n;
+                    }
+                break;
+            case 'H':
+                hour = n;
+                break;
+            case 'S':
+                second = n;
+                break;
+            default:
+                done = ETrue;
+                break;
+            }
+        }
+
+    r = ( ( ( ( year * 365 + month * 30 + day ) * 24 + hour )
+                * 60 + minute ) * 60 + second );
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// DecodeAndDeleteUndecodedL()
+// Decodes base64 encoded HbufC8 buffer arcument, deletes undecoded buffer, and
+// substitutes argument with Decoded buffer
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void DecodeAndDeleteUndecodedL( HBufC8*& aDecodee )
+    {
+    HBufC8* b( aDecodee );
+    aDecodee = NULL;
+    CleanupStack::PushL( b );
+    aDecodee = Base64DecodeL( *b );
+    CleanupStack::PopAndDestroy( b );
+    }
+
+// -----------------------------------------------------------------------------
+// CopyOrLeaveL( TDes8& aDest, const TDesC8& aSrc )
+// Copies aSrc to aDest.
+// Leaves, if length of aSrc exceeds capacity of aDest
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void CopyOrLeaveL( TDes8& aDest, const TDesC8& aSrc )
+    {
+    if ( aSrc.Length() > aDest.MaxLength() )
+        {
+        User::Leave( KErrArgument );
+        }
+    aDest.Copy( aSrc );
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedAsset::NewL
+// -----------------------------------------------------------------------------
+//
+CDrmRightsParser::CParsedAsset*
+CDrmRightsParser::CParsedAsset::NewL()
+    {
+    CParsedAsset* self = new ( ELeave ) CParsedAsset;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedAsset::~CParsedAsset
+// -----------------------------------------------------------------------------
+//
+CDrmRightsParser::CParsedAsset::~CParsedAsset()
+    {
+    delete iUid;
+    delete iId;
+    delete iIdRef;
+    delete iInherit;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedAsset::ConstructL
+// Allocate the list of attribute values
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::CParsedAsset::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedAsset::CParsedAsset
+// -----------------------------------------------------------------------------
+//
+CDrmRightsParser::CParsedAsset::CParsedAsset():
+    iUid( NULL ),
+    iId( NULL ),
+    iIdRef( NULL ),
+    iInherit( NULL )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedPermission::NewL
+// -----------------------------------------------------------------------------
+//
+CDrmRightsParser::CParsedPermission*
+CDrmRightsParser::CParsedPermission::NewL()
+    {
+    CParsedPermission* self = new ( ELeave ) CParsedPermission;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedPermission::~CParsedPermission
+// -----------------------------------------------------------------------------
+//
+CDrmRightsParser::CParsedPermission::~CParsedPermission()
+    {
+    for ( TInt i( 0 ); i < iNotOwned; ++i )
+        {
+        iAssets.Remove( 0 );
+        }
+    iAssets.ResetAndDestroy();
+    iAssets.Close();
+    delete iTopLevel;
+    delete iPlay;
+    delete iDisplay;
+    delete iPrint;
+    delete iExecute;
+    delete iExport;
+    delete iOnExpiredUrl;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedPermission::SetCurrentConstraint
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::CParsedPermission::SetCurrentConstraint(
+        TRightsType aCurrentConstraint )
+    {
+    iAvailableRights |= aCurrentConstraint;
+    iCurrentConstraint = aCurrentConstraint;
+    }
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedPermission::RemoveInvalid
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::CParsedPermission::RemoveInvalidL()
+    {
+    TUint8 valid = ( iInvalidConstraints ^ ERightsAll ) & ERightsAll;
+    iAvailableRights &= valid;
+    if ( !valid )
+        {
+        iInvalid = ETrue;
+        }
+    if ( iInvalid || ( iInvalidConstraints & ERightsTopLevel ) )
+        {
+        iInvalid = ETrue;
+        ResetConstraintL( iTopLevel );
+        }
+    if ( iInvalid || ( iInvalidConstraints & ERightsPlay ) )
+        {
+        ResetConstraintL( iPlay );
+        }
+    if ( iInvalid || ( iInvalidConstraints & ERightsDisplay ) )
+        {
+        ResetConstraintL( iDisplay );
+        }
+    if ( iInvalid || ( iInvalidConstraints & ERightsExecute ) )
+        {
+        ResetConstraintL( iExecute );
+        }
+    if ( iInvalid || ( iInvalidConstraints & ERightsPrint ) )
+        {
+        ResetConstraintL( iPrint );
+        }
+    if ( iInvalid || ( iInvalidConstraints & ERightsExport ) )
+        {
+        ResetConstraintL( iExport );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedPermission::CParsedPermission
+// -----------------------------------------------------------------------------
+//
+CDrmRightsParser::CParsedPermission::CParsedPermission()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedPermission::ConstructL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::CParsedPermission::ConstructL()
+    {
+    iTopLevel = CDRMConstraint::NewL();
+    iPlay = CDRMConstraint::NewL();
+    iDisplay = CDRMConstraint::NewL();
+    iPrint = CDRMConstraint::NewL();
+    iExecute = CDRMConstraint::NewL();
+    iExport = CDRMConstraint::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedPermission::ResetConstraintL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::CParsedPermission::ResetConstraintL(
+    CDRMConstraint*& aConstraint )
+    {
+    delete aConstraint;
+    aConstraint = NULL;
+    aConstraint = CDRMConstraint::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedRightsObject::CParsedRightsObject
+// -----------------------------------------------------------------------------
+//
+CDrmRightsParser::CParsedRightsObject::CParsedRightsObject():
+    iRightsObjectId( NULL ),
+    iCurrentAsset( NULL ),
+    iCurrentPermission( NULL ),
+    iCurrentConstraint( NULL )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedRightsObject::~CParsedRightsObject
+// -----------------------------------------------------------------------------
+//
+CDrmRightsParser::CParsedRightsObject::~CParsedRightsObject()
+    {
+    delete iRightsObjectId;
+    iAssets.ResetAndDestroy();
+    iAssets.Close();
+    iPermissions.ResetAndDestroy();
+    iPermissions.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CParsedRightsObject::RemoveInvalid
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::CParsedRightsObject::RemoveInvalid()
+    {
+    if ( iPermissions.Count() == 0 )
+        {
+        return;
+        }
+    for ( TInt j( 0 ); j < iPermissions.Count(); ++j )
+        {
+        CDrmRightsParser::CParsedPermission* permission( NULL );
+        permission = iPermissions[ j ];
+        if ( permission->iInvalid )
+            {
+            iPermissions.Remove( j );
+            delete permission;
+            }
+        permission = NULL;
+        }
+    if ( iPermissions.Count() == 0 )
+        {
+        iInvalid = ETrue;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::CDrmRightsParser
+// -----------------------------------------------------------------------------
+//
+CDrmRightsParser::CDrmRightsParser():
+    iParser( NULL ),
+    iRights( NULL ),
+    iContent( NULL ),
+    iUnknownTag( NULL )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::ConstructL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::ConstructL(
+        TParserType aType )
+    {
+    TTime currentUniversal;
+    TTime currentLocal;
+    TInt64 result( 0 );
+
+    currentUniversal.UniversalTime();
+    currentLocal.HomeTime();
+
+    result = currentLocal.Int64() - currentUniversal.Int64();
+    result /= KMinuteInMicroseconds;
+    result /= KTimeZoneIncrement;
+
+    iTimeZone = I64INT( result );
+
+    iParserType = aType;
+    if ( aType == EXmlParser )
+        {
+        iParser = CParser::NewL( KXmlParserMimeType, *this );
+        }
+    else
+        {
+        iParser = CParser::NewL( KWbxmlParserMimeType, *this );
+        }
+
+    for ( TInt i( 0 ); i < ELEMENT_COUNT( KElements ); i++ )
+        {
+        TPtrC8 ptr( KElements[ i ].iString,
+                User::StringLength( KElements[ i ].iString ) );
+        iElements[ KElements[ i ].iNumber ] =
+            iParser->StringPool().OpenStringL( ptr );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDrmRightsParser* CDrmRightsParser::NewL(
+        TParserType aType )
+    {
+    CDrmRightsParser* self( new ( ELeave ) CDrmRightsParser );
+
+    CleanupStack::PushL( self );
+    self->ConstructL( aType );
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+
+// Destructor
+EXPORT_C CDrmRightsParser::~CDrmRightsParser()
+    {
+    for ( TInt i( 0 ); i < ELEMENT_COUNT( KElements ); i++ )
+        {
+        iElements[ KElements[ i ].iNumber ].Close();
+        }
+    delete iParser;
+    delete iRights;
+    delete iContent;
+    delete iUnknownTag;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::ParseL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDrmRightsParser::ParseL(
+        const TDesC8& aRightsObject,
+        RPointerArray< CDRMRights >& aResultRights )
+    {
+    TInt i( 0 );
+
+    iElementStackDepth = 0;
+    delete iRights;
+    iRights = NULL;
+    delete iContent;
+    iContent = NULL;
+    iRights = new ( ELeave ) CParsedRightsObject;
+    iParser->ParseBeginL();
+    if ( iParserType == EWbxmlParser )
+        {
+        iParser->EnableFeature( ERawContent );
+        }
+
+    while ( i < aRightsObject.Length() )
+        {
+        TInt n( Min( aRightsObject.Length() - i, KParserChunkSize ) );
+        iParser->ParseL( aRightsObject.Mid( i, n ) );
+        i += n;
+        }
+    iParser->ParseEndL();
+    TransformRightsObjectL( aResultRights );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::ParseAndStoreL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDrmRightsParser::ParseAndStoreL(
+        const TDesC8& aRightsObject,
+        RPointerArray< CDRMRights >& aResultRights )
+    {
+    RDRMRightsClient client;
+
+    User::LeaveIfError( client.Connect() );
+    CleanupClosePushL( client );
+    ParseL( aRightsObject, aResultRights );
+    for ( TInt i( 0 ); i < aResultRights.Count(); i++ )
+        {
+        TDRMUniqueID id;
+        HBufC8 *cid( NULL );
+        CDRMRights* rights( aResultRights[ i ] );
+        rights->GetContentURI( cid );
+        if ( rights->GetAsset().iKey.Length() == 0 )
+            {
+            for ( TInt j( 0 ); j < KDCFKeySize; j++ )
+                {
+                rights->GetAsset().iKey.Append( Math::Random() );
+                }
+            }
+        client.AddRecord( rights->GetAsset().iKey, rights->GetPermission(),
+                *cid, id );
+        rights->SetLocalID( id );
+        delete cid;
+        }
+
+    CleanupStack::PopAndDestroy( &client );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnStartDocumentL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnStartDocumentL(
+        const RDocumentParameters& /*aDocParam*/,
+        TInt /*aErrorCode*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnEndDocumentL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnEndDocumentL(
+        TInt /*aErrorCode*/ )
+    {
+    if ( iRights )
+        {
+        // Remove invalid parsed permissions,
+        // and invalidate parsed rights object,
+        // if there are no valid ROs left
+        iRights->RemoveInvalid();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnStartElementL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnStartElementL(
+        const RTagInfo& aElement,
+        const RAttributeArray& aAttributes,
+        TInt /*aErrorCode*/ )
+    {
+    TBool tagRecognized( EFalse );
+
+    if ( iUnknownTag )
+        {
+        return;
+        }
+    if ( iContent )
+        {
+        delete iContent;
+        iContent = NULL;
+        iContent = HBufC8::NewL( 0 );
+        }
+
+    for ( TInt i( 0 ); i < KMaxElementCount; i++ )
+        {
+        if ( aElement.LocalName() == iElements[ i ] )
+            {
+            tagRecognized = ETrue;
+            iElementStack[ iElementStackDepth ] =
+                static_cast< TElementEnum >( i );
+            iElementStackDepth++;
+            if ( iElementStackDepth == KMaxElementNesting )
+                {
+                User::Leave( EXmlUnexpectedState );
+                }
+            break;
+            }
+        }
+    if ( tagRecognized )
+        {
+        TLex8 lex;
+        HBufC8* b( NULL );
+        TInt n( 0 );
+
+        switch ( MatchStackState() )
+            {
+            case ETopLevelConstraintState:
+                iRights->iCurrentPermission->SetCurrentConstraint(
+                    ERightsTopLevel );
+                iRights->iCurrentConstraint =
+                    iRights->iCurrentPermission->iTopLevel;
+                break;
+            case EDisplayConstraintState:
+                iRights->iCurrentPermission->SetCurrentConstraint(
+                    ERightsDisplay );
+                iRights->iCurrentConstraint =
+                    iRights->iCurrentPermission->iDisplay;
+                break;
+            case EPlayConstraintState:
+                iRights->iCurrentPermission->SetCurrentConstraint(
+                    ERightsPlay );
+                iRights->iCurrentConstraint =
+                    iRights->iCurrentPermission->iPlay;
+                break;
+            case EPrintConstraintState:
+                iRights->iCurrentPermission->SetCurrentConstraint(
+                    ERightsPrint );
+                iRights->iCurrentConstraint =
+                    iRights->iCurrentPermission->iPrint;
+                break;
+            case EExecuteConstraintState:
+                iRights->iCurrentPermission->SetCurrentConstraint(
+                    ERightsExecute );
+                iRights->iCurrentConstraint =
+                    iRights->iCurrentPermission->iExecute;
+                break;
+            case EExportConstraintState:
+                iRights->iCurrentPermission->SetCurrentConstraint(
+                    ERightsExport );
+                iRights->iCurrentConstraint =
+                    iRights->iCurrentPermission->iExport;
+                break;
+            case EAgreementAssetState:
+                iRights->iCurrentAsset = CParsedAsset::NewL();
+                iRights->iCurrentAsset->iId =
+                    GetAttributeValueL( aAttributes, KIdAttribute );
+                iRights->iCurrentAsset->iIdRef =
+                    GetAttributeValueL( aAttributes, KIdRefAttribute );
+                iRights->iAssets.Append( iRights->iCurrentAsset );
+                break;
+            case EPermissionAssetState:
+                iRights->iCurrentAsset = CParsedAsset::NewL();
+                iRights->iCurrentAsset->iId =
+                    GetAttributeValueL( aAttributes, KIdAttribute );
+                iRights->iCurrentAsset->iIdRef =
+                    GetAttributeValueL( aAttributes, KIdRefAttribute );
+                iRights->iCurrentPermission->iAssets.Append(
+                        iRights->iCurrentAsset );
+                break;
+            case EPermissionState:
+                iRights->iCurrentPermission = CParsedPermission::NewL();
+                iRights->iPermissions.Append(
+                        iRights->iCurrentPermission );
+                iRights->iCurrentPermission->iOnExpiredUrl =
+                    GetAttributeValueL( aAttributes, KOnExpiredUrlAttribute );
+                break;
+            case ESoftwareState:
+                b = GetAttributeValueL( aAttributes, KSchemaAttribute );
+                if ( !b )
+                    {
+                    b = GetAttributeValueL( aAttributes, KSchemeAttribute );
+                    }
+                if ( !b )
+                    {
+                    User::Leave( KErrArgument );
+                    }
+                CleanupStack::PushL( b );
+                if ( b->CompareF( KSchemaSymbianSid ) == 0 &&
+                        iRights->iCurrentConstraint->iSecureId ==
+                        TUid::Null() )
+                    {
+                    iSoftwareSchemeType = ESymbianSid;
+                    }
+                else if ( b->CompareF( KSchemaSymbianVid ) == 0 &&
+                        iRights->iCurrentConstraint->iVendorId ==
+                        TUid::Null() )
+                    {
+                    iSoftwareSchemeType = ESymbianVid;
+                    }
+                else
+                    {
+                    User::Leave( KErrNotSupported );
+                    }
+                CleanupStack::PopAndDestroy( b );
+                break;
+            case ETimedCountState:
+                b = GetAttributeValueL( aAttributes, KTimerAttribute );
+                if ( !b )
+                    {
+                    User::Leave( KErrArgument );
+                    }
+                CleanupStack::PushL( b );
+                lex = *b;
+                lex.Val( n );
+                if ( n < 0 )
+                    {
+                    User::Leave( KErrArgument );
+                    }
+                iRights->iCurrentConstraint->iTimedInterval = n;
+                CleanupStack::PopAndDestroy( b );
+                break;
+            case EKeyInfoState:
+                b = GetAttributeValueL( aAttributes, KIdAttrUpperCase );
+                if ( b && b->Right( KAuthSeed().Length() ).Compare(
+                            KAuthSeed ) == 0 )
+                    {
+                    iRights->iKeyIsCek = EFalse;
+                    delete b;
+                    }
+                else
+                    {
+                    iRights->iKeyIsCek = ETrue;
+                    }
+                break;
+#ifdef RD_DRM_METERING
+            case ETrackRequirementState:
+                if ( !iRights->iCurrentConstraint ||
+                     !iRights->iCurrentPermission ||
+                     iRights->iCurrentConstraint ==
+                     iRights->iCurrentPermission->iTopLevel )
+                    {
+                    User::Leave( KErrArgument );
+                    }
+                if ( !iRights->iCurrentConstraint->iDrmMeteringInfo )
+                    {
+                    iRights->iCurrentConstraint->iDrmMeteringInfo =
+                        new ( ELeave ) CDRMConstraint::TDrmMeteringInfo;
+                    }
+                b = GetAttributeValueL( aAttributes, KTimedAttribute );
+                if ( b )
+                    {
+                    CleanupStack::PushL( b );
+                    lex = *b;
+                    if ( lex.Val( n ) != KErrNone )
+                        {
+                        // given input does not fit to TInt
+                        User::Leave( KErrArgument );
+                        }
+                    iRights->iCurrentConstraint->iDrmMeteringInfo->iGraceTime = n;
+
+                    CleanupStack::PopAndDestroy( b );
+                    b = NULL; 
+                    }
+                b = GetAttributeValueL( aAttributes, KContentAccessGrantedAttribute );
+                // put value to content access granted without metering
+                if ( b && !b->CompareF( KContentAccessGrantedValueTrue ) )
+                    {
+                    iRights->iCurrentConstraint->iDrmMeteringInfo->iAllowUseWithoutMetering = ETrue;
+                    }
+                else
+                    {
+                    iRights->iCurrentConstraint->iDrmMeteringInfo->iAllowUseWithoutMetering = EFalse;
+                    }
+                delete b;
+                break;
+#endif // RD_DRM_METERING
+            }
+        }
+    if ( !tagRecognized && iElementStackDepth > 0 &&
+            iElementStack[ 0 ] == ::ERights )
+        {
+        //Found unrecognised tag in <(o-ex:)rights>. Let's ignore its content.
+        iUnknownTag = aElement.LocalName().DesC().AllocL();
+        if ( iRights && iRights->iCurrentPermission )
+            {
+            iRights->iCurrentPermission->iInvalidConstraints |=
+                iRights->iCurrentPermission->iCurrentConstraint;
+            if ( iRights->iCurrentPermission->iCurrentConstraint
+                    == ERightsTopLevel )
+                {
+                iRights->iCurrentPermission->iInvalid = ETrue;
+                }
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnEndElementL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnEndElementL(
+        const RTagInfo& aElement,
+        TInt /*aErrorCode*/ )
+    {
+    if ( iUnknownTag )
+        {
+        if ( !iUnknownTag->Compare( aElement.LocalName().DesC() ) )
+            {
+            delete iUnknownTag;
+            iUnknownTag = NULL;
+            }
+        return;
+        }
+
+    for ( TInt i ( 0 ); i < KMaxElementCount; i++ )
+        {
+        if ( aElement.LocalName() == iElements[ i ] )
+            {
+            switch ( MatchStackState() )
+                {
+                case ERoUidState:
+                    iContent->Des().Trim(); // remove ignorable white spaces
+                    iRights->iRightsObjectId = iContent->AllocL();
+                    break;
+                case EDateTimeStartState:
+                    if ( iRights->iCurrentConstraint )
+                        {
+                        iRights->iCurrentConstraint->iActiveConstraints |=
+                            EConstraintStartTime;
+                        iRights->iCurrentConstraint->iStartTime =
+                            ParseRelTimeL( *iContent );
+                        }
+                    break;
+                case EDateTimeEndState:
+                    if ( iRights->iCurrentConstraint )
+                        {
+                        iRights->iCurrentConstraint->iActiveConstraints |=
+                            EConstraintEndTime;
+                        iRights->iCurrentConstraint->iEndTime =
+                            ParseRelTimeL( *iContent );
+                        }
+                    break;
+                case EIntervalState:
+                    if ( iRights->iCurrentConstraint )
+                        {
+                        iRights->iCurrentConstraint->iActiveConstraints |=
+                            EConstraintInterval;
+                        iRights->iCurrentConstraint->iInterval =
+                            ParseRelInterval( *iContent );
+                        iRights->iCurrentConstraint->iIntervalStart =
+                            Time::NullTTime();
+                        if ( iRights->iCurrentConstraint->iInterval.Int()
+                                <= 0 )
+                            {
+                            User::Leave( KErrArgument );
+                            }
+                        }
+                    break;
+                case EAccumulatedState:
+#ifndef __DRM_OMA2
+                    User::Leave( KErrArgument );
+#endif
+                    if ( iRights->iCurrentConstraint )
+                        {
+                        iRights->iCurrentConstraint->iActiveConstraints |=
+                            EConstraintAccumulated;
+                        iRights->iCurrentConstraint->iAccumulatedTime =
+                            ParseRelInterval( *iContent ).Int();
+                        if ( iRights->iCurrentConstraint->
+                                iAccumulatedTime.Int() <= 0 )
+                            {
+                            User::Leave( KErrArgument );
+                            }
+                        }
+                    break;
+                case ECountState:
+                    if ( iRights->iCurrentConstraint )
+                        {
+                        TLex8 lex( *iContent );
+                        iRights->iCurrentConstraint->iActiveConstraints |=
+                            EConstraintCounter;
+                        lex.Val( iRights->iCurrentConstraint->
+                                iOriginalCounter );
+                        iRights->iCurrentConstraint->iCounter =
+                            iRights->iCurrentConstraint->iOriginalCounter;
+                        if ( iRights->iCurrentConstraint->iCounter <= 0 ||
+                                iRights->iCurrentConstraint->iCounter >
+                                KDRMCounterMax )
+                            {
+                            User::Leave( KErrArgument );
+                            }
+                        }
+                    break;
+                case ETimedCountState:
+#ifndef __DRM_OMA2
+                    User::Leave( KErrArgument );
+#endif
+                    if ( iRights->iCurrentConstraint )
+                        {
+                        CDRMConstraint* c( iRights->iCurrentConstraint );
+                        TLex8 lex( *iContent );
+                        lex.Val( c->iOriginalTimedCounter );
+                        if ( c->iOriginalTimedCounter <= 0 ||
+                                c->iOriginalTimedCounter > KDRMCounterMax )
+                            {
+                            User::Leave( KErrArgument );
+                            }
+                        if ( c->iTimedInterval.Int() > 0 )
+                            {
+                            c->iActiveConstraints |= EConstraintTimedCounter;
+                            c->iTimedCounter = c->iOriginalTimedCounter;
+                            }
+                        else
+                            {
+                            c->iActiveConstraints |= EConstraintCounter;
+                            c->iOriginalCounter = c->iOriginalTimedCounter;
+                            c->iCounter = c->iOriginalCounter;
+                            c->iOriginalTimedCounter = 0;
+                            }
+                        }
+                    break;
+                case ESystemState:
+#ifndef __DRM_OMA2
+                    User::Leave( KErrArgument );
+#endif
+                    if ( iRights->iCurrentConstraint )
+                        {
+                        HBufC8* b( iContent->AllocLC() );
+                        iRights->iCurrentConstraint->iSystem.AppendL( b );
+                        CleanupStack::Pop( b );
+                        iRights->iCurrentConstraint->iActiveConstraints |=
+                            EConstraintSystem;
+                        }
+                    break;
+                case EAssetUidState:
+                    iContent->Des().Trim(); // remove ignorable white spaces
+                    if ( !iRights->iCurrentAsset )
+                        {
+                        User::Leave( KErrArgument );
+                        }
+                    iRights->iCurrentAsset->iUid = iContent->AllocL();
+                    break;
+                case EAssetDigestState:
+                    if ( iParserType == EXmlParser )
+                        {
+                        DecodeAndDeleteUndecodedL( iContent );
+                        }
+                    CopyOrLeaveL( iRights->iCurrentAsset->iDigest, *iContent );
+                    break;
+                case EAssetKeyState:
+                    if ( iParserType == EXmlParser )
+                        {
+                        DecodeAndDeleteUndecodedL( iContent );
+                        }
+                    CopyOrLeaveL( iRights->iCurrentAsset->iKey, *iContent );
+                    break;
+                case EEncryptedKeyState:
+                    if ( iParserType == EXmlParser )
+                        {
+                        DecodeAndDeleteUndecodedL( iContent );
+                        }
+                    if ( iRights->iKeyIsCek )
+                        {
+                        CopyOrLeaveL(
+                            iRights->iCurrentAsset->iProtectedKey, *iContent );
+                        }
+                    else
+                        {
+                        CopyOrLeaveL(
+                            iRights->iCurrentAsset->iProtectedAuthSeed,
+                            *iContent );
+                        }
+                    break;
+                case EAssetInheritUidState:
+                    iContent->Des().Trim(); // remove ignorable white spaces
+                    iRights->iCurrentAsset->iInherit = iContent->AllocL();
+                    break;
+                case EIndividualState:
+#ifndef __DRM_OMA2
+                    User::Leave( KErrArgument );
+#endif
+                    if ( iRights->iCurrentConstraint )
+                        {
+                        HBufC8* b( NULL );
+                        iRights->iCurrentConstraint->iActiveConstraints |=
+                            EConstraintIndividual;
+                        iContent->Des().Trim(); // remove ignorable white spaces
+                        b = iContent->AllocLC();
+                        iRights->iCurrentConstraint->iIndividual.AppendL( b );
+                        CleanupStack::Pop( b );
+                        }
+                    break;
+                case ESoftwareState:
+#ifndef __DRM_OMA2
+                    User::Leave( KErrArgument );
+#endif
+                    if ( iRights->iCurrentConstraint )
+                        {
+                        TUint32 n( 0 );
+                        TLex8 lex( *iContent );
+                        User::LeaveIfError( lex.Val( n, EHex ) );
+                        if ( iSoftwareSchemeType == ESymbianSid )
+                            {
+                            iRights->iCurrentConstraint->iActiveConstraints |=
+                                EConstraintSoftware;
+                            iRights->iCurrentConstraint->iSecureId =
+                                TUid::Uid( n );
+                            }
+                        else
+                            {
+                            iRights->iCurrentConstraint->iActiveConstraints |=
+                                EConstraintVendor;
+                            iRights->iCurrentConstraint->iVendorId =
+                                TUid::Uid( n );
+                            }
+                        }
+                    break;
+                case EExportConstraintState:
+                case ETopLevelConstraintState:
+#ifndef __DRM_OMA2
+                    User::Leave( KErrArgument );
+#endif
+                case EDisplayConstraintState:
+                case EPlayConstraintState:
+                case EPrintConstraintState:
+                case EExecuteConstraintState:
+                    iRights->iCurrentConstraint = NULL;
+                    iRights->iCurrentPermission->iCurrentConstraint = 0;
+                    break;
+                case EPermissionState:
+                    iRights->iCurrentPermission->RemoveInvalidL();
+                    iRights->iCurrentPermission = NULL;
+                    break;
+
+                }
+            iElementStackDepth--;
+            if ( iElementStackDepth < 0 )
+                {
+                User::Leave( EXmlUnexpectedState );
+                }
+            break;  // no need to iterate after element name matched
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnContentL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnContentL(
+        const TDesC8& aBytes,
+        TInt /*aErrorCode*/ )
+    {
+    if ( iUnknownTag )
+        {
+        return;
+        }
+    if ( !iContent )
+        {
+        iContent = HBufC8::NewL( aBytes.Size() );
+        *iContent = aBytes;
+        }
+    else
+        {
+        iContent = iContent->ReAllocL( iContent->Size() + aBytes.Size() );
+        TPtr8 c( iContent->Des() );
+        c.Append( aBytes );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnStartPrefixMappingL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnStartPrefixMappingL(
+        const RString& /*aPrefix*/,
+        const RString& /*aUri*/,
+        TInt /*aErrorCode*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnEndPrefixMappingL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnEndPrefixMappingL(
+        const RString& /*aPrefix*/,
+        TInt /*aErrorCode*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnIgnorableWhiteSpaceL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnIgnorableWhiteSpaceL(
+        const TDesC8& /*aBytes*/,
+        TInt /*aErrorCode*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnSkippedEntityL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnSkippedEntityL(
+        const RString& /*aName*/,
+        TInt /*aErrorCode*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnProcessingInstructionL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnProcessingInstructionL(
+        const TDesC8& /*aTarget*/,
+        const TDesC8& /*aData*/,
+        TInt /*aErrorCode*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnOutOfData
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnOutOfData()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::OnError
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::OnError(
+        TInt /*aErrorCode*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::GetExtendedInterface
+// -----------------------------------------------------------------------------
+//
+TAny* CDrmRightsParser::GetExtendedInterface(
+        const TInt32 /*aUid*/ )
+    {
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::MatchStackState
+// -----------------------------------------------------------------------------
+//
+TInt CDrmRightsParser::MatchStackState( void )
+    {
+    TParserStackState r( EUnknownState );
+
+    for ( TInt i( 0 );
+            r == EUnknownState &&
+            i < ELEMENT_COUNT( KParserStackStates ); i++ )
+        {
+        TInt j( 0 );
+        TInt k( 0 );
+        for ( j = iElementStackDepth - 1, k = 0;
+                j > 0 && KParserStackStates[ i ].iStack[ k ] != ELast;
+                j--, k++ )
+            {
+            if ( iElementStack[ j ] != KParserStackStates[ i ].iStack[ k ] )
+                {
+                break;
+                }
+            }
+        if ( ( j == 0 &&
+               iElementStack[ j ] == KParserStackStates[ i ].iStack[ k ] &&
+               KParserStackStates[ i ].iStack[ k + 1 ] == ELast ) ||
+             KParserStackStates[ i ].iStack[ k ] == ELast )
+            {
+            r = KParserStackStates[ i ].iState;
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::TransformRightsObjectL
+// -----------------------------------------------------------------------------
+//
+void CDrmRightsParser::TransformRightsObjectL(
+        RPointerArray< CDRMRights >& aResult )
+    {
+    CParsedAsset* asset( NULL );
+    CDRMRights* rights( NULL );
+    CParsedPermission* permission( NULL );
+    CDRMPermission *ro( CDRMPermission::NewLC() );
+    CDRMAsset* a( NULL );
+    HBufC8* id( NULL );
+    HBufC8* idRef( NULL );
+
+    // If no permissions are given, create an empty RO.
+    // The procedure is quite different
+    // than processing the permissions
+    if ( iRights->iInvalid )
+        {
+        //The RO is invalid. Let's leave
+        User::Leave( KErrArgument );
+        }
+    if ( iRights->iPermissions.Count() == 0 )
+        {
+        for ( TInt i( 0 ); i < iRights->iAssets.Count(); i++ )
+            {
+            asset = iRights->iAssets[ i ];
+            // No uid for the asset, it's an invalid asset
+            if( !asset->iUid )
+                {
+                continue;
+                }
+
+            rights = CDRMRights::NewL();
+            CleanupStack::PushL( rights );
+
+            a = CDRMAsset::NewLC();
+            a->iDigest.Copy( asset->iDigest );
+            a->iKey.Copy( asset->iKey );
+            a->iProtectedKey.Copy( asset->iProtectedKey );
+            a->iAuthenticationSeed.Copy( asset->iAuthenticationSeed );
+            a->iProtectedAuthSeed.Copy( asset->iProtectedAuthSeed );
+
+            // guaranteed not to be NULL UID in this phase
+            a->iUid = asset->iUid->AllocL();
+
+            if ( ro->iParentUID )
+                {
+                delete ro->iParentUID;
+                ro->iParentUID = NULL;
+                }
+            if ( asset->iInherit )
+                {
+                a->iParentRights = asset->iInherit->AllocL();
+                ro->iParentUID = asset->iInherit->AllocL();
+                }
+            rights->SetAssetL( *a );
+            CleanupStack::PopAndDestroy( a );
+
+            // by default, set the RO version as OMA 1.0
+            ro->iRightsObjectVersion.iVersionMain = EOma1Rights;
+            rights->SetPermissionL( *ro );
+
+            // Warning: assuming RPointerArray
+            // does not put its argument to clenaupstack
+            aResult.AppendL( rights );
+            CleanupStack::Pop( rights );
+            }
+        }
+    else for ( TInt i( 0 ); i < iRights->iPermissions.Count(); i++ )
+        {
+        permission = iRights->iPermissions[ i ];
+        if ( permission->iInvalid )
+            {
+            // The permission under test is invalid, so let's move forward
+            continue;
+            }
+        if ( permission->iAssets.Count() > 0 )
+            {
+            // The permission refers to asset elements in the RO,
+            // add all referenced assets to the permission
+            for ( TInt j( 0 ); j < permission->iAssets.Count(); j++ )
+                {
+                TInt k( 0 );
+                for ( ; k < iRights->iAssets.Count(); k++ )
+                    {
+                    id = iRights->iAssets[ k ]->iId;
+                    idRef = permission->iAssets[ j ]->iIdRef;
+                    if ( id && idRef && *id == *idRef )
+                        {
+                        break;
+                        }
+                    }
+                if ( k < iRights->iAssets.Count() )
+                    {
+                    asset = permission->iAssets[ j ];
+                    permission->iAssets[ j ] = iRights->iAssets[ k ];
+                    delete asset;
+                    permission->iNotOwned++;
+                    }
+                }
+            }
+        else
+            {
+            // The permission does not refer to an asset explictly,
+            // link all assets in the RO to this permission
+            for ( TInt j( 0 ); j < iRights->iAssets.Count(); j++ )
+                {
+                permission->iAssets.Append( iRights->iAssets[ j ] );
+                permission->iNotOwned++;
+                }
+            }
+
+        for ( TInt j( 0 ); j < permission->iAssets.Count(); j++ )
+            {
+            asset = permission->iAssets[ j ];
+            // No uid for the asset, it's an invalid asset
+            if( !asset->iUid )
+                {
+                continue;
+                }
+
+            rights = CDRMRights::NewL();
+            CleanupStack::PushL( rights );
+
+            a = CDRMAsset::NewLC();
+            a->iDigest.Copy( asset->iDigest );
+            a->iKey.Copy( asset->iKey );
+            a->iProtectedKey.Copy( asset->iProtectedKey );
+            a->iAuthenticationSeed.Copy( asset->iAuthenticationSeed );
+            a->iProtectedAuthSeed.Copy( asset->iProtectedAuthSeed );
+
+            // guaranteed not to be NULL UID in this phase
+            a->iUid = asset->iUid->AllocL();
+
+            if ( ro->iParentUID )
+                {
+                delete ro->iParentUID;
+                ro->iParentUID = NULL;
+                }
+            if ( asset->iInherit )
+                {
+                a->iParentRights = asset->iInherit->AllocL();
+                ro->iParentUID = asset->iInherit->AllocL();
+                }
+            rights->SetAssetL( *a );
+            CleanupStack::PopAndDestroy( a );
+
+
+            // ( == iOnExpiredUrl must not be referred elsewhere)
+            ro->iOnExpiredUrl = permission->iOnExpiredUrl;
+            permission->iOnExpiredUrl = NULL;
+
+            ro->iAvailableRights = permission->iAvailableRights;
+            ro->iDisplay->DuplicateL( *permission->iDisplay );
+            ro->iPlay->DuplicateL( *permission->iPlay );
+            ro->iPrint->DuplicateL( *permission->iPrint );
+            ro->iExecute->DuplicateL( *permission->iExecute );
+            ro->iExport->DuplicateL( *permission->iExport );
+            ro->iTopLevel->DuplicateL( *permission->iTopLevel );
+            // by default, set the RO version as OMA 1.0
+            ro->iRightsObjectVersion.iVersionMain = EOma1Rights;
+            rights->SetPermissionL( *ro );
+
+            aResult.AppendL( rights );
+            CleanupStack::Pop( rights );
+            }
+        }
+    CleanupStack::PopAndDestroy( ro );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRightsParser::GetAttributeValueL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDrmRightsParser::GetAttributeValueL(
+        const RAttributeArray& aAttrList,
+        const TDesC8& aAttrName )
+    {
+    HBufC8* r( NULL );
+    RAttribute a;
+
+    for ( TInt i( 0 ); !r && i < aAttrList.Count(); i++ )
+        {
+        a = aAttrList[ i ];
+        if ( a.Attribute().LocalName().DesC().Compare( aAttrName ) == 0 )
+            {
+            r = a.Value().DesC().AllocL();
+            }
+        }
+    return r;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/DeviceHello.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,145 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef DEVICEHELLO_H
+#define DEVICEHELLO_H
+
+//  INCLUDES
+
+#include "hash.h"
+#include "RoapMessage.h"
+
+namespace Roap
+{
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CDeviceHello : public CRoapMessage
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDeviceHello* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CDeviceHello();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        virtual HBufC8* MessageAsXmlL(void);
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        virtual void GetDeviceIdsAsXmlL(CBufFlat* aBuffer);
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+        
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDeviceHello();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CDeviceHello( const CDeviceHello& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CDeviceHello& operator=( const CDeviceHello& );
+
+    public:     // Data
+        
+        // Device ID. SHA1 hash array of the public keys
+        RArray< TBuf8<SHA1_HASH> > iDeviceIdArray;
+
+        // Supported ROAP Version
+        TBuf8<KMaxRoapVersionLength> iVersion;
+
+        // Optional nonce from the trigger
+        HBufC8* iTriggerNonce;
+        
+        // Supported algorithms
+        RArray<TPtrC8> iAlgorithms;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // DEVICEHELLO_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/JoinDomainReq.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,164 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef JOINDOMAINREQ_H
+#define JOINDOMAINREQ_H
+
+//  INCLUDES
+#include <hash.h>
+#include "RoapMessage.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CJoinDomainReq : public CRoapMessage
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CJoinDomainReq* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CJoinDomainReq();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        virtual HBufC8* MessageAsXmlL(void);
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CJoinDomainReq();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CJoinDomainReq( const CJoinDomainReq& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CJoinDomainReq& operator=( const CJoinDomainReq& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        TBuf8<SHA1_HASH> iDeviceId;
+        TBuf8<SHA1_HASH> iRiId;
+        HBufC8* iDomainId;
+        TBuf8<KDeviceNonceLength> iNonce;
+        TTime iTime;
+        RPointerArray<HBufC8> iCertificateChain;
+        HBufC8* iOcspResponderKeyId;
+        TBuf8<SHA1_HASH> iPeerKeyIdentifier;
+        TBool iOcspInfoStored;
+        TBool iHashChainSupport;
+        HBufC8* iSignature;
+
+        // Optional nonce from the trigger
+        HBufC8* iTriggerNonce;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // JOINDOMAINREQ_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/JoinDomainResp.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,166 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef JOINDOMAINRESP_H
+#define JOINDOMAINRESP_H
+
+//  INCLUDES
+#include <hash.h>
+#include "RoapMessage.h"
+#include "DrmRightsClient.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CJoinDomainResp : public CRoapMessage
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CJoinDomainResp* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CJoinDomainResp();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CJoinDomainResp();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CJoinDomainResp( const CJoinDomainResp& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CJoinDomainResp& operator=( const CJoinDomainResp& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        TRoapStatus iStatus;
+        TBuf8<SHA1_HASH> iDeviceId;
+        TBuf8<SHA1_HASH> iRiId;
+        TBuf8<SHA1_HASH> iDomainKeyRiId;
+        RPointerArray<HBufC8> iMacs;
+                
+        TTime iDomainExpiration;
+        TBool iHashChainSupport;
+        RPointerArray<HBufC8> iDomainKeys;
+        RPointerArray<HBufC8> iCertificateChain;
+        RPointerArray<HBufC8> iOcspResponse;
+        HBufC8* iSignature;
+        HBufC8* iErrorUrl;
+        RPointerArray<HBufC8> iDomainKeyIDs;
+        TKeyTransportScheme iTransportScheme;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // JOINDOMAINRESP_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/JoinDomainRespParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,140 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef JOINDOMAINRESPPARSER_H
+#define JOINDOMAINRESPPARSER_H
+
+//  INCLUDES
+#include "RespParser.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+class CJoinDomainResp;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class TJoinDomainRespParser : public MRespParser
+    {
+    public: // Constructors
+
+        TJoinDomainRespParser(
+            CJoinDomainResp* aResponse);
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        virtual void OnStartElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement,
+            const RAttributeArray& aAttributes);
+
+        virtual void OnEndElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement);
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+        CJoinDomainResp* iResponse;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // JOINDOMAINRESPPARSER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/LeaveDomainReq.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,160 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef LEAVEDOMAINREQ_H
+#define LEAVEDOMAINREQ_H
+
+//  INCLUDES
+#include <hash.h>
+#include "RoapMessage.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CLeaveDomainReq : public CRoapMessage
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CLeaveDomainReq* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CLeaveDomainReq();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        virtual HBufC8* MessageAsXmlL(void);
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CLeaveDomainReq();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CLeaveDomainReq( const CLeaveDomainReq& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CLeaveDomainReq& operator=( const CLeaveDomainReq& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        TBuf8<SHA1_HASH> iDeviceId;
+        TBuf8<SHA1_HASH> iRiId;
+        HBufC8* iDomainId;
+        TBuf8<KDeviceNonceLength> iNonce;
+        TTime iTime;
+        RPointerArray<HBufC8> iCertificateChain;
+        HBufC8* iSignature;
+    	TBool iNotMember;
+        // Optional nonce from the trigger
+        HBufC8* iTriggerNonce;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // LEAVEDOMAINREQ_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/LeaveDomainResp.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,153 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef LEAVEDOMAINRESP_H
+#define LEAVEDOMAINRESP_H
+
+//  INCLUDES
+#include "RoapMessage.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CLeaveDomainResp : public CRoapMessage
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CLeaveDomainResp* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CLeaveDomainResp();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CLeaveDomainResp();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CLeaveDomainResp( const CLeaveDomainResp& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CLeaveDomainResp& operator=( const CLeaveDomainResp& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        TRoapStatus iStatus;
+        HBufC8* iDomainId;
+        HBufC8* iDeviceNonce;
+        HBufC8* iErrorUrl;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // LEAVEDOMAINRESP_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/LeaveDomainRespParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,143 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef LEAVEDOMAINRESPPARSER_H
+#define LEAVEDOMAINRESPPARSER_H
+
+//  INCLUDES
+#include "RespParser.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+class CLeaveDomainResp;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class TLeaveDomainRespParser : public MRespParser
+    {
+    public:  // Constructors
+        
+        TLeaveDomainRespParser(
+            CLeaveDomainResp* aResponse);
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+        virtual void OnStartElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement,
+            const RAttributeArray& aAttributes);
+
+        virtual void OnEndElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement);
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+        CLeaveDomainResp* iResponse;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // LEAVEDOMAINRESPPARSER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/MeteringReportReq.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,161 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef METERINGREPORTREQ_H
+#define METERINGREPORTREQ_H
+
+//  INCLUDES
+
+#include <hash.h>
+#include <Oma2Agent.h>
+#include "RoapMessage.h"
+#include "RoapDef.h"
+#include "OmaCrypto.h"
+#include "CMLACrypto.h"
+
+namespace Roap
+{
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+NONSHARABLE_CLASS( CMeteringReportReq ): public CRoapMessage
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CMeteringReportReq* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CMeteringReportReq();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+        /**
+        * Calculate MAC over <encryptedMeteringReport>
+        * @since Series 60 3.2
+        * @param None
+        * @return None
+        */
+        void InsertMacL( const TDesC8& aMacKey );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        virtual HBufC8* MessageAsXmlL(void);
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CMeteringReportReq();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CRightsReq( const CRightsReq& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CRightsReq& operator=( const CRightsReq& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+
+        TBuf8<SHA1_HASH> iDeviceId;
+        TBuf8<SHA1_HASH> iRiId;
+        TBuf8<SHA1_HASH> iEncKeyHash;
+        TBuf8<KDeviceNonceLength> iNonce;
+        TBuf8<KDeviceNonceLength> iReportNonce;
+        TTime iTime;
+        RPointerArray<HBufC8> iCertificateChain;
+        HBufC8* iSignature;
+        HBufC8* iCipherValue;
+        HBufC8* iEncryptedMekAndMak;
+        HBufC8* iMac;       
+        // Optional nonce from the trigger
+        HBufC8* iTriggerNonce;
+        TKeyTransportScheme iAlgorithmInUse;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // METERINGREPORTREQ_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/MeteringReportResp.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  class representing OMA metering report response
+*
+*/
+
+
+
+#ifndef METERINGRESP
+#define METERINGRESP
+
+//  INCLUDES
+#include <hash.h>
+#include "RoapMessage.h"
+
+namespace Roap
+{
+
+/**
+*  class representing OMA DRM metering report response
+*
+*  @lib roaphandler.dll
+*  @since S60 v3.2
+*/
+NONSHARABLE_CLASS( CMeteringResp ) : public CRoapMessage
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CMeteringResp* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CMeteringResp();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CMeteringResp();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+    public:     // Data
+        TRoapStatus iStatus;
+        TBuf8<SHA1_HASH> iDeviceId;
+        TBuf8<SHA1_HASH> iRiId;
+        HBufC8* iDeviceNonce;
+        HBufC8* iErrorUrl;
+        HBufC8* iSignature;
+        RPointerArray<HBufC8> iCertificateChain;
+        RPointerArray<HBufC8> iOcspResponse;
+        HBufC8* iPrUrl;
+    };
+}
+
+#endif      // METERINGRESP
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/MeteringReportRespParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef METERINGRESPPARSER
+#define METERINGNRESPPARSER
+
+//  INCLUDES
+#include "RespParser.h"
+#include <hash.h>
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+class CMeteringResp;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+NONSHARABLE_CLASS( TMeteringRespParser ): public MRespParser
+    {
+    public: // Constructors
+    
+        TMeteringRespParser(
+            CMeteringResp* aResponse);        
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+        virtual void OnStartElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement,
+            const RAttributeArray& aAttributes);
+
+        virtual void OnEndElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement);
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        CMeteringResp* iResponse;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // METERINGRESPPARSER   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RIContext.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,148 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef RICONTEXT_H
+#define RICONTEXT_H
+
+//  INCLUDES
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+
+namespace Roap
+{
+
+class CRIContext : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CRIContext* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CRIContext();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CRIContext();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CRIContext( const CRIContext& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CRIContext& operator=( const CRIContext& );
+
+    public:     // Data
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // RICONTEXT_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RIHello.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,165 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef RIHELLO_H
+#define RIHELLO_H
+
+//  INCLUDES
+
+#include <hash.h>
+#include "RoapMessage.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CRIHello : public CRoapMessage
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CRIHello* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CRIHello();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CRIHello();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CRIHello( const CRIHello& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CRIHello& operator=( const CRIHello& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+
+        TRoapStatus iStatus;
+        HBufC8* iSession;
+        TBuf8<KMaxRoapVersionLength> iSelectedVersion;
+        TBuf8<SHA1_HASH> iRiId;
+        HBufC8* iRiNonce;
+        HBufC8* iServerInfo;
+        HBufC8* iErrorUrl;
+        TBool iNeedDeviceDetails;
+        TBool iPeerKeyIdentifier;
+        TBuf8<SHA1_HASH> iPeerKeyId;
+        TBool iCertificateCaching;
+        RPointerArray<HBufC8> iAlgorithms;
+        RPointerArray<HBufC8> iTrustedAuthorities;
+        
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // RIHELLO_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RIHelloParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,143 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef RIHELLOPARSER_H
+#define RIHELLOPARSER_H
+
+//  INCLUDES
+
+#include <hash.h>
+#include "RespParser.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+class CRIHello;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class TRIHelloParser : public MRespParser
+    {
+    public:  // Constructors and destructor
+        
+        TRIHelloParser(
+            CRIHello* aResponse);
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+        virtual void OnStartElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement,
+            const RAttributeArray& aAttributes);
+
+        virtual void OnEndElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement);
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+        CRIHello* iResponse;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // RIHELLOPARSER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RegistrationReq.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,153 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef REGISTRATIONREQ_H
+#define REGISTRATIONREQ_H
+
+//  INCLUDES
+
+#include <hash.h>
+#include "RoapMessage.h"
+
+namespace Roap
+{
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CRegistrationReq : public CRoapMessage
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CRegistrationReq* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CRegistrationReq();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        virtual HBufC8* MessageAsXmlL(void);
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CRegistrationReq();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CRegistrationReq( const CRegistrationReq& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CRegistrationReq& operator=( const CRegistrationReq& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+
+        HBufC8* iSession;
+        TBuf8<KDeviceNonceLength> iNonce;
+
+        // Device time in UTC
+        TTime iTime;
+        RPointerArray<HBufC8> iCertificateChain;
+        HBufC8* iServerInfo;
+        HBufC8* iSignature;
+        HBufC8* iDeviceDetailsManufacturer;
+        HBufC8* iDeviceDetailsModel;
+        HBufC8* iDeviceDetailsVersion;
+        HBufC8* iOcspResponderKeyId;
+        TBuf8<SHA1_HASH> iPeerKeyIdentifier;
+        TBool iOcspInfoStored;
+        RPointerArray<HBufC8> iTrustedAuthorities;
+    
+        // Optional nonce from the trigger
+        HBufC8* iTriggerNonce;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // REGISTRATIONREQ_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RegistrationResp.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef REGISTRATIONRESP
+#define REGISTRATIONRESP
+
+//  INCLUDES
+#include "RoapMessage.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CRegistrationResp : public CRoapMessage
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CRegistrationResp* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CRegistrationResp();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CRegistrationResp();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CRegistrationResp( const CRegistrationResp& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CRegistrationResp& operator=( const CRegistrationResp& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+ 
+        TRoapStatus iStatus;
+        HBufC8* iSession;
+        HBufC8* iRiUrl;
+        HBufC8* iErrorUrl;
+        RPointerArray<HBufC8> iCertificateChain;
+        RPointerArray<HBufC8> iOcspResponse;
+        RPointerArray<HBufC8> iWhiteList;
+        HBufC8* iSignature;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // REGISTRATIONRESP   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RegistrationRespParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,141 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef REGISTRATIONRESPPARSER
+#define REGISTRATIONRESPPARSER
+
+//  INCLUDES
+#include "RespParser.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+class CRegistrationResp;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class TRegistrationRespParser : public MRespParser
+    {
+    public: // Constructors
+    
+        TRegistrationRespParser(
+            CRegistrationResp* aResponse);        
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+        virtual void OnStartElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement,
+            const RAttributeArray& aAttributes);
+
+        virtual void OnEndElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement);
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        CRegistrationResp* iResponse;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // REGISTRATIONRESPPARSER   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RespParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,78 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef RESPPARSER_H
+#define RESPPARSER_H
+
+//  INCLUDES
+#include <Xml/Parser.h>
+#include <Xml/ContentHandler.h>
+#include <Xml/XmlParserErrors.h>
+
+using namespace Xml;
+
+namespace Roap
+{
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+
+class CRoapParser;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class MRespParser
+    {
+    public: // New functions
+
+        virtual void OnStartElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement,
+            const RAttributeArray& aAttributes) = 0;
+
+        virtual void OnEndElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement) = 0;
+    };
+}
+
+#endif      // ROAPPARSER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RightsReq.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,153 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef RIGHTSREQ_H
+#define RIGHTSREQ_H
+
+//  INCLUDES
+
+#include <hash.h>
+#include "RoapMessage.h"
+#include "RoapDef.h"
+
+namespace Roap
+{
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CRightsReq : public CRoapMessage
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CRightsReq* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CRightsReq();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        virtual HBufC8* MessageAsXmlL(void);
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CRightsReq();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CRightsReq( const CRightsReq& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CRightsReq& operator=( const CRightsReq& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+
+        TBuf8<SHA1_HASH> iDeviceId;
+        TBuf8<SHA1_HASH> iRiId;
+        HBufC8* iDomainId;
+        TBuf8<KDeviceNonceLength> iNonce;
+        TTime iTime;
+        RPointerArray<HBufC8> iCertificateChain;
+        HBufC8* iSignature;
+        RPointerArray<HBufC8> iRoIdList;
+        TBuf8<SHA1_HASH> iDcfHash;
+        HBufC8* iOcspResponderKeyId;
+        TBuf8<SHA1_HASH> iPeerKeyIdentifier;
+        TBool iOcspInfoStored;
+        RPointerArray<HBufC8> iTransTrackIDs;
+        RPointerArray<HBufC8> iContentIDs;
+
+        // Optional nonce from the trigger
+        HBufC8* iTriggerNonce;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // RIGHTSREQ_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RightsResp.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,165 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef RIGHTSRESP_H
+#define RIGHTSRESP_H
+
+//  INCLUDES
+
+#include <hash.h>
+#include "RoapMessage.h"
+#include "RoapDef.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CRightsResp : public CRoapMessage
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CRightsResp* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CRightsResp();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CRightsResp();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CRightsResp( const CRightsResp& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CRightsResp& operator=( const CRightsResp& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+
+        TRoapStatus iStatus;
+        HBufC8* iSession;
+        TBuf8<SHA1_HASH> iDeviceId;
+        TBuf8<SHA1_HASH> iRiId;
+        HBufC8* iNonce;
+        RPointerArray<HBufC8> iCertificateChain;
+        RPointerArray<HBufC8> iOcspResponse;
+        HBufC8* iRoEncryptionKey;
+        HBufC8* iSignature;
+        HBufC8* iErrorUrl;
+        RPointerArray<HBufC8> iTransTrackIDs;
+        RPointerArray<HBufC8> iContentIDs;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // RIGHTSRESP_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RightsRespParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,126 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef RIGHTSRESPPARSER_H
+#define RIGHTSRESPPARSER_H
+
+//  INCLUDES
+
+#include <hash.h>
+#include "RespParser.h"
+
+namespace Roap
+{
+// FORWARD DECLARATIONS
+class CRightsResp;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class TRightsRespParser : public MRespParser
+    {
+    public:  // Constructors
+        
+        TRightsRespParser(
+            CRightsResp* aResponse);
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+        virtual void OnStartElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement,
+            const RAttributeArray& aAttributes);
+
+        virtual void OnEndElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement);
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+        CRightsResp* iResponse;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // RIGHTSRESPPARSER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RoapConnection.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef ROAP_CONNECTION_H
+#define ROAP_CONNECTION_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <es_sock.h>
+#include <CommDbConnPref.h>
+
+namespace Roap
+{
+
+// CLASS DECLARATION
+
+class CRoapConnection : public CActive
+    {
+    public:     // Constructors and destructor.
+
+        static CRoapConnection* NewL();
+
+        ~CRoapConnection();
+
+    public:     // new methods
+
+        void ConnectL
+            ( TUint32 aIap, TRequestStatus* aStatus );
+
+        void Close();
+
+        TBool IsConnected( TUint32& aIap );
+
+        RSocketServ& SocketServ();
+
+        RConnection& Conn();
+
+    private:
+
+        enum TState
+            {
+            EInit,
+            EConnecting,
+            EConnected
+            };
+
+    private:    // Constructors and destructor.
+
+        CRoapConnection();
+
+        void ConstructL();
+
+    private:  // from CActive
+
+        virtual void DoCancel();
+
+        virtual void RunL();
+
+        virtual TInt RunError( TInt aError );
+
+    private:    // new methods
+
+        void DoClose();
+
+        void Done();
+
+    private:    // data
+
+        RSocketServ iSocketServ;
+        RConnection iConnection;
+        TState iState;
+        TRequestStatus* iParentStatus;
+        TCommDbConnPref iConnPref;
+    };
+}
+
+#endif /* def CONNECTION_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RoapHttpHandler.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,189 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#ifndef ROAP_HTTP_HANDLER_H
+#define ROAP_HTTP_HANDLER_H
+
+// INCLUDES
+#include "RoapConnection.h"
+#include "RoapResponse.h"
+#include "RoapObserver.h"
+
+#include <e32base.h>
+#include <http.h>
+#include <stringpool.h>
+#include <http/mhttpauthenticationcallback.h>
+
+namespace Roap
+{
+
+// CLASS DECLARATION
+
+class CRoapHttpHandler
+: public CActive,
+  public MHTTPTransactionCallback,
+  public MHTTPDataSupplier,
+  public MHTTPAuthenticationCallback
+    {
+    public:     // Constructors and destructor
+  
+        static CRoapHttpHandler* NewL();
+
+        virtual ~CRoapHttpHandler();
+
+    public:     // new methods
+
+        void CreateConnectionL( TRequestStatus* aStatus );
+
+        void DoTransactionL
+            (
+            CRoapResponse& aResponse,
+            TDesC8& aReqBody,
+            TRequestStatus* aStatus 
+            );
+
+ 
+        void SetUrlL( TDesC8& aUrl );
+
+        void SetObserver( MRoapObserver* aRoapObserver );
+
+        void SetPreferredIap( TUint32 aPreferredIap );
+
+    protected:  // from CActive
+
+        virtual void DoCancel();
+
+        virtual void RunL();
+
+        virtual TInt RunError( TInt aError );
+
+    protected:  // from MHTTPTransactionCallback
+
+        virtual void MHFRunL
+            ( RHTTPTransaction aTransaction, const THTTPEvent& aEvent );
+
+        virtual TInt MHFRunError
+            (
+            TInt aError,
+            RHTTPTransaction aTransaction,
+            const THTTPEvent& aEvent
+            );
+
+    protected:  // from MHTTPDataSupplier
+
+        virtual TBool GetNextDataPart( TPtrC8& aDataPart );
+
+        virtual void ReleaseData();
+
+        virtual TInt OverallDataSize();
+
+        virtual TInt Reset();
+
+
+    protected:  // from MHTTPAuthenticationCallback
+    
+	    virtual TBool GetCredentialsL
+            (
+            const TUriC8& aURI,
+            RString aRealm, 
+            RStringF aAuthenticationType,
+            RString& aUsername, 
+            RString& aPassword
+            );
+
+    private:    // types
+
+        enum TRoapState         ///< State.
+            {
+            EInit,
+            EStart,
+            EConnect,
+            EReady,
+            ERequest,
+            EComplete,
+            ECloseSession,
+            };
+
+    private:    // Constructors and destructor
+     
+        CRoapHttpHandler();
+    
+        void ConstructL();
+
+    protected:    // state machine parts
+
+
+        void ConnectL();
+
+
+        void CreateSessionL();
+
+
+        void DoTransactionL();
+        
+        
+        void SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue);
+
+
+        void Complete();
+
+
+        void InstallHttpFiltersL();
+
+
+        void SelfComplete( TInt& aResult );
+
+
+        void HandleResponseHeadersL( RHTTPResponse aHttpResponse );
+        
+        
+        TBool CheckHttpCode( TInt aHttpStatus );
+
+
+        TInt AppendPduData( const TDesC8& aDataChunk );
+        
+        
+        TInt AppendMultipartData( const TDesC8& aDataChunk );
+        
+       
+        static TInt StaticTimeOut( TAny* aPointer );
+        
+        
+        void TimeOut();
+
+    private:    // data
+
+        HBufC8* iUri;
+        HBufC8* iRequestBody;
+        RHTTPSession iSession;
+        RHTTPTransaction iTransaction;
+        CRoapConnection* iConnection;
+        MRoapObserver* iObserver;
+        CRoapResponse* iResponse;
+        HBufC8* iBoundary;
+        TRequestStatus* iParentStatus;
+        TUint32 iPreferredIap;
+        TRoapState iState;
+        TInt iError;
+        CPeriodic* iTimeout;
+        TInt iBytesReceived;
+        TBool iReportBytes;
+    };
+}
+
+#endif  // ROAP_HTTP_HANDLER
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RoapLog.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,92 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logger utilities for ROAP
+*
+*/
+
+
+
+#ifndef ROAP_LOG_H
+#define ROAP_LOG_H
+
+#ifdef _DEBUG
+#include <e32debug.h>
+#define ROAPDEBUGCODE( a ) a 
+#define ROAPDEBUG( a ) RDebug::Print( a );
+#define ROAPDEBUG2( a, b ) RDebug::Print( a, b );
+#define ROAPDEBUGLIT( a ) ROAPDEBUG( _L ( a ) )
+#else
+#define ROAPDEBUGCODE( a )
+#define ROAPDEBUG( a )
+#define ROAPDEBUG2( a, b )
+#define ROAPDEBUGLIT( a )
+#endif
+
+#ifndef _ROAP_TESTING
+
+#define LOG( a )
+#define LOGLIT( a )
+#define LOGHEX( ptr, len )
+#define LOG2( a, b )
+#define PERFORMANCE_LOG( a )
+#define PERFORMANCE_LOG2( a, b )
+#define PERFORMANCE_LOGLIT( a )
+
+#else // _ROAP_TESTING
+
+#include <flogger.h>
+
+// #define PERFORMANCE_LOGGING_ONLY // Disables normal logging. Enables only minimal logging for performance testing
+#define _ROAP_DETAILED_LOGGING // Normal logging + more detailed (signature) logging
+
+_LIT(KRoapLogDir, "DRM");
+_LIT(KRoapLogFile, "ROAP.log");
+
+#ifdef PERFORMANCE_LOGGING_ONLY
+
+// Performance logging only
+
+#define LOG( a )
+#define LOGLIT( a )
+#define LOGHEX( ptr, len )
+#define LOG2( a, b )
+#define PERFORMANCE_LOG( a ) RFileLogger::Write( KRoapLogDir(), KRoapLogFile(), EFileLoggingModeAppend, a );
+#define PERFORMANCE_LOG2( a, b ) RFileLogger::WriteFormat( KRoapLogDir(), KRoapLogFile(), EFileLoggingModeAppend, a, b );
+#define PERFORMANCE_LOGLIT( a ) PERFORMANCE_LOG( _L ( a ) )
+#else // PERFORMANCE_LOGGING_ONLY
+
+// Normal logging
+
+#define LOG( a ) RFileLogger::Write( KRoapLogDir(), KRoapLogFile(), EFileLoggingModeAppend, a );
+#define LOGLIT( a ) LOG( _L ( a ) )
+#define LOGHEX( ptr, len ) RFileLogger::HexDump( KRoapLogDir(), KRoapLogFile(), EFileLoggingModeAppend, _S(""), _S(""), ptr, len );
+#define LOG2( a, b ) RFileLogger::WriteFormat( KRoapLogDir(), KRoapLogFile(), EFileLoggingModeAppend, a, b );
+#define PERFORMANCE_LOG( a )
+#define PERFORMANCE_LOG2( a, b )
+#define PERFORMANCE_LOGLIT( a )
+#endif // PERFORMANCE_LOGGING_ONLY
+#endif // _ROAP_TESTING
+#ifdef _ROAP_DETAILED_LOGGING
+#define DETAILLOG( a ) LOG( a )
+#define DETAILLOGLIT( a ) LOGLIT( a )
+#define DETAILLOGHEX( ptr, len ) LOGHEX( ptr, len )
+#define DETAILLOG2( a, b ) LOG2( a, b )
+#else
+#define DETAILLOG( a )
+#define DETAILLOGLIT( a )
+#define DETAILLOGHEX( ptr, len )
+#define DETAILLOG2( a, b )
+#endif
+
+#endif // ROAP_LOG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RoapParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,536 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ROAP parser base calss
+*
+*/
+
+
+
+#ifndef ROAPPARSER_H
+#define ROAPPARSER_H
+
+//  INCLUDES
+#include <Xml/Parser.h>
+#include <Xml/ContentHandler.h>
+#include <Xml/XmlParserErrors.h>
+#include "RoapMessage.h"
+
+using namespace Xml;
+
+namespace Roap
+{
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+enum TRoapElementEnum
+    {
+    ECipherData,
+    ECipherValue,
+    ECertificate,
+    ECertificateChain,
+    EContentID,
+    EDcfHash,
+    EDeviceDetails,
+    EDeviceID,
+    EDigestValue,
+    EDomainAlias,
+    EDomainID,
+    EDomainInfo,
+    EDomainKey,
+    EDomainName,
+    EEncKey,
+    EEncryptionMethod,
+    EExtension,
+    EExtensions,
+    EHash,
+    EId,
+    EIdentifier,
+    EJoinDomain,
+    EJoinDomainResponse,
+    EKeyIdentifier,
+    ELeaveDomain,
+    ELeaveDomainResponse,
+    EMac,
+    EManufacturer,
+    EModel,
+    ENonce,
+    ENotAfter,
+    EOcspResponse,
+    EProtectedRO,
+    ERegistrationRequest,
+    ERegistrationResponse,
+    ERiAlias,
+    ERights,
+    ERiHello,
+    ERiID,
+    ERiNonce,
+    ERiURL,
+    ERo,
+    ERoAcquisition,
+    ERoapTrigger,
+    ERoapURL,
+    ERoID,
+    ERoInfo,
+    ERoResponse,
+    ESelectedAlgorithm,
+    ESelectedVersion,
+    EServerInfo,
+    ESignature,
+    ESignatureValue,
+    ESupportedAlgorithm,
+    ETime,
+    ETimeStamp,
+    ETrustedAuthorities,
+    EVersion,
+    EX509SPKIHash,
+#ifdef RD_DRM_METERING
+    EExtendedTriggerElement,
+    EMeteringReportRequest,
+    EMeteringReportResponse,
+    EPrUrl,
+#endif
+    ELast
+    };
+
+enum TParserStackState
+    {
+    ERiHelloState,
+    ESelectedVersionState,
+    ERiIdState,
+    ERiNonceState,
+    EDeviceDetailsState,
+    ECertificateState,
+    EOcspResponseState,
+    ERiUrlState,
+    ESignatureState,
+    ERegistrationResponseState,
+    EPeerKeyIdentifierRIHelloState,
+    ETransactionIdState,
+    ETransactionIdContentIdState,
+    EWhiteListState,
+    EExtensionState,
+    ERoResponseState,
+    EDeviceIdState,
+    ENonceState,
+    ERiIdRoResponseState,
+    ESignatureRoResponseState,
+    EEncKeyState,
+    ERiIdJoinDomainResponseState,
+    EMacJoinDomainResponseState,
+    EJoinDomainResponseState,
+    ELeaveDomainResponseState,
+    EDomainIdState,
+    ENotAfterState,
+    EDomainKeyState,
+    EDomainKeyEncryptionMethodState,
+    ERoapTriggerState,
+    ERoapUrlState,
+    ERegistrationRequestState,
+    ERoAcquisitionState,
+    EJoinDomainState,
+    ELeaveDomainState,
+    ERoIdState,
+    EContentIdState,
+    ESignatureValueState,
+    EDigestValueState,
+    EServerInfoState,
+    ESupportedAlgorithmState,
+    ESelectedAlgorithmState,
+    ETrustedAuthoritiesState,
+    EDomainKeyEncKeyState,
+    EDomainAliasState,
+    ERiAliasState,
+#ifdef RD_DRM_METERING
+    EExtendedTriggerElementState,
+    EMeteringReportRequestState,
+    EMeteringReportResponseState,
+    EDeviceNonceState,
+    EMeteringReportNonceState,
+    EPostResponseUrlState,
+#endif
+    EUnknownState = -1,
+    };
+
+// FORWARD DECLARATIONS
+
+class CDeviceHello;
+class CJoinDomainReq;
+class CJoinDomainResp;
+class CLeaveDomainReq;
+class CLeaveDomainResp;
+class CRIHello;
+class CRegistrationReq;
+class CRegistrationResp;
+class CRightsReq;
+class CRightsResp;
+class CRoapTrigger;
+class MRespParser;
+class CMeteringResp;
+
+// CLASS DECLARATION
+
+/**
+*  ROAP parser base class
+*
+*  @lib roaphandler.dll
+*  @since S60 v3.0
+*/
+class CRoapParser : public CBase, public MContentHandler
+    {
+    public: // Constants
+
+        static const TInt KMaxElementCount = ELast;
+        static const TInt KMaxElementNesting = 32;
+
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CRoapParser* NewL();
+
+        /**
+        * Destructor.
+        */
+        virtual ~CRoapParser();
+
+    public: // New functions
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+        CMeteringResp* ParseMeteringRespL(
+            const TDesC8& aMessage );
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        CJoinDomainResp* ParseJoinDomainRespL(
+            const TDesC8& aMessage,
+            RPointerArray<HBufC8>& aDomainKeyElements);
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        CLeaveDomainResp* ParseLeaveDomainRespL(
+            const TDesC8& aMessage);
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        CRegistrationResp* ParseRegistrationRespL(
+            const TDesC8& aMessage);
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        CRightsResp* ParseRightsRespL(
+            const TDesC8& aMessage);
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        CRIHello* ParseRIHelloL(
+            const TDesC8& aMessage);
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        CRoapTrigger* ParseRoapTriggerL(
+            const TDesC8& aMessage);
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aDocParam Specifies the various parameters of the document.
+        * @arg   aDocParam.iCharacterSetName The character encoding of the document.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartDocumentL(
+            const RDocumentParameters& aDocParam,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndDocumentL(
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aElement is a handle to the element's details.
+        * @param aAttributes contains the attributes for the element.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartElementL(
+            const RTagInfo& aElement,
+            const RAttributeArray& aAttributes,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aElement is a handle to the element's details.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndElementL(
+            const RTagInfo& aElement,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aBytes is the raw content data for the element.
+        *        The client is responsible for converting the data to the
+        *        required character set if necessary.
+        *        In some instances the content may be binary and must not be converted.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnContentL(
+            const TDesC8& aBytes,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aPrefix is the Namespace prefix being declared.
+        * @param aUri is the Namespace URI the prefix is mapped to.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnStartPrefixMappingL(
+            const RString& aPrefix,
+            const RString& aUri,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aPrefix is the Namespace prefix that was mapped.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnEndPrefixMappingL(
+            const RString& aPrefix,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aBytes are the ignored bytes from the document being parsed.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnIgnorableWhiteSpaceL(
+            const TDesC8& aBytes,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aName is the name of the skipped entity.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnSkippedEntityL(
+            const RString& aName,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aTarget is the processing instruction target.
+        * @param aData is the processing instruction data. If empty none was supplied.
+        * @param aErrorCode is the error code.
+        *        If this is not KErrNone then special action may be required.
+        */
+        void OnProcessingInstructionL(
+            const TDesC8& aTarget,
+            const TDesC8& aData,
+            TInt aErrorCode);
+
+        /**
+        * From ?base_class ?member_description.
+        */
+        void OnOutOfData();
+
+
+        /**
+        * From ?base_class ?member_description.
+        * @param aError is the error code
+        */
+        void OnError(
+            TInt aErrorCode);
+
+
+        /**
+        * From ?base_class ?member_description.
+        * @return
+                0 if no interface matching the uid is found.
+                Otherwise, the this pointer cast to that interface.
+        * @param aUid the uid identifying the required interface.
+        */
+        TAny* GetExtendedInterface(
+            const TInt32 aUid);
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        HBufC8* GetAttributeValueL(
+            const RAttributeArray& aAttrList,
+            const TDesC8& aAttrName);
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        TRoapStatus ConvertRoapStatus(
+            const TDesC8& aStatus);
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        TPtrC8 ExtractElement(
+            const TDesC8& aMessage,
+            const TDesC8& aElement,
+            TInt& aOffset ) const;
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        TInt ExtractDomainKeyElements(
+            const TDesC8& aMessage,
+            RPointerArray<HBufC8>& aDomainKeyElements) const;
+
+
+    protected:  // New functions
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        TParserStackState MatchStackState(void);
+
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        void ParseL(
+            const TDesC8& aMessage);
+
+    protected:  // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+        /**
+        * C++ default constructor.
+        */
+        CRoapParser();
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL();
+
+    private:
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CRoapParser( const CRoapParser& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CRoapParser& operator=( const CRoapParser& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+        CParser* iParser;
+        RString iRoapElements[KMaxElementCount];
+        TInt iElementStack[KMaxElementNesting];
+        TInt iElementStackDepth;
+        HBufC8* iContent;
+        MRespParser* iResponseParser;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // ROAPPARSER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RoapResponse.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#ifndef ROAP_RESPONSE_H
+#define ROAP_RESPONSE_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <apmstd.h>
+#include "MultipartHandler.h"
+
+namespace Roap
+{
+
+// CLASS DECLARATION
+
+class CRoapResponse: public CBase, public TMultipartHandler
+    {
+    public:
+    
+        enum TMultipartState
+            {
+            ERights,
+            EDcf,
+            EOther
+            };
+    
+    public:     // Construct / destruct
+     
+        static CRoapResponse* NewL();
+        
+        virtual ~CRoapResponse();
+
+    public:
+
+        const TDesC8& ProtocolUnit() const;
+        
+        const TFileName& DcfFileName() const;
+        
+        const TDataType& DataType() const;
+        
+        void SetDcfPathL( const TPath& aPath );
+        
+        void AppendMultipartDataL( const TDesC8& aData );
+
+        virtual void HandleBodyDataL( const TDesC8& aData );
+
+        virtual void StartBodyPartL();
+        
+        virtual void EndBodyPartL();
+        
+        void SetContentNameL( const TDes& aName );
+        
+        void GetContentNameLC( HBufC*& aName ) const;
+        
+        void SetMaxSize( const TInt& aSize );
+        
+        TInt MaxSize() const;
+
+    protected: 
+     
+        CRoapResponse();
+            
+        void ConstructL();
+        
+    private:    // friends
+
+        friend class CRoapHttpHandler;
+
+    private:    // data
+
+        HBufC8* iPdu;
+        TFileName iDcfFileName; // contains the full path and file name of the temp DCF file
+        HBufC* iContentName; // content name to be used as a filename when saving temp DCF
+        TDataType iDataType;
+        TMultipartState iMultipartState;
+        TInt iMaxSize;
+    };        
+}
+
+#endif 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RoapSigner.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,170 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef ROAPSIGNER_H
+#define ROAPSIGNER_H
+
+//  INCLUDES
+
+class CSHA1;
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+class RRoapStorageClient;
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class CRoapSigner: public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CRoapSigner* NewL(RRoapStorageClient& aStorageClient);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CRoapSigner();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+        void ResetResponses(void);
+        
+        void AddResponseL(
+            const TDesC8& aResponse);
+
+        TBool VerifyAndAddResponseL(
+            const TDesC8& aResponse,
+            const TDesC8& aSignature,
+            const RPointerArray<HBufC8>& aCertificateChain);
+        
+        void ResetRequests(void);
+
+        void AddRequestL(
+            const TDesC8& aRequest);
+
+        HBufC8* SignAndAddRequestL(
+            const TDesC8& aRequest);
+        
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @param 
+        * @param 
+        */
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        
+        /**
+        * C++ default constructor.
+        */
+        CRoapSigner();
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL(RRoapStorageClient& aStorageClient);
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CRoapSigner( const CRoapStorageClient& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CRoapSigner& operator=( const CRoapStorageClient& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    protected:  // Data
+        // ?one_line_short_description_of_data
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+        
+        CSHA1* iHash;
+        RPointerArray<HBufC8> iRequests;
+        RPointerArray<HBufC8> iResponses;
+        RRoapStorageClient* iStorage;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // ROAPSIGNER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RoapSyncWrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,108 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  synchronous wrapper for ROAP
+*
+*/
+
+
+
+#ifndef CROAPSYNCWRAPPER_H
+#define CROAPSYNCWRAPPER_H
+
+#include <e32base.h>
+#include <roapobserver.h>
+
+/**
+*  Synchronous wrapper for ROAP protocol suite.
+*
+*  @since Series 60 3.0
+*/
+NONSHARABLE_CLASS(CRoapSyncWrapper) : public CActive, public Roap::MRoapObserver
+    {
+public:
+
+    IMPORT_C static CRoapSyncWrapper* NewL();
+    IMPORT_C virtual ~CRoapSyncWrapper();
+
+    /**
+    * Handle a ROAP trigger synchronously
+    *
+    * @since S60 3.1
+    * @param aTrigger ROAP Trigger
+    */
+    IMPORT_C void HandleTriggerL( const TDesC8& aTrigger );
+
+
+
+    /**
+    * Handle a ROAP trigger synchronously without user interaction
+    *
+    * @since S60 3.1
+    * @param aTrigger ROAP Trigger
+    * @return EFalse if the trigger cannot be handled silently, e.g. no RI
+    *         context exists
+    */
+    IMPORT_C TBool HandleTriggerSilentlyL( const TDesC8& aTrigger );
+
+    /**
+    * Handle ROAP error
+    *
+    * @since S60 3.1
+    * @param aError Error value returned from HandleTriggerL
+    * @param aErrorUrl Buffer for error url
+    */
+    IMPORT_C HBufC8* GetErrorUrlL( const TInt aError, TInt& aErrorType );
+
+    /**
+    * Getter for ROAP metering postResponseUrl
+    *
+    * @since S60 3.2
+    * @return post reponse URL
+    */
+    IMPORT_C HBufC8* GetPostResponseUrlL();
+
+
+    // From CActive.
+
+    void DoCancel();
+    void RunL();
+
+    // From MRoapObserver
+
+    TBool ConnectionConfL();
+    TBool ContactRiConfL();
+    TBool TransIdConfL();
+    void RightsObjectDetailsL( const RPointerArray<CDRMRights>& aRightsList );
+    void ContentDownloadInfoL( TPath& aTempFolder, TFileName& aContentName, TInt& aMaxSize );
+    void ContentDetailsL( const TDesC& aPath, const TDesC8& aType,const TUid& aAppUid );
+    void RoapProgressInfoL( const TInt aProgressInfo );
+    void ErrorUrlL( const TDesC8& aErrorUrl );
+    void PostResponseUrlL( const TDesC8& aPostResponseUrl );
+
+private:
+
+    CRoapSyncWrapper();
+    void ConstructL();
+
+private:
+
+    // Used to make asynchronous call synchronous
+    CActiveSchedulerWait    iWait;
+    HBufC8* iErrorUrl;
+    HBufC8* iPostResponseUrl;
+    };
+
+#endif      // CROAPSYNCWRAPPER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/inc/RoapTriggerParser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,143 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef ROAPTRIGGERPARSER_H
+#define ROAPTRIGGERPARSER_H
+
+//  INCLUDES
+
+#include <hash.h>
+#include "RespParser.h"
+
+namespace Roap
+{
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+class CRoapTrigger;
+
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+class TRoapTriggerParser : public MRespParser
+    {
+    public:  // Constructors and destructor
+        
+        TRoapTriggerParser(
+            CRoapTrigger* aResponse);
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+        
+        virtual void OnStartElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement,
+            const RAttributeArray& aAttributes);
+
+        virtual void OnEndElementL(
+            CRoapParser& aParser,
+            TInt aState,
+            const RTagInfo& aElement);
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+        CRoapTrigger* iResponse;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+}
+
+#endif      // ROAPTRIGGERPARSER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/DeviceHello.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,171 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <hash.h>
+#include "Base64.h"
+#include "DeviceHello.h"
+
+using namespace Roap;
+
+// CONSTANTS
+_LIT8(KReqHeader, "<roap:deviceHello xmlns:roap=\"urn:oma:bac:dldrm:roap-1.0\"");
+_LIT8(KReqVersion, "><version>");
+_LIT8(KReqNonceTrigger, " triggerNonce=\"");
+_LIT8(KReqVersion2, "\"><version>");
+_LIT8(KReqVersionEnd, "</version>");
+_LIT8(KReqDeviceIdStart, "<deviceID>");
+_LIT8(KReqKeyIndentifierStart,"<keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqKeyIndentifierEnd, "</hash></keyIdentifier>");
+_LIT8(KReqDeviceIdEnd,"</deviceID>");
+_LIT8(KReqSupportedAlgo, "<supportedAlgorithm>");
+_LIT8(KReqSupportedAlgoEnd, "</supportedAlgorithm>");
+_LIT8(KReqExtensions, "<extensions>");
+_LIT8(KReqExtensionsEnd, "</extensions>");
+_LIT8(KReqCertificateCaching, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:CertificateCaching\"></extension>");
+_LIT8(KReqEnd, "</roap:deviceHello>");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDeviceHello::CDeviceHello
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDeviceHello::CDeviceHello():
+    iTriggerNonce(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDeviceHello::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDeviceHello::ConstructL()
+    {
+    iVersion.SetLength(0);
+    }
+
+// -----------------------------------------------------------------------------
+// CDeviceHello::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDeviceHello* CDeviceHello::NewL()
+    {
+    CDeviceHello* self = new( ELeave ) CDeviceHello;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CDeviceHello::~CDeviceHello()
+    {
+    iAlgorithms.Close();
+    delete iTriggerNonce;
+    iTriggerNonce = NULL;
+    iDeviceIdArray.Close();
+    }
+    
+// -----------------------------------------------------------------------------
+// CDeviceHello::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDeviceHello::MessageAsXmlL(void)
+    {
+    HBufC8* r = NULL;
+    CBufFlat* b = NULL;
+    TInt i = 0;
+
+    b = CBufFlat::NewL(128);
+    CleanupStack::PushL(b);
+    BufAppendL(b, KReqHeader);   
+    if (iTriggerNonce)
+        {
+        BufAppendL(b, KReqNonceTrigger);
+        BufAppendL(b, *iTriggerNonce);
+        BufAppendL(b, KReqVersion2);
+        BufAppendL(b, iVersion);
+        GetDeviceIdsAsXmlL( b );
+        }
+    else
+        {
+        BufAppendL(b, KReqVersion);
+        BufAppendL(b, iVersion);
+        GetDeviceIdsAsXmlL( b ); 
+        }
+
+    for (i = 0; i < iAlgorithms.Count(); i++)
+        {
+        TPtrC8 p(0, 0);
+        BufAppendL(b, KReqSupportedAlgo);
+        p.Set(iAlgorithms[i]);
+        BufAppendL(b, p);
+        BufAppendL(b, KReqSupportedAlgoEnd);
+        }
+        
+    BufAppendL(b, KReqExtensions);
+    BufAppendL(b, KReqCertificateCaching);        
+    BufAppendL(b, KReqExtensionsEnd);        
+
+    
+    BufAppendL(b, KReqEnd);
+        
+    r = b->Ptr(0).AllocL();
+    CleanupStack::PopAndDestroy(); // b
+    return r;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDeviceHello::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDeviceHello::GetDeviceIdsAsXmlL(CBufFlat* aBuffer)
+    {
+    BufAppendL(aBuffer, KReqVersionEnd);
+    
+    for (TInt i = 0; i < iDeviceIdArray.Count(); i++)
+        {
+        HBufC8* buffer( Base64EncodeL(iDeviceIdArray[i]) );
+        CleanupStack::PushL( buffer );
+        BufAppendL(aBuffer, KReqDeviceIdStart);
+
+        BufAppendL(aBuffer, KReqKeyIndentifierStart);
+        BufAppendL(aBuffer, *buffer);
+        BufAppendL(aBuffer, KReqKeyIndentifierEnd);
+        BufAppendL(aBuffer, KReqDeviceIdEnd);
+        CleanupStack::PopAndDestroy( buffer );
+        }
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/JoinDomainReq.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,224 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "base64.h"
+#include "JoinDomainReq.h"
+#include "RoapDef.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KReqHeader, "<roap:joinDomainRequest xmlns:roap=\"urn:oma:bac:dldrm:roap-1.0\"");
+_LIT8(KReqNonceTrigger, " triggerNonce=\"");
+_LIT8(KReqNonceTriggerEnd, "\"");
+_LIT8(KReqHeaderEnd, ">");
+_LIT8(KReqNonce, "<nonce>");
+_LIT8(KReqNonceEnd, "</nonce>");
+_LIT8(KReqTime, "<time>");
+_LIT8(KReqTimeEnd, "</time>");
+_LIT8(KReqDeviceId, "<deviceID><keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqDeviceIdEnd, "</hash></keyIdentifier></deviceID>");
+_LIT8(KReqRiId, "<riID><keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqRiIdEnd, "</hash></keyIdentifier></riID>");
+_LIT8(KReqDomainId, "<domainID>");
+_LIT8(KReqDomainIdEnd, "</domainID>");
+_LIT8(KReqCertChain, "<certificateChain>");
+_LIT8(KReqCert, "<certificate>");
+_LIT8(KReqCertEnd, "</certificate>");
+_LIT8(KReqCertChainEnd, "</certificateChain>");
+_LIT8(KReqExtensions, "<extensions>");
+_LIT8(KReqExtensionsEnd, "</extensions>");
+_LIT8(KReqPeerKey, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:PeerKeyIdentifier\">\
+<identifier algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqPeerKeyEnd, "</hash></identifier></extension>");
+_LIT8(KReqNoOcspResponse, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:NoOCSPResponse\"></extension>");
+_LIT8(KReqOcspResponderKeyId, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:OCSPResponderKeyIdentifier\">\
+<identifier algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqOcspResponderKeyIdEnd, "</hash></identifier></extension>");
+_LIT8(KReqHashChainSupport, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:HashChainSupport\"></extension>");
+_LIT8(KReqSig, "<signature>");
+_LIT8(KReqSigEnd, "</signature></roap:joinDomainRequest>");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CJoinDomainReq::CJoinDomainReq
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CJoinDomainReq::CJoinDomainReq():
+    iDomainId(NULL),
+    iOcspResponderKeyId(NULL),
+    iSignature(NULL),
+    iTriggerNonce(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CJoinDomainReq::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CJoinDomainReq::ConstructL()
+    {
+    iTime.UniversalTime();
+    iPeerKeyIdentifier.SetLength(0);
+    iOcspInfoStored = EFalse;
+    iHashChainSupport = ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CJoinDomainReq::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CJoinDomainReq* CJoinDomainReq::NewL()
+    {
+    CJoinDomainReq* self = new( ELeave ) CJoinDomainReq;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CJoinDomainReq::~CJoinDomainReq()
+    {
+    iCertificateChain.ResetAndDestroy();
+    delete iDomainId;
+    delete iSignature;
+    delete iTriggerNonce;
+    delete iOcspResponderKeyId;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CJoinDomainReq::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CJoinDomainReq::MessageAsXmlL(void)
+    {
+    HBufC8* r = NULL;
+    CBufFlat* b = NULL;
+    TInt i;
+
+    b = CBufFlat::NewL(128);
+    CleanupStack::PushL(b);
+    BufAppendL(b, KReqHeader);
+    if (iTriggerNonce)
+        {
+        BufAppendL(b, KReqNonceTrigger);
+        BufAppendL(b, *iTriggerNonce);
+        BufAppendL(b, KReqNonceTriggerEnd);
+        }
+    BufAppendL(b, KReqHeaderEnd);
+
+    BufAppendL(b, KReqDeviceId);
+    BufAppendBase64L(b, iDeviceId);
+    BufAppendL(b, KReqDeviceIdEnd);
+
+    BufAppendL(b, KReqRiId);
+    BufAppendBase64L(b, iRiId);
+    BufAppendL(b, KReqRiIdEnd);
+
+    BufAppendL(b, KReqNonce);
+    BufAppendBase64L(b, iNonce);
+    BufAppendL(b, KReqNonceEnd);
+
+    BufAppendL(b, KReqTime);
+    BufAppendTimeL(b, iTime);
+    BufAppendL(b, KReqTimeEnd);
+
+    BufAppendL(b, KReqDomainId);
+    BufAppendL(b, *iDomainId);
+    BufAppendL(b, KReqDomainIdEnd);
+
+    if (iCertificateChain.Count() > 0)
+        {
+        BufAppendL(b, KReqCertChain);
+        for (i = 0; i < iCertificateChain.Count(); i++)
+            {
+            BufAppendL(b, KReqCert);
+            BufAppendBase64L(b, *iCertificateChain[i]);
+            BufAppendL(b, KReqCertEnd);
+            }
+        BufAppendL(b, KReqCertChainEnd);
+        }
+        
+    if (iPeerKeyIdentifier.Length() ||
+        iOcspResponderKeyId ||
+        iOcspInfoStored ||
+        iHashChainSupport)
+        {
+        BufAppendL(b, KReqExtensions);
+        }
+        
+    if (iPeerKeyIdentifier.Length())
+        {
+        BufAppendL(b, KReqPeerKey);
+        BufAppendBase64L(b, iPeerKeyIdentifier);
+        BufAppendL(b, KReqPeerKeyEnd);
+        }
+        
+    if (iOcspInfoStored)
+        {
+        BufAppendL(b, KReqNoOcspResponse);
+        }
+        
+    if (iOcspResponderKeyId)
+        {
+        BufAppendL(b, KReqOcspResponderKeyId);
+        BufAppendBase64L(b, *iOcspResponderKeyId);
+        BufAppendL(b, KReqOcspResponderKeyIdEnd);
+        }
+
+    if (iHashChainSupport)
+        {
+        BufAppendL(b, KReqHashChainSupport);
+        }
+               
+    if (iPeerKeyIdentifier.Length() ||
+        iOcspResponderKeyId ||
+        iOcspInfoStored ||
+        iHashChainSupport)
+        {
+        BufAppendL(b, KReqExtensionsEnd);
+        }
+
+    BufAppendL(b, KReqSig);
+    BufAppendL(b, KReqSigEnd);
+
+    r = b->Ptr(0).AllocL();
+    CleanupStack::PopAndDestroy(b);
+    return r;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/JoinDomainResp.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,136 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "JoinDomainResp.h"
+
+using namespace Roap;
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CJoinDomainResp::CJoinDomainResp
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CJoinDomainResp::CJoinDomainResp() :
+    iSignature(NULL),
+    iTransportScheme(EOma)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CJoinDomainResp::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CJoinDomainResp::ConstructL()
+    {
+    iDomainExpiration = Time::MaxTTime();
+    iHashChainSupport = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CJoinDomainResp::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CJoinDomainResp* CJoinDomainResp::NewL()
+    {
+    CJoinDomainResp* self = new( ELeave ) CJoinDomainResp;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CJoinDomainResp::~CJoinDomainResp()
+    {
+    delete iSignature;
+    delete iErrorUrl;
+    iMacs.ResetAndDestroy();
+    iDomainKeys.ResetAndDestroy();
+    iCertificateChain.ResetAndDestroy();
+    iOcspResponse.ResetAndDestroy();
+    iDomainKeyIDs.ResetAndDestroy();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CJoinDomainResp::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/JoinDomainRespParser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,221 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "Base64.h"
+#include "OmaCrypto.h"
+#include "CmlaCrypto.h"
+#include "RoapParser.h"
+#include "JoinDomainResp.h"
+#include "JoinDomainRespParser.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KStatus, "status");
+_LIT8(KErrorUrl, "errorRedirectURL");
+_LIT8(KAlgorithmAttr, "Algorithm");
+_LIT8(KInfinite, "Infinite");
+_LIT8(KId, "Id");
+_LIT8(KHashChainSupport, "HashChainSupport");
+_LIT8(KType, "type");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TJoinDomainRespParser::TJoinDomainRespParser
+// -----------------------------------------------------------------------------
+//
+TJoinDomainRespParser::TJoinDomainRespParser(
+    CJoinDomainResp* aResponse)
+    {
+    iResponse = aResponse;
+    }
+
+// -----------------------------------------------------------------------------
+// TJoinDomainRespParser::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void TJoinDomainRespParser::OnStartElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/,
+    const RAttributeArray& aAttributes)
+    {
+    HBufC8* buffer = NULL;
+
+    switch (aState)
+        {
+        case EJoinDomainResponseState:
+            buffer = aParser.GetAttributeValueL(aAttributes, KStatus);
+            if (buffer != NULL)
+                {
+                iResponse->iStatus = aParser.ConvertRoapStatus(*buffer);
+                delete buffer;
+                }
+            else
+                {
+                iResponse->iStatus = EUnknownStatus;
+                }
+                
+            iResponse->iErrorUrl = aParser.GetAttributeValueL(aAttributes, KErrorUrl);
+            break;
+        case EDomainKeyEncryptionMethodState:
+            buffer = aParser.GetAttributeValueL(aAttributes, KAlgorithmAttr);
+            if (buffer )
+                {
+                iResponse->iTransportScheme =
+                    CmlaCrypto::AlgorithmIdToTransportScheme(*buffer);
+                delete buffer;
+                }
+            break;
+        case EDomainKeyEncKeyState:
+            buffer = aParser.GetAttributeValueL(aAttributes, KId);
+            if ( buffer )
+                {
+                CleanupStack::PushL(buffer);
+                iResponse->iDomainKeyIDs.AppendL(buffer);
+                CleanupStack::Pop();
+                }
+        case EExtensionState:
+            buffer = aParser.GetAttributeValueL(aAttributes, KType );
+            if(buffer != NULL)
+                {
+                if(buffer->Find(KHashChainSupport) >= KErrNone)
+                    {
+                    iResponse->iHashChainSupport = ETrue;
+                    }
+                delete buffer;
+                }
+        break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TJoinDomainRespParser::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void TJoinDomainRespParser::OnEndElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/)
+    {
+    HBufC8* buffer = NULL;
+    
+    if (!aParser.iContent)
+        {
+        return;
+        }
+
+    switch (aState)
+        {
+        case ECertificateState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            CleanupStack::PushL(buffer);
+            iResponse->iCertificateChain.AppendL(buffer);
+            CleanupStack::Pop(); //buffer
+            break;
+        case EOcspResponseState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            CleanupStack::PushL(buffer);
+            iResponse->iOcspResponse.AppendL(buffer);
+            CleanupStack::Pop(); // buffer
+            break;
+        case ERiIdState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            if ( buffer->Length() > SHA1_HASH )
+                {
+                delete buffer;
+                buffer = NULL;
+                User::Leave( KErrCorrupt );
+                }
+            iResponse->iRiId.Copy(*buffer);
+            delete buffer;
+            break;
+        case ERiIdJoinDomainResponseState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            if ( buffer->Length() > SHA1_HASH )
+                {
+                delete buffer;
+                buffer = NULL;
+                User::Leave( KErrCorrupt );
+                }
+            iResponse->iDomainKeyRiId.Copy(*buffer);
+            delete buffer;
+            break;
+        case EDeviceIdState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            if ( buffer->Length() > SHA1_HASH )
+                {
+                delete buffer;
+                buffer = NULL;
+                User::Leave( KErrCorrupt );
+                }
+            iResponse->iDeviceId.Copy(*buffer);
+            delete buffer;
+            break;
+        case ESignatureState:
+            iResponse->iSignature = Base64DecodeL( *aParser.iContent );
+            break;
+        case EEncKeyState:
+            buffer = Base64DecodeL( *aParser.iContent );
+            CleanupStack::PushL( buffer );
+            iResponse->iDomainKeys.AppendL( buffer );
+            CleanupStack::Pop(); // buffer
+            break;
+        case ENotAfterState:
+            if ( aParser.iContent )
+                {
+                if (aParser.iContent->CompareF( KInfinite() ) == KErrNone )
+                    {
+                    iResponse->iDomainExpiration = Time::NullTTime();
+                    }
+                else
+                    {
+                    iResponse->iDomainExpiration = iResponse->Iso8601ToTime(
+                        *aParser.iContent);   
+                    }
+                }
+            break;
+        case EMacJoinDomainResponseState:
+            buffer = Base64DecodeL( *aParser.iContent );
+            CleanupStack::PushL( buffer );
+            iResponse->iMacs.AppendL( buffer );
+            CleanupStack::Pop(); // buffer
+            break;
+        }
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/LeaveDomainReq.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,173 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "base64.h"
+#include "LeaveDomainReq.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KReqHeader, "<roap:leaveDomainRequest xmlns:roap=\"urn:oma:bac:dldrm:roap-1.0\"");
+_LIT8(KReqNonceTrigger, " triggerNonce=\"");
+_LIT8(KReqNonceTriggerEnd, "\"");
+_LIT8(KReqHeaderEnd, ">");
+_LIT8(KReqNonce, "<nonce>");
+_LIT8(KReqNonceEnd, "</nonce>");
+_LIT8(KReqTime, "<time>");
+_LIT8(KReqTimeEnd, "</time>");
+_LIT8(KReqDeviceId, "<deviceID><keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqDeviceIdEnd, "</hash></keyIdentifier></deviceID>");
+_LIT8(KReqRiId, "<riID><keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqRiIdEnd, "</hash></keyIdentifier></riID>");
+_LIT8(KReqDomainId, "<domainID>");
+_LIT8(KReqDomainIdEnd, "</domainID>");
+_LIT8(KReqCertChain, "<certificateChain>");
+_LIT8(KReqCert, "<certificate>");
+_LIT8(KReqCertEnd, "</certificate>");
+_LIT8(KReqCertChainEnd, "</certificateChain>");
+_LIT8(KReqNotDomainMember, "<extensions><extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:NotDomainMember\"></extension></extensions>");
+_LIT8(KReqSig, "<signature>");
+_LIT8(KReqSigEnd, "</signature></roap:leaveDomainRequest>");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CLeaveDomainReq::CLeaveDomainReq
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CLeaveDomainReq::CLeaveDomainReq():
+    iDomainId(NULL),
+    iNonce(NULL),
+    iSignature(NULL),
+    iTriggerNonce(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CLeaveDomainReq::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CLeaveDomainReq::ConstructL()
+    {
+    iTime.UniversalTime();
+    iNotMember = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CLeaveDomainReq::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CLeaveDomainReq* CLeaveDomainReq::NewL()
+    {
+    CLeaveDomainReq* self = new( ELeave ) CLeaveDomainReq;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CLeaveDomainReq::~CLeaveDomainReq()
+    {
+    iCertificateChain.ResetAndDestroy();
+    delete iDomainId;
+    delete iSignature;
+    delete iTriggerNonce;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CLeaveDomainReq::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CLeaveDomainReq::MessageAsXmlL(void)
+    {
+    HBufC8* r = NULL;
+    CBufFlat* b = NULL;
+    TInt i;
+
+    b = CBufFlat::NewL(128);
+    CleanupStack::PushL(b);
+    BufAppendL(b, KReqHeader);
+    if (iTriggerNonce)
+        {
+        BufAppendL(b, KReqNonceTrigger);
+        BufAppendL(b, *iTriggerNonce);
+        BufAppendL(b, KReqNonceTriggerEnd);
+        }
+    BufAppendL(b, KReqHeaderEnd);
+
+    BufAppendL(b, KReqDeviceId);
+    BufAppendBase64L(b, iDeviceId);
+    BufAppendL(b, KReqDeviceIdEnd);
+
+    BufAppendL(b, KReqRiId);
+    BufAppendBase64L(b, iRiId);
+    BufAppendL(b, KReqRiIdEnd);
+
+    BufAppendL(b, KReqNonce);
+    BufAppendBase64L(b, iNonce);
+    BufAppendL(b, KReqNonceEnd);
+
+    BufAppendL(b, KReqTime);
+    BufAppendTimeL(b, iTime);
+    BufAppendL(b, KReqTimeEnd);
+
+    BufAppendL(b, KReqDomainId);
+    BufAppendL(b, *iDomainId);
+    BufAppendL(b, KReqDomainIdEnd);
+
+    if (iCertificateChain.Count() > 0)
+        {
+        BufAppendL(b, KReqCertChain);
+        for (i = 0; i < iCertificateChain.Count(); i++)
+            {
+            BufAppendL(b, KReqCert);
+            BufAppendBase64L(b, *iCertificateChain[i]);
+            BufAppendL(b, KReqCertEnd);
+            }
+        BufAppendL(b, KReqCertChainEnd);
+        }
+        
+    if ( iNotMember )
+        {
+        BufAppendL(b, KReqNotDomainMember);
+        }
+
+    BufAppendL(b, KReqSig);
+    BufAppendL(b, KReqSigEnd);
+
+    r = b->Ptr(0).AllocL();
+    CleanupStack::PopAndDestroy(b);
+    return r;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/LeaveDomainResp.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,128 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "LeaveDomainResp.h"
+
+using namespace Roap;
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CLeaveDomainResp::CLeaveDomainResp
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CLeaveDomainResp::CLeaveDomainResp()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CLeaveDomainResp::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CLeaveDomainResp::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CLeaveDomainResp::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CLeaveDomainResp* CLeaveDomainResp::NewL()
+    {
+    CLeaveDomainResp* self = new( ELeave ) CLeaveDomainResp;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CLeaveDomainResp::~CLeaveDomainResp()
+    {
+    delete iDeviceNonce;
+    delete iDomainId;
+    delete iErrorUrl;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CLeaveDomainResp::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/LeaveDomainRespParser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,103 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "Base64.h"
+#include "RoapParser.h"
+#include "LeaveDomainResp.h"
+#include "LeaveDomainRespParser.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KStatus, "status");
+_LIT8(KErrorUrl, "errorRedirectURL");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TLeaveDomainRespParser::TLeaveDomainRespParser
+// 
+// -----------------------------------------------------------------------------
+//
+TLeaveDomainRespParser::TLeaveDomainRespParser(
+    CLeaveDomainResp* aResponse)
+    {
+    iResponse = aResponse;
+    }
+
+// -----------------------------------------------------------------------------
+// TLeaveDomainRespParser::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void TLeaveDomainRespParser::OnStartElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/,
+    const RAttributeArray& aAttributes)
+    {
+    HBufC8* buffer = NULL;
+
+    switch (aState)
+        {
+        case ELeaveDomainResponseState:
+            buffer = aParser.GetAttributeValueL(aAttributes, KStatus);
+            if (buffer != NULL)
+                {
+                iResponse->iStatus = aParser.ConvertRoapStatus(*buffer);
+                delete buffer;
+                }
+            else
+                {
+                iResponse->iStatus = EUnknownStatus;
+                }
+                                          
+            iResponse->iErrorUrl = aParser.GetAttributeValueL(aAttributes, KErrorUrl);
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TLeaveDomainRespParser::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void TLeaveDomainRespParser::OnEndElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/)
+    {
+    if (!aParser.iContent)
+        {
+        return;
+        }
+        
+    switch (aState)
+        {
+        case EDomainIdState:
+            iResponse->iDomainId = aParser.iContent->AllocL();
+            break;
+        }
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/MeteringReportReq.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,362 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Class representing metering report request
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "base64.h"
+#include "MeteringReportReq.h"
+#include "RoapLog.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+// XML tag related literals
+// Warning: these literals are very fragile in respect to XML canonicalisation.
+_LIT8(KReqHeader, "<roap:meteringReportSubmit xmlns:roap=\"urn:oma:bac:dldrm:roap-1.0\"");
+_LIT8(KReqNonceTrigger, " triggerNonce=\"");
+_LIT8(KReqNonceTriggerEnd, "\"");
+_LIT8(KReqHeaderEnd, ">");
+_LIT8(KReqDeviceId, "<deviceID><keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqDeviceIdEnd, "</hash></keyIdentifier></deviceID>");
+_LIT8(KReqRiId, "<riID><keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqRiIdEnd, "</hash></keyIdentifier></riID>");
+_LIT8(KReqNonce, "<nonce>");
+_LIT8(KReqNonceEnd, "</nonce>");
+_LIT8(KReqTime, "<time>");
+_LIT8(KReqTimeEnd, "</time>");
+_LIT8(KReqMeteringReport, "<meteringReport>");
+
+_LIT8(KReqReportHeader,
+"<encryptedMeteringReport>\
+<xenc:EncryptedData xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\"\
+ Type=\"http://www.w3.org/2001/04/xmlenc#Content\">\
+<xenc:EncryptionMethod\
+ Algorithm=\"http://www.w3.org/2001/04/xmlenc#aes128-cbc\">\
+</xenc:EncryptionMethod>");
+
+_LIT8(KReqKeyInfo, "<ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">\
+<ds:RetrievalMethod URI=\"#K_MEK_and_K_MAC\"></ds:RetrievalMethod>\
+</ds:KeyInfo>");
+
+_LIT8(KReqCipherDataStart, "<xenc:CipherData><xenc:CipherValue>");
+_LIT8(KReqCipherDataEnd, "</xenc:CipherValue></xenc:CipherData></xenc:EncryptedData></encryptedMeteringReport>");
+
+_LIT8(KReqEncKeyAndMethod, "<encKey Id=\"K_MEK_and_K_MAC\"><xenc:EncryptionMethod\
+ xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\" Algorithm=\"" );
+
+_LIT8(KReqEncKeyAndMethodAfterAlgorithm, "\"></xenc:EncryptionMethod>");
+
+_LIT8(KReqEncKeyInfoStart, "<ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">");
+
+// Note the two versions below are because of different namespace
+// normalisation of element roap:X509SPKIHash on canonicalisation of
+// whole request to be signed and on canonicalisation of element 
+// <meteringReport> to be MAC calculated.
+// when changing one of these another one must be cahnges too.
+//
+// This version is used when canonicalisation is performed over
+// <roap:meteringReportSubmit>
+//
+_LIT8(KReqRoapX509AndHash, "<roap:X509SPKIHash><hash>");
+//
+//
+// This version is used when canonicalisation is taken over <meteringReport>
+// (on MAC calculation)
+//
+_LIT8(KReqRoapX509AndHashNs, "<roap:X509SPKIHash xmlns:roap=\"urn:oma:bac:dldrm:roap-1.0\"><hash>");
+
+
+_LIT8(KReqEncKeyInfoEnd, "</hash></roap:X509SPKIHash></ds:KeyInfo>\
+<xenc:CipherData xmlns:xenc=\"http://www.w3.org/2001/04/xmlenc#\"><xenc:CipherValue>");
+
+_LIT8(KReqCipherValueEnd, "</xenc:CipherValue></xenc:CipherData></encKey>");
+_LIT8(KReqMacStart, "<mac>");
+_LIT8(KReqMacEnd, "</mac>");
+_LIT8(KReqReportHeaderEnd, "</meteringReport>");
+_LIT8(KReqCertChain, "<certificateChain>");
+_LIT8(KReqCert, "<certificate>");
+_LIT8(KReqCertEnd, "</certificate>");
+_LIT8(KReqCertChainEnd, "</certificateChain>");
+_LIT8(KReqSig, "<signature>");
+_LIT8(KReqSigEnd, "</signature></roap:meteringReportSubmit>");
+// literals for key transport scheme
+_LIT8( KOmaKdf, "http://www.rsasecurity.com/rsalabs/pkcs/schemas/pkcs-1#rsaes-kem-kdf2-kw-aes128");
+_LIT8( KCmlaIp1, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-1");
+// ============================ LOCAL FUNCTIONS ===============================
+
+// ----------------------------------------------------------------------------
+// MeteringReportElementAsTextL
+//
+// write content of to given flat buffer 
+// Used from MessageAsXmlL and from InsertMacL
+// Note content depends on value of 
+// ----------------------------------------------------------------------------
+LOCAL_C inline void MeteringReportElementAsTextL(
+    CBufFlat*& aBuf,
+    const Roap::CMeteringReportReq& aReq
+    )
+    {
+    Roap::CRoapMessage::BufAppendL( aBuf, KReqMeteringReport );
+    Roap::CRoapMessage::BufAppendL( aBuf, KReqReportHeader );
+
+    Roap::CRoapMessage::BufAppendL( aBuf, KReqKeyInfo );
+
+    Roap::CRoapMessage::BufAppendL( aBuf, KReqCipherDataStart );
+
+    // actual encrypted metering data
+    if ( aReq.iCipherValue )
+        {
+        Roap::CRoapMessage::BufAppendBase64L( aBuf, *aReq.iCipherValue );
+        }
+
+    Roap::CRoapMessage::BufAppendL( aBuf, KReqCipherDataEnd );
+
+    Roap::CRoapMessage::BufAppendL( aBuf, KReqEncKeyAndMethod );
+
+    // Select KDF algorithm in use
+    if ( aReq.iAlgorithmInUse == ECmlaIp1 )
+        {
+        Roap::CRoapMessage::BufAppendL( aBuf, KCmlaIp1 );
+        }
+    else if ( aReq.iAlgorithmInUse == EOma )
+        {
+        Roap::CRoapMessage::BufAppendL( aBuf, KOmaKdf );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    Roap::CRoapMessage::BufAppendL( aBuf, KReqEncKeyAndMethodAfterAlgorithm );
+    Roap::CRoapMessage::BufAppendL( aBuf, KReqEncKeyInfoStart );
+
+    if ( aReq.iMac )
+        {
+        // used as part of roap:Meteringreport submit
+        // so namespace ROAP already defined in container element
+        Roap::CRoapMessage::BufAppendL( aBuf, KReqRoapX509AndHash );
+        }
+    else
+        {
+        // used in mac calculation 
+        // canonical form requires namespace definition for namespace roap
+        Roap::CRoapMessage::BufAppendL( aBuf, KReqRoapX509AndHashNs );
+        }
+
+    // Insert 128-bit encrypted encryption key PKI hash
+    Roap::CRoapMessage::BufAppendBase64L( aBuf, aReq.iEncKeyHash );
+
+
+    Roap::CRoapMessage::BufAppendL( aBuf, KReqEncKeyInfoEnd );
+
+    // key wrapping info
+    Roap::CRoapMessage::BufAppendBase64L( aBuf, *aReq.iEncryptedMekAndMak );
+
+    Roap::CRoapMessage::BufAppendL( aBuf, KReqCipherValueEnd );    
+
+    // Insert 128-bit encrypted MAC value
+    if ( aReq.iMac )
+        {
+        Roap::CRoapMessage::BufAppendL( aBuf, KReqMacStart );
+        Roap::CRoapMessage::BufAppendBase64L( aBuf, *aReq.iMac );
+        Roap::CRoapMessage::BufAppendL( aBuf, KReqMacEnd );
+        }
+    Roap::CRoapMessage::BufAppendL( aBuf, KReqReportHeaderEnd );
+    }
+
+// -----------------------------------------------------------------------------
+// CalculateMacL
+// -----------------------------------------------------------------------------
+//
+LOCAL_C HBufC8* CalculateMacL(const TDesC8& aElement, const TDesC8& aMacKey )
+    {
+
+    LOG( _L8( "CalculateMacL" ) );
+    LOG( _L8( "aMacKey" ) );
+    LOGHEX( aMacKey.Ptr(), aMacKey.Length() );
+    LOG( _L8( "aElement" ) );
+    LOGHEX( aElement.Ptr(), aElement.Length() );
+    if( !aMacKey.Length() || !aElement.Length() )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    CHMAC* hMac = NULL;
+    CSHA1* sha = NULL;
+    TPtrC8 hmac_value( KNullDesC8 );
+    TPtrC8 sha1_value( KNullDesC8 );
+    HBufC8* macValue = NULL;
+
+    sha = CSHA1::NewL();
+    CleanupStack::PushL( sha );
+    hMac = CHMAC::NewL( aMacKey, sha );
+    CleanupStack::Pop( sha ); // sha is now owned by hMac
+    CleanupStack::PushL( hMac );
+    hMac->Update( aElement );
+    hmac_value.Set( hMac->Final() );
+
+    macValue = hmac_value.AllocL();
+    LOG( _L8( "macValue" ) );
+    LOGHEX( macValue->Ptr(), macValue->Length() );
+
+    CleanupStack::PopAndDestroy( hMac );
+    return macValue;
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRightsReq::CRightsReq
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CMeteringReportReq::CMeteringReportReq():
+    iNonce(NULL),
+    iReportNonce(NULL),
+    iSignature(NULL),
+    iCipherValue(NULL),
+    iMac(NULL),
+    iTriggerNonce(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsReq::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CMeteringReportReq::ConstructL()
+    {
+    iTime.UniversalTime();
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsReq::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CMeteringReportReq* CMeteringReportReq::NewL()
+    {
+    CMeteringReportReq* self = new( ELeave ) CMeteringReportReq;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+
+// Destructor
+CMeteringReportReq::~CMeteringReportReq()
+    {
+    if ( iCertificateChain.Count() )
+        {
+        iCertificateChain.ResetAndDestroy();
+        }
+    delete iSignature;
+    delete iTriggerNonce;
+    delete iCipherValue;
+    delete iEncryptedMekAndMak;
+    delete iMac;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRightsReq::MessageAsXmlL
+// Gives XML representation of meteringreport request
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CMeteringReportReq::MessageAsXmlL(void)
+    {
+    HBufC8* r( NULL );
+    CBufFlat* b( CBufFlat::NewL( 128 ) );
+    CleanupStack::PushL( b );
+    b->InsertL( 0, KReqHeader );
+    if ( iTriggerNonce )
+        {
+        BufAppendL( b, KReqNonceTrigger );
+        BufAppendL( b, *iTriggerNonce );
+        BufAppendL( b, KReqNonceTriggerEnd );
+        }
+    BufAppendL( b, KReqHeaderEnd );
+
+    BufAppendL( b, KReqDeviceId );
+    BufAppendBase64L( b, iDeviceId );
+    BufAppendL( b, KReqDeviceIdEnd );
+
+    BufAppendL( b, KReqRiId );
+    BufAppendBase64L( b, iRiId );
+    BufAppendL( b, KReqRiIdEnd );
+
+    BufAppendL( b, KReqNonce );
+    BufAppendBase64L( b, iNonce );
+    BufAppendL( b, KReqNonceEnd );
+
+    BufAppendL( b, KReqTime );
+    BufAppendTimeL( b, iTime );
+    BufAppendL( b, KReqTimeEnd );
+
+    MeteringReportElementAsTextL( b, *this );
+
+    if ( iCertificateChain.Count() > 0 )
+        {
+        BufAppendL( b, KReqCertChain );
+        for ( TInt i( 0 ); i < iCertificateChain.Count(); i++ )
+            {
+            BufAppendL( b, KReqCert );
+            BufAppendBase64L( b, *iCertificateChain[ i ] );
+            BufAppendL( b, KReqCertEnd );
+            }
+        BufAppendL( b, KReqCertChainEnd );
+        }
+
+    BufAppendL(b, KReqSig);
+    BufAppendL(b, KReqSigEnd);
+
+    r = b->Ptr( 0 ).AllocL();
+    CleanupStack::PopAndDestroy( b );
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CMeteringReportReq::InsertMacL( const TDesC8& aMac )
+// Calculate MAC -value over <encryptedMeteringReport>
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CMeteringReportReq::InsertMacL( const TDesC8& aMacKey )
+    {
+    CBufFlat* b( CBufFlat::NewL( 128 ) );
+    CleanupStack::PushL( b );
+
+
+    MeteringReportElementAsTextL( b, *this );
+
+    // Calculate MAC -value over <encryptedMeteringReport>
+    // without the actual <mac> -element
+
+    iMac = CalculateMacL( b->Ptr( 0 ), aMacKey );
+    CleanupStack::PopAndDestroy( b );
+    return;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/MeteringReportResp.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  class representing metering report response
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "MeteringReportResp.h"
+
+using namespace Roap;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRegistrationResp::CRegistrationResp
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CMeteringResp::CMeteringResp()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRegistrationResp::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CMeteringResp::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRegistrationResp::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CMeteringResp* CMeteringResp::NewL()
+    {
+    CMeteringResp* self = new( ELeave ) CMeteringResp;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+
+// Destructor
+CMeteringResp::~CMeteringResp()
+    {
+    iCertificateChain.ResetAndDestroy();
+    iOcspResponse.ResetAndDestroy();
+    delete iDeviceNonce;
+    delete iErrorUrl;
+    delete iSignature;
+    delete iPrUrl;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/MeteringReportRespParser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,176 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  MeteringReportResponse Parser
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "Base64.h"
+#include "RoapParser.h"
+#include "MeteringReportResp.h"
+#include "MeteringReportRespParser.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KStatus, "status");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TRegistrationRespParser::TRegistrationRespParser
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+TMeteringRespParser::TMeteringRespParser(
+    CMeteringResp* aResponse)
+    {
+    iResponse = aResponse;
+    }
+
+// -----------------------------------------------------------------------------
+// TMeteringRespParser::OnStartElementL
+// -----------------------------------------------------------------------------
+//
+void TMeteringRespParser::OnStartElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/,
+    const RAttributeArray& aAttributes)
+    {
+    HBufC8* buffer = NULL;
+
+    switch (aState)
+        {
+        case EMeteringReportResponseState:
+            buffer = aParser.GetAttributeValueL(aAttributes, KStatus);
+            if ( buffer )
+                {
+                CleanupStack::PushL( buffer );
+
+                // In case of a malformer request
+                _LIT8(KStatus, "MalFormedRequest");
+                if ( buffer->Compare( KStatus ) == 0 )
+                    {
+                    iResponse->iStatus = EMalformedRequest;
+                    }
+                else
+                    {
+                    iResponse->iStatus = aParser.ConvertRoapStatus( *buffer );
+                    }
+                CleanupStack::PopAndDestroy( buffer );
+                }
+            else
+                {
+                iResponse->iStatus = EUnknownStatus;
+                }
+            break;
+        default:
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TMeteringRespParser::OnEndElementL
+// -----------------------------------------------------------------------------
+//
+void TMeteringRespParser::OnEndElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/)
+    {
+    HBufC8* buffer = NULL;
+
+    if ( !aParser.iContent )
+        {
+        return;
+        }
+
+    switch (aState)
+        {
+        case EDeviceIdState:
+            buffer = Base64DecodeL( *aParser.iContent );
+            CleanupStack::PushL( buffer );
+            if ( buffer->Length() != SHA1_HASH )
+                {
+                CleanupStack::PopAndDestroy( buffer );
+                User::Leave( KErrCorrupt );
+                }
+            iResponse->iDeviceId.Copy( *buffer );
+            CleanupStack::PopAndDestroy( buffer );
+            break;
+        case ERiIdState:
+            buffer = Base64DecodeL( *aParser.iContent );
+            CleanupStack::PushL( buffer );
+            if ( buffer->Length() != SHA1_HASH )
+                {
+                User::Leave( KErrCorrupt );
+                }
+            iResponse->iRiId.Copy( *buffer );
+            CleanupStack::PopAndDestroy( buffer );
+            buffer=NULL;
+            break;
+        case ENonceState:
+            if( aParser.iContent->Length() )
+                {
+                buffer = Base64DecodeL( *aParser.iContent );
+                CleanupStack::PushL( buffer );
+                if ( buffer->Length() != KDeviceNonceLength )
+                    {
+                    User::Leave( KErrCorrupt );
+                    }
+                CleanupStack::Pop( buffer );
+                iResponse->iDeviceNonce = buffer;
+                buffer=NULL;
+                }
+            else
+                {
+                User::Leave( KErrCorrupt );
+                }
+            break;
+        case ESignatureState:
+            iResponse->iSignature = Base64DecodeL( *aParser.iContent );
+            break;
+        case ECertificateState:
+            buffer = Base64DecodeL( *aParser.iContent );
+            CleanupStack::PushL( buffer );
+            iResponse->iCertificateChain.AppendL( buffer );
+            CleanupStack::Pop( buffer );
+            break;
+        case EOcspResponseState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            CleanupStack::PushL(buffer);
+            iResponse->iOcspResponse.AppendL(buffer);
+            CleanupStack::Pop( buffer );
+            break;
+        case EPostResponseUrlState:
+            if ( aParser.iContent )
+                {
+                iResponse->iPrUrl = aParser.iContent->AllocL();
+                }
+            else
+                {
+                User::Leave( KErrCorrupt );
+                }
+            break;
+        default:
+            break;
+        }
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RIContext.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "RIContext.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRIContext::CRIContext
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRIContext::CRIContext()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRIContext::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRIContext::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CJoinDomainReq::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRIContext* CRIContext::NewL()
+    {
+    CRIContext* self = new( ELeave ) CRIContext;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CRIContext::~CRIContext()
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RIHello.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,142 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "RIHello.h"
+
+using namespace Roap;
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRIHello::CRIHello
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRIHello::CRIHello():
+    iStatus(ESuccess),
+    iSession(NULL),
+    iRiNonce(NULL),
+    iServerInfo(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRIHello::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRIHello::ConstructL()
+    {
+    iSelectedVersion.SetLength(0);
+    iRiId.SetLength(0);
+    iPeerKeyId.SetLength(0);
+    iNeedDeviceDetails = EFalse;
+    iPeerKeyIdentifier = EFalse;
+    iCertificateCaching = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CRIHello::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRIHello* CRIHello::NewL()
+    {
+    CRIHello* self = new( ELeave ) CRIHello;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CRIHello::~CRIHello()
+    {
+    delete iSession;
+    delete iRiNonce;
+    delete iServerInfo;
+    delete iErrorUrl;
+    iAlgorithms.ResetAndDestroy();
+    iTrustedAuthorities.ResetAndDestroy();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRIHello::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RIHelloParser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "Base64.h"
+#include "RoapParser.h"
+#include "RIHello.h"
+#include "RIHelloParser.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KStatus, "status");
+_LIT8(KType, "type");
+_LIT8(KSessionId, "sessionId");
+_LIT8(KDeviceDetails, "DeviceDetails");
+_LIT8(KPeerKeyIdentifier, "PeerKeyIdentifier");
+_LIT8(KCertificateCaching, "CertificateCaching");
+_LIT8(KErrorUrl, "errorRedirectURL");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TRIHelloParser::TRIHelloParser
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+TRIHelloParser::TRIHelloParser(
+    CRIHello* aResponse)
+    {
+    iResponse = aResponse;
+    }
+
+// -----------------------------------------------------------------------------
+// TRIHelloRespParser::OnStartElementL
+// 
+// -----------------------------------------------------------------------------
+//
+void TRIHelloParser::OnStartElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/,
+    const RAttributeArray& aAttributes)
+    {
+    HBufC8* buffer = NULL;
+
+    switch (aState)
+        {
+        case ERiHelloState:
+            {
+            buffer = aParser.GetAttributeValueL(aAttributes, KStatus);
+            if (buffer != NULL)
+                {
+                iResponse->iStatus = aParser.ConvertRoapStatus(*buffer);
+                delete buffer;
+                }
+            else
+                {
+                iResponse->iStatus = EUnknownStatus;
+                }
+            iResponse->iSession =
+                aParser.GetAttributeValueL(aAttributes, KSessionId);
+                              
+            iResponse->iErrorUrl = aParser.GetAttributeValueL(aAttributes, KErrorUrl);
+            break;
+            }
+        case EExtensionState:
+            {
+            buffer = aParser.GetAttributeValueL(aAttributes, KType );
+            if(buffer != NULL)
+                {
+                if(buffer->Find(KDeviceDetails) >= KErrNone)
+                    {
+                    iResponse->iNeedDeviceDetails = ETrue;
+                    }
+                 if(buffer->Find(KPeerKeyIdentifier) >= KErrNone)
+                    {
+                    iResponse->iPeerKeyIdentifier = ETrue;
+                    }
+                 if(buffer->Find(KCertificateCaching) >= KErrNone)
+                    {
+                    iResponse->iCertificateCaching = ETrue;
+                    }
+                delete buffer;
+                }
+            break;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TRIHelloRespParser::OnEndElementL
+// 
+// -----------------------------------------------------------------------------
+//
+void TRIHelloParser::OnEndElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/)
+    {
+    HBufC8* buffer = NULL;
+    
+    if( !aParser.iContent )
+        {
+        return;
+        }
+
+    switch (aState)
+        {
+        case ESelectedVersionState:
+            if ( aParser.iContent->Length() > KMaxRoapVersionLength )
+                {
+                User::Leave( KErrCorrupt );
+                }
+            iResponse->iSelectedVersion.Copy(*aParser.iContent);
+            break;
+        case ERiNonceState:
+            iResponse->iRiNonce = Base64DecodeL(*aParser.iContent);
+            break;
+        case ERiIdState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            if ( buffer->Length() > SHA1_HASH )
+                {
+                delete buffer;
+                buffer = NULL;
+                User::Leave( KErrCorrupt );
+                }
+            iResponse->iRiId.Copy(*buffer);
+            delete buffer;
+            break;
+        case ESelectedAlgorithmState:
+            buffer = aParser.iContent->AllocLC();
+            iResponse->iAlgorithms.AppendL( buffer );
+            CleanupStack::Pop();
+            break;
+        case EServerInfoState:
+            iResponse->iServerInfo = aParser.iContent->AllocL();   
+            break;
+        case ETrustedAuthoritiesState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            iResponse->iTrustedAuthorities.AppendL(buffer);
+            break;
+        case EPeerKeyIdentifierRIHelloState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            if ( buffer->Length() > SHA1_HASH )
+                {
+                delete buffer;
+                buffer = NULL;
+                User::Leave( KErrCorrupt );
+                }
+            iResponse->iPeerKeyId.Copy(*buffer);
+            delete buffer;
+            break;
+        }
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RegistrationReq.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,259 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "base64.h"
+#include "RegistrationReq.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KReqHeader, "<roap:registrationRequest xmlns:roap=\"urn:oma:bac:dldrm:roap-1.0\"\
+ sessionId=\"");
+_LIT8(KReqSessionIdEnd, "\"");
+_LIT8(KReqNonceTrigger, " triggerNonce=\"");
+_LIT8(KReqNonceTriggerEnd, "\"");
+_LIT8(KReqHeaderEnd, ">");
+_LIT8(KReqNonce, "<nonce>");
+_LIT8(KReqNonceEnd, "</nonce>");
+_LIT8(KReqTime, "<time>");
+_LIT8(KReqTimeEnd, "</time>");
+_LIT8(KReqCertChain, "<certificateChain>");
+_LIT8(KReqCert, "<certificate>");
+_LIT8(KReqCertEnd, "</certificate>");
+_LIT8(KReqCertChainEnd, "</certificateChain>");
+_LIT8(KReqTrustedAuthorities,"<trustedAuthorities>");
+_LIT8(KReqTrustedRoot, "<keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqTrustedRootEnd, "</hash></keyIdentifier>");
+_LIT8(KReqTrustedAuthoritiesEnd, "</trustedAuthorities>");
+_LIT8(KReqServerInfo, "<serverInfo>");
+_LIT8(KReqServerInfoEnd, "</serverInfo>");
+_LIT8(KReqExtensions, "<extensions>");
+_LIT8(KReqExtensionsEnd, "</extensions>");
+_LIT8(KReqPeerKey, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:PeerKeyIdentifier\">\
+<identifier algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqPeerKeyEnd, "</hash></identifier></extension>");
+_LIT8(KReqNoOcspResponse, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:NoOCSPResponse\"></extension>");
+_LIT8(KReqOcspResponderKeyId, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:OCSPResponderKeyIdentifier\">\
+<identifier algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqOcspResponderKeyIdEnd, "</hash></identifier></extension>");
+_LIT8(KReqDevDetails, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:DeviceDetails\"><manufacturer>");
+_LIT8(KReqDevDetailsModel, "</manufacturer><model>");
+_LIT8(KReqDevDetailsVersion, "</model><version>");
+_LIT8(KReqDevDetailsEnd, "</version></extension>");
+_LIT8(KReqSig, "<signature>");
+_LIT8(KReqSigEnd, "</signature></roap:registrationRequest>");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRegistrationReq::CRegistrationReq
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRegistrationReq::CRegistrationReq():
+    iSession(NULL),
+    iNonce(NULL),
+    iServerInfo(NULL),
+    iSignature(NULL),
+    iDeviceDetailsManufacturer(NULL),
+    iDeviceDetailsModel(NULL),
+    iDeviceDetailsVersion(NULL),
+    iOcspResponderKeyId(NULL),
+    iTriggerNonce(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRegistrationReq::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRegistrationReq::ConstructL()
+    {
+    iTime.UniversalTime();
+    iPeerKeyIdentifier.SetLength(0);
+    iOcspInfoStored = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CRegistrationReq::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRegistrationReq* CRegistrationReq::NewL()
+    {
+    CRegistrationReq* self = new( ELeave ) CRegistrationReq;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CRegistrationReq::~CRegistrationReq()
+    {
+    iCertificateChain.ResetAndDestroy();
+    delete iSession;
+    delete iSignature;
+    delete iDeviceDetailsManufacturer;
+    delete iDeviceDetailsModel;
+    delete iDeviceDetailsVersion;
+    delete iTriggerNonce;
+    delete iServerInfo;
+    delete iOcspResponderKeyId;
+    iTrustedAuthorities.ResetAndDestroy();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRegistrationReq::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CRegistrationReq::MessageAsXmlL(void)
+    {
+    HBufC8* r = NULL;
+    CBufFlat* b = NULL;
+    TInt i;
+
+    b = CBufFlat::NewL(128);
+    CleanupStack::PushL(b);
+    BufAppendL(b, KReqHeader);
+    BufAppendL(b, *iSession);
+    BufAppendL(b, KReqSessionIdEnd);
+    if (iTriggerNonce)
+        {
+        BufAppendL(b, KReqNonceTrigger);
+        BufAppendL(b, *iTriggerNonce);
+        BufAppendL(b, KReqNonceTriggerEnd);
+        }
+    BufAppendL(b, KReqHeaderEnd);
+
+    BufAppendL(b, KReqNonce);
+    BufAppendBase64L(b, iNonce);
+    BufAppendL(b, KReqNonceEnd);
+
+    BufAppendL(b, KReqTime);
+    BufAppendTimeL(b, iTime);
+    BufAppendL(b, KReqTimeEnd);
+
+    if (iCertificateChain.Count() > 0)
+        {
+        BufAppendL(b, KReqCertChain);
+        for (i = 0; i < iCertificateChain.Count(); i++)
+            {
+            BufAppendL(b, KReqCert);
+            BufAppendBase64L(b, *iCertificateChain[i]);
+            BufAppendL(b, KReqCertEnd);
+            }
+        BufAppendL(b, KReqCertChainEnd);
+        }
+        
+    if (iTrustedAuthorities.Count() > 0)
+        {
+        BufAppendL(b, KReqTrustedAuthorities);
+        for (i = 0; i < iTrustedAuthorities.Count(); i++)
+            {
+            BufAppendL(b, KReqTrustedRoot);
+            BufAppendBase64L(b, *iTrustedAuthorities[i]);
+            BufAppendL(b, KReqTrustedRootEnd);
+            }
+        BufAppendL(b, KReqTrustedAuthoritiesEnd);     
+        }
+        
+    if (iServerInfo)
+        {
+        BufAppendL(b, KReqServerInfo);
+        BufAppendL(b, *iServerInfo);
+        BufAppendL(b, KReqServerInfoEnd);    
+        }
+        
+    if ((iDeviceDetailsManufacturer &&
+         iDeviceDetailsModel &&
+         iDeviceDetailsVersion) ||
+         iPeerKeyIdentifier.Length() ||
+         iOcspResponderKeyId ||
+         iOcspInfoStored )
+        {
+        BufAppendL(b, KReqExtensions);
+        }
+        
+    if (iPeerKeyIdentifier.Length())
+        {
+        BufAppendL(b, KReqPeerKey);
+        BufAppendBase64L(b, iPeerKeyIdentifier);
+        BufAppendL(b, KReqPeerKeyEnd);
+        }
+        
+     if (iOcspInfoStored)
+        {
+        BufAppendL(b, KReqNoOcspResponse);
+        }
+        
+     if (iOcspResponderKeyId)
+        {
+        BufAppendL(b, KReqOcspResponderKeyId);
+        BufAppendBase64L(b, *iOcspResponderKeyId);
+        BufAppendL(b, KReqOcspResponderKeyIdEnd);
+        }
+         
+    if (iDeviceDetailsManufacturer != NULL &&
+        iDeviceDetailsModel != NULL &&
+        iDeviceDetailsVersion != NULL)
+        {
+        BufAppendL(b, KReqDevDetails);
+        BufAppendL(b, *iDeviceDetailsManufacturer);
+        BufAppendL(b, KReqDevDetailsModel);
+        BufAppendL(b, *iDeviceDetailsModel);
+        BufAppendL(b, KReqDevDetailsVersion);
+        BufAppendL(b, *iDeviceDetailsVersion);
+        BufAppendL(b, KReqDevDetailsEnd);
+        }
+        
+    if ((iDeviceDetailsManufacturer &&
+         iDeviceDetailsModel &&
+         iDeviceDetailsVersion) ||
+         iPeerKeyIdentifier.Length() ||
+         iOcspResponderKeyId ||
+         iOcspInfoStored )
+        {
+        BufAppendL(b, KReqExtensionsEnd);
+        }
+
+    BufAppendL(b, KReqSig);
+    BufAppendL(b, KReqSigEnd);
+
+    r = b->Ptr(0).AllocL();
+    CleanupStack::PopAndDestroy(b);
+    return r;
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RegistrationResp.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,135 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "RegistrationResp.h"
+
+using namespace Roap;
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRegistrationResp::CRegistrationResp
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRegistrationResp::CRegistrationResp():
+    iSession(NULL),
+    iRiUrl(NULL),
+    iSignature(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRegistrationResp::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRegistrationResp::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRegistrationResp::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRegistrationResp* CRegistrationResp::NewL()
+    {
+    CRegistrationResp* self = new( ELeave ) CRegistrationResp;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CRegistrationResp::~CRegistrationResp()
+    {
+    iCertificateChain.ResetAndDestroy();
+    iOcspResponse.ResetAndDestroy();
+    iWhiteList.ResetAndDestroy();
+    delete iSession;
+    delete iRiUrl;
+    delete iSignature;
+    delete iErrorUrl;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRegistrationResp::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RegistrationRespParser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "Base64.h"
+#include "RoapParser.h"
+#include "RegistrationResp.h"
+#include "RegistrationRespParser.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KStatus, "status");
+_LIT8(KSessionId, "sessionId");
+_LIT8(KErrorUrl, "errorRedirectURL");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TRegistrationRespParser::TRegistrationRespParser
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+TRegistrationRespParser::TRegistrationRespParser(
+    CRegistrationResp* aResponse)
+    {
+    iResponse = aResponse;
+    }
+
+// -----------------------------------------------------------------------------
+// TRegistrationRespParser::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void TRegistrationRespParser::OnStartElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/,
+    const RAttributeArray& aAttributes)
+    {
+    HBufC8* buffer = NULL;
+
+    switch (aState)
+        {
+        case ERegistrationResponseState:
+            buffer = aParser.GetAttributeValueL(aAttributes, KStatus);
+            if (buffer != NULL)
+                {
+                iResponse->iStatus = aParser.ConvertRoapStatus(*buffer);
+                delete buffer;
+                }
+            else
+                {
+                iResponse->iStatus = EUnknownStatus;
+                }
+            iResponse->iSession =
+                aParser.GetAttributeValueL(aAttributes, KSessionId);
+                            
+            iResponse->iErrorUrl = aParser.GetAttributeValueL(aAttributes, KErrorUrl);
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TRegistrationRespParser::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void TRegistrationRespParser::OnEndElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/)
+    {
+    switch (aState)
+        {
+        case ECertificateState:
+            if( aParser.iContent->Length() )
+                iResponse->iCertificateChain.Append(
+                    Base64DecodeL(*aParser.iContent));
+            break;
+        case EOcspResponseState:
+            if( aParser.iContent->Length() )
+                iResponse->iOcspResponse.Append(Base64DecodeL(*aParser.iContent));
+            break;
+        case ERiUrlState:
+            if( aParser.iContent->Length() )
+                iResponse->iRiUrl = aParser.iContent->AllocL();
+            break;
+        case ESignatureState:
+            if( aParser.iContent->Length() )
+                iResponse->iSignature = Base64DecodeL(*aParser.iContent);
+            break;
+        case EWhiteListState:
+            if( aParser.iContent->Length() )
+                iResponse->iWhiteList.Append(aParser.iContent->AllocL());
+            break;
+        }
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RightsReq.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,254 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "base64.h"
+#include "RightsReq.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KReqHeader, "<roap:roRequest xmlns:roap=\"urn:oma:bac:dldrm:roap-1.0\"");
+_LIT8(KReqNonceTrigger, " triggerNonce=\"");
+_LIT8(KReqNonceTriggerEnd, "\"");
+_LIT8(KReqHeaderEnd, ">");
+_LIT8(KReqNonce, "<nonce>");
+_LIT8(KReqNonceEnd, "</nonce>");
+_LIT8(KReqTime, "<time>");
+_LIT8(KReqTimeEnd, "</time>");
+_LIT8(KReqDeviceId, "<deviceID><keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqDeviceIdEnd, "</hash></keyIdentifier></deviceID>");
+_LIT8(KReqRiId, "<riID><keyIdentifier xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqRiIdEnd, "</hash></keyIdentifier></riID>");
+_LIT8(KReqRoInfo, "<roInfo>");
+_LIT8(KReqRoInfoEnd, "</roInfo>");
+_LIT8(KReqRoId, "<roID>");
+_LIT8(KReqRoIdEnd, "</roID>");
+_LIT8(KReqDomainId, "<domainID>");
+_LIT8(KReqDomainIdEnd, "</domainID>");
+_LIT8(KReqCertChain, "<certificateChain>");
+_LIT8(KReqCert, "<certificate>");
+_LIT8(KReqCertEnd, "</certificate>");
+_LIT8(KReqCertChainEnd, "</certificateChain>");
+_LIT8(KReqExtensions, "<extensions>");
+_LIT8(KReqExtensionsEnd, "</extensions>");
+_LIT8(KReqPeerKey, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:PeerKeyIdentifier\">\
+<identifier algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqPeerKeyEnd, "</hash></identifier></extension>");
+_LIT8(KReqNoOcspResponse, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:NoOCSPResponse\"></extension>");
+_LIT8(KReqOcspResponderKeyId, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:OCSPResponderKeyIdentifier\">\
+<identifier algorithm=\"http://www.w3.org/2000/09/xmldsig#sha1\" xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KReqOcspResponderKeyIdEnd, "</hash></identifier></extension>");
+_LIT8(KReqTransactionContentId, "<extension xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\
+ xsi:type=\"roap:TransactionIdentifier\"><contentID>");
+ _LIT8(KReqTransactionContentIdEnd, "</contentID>");
+ _LIT8(KReqTransactionId, "<id>");
+_LIT8(KReqTransactionIdEnd, "</id></extension>");
+_LIT8(KReqSig, "<signature>");
+_LIT8(KReqSigEnd, "</signature></roap:roRequest>");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRightsReq::CRightsReq
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRightsReq::CRightsReq():
+    iDomainId(NULL),
+    iNonce(NULL),
+    iSignature(NULL),
+    iDcfHash(NULL),
+    iOcspResponderKeyId(NULL),
+    iTriggerNonce(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsReq::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRightsReq::ConstructL()
+    {
+    iDcfHash.SetLength(0);
+    iTime.UniversalTime();
+    iPeerKeyIdentifier.SetLength(0);
+    iOcspInfoStored = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsReq::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRightsReq* CRightsReq::NewL()
+    {
+    CRightsReq* self = new( ELeave ) CRightsReq;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CRightsReq::~CRightsReq()
+    {
+    iRoIdList.ResetAndDestroy();
+    iCertificateChain.ResetAndDestroy();
+    iTransTrackIDs.ResetAndDestroy();
+    iContentIDs.ResetAndDestroy();
+    delete iDomainId;
+    delete iSignature;
+    delete iTriggerNonce;
+    delete iOcspResponderKeyId;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRightsReq::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CRightsReq::MessageAsXmlL(void)
+    {
+    HBufC8* r = NULL;
+    CBufFlat* b = NULL;
+    TInt i;
+
+    b = CBufFlat::NewL(128);
+    CleanupStack::PushL(b);
+    b->InsertL(0, KReqHeader);
+    if (iTriggerNonce)
+        {
+        BufAppendL(b, KReqNonceTrigger);
+        BufAppendL(b, *iTriggerNonce);
+        BufAppendL(b, KReqNonceTriggerEnd);
+        }
+    BufAppendL(b, KReqHeaderEnd);
+
+    BufAppendL(b, KReqDeviceId);
+    BufAppendBase64L(b, iDeviceId);
+    BufAppendL(b, KReqDeviceIdEnd);
+
+    if (iDomainId)
+        {
+        BufAppendL(b, KReqDomainId);
+        BufAppendL(b, *iDomainId);
+        BufAppendL(b, KReqDomainIdEnd);
+        }
+
+    BufAppendL(b, KReqRiId);
+    BufAppendBase64L(b, iRiId);
+    BufAppendL(b, KReqRiIdEnd);
+
+    BufAppendL(b, KReqNonce);
+    BufAppendBase64L(b, iNonce);
+    BufAppendL(b, KReqNonceEnd);
+
+    BufAppendL(b, KReqTime);
+    BufAppendTimeL(b, iTime);
+    BufAppendL(b, KReqTimeEnd);
+
+    BufAppendL(b, KReqRoInfo);
+    for (i = 0; i < iRoIdList.Count(); i++)
+        {
+        BufAppendL(b, KReqRoId);
+        BufAppendL(b, *iRoIdList[i]);
+        BufAppendL(b, KReqRoIdEnd);
+        }
+    BufAppendL(b, KReqRoInfoEnd);
+
+    if (iCertificateChain.Count() > 0)
+        {
+        BufAppendL(b, KReqCertChain);
+        for (i = 0; i < iCertificateChain.Count(); i++)
+            {
+            BufAppendL(b, KReqCert);
+            BufAppendBase64L(b, *iCertificateChain[i]);
+            BufAppendL(b, KReqCertEnd);
+            }
+        BufAppendL(b, KReqCertChainEnd);
+        }
+        
+    if (iTransTrackIDs.Count() ||
+        iPeerKeyIdentifier.Length() ||
+        iOcspResponderKeyId ||
+        iOcspInfoStored)
+        {
+        BufAppendL(b, KReqExtensions);
+        }
+        
+    if (iPeerKeyIdentifier.Length())
+        {
+        BufAppendL(b, KReqPeerKey);
+        BufAppendBase64L(b, iPeerKeyIdentifier);
+        BufAppendL(b, KReqPeerKeyEnd);
+        }
+        
+    if (iOcspInfoStored)
+        {
+        BufAppendL(b, KReqNoOcspResponse);
+        }
+        
+    if (iOcspResponderKeyId)
+        {
+        BufAppendL(b, KReqOcspResponderKeyId);
+        BufAppendBase64L(b, *iOcspResponderKeyId);
+        BufAppendL(b, KReqOcspResponderKeyIdEnd);
+        }
+        
+    for ( TInt i = 0; i < iTransTrackIDs.Count() && i < iContentIDs.Count(); i++ )
+        {
+        BufAppendL(b, KReqTransactionContentId);
+        BufAppendL(b, *iContentIDs[i]);
+        BufAppendL(b, KReqTransactionContentIdEnd);
+        BufAppendL(b, KReqTransactionId);
+        BufAppendL(b, *iTransTrackIDs[i]);
+        BufAppendL(b, KReqTransactionIdEnd);
+        }
+               
+    if (iTransTrackIDs.Count() ||
+         iPeerKeyIdentifier.Length() ||
+         iOcspResponderKeyId ||
+         iOcspInfoStored)
+        {
+        BufAppendL(b, KReqExtensionsEnd);
+        }
+
+    BufAppendL(b, KReqSig);
+    BufAppendL(b, KReqSigEnd);
+
+    r = b->Ptr(0).AllocL();
+    CleanupStack::PopAndDestroy(b);
+    return r;
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RightsResp.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,101 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "RightsResp.h"
+
+using namespace Roap;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRightsResp::CRightsResp
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRightsResp::CRightsResp():
+    iSession(NULL),
+    iNonce(NULL),
+    iRoEncryptionKey(NULL),
+    iSignature(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsResp::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRightsResp::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsResp::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRightsResp* CRightsResp::NewL()
+    {
+    CRightsResp* self = new( ELeave ) CRightsResp;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CRightsResp::~CRightsResp()
+    {
+    iCertificateChain.ResetAndDestroy();
+    iOcspResponse.ResetAndDestroy();
+    iTransTrackIDs.ResetAndDestroy();
+    iContentIDs.ResetAndDestroy();
+    delete iSession;
+    delete iSignature;
+    delete iNonce;
+    delete iRoEncryptionKey;
+    delete iErrorUrl;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRightsResp::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RightsRespParser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,157 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "Base64.h"
+#include "RoapParser.h"
+#include "RightsResp.h"
+#include "RightsRespParser.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KStatus, "status");
+_LIT8(KSessionId, "sessionId");
+_LIT8(KErrorUrl, "errorRedirectURL");
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TRightsRespParser::TRightsRespParser
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+TRightsRespParser::TRightsRespParser(
+    CRightsResp* aResponse)
+    {
+    iResponse = aResponse;
+    }
+
+// -----------------------------------------------------------------------------
+// TRightsRespParser::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void TRightsRespParser::OnStartElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/,
+    const RAttributeArray& aAttributes)
+    {
+    HBufC8* buffer = NULL;
+
+    switch (aState)
+        {
+        case ERoResponseState:
+            buffer = aParser.GetAttributeValueL(aAttributes, KStatus);
+            if (buffer != NULL)
+                {
+                iResponse->iStatus = aParser.ConvertRoapStatus(*buffer);
+                delete buffer;
+                }
+            else
+                {
+                iResponse->iStatus = EUnknownStatus;
+                }
+            iResponse->iSession =
+                aParser.GetAttributeValueL(aAttributes, KSessionId);
+                
+            iResponse->iErrorUrl = aParser.GetAttributeValueL(aAttributes, KErrorUrl);
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TRightsRespParser::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void TRightsRespParser::OnEndElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/)
+    {
+    HBufC8* buffer = NULL;
+    
+    if ( !aParser.iContent )
+        {
+        return;
+        }
+
+    switch (aState)
+        {
+        case ECertificateState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            CleanupStack::PushL(buffer);
+            iResponse->iCertificateChain.AppendL(buffer);
+            CleanupStack::Pop(); // buffer
+            break;
+        case EOcspResponseState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            CleanupStack::PushL(buffer);
+            iResponse->iOcspResponse.AppendL(buffer);
+            CleanupStack::Pop(); // buffer
+            break;
+        case ERiIdRoResponseState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            if ( buffer->Length() > SHA1_HASH )
+                {
+                delete buffer;
+                buffer = NULL;
+                User::Leave( KErrCorrupt );
+                }
+            iResponse->iRiId.Copy(*buffer);
+            delete buffer;
+            break;
+        case EDeviceIdState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            if ( buffer->Length() > SHA1_HASH )
+                {
+                delete buffer;
+                buffer = NULL;
+                User::Leave( KErrCorrupt );
+                }
+            iResponse->iDeviceId.Copy(*buffer);
+            delete buffer;
+            break;
+        case ENonceState:
+            iResponse->iNonce = Base64DecodeL(*aParser.iContent);
+            break;
+        case ESignatureRoResponseState:
+            iResponse->iSignature = Base64DecodeL(*aParser.iContent);
+            break;
+        case EEncKeyState:
+            iResponse->iRoEncryptionKey = Base64DecodeL(*aParser.iContent);
+            break;
+        case ETransactionIdContentIdState:
+            buffer = aParser.iContent->AllocLC();
+            iResponse->iContentIDs.AppendL( buffer );
+            CleanupStack::Pop(); // buffer
+            break;
+        case ETransactionIdState:
+            buffer = aParser.iContent->AllocLC();
+            iResponse->iTransTrackIDs.AppendL( buffer );
+            CleanupStack::Pop(); // buffer
+            break;
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RoapConnection.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,359 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Connection manager for ROAP
+*
+*/
+
+
+// INCLUDE FILES
+#include <cmconnectionmethod.h>
+#include <cmdestination.h>
+#include <cmconnectionmethoddef.h>
+#include <cmmanager.h>
+#include <centralrepository.h>
+#include <CommDbConnPref.h>
+#include <cdblen.h>
+#include <es_enum.h>
+#ifdef __SERIES60_NATIVE_BROWSER
+#include <BrowserUiSDKCRKeys.h>
+#endif
+#include "RoapConnection.h"
+#include "RoapDef.h"
+#include "RoapLog.h"
+
+
+
+#ifndef __SERIES60_NATIVE_BROWSER
+    const TUid KCRUidBrowser   = {0x10008D39};
+    const TUint32 KBrowserDefaultAccessPoint =  0x0000000E;
+    const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
+    const TUint32 KBrowserNGDefaultSnapId = 0x00000053;
+#endif
+
+
+// ================= LOCAL FUNCTIONS =========================================
+// ---------------------------------------------------------------------------
+// IapIdOfDefaultSnapL
+// for trapping purposes only
+// ---------------------------------------------------------------------------
+//
+LOCAL_C TUint32 IapIdOfDefaultSnapL(
+    RCmManager& aCmManager,
+    const TUint32 aDefaultSnap )
+    {
+    RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) );
+    CleanupClosePushL( dest );
+    TUint32 iapIdOfDest( 0 );
+
+    if ( dest.ConnectionMethodCount() <= 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
+    CleanupClosePushL( cMeth );
+
+    iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId );
+    CleanupStack::PopAndDestroy( &cMeth );
+    CleanupStack::PopAndDestroy( &dest );
+    return iapIdOfDest;
+    }
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::NewL
+// ---------------------------------------------------------------------------
+//
+Roap::CRoapConnection* Roap::CRoapConnection::NewL()
+    {
+    CRoapConnection* conn = new (ELeave) CRoapConnection();
+    CleanupStack::PushL( conn );
+    conn->ConstructL();
+    CleanupStack::Pop( conn );
+    return conn;
+    }
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::~CRoapConnection
+// ---------------------------------------------------------------------------
+//
+Roap::CRoapConnection::~CRoapConnection()
+    {
+    Cancel();
+    iConnection.Close();
+    iSocketServ.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::ConnectL
+// ---------------------------------------------------------------------------
+//
+void Roap::CRoapConnection::ConnectL
+( TUint32 aIap, TRequestStatus* aStatus )
+    {
+    LOGLIT( "CRoapConnection::ConnectL" )
+    const TInt KAlwaysAskSelectionMode( 1 );
+    const TInt KDestinationSelectionMode( 2 );
+
+    if ( iState == EInit )
+        {
+        // Not connected. Attach to existing connection, or create new one if
+        // allowed.
+        iStatus = KErrRoapGeneral;
+
+        // Make this part atomic by pushing closes on the stack.
+        User::LeaveIfError( iSocketServ.Connect() );
+        CleanupClosePushL<RSocketServ>( iSocketServ );
+        User::LeaveIfError( iConnection.Open( iSocketServ ) );
+        CleanupClosePushL<RConnection>( iConnection );
+
+        TConnectionInfoBuf connInfo;
+        TInt ap = 0;
+        TInt alwaysAsk = 0;
+        TUint count;
+        User::LeaveIfError( iConnection.EnumerateConnections( count ) );
+        TUint i;
+        if ( count )
+            {
+            // Select from existing connections. Try to make AP match.
+            for ( i = count; i; i-- )
+                {
+                // Note: GetConnectionInfo expects 1-based index.
+                User::LeaveIfError( iConnection.GetConnectionInfo( i, connInfo ) );
+                if ( aIap == 0 || connInfo().iIapId == aIap )
+                    {
+                    // "Accept any" or AP match. Attach to this one.
+                    break;
+                    }
+                }
+            if ( !i )
+                {
+                // No AP match, select AP with largest index.
+                User::LeaveIfError
+                    ( iConnection.GetConnectionInfo( count, connInfo ) );
+                }
+            User::LeaveIfError
+                ( iConnection.Attach( connInfo, RConnection::EAttachTypeNormal ) );
+            iState = EConnected;
+            iStatus = KErrNone;
+            }
+        else
+            {
+            // No existing connections, create new one.
+#ifdef __WINS__
+            // WINS connection creation does not work if preferences are given.
+            // Defaults are to be used always.
+            iConnection.Start( iStatus );
+#else
+            // Note: the TCommDbConnPref must NOT be stack variable.
+            // It must persist until completion of RConnection::Start().
+            iConnPref.SetDirection( ECommDbConnectionDirectionOutgoing );
+            //iConnPref.SetDialogPreference( ECommDbDialogPrefWarn )
+            iConnPref.SetBearerSet( ECommDbBearerCSD | ECommDbBearerWcdma );
+            // New connection is always created with user-selected AP
+            // so 0 is used instead of aIap.
+
+            TInt defaultSnap( 0 );
+            CRepository* repository( NULL );
+            repository = CRepository::NewL( KCRUidBrowser );
+            CleanupStack::PushL( repository );
+
+            repository->Get( KBrowserDefaultAccessPoint, ap);
+            repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
+            repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
+            CleanupStack::PopAndDestroy( repository );
+            repository = NULL;
+
+            TUint32 iapd32 = 0;
+            TInt err = KErrNone;
+
+            if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
+                {
+                alwaysAsk = KAlwaysAskSelectionMode;
+                }
+            else
+                {
+                RCmManager cmManager;
+                cmManager.OpenLC();
+                if ( !alwaysAsk )
+                    {
+                    TRAP( err, iapd32 = cmManager.GetConnectionMethodInfoIntL(
+                            ap, CMManager::ECmIapId ) );
+                    }
+                else if ( alwaysAsk == KDestinationSelectionMode )
+                    {
+                    TRAP( err, iapd32 = IapIdOfDefaultSnapL(
+                            cmManager, defaultSnap ) );
+                    }
+                CleanupStack::PopAndDestroy( &cmManager );
+                }
+
+            if ( err || alwaysAsk == KAlwaysAskSelectionMode )
+                {
+                // Always ask
+                LOGLIT( "SetDialogPreference( ECommDbDialogPrefPrompt )" )
+                iConnPref.SetDialogPreference( ECommDbDialogPrefPrompt );
+                iapd32 = 0;
+                }
+            else
+                {
+                // User defined
+                LOGLIT( "SetDialogPreference( ECommDbDialogPrefDoNotPrompt )" )
+                iConnPref.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
+                }
+
+            iConnPref.SetIapId( iapd32 );
+            iConnection.Start( iConnPref, iStatus );
+#endif
+            iState = EConnecting;
+            SetActive();    // The only path with a real async request.
+            }
+        CleanupStack::Pop( 2, &iSocketServ ); // closing iConn and iSockServ
+        // End of atomic part.
+        }
+    else
+        {
+        // Not expecting this to be called in other states.
+        }
+
+    iParentStatus = aStatus;
+    *iParentStatus = KRequestPending;
+
+    if ( !IsActive() )
+        {
+        // Unless we have an outstanding connect request (iConn.Start),
+        // we are done.
+        User::RequestComplete( iParentStatus, iStatus.Int() );
+        iParentStatus = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::Close
+// ---------------------------------------------------------------------------
+//
+void Roap::CRoapConnection::Close()
+    {
+    LOGLIT( "CRoapConnection::Close" )
+
+    Cancel();
+    iConnection.Close();
+    iSocketServ.Close();
+    iState = EInit;
+    }
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::IsConnected
+// ---------------------------------------------------------------------------
+//
+TBool Roap::CRoapConnection::IsConnected( TUint32& aIap )
+    {
+    LOGLIT( "CRoapConnection::IsConnected" )
+
+    TBool connected( EFalse );
+    if( iState == EConnected )
+        {
+        TBuf<KCommsDbSvrMaxColumnNameLength * 2 + 1> iapId;
+        _LIT( KFormatIapId, "%S\\%S" );
+        TPtrC iap( IAP );
+        TPtrC id( COMMDB_ID );
+        iapId.Format( KFormatIapId, &iap, &id );
+        TInt err = iConnection.GetIntSetting( iapId, aIap );
+        connected = err ? EFalse : ETrue;
+        }
+    return connected;
+    }
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::CRoapConnection
+// ---------------------------------------------------------------------------
+//
+Roap::CRoapConnection::CRoapConnection()
+: CActive( CActive::EPriorityStandard ),
+  iState( EInit )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::ConstructL
+// ---------------------------------------------------------------------------
+//
+void Roap::CRoapConnection::ConstructL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::DoCancel
+// ---------------------------------------------------------------------------
+//
+void Roap::CRoapConnection::DoCancel()
+    {
+    LOGLIT( "CRoapConnection::DoCancel" )
+
+    iConnection.Close();
+    iSocketServ.Close();
+    User::RequestComplete( iParentStatus, KErrCancel );
+    }
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::RunL
+// ---------------------------------------------------------------------------
+//
+void Roap::CRoapConnection::RunL()
+    {
+    LOGLIT( "CCRoapConnection::RunL" )
+
+    User::LeaveIfError( iStatus.Int() );    // Handle errors in RunError().
+
+    iState = EConnected;
+    User::RequestComplete( iParentStatus, iStatus.Int() );
+    iParentStatus = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::RunError
+// ---------------------------------------------------------------------------
+//
+TInt Roap::CRoapConnection::RunError( TInt  /* aError */ )
+    {
+    LOGLIT( "CRoapConnection::RunError" )
+
+    iConnection.Close();
+    iSocketServ.Close();
+    iState = EInit;
+    User::RequestComplete( iParentStatus, iStatus.Int() );
+    iParentStatus = NULL;
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::SocketServ
+// ---------------------------------------------------------------------------
+//
+RSocketServ& Roap::CRoapConnection::SocketServ()
+    {
+    return iSocketServ;
+    }
+
+// ---------------------------------------------------------------------------
+// Roap::CRoapConnection::Conn
+// ---------------------------------------------------------------------------
+//
+RConnection& Roap::CRoapConnection::Conn()
+    {
+    return iConnection;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RoapEng.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,2695 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Roap engine
+ *
+*/
+
+
+// INCLUDE FILES
+
+#include <random.h>
+
+#include <DocumentHandler.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include  <PathInfo.h>
+#include  <DriveInfo.h>
+#else
+#include  <PathInfo.h>
+#endif
+
+#ifndef __WINS__
+#include <etelmm.h>
+#include <mmtsy_names.h>
+#include <SysUtil.h>
+#endif
+
+#include <flogger.h>
+#include <x509cert.h>
+#include <x509CertExt.h>
+#include <hash.h>
+#include <utf.h>
+#include <asn1dec.h>
+#include <centralrepository.h>
+#include <e32base.h>  // CleanupResetAndDestroyPushL dependencies
+
+#include "cleanupresetanddestroy.h" // CleanupResetAndDestroyPushL
+#include "DrmRights.h"
+#include "RoapEng.h"
+#include "RoapTrigger.h"
+#include "wbxmlroaptriggerparser.h"
+#include "RoapResponse.h"
+#include "RoapMessage.h"
+#include "RoapParser.h"
+#include "RoapSigner.h"
+#include "DeviceHello.h"
+#include "RIHello.h"
+#include "RegistrationReq.h"
+#include "RegistrationResp.h"
+#include "RightsReq.h"
+#include "RightsResp.h"
+#include "JoinDomainReq.h"
+#include "JoinDomainResp.h"
+#include "LeaveDomainReq.h"
+#include "LeaveDomainResp.h"
+#ifdef RD_DRM_METERING
+#include "MeteringReportReq.h"
+#include "MeteringReportResp.h"
+#endif
+#include "RoapStorageClient.h"
+#include "RoapDef.h"
+#include "RoapLog.h"
+#include "RoapObserver.h"
+#include "CmlaCrypto.h"
+#include "DrmRiContext.h"
+#include "DrmDomainContext.h"
+#include "DrmProtectedRoParser.h"
+#include "DRMClockClient.h"
+#include "DcfRep.h"
+#include "dcfentry.h"
+#include "Base64.h"
+#include "drmsettingsplugininternalcrkeys.h"
+
+
+#define STUB_C_CLASS_IN_NAMESPACE( n, c ) namespace n { class c: public CBase { private: c(); public: virtual ~c(); }; } n::c::c() {} n::c::~c() {}
+#define STUB_C_CLASS( c ) class c : public CBase { private: c(); public: virtual ~c(); }; c::c() {} c::~c() {}
+// This class does not do anything.
+// It is defined here only to keep binary compatibility,
+// because of unintentional class name leak in
+// armv5 export history.
+// Don't ever use this class for anything.
+STUB_C_CLASS_IN_NAMESPACE( Roap , CWbxmlRoapTriggerToXmlParser )
+
+// Yet another stub classes because of moved classes
+// which have leaked virtual table entries
+STUB_C_CLASS( COCSPResponse )
+STUB_C_CLASS( COCSPResponseCertInfo )
+
+
+using namespace Roap;
+// ================= CONSTANTS =======================
+// For parsing multipart content
+_LIT8(KCmlaIp1, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-1");
+_LIT8(KLeaveDomainElement, "leaveDomain");
+_LIT8(KSignedInfoElement, "SignedInfo");
+_LIT(KBOM1, "\xFFFE");
+_LIT(KBOM2, "\xFEFF");
+#ifdef RD_DRM_METERING
+_LIT8( KRoapVersion11, "1.1" );
+#endif
+
+static const TInt KDomainGenerationLength( 3 );
+static const TInt KMinCertChainLength( 3 );
+// ================= LOCAL FUNCTIONS =======================
+
+LOCAL_C TBool SortArrays(
+    RPointerArray<HBufC8>& aKeys,
+    RPointerArray<HBufC8>& aMacs,
+    RPointerArray<HBufC8>& aElements,
+    RArray<TInt>& aOrder )
+    {
+    TInt i;
+    TInt j;
+    TInt index;
+    HBufC8* temp1 = NULL;
+    HBufC8* temp2 = NULL;
+    HBufC8* temp3 = NULL;
+    TBool isInOrder = ETrue;
+
+    if ( aOrder.Count() != aKeys.Count() || aKeys.Count() != aMacs.Count()
+        || aMacs.Count() != aElements.Count() )
+        {
+        return EFalse;
+        }
+
+    for ( i = 0; i < aKeys.Count(); i++ )
+        {
+        index = aOrder[i];
+        temp1 = aKeys[i];
+        temp2 = aMacs[i];
+        temp3 = aElements[i];
+        j = i;
+        while ( ( j > 0 ) && ( aOrder[j - 1] > index ) )
+            {
+            isInOrder = EFalse;
+            aOrder[j] = aOrder[j - 1];
+            aKeys[j] = aKeys[j - 1];
+            aMacs[j] = aMacs[j - 1];
+            aElements[j] = aElements[j - 1];
+            j = j - 1;
+            }
+        aOrder[j] = index;
+        aKeys[j] = temp1;
+        aMacs[j] = temp2;
+        aElements[j] = temp3;
+        }
+    return isInOrder;
+    }
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CRoapEng::NewL()
+// ---------------------------------------------------------
+//
+EXPORT_C CRoapEng* CRoapEng::NewL()
+    {
+    CRoapEng* engine = new ( ELeave ) CRoapEng();
+    CleanupStack::PushL( engine );
+    engine->ConstructL();
+    CleanupStack::Pop( engine );
+    return engine;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::~CRoapEng()
+// ---------------------------------------------------------
+//
+EXPORT_C CRoapEng::~CRoapEng()
+    {
+    if ( iStorageClient )
+        {
+        iStorageClient->Close();
+        }
+    delete iStorageClient;
+    if ( iClockClient )
+        {
+        iClockClient->Close();
+        }
+    delete iClockClient;
+    delete iParser;
+    delete iSigner;
+    delete iDeviceId;
+    delete iRoParser;
+    delete iDcfRep;
+    iRiAlgorithms.ResetAndDestroy();
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::~CRoapEng()
+// ---------------------------------------------------------
+//
+void CRoapEng::ConstructL()
+    {
+    LOGLIT( "CRoapEng::ConstructL" )
+
+    CRoapEngBase::ConstructL();
+    iParser = CRoapParser::NewL();
+    iStorageClient = new ( ELeave ) RRoapStorageClient;
+    User::LeaveIfError( iStorageClient->Connect() );
+    iClockClient = new ( ELeave ) RDRMClockClient;
+    User::LeaveIfError( iClockClient->Connect() );
+    TBuf8<SHA1_HASH> deviceId;
+    iStorageClient->GetDevicePublicKeyHashL( deviceId );
+    iDeviceId = deviceId.AllocL();
+    iSigner = CRoapSigner::NewL( *iStorageClient );
+    iRoParser = CDrmProtectedRoParser::NewL();
+    iDcfRep = CDcfRep::NewL();
+    iCertNeeded = ETrue;
+    iRiSupportsCertCaching = EFalse;
+    iTransStatus = ENotAsked;
+    iSelectedAlgorithms = EOma;
+    iSelectedRoot = KNullDesC8;
+    iStorageClient->SelectTrustedRootL( KNullDesC8 );
+    iDeviceTimeError = EFalse;
+    iDomainId.SetLength( 0 );
+    iSecureTime = ETrue;
+    iZone = 0;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::CRoapEng()
+// ---------------------------------------------------------
+//
+CRoapEng::CRoapEng() :
+    CRoapEngBase()
+    {
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::ParseTriggerL()
+// ---------------------------------------------------------
+//
+CRoapTrigger* CRoapEng::ParseTriggerL( const TDesC8& aTrigger )
+    {
+    LOGLIT( "CRoapEng::ParseTriggerL" )
+
+    CRoapTrigger* trigger( NULL );
+    RBuf8 xmlTrigger;
+    CleanupClosePushL( xmlTrigger );
+    _LIT8( KRoap, "<roap:roapTrigger" );
+    if ( aTrigger.FindF( KRoap ) == KErrNotFound )
+        {
+        DRM::CWbxmlRoapTriggerParser* wbParser(
+            DRM::CWbxmlRoapTriggerParser::NewLC() );
+        HBufC8* b( NULL );
+        TRAPD( parseError, b = wbParser->ParseL( aTrigger ) );
+        if ( parseError == KErrNone )
+            {
+            xmlTrigger.Assign( b );
+            b = NULL;
+            LOGLIT( "  We have a WBXML trigger" )
+            }
+        else
+            { // OMA BCAST: Check if this is an XML trigger after all..
+            LOGLIT( "  We have an XML trigger after all" )
+            xmlTrigger.CreateL( aTrigger );
+            }
+        CleanupStack::PopAndDestroy( wbParser );
+        }
+    else
+        {
+        xmlTrigger.CreateL( aTrigger );
+        }
+    trigger = iParser->ParseRoapTriggerL( xmlTrigger );
+
+    CleanupStack::PushL( trigger );
+    if ( !trigger || !trigger->ValidTrigger() )
+        {
+        User::Leave( KErrRoapGeneral );
+        }
+
+    // check that SilentRightsUrl is on the white list
+    // URL is searched from pre-configured white list
+    TBool fromPreConfiguredWhiteList( ETrue );
+    if ( iStorageClient->WhiteListURLExistsL( *trigger->iRoapUrl, fromPreConfiguredWhiteList ) )
+        {
+        iAllowedToContactRi = ETrue;
+        }
+
+    if ( trigger->iTriggerType == ELeaveDomainTrigger && trigger->iSignature )
+        {
+        if ( !VerifyTriggerSignatureL( xmlTrigger, *trigger ) )
+            {
+            User::Leave( KErrRoapServerFatal );
+            }
+        }
+
+    CleanupStack::Pop( trigger );
+    CleanupStack::PopAndDestroy( &xmlTrigger );
+
+    return trigger;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::GetRIContextL()
+// ---------------------------------------------------------
+//
+void CRoapEng::GetRIContextL( TBool& aRegistered, const TDesC8& aRiId )
+    {
+    LOGLIT( "CRoapEng::GetRIContextL" )
+
+    CDRMRIContext* context = NULL;
+
+    aRegistered = EFalse;
+
+    // delete old RI context and obtain a new one
+    delete iStoredRiContext;
+    iStoredRiContext = NULL;
+    context = iStorageClient->GetRIContextL( aRiId );
+    if ( !context )
+        {
+        return;
+        }
+
+    iStoredRiContext = context;
+    iRiSupportsCertCaching = iStoredRiContext->DeviceCertCached();
+    iSelectedRoot = iStoredRiContext->SelectedDeviceRoot();
+    iStorageClient->SelectTrustedRootL( iSelectedRoot );
+
+    if ( context->CertificateChain().Count() && context->ExpiryTime()
+        > GetDrmTimeL() )
+        {
+        aRegistered = ETrue;
+        iUseRiContextUrl = EFalse;
+        }
+    else
+        {
+        // Received Context was invalid or expired
+        iUseRiContextUrl = EFalse;
+        delete iStoredRiContext;
+        iStoredRiContext = NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::GetDomainContextL()
+// ---------------------------------------------------------
+//
+void CRoapEng::GetDomainContextL(
+    TBool& aIsJoined,
+    TBool& aIsValidGeneration,
+    const TDesC8& aDomainId )
+    {
+    LOGLIT( "CRoapEng::GetDomainContextL" )
+
+    TInt generation = 0;
+    CDRMDomainContext* context = NULL;
+
+    aIsJoined = EFalse;
+    aIsValidGeneration = EFalse;
+
+    // last 3 digits are for Domain generation
+    context = iStorageClient->GetDomainContextL( aDomainId );
+
+    if ( !context )
+        {
+        return;
+        }
+
+    if ( context->ExpiryTime() > GetDrmTimeL() || context->ExpiryTime()
+        == Time::NullTTime() )
+        {
+        aIsJoined = ETrue;
+        }
+
+    TLex8 lex( aDomainId.Right( KDomainGenerationLength ) );
+    lex.Val( generation );
+
+    if ( context->DomainGeneration() >= generation )
+        {
+        aIsValidGeneration = ETrue;
+        }
+
+    delete context;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::CreateReqMessageL()
+// ---------------------------------------------------------
+//
+void CRoapEng::CreateReqMessageL()
+    {
+    LOGLIT( "CRoapEng::CreateReqMessageL" )
+
+    __ASSERT_ALWAYS( iTrigger, User::Invariant() );
+    __ASSERT_ALWAYS( !iRequest, User::Invariant() );
+
+    switch ( iReqMessage )
+        {
+        case EDeviceHello:
+            {
+            iRequest = CreateDeviceHelloL();
+            break;
+            }
+        case ERegistration:
+            {
+            iRequest = CreateRegistrationRequestL();
+            break;
+            }
+        case EROAcquisition:
+            {
+            iRequest = CreateRightsRequestL();
+            break;
+            }
+        case EJoinDomain:
+            {
+            iRequest = CreateJoinDomainRequestL();
+            break;
+            }
+        case ELeaveDomain:
+            {
+            iRequest = CreateLeaveDomainRequestL();
+            break;
+            }
+#ifdef RD_DRM_METERING
+        case EMeteringRequest:
+            {
+            iRequest = CreateMeteringReportRequestL();
+            break;
+            }
+#endif
+        default:
+            {
+            User::Leave( KErrArgument );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::CreateDeviceHelloL()
+// ---------------------------------------------------------
+//
+CRoapMessage* CRoapEng::CreateDeviceHelloL()
+    {
+    LOGLIT( "CRoapEng::CreateDeviceHelloL" )
+    PERFORMANCE_LOGLIT( "Registration protocol started" )
+
+    RPointerArray<TDesC8> idArray;
+    CDeviceHello* req = CDeviceHello::NewL();
+    CleanupStack::PushL( req );
+
+    // Multi-PKI addition
+    CleanupResetAndDestroyPushL( idArray );
+    CreateDeviceIdHashArrayL( idArray );
+    for ( TInt i = 0; i < idArray.Count(); i++ )
+        {
+        req->iDeviceIdArray.AppendL( *idArray[i] );
+        }
+    CleanupStack::PopAndDestroy( &idArray );
+    // Multi-PKI
+
+#ifndef RD_DRM_METERING
+    req->iVersion.Copy( KRoapVersion ); // Version 1.0
+#else
+    req->iVersion.Copy( KRoapVersion11 );
+#endif
+    if ( iTrigger->iNonce )
+        {
+        req->iTriggerNonce = iTrigger->iNonce->AllocL();
+        }
+    CmlaCrypto::SupportedAlgorithmsL( req->iAlgorithms );
+    iSelectedAlgorithms = EOma;
+
+    CleanupStack::Pop( req );
+    return req;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::CreateRegistrationRequestL()
+// ---------------------------------------------------------
+//
+CRoapMessage* CRoapEng::CreateRegistrationRequestL()
+    {
+    LOGLIT( "CRoapEng::CreateRegistrationRequestL ->" )
+
+    __ASSERT_ALWAYS( iResponse, User::Invariant() );
+
+    CRegistrationReq* req = NULL;
+    CRIHello* resp = NULL;
+    RPointerArray<HBufC8> trustedRootArray;
+    HBufC8* temp = NULL;
+
+    resp = STATIC_CAST( CRIHello*, iResponse );
+    req = CRegistrationReq::NewL();
+    CleanupStack::PushL( req );
+    if ( resp->iSession )
+        {
+        req->iSession = resp->iSession->AllocL();
+        }
+    else
+        {
+        User::Leave( KErrRoapServerFatal );
+        }
+
+    req->iNonce.SetLength( KDeviceNonceLength );
+    TRandom::Random( req->iNonce );
+
+    req->iTime = GetDrmTimeL();
+
+    // store the nonce for DRM Time sync
+    iRegReqNonce = req->iNonce;
+
+    if ( iCertNeeded )
+        {
+        req->iCertificateChain = GetCertificateChainL();
+        if ( resp->iCertificateCaching )
+            {
+            iCertNeeded = EFalse;
+            }
+        }
+
+    // Send all our trusted roots to the RI
+    CleanupResetAndDestroyPushL( trustedRootArray );
+
+    LOGLIT( "  Getting trusted roots" )
+
+    iStorageClient->GetTrustedRootsL( trustedRootArray );
+
+    if ( !trustedRootArray.Count() )
+        {
+        // No trusted roots found!
+        LOGLIT( "  No trusted roots found!" )
+        User::Leave( KErrRoapDevice );
+        }
+    for ( TInt i = 0; i < trustedRootArray.Count(); i++ )
+        {
+        temp = trustedRootArray[i]->AllocLC();
+        req->iTrustedAuthorities.AppendL( temp );
+        CleanupStack::Pop( temp );
+        }
+
+    LOGLIT( "  Setting server info" )
+    if ( resp->iServerInfo && resp->iServerInfo->Size() )
+        {
+        req->iServerInfo = resp->iServerInfo->AllocL();
+        }
+
+    if ( iStoredRiContext )
+        {
+        LOGLIT( "  RI context available" )
+        req->iPeerKeyIdentifier = iStoredRiContext->RIID();
+
+        if ( iStoredRiContext->OCSPResponse().Count() && !iDeviceTimeError )
+            {
+            req->iOcspInfoStored = ETrue;
+            req->iOcspResponderKeyId = GetOCSPResponderKeyHashL();
+            }
+        }
+    if ( resp->iNeedDeviceDetails )
+        {
+        LOGLIT( "  Getting device details" )
+        GetDeviceDetailsL( req->iDeviceDetailsManufacturer,
+            req->iDeviceDetailsModel, req->iDeviceDetailsVersion );
+        }
+
+    if ( iTrigger->iNonce )
+        {
+        req->iTriggerNonce = iTrigger->iNonce->AllocL();
+        }
+
+    CleanupStack::PopAndDestroy( &trustedRootArray );
+    CleanupStack::Pop( req );
+
+    LOGLIT( "CRoapEng::CreateRegistrationRequestL <-" )
+
+    return req;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::CreateRightsRequestL()
+// ---------------------------------------------------------
+//
+CRoapMessage* CRoapEng::CreateRightsRequestL()
+    {
+    LOGLIT( "CRoapEng::CreateRightsRequestL" )
+    PERFORMANCE_LOGLIT( "RO acquisition protocol started" )
+
+    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
+
+    CRightsReq* req = NULL;
+    RPointerArray<HBufC8> ttIDs;
+    RPointerArray<HBufC8> cids;
+    HBufC8* temp = NULL;
+    TBuf8<SHA1_HASH> deviceId;
+
+    req = CRightsReq::NewL();
+    CleanupStack::PushL( req );
+
+    req->iNonce.SetLength( KDeviceNonceLength );
+    TRandom::Random( req->iNonce );
+
+    req->iTime = GetDrmTimeL();
+
+    iStorageClient->GetDevicePublicKeyHashL( deviceId );
+    delete iDeviceId;
+    iDeviceId = NULL;
+    iDeviceId = deviceId.AllocL();
+    req->iDeviceId = *iDeviceId;
+
+    req->iRiId.Copy( iTrigger->iRiId );
+
+    if ( !iRiSupportsCertCaching )
+        {
+        req->iCertificateChain = GetCertificateChainL();
+        }
+    if ( iTrigger->iDomainId )
+        {
+        req->iDomainId = iTrigger->iDomainId->AllocL();
+        }
+
+    for ( TInt i = 0; i < iTrigger->iRoIdList.Count(); i++ )
+        {
+        temp = iTrigger->iRoIdList[i]->AllocLC();
+        req->iRoIdList.AppendL( temp );
+        CleanupStack::Pop( temp );
+        }
+
+    if ( iStoredRiContext )
+        {
+        req->iPeerKeyIdentifier = iStoredRiContext->RIID();
+
+        if ( iStoredRiContext->OCSPResponse().Count() )
+            {
+            req->iOcspInfoStored = ETrue;
+            req->iOcspResponderKeyId = GetOCSPResponderKeyHashL();
+            }
+        }
+
+    CleanupResetAndDestroyPushL( cids );
+
+    CleanupResetAndDestroyPushL( ttIDs );
+
+    FetchTransactionIDL( ttIDs, cids );
+
+    for ( TInt i = 0; i < ttIDs.Count() && i < cids.Count(); i++ )
+        {
+        temp = ttIDs[i]->AllocLC();
+        req->iTransTrackIDs.AppendL( temp );
+        CleanupStack::Pop( temp );
+        temp = cids[i]->AllocLC();
+        req->iContentIDs.AppendL( temp );
+        CleanupStack::Pop( temp );
+        }
+
+    CleanupStack::PopAndDestroy( &ttIDs );
+    CleanupStack::PopAndDestroy( &cids );
+
+    if ( iTrigger->iNonce )
+        {
+        req->iTriggerNonce = iTrigger->iNonce->AllocL();
+        }
+
+    CleanupStack::Pop( req );
+    return req;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::CreateJoinDomainRequestL()
+// ---------------------------------------------------------
+//
+CRoapMessage* CRoapEng::CreateJoinDomainRequestL()
+    {
+    LOGLIT( "CRoapEng::CreateJoinDomainRequestL" )
+    PERFORMANCE_LOGLIT( "Join domain protocol started" )
+
+    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
+
+    CJoinDomainReq* req = NULL;
+    TBuf8<SHA1_HASH> deviceId;
+
+    req = CJoinDomainReq::NewL();
+    CleanupStack::PushL( req );
+
+    req->iNonce.SetLength( KDeviceNonceLength );
+    TRandom::Random( req->iNonce );
+
+    req->iTime = GetDrmTimeL();
+
+    iStorageClient->GetDevicePublicKeyHashL( deviceId );
+    delete iDeviceId;
+    iDeviceId = NULL;
+    iDeviceId = deviceId.AllocL();
+    req->iDeviceId = *iDeviceId;
+
+    req->iRiId.Copy( iTrigger->iRiId );
+
+    if ( !iRiSupportsCertCaching )
+        {
+        req->iCertificateChain = GetCertificateChainL();
+        }
+    if ( iTrigger->iDomainId )
+        {
+        req->iDomainId = iTrigger->iDomainId->AllocL();
+        iDomainId.Copy( *req->iDomainId );
+        }
+    else if ( iDomainId.Length() && iTrigger->iTriggerType
+        == ERoAcquisitionTrigger )
+        {
+        req->iDomainId = iDomainId.AllocL();
+        }
+    else
+        {
+        User::Leave( KErrRoapServerFatal );
+        }
+
+    if ( iStoredRiContext )
+        {
+        req->iPeerKeyIdentifier = iStoredRiContext->RIID();
+
+        if ( iStoredRiContext->OCSPResponse().Count() )
+            {
+            req->iOcspInfoStored = ETrue;
+            req->iOcspResponderKeyId = GetOCSPResponderKeyHashL();
+            }
+        }
+
+#ifdef _DISABLE_HASH_CHAIN_GENERATION
+    req->iHashChainSupport = EFalse;
+#endif
+
+    if ( iTrigger->iNonce )
+        {
+        req->iTriggerNonce = iTrigger->iNonce->AllocL();
+        }
+
+    CleanupStack::Pop( req );
+    return req;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::CreateLeaveDomainRequestL()
+// ---------------------------------------------------------
+//
+CRoapMessage* CRoapEng::CreateLeaveDomainRequestL()
+    {
+    LOGLIT( "CRoapEng::CreateLeaveDomainRequestL" )
+    PERFORMANCE_LOGLIT( "Leave domain protocol started" )
+
+    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
+
+    if ( !iTrigger->iDomainId )
+        {
+        User::Leave( KErrRoapServerFatal );
+        }
+    // delete Domain context before sending LeaveDomain req
+    TRAPD( ret, iStorageClient->DeleteDomainContextL( *iTrigger->iDomainId ));
+
+    CLeaveDomainReq* req = NULL;
+    TBuf8<SHA1_HASH> deviceId;
+
+    req = CLeaveDomainReq::NewL();
+    CleanupStack::PushL( req );
+
+    if ( ret == KErrNotFound )
+        {
+        req->iNotMember = ETrue;
+        }
+    else
+        {
+        req->iNotMember = EFalse;
+        User::LeaveIfError( ret );
+        }
+
+    req->iNonce.SetLength( KDeviceNonceLength );
+    TRandom::Random( req->iNonce );
+
+    req->iTime = GetDrmTimeL();
+
+    iStorageClient->GetDevicePublicKeyHashL( deviceId );
+    delete iDeviceId;
+    iDeviceId = NULL;
+    iDeviceId = deviceId.AllocL();
+    req->iDeviceId = *iDeviceId;
+
+    req->iRiId.Copy( iTrigger->iRiId );
+
+    if ( !iRiSupportsCertCaching )
+        {
+        req->iCertificateChain = GetCertificateChainL();
+        }
+    if ( iTrigger->iDomainId )
+        {
+        req->iDomainId = iTrigger->iDomainId->AllocL();
+        }
+
+    if ( iTrigger->iNonce )
+        {
+        req->iTriggerNonce = iTrigger->iNonce->AllocL();
+        }
+
+    CleanupStack::Pop( req );
+    return req;
+    }
+// ---------------------------------------------------------
+// CRoapEng::CreateMeteringReportRequestL()
+// ---------------------------------------------------------
+//
+CRoapMessage* CRoapEng::CreateMeteringReportRequestL()
+    {
+#ifndef RD_DRM_METERING
+    return NULL;
+#else
+
+    LOGLIT( "CRoapEng::CreateMeteringReportRequestL" )
+    PERFORMANCE_LOGLIT( "Metering report creation started" )
+
+    CMeteringReportReq* req = NULL;
+    TBuf8<SHA1_HASH> deviceId;
+    TBuf8<OmaCrypto::KMacSize> macKey;
+    TBool registered( EFalse );
+
+    req = CMeteringReportReq::NewL();
+    CleanupStack::PushL( req );
+    req->iAlgorithmInUse = iSelectedAlgorithms;
+    // check if we are not using OMA algorithms
+    // and update selected algorithm accordingly
+    GetRIContextL( registered, iTrigger->iRiId );
+    if ( registered && iStoredRiContext )
+        {
+        for ( TInt i = 0; i < iStoredRiContext->Algorithms().Count(); i++ )
+            {
+            if ( iStoredRiContext->Algorithms()[i]->CompareF( KCmlaIp1() )
+                == KErrNone )
+                {
+                // note currently assumed that only
+                // 1 of 7 ppossible algorithms used
+                req->iAlgorithmInUse = ECmlaIp1;
+                break;
+                }
+            }
+        }
+
+    // generate DeviceNonce
+    req->iNonce.SetLength( KDeviceNonceLength );
+    TRandom::Random( req->iNonce );
+
+    // generate MeteringNonce
+    req->iReportNonce.SetLength( KDeviceNonceLength );
+    TRandom::Random( req->iReportNonce );
+
+    // fetch secure time for request
+    req->iTime = GetDrmTimeL();
+
+    // insert DeviceId
+    iStorageClient->GetDevicePublicKeyHashL( deviceId );
+    delete iDeviceId;
+    iDeviceId = NULL;
+    iDeviceId = deviceId.AllocL();
+    req->iDeviceId = *iDeviceId;
+
+    // insert RiId
+    req->iRiId.Copy( iTrigger->iRiId );
+
+    // insert Certificate chain if needed
+    if ( !iRiSupportsCertCaching )
+        {
+        req->iCertificateChain = GetCertificateChainL();
+        }
+
+    // add trigger Nonce
+    if ( iTrigger->iNonce )
+        {
+        req->iTriggerNonce = iTrigger->iNonce->AllocL();
+        }
+
+    // Get from server encrypted metering report mac key as plain,
+    // MEK and MAC key as encypted, and hash of
+    // PKI public key used in encryition
+    req->iCipherValue = iStorageClient->GetMeteringDataL( req->iRiId, macKey,
+        req->iEncKeyHash, req->iEncryptedMekAndMak );
+
+    // calculate mac over <encryptedMeteringReport>
+    req->InsertMacL( macKey );
+
+    CleanupStack::Pop( req );
+    return req;
+
+#endif //RD_DRM_METERING
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::HandleRoapResponseL()
+// ---------------------------------------------------------
+//
+void CRoapEng::HandleRoapResponseL( const TDesC8& aXmlResponse )
+    {
+    LOGLIT( "CRoapEng::HandleRoapMessageL" )
+
+    delete iResponse;
+    iResponse = NULL;
+
+    switch ( iReqMessage )
+        {
+        case EDeviceHello:
+            {
+            HandleRIHelloPduL( aXmlResponse );
+            break;
+            }
+        case ERegistration:
+            {
+            HandleReqResponsePduL( aXmlResponse );
+            break;
+            }
+        case EROAcquisition:
+            {
+            HandleRightsResponsePduL( aXmlResponse, EFalse );
+            break;
+            }
+        case EJoinDomain:
+            {
+            HandleJoinDomainResponsePduL( aXmlResponse );
+            break;
+            }
+        case ELeaveDomain:
+            {
+            HandleLeaveDomainResponsePduL( aXmlResponse );
+            break;
+            }
+#ifdef RD_DRM_METERING
+        case EMeteringRequest:
+            {
+            HandleMeteringReportResponsePduL( aXmlResponse );
+            break;
+            }
+#endif
+        default:
+            {
+            User::Leave( KErrArgument );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::HandleRIHelloPduL()
+// ---------------------------------------------------------
+//
+void CRoapEng::HandleRIHelloPduL( const TDesC8& aRiHello )
+    {
+    LOGLIT( "CRoapEng::HandleRIHelloPduL" )
+
+    CRIHello* resp = NULL;
+    HBufC8* temp = NULL;
+
+    resp = iParser->ParseRIHelloL( aRiHello );
+    iRoapStatus = resp->iStatus;
+    iResponse = resp;
+    if ( iRoapStatus == ESuccess )
+        {
+        iCertNeeded = ETrue;
+        iRiSupportsCertCaching = EFalse;
+
+        if ( resp->iPeerKeyIdentifier )
+            {
+            iRiSupportsCertCaching = ETrue;
+            if ( resp->iPeerKeyId.Length() )
+                {
+                if ( resp->iPeerKeyId.CompareF( *iDeviceId ) == KErrNone )
+                    {
+                    iCertNeeded = EFalse;
+                    }
+                }
+            else
+                {
+                iCertNeeded = EFalse;
+                }
+            }
+        else if ( resp->iCertificateCaching )
+            {
+            iRiSupportsCertCaching = ETrue;
+            }
+
+        if ( resp->iAlgorithms.Count() )
+            {
+            iRiAlgorithms.ResetAndDestroy();
+            for ( TInt i = 0; i < resp->iAlgorithms.Count(); i++ )
+                {
+                if ( resp->iAlgorithms[i]->CompareF( KCmlaIp1() ) == KErrNone )
+                    {
+                    iSelectedAlgorithms = ECmlaIp1;
+                    }
+                temp = resp->iAlgorithms[i]->AllocLC();
+                iRiAlgorithms.AppendL( temp );
+                CleanupStack::Pop( temp );
+                }
+            }
+        iRiId.Copy( resp->iRiId );
+        iRiVersion.Copy( resp->iSelectedVersion );
+
+        /***
+         This is needed when the multiple PKIs are supported.
+         ***/
+        if ( resp->iTrustedAuthorities.Count() )
+            {
+            // select the first matching root from the list
+            LOGLIT( "Choose the first matching trust anchor" )
+            iStorageClient->SelectTrustedRootL( resp->iTrustedAuthorities,
+                iSelectedRoot );
+            LOGLIT( "The trust anchor selected" )
+            DETAILLOGHEX( iSelectedRoot.Ptr(), iSelectedRoot.Length() )
+            }
+        else
+            {
+            if ( iStoredRiContext && iStoredRiContext->RIID() == iRiId )
+                {
+                if ( iSelectedRoot != iStoredRiContext->SelectedDeviceRoot() )
+                    {
+                    DETAILLOGLIT( "Changing trusted root to that of saved RI context" )
+                    DETAILLOGLIT( "old root" )
+                    DETAILLOGHEX( iSelectedRoot.Ptr(), iSelectedRoot.Length() )
+
+                    iSelectedRoot = iStoredRiContext->SelectedDeviceRoot();
+                    iStorageClient->SelectTrustedRootL( iSelectedRoot );
+                    }
+                DETAILLOGLIT( "Using trusted root of saved RI context" )
+                DETAILLOGHEX( iSelectedRoot.Ptr(), iSelectedRoot.Length() )
+                }
+            else
+                {
+                DETAILLOGLIT( "Using default trusted root" )
+                iSelectedRoot = KNullDesC8;
+                iStorageClient->SelectTrustedRootL( iSelectedRoot );
+                }
+            }
+
+        iSigner->AddRequestL( aRiHello );
+        }
+    else if ( resp->iErrorUrl )
+        {
+        if ( iObserver )
+            {
+            iObserver->ErrorUrlL( *resp->iErrorUrl );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::HandleReqResponsePduL()
+// ---------------------------------------------------------
+//
+void CRoapEng::HandleReqResponsePduL( const TDesC8& aRegResp )
+    {
+    LOGLIT( "CRoapEng::HandleReqResponsePduL" )
+
+    CRegistrationResp* resp = NULL;
+    CDRMRIContext* context = NULL;
+    CX509Certificate* cert = NULL;
+    TTime riExpiry;
+    TBool status = EFalse;
+    TUint8 riCertCaching = EFalse;
+
+    resp = iParser->ParseRegistrationRespL( aRegResp );
+    iRoapStatus = resp->iStatus;
+    iResponse = resp;
+    if ( iRoapStatus == ESuccess )
+        {
+        if ( resp->iOcspResponse.Count() > 0 )
+            {
+            // adjust DRM Time according to OCSP response
+            // All needed verifications done in server side
+            TBool deviceTimeUpdated( EFalse );
+            if ( resp->iCertificateChain.Count() > 0 )
+                {
+                deviceTimeUpdated = iStorageClient->UpdateDrmTimeL(
+                    resp->iCertificateChain, resp->iOcspResponse,
+                    iRegReqNonce );
+                }
+            else if ( iStoredRiContext )
+                {
+                deviceTimeUpdated = iStorageClient->UpdateDrmTimeL(
+                    iStoredRiContext->CertificateChain(),
+                    resp->iOcspResponse, iRegReqNonce );
+                }
+            if ( deviceTimeUpdated )
+                {
+                LOGLIT( "drm time updated" )
+                iDeviceTimeError = EFalse;
+                }
+            }
+
+        if ( !iStoredRiContext || ( resp->iCertificateChain.Count()
+            && resp->iOcspResponse.Count() ) )
+            {
+            status = VerifyCertificateChainL( resp->iCertificateChain,
+                resp->iOcspResponse );
+            if ( !status )
+                {
+                LOGLIT( "Certificate chain validation failed" )
+                User::Leave( KErrRoapServerFatal );
+                }
+            status = ValidateRiIdL( iRiId, *resp->iCertificateChain[0] );
+            if ( !status )
+                {
+                LOGLIT( "RI ID validation failed" )
+                User::Leave( KErrRoapServerFatal );
+                }
+            }
+
+        if ( iStoredRiContext )
+            {
+            // if we have already stored certificates -> use those.
+            status = VerifySignatureL( aRegResp, *resp->iSignature,
+                iStoredRiContext->CertificateChain() );
+            }
+        else
+            {
+            // otherwise use the received certificates
+            status = VerifySignatureL( aRegResp, *resp->iSignature,
+                resp->iCertificateChain );
+            }
+
+        if ( !status )
+            {
+            LOGLIT( "Signature verification failed" )
+            User::Leave( KErrRoapServerFatal );
+            }
+
+        if ( resp->iCertificateChain.Count() )
+            {
+            // Validate RI certificate
+            cert = CX509Certificate::NewLC( *resp->iCertificateChain[0] );
+
+            status = ValidateRiCertificateL( cert );
+            if ( !status )
+                {
+                User::LeaveIfError( KErrRoapServerFatal );
+                }
+
+            riExpiry = cert->ValidityPeriod().Finish();
+
+            iRiSupportsCertCaching ? riCertCaching = ETrue : riCertCaching
+                = EFalse;
+
+            context = CDRMRIContext::NewLC( iRiId, *iRiAlias, iRiVersion,
+                iRiAlgorithms, resp->iWhiteList, *resp->iRiUrl, riExpiry,
+                resp->iCertificateChain, resp->iOcspResponse, riCertCaching,
+                iSelectedRoot, ETrue );
+
+            iStorageClient->AddRIContextL( *context );
+            delete iStoredRiContext;
+            iStoredRiContext = context;
+            CleanupStack::Pop( context );
+            CleanupStack::PopAndDestroy( cert );
+            }
+        }
+    else
+        {
+        if ( resp->iErrorUrl )
+            {
+            if ( iObserver )
+                {
+                iObserver->ErrorUrlL( *resp->iErrorUrl );
+                }
+            }
+        iSigner->ResetResponses();
+        }
+
+    PERFORMANCE_LOGLIT( "Registration protocol completed" )
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::HandleRightsResponseL()
+// ---------------------------------------------------------
+//
+void CRoapEng::HandleRightsResponsePduL(
+    const TDesC8& aRightsResp,
+    TBool aOnePass )
+    {
+    LOGLIT( "CRoapEng::HandleRightsResponsePduL" )
+
+    CRightsResp* resp = NULL;
+    TBool status = EFalse;
+
+    resp = iParser->ParseRightsRespL( aRightsResp );
+
+    CleanupStack::PushL( resp );
+
+    if ( resp->iStatus == ESuccess )
+        {
+        if ( !aOnePass )
+            {
+            // 2-pass protocol
+            __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
+
+            CRightsReq* request = NULL;
+            request = STATIC_CAST( CRightsReq*, iRequest );
+            if ( resp->iDeviceId.CompareF( request->iDeviceId ) != KErrNone
+                || resp->iRiId.CompareF( request->iRiId ) != KErrNone
+                || resp->iNonce->CompareF( request->iNonce ) != KErrNone )
+                {
+                User::Leave( KErrRoapServerFatal );
+                }
+            }
+        else
+            {
+            LOGLIT( "1-pass ROAP" )
+            // 1-pass protocol
+            TBool registered = EFalse;
+            GetRIContextL( registered, resp->iRiId );
+            if ( !registered )
+                {
+                // Recoverable error by re-registering the device
+                // (after receiving user consent or iv device belongs to whiteliust)
+                LOGLIT( "Device not registered to RI" )
+                User::Leave( KErrRoapNotRegistered );
+                }
+            if ( resp->iDeviceId.CompareF( *iDeviceId ) != KErrNone )
+                {
+                // Unrecoverable error
+                LOGLIT( "Device ID mismatch!" )
+                User::Leave( KErrRoapServerFatal );
+                }
+            }
+
+        if ( !iStoredRiContext || ( resp->iCertificateChain.Count()
+            && resp->iOcspResponse.Count() ) )
+            {
+            status = VerifyCertificateChainL( resp->iCertificateChain,
+                resp->iOcspResponse );
+            if ( !status )
+                {
+                LOGLIT( "Certificate chain validation failed" )
+                User::Leave( KErrRoapServerFatal );
+                }
+            status = ValidateRiIdL( resp->iRiId, *resp->iCertificateChain[0] );
+            if ( !status )
+                {
+                LOGLIT( "RI ID validation failed" )
+                User::Leave( KErrRoapServerFatal );
+                }
+            }
+
+        status = VerifySignatureL( aRightsResp, *resp->iSignature,
+            iStoredRiContext->CertificateChain() );
+        if ( !status )
+            {
+            LOGLIT( "Signature verification failed" )
+            User::Leave( KErrRoapServerFatal );
+            }
+
+        iReturnedROs.ResetAndDestroy();
+        TRAPD( r, iRoParser->ParseAndStoreL( aRightsResp, iReturnedROs ));
+
+        if ( r == KErrRightsServerDomainNotRegistered )
+            {
+            // perform implicit Join Domain
+            LOGLIT( "Domain RO received - Not joined" )
+            LOGLIT( "Perform impicit Join Domain before storing the RO" )
+
+            HBufC8* domainID = NULL;
+
+            domainID = iRoParser->GetDomainIdL( aRightsResp );
+
+            if ( domainID && domainID->Length() <= KDomainIdLength )
+                {
+                iDomainId.Copy( *domainID );
+                delete domainID;
+                domainID = NULL;
+                }
+            else
+                {
+                LOGLIT( "No Domain ID available!" )
+                User::Leave( KErrRoapServerFatal );
+                }
+
+            delete iDomainRightsResp;
+            iDomainRightsResp = NULL;
+            iDomainRightsResp = aRightsResp.AllocL();
+            iImplicitJoinDomain = ETrue;
+            }
+        else
+            {
+            User::LeaveIfError( r );
+
+            if ( !aOnePass )
+                {
+                if ( iObserver )
+                    {
+                    iObserver->RightsObjectDetailsL( iReturnedROs ); // pass RO details to UI
+                    }
+                }
+            }
+
+            TRAP( r, InsertTransactionIDL( resp->iTransTrackIDs, resp->iContentIDs ) );
+            TRAP( r, InsertDomainRosL() );
+
+        // Device DRM Time is insecure, but server thinks that the time is correct
+        // -> Set DRM Time as secure
+        if ( !iSecureTime )
+            {
+            SetDrmTimeSecureL();
+            }
+        }
+    else
+        {
+        if ( resp->iErrorUrl )
+            {
+            if ( iObserver )
+                {
+                iObserver->ErrorUrlL( *resp->iErrorUrl );
+                }
+            }
+        iSigner->ResetResponses();
+        }
+
+    CleanupStack::Pop( resp );
+
+    if ( !aOnePass )
+        {
+        iRoapStatus = resp->iStatus;
+        iResponse = resp;
+        }
+
+    PERFORMANCE_LOGLIT( "RO acquisition protocol completed" )
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::HandleJoinDomainResponseL()
+// ---------------------------------------------------------
+//
+void CRoapEng::HandleJoinDomainResponsePduL( const TDesC8& aJoinResp )
+    {
+    LOGLIT( "CRoapEng::HandleJoinDomainResponsePduL" )
+
+    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
+
+    CJoinDomainResp* resp = NULL;
+    CDRMDomainContext* context = NULL;
+    RPointerArray<HBufC8> domainKeyElements;
+    TBool status = EFalse;
+
+    CleanupResetAndDestroyPushL( domainKeyElements );
+
+    resp = iParser->ParseJoinDomainRespL( aJoinResp, domainKeyElements );
+
+    iResponse = resp;
+    iRoapStatus = resp->iStatus;
+
+    if ( iRoapStatus == ESuccess )
+        {
+        if ( resp->iDomainKeyRiId != resp->iRiId )
+            {
+            LOGLIT( "resp->iDomainKeyRiId != resp->iRiId" )
+            User::Leave( KErrRoapServerFatal );
+            }
+
+        if ( !iStoredRiContext || ( resp->iCertificateChain.Count()
+            && resp->iOcspResponse.Count() ) )
+            {
+            status = VerifyCertificateChainL( resp->iCertificateChain,
+                resp->iOcspResponse );
+            if ( !status )
+                {
+                LOGLIT( "Certificate chain validation failed" )
+                User::Leave( KErrRoapServerFatal );
+                }
+            status = ValidateRiIdL( resp->iRiId, *resp->iCertificateChain[0] );
+            if ( !status )
+                {
+                LOGLIT( "RI ID validation failed" )
+                User::Leave( KErrRoapServerFatal );
+                }
+            }
+
+        status = VerifySignatureL( aJoinResp, *resp->iSignature,
+            iStoredRiContext->CertificateChain() );
+        if ( !status )
+            {
+            LOGLIT( "Signature verification failed" )
+            User::Leave( KErrRoapServerFatal );
+            }
+
+        if ( resp->iDomainKeys.Count() > 1 && resp->iDomainKeyIDs.Count() > 1
+            && resp->iDomainKeys.Count() == resp->iDomainKeyIDs.Count() )
+            {
+            // Sort domain keys by generation (000 generation is first)
+            TLex8 lex;
+            TInt generation = 0;
+            RArray<TInt> generations;
+            CleanupClosePushL( generations );
+
+            for ( TInt i = 0; i < resp->iDomainKeyIDs.Count(); i++ )
+                {
+                lex = resp->iDomainKeyIDs[i]->Right( KDomainGenerationLength );
+                lex.Val( generation );
+                generations.AppendL( generation );
+                }
+
+            SortArrays( resp->iDomainKeys, resp->iMacs, domainKeyElements,
+                generations );
+
+            CleanupStack::PopAndDestroy( &generations );
+            }
+
+        if ( !resp->iDomainKeys.Count() )
+            {
+            LOGLIT( "No valid domain keys present!" )
+            User::Leave( KErrRoapServerFatal );
+            }
+
+#ifdef _DISABLE_HASH_CHAIN_GENERATION
+        resp->iHashChainSupport = EFalse;
+#endif
+
+        if ( resp->iHashChainSupport )
+            {
+            if ( resp->iDomainKeys.Count() > 1 )
+                {
+                LOGLIT( "More than one Domain key present, hash chain key generation is supported!" )
+                // Might be KErrRoapServerFatal server error
+                }
+            }
+
+        context = CDRMDomainContext::NewLC( iDomainId,
+            resp->iDomainExpiration, resp->iHashChainSupport,
+            resp->iDomainKeys, resp->iRiId,
+            iStoredRiContext->RightsIssuerURL() );
+        iStorageClient->AddDomainContextL( *context, resp->iMacs,
+            domainKeyElements, resp->iTransportScheme );
+        iDomainId.SetLength( 0 );
+        CleanupStack::PopAndDestroy( context );
+
+        if ( iDomainRightsResp )
+            {
+            // It's a implicit Join Domain case
+            // We still need to store the domain RO
+            StoreDomainRightsL();
+            }
+
+        // Device DRM Time is insecure, but server thinks that the time is correct
+        // -> Set DRM Time as secure
+        if ( !iSecureTime )
+            {
+            SetDrmTimeSecureL();
+            }
+        }
+    else
+        {
+        if ( resp->iErrorUrl )
+            {
+            if ( iObserver )
+                {
+                iObserver->ErrorUrlL( *resp->iErrorUrl );
+                }
+            }
+        iSigner->ResetResponses();
+        }
+    CleanupStack::PopAndDestroy( &domainKeyElements );
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::HandleLeaveDomainResponseL()
+// ---------------------------------------------------------
+//
+void CRoapEng::HandleLeaveDomainResponsePduL( const TDesC8& aLeaveResp )
+    {
+    LOGLIT( "CRoapEng::HandleLeaveDomainResponsePduL" )
+
+    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
+
+    CLeaveDomainResp* resp = NULL;
+    resp = iParser->ParseLeaveDomainRespL( aLeaveResp );
+    iRoapStatus = resp->iStatus;
+    iResponse = resp;
+    if ( iRoapStatus == ESuccess )
+        {
+
+        }
+    else if ( resp->iErrorUrl )
+        {
+        if ( iObserver )
+            {
+            iObserver->ErrorUrlL( *resp->iErrorUrl );
+            }
+        }
+
+    PERFORMANCE_LOGLIT( "Leave domain protocol completed" )
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::HandleMeteringReportResponsePduL()
+// ---------------------------------------------------------
+//
+#ifndef RD_DRM_METERING
+void CRoapEng::HandleMeteringReportResponsePduL( const TDesC8& /*aMeteringResp*/)
+    {
+    }
+#else
+void CRoapEng::HandleMeteringReportResponsePduL( const TDesC8& aMeteringResp )
+    {
+    LOGLIT( "CRoapEng::HandleMeteringReportResponsePduL" )
+    __ASSERT_ALWAYS( iStoredRiContext, User::Invariant() );
+
+    CMeteringResp* resp = NULL;
+    CMeteringReportReq* request = NULL;
+
+    resp = iParser->ParseMeteringRespL( aMeteringResp );
+
+    request = static_cast<CMeteringReportReq*> ( iRequest );
+
+    iRoapStatus = resp->iStatus;
+    iResponse = resp;
+    if ( iRoapStatus == ESuccess )
+        {
+        if ( resp->iDeviceId.CompareF( *iDeviceId ) != KErrNone
+            || resp->iDeviceNonce->CompareF( request->iNonce ) != KErrNone )
+            {
+            LOGLIT( "Mismatch in deviceId or in nonce" )
+            LOGLIT( "Observed DeviceId" )
+            LOGHEX( resp->iDeviceId.Ptr(), resp->iDeviceId.Length() )
+            LOGLIT( "Expected DeviceId" )
+            LOGHEX( request->iDeviceId.Ptr(), request->iDeviceId.Length() )
+            LOGLIT( "Observed nonce" )
+            LOGHEX( resp->iDeviceNonce->Ptr(), resp->iDeviceNonce->Length() )
+            LOGLIT( "Expected nonce" )
+            User::Leave( KErrRoapServerFatal );
+            }
+
+        if ( !iStoredRiContext || ( resp->iCertificateChain.Count()
+            && resp->iOcspResponse.Count() ) )
+            {
+            if ( !VerifyCertificateChainL( resp->iCertificateChain,
+                resp->iOcspResponse ) )
+                {
+                LOGLIT( "Certificate chain validation failed" )
+                User::Leave( KErrRoapServerFatal );
+                }
+            if ( !ValidateRiIdL( resp->iRiId, *resp->iCertificateChain[0] ) )
+                {
+                LOGLIT( "RI ID validation failed" )
+                User::Leave( KErrRoapServerFatal );
+                }
+            }
+
+        if ( !VerifySignatureL( aMeteringResp, *resp->iSignature,
+            iStoredRiContext->CertificateChain() ) )
+            {
+            LOGLIT( "Signature verification failed" )
+            User::Leave( KErrRoapServerFatal );
+            }
+
+        // Everything is fine, we can delete metering data
+        iStorageClient->DeleteMeteringDataL( resp->iRiId );
+
+        // notify PostResponseUrl for iObserver
+        if ( resp->iPrUrl )
+            {
+            HBufC8* prUrl( resp->iPrUrl );
+            LOGLIT( "PrUrl" )
+            LOGHEX( prUrl->Ptr(), prUrl->Length() )
+            if ( iObserver )
+                {
+                iObserver->PostResponseUrlL( *prUrl );
+                LOGLIT( "Notified observer with PostResponseUrl" )
+                }
+            else
+                {
+                LOGLIT( "Warning no observer for PostResponseUrl" )
+                }
+            }
+        }
+    return;
+    }
+#endif //RD_DRM_METERING
+// ---------------------------------------------------------
+// CRoapEng::HandleMultipartL()
+// ---------------------------------------------------------
+//
+void CRoapEng::HandleMultipartL()
+    {
+    LOGLIT( "CRoapEng::HandleMultipartL" )
+
+    TInt rightsErr( KErrNone );
+    TInt err( KErrNone );
+    TInt docErr( KErrNone );
+    TDataType type = TDataType();
+    TBool mmcAllowed( EFalse );
+    HBufC* contentName( NULL );
+    RBuf newPath;
+    TUid app_uid;
+    RBuf rootPath;
+
+    TRAP( rightsErr, HandleRoapResponseL( iRoapResp->ProtocolUnit() ) );
+
+    newPath.CreateL( KMaxFileName );
+    CleanupClosePushL( newPath  );
+
+    CDocumentHandler* docHandler( CDocumentHandler::NewLC() );
+
+    if ( iRoapResp->DcfFileName().Left( 1 ).CompareF( _L ("e") ) == 0 )
+        {
+        mmcAllowed = ETrue;
+        }
+
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+
+#ifndef RD_MULTIPLE_DRIVE
+    rootPath.CreateL( mmcAllowed ?
+        PathInfo::MemoryCardRootPath() :
+        PathInfo::PhoneMemoryRootPath() );
+
+#else //RD_MULTIPLE_DRIVE
+    _LIT( KSysDriveRoot, "_:\\Data\\");
+    _LIT( KMassDriveRoot, "_:\\" );
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+
+    if ( mmcAllowed )
+        {
+        // Set root path to memory card root
+        rootPath.CreateL( KMassDriveRoot() );
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNumber );
+        }
+    else
+        {
+        // Set root path to system root
+        rootPath.CreateL( KSysDriveRoot() );
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+        }
+    fs.DriveToChar( driveNumber, driveLetter );
+    __ASSERT_ALWAYS( rootPath.Length()>0, User::Invariant() );
+    rootPath[0] = (TUint)driveLetter;
+
+
+#endif
+    CleanupClosePushL( rootPath );
+
+    iRoapResp->GetContentNameLC( contentName );
+
+    if ( contentName && contentName->Length()
+        && fs.IsValidName( *contentName ) )
+        {
+        if ( !rightsErr )
+            {
+            TRAP( err, docErr = docHandler->SilentMoveL( iRoapResp->DcfFileName(),
+                    *contentName, rootPath, type, KEntryAttNormal ) );
+            }
+        else
+            {
+            // when an error occured during RO storing -> show "saved to" note
+            TRAP( err, docErr = docHandler->MoveL( iRoapResp->DcfFileName(),
+                    *contentName, type, KEntryAttNormal ) );
+            }
+
+        }
+    else
+        {
+        if ( !rightsErr )
+            {
+            // use the default name
+            User::LeaveIfError( docHandler->SilentMoveL(
+                iRoapResp->DcfFileName(), KNullDesC(), rootPath, type,
+                KEntryAttNormal ) );
+            }
+        else
+            {
+            // when an error occured during RO storing -> show "saved to" note
+            docHandler->MoveL( iRoapResp->DcfFileName(), KNullDesC(), type,
+                KEntryAttNormal );
+            }
+        }
+
+    if ( err || docErr )
+        {
+        if ( !rightsErr )
+            {
+            // use the default name
+            User::LeaveIfError( docHandler->SilentMoveL(
+                iRoapResp->DcfFileName(), KNullDesC(), rootPath, type,
+                KEntryAttNormal ) );
+            }
+        else
+            {
+            // when an error occured during RO storing -> show "saved to" note
+            docHandler->MoveL( iRoapResp->DcfFileName(), KNullDesC(), type,
+                KEntryAttNormal );
+            }
+        }
+    User::LeaveIfError( rightsErr );
+
+    User::LeaveIfError( docHandler->GetPath( newPath ) );
+    User::LeaveIfError( docHandler->HandlerAppUid( app_uid ) );
+
+    if ( iObserver )
+        {
+        iObserver->ContentDetailsL( newPath, type.Des8(), app_uid );
+        }
+
+    CleanupStack::PopAndDestroy( contentName );
+    CleanupStack::PopAndDestroy( &rootPath );
+
+    CleanupStack::PopAndDestroy( &fs );
+    CleanupStack::PopAndDestroy( docHandler );
+    CleanupStack::PopAndDestroy( &newPath );
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::SignMessageL()
+// ---------------------------------------------------------
+//
+HBufC8* CRoapEng::SignMessageL( const TDesC8& aMessage ) const
+    {
+    LOGLIT( "CRoapEng::SignMessageL" )
+    HBufC8* r = NULL;
+
+    if ( iReqMessage == EDeviceHello )
+        {
+        // Device Hello always resets signing chain!!
+        iSigner->ResetRequests();
+        iSigner->ResetResponses();
+        // Device Hello or RI Hello is not signed
+        iSigner->AddRequestL( aMessage );
+        r = aMessage.AllocL();
+        }
+    else
+        {
+        r = iSigner->SignAndAddRequestL( aMessage );
+        iSigner->ResetRequests();
+
+        if ( iReqMessage == ERegistration )
+            {
+            // Add signed request to the signer for verifying signature on
+            // response (for Registration protocol only).
+            iSigner->AddResponseL( *r );
+            }
+        }
+    return r;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::VerifySignatureL()
+// ---------------------------------------------------------
+//
+TBool CRoapEng::VerifySignatureL(
+    const TDesC8& aMessage,
+    const TDesC8& aSignature,
+    const RPointerArray<HBufC8>& aCertificateChain ) const
+    {
+    LOGLIT( "CRoapEng::VerifySignatureL" )
+
+    TBool isValid = ETrue;
+
+    if ( iReqMessage != EDeviceHello && iReqMessage != ELeaveDomain )
+        {
+        // RI Hello and Leave Domain resp are not signed
+        isValid = iSigner->VerifyAndAddResponseL( aMessage, aSignature,
+            aCertificateChain );
+        iSigner->ResetResponses();
+        }
+
+#ifdef _DISABLE_SIGNATURE_CHECK
+    isValid = ETrue;
+#endif
+    return isValid;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::VerifyTriggerSignatureL()
+// ---------------------------------------------------------
+//
+TBool CRoapEng::VerifyTriggerSignatureL(
+    const TDesC8& aXmlTrigger,
+    const CRoapTrigger& aTrigger ) const
+    {
+    LOGLIT( "CRoapEng::ValidateTriggerSignatureL" )
+
+    TPtrC8 element( KNullDesC8 );
+    TPtrC8 signedInfo( KNullDesC8 );
+    CDRMDomainContext* context( NULL );
+    HBufC8* domainKey( NULL );
+    HBufC8* unwrappedMacKey( NULL );
+    CSHA1* digest( NULL );
+    CMessageDigest* hMac( NULL );
+    TBool result( ETrue );
+    TInt pos( 0 );
+    TInt generation( 0 );
+
+    element.Set( iParser->ExtractElement( aXmlTrigger, KLeaveDomainElement(),
+        pos ) );
+    pos = 0;
+    signedInfo.Set( iParser->ExtractElement( aXmlTrigger,
+        KSignedInfoElement(), pos ) );
+
+    if ( !element.Length() || !signedInfo.Length() || !aTrigger.iEncKey
+        || !aTrigger.iSignature )
+        {
+        User::Leave( KErrRoapServerFatal );
+        }
+
+    context = iStorageClient->GetDomainContextL( *aTrigger.iDomainId );
+
+    if ( !context )
+        {
+        // we are not member of the domain
+        LOGLIT( "No DomainContext for the domain -> Cannot verify Trigger signature" )
+        return ETrue;
+        }
+    CleanupStack::PushL( context );
+
+    TLex8 lex( aTrigger.iDomainId->Right( KDomainGenerationLength ) );
+    lex.Val( generation );
+    domainKey = context->DomainKeyL( generation );
+    User::LeaveIfNull( domainKey );
+    CleanupStack::PushL( domainKey );
+
+    unwrappedMacKey = OmaCrypto::AesUnwrapL( *domainKey, *aTrigger.iEncKey );
+    CleanupStack::PopAndDestroy( domainKey );
+    CleanupStack::PushL( unwrappedMacKey );
+
+    // hash the leaveDomain element
+    digest = CSHA1::NewL();
+    CleanupStack::PushL( digest );
+    digest->Update( element );
+
+    if ( digest->Final().CompareF( *aTrigger.iDigestValue ) )
+        {
+        LOGLIT( "Reference Validation failed!" )
+        result = EFalse;
+        }
+
+    if ( result )
+        {
+        // calculate HMAC signature
+        hMac = CMessageDigestFactory::NewHMACLC( CMessageDigest::ESHA1,
+            *unwrappedMacKey );
+        hMac->Update( signedInfo );
+
+        if ( hMac->Final().CompareF( *aTrigger.iSignature ) != 0 )
+            {
+            LOGLIT( "Signature Validation failed!" )
+            result = EFalse;
+            }
+        CleanupStack::PopAndDestroy( hMac );
+        }
+
+    CleanupStack::PopAndDestroy( digest );
+    CleanupStack::PopAndDestroy( unwrappedMacKey );
+    CleanupStack::PopAndDestroy( context );
+
+    if ( !result )
+        {
+        LOGLIT( "Trigger signature check failed!" )
+        }
+
+#ifdef _DISABLE_SIGNATURE_CHECK
+    result = ETrue;
+#endif
+    return result;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::VerifyCertificateChainL()
+// ---------------------------------------------------------
+//
+TBool CRoapEng::VerifyCertificateChainL(
+    const RPointerArray<HBufC8>& aCertificateChain,
+    const RPointerArray<HBufC8>& aOcspResponses ) const
+    {
+    LOGLIT( "CRoapEng::VerifyCertificateChainL" )
+
+    CX509Certificate* cert = NULL;
+    CX509Certificate* signingCert = NULL;
+    CX509Certificate* riCA = NULL;
+    TBool result = EFalse;
+    RPointerArray<HBufC8> serialNums;
+    CX500DistinguishedName* rootDistName = NULL;
+    HBufC* rootName = NULL;
+    HBufC8* rootCert = NULL;
+    HBufC8* temp = NULL;
+
+    if ( !aCertificateChain.Count() || !aOcspResponses.Count() )
+        {
+        User::Leave( KErrRoapServerFatal );
+        }
+
+    // Get the last cert from the chain. It is signed by some of our trusted anchor
+    riCA = CX509Certificate::NewLC(
+        *( aCertificateChain[aCertificateChain.Count() - 1] ) );
+    rootDistName = CX500DistinguishedName::NewLC( riCA->IssuerName() );
+    rootName = rootDistName->DisplayNameL();
+    CleanupStack::PushL( rootName );
+    // Get the correct root cert for validating the whole chain
+    rootCert = iStorageClient->GetRootCertificateL( *rootName );
+    CleanupStack::PopAndDestroy( rootName );
+    CleanupStack::PopAndDestroy( rootDistName );
+    CleanupStack::PopAndDestroy( riCA );
+
+    if ( !rootCert )
+        {
+        LOGLIT( "No root certificate present!" )
+        LOGLIT( "Certificate chain verification failed." )
+        return EFalse;
+        }
+    CleanupStack::PushL( rootCert );
+
+    CleanupResetAndDestroyPushL( serialNums );
+
+    for ( TInt i = 0; i < aCertificateChain.Count(); i++ )
+        {
+        cert = CX509Certificate::NewLC( *aCertificateChain[i] );
+        temp = cert->SerialNumber().AllocLC();
+        serialNums.AppendL( temp );
+        CleanupStack::Pop( temp );
+        if ( aCertificateChain.Count() - 1 == i )
+            {
+            // signingCert = Trusted root cert
+            signingCert = CX509Certificate::NewLC( *rootCert );
+            }
+        else
+            {
+            signingCert = CX509Certificate::NewLC( *aCertificateChain[i + 1] );
+            }
+        result = cert->VerifySignatureL( signingCert->PublicKey().KeyData() );
+
+#ifdef _DISABLE_CERT_CHECK
+        result = ETrue;
+#endif
+        CleanupStack::PopAndDestroy( signingCert );
+        CleanupStack::PopAndDestroy( cert );
+        if ( !result )
+            {
+            LOGLIT( "Certificate chain verification failed." )
+            CleanupStack::PopAndDestroy( 2, rootCert );
+            return result;
+            }
+        }
+
+    if ( aCertificateChain.Count() >= 2 )
+        {
+        result = VerifyOcspResponsesL( aOcspResponses, *aCertificateChain[1],
+            serialNums );
+
+        if ( !result )
+            {
+            // CoreMedia's OCSP responder cert is signed by the root -> against CMLA spec
+            LOGLIT( "Try to verify OCSP response cert using root cert" )
+            result = VerifyOcspResponsesL( aOcspResponses, *rootCert,
+                serialNums );
+            }
+        }
+    else if ( aCertificateChain.Count() == 1 )
+        {
+        // There is only one cert in the cert chain -> the OCSP response cert is verified with root cert
+        result = VerifyOcspResponsesL( aOcspResponses, *rootCert, serialNums );
+        }
+    else
+        {
+        result = EFalse;
+        }
+
+    if ( iStoredRiContext && aCertificateChain.Count() && result )
+        {
+        cert = CX509Certificate::NewLC( *aCertificateChain[0] );
+        if ( iStoredRiContext->ExpiryTime() < cert->ValidityPeriod().Finish() )
+            {
+            iStoredRiContext->SetCertificateChainL( aCertificateChain );
+            iStoredRiContext->SetOCSPResponseL( aOcspResponses );
+
+            // update RI Context
+            iStorageClient->AddRIContextL( *iStoredRiContext );
+            }
+        CleanupStack::PopAndDestroy( cert );
+        }
+
+    CleanupStack::PopAndDestroy( 2, rootCert ); // serialNums, rootCert
+
+#ifdef _ROAP_TESTING
+    if ( result )
+        {
+        LOGLIT( "Certificate chain verification ok." )
+        }
+    else
+        {
+        LOGLIT( "Certificate chain verification failed." )
+        }
+#endif
+#ifdef _DISABLE_CERT_CHECK
+    result = ETrue;
+#endif
+
+    return result;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::VerifyOcspResponsesL()
+// ---------------------------------------------------------
+//
+TBool CRoapEng::VerifyOcspResponsesL(
+    const RPointerArray<HBufC8>& aOcspResponses,
+    const TDesC8& aRiCaCert,
+    const RPointerArray<HBufC8>& aCertSerialNums ) const
+    {
+    LOGLIT( "CRoapEng::VerifyOcspResponsesL" )
+
+#ifdef _DISABLE_OCSP_CHECK
+    TBool result( ETrue );
+#else
+    // Get verification result from the server
+    TBool result( iStorageClient->VerifyOcspResponsesL( aOcspResponses,
+        aRiCaCert, aCertSerialNums ) );
+#endif
+
+#ifdef _ROAP_TESTING
+    if ( result )
+        {
+        LOGLIT( "OCSP response verification ok." )
+        }
+    else
+        {
+        LOGLIT( "OCSP response verification failed." )
+        }
+#endif
+
+    return result;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::ValidateRiCertificateL()
+// ---------------------------------------------------------
+//
+TBool CRoapEng::ValidateRiCertificateL( const CX509Certificate* aCert )
+    {
+    LOGLIT( "CRoapEng::ValidateRiCertificateL" )
+
+    TBool ret = ETrue;
+    const CX509CertExtension* ext = NULL;
+    CX509KeyUsageExt* keyUsageExt = NULL;
+    CX509ExtendedKeyUsageExt* extendedKeyUsage = NULL;
+    TTime riExpiry;
+    TInt count = 0;
+
+    if ( iSelectedAlgorithms == ECmlaIp1 )
+        {
+        // Check RI certificate extensions only in CMLA case
+        ext = aCert->Extension( KKeyUsage() );
+        if ( !ext || !( ext->Critical() ) )
+            {
+            LOGLIT( "RI cert KeyUsage extension missing or not critical!" )
+            ret = EFalse;
+            }
+
+        if ( ext && ret )
+            {
+            keyUsageExt = CX509KeyUsageExt::NewLC( ext->Data() );
+            if ( !keyUsageExt->IsSet( EX509DigitalSignature ) )
+                {
+                LOGLIT( "DigitalSignature bit is not set in KeyUsageExt of RI cert!" )
+                ret = EFalse;
+                }
+            CleanupStack::PopAndDestroy( keyUsageExt );
+            }
+
+        ext = aCert->Extension( KExtendedKeyUsage() );
+        if ( !ext || !( ext->Critical() ) )
+            {
+            LOGLIT( "RI cert ExtendedKeyUsage extension missing or not critical!" )
+            ret = EFalse;
+            }
+
+        if ( ext && ret )
+            {
+            ret = EFalse;
+            extendedKeyUsage = CX509ExtendedKeyUsageExt::NewLC( ext->Data() );
+            count = extendedKeyUsage->KeyUsages().Count();
+            for ( TInt i = 0; i < count && !ret; i++ )
+                {
+                if ( extendedKeyUsage->KeyUsages().At( i )->CompareF(
+                    KOmaKpRightsIssuerOid() ) == 0 )
+                    {
+                    ret = ETrue;
+                    }
+                }
+            if ( !ret )
+                {
+                LOGLIT( "OmaKpRightsIssuer OID is not set in ExtendedKeyUsageExt of RI cert!" )
+                }
+            CleanupStack::PopAndDestroy( extendedKeyUsage );
+            }
+        }
+
+    riExpiry = aCert->ValidityPeriod().Finish();
+
+    if ( riExpiry < GetDrmTimeL() )
+        {
+        LOGLIT( "RI Context certificate is expired!" )
+        ret = EFalse;
+        }
+#ifdef _DISABLE_CERT_CHECK
+    ret = ETrue;
+#endif
+    return ret;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::GetCertificateChainL()
+// ---------------------------------------------------------
+//
+RPointerArray<HBufC8> CRoapEng::GetCertificateChainL() const
+    {
+    LOGLIT( "CRoapEng::GetCertificateChainL ->" )
+
+    TInt err = KErrNone;
+    RPointerArray<HBufC8> certificateChain;
+    HBufC8* root = NULL;
+
+    CleanupResetAndDestroyPushL( certificateChain );
+
+    err = iStorageClient->GetDeviceCertificateChainL( certificateChain );
+
+    if ( err )
+        {
+        User::Leave( err );
+        }
+
+    if ( certificateChain.Count() < KMinCertChainLength )
+        {
+        // the CMLA chain must always contain:
+        // the device certificate,
+        // at lest one signing certificate (device CA),
+        // and the root certificate
+        DETAILLOGLIT( "Got improper certificate chain!!" )
+        // Leaving in production devices.
+        User::Leave( KErrRoapDevice );
+        __ASSERT_DEBUG( ETrue, User::Invariant() );
+        }
+
+    // delete and remove the root certificate (it's always the last one in the list)
+    root = certificateChain[certificateChain.Count() - 1];
+    delete root;
+    certificateChain.Remove( certificateChain.Count() - 1 );
+
+    CleanupStack::Pop( &certificateChain );
+
+    LOGLIT( "CRoapEng::GetCertificateChainL <-" )
+
+    return certificateChain;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::GetDeviceDetailsL()
+// ---------------------------------------------------------
+//
+void CRoapEng::GetDeviceDetailsL(
+    HBufC8*& aManufacturer,
+    HBufC8*& aModel,
+    HBufC8*& aVersion )
+    {
+    LOGLIT( "-> CRoapEng::GetDeviceDetailsL" )
+
+#ifndef __WINS__
+    TInt numPhone = 0;
+    TUint32 caps = 0;
+    TName tsyName;
+    RMobilePhone phone;
+    RTelServer etelServer;
+    RTelServer::TPhoneInfo phoneInfo;
+    HBufC* version = NULL;
+
+    User::LeaveIfError( etelServer.Connect() );
+
+    CleanupClosePushL( etelServer );
+
+    User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) );
+    User::LeaveIfError( etelServer.EnumeratePhones( numPhone) );
+
+    for (TInt i(0); i < numPhone; i++)
+        {
+        User::LeaveIfError( etelServer.GetPhoneInfo( i, phoneInfo ) );
+        User::LeaveIfError( etelServer.GetTsyName( i,tsyName ) );
+
+        if ( tsyName.CompareF( KMmTsyModuleName ) == 0)
+            {
+            break;
+            }
+        }
+
+    User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) );
+    CleanupClosePushL( phone );
+
+    phone.GetIdentityCaps( caps );
+    if ( !( caps & RMobilePhone::KCapsGetManufacturer ) &&
+        !( caps & RMobilePhone::KCapsGetModel ) )
+        {
+        User::Leave( KErrRoapGeneral );
+        }
+
+    RMobilePhone::TMobilePhoneIdentityV1 details;
+    TRequestStatus status;
+
+    phone.GetPhoneId( status, details );
+    User::WaitForRequest( status );
+
+    User::LeaveIfError( status.Int() );
+
+    HBufC8* manufacturer( HBufC8::NewLC( details.iManufacturer.Length() ) );
+    manufacturer->Des().Copy( details.iManufacturer );
+    HBufC8* model( HBufC8::NewLC( details.iModel.Length() ) );
+    model->Des().Copy( details.iModel );
+
+    version = HBufC::NewLC( KSysUtilVersionTextLength );
+    TPtr ptr( version->Des() );
+    User::LeaveIfError( SysUtil::GetSWVersion( ptr ) );
+
+    // remove possible BOM from the end
+    if ( ptr.Right( KBOM1().Length() ).CompareF( KBOM1 ) == KErrNone )
+        {
+        ptr.Delete( ptr.Length() - KBOM1().Length(), KBOM1().Length() );
+        }
+    if ( ptr.Right( KBOM2().Length() ).CompareF( KBOM2 ) == KErrNone )
+        {
+        ptr.Delete( ptr.Length() - KBOM2().Length(), KBOM2().Length() );
+        }
+
+    aVersion = CnvUtfConverter::ConvertFromUnicodeToUtf8L( ptr );
+
+    CleanupStack::PopAndDestroy( version );
+    CleanupStack::Pop( model );
+    CleanupStack::Pop( manufacturer );
+    aManufacturer = manufacturer;
+    aModel = model;
+    CleanupStack::PopAndDestroy( &phone );
+    CleanupStack::PopAndDestroy( &etelServer );
+#else
+    aManufacturer = _L8("Nokia").AllocL();
+    aModel = _L8("Emulator").AllocL();
+    aVersion = _L8("9.0").AllocL();
+#endif
+
+    LOGLIT( "Device details:" )
+    LOGLIT( "   Manufacturer: " )
+    LOG( aManufacturer->Des() )
+    LOGLIT( "   Model: " )
+    LOG( aModel->Des() )
+    LOGLIT( "   Revision: " )
+    LOG( aVersion->Des() )
+
+    LOGLIT( "<- CRoapEng::GetDeviceDetailsL" )
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::FetchTransactionIDL()
+// ---------------------------------------------------------
+//
+void CRoapEng::FetchTransactionIDL(
+    RPointerArray<HBufC8>& aTransIDs,
+    RPointerArray<HBufC8>& aContentIDs )
+    {
+    LOGLIT( "CRoapEng::FetchTransactionIDL" )
+
+    __ASSERT_ALWAYS( iTrigger, User::Invariant() );
+
+    RArray<TPair> array;
+    TInt err = KErrNone;
+
+    CleanupClosePushL( array );
+
+    if ( !iTrigger->iContentIdList.Count() )
+        {
+        CleanupStack::PopAndDestroy( &array );
+        return;
+        }
+
+    if ( iTransStatus == ENotAsked && iObserver )
+        {
+        UpdateTransactionTrackingStatusL();
+        }
+    if ( iTransStatus == EAllowed )
+        {
+        for ( TInt i = 0; i < iTrigger->iContentIdList.Count(); i++ )
+            {
+            TPair pair;
+            pair.iCid = iTrigger->iContentIdList[i]->Alloc(); // duplicate contentID,
+            pair.iTtid = NULL; // pair.iCid is deleted by iRequest
+            err = array.Append( pair );
+            if ( err )
+                {
+                delete pair.iCid;
+                pair.iCid = NULL;
+                }
+            }
+
+            TRAP_IGNORE(iDcfRep->GetTtidL( array ) );
+
+        for ( TInt i = 0; i < array.Count(); i++ )
+            {
+            if ( array[i].iTtid && array[i].iCid && array[i].iTtid->Length()
+                && array[i].iCid->Length() )
+                {
+                err = aContentIDs.Append( array[i].iCid );
+                if ( !err )
+                    {
+                    aTransIDs.Append( array[i].iTtid );
+                    }
+                else
+                    {
+                    delete array[i].iCid;
+                    array[i].iCid = NULL;
+                    delete array[i].iTtid;
+                    array[i].iTtid = NULL;
+                    }
+                }
+            else if ( array[i].iTtid || array[i].iCid )
+                {
+                delete array[i].iTtid;
+                array[i].iTtid = NULL;
+                delete array[i].iCid;
+                array[i].iCid = NULL;
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy( &array );
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::InsertTransactionIDL()
+// ---------------------------------------------------------
+//
+void CRoapEng::InsertTransactionIDL(
+    RPointerArray<HBufC8>& aTransIDs,
+    RPointerArray<HBufC8>& aContentIDs )
+    {
+    LOGLIT( "CRoapEng::InsertTransactionIDL" )
+
+    RArray<TPair> array;
+    TRequestStatus status;
+
+    CleanupClosePushL( array );
+
+    if ( !aTransIDs.Count() || !aContentIDs.Count() )
+        {
+        LOGLIT( "Insert ttID: Wrong input data" )
+        CleanupStack::PopAndDestroy( &array );
+        return;
+        }
+
+    if ( aTransIDs.Count() != aContentIDs.Count() )
+        {
+        LOGLIT( "Insert ttID: ttID.Count != cid.Count" )
+        CleanupStack::PopAndDestroy( &array );
+        return;
+        }
+
+    if ( iTransStatus == ENotAsked && iObserver )
+        {
+        UpdateTransactionTrackingStatusL();
+        }
+    if ( iTransStatus == EAllowed )
+        {
+        for ( TInt i = 0; i < aContentIDs.Count() && i < aTransIDs.Count(); i++ )
+            {
+            TPair pair;
+            pair.iCid = aContentIDs[i];
+            pair.iTtid = aTransIDs[i];
+            array.Append( pair );
+            }
+
+        iDcfRep->SetTtid( array, status );
+        User::WaitForRequest( status );
+        }
+
+    CleanupStack::PopAndDestroy( &array );
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::GetOCSPResponderKeyHashL()
+// ---------------------------------------------------------
+//
+HBufC8* CRoapEng::GetOCSPResponderKeyHashL() const
+    {
+    LOGLIT( "CRoapEng::GetOCSPResponderKeyHashL" )
+
+    if ( !iStoredRiContext )
+        {
+        User::Leave( KErrRoapNotRegistered );
+        }
+    return iStorageClient->GetOcspResponderIdL( iStoredRiContext->RIID() );
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::GetDrmTimeL()
+// ---------------------------------------------------------
+//
+TTime CRoapEng::GetDrmTimeL()
+    {
+    LOGLIT( "CRoapEng::GetDrmTimeL" )
+
+    TTime drmTime;
+    DRMClock::ESecurityLevel secureTime;
+    TInt zone( 0 );
+
+    User::LeaveIfError( iClockClient->GetSecureTime( drmTime, zone,
+        secureTime ) );
+
+    if ( secureTime == DRMClock::KInsecure )
+        {
+        iSecureTime = EFalse;
+        }
+    else
+        {
+        iSecureTime = ETrue;
+        }
+
+    return drmTime;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::SetDrmTimeSecureL()
+// ---------------------------------------------------------
+//
+void CRoapEng::SetDrmTimeSecureL()
+    {
+    LOGLIT( "CRoapEng::SetDrmTimeSecureL" )
+
+    TTime drmTime;
+    DRMClock::ESecurityLevel secureTime;
+    TInt zone( 0 );
+
+    User::LeaveIfError( iClockClient->GetSecureTime( drmTime, zone,
+        secureTime ) );
+    User::LeaveIfError( iClockClient->UpdateSecureTime( drmTime, zone ) );
+
+    iSecureTime = ETrue;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::AdjustDrmTime()
+// ---------------------------------------------------------
+//
+void CRoapEng::AdjustDrmTimeL(
+    const RPointerArray<HBufC8>& aOcspResponses,
+    TDesC8& aRegReqNonce ) const
+    {
+    // To be removed on next API change.
+    // Replace calls with direct call to RRoapStorageClient.
+    LOGLIT( "CRoapEng::AdjustDrmTime calling server" )
+    if ( aOcspResponses.Count() > 0 )
+        {
+        iStorageClient->UpdateDrmTimeL( iStoredRiContext->CertificateChain(),
+            aOcspResponses, aRegReqNonce );
+        }
+    else
+        {
+        LOGLIT( "No OCSP responses present." )
+        }
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::StoreDomainRightsL()
+// ---------------------------------------------------------
+//
+void CRoapEng::StoreDomainRightsL()
+    {
+    LOGLIT( "CRoapEng::StoreDomainRightsL" )
+
+    RPointerArray<CDRMRights> returnedROs;
+
+    CleanupResetAndDestroyPushL( returnedROs );
+
+    iRoParser->ParseAndStoreL( *iDomainRightsResp, returnedROs );
+
+    if ( iObserver )
+        {
+        iObserver->RightsObjectDetailsL( returnedROs ); // pass RO details to UI
+        }
+
+    delete iDomainRightsResp;
+    iDomainRightsResp = NULL;
+
+    iImplicitJoinDomain = EFalse;
+
+    CleanupStack::PopAndDestroy( &returnedROs );
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::InsertDomainRosL()
+// ---------------------------------------------------------
+//
+void CRoapEng::InsertDomainRosL()
+    {
+    CDcfRep* rep = NULL;
+    CDcfEntry* entry = NULL;
+    CContent* content = NULL;
+    TPtr8 ptr( NULL, 0 );
+    TInt i;
+    RFile file;
+    RFs fs;
+    TInt error( 0 );
+
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    rep = CDcfRep::NewL();
+    CleanupStack::PushL( rep );
+    for ( i = 0; i < iReturnedROs.Count(); i++ )
+        {
+        if ( iReturnedROs[i]->GetPermission().iDomainID )
+            {
+            rep->OrderListL( *iReturnedROs[i]->GetAsset().iUid );
+            entry = rep->NextL();
+            while ( entry )
+                {
+                CleanupStack::PushL( entry );
+                error = file.Open( fs, entry->FileName(), EFileWrite
+                    | EFileShareReadersOrWriters );
+                if ( !error )
+                    {
+                    CleanupClosePushL( file );
+                    content = CContent::NewLC( file );
+                    content->AgentSpecificCommand( EEmbedDomainRo,
+                        KNullDesC8, ptr );
+                    CleanupStack::PopAndDestroy( 2, &file ); // content, file
+                    }
+                CleanupStack::PopAndDestroy( entry );
+                entry = rep->NextL();
+                }
+            }
+        }
+    CleanupStack::PopAndDestroy( 2, &fs ); // rep, fs
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::MapStatusL()
+// ---------------------------------------------------------
+//
+TInt CRoapEng::MapStatusL()
+    {
+    LOGLIT( "CRoapEng::MapStatusL" )
+
+    if ( iRoapStatus == ESuccess )
+        {
+        LOGLIT( "ROAP Status: success " )
+        return KErrNone;
+        }
+
+    if ( iRoapStatus == ENotRegistered || iRoapStatus == EDeviceTimeError )
+        {
+        // Initiate registration protocol
+        LOG2( _L ( "Not Registered! Status: %d" ), iRoapStatus )
+
+        if ( iRoapStatus == EDeviceTimeError )
+            {
+            iDeviceTimeError = ETrue;
+            }
+
+        return KErrRoapNotRegistered;
+        }
+
+    LOG2( _L ( "ROAP Error! Status: %d" ), iRoapStatus )
+
+    switch ( iRoapStatus )
+        {
+        case EUnknownError:
+        case EAbort:
+            {
+            User::Leave( KErrRoapServer );
+            }
+        case ENotSupported:
+        case EAccessDenied:
+        case ENotFound:
+        case EMalformedRequest:
+        case EUnknownRequest:
+        case EUnknownCriticalExtension:
+        case EUnsupportedVersion:
+        case EUnsupportedAlgorithm:
+        case ESignatureError:
+        case EInvalidDCFHash:
+            {
+            User::Leave( KErrRoapServerFatal );
+            }
+        case ENoCertificateChain:
+        case EInvalidCertificateChain:
+        case ETrustedRootCertificateNotPresent:
+            {
+            User::Leave( KErrRoapDevice );
+            }
+        case EInvalidDomain:
+            {
+            User::Leave( KErrRoapInvalidDomain );
+            }
+        case EDomainFull:
+            {
+            User::Leave( KErrRoapDomainFull );
+            }
+        default:
+            {
+            User::Leave( KErrRoapUnsupported );
+            }
+        }
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::ValidateRiIdL()
+//
+// Validates that RI ID equals to public key hash of RI certificate
+// ---------------------------------------------------------
+//
+TBool CRoapEng::ValidateRiIdL( TDesC8& aRiId, TDesC8& aCertBuf )
+    {
+    TBool valid = EFalse;
+    CX509Certificate* riCert = NULL;
+    CSHA1* hash = NULL;
+    HBufC8* publicKeyHash = NULL;
+
+    riCert = CX509Certificate::NewLC( aCertBuf );
+
+    // hash the SubjectPublicKeyInfo element
+    hash = CSHA1::NewL();
+    CleanupStack::PushL( hash );
+    hash->Hash( *riCert->DataElementEncoding(
+        CX509Certificate::ESubjectPublicKeyInfo ) );
+    publicKeyHash = hash->Final().AllocLC();
+
+    if ( aRiId.Compare( *publicKeyHash ) == KErrNone )
+        {
+        valid = ETrue;
+        }
+
+    CleanupStack::PopAndDestroy( publicKeyHash );
+    CleanupStack::PopAndDestroy( hash );
+    CleanupStack::PopAndDestroy( riCert );
+
+    return valid;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::UpdateTransactionTrackingStatusL()
+//
+// Update the status of transaction tracking variable
+// ---------------------------------------------------------
+//
+void CRoapEng::UpdateTransactionTrackingStatusL()
+    {
+    TInt value = KErrNone;
+    CRepository* repository = CRepository::NewL( KCRUidDRMSettings );
+    repository->Get( KDRMSettingsTransactionTracking, value );
+    delete repository;
+    iTransStatus = value ? EAllowed : EForbidden;
+    }
+
+// ---------------------------------------------------------
+// CRoapEng::CreateDeviceIdHashArrayL()
+// ---------------------------------------------------------
+//
+TInt CRoapEng::CreateDeviceIdHashArrayL( RPointerArray<TDesC8>& aIdArray )
+    {
+    TInt err( KErrNone );
+    RPointerArray<HBufC8> certChain;
+    CSHA1* hasher = NULL;
+    HBufC8* publicKey = NULL;
+    CX509Certificate* cert = NULL;
+
+    err = iStorageClient->GetDeviceCertificateChainL( certChain );
+
+    CleanupResetAndDestroyPushL( certChain );
+
+    hasher = CSHA1::NewL();
+    CleanupStack::PushL( hasher );
+    // take the hash of device certificate
+    if (certChain.Count()<=0)
+        {
+        LOGLIT( "Could get Device id Hash!!!" )
+        User::Leave( KErrGeneral );
+        }
+    cert = CX509Certificate::NewL( *certChain[0] );
+    CleanupStack::PushL( cert );
+    publicKey = cert->DataElementEncoding(
+        CX509Certificate::ESubjectPublicKeyInfo )->AllocLC();
+
+    hasher->Hash( *publicKey );
+
+    HBufC8 *elem( hasher->Final().AllocLC() );
+    aIdArray.AppendL( elem );
+    CleanupStack::Pop( elem );
+
+    CleanupStack::PopAndDestroy( publicKey );
+    CleanupStack::PopAndDestroy( cert );
+
+    CleanupStack::PopAndDestroy( hasher );
+    CleanupStack::PopAndDestroy( &certChain );
+    return err;
+    }
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RoapEngBase.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,868 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  core ROAP engine
+*
+*/
+
+
+// INCLUDE FILES
+#include <DrmRights.h>
+#include <DrmRightsClient.h>
+// #include <GenericParam.h> // from S60
+#include "RoapEngBase.h"
+#include "RoapHttpHandler.h"
+#include "RoapTrigger.h"
+#include "RoapDef.h"
+#include "RoapMessage.h"
+#include "RoapLog.h"
+#include "RoapObserver.h"
+#include "DrmRiContext.h"
+#include "RoapStorageClient.h"
+
+using namespace Roap;
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CRoapEngBase::~CRoapEngBase()
+// ---------------------------------------------------------
+//
+EXPORT_C CRoapEngBase::~CRoapEngBase()
+    {
+    Cancel();
+    delete iTrigger;
+    delete iRequest;
+    delete iResponse;
+    delete iRoapResp;
+    delete iHttpHandler;
+    delete iStoredRiContext;
+    iReturnedROs.ResetAndDestroy();
+    delete iDomainRightsResp;
+    delete iRiAlias;
+    }
+
+// ---------------------------------------------------------
+// CRoapEngBase::CRoapEngBase()
+// ---------------------------------------------------------
+//
+CRoapEngBase::CRoapEngBase( ): CActive( CActive::EPriorityStandard ),
+    iPreferredIap(0)
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------
+// CRoapEngBase::ConstructL()
+// ---------------------------------------------------------
+//
+void CRoapEngBase::ConstructL()
+    {
+    LOGLIT( "CRoapEngBase::ConstructL" )
+
+    iCompleted = EFalse;
+    iState = EInit;
+    iTransTrackConf = EFalse;
+    iAllowedToContactRi = EFalse;
+    iUseRiContextUrl = EFalse;
+    iImplicitJoinDomain = EFalse;
+    iReRegistered = EFalse;
+    iRiAlias = NULL;
+    }
+
+
+// ---------------------------------------------------------
+// CRoapEngBase::SetTriggerL()
+// ---------------------------------------------------------
+//
+EXPORT_C void CRoapEngBase::SetTriggerL( const TDesC8& aXmlTrigger,
+    const CAiwGenericParamList* /*aParamList*/,
+    TTriggerType& aType,
+    TRiContextStatus& aContextStatus,
+    TDomainOperation& aDomainOperation,
+    RPointerArray<HBufC8>& aContentIdList )
+    {
+    LOGLIT( "CRoapEngBase::SetTriggerL" )
+
+#ifndef __DRM_OMA2
+    User::Leave(KErrNotSupported);
+#endif
+
+    __ASSERT_ALWAYS( iState == EInit || iState == EReady, \
+        User::Invariant() );
+    TBool registered = EFalse;
+    TBool isValidDomainGeneration = ETrue;
+    TInt error = KErrNone;
+    HBufC8* temp = NULL;
+    aDomainOperation = ENotDomainOperation;
+    iProgressInBytes = KRoapProgressDelta;
+
+    delete iTrigger;
+    iTrigger = NULL;
+
+    iTrigger = ParseTriggerL( aXmlTrigger );
+
+    if ( !iTrigger || !iTrigger->ValidTrigger() )
+        {
+        LOGLIT( "Trigger parsing failed!" )
+        User::Leave( KErrRoapGeneral );
+        }
+
+    aType = iTrigger->iTriggerType;
+
+    if ( iTrigger->iTriggerType == ERegistrationTrigger )
+        {
+        iReqMessage = EDeviceHello;
+        if ( iAllowedToContactRi )
+            {
+            aContextStatus = EInvalidContextNoConf;
+            }
+        else
+            {
+            aContextStatus = EInvalidContext;
+            }
+        iState = EReady;
+        return;
+        }
+    else if ( iTrigger->iTriggerType == ERoAcquisitionTrigger )
+        {
+        iReqMessage = EROAcquisition;
+        }
+    else if ( iTrigger->iTriggerType == EJoinDomainTrigger )
+        {
+        iReqMessage = EJoinDomain;
+        }
+    else if ( iTrigger->iTriggerType == ELeaveDomainTrigger )
+        {
+        iReqMessage = ELeaveDomain;
+        }
+#ifdef RD_DRM_METERING
+    else if ( iTrigger->iTriggerType == EMeteringReportTrigger )
+        {
+        iReqMessage = EMeteringRequest;
+        }
+#endif
+    else
+        {
+        LOG2(_L ("Unsupported Trigger type: %d"), iTrigger->iTriggerType)
+        User::Leave( KErrRoapUnsupported );
+        }
+
+    GetRIContextL( registered, iTrigger->iRiId );
+
+    if ( !registered )
+        {
+        LOGLIT( "No valid RI Context -> Device Hello" )
+        iReqMessage = EDeviceHello;
+        aContextStatus = EInvalidContext;
+        }
+    else
+        {
+        aContextStatus = EValidContext;
+        }
+
+    if ( iTrigger->iTriggerType == EJoinDomainTrigger )
+        {
+        GetDomainContextL( registered, isValidDomainGeneration, *iTrigger->iDomainId );
+        registered ? aDomainOperation = EKeyUpgradeOperation : aDomainOperation = EJoinDomainOperation;
+        }
+
+    for ( TInt i = 0; i < iTrigger->iContentIdList.Count(); i++ )
+        {
+        temp = iTrigger->iContentIdList[i]->Alloc();
+        if ( temp )
+            {
+            error = aContentIdList.Append( temp );
+            if ( error )
+                {
+                aContentIdList.ResetAndDestroy();
+                delete temp;
+                User::Leave( error );
+                }
+            }
+        else
+            {
+            aContentIdList.ResetAndDestroy();
+            User::Leave( KErrNoMemory );
+            }
+        }
+
+    if ( iTrigger->iDomainId &&  iTrigger->iTriggerType == ERoAcquisitionTrigger )
+        {
+        GetDomainContextL( registered, isValidDomainGeneration, *iTrigger->iDomainId );
+        if ( !registered || !isValidDomainGeneration )
+            {
+            // We don't have a valid Domain key for the RO -> JoinDomain
+            LOGLIT( "Perform implicit Join Domain" )
+            iImplicitJoinDomain = ETrue;
+            if ( aContextStatus == EValidContext )
+                {
+                iReqMessage = EJoinDomain;
+                }
+            }
+        }
+    iState = EReady;
+
+    if ( aContextStatus == EInvalidContext && iAllowedToContactRi )
+        {
+        aContextStatus = EInvalidContextNoConf;
+        }
+    else if ( aContextStatus == EInvalidContext )
+        {
+        RRoapStorageClient client;
+        User::LeaveIfError( client.Connect() );
+        CleanupClosePushL( client );
+        // check that SilentRightsUrl is on the white list
+        // URL is searched from pre-configured white list
+        TBool fromPreConfiguredWhiteList( ETrue );
+        if ( client.WhiteListURLExistsL( *iTrigger->iRoapUrl, fromPreConfiguredWhiteList ) )
+            {
+            aContextStatus = EInvalidContextNoConf;
+            }
+        CleanupStack::PopAndDestroy( &client );
+        }
+
+    if ( iTrigger->iRiAlias )
+        {
+        iRiAlias = iTrigger->iRiAlias->AllocL();
+        }
+
+    }
+
+
+// ---------------------------------------------------------
+// CRoapEngBase::AcceptL()
+// ---------------------------------------------------------
+//
+EXPORT_C void CRoapEngBase::AcceptL( MRoapObserver* aObserver, TRequestStatus* aStatus )
+    {
+    LOGLIT( "CRoapEngBase::Accept" )
+    PERFORMANCE_LOGLIT( "ROAP started" )
+
+    if ( iState != EReady )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    iObserver = aObserver;
+    iParentStatus = aStatus;
+    *iParentStatus = KRequestPending;
+    iResult = KErrNone;
+
+    if ( iObserver )
+        {
+        iObserver->RoapProgressInfoL( iProgressInBytes );
+        }
+    iProgressInBytes = Min( iProgressInBytes + KRoapProgressDelta, KRoapProgressMax );
+
+    Continue( ECreateConn );
+    }
+
+
+// ---------------------------------------------------------
+// CRoapEngBase::Reject()
+// ---------------------------------------------------------
+//
+EXPORT_C void CRoapEngBase::Reject()
+    {
+    LOGLIT( "CRoapEngBase::Reject" )
+
+    Cancel();
+
+    // Cleanup first, so that
+    DoCleanup();
+
+    delete iTrigger;
+    iTrigger = NULL;
+    delete iRequest;
+    iRequest = NULL;
+    delete iResponse;
+    iResponse = NULL;
+    delete iRoapResp;
+    iRoapResp = NULL;
+    delete iHttpHandler;
+    iHttpHandler = NULL;
+    delete iStoredRiContext;
+    iStoredRiContext = NULL;
+    delete iDomainRightsResp;
+    iDomainRightsResp = NULL;
+
+    iImplicitJoinDomain = EFalse;
+
+    iState = EInit;
+    }
+
+
+// ---------------------------------------------------------
+// CRoapEngBase::DoCleanup()
+// ---------------------------------------------------------
+//
+EXPORT_C TInt CRoapEngBase::DoCleanup()
+    {
+    LOGLIT( "CRoapEngBase::DoCleanup" )
+
+    RDRMRightsClient rightsClient;
+    HBufC8* contentUri = NULL;
+    TInt error = KErrNone;
+
+    if ( iTrigger && iTrigger->iTriggerType == ERoAcquisitionTrigger )
+        {
+        if ( iCompleted )
+            {
+            error = rightsClient.Connect();
+            if ( !error)
+                {
+                for ( TInt i = 0; i < iReturnedROs.Count(); i++ )
+                    {
+                    error = iReturnedROs[i]->GetContentURI( contentUri );
+                    if ( !error )
+                        {
+                        // rightsClient.DeleteDbEntry( *contentUri, iReturnedROs[i]->GetLocalID() )
+                        }
+                    }
+                rightsClient.Close();
+                }
+            iReturnedROs.ResetAndDestroy();
+            }
+        }
+    if ( iRoapResp )
+        {
+        if ( iRoapResp->DcfFileName().Length() )
+            {
+            RFs fs;
+            error = fs.Connect();
+            if ( error != KErrNone )
+                {
+                fs.Delete( iRoapResp->DcfFileName() );
+                }
+            fs.Close();
+            }
+        }
+    return error;
+    }
+
+
+// ---------------------------------------------------------
+// CRoapEngBase::HandleRoReponseL()
+// ---------------------------------------------------------
+//
+EXPORT_C void CRoapEngBase::HandleRoReponseL( const TDesC8& aResponse, RPointerArray<CDRMRights>& aParsedRights )
+    {
+    LOGLIT( "CRoapEngBase::HandleRoReponseL" )
+
+    __ASSERT_ALWAYS( iState == EInit, User::Invariant() );
+
+    aParsedRights.ResetAndDestroy();
+
+    TRAPD( error, HandleRightsResponsePduL( aResponse, ETrue ) );
+    if ( error == KErrRoapNotRegistered )
+        {
+        // Needs to register
+        }
+    else if ( iReturnedROs.Count() )
+        {
+        for ( TInt i = 0; i < iReturnedROs.Count(); i++ )
+            {
+            CDRMRights* temp = CDRMRights::NewL();
+            CleanupStack::PushL( temp );
+            *temp = *iReturnedROs[i];
+            aParsedRights.AppendL( temp );
+            CleanupStack::Pop( temp );
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CRoapEngBase::GetTrigger()
+// ---------------------------------------------------------
+//
+EXPORT_C const CRoapTrigger& CRoapEngBase::Trigger() const
+    {
+    return *iTrigger;
+    }
+
+// ---------------------------------------------------------
+// CRoapEngBase::DoCancel()
+// ---------------------------------------------------------
+//
+void CRoapEngBase::DoCancel()
+    {
+    LOGLIT( "CRoapEngBase::DoCancel" )
+
+    if (iHttpHandler)
+        {
+        iHttpHandler->Cancel();
+        }
+    iResult = KErrCancel;
+    CompleteRequest();
+    }
+
+
+// ---------------------------------------------------------
+// CRoapEngBase::RunL()
+// ---------------------------------------------------------
+//
+void CRoapEngBase::RunL()
+    {
+    LOGLIT( "CRoapEngBase::RunL" )
+
+    switch ( iState )
+        {
+        case ECreateConn:
+                {
+                CreateConnectionL();
+                break;
+                }
+        case EStartTrans:
+                {
+                StartTransactionL();
+                break;
+                }
+        case ERespReceived:
+                {
+                HandleResponseL();
+                break;
+                }
+        case EComplete:
+                {
+                CompleteL();
+                break;
+                }
+        default:
+                {
+                break;
+                }
+        }
+    }
+
+// ---------------------------------------------------------
+// CRoapEngBase::RunError()
+// ---------------------------------------------------------
+//
+TInt CRoapEngBase::RunError( TInt aError )
+    {
+    LOG2( _L ( "CRoapEngBase::RunError: %d" ), aError )
+    PERFORMANCE_LOG2( _L ( "Error occured: %d" ), aError  )
+
+    iResult = aError;
+
+    if ( aError == KErrTimedOut || aError == KErrDisconnected )
+        {
+        // Retry in time out and disconnected cases
+        iResult = KErrRoapServer;
+        }
+
+    if ( iReqMessage == ERegistration )
+        {
+        // in case of retry send DeviceHello (not RegRequest)
+        iReqMessage = EDeviceHello;
+        }
+
+    if ( iRoapResp )
+        {
+        if ( iRoapResp->DcfFileName().Length() )
+            {
+            RFs fs;
+            if ( fs.Connect() )
+                {
+                fs.Delete( iRoapResp->DcfFileName() );
+                fs.Close();
+                }
+            }
+        }
+
+    iCompleted = ETrue;
+    Continue( EComplete );
+
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CRoapEngBase::CreateConnectionL()
+// ---------------------------------------------------------
+//
+void CRoapEngBase::CreateConnectionL()
+    {
+    LOGLIT( "CRoapEngBase::CreateConnectionL" )
+
+    __ASSERT_ALWAYS( iState == ECreateConn, User::Invariant() );
+
+    if ( iObserver )
+        {
+        iObserver->RoapProgressInfoL( iProgressInBytes );
+        }
+    iProgressInBytes = Min( iProgressInBytes + KRoapProgressDelta, KRoapProgressMax );
+
+    iHttpHandler = CRoapHttpHandler::NewL();
+    iHttpHandler->SetObserver( iObserver );
+    iHttpHandler->SetPreferredIap( iPreferredIap );
+    iHttpHandler->CreateConnectionL( &iStatus );
+
+    iState = EStartTrans;
+    SetActive();
+    }
+
+// ---------------------------------------------------------
+// CRoapEngBase::StartTransactionL()
+// ---------------------------------------------------------
+//
+void CRoapEngBase::StartTransactionL()
+    {
+    LOGLIT( "CRoapEngBase::StartTransactionL" )
+
+    User::LeaveIfError( iStatus.Int() );
+
+    __ASSERT_ALWAYS( iState == EStartTrans, User::Invariant() );
+    __ASSERT_ALWAYS( iHttpHandler, User::Invariant() );
+    __ASSERT_ALWAYS( iTrigger, User::Invariant() );
+    __ASSERT_ALWAYS( !iRequest, User::Invariant() );
+
+    if ( iObserver )
+        {
+        iObserver->RoapProgressInfoL( iProgressInBytes );
+        }
+    iProgressInBytes = Min( iProgressInBytes + KRoapProgressDelta, KRoapProgressMax );
+
+    HBufC8* reqBody = NULL;
+    HBufC8* signedReqBody = NULL;
+    HBufC8* url = NULL;
+
+    CreateReqMessageL(); // creates iRequest
+
+    reqBody = iRequest->MessageAsXmlL();
+
+    CleanupStack::PushL( reqBody );
+
+    if ( iUseRiContextUrl )
+        {
+        if ( iStoredRiContext )
+            {
+            url = HBufC8::NewMaxLC( iStoredRiContext->RightsIssuerURL().Length() );
+            url->Des().Copy( iStoredRiContext->RightsIssuerURL() );
+            }
+        else
+            {
+            User::Leave( KErrRoapNotRegistered );
+            }
+        }
+    else
+        {
+        url = HBufC8::NewMaxLC( iTrigger->iRoapUrl->Length() );
+        url->Des().Copy( *iTrigger->iRoapUrl );
+        }
+
+    signedReqBody = SignMessageL( *reqBody );
+
+    CleanupStack::PushL( signedReqBody );
+
+    LOGHEX(signedReqBody->Ptr(), signedReqBody->Length())
+
+    iRoapResp = CRoapResponse::NewL();
+
+    iHttpHandler->SetUrlL( *url );
+
+    if ( iReqMessage == EROAcquisition )
+        {
+        if ( iObserver )
+            {
+            iObserver->RoapProgressInfoL( iProgressInBytes );
+            }
+        iProgressInBytes = Min( iProgressInBytes + KRoapProgressDelta, KRoapProgressMax );
+        }
+
+    iHttpHandler->DoTransactionL(*iRoapResp, *signedReqBody, &iStatus );
+
+    CleanupStack::PopAndDestroy( signedReqBody );
+    CleanupStack::PopAndDestroy( url );
+    CleanupStack::PopAndDestroy( reqBody );
+
+    iState = ERespReceived;
+    SetActive();
+    }
+
+
+// ---------------------------------------------------------
+// CRoapEngBase::HandleResponseL()
+// ---------------------------------------------------------
+//
+void CRoapEngBase::HandleResponseL()
+    {
+    LOGLIT( "CRoapEngBase::HandleResponseL" )
+
+    __ASSERT_ALWAYS( iState == ERespReceived, User::Invariant() );
+    __ASSERT_ALWAYS( iRoapResp, User::Invariant() );
+
+    User::LeaveIfError( iStatus.Int() );
+
+    LOG(iRoapResp->DataType().Des())
+    LOGHEX(iRoapResp->ProtocolUnit().Ptr(), iRoapResp->ProtocolUnit().Length())
+
+    TInt status = KErrNone;
+
+    if ( iRoapResp->DataType() == TDataType( KRoapPDUType  ) )
+        {
+        LOGLIT( "ROAP PDU datatype received." )
+
+            if ( iObserver )
+                {
+                iObserver->RoapProgressInfoL( iProgressInBytes );
+                }
+        iProgressInBytes = Min( iProgressInBytes + KRoapProgressDelta, KRoapProgressMax );
+
+        HandleRoapResponseL( iRoapResp->ProtocolUnit() );
+        }
+    else if ( iRoapResp->DataType() == TDataType( KMultipartRelatedType ) )
+        {
+        LOGLIT( "Multipart related datatype received." )
+            HandleMultipartL();
+        }
+    else
+        {
+        LOGLIT( "Error: Unsupported response datatype." )
+
+            User::Leave( KErrRoapUnsupported );
+        }
+
+    status = MapStatusL();
+
+    iUseRiContextUrl = EFalse;
+
+    if ( status == KErrRoapNotRegistered )
+        {
+        // Not registered or DRM Time is incorrect
+        // -> Check user consent and initiate the registration protocol
+
+        if ( iReRegistered )
+            {
+            LOGLIT( "DRM Time update or re-registering is already performed once!" )
+                User::Leave( KErrRoapServer );
+            }
+
+        if ( iObserver && !iAllowedToContactRi )
+            {
+            if ( iObserver->ContactRiConfL() )
+                {
+                iReqMessage = EDeviceHello;
+                iCompleted = EFalse;
+                iAllowedToContactRi = ETrue;
+                iUseRiContextUrl = EFalse;
+                }
+            else
+                {
+                User::Leave( status );
+                }
+            }
+        else
+            {
+            iReqMessage = EDeviceHello;
+            iCompleted = EFalse;
+            }
+        iReRegistered = ETrue;
+        }
+    else
+        {
+        SetProtocolL();
+        }
+
+    // delete previous request and response
+    delete iRequest;
+    iRequest = NULL;
+    delete iRoapResp;
+    iRoapResp = NULL;
+
+    if ( !iCompleted )
+        {
+        // Send next request
+        Continue( EStartTrans );
+        }
+    else
+        {
+        // Complete request
+        Continue( EComplete );
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CRoapEngBase::SetProtocol()
+// ---------------------------------------------------------
+//
+void CRoapEngBase::SetProtocolL()
+    {
+    LOG2( _L ( "CRoapEngBase::SetProtocol: %d" ), iReqMessage )
+
+        switch ( iReqMessage )
+            {
+            case EDeviceHello:
+                    {
+                    iReqMessage = ERegistration;
+                    iCompleted = EFalse;
+                    break;
+                    }
+            case ERegistration:
+                    {
+                    if ( iTrigger->iTriggerType != ERegistrationTrigger )
+                        {
+                        if ( !iImplicitJoinDomain && iTrigger->iTriggerType == ERoAcquisitionTrigger )
+                            {
+                            iReqMessage = EROAcquisition;
+                            }
+                        else if ( iTrigger->iTriggerType == EJoinDomainTrigger )
+                            {
+                            iReqMessage = EJoinDomain;
+                            }
+                        else if ( iTrigger->iTriggerType == ELeaveDomainTrigger )
+                            {
+                            iReqMessage = ELeaveDomain;
+                            }
+#ifdef RD_DRM_METERING
+                        else if ( iTrigger->iTriggerType == EMeteringReportTrigger )
+                            {
+                            iReqMessage = EMeteringRequest;
+                            }
+#endif
+                        else if ( iImplicitJoinDomain && iTrigger->iTriggerType == ERoAcquisitionTrigger )
+                            {
+                            iReqMessage = EJoinDomain;
+                            }
+                        else
+                            {
+                            User::Leave( KErrRoapUnsupported );
+                            }
+                        iCompleted = EFalse;
+                        }
+                    else
+                        {
+                        iCompleted = ETrue;
+                        }
+                    break;
+                    }
+            case EROAcquisition:
+                    {
+                    if ( iImplicitJoinDomain && iTrigger->iTriggerType == ERoAcquisitionTrigger )
+                        {
+                        iReqMessage = EJoinDomain;
+                        iImplicitJoinDomain = EFalse;
+                        iCompleted = EFalse;
+                        }
+                    else
+                        {
+                        iCompleted = ETrue;
+                        }
+                    break;
+                    }
+            case EJoinDomain:
+                    {
+                    if ( iImplicitJoinDomain && iTrigger->iTriggerType == ERoAcquisitionTrigger )
+                        {
+                        iReqMessage = EROAcquisition;
+                        iImplicitJoinDomain = EFalse;
+                        iCompleted = EFalse;
+                        }
+                    else
+                        {
+                        iCompleted = ETrue;
+                        }
+                    break;
+                    }
+#ifdef RD_DRM_METERING
+            case EMeteringRequest:
+                    {
+                    if ( iTrigger->iTriggerType != EMeteringReportTrigger )
+                        {
+                        // PostUrl would be done here?
+                        iCompleted = EFalse;
+                        }
+                    else
+                        {
+                        iCompleted = ETrue;
+                        }
+                    break;
+                    }
+#endif
+            default:
+                    {
+                    iCompleted = ETrue;
+                    break;
+                    }
+            }
+    if (iCompleted)
+        {
+        LOGLIT( "Completed" )
+        }
+    else
+        {
+        LOG2(_L ("Next protocol: %d"), iReqMessage)
+        }
+    }
+
+// ---------------------------------------------------------
+// CRoapEngBase::CompleteL()
+// ---------------------------------------------------------
+//
+void CRoapEngBase::CompleteL()
+    {
+    LOGLIT( "CRoapEngBase::CompleteL" )
+
+        if ( iCompleted )
+            {
+            CompleteRequest();
+            }
+    }
+
+
+// ---------------------------------------------------------
+// CRoapEngBase::CompleteRequest()
+// ---------------------------------------------------------
+//
+void CRoapEngBase::CompleteRequest()
+    {
+    LOGLIT( "CRoapEngBase::CompleteRequest" )
+    PERFORMANCE_LOGLIT( "ROAP completed" )
+
+    // Complete request
+    iState = EReady;
+
+    // Delete allocated member variables also here since AcceptL
+    // might be called in retry case without deleting the CRoapEngBase instance
+    delete iRequest;
+    iRequest = NULL;
+    delete iRoapResp;
+    iRoapResp = NULL;
+    delete iResponse;
+    iResponse = NULL;
+    delete iHttpHandler;
+    iHttpHandler = NULL;
+    iReturnedROs.ResetAndDestroy();
+    delete iDomainRightsResp;
+    iDomainRightsResp = NULL;
+    iImplicitJoinDomain = EFalse;
+
+    // Notify caller
+    User::RequestComplete( iParentStatus, iResult );
+    iParentStatus = NULL;
+    }
+
+
+// ---------------------------------------------------------
+// CRoapEngBase::Continue
+// ---------------------------------------------------------
+//
+void CRoapEngBase::Continue( TRoapState aNextState )
+    {
+    iState = aNextState;
+    TRequestStatus* ownStatus = &iStatus;
+    *ownStatus = KRequestPending;
+    SetActive();
+    User::RequestComplete( ownStatus, KErrNone );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RoapHttpHandler.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,937 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Http interface for RoapHandler
+*
+*/
+
+
+// INCLUDE FILES
+#include <stringpool.h>
+#include <http/thttphdrval.h>
+#include <HttpFilterCommonStringsExt.h>
+
+#include "RoapHttpHandler.h"
+#include "RoapObserver.h"
+#include "RoapDef.h"
+#include "RoapLog.h"
+
+//#include <CookieFilterInterface.h>
+//#include <uaproffilter_interface.h>
+//#include <HttpFilterProxyInterface.h>
+#include <httpfilteriopinterface.h>
+
+
+using namespace Roap;
+
+// ================= CONSTANTS ======================
+
+// The time out value in HTTP, 30 sec
+LOCAL_D const TInt KRoapTimeoutValue = 60000000;
+
+_LIT8( KTestUserName, "iopvf" );
+_LIT8( KTestPassword, "r72005" );
+/*
+_LIT8( KTestUserName, "moria" );
+_LIT8( KTestPassword, "mellon" );
+*/
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::NewL()
+// ---------------------------------------------------------
+//
+CRoapHttpHandler* CRoapHttpHandler::NewL()
+    {
+    CRoapHttpHandler* handler = new ( ELeave ) CRoapHttpHandler();
+    CleanupStack::PushL( handler );
+    handler->ConstructL();
+    CleanupStack::Pop( handler );
+    return handler;
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::~CHttpLoader()
+// ---------------------------------------------------------
+//
+CRoapHttpHandler::~CRoapHttpHandler()
+    {
+    Cancel();
+    iSession.Close(); // iSession also closes iTransaction
+    delete iRequestBody;
+    delete iUri;
+    delete iBoundary;
+    delete iConnection;
+    delete iTimeout;
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::ConstructL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::ConstructL()
+    {
+    LOG( _L("CRoapHttpHandler::ConstructL") );
+
+    iConnection = CRoapConnection::NewL();
+    iTimeout = CPeriodic::NewL( CActive::EPriorityUserInput );
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::CreateConnectionL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::CreateConnectionL( TRequestStatus* aStatus )
+    {
+    LOG( _L("CRoapHttpHandler::CreateConnectionL") );
+
+    __ASSERT_ALWAYS( iState == EInit || iState == EReady, \
+                                            User::Invariant() );
+    __ASSERT_ALWAYS( iConnection, User::Invariant() );
+
+    TUint32 ap;
+    if ( iConnection->IsConnected( ap ) )
+        {
+        // Already connected
+        User::RequestComplete( iParentStatus, KErrAlreadyExists );
+        iParentStatus = NULL;
+        return;
+        }
+
+    if ( iObserver && !iObserver->ConnectionConfL() )
+        {
+        User::Leave( KErrCancel );
+        }
+
+    iParentStatus = aStatus;
+    *iParentStatus = KRequestPending;
+    iState = EStart;
+    TRequestStatus* ownStatus = &iStatus;
+    *ownStatus = KRequestPending;
+    SetActive();
+    User::RequestComplete( ownStatus, KErrNone );
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::IsConnectedL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::SetObserver( MRoapObserver* aRoapObserver )
+    {
+    LOG( _L("CRoapHttpHandler::SetObserver") );
+
+    iObserver = aRoapObserver;
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::CreateConnectionL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::DoTransactionL(
+            CRoapResponse& aResponse,
+            TDesC8& aReqBody,
+            TRequestStatus* aStatus )
+    {
+    LOG( _L("CRoapHttpHandler::DoTransactionL1") );
+
+    __ASSERT_ALWAYS( iState == EReady, User::Invariant() );
+    __ASSERT_ALWAYS( !iRequestBody, User::Invariant() );
+
+    iRequestBody = aReqBody.AllocL();
+    iResponse = &aResponse;
+
+    iParentStatus = aStatus;
+    *iParentStatus = KRequestPending;
+    iState = ERequest;
+    TRequestStatus* ownStatus = &iStatus;
+    *ownStatus = KRequestPending;
+    SetActive();
+    User::RequestComplete( ownStatus, KErrNone );
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::SetUrlL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::SetUrlL( TDesC8& aUrl )
+    {
+    LOG( _L("CRoapHttpHandler::SetUrlL") );
+
+    delete iUri;
+    iUri = NULL;
+    iUri = aUrl.AllocL();
+    }
+
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::DoCancel()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::DoCancel()
+    {
+    LOG( _L("CRoapHttpHandler::DoCancel") );
+
+    switch ( iState )
+        {
+        case EStart:
+        case EConnect:
+            {
+            iConnection->Cancel();
+            break;
+            }
+        case EComplete:
+            {
+            iTransaction.Close();
+            SelfComplete( iError );
+            break;
+            }
+        default:
+            {
+            break;
+            }
+        }
+    iError = KErrCancel;
+    Complete();
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::RunL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::RunL()
+    {
+    LOG( _L("CRoapHttpHandler::RunL") );
+
+    User::LeaveIfError( iStatus.Int() );
+
+    switch ( iState )
+        {
+        case EStart:
+            {
+            ConnectL();
+            break;
+            }
+        case EConnect:
+            {
+            CreateSessionL();
+            break;
+            }
+        case ERequest:
+            {
+            DoTransactionL();
+            break;
+            }
+        case EComplete:
+            {
+            TUint32 ap;
+            iState = iConnection->IsConnected( ap ) ? EReady : EInit;
+            Complete();
+            break;
+            }
+        case EInit:
+        default:
+            {
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::RunError()
+// ---------------------------------------------------------
+//
+TInt CRoapHttpHandler::RunError( TInt aError )
+    {
+    LOG( _L("CRoapHttpHandler::RunError") );
+
+    iError = aError;
+    TUint32 ap;
+    iState = iConnection->IsConnected( ap ) ? EReady : EInit;
+    Complete();
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::ConnectL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::ConnectL()
+    {
+    LOG( _L("CRoapHttpHandler::ConnectL") );
+
+    __ASSERT_ALWAYS( iState == EStart, User::Invariant() );
+
+    iConnection->ConnectL ( iPreferredIap, &iStatus );
+    iState = EConnect;
+    iError = KErrNone;
+    SetActive();
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::SetPreferredIap()
+// ---------------------------------------------------------
+void CRoapHttpHandler::SetPreferredIap( TUint32 aPreferredIap )
+    {
+    LOG( _L("CRoapHttpHandler::SetPreferredIap") );
+
+    iPreferredIap = aPreferredIap;
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::CreateSessionL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::CreateSessionL()
+    {
+    LOG( _L("CRoapHttpHandler::CreateSessionL") );
+
+    __ASSERT_ALWAYS( iState == EConnect, User::Invariant() );
+
+    TUint32 ap;
+
+    if ( !iConnection->IsConnected( ap ) )
+        {
+        User::Leave( KErrRoapGeneral );
+        }
+
+    iSession.Close();
+    iSession.OpenL();
+
+    RStringPool strPool = iSession.StringPool();
+
+    // Remove first session properties just in case.
+    RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
+
+    // Clear RConnection and Socket Server instances
+    connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable()));
+    connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable()));
+
+    THTTPHdrVal proxyUsage(strPool.StringF(HTTP::EUseProxy,RHTTPSession::GetTable()));
+    connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()));
+    connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()));
+
+    connInfo.SetPropertyL
+        (
+        strPool.StringF( HTTP::EHttpSocketServ, RHTTPSession::GetTable() ),
+        THTTPHdrVal( iConnection->SocketServ().Handle() )
+        );
+
+    connInfo.SetPropertyL
+        (
+        strPool.StringF( HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ),
+        THTTPHdrVal( REINTERPRET_CAST( TInt, &iConnection->Conn() ) )
+        );
+
+    InstallHttpFiltersL();
+
+    // Complete requests
+    iState = EReady;
+    SelfComplete( iError );
+    // Notify CRoapEngBase
+    Complete();
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::InstallHttpFilters()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::InstallHttpFiltersL()
+    {
+    LOG( _L("CRoapHttpHandler::InstallHttpFiltersL") );
+
+ // CHttpUAProfFilterInterface::InstallFilterL( iSession );
+ // CHttpCookieFilter::InstallFilterL( iSession );
+    InstallAuthenticationL( iSession );
+ // CHttpFilterProxyInterface::InstallFilterL( iSession );
+
+    // This filter adds port number to HTTP header Host
+    // on HTTP(S) CONNECT via proxy.
+    // Note: the filter is for interoperability, since some WAP GWs
+    // do not work with Host header not having port number.
+    CHttpFilterIopInterface::InstallFilterL( iSession, iopOptionHostHeader );
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::DoTransactionL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::DoTransactionL()
+    {
+    LOG( _L("CRoapHttpHandler::DoTransactionL2") );
+
+    __ASSERT_ALWAYS( iState == ERequest, User::Invariant() );
+
+    TUriParser8 uri;
+    User::LeaveIfError( uri.Parse( *iUri ) );
+    RStringF POST;
+    POST = iSession.StringPool().StringF( HTTP::EPOST, RHTTPSession::GetTable() );
+    iTransaction = iSession.OpenTransactionL( uri, *this, POST );
+
+    // Set required headers
+    RHTTPHeaders hdrs = iTransaction.Request().GetHeaderCollection();
+
+    SetHeaderL(hdrs, HTTP::EAccept, _L8("*/*") ); // for testing
+    SetHeaderL(hdrs, HTTP::EAccept, KRoapPDUType );
+    SetHeaderL(hdrs, HTTP::EAccept, KMultipartRelatedType );
+
+    SetHeaderL(hdrs, HTTP::EContentType, KRoapPDUType);
+
+    iBytesReceived = 0;
+    // Add request body
+    MHTTPDataSupplier* ds = this;
+    iTransaction.Request().SetBody(*ds);
+
+    iTransaction.SubmitL();
+
+    iState = EComplete;
+    iStatus = KRequestPending;
+    SetActive();
+
+    iTimeout->Cancel();
+    iTimeout->Start( KRoapTimeoutValue,
+                     KRoapTimeoutValue,
+                     TCallBack( StaticTimeOut,this ) );
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::SetHeaderL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue)
+    {
+    LOG( _L("CRoapHttpHandler::SetHeaderL") );
+
+    RStringF valStr = iSession.StringPool().OpenFStringL(aHdrValue);
+    THTTPHdrVal val(valStr);
+    aHeaders.SetFieldL(iSession.StringPool().StringF(aHdrField,RHTTPSession::GetTable()), val);
+    valStr.Close();
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::Complete()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::Complete()
+    {
+    LOG( _L("CRoapHttpHandler::Complete") );
+
+    delete iRequestBody;
+    iRequestBody = NULL;
+    delete iUri;
+    iUri = NULL;
+
+    if ( iTimeout )
+        {
+        iTimeout->Cancel();
+        }
+
+    User::RequestComplete( iParentStatus, iError );
+    iParentStatus = NULL;
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::CRoapHttpHandler()
+// ---------------------------------------------------------
+//
+CRoapHttpHandler::CRoapHttpHandler(): CActive( CActive::EPriorityStandard )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::SelfComplete()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::SelfComplete( TInt& aResult )
+    {
+    LOG( _L("CRoapHttpHandler::SelfComplete") );
+
+    if ( iStatus == KRequestPending )
+        {
+        TRequestStatus* ownStatus = &iStatus;
+        User::RequestComplete( ownStatus, aResult );
+        }
+    else
+        {
+        if ( aResult != KErrNone )
+            {
+            iStatus = aResult;
+            }
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::MHFRunL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::MHFRunL( RHTTPTransaction  /* aTransaction */,
+                                const THTTPEvent& aEvent )
+    {
+    LOG( _L("CRoapHttpHandler::MHFRunL") );
+
+    // Restart timer
+    iTimeout->Cancel();
+    iTimeout->Start( KRoapTimeoutValue,
+                     KRoapTimeoutValue,
+                     TCallBack( StaticTimeOut,this ) );
+
+    switch ( aEvent.iStatus )
+        {
+        case THTTPEvent::EGotResponseHeaders:
+            {
+            LOG( _L("Got Response Headers!") );
+
+            HandleResponseHeadersL( iTransaction.Response() );
+            break;
+            }
+
+        case THTTPEvent::EGotResponseBodyData:
+            {
+            LOG( _L("Got Response Body Data!") );
+
+            TInt ret( KErrNone );
+            MHTTPDataSupplier* body = iTransaction.Response().Body();
+            TPtrC8 ptr;
+            body->GetNextDataPart( ptr );
+
+            iBytesReceived += ptr.Length();
+            if ( iResponse->iDataType == TDataType( KMultipartRelatedType ) )
+                {
+                ret = AppendMultipartData( ptr );
+                }
+            else
+                {
+                ret = AppendPduData( ptr );
+                }
+
+            if ( iObserver && iReportBytes )
+                {
+                iObserver->RoapProgressInfoL( KRoapProgressMax + iBytesReceived );
+                }
+
+            body->ReleaseData();
+            User::LeaveIfError( ret );
+            break;
+            }
+
+        case THTTPEvent::EFailed:
+            {
+            LOG( _L("HTTP Event Failed!") );
+            if ( iResponse->iDataType == TDataType( KMultipartRelatedType ) )
+                {
+                }
+            if ( iError == KErrNone )
+                {
+                iError = KErrRoapGeneral;
+                }
+            iTransaction.Close();
+            SelfComplete( iError );
+            break;
+            }
+
+        case THTTPEvent::ESucceeded:
+            {
+            LOG( _L("HTTP Event Succeeded!") );
+
+            if ( iResponse->iDataType == TDataType( KMultipartRelatedType ) )
+                {
+                }
+            iTransaction.Close();
+            SelfComplete( iError );
+            break;
+            }
+
+        case THTTPEvent::ERedirectRequiresConfirmation:
+            {
+            LOG( _L("HTTP event ERedirectRequiresConfirmation received") );
+            iTransaction.SubmitL();
+            }
+
+        default:
+            {
+            LOG( _L("Unknown HTTP event recieved") );
+            if ( aEvent.iStatus == KErrHttpRedirectUseProxy )
+                {
+                }
+            else
+                {
+                if (aEvent.iStatus < 0)
+                    {
+                     LOG( _L("An Error Occured during HTTP transaction!") );
+                    }
+                // Handle errors in MHFRunError.
+                User::LeaveIfError( aEvent.iStatus );
+                }
+            break;
+            }
+        }
+
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::MHFRunError()
+// ---------------------------------------------------------
+//
+TInt CRoapHttpHandler::MHFRunError (
+        TInt aError,
+        RHTTPTransaction /* aTransaction */,
+        const THTTPEvent& /* aEvent */
+        )
+    {
+    LOG( _L("CRoapHttpHandler::MHFRunError") );
+
+    iTransaction.Close();
+    iError = aError;
+    SelfComplete( iError );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::HandleResponseHeadersL()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::HandleResponseHeadersL( RHTTPResponse aHttpResponse )
+    {
+    LOG( _L("CRoapHttpHandler::HandleResponseHeadersL ->") );
+
+    RHTTPHeaders headers = aHttpResponse.GetHeaderCollection();
+
+    TInt httpCode = aHttpResponse.StatusCode();
+    TBool status;
+
+    status = CheckHttpCode( httpCode );
+
+    if ( status )
+        {
+        RStringF contentTypeStr;
+        RStringF boundaryStr;
+        THTTPHdrVal contentTypeVal;
+        THTTPHdrVal boundaryVal;
+        TPtrC8 ptrContentType(KNullDesC8);
+        RStringPool srtPool;
+        srtPool = iSession.StringPool();
+
+        contentTypeStr = srtPool.StringF( HTTP::EContentType, RHTTPSession::GetTable() );
+
+        User::LeaveIfError( headers.GetField( contentTypeStr, 0, contentTypeVal ) );
+
+        if ( contentTypeVal.Type() == THTTPHdrVal::KStrFVal )
+            {
+            iResponse->iDataType = TDataType( contentTypeVal.StrF().DesC() );
+            }
+
+        if ( iResponse->iDataType == TDataType( KMultipartRelatedType ) )
+            {
+            TPath tempPath;
+            TFileName fileName;
+            TInt maxSize( 0 );
+
+            if ( iObserver )
+                {
+                iObserver->ContentDownloadInfoL( tempPath, fileName, maxSize );
+                }
+
+            boundaryStr = srtPool.StringF( HttpFilterCommonStringsExt::EBoundary,
+                                           HttpFilterCommonStringsExt::GetTable() );
+
+            if ( headers.GetParam( contentTypeStr, boundaryStr, boundaryVal ) == KErrNone )
+                {
+                // Boundary param found
+                delete iBoundary;
+                iBoundary = NULL;
+                iBoundary = boundaryVal.StrF().DesC().AllocL();
+                }
+            else
+                {
+                // a multipart without boundary param
+                LOG( _L("Error: multipart boundary missing") );
+                   User::Leave( KErrRoapGeneral );
+                }
+            iResponse->SetDcfPathL( tempPath );
+            iResponse->SetContentNameL( fileName );
+            iReportBytes = ETrue;
+
+            if ( iObserver )
+                {
+                iObserver->RoapProgressInfoL( KRoapProgressMax );
+                }
+            }
+        else
+            {
+            iReportBytes = EFalse;
+            }
+
+        LOG( iResponse->iDataType.Des() );
+
+        if ( iResponse->iDataType != TDataType( KRoapPDUType ) &&
+             iResponse->iDataType != TDataType( KMultipartRelatedType ) )
+            {
+            LOG( _L("Response type not supported") );
+            User::Leave( KErrRoapUnsupported );
+            }
+
+        if ( aHttpResponse.HasBody() &&
+             iResponse->iDataType == TDataType( KRoapPDUType ) )
+            {
+            // Allocate memory for Response PDU
+            TInt dataSize = aHttpResponse.Body()->OverallDataSize();
+            if ( dataSize >= 0 )
+                {
+                HBufC8* buf = HBufC8::NewL( dataSize );
+                delete iResponse->iPdu;
+                iResponse->iPdu = buf;
+                }
+            }
+        }
+    LOG( _L("-> CRoapHttpHandler::HandleResponseHeadersL") );
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::CheckHttpCode()
+// ---------------------------------------------------------
+//
+TBool CRoapHttpHandler::CheckHttpCode( TInt aHttpStatus )
+    {
+    RBuf logBuffer;
+    logBuffer.CleanupClosePushL();
+    logBuffer.CreateL( KMaxPath );
+    LOG( _L( "CRoapHttpHandler::CheckHttpCode") );
+    logBuffer.Append( _L( "HTTP status code: ") );
+    logBuffer.AppendNum( aHttpStatus );
+    LOG( logBuffer );
+    CleanupStack::PopAndDestroy( &logBuffer );
+
+    if ( HTTPStatus::IsInformational( aHttpStatus ) )
+        {
+        // 1xx
+        // Informational messages.
+        iError = KErrNone;
+        return EFalse;
+        }
+    else if ( aHttpStatus == HTTPStatus::EOk ||
+              aHttpStatus == HTTPStatus::ENonAuthoritativeInfo )
+        {
+        // 200 OK
+        // 203 Non-Authoritative Information
+        iError = KErrNone;
+        return ETrue;
+        }
+    else if ( HTTPStatus::IsSuccessful( aHttpStatus ) )
+        {
+        // 2xx
+        // Success codes without an usable body.
+        iError = KErrRoapServer;
+        return EFalse;
+        }
+    // 3xx codes handled by redirect filter.
+    else if ( aHttpStatus == HTTPStatus::EUnauthorized ||
+              aHttpStatus == HTTPStatus::EProxyAuthenticationRequired )
+        {
+        // 401 Unauthorized
+        // 407 Proxy authentication required
+        iError = KErrRoapGeneral;
+        return EFalse;
+        }
+    else if ( aHttpStatus == HTTPStatus::ENotFound ||
+              aHttpStatus == HTTPStatus::EGone )
+        {
+        // 404 Not found
+        // 410 Gone
+        iError = KErrRoapGeneral;
+        return EFalse;
+        }
+    else if ( HTTPStatus::IsClientError( aHttpStatus ) )
+        {
+        // 4xx
+        iError = KErrRoapDevice;
+        return EFalse;
+        }
+    else if ( aHttpStatus == HTTPStatus::EHTTPVersionNotSupported )
+        {
+        // 505 HTTP Version Not Supported
+        // Retry with lower HTTP version if we can.
+        iError = /*VersionRetryL() ? KErrNone :*/ KErrRoapServer;
+        return EFalse;
+        }
+    else if ( HTTPStatus::IsServerError( aHttpStatus ) )
+        {
+        // 5xx
+        // HTTP/1.0 servers may return other 5xx error codes for HTTP/1.1
+        // requests. So the same treatment  is given for all 5xx errors
+        // (version retry) - it's worth a try.
+        iError = /* VersionRetryL() ? KErrNone :*/ KErrRoapServer;
+        return EFalse;
+        }
+    else
+        {
+        // Everything else.
+        iError = KErrRoapGeneral;
+        }
+    return EFalse;
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::AppendData()
+// ---------------------------------------------------------
+//
+TInt CRoapHttpHandler::AppendPduData( const TDesC8& aDataChunk )
+    {
+    LOG( _L("CRoapHttpHandler::AppendData") );
+
+    TInt needed = iResponse->iPdu->Des().Length() + aDataChunk.Length();
+    if ( iResponse->iPdu->Des().MaxLength() < needed )
+        {
+        HBufC8* buf = iResponse->iPdu->ReAlloc( needed );
+        if ( buf )
+            {
+            iResponse->iPdu = buf;
+            }
+        else
+            {
+            return KErrNoMemory;
+            }
+        }
+    iResponse->iPdu->Des().Append( aDataChunk );
+    return KErrNone;
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::AppendMultipartData()
+// ---------------------------------------------------------
+//
+TInt CRoapHttpHandler::AppendMultipartData( const TDesC8& aDataChunk  )
+    {
+//    LOG( _L("CRoapHttpHandler::AppendMultipartData") );
+    TInt r = KErrNone;
+    TRAP( r, iResponse->AppendMultipartDataL( aDataChunk ) );
+    return r;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRoapHttpHandler::StaticTimeOut()
+// -----------------------------------------------------------------------------
+//
+TInt CRoapHttpHandler::StaticTimeOut( TAny* aPointer )
+    {
+    CRoapHttpHandler* itself = STATIC_CAST(CRoapHttpHandler*, aPointer);
+    if ( itself )
+        {
+        itself->TimeOut();
+        }
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRoapHttpHandler::TimeOut()
+// -----------------------------------------------------------------------------
+//
+void CRoapHttpHandler::TimeOut()
+    {
+    LOG( _L("CRoapHttpHandler::TimeOut") );
+
+    iTransaction.Close();
+    iError = KErrTimedOut;
+    SelfComplete( iError );
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::GetNextDataPart()
+// ---------------------------------------------------------
+//
+TBool CRoapHttpHandler::GetNextDataPart( TPtrC8& aDataPart )
+    {
+    LOG( _L("CRoapHttpHandler::GetNextDataPart") );
+
+    aDataPart.Set( iRequestBody->Des() );
+    return ETrue;
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::ReleaseData()
+// ---------------------------------------------------------
+//
+void CRoapHttpHandler::ReleaseData()
+    {
+    LOG( _L("CRoapHttpHandler::ReleaseData") );
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::OverallDataSize()
+// ---------------------------------------------------------
+//
+TInt CRoapHttpHandler::OverallDataSize()
+    {
+    LOG( _L("CRoapHttpHandler::OverallDataSize") );
+
+    return iRequestBody->Des().Size();
+    }
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::Reset()
+// ---------------------------------------------------------
+//
+TInt CRoapHttpHandler::Reset()
+    {
+    LOG( _L("CRoapHttpHandler::Reset") );
+
+    return KErrNone;
+    }
+
+
+// ---------------------------------------------------------
+// CRoapHttpHandler::GetCredentialsL()
+// ---------------------------------------------------------
+//
+TBool CRoapHttpHandler::GetCredentialsL
+        (
+        const TUriC8& /*aURI*/,
+        RString /*aRealm*/,
+        RStringF aAuthenticationType,
+        RString& aUsername,
+        RString& aPassword
+        )
+    {
+    LOG( _L( "CRoapHttpHandler::GetCredentialsL") );
+    TBuf8<64> b;
+
+    HBufC8* username = NULL;
+    HBufC8* password = NULL;
+
+    b.Copy(aAuthenticationType.DesC());
+    LOG(b);
+
+    username = KTestUserName().AllocLC();
+    aUsername = iSession.StringPool().OpenStringL( *username );
+    CleanupStack::PopAndDestroy( username );
+
+    password = KTestPassword().AllocLC();
+    aPassword = iSession.StringPool().OpenStringL( *password );
+    CleanupStack::PopAndDestroy( password );
+
+    return ETrue;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RoapMessage.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,245 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "RoapMessage.h"
+#include "Base64.h"
+
+using namespace Roap;
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+const TInt KIso8601TimeLength = 20;
+_LIT8(KIso8601TimeFormat, "%04d-%02d-%02dT%02d:%02d:%02dZ");
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+//?type ?function_name( ?arg_type, ?arg_type );
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRoapMessage::CRoapMessage
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRoapMessage::CRoapMessage()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapMessage::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRoapMessage::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapMessage::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRoapMessage* CRoapMessage::NewL()
+    {
+    CRoapMessage* self = new( ELeave ) CRoapMessage;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+CRoapMessage::~CRoapMessage()
+    {
+    delete iXmlData;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRoapMessage::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CRoapMessage::MessageAsXmlL(void)
+    {
+    return iXmlData->AllocL();
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapMessage::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CRoapMessage::SetXmlData(
+    HBufC8* aData)
+    {
+    iXmlData = aData;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapMessage::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CRoapMessage::TimeToIso8601L(
+    TTime& aTime)
+    {
+    HBufC8* r = NULL;
+    TDateTime t;
+    
+    t = aTime.DateTime();
+    r = HBufC8::NewMax(KIso8601TimeLength);
+    User::LeaveIfNull(r);
+    TPtr8 des = r->Des();
+    des.Format(KIso8601TimeFormat, t.Year(), t.Month() + 1, t.Day() + 1,
+        t.Hour(), t.Minute(), t.Second());
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapMessage::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TTime CRoapMessage::Iso8601ToTime(TDesC8& aTimeString)
+    {
+    TLex8 lex;
+    TInt year = 0;
+    TInt month = 0;
+    TInt day = 0;
+    TInt hour = 0;
+    TInt minute = 0;
+    TInt second = 0;
+    TTime r = Time::NullTTime();
+    TLocale l;
+    TTimeIntervalSeconds offset(l.UniversalTimeOffset());
+
+    if (aTimeString.Length() > 0)
+        {    
+        lex = aTimeString;
+        lex.Val(year);
+        lex.Inc();
+        lex.Val(month);
+        lex.Inc();
+        lex.Val(day);
+        lex.Inc();
+        lex.Val(hour);
+        lex.Inc();
+        lex.Val(minute);
+        lex.Inc();
+        lex.Val(second);
+        r = TTime(TDateTime(year, static_cast<TMonth>(month - 1), day - 1, hour,
+            minute, second, 0));
+        if (lex.Get() != 'Z')
+            {
+            r += offset;
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapMessage::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CRoapMessage::BufAppendL(
+    CBufFlat* aBuffer,
+    const TDesC8& aConst)
+    {
+    aBuffer->InsertL(aBuffer->Size(), aConst);
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapMessage::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CRoapMessage::BufAppendBase64L(
+    CBufFlat* aBuffer,
+    const TDesC8& aConst)
+    {
+    HBufC8* buffer = NULL;
+
+    buffer = Base64EncodeL(aConst);
+    CleanupStack::PushL(buffer);
+    aBuffer->InsertL(aBuffer->Size(), *buffer);
+    CleanupStack::PopAndDestroy(buffer);
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapMessage::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CRoapMessage::BufAppendTimeL(
+    CBufFlat* aBuffer,
+    TTime& aTime)
+    {
+    HBufC8* buffer = NULL;
+
+    buffer = TimeToIso8601L(aTime);
+    CleanupStack::PushL(buffer);
+    aBuffer->InsertL(aBuffer->Size(), *buffer);
+    CleanupStack::PopAndDestroy(buffer);
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RoapParser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,897 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ROAP response parser
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+
+#include "DeviceHello.h"
+#include "JoinDomainReq.h"
+#include "JoinDomainResp.h"
+#include "LeaveDomainReq.h"
+#include "LeaveDomainResp.h"
+#ifdef RD_DRM_METERING
+#include "MeteringReportReq.h"
+#include "MeteringReportResp.h"
+#include "MeteringReportRespParser.h"
+#endif
+#include "RIHello.h"
+#include "RegistrationReq.h"
+#include "RegistrationResp.h"
+#include "RightsReq.h"
+#include "RightsResp.h"
+#include "RoapTrigger.h"
+#include "RoapMessage.h"
+
+#include "RoapParser.h"
+#include "RespParser.h"
+#include "JoinDomainRespParser.h"
+#include "LeaveDomainRespParser.h"
+#include "RIHelloParser.h"
+#include "RegistrationRespParser.h"
+#include "RightsRespParser.h"
+#include "RoapTriggerParser.h"
+#include "RoapLog.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+#define ELEMENT_COUNT(x) static_cast<TInt>((sizeof(x) / sizeof (x[0])))
+
+const TInt KParserChunkSize = 512;
+const TInt KRoapElementCount = ELast;
+const TInt KMaxElementNesting = 24;
+
+struct TRoapElements
+    {
+    const TText8* iString;
+    TInt iNumber;
+    };
+
+struct TStackState
+    {
+    TParserStackState iState;
+    TRoapElementEnum iStack[KMaxElementNesting];
+    };
+
+static const TRoapElements KStatusValues[] =
+    {
+    {_S8("Success"), ESuccess},
+    {_S8("UnknownError"), EUnknownError},
+    {_S8("Abort"), EAbort},
+    {_S8("NotSupported"), ENotSupported},
+    {_S8("AccessDenied"), Roap::EAccessDenied},
+    {_S8("NotFound"), ENotFound},
+    {_S8("MalformedRequest"), EMalformedRequest},
+    {_S8("UnknownRequest"), EUnknownRequest},
+    {_S8("UnknownCriticalExtension"), EUnknownCriticalExtension},
+    {_S8("UnsupportedVersion"), EUnsupportedVersion},
+    {_S8("UnsupportedAlgorithm"), EUnsupportedAlgorithm},
+    {_S8("NoCertificateChain"), ENoCertificateChain},
+    {_S8("InvalidCertificateChain"), EInvalidCertificateChain},
+    {_S8("TrustedRootCertificateNotPresent"), ETrustedRootCertificateNotPresent},
+    {_S8("SignatureError"), ESignatureError},
+    {_S8("DeviceTimeError"), EDeviceTimeError},
+    {_S8("NotRegistered"), ENotRegistered},
+    {_S8("InvalidDCFHash"), EInvalidDCFHash},
+    {_S8("InvalidDomain"), EInvalidDomain},
+    {_S8("DomainFull"), EDomainFull},
+    {_S8("MalformedMeteringReport"), EMalformedMeteringReport},
+    {_S8("UnableToDecryptMeteringReport"), EUnableToDecryptMeteringReport},
+    {_S8("UnableToValidateMeteringReportMAC"), EUnableToValidateMeteringReportMAC},
+    };
+
+static const TRoapElements KRoapElements[ELast] =
+    {
+    {_S8("certificate"), ECertificate},
+    {_S8("certificateChain"), ECertificateChain},
+    {_S8("CipherData"), ECipherData},
+    {_S8("CipherValue"), ECipherValue},
+    {_S8("contentID"), Roap::EContentID},
+    {_S8("dcfHash"), EDcfHash},
+    {_S8("deviceDetails"), EDeviceDetails},
+    {_S8("deviceID"), EDeviceID},
+    {_S8("DigestValue"), EDigestValue},
+    {_S8("dn"), EDomainName},
+    {_S8("domainAlias"), EDomainAlias},
+    {_S8("domainID"), EDomainID},
+    {_S8("domainInfo"), EDomainInfo},
+    {_S8("domainKey"), EDomainKey},
+    {_S8("encKey"), EEncKey},
+    {_S8("EncryptionMethod"), EEncryptionMethod},
+    {_S8("extension"), EExtension},
+    {_S8("extensions"), EExtensions},
+    {_S8("hash"), EHash},
+    {_S8("id"), EId},
+    {_S8("identifier"), EIdentifier},
+    {_S8("joinDomain"), EJoinDomain},
+    {_S8("joinDomainResponse"), EJoinDomainResponse},
+    {_S8("keyIdentifier"), EKeyIdentifier},
+    {_S8("leaveDomain"), ELeaveDomain},
+    {_S8("leaveDomainResponse"), ELeaveDomainResponse},
+    {_S8("mac"), EMac},
+    {_S8("manufacturer"), EManufacturer},
+    {_S8("model"), EModel},
+    {_S8("nonce"), ENonce},
+    {_S8("notAfter"), ENotAfter},
+    {_S8("ocspResponse"), EOcspResponse},
+    {_S8("protectedRO"), EProtectedRO},
+    {_S8("registrationRequest"), ERegistrationRequest},
+    {_S8("registrationResponse"), ERegistrationResponse},
+    {_S8("riAlias"), ERiAlias},
+    {_S8("rights"), Roap::ERights},
+    {_S8("riHello"), ERiHello},
+    {_S8("riID"), ERiID},
+    {_S8("riNonce"), ERiNonce},
+    {_S8("riURL"), ERiURL},
+    {_S8("ro"), ERo},
+    {_S8("roAcquisition"), ERoAcquisition},
+    {_S8("roapTrigger"), ERoapTrigger},
+    {_S8("roapURL"), ERoapURL},
+    {_S8("roID"), ERoID},
+    {_S8("roInfo"), ERoInfo},
+    {_S8("roResponse"), ERoResponse},
+    {_S8("selectedAlgorithm"), ESelectedAlgorithm},
+    {_S8("selectedVersion"), ESelectedVersion},
+    {_S8("serverInfo"), EServerInfo},
+    {_S8("signature"), ESignature},
+    {_S8("SignatureValue"), ESignatureValue},
+    {_S8("supportedAlgorithm"), ESupportedAlgorithm},
+    {_S8("time"), ETime},
+    {_S8("timeStamp"), ETimeStamp},
+    {_S8("trustedAuthorities"), ETrustedAuthorities},
+    {_S8("version"), EVersion},
+    {_S8("X509SPKIHash"), EX509SPKIHash},
+#ifdef RD_DRM_METERING
+    {_S8("extendedTrigger"), EExtendedTriggerElement},
+    {_S8("meteringReport"), EMeteringReportRequest},
+    {_S8("meteringReportResponse"), EMeteringReportResponse},
+    {_S8("prURL"), EPrUrl}
+#endif
+    };
+
+// The stack states have to be sorted with descending length. The
+// MatchStackState function searches for the first matching state.
+static const TStackState KParserStackStates[] =
+    {
+    // 4 elements --------------------------------------------------------------
+    {ERiIdRoResponseState, {EHash, EKeyIdentifier, ERiID, ERoResponse, ELast}},
+    {ERiIdJoinDomainResponseState, {EHash, EKeyIdentifier, ERiID, EJoinDomainResponse, ELast}},
+    // 3 elements --------------------------------------------------------------
+#ifdef RD_DRM_METERING
+    {EPostResponseUrlState, {EPrUrl, EExtension, EExtensions, ELast}},
+#endif
+    {EDeviceIdState, {EHash, EKeyIdentifier, EDeviceID, ELast}},
+    {ETrustedAuthoritiesState, {EHash, EKeyIdentifier, ETrustedAuthorities, ELast}},
+    {EPeerKeyIdentifierRIHelloState, {EIdentifier, EExtension, EExtensions, ELast}},
+    {ETransactionIdState, {EId, EExtension, EExtensions, ELast}},
+    {ETransactionIdContentIdState, {Roap::EContentID, EExtension, EExtensions, ELast}},
+    {EWhiteListState, {EDomainName, EExtension, EExtensions, ELast}},
+    {EDeviceDetailsState, {EDeviceDetails, EExtensions, ERiHello, ELast}},
+    {ERiIdState, {EHash, EKeyIdentifier, ERiID, ELast}},
+    {EEncKeyState, {ECipherValue, ECipherData, EEncKey, ELast}},
+    {EDomainKeyEncryptionMethodState, {EEncryptionMethod, EEncKey, EDomainKey, ELast}},
+    {EMacJoinDomainResponseState, {EMac, EDomainKey, EDomainInfo, ELast}},
+    // 2 elements --------------------------------------------------------------
+    {EDomainKeyEncKeyState, {EEncKey, EDomainKey, ELast}},
+    {ECertificateState, {ECertificate, ECertificateChain, ELast}},
+    {ESignatureRoResponseState, {ESignature, ERoResponse, ELast}},
+    {EExtensionState, {EExtension, EExtensions, ELast}},
+    // 1 element ---------------------------------------------------------------
+    {ERiAliasState, {ERiAlias, ELast}},
+    {EDomainAliasState, {EDomainAlias, ELast}},
+    {ERiHelloState, {ERiHello, ELast}},
+    {ESelectedVersionState, {ESelectedVersion, ELast}},
+    {ERiNonceState, {ERiNonce, ELast}},
+    {EOcspResponseState, {EOcspResponse, ELast}},
+    {ERiUrlState, {ERiURL, ELast}},
+    {ESignatureState, {ESignature, ELast}},
+    {ERegistrationResponseState, {ERegistrationResponse, ELast}},
+    {ERoResponseState, {ERoResponse, ELast}},
+    {EJoinDomainResponseState, {EJoinDomainResponse, ELast}},
+    {ELeaveDomainResponseState, {ELeaveDomainResponse, ELast}},
+    {EDomainIdState, {EDomainID, ELast}},
+    {ENonceState, {ENonce, ELast}},
+    {ENotAfterState, {ENotAfter, ELast}},
+    {EDomainKeyState, {EDomainKey, ELast}},
+    {ERoapTriggerState, {ERoapTrigger, ELast}},
+    {ERoapUrlState, {ERoapURL, ELast}},
+    {ERegistrationRequestState, {ERegistrationRequest, ELast}},
+    {ERoAcquisitionState, {ERoAcquisition, ELast}},
+    {EJoinDomainState, {EJoinDomain, ELast}},
+    {ELeaveDomainState, {ELeaveDomain, ELast}},
+    {ERoIdState, {ERoID, ELast}},
+    {EContentIdState, {Roap::EContentID, ELast}},
+    {ESignatureValueState, {ESignatureValue, ELast}},
+    {EDigestValueState, {EDigestValue, ELast}},
+    {EServerInfoState, {EServerInfo, ELast}},
+    {ESupportedAlgorithmState, {ESupportedAlgorithm, ELast}},
+    {ESelectedAlgorithmState, {ESelectedAlgorithm, ELast}},
+#ifdef RD_DRM_METERING
+    {EExtendedTriggerElementState, {EExtendedTriggerElement, ELast}},
+    {EMeteringReportRequestState, {EMeteringReportRequest, ELast}},
+    {EMeteringReportResponseState, {EMeteringReportResponse, ELast}}
+#endif
+    };
+
+_LIT8(KParserMimeType, "text/xml");
+_LIT8(KDomainKey, "domainKey");
+_LIT8(KMac, "mac>");
+_LIT8(KMacEnd, "</mac>");
+
+// ============================ auto_handde helper class =======================
+//Auto handle for easening handle release on exceptional exit situations
+template<class T> class auto_handle
+    {
+    public:
+
+    auto_handle() {}
+    auto_handle(T aHandle) : iHandle( aHandle ) {}
+    auto_handle( auto_handle<T>& aHandle) : iHandle( aHandle.release() ) {}
+    ~auto_handle() { iHandle.Close(); }
+    const T& operator()() const { return iHandle; }
+    T& operator()() { return iHandle; }
+    T get() const { return iHandle; }
+    T release() { T temp = iHandle; iHandle = 0; return temp; }
+
+    private:
+    T iHandle;
+    };
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRoapParser::CRoapParser
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRoapParser::CRoapParser():
+    iParser(NULL),
+    iResponseParser(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::ConstructL()
+    {
+    TInt i;
+
+    iParser = CParser::NewL(KParserMimeType, *this);
+    for (i = 0; i < KRoapElementCount; i++)
+        {
+        TPtrC8 ptr(KRoapElements[i].iString, User::StringLength(
+            KRoapElements[i].iString));
+        iRoapElements[KRoapElements[i].iNumber] =
+            iParser->StringPool().OpenStringL(ptr);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRoapParser* CRoapParser::NewL()
+    {
+    CRoapParser* self = new( ELeave ) CRoapParser;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+
+// Destructor
+CRoapParser::~CRoapParser()
+    {
+    TInt i;
+    for (i = 0; i < ELEMENT_COUNT(KRoapElements); i++)
+        {
+        iRoapElements[KRoapElements[i].iNumber].Close();
+        }
+    delete iParser;
+    delete iContent;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::ParseMeteringRespL
+// -----------------------------------------------------------------------------
+//
+#ifndef RD_DRM_METERING
+CMeteringResp* CRoapParser::ParseMeteringRespL( const TDesC8& /*aMessage*/ )
+    {
+    return NULL;
+    }
+#else
+CMeteringResp* CRoapParser::ParseMeteringRespL( const TDesC8& aMessage )
+    {
+    LOG( _L("CRoapParser::ParseMeteringRespL") );
+    CMeteringResp* r = CMeteringResp::NewL();
+    CleanupStack::PushL(r);
+    TMeteringRespParser p(r);
+    iResponseParser = &p;
+    ParseL(aMessage);
+    CleanupStack::Pop(r);
+    return r;
+    }
+#endif
+// -----------------------------------------------------------------------------
+// CRoapParser::ParseJoinDomainRespL
+// -----------------------------------------------------------------------------
+//
+CJoinDomainResp* CRoapParser::ParseJoinDomainRespL(
+    const TDesC8& aMessage, RPointerArray<HBufC8>& aDomainKeyElements)
+    {
+    LOG( _L("CRoapParser::ParseJoinDomainRespL") );
+
+    CJoinDomainResp* r = CJoinDomainResp::NewL();
+    CleanupStack::PushL(r);
+    TJoinDomainRespParser p(r);
+    iResponseParser = &p;
+    ParseL(aMessage);
+    if ( r->iStatus == ESuccess )
+        {
+        User::LeaveIfError(
+            ExtractDomainKeyElements(aMessage, aDomainKeyElements));
+        }
+    CleanupStack::Pop(r);
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::ParseLeaveDomainRespL
+// -----------------------------------------------------------------------------
+//
+CLeaveDomainResp* CRoapParser::ParseLeaveDomainRespL(
+    const TDesC8& aMessage)
+    {
+    LOG( _L("CRoapParser::ParseLeaveDomainRespL") );
+
+    CLeaveDomainResp* r = CLeaveDomainResp::NewL();
+    CleanupStack::PushL(r);
+    TLeaveDomainRespParser p(r);
+    iResponseParser = &p;
+    ParseL(aMessage);
+    CleanupStack::Pop(r);
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::ParseRegistrationResp
+// -----------------------------------------------------------------------------
+//
+CRegistrationResp* CRoapParser::ParseRegistrationRespL(
+    const TDesC8& aMessage)
+    {
+    LOG( _L("CRoapParser::ParseRegistrationRespL") );
+
+    CRegistrationResp* r = CRegistrationResp::NewL();
+    CleanupStack::PushL(r);
+    TRegistrationRespParser p(r);
+    iResponseParser = &p;
+    ParseL(aMessage);
+    CleanupStack::Pop(r);
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::ParseRightsRespL
+// -----------------------------------------------------------------------------
+//
+CRightsResp* CRoapParser::ParseRightsRespL(
+    const TDesC8& aMessage)
+    {
+    LOG( _L("CRoapParser::ParseRightsRespL") );
+
+    CRightsResp* r = CRightsResp::NewL();
+    CleanupStack::PushL(r);
+    TRightsRespParser p(r);
+    iResponseParser = &p;
+    ParseL(aMessage);
+    CleanupStack::Pop(r);
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::ParseRIHelloL
+// -----------------------------------------------------------------------------
+//
+CRIHello* CRoapParser::ParseRIHelloL(
+    const TDesC8& aMessage)
+    {
+    LOG( _L("CRoapParser::ParseRIHelloL") );
+
+    CRIHello* r = CRIHello::NewL();
+    CleanupStack::PushL(r);
+    TRIHelloParser p(r);
+    iResponseParser = &p;
+    ParseL(aMessage);
+    CleanupStack::Pop(r);
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::ParseRoapTriggerL
+// -----------------------------------------------------------------------------
+//
+CRoapTrigger* CRoapParser::ParseRoapTriggerL(
+    const TDesC8& aMessage)
+    {
+    LOG( _L("CRoapParser::ParseRoapTriggerL") );
+
+    CRoapTrigger* r = CRoapTrigger::NewL();
+    CleanupStack::PushL(r);
+    TRoapTriggerParser p(r);
+    iResponseParser = &p;
+    ParseL(aMessage);
+    CleanupStack::Pop(r);
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::ParseL
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::ParseL(
+    const TDesC8& aMessage)
+    {
+    TInt i;
+    TInt n;
+
+    iElementStackDepth = 0;
+    delete iContent;
+    iContent = NULL;
+    iParser->ParseBeginL();
+    i = 0;
+    while (i < aMessage.Length())
+        {
+        n = Min(aMessage.Length() - i, KParserChunkSize);
+        iParser->ParseL(aMessage.Mid(i, n));
+        i += n;
+        }
+    iParser->ParseEndL();
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnStartDocumentL
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnStartDocumentL(
+    const RDocumentParameters& /*aDocParam*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnEndDocumentL
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnEndDocumentL(
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnStartElementL
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnStartElementL(
+    const RTagInfo& aElement,
+    const RAttributeArray& aAttributes,
+    TInt /*aErrorCode*/)
+    {
+    TInt i;
+    TInt state;
+
+    if (iContent)
+        {
+        delete iContent;
+        iContent = NULL;
+        iContent = HBufC8::NewL(0);
+        }
+
+    for (i = 0; i < KRoapElementCount; i++)
+        {
+        if (aElement.LocalName() == iRoapElements[i])
+            {
+            iElementStack[iElementStackDepth] =
+                static_cast<TRoapElementEnum>(i);
+            iElementStackDepth++;
+            state = MatchStackState();
+            iResponseParser->OnStartElementL(*this, state, aElement,
+                aAttributes);
+            if (iElementStackDepth == KMaxElementNesting)
+                {
+                User::Leave(EXmlUnexpectedState);
+                }
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnEndElementL
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnEndElementL(
+    const RTagInfo& aElement,
+    TInt /*aErrorCode*/)
+    {
+    TInt i;
+    TInt state;
+
+    for (i = 0; i < KRoapElementCount; i++)
+        {
+        if (aElement.LocalName() == iRoapElements[i])
+            {
+            state = MatchStackState();
+            iResponseParser->OnEndElementL(*this, state, aElement);
+            iElementStackDepth--;
+            if (iElementStackDepth < 0)
+                {
+                User::Leave(EXmlUnexpectedState);
+                }
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnContentL
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnContentL(
+    const TDesC8& aBytes,
+    TInt /*aErrorCode*/)
+    {
+    if ( !iContent )
+        {
+        iContent = HBufC8::NewL(aBytes.Size());
+        *iContent = aBytes;
+        }
+    else
+        {
+        iContent = iContent->ReAllocL(iContent->Size() + aBytes.Size());
+        TPtr8 c(iContent->Des());
+        c.Append(aBytes);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnStartPrefixMappingL
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnStartPrefixMappingL(
+    const RString& /*aPrefix*/,
+    const RString& /*aUri*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnEndPrefixMappingL
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnEndPrefixMappingL(
+    const RString& /*aPrefix*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnIgnorableWhiteSpaceL
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnIgnorableWhiteSpaceL(
+    const TDesC8& /*aBytes*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnSkippedEntityL
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnSkippedEntityL(
+    const RString& /*aName*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnProcessingInstructionL
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnProcessingInstructionL(
+    const TDesC8& /*aTarget*/,
+    const TDesC8& /*aData*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnOutOfData
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnOutOfData()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::OnError
+// -----------------------------------------------------------------------------
+//
+void CRoapParser::OnError(
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::GetExtendedInterface
+// -----------------------------------------------------------------------------
+//
+TAny* CRoapParser::GetExtendedInterface(
+    const TInt32 /*aUid*/)
+    {
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::MatchStackState
+// -----------------------------------------------------------------------------
+//
+TParserStackState CRoapParser::MatchStackState(void)
+    {
+    TInt i;
+    TInt j;
+    TInt k;
+    TParserStackState r = EUnknownState;
+
+    for (i = 0;
+        r == EUnknownState &&
+        i < ELEMENT_COUNT(KParserStackStates); i++)
+        {
+        for (j = iElementStackDepth - 1, k = 0;
+            j > 0 && KParserStackStates[i].iStack[k] != ELast;
+            j--, k++)
+            {
+            if (iElementStack[j] != KParserStackStates[i].iStack[k])
+                {
+                break;
+                }
+            }
+        if ((j == 0 && iElementStack[j] == KParserStackStates[i].iStack[k]) ||
+            KParserStackStates[i].iStack[k] == ELast)
+            {
+            r = KParserStackStates[i].iState;
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::GetAttributeValueL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CRoapParser::GetAttributeValueL(
+    const RAttributeArray& aAttrList,
+    const TDesC8& aAttrName)
+    {
+    HBufC8* r = NULL;
+    RAttribute a;
+    TInt i;
+
+    for (i = 0; !r && i < aAttrList.Count(); i++)
+        {
+        a = aAttrList[i];
+        if (a.Attribute().LocalName().DesC().Compare(aAttrName) == 0)
+            {
+            r = a.Value().DesC().AllocL();
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::ConvertRoapStatus
+// -----------------------------------------------------------------------------
+//
+TRoapStatus CRoapParser::ConvertRoapStatus(
+    const TDesC8& aStatus)
+    {
+    TInt i;
+    TRoapStatus r = EUnknownStatus;
+
+    for (i = 0; r == EUnknownStatus && i < ELEMENT_COUNT(KStatusValues); i++)
+        {
+        if (aStatus.Compare(TPtrC8(KStatusValues[i].iString,
+            aStatus.Size())) == 0)
+            {
+            r = static_cast<TRoapStatus>(KStatusValues[i].iNumber);
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::ExtractElement
+// Note: uses auto_handle helper class
+// -----------------------------------------------------------------------------
+//
+TPtrC8 CRoapParser::ExtractElement(
+    const TDesC8& aMessage, const TDesC8& aElement, TInt& aOffset ) const
+    {
+    LOG( _L("CRoapParser::ExtractElement") );
+
+    TPtrC8 temp( KNullDesC8 );
+    TInt pos = ( 0 );
+    TInt startPos = ( 0 );
+    TInt endPos = ( 0 );
+    TInt ret( 0 );
+    TInt startLength ( 0 );
+    const TInt KSpaceForDelimiters( 3 ); // max "</" aElement ">"
+
+    auto_handle< RBuf8 > tagToBeFound;
+    // Must be nonleaving since this function is nonleaving
+    ret = tagToBeFound().Create( aElement.Length() + KSpaceForDelimiters );
+    if ( ret != KErrNone )
+        {
+        aOffset = -1;
+        return KNullDesC8();
+        }
+
+    //First we try to find start tag (as localname)
+    tagToBeFound().SetLength( 0 );
+    tagToBeFound().AppendFormat( _L8( "<%S" ), &aElement );
+
+    temp.Set( aMessage.Mid( aOffset ) );
+
+
+    startPos = temp.Find( tagToBeFound() );
+
+    if ( startPos < 0 )
+        {//Not found, let's try with namespace start
+        tagToBeFound().SetLength( 0 );
+        tagToBeFound().AppendFormat( _L8( ":%S" ), &aElement );
+        pos = temp.Find( tagToBeFound() );
+        if ( pos < 0 )
+            {//Not possible to find valid tag with given name
+            aOffset = -1;
+            return KNullDesC8();
+            }
+        temp.Set( aMessage.Left( pos ) );
+        startPos = temp.LocateReverse('<');
+        if ( startPos < 0 )
+            {
+            aOffset = -1;
+            return KNullDesC8();
+            }
+        //Calculate length for the new string to be stored
+        ret = tagToBeFound().ReAlloc(
+            ( pos - startPos ) + aElement.Length() + KSpaceForDelimiters );
+        if ( ret != KErrNone )
+            {
+            aOffset = -1;
+            return KNullDesC8();
+            }
+        tagToBeFound().SetLength( 0 );
+        tagToBeFound().Append( temp.Mid( startPos ) );
+        tagToBeFound().AppendFormat( _L8( ":%S" ), &aElement );
+        }
+
+    startLength = tagToBeFound().Length(); //needed in later calculations
+    startPos += aOffset;
+    temp.Set( aMessage.Mid( startPos + startLength ) );
+
+    //Now find the end element. First prepare element to be found
+    tagToBeFound().Insert( 1, _L8( "/" ) ); // '/' after '<'
+    tagToBeFound().Append( _L8( ">" ) ); // '>' as last
+
+
+    endPos = temp.Find(tagToBeFound());
+    if ( endPos < 0)
+        {
+        aOffset = -1;
+        return KNullDesC8();
+        }
+    endPos += startPos + startLength + tagToBeFound().Length();
+
+    temp.Set( aMessage.Mid(startPos, endPos - startPos) );
+
+    aOffset = endPos;
+    LOG( _L( "Extracted element" ) );
+    LOGHEX( temp.Ptr(), temp.Length() );
+
+    //auto_handle closes and frees allocated resources
+    return temp;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapParser::ExtractDomainKeyElements
+// -----------------------------------------------------------------------------
+//
+TInt CRoapParser::ExtractDomainKeyElements(
+    const TDesC8& aMessage, RPointerArray<HBufC8>& aDomainKeyElements ) const
+    {
+    LOG( _L("CRoapParser::ExtractDomainKeyElements") );
+
+    TPtrC8 temp(KNullDesC8);
+    TPtrC8 elementPtr(KNullDesC8);
+    TInt pos = 0;
+    HBufC8* element = NULL;
+    TInt err = KErrNone;
+    TPtr8 ptr(0, 0);
+    TInt macStart = 0;
+    TInt macEnd = 0;
+
+    // extract DomainKey elements to aDomainKeyElements array
+    while (true)
+        {
+        elementPtr.Set( ExtractElement( aMessage, KDomainKey(), pos ) );
+
+        if( pos < 0 )
+            {
+            // no more DomainKeys present
+            if(aDomainKeyElements.Count())
+                {
+                return KErrNone;
+                }
+            else
+                {
+                aDomainKeyElements.ResetAndDestroy();
+                return KErrRoapServerFatal;
+                }
+            }
+
+        element = elementPtr.Alloc();
+        if(!element)
+            {
+            return KErrNoMemory;
+            }
+
+        // remove mac element from found DomainKeyElement
+        macStart = element->Find( KMac );
+        temp.Set(element->Left(macStart));
+        macStart = temp.LocateReverse('<');
+        macEnd = element->Find( KMacEnd ) + KMacEnd().Length();
+        if ( macStart < 0 || macEnd < 0 )
+            {
+            aDomainKeyElements.ResetAndDestroy();
+            return KErrRoapServerFatal;
+            }
+        ptr.Set( element->Des() );
+        ptr.Replace( macStart, macEnd - macStart, KNullDesC8 );
+
+        err = aDomainKeyElements.Append(element);
+        if(err)
+            {
+            delete element;
+            element = NULL;
+            aDomainKeyElements.ResetAndDestroy();
+            return err;
+            }
+        }
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RoapResponse.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,305 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#undef _ROAP_TESTING
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+// INCLUDE FILES
+#include "RoapResponse.h"
+#include "RoapLog.h"
+
+using namespace Roap;
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+#ifndef RD_MULTIPLE_DRIVE
+// default filename
+_LIT( KMultipartPduTempPath, "c:\\");
+#endif
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRoapResponse::CRoapResponse()
+// -----------------------------------------------------------------------------
+//
+CRoapResponse::CRoapResponse()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapResponse::ConstructL()
+// -----------------------------------------------------------------------------
+//
+void CRoapResponse::ConstructL()
+    {
+    iPdu = HBufC8::NewL( 0 );
+    iMultipartState = EOther;
+    iMaxSize = -1;
+    }    
+
+// -----------------------------------------------------------------------------
+// CRoapResponse::NewL()
+// -----------------------------------------------------------------------------
+//
+CRoapResponse* CRoapResponse::NewL()
+    {
+    CRoapResponse* self = new( ELeave ) CRoapResponse;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapResponse::~CRoapResponse()
+// -----------------------------------------------------------------------------
+//
+CRoapResponse::~CRoapResponse()
+    {
+    delete iPdu;
+    delete iContentName;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapResponse::ProtocolUnit()
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CRoapResponse::ProtocolUnit() const
+    {
+    return *iPdu;
+    }
+    
+// -----------------------------------------------------------------------------
+// CRoapResponse::PduFileName()
+// -----------------------------------------------------------------------------
+//
+const TFileName& CRoapResponse::DcfFileName() const
+    {
+    return iDcfFileName;
+    }
+    
+// -----------------------------------------------------------------------------
+// CRoapResponse::SetPduFileName()
+// -----------------------------------------------------------------------------
+//
+void CRoapResponse::SetDcfPathL(
+    const TPath& aPath )
+    {
+    LOG( _L("CRoapResponse::SetDcfPathL->") );
+    
+    RFs fs;
+    RFile file;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    
+    if ( aPath.Length() > 3 )
+        {
+        User::LeaveIfError( file.Temp( fs, aPath, iDcfFileName,
+                            EFileShareExclusive | EFileWrite ) );
+        }
+    else 
+        {
+        
+#ifndef RD_MULTIPLE_DRIVE
+        
+        User::LeaveIfError( file.Temp( fs, KMultipartPduTempPath(), iDcfFileName,
+                            EFileShareExclusive | EFileWrite ) );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+        _LIT( KDriveRoot, "%c:\\");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	    fs.DriveToChar( driveNumber, driveLetter );
+    
+	    TFileName multipartTemp;
+	    multipartTemp.Format( KDriveRoot, (TUint)driveLetter );
+        
+        User::LeaveIfError( file.Temp( fs, multipartTemp, iDcfFileName,
+                            EFileShareExclusive | EFileWrite ) );
+    
+#endif
+        }
+    LOG2( _L("iDcfFileName: %S"), &iDcfFileName );    
+        
+    file.Close();
+    CleanupStack::PopAndDestroy();
+    LOG( _L("CRoapResponse::SetDcfFileName <-") );
+    }
+    
+// -----------------------------------------------------------------------------
+// CRoapResponse::AppendPduFileDataL()
+// -----------------------------------------------------------------------------
+//
+void CRoapResponse::AppendMultipartDataL(
+    const TDesC8& aData )
+    {
+    WriteL( aData );
+    }
+    
+// ---------------------------------------------------------
+// CRoapResponse::DataType()
+// ---------------------------------------------------------
+//
+const TDataType& CRoapResponse::DataType() const
+    {
+    return iDataType;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapResponse::HandleBodyDataL
+// 
+// -----------------------------------------------------------------------------
+//
+void CRoapResponse::HandleBodyDataL(
+    const TDesC8& aData)
+    {
+    LOG( _L("CRoapResponse::HandleBodyDataL ->") );
+    if ( iMultipartState == ERights )
+        {
+        LOG( _L("  saving RO data") );
+        iPdu = iPdu->ReAlloc( iPdu->Size() + aData.Size() );
+        User::LeaveIfNull( iPdu );
+        iPdu->Des().Append( aData );
+        }
+    else if ( iMultipartState == EDcf )
+        {
+        RFs fs;
+        RFile file;
+        
+        LOG( _L("  saving DCF data") );
+        User::LeaveIfError( fs.Connect() );
+        CleanupClosePushL( fs );
+        User::LeaveIfError( file.Open( fs, iDcfFileName,
+            EFileShareExclusive | EFileWrite ) );
+        CleanupClosePushL( file );
+        User::LeaveIfError( file.Write( KMaxTInt32, aData ) );
+        CleanupStack::PopAndDestroy( 2 ); // file, fs
+        }
+    LOG( _L("CRoapResponse::HandleBodyDataL <-") );
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapResponse::StartBodyPartL
+// 
+// -----------------------------------------------------------------------------
+//
+void CRoapResponse::StartBodyPartL()
+    {
+    LOG( _L("CRoapResponse::StartBodyPartL ->") );
+    if ( iMultipartState == EOther )
+        {
+        LOG( _L("  starting RO part") );
+        iMultipartState = ERights;
+        }
+    else if ( iMultipartState == ERights )
+        {
+        LOG( _L("  starting DCF part") );
+        iMultipartState = EDcf;
+        }
+    else
+        {
+        LOG( _L("  some other part") );
+        }
+    LOG( _L("CRoapResponse::StartBodyPartL <-") );
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapResponse::EndBodyPartL
+// 
+// -----------------------------------------------------------------------------
+//
+void CRoapResponse::EndBodyPartL()
+    {
+    LOG( _L("CRoapResponse::EndBodyPartL ->") );
+    LOG( _L("CRoapResponse::EndBodyPartL <-") );
+    }
+    
+// -----------------------------------------------------------------------------
+// CRoapResponse::SetContentNameL
+// 
+// -----------------------------------------------------------------------------
+//    
+void CRoapResponse::SetContentNameL( const TDes& aName )
+    {
+    LOG( _L("CRoapResponse::SetContentNameL") );
+    
+    delete iContentName;
+    iContentName = NULL;
+    
+    iContentName = aName.AllocL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRoapResponse::GetContentNameLC
+// 
+// -----------------------------------------------------------------------------
+//
+void CRoapResponse::GetContentNameLC( HBufC*& aName ) const
+    {
+    LOG( _L("CRoapResponse::GetContentName") );
+        
+    if ( iContentName )
+        aName = iContentName->AllocLC();
+    else
+        aName = NULL;
+    }
+// -----------------------------------------------------------------------------
+// CRoapResponse::SetMaxSize
+// 
+// -----------------------------------------------------------------------------
+//    
+void CRoapResponse::SetMaxSize( const TInt& aSize )
+    {
+    LOG( _L("CRoapResponse::SetMaxSize") );
+    
+    iMaxSize = aSize;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRoapResponse::MaxSize
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CRoapResponse::MaxSize() const
+    {
+    LOG( _L("CRoapResponse::MaxSize") );
+        
+    return iMaxSize;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RoapSigner.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,297 @@
+/*
+* Copyright (c) 2002 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ROAP message signer class implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <f32file.h>
+#include <s32file.h>
+#include <hash.h>
+#include <signed.h>
+#include <asymmetric.h>
+#include <hash.h>
+#include <asn1enc.h>
+#include <x509cert.h>
+#include "base64.h"
+#include "RoapSigner.h"
+#include "RoapStorageClient.h"
+#include "RoapLog.h"
+
+using namespace Roap;
+
+// CONSTANTS
+_LIT8( KSignatureStart, "<signature>" );
+_LIT8( KSignatureEnd, "</signature>" );
+_LIT8( KRoEndWithPrefix, "</roap:protectedRO>" );
+_LIT8( KRoEnd, "</protectedRO>" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RoapSigner::RoapSigner
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRoapSigner::CRoapSigner():
+    iHash( NULL ),
+    iStorage( NULL )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRIHello::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRoapSigner::ConstructL( RRoapStorageClient& aStorageClient )
+    {
+    iHash = CSHA1::NewL();
+    iStorage = &aStorageClient;
+    }
+
+
+// Destructor
+CRoapSigner::~CRoapSigner()
+    {
+    iRequests.ResetAndDestroy();
+    iResponses.ResetAndDestroy();
+    delete iHash;
+    }
+
+// -----------------------------------------------------------------------------
+// RoapSigner::
+//
+// -----------------------------------------------------------------------------
+//
+CRoapSigner* CRoapSigner::NewL( RRoapStorageClient& aStorageClient )
+    {
+    CRoapSigner* self = new ( ELeave ) CRoapSigner();
+
+    CleanupStack::PushL( self );
+    self->ConstructL( aStorageClient );
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapSigner::ResetRequests
+// -----------------------------------------------------------------------------
+//
+void CRoapSigner::ResetRequests( void )
+    {
+    iRequests.ResetAndDestroy();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRoapSigner::ResetResponses
+// -----------------------------------------------------------------------------
+//
+void CRoapSigner::ResetResponses( void )
+    {
+    iResponses.ResetAndDestroy();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRoapSigner::AddResponseL
+// -----------------------------------------------------------------------------
+//
+void CRoapSigner::AddResponseL(
+    const TDesC8& aResponse )
+    {
+    HBufC8* b = aResponse.AllocLC();
+    iResponses.AppendL( b );
+    CleanupStack::Pop( b );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRoapSigner::VerifyAndAddResponseL
+// -----------------------------------------------------------------------------
+//
+TBool CRoapSigner::VerifyAndAddResponseL(
+    const TDesC8& aResponse,
+    const TDesC8& aSignature,
+    const RPointerArray<HBufC8>& aCertificateChain )
+    {
+    TBool r = ETrue;
+    TInt i( 0 );
+    TInt startPoint = 0;
+    TInt endPoint = 0;
+    TInt roEnd = 0;
+    TPtr8 ptr( 0, 0 );
+    TPtrC8 hash( 0, 0 );
+    HBufC8* tempMessage = NULL;
+    TInt lastRoEnd( 0 );
+
+    LOGLIT( "CRoapSigner::VerifyAndAddResponseL" );
+
+    // locate the last protectedRO endtag - there could be also <signature> elemet
+    // inside the ro element
+    while ( lastRoEnd >= 0 )
+        {
+        TInt tagIncrement( KRoEndWithPrefix().Length() );
+        roEnd += lastRoEnd;
+        TPtrC8 startPtr( aResponse.Mid( roEnd ) );
+        lastRoEnd = startPtr.Find( KRoEndWithPrefix );
+        if ( lastRoEnd == KErrNotFound )
+            {
+            // try again without namespace prefix
+            lastRoEnd = startPtr.Find( KRoEnd );
+            tagIncrement = KRoEnd().Length();
+            }
+        if ( lastRoEnd > 0 )
+            {
+            lastRoEnd += tagIncrement;
+            }
+        DETAILLOG2( _L( "lastRoEnd %08x:" ), lastRoEnd );
+        }
+    DETAILLOG2( _L( "roEnd %08x:" ), roEnd );
+    if ( roEnd > 0 )
+        {
+        startPoint = aResponse.Right( aResponse.Length() - roEnd ).Find( KSignatureStart );
+        startPoint += roEnd;
+        endPoint = aResponse.Right( aResponse.Length() - roEnd ).Find( KSignatureEnd )
+                                   + KSignatureEnd().Length();
+        endPoint += roEnd;
+        }
+    else
+        {
+        startPoint = aResponse.Find( KSignatureStart );
+        endPoint = aResponse.Find( KSignatureEnd ) + KSignatureEnd().Length();
+        }
+
+    tempMessage = HBufC8::NewMax( aResponse.Length() -
+                                 2 * KSignatureStart().Length() );
+    User::LeaveIfNull( tempMessage );
+    ptr.Set( tempMessage->Des() );
+    ptr.Copy( aResponse.Left( startPoint ) );
+    ptr.Append( aResponse.Right( aResponse.Length() - endPoint ) );
+
+    iResponses.Append( tempMessage );
+    iHash->Reset();
+    for ( i = 0; i < iResponses.Count(); i++ )
+        {
+        DETAILLOG2( _L( "Message %d:" ), i );
+        DETAILLOGHEX( iResponses[ i ]->Ptr(), iResponses[ i ]->Length() );
+        iHash->Update( *iResponses[ i ] );
+        }
+
+    hash.Set( iHash->Final() );
+
+    LOGLIT( "Hash" );
+    LOGHEX( hash.Ptr(), hash.Length() );
+    LOGLIT( "Signature" );
+    LOGHEX( aSignature.Ptr(), aSignature.Length() );
+
+    r= iStorage->VerifyL( aSignature, hash, aCertificateChain );
+
+#ifdef _ROAP_TESTING
+    if ( r )
+        {
+        LOGLIT( "Signature verification ok." );
+        }
+    else
+        {
+        LOGLIT( "Signature verification failed." );
+        }
+#endif
+
+    return r;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRoapSigner::AddRequestL
+// -----------------------------------------------------------------------------
+//
+void CRoapSigner::AddRequestL(
+    const TDesC8& aRequest )
+    {
+    HBufC8* b = aRequest.AllocLC();
+    iRequests.AppendL( b );
+    CleanupStack::Pop( b );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRoapSigner::SignAndAddRequestL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CRoapSigner::SignAndAddRequestL(
+    const TDesC8& aRequest )
+    {
+    TInt i;
+    TInt insertPoint;
+    HBufC8* s;
+    HBufC8* r;
+    TPtr8 ptr( 0, 0 );
+    HBufC8* signature = NULL;
+    HBufC8* tempMessage = NULL;
+    TPtrC8 hash( 0, 0 );
+
+    LOGLIT( "CRoapSigner::SignAndAddRequestL" );
+
+    insertPoint = aRequest.Find( KSignatureStart ) + KSignatureStart().Length();
+    tempMessage = HBufC8::NewMax( aRequest.Length() -
+        2 * KSignatureStart().Length() );
+    User::LeaveIfNull( tempMessage );
+    ptr.Set( tempMessage->Des() );
+    ptr.Copy( aRequest.Left( insertPoint - KSignatureStart().Length() ) );
+    ptr.Append( aRequest.Right( aRequest.Length() - insertPoint -
+        KSignatureStart().Length() - 1 ) );
+
+    iHash->Reset();
+    for ( i = 0; i < iRequests.Count(); i++ )
+        {
+        DETAILLOG2( _L( "Message %d:" ), i );
+        DETAILLOGHEX( iRequests[ i ]->Ptr(), iRequests[ i ]->Length() );
+        iHash->Update( *iRequests[ i ] );
+        }
+    DETAILLOG2( _L( "Message %d:" ), i );
+    DETAILLOGHEX( tempMessage->Ptr(), tempMessage->Length() );
+    iHash->Update( *tempMessage );
+    delete tempMessage;
+    hash.Set( iHash->Final() );
+    LOGLIT( "Hash" );
+    LOGHEX( hash.Ptr(), hash.Length() );
+
+    iStorage->SignL( hash, signature );
+    CleanupStack::PushL( signature );
+
+    LOGLIT( "Signature" );
+    LOGHEX( signature->Ptr(), signature->Length() );
+
+    s = Base64EncodeL( *signature );
+    CleanupStack::PushL( s );
+    r = HBufC8::NewMax( s->Length() + aRequest.Length() );
+    User::LeaveIfNull( r );
+    ptr.Set( r->Des() );
+    ptr.Copy( aRequest.Left( insertPoint ) );
+    ptr.Append( *s );
+    ptr.Append( aRequest.Right( aRequest.Length() - insertPoint ) );
+    CleanupStack::PopAndDestroy( s );
+    CleanupStack::PopAndDestroy( signature );
+
+    iRequests.Append( r->Des().AllocL() );
+    return r;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RoapSyncWrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,236 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Synchronous wrapper for ROAP protocol suite
+*
+*/
+
+
+#include <RoapEng.h>
+#include "RoapSyncWrapper.h"
+#include <RoapDef.h>
+
+using namespace Roap;
+
+// ============================  LOCAL FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// UpdateUrlL
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void UpdateUrlL( HBufC8*& aTargetUrl, const TDesC8& aSourceUrl )
+    {
+    if ( aTargetUrl )
+        {
+        delete aTargetUrl;
+        aTargetUrl = NULL;
+        }
+    if ( aSourceUrl.Length() )
+        {
+        aTargetUrl = aSourceUrl.AllocL();
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// DoResetAndDestroy
+// Does RPointerArray< >->ResetAndDestroy() for the given array aPtr.
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void DoResetAndDestroy( TAny* aPtr )
+    {
+    ( reinterpret_cast< RPointerArray< HBufC8 >* >( aPtr ) )->
+        ResetAndDestroy();
+    }
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+CRoapSyncWrapper::CRoapSyncWrapper() : CActive( EPriorityStandard )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+void CRoapSyncWrapper::ConstructL()
+    {
+    }
+
+EXPORT_C CRoapSyncWrapper* CRoapSyncWrapper::NewL()
+    {
+    CRoapSyncWrapper* self = new ( ELeave ) CRoapSyncWrapper;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+EXPORT_C CRoapSyncWrapper::~CRoapSyncWrapper()
+    {
+    Cancel();
+    delete iErrorUrl;
+    delete iPostResponseUrl;
+    }
+
+EXPORT_C void CRoapSyncWrapper::HandleTriggerL( const TDesC8& aTrigger )
+    {
+    TTriggerType triggerType;
+    TRiContextStatus contextStatus;
+    TDomainOperation domainOperation;
+    RPointerArray<HBufC8> contentIds;
+    CRoapEng* roapEng = CRoapEng::NewL();
+
+    CleanupStack::PushL( roapEng );
+    roapEng->SetTriggerL( aTrigger, NULL, triggerType, contextStatus,
+        domainOperation, contentIds );
+    contentIds.ResetAndDestroy();
+    roapEng->AcceptL( this, &iStatus );
+    SetActive();
+    iWait.Start();
+    CleanupStack::PopAndDestroy( roapEng );
+    User::LeaveIfError( iStatus.Int() );
+    }
+
+EXPORT_C TBool CRoapSyncWrapper::HandleTriggerSilentlyL( const TDesC8& aTrigger )
+    {
+    TTriggerType triggerType;
+    TRiContextStatus contextStatus;
+    TDomainOperation domainOperation;
+    RPointerArray<HBufC8> contentIds;
+    CRoapEng* roapEng = CRoapEng::NewL();
+    TBool r = EFalse;
+
+    TCleanupItem item( DoResetAndDestroy, &contentIds );
+    CleanupStack::PushL( item );
+    CleanupStack::PushL( roapEng );
+    roapEng->SetTriggerL( aTrigger, NULL, triggerType, contextStatus,
+        domainOperation, contentIds );
+
+    // if we have a valid RI context, or if there is no user confirmation needed, do the ROAP
+    if ( contextStatus != EInvalidContext )
+        {
+        roapEng->AcceptL( this, &iStatus );
+        SetActive();
+        iWait.Start();
+        User::LeaveIfError( iStatus.Int() );
+        r = ETrue;
+        }
+    CleanupStack::PopAndDestroy( roapEng );
+    CleanupStack::PopAndDestroy( &contentIds );
+    return r;
+    }
+
+EXPORT_C HBufC8* CRoapSyncWrapper::GetErrorUrlL( const TInt aError, TInt& aErrorType )
+    {
+
+    // ROAP ERROR CODES
+    switch ( aError )
+        {
+        case KErrRoapUnsupported:
+        case KErrRoapServerFatal:
+        case KErrRoapDevice:
+        case KErrRoapInvalidDomain:
+            {
+            aErrorType = KErrRoapPermanent;
+            break;
+            }
+        case KErrRoapGeneral:
+        case KErrRoapServer:
+        case KErrRoapDomainFull:
+        case KErrRoapNotRegistered:
+            {
+            aErrorType = KErrRoapTemporary;
+            break;
+            }
+        }
+
+    if( iErrorUrl )
+        {
+        return iErrorUrl->AllocL();
+        }
+    return NULL;
+    }
+
+void CRoapSyncWrapper::ErrorUrlL( const TDesC8& aErrorUrl )
+    {
+    UpdateUrlL( iErrorUrl, aErrorUrl );
+    }
+
+void CRoapSyncWrapper::DoCancel()
+    {
+    if (iWait.IsStarted())
+        {
+        iWait.AsyncStop();
+        }
+    }
+
+void CRoapSyncWrapper::RunL()
+    {
+    iWait.AsyncStop();
+    }
+
+TBool CRoapSyncWrapper::ConnectionConfL()
+    {
+    return ETrue;
+    }
+
+TBool CRoapSyncWrapper::ContactRiConfL()
+    {
+    return ETrue;
+    }
+
+TBool CRoapSyncWrapper::TransIdConfL()
+    {
+    return EFalse;
+    }
+
+void CRoapSyncWrapper::RightsObjectDetailsL(
+    const RPointerArray<CDRMRights>& /*aRightsList*/ )
+    {
+    // do nothing
+    }
+
+void CRoapSyncWrapper::ContentDownloadInfoL( TPath& /*aTempFolder*/,
+    TFileName& /*aContentName*/,
+    TInt& aMaxSize )
+    {
+    aMaxSize = -1;
+    }
+
+void CRoapSyncWrapper::ContentDetailsL( const TDesC& /*aPath*/,
+    const TDesC8& /*aType*/,
+    const TUid& /*aAppUid*/ )
+    {
+    }
+
+
+void CRoapSyncWrapper::RoapProgressInfoL( const TInt /*aProgressInfo*/ )
+    {
+    // do nothing
+    }
+
+void CRoapSyncWrapper::PostResponseUrlL( const TDesC8& aPostResponseUrl )
+    {
+    UpdateUrlL( iPostResponseUrl, aPostResponseUrl );
+    }
+
+EXPORT_C HBufC8* CRoapSyncWrapper::GetPostResponseUrlL()
+    {
+    if ( iPostResponseUrl )
+        {
+        return iPostResponseUrl->AllocL();
+        }
+    return NULL;
+    }
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RoapTrigger.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,307 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+
+#include "RoapTrigger.h"
+
+using namespace Roap;
+
+// ================= CONSTANTS =======================
+_LIT8( KTriggerHeader, "<roap-trigger:roapTrigger>" );
+_LIT8(KRegistrationStart, "<registrationRequest>");
+_LIT8(KRegistrationEnd, "</registrationRequest>");
+_LIT8(KRoAcquisitionStart, "<roAcquisition>");
+_LIT8(KRoAcquisitionEnd, "</roAcquisition>");
+_LIT8(KJoinDomianStart, "<joinDomain>");
+_LIT8(KJoinDomianEnd, "</joinDomain>");
+_LIT8(KLeaveDomianStart, "<leaveDomain>");
+_LIT8(KLeaveDomianEnd, "</leaveDomain>");
+#ifdef RD_DRM_METERING
+_LIT8(KExtendedTriggerStart, "<extendedTrigger ");
+_LIT8(KIdStart, "id=\"");
+_LIT8(KIdEnd, "\" " );
+_LIT8(KMeteringType, "type=\"meteringReport\">");
+_LIT8(KExtendedTriggerEnd, "</extendedTrigger>");
+#endif
+_LIT8(KRiIdStart, "<riID><keyIdentifier xsi:type=\"roap:X509SPKIHash\"><hash>");
+_LIT8(KRiIdEnd, "</hash></keyIdentifier></riID>");
+_LIT8(KRiAliasStart, "<riAlias>");
+_LIT8(KRiAliasEnd, "</riAlias>");
+_LIT8(KRoapUrlStart, "<roapURL>");
+_LIT8(KRoapUrlEnd, "</roapURL>");
+_LIT8(KDomainIdStart, "<domainID>");
+_LIT8(KDomainIdEnd, "</domainID>");
+_LIT8(KDomainAliasStart, "<domainAlias>");
+_LIT8(KDomainAliasEnd, "</domainAlias>");
+_LIT8(KRoIdStart, "<roID>");
+_LIT8(KRoIdEnd, "</roID>");
+_LIT8(KContentIdStart, "<contentID>");
+_LIT8(KContentIdEnd, "</contentID>");  
+_LIT8( KTriggerEnd,"</roap-trigger:roapTrigger>");
+
+
+// FORWARD DECLARATIONS
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CRoapTrigger::NewL()
+// ---------------------------------------------------------
+//
+EXPORT_C CRoapTrigger* CRoapTrigger::NewL()
+    {
+    CRoapTrigger* data = new (ELeave) CRoapTrigger();
+    CleanupStack::PushL( data );
+    data->ConstructL();
+    CleanupStack::Pop( data );
+    return data;
+    }
+    
+// ---------------------------------------------------------
+// CRoapTrigger::NewL()
+// ---------------------------------------------------------
+//
+EXPORT_C CRoapTrigger* CRoapTrigger::NewL( const TTriggerType& aTriggerType,
+                                           const TDesC8& aRiId,
+                                           const TDesC8& aDomainId,
+                                           const TDesC8& aRoapUrl,
+                                           const RPointerArray<HBufC8>& aRoIdList,
+                                           const RPointerArray<HBufC8>& aContentIdList )
+    {
+    CRoapTrigger* data = new (ELeave) CRoapTrigger();
+    CleanupStack::PushL( data );
+    data->ConstructL( aTriggerType, aRiId, aDomainId, aRoapUrl, aRoIdList, aContentIdList );
+    CleanupStack::Pop( data );
+    return data;
+    }
+
+// ---------------------------------------------------------
+// CRoapTrigger::~CRoapTrigger()
+// ---------------------------------------------------------
+//
+EXPORT_C CRoapTrigger::~CRoapTrigger()
+    {
+    delete iId;
+    delete iDomainId;
+    delete iRoapUrl;
+    delete iSignature;
+    delete iEncKey;
+    delete iNonce;
+    delete iDigestValue;
+    delete iRiAlias;
+    delete iDomainAlias;
+    iRoIdList.ResetAndDestroy();
+    iContentIdList.ResetAndDestroy();
+    }
+
+// ---------------------------------------------------------
+// CRoapTrigger::CRoapTrigger()
+// ---------------------------------------------------------
+//
+CRoapTrigger::CRoapTrigger():
+    iId(NULL),
+    iDomainId(NULL),
+    iRoapUrl(NULL),
+    iSignature(NULL),
+    iEncKey(NULL),
+    iNonce(NULL),
+    iDigestValue(NULL),
+    iRiAlias(NULL)
+    {
+    }
+
+// ---------------------------------------------------------
+// CRoapTrigger::ConstructL()
+// ---------------------------------------------------------
+//
+void CRoapTrigger::ConstructL()
+    {  
+    }
+    
+// ---------------------------------------------------------
+// CRoapTrigger::ConstructL()
+// ---------------------------------------------------------
+//
+void CRoapTrigger::ConstructL( const TTriggerType& aTriggerType,
+                               const TDesC8& aRiId,
+                               const TDesC8& aDomainId,
+                               const TDesC8& aRoapUrl,
+                               const RPointerArray<HBufC8>& aRoIdList,
+                               const RPointerArray<HBufC8>& aContentIdList )
+    {
+    HBufC8* temp = NULL;
+    
+    iTriggerType = aTriggerType;
+    iRiId.Copy( aRiId );
+    iDomainId = aDomainId.AllocL();
+    iRoapUrl = aRoapUrl.AllocL();
+    
+    for( TInt i = 0; i < aRoIdList.Count(); i++ )
+        {
+        temp = aRoIdList[i]->AllocLC();
+        iRoIdList.AppendL( temp );
+        CleanupStack::Pop(); //temp
+        }
+        
+    for( TInt i = 0; i < aContentIdList.Count(); i++ )
+        {
+        temp = aContentIdList[i]->AllocLC();
+        iContentIdList.AppendL( temp );
+        CleanupStack::Pop(); //temp
+        }    
+    }
+    
+// -----------------------------------------------------------------------------
+// CRoapTrigger::MessageAsXmlL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* CRoapTrigger::MessageAsXmlL(void)
+    {
+    HBufC8* r = NULL;
+    CBufFlat* b = NULL;
+    TInt i;
+
+    b = CBufFlat::NewL(128);
+    CleanupStack::PushL(b);
+    BufAppendL(b, KTriggerHeader);
+    
+    switch ( iTriggerType )
+        {
+        case ERegistrationTrigger:
+            BufAppendL(b, KRegistrationStart);
+            break;
+        case ERoAcquisitionTrigger:
+            BufAppendL(b, KRoAcquisitionStart);
+            break;
+        case EJoinDomainTrigger:
+            BufAppendL(b, KJoinDomianStart);
+            break;
+        case ELeaveDomainTrigger:
+            BufAppendL(b, KLeaveDomianStart);
+            break;
+#ifdef RD_DRM_METERING            
+        case EExtendedTrigger:
+            BufAppendL(b, KExtendedTriggerStart);
+            BufAppendL(b, KIdStart);
+            BufAppendL(b, *iId );
+            BufAppendL(b, KIdEnd);
+            BufAppendL(b, KMeteringType );
+            break;
+#endif        
+        }
+        
+    if (iRiId.Length() > 0)
+        {
+        BufAppendL(b, KRiIdStart);
+        BufAppendBase64L(b, iRiId);
+        BufAppendL(b, KRiIdEnd);
+        }
+        
+    if (iRiAlias)
+        {
+        BufAppendL(b, KRiAliasStart);
+        BufAppendBase64L(b, *iRiAlias);
+        BufAppendL(b, KRiAliasEnd);
+        }
+        
+    if (iDomainId)
+        {
+        BufAppendL(b, KDomainIdStart);
+        BufAppendL(b, *iDomainId);
+        BufAppendL(b, KDomainIdEnd);
+        }
+        
+     if (iDomainAlias)
+        {
+        BufAppendL(b, KDomainAliasStart);
+        BufAppendBase64L(b, *iDomainAlias);
+        BufAppendL(b, KDomainAliasEnd);
+        }
+        
+     if (iRoapUrl)
+        {
+        BufAppendL(b, KRoapUrlStart);
+        BufAppendL(b, *iRoapUrl);
+        BufAppendL(b, KRoapUrlEnd);
+        }
+        
+    for (i = 0; i < iRoIdList.Count(); i++)
+        {
+        BufAppendL(b, KRoIdStart);
+        BufAppendL(b, *iRoIdList[i]);
+        BufAppendL(b, KRoIdEnd);
+        }
+        
+    for (i = 0; i < iContentIdList.Count(); i++)
+        {
+        BufAppendL(b, KContentIdStart);
+        BufAppendL(b, *iContentIdList[i]);
+        BufAppendL(b, KContentIdEnd);
+        }
+         
+    switch ( iTriggerType )
+        {
+        case ERegistrationTrigger:
+            BufAppendL(b, KRegistrationEnd);
+            break;
+        case ERoAcquisitionTrigger:
+            BufAppendL(b, KRoAcquisitionEnd);
+            break;
+        case EJoinDomainTrigger:
+            BufAppendL(b, KJoinDomianEnd);
+            break;
+        case ELeaveDomainTrigger:
+            BufAppendL(b, KLeaveDomianEnd);
+            break;
+#ifdef RD_DRM_METERING            
+        case EExtendedTrigger:
+            BufAppendL(b, KExtendedTriggerEnd);
+            break;
+#endif            
+        }
+
+    BufAppendL(b, KTriggerEnd);
+
+    r = b->Ptr(0).AllocL();
+    CleanupStack::PopAndDestroy(b);
+    return r;
+    }
+    
+// ---------------------------------------------------------
+// CRoapTrigger::ValidTrigger()
+// ---------------------------------------------------------
+//    
+EXPORT_C TBool CRoapTrigger::ValidTrigger()
+    {
+    if ( iTriggerType == EJoinDomainTrigger ||
+         iTriggerType == ELeaveDomainTrigger )
+        {
+        if ( !iDomainId )
+            {
+            return EFalse;
+            }
+        }
+    if ( iRiId.Length() > 0 && iRoapUrl )
+        {
+        return ETrue;
+        }
+    return EFalse;   
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roap/src/RoapTriggerParser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,181 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "Base64.h"
+#include "RoapParser.h"
+#include "RoapTrigger.h"
+#include "RoapTriggerParser.h"
+
+using namespace Roap;
+
+// LOCAL CONSTANTS AND MACROS
+
+_LIT8(KId, "id");
+#ifdef RD_DRM_METERING  
+_LIT8(KType, "type");
+_LIT8(KMeteringReport, "meteringReport" );
+#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TRoapTriggerParser::TRoapTriggerParser
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+TRoapTriggerParser::TRoapTriggerParser(
+    CRoapTrigger* aResponse)
+    {
+    iResponse = aResponse;
+    }
+
+// -----------------------------------------------------------------------------
+// TRoapTriggerRespParser::OnStartElementL
+// 
+// -----------------------------------------------------------------------------
+//
+void TRoapTriggerParser::OnStartElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/,
+    const RAttributeArray& aAttributes)
+    {
+    if (aState == ERegistrationRequestState ||
+        aState == ERoAcquisitionState ||
+        aState == EJoinDomainState ||
+        aState == ELeaveDomainState
+#ifdef RD_DRM_METERING            
+        || aState == EExtendedTriggerElementState 
+#endif  
+        )
+        {
+        iResponse->iId =
+            aParser.GetAttributeValueL(aAttributes, KId);
+
+        }
+    switch (aState)
+        {
+        case ERegistrationRequestState:
+            iResponse->iTriggerType = ERegistrationTrigger;
+            break;
+        case ERoAcquisitionState:
+            iResponse->iTriggerType = ERoAcquisitionTrigger;
+            break;
+        case EJoinDomainState:
+            iResponse->iTriggerType = EJoinDomainTrigger;
+            break;
+        case ELeaveDomainState:
+            iResponse->iTriggerType = ELeaveDomainTrigger;
+            break;
+#ifdef RD_DRM_METERING                   
+        case EExtendedTriggerElementState:
+            HBufC8* type = aParser.GetAttributeValueL(aAttributes, KType);
+            CleanupStack::PushL( type );
+            if ( type->Compare( KMeteringReport ) == 0 )
+                {
+                iResponse->iTriggerType = EMeteringReportTrigger;                     
+                }
+            else
+                { // We have an unsupported extendedTrigger
+                iResponse->iTriggerType = EExtendedTrigger;
+                }
+            CleanupStack::PopAndDestroy( type ); // Not needed anymore since
+            break;                               // triggerType is set
+#endif                 
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TRoapTriggerRespParser::OnEndElementL
+// 
+// -----------------------------------------------------------------------------
+//
+void TRoapTriggerParser::OnEndElementL(
+    CRoapParser& aParser,
+    TInt aState,
+    const RTagInfo& /*aElement*/)
+    {
+    HBufC8* buffer = NULL;
+
+    switch (aState)
+        {
+        case ERoapUrlState:
+            if( aParser.iContent )
+                iResponse->iRoapUrl = aParser.iContent->AllocL();                    
+            break;
+        case EDomainIdState:
+            if( aParser.iContent && !iResponse->iDomainId )
+                iResponse->iDomainId = aParser.iContent->AllocL();                    
+            break;
+        case ERiIdState:
+            buffer = Base64DecodeL(*aParser.iContent);
+            if ( buffer->Length() > SHA1_HASH )
+                {
+                delete buffer;
+                buffer = NULL;
+                User::Leave( KErrCorrupt );
+                }
+            iResponse->iRiId.Copy(*buffer);
+            delete buffer;
+            break;
+        case ERoIdState:
+            if( aParser.iContent )
+                {
+                buffer = aParser.iContent->AllocLC();
+                iResponse->iRoIdList.AppendL( buffer );
+                CleanupStack::Pop();
+                }
+            break;
+        case EContentIdState:
+            if( aParser.iContent )
+                {
+                buffer = aParser.iContent->AllocLC();
+                iResponse->iContentIdList.AppendL( buffer );
+                CleanupStack::Pop();
+                }                    
+            break;
+        case ESignatureValueState:
+            iResponse->iSignature = Base64DecodeL(*aParser.iContent);
+            break;
+        case EEncKeyState:
+            iResponse->iEncKey = Base64DecodeL(*aParser.iContent);
+            break;
+        case ENonceState:
+            if( aParser.iContent )
+                iResponse->iNonce = aParser.iContent->AllocL();                   
+            break;
+        case EDigestValueState:
+            if( aParser.iContent )
+                iResponse->iDigestValue = Base64DecodeL(*aParser.iContent);                   
+            break;
+        case ERiAliasState:
+            if( aParser.iContent )
+                   iResponse->iRiAlias = aParser.iContent->AllocL();
+            break;
+        case EDomainAliasState:
+            if( aParser.iContent )
+                   iResponse->iDomainAlias = aParser.iContent->AllocL();
+            break;
+        }
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/inc/DRMDomainContext.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,450 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Datatype for the Common Rights Database Data
+*
+*/
+
+
+#ifndef DRMDOMAINCONTEXT_H
+#define DRMDOMAINCONTEXT_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include "RoapMessage.h"
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class RReadStream;
+class RWriteStream;
+class CRSAPublicKey;
+
+// TYPE DEFINITIONS
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+using namespace Roap;
+
+/**
+*  CDRMDomainContext implements a datatype for the common data for a single
+*  content identifier
+*
+*  @lib RightsServer.dll
+*  @since 3.0
+*/
+
+class CDRMDomainContext : public CBase
+    {
+
+    public: // Constructors and destructor
+
+        /**
+        * NewLC
+        *
+        * Creates an instance of the CDRMDomainContext class and returns a pointer
+        * to it. The function leaves the object into the cleanup stack
+        *
+        * @since    3.0
+        * @param    aDomainID : Domain Identifier
+        * @param    aExpiryTime : Domain expiration time
+        * @param    aHashChained : Does the domain support hash chaining
+        * @param    aDomainKeys : a pointer array of the domain keys
+        * @param    aRiId : the rights issuer ID
+        * @param    aRightsIssuerURL : the rights issuer URL
+        * @return   Functional CDRMDomainContext object, Function leaves if an error
+        *           occurs.
+        */
+        IMPORT_C static CDRMDomainContext* NewLC( const TDesC8& aDomainID,
+                                         const TTime& aExpiryTime,
+                                         const TBool aHashChained,
+                                         const RPointerArray< HBufC8 >& aDomainKeys,
+                                         const TDesC8& aRiId,
+                                         const TDesC8& aRightsIssuerURL );
+
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMDomainContext class and returns a pointer
+        * to it.
+        *
+        * @since    3.0
+        * @param    aDomainID : Domain Identifier
+        * @param    aExpiryTime : Domain expiration time
+        * @param    aHashChained : Does the domain support hash chaining
+        * @param    aDomainKeys : a pointer array of the domain keys
+        * @param    aRiId : the rights issuer ID
+        * @param    aRightsIssuerURL : the rights issuer URL
+        * @return   Functional CDRMDomainContext object, Function leaves if an error
+        *           occurs.
+        */
+        IMPORT_C static CDRMDomainContext* NewL( const TDesC8& aDomainID,
+                                        const TTime& aExpiryTime,
+                                        const TBool aHashChained,
+                                        const RPointerArray< HBufC8 >& aDomainKeys,
+                                        const TDesC8& aRiId,
+                                        const TDesC8& aRightsIssuerURL );
+
+
+        /**
+        * NewLC
+        *
+        * Creates an instance of the CDRMDomainContext class and returns a pointer
+        * to it. The function leaves the object into the cleanup stack
+        *
+        * @since  3.0
+        * @return Functional CDRMDomainContext object, Function leaves if an error
+        *         occurs.
+        */
+        IMPORT_C static CDRMDomainContext* NewLC();
+
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMDomainContext class and returns a pointer
+        * to it.
+        *
+        * @since  3.0
+        * @return Functional CDRMDomainContext object, Function leaves if an error
+        *         occurs.
+        */
+        IMPORT_C static CDRMDomainContext* NewL();
+
+        /**
+        * Default Constructor - First phase.
+        * Can be used by itself to generate an empty object
+        */
+        CDRMDomainContext();
+
+        /**
+        * Destructor
+        */
+        IMPORT_C virtual ~CDRMDomainContext();
+
+
+        /**
+        * DomainID
+        *
+        * Returns a constant TDesC8& reference to the domain id
+        *
+        * @since    3.0
+        * @return   a pointer to the content id or null
+        */
+        IMPORT_C const TPtrC8 DomainID() const;
+
+        /**
+        * ExpiryTime
+        *
+        * Returns a constant TTime reference to the expiry time
+        *
+        * @since    3.0
+        * @return   a pointer to the content hash or null
+        */
+        IMPORT_C const TTime ExpiryTime() const;
+
+        /**
+        * HashChained
+        *
+        * Returns a constant TBool reference to the hash chained boolean
+        *
+        * @since    3.0
+        * @return   a pointer to the rights issuer or null
+        */
+        IMPORT_C TBool HashChained() const;
+
+        /**
+        * DomainKeys
+        *
+        * Return a constant RPointerArray reference to the domain keys
+        *
+        * @since    3.0
+        * @return   a pointer to the content name or null
+        */
+        IMPORT_C const RPointerArray< HBufC8 >& DomainKeys() const;
+
+        /**
+        * DomainKeyL
+        *
+        * Return a pointer of the domain key specified by the parameter
+        * Note: pointer ownership goes to caller. I.e. Caller is responsible
+        * of freeing memory reserved for the pointer.
+        *
+        * @since    3.0
+        * @leave    KErrAgument if aGeneration is not valid
+        * @return   a reference to the key
+        */
+        IMPORT_C HBufC8* DomainKeyL( const TInt aGeneration ) const;
+
+        /**
+        * Generation
+        *
+        * Returns a constant TInt reference to the domain generation
+        *
+        * @since    3.0
+        * @return   a pointer to the rights issuer or null
+        */
+        IMPORT_C TInt DomainGeneration() const;
+
+
+        /**
+        * PublicKey
+        *
+        * Returns a constant reference to rights issuer ID
+        *
+        * @since    3.0
+        * @return   the rights issuer ID
+        */
+        IMPORT_C const TDesC8& RightsIssuerID() const;
+
+        /**
+        * RightsIssuerURL
+        *
+        * Returns a constant TDesC8& reference to the rights issuer url
+        *
+        * @since    3.0
+        * @return   a pointer to the content id or null
+        */
+        IMPORT_C const TDesC8& RightsIssuerURL() const;
+
+
+
+        /**
+        * SetDomainIDL
+        *
+        * Sets the domain id, deletes the previous one if one
+        * exits
+        *
+        * @since    3.0
+        * @param    aDomainID : Domain identifier
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void SetDomainIDL( const TDesC8& aDomainID );
+
+        /**
+        * SetExpiryTimeL
+        *
+        * Sets the expiration time
+        *
+        * @since    3.0
+        * @param    aExpiryTime : expiration time
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void SetExpiryTimeL( const TTime& aExpiryTime );
+
+        /**
+        * SetHashChainedL
+        *
+        * Sets the hash chained status
+        *
+        * @since    3.0
+        * @param    aHashChained : hash chained status boolean value
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void SetHashChainedL( const TBool& aHashChained );
+
+
+        /**
+        * SetDomainKeysL
+        *
+        * Sets the domain keys, deletes the old ones if they exist
+        *
+        * @since    3.0
+        * @param    aDomainKeys : pointer array with the domain keys
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void SetDomainKeysL( const RPointerArray< HBufC8 >& aDomainKeys );
+
+        /**
+        * SetPublicKeyL
+        *
+        * Sets the public key, deletes the old one if one exist
+        *
+        * @since    3.0
+        * @param    aRightsIsserID : rights issuer ID
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void SetRightsIssuerIDL( const TDesC8& aRightsIssuerID );
+
+        /**
+        * SetRightsIssuerURLL
+        *
+        * Sets the rights issuer url, deletes the previous one if one
+        * exits
+        *
+        * @since    3.0
+        * @param    aRightsIssuerURL : rights issuer url
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void SetRightsIssuerURLL( const TDesC8& aRightsIssuerURL );
+
+
+        /**
+        * ExternalizeL
+        *
+        * Writes the data of the object into the stream
+        *
+        * @since    3.0
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
+
+        /**
+        * InternalizeL
+        *
+        * Reads the data of the object from the stream
+        *
+        * @since    3.0
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void InternalizeL( RReadStream& aStream );
+
+        /**
+        * ImportL
+        *
+        * Reads the data of the object from the descriptor and initialized the
+        * object accordingly
+        *
+        * @since    3.0
+        * @param    aBuffer : the buffer containing the data of the imported object
+        * @return   None, The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void ImportL( const TDesC8& aBuffer );
+
+        /**
+        * ExportL
+        *
+        * Writes the data of the object into an HBufC8 and returns a pointer
+        * to it. The caller is responsible for deleting the object.
+        *
+        * @since    3.0
+        * @return   Returns an HBufC8* containing the data of the object,
+        *           The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C HBufC8* ExportL() const;
+
+
+        /**
+        * Size
+        *
+        * Returns the size of the externalized object
+        *
+        * @since    3.0
+        * @return   the amount of bytes the externalize object occupies
+        */
+        IMPORT_C TInt Size() const;
+
+    protected:
+        /**
+        * Constructor
+        */
+        CDRMDomainContext( const TTime& aExpiryTime,
+                           const TBool aHashChained );
+
+    private:
+
+
+        /**
+        * ConstructL
+        *
+        * Second phase constructor
+        *
+        * @since  3.0
+        * @param  aContentID : Content Identifier
+        * @param  aContentHash : Content Hash
+        * @param  aRightsIssuer : Rights Issuer for this content
+        * @return Functional CDRMDomainContext object, Function leaves if an error
+        *         occurs.
+        */
+        void ConstructL( const TDesC8& aDomainID,
+                         const RPointerArray< HBufC8 > aDomainKeys,
+                         const TDesC8& aRightsIssuerID,
+                         const TDesC8& aRightsIssuerURL );
+
+        /**
+        * Assignment operator - Prevented
+        */
+        CDRMDomainContext& operator =( const CDRMDomainContext& );
+
+        /**
+        * Copy constructor - Prevented
+        */
+        CDRMDomainContext( const CDRMDomainContext& );
+
+        /**
+        * WriteInt64L
+        *
+        * Writes the 64 bit integer to the stream
+        *
+        * @since    3.0
+        * @param    aWrite : the 64 bit integer to write
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const;
+
+        /**
+        * ReadInt64L
+        *
+        * Reads the 64 bit integer from the stream
+        *
+        * @since    3.0
+        * @param    aRead : the 64 bit integer read
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void ReadInt64L( TInt64& aRead, RReadStream& aStream );
+
+    private: // Internal Data
+
+        // Domain identifier
+        TBuf8< KDomainIdLength > iDomainID;
+
+        // Expiry time
+        TTime iExpiryTime;
+
+        // Has chained domain key support
+        TBool iHashChained;
+
+        // Domain keys
+        RPointerArray< HBufC8 > iDomainKeys;
+
+        TBuf8< SHA1_HASH > iRightsIssuerID;
+
+        // Rights issuer URL
+        HBufC8* iRightsIssuerURL;
+    };
+
+#endif      // DRMCOMMONDATA_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/inc/DRMRIContext.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,617 @@
+/*
+* 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:  Datatype for the Common Rights Database Data
+*
+*/
+
+
+#ifndef DRMRICONTEXT_H
+#define DRMRICONTEXT_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <hash.h>
+#include "RoapMessage.h"
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class RReadStream;
+class RWriteStream;
+
+// TYPE DEFINITIONS
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMRIContext implements a datatype for the common data for a single
+*  content identifier
+*
+*  @lib RightsServer.dll
+*  @since 3.0
+*/
+
+class CDRMRIContext : public CBase 
+    {
+    
+    public: // Constructors and destructor
+        
+        /**
+        * NewLC
+        *
+        * Creates an instance of the CDRMRIContext class and returns a pointer 
+        * to it. The function leaves the object into the cleanup stack
+        *
+        * @since    3.0
+        * @param    aRIID : Rights issue identifier SHA1_HASH
+        * @param    aRiAlias: RI Alias, extracted from RoapTrigger        
+        * @param    aVersion : Selected version KMaxRoapVersionLength
+        * @param    aAlgorithms : Algorithm strings
+        * @param    aRIURLs : Rights issuer urls,
+        * @param    aRightsIssuerURL: An URL that can be used for contactig the RI
+        *                             (e,g, in the case where RI Context is expired)
+        * @param    aExpiryTime : Expiration time
+        * @param    aChain: The RI ceritificate chain
+        * @param    aResponses: The OCSP responses for validating certificates
+        *                       in the RI certificate chain
+        * @param    aSelectedDeviceRoot: The selected certificate chain that is
+        *           used for wrapping the REKs and Domain Keys. Presented as a
+        *           public key hash of the root certificate
+        * @param    aIsMeteringAllowed: Wheter metering is allowed for this RI
+        *  
+        * @return   Functional CDRMRIContext object, Function leaves if an error 
+        *           occurs.
+        */
+        IMPORT_C static CDRMRIContext* NewLC( const TDesC8& aRIID,
+                                              const TDesC8& aRiAlias,
+                                              const TDesC8& aVersion,
+                                              const RPointerArray< HBufC8 >& aAlgorithms,
+                                              const RPointerArray< HBufC8 >& aRIURLs,
+                                              const TDesC8& aRightsIssuerURL,
+                                              const TTime& aExpiryTime,
+                                              const RPointerArray< HBufC8 >& aChain,
+                                              const RPointerArray< HBufC8 >& aResponses,
+                                              const TUint8 aDeviceCertCached,
+                                              const TDesC8& aSelectedDeviceRoot,
+                                              const TUint8 aIsMeteringAllowed = ETrue );
+        
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMRIContext class and returns a pointer 
+        * to it.
+        *
+        * @since    3.0
+        * @param    aRIID : Rights issue identifier SHA1_HASH
+        * @param    aRiAlias: RI Alias, extracted from RoapTrigger            
+        * @param    aVersion : Selected version KMaxRoapVersionLength
+        * @param    aAlgorithms : Algorithm strings
+        * @param    aRIURLs : Rights issuer urls
+        * @param    aExpiryTime : Expiration time
+        * @param    aChain: The RI ceritificate chain
+        * @param    aResponses: The OCSP responses for validating certificates
+        *                       in the RI certificate chain        
+        * @param    aSelectedDeviceRoot: The selected certificate chain that is
+        *           used for wrapping the REKs and Domain Keys. Presented as a
+        *           public key hash of the root certificate
+        * @param    aIsMeteringAllowed: Wheter metering is allowed for this RI        
+        *  
+        * @return   Functional CDRMRIContext object, Function leaves if an error 
+        *           occurs.
+        */
+        IMPORT_C static CDRMRIContext* NewL( const TDesC8& aRIID,
+                                             const TDesC8& aRiAlias,        
+                                             const TDesC8& aVersion,
+                                             const RPointerArray< HBufC8 >& aAlgorithms,
+                                             const RPointerArray< HBufC8 >& aRIURLs,
+                                             const TDesC8& aRightsIssuerURL,
+                                             const TTime& aExpiryTime,
+                                             const RPointerArray< HBufC8 >& aChain,
+                                             const RPointerArray< HBufC8 >& aResponses,
+                                             const TUint8 aDeviceCertCached,
+                                             const TDesC8& aSelectedDeviceRoot,
+                                             const TUint8 aIsMeteringAllowed = ETrue );
+
+        /**
+        * NewLC
+        *
+        * Creates an instance of the CDRMRIContext class and returns a pointer 
+        * to it. The function leaves the object into the cleanup stack
+        *
+        * @since    3.0
+        * @return   Functional CDRMRIContext object, Function leaves if an error 
+        *           occurs.
+        */
+        IMPORT_C static CDRMRIContext* NewLC();
+        
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMRIContext class and returns a pointer 
+        * to it.
+        *
+        * @since    3.0
+        * @return   Functional CDRMRIContext object, Function leaves if an error 
+        *           occurs.
+        */
+        IMPORT_C static CDRMRIContext* NewL();
+
+        /**
+        * Destructor
+        */
+        IMPORT_C virtual ~CDRMRIContext();
+        
+  public: // Get and set functions
+        
+        /**
+        * RIID
+        * 
+        * Returns a constant TDesC8 reference to the rights issuer id
+        *
+        * @since    3.0
+        * @return   a const reference to the rights issuer id
+        */        
+        IMPORT_C const TDesC8& RIID() const;
+        
+        /**
+        * RIAlias
+        * 
+        * Returns a constant TDesC8 reference to the rights issuer alias
+        *
+        * @since    3.2
+        * @return   a const reference to the rights issuer alias
+        */
+        IMPORT_C const TDesC8& RIAlias() const;
+        
+        
+        /**
+        * Version
+        * 
+        * Returns a constant TDesC8 reference to the version
+        *
+        * @since    3.0
+        * @return   a const reference to the rights issuer id
+        */        
+        IMPORT_C const TDesC8& Version() const;
+        
+
+        /**
+        * Algorithms
+        * 
+        * Returns a constant reference to the algorithm pointer array
+        *
+        * @since    3.0
+        * @return   a const reference to a pointer array with the algorithms
+        */        
+        IMPORT_C const RPointerArray< HBufC8 >& Algorithms() const;  
+
+
+        /**
+        * RIURLs
+        * 
+        * Returns a constant reference to the url pointer array
+        *
+        * @since    3.0
+        * @return   a const reference to a pointer array with the right issuer
+        *           urls
+        */        
+        IMPORT_C const RPointerArray< HBufC8 >& RIURLs() const;
+        
+        
+        /**
+        * RIURLs
+        * 
+        * Returns a constant reference to the rights issuer url
+        *
+        * @since    3.0
+        * @return   a const reference to a the rights issuer url
+        */
+        IMPORT_C const TDesC8& RightsIssuerURL() const;
+
+
+        /**
+        * ExpiryTime
+        *
+        * Returns a constant reference to the expiration time
+        *
+        * @since    3.0
+        * @return   a cont reference to the expiration time
+        */
+        IMPORT_C const TTime ExpiryTime() const;
+
+        
+        /**
+        * CertificateChain
+        * 
+        * Returns a constant reference to the algorithm pointer array
+        *
+        * @since    3.0
+        * @return   a const reference to a pointer array with the algorithms
+        */       
+        IMPORT_C const RPointerArray< HBufC8 >& CertificateChain() const;
+
+
+        /**
+        * OCSPResponse
+        * 
+        * Returns a constant reference to the algorithm pointer array
+        *
+        * @since    3.0
+        * @return   a const reference to a pointer array with the algorithms
+        */        
+        IMPORT_C const RPointerArray< HBufC8 >& OCSPResponse() const;
+        
+
+        /**
+        * DeviceCertCached
+        * 
+        * Returns an indication if the RI has stored the Device certificate or not
+        *
+        * @since    3.0
+        * @return   EFalse or ETrue
+        */         
+        IMPORT_C TUint8 DeviceCertCached() const;
+        
+        /**
+        * SelectedDeviceRoot
+        * 
+        * Returns a constant TDesC8 reference to the selected Device root
+        *
+        * @since    3.0
+        * @return   a const reference to the selected Device root
+        */      
+        IMPORT_C const TDesC8& SelectedDeviceRoot() const;
+
+        /**
+        * IsMeteringAllowed
+        * 
+        * Checks wheter metering is allowed for a this RightsIssuer
+        *
+        * @since    3.2
+        */        
+        IMPORT_C TUint8 IsMeteringAllowed() const; 
+
+        /**
+        * SetRIIDL
+        * 
+        * Sets the rights issuer identifier, overwrites the previous one 
+        * if one exits
+        *
+        * @since    3.0
+        * @param    aRIID : Rights Issuer Identifier        
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */        
+        IMPORT_C void SetRIIDL( const TDesC8& aRIID );
+
+
+        /**
+        * SetRightsIssuerURLL
+        * 
+        * Sets the RI URL, deletes the old one
+        *
+        * @since    3.0
+        * @param    aRightsIssuerURL : a reference to the new rights issuer url
+        */ 
+        IMPORT_C void SetRightsIssuerURLL( const TDesC8& aRightsIssuerURL );        
+        
+         /**
+        * SetVersionL
+        * 
+        * Sets the version, overwrites the previous one if one exits
+        *
+        * @since    3.0
+        * @param    aVersion : version string       
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */        
+        IMPORT_C void SetVersionL( const TDesC8& aRIID );    
+           
+
+        /**
+        * SetAlgorithmsL
+        * 
+        * Sets the algorithms, deletes the old ones
+        *
+        * @since    3.0
+        * @param    aAlgorithms : a pointer array with the used algorithms
+        * @return   a pointer to the content id or null
+        */        
+        IMPORT_C void SetAlgorithmsL( const RPointerArray< HBufC8 >& aAlgorithms ); 
+        
+        
+        /**
+        * SetRIURLsL
+        * 
+        * Sets the algorithms, deletes the old ones
+        *
+        * @since    3.0
+        * @param    aRIURLs : a pointer array with the rights issuer urls       
+        * @return   a pointer to the content id or null
+        */        
+        IMPORT_C void SetRIURLsL( const RPointerArray< HBufC8 >& aRIURLs );        
+             
+        /**
+        * SetExpiryTimeL
+        * 
+        * Sets the expiration time to the given value
+        *
+        * @since    3.0
+        * @param    aExpiryTime : the expiration time        
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */        
+        IMPORT_C void SetExpiryTimeL( const TTime& aExpiryTime );
+
+         /**
+        * SetCertificateChainL
+        * 
+        * Sets the certificate chain
+        *
+        * @since    3.0
+        * @param    aChain : the certificate chain        
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */          
+        IMPORT_C void SetCertificateChainL( const RPointerArray< HBufC8 >& aChain );
+        
+         /**
+        * SetOCSPResponseL
+        * 
+        * Sets the OCSP responses
+        *
+        * @since    3.0
+        * @param    aResponses : the OCSP responses      
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */         
+        IMPORT_C void SetOCSPResponseL( const RPointerArray< HBufC8 >& aResponses );
+        
+         /**
+        * SetDeviceCertCached
+        * 
+        * Sets the indication whether the RI has stored the Device public key or not
+        *
+        * @since    3.0
+        * @param    aIsCached : The certificate caching indication (ETrue/EFalse)     
+        */         
+        IMPORT_C void SetDeviceCertCached( TUint8& aIsCached );
+
+        /**
+        * WhiteListURLExistsL
+        * 
+        * Checks the white list to see if the url is in the list
+        *
+        * @since    3.0
+        * @param    aURL : the URL to look for       
+        * @return   ETrue if the url is in the white list
+        *           EFalse if it is not
+        */    
+        IMPORT_C TBool WhiteListURLExistsL( const TDesC8& aURL ) const;
+        
+        
+        /**
+        * SetSelectedDeviceRoot
+        * 
+        * Sets the selected Device root, overwrites the previous one 
+        * if one exits
+        *
+        * @since    3.0
+        * @param    aSelectedDeviceRoot : Hash of the root certificate public key
+        */        
+        IMPORT_C void SetSelectedDeviceRoot( const TDesC8& aSelectedDeviceRoot );
+
+        /**
+        * SetMeteringStatus
+        * 
+        * Sets the value for metering to be enabled or disabled
+        *
+        * @since    3.2
+        * @param    aIsAllowed : ETrue if set to allowed, EFalse if not allowed
+        */        
+        IMPORT_C void SetMeteringStatus( const TBool aIsAllowed );               
+                     
+    public: // Storing functions
+        /**
+        * ExternalizeL
+        * 
+        * Writes the data of the object into the stream
+        *
+        * @since    3.0
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
+        
+        /**
+        * InternalizeL
+        * 
+        * Reads the data of the object from the stream
+        *
+        * @since    3.0
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void InternalizeL( RReadStream& aStream );   
+
+
+        /**
+        * ImportL
+        * 
+        * Reads the data of the object from the descriptor and initialized the 
+        * object accordingly
+        *
+        * @since    3.0
+        * @param    aBuffer : the buffer containing the data of the imported object
+        * @return   None, The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C void ImportL( const TDesC8& aBuffer );
+    
+        /**
+        * ExportL
+        * 
+        * Writes the data of the object into an HBufC8 and returns a pointer
+        * to it. The caller is responsible for deleting the object.
+        *
+        * @since    3.0
+        * @return   Returns an HBufC8* containing the data of the object,
+        *           The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        IMPORT_C HBufC8* ExportL() const; 
+       
+        
+        /**
+        * Size
+        *
+        * Returns the size of the externalized object
+        *
+        * @since    3.0
+        * @return   the amount of bytes the externalize object occupies
+        */           
+        IMPORT_C TInt Size() const;
+        
+    private:
+        /**
+        * Default constructor
+        */
+        CDRMRIContext();    
+    
+        /**
+        * ConstructL
+        *
+        * Second phase constructor
+        *
+        * @since    3.0
+        * @param    aRIID : Rights issuer identifier SHA1_HASH
+        * @param    aRiAlias : Rights issuer alias from RoapTrigger        
+        * @param    aVersion : Selected version KMaxRoapVersionLength
+        * @param    aAlgorithms : Algorithm strings
+        * @param    aRIURLs : Rights issuer urls,
+        * @param    aRightsIssuerURL: An URL that can be used for contactig the RI
+        *                             (e,g, in the case where RI Context is expired)
+        * @param    aExpiryTime : Expiration time
+        * @param    aChain: The RI ceritificate chain
+        * @param    aResponses: The OCSP responses for validating certificates
+        *                       in the RI certificate chain
+        * @param    aSelectedDeviceRoot: The selected certificate chain that is
+        *           used for wrapping the REKs and Domain Keys. Presented as a
+        *           public key hash of the root certificate
+        * @param    aIsMeteringAllowed: Wheter metering is allowed for this RI
+        *        
+        * @return   Functional CDRMRIContext object, Function leaves if an error 
+        *           occurs.
+        */  
+        void ConstructL( const TDesC8& aRIID,
+                         const TDesC8& aRiAlias,
+                         const TDesC8& aVersion,
+                         const RPointerArray< HBufC8 >& aAlgorithms,
+                         const RPointerArray< HBufC8 >& aRIURLs,
+                         const TDesC8& aRightsIssuerURL,
+                         const TTime& aExpiryTime,
+                         const RPointerArray< HBufC8 >& aChain,
+                         const RPointerArray< HBufC8 >& aResponses,
+                         const TUint8 aDeviceCertCached,
+                         const TDesC8& aSelectedDeviceRoot,
+                         const TUint8 aIsMeteringAllowed );
+
+        /**
+        * Assignment operator - Prevented
+        */
+        CDRMRIContext& operator =( const CDRMRIContext& );    
+    
+        /**
+        * Copy constructor - Prevented
+        */
+        CDRMRIContext( const CDRMRIContext& );                
+
+        /**
+        * WriteInt64L
+        * 
+        * Writes the 64 bit integer to the stream
+        *
+        * @since    3.0
+        * @param    aWrite : the 64 bit integer to write
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const;
+
+        /**
+        * ReadInt64L
+        * 
+        * Reads the 64 bit integer from the stream
+        *
+        * @since    3.0
+        * @param    aRead : the 64 bit integer read
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void ReadInt64L( TInt64& aRead, RReadStream& aStream ); 
+
+
+    private: // Internal Data
+    
+        // Rights Issuer identifier
+        TBuf8<SHA1_HASH> iRIID;
+        
+        // Rights Issuer Alias
+        HBufC8* iRiAlias;
+        
+        // Selected Version
+        TBuf8<Roap::KMaxRoapVersionLength> iVersion;
+        
+        // Selected Algorithms
+        RPointerArray< HBufC8 > iAlgorithms;
+        
+        // Domain name white list
+        RPointerArray< HBufC8 > iRIURLs;
+        
+        // Rights issuer URL
+        HBufC8* iRightsIssuerURL;
+        
+        // Rights issuer context expiry time
+        TTime iExpiryTime;
+
+        // Rights issuer certificate chain        
+        RPointerArray<HBufC8> iCertificateChain;
+
+        // OCSP responses for validating certificates       
+        RPointerArray<HBufC8> iOcspResponse;
+
+        // Certificate caching indication (has an RI stored the Device certificate)        
+        TUint8 iDeviceCertCached;
+        
+        // The selected Device certificate chain
+        TBuf8<SHA1_HASH> iSelectedDeviceRoot;
+        
+        // The status of metering allowance
+        TUint8 iIsMeteringAllowed;
+    };
+
+#endif      // DRMRICONTEXT_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/inc/RoapOcsp.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,275 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OCSP response classes
+*
+*/
+
+
+#ifndef __ROAPOCSP_H__
+#define __ROAPOCSP_H__
+
+#include <e32base.h>
+#include <signed.h>
+#include <f32file.h>
+
+static const TInt KOCSPNonceBytes( 16 );
+
+class COCSPResponseCertInfo;
+class COCSPCertID;
+class COCSPResponse;
+class COCSPResponseDecoder;
+
+class CASN1EncBase;
+class CASN1EncContainer;
+class TASN1DecGeneric;
+
+class CX509Certificate;
+class CX509CertChain;
+class CPKIXCertChain;
+
+// Enums placed in OCSP namespace
+namespace OCSP
+    {
+    // Globally-reserved error codes - range is -7601 to -7649
+    enum
+        {
+        KErrTransportFailure = -7601,
+        KErrInvalidURI = -7602,
+        KErrNoCertificates = -7603
+        };
+
+    // What we think of the response, or why we haven't got one
+    enum TStatus
+        {
+        // Error in communication with server
+        ETransportError = 1,
+
+        // Internal problem processing response
+        EClientInternalError = 2,
+
+        // No OCSP server specified
+        ENoServerSpecified = 3,
+
+        // Invalid sever URI
+        EInvalidURI = 4,
+
+        // Problems understanding the response
+        EMalformedResponse = 10,
+        EUnknownResponseType = 11,
+        EUnknownCriticalExtension = 12,
+
+        // Unsuccessful responses from server
+        EMalformedRequest = 20,
+        EServerInternalError = 21,
+        ETryLater = 22,
+        ESignatureRequired = 23,
+        EClientUnauthorised = 24,
+
+        // Response validation failures
+        EMissingCertificates = 30,
+        EResponseSignatureValidationFailure = 31,
+
+        // Time problems
+        EThisUpdateTooLate = 40,
+        EThisUpdateTooEarly = 41,
+        ENextUpdateTooEarly = 42,
+        ECertificateNotValidAtValidationTime = 43,
+
+        // Nonce error
+        ENonceMismatch = 50,
+
+        // Response sufficiently valid to use - clients to decide if
+        // missing nonce is sufficiently serious to require rejection
+        EMissingNonce = 51,
+
+        EValid = 100,
+        };
+
+    // What does the response say about the certificates?
+    // IMPORTANT: Do not change the order these are in
+    enum TResult
+        {
+        EGood = 10, EUnknown = 20, ERevoked = 30
+        };
+    }
+
+/**
+* Information about a certificate sent as part of an OCSP request.
+*/
+
+NONSHARABLE_CLASS( COCSPRequestCertInfo ) : public CBase
+    {
+public:
+
+    /**
+    * Get the certificate present in the request.
+    */
+
+    const CX509Certificate& Subject() const;
+
+    /**
+    * Get the issuer of the certificate present in the request.
+    */
+
+    const CX509Certificate& Issuer() const;
+
+public:
+
+    // Not exported
+    static COCSPRequestCertInfo* NewLC(
+        const CX509Certificate& aSubject,
+        const CX509Certificate& aIssuer );
+
+    ~COCSPRequestCertInfo();
+
+    const COCSPCertID& CertID() const;
+
+private:
+
+    COCSPRequestCertInfo( const CX509Certificate& aIssuer,
+        const CX509Certificate& aSubject );
+    void ConstructL();
+
+private:
+
+    const CX509Certificate& iSubject;
+    const CX509Certificate& iIssuer;
+    COCSPCertID* iCertID;
+    };
+
+/**
+* Represents an OCSP protocol response.
+*/
+
+NONSHARABLE_CLASS( COCSPResponse ) : public CSignedObject
+    {
+public:
+
+    /**
+    * Get the number of certificates statuses present in the response.
+    */
+
+    TInt CertCount() const;
+
+    /**
+    * Get a COCSPResponseCertInfo object containing details about one of the
+    * certificate statuses present in the response.
+    */
+
+    COCSPResponseCertInfo* CertInfo( TUint aIndex ) const;
+
+    /**
+    * Get the producedAt time for the response.
+    */
+
+    TTime ProducedAt() const;
+
+    /**
+    * Get the archiveCutoff time for the response, or NULL if it was not present.
+    */
+
+    const TTime* ArchiveCutoff() const;
+
+    const TPtrC8* SigningCerts() const;
+
+public:
+
+    // This class is created and initialised by the response decoder
+    friend class COCSPResponseDecoder;
+
+    ~COCSPResponse();
+
+    /**
+    * Get the index for the given cert, or KErrNotFound.
+    */
+
+    TInt Find( const COCSPCertID& aCertID ) const;
+
+    // Enums to use in DataElementEncoding
+    enum
+        {
+        ECertificateChain,
+        ENonce,
+        EResponderIDName, // Only one of the ResponderIDs won't be NULL
+        EResponderIDKeyHash
+        };
+
+    // From CSignedObject
+    const TPtrC8* DataElementEncoding( const TUint aIndex ) const;
+
+private:
+
+    COCSPResponse();
+
+    // From CSignedObject
+    const TPtrC8 SignedDataL() const;
+    void InternalizeL( RReadStream& aStream );
+
+private:
+
+    // Time of response, and of archiveCutoff extension (if present)
+    TTime iProducedAt;
+    TTime* iArchiveCutoff;
+
+    // Value of nonce in response extension (if present)
+    TPtrC8 iNonce;
+
+    // Point to the signing certificates in the response
+    TPtrC8 iSigningCerts;
+
+    // Point to the signed portion of the data
+    TPtrC8 iSignedData;
+
+    // There are two ways the responder ID can be specified - only
+    // one of these will be used
+    TPtrC8 iResponderIDName;
+    TPtrC8 iResponderIDKeyHash;
+
+    RPointerArray<COCSPResponseCertInfo> iCertInfos;
+    };
+
+/**
+* Information about a certificate status, as given in OCSP response
+* singleResponse data item.
+*/
+
+NONSHARABLE_CLASS( COCSPResponseCertInfo ) : public CBase
+    {
+public:
+
+    OCSP::TResult Status() const;
+    TTime ThisUpdate() const;
+    const TTime* NextUpdate() const; // NULL if nextUpdate not set
+    const TTime* RevocationTime() const; // NULL if not revoked
+
+public:
+
+    static COCSPResponseCertInfo* NewLC( CArrayPtr<TASN1DecGeneric>& items );
+    ~COCSPResponseCertInfo();
+    COCSPCertID* CertID() const;
+
+private:
+    void ConstructL( CArrayPtr<TASN1DecGeneric>& items );
+
+private:
+    OCSP::TResult iStatus;
+
+    TTime iThisUpdate;
+    TTime* iNextUpdate;
+    TTime* iRevocationTime;
+
+    COCSPCertID* iCertID;
+    };
+
+#endif // __ROAPOCSP_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/inc/RoapStorageServer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,130 @@
+/*
+* 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:  DRM3 Notifier manages all notifications out of the system.
+*
+*/
+
+
+
+#ifndef CRoapStorageServer_H
+#define CRoapStorageServer_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include "RoapStorageSession.h"
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+TInt StartupRoapStorage( TAny* );
+ 
+// FORWARD DECLARATIONS
+// CLASS DECLARATION
+class CDRMContextDB;
+
+/**
+*  This class implements the Roap Storage Server functionality.
+*
+*  @lib RightsServer.exe
+*  @since 3.0
+*/
+NONSHARABLE_CLASS( CRoapStorageServer ) : public CServer2
+    {
+    public:  // Constructors and destructor
+        
+        /**
+         * Two-phased constructor.
+         * @since 3.0
+         * @return Pointer to newly created server instance.
+         */
+        static CRoapStorageServer* NewL();
+        
+        /**
+         * Destructor.
+         * @since 3.0
+         */
+        ~CRoapStorageServer();
+        
+         /**
+         * Returns CDRMContextDB handle 
+         * @since 3.0
+         */        
+        CDRMContextDB* ContextDB();
+        
+    public: // Functions from base classes
+
+    protected:  // New functions
+    
+        /**
+         * Import PKI keys into the private directory
+         * @since 3.0
+         */
+        void ImportKeysL();
+        
+    protected:  // Functions from base classes
+        //class CServer
+        /**
+         * RunError.
+         * @since 3.0
+         * @param aError Error code from RunL function.
+         * @return An error is returned if RunError() cannot process the
+         * error.
+         */
+        TInt RunError( TInt aError );
+        
+    private:
+        /**
+         * C++ default constructor.
+         * @since 3.0
+         */
+        CRoapStorageServer();
+        
+        /**
+         * By default Symbian 2nd phase constructor is private.
+         * @since 3.0
+         */
+        void ConstructL();
+        
+        
+    private: // Functions from base classes
+        // Class CServer
+        /** 
+         * NewSessionL
+         * @since 3.0
+         */
+        CSession2* NewSessionL( const TVersion& aVersion,
+                                const RMessage2& aMessage) const;
+        
+    public:     // Data
+        
+    protected:  // Data
+        
+    private:    // Data
+    
+        RFs iRFs;
+        CDRMContextDB* iRoapStorage;
+        
+    public:     // Friend classes
+        
+    protected:  // Friend classes
+        
+    private:    // Friend classes
+        
+};
+
+#endif      // CDRMRIGHTSSERVER_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/inc/RoapStorageSession.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,184 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This class declares the interface of class CRoapStorageSession.
+*                handles the queues for notification events
+*
+*/
+
+
+#ifndef ROAP_STORAGE_SESSION_H
+#define ROAP_STORAGE_SESSION_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// CONSTANTS
+// MACROS
+// FUNCTION PROTOTYPES
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class RMessage2;
+class MDrmKeyStorage;
+class LazyClockClient;
+
+// CLASS DECLARATION
+
+/**
+*  This class is the server side instance of C/S communications of a certain
+*  session.
+
+*  @since 3.0
+*/
+NONSHARABLE_CLASS( CRoapStorageSession ): public CSession2
+{
+    enum TPanic
+        {
+        EPanicBadDescriptor, EPanicBadFunction
+        };
+public:
+    // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     *
+     * @since 3.0
+     * @param aClient Associated client side thread.
+     * @return New session instance.
+     */
+    static CRoapStorageSession* NewL();
+
+    /**
+     * Destructor.
+     * @since 3.0
+     */
+    virtual ~CRoapStorageSession();
+
+public:
+    // Functions from base classes
+
+   /**
+     * From CSession2: Handles the service request event.
+     * @since 3.0
+     * @param aMessage The message related to the event.
+     */
+    void ServiceL( const RMessage2& aMessage );
+
+    /**
+     * Utility function for ServiceL
+     * @since 3.0
+     * @param aMessage The message related to the event.
+     * @exception Method leaves with appropriate exception value
+     *            if any errors occured.
+     */
+    void DispatchL( const RMessage2& aMessage );
+
+    /**
+     * From CSession2: Handles ServiceL errors
+     * @since 3.0
+     */
+    void ServiceError( const RMessage2& aMessage, TInt aError );
+
+private:
+
+    /**
+     * C++ constructor.
+     * @since 3.0
+     * @param aClient Client thread.
+     */
+    CRoapStorageSession();
+
+    /**
+     * Second phase constructor.
+     * @since 3.0
+     */
+    void ConstructL();
+
+    static void PanicClient( const RMessage2& aMessage, TPanic aReason );
+
+    void AddRiContextL( const RMessage2& aMessage );
+
+    void AddDomainContextL( const RMessage2& aMessage );
+
+    void GetRiContextL( const RMessage2& aMessage );
+
+    void GetDomainContextL( const RMessage2& aMessage );
+
+    void GetDataL( const RMessage2& aMessage );
+
+    void DeleteRiContextL( const RMessage2& aMessage );
+
+    void DeleteDomainContextL( const RMessage2& aMessage );
+
+    void DeleteExpiredRIsL( const RMessage2& aMessage );
+
+    void DeleteExpiredDomainsL( const RMessage2& aMessage );
+
+    void WhiteListUrlExistsL( const RMessage2& aMessage );
+
+    void GetDevicePublicKeyDerL( const RMessage2& aMessage );
+
+    void GetDeviceCertificateChainL( const RMessage2& aMessage );
+
+    void SignL( const RMessage2& aMessage );
+
+    void SelectTrustedRootL( const RMessage2& aMessage );
+
+    void ActivateTrustedRootL( const RMessage2& aMessage );
+
+    void GetTrustedRootsL( const RMessage2& aMessage );
+
+    void GetRootCertificateL( const RMessage2& aMessage );
+
+    void DeleteExpiredContextsL( const RMessage2& aMessage );
+
+    void DeleteAllL( const RMessage2& aMessage );
+
+    void RsaSignL( const RMessage2& aMessage );
+
+    void GetMeteringDataL( const RMessage2& aMessage );
+
+    void DeleteMeteringDataL( const RMessage2& aMessage );
+
+    void GetAllRIContextsL( const RMessage2& aMessage );
+
+    void UpdateRIContextL( const RMessage2& aMessage );
+
+    void UpdateDrmTimeL( const RMessage2& aMessage );
+
+    void
+        CRoapStorageSession::VerifyOcspResponsesL( const RMessage2& aMessage );
+
+    void GetOcspResponderIdL( const RMessage2& aMessage );
+
+    // Prohibit copy constructor.
+    CRoapStorageSession( const CRoapStorageSession& );
+    // Prohibit assigment operator.
+    CRoapStorageSession& operator=( const CRoapStorageSession& );
+
+private:
+    // Data
+
+    HBufC8* iPreparedData;
+
+    MDrmKeyStorage* iKeyStorage;
+
+    TBool iDeleteExpired;
+
+    LazyClockClient* iLazyClock;
+
+};
+#endif      // ROAP_STORAGE_SESSION_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/inc/certid.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,57 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// Declare certID object, representing the CertID data structure from the OCSP spec.
+// Used in cert info objects for requests and responses.
+
+#ifndef __OCSP_ROAP_CERTID_H__
+#define __OCSP_ROAP_CERTID_H__
+
+#include <hash.h>
+
+class CASN1EncBase;
+class CX509Certificate;
+
+// CertID, used in requests and responses
+class COCSPCertID : public CBase
+	{
+public:
+	// Make from certificates - subject mustn't be deleted in our lifetime
+	static COCSPCertID* NewL(const CX509Certificate& aSubject, const CX509Certificate& aIssuer);
+
+	// Make from binary data - which mustn't be deleted in our lifetime
+	static COCSPCertID* NewL(const TDesC8& aBinaryData);
+
+	// Construct ASN1 encoding object for the CertID data
+	CASN1EncBase* EncoderLC() const;
+
+    TPtrC8 SerialNumber() const;
+
+	TBool operator==(const COCSPCertID& rhs) const;
+
+private:
+	void ConstructL(const CX509Certificate& aSubject, const CX509Certificate& aIssuer);
+	void ConstructL(const TDesC8& aBinaryData);
+
+private:
+	TBuf8<SHA_HASH> iIssuerNameHash;
+	TBuf8<SHA_HASH> iIssuerKeyHash;
+	TPtrC8 iSerialNumber; // Refers to the input certificate or input binary data
+	};
+
+#endif // __OCSP_ROAP_CERTID_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/inc/oids.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// Define OIDs we use in OCSP - comment out the ones we don't use
+
+#ifndef __OCSP_ROAP_OIDS_H__
+#define __OCSP_ROAP_OIDS_H__
+
+// OCSP OIDs
+
+_LIT(KOCSPOidBasic,				"1.3.6.1.5.5.7.48.1.1");
+_LIT(KOCSPOidNonce,				"1.3.6.1.5.5.7.48.1.2");
+//_LIT(KOCSPOidCrl,				"1.3.6.1.5.5.7.48.1.3");
+_LIT(KOCSPOidResponse,			"1.3.6.1.5.5.7.48.1.4");
+_LIT(KOCSPOidNoCheck,			"1.3.6.1.5.5.7.48.1.5");
+_LIT(KOCSPOidArchiveCutoff,		"1.3.6.1.5.5.7.48.1.6");
+_LIT(KOCSPOidServiceLocator,	"1.3.6.1.5.5.7.48.1.7");
+
+const TUint KOCSPMaxOidEncodingLength = 20;
+
+#endif // __OCSP_ROAP_OIDS_H__
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/inc/responsedecoder.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#ifndef __OCSP_ROAP_RESPONSEDECODER_H__
+#define __OCSP_ROAP_RESPONSEDECODER_H__
+
+#include <e32base.h>
+
+class COCSPResponse;
+class TASN1DecGeneric;
+
+/**
+ * Handles decoding an OCSP response and creating a COCSPResponse object.
+ */
+
+NONSHARABLE_CLASS(COCSPResponseDecoder) : public CBase
+	{
+public:
+
+	/**
+	 * Create a new decoder object and decoder an ocsp response.
+	 * Can leave with one of the OCSP::TStatus codes.
+	 */
+	
+	static COCSPResponseDecoder* NewL(const TDesC8& aEncoding);
+
+	~COCSPResponseDecoder();
+
+	COCSPResponse* TakeResponse(); // Will return null if response was invalid
+
+private:
+
+	COCSPResponseDecoder();
+	void ConstructL(const TDesC8& aEncoding);
+
+	// Decoding methods
+	void DecodeOCSPResponseL(const TDesC8& aEncoding);
+	void DecodeResponseBytesL(const TDesC8& aEncoding);
+	void DecodeBasicOCSPResponseL(const TDesC8& aEncoding);
+	void DecodeResponseDataL(const TDesC8& aEncoding);
+	void DecodeCertificatesL(const TDesC8& aEncoding);
+	void DecodeResponseExtensionsL(const TDesC8& aEncoding);
+	void DecodeResponseExtensionL(const TDesC8& aEncoding);
+	void DecodeResponsesL(const TDesC8& aEncoding);
+	void DecodeSingleResponseL(const TDesC8& aEncoding);
+
+	CArrayPtr<TASN1DecGeneric>* DecodeSequenceLC(const TDesC8& aEncoding);
+	CArrayPtr<TASN1DecGeneric>* DecodeSequenceLC(const TDesC8& aEncoding,
+		const TInt aMinTerms, const TInt aMaxTerms);
+
+	COCSPResponse* iResponse;
+	};
+
+#endif // __OCSP_ROAP_RESPONSEDECODER_H__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/src/DRMContextDB.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,941 @@
+/*
+* 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:  Datatype for Rights Constraint
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32file.h>
+#include <s32std.h>
+#include <caf/caf.h>
+
+#include "DRMContextDB.h"
+#include "DRMRIContext.h"
+#include "DRMDomainContext.h"
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMContextDB::NewLC
+// -----------------------------------------------------------------------------
+//
+CDRMContextDB* CDRMContextDB::NewLC( const TFileName& aRightsIssuerContextFile, 
+                                     const TFileName& aDomainContextFile,
+                                     RFs& aFileServer )
+    {
+    CDRMContextDB* self = new( ELeave ) CDRMContextDB( aFileServer );
+    CleanupStack::PushL( self );
+    self->ConstructL( aRightsIssuerContextFile, 
+                      aDomainContextFile );
+
+    return self;    
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMContextDB::NewL
+// -----------------------------------------------------------------------------
+//
+CDRMContextDB* CDRMContextDB::NewL( const TFileName& aRightsIssuerContextFile, 
+                                    const TFileName& aDomainContextFile,
+                                    RFs& aFileServer )
+    {
+    CDRMContextDB* self = NewLC( aRightsIssuerContextFile, 
+                                 aDomainContextFile,  
+                                 aFileServer );
+    CleanupStack::Pop();	
+    
+    return self;    
+    };
+                                 
+// -----------------------------------------------------------------------------
+// CDRMContextDB::OpenLC
+// -----------------------------------------------------------------------------
+//
+CDRMContextDB* CDRMContextDB::OpenLC( const TFileName& aRightsIssuerContextFile, 
+                                      const TFileName& aDomainContextFile,
+                                      RFs& aFileServer )
+    {
+    CDRMContextDB* self = new( ELeave ) CDRMContextDB( aFileServer );
+    CleanupStack::PushL( self );    
+    self->ConstructL( aRightsIssuerContextFile, 
+                      aDomainContextFile );
+    
+    return self;
+    };    
+    
+// -----------------------------------------------------------------------------
+// CDRMContextDB::OpenL
+// -----------------------------------------------------------------------------
+//
+CDRMContextDB* CDRMContextDB::OpenL( const TFileName& aRightsIssuerContextFile, 
+                                     const TFileName& aDomainContextFile,
+                                     RFs& aFileServer )
+    {
+    CDRMContextDB* self = OpenLC( aRightsIssuerContextFile, 
+                                  aDomainContextFile,  
+                                  aFileServer );
+    CleanupStack::Pop();
+    
+    return self;    
+    };    
+    
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+// 
+CDRMContextDB::~CDRMContextDB()
+    {
+    // Permanent File Store
+    if( iDomainStore )
+        {
+        delete iDomainStore;
+        iDomainStore = NULL;
+        }
+        
+    // Permanent File Store
+    if( iRightsIssuerStore )
+        {
+        delete iRightsIssuerStore;
+        iRightsIssuerStore = NULL;
+        }
+        
+    // index array    
+    iDomainArray.Close();
+    
+    // index array
+    iRightsIssuerArray.Close();
+    }; 
+      
+    
+// -----------------------------------------------------------------------------
+// CDRMContextDB::StoreDomainContextL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::StoreDomainContextL( const CDRMDomainContext& aContext )
+    {
+    TStreamId rootId;
+    RStoreWriteStream stream;
+    RStoreWriteStream rootStream;
+    CDRMContextDB::TContextIndex searchData;
+    TInt index;
+    
+    // Copy the domain id to the 
+    searchData.iContextID.Copy( aContext.DomainID() );
+    
+    // get the id from the array if it doesn't exist, error
+    index = iDomainArray.Find( searchData, TContextIndex::Match );    
+    
+    if( index == KErrNotFound )
+        {
+        TStreamId sid;
+        // Create a new stream to the store:
+        sid = stream.CreateLC( *iDomainStore );    
+        
+        searchData.iStreamID = sid.Value();
+        
+        // Externalize the domain data
+        aContext.ExternalizeL( stream );
+        stream.CommitL();
+        
+        // add the id to the array
+        iDomainArray.Append( searchData );
+        
+        // Get the stream id of the root
+        rootId = iDomainStore->Root();  
+        
+        // Open the root stream
+        rootStream.ReplaceLC( *iDomainStore, rootId );
+        
+        // Store the changed index
+        StoreDomainIndexL( rootStream );    
+        rootStream.CommitL(); 
+        
+        // Commit the store
+        iDomainStore->CommitL();                      
+        
+        CleanupStack::PopAndDestroy();  // root stream
+        CleanupStack::PopAndDestroy();  // stream       
+        }
+    else
+        {
+        // open an existing one
+        TStreamId sid( iDomainArray[ index ].iStreamID );
+        
+        // Replace the existing stream
+        stream.ReplaceLC( *iDomainStore, sid );
+    
+        // Externalize the permission data
+        aContext.ExternalizeL( stream );
+    
+        // Required by the ReplaceLC
+        stream.CommitL();
+
+        // Commit the store    
+        iDomainStore->CommitL();
+    
+        CleanupStack::PopAndDestroy(); // stream    
+        }
+        
+    iDomainStore->CompactL();
+    iDomainStore->CommitL();
+    };    
+    
+// -----------------------------------------------------------------------------
+// CDRMContextDB::FetchDomainContextL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::FetchDomainContextL( CDRMDomainContext& aContext ) const
+    {   
+    RStoreReadStream stream;
+    TUint32 index = 0;
+
+    TContextIndex searchData;
+    
+    // Copy the domain id to the search data
+    searchData.iContextID.Copy( aContext.DomainID() );
+    
+    // get the id from the array if it doesn't exist, error
+    User::LeaveIfError( index = iDomainArray.Find( searchData, 
+                                                   TContextIndex::Match ) );
+
+    TStreamId sid( iDomainArray[ index ].iStreamID );
+    // Open the root stream
+    
+    stream.OpenLC( *iDomainStore, sid );
+
+    // Read the common id
+    aContext.InternalizeL( stream );
+    
+    // Close the stream
+    CleanupStack::PopAndDestroy();        
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMContextDB::FetchDomainContextL 
+// For getting with the current id
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::FetchDomainContextL( CDRMDomainContext& aContext, 
+                                         const TInt32& aStream ) const
+    {
+    RStoreReadStream stream;
+    TStreamId sid( aStream );
+       
+    stream.OpenLC( *iDomainStore, sid );
+
+    // Read the common id
+    aContext.InternalizeL( stream );
+    
+    // Close the stream
+    CleanupStack::PopAndDestroy();        
+    };    
+    
+// -----------------------------------------------------------------------------
+// CDRMContextDB::DeleteDomainContextL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::DeleteDomainContextL( const TDesC8& aDomainID )
+    {
+    TStreamId rootId;
+    TInt index = 0;
+    RStoreWriteStream rootStream;
+
+    TContextIndex searchData;
+    
+    // Copy the domain id to the search data
+    // The last three digits presents the Domain generation
+    searchData.iContextID.Copy( aDomainID.Mid(0, aDomainID.Length() - 3 ) );
+    
+    // get the id from the array if it doesn't exist, error
+    index = iDomainArray.Find( searchData, TContextIndex::Match ); 
+    
+    User::LeaveIfError( index = iDomainArray.Find( searchData, 
+                                                   TContextIndex::Match ) );
+
+    TStreamId sid( iDomainArray[ index ].iStreamID );
+
+    // Delete the stream from the store
+    iDomainStore->DeleteL( sid );
+            
+    iDomainArray.Remove( index );       
+    
+    
+    // Get the stream id of the root
+    rootId = iDomainStore->Root();
+    
+    // Open the root stream
+    rootStream.ReplaceLC( *iDomainStore, rootId );
+        
+    // Store the changed index
+    StoreDomainIndexL( rootStream );    
+    rootStream.CommitL();
+
+    // Commit the store
+    iDomainStore->CommitL();
+    
+    CleanupStack::PopAndDestroy();  // root stream
+    
+    // Compact and commit the changes
+    iDomainStore->CompactL();
+    iDomainStore->CommitL();        
+    };
+ 
+// -----------------------------------------------------------------------------
+// CDRMContextDB::StoreRightsIssuerContextL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::StoreRightsIssuerContextL( const CDRMRIContext& aContext )
+    {
+    TStreamId rootId;
+    RStoreWriteStream stream;
+    RStoreWriteStream rootStream;
+    TContextIndex searchData;
+    TInt index;
+    
+    // Copy the domain id to the 
+    searchData.iContextID.Copy( aContext.RIID() );
+    
+    // get the id from the array if it doesn't exist, error
+    index = iRightsIssuerArray.Find( searchData, TContextIndex::Match );    
+    
+    if( index == KErrNotFound )
+        {
+        TStreamId sid;
+        // Create a new stream to the store:
+        sid = stream.CreateLC( *iRightsIssuerStore );    
+        
+        searchData.iStreamID = sid.Value();
+        
+        // Externalize the domain data
+        aContext.ExternalizeL( stream );
+        stream.CommitL();
+        
+        // add the id to the array
+        iRightsIssuerArray.Append( searchData );
+        
+        // Get the stream id of the root
+        rootId = iRightsIssuerStore->Root();  
+        
+        // Open the root stream
+        rootStream.ReplaceLC( *iRightsIssuerStore, rootId );
+        
+        // Store the changed index
+        StoreRightsIssuerIndexL( rootStream );    
+        rootStream.CommitL(); 
+        
+        // Commit the store
+        iRightsIssuerStore->CommitL();                      
+        
+        CleanupStack::PopAndDestroy();  // root stream
+        CleanupStack::PopAndDestroy();  // stream       
+        }
+    else
+        {
+        // open an existing one
+        TStreamId sid( iRightsIssuerArray[ index ].iStreamID );
+        
+        // Replace the existing stream
+        stream.ReplaceLC( *iRightsIssuerStore, sid );
+    
+        // Externalize the permission data
+        aContext.ExternalizeL( stream );
+    
+        // Required by the ReplaceLC
+        stream.CommitL();
+
+        // Commit the store    
+        iRightsIssuerStore->CommitL();
+    
+        CleanupStack::PopAndDestroy(); // stream    
+        }
+        
+    iRightsIssuerStore->CompactL();
+    iRightsIssuerStore->CommitL();
+    };    
+    
+// -----------------------------------------------------------------------------
+// CDRMContextDB::FetchRightsIssuerContextL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::FetchRightsIssuerContextL( CDRMRIContext& aContext ) const
+    {   
+    RStoreReadStream stream;
+    TUint32 index = 0;
+
+    TContextIndex searchData;
+    
+    // Copy the domain id to the search data
+    searchData.iContextID.Copy( aContext.RIID() );
+    
+    // get the id from the array if it doesn't exist, error
+    User::LeaveIfError( index = iRightsIssuerArray.Find( searchData, 
+                                                   TContextIndex::Match ) );
+
+    TStreamId sid( iRightsIssuerArray[ index ].iStreamID );
+    // Open the root stream
+    
+    stream.OpenLC( *iRightsIssuerStore, sid );
+
+    // Read the common id
+    aContext.InternalizeL( stream );
+    
+    // Close the stream
+    CleanupStack::PopAndDestroy();        
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMContextDB::FetchRightsIssuerContextL 
+// For getting with the current id
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::FetchRightsIssuerContextL( CDRMRIContext& aContext, 
+                                               const TInt32& aStream ) const
+    {
+    RStoreReadStream stream;
+    TStreamId sid( aStream );
+       
+    stream.OpenLC( *iRightsIssuerStore, sid );
+
+    // Read the common id
+    aContext.InternalizeL( stream );
+    
+    // Close the stream
+    CleanupStack::PopAndDestroy();        
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMContextDB::FetchAllRightsIssuerContextsL
+// For getting with the current id
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::FetchAllRightsIssuerContextsL( RPointerArray<CDRMRIContext>& aContexts) const
+    {
+    CDRMRIContext* context = NULL;
+
+    // No RI contexts to retrieve
+    if ( iRightsIssuerArray.Count() == 0) 
+        {
+        return;
+        }
+    
+    for( TInt count = 0; count < iRightsIssuerArray.Count(); count++ )
+        {
+        context = CDRMRIContext::NewLC();
+        FetchRightsIssuerContextL( *context, iRightsIssuerArray[ count ].iStreamID );
+        aContexts.AppendL( context );
+        CleanupStack::Pop( context );    
+        }    
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMContextDB::UpdateRightsIssuerContextL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::UpdateRightsIssuerContextL( const CDRMRIContext& aContext )
+    {
+    TStreamId rootId;
+    TInt index = 0;
+    RStoreWriteStream stream;    
+    CDRMRIContext* context = NULL;
+    
+    TContextIndex searchData;
+    
+    // Copy the domain id to the search data
+    searchData.iContextID.Copy( aContext.RIID() );
+    
+    // get the id from the array if it doesn't exist, error
+    User::LeaveIfError( index = iRightsIssuerArray.Find( searchData, 
+                                                   TContextIndex::Match ) );
+
+    TStreamId sid( iRightsIssuerArray[ index ].iStreamID );
+    
+    // Read the old context:    
+    context = CDRMRIContext::NewLC();
+    FetchRightsIssuerContextL( *context, iRightsIssuerArray[ index ].iStreamID );
+    
+    // update only the metering status:    
+    context->SetMeteringStatus( aContext.IsMeteringAllowed() );
+    
+    // Replace the existing stream
+    stream.ReplaceLC( *iRightsIssuerStore, sid );
+    
+    // Externalize the permission data
+    context->ExternalizeL( stream );
+     
+    // Required by the ReplaceLC
+    stream.CommitL();   
+    
+    // Commit the store    
+    iRightsIssuerStore->CommitL();
+    
+    CleanupStack::PopAndDestroy(); // stream
+    CleanupStack::PopAndDestroy(context);        
+    
+    
+    // Compact and commit the changes
+    iRightsIssuerStore->CompactL();
+    iRightsIssuerStore->CommitL();        
+    };
+
+
+    
+// -----------------------------------------------------------------------------
+// CDRMContextDB::DeleteRightsIssuerContextL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::DeleteRightsIssuerContextL( const TDesC8& aStream )
+    {
+    TStreamId rootId;
+    TInt index = 0;
+    RStoreWriteStream rootStream;
+
+    TContextIndex searchData;
+    
+    // Copy the domain id to the search data
+    searchData.iContextID.Copy( aStream );
+    
+    // get the id from the array if it doesn't exist, error
+    User::LeaveIfError( index = iRightsIssuerArray.Find( searchData, 
+                                                   TContextIndex::Match ) );
+
+    TStreamId sid( iRightsIssuerArray[ index ].iStreamID );
+
+    // Delete the stream from the store
+    iRightsIssuerStore->DeleteL( sid );
+            
+    iRightsIssuerArray.Remove( index );       
+    
+    
+    // Get the stream id of the root
+    rootId = iRightsIssuerStore->Root();
+    
+    // Open the root stream
+    rootStream.ReplaceLC( *iRightsIssuerStore, rootId );
+        
+    // Store the changed index
+    StoreDomainIndexL( rootStream );    
+    rootStream.CommitL();
+
+    // Commit the store
+    iRightsIssuerStore->CommitL();
+    
+    CleanupStack::PopAndDestroy();  // root stream
+    
+    // Compact and commit the changes
+    iRightsIssuerStore->CompactL();
+    iRightsIssuerStore->CommitL();        
+    }; 
+                           
+// -----------------------------------------------------------------------------
+// CDRMContextDB::WhiteListURLExistsL
+// -----------------------------------------------------------------------------
+//
+TBool CDRMContextDB::WhiteListURLExistsL( const TDesC8& aRightsIssuerURL )
+    {
+    CDRMRIContext* context = NULL;
+    TBool retVal = EFalse;
+
+    if ( iRightsIssuerArray.Count() == 0) 
+        {
+        return retVal;
+        }
+    
+    context = CDRMRIContext::NewLC();
+    
+    for( TInt count = 0; count < iRightsIssuerArray.Count(); count++ )
+        {
+        FetchRightsIssuerContextL( *context, iRightsIssuerArray[ count ].iStreamID );
+        if( context->WhiteListURLExistsL( aRightsIssuerURL ) )
+            {
+            retVal = ETrue;
+            count = iRightsIssuerArray.Count();           
+            }
+        }
+    CleanupStack::PopAndDestroy(); // context       
+    return retVal;    
+    };    
+
+// -----------------------------------------------------------------------------
+// CDRMContextDB::DeleteExpiredDomainContextsL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::DeleteExpiredDomainContextsL( const TTime& aTime )
+    {  
+    CDRMDomainContext* context = NULL;    
+    TStreamId rootId;
+    RStoreWriteStream rootStream;
+
+    // Check if there is anything to go through
+    if ( iDomainArray.Count() == 0) 
+        {
+        return;
+        }
+      
+    context = CDRMDomainContext::NewLC();
+        
+    // Delete all permissions from the store which have expired    
+    for( TInt i = 0; i < iDomainArray.Count();)
+        {
+        FetchDomainContextL( *context, iDomainArray[i].iStreamID );
+        
+        if( context->ExpiryTime() < aTime && context->ExpiryTime() != Time::NullTTime() )
+            {
+            iDomainStore->DeleteL( TStreamId( iDomainArray[i].iStreamID ) );
+            iDomainArray.Remove(i);
+            }
+        else 
+            {
+            i++; // increment the counter for the next run       
+            }   
+        }
+        
+    CleanupStack::PopAndDestroy();  // context
+    
+    // Get the stream id of the root
+    rootId = iDomainStore->Root();
+    
+    // Open the root stream
+    rootStream.ReplaceLC( *iDomainStore, rootId );
+        
+    // Store the changed index
+    StoreDomainIndexL( rootStream );    
+    rootStream.CommitL();
+
+    // Commit the store
+    iDomainStore->CommitL();
+    
+    CleanupStack::PopAndDestroy();  // root stream
+    
+    // Compact and Commit the store
+    iDomainStore->CompactL();
+    iDomainStore->CommitL();          
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMContextDB::DeleteExpiredRightsIssuerContextsL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::DeleteExpiredRightsIssuerContextsL( const TTime& aTime )
+    {
+    CDRMRIContext* context = NULL;    
+    TStreamId rootId;
+    RStoreWriteStream rootStream;
+
+    // Check if there is anything to go through
+    if ( iRightsIssuerArray.Count() == 0) 
+        {
+        return;
+        }
+        
+    context = CDRMRIContext::NewLC(); 
+           
+    // Delete all permissions from the store which have expired    
+    for( TInt i = 0; i < iRightsIssuerArray.Count();)
+        {
+        FetchRightsIssuerContextL( *context, iRightsIssuerArray[i].iStreamID );
+        
+        if( context->ExpiryTime() < aTime && context->ExpiryTime() != Time::NullTTime() )
+            {
+            iRightsIssuerStore->DeleteL( TStreamId( iRightsIssuerArray[i].iStreamID ) );
+            iRightsIssuerArray.Remove(i);
+            }
+        else
+            {
+            i++; // increment the counter for the next run                 
+            }       
+        }
+        
+    CleanupStack::PopAndDestroy();  // context 
+    
+    // Get the stream id of the root
+    rootId = iRightsIssuerStore->Root();
+    
+    // Open the root stream
+    rootStream.ReplaceLC( *iRightsIssuerStore, rootId );
+        
+    // Store the changed index
+    StoreRightsIssuerIndexL( rootStream );    
+    rootStream.CommitL();
+
+    // Commit the store
+    iRightsIssuerStore->CommitL();
+    
+    CleanupStack::PopAndDestroy();  // root stream
+    
+    // Compact and Commit the store
+    iRightsIssuerStore->CompactL();
+    iRightsIssuerStore->CommitL();           
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMContextDB::CreateAndInitializeRIStoreL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::CreateAndInitializeRIStoreL( const TFileName& aRightsIssuerStore )
+    {
+    TStreamId rootId;  
+    RStoreWriteStream rootStream;
+        
+    // Create and initialize the permanent file store
+    iRightsIssuerStore = CPermanentFileStore::ReplaceL( iFileServer, 
+                                                        aRightsIssuerStore,
+                                                        EFileRead|EFileWrite );                                          
+    iRightsIssuerStore->SetTypeL( KPermanentFileStoreLayoutUid );
+    iRightsIssuerStore->CommitL(); 
+    
+    // Create the root stream:                                                   
+    rootId = rootStream.CreateLC( *iRightsIssuerStore );
+         
+    // Create the index
+    // Commit the previous changes 
+    StoreRightsIssuerIndexL( rootStream );
+    rootStream.CommitL();
+    
+    iRightsIssuerStore->SetRootL( rootId );
+    iRightsIssuerStore->CommitL();  
+    
+    // Commit the changes to the store as well
+    CleanupStack::PopAndDestroy(); // rootStream
+    
+    iRightsIssuerStore->CompactL();
+    iRightsIssuerStore->CommitL();
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMContextDB::CreateAndInitializeDomainStoreL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::CreateAndInitializeDomainStoreL( const TFileName& aDomainStore )
+    {
+    TStreamId rootId;  
+    RStoreWriteStream rootStream;
+        
+    // Create and initialize the permanent file store
+    iDomainStore = CPermanentFileStore::ReplaceL( iFileServer, 
+                                                        aDomainStore,
+                                                        EFileRead|EFileWrite );                                          
+    iDomainStore->SetTypeL( KPermanentFileStoreLayoutUid );
+    iDomainStore->CommitL(); 
+    
+    // Create the root stream:                                                   
+    rootId = rootStream.CreateLC( *iDomainStore );
+                                               
+    // Create the index
+    // Commit the previous changes 
+    StoreDomainIndexL( rootStream );
+    rootStream.CommitL();
+    
+    iDomainStore->SetRootL( rootId );   
+    iDomainStore->CommitL();    
+        
+    // Commit the changes to the store as well
+    CleanupStack::PopAndDestroy(); // rootStream 
+    
+    iDomainStore->CompactL();
+    iDomainStore->CommitL();       
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMContextDB::StoreRightsIssuerIndexL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::StoreRightsIssuerIndexL( RWriteStream& aStream ) const
+    {
+    // Write the array size and possibly the array to the stream
+    aStream.WriteInt32L( iRightsIssuerArray.Count() );
+             
+    for( TInt count = 0; count < iRightsIssuerArray.Count(); count++ )
+        {
+        aStream << iRightsIssuerArray[ count ].iContextID;
+        aStream.WriteUint32L( iRightsIssuerArray[ count ].iStreamID );
+        }
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMContextDB::StoreDomainIndexL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::StoreDomainIndexL( RWriteStream& aStream ) const
+    {
+    // Write the array size and possibly the array to the stream
+    aStream.WriteInt32L( iDomainArray.Count() );
+    
+    for( TInt count = 0; count < iDomainArray.Count(); count++ )
+        {
+        aStream << iDomainArray[ count ].iContextID;
+        aStream.WriteUint32L( iDomainArray[ count ].iStreamID );
+        }
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMContextDB::FetchRightsIssuerIndexL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::FetchRightsIssuerIndexL()
+    {
+    TStreamId rootId;
+    RStoreReadStream stream;
+    TInt count = 0;
+    TContextIndex index;
+ 
+    // Get the stream id of the root
+    rootId = iRightsIssuerStore->Root();
+    
+    // Open the root stream
+    stream.OpenLC( *iRightsIssuerStore, rootId );
+    
+    // read the count of the array:
+    iRightsIssuerArray.Reset();
+    
+    count = stream.ReadInt32L();
+    
+    for( ; count > 0; count-- )
+        {
+        stream >> index.iContextID;
+        index.iStreamID = stream.ReadInt32L();
+        iRightsIssuerArray.Append( index );
+        }
+     
+    // Close the stream
+    CleanupStack::PopAndDestroy();    
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMContextDB::FetchDomainIndexL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::FetchDomainIndexL()
+    {
+    TStreamId rootId;
+    RStoreReadStream stream;
+    TInt count = 0;
+    TContextIndex index;
+ 
+    // Get the stream id of the root
+    rootId = iDomainStore->Root();
+    
+    // Open the root stream
+    stream.OpenLC( *iDomainStore, rootId );
+    
+    // read the count of the array:
+    iDomainArray.Reset();
+    
+    count = stream.ReadInt32L();
+    
+    for( ; count > 0; count-- )
+        {
+        stream >> index.iContextID;
+        index.iStreamID = stream.ReadInt32L();
+        iDomainArray.Append( index );
+        }
+     
+    // Close the stream
+    CleanupStack::PopAndDestroy();    
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMContextDB::DeleteAllL
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::DeleteAllL( const TFileName& aRightsIssuerContextFile, 
+                                const TFileName& aDomainContextFile )
+    {
+    delete iRightsIssuerStore;
+    iRightsIssuerStore = NULL;
+    iRightsIssuerArray.Reset();
+    CreateAndInitializeRIStoreL( aRightsIssuerContextFile );
+ 
+    delete iDomainStore;
+    iDomainStore = NULL;
+    iDomainArray.Reset();
+    CreateAndInitializeDomainStoreL( aDomainContextFile );
+    }
+
+// -----------------------------------------------------------------------------
+// Default Constructor - First phase.
+// Can be used by itself to generate an empty object
+// -----------------------------------------------------------------------------
+//
+CDRMContextDB::CDRMContextDB( RFs& aFileServer ) :
+    iFileServer( aFileServer )
+    {
+    };
+
+// -----------------------------------------------------------------------------
+// 2nd phase Constructor
+// -----------------------------------------------------------------------------
+//
+void CDRMContextDB::ConstructL( const TFileName& aRightsIssuerContextFile, 
+                                const TFileName& aDomainContextFile )
+    {
+    TInt error = KErrNone;
+    
+    // Open the file store
+    TRAP( error, iRightsIssuerStore = CPermanentFileStore::OpenL( iFileServer, 
+                                                      aRightsIssuerContextFile, 
+                                                      EFileRead|EFileWrite ) );
+    if( error == KErrNotFound )
+        {
+        CreateAndInitializeRIStoreL( aRightsIssuerContextFile );
+        }
+    else 
+        {   
+        User::LeaveIfError( error );
+        
+        // Get the index
+        FetchRightsIssuerIndexL();       
+        }    
+    
+    
+    // Open the file store
+    TRAP( error, iDomainStore = CPermanentFileStore::OpenL( iFileServer, 
+                                                      aDomainContextFile, 
+                                                      EFileRead|EFileWrite ) );
+    if( error == KErrNotFound ) 
+        {
+        CreateAndInitializeDomainStoreL( aDomainContextFile );
+        }
+    else 
+        {   
+        User::LeaveIfError( error );
+        
+        // Get the index
+        FetchDomainIndexL();       
+        
+        }
+    };
+            
+// End of File    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/src/DRMDomainContext.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,609 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Datatype for the Common Rights Database Data
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32strm.h>
+#include <s32mem.h>
+#include <caf/caf.h>
+#include <asymmetric.h>
+
+#include "DRMDomainContext.h"
+#include "OmaCrypto.h"
+#include "drmlog.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+const TInt KMaxUrlLength = 32768;
+const TUint8 KMinDomainIdSize = 4;
+const TUint8 KMaxDomainIdSize = 20;
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMDomainContext* CDRMDomainContext::NewLC( const TDesC8& aDomainID,
+                                             const TTime& aExpiryTime,
+                                             const TBool aHashChained,
+                                             const RPointerArray< HBufC8 >& aDomainKeys,
+                                             const TDesC8& aRiId,
+                                             const TDesC8& aRightsIssuerURL )
+    {
+    CDRMDomainContext* self = new( ELeave ) CDRMDomainContext( aExpiryTime,
+                                                               aHashChained );
+    CleanupStack::PushL( self );
+    self->ConstructL( aDomainID, aDomainKeys,
+                      aRiId, aRightsIssuerURL );
+
+    return self;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMDomainContext* CDRMDomainContext::NewL(const TDesC8& aDomainID,
+                                           const TTime& aExpiryTime,
+                                           const TBool aHashChained,
+                                           const RPointerArray< HBufC8 >& aDomainKeys,
+                                           const TDesC8& aRiId,
+                                           const TDesC8& aRightsIssuerURL  )
+    {
+    CDRMDomainContext* self = NewLC( aDomainID, aExpiryTime,
+                                     aHashChained, aDomainKeys,
+                                     aRiId, aRightsIssuerURL );
+    CleanupStack::Pop();
+
+    return self;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMDomainContext* CDRMDomainContext::NewLC()
+    {
+    CDRMDomainContext* self = new( ELeave ) CDRMDomainContext();
+    CleanupStack::PushL( self );
+
+    return self;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMDomainContext* CDRMDomainContext::NewL()
+    {
+    CDRMDomainContext* self = NewLC();
+    CleanupStack::Pop();
+
+    return self;
+    };
+
+
+// -----------------------------------------------------------------------------
+// Default Constructor - First phase.
+// Can be used by itself to generate an empty object
+// -----------------------------------------------------------------------------
+//
+CDRMDomainContext::CDRMDomainContext():
+    iHashChained( EFalse ),
+    iRightsIssuerURL( NULL )
+    {
+    iDomainID.SetLength( 0 );
+    iRightsIssuerID.SetLength( 0 );
+    iDomainKeys.Reset();
+    };
+
+
+// -----------------------------------------------------------------------------
+// Default Constructor - First phase.
+// Can be used by itself to generate an empty object
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMDomainContext::CDRMDomainContext( const TTime& aExpiryTime,
+                                      const TBool aHashChained ) :
+    iExpiryTime( aExpiryTime ),
+    iHashChained( aHashChained )
+    {
+    iDomainID.SetLength( 0 );
+    iRightsIssuerID.SetLength( 0 );
+    iDomainKeys.Reset();
+    };
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMDomainContext::~CDRMDomainContext()
+    {
+    // Empty and destroy the pointer array
+    iDomainKeys.ResetAndDestroy();
+
+    if( iRightsIssuerURL )
+        {
+        delete iRightsIssuerURL;
+        iRightsIssuerURL = NULL;
+        }
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::DomainID
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TPtrC8 CDRMDomainContext::DomainID() const
+    {
+    // last three digits presents the domain generation
+    if ( iDomainID.Length() >= KMinDomainIdSize &&
+        iDomainID.Length() <= KMaxDomainIdSize  )
+        {
+        return iDomainID.Left( iDomainID.Length() - 3 );
+        }
+    else
+        {
+        return KNullDesC8();
+        }
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::ExpiryTime
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TTime CDRMDomainContext::ExpiryTime() const
+    {
+    return iExpiryTime;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::HashChained
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMDomainContext::HashChained() const
+    {
+    return iHashChained;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::DomainKeys
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const RPointerArray< HBufC8 >& CDRMDomainContext::DomainKeys() const
+    {
+    return iDomainKeys;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::DomainKey
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* CDRMDomainContext::DomainKeyL( const TInt aGeneration ) const
+    {
+    TInt newestGeneration( DomainGeneration() );
+    TInt loops( newestGeneration - aGeneration );
+    HBufC8* domainKey( NULL );
+    HBufC8* temp( NULL );
+
+    if ( loops < 0 || aGeneration > newestGeneration )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    if ( iHashChained )
+        {
+        domainKey = iDomainKeys[0]->AllocL();
+        for ( TInt i = 0; i < loops; i++ )
+            {
+            CleanupStack::PushL( domainKey );
+            temp = OmaCrypto::KdfL( *domainKey, KNullDesC8, OmaCrypto::KKeySize );
+            CleanupStack::PopAndDestroy( domainKey );
+            domainKey = temp;
+            }
+        }
+    else
+        {
+        domainKey = iDomainKeys[aGeneration]->AllocL();
+        }
+
+    return domainKey;
+    }
+
+/// -----------------------------------------------------------------------------
+// CDRMDomainContext::DomainGeneration
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMDomainContext::DomainGeneration() const
+    {
+    // last three digits presents the domain generation
+    TInt generation = 0;
+    TLex8 lex( iDomainID.Right( 3 ) );
+    lex.Val( generation );
+    return generation;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::PublicKey
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CDRMDomainContext::RightsIssuerID() const
+    {
+    return iRightsIssuerID;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::RightsIssuerURL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CDRMDomainContext::RightsIssuerURL() const
+    {
+    return *iRightsIssuerURL;
+    };
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::SetDomainIDL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMDomainContext::SetDomainIDL( const TDesC8& aDomainID )
+    {
+    if ( aDomainID.Length() >= KMinDomainIdSize &&
+        aDomainID.Length() <= KMaxDomainIdSize  )
+        {
+    iDomainID.Copy(aDomainID);
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::SetExpiryTimeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMDomainContext::SetExpiryTimeL( const TTime& aExpiryTime )
+    {
+    iExpiryTime = aExpiryTime;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::SetHashChained
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMDomainContext::SetHashChainedL( const TBool& aHashChained )
+    {
+    iHashChained = aHashChained;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::SetDomainKeysL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMDomainContext::SetDomainKeysL(
+    const RPointerArray< HBufC8 >& aDomainKeys )
+    {
+    HBufC8* tempData = NULL;
+
+    // Clear the old algorithms
+    iDomainKeys.ResetAndDestroy();
+
+    // Append the new stuff
+    for( TInt i = 0; i < aDomainKeys.Count(); i++ )
+        {
+        tempData = aDomainKeys[i]->AllocLC();
+        iDomainKeys.AppendL( tempData );
+        CleanupStack::Pop();
+        }
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::SetPublicKeyL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMDomainContext::SetRightsIssuerIDL(
+    const TDesC8& aRightsIssuerID )
+    {
+    iRightsIssuerID.Copy( aRightsIssuerID );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::SetRightsIssuerURLL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMDomainContext::SetRightsIssuerURLL(
+    const TDesC8& aRightsIssuerURL )
+    {
+    HBufC8* newRightsIssuerURL = aRightsIssuerURL.AllocL();
+
+    if( iRightsIssuerURL )
+        {
+        delete iRightsIssuerURL;
+        iRightsIssuerURL = NULL;
+        }
+    iRightsIssuerURL = newRightsIssuerURL;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::ExternalizeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMDomainContext::ExternalizeL( RWriteStream& aStream ) const
+    {
+    TUint8 flag;
+
+    // Write the ContentID
+    aStream << iDomainID;
+
+    // expiry time
+    WriteInt64L( iExpiryTime.Int64(), aStream );
+
+    // hash chained
+    aStream.WriteInt8L( iHashChained );
+
+    // write the domain keys
+
+    // How many:
+    aStream.WriteInt32L( iDomainKeys.Count() );
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < iDomainKeys.Count(); i++ )
+        {
+        aStream << *(iDomainKeys[i]);
+        }
+
+    // Write the rights issuer ID
+    aStream << iRightsIssuerID;
+
+    // Write the rights issuer url
+    if (iRightsIssuerURL)
+        {
+        flag = ETrue;
+        aStream << flag;
+        aStream << *iRightsIssuerURL;
+        }
+    else
+        {
+        flag = EFalse;
+        aStream << flag;
+        }
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::InternalizeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMDomainContext::InternalizeL( RReadStream& aStream )
+    {
+    HBufC8* dataPart = 0;
+    TPtr8 dataBuffer(NULL,0,0);
+    TInt count = 0;
+    TInt64 timeData;
+    TUint8 flag;
+
+    // Read the DomainID
+    aStream >> iDomainID;
+
+    // read the expiry time
+    ReadInt64L( timeData, aStream );
+    iExpiryTime = timeData;
+
+    // read the hash chained
+    iHashChained = aStream.ReadInt8L();
+
+    // read the algorithms
+
+    // How many:
+    count = aStream.ReadInt32L();
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < count; i++ )
+        {
+        // Read the ContentID
+        dataPart = HBufC8::NewL( aStream, KMaxUrlLength );
+
+        // assign the new content id
+        iDomainKeys.AppendL( dataPart );
+        }
+
+    // Read the rights issuer ID
+    aStream >> iRightsIssuerID;
+
+    // Read the rights issuer url
+    if( iRightsIssuerURL )
+        {
+        delete iRightsIssuerURL;
+        iRightsIssuerURL = NULL;
+        }
+
+    aStream >> flag;
+    if (flag)
+        {
+        iRightsIssuerURL = HBufC8::NewL( aStream, KMaxUrlLength );
+        }
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::ImportL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMDomainContext::ImportL( const TDesC8& aBuffer )
+    {
+    TInt size = aBuffer.Size();
+    RMemReadStream stream( (TAny*)( aBuffer.Ptr() ), size );
+    CleanupClosePushL( stream );
+
+    InternalizeL( stream );
+
+    CleanupStack::PopAndDestroy(); // Stream
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::ExportL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* CDRMDomainContext::ExportL() const
+    {
+    TInt size = Size();
+    HBufC8* data = HBufC8::NewMaxLC( size );
+
+    RMemWriteStream stream( (TAny*)( data->Ptr() ), size );
+    CleanupClosePushL( stream );
+
+    ExternalizeL( stream );
+
+    CleanupStack::PopAndDestroy(); // Stream
+    CleanupStack::Pop();
+    return data;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::Size
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMDomainContext::Size() const
+    {
+    TInt size = 0;
+
+    // domain identifier
+    size += sizeof(TInt32);
+    size += iDomainID.Length();
+
+    // size of the expiry time
+    size += sizeof(TInt64);
+
+    // size of the boolean
+    size += sizeof(TBool);
+
+    // How many:
+    size += sizeof(TInt32);
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < iDomainKeys.Count(); i++ )
+        {
+        size += sizeof(TInt32);
+        size += iDomainKeys[i]->Size();
+        }
+
+    // Domain generation
+    size += sizeof(TInt32);
+
+    // rights issuer ID
+    size += sizeof(TInt32);
+    size += iRightsIssuerID.Length();
+
+    // rights issuer url
+    size += sizeof(TUint8);
+    if( iRightsIssuerURL )
+        {
+        size += sizeof(TInt32);
+        size += iRightsIssuerURL->Size();
+        }
+
+    return size;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDomainContext::ConstructL
+// Second phase constructor
+// -----------------------------------------------------------------------------
+//
+void CDRMDomainContext::ConstructL( const TDesC8& aDomainID,
+                                    const RPointerArray< HBufC8 > aDomainKeys,
+                                    const TDesC8& aRightsIssuerID,
+                                    const TDesC8& aRightsIssuerURL )
+    {
+    HBufC8* domainKey = NULL;
+
+    // Copy the domain identifier
+    if ( aDomainID.Length() >= KMinDomainIdSize &&
+        aDomainID.Length() <= KMaxDomainIdSize  )
+        {
+    iDomainID.Copy( aDomainID );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // Copy the domain keys
+    for( TInt i = 0; i < aDomainKeys.Count();i++ )
+        {
+        domainKey = aDomainKeys[i]->AllocLC();
+        iDomainKeys.AppendL( domainKey );
+        CleanupStack::Pop();
+        }
+
+    // copy the rights issuer ID
+    iRightsIssuerID.Copy( aRightsIssuerID );
+
+    // copy the rights issuer URL
+    iRightsIssuerURL = aRightsIssuerURL.AllocL();
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::WriteInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMDomainContext::WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const
+    {
+    TPtr8 output( reinterpret_cast<TUint8*>(const_cast<TInt64*>(&aWrite)),
+                  sizeof(TInt64), sizeof(TInt64) );
+
+    aStream.WriteL( output, sizeof(TInt64) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::ReadInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMDomainContext::ReadInt64L( TInt64& aRead, RReadStream& aStream )
+    {
+    TPtr8 input( reinterpret_cast<TUint8*>(&aRead), 0, sizeof(TInt64) );
+
+    aStream.ReadL( input, sizeof(TInt64) );
+    };
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/src/DRMRIContext.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1031 @@
+/*
+* Copyright (c) 2004 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Datatype for the Common Rights Database Data
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32strm.h>
+#include <s32mem.h>
+#include <caf/caf.h>
+#include <uri8.h>
+
+#include "drmlog.h"
+#include "DRMRIContext.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+const TInt KMaxCertificateLength = 327680;
+const TInt KMaxUrlLength = 32768;
+const TInt KMaxRiAliasLength = 1024;
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMRIContext* CDRMRIContext::NewLC( const TDesC8& aRIID,
+                                              const TDesC8& aRiAlias,
+                                              const TDesC8& aVersion,
+                                              const RPointerArray< HBufC8 >& aAlgorithms,
+                                              const RPointerArray< HBufC8 >& aRIURLs,
+                                              const TDesC8& aRightsIssuerURL,
+                                              const TTime& aExpiryTime,
+                                              const RPointerArray< HBufC8 >& aChain,
+                                              const RPointerArray< HBufC8 >& aResponses,
+                                              const TUint8 aDeviceCertCached,
+                                              const TDesC8& aSelectedDeviceRoot,
+                                              const TUint8 aIsMeteringAllowed )
+    {
+    CDRMRIContext* self = new( ELeave ) CDRMRIContext();
+    CleanupStack::PushL( self );
+    self->ConstructL( aRIID, aRiAlias, aVersion, aAlgorithms,
+                      aRIURLs, aRightsIssuerURL, aExpiryTime,
+                      aChain, aResponses, aDeviceCertCached,
+                      aSelectedDeviceRoot, aIsMeteringAllowed );
+
+    return self;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMRIContext* CDRMRIContext::NewL( const TDesC8& aRIID,
+                                             const TDesC8& aRiAlias,
+                                             const TDesC8& aVersion,
+                                             const RPointerArray< HBufC8 >& aAlgorithms,
+                                             const RPointerArray< HBufC8 >& aRIURLs,
+                                             const TDesC8& aRightsIssuerURL,
+                                             const TTime& aExpiryTime,
+                                             const RPointerArray< HBufC8 >& aChain,
+                                             const RPointerArray< HBufC8 >& aResponses,
+                                             const TUint8 aDeviceCertCached,
+                                             const TDesC8& aSelectedDeviceRoot,
+                                             const TUint8 aIsMeteringAllowed )
+    {
+    CDRMRIContext* self = NewLC( aRIID, aRiAlias, aVersion, aAlgorithms,
+                                 aRIURLs, aRightsIssuerURL, aExpiryTime,
+                                 aChain, aResponses, aDeviceCertCached,
+                                 aSelectedDeviceRoot, aIsMeteringAllowed );
+    CleanupStack::Pop();
+
+    return self;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMRIContext* CDRMRIContext::NewLC()
+    {
+    CDRMRIContext* self = new( ELeave ) CDRMRIContext();
+    CleanupStack::PushL( self );
+
+    return self;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMRIContext* CDRMRIContext::NewL()
+    {
+    CDRMRIContext* self = NewLC();
+    CleanupStack::Pop();
+
+    return self;
+    };
+
+
+// -----------------------------------------------------------------------------
+// Default Constructor - First phase.
+// Can be used by itself to generate an empty object
+// -----------------------------------------------------------------------------
+//
+CDRMRIContext::CDRMRIContext()
+    {
+
+    };
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMRIContext::~CDRMRIContext()
+    {
+    // Delete the algorithm array
+    iAlgorithms.ResetAndDestroy();
+    iAlgorithms.Close();
+
+    // Delete the ri uri array
+    iRIURLs.ResetAndDestroy();
+    iRIURLs.Close();
+
+    // Delete the certificate chain
+    iCertificateChain.ResetAndDestroy();
+    iCertificateChain.Close();
+
+    // Delete the OCSP responses
+    iOcspResponse.ResetAndDestroy();
+    iOcspResponse.Close();
+
+    delete iRightsIssuerURL;
+    delete iRiAlias;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::RIID
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CDRMRIContext::RIID() const
+    {
+    return iRIID;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::RIAlias
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CDRMRIContext::RIAlias() const
+    {
+    return *iRiAlias;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::Version
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CDRMRIContext::Version() const
+    {
+    return iVersion;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::Algorithms
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const RPointerArray< HBufC8 >& CDRMRIContext::Algorithms() const
+    {
+    return iAlgorithms;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::RIURLs
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const RPointerArray< HBufC8 >& CDRMRIContext::RIURLs() const
+    {
+    return iRIURLs;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::RightsIssuerURL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CDRMRIContext::RightsIssuerURL() const
+    {
+    return *iRightsIssuerURL;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::ExpiryTime
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TTime CDRMRIContext::ExpiryTime() const
+    {
+    return iExpiryTime;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::CertificateChain
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const RPointerArray< HBufC8 >& CDRMRIContext::CertificateChain() const
+    {
+    return iCertificateChain;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::OCSPResponse
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const RPointerArray< HBufC8 >& CDRMRIContext::OCSPResponse() const
+    {
+    return iOcspResponse;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::DeviceCertCached
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TUint8 CDRMRIContext::DeviceCertCached() const
+    {
+    return iDeviceCertCached;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SelectedDeviceRoot
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CDRMRIContext::SelectedDeviceRoot() const
+    {
+    return iSelectedDeviceRoot;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::IsMeteringAllowed
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TUint8 CDRMRIContext::IsMeteringAllowed() const
+    {
+    return iIsMeteringAllowed;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SetRIIDL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::SetRIIDL( const TDesC8& aRIID )
+    {
+    if ( ( aRIID.Length() <= 0 ) || ( aRIID.Length() > SHA1_HASH ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    iRIID.Copy( aRIID );
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SetVersionL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::SetVersionL( const TDesC8& aVersion )
+    {
+    if ( ( aVersion.Length() <= 0 ) ||
+        ( aVersion.Length() > Roap::KMaxRoapVersionLength ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    iVersion.Copy( aVersion );
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SetAlgorithmsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::SetAlgorithmsL( const RPointerArray< HBufC8 >& aAlgorithms )
+    {
+    HBufC8* tempData = NULL;
+
+    // Clear the old algorithms
+    iAlgorithms.ResetAndDestroy();
+
+    // Append the new stuff
+    for( TInt i = 0; i < aAlgorithms.Count(); i++ )
+        {
+        tempData = aAlgorithms[i]->AllocLC();
+        iAlgorithms.AppendL( tempData );
+        CleanupStack::Pop();
+        }
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SetRIURLsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::SetRIURLsL( const RPointerArray< HBufC8 >& aRIURLs )
+    {
+    HBufC8* tempData = NULL;
+
+    // Clear the old algorithms
+    iRIURLs.ResetAndDestroy();
+
+    // Append the new stuff
+    for( TInt i = 0; i < aRIURLs.Count(); i++ )
+        {
+        tempData = aRIURLs[i]->AllocLC();
+        iRIURLs.AppendL( tempData );
+        CleanupStack::Pop();
+        }
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SetRightsIssuerURLL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::SetRightsIssuerURLL(
+    const TDesC8& aRightsIssuerURL )
+    {
+    HBufC8* newRightsIssuerURL = aRightsIssuerURL.AllocL();
+
+    if( iRightsIssuerURL )
+        {
+        delete iRightsIssuerURL;
+        iRightsIssuerURL = NULL;
+        }
+    iRightsIssuerURL = newRightsIssuerURL;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SetExpiryTimeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::SetExpiryTimeL( const TTime& aExpiryTime )
+    {
+    iExpiryTime = aExpiryTime;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SetCertificateChainL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::SetCertificateChainL( const RPointerArray< HBufC8 >& aChain )
+    {
+    HBufC8* tempData = NULL;
+
+    // Clear the old algorithms
+    iCertificateChain.ResetAndDestroy();
+
+    // Append the new stuff
+    for( TInt i = 0; i < aChain.Count(); i++ )
+        {
+        tempData = aChain[i]->AllocLC();
+        iCertificateChain.AppendL( tempData );
+        CleanupStack::Pop();
+        }
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SetOCSPResponseL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::SetOCSPResponseL( const RPointerArray< HBufC8 >& aResponses )
+    {
+    HBufC8* tempData = NULL;
+
+    // Clear the old algorithms
+    iOcspResponse.ResetAndDestroy();
+
+    // Append the new stuff
+    for( TInt i = 0; i < aResponses.Count(); i++ )
+        {
+        tempData = aResponses[i]->AllocLC();
+        iOcspResponse.AppendL( tempData );
+        CleanupStack::Pop();
+        }
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SetDeviceCertCached
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::SetDeviceCertCached( TUint8& aIsCached )
+    {
+    iDeviceCertCached = aIsCached;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::WhiteListURLExistsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMRIContext::WhiteListURLExistsL( const TDesC8& aURL ) const
+    {
+    TUriParser8 uri1;
+    TUriParser8 uri2;
+    uri1.Parse( aURL );
+
+    for( TInt i = 0; i < iRIURLs.Count(); i++ )
+        {
+        uri2.Parse( *iRIURLs[i] );
+        if ( uri2.Compare( uri1, EUriHost ) == 0 )
+            {
+            return ETrue;
+            }
+        }
+
+    if( iRightsIssuerURL )
+        {
+        uri2.Parse( *iRightsIssuerURL );
+        if ( uri2.Compare(uri1, EUriHost ) == 0 )
+            {
+            return ETrue;
+            }
+        }
+    return EFalse;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SetSelectedDeviceRoot
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::SetSelectedDeviceRoot( const TDesC8& aSelectedDeviceRoot )
+    {
+    if ( ( aSelectedDeviceRoot.Length() <= 0 ) ||
+        ( aSelectedDeviceRoot.Length() > SHA1_HASH ) )
+        {
+        return;
+        }
+    iSelectedDeviceRoot.Copy( aSelectedDeviceRoot );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::SetMeteringStatus
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::SetMeteringStatus( const TBool aIsMeteringAllowed )
+    {
+    iIsMeteringAllowed = aIsMeteringAllowed;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::ExternalizeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::ExternalizeL( RWriteStream& aStream ) const
+    {
+    TInt dataLength = 0;
+    TUint8 flag;
+
+    // write the iRIID
+    aStream.WriteL( iRIID );
+
+    // write the iRiAlias
+    if ( iRiAlias )
+        {
+        flag = ETrue;
+        aStream << flag;
+        aStream << *iRiAlias;
+        }
+    else
+        {
+        flag = EFalse;
+        aStream << flag;
+        }
+
+    // write the version length
+    aStream.WriteInt8L( static_cast<TInt8>(iVersion.Length() ) );
+
+    // write the version
+    if( iVersion.Length() )
+        {
+        aStream.WriteL( iVersion );
+        }
+
+    // write the algorithms
+
+    // How many:
+    aStream.WriteInt32L( iAlgorithms.Count() );
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < iAlgorithms.Count(); i++ )
+        {
+        dataLength = 0;
+        if( iAlgorithms[i] )
+            {
+            dataLength = iAlgorithms[i]->Length();
+            }
+        aStream.WriteInt32L( dataLength );
+
+        if( dataLength )
+            {
+            aStream.WriteL( iAlgorithms[i]->Des() );
+            }
+        }
+
+    // write the algorithms
+
+    // How many:
+    aStream.WriteInt32L( iRIURLs.Count() );
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < iRIURLs.Count(); i++ )
+        {
+        dataLength = 0;
+        if( iRIURLs[i] )
+            {
+            dataLength = iRIURLs[i]->Length();
+            }
+        aStream.WriteInt32L( dataLength );
+
+        if( dataLength )
+            {
+            aStream.WriteL( iRIURLs[i]->Des() );
+            }
+        }
+
+    // Write the rights issuer url
+    if (iRightsIssuerURL)
+        {
+        flag = ETrue;
+        aStream << flag;
+        aStream << *iRightsIssuerURL;
+        }
+    else
+        {
+        flag = EFalse;
+        aStream << flag;
+        }
+
+    // write the expiry time
+    WriteInt64L( iExpiryTime.Int64(), aStream );
+
+    // How many:
+    aStream.WriteInt32L( iCertificateChain.Count() );
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < iCertificateChain.Count(); i++ )
+        {
+        aStream << *(iCertificateChain[i]);
+        }
+
+    // How many:
+    aStream.WriteInt32L( iOcspResponse.Count() );
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < iOcspResponse.Count(); i++ )
+        {
+        aStream << *(iOcspResponse[i]);
+        }
+
+    // certificate caching indication
+    aStream << iDeviceCertCached;
+
+    // write the iSelectedDeviceRoot
+    if (iSelectedDeviceRoot.Length())
+        {
+        flag = ETrue;
+        aStream << flag;
+        aStream.WriteL(iSelectedDeviceRoot);
+        }
+    else
+        {
+        flag = EFalse;
+        aStream << flag;
+        }
+
+    // Add metering allowance info
+    aStream << iIsMeteringAllowed;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::InternalizeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::InternalizeL( RReadStream& aStream )
+    {
+    TInt dataLength = 0;
+    HBufC8* dataPart = 0;
+    TPtr8 dataBuffer(NULL,0,0);
+    TInt count = 0;
+    TInt64 timeData;
+    TUint8 flag;
+
+    // read the iRIID
+    aStream.ReadL( iRIID );
+
+    // Read the rights issuer Alias
+    if( iRiAlias )
+        {
+        delete iRiAlias;
+        iRiAlias = NULL;
+        }
+
+    aStream >> flag;
+    if (flag)
+        {
+        iRiAlias = HBufC8::NewL( aStream, KMaxRiAliasLength );
+        }
+
+    // size of the version string which is not always 20
+    count = aStream.ReadInt8L();
+
+    // read the version
+    if( count )
+        {
+        aStream.ReadL( iVersion, count );
+        }
+
+    // read the algorithms
+
+    // How many:
+    count = aStream.ReadInt32L();
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < count; i++ )
+        {
+        // Read the ContentID
+        dataLength = aStream.ReadInt32L();
+
+        if( dataLength )
+            {
+            // Reserve a new buffer:
+            dataPart = HBufC8::NewMaxLC( dataLength );
+
+            // Set the read buffer:
+            dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+
+            // Read the data:
+            aStream.ReadL( dataBuffer );
+
+            // Pop the buffer
+            CleanupStack::Pop(); // dataPart
+
+            // assign the new content id
+            iAlgorithms.AppendL( dataPart );
+            }
+        }
+
+    // read the urls
+
+    // How many:
+    count = aStream.ReadInt32L();
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < count; i++ )
+        {
+        // Read the ContentID
+        dataLength = aStream.ReadInt32L();
+
+        if( dataLength )
+            {
+            // Reserve a new buffer:
+            dataPart = HBufC8::NewMaxLC( dataLength );
+
+            // Set the read buffer:
+            dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+
+            // Read the data:
+            aStream.ReadL( dataBuffer );
+
+            // Pop the buffer
+            CleanupStack::Pop(); // dataPart
+
+            // assign the new content id
+            iRIURLs.AppendL( dataPart );
+            }
+        }
+
+    // Read the rights issuer url
+    if( iRightsIssuerURL )
+        {
+        delete iRightsIssuerURL;
+        iRightsIssuerURL = NULL;
+        }
+
+    aStream >> flag;
+    if (flag)
+        {
+        iRightsIssuerURL = HBufC8::NewL( aStream, KMaxUrlLength );
+        }
+
+    // write the expiry time
+    ReadInt64L( timeData, aStream );
+    iExpiryTime = timeData;
+
+    // How many:
+    count = aStream.ReadInt32L();
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < count; i++ )
+        {
+        // Read the certificate
+        dataPart = HBufC8::NewL( aStream, KMaxCertificateLength );
+
+        // assign the certificate
+        iCertificateChain.AppendL( dataPart );
+        }
+
+    // How many:
+    count = aStream.ReadInt32L();
+
+     // for each in rpointerarray
+    for( TInt i = 0; i < count; i++ )
+        {
+        // Read the certificate
+        dataPart = HBufC8::NewL( aStream, KMaxCertificateLength );
+
+        // assign the certificate
+        iOcspResponse.AppendL( dataPart );
+        }
+
+    // certificate caching indication
+    aStream >> iDeviceCertCached;
+
+    // write the iSelectedDeviceRoot
+    aStream >> flag;
+    if(flag)
+        {
+        aStream.ReadL( iSelectedDeviceRoot );
+        }
+
+    aStream >> iIsMeteringAllowed;
+
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::ImportL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMRIContext::ImportL( const TDesC8& aBuffer )
+    {
+    TInt size = aBuffer.Size();
+    RMemReadStream stream( (TAny*)( aBuffer.Ptr() ), size );
+    CleanupClosePushL( stream );
+
+    InternalizeL( stream );
+
+    CleanupStack::PopAndDestroy(); // Stream
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::ExportL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* CDRMRIContext::ExportL() const
+    {
+    TInt size = Size();
+    HBufC8* data = HBufC8::NewMaxLC( size );
+
+    RMemWriteStream stream( (TAny*)( data->Ptr() ), size );
+    CleanupClosePushL( stream );
+
+    ExternalizeL( stream );
+
+    CleanupStack::PopAndDestroy(); // Stream
+    CleanupStack::Pop();
+    return data;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::Size
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMRIContext::Size() const
+    {
+    TInt size = 0;
+
+    // get the size of iRIID
+    size += SHA1_HASH;
+
+    // get the size of RiAlias
+    size += sizeof(TUint8);
+    if( iRiAlias )
+        {
+        size += iRiAlias->Size();
+        }
+
+    // get the size of version
+    size += sizeof(TInt8);
+
+    size += iVersion.Length();
+
+    // get the size of the algorithms
+
+    // How many:
+    size += sizeof(TInt32);
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < iAlgorithms.Count(); i++ )
+        {
+        size += sizeof(TInt32);
+
+        if( iAlgorithms[i] )
+            {
+            size += iAlgorithms[i]->Size();
+            }
+        }
+
+    // get the size of the riurls
+
+    // How many:
+    size += sizeof(TInt32);
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < iRIURLs.Count(); i++ )
+        {
+        size += sizeof(TInt32);
+
+        if( iRIURLs[i] )
+            {
+            size += iRIURLs[i]->Size();
+            }
+        }
+
+    // rights issuer url
+    size += sizeof(TUint8);
+    if( iRightsIssuerURL )
+        {
+        size += sizeof(TInt32);
+        size += iRightsIssuerURL->Size();
+        }
+
+    // How many:
+    size += sizeof(TInt32);
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < iCertificateChain.Count(); i++ )
+        {
+        size += sizeof(TInt32);
+
+        if( iCertificateChain[i] )
+            {
+            size += iCertificateChain[i]->Size();
+            }
+        }
+
+    // How many:
+    size += sizeof(TInt32);
+
+    // for each in rpointerarray
+    for( TInt i = 0; i < iOcspResponse.Count(); i++ )
+        {
+        size += sizeof(TInt32);
+
+        if( iOcspResponse[i] )
+            {
+            size += iOcspResponse[i]->Size();
+            }
+        }
+
+    // write the expiry time
+    size += sizeof(TInt64);
+
+    // certificate caching indication
+    size += sizeof(TUint8);
+
+    // get the size of iSelectedDeviceRoot
+    size += sizeof(TUint8);
+    if(iSelectedDeviceRoot.Length())
+        {
+        size += SHA1_HASH;
+        }
+
+    // get the size of iIsMeteringAllowed
+    size += sizeof(TUint8);
+
+    return size;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::ConstructL
+// Second phase constructor
+// -----------------------------------------------------------------------------
+//
+void CDRMRIContext::ConstructL( const TDesC8& aRIID,
+                                const TDesC8& aRiAlias,
+                                const TDesC8& aVersion,
+                                const RPointerArray< HBufC8 >& aAlgorithms,
+                                const RPointerArray< HBufC8 >& aRIURLs,
+                                const TDesC8& aRightsIssuerURL,
+                                const TTime& aExpiryTime,
+                                const RPointerArray< HBufC8 >& aChain,
+                                const RPointerArray< HBufC8 >& aResponses,
+                                const TUint8 aDeviceCertCached,
+                                const TDesC8& aSelectedDeviceRoot,
+                                const TUint8 aIsMeteringAllowed )
+    {
+    HBufC8* tempVar = NULL;
+
+    if ( aRIID.Length() > SHA1_HASH )
+        {
+        User::Leave( KErrArgument);
+        }
+
+    iRIID.Copy( aRIID );
+
+    if ( &aRiAlias  && aRiAlias.Length() )
+        {
+        iRiAlias = aRiAlias.AllocL();
+        }
+
+    // The size here should also be fixed
+    iVersion.Copy( aVersion );
+
+    // copy the algorithms
+    for( TInt i = 0; i < aAlgorithms.Count(); i++ )
+        {
+        tempVar = aAlgorithms[i]->AllocLC();
+        iAlgorithms.AppendL( tempVar );
+        CleanupStack::Pop();
+        }
+
+    // copy the rights issuer urls
+    for( TInt i = 0; i < aRIURLs.Count(); i++ )
+        {
+        tempVar = aRIURLs[i]->AllocLC();
+        iRIURLs.AppendL( tempVar );
+        CleanupStack::Pop();
+        }
+
+     // copy the rights issuer URL
+     if ( aRightsIssuerURL.Length() )
+        {
+        iRightsIssuerURL = aRightsIssuerURL.AllocL();
+        }
+
+    // copy the certificate chain
+    for( TInt i = 0; i < aChain.Count(); i++ )
+        {
+        tempVar = aChain[i]->AllocLC();
+        iCertificateChain.AppendL( tempVar );
+        CleanupStack::Pop();
+        }
+
+    // copy the certificate chain
+    for( TInt i = 0; i < aResponses.Count(); i++ )
+        {
+        tempVar = aResponses[i]->AllocLC();
+        iOcspResponse.AppendL( tempVar );
+        CleanupStack::Pop();
+        }
+
+    // set the time
+    iExpiryTime = aExpiryTime;
+
+    // certificate caching indication
+    iDeviceCertCached = aDeviceCertCached;
+
+    if ( aSelectedDeviceRoot.Length() > SHA1_HASH )
+        {
+        User::Leave( KErrArgument);
+        }
+
+    iSelectedDeviceRoot.Copy( aSelectedDeviceRoot );
+
+    iIsMeteringAllowed = aIsMeteringAllowed;
+  };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::WriteInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMRIContext::WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const
+    {
+    TPtr8 output( reinterpret_cast<TUint8*>(const_cast<TInt64*>(&aWrite)),
+                  sizeof(TInt64), sizeof(TInt64) );
+
+    aStream.WriteL( output, sizeof(TInt64) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRIContext::ReadInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMRIContext::ReadInt64L( TInt64& aRead, RReadStream& aStream )
+    {
+    TPtr8 input( reinterpret_cast<TUint8*>(&aRead), 0, sizeof(TInt64) );
+
+    aStream.ReadL( input, sizeof(TInt64) );
+    };
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/src/RoapStorageClient.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,990 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client Class of ROAP Storage Server
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <f32file.h>
+#include <s32file.h>
+#include <x509cert.h>
+#include <x509keys.h>
+#include <asn1dec.h>
+#include <hash.h>
+#include <s32mem.h>
+#include <e32base.h>  // CleanupResetAndDestroyPushL dependencies
+#include "OmaCrypto.h"
+#include "RoapStorageClient.h"
+#include "DRMRIContext.h"
+#include "DRMDomainContext.h"
+#include "drmroapclientserver.h"
+#include "drmrightsclient.h"
+#include "cleanupresetanddestroy.h" // CleanupResetAndDestroyPushL
+// LOCAL CONSTANTS AND MACROS
+
+LOCAL_C const TInt KMaxMessageSlots = 4;
+const TInt KMaxElementLength = 327680;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ArrayToBuffer
+// Created buffer will contain <amount of elements:int32, data1, data2 ...>
+// -----------------------------------------------------------------------------
+//
+LOCAL_C HBufC8* ArrayToBufferLC( const RPointerArray<HBufC8>& aArray )
+    {
+    HBufC8* buffer = NULL;
+    TInt32 sizeOfElements = 0;
+
+    for ( TInt i = 0; i < aArray.Count(); i++ )
+        {
+        // sizeof(TInt) is for element length info
+        sizeOfElements += aArray[i]->Length() + sizeof(TInt);
+        }
+
+    // length of elements + amount of elements
+    sizeOfElements += sizeof(TInt32);
+
+    buffer = HBufC8::NewMaxLC( sizeOfElements );
+
+    RMemWriteStream stream( (TAny*)( buffer->Ptr() ), sizeOfElements );
+    CleanupClosePushL( stream );
+
+    stream.WriteInt32L( aArray.Count() );
+
+    for ( TInt i = 0; i < aArray.Count(); i++ )
+        {
+        stream << *aArray[i];
+        }
+
+    CleanupStack::PopAndDestroy( &stream );
+
+    return buffer;
+    }
+
+// -----------------------------------------------------------------------------
+// BufferToArrayL
+// Created buffer will contain <amount of elements:int32, element data1, element data2...>
+// -----------------------------------------------------------------------------
+//
+LOCAL_C RPointerArray<HBufC8> BufferToArrayL( TDesC8& aBuffer )
+    {
+    TInt32 count = 0;
+    HBufC8* element = NULL;
+    RPointerArray<HBufC8> array;
+    TInt size = aBuffer.Size();
+    RMemReadStream stream( (TAny*)( aBuffer.Ptr() ), size );
+    CleanupClosePushL( stream );
+
+    CleanupResetAndDestroyPushL( array );
+
+    // amount of elements
+    count = stream.ReadInt32L();
+
+    // for each in RPointerArray
+    for ( TInt i = 0; i < count; i++ )
+        {
+        // Read the element and append it to array
+        element = HBufC8::NewLC( stream, KMaxElementLength );
+        array.AppendL( element );
+        CleanupStack::Pop( element );
+        }
+
+    CleanupStack::Pop( &array );
+    CleanupStack::PopAndDestroy( &stream );
+
+    return array;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::RoapStorageClient
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C Roap::RRoapStorageClient::RRoapStorageClient()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::~RRoapStorageClient()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C Roap::RRoapStorageClient::~RRoapStorageClient()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::Connect
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt Roap::RRoapStorageClient::Connect()
+    {
+    TInt ret( KErrNone );
+
+    const TVersion requiredVersion( Roap::KServerMajorVersion,
+        Roap::KServerMinorVersion, Roap::KServerBuildVersion );
+
+    RDRMRightsClient::StartServer();
+
+    ret = CreateSession( KServerName, requiredVersion, KMaxMessageSlots );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::GetDevicePublicKeyL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt Roap::RRoapStorageClient::GetDevicePublicKeyL(
+    CRSAPublicKey*& aPublicKey )
+    {
+    HBufC8* publicKeyDer( NULL );
+    CX509SubjectPublicKeyInfo* publicKeyInfo( NULL );
+    TX509KeyFactory factory;
+
+    GetDevicePublicKeyDerL( publicKeyDer );
+    CleanupStack::PushL( publicKeyDer );
+    publicKeyInfo = CX509SubjectPublicKeyInfo::NewLC( *publicKeyDer );
+    aPublicKey = factory.RSAPublicKeyL( publicKeyInfo->KeyData() );
+
+    CleanupStack::PopAndDestroy( publicKeyInfo );
+    CleanupStack::PopAndDestroy( publicKeyDer );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::GetDevicePublicKeyDerL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt Roap::RRoapStorageClient::GetDevicePublicKeyDerL(
+    HBufC8*& aPublicKey )
+    {
+    TInt size = 0;
+    TInt error = KErrNone;
+    TPckg<TInt> package( size );
+
+    error = SendReceive( Roap::EGetPublicKey, TIpcArgs( &package ) );
+
+    User::LeaveIfError( error );
+
+    HBufC8* publicKey( HBufC8::NewMaxLC( size ) );
+    TPtr8 objectPkg( const_cast<TUint8*> ( publicKey->Ptr() ), size, size );
+
+    User::LeaveIfError( SendReceive( Roap::EGetData, TIpcArgs( &objectPkg ) ) );
+
+    CleanupStack::Pop( publicKey );
+    aPublicKey = publicKey;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::GetDevicePublicKeyHashL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt Roap::RRoapStorageClient::GetDevicePublicKeyHashL( TDes8& aHash )
+    {
+    CSHA1* hash = NULL;
+    HBufC8* key = NULL;
+
+    GetDevicePublicKeyDerL( key );
+    CleanupStack::PushL( key );
+    hash = CSHA1::NewL();
+    CleanupStack::PushL( hash );
+    hash->Hash( *key );
+    aHash.Copy( hash->Final() );
+    CleanupStack::PopAndDestroy( hash );
+    CleanupStack::PopAndDestroy( key );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::GetDeviceCertificateChainL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt Roap::RRoapStorageClient::GetDeviceCertificateChainL(
+    RPointerArray<HBufC8>& aCertChain )
+    {
+    TInt size = 0;
+    TInt error = KErrNone;
+    TPckg<TInt> package( size );
+    HBufC8* certChainBuf = NULL;
+
+    error = SendReceive( Roap::EGetCertificates, TIpcArgs( &package ) );
+
+    User::LeaveIfError( error );
+
+    certChainBuf = HBufC8::NewMaxLC( size );
+    TPtr8 objectPkg( const_cast<TUint8*> ( certChainBuf->Ptr() ), size, size );
+
+    User::LeaveIfError( SendReceive( Roap::EGetData, TIpcArgs( &objectPkg ) ) );
+
+    aCertChain = BufferToArrayL( *certChainBuf );
+
+    CleanupStack::PopAndDestroy( certChainBuf );
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::SignL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt Roap::RRoapStorageClient::SignL(
+    const TDesC8& aHash,
+    HBufC8*& aSignature )
+    {
+    TInt size = 0;
+    TInt error = KErrNone;
+    TPckg<TInt> package( size );
+
+    if ( aHash.Length() )
+        {
+        error
+            = SendReceive( Roap::ESignMessage, TIpcArgs( &package, &aHash ) );
+
+        User::LeaveIfError( error );
+
+        HBufC8* signature( HBufC8::NewMaxLC( size ) );
+        TPtr8
+            objectPkg( const_cast<TUint8*> ( signature->Ptr() ), size, size );
+
+        User::LeaveIfError( SendReceive( Roap::EGetData,
+            TIpcArgs( &objectPkg ) ) );
+
+        CleanupStack::Pop( signature );
+        aSignature = signature;
+        return KErrNone;
+        }
+
+    User::Leave( KErrArgument );
+    return KErrArgument;
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::SignL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt Roap::RRoapStorageClient::RsaSignL(
+    const TDesC8& aHash,
+    HBufC8*& aSignature )
+    {
+    TInt size = 0;
+    TInt error = KErrNone;
+    TPckg<TInt> package( size );
+
+    if ( aHash.Length() )
+        {
+        error = SendReceive( Roap::ERsaSign, TIpcArgs( &package, &aHash ) );
+
+        User::LeaveIfError( error );
+
+        HBufC8* signature( HBufC8::NewMaxLC( size ) );
+        TPtr8
+            objectPkg( const_cast<TUint8*> ( signature->Ptr() ), size, size );
+
+        User::LeaveIfError( SendReceive( Roap::EGetData,
+            TIpcArgs( &objectPkg ) ) );
+
+        CleanupStack::Pop( signature );
+        aSignature = signature;
+        return KErrNone;
+        }
+
+    User::Leave( KErrArgument );
+    return KErrArgument;
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::VerifyL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool Roap::RRoapStorageClient::VerifyL(
+    const TDesC8& aSignature,
+    const TDesC8& aHash,
+    const RPointerArray<HBufC8>& aCertificateChain )
+    {
+    CRSAPublicKey* publicKey( NULL );
+    TBool r( ETrue );
+    CX509Certificate* cert( NULL );
+    TX509KeyFactory factory;
+
+    if ( aCertificateChain.Count() <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+    cert = CX509Certificate::NewLC( *aCertificateChain[0] );
+    publicKey = factory.RSAPublicKeyL( cert->PublicKey().KeyData() );
+    CleanupStack::PushL( publicKey );
+    r = OmaCrypto::RsaPssVerifyHashL( publicKey, aSignature, aHash );
+    CleanupStack::PopAndDestroy( publicKey );
+    CleanupStack::PopAndDestroy( cert );
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::GetRIContextL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMRIContext* Roap::RRoapStorageClient::GetRIContextL(
+    const TDesC8& aRiID )
+    {
+    TInt error = KErrNone;
+    CDRMRIContext* context( NULL );
+
+    if ( aRiID.Length() )
+        {
+        TInt size = 0;
+        TPckg<TInt> package( size );
+
+        error
+            = SendReceive( Roap::EGetRiContext, TIpcArgs( &package, &aRiID ) );
+
+        if ( error == KErrNotFound )
+            {
+            return NULL;
+            }
+
+        User::LeaveIfError( error );
+
+        HBufC8* contextData = HBufC8::NewMaxLC( size );
+
+        // Package 'object' into TPtr8.
+        TPtr8 objectPkg( const_cast<TUint8*> ( contextData->Ptr() ), size,
+            size );
+
+        User::LeaveIfError( SendReceive( Roap::EGetData,
+            TIpcArgs( &objectPkg ) ) );
+
+        context = CDRMRIContext::NewLC();
+
+        context->ImportL( contextData->Des() );
+
+        CleanupStack::Pop( context );
+        CleanupStack::PopAndDestroy( contextData );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    return context;
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::GetDomainContextL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMDomainContext* Roap::RRoapStorageClient::GetDomainContextL(
+    const TDesC8& aDomainID )
+    {
+    TInt error = KErrNone;
+    CDRMDomainContext* context( NULL );
+
+    if ( aDomainID.Length() )
+        {
+        TInt size = 0;
+        TPckg<TInt> package( size );
+
+        // Call the server. Throw an exception in case of an error.
+        error = SendReceive( Roap::EGetDomainContext, TIpcArgs( &package,
+            &aDomainID ) );
+
+        if ( error == KErrNotFound )
+            {
+            return NULL;
+            }
+
+        HBufC8* contextData = HBufC8::NewMaxLC( size );
+
+        // Package 'object' into TPtr8.
+        TPtr8 objectPkg( const_cast<TUint8*> ( contextData->Ptr() ), size,
+            size );
+
+        User::LeaveIfError( SendReceive( Roap::EGetData,
+            TIpcArgs( &objectPkg ) ) );
+
+        context = CDRMDomainContext::NewLC();
+
+        context->ImportL( contextData->Des() );
+
+        CleanupStack::Pop( context );
+        CleanupStack::PopAndDestroy( contextData );
+
+        return context;
+        }
+
+    User::Leave( KErrArgument );
+
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::AddRIContextL
+// Add a new RI Context to the ROAP storage
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void Roap::RRoapStorageClient::AddRIContextL(
+    const CDRMRIContext& aRiContext )
+    {
+    HBufC8* contextData = aRiContext.ExportL();
+    TInt size = aRiContext.Size();
+    TPtr8 riContext( NULL, 0 );
+    if ( size )
+        {
+        riContext.Set( const_cast<TUint8*> ( contextData->Ptr() ), size, size );
+
+        User::LeaveIfError( SendReceive( Roap::EAddRiContext, TIpcArgs(
+            &riContext ) ) );
+        }
+    delete contextData;
+    contextData = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::AddDomainContextL
+// Add a new Domain Context to the ROAP storage
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void Roap::RRoapStorageClient::AddDomainContextL(
+    const CDRMDomainContext& aDomainContext,
+    const RPointerArray<HBufC8>& aMacs,
+    const RPointerArray<HBufC8>& aDomainKeyElements,
+    TKeyTransportScheme& aTransportScheme )
+    {
+    TPckg<TKeyTransportScheme> package( aTransportScheme );
+    HBufC8* contextData = aDomainContext.ExportL();
+    CleanupStack::PushL( contextData );
+    TInt size = aDomainContext.Size();
+    TPtr8 contextPtr( NULL, 0 );
+    TPtr8 domainXmltPtr( 0, 0 );
+    TPtr8 macValuesPtr( 0, 0 );
+    HBufC8* domainXml = NULL;
+    HBufC8* macValues = NULL;
+
+    domainXml = ArrayToBufferLC( aDomainKeyElements );
+    macValues = ArrayToBufferLC( aMacs );
+
+    if ( size && domainXml && macValues )
+        {
+        contextPtr.Set( const_cast<TUint8*> ( contextData->Ptr() ), size,
+            size );
+        domainXmltPtr.Set( domainXml->Des() );
+        macValuesPtr.Set( macValues->Des() );
+
+        User::LeaveIfError( SendReceive( Roap::EAddDomainContext, TIpcArgs(
+            &contextPtr, &package, &macValuesPtr, &domainXmltPtr ) ) );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    CleanupStack::PopAndDestroy( macValues );
+    CleanupStack::PopAndDestroy( domainXml );
+    CleanupStack::PopAndDestroy( contextData );
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::DeleteRiContextL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void Roap::RRoapStorageClient::DeleteRiContextL( const TDesC8& aRiID )
+    {
+    if ( aRiID.Length() )
+        {
+        User::LeaveIfError( SendReceive( Roap::EDeleteRiContext, TIpcArgs(
+            &aRiID ) ) );
+        return;
+        }
+    User::Leave( KErrArgument );
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::DeleteDomainContextL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void Roap::RRoapStorageClient::DeleteDomainContextL(
+    const TDesC8& aDomainID )
+    {
+    if ( aDomainID.Length() )
+        {
+        User::LeaveIfError( SendReceive( Roap::EDeleteDomainContext,
+            TIpcArgs( &aDomainID ) ) );
+        return;
+        }
+    User::Leave( KErrArgument );
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::DeleteExpiredRIsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void Roap::RRoapStorageClient::DeleteExpiredRIsL( const TTime& aTime )
+    {
+    TPckg<TTime> package( aTime );
+
+    User::LeaveIfError( SendReceive( Roap::EDeleteExpiredRIs, TIpcArgs(
+        &package ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::DeleteExpiredDomainsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void Roap::RRoapStorageClient::DeleteExpiredDomainsL(
+    const TTime& aTime )
+    {
+    TPckg<TTime> package( aTime );
+
+    User::LeaveIfError( SendReceive( Roap::EDeleteExpiredDomains, TIpcArgs(
+        &package ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::DeleteExpiredContextsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void Roap::RRoapStorageClient::DeleteExpiredContextsL(
+    const TTime& aTime )
+    {
+    TPckg<TTime> package( aTime );
+
+    User::LeaveIfError( SendReceive( Roap::EDeleteExpired,
+        TIpcArgs( &package ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::DeleteAllL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void Roap::RRoapStorageClient::DeleteAllL()
+    {
+    User::LeaveIfError( SendReceive( Roap::EDeleteAll ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::WhiteListURLExistsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool Roap::RRoapStorageClient::WhiteListURLExistsL(
+    const TDesC8& aURL, TBool& aFromPreconfiguredWhiteList )
+    {
+    TInt r = KErrArgument;
+
+    TPckg<TBool> preConfiguredInOutParam( aFromPreconfiguredWhiteList );
+    if ( aURL.Length() )
+        {
+        // Call the server.
+        r = SendReceive( Roap::EWhiteListCheck, TIpcArgs( &aURL,
+            &preConfiguredInOutParam ) );
+        if ( r == KErrNone )
+            {
+            return ETrue;
+            }
+        else if ( r == KErrNotFound )
+            {
+            return EFalse;
+            }
+        }
+    User::LeaveIfError( r );
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::SelectTrustedRootL()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt Roap::RRoapStorageClient::SelectTrustedRootL(
+    const RPointerArray<HBufC8>& aTrustedRoots,
+    TDes8& aSelectedRoot ) const
+    {
+    TInt ret = KErrNone;
+
+    if ( aTrustedRoots.Count() )
+        {
+        HBufC8* rootsBuf = NULL;
+        rootsBuf = ArrayToBufferLC( aTrustedRoots );
+
+        ret = SendReceive( Roap::ESelectRoot, TIpcArgs( rootsBuf,
+            &aSelectedRoot ) );
+
+        CleanupStack::PopAndDestroy( rootsBuf );
+        return ret;
+        }
+
+    return KErrArgument;
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::SelectTrustedRootL()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt Roap::RRoapStorageClient::SelectTrustedRootL(
+    const TDesC8& aTrustedRoot ) const
+    {
+    TInt ret = KErrNone;
+
+    if ( aTrustedRoot.Length() > SHA1_HASH )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    ret = SendReceive( Roap::EActivateRoot, TIpcArgs( &aTrustedRoot ) );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::GetTrustedRootsL()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void Roap::RRoapStorageClient::GetTrustedRootsL(
+    RPointerArray<HBufC8>& aTrustedRoots ) const
+    {
+    TInt size = 0;
+    TPckg<TInt> package( size );
+
+    User::LeaveIfError( SendReceive( Roap::EGetTrustedRoots, TIpcArgs(
+        &package ) ) );
+
+    HBufC8* rootsData = HBufC8::NewMaxLC( size );
+
+    // Package 'object' into TPtr8.
+    TPtr8 objectPkg( const_cast<TUint8*> ( rootsData->Ptr() ), size, size );
+
+    User::LeaveIfError( SendReceive( Roap::EGetData, TIpcArgs( &objectPkg ) ) );
+
+    aTrustedRoots = BufferToArrayL( *rootsData );
+
+    CleanupStack::PopAndDestroy( rootsData );
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::GetTrustedRootL()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* Roap::RRoapStorageClient::GetRootCertificateL(
+    const TDesC& aSubject ) const
+    {
+    TInt error = KErrNone;
+    HBufC8* rootCert = NULL;
+
+    if ( aSubject.Length() )
+        {
+        TInt size = 0;
+        TPckg<TInt> package( size );
+
+        error = SendReceive( Roap::EGetRootCert, TIpcArgs( &package,
+            &aSubject ) );
+
+        if ( error == KErrNotFound )
+            {
+            return NULL;
+            }
+
+        User::LeaveIfError( error );
+
+        rootCert = HBufC8::NewMaxLC( size );
+
+        // Package 'object' into TPtr8.
+        TPtr8 objectPkg( const_cast<TUint8*> ( rootCert->Ptr() ), size, size );
+
+        User::LeaveIfError( SendReceive( Roap::EGetData,
+            TIpcArgs( &objectPkg ) ) );
+
+        CleanupStack::Pop( rootCert );
+        return rootCert;
+        }
+
+    User::Leave( KErrArgument );
+
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::GetMeteringData()
+// -----------------------------------------------------------------------------
+//
+#ifndef RD_DRM_METERING
+EXPORT_C HBufC8* Roap::RRoapStorageClient::GetMeteringDataL(
+    TDesC8& /*aRiId*/,
+    TDes8& /*aMacKey*/,
+    TDes8& /*aEncKeyHash*/,
+    HBufC8*& /*aEncryptedMekAndMak*/ )
+    {
+    return NULL;
+    }
+#else
+EXPORT_C HBufC8* Roap::RRoapStorageClient::GetMeteringDataL(
+    TDesC8& aRiId,
+    TDes8& aMacKey,
+    TDes8& aEncKeyHash,
+    HBufC8*& aEncryptedMekAndMak )
+    {
+    TInt error = KErrNone;
+    HBufC8* meteringData = NULL;
+    HBufC8* csBuffer = NULL;
+
+    if ( aRiId.Length() )
+        {
+        TInt mekAndMakSize = 0;
+        TInt meteringDataSize = 0;
+        TPckg<TInt> MakMek( mekAndMakSize );
+        TPckg<TInt> dataSize( meteringDataSize );
+
+        error = SendReceive( Roap::EGetMeteringData, TIpcArgs( &aRiId,
+            &MakMek, &dataSize ) );
+
+        if ( error == KErrNotFound )
+            {
+            return NULL;
+            }
+
+        User::LeaveIfError( error );
+
+        csBuffer = HBufC8::NewMaxLC( OmaCrypto::KMacSize + SHA1_HASH
+            + mekAndMakSize + meteringDataSize );
+
+        // Package 'object' into TPtr8.
+        TPtr8 objectPkg( const_cast<TUint8*> ( csBuffer->Ptr() ),
+            OmaCrypto::KMacSize + SHA1_HASH + mekAndMakSize
+                + meteringDataSize, OmaCrypto::KMacSize + SHA1_HASH
+                + mekAndMakSize + meteringDataSize );
+
+        User::LeaveIfError( SendReceive( Roap::EGetData,
+            TIpcArgs( &objectPkg ) ) );
+
+        aMacKey = objectPkg.Mid( 0, OmaCrypto::KMacSize );
+        aEncKeyHash = objectPkg.Mid( OmaCrypto::KMacSize, SHA1_HASH );
+        aEncryptedMekAndMak = objectPkg.Mid( OmaCrypto::KMacSize + SHA1_HASH,
+            mekAndMakSize ).AllocL();
+        meteringData = objectPkg.Mid( OmaCrypto::KMacSize + SHA1_HASH
+            + mekAndMakSize, meteringDataSize ).AllocL();
+        CleanupStack::PopAndDestroy( csBuffer );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    return meteringData;
+    }
+#endif //RD_DRM_METERING
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::DeleteMeteringDataL
+// -----------------------------------------------------------------------------
+//
+#ifndef RD_DRM_METERING
+EXPORT_C void Roap::RRoapStorageClient::DeleteMeteringDataL(
+    const TDesC8& /*aRiId*/)
+    {
+    return;
+    }
+#else
+EXPORT_C void Roap::RRoapStorageClient::DeleteMeteringDataL(
+    const TDesC8& aRiId )
+    {
+    if ( aRiId.Length() )
+        {
+        User::LeaveIfError( SendReceive( Roap::EDeleteMeteringData, TIpcArgs(
+            &aRiId ) ) );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    return;
+    }
+#endif //RD_DRM_METERING
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::GetAllRIContextsL
+// -----------------------------------------------------------------------------
+//
+#ifndef RD_DRM_METERING
+EXPORT_C void Roap::RRoapStorageClient::GetAllRIContextsL(
+    RPointerArray<Roap::CDRMRIContext>& /*aRiContexts*/)
+    {
+    }
+#else
+EXPORT_C void Roap::RRoapStorageClient::GetAllRIContextsL(
+    RPointerArray<CDRMRIContext>& aRiContexts )
+    {
+    TInt error = KErrNone;
+    CDRMRIContext* context = NULL;
+
+    // Clear whatever is in the list.
+    aRiContexts.ResetAndDestroy();
+
+    TInt size = 0;
+    TInt blocksize = 0;
+
+    TPckg<TInt> package( size );
+
+    error = SendReceive( Roap::ERetrieveAllRIContexts, TIpcArgs( &package ) );
+
+    // None are found is not an error, but just an empty list.
+    if ( error == KErrNotFound )
+        {
+        return;
+        }
+
+    // otherwise it is an error.
+    User::LeaveIfError( error );
+
+    // Get the data block received.
+
+
+    HBufC8* contextData = HBufC8::NewMaxLC( size );
+
+    // Package 'object' into TPtr8.
+    TPtr8 objectPkg( const_cast<TUint8*> ( contextData->Ptr() ), size, size );
+
+    User::LeaveIfError( SendReceive( Roap::EGetData, TIpcArgs( &objectPkg ) ) );
+
+    RMemReadStream stream( (TAny*)( objectPkg.Ptr() ), size );
+    CleanupClosePushL( stream );
+
+    // We have the data, parse it and fill the aRiContexts:
+
+    blocksize = stream.ReadInt32L();
+
+    while ( blocksize )
+        {
+        // Create a new context:
+        context = CDRMRIContext::NewLC();
+
+        // import it from the data block
+        context->InternalizeL( stream );
+
+        // add it to the pointer array
+        aRiContexts.AppendL( context );
+
+        // pop it from the cleanup stack
+        CleanupStack::Pop( context ); // context
+
+
+        // read the new block size and increment the offset:
+        blocksize = stream.ReadInt32L();
+        }
+
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( contextData );
+    return;
+    }
+
+#endif // RD_DRM_METERING
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::UpdateRiContextL
+// -----------------------------------------------------------------------------
+//
+#ifndef RD_DRM_METERING
+EXPORT_C void Roap::RRoapStorageClient::UpdateRIContextL(
+    const Roap::CDRMRIContext& /*aContext*/)
+    {
+    }
+#else
+EXPORT_C void Roap::RRoapStorageClient::UpdateRIContextL(
+    const CDRMRIContext& aContext )
+    {
+    HBufC8* contextData = aContext.ExportL();
+    CleanupStack::PushL( contextData );
+    TInt size = aContext.Size();
+    TPtr8 riContext( NULL, 0 );
+    if ( size )
+        {
+        riContext.Set( const_cast<TUint8*> ( contextData->Ptr() ), size, size );
+
+        User::LeaveIfError( SendReceive( Roap::EUpdateRIContext, TIpcArgs(
+            &riContext ) ) );
+        }
+    CleanupStack::PopAndDestroy( contextData );
+    }
+#endif // RD_DRM_METERING
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::UpdateDrmTimeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool Roap::RRoapStorageClient::UpdateDrmTimeL(
+    const RPointerArray<HBufC8>& aCertChain,
+    const RPointerArray<HBufC8>& aOcspResponses,
+    const TDesC8& aNonce )
+    {
+    TBool clockUpdated( EFalse );
+    TPckg<TBool> retParam( clockUpdated );
+    HBufC8* certChain( ArrayToBufferLC( aCertChain ) );
+    HBufC8* ocspResponses( ArrayToBufferLC( aOcspResponses ) );
+    TPtrC8 nonceParam( aNonce );
+    User::LeaveIfError( SendReceive( Roap::EUpdateDrmTime, TIpcArgs(
+        certChain, ocspResponses, &nonceParam, &retParam ) ) );
+    CleanupStack::PopAndDestroy( ocspResponses );
+    CleanupStack::PopAndDestroy( certChain );
+    return clockUpdated;
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::VerifyOcspResponsesL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool Roap::RRoapStorageClient::VerifyOcspResponsesL(
+    const RPointerArray<HBufC8>& aOcspResponses,
+    const TDesC8& aRiCaCert,
+    const RPointerArray<HBufC8>& aCertSerialNums )
+    {
+    TBool ret( EFalse );
+    HBufC8* ocspData( ArrayToBufferLC( aOcspResponses ) );
+    HBufC8* serialNumsData( ArrayToBufferLC( aCertSerialNums ) );
+
+    TPtrC8 riCaCertParam( aRiCaCert );
+    TPckg<TBool> retParam( ret );
+
+    User::LeaveIfError( SendReceive( Roap::EVerifyOcspResponses, TIpcArgs(
+        ocspData, &riCaCertParam, serialNumsData, &retParam ) ) );
+
+    CleanupStack::PopAndDestroy( serialNumsData );
+    CleanupStack::PopAndDestroy( ocspData );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::GetOcspResponderIdL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* Roap::RRoapStorageClient::GetOcspResponderIdL(
+    const TDesC8& aRiID )
+    {
+    TPtrC8 riIdParam( aRiID );
+    TInt size( 0 );
+    TPckg<TInt> sizeParam( size );
+
+    User::LeaveIfError( SendReceive( Roap::EGetOcspResponderId, TIpcArgs(
+        &riIdParam, &sizeParam ) ) );
+
+    if ( size == 0 )
+        {
+        return NULL;
+        }
+    HBufC8* responderData = HBufC8::NewMaxLC( size );
+
+    // Package 'object' into TPtr8.
+    TPtr8 objectPkg( responderData->Des() );
+
+    User::LeaveIfError( SendReceive( Roap::EGetData, TIpcArgs( &objectPkg ) ) );
+
+    CleanupStack::Pop( responderData );
+    return responderData;
+    }
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/src/RoapStorageClientStub.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,489 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <f32file.h>
+#include <s32file.h>
+#include <x509cert.h>
+#include <x509keys.h>
+#include <asn1dec.h>
+#include <hash.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "OmaCrypto.h"
+#include "RoapStorageClient.h"
+
+using namespace Roap;
+
+// EXTERNAL DATA STRUCTURES
+//extern  ?external_data;
+
+// EXTERNAL FUNCTION PROTOTYPES  
+//extern ?external_function( ?arg_type,?arg_type );
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// LOCAL CONSTANTS AND MACROS
+//const ?type ?constant_var = ?constant;
+//#define ?macro_name ?macro_def
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT(KCertChainDir, "%c:\\drm\\PKI\\");
+_LIT(KSigningCertPrefix, "SigningCert");
+_LIT(KDeviceCertFileName, "%c:\\drm\\PKI\\DeviceCert.der");
+_LIT(KDevicePrivateKeyFileName, "%c:\\drm\\PKI\\DevicePrivateKey.der");
+#else
+_LIT(KCertChainDir, "c:\\drm\\PKI\\");
+_LIT(KSigningCertPrefix, "SigningCert");
+_LIT(KDeviceCertFileName, "c:\\drm\\PKI\\DeviceCert.der");
+_LIT(KDevicePrivateKeyFileName, "c:\\drm\\PKI\\DevicePrivateKey.der");
+#endif
+
+
+// MODULE DATA STRUCTURES
+//enum ?declaration
+//typedef ?declaration
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C void ReadFileL(
+    HBufC8*& aContent,
+    const TDesC& aName);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void ReadFileL(
+    HBufC8*& aContent,
+    const TDesC& aName)
+	{	
+	TInt size = 0;
+	RFile file;
+	RFs fs;
+
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+	User::LeaveIfError(file.Open(fs, aName, EFileRead));
+    CleanupClosePushL(file);
+    User::LeaveIfError(file.Size(size));
+    aContent = HBufC8::NewLC(size);
+    TPtr8 ptr(aContent->Des());
+    User::LeaveIfError(file.Read(ptr, size));
+	CleanupStack::Pop(); //aContent
+	CleanupStack::PopAndDestroy(2); // file, fs
+	}
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::RoapStorageClient
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+RRoapStorageClient::RRoapStorageClient()
+    {
+    }
+
+// Destructor
+RRoapStorageClient::~RRoapStorageClient()
+    {
+    
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::?member_function
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt RRoapStorageClient::Connect(void)
+    {
+    return KErrNone;
+    }
+
+TInt RRoapStorageClient::GetDeviceCertificateL(
+    HBufC8*& aCert)
+    {
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    ReadFileL(aCert, KDeviceCertFileName);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    RFs fs;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	
+	User::LeaveIfError( fs.Connect() );
+	fs.DriveToChar( driveNumber, driveLetter );
+    fs.Close();
+    
+	TFileName deviceCertFileName;
+	deviceCertFileName.Format( KDeviceCertFileName, (TUint)driveLetter );
+    
+    ReadFileL(aCert, deviceCertFileName);
+    
+#endif
+    
+    return KErrNone;
+    }
+
+TInt RRoapStorageClient::GetDevicePublicKeyL(
+    CRSAPublicKey*& aPublicKey)
+    {
+    HBufC8* certData;
+    CX509Certificate* cert;
+    TX509KeyFactory factory;
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    ReadFileL(certData, KDeviceCertFileName);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    RFs fs;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	
+	User::LeaveIfError( fs.Connect() );
+	fs.DriveToChar( driveNumber, driveLetter );
+    fs.Close();
+    
+	TFileName deviceCertFileName;
+	deviceCertFileName.Format( KDeviceCertFileName, (TUint)driveLetter );
+    
+    ReadFileL(certData, deviceCertFileName);
+    
+#endif
+    
+    CleanupStack::PushL(certData);
+    cert = CX509Certificate::NewLC(*certData);
+    aPublicKey = factory.RSAPublicKeyL(cert->PublicKey().KeyData());
+    CleanupStack::PopAndDestroy(2); // cert, certData
+    return KErrNone;
+    }
+    
+TInt RRoapStorageClient::GetDevicePublicKeyDerL(
+    HBufC8*& aPublicKey)
+    {
+    HBufC8* certData;
+    CX509Certificate* cert;
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    ReadFileL(certData, KDeviceCertFileName);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    RFs fs;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	
+	User::LeaveIfError( fs.Connect() );
+	fs.DriveToChar( driveNumber, driveLetter );
+    fs.Close();
+    
+	TFileName deviceCertFileName;
+	deviceCertFileName.Format( KDeviceCertFileName, (TUint)driveLetter );
+    
+    ReadFileL(certData, deviceCertFileName);
+    
+#endif
+     
+    CleanupStack::PushL(certData);
+    cert = CX509Certificate::NewLC(*certData);
+    aPublicKey = cert->PublicKey().KeyData().AllocL();
+    CleanupStack::PopAndDestroy(2); // cert, certData
+    return KErrNone;
+    }
+
+TInt RRoapStorageClient::GetDevicePublicKeyHashL(
+    TDes8& aHash)
+    {
+    CSHA1* hash = NULL;
+    HBufC8* key = NULL;
+    
+    GetDevicePublicKeyDerL(key);
+    CleanupStack::PushL(key);
+    hash = CSHA1::NewL();
+    CleanupStack::PushL(hash);
+    hash->Hash(*key);
+    aHash.Copy(hash->Final());
+    CleanupStack::PopAndDestroy(2); // hash, key
+    return KErrNone;
+    }
+
+TInt RRoapStorageClient::GetDevicePrivateKeyL(
+    CRSAPrivateKey*& aKey)
+    {
+    HBufC8* raw = NULL;
+	TASN1DecInteger encInt;
+    TInt pos = 0;
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    ReadFileL(raw, KDevicePrivateKeyFileName);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    RFs fs;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	
+	User::LeaveIfError( fs.Connect() );
+	fs.DriveToChar( driveNumber, driveLetter );
+    fs.Close();
+    
+	TFileName devicePrivateKeyFileName;
+	devicePrivateKeyFileName.Format( 
+	                    KDevicePrivateKeyFileName, (TUint)driveLetter );
+    
+    ReadFileL(raw, devicePrivateKeyFileName);
+    
+#endif
+    
+    CleanupStack::PushL(raw);
+
+	TASN1DecGeneric gen(*raw);
+	gen.InitL();
+	pos += gen.LengthDERHeader();
+	if (gen.Tag() != EASN1Sequence)
+        {
+		User::Leave(KErrArgument);
+        }
+
+    encInt.DecodeDERShortL(*raw, pos); // version
+	RInteger modulus = encInt.DecodeDERLongL(*raw, pos);
+    CleanupStack::PushL(modulus);
+	RInteger publicExponent = encInt.DecodeDERLongL(*raw, pos);
+    CleanupStack::PushL(publicExponent);
+	RInteger privateExponent = encInt.DecodeDERLongL(*raw, pos);
+    CleanupStack::PushL(privateExponent);
+
+	aKey = CRSAPrivateKeyStandard::NewL(modulus, privateExponent);
+
+    CleanupStack::Pop(); // privateExponent
+    CleanupStack::PopAndDestroy();// publicExponent
+    CleanupStack::Pop(); // modulus
+    CleanupStack::PopAndDestroy(); // raw
+
+    return KErrNone;
+    }
+
+TInt RRoapStorageClient::GetDeviceCertificateChainL(
+    RPointerArray<HBufC8>& aCertChain)
+    {
+    RFs fs;
+    RFile file;
+    TFileName fileName;
+    CDir* dir;
+    HBufC8* cert;
+    TInt size;
+    TPtr8 ptr(0, 0);
+    TInt itemsToPop = 0;
+    TInt i;
+    TEntry entry;
+
+    CleanupClosePushL(aCertChain);
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    
+#ifndef RD_MULTIPLE_DRIVE
+
+    User::LeaveIfError(fs.GetDir(KCertChainDir, KEntryAttMatchMask,
+        ESortByName, dir));
+    User::LeaveIfError(fs.SetSessionPath(KCertChainDir));
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	fs.DriveToChar( driveNumber, driveLetter );
+    
+	TFileName certChainDir;
+	certChainDir.Format( KCertChainDir, (TUint)driveLetter );
+    
+    User::LeaveIfError(fs.GetDir(certChainDir, KEntryAttMatchMask,
+        ESortByName, dir));
+    User::LeaveIfError(fs.SetSessionPath(certChainDir));
+    
+#endif
+    
+    CleanupStack::PushL(dir);
+    GetDeviceCertificateL(cert);
+    CleanupStack::PushL(cert);
+    User::LeaveIfError(aCertChain.Append(cert));
+    itemsToPop++;
+    for (i = 0; i < dir->Count(); i++)
+        {
+        entry = (*dir)[i];
+        if (entry.iName.Left(KSigningCertPrefix().Length()).CompareF(
+            KSigningCertPrefix) == 0)
+            {
+            User::LeaveIfError(file.Open(fs, entry.iName, EFileRead));
+            CleanupClosePushL(file);
+            User::LeaveIfError(file.Size(size));
+            cert = HBufC8::NewMax(size);
+            ptr.Set(cert->Des());
+            CleanupStack::PushL(cert);
+            User::LeaveIfError(aCertChain.Append(cert));
+            itemsToPop++;
+            User::LeaveIfError(file.Read(ptr));
+            CleanupStack::Pop(); // cert
+            CleanupStack::PopAndDestroy(); // file
+            CleanupStack::PushL(cert);
+            }
+        }
+    CleanupStack::Pop(itemsToPop); // cert
+    CleanupStack::PopAndDestroy(2); // fs, dir
+    CleanupStack::Pop(); // aCertChain
+    return KErrNone;
+    }
+
+TInt RRoapStorageClient::SignL(
+    const TDesC8& aHash,
+    HBufC8*& aSignature)
+    {
+    CRSAPrivateKey* privateKey = NULL;
+    
+    GetDevicePrivateKeyL(privateKey);
+    CleanupStack::PushL(privateKey);
+    aSignature = OmaCrypto::RsaPssSignHashL(privateKey, aHash);
+    CleanupStack::PopAndDestroy(); // privateKey
+    return KErrNone;
+    }
+
+TBool RRoapStorageClient::VerifyL(
+    const TDesC8& aSignature,
+    const TDesC8& aHash)
+    {
+    CRSAPublicKey* publicKey = NULL;
+    TBool r = ETrue;
+    
+    GetDevicePublicKeyL(publicKey);
+    CleanupStack::PushL(publicKey);
+    r = OmaCrypto::RsaPssVerifyHashL(publicKey, aSignature, aHash);
+    CleanupStack::PopAndDestroy(); // privateKey
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// RoapStorageClient::GetRIContextL
+// -----------------------------------------------------------------------------
+//    
+CDRMRIContext* RRoapStorageClient::GetRIContextL( const TDesC8& aRiID )
+    {    
+    return NULL;
+    }
+ 
+    
+// -----------------------------------------------------------------------------
+// RoapStorageClient::GetDomainContextL
+// -----------------------------------------------------------------------------
+//    
+CDRMDomainContext* RRoapStorageClient::GetDomainContextL( const TDesC8& aDomainID )
+    {    
+    return NULL;
+    }
+    
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::AddRIContextL
+// Add a new RI Context to the ROAP storage
+// -----------------------------------------------------------------------------
+//
+void RRoapStorageClient::AddRIContextL( const CDRMRIContext& aRiContext )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::AddDomainContextL
+// Add a new RI Context to the ROAP storage
+// -----------------------------------------------------------------------------
+//
+void RRoapStorageClient::AddDomainContextL( const CDRMDomainContext& aDomainContext,
+                                            TKeyTransportScheme& aTransportScheme )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::DeleteRiContextL
+// -----------------------------------------------------------------------------
+//    
+void RRoapStorageClient::DeleteRiContextL( const TDesC8& aRiID )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::DeleteDomainContextL
+// -----------------------------------------------------------------------------
+//    
+void RRoapStorageClient::DeleteDomainContextL( const TDesC8& aDomainID )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::DeleteExpiredRIsL
+// -----------------------------------------------------------------------------
+//    
+void RRoapStorageClient::DeleteExpiredRIsL( const TTime& aTime )
+    {
+    }
+    
+    
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::DeleteExpiredDomainsL
+// -----------------------------------------------------------------------------
+//    
+void RRoapStorageClient::DeleteExpiredDomainsL( const TTime& aTime )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// RRoapStorageClient::WhiteListURLExistsL
+// -----------------------------------------------------------------------------
+//    
+TBool RRoapStorageClient::WhiteListURLExistsL( const TDesC8& aURL )
+    {
+    return EFalse;
+    }         
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/src/RoapStorageServer.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,431 @@
+/*
+* 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:  
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "RoapStorageServer.h"
+#include "DRMContextDB.h"
+#include "RoapLog.h"
+#include "drmroapclientserver.h"
+#include "drmcommonclientserver.h"
+#include "drmkeystorage.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+
+
+// LOCAL CONSTANTS AND MACROS
+const TUint8 KMaxStartTries = 5;
+const TInt KWaitingTime = 1000000; // 10 secs
+
+_LIT( KRoapStorageThread, "RoapStorageServer" );
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT( KRIContextFileName, "%c:\\private\\101F51F2\\ricontexts.dat" );
+_LIT( KDomainContextFileName, "%c:\\private\\101F51F2\\domaincontexts.dat" );
+// File names and paths for importing keys
+_LIT( KImportDir, "%c:\\private\\101F51F2\\import\\" );
+_LIT( KInputFilePattern, "%c:\\private\\101F51F2\\import\\SigningCert*" );
+_LIT( KDeviceKeyFileName, "%c:\\private\\101F51F2\\import\\DevicePrivateKey.der" );
+_LIT( KDeviceCertFileName, "%c:\\private\\101F51F2\\import\\DeviceCert.der" );
+#else
+// File names and paths for importing keys
+_LIT( KImportDir, "c:\\private\\101F51F2\\import\\" );
+_LIT( KInputFilePattern, "c:\\private\\101F51F2\\import\\SigningCert*" );
+_LIT( KDeviceKeyFileName, "c:\\private\\101F51F2\\import\\DevicePrivateKey.der" );
+_LIT( KDeviceCertFileName, "c:\\private\\101F51F2\\import\\DeviceCert.der" );
+#endif
+
+// MODULE DATA STRUCTURES
+using Roap::KServerMajorVersion;
+using Roap::KServerMinorVersion;
+using Roap::KServerBuildVersion;
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TInt StartRoapServer( RSemaphore& aClientSem );
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// Function StartRoapServer().
+// This function starts the actual server under TRAP harness and starts
+// waiting for connections. This function returns only if there has been
+// errors during server startup or the server is stopped for some reason.
+// 
+// Returns: TInt: Symbian OS error code.
+// -----------------------------------------------------------------------------
+LOCAL_C TInt StartRoapServer( RSemaphore& aClientSem ) 
+
+    {
+    TInt error = KErrNone;
+    CRoapStorageServer* server = NULL;
+    TUint8 count = 0;
+
+    do 
+        {
+        ++count;
+        TRAP( error, ( server = CRoapStorageServer::NewL() ) );
+        if ( error ) 
+           {
+           User::After( TTimeIntervalMicroSeconds32(KWaitingTime) );
+           }
+       
+        } while( error && ( count <= KMaxStartTries ) );
+    
+    if( error ) 
+        {
+        return error;
+        }
+        
+    // Release the semaphore...
+    aClientSem.Signal();
+    aClientSem.Close();
+    
+    // Start waiting for connections
+    CActiveScheduler::Start();
+    
+    // Delete CRoapStorageServer
+    delete server;
+    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// Function ReadFileL().
+// Read a file into a buffer
+// -----------------------------------------------------------------------------
+LOCAL_C void ReadFileL( RFs& aFs, HBufC8*& aContent, const TDesC& aName )
+	{	
+	TInt size = 0;
+	RFile file;
+	
+	User::LeaveIfError( file.Open( aFs, aName, EFileRead ) );
+	CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    aContent = HBufC8::NewLC( size );
+    TPtr8 ptr( aContent->Des() );
+    User::LeaveIfError( file.Read( ptr, size) );
+    CleanupStack::Pop(); // aContent
+	CleanupStack::PopAndDestroy(); // file
+	}
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRoapStorageServer::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRoapStorageServer* CRoapStorageServer::NewL()
+    {
+    CRoapStorageServer* self = new( ELeave ) CRoapStorageServer();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self ); 
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CRoapStorageServer::~CRoapStorageServer() 
+    {
+    iRFs.Close();
+    delete iRoapStorage;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapStorageServer::RunErrorL
+// From CActive. Complete the request and restart the scheduler.
+// -----------------------------------------------------------------------------
+//
+TInt CRoapStorageServer::RunError( TInt aError ) 
+    {
+    // Inform the client.
+    Message().Complete( aError );
+    // Restart the scheduler.
+    ReStart();
+    // Error handled.
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapStorageServer::NewSessionL
+// Called when a client requires a new instance.
+// -----------------------------------------------------------------------------
+CSession2* CRoapStorageServer::NewSessionL(
+    const TVersion& aVersion,
+    const RMessage2& /*aMessage*/) const
+    {
+    RThread client;
+    // Check that the versions are compatible.
+    if ( ! User::QueryVersionSupported( TVersion( KServerMajorVersion,
+                                                  KServerMinorVersion,
+                                                  KServerBuildVersion ), 
+                                        aVersion ) ) 
+        {
+        // Sorry, no can do.
+        User::Leave( KErrNotSupported );
+        }
+    return CRoapStorageSession::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapStorageServer::CRoapStorageServer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRoapStorageServer::CRoapStorageServer() : 
+    CServer2( EPriorityStandard ),
+    iRoapStorage( NULL )
+    {
+    // Nothing
+    }
+    
+// -----------------------------------------------------------------------------
+// CRoapStorageServer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRoapStorageServer::ConstructL() 
+    {
+    TInt err = KErrNone;
+    
+    User::RenameThread( KRoapStorageThread );
+    StartL( Roap::KServerName );
+    User::LeaveIfError(iRFs.Connect());
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    iRoapStorage = CDRMContextDB::NewL( KRIContextFile(), 
+                                        KDomainContextFile(),
+                                        iRFs );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	iRFs.DriveToChar( driveNumber, driveLetter );
+	
+	TFileName riContextFile;
+	riContextFile.Format( KRIContextFileName, (TUint)driveLetter );
+    
+    TFileName domainContextFile;
+	domainContextFile.Format( KDomainContextFileName, (TUint)driveLetter );
+    
+    iRoapStorage = CDRMContextDB::NewL( riContextFile, 
+                                        domainContextFile,
+                                        iRFs );
+    
+#endif
+    
+    TRAP( err, ImportKeysL() );
+    }
+    
+// -----------------------------------------------------------------------------
+// CRoapStorageServer::ContextDB
+// Return the internal ROAP storage object
+// -----------------------------------------------------------------------------
+//       
+CDRMContextDB* CRoapStorageServer::ContextDB()
+    {
+    return iRoapStorage;
+    }
+
+// -----------------------------------------------------------------------------
+// CRoapStorageServer::ImportKeys
+// Import keys which are stored in the import directory into the private
+// directory. Only one key pair plus assocated certificates can be imported
+// at a time. The file names are DevicePrivateKey.der, DeviceCert.der and
+// SigningCertXX.der.
+// -----------------------------------------------------------------------------
+//       
+void CRoapStorageServer::ImportKeysL()
+    {
+    MDrmKeyStorage* storage = NULL; 
+    HBufC8* privateKey = NULL;
+    HBufC8* cert = NULL;
+    RArray<TPtrC8> certChain;
+    RPointerArray<HBufC8> buffers;
+    TFileName fileName;
+    RFile file;
+    TInt i;
+    CDir* dir = NULL;
+    TInt err = KErrNone;
+    
+    __UHEAP_MARK;
+    LOG( _L( "CRoapStorageServer::ImportKeysL" ) );
+    CleanupClosePushL( buffers );
+    CleanupClosePushL( certChain );
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    ReadFileL( iRFs, privateKey, KDeviceKeyFileName );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TFileName tempPath;
+    TFileName tempPath2;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	iRFs.DriveToChar( driveNumber, driveLetter );
+	
+	tempPath.Format( KDeviceKeyFileName, (TUint)driveLetter );
+    
+    ReadFileL( iRFs, privateKey, tempPath );
+    
+#endif
+    
+    CleanupStack::PushL( privateKey );
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    ReadFileL( iRFs, cert, KDeviceCertFileName );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+	tempPath2.Format( KDeviceCertFileName, (TUint)driveLetter );
+    
+    ReadFileL( iRFs, cert, tempPath2 );
+    
+#endif
+    
+    CleanupStack::PushL( cert );
+    buffers.AppendL( cert );
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    iRFs.Delete( KDeviceKeyFileName );
+    iRFs.Delete( KDeviceCertFileName );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+	iRFs.Delete( tempPath );
+    iRFs.Delete( tempPath2 );
+    
+#endif
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    User::LeaveIfError( iRFs.GetDir( KInputFilePattern, KEntryAttNormal,
+        ESortByName, dir ) );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+	tempPath.Format( KInputFilePattern, (TUint)driveLetter );
+    
+    User::LeaveIfError( iRFs.GetDir( tempPath, KEntryAttNormal,
+        ESortByName, dir ) );
+    
+#endif
+    
+    CleanupStack::PushL( dir );
+    
+    for ( i = 0; i < dir->Count(); i++ )
+        {
+        
+#ifndef RD_MULTIPLE_DRIVE
+    
+        fileName.Copy( KImportDir );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+	    tempPath.Format( KImportDir, (TUint)driveLetter );
+        
+        fileName.Copy( tempPath );
+    
+#endif
+        
+        fileName.Append( (*dir)[i].iName );
+        ReadFileL( iRFs, cert, fileName );
+        CleanupStack::PushL( cert );
+        buffers.AppendL( cert );
+        
+        iRFs.Delete( fileName );
+        }
+    for ( i = 0; i < buffers.Count(); i++ )
+        {
+        certChain.AppendL( *( buffers[i] ) );
+        }
+    storage = DrmKeyStorageNewL();
+    TRAP( err, storage->ImportDataL( *privateKey, certChain ) );
+    delete storage;
+    CleanupStack::PopAndDestroy( i + 1 ); // certs & dir
+    CleanupStack::PopAndDestroy( 3 ); // privateKey, certChain, buffers
+    LOG( _L( "CRoapStorageServer::ImportKeysL done" ) );
+    __UHEAP_MARKEND;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+// -----------------------------------------------------------------------------
+// Function StartupRoapStorage().
+// This function starts the actual Roap Storage
+// the cleanup stack and active scheduler.
+// Returns: TInt: Symbian OS error code.
+// -----------------------------------------------------------------------------
+//
+
+TInt StartupRoapStorage( TAny* ) 
+    {    
+    TInt error = KErrNone;
+    CTrapCleanup* trap = CTrapCleanup::New();
+    __ASSERT_ALWAYS( trap, User::Invariant() );
+    
+    CActiveScheduler* scheduler = new CActiveScheduler();
+    __ASSERT_ALWAYS( scheduler, User::Invariant() );
+    
+    CActiveScheduler::Install( scheduler );
+    RSemaphore clientSem;
+    __ASSERT_ALWAYS( clientSem.OpenGlobal( KDRMEngCommonSemaphore ) == 0, User::Invariant() );
+    
+    error = StartRoapServer( clientSem );
+    
+    if ( error ) {
+        // Server creation failed. Release the semaphore.
+        // In case of successful startup, CRoapStorageServer
+        // releases the semaphore.
+        clientSem.Signal();
+        clientSem.Close();
+        }
+    
+    delete scheduler; 
+    scheduler = NULL;
+    
+    delete trap;
+    trap = NULL;
+    
+    // __ASSERT_ALWAYS( !error, User::Invariant() );
+    
+    return KErrNone;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/src/RoapStorageSession.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,2506 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Session class for handling roap storage client requests
+*
+*/
+
+
+// INCLUDE FILES
+#include <s32file.h>
+#include <f32file.h>
+#include <x509cert.h>
+#include <x509keys.h>
+#include <asn1dec.h>
+#include <hash.h>
+#include <s32mem.h>
+#include <centralrepository.h>
+#include <uri8.h>
+#ifdef RD_DRM_METERING
+#include <DRMRightsClient.h>
+#include <random.h>
+#endif //RD_DRM_METERING
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+#include <e32base.h>  // CleanupResetAndDestroyPushL dependencies
+#include "drmaescrypto.h"
+#include "RoapStorageSession.h"
+#include "DRMContextDB.h"
+#include "DRMRIContext.h"
+#include "DRMDomainContext.h"
+#include "RoapStorageServer.h"
+#include "CmlaCrypto.h"
+#include "DrmAesCrypto.h"
+#include "DrmKeyStorage.h"
+#include "RoapDef.h"
+#include "RoapLog.h"
+#include "drmroapclientserver.h"
+#include "drmclockclient.h"
+#include "DrmTypes.h"
+#include "drmpointerarray.h"
+//OCSP classes
+#include "roapocsp.h"
+#include "responsedecoder.h"
+#include "certid.h"
+//drm clock
+#include "drmclockclient.h"
+
+#include "base64.h"
+
+#include "cleanupresetanddestroy.h" // CleanupResetAndDestroyPushL
+// NAMESPACES
+using namespace Roap;
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+const TInt KMaxElementLength = 327680;
+const TInt KMinDomainIdLength = 4;
+// DEBUG PRINT MACROS
+#ifdef _DEBUG
+#include <flogger.h>
+_LIT(KMacLogDir, "DRM");
+_LIT(KMacLogFile, "MAC.log");
+#define MACLOG( a ) RFileLogger::Write( KMacLogDir(), KMacLogFile(), EFileLoggingModeAppend, a );
+#define MACLOGHEX( ptr, len ) RFileLogger::HexDump( KMacLogDir(), KMacLogFile(), EFileLoggingModeAppend, _S(""), _S(""), ptr, len );
+#define MACLOGLIT( a ) MACLOG( _L ( a ) )
+#define _DRM_DETAILED_DEBUG // uncomment if want detailed debugs to log file
+#else
+#undef _DRM_DETAILED_DEBUG
+#define MACLOG( a )
+#define MACLOGHEX( ptr, len )
+#define MACLOGLIT( a )
+#endif
+#ifdef _DRM_DETAILED_DEBUG
+#define MACLOGDETAIL( a ) MACLOG( a )
+#define MACLOGHEXDETAIL( ptr, len ) MACLOGHEX( ptr, len )
+#define MACLOGLITDETAIL( a ) MACLOGLIT( a )
+#define MACLOGLDETAIL( a ) MACLOGLIT( a )
+#define CERTDETAIL( c ) \
+{ \
+const TPtrC8* n( c->DataElementEncoding( CX509Certificate::ESerialNumber ) ); \
+const TPtrC8* a( c->DataElementEncoding( CX509Certificate::EAlgorithmId ) ); \
+const TPtrC8* s( c->DataElementEncoding( CX509Certificate::ESubjectName ) ); \
+const TPtrC8* i( c->DataElementEncoding( CX509Certificate::EIssuerName ) ); \
+const TPtrC8* p( c->DataElementEncoding( CX509Certificate::ESubjectPublicKeyInfo ) ); \
+MACLOGLDETAIL( "certificate (subject issuer serial algorithm key)" ) \
+MACLOGHEXDETAIL( s->Ptr(), s->Length() ) \
+MACLOGHEXDETAIL( i->Ptr(), i->Length() ) \
+MACLOGHEXDETAIL( n->Ptr(), n->Length() ) \
+MACLOGHEXDETAIL( a->Ptr(), a->Length() ) \
+MACLOGHEXDETAIL( p->Ptr(), p->Length() ) \
+}
+#else
+#define MACLOGDETAIL( a )
+#define MACLOGHEXDETAIL( ptr, len )
+#define MACLOGLITDETAIL( a )
+#define MACLOGLDETAIL( a )
+#define CERTDETAIL( a )
+#endif
+// END OF DEBUG PRINT MACROS
+// LOCAL CONSTANTS AND MACROS
+_LIT8( KRoapDomainKey, "roap:domainKey");
+_LIT8( KRoapX509SPKIHash, "roap:X509SPKIHash");
+_LIT8( KRoapXmlNs, " xmlns:roap=\"urn:oma:bac:dldrm:roap-1.0\"");
+#ifdef RD_DRM_METERING
+_LIT8( KCmlaIp1, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-1");
+#endif
+
+static const TUid KCRUidRoapHandler =
+    {
+    0x10205CBF
+    };
+static const TInt KRoapHandlerRegistrationWhitelist = 1;
+static const TInt KMaxWhiteListLen = 1024;
+
+static const TInt KTzZulu( 0 ); //UTC time zone
+#ifdef RD_MULTIPLE_DRIVE
+_LIT( KRIContextFileName, "_:\\private\\101F51F2\\ricontexts.dat" );
+_LIT( KDomainContextFileName, "_:\\private\\101F51F2\\domaincontexts.dat" );
+#endif
+
+#define ROAPDB ( ( CRoapStorageServer* )( Server() ) )->ContextDB()
+
+static const TInt KP3( 3 );
+#define IPCREAD0L( a ) aMessage.ReadL( 0, a )
+#define IPCREAD1L( a ) aMessage.ReadL( 1, a )
+#define IPCREAD2L( a ) aMessage.ReadL( 2, a )
+#define IPCREAD3L( a ) aMessage.ReadL( KP3, a )
+#define IPCWRITE0L( a ) aMessage.WriteL( 0, a )
+#define IPCWRITE1L( a ) aMessage.WriteL( 1, a )
+#define IPCWRITE2L( a ) aMessage.WriteL( 2, a )
+#define IPCWRITE3L( a ) aMessage.WriteL( KP3, a )
+#define IPCGETDESLEN0 aMessage.GetDesLength( 0 )
+#define IPCGETDESLEN1 aMessage.GetDesLength( 1 )
+#define IPCGETDESLEN2 aMessage.GetDesLength( 2 )
+#define IPCGETDESLEN3 aMessage.GetDesLength( KP3 )
+#define IPCGETDESMAXLEN0 aMessage.GetDesMaxLength( 0 )
+#define IPCGETDESMAXLEN1 aMessage.GetDesMaxLength( 1 )
+#define IPCGETDESMAXLEN2 aMessage.GetDesMaxLength( 2 )
+#define IPCGETDESMAXLEN3 aMessage.GetDesMaxLength( KP3 )
+
+const TInt KSanityDataLengthLow = 0;
+const TInt KSanityDataLengthHigh = 32768;
+// DATA TYPES
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C RPointerArray<HBufC8> BufferToArrayL( TDesC8& aBuffer );
+LOCAL_C HBufC8* ArrayToBufferLC( const RPointerArray<HBufC8>& aArray );
+
+LOCAL_C void UnwrapDomainKeyL( MDrmKeyStorage* aKeyStorage,
+    const TDesC8& aProtectedDomainKey, HBufC8*& aDomainKey, HBufC8*& aMacKey,
+    TKeyTransportScheme& aTransportScheme );
+LOCAL_C TBool VerifyMacL( TDesC8& aDomainElements, TDesC8& aMacs,
+    RPointerArray<HBufC8>& aMacKeys );
+
+// ---------------------------------------------------------------------------
+// DeleteAndSetNull
+// ---------------------------------------------------------------------------
+//
+template<typename Taa> Taa*& DeleteAndSetNull( Taa*& aArg )
+    {
+    if ( aArg )
+        {
+        delete aArg;
+        aArg = NULL;
+        }
+    return aArg;
+    }
+
+// ---------------------------------------------------------------------------
+// SanitizeL
+// Performs a sanity check on length parameters
+// ---------------------------------------------------------------------------
+//
+LOCAL_C void SanitizeL( TInt aParam )
+    {
+    User::LeaveIfError( aParam );
+    if ( aParam <= KSanityDataLengthLow || aParam > KSanityDataLengthHigh )
+        {
+        User::Leave( KErrArgument );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Swap elements
+// ---------------------------------------------------------------------------
+//
+template<typename T>
+LOCAL_C void SwapElement( RPointerArray<T>& aArray, TInt aFirst, TInt aSecond )
+    {
+    if ( aFirst != aSecond )
+        {
+        T* temp( NULL);
+        temp = aArray[aFirst];
+        aArray[aFirst] = aArray[aSecond];
+        aArray[aSecond] = temp;
+        }
+    }
+// ---------------------------------------------------------------------------
+// Sort Ocsp responses for certChain validation
+// ---------------------------------------------------------------------------
+//
+LOCAL_C TBool SortOcspCertsL( RPointerArray<CX509Certificate>& aOcspCerts,
+    const CX509Certificate* aRootCert )
+    {
+    MACLOGLITDETAIL( "::SortOcspCertsL -->" )
+    const TInt last( aOcspCerts.Count() - 1 );
+    TBool sortable( EFalse );
+
+    // Find first find cert issued by root cert
+    // There can be only one cert issued by Root on valid cert chain
+    for ( TInt i( 0 ); !sortable && i <= last; i++ )
+        {
+        if ( aRootCert->SubjectName().ExactMatchL(
+            aOcspCerts[i]->IssuerName() ) )
+            {
+            SwapElement<CX509Certificate> ( aOcspCerts, i, last );
+            sortable = ETrue;
+            }
+        }
+
+    for ( TInt s(last); sortable && s > 0; s-- )
+        {
+        sortable = EFalse;
+        for ( TInt i( s - 1 ); !sortable && i >= 0; i-- )
+            {
+            // compare cert s subject to issuer i
+            if ( aOcspCerts[s]->SubjectName().ExactMatchL(
+                aOcspCerts[i]->IssuerName() ) )
+                {
+                SwapElement<CX509Certificate> ( aOcspCerts, i, s-1 );
+                sortable = ETrue;
+                }
+            }
+        }
+    MACLOGLITDETAIL( "--> ::SortOcspCertsL" )
+    return sortable;
+    }
+
+// ---------------------------------------------------------------------------
+// VerifyOcspCertChainL()
+// ---------------------------------------------------------------------------
+//
+LOCAL_C TBool VerifyOcspCertChainL( const COCSPResponse& aResponse,
+    const CX509Certificate* aRootCert, CX509Certificate*& aOcspCert )
+    {
+    MACLOGLITDETAIL( "::VerifyOcspCertChainL -->" )
+
+
+
+    CX509Certificate* cert = NULL;
+    const CX509Certificate* signingCert = NULL;
+    TInt pos = 0;
+    TBool result = ETrue;
+
+    RPointerArray<CX509Certificate> certArray;
+    CleanupResetAndDestroyPushL( certArray );
+
+    const TPtrC8* ocspCerts( aResponse.SigningCerts() );
+
+    if ( !ocspCerts )
+        {
+        MACLOGLIT( "No OCSP certs present" )
+#ifdef _DISABLE_OCSP_CHECK
+        CleanupStack::PopAndDestroy( &certArray );
+        return ETrue;
+#endif
+        User::Leave( KErrRoapServerFatal );
+        }
+
+    MACLOGLITDETAIL( "getting certs in OCSP response" )
+    while ( pos < ocspCerts->Length() )
+        {
+        cert = CX509Certificate::NewLC( *ocspCerts, pos );
+        certArray.AppendL( cert );
+        CleanupStack::Pop( cert );
+        CERTDETAIL( cert )
+        }
+
+    result = SortOcspCertsL( certArray, aRootCert );
+
+    // validate the OCSP cert chain up till root cert (root cert is already validated)
+    for ( TInt i = 0; i < certArray.Count() && result; i++ )
+        {
+        cert = certArray[i];
+        if ( certArray.Count() - 1 == i )
+            {
+            signingCert = aRootCert;
+            }
+        else
+            {
+            signingCert = certArray[i + 1];
+            }
+        MACLOGLDETAIL( "OCSP verify, using certificate" )
+        CERTDETAIL( cert )
+        result = cert->VerifySignatureL( signingCert->PublicKey().KeyData() );
+#ifdef _DEBUG
+        if ( result )
+            {
+            MACLOGLIT( "Verify succeeded." )
+            }
+        else
+            {
+            MACLOGLIT( "Verify failed." )
+            }
+#endif
+        }
+
+    // Copy OCSP cert and return it
+    aOcspCert = CX509Certificate::NewL( *certArray[0] );
+
+    CleanupStack::PopAndDestroy( &certArray );
+    MACLOGLITDETAIL( "--> ::VerifyOcspCertChainL" )
+    return result;
+    }
+
+
+#ifdef _DISABLE_DRM_TIME_UPDATE_CHECK
+LOCAL_C TBool IsCmlaRootL(
+    const RPointerArray<HBufC8>& /*aTrustedRoots*/,
+    const CX509Certificate* /* aRootCert */)
+    {
+    MACLOGLITDETAIL( "IsCmlaRootL -->\n--> IsCmlaRootL" )
+    return ETrue;
+    }
+#else
+LOCAL_C TBool IsCmlaRootL( const RPointerArray<HBufC8>& aTrustedRoots,
+    const CX509Certificate* aRootCert )
+    {
+    MACLOGLITDETAIL( "IsCmlaRootL -->" )
+    TBool isCmlaRoot( EFalse );
+    // Check are we running on a CMLA device
+    for ( TInt i = 0; i < aTrustedRoots.Count() && !isCmlaRoot; i++ )
+        {
+        HBufC8* encodedRoot( Base64EncodeL( *aTrustedRoots[i] ) );
+        CleanupStack::PushL( encodedRoot );
+        if ( encodedRoot->CompareF( KRoapCmlaRootHash() ) == 0
+            || encodedRoot->CompareF( KRoapCmlaRnDRootHash() ) == 0
+            || encodedRoot->CompareF( KRoapCmlaRnDRootHashOld() ) == 0 )
+            {
+            isCmlaRoot = ETrue;
+            }
+        CleanupStack::PopAndDestroy( encodedRoot );
+        encodedRoot = NULL;
+        }
+    if ( isCmlaRoot )
+        {
+        __UHEAP_MARK;
+        // The root cert found, check that it's the CMLA (production or R&D) root
+        CSHA1* hash( CSHA1::NewL() );
+        CleanupStack::PushL( hash );
+        hash->Hash( *aRootCert->DataElementEncoding(
+            CX509Certificate::ESubjectPublicKeyInfo ) );
+        MACLOGLDETAIL( "Inputs for SHA1" )
+        MACLOGHEXDETAIL(
+            aRootCert->DataElementEncoding(
+                CX509Certificate::ESubjectPublicKeyInfo )->Ptr(),
+            aRootCert->DataElementEncoding(
+                CX509Certificate::ESubjectPublicKeyInfo )->Length() )
+
+        HBufC8* encodedRoot( Base64EncodeL( hash->Final() ) );
+        CleanupStack::PushL( encodedRoot );
+
+        MACLOGLDETAIL( "Encoded root (base64 encoded SHA1 of public key)" )
+        MACLOGDETAIL( *encodedRoot )
+        MACLOGLDETAIL( "CMLA root" )
+        MACLOGDETAIL( KRoapCmlaRootHash() )
+        MACLOGLDETAIL( "CMLA RD root" )
+        MACLOGDETAIL( KRoapCmlaRnDRootHash() )
+        MACLOGLDETAIL( "old CMLA RD root" )
+        MACLOGDETAIL( KRoapCmlaRnDRootHashOld() )
+
+        if ( encodedRoot->CompareF( KRoapCmlaRootHash() ) != 0
+            && encodedRoot->CompareF( KRoapCmlaRnDRootHash() ) != 0
+            && encodedRoot->CompareF( KRoapCmlaRnDRootHashOld() ) != 0 )
+            {
+            // The RI CA cert is not signed by CMLA root
+            MACLOGLIT( "The RI CA cert is not signed by CMLA (production or R&D) root" )
+            isCmlaRoot = EFalse;
+            }
+        else
+            {
+            // We are running on a CMLA device and
+            // RI certificate is signed by the CMLA (production or R&D) root
+            // -> Verify still that the OCSP chain is signed by CMLA
+            MACLOGLIT( "RI certificate is signed by the CMLA root" )
+            }
+        CleanupStack::PopAndDestroy( encodedRoot );
+        CleanupStack::PopAndDestroy( hash );
+        __UHEAP_MARKEND;
+        }
+    MACLOGLITDETAIL( "--> IsCmlaRootL" )
+    return isCmlaRoot;
+    }
+#endif
+
+
+// ---------------------------------------------------------------------------
+// ValidateNonceL
+// ---------------------------------------------------------------------------
+//
+LOCAL_C TBool ValidateNonceL( const COCSPResponse& aResponse,
+    const TDesC8& aRegReqNonce )
+    {
+    // check that nonce in OCSP response equals to the nonce sent in Reg Request
+    TBool ret( EFalse );
+    const TPtrC8 * nonce( aResponse.DataElementEncoding(
+        COCSPResponse::ENonce ) );
+
+    if ( !nonce )
+        {
+        // no nonce found -> don't update DRM Time
+        MACLOGLIT( "No nonce in the OCSP response!" )
+        ret = EFalse;
+        }
+    else if ( nonce->CompareF( aRegReqNonce ) != 0 )
+        {
+        // Maybe the nonce is in ASN.1 format?
+        // -> Remove the first two bytes (type and size), and try again
+        TASN1DecGeneric asn1Dec( *nonce );
+        asn1Dec.InitL();
+        TPtrC8 ptr( asn1Dec.GetContentDER() );
+        if ( ptr.CompareF( aRegReqNonce ) != 0 )
+            {
+            MACLOGLIT( "Fatal server error: OCSP nonce != RegRequest nonce!" )
+            User::Leave( KErrRoapServerFatal );
+            }
+        else
+            {
+            MACLOGLIT( "OCSP nonce == RegRequest nonce." )
+            ret = ETrue;
+            }
+        MACLOGLDETAIL( "values ( OCSP nonce, request nonce  )" )
+        MACLOGHEXDETAIL( nonce->Ptr(), nonce->Length() )
+        MACLOGHEXDETAIL( aRegReqNonce.Ptr(), aRegReqNonce.Length() )
+        }
+    else
+        {
+        ret = ETrue;
+        MACLOGLDETAIL( "values ( OCSP nonce, request nonce  )" )
+        MACLOGHEXDETAIL( nonce->Ptr(), nonce->Length() )
+        MACLOGHEXDETAIL( aRegReqNonce.Ptr(), aRegReqNonce.Length() )
+        }
+    return ret;
+    }
+// ---------------------------------------------------------------------------
+// IsTimeUpdateAllowedL()
+// ---------------------------------------------------------------------------
+//
+LOCAL_C TBool IsTimeUpdateAllowedL(
+    const RPointerArray<HBufC8>& aTrustedRoots,
+    const RPointerArray<HBufC8>& aRootCertificates,
+    const RPointerArray<HBufC8>& aCertChain,
+    const COCSPResponse& aOcspResponse,
+    const TDesC8& aRegReqNonce )
+    {
+    MACLOGLITDETAIL( "::IsTimeUpdateAllowedL -->" )
+
+
+    // check that nonce in OCSP response equals to the nonce sent in Reg Request
+    TBool bIsAllowed( ValidateNonceL( aOcspResponse, aRegReqNonce ) );
+
+    if ( !bIsAllowed )
+        {
+        MACLOGLIT( "No nonce. Not possible to update DRM time" )
+        return bIsAllowed;
+        }
+
+
+    if ( !aCertChain.Count() )
+        {
+        MACLOGLIT( "Wrong input data - No certificates or OCSP responses" )
+        bIsAllowed = EFalse;
+        return bIsAllowed;
+        }
+
+    CX509Certificate* riCa = NULL;
+    CX509Certificate* rootCert = NULL;
+    // Get the last cert from the chain.
+    // It should be signed by some of our trusted anchor
+    riCa = CX509Certificate::NewLC( *( aCertChain[aCertChain.Count() - 1] ) );
+    MACLOGLITDETAIL( "Selected as RI CA" ) // (last of given cert chain)
+    CERTDETAIL( riCa )
+
+    // iterate over root certificates and check, whether given
+    // RI CA issuer matches name of the selected root
+    for ( TInt i = 0; i < aRootCertificates.Count() && !rootCert; i++ )
+        {
+        rootCert = CX509Certificate::NewL( *aRootCertificates[i] );
+        if ( !rootCert->SubjectName().ExactMatchL( riCa->IssuerName() ) )
+            {
+            delete rootCert;
+            rootCert = NULL;
+            }
+        }
+
+    if ( rootCert )
+        {
+        MACLOGLDETAIL( "Selected root CERT" )
+        CERTDETAIL( rootCert )
+        CleanupStack::PushL( rootCert );
+
+        if ( IsCmlaRootL( aTrustedRoots, rootCert ) )
+            {
+            CX509Certificate* ocspCert = NULL;
+            __UHEAP_MARK;
+            // Try to verify OCSP cert chain with the root cert
+            if ( VerifyOcspCertChainL( aOcspResponse, rootCert,
+                DeleteAndSetNull<CX509Certificate> ( ocspCert ) ) )
+                {
+                MACLOGLITDETAIL( "OCSP cert chain verified with root cert" )
+                MACLOGLIT( "DRM Time update allowed!" )
+                bIsAllowed = ETrue;
+                }
+            // Try to verify OCSP cert chain with the RI CA cert
+
+            else if ( VerifyOcspCertChainL( aOcspResponse, riCa,
+                DeleteAndSetNull<CX509Certificate> ( ocspCert ) ) )
+                {
+                MACLOGLITDETAIL( "OCSP cert chain verified with RI CA cert" )
+                // Check signing of RiCa
+                bIsAllowed = riCa->VerifySignatureL(
+                    rootCert->PublicKey().KeyData() );
+                if ( !bIsAllowed )
+                    {
+                    MACLOGLITDETAIL( "RI CA cert verify failed" )
+                    MACLOGLIT( "DRM time update not allowed!" )
+                    }
+                else
+                    {
+                    MACLOGLITDETAIL( "RI CA verified with root cert" )
+                    MACLOGLIT( "DRM time update allowed" )
+                    }
+                }
+            else
+                {
+                MACLOGLITDETAIL( "OCSP cert chain verify failed" )
+                MACLOGLIT( "DRM Time update is not allowed!" )
+                bIsAllowed = EFalse;
+                }
+
+            if ( ocspCert )
+                {
+                if ( !aOcspResponse.VerifySignatureL(
+                    ocspCert->PublicKey().KeyData() ) )
+                    {
+                    MACLOGLIT( "OCSP response signature verification failed" )
+                    bIsAllowed = EFalse;
+                    }
+                if ( bIsAllowed )
+                    {
+                    const TTime timeCandidate( aOcspResponse.ProducedAt() );
+                    if ( !ocspCert->ValidityPeriod().Valid( timeCandidate ) )
+                        {
+                        MACLOGLIT( "OCSP responder cert expired in respect to proposed new time" )
+                        bIsAllowed = EFalse;
+                        }
+                    }
+                }
+            DeleteAndSetNull<CX509Certificate> ( ocspCert );
+            __UHEAP_MARKEND;
+            }
+        CleanupStack::PopAndDestroy( rootCert );
+        rootCert = NULL;
+        }
+    CleanupStack::PopAndDestroy( riCa );
+    riCa = NULL;
+    MACLOGLITDETAIL( "--> ::IsTimeUpdateAllowedL" )
+    return bIsAllowed;
+    }
+
+//LOCAL CLASS DECLARATION
+// Used for lazy connecting to clock server (only connected if needed)
+class LazyClockClient
+    {
+public:
+    inline LazyClockClient();
+    inline virtual ~LazyClockClient();
+    inline void GetSecureTimeL( TTime& aTime, TInt& aZone,
+        DRMClock::ESecurityLevel& aLevel );
+    inline void UpdateSecureTimeL( const TTime& aTime, const TInt aZone );
+    inline void Close();
+private:
+    inline void ConnectL();
+    TBool iConnected;
+    RDRMClockClient iClock;
+    };
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// ---------------------------------------------------------------------------
+inline LazyClockClient::LazyClockClient() :
+    iConnected( EFalse )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+inline LazyClockClient::~LazyClockClient()
+    {
+    Close();
+    }
+
+// ---------------------------------------------------------------------------
+inline void LazyClockClient::Close()
+    {
+    iClock.Close();
+    iConnected = EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+inline void LazyClockClient::ConnectL()
+    {
+    if ( !iConnected )
+        {
+        User::LeaveIfError( iClock.Connect() );
+        iConnected = ETrue;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+inline void LazyClockClient::GetSecureTimeL( TTime& aTime, TInt& aZone,
+    DRMClock::ESecurityLevel& aLevel )
+    {
+    ConnectL();
+    User::LeaveIfError( iClock.GetSecureTime( aTime, aZone, aLevel ) );
+    }
+
+// ---------------------------------------------------------------------------
+inline void LazyClockClient::UpdateSecureTimeL( const TTime& aTime,
+    const TInt aZone )
+    {
+    ConnectL();
+    User::LeaveIfError( iClock.UpdateSecureTime( aTime, aZone ) );
+    }
+
+
+// CRoapStorageSession methods
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::NewLC
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CRoapStorageSession* CRoapStorageSession::NewL()
+    {
+    CRoapStorageSession* self = new ( ELeave ) CRoapStorageSession();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::~CRoapStorageSession
+// Destructor.
+// ---------------------------------------------------------------------------
+//
+CRoapStorageSession::~CRoapStorageSession()
+    {
+    delete iPreparedData;
+    delete iKeyStorage;
+    delete iLazyClock;
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::ServiceL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::ServiceL( const RMessage2& aMessage )
+    {
+    DispatchL( aMessage );
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::DispatchL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::DispatchL( const RMessage2& aMessage )
+    {
+    switch ( aMessage.Function() )
+        {
+        case EAddRiContext:
+            {
+            AddRiContextL( aMessage );
+            break;
+            }
+        case EAddDomainContext:
+            {
+            AddDomainContextL( aMessage );
+            break;
+            }
+        case EGetRiContext:
+            {
+            GetRiContextL( aMessage );
+            break;
+            }
+        case EGetDomainContext:
+            {
+            GetDomainContextL( aMessage );
+            break;
+            }
+        case EGetData:
+            {
+            GetDataL( aMessage );
+            break;
+            }
+        case EDeleteRiContext:
+            {
+            DeleteRiContextL( aMessage );
+            break;
+            }
+        case EDeleteDomainContext:
+            {
+            DeleteDomainContextL( aMessage );
+            break;
+            }
+        case EDeleteExpiredRIs:
+            {
+            DeleteExpiredRIsL( aMessage );
+            break;
+            }
+        case EDeleteExpiredDomains:
+            {
+            DeleteExpiredDomainsL( aMessage );
+            break;
+            }
+        case EWhiteListCheck:
+            {
+            WhiteListUrlExistsL( aMessage );
+            break;
+            }
+        case EGetPublicKey:
+            {
+            GetDevicePublicKeyDerL( aMessage );
+            break;
+            }
+        case EGetCertificates:
+            {
+            GetDeviceCertificateChainL( aMessage );
+            break;
+            }
+        case ESignMessage:
+            {
+            SignL( aMessage );
+            break;
+            }
+        case ESelectRoot:
+            {
+            SelectTrustedRootL( aMessage );
+            break;
+            }
+        case EActivateRoot:
+            {
+            ActivateTrustedRootL( aMessage );
+            break;
+            }
+        case EGetTrustedRoots:
+            {
+            GetTrustedRootsL( aMessage );
+            break;
+            }
+        case EGetRootCert:
+            {
+            GetRootCertificateL( aMessage );
+            break;
+            }
+        case EDeleteExpired:
+            {
+            DeleteExpiredContextsL( aMessage );
+            break;
+            }
+        case EDeleteAll:
+            {
+            DeleteAllL( aMessage );
+            break;
+            }
+        case ERsaSign:
+            {
+            RsaSignL( aMessage );
+            break;
+            }
+#ifdef RD_DRM_METERING
+        case EGetMeteringData:
+            {
+            GetMeteringDataL( aMessage );
+            break;
+            }
+        case EDeleteMeteringData:
+            {
+            DeleteMeteringDataL( aMessage );
+            break;
+            }
+        case ERetrieveAllRIContexts:
+            {
+            GetAllRIContextsL( aMessage );
+            break;
+            }
+        case EUpdateRIContext:
+            {
+            UpdateRIContextL( aMessage );
+            break;
+            }
+#endif // RD_DRM_METERING
+        case EUpdateDrmTime:
+            {
+            UpdateDrmTimeL( aMessage );
+            break;
+            }
+        case EVerifyOcspResponses:
+            {
+            VerifyOcspResponsesL( aMessage );
+            break;
+            }
+        case EGetOcspResponderId:
+            {
+            GetOcspResponderIdL( aMessage );
+            break;
+            }
+        default:
+            MACLOGLIT( "CRoapStorageSession::ServiceL: Invalid command" )
+            PanicClient( aMessage, EPanicBadFunction );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::PanicClient
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::PanicClient(
+    const RMessage2& aMessage,
+    TPanic aReason )
+    {
+    _LIT( KPanicCategory, "RoapStorageSession" );
+    if ( !aMessage.IsNull() )
+        {
+        aMessage.Panic( KPanicCategory, aReason );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::ServiceError
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::ServiceError(
+    const RMessage2& aMessage,
+    TInt aError )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::ServiceError -->" )
+
+    if ( aError == KErrBadDescriptor )
+        {
+        PanicClient( aMessage, EPanicBadDescriptor );
+        }
+    else
+        {
+        CSession2::ServiceError( aMessage, aError );
+        }
+    MACLOGLITDETAIL( "--> CRoapStorageSession::ServiceError" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::CRoapStorageSession
+// Default constructor.
+// ---------------------------------------------------------------------------
+//
+CRoapStorageSession::CRoapStorageSession()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::ConstructL
+// Second phase constructor. Initializes the log tool in DRM internal testing.
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::ConstructL()
+    {
+    iKeyStorage = DrmKeyStorageNewL();
+    iKeyStorage->SelectDefaultRootL();
+    iDeleteExpired = ETrue;
+    iLazyClock = new ( ELeave ) LazyClockClient();
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::AddRiContextL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::AddRiContextL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::AddRiContextL -->" )
+    CDRMRIContext* context = NULL;
+    HBufC8* contextData = NULL;
+    TPtr8 data( NULL, 0 );
+    TInt size = 0;
+
+    if ( iDeleteExpired )
+        {
+        TTime drmTime;
+        DRMClock::ESecurityLevel level;
+        TInt zone = KTzZulu;
+        iLazyClock->GetSecureTimeL( drmTime, zone, level );
+
+        if ( level == DRMClock::KSecure )
+            {
+            ROAPDB->DeleteExpiredRightsIssuerContextsL( drmTime );
+            ROAPDB->DeleteExpiredDomainContextsL( drmTime );
+            iDeleteExpired = EFalse;
+            }
+        }
+
+    size = User::LeaveIfError( IPCGETDESLEN0 );
+    contextData = HBufC8::NewMaxLC( size );
+    data.Set( const_cast<TUint8*> ( contextData->Ptr() ), 0, size );
+    IPCREAD0L( data );
+    MACLOGLITDETAIL( "Serialized RI context" )
+    MACLOGHEXDETAIL( contextData->Ptr(), contextData->Length() )
+
+    context = CDRMRIContext::NewLC();
+    context->ImportL( data );
+    ROAPDB->StoreRightsIssuerContextL( *context );
+
+    CleanupStack::PopAndDestroy( context );
+    CleanupStack::PopAndDestroy( contextData );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::AddRiContextL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::AddDomainContextL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::AddDomainContextL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::AddDomainContextL -->" )
+    CDRMDomainContext* context = NULL;
+    HBufC8* contextData = NULL;
+    HBufC8* domainElements = NULL;
+    HBufC8* macs = NULL;
+    TPtr8 data( NULL, 0 );
+    TInt size = 0;
+    TKeyTransportScheme transScheme;
+    TPckg<TKeyTransportScheme> package( transScheme );
+
+    HBufC8* plainDomainKey = NULL;
+    HBufC8* plainMacKey = NULL;
+
+    if ( iDeleteExpired )
+        {
+        TTime drmTime;
+        DRMClock::ESecurityLevel level;
+        TInt zone = KTzZulu;
+        iLazyClock->GetSecureTimeL( drmTime, zone, level );
+
+        if ( level == DRMClock::KSecure )
+            {
+            ROAPDB->DeleteExpiredRightsIssuerContextsL( drmTime );
+            ROAPDB->DeleteExpiredDomainContextsL( drmTime );
+            iDeleteExpired = EFalse;
+            }
+        }
+
+    RPointerArray<HBufC8> plainDomainKeys;
+    CleanupResetAndDestroyPushL( plainDomainKeys );
+
+    RPointerArray<HBufC8> plainMacKeys;
+    CleanupResetAndDestroyPushL( plainMacKeys );
+
+    size = IPCGETDESLEN0;
+
+    if ( size <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    contextData = HBufC8::NewMaxLC( size );
+    data.Set( const_cast<TUint8*> ( contextData->Ptr() ), 0, size );
+    IPCREAD0L( data );
+    MACLOGLITDETAIL( "Serialized domain context" )
+    MACLOGHEXDETAIL( contextData->Ptr(), contextData->Length() )
+
+    context = CDRMDomainContext::NewLC();
+    context->ImportL( data );
+
+    TPtrC8 domainId = context->DomainID();
+
+    if ( domainId.Length() <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    IPCREAD1L( package );
+
+    size = IPCGETDESLEN2;
+
+    if ( size <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    macs = HBufC8::NewLC( size );
+    data.Set( macs->Des() );
+    IPCREAD2L( data );
+
+    size = IPCGETDESLEN3;
+
+    if ( size <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    domainElements = HBufC8::NewLC( size );
+    data.Set( domainElements->Des() );
+    IPCREAD3L( data );
+
+    const RPointerArray<HBufC8>& domainKeys( context->DomainKeys() );
+
+    for ( TInt i = 0; i < domainKeys.Count(); i++ )
+        {
+        UnwrapDomainKeyL( iKeyStorage, *domainKeys[i], plainDomainKey,
+            plainMacKey, transScheme );
+        TInt ret( plainDomainKeys.Append( plainDomainKey ) );
+        if ( ret )
+            {
+            // Append did not succeed,
+            // delete buffers not in CleanupStack and leave.
+            delete plainDomainKey;
+            plainDomainKey = NULL;
+            delete plainMacKey;
+            plainMacKey = NULL;
+            User::LeaveIfError( ret );
+            }
+        CleanupStack::PushL( plainMacKey );
+        plainMacKeys.AppendL( plainMacKey );
+        CleanupStack::Pop( plainMacKey );
+        }
+
+    if ( !VerifyMacL( *domainElements, *macs, plainMacKeys ) )
+        {
+        User::Leave( KErrRoapServerFatal );
+        }
+
+    context->SetDomainKeysL( plainDomainKeys );
+
+    ROAPDB->StoreDomainContextL( *context );
+
+    CleanupStack::PopAndDestroy( domainElements );
+    CleanupStack::PopAndDestroy( macs );
+    CleanupStack::PopAndDestroy( context );
+    CleanupStack::PopAndDestroy( contextData );
+    CleanupStack::PopAndDestroy( &plainMacKeys );
+    CleanupStack::PopAndDestroy( &plainDomainKeys );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::AddDomainContextL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::GetRiContextL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::GetRiContextL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::GetRiContextL -->" )
+    CDRMRIContext* context = CDRMRIContext::NewLC();
+    HBufC8* riId = NULL;
+    TInt size = 0;
+    TPtr8 data( NULL, 0 );
+
+    TPckg<TInt> package( size );
+    riId = HBufC8::NewLC( User::LeaveIfError( IPCGETDESLEN1 ) );
+    data.Set( riId->Des() );
+    IPCREAD1L( data );
+    if ( riId->Length() != SHA1_HASH )
+        {
+        User::Leave( KErrArgument );
+        }
+    context->SetRIIDL( *riId );
+    ROAPDB->FetchRightsIssuerContextL( *context );
+    size = context->Size();
+    IPCWRITE0L( package );
+    delete iPreparedData;
+    iPreparedData = NULL;
+    iPreparedData = context->ExportL();
+
+    CleanupStack::PopAndDestroy( riId ); // riId, context
+    CleanupStack::PopAndDestroy( context ); // riId, context
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( " --> CRoapStorageSession::GetRiContextL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::GetDomainContextL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::GetDomainContextL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::GetDomainContextL -->" )
+    RThread thread;
+    aMessage.ClientL( thread );
+    CleanupClosePushL( thread );
+
+    CDRMDomainContext* context = CDRMDomainContext::NewLC();
+    HBufC8* domainId = NULL;
+    TInt size = 0;
+    TPtr8 data( NULL, 0 );
+    _LIT_SECURITY_POLICY_V0(vidCheck, VID_DEFAULT);
+    // Check Default VID
+
+    TPckg<TInt> package( size );
+    domainId = HBufC8::NewLC( User::LeaveIfError( IPCGETDESLEN1 ) );
+    data.Set( domainId->Des() );
+    IPCREAD1L( data );
+    if ( domainId->Length() < KMinDomainIdLength || domainId->Length()
+        > SHA1_HASH )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    context->SetDomainIDL( *domainId );
+    ROAPDB->FetchDomainContextL( *context );
+    if ( !vidCheck.CheckPolicy( thread ) )
+        {
+        // Remove sensitive data since trusted vendor id not present
+        RPointerArray<HBufC8> emptyDomainKeys;
+        CleanupResetAndDestroyPushL( emptyDomainKeys );
+        emptyDomainKeys.Reset();
+        context->SetDomainKeysL( emptyDomainKeys );
+        CleanupStack::PopAndDestroy( &emptyDomainKeys );
+        }
+    size = context->Size();
+    IPCWRITE0L( package );
+    delete iPreparedData;
+    iPreparedData = NULL;
+    iPreparedData = context->ExportL();
+
+    CleanupStack::PopAndDestroy( domainId );
+    CleanupStack::PopAndDestroy( context );
+    CleanupStack::PopAndDestroy( &thread );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( " --> CRoapStorageSession::GetDomainContextL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::GetDataL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::GetDataL( const RMessage2& aMessage )
+    {
+    if ( !iPreparedData )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    IPCWRITE0L( iPreparedData->Des() );
+
+    delete iPreparedData;
+    iPreparedData = NULL;
+
+    aMessage.Complete( KErrNone );
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::DeleteRiContextL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::DeleteRiContextL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::DeleteRiContextL -->" )
+    HBufC8* riId = NULL;
+    TPtr8 data( NULL, 0 );
+
+    SanitizeL( aMessage.GetDesLength( 0 ) );
+
+    riId = HBufC8::NewLC( IPCGETDESLEN0 );
+    data.Set( riId->Des() );
+    IPCREAD0L( data );
+
+    if ( riId->Length() != SHA1_HASH )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    ROAPDB->DeleteRightsIssuerContextL( *riId );
+
+    CleanupStack::PopAndDestroy( riId );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::DeleteRiContextL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::DeleteDomainContextL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::DeleteDomainContextL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::DeleteDomainContextL -->" )
+    HBufC8* domainId = NULL;
+    TPtr8 data( NULL, 0 );
+
+    SanitizeL( aMessage.GetDesLength( 0 ) );
+
+    domainId = HBufC8::NewLC( IPCGETDESLEN0 );
+    data.Set( domainId->Des() );
+    IPCREAD0L( data );
+
+    if ( domainId->Length() < KMinDomainIdLength || domainId->Length()
+        > SHA1_HASH )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    ROAPDB->DeleteDomainContextL( *domainId );
+
+    CleanupStack::PopAndDestroy( domainId );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::DeleteDomainContextL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::DeleteExpiredRIsL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::DeleteExpiredRIsL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::DeleteExpiredRIsL -->" )
+    TTime time;
+    TPckg<TTime> package( time );
+
+    IPCREAD0L( package );
+    ROAPDB->DeleteExpiredRightsIssuerContextsL( time );
+
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::DeleteExpiredRIsL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::DeleteExpiredDomainsL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::DeleteExpiredDomainsL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::DeleteExpiredDomainsL -->" )
+    TTime time;
+    TPckg<TTime> package( time );
+
+    IPCREAD0L( package );
+    ROAPDB->DeleteExpiredDomainContextsL( time );
+
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::DeleteExpiredDomainsL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::WhiteListUrlExistsL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::WhiteListUrlExistsL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::WhiteListURLExistsL -->" )
+    HBufC8* url = NULL;
+    TPtr8 data( NULL, 0 );
+    TBool exists = EFalse;
+
+    __UHEAP_MARK;
+    SanitizeL( aMessage.GetDesLength( 0 ) );
+    User::LeaveIfError( IPCGETDESLEN1 );
+    TBool fromPreConfiguredWhiteList( EFalse );
+    TPckg<TBool> preConfiguredInOutParam( fromPreConfiguredWhiteList );
+
+    url = HBufC8::NewLC( IPCGETDESLEN0 );
+    data.Set( url->Des() );
+    IPCREAD0L( data );
+    IPCREAD1L( preConfiguredInOutParam );
+    exists = ROAPDB->WhiteListURLExistsL( *url );
+
+    if ( exists )
+        {
+        fromPreConfiguredWhiteList = EFalse;
+        }
+    else if ( fromPreConfiguredWhiteList )
+        {
+        TPtrC8 whitelistElement( NULL, 0 );
+        HBufC* buffer = HBufC::NewLC( KMaxWhiteListLen );
+        HBufC8* whitelist = HBufC8::NewLC( KMaxWhiteListLen );
+
+        TPtr ptr( NULL, 0 );
+        ptr.Set( buffer->Des() );
+        CRepository* repository = CRepository::NewLC( KCRUidRoapHandler );
+        repository->Get( KRoapHandlerRegistrationWhitelist, ptr );
+        data.Set( whitelist->Des() );
+        data.Copy( ptr );
+        TLex8 lex( *whitelist );
+
+        TUriParser8 uri;
+        uri.Parse( *url );
+
+        const TDesC8& host = uri.Extract( EUriHost );
+        while ( !exists && !lex.Eos() )
+            {
+            whitelistElement.Set( lex.NextToken() );
+            if ( host.Right( whitelistElement.Length() ).CompareF(
+                whitelistElement ) == 0 )
+                {
+                exists = ETrue;
+                }
+            }
+        fromPreConfiguredWhiteList = exists;
+        CleanupStack::PopAndDestroy( repository );
+        CleanupStack::PopAndDestroy( whitelist );
+        CleanupStack::PopAndDestroy( buffer );
+        }
+
+    CleanupStack::PopAndDestroy( url );
+    IPCWRITE1L( preConfiguredInOutParam );
+    exists ? aMessage.Complete( KErrNone ) : aMessage.Complete( KErrNotFound );
+    __UHEAP_MARKEND;
+    MACLOGLITDETAIL( "--> CRoapStorageSession::WhiteListURLExistsL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::GetDevicePublicKeyDerL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::GetDevicePublicKeyDerL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::GetDevicePublicKeyDerL -->" )
+    HBufC8* publicKey = NULL;
+    TInt size = 0;
+    TPtr8 data( NULL, 0 );
+    TPckg<TInt> package( size );
+    CX509Certificate* cert = NULL;
+    RPointerArray<HBufC8> certChain;
+
+    CleanupResetAndDestroyPushL( certChain );
+
+    iKeyStorage->GetCertificateChainL( certChain );
+    if ( certChain.Count() > 0 )
+        cert = CX509Certificate::NewL( *certChain[0] );
+    else
+        User::Leave( KErrNotFound );
+    CleanupStack::PopAndDestroy( &certChain );
+    CleanupStack::PushL( cert );
+    publicKey = cert->DataElementEncoding(
+        CX509Certificate::ESubjectPublicKeyInfo )->AllocLC();
+    size = publicKey->Size();
+    IPCWRITE0L( package );
+    delete iPreparedData;
+    iPreparedData = NULL;
+    iPreparedData = publicKey;
+    CleanupStack::Pop( publicKey );
+    CleanupStack::PopAndDestroy( cert );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::GetDevicePublicKeyDerL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::GetDeviceCertificateChainL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::GetDeviceCertificateChainL(
+    const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::GetCertificateChainL -->" )
+    RPointerArray<HBufC8> certChain;
+    HBufC8* certChainBuf = NULL;
+    TInt bufferSize = 0;
+    TPckg<TInt> package( bufferSize );
+
+    CleanupResetAndDestroyPushL( certChain );
+
+    iKeyStorage->GetCertificateChainL( certChain );
+    certChainBuf = ArrayToBufferLC( certChain );
+    CleanupStack::Pop( certChainBuf );
+    CleanupStack::PopAndDestroy( &certChain );
+    CleanupStack::PushL( certChainBuf );
+    bufferSize = certChainBuf->Size();
+    IPCWRITE0L( package );
+    delete iPreparedData;
+    iPreparedData = certChainBuf;
+    CleanupStack::Pop( certChainBuf );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::GetCertificateChainL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::SignL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::SignL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::SignL -->" )
+    HBufC8* hash = NULL;
+    HBufC8* signature = NULL;
+    TInt size = 0;
+    TPtr8 data( NULL, 0 );
+    TPckg<TInt> package( size );
+
+    if ( IPCGETDESLEN1 <= 0 || IPCGETDESLEN1 >= KMaxTInt / 2 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    hash = HBufC8::NewLC( IPCGETDESLEN1 );
+
+    data.Set( hash->Des() );
+    IPCREAD1L( data );
+    signature = OmaCrypto::RsaPssSignHashL( iKeyStorage, *hash );
+    CleanupStack::PushL( signature );
+    size = signature->Size();
+    IPCWRITE0L( package );
+    delete iPreparedData;
+    iPreparedData = signature;
+    CleanupStack::Pop( signature );
+    CleanupStack::PopAndDestroy( hash );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::SignL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::RsaSignL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::RsaSignL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::RsaSignL -->" )
+    HBufC8* hash = NULL;
+    HBufC8* signature = NULL;
+    TInt size = 0;
+    TPtr8 data( NULL, 0 );
+    TPckg<TInt> package( size );
+
+    if ( IPCGETDESLEN1 <= 0 || IPCGETDESLEN1 >= KMaxTInt / 2 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    hash = HBufC8::NewLC( IPCGETDESLEN1 );
+
+    data.Set( hash->Des() );
+    IPCREAD1L( data );
+    signature = iKeyStorage->RsaSignL( data );
+    CleanupStack::PushL( signature );
+    size = signature->Size();
+    IPCWRITE0L( package );
+    delete iPreparedData;
+    iPreparedData = signature;
+    CleanupStack::Pop( signature );
+    CleanupStack::PopAndDestroy( hash );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::RsaSignL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::SelectTrustedRootL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::SelectTrustedRootL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::SelectTrustedRootL -->" )
+    RPointerArray<HBufC8> riRoots;
+    RPointerArray<HBufC8> deviceRoots;
+    HBufC8* rootsBuf = NULL;
+    TPtr8 data( NULL, 0 );
+    TBool commonRootFound = EFalse;
+    TInt i = 0;
+    TInt j = 0;
+
+    CleanupResetAndDestroyPushL( riRoots );
+    CleanupResetAndDestroyPushL( deviceRoots );
+
+    SanitizeL( aMessage.GetDesLength( 0 ) );
+    rootsBuf = HBufC8::NewLC( IPCGETDESLEN0 );
+
+    data.Set( rootsBuf->Des() );
+    IPCREAD0L( data );
+    riRoots = BufferToArrayL( *rootsBuf );
+    iKeyStorage->GetTrustedRootsL( deviceRoots );
+
+    while ( i < deviceRoots.Count() && !commonRootFound )
+        {
+        j = 0;
+        while ( j < riRoots.Count() && !commonRootFound )
+            {
+            if ( deviceRoots[i]->CompareF( *riRoots[j] ) == KErrNone )
+                {
+                commonRootFound = ETrue;
+                }
+            ++j;
+            }
+        ++i;
+        }
+    if ( !commonRootFound )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    const TPtrC8 selectedRoot( *( deviceRoots[i - 1] ) );
+    iKeyStorage->SelectTrustedRootL( selectedRoot );
+    IPCWRITE1L( selectedRoot );
+    MACLOGLITDETAIL( "Selected trusted root" )
+    MACLOGHEXDETAIL( selectedRoot.Ptr(), selectedRoot.Length() )
+
+    CleanupStack::PopAndDestroy( rootsBuf );
+    CleanupStack::PopAndDestroy( &deviceRoots );
+    CleanupStack::PopAndDestroy( &riRoots );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::SelectTrustedRootL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::ActivateTrustedRootL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::ActivateTrustedRootL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::ActivateTrustedRootL -->" )
+    TBuf8<SHA1_HASH> trustedRoot;
+
+    if ( IPCGETDESLEN0 <= 0 )
+        {
+        // select default root
+        iKeyStorage->SelectTrustedRootL( KNullDesC8 );
+        }
+    else
+        {
+        // select the root indicated by the client
+        IPCREAD0L( trustedRoot );
+        if ( trustedRoot.Length() != SHA1_HASH )
+            {
+            User::Leave( KErrArgument );
+            }
+        iKeyStorage->SelectTrustedRootL( trustedRoot );
+        }
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::ActivateTrustedRootL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::GetTrustedRootsL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::GetTrustedRootsL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::GetTrustedRootsL -->" )
+    RPointerArray<HBufC8> deviceRoots;
+    TInt size = 0;
+    HBufC8* rootsData = NULL;
+
+    CleanupResetAndDestroyPushL( deviceRoots );
+
+    TPckg<TInt> package( size );
+    iKeyStorage->GetTrustedRootsL( deviceRoots );
+    rootsData = ArrayToBufferLC( deviceRoots );
+    size = rootsData->Size();
+    IPCWRITE0L( package );
+    delete iPreparedData;
+    iPreparedData = NULL;
+    iPreparedData = rootsData;
+
+    CleanupStack::Pop( rootsData );
+    CleanupStack::PopAndDestroy( &deviceRoots );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::GetTrustedRootsL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::GetRootCertificateL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::GetRootCertificateL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::GetRootCertificateL -->" )
+    HBufC8* rootCertBuf( NULL );
+    HBufC* subject( NULL );
+    TInt size( 0 );
+    TPtr data( NULL, 0 );
+    RPointerArray<HBufC8> rootCerts;
+    TPckg<TInt> package( size );
+    CX509Certificate* rootCert( NULL );
+    HBufC* rootName( NULL );
+    TInt i = 0;
+
+    SanitizeL( IPCGETDESLEN1 );
+    subject = HBufC::NewLC( User::LeaveIfError( IPCGETDESLEN1 ) );
+    data.Set( subject->Des() );
+    IPCREAD1L( data );
+
+    iKeyStorage->GetRootCertificatesL( rootCerts );
+
+    CleanupResetAndDestroyPushL( rootCerts );
+
+    for ( i = 0; i < rootCerts.Count() && !rootCertBuf; i++ )
+        {
+        rootCert = CX509Certificate::NewLC( *( rootCerts[i] ) );
+        rootName = rootCert->IssuerName().DisplayNameL();
+        CleanupStack::PushL( rootName );
+        const TInt compareResult( rootName->CompareF( *subject ) );
+        CleanupStack::PopAndDestroy( rootName );
+        CleanupStack::PopAndDestroy( rootCert );
+        if ( compareResult == KErrNone )
+            {
+            rootCertBuf = rootCerts[i]->AllocLC();
+            }
+        }
+
+    if ( !rootCertBuf )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    size = rootCertBuf->Size();
+    IPCWRITE0L( package );
+    delete iPreparedData;
+    iPreparedData = NULL;
+    iPreparedData = rootCertBuf;
+
+    CleanupStack::Pop( rootCertBuf );
+    CleanupStack::PopAndDestroy( &rootCerts );
+    CleanupStack::PopAndDestroy( subject );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::GetRootCertificateL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::DeleteExpiredContextsL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::DeleteExpiredContextsL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::DeleteExpiredContextsL -->" )
+    TTime time;
+    TPckg<TTime> package( time );
+
+    IPCREAD0L( package );
+    ROAPDB->DeleteExpiredRightsIssuerContextsL( time );
+    ROAPDB->DeleteExpiredDomainContextsL( time );
+
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::DeleteExpiredContextsL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::DeleteAllL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::DeleteAllL( const RMessage2& aMessage )
+    {
+
+    MACLOGLITDETAIL( "CRoapStorageSession::DeleteAllL -->" )
+#ifndef RD_MULTIPLE_DRIVE
+
+    ROAPDB->DeleteAllL( KRIContextFile(), KDomainContextFile() );
+
+#else //RD_MULTIPLE_DRIVE
+    RFs fs;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    fs.DriveToChar( driveNumber, driveLetter );
+    CleanupStack::PopAndDestroy( &fs );
+
+    TFileName riContextFile;
+    riContextFile.Copy( KRIContextFileName );
+    __ASSERT_ALWAYS( riContextFile.Length()>0, User::Invariant() );
+    riContextFile[0] = ( TUint )driveLetter;
+
+    TFileName domainContextFile;
+    domainContextFile.Copy( KDomainContextFileName );
+    __ASSERT_ALWAYS( domainContextFile.Length()>0, User::Invariant() );
+    domainContextFile[0] = ( TUint )driveLetter;
+
+    ROAPDB->DeleteAllL( riContextFile, domainContextFile );
+
+#endif
+
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::DeleteAllL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::GetMeteringDataL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::GetMeteringDataL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::GetMeteringDataL -->" )
+#ifndef RD_DRM_METERING
+    aMessage.Complete( KErrNotSupported );
+#else
+    HBufC8* riId = NULL;
+    HBufC8* meteringData = NULL;
+    HBufC8* encryptedMeteringData = NULL;
+    RDRMRightsClient client;
+    TInt mekAndMakSize = 0;
+    TInt meteringDataSize = 0;
+    TPtr8 data( NULL, 0 );
+    TPtr8 ptr( NULL, 0 );
+    TPckg<TInt> MakMek( mekAndMakSize );
+    TPckg<TInt> dataSize( meteringDataSize );
+    TBuf8<KDCFKeySize> mac;
+    TBuf8<KDCFKeySize> mek;
+    TBuf8<KDCFKeySize> initializingVector;
+    CRSAPublicKey* riPublicKey = NULL;
+    CX509Certificate* cert = NULL;
+    CSHA1* hasher = NULL;
+    TBuf8<SHA1_HASH> encKeyHash;
+    TX509KeyFactory factory;
+    TKeyTransportScheme selectedAlgorithm = EOma;
+    HBufC8* encryptedMekAndMak = NULL;
+    CDRMRIContext* context = NULL;
+
+    User::LeaveIfError( client.Connect() );
+    CleanupClosePushL( client );
+
+    SanitizeL( aMessage.GetDesLength( 0 ) );
+
+    riId = HBufC8::NewLC( IPCGETDESLEN0 );
+    data.Set( riId->Des() );
+    IPCREAD0L( data );
+
+    // generate mek
+    mek.SetLength( OmaCrypto::KKeySize );
+    TRandom::Random( mek );
+
+    // generate mac
+    mac.SetLength( OmaCrypto::KMacSize );
+    TRandom::Random( mac );
+
+    initializingVector.SetLength( KDCFKeySize );
+    TRandom::Random( initializingVector );
+
+    context = CDRMRIContext::NewLC();
+    context->SetRIIDL( *riId );
+    ROAPDB->FetchRightsIssuerContextL( *context );
+
+    cert = CX509Certificate::NewLC( *( context->CertificateChain() )[0] );
+
+    hasher = CSHA1::NewL();
+    CleanupStack::PushL( hasher );
+    // Calculate SHA1_HASH for RI public key
+    hasher->Hash( *cert->DataElementEncoding(
+        CX509Certificate::ESubjectPublicKeyInfo ) );
+    encKeyHash.Append( hasher->Final() );
+    CleanupStack::PopAndDestroy( hasher );
+
+    riPublicKey = factory.RSAPublicKeyL( cert->PublicKey().KeyData() );
+    CleanupStack::PopAndDestroy( cert );
+    cert = NULL;
+    CleanupStack::PushL( riPublicKey );
+
+    // check if we are not using OMA algorithms
+    for ( TInt i = 0; i < context->Algorithms().Count(); i++ )
+        {
+        if ( context->Algorithms()[i]->CompareF( KCmlaIp1() ) == KErrNone )
+            {
+            selectedAlgorithm = ECmlaIp1;
+            break;
+            }
+        }
+
+    // Wrap Mek and Mac with RI's public key
+    if ( selectedAlgorithm == EOma )
+        {
+        encryptedMekAndMak = OmaCrypto::RsaKemKwsEncryptL( riPublicKey, mek,
+            mac );
+        }
+    else
+        { // CMLA
+        encryptedMekAndMak = CmlaCrypto::CmlaIpEncryptL( selectedAlgorithm,
+            riPublicKey, mek, mac );
+        }
+    CleanupStack::PopAndDestroy( riPublicKey );
+    riPublicKey = NULL;
+    CleanupStack::PopAndDestroy( context );
+    context = NULL;
+
+    CleanupStack::PushL( encryptedMekAndMak );
+
+    mekAndMakSize = encryptedMekAndMak->Size();
+    // Get the actual metering data!!!
+    meteringData = client.GetMeteringDataL( *riId );
+
+    if ( !meteringData )
+        {
+        MACLOGLIT( "No metering Data found from DB!:" )
+        }
+    else
+        {
+        MACLOGLIT( "Raw meteringData:" )
+        MACLOGHEX( meteringData->Ptr(), meteringData->Length() )
+        CleanupStack::PushL( meteringData );
+
+        encryptedMeteringData = DrmAesCrypto::DrmAesEncryptL( mek,
+            initializingVector, ETrue, meteringData->Des() );
+
+        CleanupStack::PopAndDestroy( meteringData );
+        meteringData = NULL;
+
+        CleanupStack::PushL( encryptedMeteringData );
+
+        MACLOGLIT( "Ciphered meteringData with 128-bit AESCBC:" )
+        MACLOGHEX( encryptedMeteringData->Ptr(), encryptedMeteringData->Length())
+        meteringDataSize = encryptedMeteringData->Size();
+        }
+
+    IPCWRITE1L( MakMek );
+    IPCWRITE2L( dataSize );
+    if ( iPreparedData )
+        {
+        delete iPreparedData;
+        iPreparedData = NULL;
+        }
+    iPreparedData = HBufC8::NewL( OmaCrypto::KMacSize + SHA1_HASH
+        + mekAndMakSize + meteringDataSize );
+    ptr.Set( iPreparedData->Des() );
+    ptr.Copy( mac );
+    ptr.Append( encKeyHash );
+    ptr.Append( *encryptedMekAndMak );
+    if ( encryptedMeteringData )
+        {
+        ptr.Append( *encryptedMeteringData );
+        CleanupStack::PopAndDestroy( encryptedMeteringData );
+        }
+
+    MACLOGLIT( "Final iPreparedData:" )
+    MACLOGHEX( iPreparedData->Ptr(), iPreparedData->Length() )
+
+    CleanupStack::PopAndDestroy( encryptedMekAndMak );
+    CleanupStack::PopAndDestroy( riId );
+    CleanupStack::PopAndDestroy( &client );
+    // riId, client
+    aMessage.Complete( KErrNone );
+#endif //RD_DRM_METERING
+    MACLOGLITDETAIL( "--> CRoapStorageSession::GetMeteringDataL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::DeleteMeteringDataL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::DeleteMeteringDataL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::DeleteMeteringDataL -->" )
+#ifndef RD_DRM_METERING
+    aMessage.Complete( KErrNotSupported );
+#else
+    HBufC8* riId = NULL;
+    TPtr8 data( NULL, 0 );
+    RDRMRightsClient client;
+
+    User::LeaveIfError( client.Connect() );
+    CleanupClosePushL( client );
+    riId = HBufC8::NewLC( User::LeaveIfError( IPCGETDESLEN0 ) );
+    data.Set( riId->Des() );
+    IPCREAD0L( data );
+    client.DeleteMeteringDataL( *riId );
+
+    CleanupStack::PopAndDestroy( riId );
+    CleanupStack::PopAndDestroy( &client );
+
+    aMessage.Complete( KErrNone );
+#endif // RD_DRM_METERING
+    MACLOGLITDETAIL( "--> CRoapStorageSession::DeleteMeteringDataL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::GetAllRIContextsL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::GetAllRIContextsL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::GetAllRIContextsL -->" )
+#ifndef RD_DRM_METERING
+    aMessage.Complete( KErrNotSupported );
+#else
+    TInt size = 0;
+    TPtr8 data( NULL, 0 );
+    CDRMPointerArray<CDRMRIContext>* contexts = CDRMPointerArray<
+        CDRMRIContext>::NewLC();
+    contexts->SetAutoCleanup( ETrue );
+
+    TPckg<TInt> package( size );
+
+    ROAPDB->FetchAllRightsIssuerContextsL( *contexts );
+
+    // Calculate the size of the output buffer:
+    if ( contexts->Count() )
+        {
+        size = contexts->Count() * sizeof(TInt) + sizeof(TInt);
+        for ( TInt i = 0; i < contexts->Count(); i++ )
+            {
+            size += ( *contexts )[i]->Size();
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    IPCWRITE0L( package );
+
+    // Create a buffer of the proper size and export the data to the buffer:
+    if ( iPreparedData )
+        {
+        delete iPreparedData;
+        iPreparedData = NULL;
+        }
+    iPreparedData = HBufC8::NewMaxL( size );
+
+    if ( !iPreparedData )
+        {
+        User::Leave( KErrNoMemory );
+        }
+
+    RMemWriteStream stream( ( TAny* )( iPreparedData->Ptr() ), size );
+    CleanupClosePushL( stream );
+    TInt value = 0;
+
+    for ( TInt i = 0; i < contexts->Count(); i++ )
+        {
+        // Size:
+        value = ( *contexts )[i]->Size();
+        stream.WriteInt32L( value );
+
+        // Data:
+        ( *contexts )[i]->ExternalizeL( stream );
+        }
+    // Finishing size:
+    value = 0;
+    stream.WriteInt32L( value );
+
+    CleanupStack::PopAndDestroy( 2, contexts ); // stream, contexts
+
+    aMessage.Complete( KErrNone );
+#endif // RD_DRM_METERING
+    MACLOGLITDETAIL( "--> CRoapStorageSession::GetAllRIContextsL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::UpdateRIContextL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::UpdateRIContextL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::UpdateRIContextL -->" )
+#ifndef RD_DRM_METERING
+    aMessage.Complete( KErrNotSupported );
+#else
+    CDRMRIContext* context = NULL;
+    HBufC8* contextData = NULL;
+    TPtr8 data( NULL, 0 );
+    TInt size = 0;
+
+    size = User::LeaveIfError( IPCGETDESLEN0 );
+    contextData = HBufC8::NewMaxLC( size );
+    data.Set( const_cast<TUint8*> ( contextData->Ptr() ), 0, size );
+    IPCREAD0L( data );
+    context = CDRMRIContext::NewLC();
+    context->ImportL( data );
+
+    // Update RI context:
+    ROAPDB->UpdateRightsIssuerContextL( *context );
+
+    CleanupStack::PopAndDestroy( context );
+    CleanupStack::PopAndDestroy( contextData );
+    aMessage.Complete( KErrNone );
+#endif // RD_DRM_METERING
+    MACLOGLITDETAIL( "--> CRoapStorageSession::UpdateRIContextL" )
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::UpdateDrmTimeL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::UpdateDrmTimeL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::UpdateDrmTimeL -->" )
+    COCSPResponseDecoder* responseDecoder = NULL;
+    COCSPResponse* response = NULL;
+    RPointerArray<HBufC8> ocspResponses;
+
+    RPointerArray<HBufC8> riCertChain;
+
+    TBool clockUpdated( EFalse );
+    TPckg<TBool> retBuf( clockUpdated );
+
+    // Some sanity checks
+    const TInt argLen0( IPCGETDESLEN0 );
+    const TInt argLen1( IPCGETDESLEN1 );
+    const TInt argLen2( IPCGETDESLEN2 );
+    SanitizeL( argLen0 );
+    SanitizeL( argLen1 );
+    SanitizeL( argLen2 );
+    User::LeaveIfError( IPCGETDESLEN3 );
+
+    RBuf8 readBuf;
+    CleanupClosePushL( readBuf );
+    readBuf.CreateL( Max( argLen0, Max( argLen1, argLen2 ) ) );
+
+    readBuf.Zero();
+    IPCREAD0L( readBuf );
+    MACLOGLDETAIL( "---- read Ri Cert Chain ----" )
+    MACLOGHEXDETAIL( readBuf.Ptr(), readBuf.Length() )
+    riCertChain = BufferToArrayL( readBuf );
+    CleanupResetAndDestroyPushL( riCertChain );
+
+    readBuf.Zero();
+    IPCREAD1L( readBuf );
+    MACLOGLDETAIL( "---- read serialized OCSP responses ----" )
+    MACLOGHEXDETAIL( readBuf.Ptr(), readBuf.Length() )
+    ocspResponses = BufferToArrayL( readBuf );
+    CleanupResetAndDestroyPushL( ocspResponses );
+
+    readBuf.Zero();
+    IPCREAD2L( readBuf );
+    MACLOGLDETAIL( "---- read request nonce ----" )
+    MACLOGHEXDETAIL( readBuf.Ptr(), readBuf.Length() )
+    const TPtrC8 regReqNonce( readBuf ); // Do not modify readBuf after this.
+
+    // Get trusted roots and root certificates.
+    RPointerArray<HBufC8> trustedRoots;
+    CleanupResetAndDestroyPushL( trustedRoots );
+    iKeyStorage->GetTrustedRootsL( trustedRoots );
+    RPointerArray<HBufC8> rootCertificates;
+    CleanupResetAndDestroyPushL( rootCertificates );
+    iKeyStorage->GetRootCertificatesL( rootCertificates );
+
+    //First, check, if update is allowed
+    if ( ocspResponses.Count() )
+        {
+        responseDecoder = COCSPResponseDecoder::NewL( *ocspResponses[0] );
+        CleanupStack::PushL( responseDecoder );
+        response = responseDecoder->TakeResponse(); // CRoapEng owns the response now
+        User::LeaveIfNull( response );
+        CleanupStack::PopAndDestroy( responseDecoder );
+        responseDecoder = NULL;
+        CleanupStack::PushL( response );
+        if ( ::IsTimeUpdateAllowedL( trustedRoots, rootCertificates,
+            riCertChain, *response, regReqNonce ) )
+            {
+            iLazyClock->UpdateSecureTimeL( response->ProducedAt(), KTzZulu );
+            clockUpdated = ETrue;
+            MACLOGLIT( "DRM time updated" )
+            }
+
+        CleanupStack::PopAndDestroy( response );
+        }
+    else
+        {
+        MACLOGLIT( "No OCSP responses present!" )
+        // So wrong argument got
+        }
+    CleanupStack::PopAndDestroy( &rootCertificates );
+    CleanupStack::PopAndDestroy( &trustedRoots );
+    CleanupStack::PopAndDestroy( &ocspResponses );
+    CleanupStack::PopAndDestroy( &riCertChain );
+    CleanupStack::PopAndDestroy( &readBuf );
+    IPCWRITE3L( retBuf );
+
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::UpdateDrmTimeL" )
+    }
+
+// ---------------------------------------------------------------------------
+// BufferToArrayL
+// Created buffer will contain
+// <amount of elements:int32, element data1, element data2...>
+// ---------------------------------------------------------------------------
+//
+LOCAL_C RPointerArray<HBufC8> BufferToArrayL( TDesC8& aBuffer )
+    {
+    TInt32 count = 0;
+    HBufC8* element = NULL;
+    RPointerArray<HBufC8> array;
+    CleanupResetAndDestroyPushL( array );
+    TInt size = aBuffer.Size();
+    RMemReadStream stream( ( TAny* )( aBuffer.Ptr() ), size );
+    CleanupClosePushL( stream );
+
+    // amount of elements
+    count = stream.ReadInt32L();
+
+    // for each element in RPointerArray
+    for ( TInt i = 0; i < count; i++ )
+        {
+        // Read the element and append it to array
+        element = HBufC8::NewLC( stream, KMaxElementLength );
+        array.AppendL( element );
+        CleanupStack::Pop( element );
+        }
+
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::Pop( &array );
+    return array;
+    }
+
+// ---------------------------------------------------------------------------
+// ArrayToBuffer
+// Created buffer will contain <amount of elements:int32, data1, data2 ...>
+// ---------------------------------------------------------------------------
+//
+LOCAL_C HBufC8* ArrayToBufferLC( const RPointerArray<HBufC8>& aArray )
+    {
+    HBufC8* buffer = NULL;
+    TInt32 sizeOfElements = 0;
+
+    for ( TInt i = 0; i < aArray.Count(); i++ )
+        {
+        sizeOfElements += aArray[i]->Length() + sizeof(TInt); // sizeof(TInt) is for
+        // element length info
+        }
+    // length of elements + amount of elements
+    sizeOfElements += sizeof(TInt32);
+
+    buffer = HBufC8::NewMaxLC( sizeOfElements );
+
+    RMemWriteStream stream( ( TAny* )( buffer->Ptr() ), sizeOfElements );
+    CleanupClosePushL( stream );
+
+    stream.WriteInt32L( aArray.Count() );
+
+    for ( TInt i = 0; i < aArray.Count(); i++ )
+        {
+        stream << *( aArray[i] );
+        }
+
+    CleanupStack::PopAndDestroy( &stream );
+
+    return buffer;
+    }
+
+// ---------------------------------------------------------------------------
+// UnwrapDomainKeyL
+// ---------------------------------------------------------------------------
+//
+LOCAL_C void UnwrapDomainKeyL(
+    MDrmKeyStorage* aKeyStorage,
+    const TDesC8& aProtectedDomainKey,
+    HBufC8*& aDomainKey,
+    HBufC8*& aMacKey,
+    TKeyTransportScheme& aTransportScheme )
+    {
+    MACLOGLITDETAIL( "::UnwrapDomainKeyL -->" )
+    TBuf8<OmaCrypto::KMacSize> mac;
+    TBuf8<OmaCrypto::KKeySize> dk;
+    TPtrC8 macAndRek( 0, 0 );
+    TPtrC8 wrappedCek( 0, 0 );
+
+    if ( aTransportScheme == EOma )
+        {
+        OmaCrypto::RsaKemKwsDecryptL( aKeyStorage, aProtectedDomainKey, dk,
+            mac );
+        }
+    else
+        {
+        CmlaCrypto::CmlaIpDecryptL( aTransportScheme, aKeyStorage,
+            aProtectedDomainKey, dk, mac );
+        }
+
+    HBufC8* domainKey( dk.AllocLC() );
+    aMacKey = mac.AllocL();
+    CleanupStack::Pop( domainKey );
+    aDomainKey = domainKey;
+    MACLOGLITDETAIL( "--> ::UnwrapDomainKeyL" )
+    }
+
+// ---------------------------------------------------------------------------
+// VerifyMac
+// ---------------------------------------------------------------------------
+//
+LOCAL_C TBool VerifyMacL(
+    TDesC8& aDomainElements,
+    TDesC8& aMacs,
+    RPointerArray<HBufC8>& aMacKeys )
+    {
+    MACLOGLITDETAIL( "::VerifyMacL -->" )
+    __UHEAP_MARK;
+    RPointerArray<HBufC8> domainArray;
+    RPointerArray<HBufC8> macArray;
+    CMessageDigest* hMac = NULL;
+    HBufC8* domainKeyWithNs = NULL;
+    TPtr8 domainKeyWithNsPtr( NULL, NULL );
+    TPtrC8 hmac_value( KNullDesC8 );
+    TInt index = 0;
+
+    CleanupResetAndDestroyPushL( domainArray );
+    CleanupResetAndDestroyPushL( macArray );
+
+    domainArray = BufferToArrayL( aDomainElements );
+    macArray = BufferToArrayL( aMacs );
+
+    if ( domainArray.Count() != macArray.Count() || macArray.Count()
+        != aMacKeys.Count() )
+        {
+        User::Leave( KErrRoapServerFatal );
+        }
+
+    //Verify macs
+    for ( TInt i = 0; i < aMacKeys.Count(); i++ )
+        {
+        // Add ROAP namespaces
+        domainKeyWithNs = HBufC8::NewLC( domainArray[i]->Length() + 2
+            * KRoapXmlNs().Length() );
+        domainKeyWithNsPtr.Set( domainKeyWithNs->Des() );
+        index = domainArray[i]->Find( KRoapDomainKey() );
+        if ( index == KErrNotFound )
+            {
+            index = domainArray[i]->Find( KRoapX509SPKIHash() );
+            if ( index == KErrNotFound )
+                {
+                User::Leave( KErrCorrupt );
+                }
+            index += KRoapX509SPKIHash().Length();
+            }
+        else
+            {
+            index += KRoapDomainKey().Length();
+            }
+        domainKeyWithNsPtr.Copy( domainArray[i]->Left( index ) );
+        domainKeyWithNsPtr.Append( KRoapXmlNs() );
+        domainKeyWithNsPtr.Append( domainArray[i]->Right(
+            domainArray[i]->Length() - index ) );
+
+        hMac = CMessageDigestFactory::NewHMACLC( CMessageDigest::ESHA1,
+            *aMacKeys[i] );
+        hMac->Update( domainKeyWithNsPtr );
+
+        hmac_value.Set( hMac->Final() );
+
+        MACLOGLIT( "DomainKeyElement:" )
+        MACLOGHEX( domainKeyWithNsPtr.Ptr(), domainKeyWithNsPtr.Length() )
+        MACLOGLIT( "Calculated HMAC_value:" )
+        MACLOGHEX( hmac_value.Ptr(), hmac_value.Length() )
+        MACLOGLIT( "HMAC_value:" )
+        MACLOGHEX( macArray[i]->Ptr(), macArray[i]->Length() )
+
+        if ( hmac_value.CompareF( *macArray[i] ) != 0 )
+            {
+            // MAC validation failed
+            User::Leave( KErrRightsServerMacFailed );
+            }
+        CleanupStack::PopAndDestroy( 2, domainKeyWithNs ); // hMac, domainKeyWithNs
+        }
+
+    CleanupStack::PopAndDestroy( &macArray );
+    CleanupStack::PopAndDestroy( &domainArray );
+    __UHEAP_MARKEND;
+    MACLOGLITDETAIL( "--> ::VerifyMacL" )
+    return ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::VerifyOcspResponsesL()
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::VerifyOcspResponsesL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::VerifyOcspResponsesL -->" )
+
+    const TInt argLen0( IPCGETDESLEN0 );
+    const TInt argLen1( IPCGETDESLEN1 );
+    const TInt argLen2( IPCGETDESLEN2 );
+    SanitizeL( argLen0 );
+    SanitizeL( argLen1 );
+    SanitizeL( argLen2 );
+    User::LeaveIfError( IPCGETDESLEN3 );
+
+    COCSPResponseDecoder* responseDecoder = NULL;
+    COCSPResponse* response = NULL;
+    COCSPResponseCertInfo* certInfo = NULL;
+    COCSPCertID* certID = NULL;
+    CX509Certificate* ocspCert = NULL;
+    TBool result = EFalse;
+    TInt certInfoCount = 0;
+    TInt found = KErrNone;
+    CX509Certificate* riCaCert( NULL );
+
+    TPckg<TBool> package( result );
+
+    RBuf8 readBuf;
+    CleanupClosePushL( readBuf );
+    readBuf.CreateL( Max( argLen0, Max( argLen1, argLen2 ) ) );
+
+    // read arguments
+    IPCREAD0L( readBuf );
+    RPointerArray<HBufC8> ocspResponses( BufferToArrayL( readBuf ) );
+    CleanupResetAndDestroyPushL( ocspResponses );
+    readBuf.Zero();
+
+    IPCREAD1L( readBuf );
+    riCaCert = CX509Certificate::NewLC( readBuf );
+    readBuf.Zero();
+
+    IPCREAD2L( readBuf );
+    RPointerArray<HBufC8> certSerialNums( BufferToArrayL( readBuf ) );
+    CleanupResetAndDestroyPushL( certSerialNums );
+    readBuf.Zero();
+
+    // Check OcspResponses. Only the very first response is checked.
+    if ( ocspResponses.Count() )
+        {
+        responseDecoder = COCSPResponseDecoder::NewL( *ocspResponses[0] );
+        CleanupStack::PushL( responseDecoder );
+        response = responseDecoder->TakeResponse();
+        CleanupStack::PopAndDestroy( responseDecoder );
+        User::LeaveIfNull( response );
+        CleanupStack::PushL( response );
+
+        if ( !response )
+            {
+            MACLOGLIT( "No OCSP certificate!" )
+            User::Leave( KErrArgument );
+            }
+
+        result = VerifyOcspCertChainL( *response, riCaCert, ocspCert );
+
+        CleanupStack::PushL( ocspCert );
+
+        // validate OCSP response signature and
+        // that all the RI cert in the chain is valid (status == good)
+        if ( result )
+            {
+            result = response->VerifySignatureL(
+                ocspCert->PublicKey().KeyData() );
+            }
+
+        if ( result )
+            {
+            certInfoCount = response->CertCount();
+            if ( certSerialNums.Count() && result )
+                {
+                TBool isCertStatusFound = EFalse;
+                for ( TInt i = 0; i < certInfoCount && result; i++ )
+                    {
+                    certInfo = response->CertInfo( i ); // certInfo is owned by response
+                    certID = certInfo->CertID(); // certID is owned by certInfo
+                    found = certSerialNums[0]->Compare(
+                        certID->SerialNumber() );
+                    if ( found == KErrNone )
+                        {
+                        isCertStatusFound = ETrue;
+                        if ( certInfo->Status() != OCSP::EGood )
+                            {
+                            result = EFalse;
+                            }
+                        }
+                    }
+                if ( !isCertStatusFound )
+                    {
+                    result = EFalse;
+                    }
+                }
+            }
+
+        CleanupStack::PopAndDestroy( ocspCert );
+        CleanupStack::PopAndDestroy( response );
+        }
+    CleanupStack::PopAndDestroy( &certSerialNums );
+    CleanupStack::PopAndDestroy( riCaCert );
+    CleanupStack::PopAndDestroy( &ocspResponses );
+    CleanupStack::PopAndDestroy( &readBuf );
+
+#ifdef _ROAP_TESTING
+    if ( result )
+        {
+        MACLOGLIT( "OCSP response verification ok." )
+        }
+    else
+        {
+        MACLOGLIT( "OCSP response verification failed." )
+        }
+#endif
+
+#ifdef _DISABLE_OCSP_CHECK
+    result = ETrue;
+#endif
+    IPCWRITE3L( package );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::VerifyOcspResponsesL" )
+    }
+// ---------------------------------------------------------------------------
+// CRoapStorageSession::GetOcspResponderIdL
+// ---------------------------------------------------------------------------
+//
+void CRoapStorageSession::GetOcspResponderIdL( const RMessage2& aMessage )
+    {
+    MACLOGLITDETAIL( "CRoapStorageSession::GetOCSPResponderIdL -->" )
+    COCSPResponseDecoder* rd( NULL );
+    COCSPResponse* response( NULL );
+
+    RPointerArray<CX509Certificate> certArray;
+    CX509Certificate* cert( NULL );
+    CSHA1* hash( NULL );
+    TInt pos( 0 );
+    TInt size( 0 );
+    TPckg<TInt> sizeArg( size );
+
+    SanitizeL( IPCGETDESLEN0 );
+    User::LeaveIfError( IPCGETDESLEN1 );
+    CleanupResetAndDestroyPushL( certArray );
+
+    HBufC8* riId( HBufC8::NewLC( IPCGETDESLEN0 ) );
+    TPtr8 data( riId->Des() );
+    IPCREAD0L( data );
+    if ( riId->Length() != SHA1_HASH )
+        {
+        User::Leave( KErrArgument );
+        }
+    CDRMRIContext* context( CDRMRIContext::NewLC() );
+    context->SetRIIDL( *riId );
+    CleanupStack::Pop( context );
+    CleanupStack::PopAndDestroy( riId );
+    riId = NULL;
+    CleanupStack::PushL( context );
+    ROAPDB->FetchRightsIssuerContextL( *context );
+
+    const RPointerArray<HBufC8>& ocspResponses( context->OCSPResponse() );
+    // Fetch OCSP response from given RiId
+
+    if ( !ocspResponses.Count() )
+        {
+        User::Leave( KErrRoapDevice );
+        }
+
+    rd = COCSPResponseDecoder::NewL( *ocspResponses[0] );
+    CleanupStack::PushL( rd );
+    response = rd->TakeResponse(); // CRoapEng owns the response now
+    CleanupStack::PopAndDestroy( rd );
+    rd = NULL;
+    CleanupStack::PopAndDestroy( context );
+    context = NULL;
+    User::LeaveIfNull( response );
+
+    CleanupStack::PushL( response );
+    const TPtrC8* ocspCerts( response->SigningCerts() );
+
+    TBool ocspResponseUsable( EFalse );
+    // Get SecureTime from ClockServer
+    TTime secureTime;
+    TInt zone( KTzZulu );
+    DRMClock::ESecurityLevel securityLevel( DRMClock::KInsecure );
+    iLazyClock->GetSecureTimeL( secureTime, zone, securityLevel );
+
+    if ( securityLevel == DRMClock::KSecure )
+        {
+        ocspResponseUsable = ETrue;
+        }
+    // Verify that OCSP responses are not expired
+    for ( TInt i( 0 ); ocspResponseUsable && i < response->CertCount(); ++i )
+        {
+        const TTime* nextUpdate( response->CertInfo( i )->NextUpdate() );
+        if ( !nextUpdate || *nextUpdate <= secureTime || response->CertInfo(
+            i )->RevocationTime() )
+            {
+            ocspResponseUsable = EFalse;
+            }
+        }
+
+    if ( ocspResponseUsable )
+        {
+        while ( ocspCerts && pos < ocspCerts->Length() )
+            {
+            cert = CX509Certificate::NewLC( *ocspCerts, pos );
+            certArray.AppendL( cert );
+            CleanupStack::Pop( cert );
+            }
+        ocspCerts = NULL;
+        }
+    CleanupStack::PopAndDestroy( response );
+    response = NULL;
+
+    if ( cert )
+        {
+        // hash the SubjectPublicKeyInfo element
+        hash = CSHA1::NewL();
+        CleanupStack::PushL( hash );
+        hash->Hash( *cert->DataElementEncoding(
+            CX509Certificate::ESubjectPublicKeyInfo ) );
+
+        delete iPreparedData;
+        iPreparedData = NULL;
+        iPreparedData = hash->Final().AllocL();
+        CleanupStack::PopAndDestroy( hash );
+        size = iPreparedData->Length();
+        MACLOGLIT( "Got OCSP responder" )
+        MACLOGHEX( iPreparedData->Ptr(), iPreparedData->Length() )
+        }
+    CleanupStack::PopAndDestroy( &certArray );
+    IPCWRITE1L( sizeArg );
+    aMessage.Complete( KErrNone );
+    MACLOGLITDETAIL( "--> CRoapStorageSession::GetOCSPResponderIdL" )
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/src/certid.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,176 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#include "certid.h"
+#include "bigint.h"
+
+#include <asn1dec.h>
+#include <asn1enc.h>
+#include <x509cert.h>
+
+COCSPCertID* COCSPCertID::NewL(const CX509Certificate& aSubject, const CX509Certificate& aIssuer)
+	{
+	COCSPCertID* self = new (ELeave) COCSPCertID;
+	CleanupStack::PushL(self);
+	self->ConstructL(aSubject, aIssuer);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+
+void COCSPCertID::ConstructL(const CX509Certificate& aSubject, const CX509Certificate& aIssuer)
+	{
+	CSHA1* sha1 = CSHA1::NewL();
+	CleanupStack::PushL(sha1);
+
+	// Hash of DER encoding of IssuerName from subject cert (including tag and length)
+	const TPtrC8* issuerNameDER = aSubject.DataElementEncoding(CX509Certificate::EIssuerName);
+	if (!issuerNameDER)
+		{
+		User::Leave(KErrArgument);
+		}
+
+	iIssuerNameHash.Copy(sha1->Hash(*issuerNameDER));
+
+	// We'll ignore the 'number of unused bits' octet, since this is what everyone does, even
+	// though strictly speaking the OCSP spec says to include it.  This has been discussed on
+	// the PKIX mailing list.
+	sha1->Reset();
+	TPtrC8 subjectPublicKeyContents(aIssuer.PublicKey().KeyData());
+	iIssuerKeyHash.Copy(sha1->Hash(subjectPublicKeyContents));
+
+	CleanupStack::PopAndDestroy(sha1);
+
+	// Set serial number from subject
+	iSerialNumber.Set(aSubject.SerialNumber());
+	}
+
+
+COCSPCertID* COCSPCertID::NewL(const TDesC8& aBinaryData)
+	{
+	COCSPCertID* self = new (ELeave) COCSPCertID();
+	CleanupStack::PushL(self);
+	self->ConstructL(aBinaryData);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+
+void COCSPCertID::ConstructL(const TDesC8& aBinaryData)
+	{
+	// Check the tag
+	TASN1DecGeneric decGen(aBinaryData);
+	decGen.InitL();
+	if (decGen.Tag() != EASN1Sequence)
+		{
+		User::Leave(KErrArgument);
+		}
+
+	// Decode the sequence into 4 bits
+	TASN1DecSequence decSeq;
+	CArrayPtr<TASN1DecGeneric>* items = decSeq.DecodeDERLC(decGen, 4, 4);
+
+	// First part - the hash algorithm - check for SHA1, no more needed
+	/*
+	CX509AlgorithmIdentifier* algID = CX509AlgorithmIdentifier::NewLC(items->At(0)->Encoding());
+	if (algID->Algorithm() != ESHA1)
+		{
+		User::Leave(KErrArgument);
+		}
+	CleanupStack::PopAndDestroy(algID);
+    */
+
+	// Next parts - issuerNameHash and issuerKeyHash
+	TASN1DecOctetString decOS;
+
+	HBufC8* temp = decOS.DecodeDERL(*items->At(1));
+	iIssuerNameHash.Copy(*temp);
+	delete temp;
+
+	temp = decOS.DecodeDERL(*items->At(2));
+	iIssuerKeyHash.Copy(*temp);
+	delete temp;
+
+	// Lastly, the certificate serial number - just copy a reference to the encoded data
+	iSerialNumber.Set(items->At(3)->GetContentDER());
+
+	CleanupStack::PopAndDestroy(); // items
+	}
+
+
+// Construct ASN1 encoding object for the CertID data
+CASN1EncBase* COCSPCertID::EncoderLC() const
+	{
+	CASN1EncSequence* certID = CASN1EncSequence::NewLC();
+
+	// AlgId is a sequence, containing oid and null (both specific to SHA1)
+	CASN1EncSequence* algEnc = CASN1EncSequence::NewLC();
+	CASN1EncObjectIdentifier* algOidEnc = CASN1EncObjectIdentifier::NewLC(KSHA1);
+	algEnc->AddChildL(algOidEnc);
+	CleanupStack::Pop(); // algOidEnc, now owned by algEnc
+	CASN1EncNull* nullEnc = CASN1EncNull::NewLC();
+	algEnc->AddChildL(nullEnc);
+	CleanupStack::Pop(); // nullEnc, now owned by algEnc
+	certID->AddChildL(algEnc);
+	CleanupStack::Pop(); // algEnc, now owned by certID
+
+	// issuerNameHash
+	CASN1EncOctetString* name = CASN1EncOctetString::NewLC(iIssuerNameHash);
+	certID->AddChildL(name);
+	CleanupStack::Pop(); // name, now owned by certID
+
+	// issuerKeyHash
+	CASN1EncOctetString* issuer = CASN1EncOctetString::NewLC(iIssuerKeyHash);
+	certID->AddChildL(issuer);
+	CleanupStack::Pop(); // issuer, now owned by certID
+
+	// serialNumber
+#ifdef SYMBIAN_CRYPTO
+	RInteger serialNumber = RInteger::NewL(iSerialNumber);
+	CleanupStack::PushL(serialNumber);
+#else
+	CInteger& serialNumber = *CInteger::NewLC(iSerialNumber);
+#endif	
+	CASN1EncBigInt* snEnc = CASN1EncBigInt::NewLC(serialNumber);
+	certID->AddChildL(snEnc);
+	CleanupStack::Pop(); // snEnc, now owned by certID;
+	CleanupStack::PopAndDestroy(); // serialNumber
+
+	return certID;
+	}
+
+
+TBool COCSPCertID::operator==(const COCSPCertID& rhs) const
+	{
+	if (iIssuerNameHash == rhs.iIssuerNameHash
+		&& iIssuerKeyHash == rhs.iIssuerKeyHash
+		&& iSerialNumber == rhs.iSerialNumber)
+		{
+		return ETrue;
+		}
+	else
+		{
+		return EFalse;
+		}
+	}
+
+
+TPtrC8 COCSPCertID::SerialNumber() const
+	{
+	return iSerialNumber;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/src/response.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,111 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Methods of class representing
+*                decoded OCSP response
+*
+*/
+
+
+#include <asn1dec.h>
+#include <x509cert.h>
+#include <x500dn.h>
+
+#include "roapocsp.h"
+#include "oids.h"
+#include "certid.h"
+
+COCSPResponse::COCSPResponse()
+    {
+    }
+
+COCSPResponse::~COCSPResponse()
+    {
+    delete iArchiveCutoff;
+    iCertInfos.ResetAndDestroy();
+    }
+
+TInt COCSPResponse::CertCount() const
+    {
+    return iCertInfos.Count();
+    }
+
+COCSPResponseCertInfo* COCSPResponse::CertInfo( TUint aIndex ) const
+    {
+    return iCertInfos[aIndex];
+    }
+
+const TPtrC8 COCSPResponse::SignedDataL() const
+    {
+    return iSignedData;
+    }
+
+const TPtrC8* COCSPResponse::SigningCerts() const
+    {
+    return iSigningCerts.Length() ? &iSigningCerts : NULL;
+    }
+
+const TPtrC8* COCSPResponse::DataElementEncoding( const TUint aIndex ) const
+    {
+    const TPtrC8* result( NULL );
+
+    switch ( aIndex )
+        {
+        case ECertificateChain:
+            result = iSigningCerts.Length() ? &iSigningCerts : NULL;
+            break;
+        case ENonce:
+            result = iNonce.Length() ? &iNonce : NULL;
+            break;
+        case EResponderIDName:
+            result = iResponderIDName.Length() ? &iResponderIDName : NULL;
+            break;
+        case EResponderIDKeyHash:
+            result = iResponderIDKeyHash.Length() ? &iResponderIDKeyHash : NULL;
+            break;
+        default:
+            return NULL;
+        }
+
+    return result;
+    }
+
+void COCSPResponse::InternalizeL( RReadStream& /* aStream */)
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+TTime COCSPResponse::ProducedAt() const
+    {
+    return iProducedAt;
+    }
+
+const TTime* COCSPResponse::ArchiveCutoff() const
+    {
+    return iArchiveCutoff;
+    }
+
+TInt COCSPResponse::Find( const COCSPCertID& aCertID ) const
+    {
+    TInt count = CertCount();
+    for ( TInt index = 0; index < count; ++index )
+        {
+        const COCSPCertID& responseCertID( *CertInfo( index )->CertID() );
+        if ( responseCertID == aCertID )
+            {
+            return index;
+            }
+        }
+
+    return KErrNotFound;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/src/responsecertinfo.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,171 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#include "certid.h"
+#include "RoapOcsp.h"
+#include "RoapDef.h"
+
+#include <asn1dec.h>
+
+const TUint KGoodTag = 0;
+const TUint KRevokedTag = 1;
+const TUint KUnknownTag = 2;
+
+const TUint KNextUpdateTag = 0;
+const TUint KSingleExtensionsTag = 1;
+
+COCSPResponseCertInfo* COCSPResponseCertInfo::NewLC(CArrayPtr<TASN1DecGeneric>& items)
+	{
+	COCSPResponseCertInfo* self = new (ELeave) COCSPResponseCertInfo;
+	CleanupStack::PushL(self);
+	self->ConstructL(items);
+	return self;
+	}
+
+
+COCSPResponseCertInfo::~COCSPResponseCertInfo()
+	{
+	delete iNextUpdate;
+	delete iRevocationTime;
+	delete iCertID;
+	}
+
+
+OCSP::TResult COCSPResponseCertInfo::Status() const
+	{
+	return iStatus;
+	}
+
+
+TTime COCSPResponseCertInfo::ThisUpdate() const
+	{
+	return iThisUpdate;
+	}
+
+
+const TTime* COCSPResponseCertInfo::NextUpdate() const
+	{
+	return iNextUpdate;
+	}
+
+
+const TTime* COCSPResponseCertInfo::RevocationTime() const
+	{
+	return iRevocationTime;
+	}
+
+
+COCSPCertID* COCSPResponseCertInfo::CertID() const
+	{
+	return iCertID;
+	}
+
+
+void COCSPResponseCertInfo::ConstructL(CArrayPtr<TASN1DecGeneric>& items)
+	{
+	// The CertID
+	iCertID = COCSPCertID::NewL(items.At(0)->Encoding());
+	
+	// The cert status - implicitly tagged
+	TASN1DecGeneric& statusDec = *items.At(1);
+	switch(statusDec.Tag())
+		{
+		case KGoodTag:
+			iStatus = OCSP::EGood;
+			break;
+		case KRevokedTag:
+			{
+			iStatus = OCSP::ERevoked;
+
+			// Get revocation time
+			TASN1DecSequence seqDec;
+			CArrayPtr<TASN1DecGeneric>* revokedInfo = seqDec.DecodeDERLC(statusDec, 1, 2);
+			if (revokedInfo)
+				{
+				TASN1DecGeneric& revocationTimeDec = *revokedInfo->At(0);
+				if (revocationTimeDec.Tag() != EASN1GeneralizedTime)
+					{
+					User::Leave(OCSP::EMalformedResponse);
+					}
+
+				TASN1DecGeneralizedTime decGT;
+				iRevocationTime = new (ELeave) TTime(decGT.DecodeDERL(revocationTimeDec));
+
+				CleanupStack::PopAndDestroy();  // revokedInfo
+				}
+			break;
+			}
+		case KUnknownTag:
+			iStatus = OCSP::EUnknown;
+			break;
+		default:
+			User::Leave(OCSP::EMalformedResponse);
+		}
+		
+	// Carry on with thisUpdate
+	TASN1DecGeneralizedTime decGT;
+	iThisUpdate = decGT.DecodeDERL(*items.At(2));
+
+	// Optional bits...
+	TInt numItems = items.Count();
+	if (numItems > 3)
+		{
+		TInt nextItem = 3;
+
+		// Maybe nextUpdate is there too
+		TASN1DecGeneric& item4 = *items.At(3);
+		if (item4.Tag() == KNextUpdateTag)
+			{
+			++nextItem;
+			TASN1DecGeneralizedTime decGT;
+			TInt pos = 0;
+			iNextUpdate = new (ELeave) TTime (decGT.DecodeDERL(item4.GetContentDER(), pos));
+			}
+
+		// Check for extensions - we don't support any, but we need to leave if there are any marked 'critical'
+		if (nextItem < numItems)
+			{
+			TASN1DecGeneric& extnList = *items.At(nextItem);
+			if (extnList.Tag() == KSingleExtensionsTag)
+				{
+				// OK, we've got extensions, with an explicit tag.  Loop through them...
+				TASN1DecSequence decSeq;
+				TInt pos = 0;
+				CArrayPtr<TASN1DecGeneric>* extns = decSeq.DecodeDERLC(extnList.GetContentDER(), pos);
+				TInt numExts = extns->Count();
+				for (TInt extIndex = 0; extIndex < numExts; ++extIndex)
+					{
+					TASN1DecGeneric& ext = *extns->At(extIndex);
+					CArrayPtr<TASN1DecGeneric>* terms = decSeq.DecodeDERLC(ext);
+
+					// Check critical flag (may be absent - default value false
+					if (terms->Count() == 3)
+						{
+						TASN1DecBoolean boolDec;
+						if (boolDec.DecodeDERL(*terms->At(1)))
+							{
+							User::Leave(OCSP::EUnknownCriticalExtension);
+							}
+						}
+					CleanupStack::PopAndDestroy(); // Clean up 'terms'
+					}
+				CleanupStack::PopAndDestroy(); // Clean up 'extns'
+				}
+			}
+		}
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/roapstorage/src/responsedecoder.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,428 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  OCSP response decoder for given response
+*
+*/
+
+
+#include "responsedecoder.h"
+#include "oids.h"
+#include "RoapOcsp.h"
+#include <asn1dec.h>
+#include <x509cert.h>
+
+// Enum values in DER encoding of response status
+enum
+    {
+    ESuccessfulEncoding = 0,
+    EMalformedRequestEncoding = 1,
+    EInternalErrorEncoding = 2,
+    ETryLaterEncoding = 3,
+    ESigRequiredEncoding = 5,
+    EUnauthorisedEncoding = 6
+    };
+
+
+// Tag values in DER encoded response data
+const TUint KResponseBytesTag = 0;
+const TUint KCertificatesTag = 0;
+const TUint KVersionTag = 0;
+const TUint KResponderIDNameTag = 1;
+const TUint KReponsderIDKeyHashTag = 2;
+const TUint KResponseExtensionsTag = 1;
+
+
+COCSPResponseDecoder* COCSPResponseDecoder::NewL(const TDesC8& aEncoding)
+    {
+    COCSPResponseDecoder* self = new (ELeave) COCSPResponseDecoder;
+    CleanupStack::PushL(self);
+    self->ConstructL(aEncoding);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+
+COCSPResponseDecoder::COCSPResponseDecoder()
+    {
+    }
+
+
+COCSPResponseDecoder::~COCSPResponseDecoder()
+    {
+    delete iResponse;
+    }
+
+
+void COCSPResponseDecoder::ConstructL(const TDesC8& aEncoding)
+    {
+    iResponse = new (ELeave) COCSPResponse;
+
+    // Populate CSignedObject data members
+    iResponse->iKeyFactory = new (ELeave) TX509KeyFactory; // Unconventional class name
+    iResponse->iEncoding = aEncoding.AllocL();
+
+    TRAPD(error, DecodeOCSPResponseL(*iResponse->iEncoding));
+    if (error == KErrArgument || error == KErrNotSupported)
+        {
+        // These arise from problems parsing the data in X509 or ASN1
+        error = OCSP::EMalformedResponse;
+        }
+
+    if (error != KErrNone)
+        {
+        // Errors and our status codes go back to the client
+        delete iResponse;
+        iResponse = NULL;
+        User::Leave(error);
+        }
+    }
+
+
+COCSPResponse* COCSPResponseDecoder::TakeResponse()
+    {
+    COCSPResponse* result = iResponse;
+    iResponse = NULL;
+    return result;
+    }
+
+
+CArrayPtr<TASN1DecGeneric>* COCSPResponseDecoder::DecodeSequenceLC(const TDesC8& aEncoding)
+    {
+    CArrayPtr<TASN1DecGeneric>* items = NULL;
+
+    // Check we've got a sequence
+    TASN1DecGeneric decGen(aEncoding);
+    decGen.InitL();
+    if (decGen.Tag() != EASN1Sequence)
+        {
+        User::Leave(KErrArgument);
+        }
+    else
+        {
+        // Decode the sequence
+        TASN1DecSequence decSeq;
+        items = decSeq.DecodeDERLC(decGen);
+        }
+    return items;
+    }
+
+
+CArrayPtr<TASN1DecGeneric>* COCSPResponseDecoder::DecodeSequenceLC(const TDesC8& aEncoding,
+                                                            const TInt aMinTerms,
+                                                            const TInt aMaxTerms)
+    {
+    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding);
+    TInt count = items->Count();
+    if (count < aMinTerms || count > aMaxTerms)
+        {
+        // User::Leave(KErrArgument);
+        }
+
+    return items;
+    }
+
+
+void COCSPResponseDecoder::DecodeOCSPResponseL(const TDesC8& aEncoding)
+    {
+    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding, 1, 2);
+
+    // Use integer decoding for enumerated
+    TASN1DecInteger decInt;
+    TInt status = decInt.DecodeDERShortL(*items->At(0));
+    if (status == ESuccessfulEncoding)
+        {
+        if (items->Count() != 2)
+            {
+            User::Leave(OCSP::EMalformedResponse);
+            }
+
+        // Check tag on second part is [0]
+        // We ignore any other parts in the sequence after that
+        TASN1DecGeneric& responseBytesDec = *items->At(1);
+        if (responseBytesDec.Tag() != KResponseBytesTag)
+            {
+            User::Leave(OCSP::EMalformedResponse);
+            }
+
+        // It's OK, so decode the response bytes object therein
+        DecodeResponseBytesL(responseBytesDec.GetContentDER());
+        }
+    else
+        {
+        if (items->Count() != 1)
+            {
+            User::Leave(KErrArgument);
+            }
+
+        switch (status)
+            {
+            case EMalformedRequestEncoding:
+                User::Leave(OCSP::EMalformedRequest);
+            case EInternalErrorEncoding:
+                User::Leave(OCSP::EServerInternalError);
+                break;
+            case ETryLaterEncoding:
+                User::Leave(OCSP::ETryLater);
+                break;
+            case ESigRequiredEncoding:
+                User::Leave(OCSP::ESignatureRequired);
+                break;
+            case EUnauthorisedEncoding:
+                User::Leave(OCSP::EClientUnauthorised);
+                break;
+            default:
+                User::Leave(OCSP::EMalformedResponse);
+            }
+        }
+        CleanupStack::PopAndDestroy(items);
+    }
+
+
+void COCSPResponseDecoder::DecodeResponseBytesL(const TDesC8& aEncoding)
+    {
+    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding, 2, 2);
+
+    TASN1DecObjectIdentifier decOid;
+    HBufC* oid = decOid.DecodeDERL(*items->At(0));
+    CleanupStack::PushL(oid);
+    if (*oid != KOCSPOidBasic)
+        {
+        User::Leave(OCSP::EUnknownResponseType);
+        }
+
+    TASN1DecGeneric& response = *items->At(1);
+    if (response.Tag() != EASN1OctetString)
+        {
+        User::Leave(OCSP::EMalformedResponse);
+        }
+
+    DecodeBasicOCSPResponseL(response.GetContentDER());
+
+    CleanupStack::PopAndDestroy(2, items); // oid, items
+    }
+
+
+void COCSPResponseDecoder::DecodeBasicOCSPResponseL(const TDesC8& aEncoding)
+    {
+    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding, 3, 4);
+
+    // First, the ResponseData object
+    DecodeResponseDataL(items->At(0)->Encoding());
+
+    // Continue, with the AlgorithmIdentifier
+    iResponse->iSigningAlgorithm = CX509SigningAlgorithmIdentifier::NewL(items->At(1)->Encoding());
+
+    // Now move on to the signature
+    TASN1DecBitString encBS;
+    iResponse->iSignature = encBS.ExtractOctetStringL(*items->At(2));
+
+    // And finally, the certs (if they're there)
+    if (items->Count() == 4)
+        {
+        // Check explicit tag [0]
+        TASN1DecGeneric& certsDec = *items->At(3);
+        if (certsDec.Tag() != KCertificatesTag)
+            {
+            User::Leave(OCSP::EMalformedResponse);
+            }
+
+        // It's OK, so decode the response bytes object therein
+        DecodeCertificatesL(certsDec.GetContentDER());
+        }
+
+    CleanupStack::PopAndDestroy(items);
+    }
+
+
+void COCSPResponseDecoder::DecodeCertificatesL(const TDesC8& aEncoding)
+    {
+    TASN1DecGeneric dec(aEncoding);
+    dec.InitL();
+    if (dec.Tag() != EASN1Sequence)
+        {
+        User::Leave(OCSP::EMalformedResponse);
+        }
+
+    // Just stores a reference to the encoding
+    iResponse->iSigningCerts.Set(dec.GetContentDER());
+    }
+
+
+void COCSPResponseDecoder::DecodeResponseDataL(const TDesC8& aEncoding)
+    {
+    TInt index = 0;
+
+    // This is the signed data
+    iResponse->iSignedData.Set(aEncoding);
+
+    // Exclude 5 items in sequence - defaulted version v1 shouldn't appear in DER
+    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding, 3, 4);
+
+    // First item is responderID choice, or maybe version
+    TASN1DecGeneric& item0 = *items->At(index); // index = 0
+
+    ++index;
+
+    switch (item0.Tag())
+        {
+        case KResponderIDNameTag:
+            // Set to Name DER encoding
+            iResponse->iResponderIDName.Set(item0.GetContentDER());
+            break;
+        case KReponsderIDKeyHashTag:
+            {
+            // Set to KeyHash to value within the octet string
+            TASN1DecGeneric decGen(item0.GetContentDER());
+            decGen.InitL();
+            iResponse->iResponderIDKeyHash.Set(decGen.GetContentDER());
+            break;
+            }
+        case KVersionTag:
+            {
+            // skip the version, the next one should be responderID
+            TASN1DecGeneric item1 = *items->At(index); // index = 1
+            ++index;
+            if (item1.Tag() == KResponderIDNameTag)
+                {
+                iResponse->iResponderIDName.Set(item1.GetContentDER());
+                break;
+                }
+            else if (item1.Tag() == KReponsderIDKeyHashTag)
+                {
+                TASN1DecGeneric decGen(item1.GetContentDER());
+                decGen.InitL();
+                iResponse->iResponderIDKeyHash.Set(decGen.GetContentDER());
+                break;
+                }
+            else
+                {
+                // falling through...
+                }
+            }
+        default:
+            User::Leave(OCSP::EMalformedResponse);
+        }
+
+
+    // ProducedAt is a GeneralizedTime
+    TASN1DecGeneralizedTime decGT;
+    iResponse->iProducedAt = decGT.DecodeDERL(*items->At(index)); // index = 1 | 2
+    ++index;
+
+    // Now the responses themselves
+    DecodeResponsesL(items->At(index)->Encoding()); // index = 2 | 3
+    ++index;
+
+    // Continue if extensions exist
+    if (items->Count() == index + 1) // index = 3 | 4
+        {
+        // Check tag on responseExtensions
+        TASN1DecGeneric& item3 = *items->At(index);
+        if (item3.Tag() != KResponseExtensionsTag)
+            {
+            User::Leave(OCSP::EMalformedResponse);
+            }
+
+        DecodeResponseExtensionsL(item3.GetContentDER());
+        }
+    CleanupStack::PopAndDestroy(items);
+    }
+
+
+void COCSPResponseDecoder::DecodeResponseExtensionsL(const TDesC8& aEncoding)
+    {
+    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding);
+    TInt count = items->Count();
+    for (TInt index = 0; index < count; ++index)
+        {
+        DecodeResponseExtensionL(items->At(index)->Encoding());
+        }
+
+    CleanupStack::PopAndDestroy(items);
+    }
+
+
+void COCSPResponseDecoder::DecodeResponseExtensionL(const TDesC8& aEncoding)
+    {
+    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding, 2, 3);
+
+    // Get oid
+    TASN1DecGeneric& oid = *items->At(0);
+    if (oid.Tag() != EASN1ObjectIdentifier)
+        {
+        User::Leave(OCSP::EMalformedResponse);
+        }
+
+    TASN1DecObjectIdentifier oidDec;
+    HBufC* oidVal = oidDec.DecodeDERL(oid);
+    CleanupStack::PushL(oidVal);
+
+    TBool critical = EFalse; // Default value of critical flag
+    if (items->Count() == 3)
+        {
+        // The critical flag is specified - what does it say?
+        TASN1DecBoolean decBool;
+        critical = decBool.DecodeDERL(*items->At(1));
+        }
+
+    TASN1DecGeneric& extnVal = items->Count() == 3 ? *items->At(2) : *items->At(1);
+    if (extnVal.Tag() != EASN1OctetString)
+        {
+        User::Leave(OCSP::EMalformedResponse);
+        }
+
+    // Check oid to decide what to do
+    if (*oidVal == KOCSPOidNonce)
+        {
+        iResponse->iNonce.Set(extnVal.GetContentDER());
+        }
+    else if (*oidVal == KOCSPOidArchiveCutoff)
+        {
+        TASN1DecGeneralizedTime decGT;
+        TInt pos = 0;
+        iResponse->iArchiveCutoff = new (ELeave) TTime(decGT.DecodeDERL(extnVal.GetContentDER(), pos));
+        }
+    else if (critical)
+        {
+        // Didn't understand extension, and it was critical!  Erk!
+        User::Leave(OCSP::EUnknownCriticalExtension);
+        }
+
+    CleanupStack::PopAndDestroy(2, items); // oidVal, items
+    }
+
+
+void COCSPResponseDecoder::DecodeResponsesL(const TDesC8& aEncoding)
+    {
+    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding);
+    TInt count = items->Count();
+    for (TInt index = 0; index < count; ++index)
+        {
+        DecodeSingleResponseL(items->At(index)->Encoding());
+        }
+
+    CleanupStack::PopAndDestroy(items);
+    }
+
+
+void COCSPResponseDecoder::DecodeSingleResponseL(const TDesC8& aEncoding)
+    {
+    CArrayPtr<TASN1DecGeneric>* items = DecodeSequenceLC(aEncoding, 3, 5);
+
+    COCSPResponseCertInfo* response = COCSPResponseCertInfo::NewLC(*items);
+    User::LeaveIfError(iResponse->iCertInfos.Append(response));
+    CleanupStack::Pop(response); // Now owned through iSingleResponses
+
+    CleanupStack::PopAndDestroy(items);
+    }
Binary file omadrm/drmengine/server/data/101F51F2.exc has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMActiveDeletion.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,140 @@
+/*
+* 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:  Active object handling "Delete Expired Permission"
+*
+*/
+
+
+#ifndef DRMACTIVEDELETION_H
+#define DRMACTIVEDELETION_H
+
+// INCLUDES
+
+#include <e32base.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class CDRMRightsDB;
+class CDRMDbSession;                                                         
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMActiveDeletion implements expired rights cleanup callback
+*  for drm rights database
+*
+*  @lib RightsServer.exe
+*  @since 3.0
+*/
+NONSHARABLE_CLASS( CDRMActiveDeletion ) : public CActive
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMRightCleaner class and returns a pointer
+        * to it
+        *
+        * @since    3.0
+        * @param    aFs : Open file server session
+        * @param    aDatabase : CDRMRightsDB object
+        * @param    aStatus : The request status to complete when the operation is 
+        *                     fully done
+        * @param    aDatabasePath : full pathname of the database path
+        * @param    aTime : Time to check expiration against 
+        *
+        * @return   Functional CDRMActiveDeletion object, Function leaves if an error
+        *           occurs.
+        */
+        static CDRMActiveDeletion* NewLC( const RMessagePtr2& aMessage,
+                                          CDRMDbSession& aSession );
+          
+        /**
+        * Destructor
+        */
+        virtual ~CDRMActiveDeletion();
+
+    public: // New functions    
+
+        /**
+        * ActivateL
+        * 
+        * Activates the object by adding it to scheduler etc.
+        *
+        * @since    3.0
+        * @return   None
+        *
+        */      
+        void ActivateL( const TTime& aSecureTime,
+                        CDRMRightsDB& aDb );
+         
+    protected:
+    
+        /**
+        * Default Constructor - First phase.
+        */
+        CDRMActiveDeletion( const RMessagePtr2& aMessage,
+                            CDRMDbSession& aSession ); 
+        
+        /**
+        * From CActive: RunL.
+        */
+        void RunL();
+
+        /**
+        * From CActive: DoCancel performs cancel
+        */        
+        void DoCancel();
+      
+        /**
+        * From CActive: RunError checks the errors from RunL.
+        */
+        // void RunError();                        
+                        
+    private:
+        /**
+        * Default Constructor - First phase. Prevented.
+        */
+        CDRMActiveDeletion(); 
+    
+        /**
+        * Assignment operator - Prevented
+        */
+        CDRMActiveDeletion& operator =( const CDRMActiveDeletion& );    
+    
+        /**
+        * Copy constructor - Prevented
+        */
+        CDRMActiveDeletion( const CDRMActiveDeletion& );                
+     
+    private:
+        // The message.
+        const RMessagePtr2& iMessage;
+        CDRMDbSession& iSession;
+    
+        // The instane doing the deletion.
+        CActive* iActiveOperation;
+    };
+
+#endif      // DRMACTIVEDELETION_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMActiveOperation.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,177 @@
+/*
+* 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:  Active object handling "Delete Expired Permission"
+*
+*/
+
+
+#ifndef DRMACTIVEOPERATION_H
+#define DRMACTIVEOPERATION_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <s32file.h>
+
+// CONSTANTS
+
+const TInt KOperationDeleteExpired  = 1;
+const TInt KOperationExportObsolete = 2;
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class CDRMRightsDB;
+class CDRMDbSession;
+class RFs;
+                                                     
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMActiveOperation implements active objects for
+*  for drm rights server
+*
+*  @lib RightsServer.exe
+*  @since 3.0
+*/
+NONSHARABLE_CLASS( CDRMActiveOperation ) : public CActive
+    {
+    public: // Typedefs
+    typedef enum 
+        {
+        EOperationNone = 0,
+        EOperationDeleteExpired  = 1,
+        EOperationExportObsolete = 2    
+        } TOperationType;
+    
+    public: // Constructors and destructor
+        
+        /**
+        * NewLC
+        *
+        * Creates an instance of CDRMActiveOperation class and returns a pointer to it
+        * also leaves the object to the cleanup stack
+        *
+        * @since    3.0
+        * @param    aMessage: the asynchronous message
+        * @param    aSession : Session this operation is connected to
+        * @param    aOperation : The operation to perform
+        * @return   Functional CDRMActiveOperation object, Function leaves if an error
+        *           occurs.
+        */
+        static CDRMActiveOperation* NewLC( const RMessagePtr2& aMessage,
+                                          CDRMDbSession& aSession,
+                                          TOperationType aOperation );
+          
+        /**
+        * Destructor
+        */
+        virtual ~CDRMActiveOperation();
+
+    public: // New functions    
+
+        /**
+        * ActivateL
+        * 
+        * Activates the object by adding it to scheduler etc.
+        *
+        * @since    3.0
+        * @return   None
+        *
+        */      
+        void ActivateL( CDRMRightsDB& aDb,
+                        const TTime& aSecureTime );
+
+
+        /**
+        * ActivateL
+        * 
+        * Activates the object by adding it to scheduler etc.
+        *
+        * @since    3.0
+        * @return   None
+        *
+        */      
+        void ActivateL( CDRMRightsDB& aDb,
+                        RFs& aFileServer,
+                        const TDesC& aTempPath, 
+                        const TBool aPerformScan = EFalse );
+         
+         
+        void Remove(); 
+    protected:
+    
+        /**
+        * Default Constructor - First phase.
+        */
+        CDRMActiveOperation( const RMessagePtr2& aMessage,
+                            CDRMDbSession& aSession,
+                            TOperationType aOperation ); 
+        
+        /**
+        * From CActive: RunL.
+        */
+        void RunL();
+
+        /**
+        * From CActive: DoCancel performs cancel
+        */        
+        void DoCancel();
+      
+        /**
+        * From CActive: RunError checks the errors from RunL.
+        */
+        // void RunError();                        
+                        
+    private:
+        /**
+        * Default Constructor - First phase. Prevented.
+        */
+        CDRMActiveOperation(); 
+    
+        /**
+        * Assignment operator - Prevented
+        */
+        CDRMActiveOperation& operator =( const CDRMActiveOperation& );    
+    
+        /**
+        * Copy constructor - Prevented
+        */
+        CDRMActiveOperation( const CDRMActiveOperation& );                
+     
+    private:
+        // The message.
+        const RMessagePtr2& iMessage;
+        CDRMDbSession& iSession;
+        
+        // The operation to perform
+        TOperationType iOperation;
+        
+        // The instance doing the operation.
+        CActive* iActiveOperation;
+        
+        // File name of the operation
+        TFileName* iFileName;
+        RFileWriteStream iFileStream;
+        RFs* iFileServer;
+    };
+
+#endif      // DRMACTIVEOPERATION_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMCommonData.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,330 @@
+/*
+* 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:  Datatype for the Common Rights Database Data
+*
+*/
+
+
+#ifndef DRMCOMMONDATA_H
+#define DRMCOMMONDATA_H
+
+// INCLUDES
+
+#include <e32base.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class RReadStream;
+class RWriteStream;
+
+// TYPE DEFINITIONS
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMCommonData implements a datatype for the common data for a single
+*  content identifier
+*
+*  @lib RightsServer.dll
+*  @since 3.0
+*/
+
+class CDRMCommonData : public CBase 
+    {
+    
+    public: // Constructors and destructor
+        
+        /**
+        * NewLC
+        *
+        * Creates an instance of the CDRMCommonData class and returns a pointer 
+        * to it. The function leaves the object into the cleanup stack
+        *
+        * @since  3.0
+        * @param  aContentID : Content Identifier
+        * @param  aContentHash : Content Hash
+        * @param  aRightsIssuer : Rights Issuer for this content
+        * @return Functional CDRMCommonData object, Function leaves if an error 
+        *         occurs.
+        */
+        static CDRMCommonData* NewLC( const TDesC8& aContentID,
+                                      const TDesC8& aContentHash,
+                                      const TDesC8& aRightsIssuer,
+                                      const TDesC& aContentName,
+                                      const TDesC8& aAuthenticationSeed );
+        
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMCommonData class and returns a pointer 
+        * to it.
+        *
+        * @since  3.0
+        * @param  aContentID : Content Identifier
+        * @param  aContentHash : Content Hash
+        * @param  aRightsIssuer : Rights Issuer for this content
+        * @return Functional CDRMCommonData object, Function leaves if an error 
+        *         occurs.
+        */
+        static CDRMCommonData* NewL( const TDesC8& aContentID,
+                                     const TDesC8& aContentHash,
+                                     const TDesC8& aRightsIssuer,
+                                     const TDesC& aContentName,
+                                     const TDesC8& aAuthenticationSeed );
+                                     
+        /**
+        * NewLC
+        *
+        * Creates an empty instance of the CDRMCommonData class and returns a pointer 
+        * to it. The function leaves the object into the cleanup stack
+        *
+        * @since  3.0
+        * @return Functional CDRMCommonData object, Function leaves if an error 
+        *         occurs.
+        */
+        static CDRMCommonData* NewLC();                                     
+                                     
+        /**
+        * NewL
+        *
+        * Creates an empty instance of the CDRMCommonData class and returns a pointer 
+        * to it.
+        *
+        * @since  3.0
+        * @return Functional CDRMCommonData object, Function leaves if an error 
+        *         occurs.
+        */
+        static CDRMCommonData* NewL();                                     
+
+          
+        /**
+        * Destructor
+        */
+        virtual ~CDRMCommonData();
+        
+        
+        /**
+        * ContentID
+        * 
+        * Returns a constant HBufC8 pointer to the content id
+        *
+        * @since    3.0
+        * @return   a pointer to the content id or null
+        */        
+        const TDesC8& ContentID() const;
+        
+        /**
+        * ContentHash
+        * 
+        * Returns a constant HBufC8 pointer to the content hash
+        *
+        * @since    3.0      
+        * @return   a pointer to the content hash or null
+        */        
+        const TDesC8& ContentHash() const;
+        
+        /**
+        * RightsIssuer
+        * 
+        * Returns a constant HBufC8 pointer to the rights issuer
+        *
+        * @since    3.0            
+        * @return   a pointer to the rights issuer or null
+        */         
+        const TDesC8& RightsIssuer() const;
+
+        /**
+        * CotentName
+        *
+        * Return a constant HBufC pointer to the content name
+        *
+        * @since    3.0
+        * @return   a pointer to the content name or null 
+        */
+        const TDesC& ContentName() const;
+
+        /**
+        * AuthenticationSeed
+        * 
+        * Returns a constant HBufC8 pointer to the authentication seed
+        *
+        * @since    3.0            
+        * @return   a pointer to the authentication seed or null
+        */         
+        const TDesC8& AuthenticationSeed() const;
+
+        /**
+        * SetContentIDL
+        * 
+        * Sets the content id, deletes the previous one if one
+        * exits
+        *
+        * @since    3.0
+        * @param    aContentID : Content Identifier        
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */        
+        void SetContentIDL( const TDesC8& aContentID );
+        
+        /**
+        * SetContentHashL
+        * 
+        * Sets the content hash, deletes the previous one if one
+        * exits
+        *
+        * @since    3.0
+        * @param    aContentHash : Content Hash             
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */        
+        void SetContentHashL( const TDesC8& aContentHash );
+        
+        /**
+        * SetRightsIssuerL
+        * 
+        * Sets the rights issuer, deletes the previous one if one
+        * exits
+        *
+        * @since    3.0
+        * @param    aRightsIssuer : Rights Issuer for this content         
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */         
+        void SetRightsIssuerL( const TDesC8& aRightsIssuer );
+        
+        
+        /**
+        * SetContentNameL
+        *
+        * Sets the content name, deletes the previous one if it exists
+        *
+        * @since    3.0
+        * @param    aContentName : The name that is given to the content
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void SetContentNameL( const TDesC& aContentName );
+
+        /**
+        * SetAuthenticationSeedL
+        * 
+        * Sets the authentication seed, deletes the previous one if one
+        * exits
+        *
+        * @since    3.0
+        * @param    aAuthenticationSeed : Rights Issuer for this content         
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */         
+        void SetAuthenticationSeedL( const TDesC8& aAuthenticationSeed );
+
+        
+        /**
+        * ExternalizeL
+        * 
+        * Writes the data of the object into the stream
+        *
+        * @since    3.0
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void ExternalizeL( RWriteStream& aStream ) const;
+        
+        /**
+        * InternalizeL
+        * 
+        * Reads the data of the object from the stream
+        *
+        * @since    3.0
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void InternalizeL( RReadStream& aStream );   
+       
+        
+        /**
+        * Size
+        *
+        * Returns the size of the externalized object
+        *
+        * @since    3.0
+        * @return   the amount of bytes the externalize object occupies
+        */           
+        TInt Size() const;
+        
+    private:
+        /**
+        * Default Constructor - First phase.
+        */
+        CDRMCommonData(); 
+    
+        /**
+        * ConstructL
+        *
+        * Second phase constructor
+        *
+        * @since  3.0
+        * @param  aContentID : Content Identifier
+        * @param  aContentHash : Content Hash
+        * @param  aRightsIssuer : Rights Issuer for this content
+        * @return Functional CDRMCommonData object, Function leaves if an error 
+        *         occurs.
+        */  
+        void ConstructL( const TDesC8& aContentID,
+                         const TDesC8& aContentHash,
+                         const TDesC8& aRightsIssuer,
+                         const TDesC& aContentName,
+                         const TDesC8& aAuthenticationSeed );
+
+        /**
+        * Assignment operator - Prevented
+        */
+        CDRMCommonData& operator =( const CDRMCommonData& );    
+    
+        /**
+        * Copy constructor - Prevented
+        */
+        CDRMCommonData( const CDRMCommonData& );                
+
+
+    private: // Internal Data
+    
+        // Content identifier of the content
+        HBufC8* iContentID;
+        
+        // Hash of the content DCF
+        HBufC8* iContentHash;
+        
+        // Issuer of the rights
+        HBufC8* iRightsIssuer;
+        
+        // Content name
+        HBufC* iContentName;
+        
+        // Authentication seed
+        HBufC8* iAuthenticationSeed;
+    };
+
+#endif      // DRMCOMMONDATA_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMContextDB.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,451 @@
+/*
+* 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:  Datatype for Rights Constraint
+*
+*/
+
+
+#ifndef DRMCONTEXTDB_H
+#define DRMCONTEXTDB_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <hash.h>
+
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class CDRMRIContext;
+class CDRMDomainContext;
+class CPermanentFileStore;
+class RWriteStream;
+class TStreamId;
+
+// TYPE DEFINITIONS
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMContextDB implements the rights database required by DRM Engine
+*
+*  @lib RightsServer.dll
+*  @since 3.0
+*/
+
+NONSHARABLE_CLASS( CDRMContextDB ) : public CBase 
+    {
+public: // Constructors and destructor
+
+    /**
+    * NewLC
+    *
+    * Creates an instance of the CDRMContextDB class and returns a pointer 
+    * to it. The function leaves the object into the cleanup stack
+    *
+    * @since    3.0
+    * @param    aRightsIssuerContextFile : Full pathname of the ri context file
+    * @param    aDomainContextFile : Full pathname of the domain context file
+    * @param    aFileServer : File server instance to use
+    * @return   Functional CDRMContextDB object, Function leaves if an error 
+    *           occurs.
+    */
+    static CDRMContextDB* NewLC( const TFileName& aRightsIssuerContextFile, 
+                                 const TFileName& aDomainContextFile,
+                                 RFs& aFileServer );
+    
+    /**
+    * NewL
+    *
+    * Creates an instance of the CDRMContextDB class and returns a pointer 
+    * to it.
+    *
+    * @since    3.0
+    * @param    aRightsIssuerContextFile : Full pathname of the ri context file
+    * @param    aDomainContextFile : Full pathname of the domain context file
+    * @param    aFileServer : File server instance to use   
+    * @return   Functional CDRMContextDB object, Function leaves if an error 
+    *           occurs.
+    */
+    static CDRMContextDB* NewL( const TFileName& aRightsIssuerContextFile, 
+                                const TFileName& aDomainContextFile,
+                                RFs& aFileServer );
+    /**
+    * OpenLC
+    *
+    * Opens the store and creates an instance of the CDRMContextDB class and returns
+    * a pointer to it. The function leaves the object into the cleanup stack
+    *
+    * @since    3.0
+    * @param    aRightsIssuerContextFile : Full pathname of the ri context file
+    * @param    aDomainContextFile : Full pathname of the domain context file
+    * @param    aFileServer : File server instance to use     
+    * @return   Functional CDRMContextDB object, Function leaves if an error 
+    *           occurs.
+    */
+    static CDRMContextDB* OpenLC( const TFileName& aRightsIssuerContextFile, 
+                                  const TFileName& aDomainContextFile,
+                                  RFs& aFileServer );
+    /**
+    * OpenL
+    *
+    * Opens the store and creates an instance of the CDRMContextDB class and returns
+    * a pointer to it.
+    *
+    * @since    3.0
+    * @param    aRightsIssuerContextFile : Full pathname of the ri context file
+    * @param    aDomainContextFile : Full pathname of the domain context file
+    * @param    aFileServer : File server instance to use      
+    * @return   Functional CDRMContextDB object, Function leaves if an error 
+    *           occurs.
+    */
+    static CDRMContextDB* OpenL( const TFileName& aRightsIssuerContextFile, 
+                                 const TFileName& aDomainContextFile,
+                                 RFs& aFileServer );
+
+    /*
+    * Destructor
+    */ 
+    virtual ~CDRMContextDB(); 
+
+
+public: // New functions
+     
+    
+    /**
+    * StoreDomainContextL
+    * 
+    * Writes the data of the domain context to the stream store
+    *
+    * @since    3.0
+    * @param    aContext : CDRMDomainContext class to externalize
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void StoreDomainContextL( const CDRMDomainContext& aContext );    
+    
+    /**
+    * FetchDomainContextL
+    * 
+    * Reads the data of the object from the stream store
+    *
+    * @since    3.0
+    * @param    aContext : a CDRMDomainContext class to internalize to
+    *                      with the domain id set to the requested id
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void FetchDomainContextL( CDRMDomainContext& aContext ) const;
+    
+    /**
+    * FetchDomainContextL
+    * 
+    * Reads the data of the object from the stream
+    *
+    * @since    3.0
+    * @param    aContext : a CDRMDomainContext class to internalize to
+    *                      with the domain id set to the requested id
+    * @param    aStream : stream to read from
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void FetchDomainContextL( CDRMDomainContext& aContext, 
+                              const TInt32& aStream ) const;    
+
+    /**
+    * DeleteDomainContextL
+    * 
+    * Deletes the data of the object from the stream store
+    *
+    * @since    3.0
+    * @param    aDomainID : the domain to delete
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void DeleteDomainContextL( const TDesC8& aDomainID );
+
+
+    /**
+    * StoreRightsIssuerContextL
+    * 
+    * Writes the data of the rights issuer context to the stream store
+    *
+    * @since    3.0
+    * @param    aPermission : CDRMPermission class to externalize
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void StoreRightsIssuerContextL( const CDRMRIContext& aContext );    
+    
+    /**
+    * FetchRightsIssuerContextL
+    * 
+    * Reads the data of the object from the stream store
+    *
+    * @since    3.0
+    * @param    aContext : a CDRMRightsIssuerContext class to internalize to
+    *                      with the domain id set to the requested id
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void FetchRightsIssuerContextL( CDRMRIContext& aContext ) const;
+
+    /**
+    * FetchRightsIssuerContextL
+    * 
+    * Reads the data of the object from the stream
+    *
+    * @since    3.0
+    * @param    aContext : a CDRMRightsIssuerContext class to internalize to
+    *                      with the domain id set to the requested id
+    * @param    aStream : stream to read from
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void FetchRightsIssuerContextL( CDRMRIContext& aContext, 
+                                    const TInt32& aStream ) const;
+    /**
+    * DeleteRightsIssuerContextL
+    * 
+    * Deletes the data of the object from the stream store
+    *
+    * @since    3.0
+    * @param    aRightsIssuerID : the rights issuer to delete
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void DeleteRightsIssuerContextL( const TDesC8& aRightsIssuerID );
+
+                           
+    /**
+    * WhiteListURLExistsL
+    * 
+    * Goes through all the Rights Issuer contexts and checks if the given URL
+    * is in one of them.
+    *
+    * @since    3.0
+    * @param    aPointerArray : return value pointer array of the permissions
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    TBool WhiteListURLExistsL( const TDesC8& aRightsIssuerURL );
+
+    
+    /**
+    * DeleteExpiredDomainContextsL
+    * 
+    * Deletes the expired domain contexts
+    *
+    * @since    3.0
+    * @param    aTime : the reference time, all contexts before this time will be
+    *                   deleted
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void DeleteExpiredDomainContextsL( const TTime& aTime );
+ 
+ 
+    /**
+    * DeleteExpiredRightsIssuerContextsL
+    * 
+    * Deletes the expired domain contexts
+    *
+    * @since    3.0
+    * @param    aTime : the reference time, all contexts before this time will be
+    *                   deleted
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void DeleteExpiredRightsIssuerContextsL( const TTime& aTime );
+    
+    /**
+    *
+    * DeleteAllL
+    *
+    * Deletes all stored RI and Domain contexts
+    *
+    * @since    3.0
+    * @param    aRightsIssuerContextFile: Full pathname of the ri context file
+    * @param    aDomainContextFile: Full pathname of the domain context file
+    *
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    *
+    */
+    void DeleteAllL( const TFileName& aRightsIssuerContextFile, 
+                     const TFileName& aDomainContextFile );
+
+    /**
+    *
+    * FetchAllRightsIssuerContextsL
+    *
+    * Retrieves all stored RI contexts in a pointer array
+    *
+    * @since    3.2
+    * @param    aContexts: RPointerArray for storage of the RI contexts
+    *
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    *
+    */
+    void FetchAllRightsIssuerContextsL( RPointerArray<CDRMRIContext>& aContexts) const;
+
+    /**
+    *
+    * UpdateRightsIssuerContextL
+    *
+    * Updates the metering status of the RI context
+    *
+    * @since    3.2
+    * @param    aContext: The RI context which has the updated data
+    *
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    *
+    */
+    void UpdateRightsIssuerContextL( const CDRMRIContext& aContext );  
+
+private:
+
+    /**
+    * CreateAndInitializeRIStoreL
+    * 
+    * Writes the data of index into the store root
+    *
+    * @since    3.0
+    * @param    aRightsStore : Full path filename of the ri context store    
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void CreateAndInitializeRIStoreL( const TFileName& aRIStore );
+
+    /**
+    * CreateAndInitializeDomainStoreL
+    * 
+    * Writes the data of index into the store root
+    *
+    * @since    3.0
+    * @param    aRightsStore : Full path filename of the domain context store    
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void CreateAndInitializeDomainStoreL( const TFileName& aDomainStore );
+
+    /**
+    * StoreDomainIndexL
+    * 
+    * Writes the data of index into the store root
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void StoreDomainIndexL( RWriteStream& aStream ) const;
+    
+    /**
+    * FetchDomainIndexL
+    * 
+    * Reads the data of the index from the store root
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void FetchDomainIndexL();
+
+    /**
+    * StoreRightsIssuerIndexL
+    * 
+    * Writes the data of index into the store root
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void StoreRightsIssuerIndexL( RWriteStream& aStream ) const;
+    
+    /**
+    * FetchRightsIssuerIndexL
+    * 
+    * Reads the data of the index from the store root
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void FetchRightsIssuerIndexL();
+    
+    /*
+    * Default Constructor
+    */ 
+    CDRMContextDB( RFs& aFileServer );
+
+    /*
+    * 2nd phase Constructor
+    *
+    * @param    aRightsStore : Full path filename of the rights store
+    */ 
+    void ConstructL( const TFileName& aRightsIssuerContextFile, 
+                     const TFileName& aDomainContextFile );
+
+private:
+
+    NONSHARABLE_CLASS( TContextIndex )
+        {
+    public:
+        
+        TBuf8<SHA1_HASH> iContextID;
+        TInt32 iStreamID;
+        
+        static TInt Compare( const TContextIndex& aFirst,
+                             const TContextIndex& aSecond )
+            {
+            return aFirst.iContextID.Compare( aSecond.iContextID );
+            };
+            
+        static TBool Match( const TContextIndex& aFirst,
+                            const TContextIndex& aSecond )
+            {
+            if( aFirst.iContextID.Compare( aSecond.iContextID ) )
+                {
+                return EFalse;
+                }
+            return ETrue;    
+            };    
+            
+        };
+
+    RFs& iFileServer;
+
+    // File stores
+    CPermanentFileStore* iDomainStore;
+    CPermanentFileStore* iRightsIssuerStore;
+    
+    // Index arrays
+    RArray<TContextIndex> iDomainArray;
+    RArray<TContextIndex> iRightsIssuerArray;
+   
+    // Some index data
+    };
+
+#endif      // DRMCONTEXTDB_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMDbSession.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,696 @@
+/*
+* Copyright (c) 2003-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:  This class declares the interface of class CDRMDbSession.
+*
+*/
+
+
+#ifndef CDRMDBSESSION_H
+#define CDRMDBSESSION_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <caf/caf.h>
+#include "DRMTypes.h"
+#include "DRMConstraint.h"
+#include "DRMEngineClientServer.h"
+#include "drmcommonclientserver.h"
+#include "drmenginetypedefs.h"
+#include "roapstorageclient.h"
+
+// CONSTANTS
+// MACROS
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CDRMParentStorage;
+
+class CDRMConsume;
+class CDRMPermission;
+class CDRMNotifier;
+class CDRMObsoleteFinder;
+
+// DATA TYPES
+// CLASS DECLARATION
+
+/**
+*  Server side instance of DRM Rights Database session.
+*  This class is the server side instance of C/S communications of a certain
+*  session.
+*
+*  @lib RightsServer.exe
+*  @since S60Rel2.5
+*/
+NONSHARABLE_CLASS( CDRMDbSession ) : public CSession2
+    {
+public:  // Constructors and destructor
+
+    /**
+    * Two-phased constructor.
+    * @since S60Rel2.6
+    * @return New session instance.
+    */
+    static CDRMDbSession* NewL();
+
+   /**
+    * Destructor.
+    * @since S60Rel2.5
+    */
+   virtual ~CDRMDbSession();
+
+public: // Functions from base classes
+
+    /**
+    * From CSession2: Handles the service request event.
+    * @since S60Rel2.6
+    * @param aMessage The message related to the event.
+    * @exception Method leaves with appropriate exception value
+    *            if any errors occured.
+    */
+    void ServiceL( const RMessage2& aMessage );
+
+    /**
+    * From CSession2: Handles the errors from ServiceL if encountered.
+    * @since S60Rel3.0
+    * @param aMessage The message related to the event.
+    * @param aError   Error code.
+    */
+    virtual void ServiceError( const RMessage2& aMessage,
+                               TInt aError );
+
+public: // New functions
+
+   void AsyncOperationDone();
+
+   void AsyncOperationDone( TFileName* aFileName );
+
+    /**
+    * This method tries to find a suitable rights object
+    * from the given list which allows the specified intent.
+    * @since S60Rel3.0
+    * @param aIntent Intent.
+    * @param aRights List of rights objects.
+    * @param aParent Out-parameter: related parent permission. The caller
+    *                owns the parent.
+    * @param aUpdate Out-parameter: whether to update the rights object
+    * (if one is found).
+    * @return Symbian error or CAF error. KErrNone if everything goes
+    *         properly
+    */
+    TInt FindRightsObject( const ContentAccess::TIntent aIntent,
+                           const TDesC8& aURI,
+                           CDRMPermission*& aChild,
+                           HBufC8*& aUsedURI,
+                           TUint32& aReason );
+
+    /**
+    * Check whether the identified permission allows the caller to get
+    * decrypted data. Enforces e.g. capability checking
+    *
+    * @param aContentId Content ID of the content, can be NULL
+    * @param aPermission Permission which grants access, can be NULL
+    * @param aIntent Consumption intent
+    * @return KErrAccessDenied if the caller does not have sufficient
+    *         credentials, KErrNone if access is granted, or other
+    *         Symbian errors
+    */
+    TInt VerifyCredentials( HBufC8* aContentId,
+                            CDRMPermission* aPermission,
+                            TIntent aIntent );
+
+    /**
+    * Return the SID of the client
+    * @return SID of the client
+    */
+    TUid GetClientSid();
+
+    /**
+    * Return the VID of the client
+    * @return VID of the client
+    */
+    TUid GetClientVid();
+
+    /**
+    * Return if the client has sufficient DRM capability
+    * @return ETrue if the capability is available, EFalse otherwise
+    */
+    TBool ClientHasCapability();
+
+    /**
+    * This method returns handle to the Roap storage client.
+    *
+    * @since S60 3.2
+    * @return Handle to the Roap storage client
+    */
+    Roap::RRoapStorageClient& RoapClient();
+
+    /**
+    * This method connects the roap client, does nothing if it's already connected
+    *
+    * @since S60 3.2
+    * @return Handle to the Roap storage client
+    */
+    TInt ConnectRoapClient();
+
+protected:  // New functions
+
+protected:  // Functions from base classes
+
+private:
+
+    enum TProtectionType
+        {
+        ENoProtection,
+        EPublicKey,
+        EDomainKey,
+        };
+
+    enum TCredentialsCheckType
+        {
+        ENotChecked,
+        ECheckedAndAllowed,
+        ECheckedAndDenied,
+        };
+
+    /**
+    * C++ constructor.
+    * @since S60Rel2.6
+    */
+    CDRMDbSession();
+
+    /**
+    * Second phase constructor.
+    * @since S60Rel2.6
+    */
+    void ConstructL();
+
+    /**
+    * Helper function for ServiceL().
+    * @since S60Rel2.5
+    * @param aMessage The message associated to the event.
+    */
+    void AddRecordL( const RMessage2& aMessage,
+                     TProtectionType aProtection );
+
+    /**
+    * Helper function for ServiceL().
+    * @since S60Rel2.5
+    * @param aMessage The message associated to the event.
+    */
+    void GetRecordL( const RMessage2& aMessage );
+
+    /**
+    * Helper function for ServiceL().
+    * @since S60Rel2.5
+    * @param aMessage The message associated to the event.
+    */
+    void GetEntryListL( const RMessage2& aMessage );
+
+    /**
+    * Helper function for ServiceL().
+    * @since S60Rel2.5
+    * @param aMessage The message associated to the event.
+    */
+    void DeleteL( const RMessage2& aMessage );
+
+    /**
+    * Helper function for ServiceL().
+    * @since S60Rel2.5
+    * @param aMessage The message associated to the event.
+    */
+    void DeleteRecordL( const RMessage2& aMessage );
+
+    /**
+    * Helper function for ServiceL().
+    * @since S60Rel2.5
+    * @param aMessage The message associated to the event.
+    */
+    void ExportCIDsL( const RMessage2& aMessage );
+
+    /**
+    * Helper function for ServiceL().
+    * @since S60Rel2.5
+    * @param aMessage The message associated to the event.
+    */
+    void GetKeyL( const RMessage2& aMessage );
+
+    /**
+    * Helper function for ServiceL().
+    * @since S60Rel2.5
+    * @param aMessage The message associated to the event.
+    */
+    void CheckRightsL( const RMessage2& aMessage );
+
+    /**
+    * Helper function for ServiceL().
+    * @since S60Rel2.5
+    * @param aMessage The message associated to the event.
+    */
+    void CountL( const RMessage2& aMessage );
+
+    /**
+    * Implementation of DeleteAll() command.
+    * @since 2.5
+    * @param aMessage The message associated to the event.
+    */
+    void DeleteAllL( const RMessage2& aMessage );
+
+    /**
+    * Implementation of ConsumeL() command.
+    * @since 2.5
+    * @param aMessage The message associated to the event.
+    */
+    void ConsumeL( const RMessage2& aMessage );
+
+    /**
+    * Check if Consume is possible
+    * @since 3.0
+    * @param aMessage The message associated to the event.
+    */
+    void CheckConsumeL( const RMessage2& aMessage );
+
+    /**
+    * Calculate the padding using a given data block
+    * @since 2.5
+    * @param aMessage The message associated to the event.
+    */
+    void CalculatePaddingL( const RMessage2& aMessage );
+
+    /**
+    * Give secure time & trust level to the client.
+    * @since 2.6
+    * @params aMessage The message associated to the event.
+    */
+    void SecureTimeL( const RMessage2& aMessage );
+
+    /**
+    * Encrypt data using the session key
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void EncryptL( const RMessage2& aMessage );
+
+    /**
+    * Decrypt data using the session key
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void DecryptL( const RMessage2& aMessage );
+
+    /**
+    * Initialize the session key
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void InitializeKeyL( const RMessage2& aMessage );
+
+    /**
+    * Initialize the session key from a group key
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void InitializeGroupKeyL( const RMessage2& aMessage );
+
+    /**
+    * Return the prepared data to the client.
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void GetPreparedDataL( const RMessage2& aMessage );
+
+    /**
+    * Return the prepared data to the client.
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void AddDomainROL( const RMessage2& aMessage );
+
+    /**
+    * Return the prepared data to the client.
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void GetDomainROL( const RMessage2& aMessage );
+
+    /**
+    * Return the prepared data to the client.
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void DeleteDomainROL( const RMessage2& aMessage );
+
+    /**
+    * Return the domain RO for a given content ID.
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void GetDomainRosForCidL( const RMessage2& aMessage );
+
+    /**
+    * Check whether the RO is in Replay Cache.
+    * @since 3.0
+    * @pareams aMessage The message associated to the event.
+    */
+    void IsInCacheL( const RMessage2& aMessage );
+
+    /**
+    * Add the RO entry to Replay Cache.
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void AddToCacheL( const RMessage2& aMessage );
+
+    /**
+    * Delete expired permission if we have secure time.
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void DeleteExpiredPermissionsL( const RMessage2& aMessage );
+
+    /**
+    * Sets the estimated arrival for a Content URI
+    * @since 2.6
+    * @params aMessage The message associated to the event.
+    */
+    void SetEstimatedArrivalL( const RMessage2& aMessage );
+
+    /**
+    * Gets the estimated arrival for a Content URI
+    * @since 2.6
+    * @params aMessage The message associated to the event.
+    */
+    void GetEstimatedArrivalL( const RMessage2& aMessage );
+
+    /**
+    * Gets the udt data
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void GetUdtDataL( const RMessage2& aMessage );
+
+    /**
+    * Initiates the UDT
+    * @since 3.0
+    * @params aMessage The message associated to the event.
+    */
+    void InitiateUdtL( const RMessage2& aMessage );
+
+    /**
+    * Helper function for ServiceL().
+    * @since 3.0
+    * @param aMessage The message associated to the event.
+    */
+    void InitExportOrphanedCIDsL( const RMessage2& aMessage );
+
+    /**
+    * Helper function for ServiceL().
+    * @since 3.0
+    * @param aMessage The message associated to the event.
+    */
+    void ExportOrphanedCIDsL( const RMessage2& aMessage );
+
+    /**
+    * Unwrap MAC and REK which are wrapped either with
+    * device public key or domain key
+    * @since 3.1
+    * @param aMessage The message associated to the event.
+    * @param aDomainRo ETrue if a domain key is used for wrapping
+    *                  EFalse if device public key is used wrapping
+    */
+    void UnwrapMacAndRekL( const RMessage2& aMessage, TBool aDomainRo );
+
+    /**
+    * This methods converts the given list into a permanent file
+    * representation.
+    * @since S60Rel2.5
+    * @param aList List to be converted into a file.
+    * @param aFile Output file name.
+    */
+    void ListToFileL( RPointerArray< CDRMPermission >& aList,
+                      TFileName& aFile );
+
+    /**
+    * Tries to locate the best permission candidates from the given list based
+    * on the given usage intent.
+    * @return Index of the best child in aList, >= 0 always. Leaves if no
+    *         suitable child is found.
+    */
+    TInt FindBestROsL( RDRMPermissionList& aList,
+                       const TDesC8& aURI,
+                       const ContentAccess::TIntent aIntent,
+                       HBufC8*& aUsedURI,
+                       TUint32& aReason );
+
+    /**
+    * Returns ETrue if might be possible to use the permission
+    * as a child permission in the first place.
+    */
+    TBool IsValidPermissionL( CDRMPermission& aPermission,
+                              const ContentAccess::TIntent aIntent,
+                              const TTime& aTime,
+                              TUint32& aReason );
+
+
+    void Normalize( CDRMPermission& aPermission,
+                    CDRMConstraint& aNormalized,
+                    const ContentAccess::TIntent aIntent );
+
+    TBool BetterPermission( const CDRMConstraint& aNewOne,
+                            const CDRMConstraint& aOldOne );
+
+
+    TInt GetBestROL( RDRMPermissionList& aList,
+                     const TIntent aIntent,
+                     TUint32& aReason );
+
+    /**
+    * This method checks whether the constraint has expired.
+    *
+    * @since S60Rel2.5
+    * @param aConstraint Rights constraint.
+    * @return Truth value.
+    */
+    inline TBool Expired( const CDRMConstraint& aConstraint );
+
+    /**
+    * finds the parent permissions and does not add unusable parents and removes unusable childred
+    *
+    * @param aList      List of child permissions
+    * @param aIntent    Intent for use
+    * @param aDrmTime   Drm time of the device
+    * @param aReason    Out-parameter: a bitvector of why some prmissions were disqualified
+    */
+    void FindParentsAndRemoveUnusableL( RDRMPermissionList& aList,
+                                        const TDesC8& aURI,
+                                        CDRMPointerArray<HBufC8>& aCids,
+                                        const TIntent aIntent,
+                                        const TTime& aDrmTime,
+                                        TUint32& aReason );
+
+    /**
+    * This method checks whether the constraint is invalid
+    * (count < 1 || interval <= 0 ).
+    *
+    * @since S60Rel2.6
+    * @param aConstraint Rights constraint.
+    * @return Truth value.
+    */
+    inline TBool Invalid( const CDRMConstraint& aConstraint );
+
+    /**
+    * This method updates the trusted time and its trust level from DRM server.
+    * Since S60Rel2.5
+    */
+    inline void UpdateSecureTime();
+
+    /**
+    * Unwrap a CEK which is wrapped with a REK
+    *
+    * @param aProtectedCek Wrapped CEK
+    * @return Unwrapped CEK
+    */
+    HBufC8* UnwrapProtectedCekL( const TDesC8& aProtectedCek );
+
+    /**
+    * Unwrap a CEK which is wrapped with a domain key.
+    *
+    * @param aProtectedCek Wrapped CEK
+    * @param aDomainId ID of the domain key
+    * @return Unwrapped CEK
+    */
+    HBufC8* UnwrapDomainCekL( const TDesC8& aProtectedCek,
+                              const TDesC8& aDomainId );
+
+    /**
+    * Set the authentication seed for a content ID
+    *
+    * @param aMessage IPC message
+    */
+    void SetAuthenticationSeedL( const RMessage2& aMessage );
+
+    /**
+    * Return the authentication seed for a content ID
+    *
+    * @param aMessage IPC message
+    */
+    void GetAuthenticationSeedL( const RMessage2& aMessage );
+
+    /**
+    * Integrity protection for protected ROs
+    *
+    * @param aMessage IPC message
+    */
+    void VerifyMacL( const RMessage2& aMessage );
+
+    /**
+    *
+    *
+    * @param aMessage IPC message
+    */
+    void GetSupportedIndividualsL( const RMessage2& aMessage );
+
+    /**
+    * Stop watching the DCF repository server and the rights DB
+    *
+    * @param aMessage IPC message
+    */
+    void StopWatchingL( const RMessage2& aMessage );
+
+    /**
+    * Return the current content ID
+    *
+    * @return content ID
+    */
+    const TDesC8& GetContentId();
+
+    /**
+    * Remove permissions which are currently invalid (e.g. domain context
+    * not available)
+    *
+    * @param aList List of permissions
+    */
+    void RemoveInvalidPermissionsL( CDRMPermissionList* aList );
+
+    void SetNameL( const RMessage2& aMessage );
+
+    void GetNameL( const RMessage2& aMessage );
+
+    void GetWideDataL( const RMessage2& aMessage );
+
+    void Cancel( const RMessage2& aMessage );
+
+    void GetFLUriL( const RMessage2& aMessage );
+
+    void EncodeRightsIssuerL( const RMessage2& aMessage );
+
+    void DecodeRightsIssuerL( const RMessage2& aMessage );
+
+    void GetRandomDataL( const RMessage2& aMessage );
+
+    void GetFlURI( TDes8& aURI );
+
+    void AesEncryptL( const TDesC8& aKey,
+                      const TDesC8& aIV,
+                      const TBool aAddPadding,
+                      TDes8& aData );
+
+    void AesDecryptL( const TDesC8& aKey,
+                      const TDesC8& aIV,
+                      const TBool aRemovePadding,
+                      TDes8& aData );
+
+    void GenerateIVL( TDes8& aData );
+
+    TBool PendingRights(const TDesC8& aCid, TBool aRemoval = ETrue);
+
+    /**
+    * This method tries to find a suitable rights object
+    * from the given list which allows the specified intent.
+    * @since S60Rel3.0
+    * @param aIntent Intent.
+    * @param aURI    Content URI
+    * @param aChild  Out-parameter: related child permissino. The caller
+    *                owns the child.
+    * @param aParent Out-parameter: related parent permission. The caller
+    *                owns the parent.
+    * @param aReason A bitvector of reasons for rights object rejection
+    */
+    void FindRightsObjectL( const ContentAccess::TIntent aIntent,
+                            const TDesC8& aURI,
+                            CDRMPermission*& aChild,
+                            HBufC8*& aUsedURI,
+                            TUint32& aReason );
+
+    /**
+    * Check if the deletion of the mentioned content id is allowed:
+    */
+    TBool DeleteAllowedL( const TDesC8& aContentId );
+
+    // Prohibit copy constructor.
+    CDRMDbSession( const CDRMDbSession& );
+    // Prohibit assigment operator.
+    CDRMDbSession& operator=( const CDRMDbSession& );
+
+    void GetMeteringDataL( const RMessage2& aMessage );
+
+    void DeleteMeteringDataL( const RMessage2& aMessage );
+
+public:     // Data
+
+protected:  // Data
+
+private:    // Data
+
+    TTime iTrustedTime;
+    TBool iSecureTime;
+    HBufC8* iPreparedData;
+    HBufC* iWidePreparedData;
+    CActive* iPendingRequest;
+    CDRMConsume* iConsume;
+
+    // Decryption key for this session
+    TBuf8< KDRMKeyLength > iCek;
+
+    // Rights encyrption key for this session, used for adding protected keys and
+    // the authentication seed
+    TBuf8< KDRMKeyLength > iRek;
+
+    TBuf8< KDRMKeyLength > iMac;
+
+    // Have the credentials of the caller been checked for this session?
+    TCredentialsCheckType iCredentialsChecked;
+
+    // Filename used for getting obsolete Contents
+    TFileName* iFileName;
+
+    // Client handle
+    RThread iClient;
+
+    // ID of the currently handled content
+    HBufC8* iContentId;
+
+    // Roap client
+    TBool iRoapClientConnected;
+    Roap::RRoapStorageClient iRoapClient;
+
+public:     // Friend classes
+protected:  // Friend classes
+private:    // Friend classes
+    };
+
+#include "DRMDbSession.inl"
+
+
+#endif      // CDRMDBSESSION_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMDbSession.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,62 @@
+/*
+* 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:  This file contains inline functions of class CDRMDbSession
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "DRMConstraint.h"
+#include "DRMRightsServer.h"
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+inline TBool CDRMDbSession::Invalid( const CDRMConstraint& aConstraint )
+    {
+    if ( ( ( aConstraint.iActiveConstraints & EConstraintCounter ) &&
+           ( aConstraint.iCounter < 1 ) ) ||
+         ( ( aConstraint.iActiveConstraints & 
+             EConstraintInterval ) &&
+           ( aConstraint.iIntervalStart != Time::NullTTime() ) ) )
+        {
+        return ETrue;
+        }
+
+    return EFalse;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMDbSession::UpdateSecureTime
+// Update secure time.
+// -----------------------------------------------------------------------------
+inline void CDRMDbSession::UpdateSecureTime()
+    {
+    iSecureTime = ( ( CDRMRightsServer* )( Server() ) )->
+                  GetSecureTime( iTrustedTime );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::UpdateSecureTime
+// Update secure time.
+// -----------------------------------------------------------------------------
+inline const TDesC8& CDRMDbSession::GetContentId()
+    {
+    return *iContentId;
+    }
+
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMEngineClientServer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,441 @@
+/*
+* 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:  This file defines RightsServer.exe's client/server interface
+*
+*/
+
+
+#ifndef DRMENGINECLIENTSERVER_H
+#define DRMENGINECLIENTSERVER_H
+
+//  INCLUDES
+#include <e32def.h>
+// #include <e32uid.h>
+
+// Added namespace to prevent namespace pollution (TDRMCommand).
+namespace DRMEngine
+    {
+    // CONSTANTS
+    const TUint8 KServerMajorVersion =  3;
+    const TUint8 KServerMinorVersion =  0;
+    const TUint16 KServerBuildVersion =  0;
+    
+    const TInt KServerUID = 0x101F51F2;
+    const TInt KNullUID = 0x0;
+    const TInt KMaxOmaV1CIDLength = 256;
+        
+    _LIT( KDRMSemaphore, "RightsServerSem" );
+   
+    _LIT( KServerName, "!RightsServer" );   
+    
+    // MACROS
+    // DATA TYPES
+       
+    enum TCommand 
+        {
+        /*
+        Command: failsafe
+        */
+        ENone,       /* 0 */
+        
+        /*
+        Command: Add a new rights object into database.
+        Params: 
+        TDesC8( CID ),
+        TPtr8( TRightsObject ),
+        TDesC8( CEK ),
+        TDes8( Unique ID )
+        */ 
+        EAddRecord,
+        
+        /*
+        Command: Get single rights object.
+        Params:
+        TPckg8<TInt>,
+        NULL,
+        TPtrC8( TDRMUniqueID ),
+        TDesC8( CID )
+        */
+        EGetDbEntry,
+        
+        /*
+        Command: Get list of rights objects and store the list 
+        into a temporary file.
+        Params: 
+        TFileName( temp file ),
+        TDesC8( CID ),
+        */
+        EGetEntryList,
+        
+        /*
+        Command: Delete all ROs with certain CID.
+        Params:
+        NULL,
+        NULL,
+        TDesC8( CID )
+        */ 
+        EDeleteWithCID,
+        
+        /*
+        Command: Delete one RO, identified with UID & CID.
+        Params:
+        TPtr8( TDRMUniqueID )
+        NULL,
+        NULL,
+        TDesC8( Content-ID )
+        */
+        EDeleteRO,  /* 5 */
+        
+        /*
+        Command: Export Content-ID list into a file.
+        Params:
+        TDes( File name )
+        */
+        EExportCIDs,
+        
+        /* 
+        Command: Get decryption key, update rights if said to do so.
+        Params: 
+        TInt( usage intention ),
+        TDesC8( content ID ),
+        TDRMKey( key ),
+        */
+        EGetKey,
+        
+        /*
+        Command: Check whether there is available rights.
+        Params:
+        TInt( usage intention ),
+        TDesC8( content ID )
+        */
+        ECheckRights,
+        /*
+        Command: Return how many rights object there is in the DB.
+        Params:
+        TPtr8( integer )
+        */
+        ECount,
+        
+        /*
+        Command: Delete every RO from the database.
+        Params:
+        -
+        */
+        EDeleteAll, /* 10 */
+
+        /*
+          Command: Consume the right with database
+          Params: 
+          TDesC8( content ID )
+        */
+        EConsume,
+
+        /*
+        Command: Calculate the padding from file ending
+        Params:
+        TDesC8( content ID )
+        TDesC8( last two data blocks )
+        */
+        ECalculatePadding,
+
+        /*
+         Command: Get the secure time and trust level.
+         Params:
+         TPckg< TInt64 > time
+         TPckg< TBool > trust level
+        */
+        ESecureTime,
+
+        /*
+        Command: Add a protected rights object into database.
+        Params: 
+        TDesC8( CID ),
+        TPtr8( TRightsObject ),
+        TDesC8( REK + CEK + MAC),
+        TDes8( Unique ID )
+        */ 
+        EAddProtectedRecord,
+        
+        /*
+        Command: Add a domain rights object into database.
+        Params: 
+        TDesC8( CID ),
+        TPtr8( TRightsObject ),
+        TDesC8( wrapped CEK ),
+        TDes8( Unique ID )
+        */ 
+        EAddDomainRecord,   /* 15 */
+        
+        
+        /*
+        Command: Gets the prepared data from the server size
+        TPtr8( data )
+        */
+        EGetPreparedData,
+        
+        /*
+        Command: Adds the domain ro xml representation to the server
+        TDesC8( RoId )
+        TDesC8( XmlData )
+        */
+        EAddDomainRO,
+        
+        /*
+        Command: Gets the domain ro xml representation from the server
+        TDesC8( RoId )
+        */
+        EGetDomainRO,
+        
+        /*
+        Command: Deletes the domain ro xml representation from the server
+        TDesC8( RoId )
+        */
+        EDeleteDomainRO,
+        
+        /*
+        Command: Checks whether the item is in Replay Cache.
+        TDesC8( ID )
+        TPckgC< TTime >
+        TPckg< TBool return value >
+        */
+        EIsInCache,     /* 20 */
+        
+        /*
+        Command: Add an entry to Replay Cache.
+        TDesC8( ID )
+        TPckgC< TTime >
+        */
+        EAddToCache,
+
+        /*
+        Command: Initialize the session key
+        TDesC8( content ID )
+        */
+        EInitializeKey,
+
+        /*
+        Command: Initialize the session key from a group key
+        TDesC8( group ID )
+        TDesC8( group Key )
+        TInt( encryption method )
+        */
+        EInitializeGroupKey,
+
+        /*
+        Command: Decrypt data using the session key
+        TDesC8( initialization vector )
+        TBool( remove padding? )
+        TPtr8( data )
+        */
+        EDecrypt,
+
+        /*
+        Command: Encrypt data using the session key
+        TDesC8( initialization vector )
+        TBool( add padding? )
+        TPtr8( data )
+        */
+        EEncrypt,   /* 25 */
+
+        /*
+        Command: Get the domain RO as XML for the given content ID
+        TDesC8( content ID )
+        TPtr8( RO as XML )
+        */
+        EGetDomainRoForCid,
+
+        /*
+        Command: Check if consume is possible
+        Params: 
+        TInt( intent )
+        TDesC8( content ID )
+        */
+        ECheckConsume,
+    
+        /*
+        Command: Delete expired permissions.
+        */
+        EDeleteExpired,
+        
+        /*
+        Command: Set the estimated arrival time
+        Params:
+        TDesC8( content ID )
+        TTimeIntervalSeconds( time until arrival )
+        */
+        ESetEstimatedArrival,
+        
+        /*
+        Command: Get the estimated arrival time
+        Params:
+        TDesC8( content ID )
+        TTimeIntervalSeconds( time until arrival )
+        */
+        EGetEstimatedArrival,   /* 30 */
+        
+        /*
+        Command: Set name
+        Params:
+        TDesC8( content-ID)
+        TDesC( name )
+        */
+        ESetName,
+        
+        /*
+        Command: Get name
+        Params:
+        TDesC8( content-ID)
+        TPckgBuf< TInt >( data lengt to be returned )
+        */
+        EGetName,
+        
+        /*
+        Command: Gets the prepared data from the server size
+        TPtr( data )
+        */
+        EGetWideData,
+        
+        /*
+        Command: Cancel
+        */
+        ECancel,
+
+        /*
+	    Command: Get Udt Data
+	    TDesC8( UDT Data );
+        */
+        EGetUdtData,    /* 35 */
+
+        /*
+        Command: Initiate Udt
+        TDesC8( key )
+        */
+        EInitiateUdt,
+
+        /*
+        Command: Export Orphaned Content-ID list into a file.
+        Params:
+        TBool( perform file scan )
+        */
+        EInitOrphanedList,
+
+        /*
+        Command: Export Orphaned Content-ID list into a file.
+        Params:
+        TDes( File name )
+        */
+        EGetOrphanedList,
+        
+        /*
+        Command: Get FL URI.
+        Params:
+        TBuf8< 256 >( URI )
+        */
+        EGetFLUri,
+        
+        /*
+        Command: Encode rights issuer url.
+        Params:
+        TPtr8( original ), room for result also.        
+        */
+        EEncodeRightsIssuerField,   /* 40 */
+        
+        /*
+        Command: Decode rights issuer url.
+        Params:
+        TDesC8( original ).
+        TPtr8( decoded )
+        */
+        EDecodeRightsIssuerField,
+
+        /*
+        Command: Set the authentication seed for a content ID
+        Params:
+        TDesC8( content ID)
+        TDesC8( authentication seed )
+        */
+        ESetAuthenticationSeed,
+
+        /*
+        Command: Get the authentication seed for a content ID
+        Params:
+        TDesC8( content ID)
+        TPtr8( authentication seed )
+        */
+        EGetAuthenticationSeed,
+        
+        /*
+        Command: Verify the MAC
+        Params:
+        TDesC8( RO element)
+        TDesC8( MAC value )
+        */
+        EVerifyMac,
+        
+        /*
+        Command: Get the supported individuals list
+        Params:
+        RPointerArray<HBufC8>
+        */
+        EGetSupportedIndividuals,   /* 45 */
+        
+        /*
+        Command: Stop watching the DCF repository server
+        */
+        EStopWatching,
+        
+        /*
+        Command: Unwraps public key encrypted MAC and REK keys.
+        Params:
+        TDesC8 aMacAndRek,
+        TKeyTransportScheme& aTransScheme,
+        TDesC8 aRiID
+        */
+        EUnwrapDeviceMacAndRek,
+        
+        /*
+        Command: Unwraps domain key encrypted MAC and REK keys.
+        Params:
+        TDesC8 aMacAndRek,
+        TKeyTransportScheme& aTransScheme,
+        TDesC8 aRiID
+        */
+        EUnwrapDomainMacAndRek,
+        
+        /*
+        Command: Fills the given buffer with random data
+        Params:
+        TDesC8 aRandomData,
+        */
+        EGetRandomData,
+        
+        /*
+        Command: Wrap metering data per RiId
+        Params:
+        TDesC8 aRiId,
+        */
+        EGetMeteringData,   /* 50 */
+
+        /*
+        Command: Delete metering data per RiId
+        Params:
+        TDesC8 aRiId,
+        */        
+        EDeleteMeteringData
+        };
+    }
+
+#endif      // DRMENGINECLIENTSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMObsoleteFinder.h	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Interface for the DRM Rights database
+*
+*/
+
+
+#ifndef DRMOBSOLETEFINDER_H
+#define DRMOBSOLETEFINDER_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include "drmpointerarray.h"
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class RFs;
+class CDir;
+class CDRMRightsDB;
+class CDcfRep;
+                                                         
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMObsoleteFinder implements expired rights cleanup
+*  for drm rights database
+*
+*  @lib RightsServer.exe
+*  @since 3.0
+*/
+
+NONSHARABLE_CLASS( CDRMObsoleteFinder ) : public CActive
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMObsoleteFinder class and returns a pointer
+        * to it
+        *
+        * @since    3.0
+        * @param    aFs : Open file server session
+        * @param    aDatabase : CDRMRightsDB object
+        * @param    aStatus : The request status to complete when the operation is 
+        *                     fully done
+        * @param    aStream : stream to write the result into
+        * @param    aPerformScan : if a filesystem scan need to be performed
+        *
+        * @return   Functional CDRMObsoleteFinder object, Function leaves if an error
+        *           occurs.
+        */
+        static CDRMObsoleteFinder* NewL( RFs& aFs,
+                                        CDRMRightsDB* aDatabase,
+                                        TRequestStatus& aStatus,
+                                        RWriteStream& aStream,
+                                        TBool aPerformScan );
+          
+        /**
+        * Destructor
+        */
+        virtual ~CDRMObsoleteFinder();
+
+    public: // New functions    
+
+        /**
+        * ExecuteCleanupLD
+        * 
+        * Delete expired permissions. The object is deleted when
+        * the function completes
+        *
+        * @since    3.0
+        * @return   None
+        *
+        */      
+        void ExecuteFinderLD();
+        
+        
+        void DoCleanup();
+         
+    protected:
+        /**
+        * From CActive: RunL.
+        */
+        void RunL();
+
+
+        /**
+        * From CActive: DoCancel performs cancel
+        */        
+        void DoCancel();
+      
+        /**
+        * From CActive: RunError checks the errors from RunL.
+        */
+        TInt RunError( TInt aError );                        
+                        
+    private:
+        /**
+        * Default Constructor - First phase. Prevented.
+        */
+        CDRMObsoleteFinder(); 
+    
+        /**
+        * Default Constructor - First phase.
+        */
+        CDRMObsoleteFinder( RFs& aFs,
+                            CDRMRightsDB* aDatabase,
+                            TRequestStatus& aStatus,
+                            RWriteStream& aStream ); 
+        
+        /**
+        * ConstructL
+        *
+        * Second phase constructor
+        *
+        * @since  3.0
+        * @return Leaves if an error occurs
+        */  
+        void ConstructL( const TBool aPerformScan );  
+
+        /**
+        * Assignment operator - Prevented
+        */
+        CDRMObsoleteFinder& operator =( const CDRMObsoleteFinder& );    
+    
+        /**
+        * Copy constructor - Prevented
+        */
+        CDRMObsoleteFinder( const CDRMObsoleteFinder& );                
+
+
+        /**
+        * Get possible parents the content if there are any
+        *
+        * @since    3.0
+        * @param    aContentId : identifier of the content whom to check for
+        *                        parents
+        * @param    aParents : pointer array of parents the new ones will be
+        *                      inserted
+        * @return none
+        */
+        void GetParentsL( const TDesC8& aContentId,
+                          RPointerArray<HBufC8>& aParents );
+
+        /**
+        * Write the Obsolete contents to the stream
+        *
+        * @since    3.0
+        * @return   none
+        * @leave    Symbian OS error code
+        */
+        void ObsoleteToStreamL();
+     
+    private:
+        // Dcf repository client
+        CDcfRep* iDcfClient;
+        
+        // List of content id's
+        CDRMPointerArray<HBufC8>* iContents;
+        
+        // List of content id's
+        CDRMPointerArray<HBufC8>* iParents;
+        
+        // List of content id's
+        CDRMPointerArray<HBufC8>* iNoContents;
+                               
+        // Index we are going at:
+        TInt iIndex;
+    
+        // fileserver session
+        RFs& iFileServer;
+
+        // output stream
+        RWriteStream& iStream;
+    
+        // rights database file, fileserver subsession
+        CDRMRightsDB* iRightsDb;
+    
+        // request status to be set complete
+        TRequestStatus& iOperationStatus;
+        
+        // State of the active object
+        TInt iState;
+        
+        // Cancelling status
+        TInt iCancel;
+    };
+
+#endif      // DRMOBSOLETEFINDER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMPointerArray.h	Thu Dec 17 08:52:27 2009 +0200
@@ -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:
+*
+*/
+
+
+#ifndef DRMPOINTERARRAY_H
+#define DRMPOINTERARRAY_H
+
+#include <e32base.h>
+#include <e32cmn.h>
+
+template < class T > NONSHARABLE_CLASS( RDRMPointerArray ) : public RPointerArray< T >
+    {
+    public:
+        inline explicit RDRMPointerArray( TInt aGranularity );
+        inline RDRMPointerArray( TInt aMinGrowBy, TInt aFactor );
+        inline RDRMPointerArray();
+        virtual ~RDRMPointerArray();
+        
+        // If set to ETrue, RPointerArray::ResetAndDestroy() is called 
+        // automatically in destructor. Otherwise only RPointerArrary::Close()
+        // is called.
+        inline void SetAutoCleanup( const TBool aCleanup );
+                
+    protected:
+        TBool iDoResetAndDestroy;
+    };
+
+template < class T > NONSHARABLE_CLASS( CDRMPointerArray ) : public CBase, public RDRMPointerArray< class T >
+    {
+    public:
+        static CDRMPointerArray* NewLC( TInt aGranularity );
+        static CDRMPointerArray* NewL( TInt aGranularity );
+        static CDRMPointerArray* NewLC( TInt aMinGrowBy, TInt aFactor );
+        static CDRMPointerArray* NewL( TInt aMinGrowBy, TInt aFactor );
+        static CDRMPointerArray* NewLC();
+        static CDRMPointerArray* NewL();
+        
+        // Note: Does not do ResetAndDestroy() by default. 
+        // Use SetAutoCleanup to do reallyclean.
+        ~CDRMPointerArray();
+        
+        
+    protected:
+        explicit CDRMPointerArray( TInt aGranularity );
+        CDRMPointerArray( TInt aMinGrowBy, TInt aFactor );
+        CDRMPointerArray();        
+        
+    private:
+    };
+
+
+#include "drmpointerarray.inl"
+
+#endif // DRMPOINTERARRAY_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMPointerArray.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,126 @@
+/*
+* 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:
+*
+*/
+
+
+#ifndef DRMPOINTERARRAY_INL
+#define DRMPOINTERARRAY_INL
+
+template < class T > RDRMPointerArray< T >::RDRMPointerArray( TInt aGranularity ):
+RPointerArray< T >( aGranularity ),
+iDoResetAndDestroy( EFalse )
+    {
+    }
+    
+template < class T > RDRMPointerArray< T >::RDRMPointerArray( TInt aMinGrowBy,
+                                                              TInt aFactor ):
+RPointerArray< T >( aMinGrowBy, aFactor ),
+iDoResetAndDestroy( EFalse )
+    {
+    }
+    
+template < class T > RDRMPointerArray< T >::RDRMPointerArray() :
+RPointerArray< T >(),
+iDoResetAndDestroy( EFalse )
+    {
+    // Nothing
+    }
+    
+template < class T > RDRMPointerArray< T >::~RDRMPointerArray()
+    {
+    if ( iDoResetAndDestroy )
+        {
+        RPointerArray< T >::ResetAndDestroy();
+        }
+        
+    RPointerArray< T >::Close();
+    }
+
+template < class T > void RDRMPointerArray< T >::SetAutoCleanup( const TBool aCleanup )
+    {
+    iDoResetAndDestroy = aCleanup;
+    }
+
+
+template < class T > CDRMPointerArray< T >* CDRMPointerArray< T >::NewLC( TInt aGranularity )
+    {
+    CDRMPointerArray< T >* self = CDRMPointerArray< T >::NewL( aGranularity );
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+template < class T > CDRMPointerArray< T >* CDRMPointerArray< T >::NewL( TInt aGranularity )
+    {
+    CDRMPointerArray< T >* self = new( ELeave ) CDRMPointerArray< T >( aGranularity );
+    
+    return self;
+    }
+
+template < class T > 
+CDRMPointerArray< T >* CDRMPointerArray< T >::NewLC( TInt aMinGrowBy, TInt aFactor )
+    {
+    CDRMPointerArray< T >* self = CDRMPointerArray< T >::NewL( aMinGrowBy, aFactor );
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+template < class T > 
+CDRMPointerArray< T >* CDRMPointerArray< T >::NewL( TInt aMinGrowBy, TInt aFactor )
+    {
+    CDRMPointerArray< T >* self = new( ELeave ) CDRMPointerArray< T >( aMinGrowBy, aFactor );
+    
+    return self;
+    }
+
+
+ 
+template < class T > CDRMPointerArray< T >*  CDRMPointerArray< T >::NewLC()
+    {
+    CDRMPointerArray< T >* self = CDRMPointerArray< T >::NewL();
+    CleanupStack::PushL( self );
+    
+    return self;
+    }
+    
+template < class T > CDRMPointerArray< T >*  CDRMPointerArray< T >::NewL()
+    {
+    CDRMPointerArray< T >* self = new ( ELeave ) CDRMPointerArray< T >;
+    
+    return self;
+    }
+    
+    
+template < class T > CDRMPointerArray< T >::~CDRMPointerArray()
+    {
+    // Nothing special
+    }
+    
+template < class T > CDRMPointerArray< T >::CDRMPointerArray( TInt aGranularity ):
+RDRMPointerArray< T >( aGranularity )
+    {
+    }
+    
+template < class T > CDRMPointerArray< T >::CDRMPointerArray( TInt aMinGrowBy, TInt aFactor ):
+RDRMPointerArray< T >( aMinGrowBy, aFactor )
+    {
+    }
+
+template < class T > CDRMPointerArray< T >::CDRMPointerArray():
+RDRMPointerArray< T >()
+    {
+    }
+    
+#endif // DRMPOINTERARRAY_INL
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMReplayCache.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,237 @@
+/*
+* 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:  This class declares the interface of class CDRMDbSession.
+*
+*/
+
+
+#ifndef DRMREPLAYCACHE_H
+#define DRMREPLAYCACHE_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <D32DBMS.H>
+
+// CONSTANTS
+// MACROS
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CPersistentStore;
+
+// DATA TYPES
+
+// CLASS DECLARATION
+
+/**
+*  Rights server's replay cache.
+*  This class manages storing information about the latest stored permissions.
+*
+*  @lib RightsServer.exe
+*  @since S60Rel3.0
+*/
+NONSHARABLE_CLASS( RDRMReplayCache )
+    {
+    public: // Constructors and destructor
+    
+    /**
+    * Constructor.
+    * @since S60Rel3.0
+    */
+    RDRMReplayCache( RFs& aFs );
+    
+    /**
+    * Default constructor.
+    * @since S60Rel3.0
+    */
+    RDRMReplayCache();
+    
+    public: // New functions
+    
+    /**
+    * Sets the ifs according to this reference.
+    *
+    * @since S60Rel3.0
+    * @param aFs Reference to open file server session. 
+    */
+    void Set( RFs& aFs );
+    
+    /**
+    * Closes the cache.
+    * @since S60Rel3.0
+    */
+    void Close();
+    
+    /**
+    * Initializes the view.
+    * @since S60Rel3.0
+    * @param aTimedDb File name of the db with timestamped permissions.
+    * @param aPlainDb File name of the db with permissions without timestamps.
+    */
+    void InitL( const TDesC& aTimedDb,
+                const TDesC& aPlainDb );
+                
+    /**
+    * Destructor.
+    * @since S60Rel3.0
+    */
+    ~RDRMReplayCache();
+    
+    /**
+    * Add an entry to the DB. Overloaded.
+    * @since S60Rel3.0
+    * @param aID    Content-ID.
+    * @param aaTime Timestamp of the permission.
+    * @param aaTime Insertion time.
+    */
+    void AddL( const TDesC8& aID, 
+               const TTime& aTime,
+               const TTime& aInsertionTime  );
+
+    /**
+    * Add an entry to the DB. Overloaded.
+    * @since S60Rel3.0
+    * @param aID    Content-ID.
+    * @param aaTime Insertion time.
+    */
+    void AddL( const TDesC8& aID, 
+               const TTime& aInsertionTime  );
+
+    /**
+    * Checks whether an entry is in cache. Overloaded.
+    * @since S60Rel3.0
+    * @param aID    Content-ID.
+    * @param aaTime Timestamp of the permission.
+    * @return Boolean.
+    */
+    TBool InCacheL( const TDesC8& aCID, 
+                    const TTime& aTime );
+    
+    /**
+    * Checks whether an entry is in cache. Overloaded.
+    * @since S60Rel3.0
+    * @param aID    Content-ID.
+    * @return Boolean.
+    */
+    TBool InCacheL( const TDesC8& aCID );
+
+    private: // Constants
+    enum TDatabaseId
+        {
+        ETimeDb,
+        EPlainDb
+        };
+        
+    private: // Private functions
+    
+    /**
+    * Initializes the database.
+    * @since S60Rel3.0
+    * @param aDb Database.
+    * @param aFileName File name.
+    * @param aId Database ID.
+    */
+    void InitDbL( RDbNamedDatabase& aDb, 
+                  const TDesC& aFileName,
+                  TDatabaseId aId );
+
+    /**
+    * Opens a database.
+    * @since S60Rel3.0
+    * @param aDb Database.
+    * @param aFileName File name.
+    */
+    void OpenDbL( RDbNamedDatabase& aDb, 
+                  const TDesC& aFileName );
+
+    /**
+    * Replace an existing database.
+    * @since S60Rel3.0
+    * @param aDb Database.
+    * @param aFileName File name.
+    * @param aId Database ID.
+    */
+    void ReplaceDbL( RDbNamedDatabase& aDb,
+                     const TDesC& aFileName, 
+                     TDatabaseId aId );
+
+    /**
+    * Initializes the view.
+    * @since S60Rel3.0
+    * @param aView View to initialize.
+    * @param aDb Database ID.
+    */
+    void InitViewLC( RDbView& aView, 
+                     TDatabaseId aDb,
+                     TBool aUpdate );
+    
+    /**
+    * Compare the given ID to the ID in the current position of the view.
+    * @since S60Rel3.0
+    * @param aView View.
+    * @param aCID Content-ID to check.
+    * @return Boolean.
+    */
+    TBool CompareCIDL( RDbRowSet& aView, const TDesC8& aCID );
+    
+    /**
+    * Push a cleanup item to the cleanup stack in order to rollback
+    * the database.
+    * @since S60Rel3.0
+    * @param aDb Database.
+    */
+    void PushL( RDbDatabase& aDb );
+    
+    /**
+    * Pop the cleanup item pushed in by PushL
+    * @since S60Rel3.0
+    */
+    void Pop();
+
+    /**
+    * Delete items starting from the oldest one.
+    * @since S60Rel3.0
+    * @param aView View.
+    * @param aHowMany How many items to delete. 
+    */
+    void DeleteOldestsL( RDbRowSet& aView, TInt16 aHowMany );
+    
+    /**
+    * Compacts the view to the upper limit of the view capacity.
+    * @since S60Rel3.0
+    * @param aView View to compact.
+    */
+    void CompactViewL( RDbRowSet& aView );
+    
+    /**
+    * Insert a content-id to the current position in the view.
+    * @since S60Rel3.0
+    * @param aView View to which the insertion is made.
+    * @param aId ID to add.    
+    */
+    void InsertIdL( RDbRowSet& aView, 
+                    const TDesC8& aId );
+    
+    private: // Data
+    // File server session handle. Not owned by this object.
+    RFs* iFs;
+    
+    // Database for timestamped items.
+    RDbNamedDatabase iTimeDb;
+    
+    // Database for the items without timestamp.
+    RDbNamedDatabase iPlainDb;
+    // RDbView iView;
+    };
+
+#endif //DRMREPLAYCACHE_H   
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMRightsCleaner.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,181 @@
+/*
+* 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:  Interface for the DRM Rights database
+*
+*/
+
+
+#ifndef DRMRIGHTSCLEANER_H
+#define DRMRIGHTSCLEANER_H
+
+// INCLUDES
+
+#include <e32base.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class RFs;
+class CDir;
+class CDRMRightsDB;
+                                                         
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMRightsCleaner implements expired rights cleanup
+*  for drm rights database
+*
+*  @lib RightsServer.exe
+*  @since 3.0
+*/
+
+NONSHARABLE_CLASS( CDRMRightsCleaner ) : public CActive
+    {
+    public: // Constructors and destructor
+        
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMRightCleaner class and returns a pointer
+        * to it
+        *
+        * @since    3.0
+        * @param    aFs : Open file server session
+        * @param    aDatabase : CDRMRightsDB object
+        * @param    aStatus : The request status to complete when the operation is 
+        *                     fully done
+        * @param    aDatabasePath : full pathname of the database path
+        * @param    aTime : Time to check expiration against 
+        *
+        * @return   Functional CDRMRightsCleaner object, Function leaves if an error
+        *           occurs.
+        */
+        static CDRMRightsCleaner* NewL( RFs& aFs,
+                                        CDRMRightsDB* aDatabase,
+                                        TRequestStatus& aStatus,
+                                        const TDesC& aDatabasePath,
+                                        const TTime& aTime );
+          
+        /**
+        * Destructor
+        */
+        virtual ~CDRMRightsCleaner();
+
+    public: // New functions    
+
+        /**
+        * ExecuteCleanupLD
+        * 
+        * Delete expired permissions. The object is deleted when
+        * the function completes
+        *
+        * @since    3.0
+        * @return   None
+        *
+        */      
+        void ExecuteCleanupLD();
+        
+        void DoCleanup();
+         
+    protected:
+        /**
+        * From CActive: RunL.
+        */
+        void RunL();
+
+
+        /**
+        * From CActive: DoCancel performs cancel
+        */        
+        void DoCancel();
+      
+        /**
+        * From CActive: RunError checks the errors from RunL.
+        */
+        TInt RunError( TInt aError );                        
+                        
+    private:
+        /**
+        * Default Constructor - First phase. Prevented.
+        */
+        CDRMRightsCleaner(); 
+    
+        /**
+        * Default Constructor - First phase.
+        */
+        CDRMRightsCleaner( RFs& aFs,
+                           CDRMRightsDB* aDatabase,
+                           TRequestStatus& aStatus,
+                           const TDesC& aDatabasePath,
+                           const TTime& aTime ); 
+        
+        /**
+        * ConstructL
+        *
+        * Second phase constructor
+        *
+        * @since  3.0
+        * @return Leaves if an error occurs
+        */  
+        void ConstructL();  
+
+        /**
+        * Assignment operator - Prevented
+        */
+        CDRMRightsCleaner& operator =( const CDRMRightsCleaner& );    
+    
+        /**
+        * Copy constructor - Prevented
+        */
+        CDRMRightsCleaner( const CDRMRightsCleaner& );                
+     
+    private:
+        // fileserver session
+        RFs& iFileServer;
+    
+        // rights database file, fileserver subsession
+        CDRMRightsDB* iRightsDb;
+    
+        // request status to be set complete
+        TRequestStatus& iOperationStatus;
+        
+        // Path of the rights database
+        TFileName iDatabasePath;
+        
+        // Expiration time to check against
+        TTime iExpirationTime;
+        
+        // Looping calculators
+        CDir* iCurrentDirectory;
+        
+        // directory index:
+        TInt iDirIndex;
+        
+        // FileIndex
+        TInt iCurrentFile;
+        
+        // Cancelling call:
+        TInt iCancel;
+    };
+
+#endif      // DRMRIGHTSCLEANER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMRightsData.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,364 @@
+/*
+* 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:  Datatype for Rights Constraint
+*
+*/
+
+
+#ifndef DRMRIGHTSDATA_H
+#define DRMRIGHTSDATA_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include "DRMTypes.h"
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class CDRMPermission;
+class CDRMCommonData;
+class CPermanentFileStore;
+class RWriteStream;
+class TStreamId;
+
+// TYPE DEFINITIONS
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMRightsData implements the rights database required by DRM Engine
+*
+*  @lib RightsServer.dll
+*  @since 3.0
+*/
+
+NONSHARABLE_CLASS( CDRMRightsData ) : public CBase 
+    {
+public: // Constructors and destructor
+    /**
+    * NewLC
+    *
+    * Creates an instance of the CDRMRightsData class and returns a pointer 
+    * to it. The function leaves the object into the cleanup stack
+    *
+    * @since  3.0
+    * @param    aData : The common data to store takes possession of the data
+    * @param    aKey : Key of the content
+    * @param    aRightsFile : Full pathname of the rights store
+    * @param    aFileServer : File server instance to use
+    * @return   Functional CDRMRightsData object, Function leaves if an error 
+    *           occurs.
+    */
+    static CDRMRightsData* NewLC( CDRMCommonData* aData,
+                                  const TDesC8& aKey, 
+                                  const TFileName& aRightsFile,
+                                  RFs& aFileServer );
+    
+    /**
+    * NewL
+    *
+    * Creates an instance of the CDRMRightsData class and returns a pointer 
+    * to it.
+    *
+    * @since  3.0
+    * @param    aData : The common data to store takes possession of the data
+    * @param    aKey : Key of the content
+    * @param    aRightsFile : Full pathname of the rights store
+    * @param    aFileServer : File server instance to use    
+    * @return   Functional CDRMRightsData object, Function leaves if an error 
+    *           occurs.
+    */
+    static CDRMRightsData* NewL( CDRMCommonData* aData, 
+                                 const TDesC8& aKey,
+                                 const TFileName& aRightsFile,
+                                 RFs& aFileServer );
+    /**
+    * OpenLC
+    *
+    * Opens the store and creates an instance of the CDRMRightsData class and returns
+    * a pointer to it. The function leaves the object into the cleanup stack
+    *
+    * @since  3.0
+    * @param  aRightsFile : Full pathname of the rights store
+    * @param    aFileServer : File server instance to use    
+    * @return Functional CDRMRightsData object, Function leaves if an error 
+    *         occurs.
+    */
+    static CDRMRightsData* OpenLC( const TFileName& aRightsFile,
+                                   RFs& aFileServer );
+    /**
+    * OpenL
+    *
+    * Opens the store and creates an instance of the CDRMRightsData class and returns
+    * a pointer to it.
+    *
+    * @since  3.0
+    * @param  aRightsFile : Full pathname of the rights store
+    * @param    aFileServer : File server instance to use    
+    * @return Functional CDRMRightsData object, Function leaves if an error 
+    *         occurs.
+    */
+    static CDRMRightsData* OpenL( const TFileName& aRightsFile,
+                                  RFs& aFileServer );
+
+    /*
+    * Destructor
+    */ 
+    virtual ~CDRMRightsData(); 
+
+
+public: // New functions
+
+    /**
+    * GetCommonDataL
+    * 
+    * returns a pointer a common data object
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    const CDRMCommonData* GetCommonDataL() const;
+
+    /**
+    * UpdateCommonDataL
+    * 
+    * Updates the common data part
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void UpdateCommonDataL( CDRMCommonData *aData );        
+    
+    /**
+    * StoreNewPermissionL
+    * 
+    * Writes the data of the permission to the store and returns
+    * the stream id
+    *
+    * @since    3.0
+    * @param    aPermission : CDRMPermission class to externalize
+    * @param    aStream : the output stream to write to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void StoreNewPermissionL( CDRMPermission& aPermission,
+                              TDRMUniqueID& aStream );    
+    
+    /**
+    * UpdatePermissionL
+    * 
+    * Writes the data of the object into the stream
+    *
+    * @since    3.0
+    * @param    aPermission : CDRMPermission class to externalize
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void UpdatePermissionL( const CDRMPermission& aPermission );
+    
+    /**
+    * FetchPermissionL
+    * 
+    * Reads the data of the object from the stream
+    *
+    * @since    3.0
+    * @param    aPermission : a CDRMPermission class to internalize to
+    * @param    aStream : the stream id to write the permission to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void FetchPermissionL( CDRMPermission& aPermission,
+                           const TDRMUniqueID& aStream ) const;
+
+    /**
+    * DeletePermissionL
+    * 
+    * Deletes the data of the object from the stream
+    *
+    * @since    3.0
+    * @param    aStream : the stream id to write the permission to
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void DeletePermissionL( const TDRMUniqueID& aStream );
+                           
+    /**
+    * FetchPermissionsL
+    * 
+    * Reads all the permissions and puts the data into the pointer array
+    *
+    * @since    3.0
+    * @param    aPointerArray : return value pointer array of the permissions
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void FetchAllPermissionsL( RPointerArray<CDRMPermission>& 
+                               aPointerArray );
+
+    /**
+    * DeleteAllPermissionsL
+    * 
+    * Deletes the data of the object from the stream
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void DeleteAllPermissionsL();
+
+
+    /**
+    * DeleteExpiredPermissionsL
+    * 
+    * Deletes the data of the object from the stream
+    *
+    * @since    3.0
+    * @param	aTime : Current secure time for checking the expiration
+    *				    if the time is Time::NullTTime() then only
+    *				    expired non time based rights are deleted
+    * @param    aParents : ETrue if any Ro's have parents otherwise EFalse
+    * @return   The amount of permissions left in the file
+    * @leave    The function leaves with Symbian OS error code if an
+    *           error occurs
+    */   
+	TInt DeleteExpiredPermissionsL( const TTime& aTime, TBool& aParents );   
+                           
+                           
+    /**
+    * StoreKeyL
+    * 
+    * Writes the key to the store
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void StoreKeyL();
+    
+    /**
+    * GetKeyL
+    * 
+    * Returns the key
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    HBufC8* GetKeyL() const;
+
+
+public:
+
+private:
+
+    /**
+    * CreateAndInitializeStoreL
+    * 
+    * Writes the data of index into the store root
+    *
+    * @since    3.0
+    * @param    aRightsStore : Full path filename of the rights store    
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void CreateAndInitializeStoreL( const TFileName& aRightsStore );
+
+    /**
+    * ExternalizeIndexL
+    * 
+    * Writes the data of index into the store root
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void StoreIndexL( RWriteStream& aStream ) const;
+    
+    /**
+    * InternalizeIndexL
+    * 
+    * Reads the data of the index from the store root
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void FetchIndexL();
+    
+    /**
+    * FetchCommonDataL();
+    *
+    * Reads the common data from the store
+    *
+    */
+    void FetchCommonDataL();
+    
+    /**
+    * FetchKeyL
+    * 
+    * Reads the key from the store
+    *
+    * @since    3.0
+    * @return   The function leaves with Symbian OS error code if an
+    *           error occurs
+    */
+    void FetchKeyL();
+    
+    /*
+    * Default Constructor
+    */ 
+    CDRMRightsData( CDRMCommonData* aData, RFs& aFileServer );
+
+    /*
+    * 2nd phase Constructor
+    *
+    * @param    aRightsStore : Full path filename of the rights store
+    */ 
+    void ConstructL( const TFileName& aRightsStore );
+
+    /*
+    * 2nd phase Constructor
+    *
+    * @param    aRightsStore : Full path filename of the rights store
+    */ 
+    void ConstructL( const TFileName& aRightsStore,
+                     const TDesC8& aKey );
+
+private:
+    RFs& iFileServer;
+
+    CPermanentFileStore* iStore;
+    
+    TBool iKeyExists;    
+    TBuf8<16> iKey;
+    RArray<TDRMUniqueID> iArray;
+    CDRMCommonData* iData;
+    TStreamId iCommonId;
+    TStreamId iKeyId;
+   
+    // Some index data
+    };
+
+#endif      // DRMRIGHTSDATA_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMRightsServer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  DRM3 Engine manages all DRM related database operations.
+*
+*/
+
+
+#ifndef CDRMRIGHTSSERVER_H
+#define CDRMRIGHTSSERVER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include <abclient.h>
+#include "drmcommonclientserver.h"
+#include "drmreplaycache.h"
+#include "drmmeteringdb.h"
+#include "drmclockclient.h"
+#include "dbwatcher.h"
+#include "procwatcher.h"
+#include "watcherobserver.h"
+
+// FORWARD DECLARATIONS
+class CDRMRightsDB;
+class CDRMNotifier;
+class CDRMClock;
+class CDRMXOma;
+class CDRMBackupObserver;
+class CDRMBackup;
+class RMobilePhone;
+        
+// CLASS DECLARATION
+
+/**
+*  This class implements the DRM5 Rights Server functionality.
+*
+*  @lib RightsServer.exe
+*  @since S60Rel2.5
+*/
+NONSHARABLE_CLASS( CDRMRightsServer ) : public CServer2, public MWatcherObserver
+    {
+    public:  // Constructors and destructor
+        
+        /**
+         * Two-phased constructor.
+         * @since S60Rel2.5
+         * @return Pointer to newly created server instance.
+         */
+        static CDRMRightsServer* NewL();
+        
+        /**
+         * Destructor.
+         * @since S60Rel2.5
+         */
+        ~CDRMRightsServer();
+        
+    public: // New functions
+
+        /**
+        * This method returns a handle to DRM Notifier.
+        * @since S60Rel2.6
+        * @return Handle to DRM Notifier.
+        */ 
+        CDRMNotifier& Notifier();
+
+        /**
+        * This method starts the ROAP storage server
+        * 
+        * @since S60Rel3.0
+        */ 
+        void StartRoapStorageL();
+        
+        /**
+        * This method returns the handle to the rights database.
+        * 
+        * @since S60Rel2.6
+        * @return Handle to the rights database.
+        */ 
+        CDRMRightsDB& Database();
+
+        RFs& FileServerSession();
+        
+        /**
+        * This method returns the handle to the metering database.
+        *
+        * @since S60 3.2
+        * @return Handle to the metering database.
+        */
+        RDrmMeteringDb& MeteringDatabase();
+        
+        RDRMReplayCache& ReplayCache();
+
+        /**
+        * List of the contents which may have rights objects on the way
+        *
+        * @since 2.6
+        * @return
+        */
+        RPointerArray<CDRMXOma>& XOmaHeaders( void );
+
+        /**
+        * This function is used to get the secure time.
+        *
+        * @since S60Rel2.5
+        * @param aTime Out-parameter where the time is stored.
+        * @return Truth value: Is the time a secure time or not.
+        */
+        TBool GetSecureTime( TTime& aTime ) const;
+        
+        /**
+         * 
+         */
+        const TDesC& GetIMEIL();
+
+        /**
+         * 
+         */
+        const CDRMPointerArray<HBufC8>& GetIMSIL();
+        
+        /**
+        * This function is used to handle backup restore events for
+        * the DRM system
+        */
+        void HandleBackupEventL( TInt aBackupEvent );     
+        
+        /**
+        * Checks if a content ID is in the list of currently consumed contents
+        * with count constraints
+        *
+        * @since 3.0
+        * @param aContentId content ID to search for
+        * @return ETrue if the content ID is in the list
+        */
+        TBool HasActiveCountConstraint( const TDesC8& aContentId );
+        
+        /**
+        * Removes a content ID from the list of currently consumed contents
+        * with count constraints
+        *
+        * @since 3.0
+        * @param aContentId content ID to remove
+        */
+        void RemoveActiveCountConstraint( const TDesC8& aContentId );
+        
+        /**
+        * Adds a content ID to the list of currently consumed contents
+        * with count constraints
+        *
+        * @since 3.0
+        * @param aContentId content ID to add
+        */
+        void AddActiveCountConstraintL( const TDesC8& aContentId );
+        
+        /**
+        * Import rights objects on startup
+        *
+        * @since 3.0
+        * @param aImportDir Directory to import from
+        */
+        void ImportRightsObjectsL( const TDesC& aImportDir );
+        
+        /**
+         * Stop watching the DCF repository server and the rights DB
+         * @since 3.1
+         */
+        void StopWatchingL();
+
+    public: // Functions from base classes
+    
+        //class MBackupOperationObserver
+        
+        /** 
+         * HandleNotifyL
+         * @since S60Rel2.5
+         * @param aBackupOperationAttributes Event related attributes.
+         */
+        void HandleNotifyL(const TUid aUid, const TDesC& aKey, 
+            const TDesC& aValue); 
+
+        //class MWatcherObserver
+        
+        /** 
+         * Called when the RDB has been modified
+         *
+         * @since S60 3.0
+         * @param aObject Changed directory
+         */
+        void WatchedObjectChangedL( const TDesC& aObject );
+            
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+    
+        //class CServer
+        /**
+         * RunError.
+         * @since S60Rel2.5
+         * @param aError Error code from RunL function.
+         * @return An error is returned if RunError() cannot process the
+         * error.
+         */
+        TInt RunError( TInt aError );
+        
+    private:
+        /**
+         * C++ default constructor.
+         * @since S60Rel2.5
+         */
+        CDRMRightsServer();
+        
+        /**
+         * By default Symbian 2nd phase constructor is private.
+         * @since S60Rel2.5
+         */
+        void ConstructL();
+        
+        /**
+         * This method fetches the database key and stores
+         * it to the given descriptor.
+         * @since S60Rel2.5
+         * @param aKey Descriptor where the key is stored.
+         */
+        void GetDbKeyL( TDRMKey& aKey );
+        
+        /** 
+         * This method generates the actual key from key seed.
+         * @since S60Rel2.5
+         * @param aKeySeed Key seed.
+         * @param aKey     The key produced.
+         */
+        void GenerateKeyL( HBufC*& aKeySeed, 
+                           TDRMKey& aKey ) const;
+
+        
+        void StartThreadL( const TDesC& aThreadName,
+                           TThreadFunction aFunc, 
+                           RSemaphore& aSemaphore );
+
+
+        void AppendExtendedIndividualConstraintsL(RMobilePhone* aMobilePhone = NULL);
+		    static void Release(TAny* aIndividualConstraintExtension);
+
+    private: // Functions from base classes
+        // Class CServer
+        /** 
+         * NewSessionL
+         * @since S60Rel2.5
+         */
+        CSession2* NewSessionL( const TVersion& aVersion,
+                                const RMessage2& aMessage) const;
+        
+    public:     // Data
+        
+    protected:  // Data
+        
+    private:    // Data
+        CDRMRightsDB* iDb;
+        
+        CDRMNotifier* iNotifier;
+        
+        RFs iFs;
+        RDRMReplayCache iCache;
+        RDrmMeteringDb iMeteringDb; 
+        RDRMClockClient iClock;
+        RPointerArray<CDRMXOma>* iXOmaHeaders;
+        RPointerArray<HBufC8> iActiveCountConstraints;
+        
+        HBufC* iIMEI;
+        
+        // Backup Observer
+        CDRMBackupObserver* iBackupObserver;
+        
+        // BackupHandler
+        CDRMBackup* iBackupHandler;
+        
+        // Backup client
+        conn::CActiveBackupClient* iActiveBackupClient;        
+        
+        // RDB Watcher
+        CDbWatcher* iDbWatcher;
+
+        // Peer process watcher
+        CProcWatcher* iProcWatcher;
+        
+        // Watching causes a restart
+        TBool iArmed;
+        
+        CDRMPointerArray<HBufC8>* iIMSI;
+        TBool iGetImsi;
+                
+    public:     // Friend classes
+        
+    protected:  // Friend classes
+        
+    private:    // Friend classes
+        
+};
+
+#endif      // CDRMRIGHTSSERVER_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/DRMXOma.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,307 @@
+/*
+* 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:  Datatype for the X-Oma header data
+*
+*/
+
+
+#ifndef DRMXOMA_H
+#define DRMXOMA_H
+
+// INCLUDES
+
+#include <e32base.h>
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+class RReadStream;
+class RWriteStream;
+
+// TYPE DEFINITIONS
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMXOma implements a datatype for the x-oma data for a single
+*  content identifier
+*
+*  @lib RightsServer.dll
+*  @since 2.6
+*/
+
+class CDRMXOma : public CBase 
+    {
+    
+    public: // Constructors and destructor
+        
+        /**
+        * NewLC
+        *
+        * Creates an instance of the CDRMXOma class and returns a pointer 
+        * to it. The function leaves the object into the cleanup stack
+        *
+        * @since    3.0
+        * @param    aContentID : Content Identifier
+        * @param    aTimeStamp : Time stamp the the object
+        * @param    aWaitTime : The wait time in seconds to wait for the rights object
+        * @return   Functional CDRMXOma object, Function leaves if an error 
+        *           occurs.
+        */
+        static CDRMXOma* NewLC( const TDesC8& aContentID,
+                                const TTime& aTimeStamp,
+                                const TTimeIntervalSeconds& aWaitTime );
+        
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMXOma class and returns a pointer 
+        * to it.
+        *
+        * @since    3.0
+        * @param    aContentID : Content Identifier
+        * @param    aTimeStamp : Time stamp the the object
+        * @param    aWaitTime : The wait time in seconds to wait for the rights object
+        * @return   Functional CDRMXOma object, Function leaves if an error 
+        *           occurs.
+        */
+        static CDRMXOma* NewL( const TDesC8& aContentID,
+                               const TTime& aTimeStamp,
+                               const TTimeIntervalSeconds& aWaitTime );
+          
+
+        
+        /**
+        * NewLC
+        *
+        * Creates an instance of the CDRMXOma class and returns a pointer 
+        * to it. The function leaves the object into the cleanup stack
+        *
+        * @since    3.0
+        * @return   Functional CDRMXOma object, Function leaves if an error 
+        *           occurs.
+        */
+        static CDRMXOma* NewLC();
+        
+        /**
+        * NewL
+        *
+        * Creates an instance of the CDRMXOma class and returns a pointer 
+        * to it.
+        *
+        * @since    3.0
+        * @return   Functional CDRMXOma object, Function leaves if an error 
+        *           occurs.
+        */
+        static CDRMXOma* NewL();
+
+        /**
+        * Destructor
+        */
+        virtual ~CDRMXOma();
+        
+        
+        /**
+        * ContentID
+        * 
+        * Returns a constant TDesC8 reference to the content id
+        *
+        * @since    3.0
+        * @return   a pointer to the content id or null
+        */        
+        const TDesC8& ContentID() const;
+        
+        
+        /**
+        * TimeStamp
+        * 
+        * Returns a constant TTime reference to the time stamp
+        *
+        * @since    3.0            
+        * @return   a pointer to the rights issuer or null
+        */         
+        const TTime& TimeStamp() const;
+
+        /**
+        * WaitTime
+        *
+        * Return a constant TTimeIntervalSeconds reference to the wait time
+        *
+        * @since    3.0
+        * @return   a pointer to the content name or null 
+        */
+        const TTimeIntervalSeconds& WaitTime() const;
+
+        /**
+        * SetContentIDL
+        * 
+        * Sets the content id, deletes the previous one if one
+        * exits
+        *
+        * @since    3.0
+        * @param    aContentID : Content Identifier        
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */        
+        void SetContentIDL( const TDesC8& aContentID );
+        
+        
+        /**
+        * SetTimeStampL
+        * 
+        * Sets the rights issuer, deletes the previous one if one
+        * exits
+        *
+        * @since    3.0
+        * @param    aTimeStamp : Timestamp of the insertion time         
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */         
+        void SetTimeStampL( const TTime& aTimeStamp );
+        
+        
+        /**
+        * SetWaitTimeL
+        *
+        * Sets the wait time, overwrites the previous one
+        *
+        * @since    3.0
+        * @param    aWaitTime : the wait time to replace the existing one
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void SetWaitTimeL( const TTimeIntervalSeconds& aWaitTime );
+        
+        /**
+        * ExternalizeL
+        * 
+        * Writes the data of the object into the stream
+        *
+        * @since    3.0
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void ExternalizeL( RWriteStream& aStream ) const;
+        
+        /**
+        * InternalizeL
+        * 
+        * Reads the data of the object from the stream
+        *
+        * @since    3.0
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void InternalizeL( RReadStream& aStream );   
+       
+        
+        /**
+        * Size
+        *
+        * Returns the size of the externalized object
+        *
+        * @since    3.0
+        * @return   the amount of bytes the externalize object occupies
+        */           
+        TInt Size() const;
+        
+    private:
+
+
+        /**
+        * Default Constructor - First phase.       
+        */
+        CDRMXOma(); 
+    
+        /**
+        * Default Constructor - First phase.
+        * @param    aTimeStamp : Time stamp the the object
+        * @param    aWaitTime : The wait time in seconds to wait for the rights object        
+        */
+        CDRMXOma( const TTime& aTimeStamp, 
+                  const TTimeIntervalSeconds& aWaitTime ); 
+    
+        /**
+        * ConstructL
+        *
+        * Second phase constructor
+        *
+        * @since	3.0
+        * @param    aContentID : Content Identifier
+        * @param    aFileName : File name of the content
+        * @return Functional CDRMXOma object, Function leaves if an error 
+        *         occurs.
+        */  
+        void ConstructL( const TDesC8& aContentID );
+
+        /**
+        * Assignment operator - Prevented
+        */
+        CDRMXOma& operator =( const CDRMXOma& );    
+    
+        /**
+        * Copy constructor - Prevented
+        */
+        CDRMXOma( const CDRMXOma& );                
+
+
+        /**
+        * WriteInt64L
+        * 
+        * Writes the 64 bit integer to the stream
+        *
+        * @since    3.0
+        * @param    aWrite : the 64 bit integer to write
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const;
+
+        /**
+        * ReadInt64L
+        * 
+        * Reads the 64 bit integer from the stream
+        *
+        * @since    3.0
+        * @param    aRead : the 64 bit integer read
+        * @param    aStream : the output stream to write to
+        * @return   The function leaves with Symbian OS error code if an
+        *           error occurs
+        */
+        void ReadInt64L( TInt64& aRead, RReadStream& aStream ); 
+
+    private: // Internal Data
+    
+        // Content identifier of the content
+        HBufC8* iContentID;
+        
+        // Time stamp of insertion of the object
+        TTime iTimeStamp;
+        
+        // Wait time
+        TTimeIntervalSeconds iWaitTime;
+    };
+
+#endif      // DRMXOMA_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/drmclockclientserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,60 @@
+/*
+* 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:  This file represents the commands for client/server 
+*                communications and common internal data types.
+*
+*/
+
+
+#ifndef DRMCLOCKCLIENTSERVER_H
+#define DRMCLOCKCLIENTSERVER_H
+
+//  INCLUDES
+#include <e32def.h>
+
+namespace DRMClock 
+    {
+    // CONSTANTS
+    const TUint8 KServerMajorVersion = 3;
+    const TUint8 KServerMinorVersion = 0;
+    const TUint16 KServerBuildVersion = 0;
+
+    _LIT( KServerName, "!DRMClockServer" );  
+        
+    // MACROS
+    // DATA TYPES
+
+    enum TDRMClockCommand 
+        {
+        /*
+          Command: Notifies the clients of the server
+          Params:
+          TRequestStatus& aRequestStatus ( given by the user )
+        */
+        EGetDRMTime = 0x01,
+    
+        /*
+          Command: Waits for notifications from the server
+          Params:
+          TRequestStatus& aRequestStatus ( given by the client )
+        */
+        EUpdateDRMTime = 0x02
+        };
+    }    
+    
+    
+
+#endif      // DRMCLIENTSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/drmcommonclientserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,47 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Internal data types for client/server communications.
+*
+*/
+
+
+#ifndef DRMGENERICCLIENTSERVER_H
+#define DRMGENERICCLIENTSERVER_H
+
+#include <caf/caf.h> 
+#include "DRMPointerArray.h"
+
+const TUint8 KDRMKeyLength = 16;
+typedef TBuf8< KDRMKeyLength > TDRMKey;
+
+
+_LIT( KDRMEngCommonSemaphore, "rightsserver" );
+
+
+enum KDRMErrors
+        {
+        EOk = KErrNone, 
+        EGeneralError = -30100, 
+        EUnknownMIME = -30101, 
+        EVersionNotSupported = -30102, 
+        ESessionError = -30103, 
+        ENoRights = KErrCANoRights, 
+        ERightsDBCorrupted = -30105, 
+        EUnsupported = KErrCANotSupported, 
+        ERightsExpired = KErrCANoPermission, 
+        EInvalidRights = -30108
+        };
+#endif      // DRMGENERICCLIENTSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/drmconsume.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,438 @@
+/*
+* 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:  Interface for the consume operations. This class handles all
+*                operations regarding rights consumption in DRM5.
+*
+*/
+
+#ifndef DRMCONSUME_H
+#define DRMCONSUME_H
+
+// INCLUDES
+#include <e32base.h>
+#include <caf/caftypes.h>
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FORWARD DECLARATIONS
+class CDRMDbSession;
+class RMessage2;
+class CDRMPermission;
+class CDRMConstraint;
+
+// TYPE DEFINITIONS
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+/**
+*  CDRMConsume acts as content consumer in DRM5 Rights Server. It is accessed
+*  by CDRMDbSession. Content consumption is initiated via HandleL() method
+*  in the beginning of the consumption, and later on the class can be
+*  controlled through Pause(), Continue() and Stop(). Destructor calls
+*  the Cancel() method.
+*  
+*  @lib RightsServer.exe
+*  @since 3.0
+*/
+NONSHARABLE_CLASS( CDRMConsume ) : public CTimer
+    {
+
+    public: // Constructors and destructor.
+        /**
+        * NewLC
+        *
+        * Two-phase constructor.
+        *
+        * @since    3.0
+        * @param    aParent Callback handle to the session
+        *                   owning this instance.
+        * @param    aURI    Content-ID.
+        * @return   A pointer to newly created object.
+        */
+        static CDRMConsume* NewLC( CDRMDbSession& aParent, 
+                                   const TDesC8& aURI,
+                                   const TDesC8* aParentId );
+        /**
+        * Destructor.
+        */
+        virtual ~CDRMConsume();
+        
+    public: // New functions.
+        /**
+        * HandleL
+        *
+        * Starts the content consumption.
+        *   
+        * Whenever this method is called, rights database also gets
+        * updated if related permissions are stateful. When calling HandleL
+        * several times for the same class instance instance, the permissions 
+        * are consumed only once if the related permissions returned by 
+        * CDRMDbSession::FindRightsObjectL() are the same returned earlier.
+        *
+        * @since    3.0
+        * @param    aIntent Usage intent.        
+        */
+        void HandleL( ContentAccess::TIntent aIntent );
+        
+        /**
+        * Pause
+        *
+        * Pauses the content consumption.
+        *
+        * Content consuption can be resumed via ContinueL() and HandleL(). 
+        * See comments in HandleL() method for information about permission 
+        * consumption.
+        *
+        * @since    3.0
+        */
+        void Pause();
+        
+        /**
+        * ContinueL
+        *
+        * Continues the content consumption.
+        *
+        * This method works similarily to HandleL.
+        *
+        * @since    3.0
+        */
+        void ContinueL();
+        
+        /**
+        * Stop
+        *
+        * Stops the content consumption.
+        *
+        * This method works similarily to Pause()
+        *
+        * @since    3.0 
+        */
+        void Stop();
+        
+        /**
+        * CountConstraintActive
+        *
+        * Checks whether a count constraint was used earlier
+        *
+        * @since    3.0 
+        * @return   ETrue if a count constraint was used earlier,
+        *           EFalse otherwise
+        */
+        TBool CountConstraintActive();
+        
+        /**
+        * IsExpired
+        *
+        * Returns ETrue if the last consumption lead to expired rights
+        *
+        * @since    3.0 
+        * @return   ETrue if the rights are expired,
+        *           EFalse otherwise
+        */
+        TBool IsExpired();
+        
+        /**
+        * Returns the current child permission
+        *
+        * @since    3.0 
+        * @return   the permission
+        */
+        CDRMPermission& GetChild();
+
+    protected: // from base class CActive
+        /**
+        * RunL
+        * 
+        * Handles the completed asynchronous request.
+        */
+        void RunL();
+        
+        /**
+        * RunError
+        *
+        * Handles errors happened during RunL().
+        *
+        * At the moment this method does nothing.
+        * 
+        * @since    3.0
+        * @param    Error code
+        * @return   KErrNone if the error could be handled. Otherwise an
+        *           error code is returned.
+        */
+        TInt RunError( TInt aError );
+        
+    protected: // New Functions
+        /**
+        * Constructor
+        * 
+        * Constructs the class instance.
+        * 
+        * @since    3.0
+        * @param    aSession Callback session to the CDRMDbSession owning
+        *           this instance.
+        */
+        CDRMConsume( CDRMDbSession& aSession );
+        
+        /**
+        * Second phase constructor
+        * 
+        * Finalizes the construction of the class instance.
+        *
+        * @since    3.0
+        * @param    aURI Content-ID
+        */
+        void ConstructL( const TDesC8& aURI,
+                         const TDesC8* aParentId );
+        
+    private: // From base class CActive
+        /**
+        * DoCancel
+        *
+        * Handles the cancelling operations.
+        * This method updates timed constraints of the permission found
+        * earlier (if such constraints exist). Calls DoCancelL() in trap
+        * harness.
+        *
+        * @since    3.0
+        */
+        void DoCancel(); 
+        
+    private: // New functions
+        /**
+        * InitializeL
+        * 
+        * This method finds the proper permissions (child & parent) for the 
+        * given intent and previously set content-ID.
+        *
+        * @since    3.0
+        * @param    aIntent Consumption intent
+        * @param    aSecureTime Whether the given time is secure or not
+        * @param    aTrustedTime Current time.
+        */
+        void InitializeL( ContentAccess::TIntent aIntent,
+                          TBool aSecureTime,
+                          const TTime& aTrustedTime );
+        
+        /**
+        * ActivateL
+        *
+        * In case of time based or interval based constraints, this method 
+        * activates the internal timer to monitor delay.
+        *
+        * @since    3.0
+        * @aParam   aSecureTime Whether the given time is secure or not.
+        * @aParam   aTrustedTime Current time.
+        */
+        void ActivateL( TBool aSecureTime,
+                        const TTime& aTrustedTime );
+
+        /**
+        * Consume
+        *
+        * This method consumes the internally stored permissions according to
+        * the given parameters. If a(ny) internally stored permission is
+        * changed, the internal status masks iTimedCounts and iTimedCounts.
+        *
+        * @since    3.0
+        * @param    aUpdateCounter Whether to consume counter constraint.
+        * @param    aInitInterval  Whether to initialize (possibly) 
+        *                          uninialized interval.
+        * @param    aUpdateTimedCount Whether to update timed counter.
+        * @param    aElapsedTime How much time has elapsed since initialization
+        * @param    aSecureTime Whether the given time is secure or not.
+        * @param    aTrustedTime Current time.
+        */
+        void Consume( TBool aUpdateCounter,
+                      TBool aInitInterval,
+                      TBool aUpdateTimedCount,
+                      const TTimeIntervalSeconds& aElapsedTime,
+                      TBool aSecureTime,
+                      const TTime& aTrustedTime );
+        
+        /**
+        * CombinePermissionsL
+        * 
+        * Combines internal iParent and iChild into iCombined.
+        *
+        * @since    3.0
+        */
+        void CombinePermissionsL();
+        
+        /**
+        * UpdateDBL
+        *
+        * Commits the internal iChild & iParent to the database in case
+        * they have changed.
+        */
+        void UpdateDBL();
+        
+        /**
+        * ConsumeConstraint
+        * 
+        * Consumes the given constraint by the given parameters.
+        * 
+        * @since    3.0
+        @ @param    aConstraint Constraint to be consumed.
+        * @param    aUpdateCounter Whether to decrease the counter constraint.
+        * @param    aInitInterval Whether to initialize (possibly)
+        *                         uninitialized interval.
+        * @param    aUpdateTimedCount Whether to decrease timed counter.
+        * @param    aElapsedTime How much time has elapsed since initialization
+        * @param    aSecureTime Whether the given time is secure or not.
+        * @param    aCumulativeTime The time that has elapsed cumulatively 
+        *                           from the start of a timed counter
+        * @param    aTrustedTime Current time.
+        */
+        TBool ConsumeConstraint( CDRMConstraint& aConstraint,
+                                 TBool aUpdateCounter,
+                                 TBool aInitInterval,
+                                 TBool aUpdateTimedCount,
+                                 const TTimeIntervalSeconds& aElapsedTime,
+                                 TBool aSecureTime,
+                                 const TTime& aTrustedTime,
+                                 TTimeIntervalSeconds& aCumulativeTime );
+        
+        /**
+        * ConsumeTimedItemsL
+        * 
+        * Consumes timed items.
+        *
+        * @since    3.0
+        * @param    aDelay The delay between timer initialization and this 
+        *                  moment.
+        * @param    aSecureTime Whether the given time is secure or not.
+        * @param    aTrustedTime Current time.
+        */
+        void ConsumeTimedItemsL( TTimeIntervalSeconds aDelay,
+                                 TBool aSecureTime,
+                                 const TTime& aTrustedTime );
+        
+        /**
+        * DoContinueL
+        * 
+        * Handles the operations of RunL() method when timer goes off.
+        * 
+        * @since    3.0
+        */        
+        void DoContinueL();
+        
+        /** 
+        * SecurityLevelChanged
+        * 
+        * Checks whether the secure time is now insecure or vice versa, 
+        * compared to the situation when ActivateL() was called.
+        *
+        * @since    3.0
+        * @param    aSecureTime Current time security level.
+        * @return   Whether the security level of the time is different.
+        */
+        TBool SecurityLevelChanged( TBool aSecureTime ) const;
+        
+        /**
+        * DoCancelL
+        *
+        * Updates time based constraints of internally stored permissions
+        * in case of cancel operation.
+        * 
+        * @since    3.0
+        */
+        void DoCancelL();
+        
+        /**
+        *
+        * Updates the metering count, defines the metering accumulated time
+        * and updates the metering database if there was metered content. 
+        * 
+        * @since S60 3.2
+        */
+        void UpdateMeteringDbL();
+        
+        /**
+        *
+        * Creates a Rights Issuer Context to Roap storage and checks the rights 
+        * of the Rights Issuer to use metering.
+        *
+        * @since S60 3.2
+        * @param aRiId
+        * @return Whether metering can be allowed base on the Rights Issuer Id or not
+        */
+        TBool CheckRiContextRightsL( const TDesC8& aRiId );
+        
+         
+    private: // New functions.
+        /**
+        * Default constructor.
+        * 
+        * Prohibited.
+        */
+        CDRMConsume(); 
+    
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+        // Callback handle.
+        CDRMDbSession& iSession;
+        
+        // Usage intent when the consumption was initialized.
+        ContentAccess::TIntent iIntent;
+        
+        // Content-id
+        HBufC8* iURI;
+        
+        // id of the parent, if this exists we are using a parent RO
+        HBufC8* iParentId;
+        
+        // The child permission used in the consumption operation.
+        CDRMPermission* iChild;
+        
+        // A constraint combined from iChild & iParent.
+        CDRMConstraint* iCombined;
+        
+        // The time when CTimer went active.
+        TTime iTime;
+        
+        // Tells how much the waiting time was when initialized.
+        TInt16 iCurrentDelay;
+        
+        // Internal state.
+        TUint8 iMask;
+        
+        // Internal state to check whether timed counters have been modified.
+        TUint8 iTimedCounts;
+        
+        // Internal state to check whether counters have been modified.
+        TUint8 iCounters;
+        
+        // Set to ETrue if a count constraint was used
+        TBool iCountConstraintActive;
+        
+        // Set to ETrue if the last consumption lead to expired rights
+        TBool iExpired;
+        
+        // Tells how much time has been actually spent rendering
+        TTimeIntervalSeconds iCumulativeDelayTop;
+        TTimeIntervalSeconds iCumulativeDelayChild;
+        
+        //  Tells the total cumulative time. It is needed when calculating
+        //  accumulated time for metering purposes. 
+        TTimeIntervalSeconds iTotalCumulativeTime;
+        
+        // Bit to tell if we use timed count
+        TBool iUsingTimedCount;      
+    };
+
+#endif // DRMCONSUME_H
+
+// EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/drmenginetypedefs.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+#ifndef DRMENGINETYPEDEFS_H
+#define DRMENGINETYPEDEFS_H
+
+#include "DRMPointerArray.h"
+#include "drmpermission.h"
+
+typedef CDRMPointerArray< CDRMPermission > CDRMPermissionList;
+typedef RDRMPointerArray< CDRMPermission > RDRMPermissionList;
+#endif DRMENGINETYPEDEFS_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/drmlog.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,63 @@
+/*
+* 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:  Debug log macro definitions
+*
+*/
+
+
+
+#ifndef DRMLOG_H
+#define DRMLOG_H
+
+//  INCLUDES
+#if (defined _DEBUG || defined _LOGGING)
+#include <E32SVR.H>
+#include <flogger.h>
+
+// CONSTANTS
+// MACROS
+
+#ifndef DRMFLOGFILE
+#define DRMFLOGFILE _L("RightsServer.log")
+#endif
+
+#define DRMLOG( a ) \
+    RFileLogger::Write(_L("drm"), DRMFLOGFILE, EFileLoggingModeAppend, a); \
+    RDebug::Print( a );
+    
+#define DRMLOG2( a, b ) \
+    RFileLogger::WriteFormat(_L("drm"), DRMFLOGFILE, EFileLoggingModeAppend, a, b); \
+    RDebug::Print( a, b );
+     
+#define DRMLOGHEX( a ) \
+    RFileLogger::HexDump(_L("drm"), DRMFLOGFILE, EFileLoggingModeAppend, _S(""), _S(""), (a).Ptr(), (a).Size());
+
+#else
+
+#define DRMLOG( a ) 
+#define DRMLOG2( a, b ) 
+#define DRMLOGHEX( a )
+
+#endif // _DEBUG
+
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+// CLASS DECLARATION
+
+#endif      // DRMLOG_H   
+            
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/drmmeteringdb.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,205 @@
+/*
+* 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:  Interface for the Metering database
+*
+*/
+
+
+#ifndef DRMMETERINGDB_H
+#define DRMMETERINGDB_H
+
+//  INCLUDES
+#include <e32std.h>
+#include <caf/caf.h>
+#include <D32DBMS.H>
+#include "DRMPointerArray.h"
+
+// CONSTANTS
+// MACROS
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CPersistentStore;
+class CDrmMeteringDbData;
+
+// DATA TYPES
+
+// CLASS DECLARATION
+
+/**
+*  Content metering information database. This class manages storing 
+*  information of Content ID, Rights Issuer ID, metered count and metered 
+*  accumulated time. 
+*
+*  @lib RightsServer.exe
+*  @since 3.2
+*/
+NONSHARABLE_CLASS( RDrmMeteringDb )
+    {
+        
+    public: // Constructors and destructor
+    
+        /**
+        * Constructor.
+        * @since S60 3.2
+        */
+        RDrmMeteringDb( RFs& aFs );
+    
+        /**
+        * Default constructor.
+        * @since S60 3.2
+        */
+        RDrmMeteringDb();
+    
+        public: // New functions
+    
+        /**
+        * Sets the iFs according to this reference.
+        *
+        * @since S60 3.2
+        * @param aFs Reference to open file server session. 
+        */
+        void Set( RFs& aFs );
+    
+        /**
+        * Closes the database.
+        * @since S60 3.2
+        */
+        void Close();
+    
+        /**
+        * Initializes the database.
+        * @since S60 3.2
+        * @param aFileName File name of the database
+        */
+        void InitL( const TDesC& aFileName );
+                
+        /**
+        * Destructor.
+        * @since S60 3.2
+        */
+        ~RDrmMeteringDb();
+    
+        /**
+        * Add a metering data entry to the database.
+        * @since S60 3.2
+        * @param aMeteringData One metering data entry
+        */
+        void AddL( const CDrmMeteringDbData* aMeteringData );
+        
+        /**  
+        * Get the metering data list based on the Rights Issuer Id from the 
+        * metering database. Return value is ETrue if at least one entry was 
+        * found corresponding to the given Rights Issuer Id. Return value is 
+        * EFalse if no entry was found. The function will leave if an error 
+        * happens in the handling of the database or if the Rights Issuer Id 
+        * is empty or too long.
+        * @since S60 3.2
+        * @param aRiId Rights Issuer Id
+        * @param aMeteringDataList Metering data list for a Rights Issuer
+        * @return Boolean
+        */
+        TBool GetL( const TDesC8& aRiId, 
+                    CDRMPointerArray< CDrmMeteringDbData >& aMeteringDataList );
+        
+        /**
+        * Delete all the metering data information associated to the given 
+        * Rights Issuer Id from the metering database. Return value is ETrue
+        * if at least one entry was found corresponding to the given Rights 
+        * Issuer Id. Return value is EFalse if no entry was found. The function 
+        * will leave if an error happens in the handling of the database or if 
+        * the Rights Issuer Id is empty or too long. 
+        * @since S60 3.2
+        * @param aRiId Rights Issuer Id 
+        * @return Boolean
+        */
+        TBool DeleteL( const TDesC8& aRiId );
+        
+    private: // Private functions
+    
+        /**
+        * Opens a database.
+        * @since S60 3.2
+        * @param aDb Database.
+        * @param aFileName File name.
+        */
+        void OpenDbL( RDbNamedDatabase& aDb, 
+                      const TDesC& aFileName );
+
+        /**
+        * Replace an existing database.
+        * @since S60 3.2
+        * @param aDb Database.
+        * @param aFileName File name.
+        */
+        void ReplaceDbL( RDbNamedDatabase& aDb,
+                         const TDesC& aFileName );
+
+        /**
+        * Initializes the view.
+        * @since S60 3.2
+        * @param aView View to initialize.
+        */
+        void InitViewLC( RDbView& aView );
+    
+        /**
+        * Compare the Rights Issuer Id and Content Id to their counterparts in
+        * the current row of the view. Return value is ETrue only if both the 
+        * Content Id and the Rights Issuer Id match their counterpart Ids in
+        * the view. Overloaded.  
+        * 
+        * @since S60 3.2
+        * @param aView View.
+        * @param aCID Content Id
+        * @param aRiId Rights Issuer Id
+        * @return Boolean
+        */
+        TBool CompareIDL( RDbRowSet& aView, 
+                          const TDesC8& aCID, 
+                          const TDesC8& aRiId );
+        
+        /**
+        * Compare the Rights Issuer Id to its counterpart in the current row 
+        * of the view. Overloaded.  
+        * 
+        * @since S60 3.2
+        * @param aView View.
+        * @param aRiId Rights Issuer Id
+        * @return Boolean
+        */
+        TBool CompareIDL( RDbRowSet& aView, const TDesC8& aRiId );
+            
+        /**
+        * Push a cleanup item to the cleanup stack in order to rollback
+        * the database.
+        * @since S60 3.2
+        * @param aDb Database.
+        */
+        void PushL( RDbDatabase& aDb );
+    
+        /**
+        * Pop the cleanup item pushed in by PushL
+        * @since S60 3.2
+        */
+        void Pop();
+
+    private: // Data
+        // File server session handle. Not owned by this object.
+        RFs* iFs;
+    
+        // Metering database 
+        RDbNamedDatabase iDb;
+    
+    };
+
+#endif //DRMMETERINGDB_H   
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/drmmeteringdbdata.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,120 @@
+/*
+* 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:  Datatype for the Metering Database Data Entry
+*
+*/
+
+
+#ifndef DRMMETERINGDBDATA_H
+#define DRMMETERINGDBDATA_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include "DRMTypes.h"
+
+/**
+*  CDrmMeteringDbData implements datatype for storing the metering data
+*  of one entry in the Metering database.
+*
+*  @lib RightsServer.dll
+*  @since 3.2
+*/
+
+NONSHARABLE_CLASS( CDrmMeteringDbData ) : public CBase 
+    {
+    
+    public: // Constructors and destructor
+        
+        /**
+        * NewLC
+        *
+        * Creates an empty instance of the CDrmMeteringDbData class and returns a pointer 
+        * to it. The function leaves the object into the cleanup stack
+        *
+        * @since  3.2
+        * @return Functional CDrmMeteringDbData object, Function leaves if an error 
+        *         occurs.
+        */
+        static CDrmMeteringDbData* NewLC();                                     
+                                     
+        /**
+        * NewL
+        *
+        * Creates an empty instance of the CDrmMeteringDbData class and returns a pointer 
+        * to it.
+        *       
+        * @since  3.2
+        * @return Functional CDrmMeteringData object, Function leaves if an error 
+        *         occurs.
+        */
+        static CDrmMeteringDbData* NewL();                                     
+          
+        /**
+        * Destructor
+        *
+        * @since  3.2
+        *
+        */
+        virtual ~CDrmMeteringDbData();
+    
+    private:
+        /**
+        * Default Constructor - First phase.
+        *
+        * @since  3.2
+        *
+        */
+        CDrmMeteringDbData(); 
+
+        /**
+        * ConstructL
+        *
+        * Second phase constructor - Empty
+        * 
+        * @since  3.2
+        *
+        */
+        void ConstructL();
+    
+        /**
+        * Assignment operator - Prevented
+        *
+        * @since  3.2
+        *
+        */
+        CDrmMeteringDbData& operator =( const CDrmMeteringDbData& );    
+    
+        /**
+        * Copy constructor - Prevented
+        *
+        * @since  3.2 
+        *
+        */
+        CDrmMeteringDbData( const CDrmMeteringDbData& );                
+
+    public: // Public data
+    
+        HBufC8* iContentId; 
+        TBuf8<KRiIdSize> iRiId;
+        TUint32 iCount;
+        TTimeIntervalSeconds iAccumulatedTime;
+        ContentAccess::TIntent iPermission;
+        HBufC8* iParentUid;
+
+    private: // Internal Data
+    };
+#endif      // DRMMETERINGDBDATA_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/drmnotifierclientserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRM Notifier's client/server interface
+*
+*/
+
+
+#ifndef DRMNOTIFIERCLIENTSERVER_H
+#define DRMNOTIFIERCLIENTSERVER_H
+
+//  INCLUDES
+#include <e32def.h>
+#include <e32uid.h>
+
+namespace DRMNotifier 
+    {
+    // CONSTANTS
+    const TUint8 KServerMajorVersion = 3;
+    const TUint8 KServerMinorVersion = 0;
+    const TUint16 KServerBuildVersion = 0;
+
+    const TInt KDRMSizeOfMessage = 350;
+
+    _LIT( KServerName, "!DRMNotifier" );
+    
+    // MACROS
+    // DATA TYPES
+
+    enum TDRMNotifyCommand 
+        {
+        /*
+          Command: Notifies the clients of the server
+          Params:
+          TRequestStatus& aRequestStatus ( given by the user )
+        */
+        ENotifyClients = 0x01,
+    
+        /*
+          Command: Waits for notifications from the server
+          Params:
+          TRequestStatus& aRequestStatus ( given by the client )
+        */
+        ERecieveNotification = 0x02,
+
+
+        /*
+          Command: Register to the specific session
+                    Used to reduce messages between client
+                    and server
+        */
+        ERegister = 0x03,
+
+        /*
+          Command: Register to the specific session
+                    Used to reduce messages between client
+                    and server
+        */
+        EUnRegister = 0x04,
+
+        /*
+          Command: Register the uri to the specific session
+                    Used to reduce messages between client
+                    and server
+        */
+        ERegisterURI = 0x05,
+
+        /*
+          Command: Register the uri to the specific session
+                    Used to reduce messages between client
+                    and server
+        */
+        EUnRegisterURI = 0x06,
+
+        /*
+          Command: Waits for notifications from the server
+          Params:
+        */
+        ECancelNotification = 0xFF
+        };
+    }
+    
+#endif      // DRMNOTIFIERCLIENTSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/drmparentstorage.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,140 @@
+/*
+* 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:  Store for parent index of Decision Making Machine
+*
+*/
+
+
+#ifndef DRMPARENTSTORAGE_H
+#define DRMPARENTSTORAGE_H
+
+// INCLUDES
+#include <badesca.h> // CDesC8ArraySeg
+#include "drmenginetypedefs.h"
+
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// TYPE DEFINITIONS
+
+// FUNCTION PROTOTYPES
+
+// CLASS DECLARATION
+
+/**
+*  CDRMParentStorage is a container for parent permissions for Decision 
+*  Making Machine.
+*
+*  @lib RightsServer.exe
+*  @since 3.0
+*/
+NONSHARABLE_CLASS( CDRMParentStorage ) : public CBase
+    {
+    public: // Constructors and destructor
+        /**
+        * NewLC
+        *
+        * Two-phase constructor.
+        *
+        * @since    3.0
+        * @return   A pointer to newly created object.
+        */
+        static CDRMParentStorage* NewLC();
+        
+        /**
+        * NewLC
+        *
+        * Two-phase constructor.
+        *
+        * @since    3.0
+        * @return   A pointer to newly created object.
+        */
+        static CDRMParentStorage* NewL();
+        
+        /**
+        * Destructor.
+        * @since Sereis 60 Release 3.0
+        */        
+        ~CDRMParentStorage();
+        
+        /**
+        * Creates a new list into the store.
+        * @since Sereis 60 Release 3.0
+        * @return A reference to a newly created list.
+        */
+        CDRMPermissionList& NewListL();
+        
+        /**
+        * Adds the id to the list. Assumes the list has been retrieved
+        * earlier with NewListL(), and the list has been filled properly.
+        * @since Sereis 60 Release 3.0
+        * @param aCID Content-ID
+        */
+        void AddL( const TDesC8& aCID );
+        
+        /**
+        * Checks whether the id is marked as bad parent.
+        * @since Sereis 60 Release 3.0
+        * @param aCID Content-ID
+        * @return boolean.
+        */
+        TBool Bad( const TDesC8& aCID );
+        
+        /**
+        * Check if there are permissions for a given id
+        * @since Sereis 60 Release 3.0
+        * @param aCID The id to be found
+        * @return List of permissions associated to the id.
+        */
+        TBool HasPermissions( const TDesC8& aCID );
+
+        /**
+        * Find operator. 
+        * Assumes the id is in store, and will panic if there are no permissions.
+        * @since Sereis 60 Release 3.0
+        * @param aCID The id to be found
+        * @return List of permissions associated to the id.
+        */
+        CDRMPermissionList& operator[]( const TDesC8& aCID );
+        
+    protected: 
+        /**
+        * Default constructor.
+        * @since Sereis 60 Release 3.0
+        */
+        CDRMParentStorage();
+        
+        /*
+        * 2nd phase constructor.
+        * @since Sereis 60 Release 3.0
+        */
+        void ConstructL();
+    private:
+        // An array of parent IDs. Ordered list.
+        CDesC8ArraySeg* iParentIDs;
+        
+        // An array of permission lists. In sync with iParentIDs.
+        RPointerArray< CDRMPermissionList > iParents;
+        
+    };
+
+#endif // DRMPARENTSTORAGE_H
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/inc/drmroapclientserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,75 @@
+/*
+* Copyright (c) 2005-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Client/server interface of ROAP server
+*
+*/
+
+
+#ifndef DRMROAPCLIENTSERVER_H
+#define DRMROAPCLIENTSERVER_H
+
+//  INCLUDES
+#include <e32def.h>
+
+
+
+_LIT( KRIContextFile, "c:\\private\\101F51F2\\ricontexts.dat" );
+_LIT( KDomainContextFile, "c:\\private\\101F51F2\\domaincontexts.dat" );
+
+
+
+namespace Roap
+    {
+    const TUint8 KServerMajorVersion = 5;
+    const TUint8 KServerMinorVersion = 0;
+    const TUint16 KServerBuildVersion = 1;
+
+    _LIT( KServerName, "!RoapStorageServer" );
+
+    enum TRoapStorageCommand
+        {
+        EAddRiContext = 0x01,
+        EAddDomainContext = 0x02,
+        EGetRiContext = 0x03,
+        EGetDomainContext = 0x04,
+        EGetData = 0x05,
+        EDeleteRiContext = 0x06,
+        EDeleteDomainContext = 0x07,
+        EDeleteExpiredRIs = 0x08,
+        EDeleteExpiredDomains = 0x09,
+        EWhiteListCheck = 0x10,
+        EGetPublicKey = 0x11,
+        EGetCertificates = 0x12,
+        ESignMessage = 0x13,
+        ESelectRoot = 0x14,
+        EActivateRoot = 0x15,
+        EGetTrustedRoots = 0x16,
+        EGetRootCert = 0x17,
+        EDeleteExpired = 0x18,
+        EDeleteAll = 0x19,
+        ERsaSign = 0x20,
+        EGetMeteringData = 0x21,
+        EDeleteMeteringData = 0x22,
+        ERetrieveAllRIContexts = 0x23,
+        EUpdateRIContext = 0x24,
+        EUpdateDrmTime = 0x25,
+        EVerifyOcspResponses = 0x26,
+        EGetOcspResponderId = 0x27
+        };
+
+    }
+
+#endif      // DRMROAPCLIENTSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMActiveDeletion.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,148 @@
+/*
+* 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:  Implementation of the parent storage for Decision Making Machine
+*
+*/
+
+
+// INCLUDE FILES
+#include "drmactivedeletion.h"
+#include "drmrightsdb.h"
+#include "drmrightscleaner.h"
+#include "drmdbsession.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+    
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMActiveDeletion::NewLC
+//
+// Two-phase constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMActiveDeletion* CDRMActiveDeletion::NewLC( const RMessagePtr2& aMessage,
+                                               CDRMDbSession& aSession )
+    {
+    CDRMActiveDeletion* self = new( ELeave ) CDRMActiveDeletion( aMessage,
+                                                                 aSession );
+    CleanupStack::PushL( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMActiveDeletion::~CDRMActiveDeletion
+//
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CDRMActiveDeletion::~CDRMActiveDeletion()
+    {
+    if ( iActiveOperation )
+        {
+        // Construction was successful, but 
+        // something has went wrong.
+
+        iActiveOperation->Cancel(); 
+        iMessage.Complete( KErrCancel );
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMActiveDeletion::ActivateL
+//
+// Activate the thing by issuing a request to the DB and executing it also.
+// -----------------------------------------------------------------------------
+//
+void CDRMActiveDeletion::ActivateL( const TTime& aTime,
+                                    CDRMRightsDB& aDb )
+    {
+    CActiveScheduler::Add( this );
+    
+    CDRMRightsCleaner* cleaner = 
+        aDb.DeleteExpiredPermissionsL( aTime, iStatus );
+    CleanupStack::PushL( cleaner );
+    cleaner->ExecuteCleanupLD();
+    CleanupStack::Pop();
+    
+    SetActive();
+    iActiveOperation = cleaner;    
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMActiveDeletion::RunL
+//
+// Handles the completition of the request.
+// -----------------------------------------------------------------------------
+//
+void CDRMActiveDeletion::RunL()
+    {
+    // All done.
+    iMessage.Complete( iStatus.Int() );
+    
+    // iActiveOperation deletes itself.
+    iActiveOperation = NULL;
+    
+    Deque();
+    
+    iSession.AsyncOperationDone();
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMActiveDeletion::DoCancel
+//
+// Cancels the operation.
+// -----------------------------------------------------------------------------
+//
+void CDRMActiveDeletion::DoCancel()
+    {
+    iActiveOperation->Cancel();
+    iActiveOperation = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMActiveDeletion::CDRMActiveDeletion
+//
+// Constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMActiveDeletion::CDRMActiveDeletion( const RMessagePtr2& aMessage,
+                                        CDRMDbSession& aSession ):
+CActive( EPriorityLow ),
+iMessage( aMessage ),
+iSession( aSession )
+    {
+    // Nothing
+    }
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMActiveOperation.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,241 @@
+/*
+* 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:  Implementation of the parent storage for Decision Making Machine
+*
+*/
+
+
+// INCLUDE FILES
+#include "drmactiveoperation.h"
+#include "drmrightsdb.h"
+#include "drmrightscleaner.h"
+#include "drmobsoletefinder.h"
+#include "drmdbsession.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+    
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMActiveOperation::NewLC
+//
+// Two-phase constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMActiveOperation* CDRMActiveOperation::NewLC( const RMessagePtr2& aMessage,
+                                               CDRMDbSession& aSession,
+                                               TOperationType aOperation )
+    {
+    CDRMActiveOperation* self = new( ELeave ) CDRMActiveOperation( aMessage,
+                                                                 aSession,
+                                                                 aOperation );
+    CleanupStack::PushL( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMActiveOperation::~CDRMActiveOperation
+//
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CDRMActiveOperation::~CDRMActiveOperation()
+    {
+    // Close the stream
+    iFileStream.Close();
+    
+    if( iFileName )
+        {
+        if( iFileServer ) 
+            {	
+            iFileServer->Delete( *iFileName );        
+            }
+        delete iFileName;
+        iFileName = NULL;  
+        }
+        
+    if ( iActiveOperation )
+        {
+        // Construction was successful, but 
+        // something has went wrong.
+        
+        iActiveOperation->Cancel();
+        if( !iMessage.IsNull() )
+            {
+            iMessage.Complete( KErrCancel );           
+            }
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMActiveOperation::ActivateL
+//
+// Activate the thing by issuing a request to the DB and executing it also.
+// -----------------------------------------------------------------------------
+//
+void CDRMActiveOperation::ActivateL( CDRMRightsDB& aDb,
+                                     const TTime& aTime )
+    {
+    CActiveScheduler::Add( this );
+    
+
+    CDRMRightsCleaner* cleaner = 
+        aDb.DeleteExpiredPermissionsL( aTime, iStatus );
+    CleanupStack::PushL( cleaner );
+    cleaner->ExecuteCleanupLD();
+    CleanupStack::Pop();
+    SetActive();
+    iActiveOperation = cleaner;             
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMActiveOperation::ActivateL
+//
+// Activate the thing by creating an object and executing it
+// -----------------------------------------------------------------------------
+//
+void CDRMActiveOperation::ActivateL( CDRMRightsDB& aDb,
+                                     RFs& aFileServer,
+                                     const TDesC& aTempPath, 
+                                     const TBool aPerformScan )
+    {
+    CActiveScheduler::Add( this );
+
+    iFileName = new (ELeave) TFileName;
+    iFileServer = &aFileServer;
+     
+    User::LeaveIfError( 
+        iFileStream.Temp( aFileServer, 
+                         aTempPath, 
+                         *iFileName, 
+                         EFileWrite | EFileStream ) );
+    
+    CDRMObsoleteFinder* finder = CDRMObsoleteFinder::NewL(aFileServer,
+                                                          &aDb,
+                                                          iStatus, 
+                                                          iFileStream,
+                                                          aPerformScan );
+    CleanupStack::PushL( finder );
+    finder->ExecuteFinderLD();
+    CleanupStack::Pop();
+    SetActive();
+    iActiveOperation = finder;              
+    }  
+
+// -----------------------------------------------------------------------------
+// CDRMActiveOperation::Remove
+//
+// Cancels the operation.
+// -----------------------------------------------------------------------------
+//
+void CDRMActiveOperation::Remove()
+    {
+    switch(iOperation)
+        {
+        case EOperationExportObsolete:
+            {
+            static_cast<CDRMObsoleteFinder*>(iActiveOperation)->DoCleanup();
+            } 
+            break;            
+        default: 
+            {
+            static_cast<CDRMRightsCleaner*>(iActiveOperation)->DoCleanup();
+            } 
+            break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMActiveOperation::RunL
+//
+// Handles the completition of the request.
+// -----------------------------------------------------------------------------
+//
+void CDRMActiveOperation::RunL()
+    {
+    TFileName* fileName = NULL;
+    
+    // All done.
+    if( !iMessage.IsNull() )
+        {
+        iMessage.Complete( iStatus.Int() );           
+        }    
+    
+    // iActiveOperation deletes itself.
+    iActiveOperation = NULL;
+    
+    Deque();
+    
+    if( iOperation == EOperationExportObsolete )
+        {
+        fileName = iFileName;
+        iFileName = NULL;
+        iSession.AsyncOperationDone(fileName);            
+        }
+    else 
+        {
+        iSession.AsyncOperationDone();            
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMActiveOperation::DoCancel
+//
+// Cancels the operation.
+// -----------------------------------------------------------------------------
+//
+void CDRMActiveOperation::DoCancel()
+    {
+    }
+    
+    
+
+// -----------------------------------------------------------------------------
+// CDRMActiveOperation::CDRMActiveOperation
+//
+// Constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMActiveOperation::CDRMActiveOperation( const RMessagePtr2& aMessage,
+                                        CDRMDbSession& aSession,
+                                        TOperationType aOperation ):
+    CActive( EPriorityLow ),
+    iMessage( aMessage ),
+    iSession( aSession ),
+    iOperation( aOperation ),
+    iFileServer( NULL )
+    {
+    // Nothing
+    }
+    
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMCommonData.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,668 @@
+/*
+* 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:  Datatype for the Common Rights Database Data
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32strm.h>
+#include "DRMCommonData.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8( KOwnNullDesC8, "" );
+_LIT( KOwnNullDesC, "" );
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMCommonData* CDRMCommonData::NewLC( const TDesC8& aContentID,
+                                       const TDesC8& aContentHash,
+                                       const TDesC8& aRightsIssuer,
+                                       const TDesC& aContentName,
+                                       const TDesC8& aAuthenticationSeed )
+    {
+    CDRMCommonData* self = new( ELeave ) CDRMCommonData();
+    CleanupStack::PushL( self );
+    self->ConstructL( aContentID, aContentHash, 
+                      aRightsIssuer, aContentName,
+                      aAuthenticationSeed );
+    
+    return self;    
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMCommonData* CDRMCommonData::NewL( const TDesC8& aContentID,
+                                      const TDesC8& aContentHash,
+                                      const TDesC8& aRightsIssuer,
+                                      const TDesC& aContentName,
+                                      const TDesC8& aAuthenticationSeed )
+    {
+    CDRMCommonData* self = NewLC( aContentID, aContentHash, 
+                                  aRightsIssuer, aContentName,
+                                  aAuthenticationSeed );
+    CleanupStack::Pop();
+    
+    return self;
+    };        
+
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMCommonData* CDRMCommonData::NewLC()
+    {
+    CDRMCommonData* self = new( ELeave ) CDRMCommonData();
+    CleanupStack::PushL( self );
+    
+    return self;    
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMCommonData* CDRMCommonData::NewL()
+    {
+    CDRMCommonData* self = NewLC();
+    CleanupStack::Pop();
+    
+    return self;
+    };           
+
+// -----------------------------------------------------------------------------
+// Default Constructor - First phase.
+// Can be used by itself to generate an empty object
+// -----------------------------------------------------------------------------
+//
+CDRMCommonData::CDRMCommonData()
+    {
+    
+    }; 
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CDRMCommonData::~CDRMCommonData()
+    {
+    if( iContentID )
+        {
+        delete iContentID;
+        iContentID = NULL;
+        }
+        
+    if( iContentHash )
+        {
+        delete iContentHash;
+        iContentHash = NULL;
+        }
+        
+    if( iRightsIssuer )
+        {
+        delete iRightsIssuer;
+        iRightsIssuer = NULL;
+        }
+        
+    if( iContentName )
+        {
+        delete iContentName;
+        iContentName = NULL;
+        }
+
+    if( iAuthenticationSeed )
+        {
+        delete iAuthenticationSeed;
+        iAuthenticationSeed = NULL;	
+        }   
+    };
+        
+        
+// -----------------------------------------------------------------------------
+// CDRMCommonData::ContentID
+// -----------------------------------------------------------------------------
+//        
+const TDesC8& CDRMCommonData::ContentID() const
+    {
+    if ( iContentID )
+        {
+        return *iContentID;
+        }
+    return KOwnNullDesC8;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::ContentHash
+// -----------------------------------------------------------------------------
+// 
+const TDesC8& CDRMCommonData::ContentHash() const
+    {
+    if ( iContentHash )
+        {
+        return *iContentHash;
+        }
+    
+    return KOwnNullDesC8;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::RightsIssuer
+// -----------------------------------------------------------------------------
+//    
+const TDesC8& CDRMCommonData::RightsIssuer() const
+    {
+    if ( iRightsIssuer )
+        {
+        return *iRightsIssuer;
+        }
+    return KOwnNullDesC8;
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMCommonData::ContentName
+// -----------------------------------------------------------------------------
+//   
+const TDesC& CDRMCommonData::ContentName() const
+    {
+    if ( iContentName )
+        {
+        return *iContentName;
+        }
+    
+    return KOwnNullDesC;
+    };    
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::AuthenticationSeed
+// -----------------------------------------------------------------------------
+//    
+const TDesC8& CDRMCommonData::AuthenticationSeed() const
+    {
+    if ( iAuthenticationSeed )
+        {
+        return *iAuthenticationSeed;
+        }
+    return KOwnNullDesC8;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::SetContentIDL
+// -----------------------------------------------------------------------------
+//         
+void CDRMCommonData::SetContentIDL( const TDesC8& aContentID )
+    {
+    HBufC8* newContentID = aContentID.AllocL();
+    
+    if( iContentID )
+        {
+        delete iContentID;
+        iContentID = NULL;
+        }
+    iContentID = newContentID;    
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::SetContentHashL
+// -----------------------------------------------------------------------------
+//        
+void CDRMCommonData::SetContentHashL( const TDesC8& aContentHash )
+    {
+    HBufC8* newContentHash = aContentHash.AllocL();
+    
+    if( iContentHash )
+        {
+        delete iContentHash;
+        iContentHash = NULL;
+        }
+    iContentHash = newContentHash;        
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::SetRightsIssuerL
+// -----------------------------------------------------------------------------
+//      
+void CDRMCommonData::SetRightsIssuerL( const TDesC8& aRightsIssuer )
+    {
+    HBufC8* newRightsIssuer = aRightsIssuer.AllocL();
+    
+    if( iRightsIssuer )
+        {
+        delete iRightsIssuer;
+        iRightsIssuer = NULL;
+        }
+    iRightsIssuer = newRightsIssuer;     
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::SetContentNameL
+// -----------------------------------------------------------------------------
+//   
+void CDRMCommonData::SetContentNameL( const TDesC& aContentName )
+    {
+    HBufC* newContentName = NULL; 
+       
+    // If the content name you want to give is empty, just delete the existing
+    // one and not do anything else;
+    if( aContentName.Length() == 0 )
+    	{
+    	if( iContentName )
+        	{
+        	delete iContentName;
+        	iContentName = NULL;
+        	}    	
+    	return;	
+    	}
+    	
+    newContentName = aContentName.AllocL();
+    
+    if( iContentName )
+        {
+        delete iContentName;
+        iContentName = NULL;
+        }
+    iContentName = newContentName;     
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::SetAuthenticationSeedL
+// -----------------------------------------------------------------------------
+//      
+void CDRMCommonData::SetAuthenticationSeedL( const TDesC8& aAuthenticationSeed )
+    {
+    HBufC8* newAuthenticationSeed = aAuthenticationSeed.AllocL();
+    
+    if( iAuthenticationSeed )
+        {
+        delete iAuthenticationSeed;
+        iAuthenticationSeed= NULL;
+        }
+    iAuthenticationSeed = newAuthenticationSeed;     
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::ExternalizeL
+// -----------------------------------------------------------------------------
+// 
+void CDRMCommonData::ExternalizeL( RWriteStream& aStream ) const
+    {
+    TInt dataLength = 0;
+    
+    // Write the ContentID
+    if( iContentID )
+        {
+        dataLength = iContentID->Length();
+        }
+    aStream.WriteInt32L( dataLength );
+    
+    if( dataLength )
+        {
+        aStream.WriteL( iContentID->Des() );        
+        }
+        
+    // Write the ContentHash
+    dataLength = 0;
+    if( iContentHash )
+        {
+        dataLength = iContentHash->Length();
+        }
+    aStream.WriteInt32L( dataLength );
+    
+    if( dataLength )
+        {
+        aStream.WriteL( iContentHash->Des() );        
+        }
+        
+    // Write the Rights Issuer
+    dataLength = 0;
+    if( iRightsIssuer )
+        {
+        dataLength = iRightsIssuer->Length();
+        }
+    aStream.WriteInt32L( dataLength );
+    
+    if( dataLength )
+        {
+        aStream.WriteL( iRightsIssuer->Des() );        
+        }
+        
+    // Write the ContentName                    
+    dataLength = 0;
+    if( iContentName )
+        {
+        dataLength = iContentName->Length();
+        }
+    aStream.WriteInt32L( dataLength );
+            
+    if( dataLength )
+        {
+        aStream.WriteL( iContentName->Des() );
+        }
+
+    // Write the Rights Issuer
+    dataLength = 0;
+    if( iAuthenticationSeed )
+        {
+        dataLength = iAuthenticationSeed->Length();
+        }
+    aStream.WriteInt32L( dataLength );
+    
+    if( dataLength )
+        {
+        aStream.WriteL( iAuthenticationSeed->Des() );        
+        }
+    
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::InternalizeL
+// -----------------------------------------------------------------------------
+// 
+void CDRMCommonData::InternalizeL( RReadStream& aStream )
+    {
+    TInt dataLength = 0;
+    HBufC8* dataPart = 0;
+    TPtr8 dataBuffer(NULL,0,0);
+        
+    // Read the ContentID
+    dataLength = aStream.ReadInt32L();
+    
+    if( dataLength )
+        {
+        // Reserve a new buffer:
+        dataPart = HBufC8::NewMaxLC( dataLength );
+        
+        // Set the read buffer:
+        dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+        // Read the data:
+        aStream.ReadL( dataBuffer );
+        
+        // Pop the buffer 
+        CleanupStack::Pop(); // dataPart
+                
+        // If an old content identifier exists delete it        
+        if( iContentID )
+            {
+            delete iContentID;
+            iContentID = NULL;
+            }
+        
+        // assign the new content id
+        iContentID = dataPart;    
+        }
+    else
+        {
+        // If an old content identifier exists delete it 
+        if( iContentID )
+            {
+            delete iContentID;
+            iContentID = NULL;
+            }        
+        }           
+        
+    // Read the Content Hash
+    dataLength = aStream.ReadInt32L();
+    
+    if( dataLength )
+        {
+        // Reserve a new buffer:
+        dataPart = HBufC8::NewMaxLC( dataLength );
+        
+        // Set the read buffer:
+        dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+        // Read the data:
+        aStream.ReadL( dataBuffer );
+        
+        // Pop the buffer 
+        CleanupStack::Pop(); // dataPart
+                
+        // If an old content identifier exists delete it        
+        if( iContentHash )
+            {
+            delete iContentHash;
+            iContentHash = NULL;
+            }
+        
+        // assign the new content id
+        iContentHash = dataPart;    
+        }
+    else
+        {
+        // If an old content identifier exists delete it 
+        if( iContentHash )
+            {
+            delete iContentHash;
+            iContentHash = NULL;
+            }        
+        }           
+        
+    // Read the rights issuer
+    dataLength = aStream.ReadInt32L();
+    
+    if( dataLength )
+        {
+        // Reserve a new buffer:
+        dataPart = HBufC8::NewMaxLC( dataLength );
+        
+        // Set the read buffer:
+        dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+        // Read the data:
+        aStream.ReadL( dataBuffer );
+        
+        // Pop the buffer 
+        CleanupStack::Pop(); // dataPart
+                
+        // If an old content identifier exists delete it        
+        if( iRightsIssuer )
+            {
+            delete iRightsIssuer;
+            iRightsIssuer = NULL;
+            }
+        
+        // assign the new content id
+        iRightsIssuer = dataPart;    
+        }
+    else
+        {
+        // If an old content identifier exists delete it 
+        if( iRightsIssuer )
+            {
+            delete iRightsIssuer;
+            iRightsIssuer = NULL;
+            }        
+        }
+
+    // Read the rights issuer
+    dataLength = aStream.ReadInt32L();
+    
+    if( dataLength )
+        {
+        HBufC16* dataPart2 = 0;
+        TPtr16 dataBuffer2(NULL,0,0);
+        
+        // Reserve a new buffer:
+        dataPart2 = HBufC::NewMaxLC( dataLength );
+        
+        // Set the read buffer:
+        dataBuffer2.Set(const_cast<TUint16*>(dataPart2->Ptr()), 0, dataLength);
+        
+        // Read the data:
+        aStream.ReadL( dataBuffer2 );
+        
+        // Pop the buffer 
+        CleanupStack::Pop(); // dataPart
+                
+        // If an old content identifier exists delete it        
+        if( iContentName )
+            {
+            delete iContentName;
+            iContentName = NULL;
+            }
+        
+        // assign the new content id
+        iContentName = dataPart2;    
+        }
+    else
+        {
+        // If an old content identifier exists delete it 
+        if( iContentName )
+            {
+            delete iContentName;
+            iContentName = NULL;
+            }        
+        }           
+
+    // Read the iAuthenticationSeed
+    dataLength = aStream.ReadInt32L();
+    
+    if( dataLength )
+        {
+        // Reserve a new buffer:
+        dataPart = HBufC8::NewMaxLC( dataLength );
+        
+        // Set the read buffer:
+        dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+        // Read the data:
+        aStream.ReadL( dataBuffer );
+        
+        // Pop the buffer 
+        CleanupStack::Pop(); // dataPart
+                
+        // If an old content identifier exists delete it        
+        if( iAuthenticationSeed )
+            {
+            delete iAuthenticationSeed;
+            iAuthenticationSeed = NULL;
+            }
+        
+        // assign the new content id
+        iAuthenticationSeed = dataPart;    
+        }
+    else
+        {
+        // If an old content identifier exists delete it 
+        if( iAuthenticationSeed )
+            {
+            delete iAuthenticationSeed;
+            iAuthenticationSeed = NULL;
+            }        
+        }
+                   
+    };   
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::Size
+// -----------------------------------------------------------------------------
+// 
+TInt CDRMCommonData::Size() const
+    {
+    TInt size = 0;
+    
+    // Content identifier of the content
+    size += sizeof(TInt32);
+    
+    if( iContentID )
+        {
+        size += iContentID->Size();
+        }
+        
+    // Hash of the content DCF
+    size += sizeof(TInt32);
+    
+    if( iContentHash )
+        {
+        size += iContentHash->Size();
+        }
+        
+    // Issuer of the rights
+    size += sizeof(TInt32);
+    
+    if( iRightsIssuer)
+        {
+        size += iRightsIssuer->Size();
+        }
+        
+    // Content name
+    size += sizeof(TInt32);
+    
+    if( iContentName )
+        {
+        size += iContentName->Size();
+        }
+    
+    // Authentication seed    
+    size += sizeof(TInt32);
+    
+    if( iAuthenticationSeed )
+        {
+        size += iAuthenticationSeed->Size();	
+        }    
+    return size;
+    };    
+ 
+// -----------------------------------------------------------------------------
+// CDRMCommonData::ConstrutL
+// Second phase constructor
+// -----------------------------------------------------------------------------
+// 
+void CDRMCommonData::ConstructL( const TDesC8& aContentID,
+                                 const TDesC8& aContentHash,
+                                 const TDesC8& aRightsIssuer,
+                                 const TDesC& aContentName,
+                                 const TDesC8& aAuthenticationSeed )
+    {
+    iContentID = aContentID.AllocL();
+    iContentHash = aContentHash.AllocL();
+    iRightsIssuer = aRightsIssuer.AllocL();
+    iContentName = aContentName.AllocL();
+    iAuthenticationSeed = aAuthenticationSeed.AllocL();
+    };                
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMDbSession.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,4928 @@
+/*
+* Copyright (c) 2003-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:  This class handles all client requests.
+*
+*/
+
+
+// INCLUDE FILES
+#include <s32file.h>
+#include <f32file.h>
+#include <symmetric.h>
+#include <rijndael.h>
+#include <caf/caf.h>
+#include <x509keys.h>
+#include <asn1dec.h>
+#include <dcfrep.h>
+
+#include <e32math.h>
+#include <utf.h>
+
+#include <SysUtil.h>    // Disk space checking
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "Oma2Agent.h"
+#include "DRMPermission.h"
+#include "DRMDbSession.h"
+#include "drmengineclientserver.h"
+#include "DRMRightsServer.h"
+#include "RoapStorageClient.h"
+#include "OmaCrypto.h"
+#include "CmlaCrypto.h"
+#include "DrmKeyStorage.h"
+#include "drmrightsdb.h"
+#include "drmparentstorage.h"
+#include "DrmDomainContext.h"
+#include "DrmRiContext.h"
+#include "drmenginetypedefs.h"
+#include "DRMXOma.h"
+
+#include "DRMNotifier.h"
+#include "DRMEventAddRemove.h"
+#include "DRMEventModify.h"
+#include "DRMRightsCleaner.h"
+#include "DRMActiveOperation.h"
+#include "drmconsume.h"
+#include "drmlog.h"
+#include "drmpointerarray.h"
+#include "base64.h"
+
+#ifdef RD_DRM_METERING
+#include "drmmeteringdbdata.h"
+#endif
+
+// NAMESPACES
+using namespace DRMEngine;
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES
+// CONSTANTS
+
+// MACROS
+#define REPLAYCACHE reinterpret_cast< CDRMRightsServer* >\
+    (const_cast<CServer2*>(Server()))->ReplayCache()
+#define DRMDB ( ( CDRMRightsServer* )( Server() ) )->Database()
+#ifdef RD_DRM_METERING
+#define METERINGDB reinterpret_cast< CDRMRightsServer* >\
+    (const_cast<CServer2*>(Server()))->MeteringDatabase()
+#endif
+#define RFSSESSION ( ( CDRMRightsServer* )( Server() ) )->FileServerSession()
+#define DRMNOTIFIER ( ( CDRMRightsServer* )( Server() ) )->Notifier()
+#define XOMAHEADER ( ( CDRMRightsServer* )( Server() ) )->XOmaHeaders()
+#define IMEI ( ( CDRMRightsServer* )( Server() ) )->GetIMEIL()
+#define IMSI ( ( CDRMRightsServer* )( Server() ) )->GetIMSIL()
+#define SERVER reinterpret_cast< CDRMRightsServer* >\
+    (const_cast<CServer2*>(Server()))
+
+#define IPCREAD0L( a ) aMessage.ReadL( 0, a )
+#define IPCREAD1L( a ) aMessage.ReadL( 1, a )
+#define IPCREAD2L( a ) aMessage.ReadL( 2, a )
+#define IPCREAD3L( a ) aMessage.ReadL( 3, a )
+#define IPCWRITE0L( a ) aMessage.WriteL( 0, a )
+#define IPCWRITE1L( a ) aMessage.WriteL( 1, a )
+#define IPCWRITE2L( a ) aMessage.WriteL( 2, a )
+#define IPCWRITE3L( a ) aMessage.WriteL( 3, a )
+#define IPCGETDESLEN0 aMessage.GetDesLength( 0 )
+#define IPCGETDESLEN1 aMessage.GetDesLength( 1 )
+#define IPCGETDESLEN2 aMessage.GetDesLength( 2 )
+#define IPCGETDESLEN3 aMessage.GetDesLength( 3 )
+#define IPCGETDESMAXLEN0 aMessage.GetDesMaxLength( 0 )
+#define IPCGETDESMAXLEN1 aMessage.GetDesMaxLength( 1 )
+#define IPCGETDESMAXLEN2 aMessage.GetDesMaxLength( 2 )
+#define IPCGETDESMAXLEN3 aMessage.GetDesMaxLength( 3 )
+
+// LOCAL CONSTANTS AND MACROS
+
+#ifdef RD_MULTIPLE_DRIVE
+
+_LIT( KDbTempPath, "%c:\\system\\temp\\" );
+_LIT( KTimedReplayCacheFile, "%c:\\private\\101F51F2\\timererc.dat" );
+_LIT( KPlainReplayCacheFile, "%c:\\private\\101F51F2\\plainrc.dat" );
+#ifdef RD_DRM_METERING
+_LIT( KMeteringDataBaseFile, "%c:\\private\\101F51F2\\meterdb.dat" );
+#endif
+
+#else
+
+_LIT( KTimedReplayCacheFile, "c:\\private\\101F51F2\\timererc.dat" );
+_LIT( KPlainReplayCacheFile, "c:\\private\\101F51F2\\plainrc.dat" );
+#ifdef RD_DRM_METERING
+_LIT( KMeteringDataBaseFile, "c:\\private\\101F51F2\\meterdb.dat" );
+#endif
+
+#endif
+
+
+const TInt KMicrosecondsToSecond = 1000000;
+_LIT8( KFLPrefix, "flk" );
+_LIT8( KFLLongPrefix, "flk:flk" );
+
+_LIT8( KFLSuffix, "@localhost" );
+
+// These need to be updated if the DRM Filter / Oma1DcfCreator URI's change
+// IMPORTANT IMPORTANT IMPORTANT
+_LIT8( KDCMUri, "ldf:31415926535@localhost");
+_LIT8( KLDFUri, "flk:flkS60_3_0_Hutchinson_2005");
+
+_LIT8(KTimeStamp, "timeStamp");
+#ifdef RD_DRM_METERING
+_LIT8(KMeteringDelimiter, ":");
+_LIT8(KCRLF, "\r\n" );
+#endif
+
+LOCAL_C const TUint8 KFLPrefixLength = 3;
+const TUint32 KTrustedShutdownClient = 0x10205CB5;
+const TUint32 KAppInstSrv = 0x101F875A;
+
+
+const TInt KSanityDataLengthLow = 0;
+const TInt KSanityDataLengthHigh = 32768;
+
+// MODULE DATA STRUCTURES
+NONSHARABLE_STRUCT( TDeleteFile )
+    {
+    RFs* iFs;
+    TFileName* iFileName;
+    };
+
+// ============================ auto_handde helper class =======================
+//Auto handle for easening handle release on exceptional exit situations
+template<class T> class auto_handle
+    {
+public:
+
+    auto_handle() {}
+    auto_handle(T aHandle) : iHandle( aHandle ) {}
+    auto_handle( auto_handle<T>& aHandle) : iHandle( aHandle.release() ) {}
+    ~auto_handle() { iHandle.Close(); }
+    const T& operator()() const { return iHandle; }
+    T& operator()() { return iHandle; }
+    T get() const { return iHandle; }
+    T release() { T temp = iHandle; iHandle = 0; return temp; }
+
+private:
+    T iHandle;
+    };
+
+// DATA TYPES
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C void DeleteFile( TAny* aHandle );
+LOCAL_C void DeleteObject( TAny* aObject );
+LOCAL_C TTime EndTime( const TTime& aTime1, const TTime& aTime2 );
+
+// FORWARD DECLARATIONS
+LOCAL_C void ModifyRightsObjectByTimeL( CDRMPermission* aRights,
+                                        TTimeIntervalMicroSeconds& aChange,
+                                        TBool aModifyInsertionTime );
+LOCAL_C void ModifyTimesInListL( CDRMPermissionList* aList,
+                                 TTimeIntervalMicroSeconds& aChange,
+                                 TBool aModifyInsertionTime );
+
+LOCAL_C void ModifyConstraintByTime( CDRMConstraint* aConstraint,
+                                     TTimeIntervalMicroSeconds& aChange );
+
+LOCAL_C TPtrC8 ExtractElement( const TDesC8& aRights, const TDesC8& aElement,
+                               TInt& aOffset );
+
+LOCAL_C TTime Iso8601ToTime( TDesC8& aTimeString );
+
+// ============================= LOCAL FUNCTIONS ==============================
+
+// -----------------------------------------------------------------------------
+// SanitizeL
+// Performs a sanity check on length parameters
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void SanitizeL( TInt aParam )
+    {
+    if( aParam <= KSanityDataLengthLow || aParam > KSanityDataLengthHigh )
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+
+
+LOCAL_C void ModifyTimesInListL( CDRMPermissionList* aList,
+    TTimeIntervalMicroSeconds& aChange,
+    TBool aModifyInsertionTime )
+    {
+    TInt i = 0;
+
+    // Go through the whole list and run the modification for all objects
+    for( i = 0; i < aList->Count(); i++ )
+        {
+        // Call modification for each rights object in the list
+        ModifyRightsObjectByTimeL( (*aList)[i], aChange, aModifyInsertionTime );
+        }
+    };
+
+LOCAL_C void ModifyRightsObjectByTimeL( CDRMPermission* aRights,
+    TTimeIntervalMicroSeconds& aChange,
+    TBool aModifyInsertionTime )
+    {
+
+    // If original insertion time exists and we want to change it, change it
+    if ( aModifyInsertionTime && aRights->iOriginalInsertTime != Time::NullTTime() )
+        {
+        aRights->iOriginalInsertTime += aChange;
+        }
+
+    if ( aRights->iAvailableRights & ERightsTopLevel )
+        {
+        ModifyConstraintByTime( aRights->iTopLevel, aChange );
+        }
+
+    // If play rights are available, check if they need to be changed
+    if ( aRights->iAvailableRights & ERightsPlay )
+        {
+        ModifyConstraintByTime( aRights->iPlay, aChange );
+        }
+
+    // If display rights are available, check if they need to be changed
+    if ( aRights->iAvailableRights & ERightsDisplay )
+        {
+        ModifyConstraintByTime( aRights->iDisplay, aChange );
+        }
+
+    // If execute rights are available, check if they need to be changed
+    if ( aRights->iAvailableRights & ERightsExecute )
+        {
+        ModifyConstraintByTime( aRights->iExecute, aChange );
+        }
+
+    // If print rights are available, check if they need to be changed
+    if ( aRights->iAvailableRights & ERightsPrint )
+        {
+        ModifyConstraintByTime( aRights->iPrint, aChange );
+        }
+
+    };
+
+LOCAL_C void ModifyConstraintByTime(
+    CDRMConstraint* aConstraint,
+    TTimeIntervalMicroSeconds& aChange )
+    {
+    // if start time exists, modify it
+    if ( aConstraint->iActiveConstraints & EConstraintStartTime )
+        {
+        aConstraint->iStartTime += aChange;
+        }
+
+    // if end time exists, modify it
+    if ( aConstraint->iActiveConstraints & EConstraintEndTime )
+        {
+        aConstraint->iEndTime += aChange;
+        }
+
+    // if activated interval exists, modify it
+    if ( aConstraint->iActiveConstraints & EConstraintInterval &&
+         aConstraint->iIntervalStart != Time::NullTTime() )
+        {
+        aConstraint->iIntervalStart += aChange;
+        }
+    };
+
+LOCAL_C TPtrC8 ExtractElement( const TDesC8& aRights,
+                               const TDesC8& aElement,
+                               TInt& aOffset )
+    {
+    DRMLOG( _L("CDRMDbSession::ExtractElement") );
+
+    TPtrC8 temp( KNullDesC8 );
+    TInt startPos = ( 0 );
+    TInt endPos = ( 0 );
+    TInt ret( 0 );
+    TInt startLength ( 0 );
+
+    auto_handle< RBuf8 > tagToBeFound;
+    // Must be nonleaving since this function is nonleaving
+    ret = tagToBeFound().Create( aElement.Length() + 3 ); // max "</" aElement ">"
+    if ( ret != KErrNone )
+        {
+        aOffset = -1;
+        return KNullDesC8();
+        }
+
+    // First we try to find the start tag (as localname)
+    tagToBeFound().SetLength( 0 );
+    tagToBeFound().AppendFormat( _L8( "<%S" ), &aElement );
+
+    temp.Set( aRights.Mid( aOffset ) );
+
+    startPos = temp.Find( tagToBeFound() );
+
+    startLength = tagToBeFound().Length();
+    startPos += aOffset;
+    temp.Set( aRights.Mid( startPos + startLength ) );
+
+    // Now find the end of the start tag
+    tagToBeFound().SetLength( 0 );
+    tagToBeFound().Append( _L8( ">" ) ); // '>' as last
+
+    // Define the starting point of the data after the start tag
+    // and skip the '>' mark.
+    startPos = startPos + startLength + temp.Find( tagToBeFound() ) + 1;
+
+    temp.Set( aRights.Mid( startPos ) );
+
+    // Finally find the start of the end tag
+    tagToBeFound().SetLength( 0 );
+    tagToBeFound().AppendFormat( _L8( "</%S" ), &aElement );
+
+    endPos = startPos + temp.Find(tagToBeFound() );
+
+    if ( endPos < startPos )
+        {
+        aOffset = -1;
+        return KNullDesC8();
+        }
+
+    temp.Set( aRights.Mid(startPos, endPos - startPos) );
+
+    aOffset = endPos;
+    DRMLOG2( _L( "Calculated length %d" ), endPos - startPos);
+    DRMLOG( _L( "Extracted element" ) );
+
+    //auto_handle closes and frees allocated resources
+    return temp;
+    };
+
+LOCAL_C TTime Iso8601ToTime( TDesC8& aTimeString )
+    {
+
+    DRMLOG( _L("CDRMDbSession::Iso8601ToTime") );
+
+    TLex8 lex;
+    TInt year = 0;
+    TInt month = 0;
+    TInt day = 0;
+    TInt hour = 0;
+    TInt minute = 0;
+    TInt second = 0;
+    TTime r = Time::NullTTime();
+    TLocale l;
+    TTimeIntervalSeconds offset(l.UniversalTimeOffset());
+
+    if (aTimeString.Length() > 0)
+        {
+        lex = aTimeString;
+        lex.Val(year);
+        lex.Inc();
+        lex.Val(month);
+        lex.Inc();
+        lex.Val(day);
+        lex.Inc();
+        lex.Val(hour);
+        lex.Inc();
+        lex.Val(minute);
+        lex.Inc();
+        lex.Val(second);
+        r = TTime(TDateTime(year, static_cast<TMonth>(month - 1), day - 1,
+                hour, minute, second, 0));
+        if (lex.Get() != 'Z')
+            {
+            r += offset;
+            }
+        }
+    return r;
+    }
+
+#ifdef RD_DRM_METERING
+LOCAL_C HBufC8* CreateMeteringDataL( CDRMPointerArray<CDrmMeteringDbData>* meteringArray )
+    {
+    // Calculate buffer size of cipher data
+    TInt size( sizeof( KCRLF ) );
+    HBufC8* cipherData = NULL;
+    TPtr8 ptr( NULL, 0 );
+
+    _LIT8( KElementStart, "<rawMeteringReportData>");
+    _LIT8( KElementEnd, "</rawMeteringReportData>");
+
+    size = KElementStart().Size() + KElementEnd().Size();
+
+    for( TUint i(0); i < meteringArray->Count(); i++ )
+        {
+        size += sizeof( ( *meteringArray)[i]->iContentId );
+        if ( (*meteringArray)[i]->iParentUid &&
+             (*meteringArray)[i]->iParentUid->Size() )
+            {
+            size += (*meteringArray)[i]->iParentUid->Size() + 1;
+            }
+        switch( (*meteringArray)[i]->iPermission )
+            {
+            case EPlay:
+                size += 4;
+                break;
+            case EView:
+            case EExecute:
+                size += 7;
+                break;
+            case EPrint:
+                size+= 5;
+                break;
+            default:
+                break; // Not a valid permission
+            }
+        size += (*meteringArray)[i]->iContentId->Size();
+        size += sizeof( (*meteringArray)[i]->iAccumulatedTime.Int() / 60 );
+        size += sizeof( (*meteringArray)[i]->iAccumulatedTime.Int() % 60 );
+        if( ( ( *meteringArray)[i]->iAccumulatedTime.Int() % 60 ) < 10 )
+            {
+            size++; //for precending zero for seconds..
+            }
+        size += sizeof( ( *meteringArray)[i]->iCount );
+        size += 4 * sizeof( KMeteringDelimiter ); // ":" -delimiter
+        size += sizeof( KCRLF );
+        }
+
+    cipherData = HBufC8::NewLC( size );
+    ptr.Set( cipherData->Des() );
+    ptr.Append( KElementStart );
+
+    for( TUint i(0); i < meteringArray->Count(); i++ )
+        {
+        ptr.Append( KCRLF );
+        if ( (*meteringArray)[i]->iParentUid &&
+             (*meteringArray)[i]->iParentUid->Size() )
+            {
+            ptr.Append( *(*meteringArray)[i]->iParentUid );
+            ptr.Append( _L(";") );
+            }
+        ptr.Append( *(*meteringArray)[i]->iContentId );
+        ptr.Append( KMeteringDelimiter );
+        switch( (*meteringArray)[i]->iPermission )
+            {
+            case EPlay:
+                ptr.Append( _L("play") );
+                break;
+            case EView:
+                ptr.Append( _L("display") );
+                break;
+            case EExecute:
+                ptr.Append( _L("execute") );
+                break;
+            case EPrint:
+                ptr.Append( _L("print") );
+                break;
+            default:
+                break; // Not a valid permission
+            }          // export not supported
+        ptr.Append( KMeteringDelimiter );
+        ptr.AppendNum( (*meteringArray)[i]->iCount );
+        ptr.Append( KMeteringDelimiter );
+        ptr.AppendNum( (*meteringArray)[i]->iAccumulatedTime.Int() / 60 );
+        ptr.Append( KMeteringDelimiter );
+        if( ( ( *meteringArray)[i]->iAccumulatedTime.Int() % 60 ) < 10 )
+            {
+            ptr.AppendNum( 0 ); //precending zero for seconds..
+            }
+        ptr.AppendNum( (*meteringArray)[i]->iAccumulatedTime.Int() % 60 );
+        }
+    ptr.Append( KCRLF );
+    ptr.Append( KElementEnd );
+    CleanupStack::Pop( cipherData );
+    return cipherData;
+    }
+#endif
+
+// ----------------------------------------------------------------------------
+// DeleteFile
+// Deletes the file by TFileName presented by aHandle
+// ----------------------------------------------------------------------------
+//
+void DeleteFile( TAny* aHandle )
+    {
+    __ASSERT_DEBUG( aHandle, User::Panic( _L( "DeleteFile" ), KErrArgument ) );
+    TDeleteFile* handle = reinterpret_cast< TDeleteFile* >( aHandle );
+
+    handle->iFs->Delete( *( handle->iFileName ) );
+    }
+
+// ----------------------------------------------------------------------------
+// DeleteObject
+// Deletes the file by TFileName presented by aHandle
+// ----------------------------------------------------------------------------
+//
+void DeleteObject( TAny* aObject )
+    {
+    __ASSERT_DEBUG( aObject, User::Panic( _L( "DeleteObject" ), KErrArgument ) );
+    MDrmKeyStorage* object = reinterpret_cast< MDrmKeyStorage* >( aObject );
+    delete object;
+    object = NULL;
+    }
+
+
+// ----------------------------------------------------------------------------
+// EndTime
+// Calculate the true end time: pick the smaller one of aTime1 & aTime2,
+// but ignore Time::NullTTime anyhow.
+// ----------------------------------------------------------------------------
+//
+TTime EndTime( const TTime& aTime1, const TTime& aTime2 )
+    {
+    TTime nullTime = Time::NullTTime();
+
+    if ( aTime1 == nullTime )
+        {
+        return aTime2;
+        }
+
+    if ( aTime2 == nullTime )
+        {
+        return aTime1;
+        }
+
+    return Min( aTime1, aTime2 );
+    }
+
+// ============================ MEMBER FUNCTIONS ==============================
+// ----------------------------------------------------------------------------
+// CDRMRightsServer::NewLC
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+CDRMDbSession* CDRMDbSession::NewL()
+    {
+    CDRMDbSession* self = new( ELeave ) CDRMDbSession();
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsServer::~CDRMDbSession
+// Destructor.
+// ----------------------------------------------------------------------------
+//
+CDRMDbSession::~CDRMDbSession()
+    {
+    DRMLOG( _L( "CDRMDbSession::~" ) );
+    delete iPreparedData;
+    iPreparedData = NULL;
+
+    delete iWidePreparedData;
+    iWidePreparedData = NULL;
+
+    delete iFileName;
+    iFileName = NULL;
+
+    if ( iPendingRequest )
+        {
+        delete iPendingRequest;
+        }
+
+    delete iContentId;
+    iContentId = NULL;
+
+    iClient.Close();
+
+    iCek = KNullDesC8;
+    iCek.FillZ();
+
+    delete iConsume;
+    iRoapClient.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsServer::CDRMDbSession
+// Default constructor.
+// ----------------------------------------------------------------------------
+//
+CDRMDbSession::CDRMDbSession():
+    iCredentialsChecked(ENotChecked),
+    iContentId(NULL)
+    {
+    iRek.SetLength( 0 );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::RoapClient
+// Returns a handle to the Roap client
+// ----------------------------------------------------------------------------
+Roap::RRoapStorageClient& CDRMDbSession::RoapClient()
+    {
+    return iRoapClient;
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsServer::ServiceL
+// Forwards requests from clients to helper methods.
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::ServiceL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::ServiceL" ) );
+    DRMLOG2( _L( "Message Handle: %08x"), aMessage.Handle() );
+
+    // Close the client before opening a new connection over it to avoid
+    // leaking memory in the kernel side
+    iClient.Close();
+
+    aMessage.ClientL( iClient );
+
+    // This function call is TRAPped by framework, and message is completed
+    // with the error in case of leaving operation.
+    switch ( aMessage.Function() )
+        {
+        case EAddRecord:
+            AddRecordL( aMessage, ENoProtection );
+            break;
+
+        case EAddProtectedRecord:
+            AddRecordL( aMessage, EPublicKey );
+            break;
+
+        case EAddDomainRecord:
+            AddRecordL( aMessage, EDomainKey );
+            break;
+
+        case EGetDbEntry:
+            GetRecordL( aMessage );
+            break;
+
+        case EGetEntryList:
+            GetEntryListL( aMessage );
+            break;
+
+        case EDeleteWithCID:
+            DeleteL( aMessage );
+            break;
+
+        case EDeleteRO:
+            DeleteRecordL( aMessage );
+            break;
+
+        case EExportCIDs:
+            ExportCIDsL( aMessage );
+            break;
+
+        case EGetKey:
+            GetKeyL( aMessage );
+            break;
+
+        case ECheckRights:
+            CheckRightsL( aMessage );
+            break;
+
+        case ECount:
+            CountL( aMessage );
+            break;
+
+        case EDeleteAll:
+            DeleteAllL( aMessage );
+            break;
+
+        case EConsume:
+            ConsumeL( aMessage );
+            break;
+
+        case ECheckConsume:
+            CheckConsumeL( aMessage );
+            break;
+
+        case ECalculatePadding:
+            CalculatePaddingL( aMessage);
+            break;
+
+        case ESecureTime:
+            SecureTimeL( aMessage );
+            break;
+
+        case EGetPreparedData:
+            GetPreparedDataL( aMessage );
+            break;
+
+        case EAddDomainRO:
+            AddDomainROL( aMessage );
+            break;
+
+        case EGetDomainRO:
+            GetDomainROL( aMessage );
+            break;
+
+        case EDeleteDomainRO:
+            DeleteDomainROL( aMessage );
+            break;
+
+        case EIsInCache:
+            IsInCacheL( aMessage );
+            break;
+
+        case EAddToCache:
+            AddToCacheL( aMessage );
+            break;
+
+        case EDecrypt:
+            DecryptL( aMessage );
+            break;
+
+        case EEncrypt:
+            EncryptL( aMessage );
+            break;
+
+        case EInitializeKey:
+            InitializeKeyL( aMessage );
+            break;
+
+        case EInitializeGroupKey:
+            InitializeGroupKeyL( aMessage );
+            break;
+
+        case EGetDomainRoForCid:
+            GetDomainRosForCidL( aMessage );
+            break;
+
+        case EDeleteExpired:
+            DeleteExpiredPermissionsL( aMessage );
+            break;
+
+        case ESetEstimatedArrival:
+            SetEstimatedArrivalL( aMessage );
+            break;
+
+        case EGetEstimatedArrival:
+            GetEstimatedArrivalL( aMessage );
+            break;
+
+        case ESetName:
+            SetNameL( aMessage );
+            break;
+
+        case EGetName:
+            GetNameL( aMessage );
+            break;
+
+        case EGetWideData:
+            GetWideDataL( aMessage );
+            break;
+
+        case ECancel:
+            Cancel( aMessage );
+            break;
+
+        case EGetUdtData:
+            GetUdtDataL( aMessage );
+            break;
+
+        case EInitiateUdt:
+            InitiateUdtL( aMessage );
+            break;
+
+        case EInitOrphanedList:
+            InitExportOrphanedCIDsL( aMessage );
+            break;
+
+        case EGetOrphanedList:
+            ExportOrphanedCIDsL( aMessage );
+            break;
+
+        case EGetFLUri:
+            GetFLUriL( aMessage );
+            break;
+
+        case EEncodeRightsIssuerField:
+            EncodeRightsIssuerL( aMessage );
+            break;
+
+        case EDecodeRightsIssuerField:
+            DecodeRightsIssuerL( aMessage );
+            break;
+
+        case ESetAuthenticationSeed:
+            SetAuthenticationSeedL( aMessage );
+            break;
+
+        case EGetAuthenticationSeed:
+            GetAuthenticationSeedL( aMessage );
+            break;
+
+        case EVerifyMac:
+            VerifyMacL( aMessage );
+            break;
+
+        case EGetSupportedIndividuals:
+            GetSupportedIndividualsL( aMessage );
+            break;
+
+        case EStopWatching:
+            StopWatchingL( aMessage );
+            break;
+
+        case EUnwrapDeviceMacAndRek:
+            UnwrapMacAndRekL( aMessage, EFalse );
+            break;
+
+        case EUnwrapDomainMacAndRek:
+            UnwrapMacAndRekL( aMessage, ETrue );
+            break;
+
+        case EGetRandomData:
+            GetRandomDataL( aMessage );
+            break;
+
+        case EGetMeteringData:
+            GetMeteringDataL( aMessage );
+            break;
+
+        case EDeleteMeteringData:
+            DeleteMeteringDataL( aMessage );
+            break;
+
+        default:
+            DRMLOG( _L( "CDRMDbSession::DispatchL: Invalid command" ) );
+            User::Leave( KErrNotSupported );
+        }
+
+    // The message has already completed successfully.
+    DRMLOG2( _L( "CDRMDbSession::ServiceL ok (%08x)"), aMessage.Handle() );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMRightsServer::ServiceError
+// Completes the request with given error code if the request is still pending.
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::ServiceError( const RMessage2& aMessage, TInt aError )
+    {
+    DRMLOG2( _L( "CDRMDbSession::ServiceError: error %d" ), aError );
+
+    if ( !aMessage.IsNull() )
+        {
+        aMessage.Complete( aError );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::ConstructL
+// Second phase constructor.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::ConstructL()
+    {
+    iRoapClientConnected = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::AddRecord
+// Get the information from the client, construct a rights object, and add
+// it to the database.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::AddRecordL(
+    const RMessage2& aMessage,
+    TProtectionType aProtection )
+    {
+    DRMLOG( _L( "CDRMDbSession::AddRecordL" ) );
+    //__UHEAP_MARK;
+
+    CDRMPermission* permission = NULL;
+    HBufC8* wrappedcek = NULL;
+    HBufC8* cek = NULL;
+    HBufC8* CID = NULL;
+    HBufC8* rightsData = NULL;
+    TInt size = 0;
+    TPtr8 data( NULL, 0 );
+    TDRMUniqueID UID;
+
+
+    CDRMEventAddRemove* event = CDRMEventAddRemove::NewLC( ERightsObjectRecieved );
+    TRequestStatus status;
+
+    SanitizeL( aMessage.GetDesLength(0) );
+    SanitizeL( aMessage.GetDesLength(1) );
+
+    size = User::LeaveIfError( IPCGETDESLEN1 );
+    rightsData = HBufC8::NewMaxLC( size );
+    data.Set( const_cast< TUint8* >( rightsData->Ptr() ), 0, size );
+    IPCREAD1L( data );
+    permission = CDRMPermission::NewLC();
+    permission->ImportL( data );
+
+    UpdateSecureTime();
+
+    // Determine whether the RO is legal.
+    if ( ( ( permission->iAvailableRights & ERightsPlay ) &&
+           ( Invalid( *permission->iPlay ) ) ) ||
+         ( ( permission->iAvailableRights & ERightsDisplay ) &&
+           ( Invalid( *permission->iDisplay ) ) ) ||
+         ( ( permission->iAvailableRights & ERightsExecute ) &&
+           ( Invalid( *permission->iExecute ) ) ) ||
+         ( ( permission->iAvailableRights & ERightsPrint ) &&
+           ( Invalid( *permission->iPrint ) ) ) ||
+         ( ( permission->iAvailableRights & ERightsTopLevel ) &&
+           ( Invalid( *permission->iTopLevel ) ) ) )
+        {
+        User::Leave( ENoRights );
+        }
+
+    size = User::LeaveIfError( IPCGETDESLEN0 );
+    CID = HBufC8::NewLC( size );
+
+    size = User::LeaveIfError( IPCGETDESLEN2 );
+
+    // Always reserve enough space for a key, if it's 0 then it is, length will be as well.
+    size = size > KDCFKeySize ? size : KDCFKeySize;
+    if( size > KSanityDataLengthHigh )
+        {
+        User::Leave(KErrArgument);
+        }
+    wrappedcek = HBufC8::NewLC( size );
+
+    data.Set( CID->Des() );
+    IPCREAD0L( data );
+
+    data.Set( wrappedcek->Des() );
+    IPCREAD2L( data );
+
+
+    if ( aProtection != ENoProtection )
+        {
+        if(!iRek.Length())
+            {
+            User::Leave(KErrNotReady);
+            }
+
+        cek = OmaCrypto::AesUnwrapL(iRek, *wrappedcek);
+        CleanupStack::PopAndDestroy( wrappedcek );
+        CleanupStack::PushL( cek );
+        }
+    else
+        {
+        cek = wrappedcek;
+        }
+
+    DRMLOG(_L("CEK:"));
+    DRMLOGHEX(( *cek ));
+
+    if ( permission->iOriginalInsertTime == Time::NullTTime() )
+        {
+        permission->iOriginalInsertTime = iTrustedTime;
+        }
+
+    DRMDB.AddDBEntryL( *CID, *permission, *cek, UID );
+
+    // Remove a rights object from the xoma list if it is there
+    RPointerArray<CDRMXOma>& array = XOMAHEADER;
+    TInt i = 0;
+
+    for( ; i < array.Count(); i++ )
+        {
+        // if the content id is found, remove it from the list
+        if( !CID->Compare( array[i]->ContentID() ) )
+            {
+            delete array[i];
+            array.Remove( i );
+            break;
+            }
+        }
+
+    // Write the UID back to the client.
+    data.Set( reinterpret_cast< TUint8* >( &UID ), sizeof( UID ),
+        sizeof( UID ) );
+    IPCWRITE3L( data );
+
+    // Notify clients
+    event->SetContentIDL(CID->Des());
+
+    DRMNOTIFIER.SendEventL(*event,status);
+    User::WaitForRequest(status);
+
+    CleanupStack::PopAndDestroy( 5 ); // cek, CID, permission, data, event
+
+    aMessage.Complete( KErrNone );
+
+    //__UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::AddRecordL done" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::GetRecordL
+// Get record.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetRecordL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::GetRecordL" ) );
+
+    CDRMPermission* object = NULL;
+    TInt size = 0;
+    TPckg< TInt > package( size );
+    TDRMUniqueID id;
+    HBufC8* CID = NULL;
+    TPtr8 data( reinterpret_cast< TUint8* >( &id ), 0, sizeof( id ) );
+
+    // Cleanup.
+    if ( iPreparedData )
+        {
+        delete iPreparedData;
+        iPreparedData = NULL;
+        }
+
+    IPCREAD2L( data );
+
+    SanitizeL( aMessage.GetDesLength(3) );
+    CID = HBufC8::NewLC( IPCGETDESLEN3 );
+
+    data.Set( CID->Des() );
+    IPCREAD3L( data );
+
+    object = DRMDB.GetDBEntryByContentIDL( *CID, id );
+    CleanupStack::PushL( object );
+
+    // modify the times in the rights object to UI time
+    UpdateSecureTime();
+    TTime currentTime;
+    currentTime.HomeTime();
+    TTimeIntervalMicroSeconds change = currentTime.Int64() - iTrustedTime.Int64();
+    ModifyRightsObjectByTimeL( object, change, ETrue );
+
+    iPreparedData = object->ExportL();
+    size = iPreparedData->Length();
+
+    IPCWRITE0L( package );
+
+    CleanupStack::PopAndDestroy( object );
+    CleanupStack::PopAndDestroy( CID );
+
+    aMessage.Complete( KErrNone );
+
+    DRMLOG( _L( "CDRMDbSession::GetRecordL ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::GetEntryListL
+// Create a temporary file from RPointerArray list the database created.
+// Return the file name to the client. In case of an error, the temporary file
+// is deleted.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetEntryListL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::GetEntryListL" ) );
+    __UHEAP_MARK;
+
+    TFileName tmpFile( KNullDesC );
+    HBufC8* CID = NULL;
+    TPtr8 data( NULL, 0 );
+
+    SanitizeL( aMessage.GetDesLength(1));
+
+    CID = HBufC8::NewLC( IPCGETDESLEN1 );
+
+
+    TDeleteFile dodeletefile =
+        {
+        &RFSSESSION,
+        &tmpFile
+        };
+
+    CDRMPermissionList* list = CDRMPermissionList::NewLC();
+    list->SetAutoCleanup( ETrue );
+
+    data.Set( CID->Des() );
+    IPCREAD1L( data );
+
+    DRMDB.GetDBEntryByContentIDL( *CID, *list );
+
+    // Exclude domain rights where we are not part of the domain
+    RemoveInvalidPermissionsL( list );
+    if ( list->Count() == 0 )
+        {
+        User::Leave( KErrCANoRights );
+        }
+
+    // modify the times in the rights object to UI time
+    UpdateSecureTime();
+    TTime currentTime;
+    currentTime.HomeTime();
+    TTimeIntervalMicroSeconds change = currentTime.Int64() - iTrustedTime.Int64();
+    ModifyTimesInListL( list, change, ETrue );
+
+    // Delete the file if something goes wrong.
+    TCleanupItem fileCleanup( DeleteFile, &dodeletefile );
+    CleanupStack::PushL( fileCleanup );
+
+    // Convert the list to a permanent file store.
+    ListToFileL( *list, tmpFile );
+
+    // It is virtually impossible to make WriteL to leave in this case,
+    // but anything is still possible...
+    IPCWRITE0L( tmpFile );
+
+    CleanupStack::Pop( &dodeletefile );
+    CleanupStack::PopAndDestroy( 2 ); // list, CID
+
+    __UHEAP_MARKEND;
+
+    // All done
+    aMessage.Complete( KErrNone );
+
+    DRMLOG( _L( "CDRMDbSession::GetEntryListL: ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::DeleteL
+// Delete all rights objects with a certain CID.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::DeleteL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::DeleteL" ) );
+    __UHEAP_MARK;
+    TPtr8 data( NULL, 0 );
+
+    // Check for VendorId
+
+    _LIT_SECURITY_POLICY_V0(vidCheck, VID_DEFAULT); // Check Default VID
+    if ( !vidCheck().CheckPolicy(iClient) )
+        {
+        User::Leave( KErrAccessDenied );
+        }
+
+    CDRMEventAddRemove* event = CDRMEventAddRemove::NewLC( ERightsObjectDeletedAll );
+    TRequestStatus status;
+
+    HBufC8* CID = HBufC8::NewLC(
+        User::LeaveIfError( IPCGETDESLEN2 ) );
+
+    data.Set( CID->Des() );
+
+    IPCREAD2L( data );
+
+
+    // Check if deletion is allowed:
+    if( DeleteAllowedL( *CID ) )
+        {
+        DRMDB.DeleteDBEntryL( *CID );
+
+        // Notify
+        event->SetContentIDL(CID->Des());
+
+        DRMNOTIFIER.SendEventL(*event,status);
+        User::WaitForRequest(status);
+        }
+    CleanupStack::PopAndDestroy( 2 ); // CID, event
+    aMessage.Complete( KErrNone );
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::DeleteL ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::DeleteRecordL
+// Delete a single RO.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::DeleteRecordL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::DeleteRecordL" ) );
+    __UHEAP_MARK;
+    TDRMUniqueID id;
+
+    _LIT_SECURITY_POLICY_V0(vidCheck, VID_DEFAULT); // Check Default VID
+    if ( !vidCheck().CheckPolicy(iClient) )
+        {
+        User::Leave( KErrAccessDenied );
+        }
+
+    CDRMEventAddRemove* event = CDRMEventAddRemove::NewLC( ERightsObjectDeleted );
+    TRequestStatus status;
+
+    TPtr8 data(
+        reinterpret_cast< TUint8* >( &id ), 0, sizeof( TDRMUniqueID ) );
+
+    HBufC8* CID = HBufC8::NewLC(
+        User::LeaveIfError( IPCGETDESLEN3 ) );
+
+    IPCREAD0L( data );
+
+    data.Set( CID->Des() );
+    IPCREAD3L( data );
+
+    // Check if deletion is allowed:
+    if( DeleteAllowedL( *CID ) )
+        {
+        DRMDB.DeleteDBEntryL( *CID, id );
+
+        event->SetContentIDL( CID->Des() );
+
+        DRMNOTIFIER.SendEventL( *event, status );
+        User::WaitForRequest( status );
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // CID, event
+
+    aMessage.Complete( KErrNone );
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::DeleteRecordL ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::ExportCIDsL
+// Create a temporary file for rights database to export the CIDs,
+// and write the file name to the client.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::ExportCIDsL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::ExportCIDsL" ) );
+    __UHEAP_MARK;
+
+    TFileName fileName( KNullDesC );
+    TDeleteFile deletefile =
+        {
+        &RFSSESSION,
+        &fileName
+        };
+
+    TCleanupItem item( DeleteFile, &deletefile );
+    CleanupStack::PushL( item );
+
+    DRMDB.ExportContentIDListL( fileName );
+
+    IPCWRITE0L( fileName );
+
+    CleanupStack::Pop( &deletefile );
+
+    aMessage.Complete( KErrNone );
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::ExportCIDsL: ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::GetKeyL
+// Ask for a list of rights object based on the given CID.
+// If there is even one rights object which allows the required consuming
+// operation, get the key from database updating the RO if necessary.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetKeyL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::GetKeyL" ) );
+    __UHEAP_MARK;
+    // If credentials haven't been checked, don't return the key
+    if (iCredentialsChecked == ECheckedAndAllowed)
+        {
+        if (iCek.Length() > 0)
+            {
+            aMessage.Write(2, iCek);
+            aMessage.Complete(KErrNone);
+            }
+        else
+            {
+            aMessage.Complete(KErrCANoRights);
+            }
+        }
+    else
+        {
+        aMessage.Complete(KErrAccessDenied);
+        }
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::GetKeyL: Ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::CheckRightsL
+// Check if there are sufficient rights at the moment. Nothing is changed from
+// the database.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::CheckRightsL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::CheckRightsL" ) );
+    TIntent intent;
+    TInt length = 0;
+    CDRMPermission* child = NULL;
+    HBufC8* cid = NULL;
+    HBufC8* buffer = NULL;
+    TPtr8 tmp( NULL, 0, 0 );
+    TInt r = KErrNone;
+    TInt size = 0;
+    TPckg<TInt> package( size );
+    TTime currentTime;
+    TTimeIntervalMicroSeconds change;
+    TUint32 reason = 0;
+    TPckg<TUint32> package2( reason );
+    TInt error = KErrNone;
+    HBufC8* uri = NULL;
+
+    delete iPreparedData;
+    iPreparedData = NULL;
+    intent = static_cast<TIntent>( aMessage.Int0() );
+    DRMLOG2(_L("Intent: %d"), intent);
+
+    if ( intent == EPlay || intent == EView ||
+         intent == EExecute || intent == EPrint || intent == EUnknown )
+        {
+        length = User::LeaveIfError( aMessage.GetDesLength( 1 ) );
+        cid = HBufC8::NewLC( length );
+        tmp.Set( cid->Des() );
+        aMessage.ReadL( 1, tmp );
+        DRMLOG(_L("CID:"));
+        DRMLOGHEX(tmp);
+        error = FindRightsObject( intent, *cid, child, uri, reason );
+        delete uri;
+        uri = NULL; // URI not used anywhere
+
+        // if an error occurs we still need to write the information to the client,
+        // but then we can leave
+        if( error )
+            {
+            aMessage.WriteL( 3, package2 );
+            User::Leave( error );
+            }
+
+        CleanupStack::PopAndDestroy( cid );
+        CleanupStack::PushL( child );
+        }
+    else if ( intent == EInstall || intent == EPeek )
+        {
+        length = User::LeaveIfError( aMessage.GetDesLength( 1 ) );
+        cid = HBufC8::NewLC( length );
+        tmp.Set( cid->Des() );
+        aMessage.ReadL( 1, tmp );
+        DRMLOG(_L("CID:"));
+        DRMLOGHEX(tmp);
+
+        // If we have the key, install and peek always have full rights
+        buffer = DRMDB.GetDecryptionKeyL( *cid );
+        CleanupStack::PopAndDestroy( cid );
+
+        if ( buffer )
+            {
+            delete buffer;
+            child = CDRMPermission::NewL();
+            CleanupStack::PushL( child );
+            child->iAvailableRights = ERightsAll;
+            }
+        else
+            {
+            r = KErrCANoRights;
+            }
+        }
+    else if ( ( intent == EPause || intent == EContinue || intent == EStop ) &&
+        iConsume )
+        {
+        // These intents only make sense if we have an ongoing session
+        child = CDRMPermission::NewL();
+        CleanupStack::PushL( child );
+        child->DuplicateL( iConsume->GetChild() );
+        }
+    else
+        {
+        r = KErrArgument;
+        }
+
+    if ( child )
+        {
+        UpdateSecureTime();
+        currentTime.HomeTime();
+        change = currentTime.Int64() - iTrustedTime.Int64();
+        ModifyRightsObjectByTimeL( child, change, ETrue );
+        iPreparedData = child->ExportL();
+        size = iPreparedData->Length();
+        aMessage.WriteL( 2, package );
+        CleanupStack::PopAndDestroy( child );
+        }
+
+    aMessage.Complete( r );
+
+    DRMLOG2( _L( "CDRMDbSession::CheckRightsL: ok (%d)" ), r );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::CountL
+// Tell the client how many ROs there are.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::CountL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::CountL" ) );
+    __UHEAP_MARK;
+    TInt count = DRMDB.GetAmountOfRightsObjectsL();
+
+    TPtr8 data( reinterpret_cast< TUint8* >( &count ),
+                sizeof( TInt ),
+                sizeof( TInt ) );
+
+    IPCWRITE0L( data );
+
+    aMessage.Complete( KErrNone );
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::CountL: ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::DeleteAll
+// Delete all ROs.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::DeleteAllL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::DeleteAllL" ) );
+
+    User::LeaveIfError( VerifyCredentials(NULL, NULL, EUnknown) );
+    if( iCredentialsChecked == ECheckedAndDenied )
+        {
+        User::Leave( KErrPermissionDenied );
+        }
+
+    //__UHEAP_MARK;
+
+    DRMDB.DeleteDBL();
+
+    REPLAYCACHE.Close();
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    #ifdef RD_DRM_METERING
+    METERINGDB.Close();
+    RFSSESSION.Delete( KMeteringDataBaseFile );
+    METERINGDB.InitL( KMeteringDataBaseFile );
+    #endif
+
+    RFSSESSION.Delete( KTimedReplayCacheFile );
+    RFSSESSION.Delete( KPlainReplayCacheFile );
+
+    REPLAYCACHE.InitL( KTimedReplayCacheFile, KPlainReplayCacheFile );
+
+#else //RD_MULTIPLE_DRIVE
+
+    TFileName tempPath;
+    TFileName tempPath2;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+
+    RFSSESSION.DriveToChar( driveNumber, driveLetter );
+
+    #ifdef RD_DRM_METERING
+    tempPath.Format( KMeteringDataBaseFile, (TUint)driveLetter );
+
+    METERINGDB.Close();
+    RFSSESSION.Delete( tempPath );
+    METERINGDB.InitL( tempPath );
+    #endif
+
+    tempPath.Format( KTimedReplayCacheFile, (TUint)driveLetter );
+    tempPath2.Format( KPlainReplayCacheFile, (TUint)driveLetter );
+
+    RFSSESSION.Delete( tempPath );
+    RFSSESSION.Delete( tempPath2 );
+
+    REPLAYCACHE.InitL( tempPath, tempPath2 );
+
+#endif
+
+    if ( !iRoapClientConnected )
+        {
+        User::LeaveIfError( iRoapClient.Connect() );
+        iRoapClientConnected = ETrue;
+        }
+
+    iRoapClient.DeleteAllL();
+
+    aMessage.Complete( KErrNone );
+    //__UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::DeleteAllL ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::ListToFileL
+// Convert the list to a file representation.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::ListToFileL( RPointerArray< CDRMPermission >& aList,
+                                 TFileName& aFile )
+    {
+    __UHEAP_MARK;
+    DRMLOG( _L( "CDRMDbSession::ListToFileL" ) );
+
+    TInt count( 0 );
+
+
+    RFileWriteStream fileStream;
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    User::LeaveIfError(
+        fileStream.Temp( RFSSESSION,
+                         KDRMDbTempPath,
+                         aFile,
+                         EFileWrite | EFileStream ) );
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+
+    RFSSESSION.DriveToChar( driveNumber, driveLetter );
+
+    TFileName dbTempPath;
+    dbTempPath.Format( KDbTempPath, (TUint)driveLetter );
+
+    User::LeaveIfError(
+      fileStream.Temp( RFSSESSION,
+                       dbTempPath,
+                       aFile,
+                       EFileWrite | EFileStream ) );
+
+#endif
+
+    CleanupClosePushL( fileStream );
+
+    TInt size( sizeof( TUint32 ) ); // streams store also other info there.
+
+    for( count = 0; count < aList.Count(); count++ )
+        {
+        size += aList[ count ]->Size();
+        }
+
+    // Reset count variable:
+    count = 0;
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &RFSSESSION,
+                                                size,
+                                                EDriveC ) )
+
+#else //RD_MULTIPLE_DRIVE
+
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &RFSSESSION,
+                                                size,
+                                                driveNumber ) )
+
+#endif
+        {
+        DRMLOG( _L( "CDRMDbSession::ListToFileL: KErrDiskFull" ) );
+        User::Leave( KErrDiskFull );
+        }
+
+    fileStream.WriteInt32L( aList.Count() );
+
+    // Write the whole stuff into the file.
+    // URIs are ignored. No use to put them to file (always the same
+    // and the client knows it already).
+    while( count < aList.Count() )
+        {
+        aList[ count ]->ExternalizeL( fileStream );
+        ++count;
+        }
+
+    fileStream.CommitL();
+
+    CleanupStack::PopAndDestroy( &fileStream );
+
+    DRMLOG( _L( "CDRMDbSession::ListToFileL: ok" ) );
+    __UHEAP_MARKEND;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::FindRightsObjectL
+// Try to locate the best RO from the given list which allows consuming of
+// content.
+// If end time is defined or an interval activated, the smallest endtime
+// is always chosen first.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::FindRightsObjectL( TIntent aIntent,
+                                       const TDesC8& aURI,
+                                       CDRMPermission*& aChild,
+                                       HBufC8*& aUsedURI,
+                                       TUint32& aReason )
+    {
+    DRMLOG( _L( "CDRMDbSession::FindRightsObjectL" ) );
+    TInt res = KErrNotFound;
+
+    if ( aUsedURI || aChild )
+        {
+        // Check that return parameters are null initially.
+        User::Leave( KErrArgument );
+        }
+
+    CDRMPermissionList *perms = CDRMPermissionList::NewLC();
+    TTime time;
+
+    perms->SetAutoCleanup( ETrue );
+    DRMDB.GetDBEntryByContentIDL( aURI , *perms );
+
+    UpdateSecureTime();
+
+    if ( iSecureTime )
+        {
+        time = iTrustedTime;
+        }
+    else
+        {
+        time = Time::NullTTime();
+        }
+
+    if ( aIntent == EPeek || aIntent == EInstall )
+        {
+        // There is at least one RO available.
+        // Use any RO, whether they are valid or not.
+        // Pick the first RO in the list.
+
+        aChild = (*perms)[0];
+        (*perms).Remove( 0 );
+
+        CleanupStack::PopAndDestroy( perms );
+        return;
+        }
+    else if ( aIntent == EUnknown )
+        {
+        // Pick one that works, no matter what the intent is
+        for ( TInt i = 0; res == KErrNotFound && i < perms->Count(); i++ )
+            {
+            if ( (*perms)[i]->Valid( time, IMSI, aReason ) )
+                {
+                res = i;
+                }
+            }
+        if ( res != KErrNotFound )
+            {
+            aChild = (*perms)[res];
+            perms->Remove( res );
+            }
+        else
+            {
+            User::Leave( KErrCANoPermission );
+            }
+        }
+    else
+        {
+        res = FindBestROsL( *perms, aURI, aIntent, aUsedURI, aReason );
+        if ( res >= 0 )
+            {
+            aChild = (*perms)[res];
+            perms->Remove( res );
+            }
+        else
+            {
+            User::Leave( KErrCANoPermission );
+            }
+        }
+    CleanupStack::PopAndDestroy( perms );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::FindRightsObject
+// Try to locate the best RO from the given list which allows consuming of
+// content.
+// If end time is defined or an interval activated, the smallest endtime
+// is always chosen first.
+// -----------------------------------------------------------------------------
+//
+TInt CDRMDbSession::FindRightsObject( TIntent aIntent,
+                                      const TDesC8& aURI,
+                                      CDRMPermission*& aChild,
+                                      HBufC8*& aUsedURI,
+                                      TUint32& aReason )
+    {
+    DRMLOG( _L( "CDRMDbSession::FindRightsObject" ) );
+    TInt error = KErrNone;
+
+    TRAP( error, FindRightsObjectL( aIntent, aURI, aChild, aUsedURI, aReason ) );
+    if ( ( error == KErrCANoRights || error == KErrCANoPermission ) &&
+        PendingRights(aURI) )
+        {
+        error = KErrCAPendingRights;
+        }
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::CheckConsumeL
+// Check if Consume is possible
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::CheckConsumeL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::CheckConsumeL" ) );
+
+    __UHEAP_MARK;
+
+    HBufC8* CID = NULL;
+    TPtr8 cid( NULL, 0, 0 );
+    TInt length = 0;
+    TIntent intent;
+    TUint32 reason = 0;
+
+    length = User::LeaveIfError( IPCGETDESLEN1 );
+    CID = HBufC8::NewLC( length );
+    cid.Set( CID->Des() );
+    IPCREAD1L( cid );
+    intent = static_cast<TIntent>(aMessage.Int0());
+
+    // Check only intents which are actually consuming something. All others
+    // always succeed, because CheckConsume is called by default when a file
+    // is opened.
+    if ( intent == EPlay || intent == EView ||
+         intent == EExecute || intent == EPrint || intent == EUnknown )
+        {
+        // Count constraints are valid for the duration of the
+        // session after they have been consumed earlier
+        if ( !( iConsume && iConsume->CountConstraintActive() ||
+                SERVER->HasActiveCountConstraint( *CID ) ) )
+            {
+            CDRMPermission* child( NULL );
+            HBufC8* uri( NULL );
+            TInt error( FindRightsObject( intent, *CID, child, uri, reason ) );
+            delete child;
+            delete uri;
+            User::LeaveIfError( error );
+            }
+        }
+/* Enable this code as soon as clients use EUnknown, and it is safe to fail
+   when no key is available
+    else if ( intent == EPeek || EInstall )
+        {
+        // We need at least the key for peek and install. This will leave if no
+        // key is there.
+        HBufC8* key = DRMDB.GetDecryptionKeyL( *CID );
+        delete key;
+        }
+*/
+
+    CleanupStack::PopAndDestroy( CID );
+    aMessage.Complete( KErrNone );
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::CheckConsumeL: ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::ConsumeL
+// Consume the right and register the consumption.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::ConsumeL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::ConsumeL" ) );
+
+    const TIntent intent = static_cast<TIntent>(aMessage.Int0());
+    HBufC8* CID = NULL;
+    TInt length = 0;
+    TPtr8 cid( NULL, 0, 0 );
+
+    length = User::LeaveIfError( IPCGETDESLEN1 );
+
+    CID = HBufC8::NewLC( length );
+
+    cid.Set( CID->Des() );
+    IPCREAD1L( cid );
+
+    if ( intent != EUnknown )
+        {
+        if ( intent == EPeek || intent == EInstall )
+            {
+            User::LeaveIfError( VerifyCredentials( CID, NULL, intent ) );
+            }
+        else
+            {
+            if ( intent == EPlay ||
+                 intent == EView ||
+                 intent == EExecute ||
+                 intent == EPrint ||
+                 intent == EStop )
+                {
+
+                if ( iConsume )
+                    {
+                    delete iConsume;
+                    iConsume = NULL;
+                    }
+                if ( intent != EStop )
+                    {
+                    CDRMConsume* consume( NULL );
+                    consume = CDRMConsume::NewLC( *this, *CID, NULL );
+                    consume->HandleL( intent );
+                    CleanupStack::Pop( consume );
+                    iConsume = consume;
+                    }
+                }
+            else
+                {
+                if ( !iConsume )
+                    {
+                    User::Leave( KErrNotReady );
+                    }
+
+                if ( intent == EPause )
+                    {
+                    iConsume->Pause();
+                    }
+                else if ( intent == EContinue )
+                    {
+                    iConsume->ContinueL();
+                    }
+                else
+                    {
+                    iConsume->Stop();
+                    }
+                }
+            }
+        }
+    else
+        {
+        // None of the other intents are allowed here, fail
+        User::Leave( KErrArgument );
+        }
+
+
+    CleanupStack::PopAndDestroy( CID );
+    aMessage.Complete( KErrNone );
+    DRMLOG( _L( "CDRMDbSession::ConsumeL: ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::CalculatePaddingL
+//
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::CalculatePaddingL( const RMessage2& aMessage )
+    {
+    __UHEAP_MARK;
+    DRMLOG( _L( "CDRMDbSession::CalculatePaddingL" ) );
+
+    CAESDecryptor* decryptor( NULL );
+    TInt i( 0 );
+
+    TBuf8<KDCFKeySize * 2> data;
+    TBuf8<KDCFKeySize> iv;
+    TBuf8<KDCFKeySize> block;
+    TPtr8 tmp( NULL, 0, 0 );
+
+    aMessage.ReadL( 0, data );
+
+    // Check that the data we read is actually of the proper length
+    if( data.Length() != KDCFKeySize*2 )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    iv.Copy(data.Left(KDCFKeySize));
+    block.Copy(data.Right(KDCFKeySize));
+
+    if( iCek.Length() != KDRMKeyLength )
+        {
+        User::Leave(KErrNotReady);
+        }
+
+    decryptor = CAESDecryptor::NewLC(iCek);
+    decryptor->Transform(block);
+    CleanupStack::PopAndDestroy( decryptor );
+
+    for (i = 0; i < KDCFKeySize; i++)
+        {
+        block[i] ^= iv[i];
+        }
+
+    if ( block[ KDCFKeySize - 1 ] > 0 && block[ KDCFKeySize - 1 ] <= 16 )
+        {
+        for ( i = KDCFKeySize - block[ KDCFKeySize - 1 ];
+              i < KDCFKeySize - 1;
+              ++i )
+            {
+            if ( block[ i ] != block[ KDCFKeySize - 1 ] )
+                {
+                User::Leave( KErrCorrupt );
+                }
+            }
+
+        aMessage.Complete( block[ KDCFKeySize - 1 ] );
+        DRMLOG2( _L( "CDRMDbSession::CalculatePaddingL: Padding = %d" ),
+                 block[ KDCFKeySize - 1 ] );
+
+        return;
+        }
+
+    User::Leave( KErrCorrupt );
+
+__UHEAP_MARKEND;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::SecureTimeL
+// returns the secure time
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::SecureTimeL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::SecureTimeL" ) );
+    __UHEAP_MARK;
+    TPckgBuf< TInt64 > time;
+    TPckg< TBool > levelPckg( iSecureTime );
+
+    UpdateSecureTime();
+
+    time() = iTrustedTime.Int64();
+
+    IPCWRITE0L( time );
+    IPCWRITE1L( levelPckg );
+
+    aMessage.Complete( KErrNone );
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::SecureTime: ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::EncryptL
+//
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::EncryptL(const RMessage2& aMessage)
+    {
+    TBuf8<KDCFKeySize> iv;
+    HBufC8* data = NULL;
+    TPtr8 ptr(NULL, 0, 0);
+    TBool addPadding;
+    __UHEAP_MARK;
+
+    DRMLOG(_L("CDRMDbSession::EncryptL"));
+
+    if( iCek.Length() != KDRMKeyLength )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    SanitizeL( aMessage.GetDesLength(0) );
+
+    addPadding = aMessage.Int2() != 0 ? ETrue : EFalse;
+    aMessage.Read(0, iv);
+    data = HBufC8::NewLC(aMessage.GetDesMaxLength(1));
+    ptr.Set(data->Des());
+    aMessage.Read(1, ptr);
+
+    AesEncryptL( iCek, iv, addPadding, ptr );
+
+    aMessage.Write(1, ptr);
+    aMessage.Complete(KErrNone);
+    CleanupStack::PopAndDestroy( data );
+    __UHEAP_MARKEND;
+    DRMLOG(_L("CDRMDbSession::EncryptL: Ok"));
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::DecryptL
+// Decrypt data and return it to the caller, using the CEK for this session
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::DecryptL(const RMessage2& aMessage)
+    {
+    DRMLOG(_L("CDRMDbSession::DecryptL"));
+
+    // If credentials haven't been checked, do it now, check for expired rights
+    if (iCredentialsChecked == ECheckedAndDenied ||
+        iCredentialsChecked == ENotChecked &&
+        VerifyCredentials(iContentId, NULL, EUnknown) != KErrNone)
+        {
+        DRMLOG(_L("Decrypt failed: untrusted client"));
+        aMessage.Complete(KErrAccessDenied);
+        }
+    else if ( iConsume && iConsume->IsExpired() )
+        {
+        DRMLOG(_L("Decrypt failed: rights expired"));
+        aMessage.Complete(KErrCANoPermission);
+        }
+    else
+        {
+        if (iCek.Length() > 0)
+            {
+            TBuf8<KDCFKeySize> iv;
+            HBufC8* data = NULL;
+            TPtr8 ptr(NULL, 0, 0);
+            TBool removePadding;
+
+            removePadding = aMessage.Int2() != 0 ? ETrue : EFalse;
+            aMessage.Read(0, iv);
+
+            data = HBufC8::NewMaxLC(aMessage.GetDesMaxLength(1));
+
+            ptr.Set(data->Des());
+            aMessage.Read(1, ptr);
+
+            AesDecryptL( iCek,
+                         iv,
+                         removePadding,
+                         ptr );
+
+            aMessage.Write(1, ptr);
+            aMessage.Complete(KErrNone);
+            CleanupStack::PopAndDestroy( data );
+            }
+        else
+            {
+            aMessage.Complete(KErrCANoRights);
+            }
+        }
+    DRMLOG(_L("CDRMDbSession::DecryptL: Ok"));
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::InitializeKeyL
+// Initialize the CEK for this session based on the content ID. Also sets the
+// content ID for later usage.
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::InitializeKeyL( const RMessage2& aMessage )
+    {
+    TPtr8 tmp(NULL, 0, 0);
+    HBufC8* key = NULL;
+    TInt error = KErrNone;
+
+    DRMLOG( _L( "CDRMDbSession::InitializeKeyL"));
+    if ( iContentId )
+        {
+        delete iContentId;
+        iContentId = NULL;
+        }
+    iContentId  = HBufC8::NewL( User::LeaveIfError( IPCGETDESLEN0 ) );
+    tmp.Set( iContentId->Des() );
+    IPCREAD0L( tmp );
+
+    __UHEAP_MARK;
+    TRAP( error, key = DRMDB.GetDecryptionKeyL( *iContentId  ) );
+    if ( ( error == KErrCANoRights || error == KErrCANoPermission ) &&
+        PendingRights( *iContentId , EFalse ) )
+        {
+        error = KErrCAPendingRights;
+        }
+
+    if ( error == KErrNone )
+        {
+        iCek.Copy( *key );
+        delete key;
+        aMessage.Complete( KErrNone );
+        }
+    else
+        {
+        aMessage.Complete( error );
+        }
+    __UHEAP_MARKEND;
+    DRMLOG2( _L( "CDRMDbSession::InitializeKeyL: %d" ), error );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::InitializeGroupKeyL
+// Initialize the CEK for this session from a given group key
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::InitializeGroupKeyL(const RMessage2& aMessage )
+    {
+    HBufC8* groupId = NULL;
+    HBufC8* groupKey = NULL;
+    TPtr8 tmp(NULL, 0, 0 );
+    HBufC8* key = NULL;
+    TRequestStatus status;
+    CAESDecryptor* aes = NULL;
+    CModeCBCDecryptor* cbc = NULL;
+
+    __UHEAP_MARK;
+
+    SanitizeL( aMessage.GetDesLength(0) );
+    SanitizeL( aMessage.GetDesLength(1) );
+
+    DRMLOG(_L("CDRMDbSession::InitializeGroupKeyL"));
+    if (aMessage.Int2() == EMethodAES_128_CBC)
+        {
+        groupId = HBufC8::NewLC(aMessage.GetDesLength(0));
+        tmp.Set(groupId->Des());
+        aMessage.Read(0, tmp);
+
+        groupKey = HBufC8::NewLC(aMessage.GetDesLength(1));
+        tmp.Set(groupKey->Des());
+        aMessage.Read(1, tmp);
+
+        key = DRMDB.GetDecryptionKeyL(*groupId);
+        CleanupStack::PushL(key);
+
+        if ( key )
+            {
+            aes = CAESDecryptor::NewLC(*key);
+            cbc = CModeCBCDecryptor::NewL(aes, groupKey->Left(KDCFKeySize));
+            CleanupStack::Pop( aes );
+            iCek.Copy(groupKey->Mid(KDCFKeySize, KDCFKeySize));
+            cbc->Transform(iCek);
+            delete cbc;
+            aMessage.Complete(KErrNone);
+            }
+        else
+            {
+            aMessage.Complete(KErrCANoRights);
+            }
+        CleanupStack::PopAndDestroy(3); // key, groupKey, groupId
+        }
+    else
+        {
+        aMessage.Complete(KErrNotSupported);
+        }
+
+    __UHEAP_MARKEND;
+    DRMLOG(_L("CDRMDbSession::InitializeGroupKeyL: Ok"));
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::GetPreparedDataL
+// Returns data which has been allocated before
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetPreparedDataL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::GetPreparedDataL" ) );
+
+    if( !iPreparedData )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    if( iPreparedData->Length() > aMessage.GetDesMaxLength(0) )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    IPCWRITE0L( iPreparedData->Des() );
+
+    aMessage.Complete( KErrNone );
+    DRMLOG( _L( "CDRMDbSession::GetPreparedDataL: ok" ) );
+
+    // Delete the data
+    delete iPreparedData;
+    iPreparedData = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::IsInCacheL
+// Checks whether the given entry is in replay cache or not.
+// -----------------------------------------------------------------------------
+void CDRMDbSession::IsInCacheL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::IsInCacheL" ) );
+
+    HBufC8* buf = HBufC8::NewLC(
+        User::LeaveIfError( IPCGETDESLEN0 ) );
+
+    TPckgBuf< TBool > res;
+    TPtr8 data( buf->Des() );
+
+    IPCREAD0L( data );
+
+    if ( aMessage.Ptr1() )
+        {
+        TPckgBuf< TTime > time;
+
+        IPCREAD1L( time );
+
+        res = REPLAYCACHE.InCacheL( *buf, time() );
+        }
+    else
+        {
+        res = REPLAYCACHE.InCacheL( *buf );
+        }
+
+    CleanupStack::PopAndDestroy( buf );
+
+    IPCWRITE2L( res );
+
+    aMessage.Complete( KErrNone );
+
+    DRMLOG( _L( "CDRMDbSession::IsInCache ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::AddToCacheL
+// Adds an entry to replay cache.
+// -----------------------------------------------------------------------------
+void CDRMDbSession::AddToCacheL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::AddToCacheL" ) );
+
+    HBufC8* buf = NULL;
+
+    UpdateSecureTime();
+
+    if ( !iSecureTime )
+        {
+        // DoSomething!
+        }
+
+    buf = HBufC8::NewLC(
+        User::LeaveIfError( IPCGETDESLEN0 ) );
+
+    TPtr8 data( buf->Des() );
+
+    IPCREAD0L( data );
+
+    if ( aMessage.Ptr1() )
+        {
+        TPckgBuf< TTime > time;
+
+        IPCREAD1L( time );
+
+        REPLAYCACHE.AddL( *buf, time(), iTrustedTime );
+        }
+
+    else
+        {
+        REPLAYCACHE.AddL( *buf, iTrustedTime );
+        }
+
+    CleanupStack::PopAndDestroy( buf );
+
+    aMessage.Complete( KErrNone );
+
+    DRMLOG( _L( "CDRMDbSession::AddToCacheL ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::AddDomainROL
+// Add domain ro xml data
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::AddDomainROL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::AddDomainROL" ) );
+    __UHEAP_MARK;
+    HBufC8* RoId = NULL;
+    HBufC8* XMLData = NULL;
+    TInt size = 0;
+    TPtr8 data( NULL, 0 );
+
+    size = User::LeaveIfError( IPCGETDESLEN0 );
+    RoId = HBufC8::NewLC( size );
+
+    size = User::LeaveIfError( IPCGETDESLEN1 );
+    XMLData = HBufC8::NewLC( size );
+
+    data.Set( RoId->Des() );
+    IPCREAD0L( data );
+
+    data.Set( XMLData->Des() );
+    IPCREAD1L( data );
+
+    DRMDB.AddDomainROL( *RoId, *XMLData );
+
+    CleanupStack::PopAndDestroy( 2 ); // RoId, XMLData
+
+    aMessage.Complete( KErrNone );
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::AddDomainROL done" ) );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::GetDomainROL
+// Get domain ro xml data
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetDomainROL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::GetDomainROL" ) );
+
+    TInt size = 0;
+    TPckg< TInt > package( size );
+    HBufC8* RoId = NULL;
+    TPtr8 data(NULL, 0);
+
+    // Cleanup.
+    if ( iPreparedData )
+        {
+        delete iPreparedData;
+        iPreparedData = NULL;
+        }
+
+    size = User::LeaveIfError( IPCGETDESLEN1 );
+
+    RoId = HBufC8::NewLC( size );
+
+    data.Set( RoId->Des() );
+    IPCREAD1L( data );
+
+    iPreparedData = DRMDB.GetDomainROL( *RoId );
+
+    size = iPreparedData->Length();
+
+    IPCWRITE0L( package );
+
+    CleanupStack::PopAndDestroy( RoId );
+
+    aMessage.Complete( KErrNone );
+
+    DRMLOG( _L( "CDRMDbSession::GetDomainROL ok" ) );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::DeleteDomainROL
+// Delete domain ro xml data
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::DeleteDomainROL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::DeleteDomainROL" ) );
+    __UHEAP_MARK;
+    TPtr8 data( NULL, 0 );
+    TInt size = 0;
+
+    size = User::LeaveIfError( IPCGETDESLEN0 );
+
+
+    HBufC8* RoId = HBufC8::NewLC( size );
+
+    data.Set( RoId->Des() );
+
+    IPCREAD0L( data );
+
+    DRMDB.DeleteDomainROL( *RoId );
+
+    CleanupStack::PopAndDestroy( RoId );
+
+    aMessage.Complete( KErrNone );
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::DeleteDomainROL ok" ) );
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::GetDomainRosForCidL
+// Return the domain ROs for a content ID in a buffer. Each RO is preceded
+// by a length field
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetDomainRosForCidL(
+    const RMessage2& aMessage)
+    {
+    DRMLOG(_L("CDRMDbSession::GetDomainRosForCidL"));
+    TInt size(0);
+    TInt roSize(0);
+    TInt pos = 0;
+    TInt indexLatest = -1;
+    TTime timeStamp = 0;
+    TTime timeLatest = 0;
+    TPckg<TInt> pkg(size);
+    TPtr8 ptr(NULL, 0);
+    TPtrC8 elementPtr(KNullDesC8);
+    TPckg<TInt> roSizePkg(roSize);
+    HBufC8* element = NULL;
+    HBufC8* id(NULL);
+    HBufC8* ro(NULL);
+    CDRMPointerArray<CDRMPermission>*
+        rights( CDRMPointerArray<CDRMPermission>::NewLC() );
+    rights->SetAutoCleanup(ETrue);
+
+    delete iPreparedData;
+    iPreparedData = NULL;
+
+    SanitizeL( aMessage.GetDesLength(0) );
+
+    id = HBufC8::NewLC(aMessage.GetDesLength(0));
+    ptr.Set(id->Des());
+    aMessage.Read(0, ptr);
+
+    TRAPD(r, DRMDB.GetDBEntryByContentIDL(*id, *rights));
+
+    if (r == KErrCANoRights || r == KErrCANoPermission )
+        {
+        r = KErrNone;
+        }
+    User::LeaveIfError(r);
+
+    for (TInt i(0); i < rights->Count(); i++)
+        {
+        if ( (*rights)[i]->iDomainID )
+            {
+            ro = DRMDB.GetDomainROL(*(*rights)[i]->iRoID);
+            CleanupStack::PushL(ro);
+
+            elementPtr.Set(ExtractElement(*ro, KTimeStamp, pos));
+
+            /* Check whether the timestamp was found or not and whether it is
+               the newest one so far or not */
+            if (pos >= 0)
+                {
+                element = elementPtr.AllocLC();
+                timeStamp = Iso8601ToTime(*element);
+                CleanupStack::PopAndDestroy(element);
+
+                if (timeStamp > timeLatest)
+                    {
+                    indexLatest = i;
+                    }
+                }
+            CleanupStack::PopAndDestroy(ro);
+            ro = NULL;
+            }
+        pos = 0;
+        }
+
+    /* At least one timestamp was found */
+    if (indexLatest >= 0 && indexLatest < rights->Count())
+        {
+        ro = DRMDB.GetDomainROL(*(*rights)[indexLatest]->iRoID);
+        CleanupStack::PushL(ro);
+
+        roSize = ro->Size();
+        if ( !iPreparedData )
+            {
+            iPreparedData = HBufC8::NewL(sizeof (TInt) + roSize);
+            }
+        else
+            {
+            iPreparedData = iPreparedData->ReAllocL(
+                size + sizeof (TInt) + roSize );
+            }
+        ptr.Set(iPreparedData->Des());
+        ptr.Append(roSizePkg);
+        ptr.Append(*ro);
+        size += sizeof (TInt) + roSize;
+        CleanupStack::PopAndDestroy(ro);
+        }
+
+    aMessage.Write(1, pkg);
+    CleanupStack::PopAndDestroy( id );
+    CleanupStack::PopAndDestroy( rights );
+
+    aMessage.Complete(KErrNone);
+    DRMLOG(_L("CDRMDbSession::GetDomainRosForCidL ok"));
+    }
+
+
+//------------------------------------------------------------------------------
+// CDRMDbSession::DeleteExpiredPermissionsL
+// Delete expired permissions if we have secure time.
+//------------------------------------------------------------------------------
+void CDRMDbSession::DeleteExpiredPermissionsL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::DeleteExpiredPermissionsL" ) );
+    CDRMActiveOperation* active( NULL );
+    TTime time;
+
+    User::LeaveIfError( VerifyCredentials(NULL, NULL, EUnknown) );
+    if( iCredentialsChecked == ECheckedAndDenied )
+        {
+        User::Leave( KErrPermissionDenied );
+        }
+
+    UpdateSecureTime();
+
+    if ( iSecureTime )
+        {
+        time = iTrustedTime;
+        }
+    else
+        {
+        time = Time::NullTTime();
+        }
+
+    if ( iPendingRequest )
+        {
+        User::Leave( KErrAlreadyExists );
+        }
+
+    active = CDRMActiveOperation::NewLC( aMessage, *this,
+                                         CDRMActiveOperation::EOperationDeleteExpired );
+    active->ActivateL( DRMDB, iTrustedTime );
+
+    iPendingRequest = active;
+
+    CleanupStack::Pop( active );
+
+    DRMLOG( _L( "CDRMDbSession::DeleteExpiredPermissionsL ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::SetEstimatedArrivalL
+// set the estimated arrival time for the content uri
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::SetEstimatedArrivalL( const RMessage2& aMessage )
+    {
+    HBufC8* CID = NULL;
+    TFileName fileName;
+    TInt length = 0;
+    TPtr8 inRead( NULL, 0 );
+    TTimeIntervalSeconds interval = 0;
+    TPckg<TTimeIntervalSeconds> package( interval );
+    RPointerArray<CDRMXOma>& array = XOMAHEADER;
+    CDRMXOma* omaData = NULL;
+
+    // Read the content id
+    length = User::LeaveIfError( IPCGETDESLEN0 );
+    CID = HBufC8::NewLC( length );
+    inRead.Set( CID->Des() );
+    IPCREAD0L( inRead );
+
+    // Read the interval
+    IPCREAD1L( package );
+
+
+    for( TInt i = 0; i < array.Count(); i++ )
+        {
+        if( !CID->Compare( (array)[i]->ContentID() ) )
+            {
+            omaData = (array)[i];
+            break;
+            }
+        }
+
+    // Update the secure time
+    UpdateSecureTime();
+
+    if( omaData ) // Exists, update
+        {
+        omaData->SetWaitTimeL( interval );
+        omaData->SetTimeStampL( iTrustedTime );
+        }
+    else // Doesn't exist, create a new one
+        {
+        omaData = CDRMXOma::NewLC( *CID, iTrustedTime, interval );
+        array.AppendL( omaData );
+        CleanupStack::Pop( omaData );
+        }
+
+    CleanupStack::PopAndDestroy( CID );
+
+    // Complete the command
+    aMessage.Complete( KErrNone );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::GetEstimatedArrivalL
+// get the estimated arrival time for the content uri
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetEstimatedArrivalL( const RMessage2& aMessage )
+    {
+    HBufC8* CID = NULL;
+    TInt length = 0;
+    TPtr8 inRead( NULL, 0 );
+    RPointerArray<CDRMXOma>& array = XOMAHEADER;
+    CDRMXOma* omaData = NULL;
+    TInt64 interval = 0;
+    TInt i = 0;
+    TTimeIntervalSeconds result = 0;
+
+    // Read the content id
+    length = User::LeaveIfError( IPCGETDESLEN0 );
+    CID = HBufC8::NewLC( length );
+    inRead.Set( CID->Des() );
+    IPCREAD0L( inRead );
+
+    for( ; i < array.Count(); i++ )
+        {
+        if( !CID->Compare( (array)[i]->ContentID() ) )
+            {
+            omaData = (array)[i];
+            break;
+            }
+        }
+
+    // Update the secure time
+    UpdateSecureTime();
+
+    if( omaData ) // Exists, update
+        {
+
+        // Special case, the rights have expired before, but have not been removed
+        // so that we do not lose the notification
+        if( omaData->WaitTime().Int() == KErrCAPendingRights )
+            {
+            interval = -1; // Fixed value for this case:
+                           // -1 means the rights should have arrived already
+
+            delete omaData;
+            omaData = 0;
+
+            array.Remove( i );
+            }
+        else
+            {
+            // Update the secure time
+            UpdateSecureTime();
+
+            interval = omaData->WaitTime().Int();
+            interval -= ( iTrustedTime.Int64() - omaData->TimeStamp().Int64() ) /
+                KMicrosecondsToSecond;
+
+            if( interval <= 0 )
+                {
+                interval = -1; // Fixed value for this case:
+                               // -1 means the rights should have arrived already
+
+                // Clean up the data: if the function fails before this
+                // the instance remains like it should
+                delete omaData;
+                omaData = 0;
+
+                array.Remove( i ); // Remove from the array
+                }
+            }
+        result = I64INT(interval);
+        TPckg<TTimeIntervalSeconds> package( result );
+        IPCWRITE1L( package );
+        }
+    else // Doesn't exist, create a new one
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    CleanupStack::PopAndDestroy( CID );
+
+    // Complete the command
+    aMessage.Complete( KErrNone );
+    };
+
+
+
+//------------------------------------------------------------------------------
+// CDRMDbSession::PendingRights
+// Check if rights are pending
+//------------------------------------------------------------------------------
+TBool CDRMDbSession::PendingRights(const TDesC8& aCid, TBool aRemoval)
+    {
+    TBool f = EFalse;
+    RPointerArray<CDRMXOma>& array = XOMAHEADER;
+    CDRMXOma* omaData = NULL;
+    TInt64 interval = 0;
+    TInt i = 0;
+    TTimeIntervalSeconds result = 0;
+
+    for( ; i < array.Count() && !f; i++ )
+        {
+        if( !aCid.Compare( (array)[i]->ContentID() ) )
+            {
+            omaData = (array)[i];
+            // Exists and is different from KErrCAPendingRights -> update
+            if( omaData && omaData->WaitTime().Int() != KErrCAPendingRights )
+                {
+                // Update the secure time
+                UpdateSecureTime();
+                interval = omaData->WaitTime().Int();
+                interval -= ( iTrustedTime.Int64() - omaData->TimeStamp().Int64() ) /
+                    KMicrosecondsToSecond;
+
+                // check if removal from the list is needed
+                if( aRemoval && interval <= 0 )
+                    {
+                    TRAPD( error, omaData->SetWaitTimeL( KErrCAPendingRights ) );
+                    error = error; // remove error
+                    }
+                f = ETrue;
+                }
+            }
+        }
+    return f;
+    }
+
+
+
+//------------------------------------------------------------------------------
+// CDRMDbSession::GetUdtDataL
+// Gets the user data transfer header data
+//------------------------------------------------------------------------------
+void CDRMDbSession::GetUdtDataL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::GetUdtDataL" ) );
+    __UHEAP_MARK;
+    // Usage intent.
+    HBufC8* udtData = NULL;
+
+    // Get the key
+    udtData = DRMDB.GetUdtDataLC();
+
+    // Write the udt data to the client.
+    // This shouldn't fail anyway.
+    IPCWRITE0L( *udtData );
+
+    CleanupStack::PopAndDestroy( udtData );
+
+    aMessage.Complete( KErrNone );
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::GetUdtDataL: Ok" ) );
+    };
+
+//------------------------------------------------------------------------------
+// CDRMDbSession::InitiateUdtL
+// Initiate user data transfer
+//------------------------------------------------------------------------------
+void CDRMDbSession::InitiateUdtL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::InitiateUdtL" ) );
+    __UHEAP_MARK;
+
+    HBufC8* encryptionKey = NULL;
+    TInt size = 0;
+    TPtr8 data( NULL, 0 );
+
+    SanitizeL( aMessage.GetDesLength(0));
+
+    size = User::LeaveIfError( IPCGETDESLEN0 );
+    encryptionKey = HBufC8::NewLC( size );
+
+    data.Set( encryptionKey->Des() );
+    IPCREAD0L( data );
+
+    // The encrypted data is encrypted with 2048 byte key, it always needs to be atleast this long
+    if( encryptionKey->Length() < 254)
+        {
+        User::Leave(KErrArgument);
+        }
+
+    DRMDB.InitiateUdtL( *encryptionKey );
+
+    CleanupStack::PopAndDestroy( encryptionKey );
+
+    aMessage.Complete( KErrNone );
+    __UHEAP_MARKEND;
+
+    DRMLOG( _L( "CDRMDbSession::InitiateUdtL done" ) );
+    };
+
+//------------------------------------------------------------------------------
+// CDRMDbSession::InitExportOrhanedCIDsL
+// Create and export the list of orphaned content id's
+//------------------------------------------------------------------------------
+void CDRMDbSession::InitExportOrphanedCIDsL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::InitExportOrphanedCIDsL" ) );
+    CDRMActiveOperation* active( NULL );
+    TBool performScan = EFalse;
+
+    User::LeaveIfError( VerifyCredentials(NULL,NULL,ContentAccess::EUnknown) );
+
+    if ( iPendingRequest )
+        {
+        User::Leave( KErrAlreadyExists );
+        }
+
+    // if the old filename exists, delete it, a new operation starts
+    if( iFileName )
+        {
+        delete iFileName;
+        iFileName = NULL;
+        }
+
+    // Read the scan data:
+    performScan = aMessage.Int0() != 0 ? ETrue : EFalse;
+
+
+    active = CDRMActiveOperation::NewLC( aMessage, *this,
+                                         CDRMActiveOperation::EOperationExportObsolete );
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    active->ActivateL( DRMDB, RFSSESSION, KDRMDbTempPath, performScan );
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+
+    RFSSESSION.DriveToChar( driveNumber, driveLetter );
+
+    TFileName dbTempPath;
+    dbTempPath.Format( KDbTempPath, (TUint)driveLetter );
+
+    active->ActivateL( DRMDB, RFSSESSION, dbTempPath, performScan );
+
+#endif
+
+    iPendingRequest = active;
+
+    CleanupStack::Pop( active );
+
+    DRMLOG( _L( "CDRMDbSession::InitExportOrphanedCIDsL: ok" ) );
+    };
+
+
+//------------------------------------------------------------------------------
+// CDRMDbSession::ExportOrhanedCIDsL
+// Create and export the list of orphaned content id's
+//------------------------------------------------------------------------------
+void CDRMDbSession::ExportOrphanedCIDsL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::ExportOrphanedCIDsL" ) );
+    if( !iFileName )
+        {
+        aMessage.Complete( KErrNotReady );
+        return;
+        }
+
+    if( iFileName->Length() > aMessage.GetDesMaxLength(0) )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    // It is virtually impossible to make WriteL to leave in this case,
+    // but anything is still possible...
+    IPCWRITE0L( *iFileName );
+
+    // if everything went well, delete the filename if not leave it
+    delete iFileName;
+    iFileName = NULL;
+
+    // All done
+    aMessage.Complete( KErrNone );
+
+    DRMLOG( _L( "CDRMDbSession::ExportOrphanedCIDsL: ok" ) );
+    };
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::UnwrapMacAndRekL
+// Unwraps public key encrypted MAC and REK keys
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::UnwrapMacAndRekL( const RMessage2& aMessage, TBool aDomainRo )
+    {
+    DRMLOG( _L( "CDRMDbSession::UnwrapMacAndRekL" ) );
+
+    __UHEAP_MARK;
+
+    MDrmKeyStorage* storage;
+    TBuf8<OmaCrypto::KMacSize> mac;
+    TBuf8<OmaCrypto::KKeySize> rek;
+    HBufC8* data = NULL;
+    TPtr8 dataPtr(0, 0);
+    TPtrC8 macAndRekPtr(0, 0);
+    HBufC8* riId = NULL;
+    TPtr8 riIdPtr(0, 0);
+    HBufC8* domainId = NULL;
+    TPtr8 domainIdPtr(0, 0);
+    CDRMRIContext* riContext = NULL;
+    TInt size = 0;
+    TKeyTransportScheme transport;
+    HBufC8* unwrappedMacAndRek = NULL;
+    CDRMDomainContext* domainContext;
+    HBufC8* domainKey = NULL;
+
+    DRMLOG(_L("CDRMDbSession::UnwrapMacAndRekL"));
+
+
+
+    SanitizeL( aMessage.GetDesLength(0) );
+    SanitizeL( aMessage.GetDesLength(1) );
+
+    size = User::LeaveIfError( IPCGETDESLEN0 );
+    data = HBufC8::NewLC( size );
+
+    size = User::LeaveIfError( IPCGETDESLEN1 );
+    riId = HBufC8::NewLC( size );
+
+    if(aDomainRo)
+        {
+        SanitizeL( aMessage.GetDesLength(2) );
+        size = User::LeaveIfError( IPCGETDESLEN2 );
+        domainId = HBufC8::NewLC( size );
+        }
+
+    dataPtr.Set( data->Des() );
+    IPCREAD0L( dataPtr );
+
+    riIdPtr.Set( riId->Des() );
+    IPCREAD1L( riIdPtr );
+
+    if(aDomainRo)
+        {
+        domainIdPtr.Set( domainId->Des() );
+        IPCREAD2L( domainIdPtr );
+        }
+
+    // The first byte defines the transport scheme
+    transport = static_cast<TKeyTransportScheme>(dataPtr[0]);
+    macAndRekPtr.Set(dataPtr.Mid(1));
+
+    DRMLOG2(_L("Transport scheme: %d"), transport);
+    DRMLOG(_L("MAC + REK:"));
+    DRMLOGHEX(macAndRekPtr);
+
+    if ( !iRoapClientConnected )
+        {
+        User::LeaveIfError( iRoapClient.Connect() );
+        iRoapClientConnected = ETrue;
+        }
+
+    if (!aDomainRo)
+        {
+        // get the trusted root from the rights issuer context
+        riContext = iRoapClient.GetRIContextL(riIdPtr);
+        if ( !riContext )
+            {
+            DRMLOG(_L("RI not registered"));
+            User::Leave(KErrRightsServerRiNotRegistered);
+            }
+        CleanupStack::PushL(riContext);
+        // connect to the storage of our PKI keys
+        storage = DrmKeyStorageNewL();
+        TCleanupItem storageCleanup( DeleteObject, storage );
+        CleanupStack::PushL(storageCleanup);
+        storage->SelectTrustedRootL(riContext->SelectedDeviceRoot());
+
+        if (transport == EOma)
+            {
+            OmaCrypto::RsaKemKwsDecryptL(storage, macAndRekPtr, rek, mac);
+            }
+        else
+            {
+            CmlaCrypto::CmlaIpDecryptL(transport, storage, macAndRekPtr, rek, mac);
+            }
+        CleanupStack::PopAndDestroy(4, data);
+        }
+    else
+        {
+        domainContext = iRoapClient.GetDomainContextL(domainIdPtr);
+        if ( !domainContext )
+            {
+            DRMLOG(_L("Domain not registered"));
+            User::Leave(KErrRightsServerDomainNotRegistered);
+            }
+        CleanupStack::PushL(domainContext);
+
+        // last three digits presents the domain generation
+        TInt generation = 0;
+        TLex8 lex( domainIdPtr.Right(3));
+        lex.Val(generation);
+
+        domainKey = domainContext->DomainKeyL(generation);
+        CleanupStack::PushL( domainKey );
+
+        // unwrap MAC and REK first with the domain key, the CEK with REK
+        unwrappedMacAndRek = OmaCrypto::AesUnwrapL(*domainKey, macAndRekPtr);
+        CleanupStack::PushL(unwrappedMacAndRek);
+
+        mac.Copy( unwrappedMacAndRek->Left( OmaCrypto::KKeySize) );
+        rek.Copy( unwrappedMacAndRek->Right( OmaCrypto::KKeySize) );
+        CleanupStack::PopAndDestroy(6, data);
+        }
+
+    DRMLOG(_L("REK:"));
+    DRMLOGHEX(rek);
+    DRMLOG(_L("MAC:"));
+    DRMLOGHEX(mac);
+
+    iMac.Copy(mac);
+    iRek.Copy(rek);
+
+    aMessage.Complete( KErrNone );
+
+    __UHEAP_MARKEND;
+
+    DRMLOG( _L( "CDRMDbSession::UnwrapMacAndRekL: ok" ) );
+    }
+
+//------------------------------------------------------------------------------
+// CDRMDbSession::FindParentsAndRemoveUnusableL()
+// Find the best ROs from aList and store references to aBest.
+//------------------------------------------------------------------------------
+void CDRMDbSession::FindParentsAndRemoveUnusableL( RDRMPermissionList& aList,
+                                                   const TDesC8& aURI,
+                                                   CDRMPointerArray<HBufC8>& aCids,
+                                                   const TIntent aIntent,
+                                                   const TTime& aDrmTime,
+                                                   TUint32& aReason )
+    {
+
+    CDRMPermissionList *permList = NULL;
+    TInt error = KErrNone;
+    HBufC8* uri = NULL;
+
+    aCids.ResetAndDestroy();
+
+
+    // to separate parents and children we store the content id, since the content id is needed
+    // by drm consume:
+    for( TInt count = 0; count < aList.Count(); count++ )
+        {
+        uri = aURI.AllocLC();
+        aCids.AppendL( uri );
+        CleanupStack::Pop( uri ); // uri
+        }
+
+
+    // Go though the list and remove the unusable RO's
+    for( TInt i = aList.Count() - 1 ; i >= 0; i-- )
+        {
+        // If the RO has valid parent rights add them to the list
+        if( aList[i]->iParentUID )
+            {
+            permList = CDRMPermissionList::NewLC();
+            permList->SetAutoCleanup( ETrue );
+
+            TRAP( error, DRMDB.GetDBEntryByContentIDL( *aList[i]->iParentUID, *permList ));
+            if( !error )
+                {
+                for( TInt j = 0; j < permList->Count(); j++ )
+                    {
+                    // check if the permission is valid and if the RI ID for child and parent
+                    // match
+                    if ( aList[i]->iRiId.Compare( (*permList)[j]->iRiId ) == 0 &&
+                        IsValidPermissionL( *(*permList)[j], aIntent, aDrmTime, aReason ) )
+                        {
+                        aList.AppendL( (*permList)[j] );
+                        (*permList)[j] = 0;
+                        uri = aList[i]->iParentUID->AllocLC();
+                        aCids.AppendL( uri );
+                        CleanupStack::Pop( uri );
+                        }
+                    }
+                }
+            CleanupStack::PopAndDestroy( permList );
+            }
+
+        // If the child is not valid remove it from the list
+        if ( !IsValidPermissionL( *aList[i], aIntent, aDrmTime, aReason ) )
+            {
+            CDRMPermission* perm = aList[i];
+            delete perm;
+            aList.Remove( i );
+
+            uri = aCids[i];
+            delete uri;
+            aCids.Remove( i );
+            perm = NULL;
+            uri = NULL;
+            }
+        }
+    // Now the list should contain only valid RO's or parents of the RO's
+    // which are valid
+    }
+
+
+//------------------------------------------------------------------------------
+// CDRMDbSession::FindBestROsL
+// Find the best ROs from aList and store references to aBest.
+//------------------------------------------------------------------------------
+TInt CDRMDbSession::FindBestROsL(
+    RDRMPermissionList& aList,
+    const TDesC8& aURI,
+    const TIntent aIntent,
+    HBufC8*& aUsedURI,
+    TUint32& aReason )
+    {
+    TTime time = Time::NullTTime();
+    CDRMPointerArray<HBufC8>* uriList = CDRMPointerArray<HBufC8>::NewLC();
+    uriList->SetAutoCleanup(ETrue);
+
+    TInt bestRo = -1;
+
+    if ( iSecureTime )
+        {
+        time = iTrustedTime;
+        }
+    else
+        {
+        time = Time::NullTTime();
+        }
+
+    FindParentsAndRemoveUnusableL( aList, aURI, *uriList, aIntent, time, aReason );
+
+    if( aList.Count() == 0 )
+        {
+        User::Leave(KErrCANoPermission);
+        }
+
+    bestRo = GetBestROL( aList, aIntent, aReason );
+
+    // Delete if it already exists
+    if( aUsedURI )
+        {
+        delete aUsedURI;
+        }
+    aUsedURI = NULL;
+
+    // if it's not the same as the normal URI return a value otherwise NULL
+    if( (*uriList)[ bestRo ]->Compare( aURI ) )
+        {
+        aUsedURI = (*uriList)[ bestRo ]->AllocL();
+        }
+
+    CleanupStack::PopAndDestroy( uriList );
+    return bestRo;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::IsValidPermissionL
+// ETrue if not expired. If the candidate has expired permission (intent,
+// not top level), ETrue is returned if the child knows it is a child.
+// -----------------------------------------------------------------------------
+TBool CDRMDbSession::IsValidPermissionL(
+    CDRMPermission& aPermission,
+    const ContentAccess::TIntent aIntent,
+    const TTime& aTime,
+    TUint32& aReason )
+    {
+    CDRMConstraint* toplevel = NULL;
+    CDRMConstraint* constraint = NULL;
+    CDRMDomainContext* domainContext = NULL;
+    TBool r = ETrue;
+    #ifdef RD_DRM_METERING
+    CDRMRIContext* riContext = NULL;
+    #endif
+
+    toplevel = aPermission.TopLevelConstraint();
+    if ( toplevel && ( !( toplevel->Valid( aTime, IMSI, aReason ) ) ) )
+        {
+        r = EFalse;
+        }
+    else
+        {
+        constraint = aPermission.ConstraintForIntent( aIntent );
+        if ( !constraint || constraint &&
+            ( !( constraint->Valid( aTime, IMSI, aReason ) ) ) )
+            {
+            r = EFalse;
+            }
+        else if ( aPermission.iDomainID )
+            {
+            if ( !iRoapClientConnected )
+                {
+                User::LeaveIfError( iRoapClient.Connect() );
+                iRoapClientConnected = ETrue;
+                }
+            domainContext = iRoapClient.GetDomainContextL( *aPermission.iDomainID );
+            if ( domainContext )
+                {
+                delete domainContext;
+                }
+            else
+                {
+                r = EFalse;
+                }
+
+            }
+
+        // If the constraint is software constrained and the sw secureid does not match
+        // remove it from the list handling
+        if( r && aPermission.SoftwareConstrained() )
+            {
+            _LIT_SECURITY_POLICY_S0(swSidCheck, constraint->iSecureId.iUid);
+            if (constraint->iActiveConstraints & EConstraintSoftware)
+                {
+                if (!swSidCheck().CheckPolicy(iClient))
+                    {
+                    r = EFalse;
+                    }
+                }
+            }
+        }
+
+    #ifdef RD_DRM_METERING
+
+    // Check if metering restricts the content usage
+    if ( r != EFalse && constraint->iDrmMeteringInfo &&
+        !constraint->iDrmMeteringInfo->iAllowUseWithoutMetering )
+        {
+        if ( !iRoapClientConnected )
+            {
+            User::LeaveIfError( iRoapClient.Connect() );
+            iRoapClientConnected = ETrue;
+            }
+        riContext = iRoapClient.GetRIContextL( aPermission.iRiId );
+        if ( !riContext || !riContext->IsMeteringAllowed() )
+            {
+            aReason |= EConstraintMetering;
+            return EFalse;
+            }
+        }
+
+    delete riContext;
+
+    #endif
+
+    return r;
+    }
+
+//------------------------------------------------------------------------------
+// CDRMDbSession::GetBestROL
+// Find the best ROs from aList and store references to aBest.
+//------------------------------------------------------------------------------
+TInt CDRMDbSession::GetBestROL(
+    RDRMPermissionList& aList,
+    const TIntent aIntent,
+    TUint32& aReason )
+    {
+    TInt count( 0 );
+    TTime time;
+
+    CDRMConstraint* normalized = CDRMConstraint::NewLC();
+    CDRMConstraint* bestOne = CDRMConstraint::NewLC();
+
+    TInt bestRo( -1 );
+
+    if ( iSecureTime )
+        {
+        time = iTrustedTime;
+        }
+    else
+        {
+        time = Time::NullTTime();
+        }
+
+    // 'count' is updated if something useful is found, and aList is
+    // updated if the permission cannot be used.
+    while  ( count < aList.Count() )
+        {
+        CDRMPermission* perm = aList[ count ];
+        TBool found( EFalse );
+
+        // If there is no constraint for the intent, there is no need to normalize
+        // There can be no rights to use in that permission
+        if( perm->ConstraintForIntent( aIntent ) )
+            {
+            Normalize( *perm, *normalized, aIntent );
+            if ( normalized->Valid( time, IMSI, aReason ) )
+                {
+                found = ETrue;
+                }
+            }
+
+        if ( found )
+            {
+            // Compare whether "normalized" is more suitable than "bestOne".
+            // If this is the first usable child & parent combination,
+            // take it.
+            if ( ( bestRo < 0 ) || BetterPermission( *normalized, *bestOne ) )
+                {
+                // "normalized" is the new "bestOne"
+                CDRMConstraint* temp = bestOne;
+                bestOne = normalized;
+                normalized = temp;
+
+                bestRo = count;
+
+                ++count;
+                }
+            else
+                {
+                // This isn't any better than the previous ones. Throw it away.
+                found = EFalse;
+                }
+            }
+
+        if ( !found )
+            {
+            // Unusable child.
+            delete perm; perm = NULL;
+            aList.Remove( count );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // bestOne, normalized
+
+    return bestRo;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::Normalize
+// Normalizes a permission.
+// -----------------------------------------------------------------------------
+void CDRMDbSession::Normalize( CDRMPermission& aPermission,
+                               CDRMConstraint& aNormalized,
+                               const ContentAccess::TIntent aIntent )
+    {
+    __ASSERT_DEBUG( aPermission.ConstraintForIntent( aIntent ), User::Invariant() );
+
+    TRAPD( error, aNormalized.DuplicateL( *( aPermission.ConstraintForIntent( aIntent ) ) ) );
+    if( !error )
+        {
+        if ( aPermission.TopLevelConstraint() )
+            {
+            aNormalized.Merge( *( aPermission.TopLevelConstraint() ) );
+            }
+        }
+    }
+// -----------------------------------------------------------------------------
+// CDRMDbSession::BetterPermission
+// Compares two permissions, and returns ETrue if aNewOne is more suitable
+// for the usage. Assumes both are valid, i.e. not expired.
+// -----------------------------------------------------------------------------
+TBool CDRMDbSession::BetterPermission( const CDRMConstraint& aNewOne,
+                                       const CDRMConstraint& aOldOne )
+    {
+    // Check Order:
+    // 1. Full
+    // 2. Start End, closest end time first
+    // 3. Interval, shortest first
+    // 4. Accumulated, shortest first
+    // 5. Timed Counter, least counters first, longest time first
+    // 6. Counter, least counters first or the first one found
+
+    const TTime nullTime = Time::NullTTime();
+    TTime oldTime = nullTime;
+    TTime newTime = nullTime;
+    TTime oldTimePos = nullTime;
+    TTime newTimePos = nullTime;
+
+    // 1. Full
+    // If the old or new one is the ultimate one, don't bother to
+    // check anything else.
+    if ( aOldOne.iActiveConstraints == EConstraintNone )
+        {
+        return EFalse;
+        }
+
+    if ( aNewOne.iActiveConstraints == EConstraintNone )
+        {
+        return ETrue;
+        }
+
+    // 2. Start & End Time
+    // Choose the one with the closest end time first
+    // All RO's to this check are already checked to be valid
+    // ActiveIntervals Also hit this spot
+
+    // First get the start and end times from the intervals if they are active or inactive:
+    if ( aOldOne.iActiveConstraints & EConstraintInterval )
+        {
+        if( aOldOne.iIntervalStart == nullTime )
+            {
+            oldTimePos = iTrustedTime;
+            oldTimePos += TTimeIntervalSeconds( aOldOne.iInterval );
+            }
+        else
+            {
+            oldTime = aOldOne.iIntervalStart;
+            oldTime += TTimeIntervalSeconds( aOldOne.iInterval );
+            }
+        }
+
+    if( aNewOne.iActiveConstraints & EConstraintInterval )
+        {
+        if( aNewOne.iIntervalStart == nullTime )
+            {
+            newTimePos = iTrustedTime;
+            newTimePos += TTimeIntervalSeconds( aNewOne.iInterval );
+            }
+        else
+            {
+            newTime = aNewOne.iIntervalStart;
+            newTime += TTimeIntervalSeconds( aNewOne.iInterval );
+            }
+        }
+
+    if ( aOldOne.iActiveConstraints & EConstraintEndTime || oldTime != nullTime )
+        {
+        oldTime = EndTime( oldTime, aOldOne.iEndTime );
+
+        if ( aNewOne.iActiveConstraints & EConstraintEndTime || newTime != nullTime )
+            {
+            newTime = EndTime( newTime, aNewOne.iEndTime );
+
+            if( newTime != oldTime )
+                {
+                return ( newTime < oldTime );
+                }
+            }
+        else
+            {
+            return EFalse;
+            }
+        }
+    else if ( aNewOne.iActiveConstraints & EConstraintEndTime || newTime != nullTime )
+        {
+        return ETrue;
+        }
+
+
+    // 3. Inactive Intervals:
+    // Choose the one with the interval ending first:
+    // Continue here if the no SE's exist or SE's are the same
+    if( aOldOne.iActiveConstraints & EConstraintInterval )
+        {
+        if( aNewOne.iActiveConstraints & EConstraintInterval )
+            {
+            oldTimePos = EndTime( oldTime, oldTimePos );
+            newTimePos = EndTime( newTime, newTimePos );
+
+            if( oldTimePos != newTimePos )
+                {
+                return ( newTimePos < oldTimePos );
+                }
+            }
+        else
+            {
+            if( aNewOne.iActiveConstraints & EConstraintAccumulated ||
+                aNewOne.iActiveConstraints & EConstraintTimedCounter ||
+                aNewOne.iActiveConstraints & EConstraintCounter )
+                {
+                return EFalse;
+                }
+            else
+                {
+                return ETrue;
+                }
+            }
+        }
+    else if( aNewOne.iActiveConstraints & EConstraintInterval )
+        {
+        if( aOldOne.iActiveConstraints & EConstraintAccumulated ||
+            aOldOne.iActiveConstraints & EConstraintTimedCounter ||
+            aOldOne.iActiveConstraints & EConstraintCounter )
+            {
+            return ETrue;
+            }
+        else
+            {
+            return EFalse;
+            }
+        }
+
+    // 4. Accumulated:
+    // Choose the shortest accumulated first
+    // Continue here if SE's or intervals do not exist or they are the same
+    if( aOldOne.iActiveConstraints & EConstraintAccumulated )
+        {
+        if( aNewOne.iActiveConstraints & EConstraintAccumulated )
+            {
+            if( aNewOne.iAccumulatedTime != aOldOne.iAccumulatedTime )
+                {
+                return ( aNewOne.iAccumulatedTime < aOldOne.iAccumulatedTime );
+                }
+            }
+        else
+            {
+            if( aNewOne.iActiveConstraints & EConstraintTimedCounter ||
+                aNewOne.iActiveConstraints & EConstraintCounter )
+                {
+                return EFalse;
+                }
+            else
+                {
+                return ETrue;
+                }
+            }
+        }
+    else if( aNewOne.iActiveConstraints & EConstraintAccumulated )
+        {
+        if( aOldOne.iActiveConstraints & EConstraintTimedCounter ||
+            aOldOne.iActiveConstraints & EConstraintCounter )
+            {
+            return ETrue;
+            }
+        else
+            {
+            return EFalse;
+            }
+        }
+
+
+    // 5. Timed Counter
+    // Choose the one with least counters first. If there is an equal number of counters
+    // left, use the one with the longest time
+    // Continue here if SE's or intervals or accumulateds do not exist or they are the same
+    if( aOldOne.iActiveConstraints & EConstraintTimedCounter )
+        {
+        if( aNewOne.iActiveConstraints & EConstraintTimedCounter )
+            {
+            if( aNewOne.iTimedCounter == aOldOne.iTimedCounter )
+                {
+                if( aNewOne.iTimedInterval != aOldOne.iTimedInterval )
+                    {
+                    return ( aNewOne.iTimedInterval < aOldOne.iTimedInterval );
+                    }
+                else
+                    {
+                    if( aNewOne.iActiveConstraints & EConstraintCounter )
+                        {
+
+                        }
+                    }
+                }
+            else
+                {
+                return ( aNewOne.iTimedCounter < aOldOne.iTimedCounter );
+                }
+
+            }
+        else
+            {
+            if( aNewOne.iActiveConstraints & EConstraintCounter )
+                {
+                return EFalse;
+                }
+            else
+                {
+                return ETrue;
+                }
+            }
+        }
+    else if( aNewOne.iActiveConstraints & EConstraintTimedCounter )
+        {
+        if( aOldOne.iActiveConstraints & EConstraintCounter )
+            {
+            return ETrue;
+            }
+        else
+            {
+            return EFalse;
+            }
+        }
+
+    // 6. Counter
+    // Choose the one with least counters:
+    // if they are the same choose the first one.
+    // Continue here if SE's or intervals or accumulateds or timed counters
+    // do not exist or they are the same
+    if( aOldOne.iActiveConstraints & EConstraintCounter )
+        {
+        if( aNewOne.iActiveConstraints & EConstraintCounter )
+            {
+            return ( aNewOne.iCounter < aOldOne.iCounter );
+            }
+        else
+            {
+            return ETrue;
+            }
+        }
+
+    // If all else fails use the old one:
+    return EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::BetterPermission
+// Compares two permissions, and returns ETrue if aNewOne is more suitable
+// for the usage. Assumes both are valid, i.e. not expired.
+// -----------------------------------------------------------------------------
+TBool BetterPermissionOld( const CDRMConstraint& aNewOne,
+    const CDRMConstraint& aOldOne ) //const
+    {
+
+    const TTime nullTime = Time::NullTTime();
+    TTime oldTime = nullTime;
+    TTime newTime = nullTime;
+    TBool inactiveIntervals = EFalse;
+
+    // If the old or new one is the ultimate one, don't bother to
+    // check anything else.
+    if ( aOldOne.iActiveConstraints == EConstraintNone )
+        {
+        return EFalse;
+        }
+
+    if ( aNewOne.iActiveConstraints == EConstraintNone )
+        {
+        return ETrue;
+        }
+
+    // If old one has count constraints but the new doesn't, the new
+    // is better. If the old one doesn't have counters but the
+    // new has, the old one is better.
+    if ( aOldOne.iActiveConstraints & EConstraintCounter )
+        {
+        if ( !( aNewOne.iActiveConstraints & EConstraintCounter ) ||
+             ( aNewOne.iCounter < aOldOne.iCounter ) )
+            {
+            return ETrue;
+            }
+        }
+    else
+        {
+        if ( aNewOne.iActiveConstraints & EConstraintCounter )
+            {
+            return EFalse;
+            }
+        }
+
+    if ( aOldOne.iActiveConstraints & EConstraintTimedCounter )
+        {
+        if ( !( aNewOne.iActiveConstraints & EConstraintTimedCounter ) ||
+             ( aNewOne.iTimedCounter < aOldOne.iTimedCounter ) )
+            {
+            return ETrue;
+            }
+        }
+    else
+        {
+        if ( aNewOne.iActiveConstraints & EConstraintTimedCounter )
+            {
+            return EFalse;
+            }
+        }
+
+    if ( aOldOne.iActiveConstraints & EConstraintAccumulated )
+        {
+        if ( !( aNewOne.iActiveConstraints & EConstraintAccumulated ) ||
+             ( aNewOne.iAccumulatedTime < aOldOne.iAccumulatedTime ) )
+            {
+            return ETrue;
+            }
+        }
+    else
+        {
+        if ( aNewOne.iActiveConstraints & EConstraintAccumulated )
+            {
+            return EFalse;
+            }
+        }
+
+    // - No intervals is better than inactive intervals.
+    // - No intervals compared to activated interval goes to
+    //   end time constraint comparison.
+    // - Activated interval is better than inactive interval.
+    // - Two inactive intervals go to end time constraint comparison.
+    if ( aOldOne.iActiveConstraints & EConstraintInterval )
+        {
+        if ( aNewOne.iActiveConstraints & EConstraintInterval )
+            {
+            if ( aOldOne.iIntervalStart == nullTime )
+                {
+                if ( aNewOne.iIntervalStart != nullTime )
+                    {
+                    return ETrue;
+                    }
+
+                // Both have inactive intervals.
+                inactiveIntervals = ETrue;
+
+//                oldTime = iTrustedTime;
+                oldTime += TTimeIntervalSeconds( aOldOne.iInterval );
+
+//                newTime = iTrustedTime;
+                newTime += TTimeIntervalSeconds( aNewOne.iInterval );
+                }
+            else
+                {
+                // Old one has activated interval.
+                if ( aNewOne.iIntervalStart == nullTime )
+                    {
+                    return EFalse;
+                    }
+
+                // Both have activated intervals.
+                oldTime = aOldOne.iIntervalStart;
+                oldTime += TTimeIntervalSeconds( aOldOne.iInterval );
+
+                newTime = aNewOne.iIntervalStart;
+                newTime += TTimeIntervalSeconds( aNewOne.iInterval );
+                }
+            }
+        else
+            {
+            // No intervals in the new one.
+            if ( aOldOne.iIntervalStart == nullTime )
+                {
+                return ETrue;
+                }
+
+            oldTime = aOldOne.iIntervalStart;
+            oldTime += TTimeIntervalSeconds( aOldOne.iInterval );
+            }
+        }
+    else
+        {
+        // The old one doesn't have intervals.
+        if ( aNewOne.iActiveConstraints & EConstraintInterval )
+            {
+            if ( aNewOne.iIntervalStart == nullTime )
+                {
+                return EFalse;
+                }
+
+            newTime = aNewOne.iIntervalStart + TTimeIntervalSeconds( aNewOne.iInterval );
+            }
+        }
+
+    if ( inactiveIntervals )
+        {
+        // The one with end time goes first.
+        if ( aOldOne.iActiveConstraints & EConstraintEndTime )
+            {
+            if ( aNewOne.iActiveConstraints & EConstraintEndTime )
+                {
+                oldTime = EndTime( oldTime, aOldOne.iEndTime );
+                newTime = EndTime( newTime, aNewOne.iEndTime );
+
+                return ( newTime < oldTime );
+                }
+
+            return EFalse;
+            }
+
+        if( aNewOne.iActiveConstraints & EConstraintEndTime )
+            {
+            return ETrue;
+            }
+
+        // Both have just inactive intervals.
+        return ( newTime < oldTime );
+        }
+
+    // Check end times and/or activated intervals.
+    if ( aOldOne.iActiveConstraints & EConstraintEndTime || oldTime != nullTime )
+        {
+        oldTime = EndTime( oldTime, aOldOne.iEndTime );
+
+        if ( aNewOne.iActiveConstraints & EConstraintEndTime || newTime != nullTime )
+            {
+            newTime = EndTime( newTime, aNewOne.iEndTime );
+
+            return ( newTime < oldTime );
+            }
+
+        // The new one doesn't have end time constraint and/or activated intervals.
+        return EFalse;
+        }
+
+    if ( aNewOne.iActiveConstraints & EConstraintEndTime || newTime != nullTime )
+        {
+        return ETrue;
+        }
+
+    // Start time does not expire, so let's keep the old one.
+
+    return EFalse;
+    }
+
+
+// ----------------------------------------------------------------------------
+// UnwrapProtectedCekL
+// Unwraps the protected CEK aProtectedCek. Caller owns the returned buffer.
+// ----------------------------------------------------------------------------
+//
+HBufC8* CDRMDbSession::UnwrapProtectedCekL(
+    const TDesC8& aProtectedCek )
+    {
+    MDrmKeyStorage* storage;
+    TBuf8<OmaCrypto::KMacSize> mac;
+    TBuf8<OmaCrypto::KKeySize> rek;
+    HBufC8* cek = NULL;
+    TPtrC8 macAndRek(0, 0);
+    TPtrC8 wrappedCek(0, 0);
+    TKeyTransportScheme transport;
+    TBuf8<KRiIdSize> rightsIssuer;
+    CDRMRIContext* riContext = NULL;
+    TInt i;
+    TInt len;
+
+    DRMLOG(_L("CDRMDbSession::UnwrapProtectedCekL"));
+
+    // first element: one byte for the transport scheme
+    i = 0;
+    transport = static_cast<TKeyTransportScheme>(aProtectedCek[i]);
+    i++;
+
+    DRMLOG2(_L("Transport scheme: %d"), transport);
+
+    // second element: the concatenated MAC and REK wrapped with the KEK
+    len = aProtectedCek[i];
+    macAndRek.Set(aProtectedCek.Mid(i + 1, len));
+    i = i + 1 + len;
+    DRMLOG(_L("MAC + REK:"));
+    DRMLOGHEX(macAndRek);
+
+    // third element: 20 bytes with the rights issuer ID
+    len = aProtectedCek[i];
+    rightsIssuer.Copy(aProtectedCek.Mid(i + 1, len));
+    i = i + 1 + len;
+    DRMLOG(_L("RI ID:"));
+    DRMLOGHEX(rightsIssuer);
+
+    // get the trusted root from the rights issuer context
+    if ( !iRoapClientConnected )
+        {
+        User::LeaveIfError( iRoapClient.Connect() );
+        iRoapClientConnected = ETrue;
+        }
+    riContext = iRoapClient.GetRIContextL(rightsIssuer);
+    if ( !riContext )
+        {
+        DRMLOG(_L("RI not registered"));
+        User::Leave(KErrRightsServerRiNotRegistered);
+        }
+    CleanupStack::PushL(riContext);
+
+    // connect to the storage of our PKI keys
+    storage = DrmKeyStorageNewL();
+    TCleanupItem storageCleanup( DeleteObject, storage );
+    CleanupStack::PushL(storageCleanup);
+    storage->SelectTrustedRootL(riContext->SelectedDeviceRoot());
+
+    if (transport == EOma)
+        {
+        OmaCrypto::RsaKemKwsDecryptL(storage, macAndRek, rek, mac);
+        }
+    else
+        {
+        CmlaCrypto::CmlaIpDecryptL(transport, storage, macAndRek, rek, mac);
+        }
+
+    DRMLOG(_L("REK:"));
+    DRMLOGHEX(rek);
+    DRMLOG(_L("MAC:"));
+    DRMLOGHEX(mac);
+
+    iMac.Copy(mac);
+    iRek.Copy(rek);
+
+    // fourth element: 24 bytes for the CEK (wrapped with the REK),
+    // this can be empty, e.g. for a parent RO (indicated by a zero length)
+    len = aProtectedCek[i];
+    if (len > 0)
+        {
+        wrappedCek.Set(aProtectedCek.Mid(i + 1, len));
+        DRMLOG(_L("Wrapped CEK:"));
+        DRMLOGHEX(wrappedCek);
+        cek = OmaCrypto::AesUnwrapL(rek, wrappedCek);
+        DRMLOG(_L("CEK:"));
+        DRMLOGHEX(( *cek ));
+        }
+    else
+        {
+        DRMLOG(_L("No CEK"));
+        cek = KNullDesC8().AllocL();
+        }
+
+    CleanupStack::PopAndDestroy(2); // riContext, storageCleanup
+    return cek;
+    }
+
+// ----------------------------------------------------------------------------
+// UnwrapDomainCekL
+// Unwraps CEK with is wrapped with a domain key. Caller owns the returned
+// buffer.
+// ----------------------------------------------------------------------------
+//
+HBufC8* CDRMDbSession::UnwrapDomainCekL(
+    const TDesC8& aProtectedCek,
+    const TDesC8& aDomainId )
+    {
+    HBufC8* unwrappedMacAndRek = NULL;
+    HBufC8* cek = NULL;
+    TPtrC8 macAndRek(0, 0);
+    TPtrC8 wrappedCek(0, 0);
+    CDRMDomainContext* domainContext;
+    HBufC8* domainKey = NULL;
+    TInt i;
+    TInt len;
+
+    DRMLOG(_L("CDRMDbSession::UnwrapDomainCekL"));
+
+    // first element (one byte for the transport scheme) is ignored
+    i = 1;
+
+    // second element: MAC and REK wrapped with the domain key (40 bytes)
+    len = aProtectedCek[i];
+    macAndRek.Set(aProtectedCek.Mid(i + 1, len));
+    i = i + 1 + len;
+    DRMLOG(_L("MAC + REK:"));
+    DRMLOGHEX(macAndRek);
+
+    // third element: 20 bytes with the rights issuer ID, is ignored
+    len = aProtectedCek[i];
+    i = i + 1 + len;
+
+    // fourth element: 24 bytes for the CEK (wrapped with the REK)
+    len = aProtectedCek[i];
+    wrappedCek.Set(aProtectedCek.Mid(i + 1, len));
+    DRMLOG(_L("Wrapped CEK:"));
+    DRMLOGHEX(wrappedCek);
+
+    // get the domain key from the domain context
+    if ( !iRoapClientConnected )
+        {
+        User::LeaveIfError( iRoapClient.Connect() );
+        iRoapClientConnected = ETrue;
+        }
+    domainContext = iRoapClient.GetDomainContextL(aDomainId);
+    if ( !domainContext )
+        {
+        DRMLOG(_L("Domain not registered"));
+        User::Leave(KErrRightsServerDomainNotRegistered);
+        }
+    CleanupStack::PushL(domainContext);
+
+    // last three digits presents the domain generation
+    TInt generation = 0;
+    TLex8 lex( aDomainId.Right(3));
+    lex.Val(generation);
+
+    domainKey = domainContext->DomainKeyL(generation);
+    CleanupStack::PushL( domainKey );
+
+    // unwrap MAC and REK first with the domain key, the CEK with REK
+    unwrappedMacAndRek = OmaCrypto::AesUnwrapL(*domainKey, macAndRek);
+    CleanupStack::PushL(unwrappedMacAndRek);
+    cek = OmaCrypto::AesUnwrapL(unwrappedMacAndRek->Right(
+            OmaCrypto::KKeySize), wrappedCek);
+    iMac.Copy( unwrappedMacAndRek->Left( OmaCrypto::KKeySize) );
+    CleanupStack::PopAndDestroy(3); // unwrappedMacAndRek, domainKey, domainContext
+
+    return cek;
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::VerifyCredentials
+// Check if the client has enough credentials to grant access to later
+// decryption.
+// ----------------------------------------------------------------------------
+//
+TInt CDRMDbSession::VerifyCredentials(
+    HBufC8* aContentId,
+    CDRMPermission* aPermission,
+    TIntent aIntent)
+    {
+    CDRMConstraint* constraint = NULL;
+    _LIT_SECURITY_POLICY_C1(drmCheck, ECapabilityDRM);
+    _LIT_SECURITY_POLICY_V0(vidCheck, VID_DEFAULT); // Check Default VID
+    RPointerArray<CDRMPermission> permissions;
+    TInt r = KErrAccessDenied;
+    TBool hasOma2Permissions = EFalse;
+    TBool hasSoftwareConstraints = EFalse;
+    TInt i;
+
+    __UHEAP_MARK;
+    // Get the applicable permission, and check if there are OMA 2 permissions or
+    // software constraints
+    if (aPermission)
+        {
+        constraint = aPermission->ConstraintForIntent(aIntent);
+        }
+    if ( aContentId )
+        {
+        TRAP_IGNORE( DRMDB.GetDBEntryByContentIDL(*aContentId, permissions) );
+        for (i = 0; i < permissions.Count(); i++)
+            {
+            if (permissions[i]->iRightsObjectVersion.iVersionMain == EOma2Rights ||
+                permissions[i]->iRightsObjectVersion.iVersionMain == ECmlaRights)
+                {
+                hasOma2Permissions = ETrue;
+                }
+            if (permissions[i]->SoftwareConstrained())
+                {
+                hasSoftwareConstraints = ETrue;
+                }
+            }
+        permissions.ResetAndDestroy();
+        permissions.Close();
+        }
+
+    // First, check for DRM capability, access granted only if there are no software
+    // constraints.
+    if (drmCheck().CheckPolicy(iClient) && !hasSoftwareConstraints)
+        {
+        r = KErrNone;
+        }
+
+    // If a permission is given, check for license manager cases as well as
+    // OMA DRM 1.0 case
+    if ( r != KErrNone && aPermission )
+        {
+        // Fallback: Check if the vendor ID is the default vendor ID,
+        // allow access for OMA DRM 1.0 rights
+        if ((aPermission->iRightsObjectVersion.iVersionMain == EOma1Rights &&
+             vidCheck().CheckPolicy(iClient)))
+            {
+            r = KErrNone;
+            }
+
+        // Check the software constraint, this can override the fallback above!
+        if ( constraint )
+            {
+            _LIT_SECURITY_POLICY_S0(swSidCheck, constraint->iSecureId.iUid);
+            _LIT_SECURITY_POLICY_V0(swVidCheck, constraint->iVendorId.iUid);
+            if (constraint->iActiveConstraints & EConstraintVendor)
+                {
+                if (swVidCheck().CheckPolicy(iClient))
+                    {
+                    r = KErrNone;
+                    }
+                else
+                    {
+                    r = KErrAccessDenied;
+                    }
+                }
+            if (constraint->iActiveConstraints & EConstraintSoftware)
+                {
+                if (swSidCheck().CheckPolicy(iClient))
+                    {
+                    r = KErrNone;
+                    }
+                else
+                    {
+                    r = KErrAccessDenied;
+                    }
+                }
+            }
+
+        }
+
+    // Application installer needs to be able to use the content even if it has SW constraints
+    _LIT_SECURITY_POLICY_S0(swSidCheck2, KAppInstSrv);
+
+    if( swSidCheck2().CheckPolicy(iClient) && hasSoftwareConstraints )
+        {
+        r = KErrNone;
+        }
+
+
+    // Check if access can be granted when only
+    // OMA DRM 1.0 permissions are currently available, and the client
+    // has the default vendor ID
+    if ( r != KErrNone && !hasOma2Permissions &&
+        !hasSoftwareConstraints && vidCheck().CheckPolicy( iClient ) )
+        {
+        r = KErrNone;
+        }
+    __UHEAP_MARKEND;
+
+    if ( r == KErrNone )
+        {
+        iCredentialsChecked = ECheckedAndAllowed;
+        }
+    else
+        {
+        iCredentialsChecked = ECheckedAndDenied;
+        }
+    return r;
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::RemoveInvalidPermissionsL
+// Remove all permissions where the domain context is not available
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::RemoveInvalidPermissionsL(
+    CDRMPermissionList* aList )
+    {
+    CDRMDomainContext* domainContext = NULL;
+    TInt i;
+    if ( !iRoapClientConnected )
+        {
+        User::LeaveIfError( iRoapClient.Connect() );
+        iRoapClientConnected = ETrue;
+        }
+    for ( i = aList->Count() - 1; i >= 0; i-- )
+        {
+        if ( (*aList)[i]->iDomainID )
+            {
+            domainContext = iRoapClient.GetDomainContextL(
+                *(*aList)[i]->iDomainID );
+            if ( domainContext )
+                {
+                delete domainContext;
+                }
+            else
+                {
+                aList->Remove( i );
+                }
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::
+//
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::SetNameL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::SetNameL" ) );
+    __UHEAP_MARK;
+
+    SanitizeL( aMessage.GetDesLength( 0 ) );
+    SanitizeL( aMessage.GetDesLength( 1 ) );
+
+    TInt namelength = User::LeaveIfError( IPCGETDESLEN1 );
+    HBufC8* cid = HBufC8::NewLC( IPCGETDESLEN0 );
+    HBufC* name = HBufC::NewLC( namelength > 0 ? namelength : 1 );
+    TPtr8 tmp( cid->Des() );
+
+    IPCREAD0L( tmp );
+    if ( namelength )
+        {
+        TPtr tmp2( name->Des() );
+        IPCREAD1L( tmp2 );
+        }
+
+    DRMDB.NameContentL( *cid, *name );
+
+    CleanupStack::PopAndDestroy( 2 );
+    __UHEAP_MARKEND;
+    aMessage.Complete( KErrNone );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::
+//
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetNameL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::GetNameL" ) );
+    HBufC8* cid = NULL;
+    TPckgBuf< TInt > size( 0 );
+
+    // Cleanup.
+    if ( iWidePreparedData )
+        {
+        delete iWidePreparedData;
+        iWidePreparedData = NULL;
+        }
+
+    SanitizeL( aMessage.GetDesLength( 0 ) );
+    cid = HBufC8::NewLC( IPCGETDESLEN0 );
+    TPtr8 tmp( cid->Des() );
+    IPCREAD0L( tmp );
+
+    iWidePreparedData = DRMDB.ContentNameLC( *cid );
+
+    CleanupStack::Pop( iWidePreparedData );
+    CleanupStack::PopAndDestroy( cid );
+
+    size() = iWidePreparedData->Length();
+    if ( iWidePreparedData->Length() == 0 )
+        {
+        // Empty name --> not asked.
+        delete iWidePreparedData;
+        iWidePreparedData = NULL;
+        }
+
+    IPCWRITE1L( size );
+
+    aMessage.Complete( KErrNone );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::
+//
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetWideDataL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSesion::GetWideDataL" ) );
+    if ( iWidePreparedData )
+        {
+        if( iWidePreparedData->Length() > aMessage.GetDesMaxLength(0) )
+            {
+            User::Leave(KErrArgument);
+            }
+
+        IPCWRITE0L( *iWidePreparedData );
+
+        delete iWidePreparedData;
+        iWidePreparedData = NULL;
+
+        aMessage.Complete( KErrNone );
+        return;
+        }
+
+    aMessage.Complete( KErrNotReady );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::
+//
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::Cancel( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::Cancel" ) );
+    if ( iPendingRequest )
+        {
+        static_cast<CDRMActiveOperation*>(iPendingRequest)->Remove();
+        }
+
+    aMessage.Complete( KErrNone );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::
+//
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetFLUriL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::GetFLUriL" ) );
+
+    TBuf8< KMaxOmaV1CIDLength > URI;
+
+    GetFlURI( URI );
+
+    if( URI.Length() > aMessage.GetDesMaxLength(0) )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    IPCWRITE0L( URI );
+    aMessage.Complete( KErrNone );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::
+//
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::EncodeRightsIssuerL( const RMessage2& aMessage )
+    {
+    __UHEAP_MARK;
+
+    DRMLOG( _L( "CRMDbSession::EncodeRightsIssuerL" ) );
+    TBuf8< KDCFKeySize > iv;
+    HBufC8* data( NULL );
+    HBufC8* tmp( NULL );
+    iv.SetLength( KDCFKeySize );
+
+    TInt size( User::LeaveIfError( IPCGETDESLEN0 ) );
+    TPtr8 des( NULL, 0, 0 );
+
+    if ( size < 1 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // Calculate the size. It could be retrieved also from GetDesMaxLength,
+    // but at least now we can be sure we won't panic in case of
+    // descriptor overflow.
+    size += KDCFKeySize - ( size % KDCFKeySize ); //padding
+    size += KDCFKeySize; //iv
+    size = ( size + 2 ) / 3 * 4; //base64
+    size += IMEI.Length();
+    size += KFLPrefixLength;
+
+    data = HBufC8::NewLC( size < KMaxOmaV1CIDLength ? KMaxOmaV1CIDLength : size );
+    des.Set( data->Des() );
+
+    GetFlURI( des );
+
+    tmp = DRMDB.GetDecryptionKeyL( *data );
+    CleanupStack::PushL( tmp );
+
+    // Get the data from client.
+    IPCREAD0L( des );
+    GenerateIVL( iv );
+
+    // Fits ok.
+    AesEncryptL( *tmp, iv, ETrue, des );
+
+    CleanupStack::PopAndDestroy( tmp );
+
+    // Fits ok.
+    des.Insert( 0, iv );
+
+    tmp = Base64EncodeL( *data );
+
+    __ASSERT_DEBUG( tmp->Length() + KFLPrefixLength + IMEI.Length() <= size,
+        User::Invariant() );
+
+    // Overwrite the original data.
+    des = KFLPrefix;
+    des.Append( IMEI );
+    des.Append( *tmp );
+
+    delete tmp;
+    tmp = NULL;
+
+    IPCWRITE0L( *data );
+
+    CleanupStack::PopAndDestroy( data );
+
+    aMessage.Complete( KErrNone );
+
+    __UHEAP_MARKEND;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::
+//
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::DecodeRightsIssuerL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::DecodeRightsIssuerL" ) );
+    __UHEAP_MARK;
+
+    HBufC8* data( NULL );
+    TInt size( IPCGETDESLEN0 );
+    TPtr8 des( NULL, 0, 0 );
+
+    if ( !size )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    SanitizeL( size );
+
+    data = HBufC8::NewLC( size );
+    des.Set( data->Des() );
+
+    IPCREAD0L( des );
+
+    if ( des.Left( KFLPrefixLength ).Compare( KFLPrefix ) == 0 )
+        {
+        HBufC8* tmp( NULL );
+        HBufC8* tmp2( NULL );
+        TPtr8 des2( NULL, 0, 0 );
+
+        tmp = CnvUtfConverter::ConvertFromUnicodeToUtf8L( IMEI );
+        CleanupStack::PushL( tmp );
+
+        if ( des.Mid( KFLPrefixLength, IMEI.Length() ).Compare( *tmp ) )
+            {
+            User::Leave( KErrCANoPermission );
+            }
+
+        tmp2 = Base64DecodeL( des.Mid( KFLPrefixLength + tmp->Length() ) );
+
+        *data = *tmp2;
+
+        delete tmp2;
+        tmp2 = NULL;
+
+        CleanupStack::PopAndDestroy( tmp );
+
+        if ( ( data->Length() % KDCFKeySize ) ||
+             data->Length() < ( KDCFKeySize << 1 ) )
+            {
+            User::Leave( KErrArgument );
+            }
+
+        tmp = HBufC8::NewLC( KMaxOmaV1CIDLength );
+
+        des.Set( tmp->Des() );
+
+        GetFlURI( des );
+
+        tmp2 = DRMDB.GetDecryptionKeyL( *tmp );
+
+        CleanupStack::PopAndDestroy( tmp );
+        CleanupStack::PushL( tmp2 );
+
+        des2.Set( const_cast< TText8* >( data->Ptr() ),
+            KDCFKeySize,
+            KDCFKeySize );
+
+        // AesDecrypt overwrites the data.
+        des.Set( const_cast< TText8* >( data->Ptr() ) + KDCFKeySize,
+            data->Length() - KDCFKeySize,
+            data->Length() - KDCFKeySize );
+
+        AesDecryptL( *tmp2, des2, ETrue, des );
+
+        // Erase the key.
+        des2.Set( tmp2->Des() );
+        des2.FillZ();
+
+        CleanupStack::PopAndDestroy( tmp2 );
+
+        if( des.Length() > aMessage.GetDesMaxLength(1) )
+            {
+            User::Leave(KErrArgument);
+            }
+        IPCWRITE1L( des );
+        }
+
+    // Something else, can't handle it. Leave it as it is.
+    CleanupStack::PopAndDestroy( data );
+
+    aMessage.Complete( KErrNone );
+
+    __UHEAP_MARKEND;
+
+    DRMLOG( _L( "CDRMDbSession::DecodeRightsIssuerL ok" ) );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::
+//
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetFlURI( TDes8& aURI )
+    {
+    aURI = KFLLongPrefix;
+    aURI.Append( IMEI );
+    aURI.Append( KFLSuffix );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::AesEncryptL
+// Encrypt data using a given key
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::AesEncryptL( const TDesC8& aKey,
+                                 const TDesC8& aIV,
+                                 const TBool aAddPadding,
+                                 TDes8& aData )
+    {
+    DRMLOG( _L( "CDRMDbSession::AesEncryptL" ) );
+
+    __UHEAP_MARK;
+
+    CModeCBCEncryptor* cbc( NULL );
+    TInt lastBlockStart( 0 );
+    TPtr8 data( NULL, 0, 0 );
+
+    if( aIV.Length() % KDCFKeySize ||
+        aKey.Length() % KDCFKeySize )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    cbc = CModeCBCEncryptor::NewL( CAESEncryptor::NewLC( aKey ), aIV );
+    CleanupStack::Pop(); // CAESEncryptor, owned by cbc.
+    CleanupStack::PushL( cbc );
+
+    lastBlockStart = aData.Length() - ( aData.Length() % KDCFKeySize );
+    for ( TInt i = 0; i  < lastBlockStart; i+= KDCFKeySize )
+        {
+        data.Set( aData.MidTPtr( i, KDCFKeySize ) );
+
+        cbc->Transform( data );
+        }
+
+    if ( aAddPadding )
+        {
+        TInt dataLength = aData.Length();
+        TUint8 padding( static_cast< TUint8 >
+            ( lastBlockStart + KDCFKeySize - dataLength ) );
+
+        __ASSERT_DEBUG( lastBlockStart + KDCFKeySize - dataLength <= KDCFKeySize,
+                        User::Invariant() );
+
+        aData.SetLength( lastBlockStart + KDCFKeySize );
+
+        for ( TInt i = dataLength; i < aData.Length(); ++i )
+            {
+            aData[ i ] = padding;
+            }
+
+        data.Set( aData.MidTPtr( lastBlockStart, KDCFKeySize ) );
+        cbc->Transform( data );
+        }
+
+    CleanupStack::PopAndDestroy( cbc );
+
+    __UHEAP_MARKEND;
+
+    DRMLOG( _L( "CDRMDbSession::AesEncryptL ok" ) );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::AesDecryptL
+// Decrypt data using a given key
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::AesDecryptL( const TDesC8& aKey,
+                                 const TDesC8& aIV,
+                                 const TBool aRemovePadding,
+                                 TDes8& aData )
+    {
+    DRMLOG( _L( "CDRMDbSession::AesDecryptL" ) );
+
+    __UHEAP_MARK;
+
+    CModeCBCDecryptor* cbc( NULL );
+
+    cbc = CModeCBCDecryptor::NewL(
+        CAESDecryptor::NewLC( aKey ), aIV );
+
+    CleanupStack::Pop(); // CAESDecryptor
+
+    __ASSERT_DEBUG( ( aData.Length() >= 0 ) &&
+                    ( aData.Length() % KDCFKeySize == 0 ),
+                    User::Invariant() );
+
+    for ( TInt count = 0; count < aData.Length(); count += KDCFKeySize )
+        {
+        TPtr8 d( aData.MidTPtr( count, KDCFKeySize ) );
+
+        cbc->Transform( d );
+        }
+
+    delete cbc; cbc = NULL;
+
+    if ( aRemovePadding )
+        {
+        TInt count( aData.Length() );
+        TUint8 c( aData[ count - 1 ] );
+
+        if ( c > KDCFKeySize )
+            {
+            User::Leave( KErrCorrupt );
+            }
+
+        aData.SetLength( count - c );
+        }
+
+    __UHEAP_MARKEND;
+
+    DRMLOG( _L( "CDRMDbSession::AesDecryptL ok" ) );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::
+//
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::GenerateIVL( TDes8& aIV )
+    {
+    DRMLOG( _L( "CDRMDbSession::GenerateIVL" ) );
+    __UHEAP_MARK;
+
+    __ASSERT_DEBUG( aIV.MaxSize() >= KDCFKeySize, User::Invariant() );
+    MDrmKeyStorage* storage = DrmKeyStorageNewL();
+    TCleanupItem storageCleanup( DeleteObject, storage );
+    CleanupStack::PushL(storageCleanup);
+
+    storage->RandomDataGetL(aIV,KDCFKeySize);
+    CleanupStack::PopAndDestroy( storage );
+
+    DRMLOG(_L("random aIV:"));
+    DRMLOGHEX(aIV);
+
+
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMDbSession::GenerateIVL ok" ) );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::
+//
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::AsyncOperationDone()
+    {
+    DRMLOG( _L( "CDRMDbSession::AsyncOperationDone" ) );
+    // All done.
+    delete iPendingRequest;
+    iPendingRequest = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::
+//
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::AsyncOperationDone( TFileName* aFileName )
+    {
+    DRMLOG( _L( "CDRMDbSession::AsyncOperationDone" ) );
+    // All done.
+    delete iPendingRequest;
+    iPendingRequest = NULL;
+
+    iFileName = aFileName;
+    }
+
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::SetAuthenticationSeedL
+// Sets the authentication seed for a content ID. Requires that the REK and KEK
+// have been set during a previous AddRecord operation
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::SetAuthenticationSeedL( const RMessage2& aMessage )
+    {
+    DRMLOG(_L("CDRMDbSession::SetAuthenticationSeedL"));
+
+    __UHEAP_MARK;
+    SanitizeL( aMessage.GetDesLength(0));
+    SanitizeL( aMessage.GetDesLength(1));
+
+    HBufC8* cid = HBufC8::NewLC(IPCGETDESLEN0);
+    HBufC8* wrappedSeed = HBufC8::NewLC(IPCGETDESLEN1);
+    HBufC8* seed = NULL;
+
+    if (iRek.Length() == 0)
+        {
+        User::Leave(KErrNotReady);
+        }
+
+    TPtr8 tmp(cid->Des());
+    IPCREAD0L(tmp );
+    TPtr8 tmp2(wrappedSeed->Des());
+    IPCREAD1L(tmp2);
+
+    seed = OmaCrypto::AesUnwrapL(iRek, *wrappedSeed);
+    CleanupStack::PushL(seed);
+    DRMDB.SetAuthenticationSeedL(*cid, *seed);
+    CleanupStack::PopAndDestroy(3); // seed, wrappedSeed, cid
+    __UHEAP_MARKEND;
+    aMessage.Complete(KErrNone);
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::GetAuthenticationSeedL
+// Returns the authentication seed for a content ID
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetAuthenticationSeedL( const RMessage2& aMessage )
+    {
+    DRMLOG(_L("CDRMDbSession::GetAuthenticationSeedL"));
+
+    __UHEAP_MARK;
+    HBufC8* cid = NULL;
+    HBufC8* seed = NULL;
+
+    SanitizeL( aMessage.GetDesLength(0));
+    cid = HBufC8::NewLC(IPCGETDESLEN0);
+
+    TPtr8 tmp(cid->Des());
+    IPCREAD0L(tmp);
+    User::LeaveIfError(VerifyCredentials(cid, NULL, EUnknown));
+    seed = DRMDB.GetAuthenticationSeedL(*cid);
+    CleanupStack::PushL(seed);
+
+    if( seed->Length() > aMessage.GetDesMaxLength(1) )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    IPCWRITE1L(*seed);
+    CleanupStack::PopAndDestroy(2); // seed, cid
+    __UHEAP_MARKEND;
+    aMessage.Complete(KErrNone);
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::VerifyMacL
+// Integrity protection for protecets ROs
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::VerifyMacL( const RMessage2& aMessage )
+    {
+    DRMLOG(_L("CDRMDbSession::VerifyMacL"));
+
+    if( !iMac.Length() )
+        {
+        User::Leave(KErrNotReady);
+        }
+
+    __UHEAP_MARK;
+
+    CHMAC* hMac = NULL;
+    CSHA1* sha = NULL;
+    TPtrC8 hmac_value( KNullDesC8 );
+    TPtrC8 sha1_value( KNullDesC8 );
+    HBufC8* signedInfo = NULL;
+    HBufC8* macValue = NULL;
+    TInt ret = KErrNone;
+
+    signedInfo = HBufC8::NewLC(IPCGETDESLEN0);
+    TPtr8 signedInfoPtr(signedInfo->Des());
+    macValue = HBufC8::NewLC(IPCGETDESLEN1);
+    TPtr8 macValuePtr(macValue->Des());
+
+    IPCREAD0L(signedInfoPtr);
+    IPCREAD1L(macValuePtr);
+
+    DRMLOG(_L("Signed info:"));
+    DRMLOGHEX(signedInfoPtr);
+    DRMLOG(_L("MAC value:"));
+    DRMLOGHEX(macValuePtr);
+
+    sha = CSHA1::NewL();
+    CleanupStack::PushL( sha );
+    hMac = CHMAC::NewL( iMac, sha );
+    CleanupStack::Pop( sha ); // sha is now owned by hMac
+    CleanupStack::PushL( hMac );
+    hMac->Update( signedInfoPtr );
+    hmac_value.Set( hMac->Final() );
+
+    DRMLOG(_L("Calculated MAC value:"));
+    DRMLOGHEX(hmac_value);
+    if ( hmac_value.Compare( macValuePtr ) != 0 )
+        {
+        // MAC validation failed
+        ret = KErrRightsServerMacFailed;
+        }
+
+    CleanupStack::PopAndDestroy(3, signedInfo); // hMac, macValue, signedInfo
+    __UHEAP_MARKEND;
+    aMessage.Complete(ret);
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::GetSupportedIndividualsL
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetSupportedIndividualsL( const RMessage2& aMessage )
+    {
+    DRMLOG( _L( "CDRMDbSession::GetSupportedIndividualsL" ) );
+    TPckgBuf< TInt > size( 0 );
+    TInt stringSize = 0;
+    TInt offset = 0;
+    TUint8* ptr = 0;
+
+    // Cleanup.
+    if ( iPreparedData )
+        {
+        delete iPreparedData;
+        iPreparedData = NULL;
+        }
+
+    for ( TInt i = 0; i < IMSI.Count(); i++ )
+        {
+        stringSize += sizeof(TInt);
+        stringSize += IMSI[i]->Size();
+        }
+
+
+    // If it's empty, just return right away
+    if( !stringSize )
+        {
+        IPCWRITE0L( size );
+        aMessage.Complete(KErrNone);
+        return;
+        }
+
+    // Otherwise create a buffer and fill it:
+    iPreparedData = HBufC8::NewMaxL( stringSize );
+    ptr = const_cast<TUint8*>( iPreparedData->Ptr() );
+
+    size() = stringSize;
+
+    for(  TInt i = 0; i < IMSI.Count(); i++ )
+        {
+        // Write the size:
+        stringSize = IMSI[i]->Size();
+        Mem::Copy(ptr+offset, &stringSize, sizeof(TInt));
+        offset += sizeof(TInt);
+
+        // Write the data:
+        Mem::Copy(ptr+offset, IMSI[i]->Ptr(), IMSI[i]->Size());
+        offset += IMSI[i]->Size();
+        }
+    IPCWRITE0L( size );
+
+    aMessage.Complete( KErrNone );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::StopWatchingL
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::StopWatchingL( const RMessage2& aMessage )
+    {
+    _LIT_SECURITY_POLICY_S0( sidCheck, KTrustedShutdownClient );
+    if ( sidCheck.CheckPolicy( aMessage ) )
+        {
+        SERVER->StopWatchingL();
+        }
+    aMessage.Complete( KErrNone );
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::DeleteAllowedL
+// ----------------------------------------------------------------------------
+//
+TBool CDRMDbSession::DeleteAllowedL( const TDesC8& aContentId )
+    {
+    TBuf8< KMaxOmaV1CIDLength > URI;
+
+    // Get the FL uri
+    GetFlURI( URI );
+
+    if( aContentId.Compare( URI ) &&
+        aContentId.Compare( KDCMUri ) &&
+        aContentId.Compare( KLDFUri ) )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// CDRMDbSession::GetRandomDataL
+// ----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetRandomDataL( const RMessage2& aMessage )
+    {
+    DRMLOG(_L("CDRMDbSession::GetRandomDataL"));
+
+    HBufC8* data = NULL;
+    SanitizeL( aMessage.GetDesMaxLength(0) );
+    SanitizeL( aMessage.GetDesLength(0));
+
+    data = HBufC8::NewMaxLC(IPCGETDESLEN0);
+    TPtr8 ptr(data->Des());
+
+    MDrmKeyStorage* storage = DrmKeyStorageNewL();
+    TCleanupItem storageCleanup( DeleteObject, storage );
+    CleanupStack::PushL(storageCleanup);
+    storage->RandomDataGetL(ptr,ptr.Size());
+    IPCWRITE0L(*data);
+
+    CleanupStack::PopAndDestroy(2, data);
+    aMessage.Complete( KErrNone );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::GetMeteringDataL
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::GetMeteringDataL( const RMessage2& aMessage )
+    {
+#ifndef RD_DRM_METERING
+    aMessage.Complete ( KErrNotSupported );
+#else
+    HBufC8* riId = NULL;
+    HBufC8* meteringData = NULL;
+    CDRMPointerArray<CDrmMeteringDbData>* meteringArray =
+        CDRMPointerArray<CDrmMeteringDbData>::NewLC();
+    meteringArray->SetAutoCleanup( ETrue );
+
+    TInt size = 0;
+    TPtr8 data( NULL, 0 );
+    TPckg<TInt> package( size );
+
+    SanitizeL( aMessage.GetDesLength(0));
+    // Empty old data
+    delete iPreparedData;
+    iPreparedData = NULL;
+
+    riId = HBufC8::NewLC( User::LeaveIfError( IPCGETDESLEN1 ) );
+    data.Set( riId->Des() );
+    IPCREAD1L( data );
+
+    if ( METERINGDB.GetL( *riId, *meteringArray ) )
+        {
+        meteringData = CreateMeteringDataL( meteringArray );
+        CleanupStack::PushL( meteringData );
+        }
+    else
+        {
+        _LIT8( KEmptyMetering, "<rawMeteringReportData>\r\n</rawMeteringReportData>");
+        meteringData = KEmptyMetering().AllocLC();
+        }
+    DRMLOGHEX( *meteringData );
+    size = meteringData->Size();
+    iPreparedData = meteringData;
+    CleanupStack::Pop( meteringData );
+
+    IPCWRITE0L( package );
+    CleanupStack::PopAndDestroy( 2 ); // riId, meteringArray
+    if ( !iPreparedData )
+        {
+        aMessage.Complete( KErrNotFound );
+        return;
+        }
+    aMessage.Complete( KErrNone );
+#endif
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMDbSession::DeleteMeteringDataL
+// -----------------------------------------------------------------------------
+//
+void CDRMDbSession::DeleteMeteringDataL( const RMessage2& aMessage )
+    {
+#ifndef RD_DRM_METERING
+    aMessage.Complete ( KErrNotSupported );
+#else
+// Metering supported
+    HBufC8* riId = NULL;
+    TPtr8 data( NULL, 0 );
+    TBool meteringDataDeleted;
+
+    riId = HBufC8::NewLC( User::LeaveIfError( IPCGETDESLEN0 ) );
+    data.Set( riId->Des() );
+    IPCREAD0L( data );
+    meteringDataDeleted = METERINGDB.DeleteL( *riId );
+
+        if( meteringDataDeleted )
+            {
+            DRMLOG( _L("CDRMDbSession::DeleteMeteringDataL -> some records were destroyed") );
+            }
+    // Do we have to do something else?
+    CleanupStack::PopAndDestroy( riId );
+    aMessage.Complete( KErrNone );
+#endif
+    }
+// -----------------------------------------------------------------------------
+// CDRMDbSession::ConnectRoapClient()
+// -----------------------------------------------------------------------------
+//
+TInt CDRMDbSession::ConnectRoapClient()
+    {
+    if( iRoapClientConnected )
+        {
+        return KErrNone;
+        }
+    TInt err( iRoapClient.Connect() );
+    if ( !err )
+        {
+        iRoapClientConnected = ETrue;
+        }
+    return err;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMObsoleteFinder.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,466 @@
+/*
+* 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:  Implementation of the DRM Rights Database
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <e32std.h>		// RPointerArray
+#include <e32def.h>		// Type definitions
+
+#include <caf/caf.h>
+#include <dcfrep.h>
+#include "DRMCommon.h"	// DRM Error messages
+#include "DRMObsoleteFinder.h"
+#include "DRMRightsDB.h"
+#include "drmlog.h"
+#include <dcfrep.h>
+
+#include <SysUtil.h>    // Disk space checking
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+const TInt KScanFileSystem = 1;
+const TInt KScanContents = 2;
+const TInt KRemoveUsedParents = 3;
+const TInt KWriteTempFile = 4;
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TInt CompareHBufC8( const HBufC8& aFirst, const HBufC8& aSecond );
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+LOCAL_C TInt CompareHBufC8( const HBufC8& aFirst, const HBufC8& aSecond )
+    {
+	return aFirst.Compare( aSecond );
+    };
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+        
+// -----------------------------------------------------------------------------
+// CDRMObsoleteFinder::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMObsoleteFinder* CDRMObsoleteFinder::NewL( RFs& aFs,
+                                            CDRMRightsDB* aDatabase,
+                                            TRequestStatus& aStatus,
+                                            RWriteStream& aStream,
+                                            TBool aPerformScan )
+    {
+    CDRMObsoleteFinder* self = new( ELeave ) CDRMObsoleteFinder( aFs, 
+                                                        aDatabase, aStatus, 
+                                                        aStream );
+    CleanupStack::PushL( self );
+    self->ConstructL( aPerformScan );
+    CleanupStack::Pop();
+    
+    return self;
+    }
+  
+        
+// -----------------------------------------------------------------------------
+// Destructor        
+// -----------------------------------------------------------------------------
+//
+CDRMObsoleteFinder::~CDRMObsoleteFinder()
+    {
+    // just in case
+    Cancel();
+    
+    if( iDcfClient )
+        {
+        delete iDcfClient;
+        iDcfClient = NULL;    
+        }
+    
+    if( iContents )
+        {
+        delete iContents;
+        iContents = NULL;   
+        }
+
+    if( iParents )
+        {
+        delete iParents;
+        iParents = NULL;            
+        }
+     
+    if( iNoContents )
+        {
+        delete iNoContents;
+        iNoContents = NULL;            
+        }            
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMObsoleteFinder::ExecuteCleanupLD        
+// -----------------------------------------------------------------------------
+//    
+void CDRMObsoleteFinder::ExecuteFinderLD()
+    {
+    TRequestStatus* status = 0;
+    
+    if( !IsAdded() ) 
+        {
+        CActiveScheduler::Add(this);        
+        }
+    if ( !IsActive() ) 
+        {
+        SetActive();        
+        }
+    
+    iOperationStatus = KRequestPending;
+    status = &iStatus;
+    User::RequestComplete(status,KErrNone);        
+    };
+
+// -----------------------------------------------------------------------------                        
+// Default Constructor - First phase.
+// -----------------------------------------------------------------------------
+//
+CDRMObsoleteFinder::CDRMObsoleteFinder( RFs& aFs,
+                                        CDRMRightsDB* aDatabase,
+                                        TRequestStatus& aStatus,
+                                        RWriteStream& aStream ) :
+    CActive( EPriorityLow ),
+    iContents( NULL ),
+    iParents( NULL ),
+    iNoContents( NULL ),
+    iIndex( -1 ),
+    iFileServer( aFs ),
+    iStream( aStream ),
+    iRightsDb( aDatabase ),
+    iOperationStatus( aStatus ),
+    iState( KScanFileSystem )                         
+    {
+        
+    }; 
+        
+
+// -----------------------------------------------------------------------------                        
+// CDRMObsoleteFinder::ConstructL
+// -----------------------------------------------------------------------------
+// 
+void CDRMObsoleteFinder::ConstructL( const TBool aPerformScan )
+    {
+    // if the scan needs to be done, the initial state is different:
+    if( aPerformScan )
+        {
+        iState = KScanFileSystem;    
+        }
+    else
+        {
+        iState = KScanContents;    
+        } 
+       
+    // connect to dcf repository
+    iDcfClient = CDcfRep::NewL();
+    
+    // Create a new list
+    iContents = CDRMPointerArray<HBufC8>::NewL();    
+    
+    // Create a new list
+    iParents = CDRMPointerArray<HBufC8>::NewL();  
+
+    // Create a new list
+    iNoContents = CDRMPointerArray<HBufC8>::NewL();  
+        
+    };  
+
+// -----------------------------------------------------------------------------                        
+// CDRMObsoleteFinder::RunError
+// -----------------------------------------------------------------------------
+//  
+TInt CDRMObsoleteFinder::RunError(TInt aError)
+    {
+    TRequestStatus* status = 0;
+    
+    if( aError != KErrNone )
+        {
+        status = &iOperationStatus;
+        User::RequestComplete( status, aError );                
+        delete this;            
+        }
+    return KErrNone;
+    };
+
+// -----------------------------------------------------------------------------                        
+// CDRMObsoleteFinder::RunL
+// -----------------------------------------------------------------------------
+//      
+void CDRMObsoleteFinder::RunL()
+    {
+    TRequestStatus* status = 0;    
+    TInt error = KErrNone;
+    HBufC8* buffer = NULL;
+
+    // If the status of the cleaning is other than KErrNone
+    User::LeaveIfError( iStatus.Int() );
+
+    switch( iState )
+        {
+        case KScanFileSystem:
+            iState = KScanContents;
+            iDcfClient->RefreshDcf( iStatus );            
+            SetActive();    
+            break;
+        case KScanContents:
+            if( iIndex == -1 )
+                {
+                // Get the contents
+                iRightsDb->GetContentIDListL( *iContents );
+                // Reset the index
+                iIndex = 0;  
+                }
+            else 
+                {
+                iIndex++;                     
+                }  
+                
+            if( iIndex >= iContents->Count() )
+                {
+                iState = KRemoveUsedParents;
+                iIndex = -1;   
+                }
+            else 
+                {
+                // Check if there is content
+                TRAP( error, iDcfClient->OrderListL( *(*iContents)[iIndex] ));
+        
+                // If an error occurs, leave if it's ok, continue
+                if( error != KErrNotFound )
+                    {
+                    User::LeaveIfError( error ); 
+                    
+                    // Get all the parents
+                    if( !error ) 
+                        {
+                        GetParentsL( *(*iContents)[iIndex], *iParents );   
+                        }                      
+                    }
+                // If the error is not found, add to the no content list    
+                else
+                    {
+                    buffer = (*iContents)[iIndex]->AllocLC();
+                    iNoContents->AppendL( buffer );
+                    CleanupStack::Pop();    
+                    }                       
+                }
+            SetActive();
+            status = &iStatus;
+            User::RequestComplete(status,KErrNone);              
+            break;
+        case KRemoveUsedParents:
+            if( iIndex == -1 )
+                {
+                iIndex = 0;  
+                }
+            else 
+                {
+                iIndex++;                     
+                }
+                  
+            if( iIndex >= iParents->Count() )
+                {
+                iState = KWriteTempFile;
+                iIndex = -1; 
+                }
+            else
+                {
+                // Find the parent
+                error = iNoContents->FindInOrder( (*iParents)[iIndex], 
+                                       TLinearOrder<HBufC8>(CompareHBufC8));
+                                      
+                if( error != KErrNotFound )
+                    {
+                    buffer = (*iNoContents)[error];
+                    iNoContents->Remove( error );
+                    delete buffer;
+                    buffer = 0;    
+                    }                                                           
+                }
+            SetActive();
+            status = &iStatus;
+            User::RequestComplete(status,KErrNone);                 
+            break;
+        case KWriteTempFile:
+            ObsoleteToStreamL();
+            // we are complete:
+            status = &iOperationStatus;
+            User::RequestComplete( status, KErrNone );                
+            delete this; 
+            return;                          
+        default:
+            // illegal status, return error and delete object
+            status = &iOperationStatus;
+            User::RequestComplete( status, KErrGeneral );
+            delete this; 
+            return;                       
+        }
+    };    
+
+
+// ----------------------------------------------------------------------------
+// CDRMObsoleteFinder::GetParentsL
+// ----------------------------------------------------------------------------
+//
+void CDRMObsoleteFinder::GetParentsL( const TDesC8& aContentId,
+                                      RPointerArray<HBufC8>& aParents )
+    {
+    HBufC8* parentId = NULL;
+    TInt error = KErrNone;
+    CDRMPointerArray<CDRMPermission>* permissions = 
+      CDRMPointerArray<CDRMPermission>::NewLC();
+    permissions->SetAutoCleanup( ETrue );
+    CDRMPointerArray<CDRMPermission>& perm = *permissions;  
+
+    TRAP( error, iRightsDb->GetDBEntryByContentIDL( aContentId, *permissions ) );
+    
+    // If there are no keys it means that there is encryption key and such, but
+    // no available permissions
+    if( error == KErrCANoRights )
+        {
+        CleanupStack::PopAndDestroy(); // permissions
+        return;    
+        }
+    else 
+        {
+        User::LeaveIfError(error);    
+        }
+        
+    for( TInt i = 0; i < permissions->Count(); i++, error = KErrNone )
+        {
+        // Check if the permission has a parent
+        if( perm[i]->iParentUID ) 
+            {
+            // if it does, insert it to the aParents array
+            error = aParents.FindInOrder( perm[i]->iParentUID, 
+                                          TLinearOrder<HBufC8>(CompareHBufC8));
+            if( error == KErrNotFound )
+                {
+                parentId = perm[i]->iParentUID->AllocLC();
+                User::LeaveIfError( aParents.InsertInOrder(parentId, 
+                                    TLinearOrder<HBufC8>(CompareHBufC8)) );
+                CleanupStack::Pop();       
+                }
+            }
+        }
+
+    CleanupStack::PopAndDestroy(); // permissions     
+    }; 
+
+
+// -----------------------------------------------------------------------------
+// CDRMObsoleteFinder::ObsoleteToStreamL
+// -----------------------------------------------------------------------------
+//
+void CDRMObsoleteFinder::ObsoleteToStreamL()
+    {
+    TInt count( 0 );
+
+
+    TInt size( 4 ); // size of the count
+    for( count = 0; count < iNoContents->Count(); count++ )
+        {
+        size += (*iNoContents)[ count ]->Size();
+        size += sizeof(TUint16);
+        }
+
+    // Reset count variable:
+    count = 0;
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFileServer, 
+                                                size, 
+                                                EDriveC ) )
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &iFileServer, 
+                                                size, 
+                                                driveNumber ) )
+    
+#endif
+
+        {
+        DRMLOG( _L( "CDRMDbSession::UriListToFileL: KErrDiskFull" ) );
+        User::Leave( KErrDiskFull );
+        }     
+    // Write the whole stuff into the file.
+    while( count < iNoContents->Count() )
+        {
+        iStream.WriteUint16L( (*iNoContents)[count]->Length() );
+        iStream.WriteL( *(*iNoContents)[count] );
+        ++count;
+        }
+    // Finish with a 0    
+    iStream.WriteUint16L( 0 );    
+    
+    iStream.CommitL();
+    }
+
+// -----------------------------------------------------------------------------                        
+// CDRMObsoleteFinder::DoCancel
+// -----------------------------------------------------------------------------
+//      
+void CDRMObsoleteFinder::DoCancel()
+    {  
+    }; 
+
+// -----------------------------------------------------------------------------                        
+// CDRMObsoleteFinder::DoCleanup
+// -----------------------------------------------------------------------------
+//      
+void CDRMObsoleteFinder::DoCleanup()
+    {
+    TRequestStatus* status = 0;      
+    if( iCancel <= 0 )
+        {
+        iCancel = 1;
+        status = &iStatus;
+        User::RequestComplete(status, KErrCancel);
+        }       
+    }; 
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMReplayCache.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,529 @@
+/*
+* 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:  Implementation of the parent storage for Decision Making Machine
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <f32file.h>
+#include <S32FILE.H>
+#include <BAUTILS.H>
+#include "drmreplaycache.h"
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+_LIT( KCIDColName, "cid" );
+_LIT( KTimeColName, "time" );
+_LIT( KInsertionTimeColName, "inserttime" );
+_LIT( KReplayCacheTable, "cache" );
+_LIT( KViewInitQuery, "SELECT * FROM cache ORDER BY inserttime ASC" );
+
+LOCAL_C const TUint KDbViewInsertionTimeOrdinal = 2;
+LOCAL_C const TUint8 KDbViewTimeOrdinal = 3;
+LOCAL_C const TUint8 KDbViewIDOrdinal = 1;
+LOCAL_C const TUint16 KDbMaxNumOfItems = 100;
+
+// MODULE DATA STRUCTURES
+NONSHARABLE_STRUCT( TDoDeleteFile ) 
+    {
+    RFs* iFs;
+    const TDesC* iFile;
+    };
+    
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C void DoRollBack( TAny* aAny );
+LOCAL_C void DoDeleteFile( TAny* aAny );
+
+// FORWARD DECLARATIONS
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// DoRollBack
+//
+// Do a rollback operation to the RDbDatabase* 
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void DoRollBack( TAny* aAny )
+    {
+    reinterpret_cast< RDbDatabase* >( aAny )->Rollback();
+    }
+
+// -----------------------------------------------------------------------------
+// DoDeleteFile
+//
+// Delete the file presented by TDoDeleteFile*
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void DoDeleteFile( TAny* aAny )
+    {
+    TDoDeleteFile* s = reinterpret_cast< TDoDeleteFile* >( aAny );
+    
+    s->iFs->Delete( *( s->iFile ) );    
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::RDRMReplayCache
+//
+// Default constructor 
+// -----------------------------------------------------------------------------
+//
+RDRMReplayCache::RDRMReplayCache():
+iFs( NULL ),
+iTimeDb(),
+iPlainDb()
+    {
+    // Nothing.    
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::RDRMReplayCache
+//
+// Constructor 
+// -----------------------------------------------------------------------------
+//
+RDRMReplayCache::RDRMReplayCache( RFs& aFs ) :
+iFs( &aFs ),
+iTimeDb(),
+iPlainDb()
+    {
+    // Nothing.
+    }
+    
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::Set
+//
+// Set iFs to given aFs.
+// -----------------------------------------------------------------------------
+//    
+void RDRMReplayCache::Set( RFs& aFs )
+    {
+    iFs = &aFs;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::Close
+//
+// Closes the databases.
+// -----------------------------------------------------------------------------
+//    
+void RDRMReplayCache::Close()
+    {
+    // iView.Close();
+    iTimeDb.Close();
+    iPlainDb.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::InitL
+//
+// Initialize the databases.
+// -----------------------------------------------------------------------------
+//    
+void RDRMReplayCache::InitL( const TDesC& aTimedDb,
+                             const TDesC& aPlainDb )
+    {
+    InitDbL( iTimeDb, aTimedDb, ETimeDb );
+    InitDbL( iPlainDb, aPlainDb, EPlainDb );
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::InCacheL
+//
+// Check whether the given entry is in cache. Overloaded.
+// -----------------------------------------------------------------------------
+//
+TBool RDRMReplayCache::InCacheL( const TDesC8& aID, 
+                                 const TTime& aTime )
+    {
+    TBool res = EFalse;
+    
+    RDbView view;
+    InitViewLC( view, ETimeDb, EFalse );
+    
+    view.FirstL();
+    
+    while ( view.AtRow() && !res )
+        {
+        view.GetL();
+        TTime time = view.ColInt64( KDbViewTimeOrdinal );
+
+        if ( time == aTime )
+            {
+            res = CompareCIDL( view, aID );
+            }
+        view.NextL();
+        }
+        
+    CleanupStack::PopAndDestroy(); // view
+    
+    return res;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::InCacheL
+//
+// Check whether the given entry is in cache. Overloaded.
+// -----------------------------------------------------------------------------
+//   
+TBool RDRMReplayCache::InCacheL( const TDesC8& aID )
+    {
+    TBool res = EFalse;
+    
+    RDbView view;
+    InitViewLC( view, EPlainDb, EFalse );
+    
+    view.FirstL();
+    
+    while ( view.AtRow() && !res )
+        {
+        view.GetL();
+        
+        res = CompareCIDL( view, aID );
+        
+        view.NextL();
+        }
+        
+    CleanupStack::PopAndDestroy(); // view
+    
+    return res;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::AddL
+//
+// Add an entry to the database. Overloaded.
+// -----------------------------------------------------------------------------
+//    
+void RDRMReplayCache::AddL( const TDesC8& aID, 
+                            const TTime& aTime,
+                            const TTime& aInsertionTime )
+    {
+    RDbColWriteStream stream;
+    RDbView view;
+        
+    PushL( iTimeDb );
+    
+    InitViewLC( view, ETimeDb, ETrue );
+    CompactViewL( view );
+
+    // Oldest ones are in the list earlier, and as long as clock works 
+    // correctly, insertiontime(n-1)<insertiontime(n).
+    view.EndL();
+    
+    User::LeaveIfError( iTimeDb.Begin() );
+    
+    view.InsertL(); 
+    
+    InsertIdL( view, aID );
+    view.SetColL( KDbViewInsertionTimeOrdinal, aInsertionTime.Int64() );
+    view.SetColL( KDbViewTimeOrdinal, aTime.Int64() );
+    
+    view.PutL();
+    
+    CleanupStack::PopAndDestroy(); // view
+    
+    User::LeaveIfError( iTimeDb.Commit() );
+    User::LeaveIfError( iTimeDb.Compact() );
+    
+    Pop(); // iTimeDb
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::AddL
+//
+// Add an entry to the database. Overloaded.
+// -----------------------------------------------------------------------------
+//   
+void RDRMReplayCache::AddL( const TDesC8& aID,
+                            const TTime& aInsertionTime )
+    {
+    
+    RDbView view;
+    
+    PushL( iPlainDb );
+    
+    InitViewLC( view, EPlainDb, ETrue );
+    CompactViewL( view );
+    
+    view .EndL();
+    
+    User::LeaveIfError( iPlainDb.Begin() );
+    
+    view.InsertL();
+    InsertIdL( view, aID );
+    view.SetColL( KDbViewInsertionTimeOrdinal, aInsertionTime.Int64() );
+    
+    view.PutL();
+    
+    CleanupStack::PopAndDestroy(); // view
+    
+    User::LeaveIfError( iPlainDb.Commit() );
+    User::LeaveIfError( iPlainDb.Compact() );
+    
+    Pop(); // iPlainDb
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::InitDbL
+//
+// Initialize the databases.
+// -----------------------------------------------------------------------------
+//       
+void RDRMReplayCache::InitDbL( RDbNamedDatabase& aDb, 
+                               const TDesC& aFileName,
+                               TDatabaseId aId )
+    {
+    TInt error = KErrNone;
+    TBool exists = BaflUtils::FileExists( *iFs, aFileName );
+    
+    if ( exists )
+        {
+        TRAP( error, OpenDbL( aDb, aFileName ) );
+        }
+    if ( error || !exists )
+        {
+        ReplaceDbL( aDb, aFileName, aId );
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::~RDRMReplayCache
+//
+// Destructor.
+// -----------------------------------------------------------------------------
+//   
+RDRMReplayCache::~RDRMReplayCache()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::OpenDbL
+//
+// Open the database.
+// -----------------------------------------------------------------------------
+//   
+void RDRMReplayCache::OpenDbL( RDbNamedDatabase& aDb, 
+                               const TDesC& aFileName )
+    {
+    CDbTableNames* tables = NULL;
+    
+    User::LeaveIfError( aDb.Open( *iFs, aFileName ) );
+    CleanupClosePushL( aDb );
+    
+    if ( aDb.IsDamaged() )
+        {
+        User::LeaveIfError( aDb.Recover() );
+        }
+        
+    // Sanity check.
+    tables = aDb.TableNamesL();
+    CleanupStack::PushL( tables );
+    
+    if ( tables->Count() != 1 || ( *tables )[ 0 ].Compare( KReplayCacheTable ) )
+        {
+        User::Leave( KErrCorrupt );
+        }
+    
+    CleanupStack::PopAndDestroy(); // tables
+    CleanupStack::Pop(); // aDb
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::ReplaceDbL
+//
+// Replace the database.
+// -----------------------------------------------------------------------------
+//       
+void RDRMReplayCache::ReplaceDbL( RDbNamedDatabase& aDb, 
+                                  const TDesC& aFileName, 
+                                  TDatabaseId aId )
+    {
+    CDbColSet*  colSet = NULL;
+//    CDbKey* key = NULL;
+    TDbCol cidCol( KCIDColName, EDbColLongText8 );
+    TDbCol insertionTimeCol( KInsertionTimeColName, EDbColInt64 );
+    TDbCol timeCol( KTimeColName, EDbColInt64 );
+    
+    TDoDeleteFile deletefile = { iFs, &aFileName };
+    
+    TCleanupItem item( DoDeleteFile, &deletefile );
+    CleanupStack::PushL( item );
+    
+    User::LeaveIfError( aDb.Replace( *iFs, aFileName ) );
+    CleanupClosePushL( aDb );
+    
+    // Add columns
+    colSet = CDbColSet::NewLC();
+    colSet->AddL( cidCol );
+    colSet->AddL( insertionTimeCol );
+    
+    if ( aId == ETimeDb )
+        {
+        colSet->AddL( timeCol );
+        }
+    
+    User::LeaveIfError( aDb.Begin() );
+    User::LeaveIfError( aDb.CreateTable( KReplayCacheTable, *colSet ) );
+    User::LeaveIfError( aDb.Commit() );
+    
+    CleanupStack::PopAndDestroy(); // colSet
+    CleanupStack::Pop(); // aDb    
+    CleanupStack::Pop(); // item
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::InitViewLC
+//
+// Initialize the view.
+// -----------------------------------------------------------------------------
+//   
+void RDRMReplayCache::InitViewLC( RDbView& aView, 
+                                  TDatabaseId aId, 
+                                  TBool aUpdate )
+    {
+    RDbDatabase* db = ( aId ==  ETimeDb ? &iTimeDb : &iPlainDb );
+    
+    User::LeaveIfError( 
+        aView.Prepare( *db, 
+                       TDbQuery( KViewInitQuery, EDbCompareCollated ), 
+                       aUpdate ? RDbRowSet::EUpdatable : RDbRowSet::EReadOnly ) );
+    
+    CleanupClosePushL( aView );
+    
+    User::LeaveIfError( aView.EvaluateAll() );
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::CompareCIDL
+//
+// Compare whether the rowset's CID matches the given CID.
+// -----------------------------------------------------------------------------
+//       
+TBool RDRMReplayCache::CompareCIDL( RDbRowSet& aView, 
+                                    const TDesC8& aCID )
+    {
+    TBool res = EFalse;
+    
+    TInt size = aView.ColLength( KDbViewIDOrdinal );
+    
+    RDbColReadStream colData;
+    colData.OpenLC( aView, KDbViewIDOrdinal );
+    
+    // The data contains also the cardinality of the CID data, but anyway... 
+    HBufC8* des = HBufC8::NewLC( colData, size );
+
+    if ( aCID.CompareC( *des ) == 0 )
+        {
+        res = ETrue;
+        }
+    
+    CleanupStack::PopAndDestroy(); // des
+    CleanupStack::PopAndDestroy(); // colData
+    
+    return res;
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::PushL
+//
+// Push a cleanup item to cleanup stack.
+// -----------------------------------------------------------------------------
+//   
+void RDRMReplayCache::PushL( RDbDatabase& aDb )
+    {
+    TCleanupItem item( DoRollBack, &aDb );
+    CleanupStack::PushL( item );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::Pop
+//
+// Pop a cleanup item pushed in by PushL.
+// -----------------------------------------------------------------------------
+//       
+void RDRMReplayCache::Pop()
+    {
+    CleanupStack::Pop();
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::DeleteOldestL
+//
+// Delete aHowMany entries from the view.
+// -----------------------------------------------------------------------------
+//       
+void RDRMReplayCache::DeleteOldestsL( RDbRowSet& aView, TInt16 aHowMany )
+    {
+    aView.FirstL();
+    
+    while ( aHowMany > 0 )
+        {
+        aView.DeleteL();
+        aView.NextL();
+        --aHowMany;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::CompactViewL
+//
+// Compact the view, deleting items if necessary.
+// -----------------------------------------------------------------------------
+//       
+void RDRMReplayCache::CompactViewL( RDbRowSet& aView )
+    {
+    TInt count = aView.CountL();
+    
+    if ( count >= KDbMaxNumOfItems )
+        {
+        // usually only one item is deleted, no need to use Begin/Commit.
+        DeleteOldestsL( aView, static_cast< TInt >( KDbMaxNumOfItems ) - count + 1 );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMReplayCache::InsertIdL
+//
+// Insert content-ID to the view.
+// -----------------------------------------------------------------------------
+//       
+void RDRMReplayCache::InsertIdL( RDbRowSet& aView, 
+                                 const TDesC8& aId )
+    {
+    
+    RDbColWriteStream stream;
+    stream.OpenLC( aView, KDbViewIDOrdinal );
+    stream << aId;
+    
+    stream.CommitL();
+    CleanupStack::PopAndDestroy(); // stream
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMRightsCleaner.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,293 @@
+/*
+* 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:  Implementation of the DRM Rights Database
+*
+*/
+
+
+
+// INCLUDE FILES
+
+#include <e32std.h>		// RPointerArray
+#include <e32def.h>		// Type definitions
+
+#include <caf/caf.h>
+#include "DRMCommon.h"	// DRM Error messages
+#include "DRMRightsCleaner.h"
+#include "DRMRightsDB.h"
+#include "drmlog.h"
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+const TInt KMaxDirs = 16;
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+// ============================ MEMBER FUNCTIONS ===============================
+
+        
+// -----------------------------------------------------------------------------
+// CDRMRightsCleaner::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMRightsCleaner* CDRMRightsCleaner::NewL( RFs& aFs,
+                                            CDRMRightsDB* aDatabase,
+                                            TRequestStatus& aStatus,
+                                            const TDesC& aDatabasePath,
+                                            const TTime& aTime )
+    {
+    CDRMRightsCleaner* self = new( ELeave ) CDRMRightsCleaner( aFs, 
+                                                        aDatabase, aStatus, 
+                                                        aDatabasePath, aTime );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    
+    return self;
+    }
+  
+        
+// -----------------------------------------------------------------------------
+// Destructor        
+// -----------------------------------------------------------------------------
+//
+CDRMRightsCleaner::~CDRMRightsCleaner()
+    {
+    // just in case
+    Deque();
+    
+    if( iCurrentDirectory )
+        {
+        delete iCurrentDirectory;
+        iCurrentDirectory = NULL;    
+        }
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsCleaner::ExecuteCleanupLD        
+// -----------------------------------------------------------------------------
+//    
+void CDRMRightsCleaner::ExecuteCleanupLD()
+    {
+    TRequestStatus* status = 0;
+    
+    if( !IsAdded() ) 
+        {
+        CActiveScheduler::Add(this);        
+        }
+    if ( !IsActive() ) 
+        {
+        SetActive();        
+        }
+    
+    iOperationStatus = KRequestPending;
+    status = &iStatus;
+    User::RequestComplete(status,KErrNone);        
+    };
+
+// -----------------------------------------------------------------------------                        
+// Default Constructor - First phase.
+// -----------------------------------------------------------------------------
+//
+CDRMRightsCleaner::CDRMRightsCleaner( RFs& aFs,
+                                      CDRMRightsDB* aDatabase,
+                                      TRequestStatus& aStatus,
+                                      const TDesC& aDatabasePath,
+                                      const TTime& aTime ) :
+    CActive( EPriorityLow ),
+    iFileServer( aFs ),
+    iRightsDb( aDatabase ),
+    iOperationStatus( aStatus ),
+    iDatabasePath( aDatabasePath ),
+    iExpirationTime( aTime ),
+    iCurrentDirectory( NULL ),
+    iDirIndex( 0 ),
+    iCurrentFile( 0 )                                  
+    {
+        
+    }; 
+        
+
+// -----------------------------------------------------------------------------                        
+// CDRMRightsCleaner::ConstructL
+// -----------------------------------------------------------------------------
+// 
+void CDRMRightsCleaner::ConstructL()
+    {   
+    };  
+
+// -----------------------------------------------------------------------------                        
+// CDRMRightsCleaner::RunError
+// More or less just ignore all errors and call RunL again
+// -----------------------------------------------------------------------------
+//  
+TInt CDRMRightsCleaner::RunError(TInt aError)
+    {
+    TRequestStatus* status = 0;  
+    
+    if( aError == KErrCancel )
+        {
+        // we are complete:
+        status = &iOperationStatus;
+        User::RequestComplete( status, KErrNone );                
+        delete this;           
+        return KErrNone;
+        }
+      
+    SetActive();
+    status = &iStatus;
+    User::RequestComplete(status,KErrNone);      
+    
+    return KErrNone;
+    };
+
+// -----------------------------------------------------------------------------                        
+// CDRMRightsCleaner::RunL
+// -----------------------------------------------------------------------------
+//      
+void CDRMRightsCleaner::RunL()
+    {
+    TRequestStatus* status = 0;    
+    TInt error = KErrNone;
+    TFileName path;
+    TInt modIndex = 0;
+    TInt removeFile = EFalse;
+
+    // If the status of the cleaning is other than KErrNone
+    User::LeaveIfError( iStatus.Int() );
+    
+    if( !iCurrentDirectory ||
+        iCurrentFile >= iCurrentDirectory->Count() )
+        {
+
+        if( iDirIndex >= KMaxDirs )
+            {
+            // we are complete:
+            status = &iOperationStatus;
+            User::RequestComplete( status, KErrNone );                
+            delete this; 
+            return;    
+            }
+        
+        // if it exists, delete it
+        if( iCurrentDirectory )
+            {
+            delete iCurrentDirectory;
+            iCurrentDirectory = 0;
+            }
+        
+        TFileName path = iDatabasePath;
+    
+    
+        path.Append(iDirIndex < 10 ? iDirIndex + '0' : iDirIndex + 'a' - 10);
+        path.Append('\\');
+
+       
+        error =  iFileServer.GetDir(path, KEntryAttDir, ESortNone, iCurrentDirectory);
+
+        DRMLOG(_L("Entering directory:"));
+        DRMLOG( path );
+
+        // increase the dir counter    
+        iDirIndex++;
+        iCurrentFile = 0;                
+        }
+
+    if( !error && iCurrentDirectory->Count() )
+        {
+        modIndex = iDirIndex-1;
+        
+        path = iDatabasePath;
+        path.Append(modIndex < 10 ? modIndex + '0' : modIndex + 'a' - 10);
+        path.Append('\\');        
+                                
+        path.Append((*iCurrentDirectory)[iCurrentFile].iName);
+    
+        DRMLOG(_L("Checking file:"));
+        DRMLOG( path );
+    
+        // increase the file counter
+        iCurrentFile++;
+                                
+        TRAP( error, removeFile = iRightsDb->DeleteExpiredL( path, iExpirationTime ) );
+        if( error != KErrNone )
+            {
+            DRMLOG2( _L( "CDRMRightsCleaner: error %d cleaning:" ), error );
+            DRMLOG( path );
+            }
+        else 
+            {
+            if ( removeFile )
+                {
+                DRMLOG(_L("Deleting file:"));
+                DRMLOG( path );
+                iFileServer.Delete( path );
+                }
+            }    
+        }
+    
+    SetActive();
+    status = &iStatus;
+    User::RequestComplete(status, KErrNone);                
+    };    
+
+// -----------------------------------------------------------------------------                        
+// CDRMRightsCleaner::DoCancel
+// -----------------------------------------------------------------------------
+//      
+void CDRMRightsCleaner::DoCancel()
+    {     
+    }; 
+
+
+// -----------------------------------------------------------------------------                        
+// CDRMRightsCleaner::DoCleanup
+// -----------------------------------------------------------------------------
+//      
+void CDRMRightsCleaner::DoCleanup()
+    {
+    TRequestStatus* status = 0;      
+    if( iCancel <= 0 )
+        {
+        Cancel();
+        iCancel = 1;
+        SetActive();
+        status = &iStatus;
+        User::RequestComplete(status, KErrCancel);
+        }       
+    }; 
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMRightsClient.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1612 @@
+/*
+* 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:  Client side class implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include <s32file.h>
+#include <etelmm.h>
+#include "DRMRightsClient.h"
+#include "DRMEngineClientServer.h"
+#include "DRMPermission.h"
+#include "DRMAsset.h"
+#include "drmlog.h"
+
+#ifdef __DRM_FULL
+#include "RDRMHelper.h"
+#endif
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+_LIT( KServerFileName, "rightsserver.exe" );
+
+
+_LIT( KRightsServerStarterSemaphore, "RightsServerStarterSemaphore" );
+
+
+// Maximum number of message slots that we use
+LOCAL_C const TInt KMaxMessageSlots = 4;
+
+// Try start the server only once. If it doesn't work, it doesn't work.
+LOCAL_C const TUint8 KStartupCount = 1;
+
+// MODULE DATA STRUCTURES
+struct TDRMFileDeletion
+    {
+    TDRMFileDeletion() : iName( KNullDesC ) {};
+    ~TDRMFileDeletion() 
+        {
+        if ( iName.Length() )
+            {
+            iFs.Delete( iName );
+            }
+        
+        iFs.Close();
+        }
+        
+    RFs iFs;
+    TFileName iName;
+    };
+
+template< class T > struct RDRMArrayReset
+    {
+    RDRMArrayReset( T& aItem ) : iItem( aItem ), 
+                                 iCleanup( ResetAndDestroy, ( TAny* )this ) {};
+    ~RDRMArrayReset() { };
+    void PushL() 
+        {
+        CleanupStack::PushL( iCleanup );
+        };
+    
+    static void ResetAndDestroy( TAny* aSelf ) 
+        {
+        ( ( RDRMArrayReset< T >* )( aSelf ) )->iItem.ResetAndDestroy(); 
+        ( ( RDRMArrayReset< T >* )( aSelf ) )->iItem.Close();
+        };
+    
+    private:        
+        RDRMArrayReset(); // prohibit
+    
+    private:
+        T& iItem;
+        TCleanupItem iCleanup;
+        
+    };
+    
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::RDRMRightsClient
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RDRMRightsClient::RDRMRightsClient() :
+    iPtr( NULL )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::~RDRMRightsClient
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RDRMRightsClient::~RDRMRightsClient()
+    {
+    }    
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::Connect
+// Opens connection to the server.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::Connect()
+    {
+    TInt ret = KErrNone;
+    TUint8 count = 0;    
+    
+    const TVersion requiredVersion( 
+        DRMEngine::KServerMajorVersion,
+        DRMEngine::KServerMinorVersion,
+        DRMEngine::KServerBuildVersion );
+    
+    FOREVER
+        {
+        DRMLOG( _L( "RDRMRightsClient::Connect(): Create a new session" ) );
+        ret = CreateSession( DRMEngine::KServerName,
+                             requiredVersion, 
+                             KMaxMessageSlots );
+                         
+        if ( ret == KErrNotFound && count < KStartupCount )
+            {
+            ret = StartServer();
+            if ( ret )
+                {
+                break;   
+                }
+            
+            ++count;
+            }
+        else
+            {
+            break;   
+            }
+        }
+
+#ifdef __DRM_FULL
+    // startup code, if it starts it starts if not it will be tried again.        
+    RDRMHelper helper;
+    TInt ignore = helper.Connect(); // Start HelperServer
+    helper.Close();  
+#endif        
+
+    DRMLOG2( _L( "RDRMRightsClient::Connect(): Result: %d" ), ret );
+    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::Close
+// Closes the connection to the server.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDRMRightsClient::Close() 
+    {
+    DRMLOG( _L( "RDRMRightsClient::Close()" ) );
+    RHandleBase::Close();
+    }
+
+EXPORT_C TInt RDRMRightsClient::StartServer()
+    {
+    DRMLOG( _L( "RDRMRightsClient::StartServer()" ) );
+    
+    RSemaphore semaphore;
+    RSemaphore semaphore2;
+    TFindServer server( DRMEngine::KServerName );
+    TFullName name;
+    RProcess process;
+    TInt error = KErrNone;
+ 
+    // "local" semaphore
+     error = semaphore2.CreateGlobal( KRightsServerStarterSemaphore,   // name
+                                    1 ,              // count
+                                    EOwnerThread );  // owner
+
+    if ( error == KErrAlreadyExists )
+        {
+        error = semaphore2.OpenGlobal( KRightsServerStarterSemaphore );
+        }  
+
+
+    // Semaphore not created or opened, don't need to close
+    if( error )
+        {
+        return error;
+        }
+          
+    // Server updated semaphore      
+    error = semaphore.CreateGlobal( DRMEngine::KDRMSemaphore,   // name
+                                    0 ,              // count
+                                    EOwnerThread );  // owner
+    
+    if ( error == KErrAlreadyExists )
+        {
+        error = semaphore.OpenGlobal( DRMEngine::KDRMSemaphore );
+        }  
+  
+    // Semaphore not created or opened, don't need to close
+    if( error )
+        {
+        semaphore2.Close();
+        return error;
+        }
+        
+    // Wait until server has done all its things.
+    semaphore2.Wait();
+                
+    // Check if the server is already running.
+    error = server.Next( name );
+    
+    if ( !error )
+        {
+        // Yep, it's already running.
+        error = KErrNone;
+        }
+    else 
+        {
+        error = process.Create( KServerFileName,
+                                KNullDesC );
+        
+        if ( !error )
+            {
+            User::After( 1000 );
+            
+            process.Resume();
+            process.Close();
+            
+            // Wait here for the server process startup to complete
+            // server will signal the global semaphore
+            semaphore.Wait();
+            }
+        }
+        
+    // Close both semaphores and signal the "local" one.    
+    semaphore.Close();         
+    semaphore2.Signal();
+    semaphore2.Close();   
+        
+    DRMLOG2( _L( "RDRMRightsClient::StartServer(): %d" ), error );
+    return error; 
+    
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::AddRecord
+// Add a new entry to the rights database.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::AddRecord( const TDesC8& aCEK, // Content encryption key
+                                  // The rights object which is to be added
+                                  const CDRMPermission& aRightsObject, 
+                                  const TDesC8& aCID, // Content-ID 
+                                  TDRMUniqueID& aID ) // Unique ID, out-parameter
+    {
+    DRMLOG( _L( "RDRMRightsClient::AddRecord" ) );
+    TInt error = KErrArgument;
+    
+    // Check the parameters.
+    if ( aCEK.Length() )
+        {
+        
+        HBufC8* rightsData = NULL;
+        TRAP( error, rightsData = aRightsObject.ExportL() );
+        TInt size = aRightsObject.Size();
+        
+        if ( rightsData && size > 0 )
+            {
+            // For C/S communications.
+            TPtr8 rightsObject( NULL, 0 );
+            TPtr8 uid( reinterpret_cast< TUint8* >( &aID ),
+                       0,
+                       sizeof( TDRMUniqueID ) );
+        
+            rightsObject.Set( const_cast< TUint8* >( rightsData->Ptr() ),
+                              size,
+                              size );
+        
+              
+            // Send the message.
+            error = SendReceive( DRMEngine::EAddRecord, 
+                             TIpcArgs( &aCID, &rightsObject, &aCEK, &uid ) );
+        
+            delete rightsData;
+            rightsData = NULL;
+            }
+        }
+    
+    DRMLOG2( _L( "RDRMRightsClient::AddRecord: %d" ), error );
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::AddProtectedRecord
+// Add a protected entry to the rights database.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::AddProtectedRecord(
+    const TDesC8& aProtectedCek,
+    TBool aDomainRecord,
+    const CDRMPermission& aRightsObject,
+    const TDesC8& aCID,
+    TDRMUniqueID& aID ) // Unique ID, out-parameter
+    {
+    DRMLOG( _L( "RDRMRightsClient::AddProtectedRecord" ) );
+    
+    TInt error = KErrNone;                                                       
+    TInt message = DRMEngine::EAddProtectedRecord;                                                                                    
+    HBufC8* rightsData = NULL;                                                   
+    TInt size = aRightsObject.Size();                                            
+    TPtr8 rightsObject( NULL, 0 );                                               
+    TPtr8 uid( reinterpret_cast< TUint8* >( &aID ), 0,                           
+        sizeof( TDRMUniqueID ) );                                                
+    TPtr8 key( NULL, 0 );                                                        
+                                                                                 
+    TRAP( error, rightsData = aRightsObject.ExportL() );                                        
+    if ( !error ) 
+        {    
+        rightsObject.Set( const_cast< TUint8* >( rightsData->Ptr() ), size,          
+            size );
+                                                                            
+        if ( aDomainRecord )                                                         
+            {
+            message = DRMEngine::EAddDomainRecord;
+            }                                                                        
+        error = SendReceive( message, TIpcArgs( &aCID, &rightsObject, &aProtectedCek, &uid ) );
+
+        delete rightsData;
+        rightsData = NULL;
+        }
+    DRMLOG2( _L( "RDRMRightsClient::AddProtectedRecord: %d" ), error );          
+    return error; 
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetDBEntriesL
+// Get a file name from the server. The file contains the rights objects,
+// which are then converted to RPointerArray.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDRMRightsClient::GetDBEntriesL( const TDesC8& aId,
+                                      RPointerArray< CDRMPermission >& aRightsList )
+    {
+    DRMLOG( _L( "RDRMRightsClient::GetDBEntries" ) );
+    if( aId.Length() )
+        {   
+        // Temporary file name from the server.
+        TDRMFileDeletion item;
+        
+        // Make sure that the array is empty.
+        aRightsList.ResetAndDestroy();
+        
+        // For file operations. Destructor of TDRMFileDeletion
+        // deletes the file & closes the session.
+        User::LeaveIfError( item.iFs.Connect() );  
+                
+        User::LeaveIfError( SendReceive( DRMEngine::EGetEntryList, 
+                                         TIpcArgs( &item.iName, &aId ) ) );
+        
+        // Convert the file to a list.
+        FileToListL( item.iFs, item.iName, aRightsList );
+        
+        DRMLOG( _L( "RDRMRightsClient::GetDBEntries ok" ) );    
+    
+        return;
+        }
+    
+    // Invalid parameter.
+    User::Leave( KErrArgument );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetDbEntryL
+// Get a single RO from the server.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMPermission* RDRMRightsClient::GetDbEntryL( const TDesC8& aContentID,
+                                                 const TDRMUniqueID& aUniqueID )
+    {
+    DRMLOG( _L( "RDRMRightsClient::GetDbEntryL" ) );
+    
+    CDRMPermission* permission = NULL;
+    TInt size = 0;
+    TPckg<TInt> package( size );
+    TPtrC8 uid( reinterpret_cast< TUint8* >( const_cast< TDRMUniqueID* >(
+        &aUniqueID ) ), sizeof( TDRMUniqueID ) );
+
+    User::LeaveIfError( SendReceive( DRMEngine::EGetDbEntry,
+        TIpcArgs( &package, NULL, &uid, &aContentID ) ) );
+    HBufC8* rightsData = HBufC8::NewMaxLC( size );
+    TPtr8 objectPkg( const_cast< TUint8* >( rightsData->Ptr() ), size,
+        size );
+    User::LeaveIfError( SendReceive( DRMEngine::EGetPreparedData,
+        TIpcArgs( &objectPkg) ) );
+    
+    permission = CDRMPermission::NewLC();
+    permission->ImportL( rightsData->Des() );
+    CleanupStack::Pop(); // permission
+    CleanupStack::PopAndDestroy(); // Rights data
+    
+    DRMLOG( _L( "RDRMRightsClient::GetDbEntryL ok" ) );
+    return permission;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::DeleteDbEntry
+// Deletes all rights objects associated with the given UID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::DeleteDbEntry( const TDesC8& aContentID )
+    {
+    DRMLOG( _L( "RDRMRightsClient::DeleteDbEntry with CID" ) );
+    
+    TInt error = KErrArgument;
+    
+    // Check the parameter.
+    if ( aContentID.Length() )
+        {
+        return SendReceive( DRMEngine::EDeleteWithCID, 
+                            TIpcArgs( NULL, NULL, &aContentID ) );
+        }
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::DeleteDbEntry
+// Delete a single rights object identified by given parameters.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::DeleteDbEntry( const TDesC8& aContentID,
+                                               const TDRMUniqueID& aUniqueID )
+    {
+    DRMLOG( _L( "RDRMRightsClient::DeleteDbEntry with CID & UID" ) );
+    
+    if ( aContentID.Length() )
+        {
+        // Something to do.
+        // Put aUniqueID inside a descriptor.
+        // Works even if its typedef is changed.
+        TPtrC8 uid( reinterpret_cast< TUint8* >( 
+                        const_cast< TDRMUniqueID* >( &aUniqueID ) ),
+                    sizeof( TDRMUniqueID ) );
+        
+        return SendReceive( DRMEngine::EDeleteRO, 
+                            TIpcArgs( &uid, NULL, NULL, &aContentID ) );
+        }
+    
+    return KErrArgument;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::ExportContentIDList
+// Overloaded method: requests all content IDs to be put to a file. 
+// Assumes that the given descriptor represents a buffer large enough to
+// contain the file name.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::ExportContentIDList( TDes& aFileName )
+    {
+    DRMLOG( _L( "RDRMRightsClient::ExportContentIDLis" ) );
+    
+    return SendReceive( DRMEngine::EExportCIDs, 
+                        TIpcArgs( &aFileName ) );
+    
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::ExportContentIDList
+// Overloaded method: requests all content IDs to be put to a file, 
+// and then converts the file into RPointerArray.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::ExportContentIDList( RPointerArray< HBufC8 >& aCIDList )
+    {
+    DRMLOG( _L( "RDRMRightsClient::ExportContentIDList to array" ) );
+    TFileName name;
+    aCIDList.ResetAndDestroy();
+    
+    TInt error = ExportContentIDList( name );
+    if ( !error )
+        {
+        RFs fs;
+        error = fs.Connect();
+        if ( !error )
+            {
+            TRAP( error, URIFileToArrayL( fs, name, aCIDList ) );
+            if ( error )
+                {
+                aCIDList.ResetAndDestroy();
+                }
+            
+            fs.Delete( name );
+            fs.Close();
+            }
+        }
+    
+    DRMLOG2( _L( "RDRMRightsClient::ExportContentIDList: %d" ), error );
+            
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetDecryptionKey
+// Fetches the decryption key from the server.
+// Uses TR mechanisms. Uses asynchronous C/S call.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::GetDecryptionKey( const TInt aIntent,
+                                                  const TDesC8& aContentID,
+                                                  TDes8& aKey )
+    {
+    DRMLOG( _L( "RDRMRightsClient::GetDecryptionKey" ) );
+    // Make this internally asynchronous.
+    TRequestStatus status;
+
+    SendReceive( DRMEngine::EGetKey,
+        TIpcArgs( aIntent, const_cast<TDesC8*>(&aContentID), &aKey ),
+        status );
+        
+    User::WaitForRequest( status );
+
+    DRMLOG2( _L( "RDRMRightsClient::GetDecryptionKey: %d" ), status.Int() );
+    
+    return status.Int();
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::CheckRights
+// Checks if appropriate rights exist for a certain content ID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::CheckRights(
+    const TInt aIntent,
+    const TDesC8& aContentID,
+    TUint32& aRejection )
+    {
+    TInt error = KErrNone;
+    TInt size = 0;
+    
+    TPckg<TInt> package( size );
+    TPckg<TUint32> package2( aRejection );
+        
+    DRMLOG( _L( "RDRMRightsClient::CheckRights" ) );
+    error = SendReceive( DRMEngine::ECheckRights, TIpcArgs( aIntent,
+        &aContentID, &package, &package2 ) );
+        
+    DRMLOG2( _L( "RDRMRightsClient::CheckRights: %d" ), error );
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetActiveRightsL
+// Checks if appropriate rights exist for a certain content ID and returns them.
+// Returns NULL if no rights are available
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMPermission* RDRMRightsClient::GetActiveRightsL(
+    const TInt aIntent,
+    const TDesC8& aContentID,
+    TUint32& aRejection )
+    {
+    TInt r;
+    TInt size = 0;
+    TPckg<TInt> package( size );
+    TPckg<TUint32> package2( aRejection );    
+    CDRMPermission* permission = NULL;
+    HBufC8* buffer = NULL;
+    
+    DRMLOG( _L( "RDRMRightsClient::GetActiveRightsL" ) );
+    r = SendReceive( DRMEngine::ECheckRights, TIpcArgs( aIntent, &aContentID,
+        &package, &package2 ) );
+
+    // Get rights. Return NULL if no rights are available, otherwise leave
+    // for all other errors.
+    if ( r == KErrNone )
+        {
+        buffer = HBufC8::NewMaxLC( size );
+        TPtr8 objectPkg( const_cast< TUint8* >( buffer->Ptr() ), size, size );
+        User::LeaveIfError( SendReceive( DRMEngine::EGetPreparedData,
+            TIpcArgs( &objectPkg) ) );
+        permission = CDRMPermission::NewLC();
+        permission->ImportL( buffer->Des() );
+        CleanupStack::Pop(); // permission
+        CleanupStack::PopAndDestroy(); // buffer
+        }
+    else if ( r != KErrCANoRights && r != KErrCANoPermission &&
+        r != KErrCAPendingRights )
+        {
+        User::Leave( r );
+        }
+    
+    DRMLOG( _L( "RDRMRightsClient::GetActiveRightsL: done" ) );
+    return permission;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::Count
+// Returns the amount of unique content IDs in the database.
+// If an error occurs, a negative value is returned (Symbian OS / DRM 3 specific
+// error code).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::Count()
+    {
+    DRMLOG( _L( "RDRMRightsClient::Count" ) );
+
+    TInt count = 0;
+    TInt error = KErrNone;
+    
+    TPtr8 ptr( reinterpret_cast< TUint8* >( &count ),
+               0, 
+               sizeof( TInt ) );
+    
+    error = SendReceive( DRMEngine::ECount, 
+                         TIpcArgs( &ptr ) );
+    
+    if ( !error )
+        {
+        error = count;
+        }
+    
+    DRMLOG2( _L( "RDRMRightsClient::Count: %d" ), error );
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::DeleteAll
+// Empties the database.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::DeleteAll()
+    {
+    DRMLOG( _L( "RDRMRightsClient::DeleteAll" ) );
+   
+    TInt error = SendReceive( DRMEngine::EDeleteAll, TIpcArgs( NULL ) ); 
+
+    DRMLOG2( _L( "RDRMRightsClient::DeleteAll: %d" ), error  );
+    
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::Consume()
+// Consume the right with specific intent and contentID
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::Consume( const TInt aIntent, 
+                                         const TDesC8& aContentID )
+    {
+    TInt error = KErrNone;
+    DRMLOG( _L( "RDRMRightsClient::Consume" ) );
+   
+    error = SendReceive( DRMEngine::EConsume, 
+                         TIpcArgs( aIntent, &aContentID ) );
+
+    DRMLOG2( _L( "RDRMRightsClient::Consume: %d" ), error  );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::CheckConsume()
+// Check if Consume is possibke
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::CheckConsume( const TInt aIntent, 
+                                              const TDesC8& aContentID )
+    {
+    TInt error = KErrNone;
+    DRMLOG( _L( "RDRMRightsClient::CheckConsume" ) );
+   
+    error = SendReceive( DRMEngine::ECheckConsume, 
+                         TIpcArgs( aIntent, &aContentID ) );
+
+    DRMLOG2( _L( "RDRMRightsClient::CheckConsume: %d" ), error  );
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::CalculatePadding
+// Calculate the padding from a data block and a certain content ID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::CalculatePadding(
+    const TDesC8& aLastTwoDataBlocks)
+    {
+    DRMLOG( _L( "RDRMRightsClient::CalculatePadding" ) );
+
+    return SendReceive( DRMEngine::ECalculatePadding,
+                        TIpcArgs ( &aLastTwoDataBlocks) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::ForwardLockURI( HBufC8*& aURI )
+    {
+    DRMLOG( _L( "RDRMRightsClient::ForwardLockURI" ) );
+    TBuf8< DRMEngine::KMaxOmaV1CIDLength > buf;
+    TInt error = SendReceive( DRMEngine::EGetFLUri,
+                              TIpcArgs( &buf ) );
+                              
+    if ( error )
+        {
+        aURI = NULL;
+        return error;
+        }
+        
+    aURI = buf.Alloc();
+
+    if ( aURI )
+        {
+        return KErrNone;
+        }
+        
+    return KErrNoMemory;
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::AddDomainRO
+// Add domain rights object xml representation to the rdb
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::AddDomainRO( const TDesC8& aRoId, 
+                                             const TDesC8& aXmlData )
+    {
+    DRMLOG( _L( "RDRMRightsClient::AddDomainRO" ) );
+    TInt error = KErrArgument;
+    
+    // Check the parameters.
+    if ( aRoId.Length() && aXmlData.Length() )
+        {     
+        // Send the message.
+        error = SendReceive( DRMEngine::EAddDomainRO, 
+                             TIpcArgs( &aRoId, &aXmlData) );
+        }
+        
+    DRMLOG2( _L( "RDRMRightsClient::AddDomainRO: %d" ), error );
+    return error;    
+    };        
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetDomainROL
+// Get domain rights object xml representation from the rdb
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* RDRMRightsClient::GetDomainROL( const TDesC8& aRoId )
+    {
+    DRMLOG( _L( "RDRMRightsClient::GetDomainROL" ) );
+    
+    // Check the parameter.
+    if ( aRoId.Length() )
+        {
+        TInt size = 0;
+        TPckg<TInt> package( size );
+        
+        // Call the server. Throw an exception in case of an error.
+        User::LeaveIfError( 
+            SendReceive( DRMEngine::EGetDomainRO, 
+                         TIpcArgs( &package, &aRoId ) ) );
+
+        HBufC8* roData = HBufC8::NewMaxLC( size );
+        
+        // Package 'object' into TPtr8.
+        TPtr8 objectPkg( const_cast< TUint8* >( roData->Ptr() ),
+                         size,
+                         size );
+
+        User::LeaveIfError( 
+            SendReceive( DRMEngine::EGetPreparedData, 
+                         TIpcArgs( &objectPkg) ) );
+        CleanupStack::Pop( roData ); // roData                 
+        return roData;
+        }
+    
+    User::Leave( KErrArgument );
+    
+    // Never reached.
+    return NULL;    
+    }; 
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetDomainROL
+// Get domain rights object xml representation from the rdb
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDRMRightsClient::GetDomainRosForCidL(
+    const TDesC8& aContentId,
+    RPointerArray<HBufC8>& aRoList)
+    {
+    TInt size = 0;
+    TPckg<TInt> pkg(size);
+    HBufC8* buffer = NULL;
+    HBufC8* ro = NULL;
+    TInt roSize;
+    TInt offset;
+
+        
+    DRMLOG(_L("RDRMRightsClient::GetDomainRoForCidL"));
+    User::LeaveIfError(SendReceive(DRMEngine::EGetDomainRoForCid,
+        TIpcArgs(&aContentId, &pkg)));
+    if (size > 0)
+        {
+        buffer = HBufC8::NewMaxLC(size);
+        TPtr8 ptr( const_cast< TUint8* >( buffer->Ptr() ),
+                         size,
+                         size );
+        User::LeaveIfError(SendReceive(DRMEngine::EGetPreparedData,
+            TIpcArgs(&ptr)));
+        offset = 0;
+        while (offset < size)
+            {
+            Mem::Copy( &roSize, ptr.Ptr()+offset, sizeof(TInt) );
+            offset += sizeof (TInt); 
+            ro = ptr.Mid(offset, roSize).AllocL();
+            aRoList.Append(ro);
+            offset += roSize;
+            }
+        CleanupStack::PopAndDestroy();
+        }
+    }; 
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::Encrypt( const TDesC8& aIv,
+                       TPtr8& aData,
+                       TBool aAddPadding )
+    {
+    return SendReceive( DRMEngine::EEncrypt, 
+                        TIpcArgs( &aIv, &aData, aAddPadding ) );
+    }                       
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::Decrypt( const TDesC8& aIv,
+                       TPtr8& aData,
+                       TBool aRemovePadding )
+    {
+    return SendReceive( DRMEngine::EDecrypt, 
+                        TIpcArgs( &aIv, &aData, aRemovePadding ) );
+    }                         
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::InitializeKey( const TDesC8& aContentId )
+    {
+    return SendReceive( DRMEngine::EInitializeKey, 
+                        TIpcArgs( &aContentId ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::InitializeGroupKey( const TDesC8& aGroupId,
+                                                    const TDesC8& aGroupKey,
+                                                    TEncryptionMethod aMethod )
+    {
+    return SendReceive( DRMEngine::EInitializeGroupKey, 
+                        TIpcArgs( &aGroupId, &aGroupKey, aMethod ) );
+    }                                            
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::DeleteDomainRO
+// Delete domain rights object xml representation from the rdb
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::DeleteDomainRO( const TDesC8& aRoId )
+    {
+    DRMLOG( _L( "RDRMRightsClient::DeleteDomainRO" ) );
+    
+    // Check the parameter.
+    if ( aRoId.Length() )
+        {
+        return SendReceive( DRMEngine::EDeleteDomainRO, 
+                            TIpcArgs( &aRoId ) );
+        }
+    
+    return KErrArgument;    
+    }; 
+
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::IsInCache( const TDesC8& aID,
+                                           const TTime& aTime,
+                                           TBool& aInCache )
+    {
+    DRMLOG( _L( "RDRMRightsClient::IsInCache" ) );
+    TPckgC< TTime > timePckg( aTime );
+    TPckg< TBool > inCache( aInCache );
+        
+    return SendReceive( DRMEngine::EIsInCache,
+                        TIpcArgs( &aID, &timePckg, &inCache ) );
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::IsInCache( const TDesC8& aID,
+                                           TBool& aInCache )
+    {
+    DRMLOG( _L( "RDRMRightsClient::IsInCache" ) );
+    
+    TPckg< TBool > inCache( aInCache );
+        
+    return SendReceive( DRMEngine::EIsInCache,
+                        TIpcArgs( &aID, NULL, &inCache ) );
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::AddToCache( const TDesC8& aID,
+                                            const TTime& aTime )
+    {
+    DRMLOG( _L( "RDRMRightsClient::AddToCache" ) );
+    
+    TPckgC< TTime > timePckg( aTime );
+    
+    return SendReceive( DRMEngine::EAddToCache,
+                        TIpcArgs( &aID, &timePckg ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::AddToCache( const TDesC8& aID )
+    {
+    DRMLOG( _L( "RDRMRightsClient::AddToCache" ) );
+    
+    return SendReceive( DRMEngine::EAddToCache,
+                        TIpcArgs( &aID, NULL ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::DeleteExpiredPermissions
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDRMRightsClient::DeleteExpiredPermissions( TRequestStatus& aStatus )
+    {
+    DRMLOG( _L( "RDRMRightsClient::DeleteExpiredPermissions" ) );
+    
+    SendReceive( DRMEngine::EDeleteExpired, aStatus );
+    }
+ 
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::SetEstimatedArrival
+// sets the estimated RO arrival time to the given delta
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::SetEstimatedArrival( const TDesC8& aContentID,
+                                            TTimeIntervalSeconds aDeltaSeconds )
+    {
+    DRMLOG( _L( "RDRMRightsClient::SetEstimatedArrival" ) );
+    TInt error = KErrNone;
+
+    TPckg< TTimeIntervalSeconds > delta( aDeltaSeconds );
+    
+    error = SendReceive( DRMEngine::ESetEstimatedArrival, 
+                         TIpcArgs( &aContentID, &delta ) );
+    
+    return error;    
+    };
+                                  
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetEstimatedArrival
+// sets the amount of time in which the RO should arrive in
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::GetEstimatedArrival( const TDesC8& aContentID,
+                                            TTimeIntervalSeconds& aDeltaSeconds )
+    {
+    DRMLOG( _L( "RDRMRightsClient::SetEstimatedArrival" ) );
+    TInt error = KErrNone;
+
+    TPckg< TTimeIntervalSeconds > delta( aDeltaSeconds );
+    
+    error = SendReceive( DRMEngine::EGetEstimatedArrival, 
+                         TIpcArgs( &aContentID, &delta ) );
+    
+    return error;     
+    }; 
+ 
+ 
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::SetName
+// sets the name.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C  TInt RDRMRightsClient::SetName( const TDesC8& aContentID,
+                                          const TDesC& aName )
+    {
+    DRMLOG( _L( "RDRMRightsClient::SetName" ) );
+    return SendReceive( DRMEngine::ESetName,
+                        TIpcArgs( &aContentID, &aName ) );
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetName
+// Gets the name. Two-phase operation.
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C TInt RDRMRightsClient::GetName( const TDesC8& aContentID,
+                                         HBufC*& aName )
+    {
+    DRMLOG( _L( "RDRMRightsClient::GetName" ) );
+    TPckgBuf< TInt > size( 0 );
+    
+    TInt error = SendReceive( DRMEngine::EGetName,
+                              TIpcArgs( &aContentID, &size ) );
+    if ( !error )
+        {
+        if ( !size() )
+            {
+            aName = HBufC::New( 1 );
+            if ( !aName )
+                {
+                error = KErrNoMemory;
+                }
+            }
+        else
+            {
+            aName = HBufC::New( size() );
+            if ( aName )
+                {
+                TPtr data( aName->Des() );
+                            
+                error = SendReceive( DRMEngine::EGetWideData,
+                                     TIpcArgs( &data ) );
+                
+                if ( error )
+                    {
+                    delete aName; aName = NULL;
+                    }
+                }
+            else
+                {
+                error = KErrNoMemory;
+                }
+            }
+        }
+        
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::Cancel
+// -----------------------------------------------------------------------------
+//      
+EXPORT_C void RDRMRightsClient::Cancel()
+    {
+    DRMLOG( _L(" RDRMRightsClient::Cancel" ) );
+    SendReceive( DRMEngine::ECancel );
+    }
+    
+    
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetUdtData
+// -----------------------------------------------------------------------------
+//   
+EXPORT_C TInt RDRMRightsClient::GetUdtData( TDes8& aUdtData )
+    {
+    DRMLOG( _L( "RDRMRightsClient::GetUdtData" ) );
+    
+    TInt error = SendReceive( DRMEngine::EGetUdtData,
+                              TIpcArgs( &aUdtData ) );
+        
+    return error;        
+    };        
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::InitializeUdt
+// -----------------------------------------------------------------------------
+//   
+EXPORT_C TInt RDRMRightsClient::InitiateUdt( const TDesC8& aKey )
+    {
+    DRMLOG( _L( "RDRMRightsClient::InitiateUdt" ) );
+    
+    TInt error = SendReceive( DRMEngine::EInitiateUdt,
+                              TIpcArgs( &aKey ) );     
+    return error;        
+    };         
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::InitOrphanedContentIdList
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDRMRightsClient::InitOrphanedContentIdList( TBool aPerformScan,
+                                                      TRequestStatus& aStatus )
+    {
+    DRMLOG( _L( "RDRMRightsClient::ExportOrphanedContentIdList" ) );
+        
+    SendReceive( DRMEngine::EInitOrphanedList, 
+                 TIpcArgs( aPerformScan ), aStatus );
+                 
+    DRMLOG( _L( "RDRMRightsClient::ExportOrphanedContentIdList done" ) );                        
+    };
+
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::ExportOrphanedContentIdList
+// -----------------------------------------------------------------------------
+//   
+EXPORT_C TInt RDRMRightsClient::ExportOrphanedContentIdList( TDes& aFileName )
+    {
+    DRMLOG( _L( "RDRMRightsClient::ExportOrphanedContentIdList" ) );
+    
+    return SendReceive( DRMEngine::EGetOrphanedList, 
+                        TIpcArgs( &aFileName ) );
+            
+    };        
+                 
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::ExportOrphanedContentIdList
+// -----------------------------------------------------------------------------
+//   
+EXPORT_C TInt RDRMRightsClient::ExportOrphanedContentIdList( 
+                        RPointerArray<HBufC8>& aContentIdList )
+    {
+    DRMLOG( _L( "RDRMRightsClient::ExportOrphanedContentIdList to array" ) );
+    TFileName name;
+    aContentIdList.ResetAndDestroy();
+    
+    TInt error = ExportOrphanedContentIdList( name );
+    if ( !error )
+        {
+        RFs fs;
+        error = fs.Connect();
+        if ( !error )
+            {
+            TRAP( error, URIFileToArrayL( fs, name, aContentIdList ) );
+            if ( error )
+                {
+                aContentIdList.ResetAndDestroy();
+                }
+            
+            fs.Delete( name );
+            fs.Close();
+            }
+        }
+    
+    DRMLOG2( _L( "RDRMRightsClient::ExportOrphanedContentIdList to array: %d" ), error );
+            
+    return error;        
+    }; 
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::EncodeRightsIssuerField
+// The encoded field is consturcted from
+// - F/L prefix
+// - phone serial number
+// - base64encode(AES IV + AES encoded original field incl. padding)
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::EncodeRightsIssuerField( 
+                                    const TDesC8& aOldValue,
+                                    HBufC8*& aNewValue )
+    {
+    DRMLOG( _L( "RDRMRightsClient::EncodeRightsIssuerField" ) );
+
+    TInt error( KErrNone );
+    
+    TInt size( aOldValue.Length() ); // original length
+    size += KDCFKeySize - ( size % KDCFKeySize ); // padding
+    size += KDCFKeySize; // IV
+    size += ( size + 2 ) / 3 * 4; // base64
+    size += RMobilePhone::KPhoneSerialNumberSize;
+    size += 3; // "flk"
+    
+    aNewValue = HBufC8::New( size );
+    if ( aNewValue )
+        {
+        TPtr8 des( aNewValue->Des() );
+        
+        des = aOldValue;
+        
+        error = SendReceive( DRMEngine::EEncodeRightsIssuerField,
+                             TIpcArgs( &des ) );
+        if ( error )
+            {
+            delete aNewValue;
+            aNewValue = NULL;
+            }
+        }
+    else
+        {
+        error = KErrNoMemory;
+        }
+    
+    DRMLOG2( _L( "RDRMRightsClient::EncodeRightsIssuerField> %d" ), error );
+    
+    return error;
+    }
+    
+EXPORT_C TInt RDRMRightsClient::DecodeRightsIssuerField( 
+                                    const TDesC8& aEncoded,
+                                    HBufC8*& aDecoded )
+    {
+    DRMLOG( _L( "DRMRightsClient::DecodeRightsIssuerField" ) );
+    
+    TInt error( KErrNone );
+    
+    aDecoded = HBufC8::New( aEncoded.Length() );
+    if ( aDecoded )
+        {
+        TPtr8 des( aDecoded->Des() );
+        
+        error = SendReceive( DRMEngine::EDecodeRightsIssuerField,
+                             TIpcArgs( &aEncoded,
+                                      &des ) );
+        if ( error )
+            {
+            delete aDecoded;
+            aDecoded = NULL;
+            }
+        else if ( !( aDecoded->Length() ) )
+            {
+            // The decoding process didn't change it.
+            *aDecoded = aEncoded;
+            }
+        }
+    else
+        {
+        error = KErrNoMemory;
+        }
+    
+    DRMLOG2( _L( "DRMRightsClient::DecodeRightsIssuerField: error %d" ), error );
+    
+    return error;
+    }
+  
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::SetAuthenticationSeed
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::SetAuthenticationSeed( const TDesC8& aContentID,
+                                                       const TDesC8& aSeed )
+    {
+    DRMLOG( _L( "RDRMRightsClient::SetAuthenticationSeed" ) );
+    return SendReceive( DRMEngine::ESetAuthenticationSeed,
+                        TIpcArgs( &aContentID, &aSeed ) );
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetAuthenticationSeed
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::GetAuthenticationSeed( const TDesC8& aContentID,
+                                                       TDes8& aSeed )
+    {
+    DRMLOG( _L( "RDRMRightsClient::GetAuthenticationSeed" ) );
+    return SendReceive( DRMEngine::EGetAuthenticationSeed,
+                        TIpcArgs( &aContentID, &aSeed ) );
+    }                                                       
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::FileToListL
+// Converts the given file into an array.
+// -----------------------------------------------------------------------------
+//
+void RDRMRightsClient::FileToListL( RFs& aFs,
+                                   const TDesC& aFileName,
+                                   RPointerArray< CDRMPermission >& aList )
+    {
+    DRMLOG( _L( "RDRMRightsClient::FileToListL" ) );
+    TInt error = KErrNone;
+    
+    // Temporary storage.
+    CDRMPermission* tmpObject;
+    
+    // To access the file data.
+    RFileReadStream fileStream;
+    
+    // How many objects there is in the file.
+    TInt size = 0;
+    
+    // Temporary counter.
+    TInt count = 0;
+    
+    
+    // Open the file.
+    User::LeaveIfError( fileStream.Open( aFs, aFileName, EFileRead | EFileStream ) );
+    CleanupClosePushL( fileStream );
+    
+    size = fileStream.ReadInt32L();
+    
+    while( count < size )
+        {
+        // Allocate a new RO.
+        tmpObject = CDRMPermission::NewL();
+        
+        // Read the object.
+        TRAP( error, tmpObject->InternalizeL( fileStream ) );
+        
+        if ( !error )
+            {
+            // Add the object into the list.
+            error = aList.Append( tmpObject );
+            }
+        
+        if ( error )
+            {
+            delete tmpObject;
+            User::Leave( error );
+            }
+        
+        // Now tmpObject is under responsibility of aList. 
+        ++count;
+        }
+    
+    // All done.
+    CleanupStack::PopAndDestroy(); // fileStream 
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::URIFileToArrayL
+// Converts the given file into an array.
+// -----------------------------------------------------------------------------
+//
+void RDRMRightsClient::URIFileToArrayL( RFs& aFs,
+                                       const TDesC& aFile,
+                                       RPointerArray< HBufC8 >& aList )
+    {
+    DRMLOG( _L( "RDRMRightsClient::URIFileToArrayL" ) );
+    RFileReadStream stream;
+    TUint16 size = 0;
+    TPtr8 data( NULL, 0, 0 );
+    
+    User::LeaveIfError( stream.Open( aFs, aFile, EFileRead | EFileStream ) );
+    CleanupClosePushL( stream );
+    
+    size = stream.ReadUint16L();
+    while( size > 0 )
+        {
+        HBufC8* tmp = HBufC8::NewLC( size );
+        data.Set( tmp->Des() );
+        stream.ReadL( data, size );
+        User::LeaveIfError( aList.Append( tmp ) );
+        CleanupStack::Pop(); // tmp
+        size = stream.ReadUint16L();
+        }
+    
+    // All read, return.
+    
+    CleanupStack::PopAndDestroy(); // stream
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::VerifyMacL
+// Verifies the MAC. 
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C TInt RDRMRightsClient::VerifyMacL(const TDesC8& aSignedInfoElement,
+                                  const TDesC8& aMacValue ) const
+    {
+    DRMLOG( _L( "RDRMRightsClient::VerifyMacL" ) );
+    
+    TInt error = SendReceive( DRMEngine::EVerifyMac,
+                              TIpcArgs( &aSignedInfoElement, &aMacValue) );
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetSupportedIndividualsL
+// retrieves the supported individuals list
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C TInt RDRMRightsClient::GetSupportedIndividualsL(
+                                    RPointerArray<HBufC8>& aIndividuals) const
+    {
+    DRMLOG( _L( "RDRMRightsClient::GetSupportedIndividualsL" ) );
+    TPckgBuf< TInt > size( 0 );    
+    TInt error = SendReceive( DRMEngine::EGetSupportedIndividuals,
+                              TIpcArgs( &size) );
+    HBufC8* dataBuf = NULL;
+    HBufC8* individual = NULL;
+    TInt indivSize;
+    TInt offset;
+                                  
+    if ( !error )
+        {
+        if ( !size() )
+            {
+            return KErrNone;
+            }
+        else
+            {
+            dataBuf = HBufC8::NewLC( size() );
+            if ( dataBuf )
+                {
+                TPtr8 data( dataBuf->Des() );
+                            
+                error = SendReceive( DRMEngine::EGetPreparedData,
+                                     TIpcArgs( &data ) );
+                
+                if ( !error )
+                    { 
+                    offset = 0;
+                    while (offset < size())
+                        {
+                        Mem::Copy( &indivSize, data.Ptr()+offset, sizeof(TInt) );
+                        offset += sizeof (TInt); 
+                        individual = data.Mid(offset, indivSize).AllocLC();
+                        aIndividuals.AppendL(individual);
+                        CleanupStack::Pop(); // individual
+                        offset += indivSize;
+                        }
+                    }
+                }
+            CleanupStack::PopAndDestroy();   
+            }
+        }                                             
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::StopWatching
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C void RDRMRightsClient::StopWatching() const
+    {
+    SendReceive( DRMEngine::EStopWatching );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::UnwrapMacAndRek
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C TInt RDRMRightsClient::UnwrapMacAndRek( const TDesC8& aMacAndRek,
+                                                 TKeyTransportScheme aTransportScheme,
+                                                 const TDesC8& aRightsIssuerId,
+                                                 const TDesC8& aDomainId ) const
+    {
+    HBufC8* data = NULL;
+    TPtr8 dataPtr( NULL, 0 );
+    TInt err = KErrNone;
+    
+    data = HBufC8::New( 1 + aMacAndRek.Size() );
+    
+    if ( data )
+        {
+        dataPtr.Set( data->Des() );
+        dataPtr.SetLength( 1 ); 
+        dataPtr[0] = aTransportScheme;
+        dataPtr.Append( aMacAndRek );
+    
+        if( aDomainId.Length() )
+            {
+            err = SendReceive( DRMEngine::EUnwrapDomainMacAndRek, TIpcArgs( &dataPtr,
+                                                                  &aRightsIssuerId,
+                                                                  &aDomainId ) );
+            }
+        else
+            {
+            err = SendReceive( DRMEngine::EUnwrapDeviceMacAndRek, TIpcArgs( &dataPtr,
+                                                                  &aRightsIssuerId,
+                                                                  NULL ) );
+            }
+        delete data;
+        data = NULL;
+        }
+    else 
+        {
+        err = KErrNoMemory;
+        }
+    
+    return err;
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetRandomDataL
+// -----------------------------------------------------------------------------
+//    
+EXPORT_C void RDRMRightsClient::GetRandomDataL( TDes8& aRandomData ) const
+    {
+    if( !aRandomData.Length() )
+        {
+        User::Leave(KErrArgument);
+        }
+    User::LeaveIfError( SendReceive( DRMEngine::EGetRandomData, TIpcArgs( &aRandomData ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetMeteringData()
+// -----------------------------------------------------------------------------
+//    
+#ifndef RD_DRM_METERING
+EXPORT_C HBufC8* RDRMRightsClient::GetMeteringDataL( const TDesC8& /*aRiId*/ )
+    {
+    return NULL;
+    }
+#else
+EXPORT_C HBufC8* RDRMRightsClient::GetMeteringDataL( const TDesC8& aRiId )
+    {
+    TInt error = KErrNone;
+    HBufC8* meteringData = NULL;
+       
+    if ( aRiId.Length() )
+        {
+        TInt size = 0;
+        TPckg<TInt> package( size );
+        
+        error = SendReceive( DRMEngine::EGetMeteringData, 
+                           TIpcArgs( &package, &aRiId ) );
+                           
+        if ( error == KErrNotFound )
+            {
+            return NULL;
+            }
+            
+        User::LeaveIfError( error );
+
+        meteringData = HBufC8::NewMaxLC( size );
+        
+        // Package 'object' into TPtr8.
+        TPtr8 objectPkg( const_cast< TUint8* >( meteringData->Ptr() ),
+                         size,
+                         size );
+
+        User::LeaveIfError( SendReceive( DRMEngine::EGetPreparedData,
+                                         TIpcArgs( &objectPkg) ) );
+        
+        CleanupStack::Pop(); // meteringData
+        return meteringData;
+        }
+    
+    User::Leave( KErrArgument );
+    return NULL;
+    }
+#endif //RD_DRM_METERING
+ 
+ // -----------------------------------------------------------------------------
+// RDRMRightsClient::DeleteMeteringDataL
+// -----------------------------------------------------------------------------
+//    
+#ifndef RD_DRM_METERING
+EXPORT_C TInt RDRMRightsClient::DeleteMeteringDataL( const TDesC8& /*aRiId*/ )
+    {
+    return KErrNotSupported;
+    }
+#else    	
+EXPORT_C TInt RDRMRightsClient::DeleteMeteringDataL( const TDesC8& aRiId )
+    {
+    if ( aRiId.Length() )
+        {
+        User::LeaveIfError( SendReceive( DRMEngine::EDeleteMeteringData,
+                            TIpcArgs( &aRiId ) ) );
+        return KErrNone;
+        }
+    else
+        {
+        return KErrArgument;
+        }
+    }
+#endif 
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+              
+    
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMRightsClientStub.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,253 @@
+/*
+* 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:  Client side class implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include <s32file.h>
+#include "DRMRightsClient.h"
+#include "DRMClientServer.h"
+#ifdef _DRM_TESTING
+#include "logfile.h"
+#endif
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+#ifdef CLIENT_STARTS_SERVER
+extern TInt DRMServerStarter();
+#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::RDRMRightsClient
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RDRMRightsClient::RDRMRightsClient() :
+    iPtr( NULL )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::~RDRMRightsClient
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RDRMRightsClient::~RDRMRightsClient()
+    {
+    }    
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::Connect
+// Opens connection to the server.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::Connect()
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::Close
+// Closes the connection to the server.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDRMRightsClient::Close() 
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::AddRecord
+// Add a new entry to the rights database.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::AddRecord( const TDesC8& aCEK, // Content encryption key
+                                  // The rights object which is to be added
+                                  const CDRMPermission& aRightsObject, 
+                                  const TDesC8& aCID, // Content-ID 
+                                  TDRMUniqueID& aID ) // Unique ID, out-parameter
+    {
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetDBEntriesL
+// Get a file name from the server. The file contains the rights objects,
+// which are then converted to RPointerArray.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void RDRMRightsClient::GetDBEntriesL( const TDesC8& aId,
+                                      RPointerArray< CDRMPermission >& aRightsList )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetDbEntryL
+// Get a single RO from the server.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMPermission* RDRMRightsClient::GetDbEntryL( const TDesC8& aContentID,
+                                                 const TDRMUniqueID& aUniqueID )
+    {
+    CDRMPermission* object = new (ELeave) CDRMPermission;
+    object->iUniqueID = aUniqueID;
+    return object;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::DeleteDbEntry
+// Deletes all rights objects associated with the given UID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::DeleteDbEntry( const TDesC8& aContentID )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::DeleteDbEntry
+// Delete a single rights object identified by given parameters.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::DeleteDbEntry( const TDesC8& aContentID,
+                                      const TDRMUniqueID& aUniqueID )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::ExportContentIDList
+// Overloaded method: requests all content IDs to be put to a file. 
+// Assumes that the given descriptor represents a buffer large enough to
+// contain the file name.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::ExportContentIDList( TDes& aFileName )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::ExportContentIDList
+// Overloaded method: requests all content IDs to be put to a file, 
+// and then converts the file into RPointerArray.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::ExportContentIDList( RPointerArray< HBufC8 >& aCIDList )
+    {
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::GetDecryptionKey
+// Fetches the decryption key from the server.
+// Uses TR mechanisms. Uses asynchronous C/S call.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::GetDecryptionKey( const TInt aIntent,
+                                        const TDesC8& aContentID,
+                                        const TBool aUpdate,
+                                        TDes8& aKey )
+    {
+    aKey.Copy(_L("0000000000000000"));
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::CheckRights
+// Checks if appropriate rights exist for a certain content ID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::CheckRights( const TInt aIntent,
+                                    const TDesC8& aContentID )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::Count
+// Returns the amount of unique content IDs in the database.
+// If an error occurs, a negative value is returned (Symbian OS / DRM 3 specific
+// error code).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::Count()
+    {
+    return 1;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::DeleteAll
+// Empties the database.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::DeleteAll()
+	{
+	return KErrNone;
+	}
+
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::Consume()
+// Consume the right with specific intent and contentID
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::Consume( const TInt aIntent, const TDesC8& aContentID, const TInt aActionIntent )
+	{
+	return KErrNone;
+	}
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::CalculatePadding
+// Calculate the padding from a data block and a certain content ID.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMRightsClient::CalculatePadding(
+    const TDesC8& aContentID,
+    const TDesC8& aLastTwoDataBlocks)
+    {
+    return 0;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::FileToListL
+// Converts the given file into an array.
+// -----------------------------------------------------------------------------
+//
+void RDRMRightsClient::FileToListL( RFs& aFs,
+                                   const TDesC& aFileName,
+                                   RPointerArray< CDRMPermission >& aList )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMRightsClient::URIFileToArrayL
+// Converts the given file into an array.
+// -----------------------------------------------------------------------------
+//
+void RDRMRightsClient::URIFileToArrayL( RFs& aFs,
+                                       const TDesC& aFile,
+                                       RPointerArray< HBufC8 >& aList )
+    {
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMRightsData.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,849 @@
+/*
+* 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:  Datatype for Rights Constraint
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32file.h>
+#include <s32std.h>
+#include <caf/caf.h>
+
+#include "DRMPointerArray.h"
+#include "DRMCommonData.h"
+#include "DRMPermission.h"
+#include "DRMRightsData.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+const TInt KEncryptionKeySize = 16;
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+class TPermData 
+    {
+    public: // Constructor
+    TPermData( HBufC8* aParentId, const TInt aIndex, TBool aIsValid ) :
+        iParentId( aParentId ),
+        iIndex( aIndex ),
+        iIsValid( aIsValid ) { };
+    
+    public: // Member variables    
+    HBufC8* iParentId; 
+    TInt iIndex;
+    TBool iIsValid;
+    };
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMRightsData::NewLC
+// -----------------------------------------------------------------------------
+//
+CDRMRightsData* CDRMRightsData::NewLC( CDRMCommonData* aData,
+                                       const TDesC8& aKey, 
+                                       const TFileName& aRightsFile,
+                                       RFs& aFileServer )
+    {
+    CDRMRightsData* self = new( ELeave ) CDRMRightsData( aData, aFileServer );
+    CleanupStack::PushL( self );
+    self->ConstructL( aRightsFile, aKey );
+
+    return self;    
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsData::NewL
+// -----------------------------------------------------------------------------
+//
+CDRMRightsData* CDRMRightsData::NewL( CDRMCommonData* aData, 
+                                      const TDesC8& aKey,
+                                      const TFileName& aRightsFile,
+                                      RFs& aFileServer )
+    {
+    CDRMRightsData* self = NewLC( aData, aKey, aRightsFile, aFileServer );
+    CleanupStack::Pop();	
+    
+    return self;    
+    };
+                                 
+// -----------------------------------------------------------------------------
+// CDRMRightsData::OpenLC
+// -----------------------------------------------------------------------------
+//
+CDRMRightsData* CDRMRightsData::OpenLC( const TFileName& aRightsFile,
+                                        RFs& aFileServer )
+    {
+    CDRMCommonData* common = CDRMCommonData::NewL();
+
+    CDRMRightsData* self = new( ELeave ) CDRMRightsData( common, aFileServer );
+    CleanupStack::PushL( self );    
+    self->ConstructL( aRightsFile );
+    
+    return self;
+    };    
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsData::OpenL
+// -----------------------------------------------------------------------------
+//
+CDRMRightsData* CDRMRightsData::OpenL( const TFileName& aRightsFile,
+                                       RFs& aFileServer )
+    {
+    CDRMRightsData* self = OpenLC( aRightsFile, aFileServer );
+    CleanupStack::Pop();
+    
+    return self;    
+    };    
+    
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+// 
+CDRMRightsData::~CDRMRightsData()
+    {
+    // Permanent File Store
+    if( iStore )
+        {;
+        delete iStore;
+        iStore = NULL;
+        }
+        
+    // index array    
+    iArray.Close();
+    
+    // Common Data
+    if( iData )
+        {
+        delete iData;
+        iData = NULL;
+        }
+    }; 
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsData::GetCommonDataL
+// -----------------------------------------------------------------------------
+//
+const CDRMCommonData* CDRMRightsData::GetCommonDataL() const
+    {
+    return iData;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsData::UpdateCommonDataL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::UpdateCommonDataL( CDRMCommonData* aData )
+    {
+    RStoreWriteStream stream;
+
+    // If not data is given, that is an error
+    if( !aData )
+        {
+        User::Leave( KErrArgument );
+        }
+           
+    // Open the stream 
+    stream.ReplaceLC( *iStore, iCommonId );
+    
+    // Delete the old data if it's around
+    // if the old data has been modified, write it as such
+    if( iData != aData )
+    	{
+        if( iData )
+        	{
+        	delete iData;
+        	iData = NULL;        	
+        	}
+    	iData = aData;        
+        }
+    
+    // Write the data to the stream
+    iData->ExternalizeL( stream );
+    
+    // commit the stream
+    stream.CommitL();
+    
+    // commit the store
+    iStore->CommitL();
+    
+    // pop the stream
+    CleanupStack::PopAndDestroy();
+    };        
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsData::StoreNewPermissionL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::StoreNewPermissionL( CDRMPermission& aPermission,
+                                          TDRMUniqueID& aStream )
+    {
+    TStreamId sid;
+    TStreamId rootId;
+    RStoreWriteStream stream;
+    RStoreWriteStream rootStream;
+       
+    // Create a new stream to the store:
+    sid = stream.CreateLC( *iStore );
+    
+    aPermission.iUniqueID = sid.Value();   
+    aStream = sid.Value();
+    
+    // Externalize the permission data
+    aPermission.ExternalizeL( stream );
+    stream.CommitL();
+        
+    // add the id to the array
+    iArray.InsertInUnsignedKeyOrder( aStream );
+
+    // Get the stream id of the root
+    rootId = iStore->Root();
+    
+    // Open the root stream
+    rootStream.ReplaceLC( *iStore, rootId );
+        
+    // Store the changed index
+    StoreIndexL( rootStream );    
+    rootStream.CommitL();
+
+    // Commit the store
+    iStore->CommitL();
+    
+    CleanupStack::PopAndDestroy();  // root stream
+    CleanupStack::PopAndDestroy();  // stream
+    
+    iStore->CompactL();
+    iStore->CommitL();
+    };    
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsData::UpdatePermissionL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::UpdatePermissionL( const CDRMPermission& aPermission )
+    {
+    TStreamId sid( aPermission.iUniqueID );
+    RStoreWriteStream stream;
+    TInt index = 0;
+    
+    // get the id from the array if it doesn't exist, error
+    index = iArray.FindInUnsignedKeyOrder( aPermission.iUniqueID );
+    
+    if( index == KErrNotFound )
+        {
+        User::Leave( KErrCANoPermission );
+        }
+    
+    // Replace the existing stream
+    stream.ReplaceLC( *iStore, sid );
+    
+    // Externalize the permission data
+    aPermission.ExternalizeL( stream );
+    
+    // Required by the ReplaceLC
+    stream.CommitL();
+
+    // Commit the store    
+    iStore->CommitL();
+    
+    CleanupStack::PopAndDestroy();
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsData::FetchPermissionL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::FetchPermissionL( CDRMPermission& aPermission,
+                                       const TDRMUniqueID& aStream ) const
+    {
+    TStreamId sid( aStream );    
+    RStoreReadStream stream;
+    TInt index = 0;
+
+    // get the id from the array if it doesn't exist, error
+    index = iArray.FindInUnsignedKeyOrder( aStream );
+    
+    if( index == KErrNotFound )
+        {
+        User::Leave( KErrCANoPermission );
+        }
+    
+    // Open the root stream
+    stream.OpenLC( *iStore, sid );
+
+    // Read the common id
+    aPermission.InternalizeL( stream );
+    
+    // Close the stream
+    CleanupStack::PopAndDestroy();        
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsData::DeletePermissionL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::DeletePermissionL( const TDRMUniqueID& aStream )
+    {
+    TStreamId sid( aStream );
+    TStreamId rootId;
+    TInt index = 0;
+    RStoreWriteStream rootStream;
+        
+    // get the id from the array if it doesn't exist, error
+    index = iArray.FindInUnsignedKeyOrder( aStream );
+    
+    if( index == KErrNotFound )
+        {
+        User::Leave( KErrCANoPermission );
+        }
+
+    // Delete the stream from the store
+    iStore->DeleteL( sid );
+            
+    iArray.Remove( index );       
+    
+    
+    // Get the stream id of the root
+    rootId = iStore->Root();
+    
+    // Open the root stream
+    rootStream.ReplaceLC( *iStore, rootId );
+        
+    // Store the changed index
+    StoreIndexL( rootStream );    
+    rootStream.CommitL();
+
+    // Commit the store
+    iStore->CommitL();
+    
+    CleanupStack::PopAndDestroy();  // root stream
+    
+    // Compact and commit the changes
+    iStore->CompactL();
+    iStore->CommitL();        
+    };
+                           
+// -----------------------------------------------------------------------------
+// CDRMRightsData::FetchAllPermissionsL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::FetchAllPermissionsL( RPointerArray<CDRMPermission>& 
+                                           aPointerArray)
+    {
+    CDRMPermission* perm = NULL;
+
+    if ( iArray.Count() == 0) 
+        {
+        User::Leave( KErrCANoPermission );
+        }
+    
+    for( TInt count = 0; count < iArray.Count(); count++ )
+        {
+        perm = CDRMPermission::NewLC();
+        FetchPermissionL( *perm, iArray[ count ] );
+        aPointerArray.AppendL( perm );
+		CleanupStack::Pop();
+        }
+    };    
+
+// -----------------------------------------------------------------------------
+// CDRMRightsData::DeleteAllPermissionsL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::DeleteAllPermissionsL()
+    {
+    TStreamId rootId;
+    RStoreWriteStream rootStream;
+    
+    // Delete all permissions from the store
+    for( TInt i = 0; i < iArray.Count(); i++ )
+        {
+        TStreamId sid( iArray[i] );
+        iStore->DeleteL( sid );
+        }
+        
+    // Reset the array    
+    iArray.Reset();
+    
+    // Get the stream id of the root
+    rootId = iStore->Root();
+    
+    // Open the root stream
+    rootStream.ReplaceLC( *iStore, rootId );
+        
+    // Store the changed index
+    StoreIndexL( rootStream );    
+    rootStream.CommitL();
+
+    // Commit the store
+    iStore->CommitL();
+    
+    CleanupStack::PopAndDestroy();  // root stream
+    
+    // Compact and Commit the store
+    iStore->CompactL();
+    iStore->CommitL();          
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsData::DeleteExpiredPermissionsL
+// Deletes all rights objects which have been expired
+// if the given time aTime is Time::NullTTime() then
+// deletes only non time based rights
+// -----------------------------------------------------------------------------
+//
+TInt CDRMRightsData::DeleteExpiredPermissionsL( const TTime& aTime, TBool& aParents )
+	{
+	CDRMPermission* permission = NULL;	   
+    RStoreReadStream stream;   
+    TStreamId rootId;
+    RStoreWriteStream rootStream;
+    TBool remove = EFalse;
+    TInt k = 0;
+    TBool performDelete = ETrue;
+    
+    // A list for the permissions:
+    CDRMPointerArray<CDRMPermission>* permList = CDRMPointerArray<CDRMPermission>::NewLC();
+    permList->SetAutoCleanup( ETrue );
+    CDRMPointerArray<TPermData>* permDataList = CDRMPointerArray<TPermData>::NewLC();
+    permDataList->SetAutoCleanup( ETrue );
+    
+    // Fill the array:
+    for( TInt j = 0  ; j < iArray.Count(); j++ )
+        {
+        TPermData* perm = NULL;
+        // Create the sid:
+        TStreamId psid( iArray[j] );
+
+    	// Open the correct stream
+    	stream.OpenLC( *iStore, psid );
+
+	    permission = CDRMPermission::NewLC();
+
+    	// Read the permission
+    	permission->InternalizeL( stream );
+    
+        permList->AppendL( permission );
+    	CleanupStack::Pop(); // permission
+    	        
+        // if the permission has a parent check if we found now or have found an
+        // expired one or a valid one,
+        // store info if required 
+        if( permission->iParentUID )
+            {
+            if( !aParents ) 
+                {
+                aParents = ETrue;
+                }
+            
+            for( k = 0; k < permDataList->Count(); k++ )
+                {
+                if( !(*permDataList)[k]->iParentId->Compare( *permission->iParentUID ) )
+                    {
+                    if( !(*permDataList)[k]->iIsValid && !permission->Expired( aTime ) )
+                        {
+                        (*permDataList)[k]->iParentId = permission->iParentUID;
+                        (*permDataList)[k]->iIndex = j;
+                        (*permDataList)[k]->iIsValid = ETrue;
+                        }
+                    break;
+                    }
+                }
+                
+            // if it's not found, add it:
+            if( k == permDataList->Count() )
+                {
+                if( !permission->Expired( aTime ) )
+                    {
+                    perm = new(ELeave) TPermData( permission->iParentUID, j, ETrue);
+                    }
+                else 
+                    {
+                    perm = new(ELeave) TPermData( permission->iParentUID, j, EFalse);                       
+                    }
+                CleanupStack::PushL( perm );
+                permDataList->AppendL( perm );
+                CleanupStack::Pop(); // perm   
+                }
+            }
+        
+        // Close the stream
+    	CleanupStack::PopAndDestroy();  // stream       
+        }
+          
+
+    // Delete all expired permissions from the store
+    for( TInt i = iArray.Count() - 1 ; i >= 0; i-- )
+        {
+        permission = (*permList)[i];
+        
+		// Check if the permission is expired
+		// if it is, check if it has a parent and if it can be deleted
+		if( permission->Expired( aTime ) )
+			{
+			// if it has a parent go through the list and see if this can be deleted
+			// or not
+			if( permission->iParentUID )
+			    {
+			    performDelete = EFalse;
+			    for( k = 0; k < permDataList->Count(); k++ )
+			        {
+			        TPermData* aData = (*permDataList)[k];
+			        
+			        // since it's set up like this a pointer comparison is enough:
+			        if( !(*permDataList)[k]->iParentId->Compare( *permission->iParentUID  ) ) 
+			            {
+			            if( i != (*permDataList)[k]->iIndex ) 
+			                {
+			                performDelete = ETrue;
+			                }
+			            }
+			        }
+			    }
+			
+		    if( performDelete )	
+		        {
+                // Create the sid:
+                TStreamId sid( iArray[i] );
+                		        
+			    iStore->Delete( sid );
+			
+	            // remove from the array		
+		        iArray.Remove( i );				
+		    
+		        if( !remove )
+		            {
+		            remove = ETrue;    
+		            }
+			    }    
+			}
+		performDelete = ETrue;			
+        }
+
+    CleanupStack::PopAndDestroy( 2 ); // permDataList, permList 
+        
+    // Write the data into the the file   
+    // if some of the rights have been removed
+    if( remove ) 
+        {
+        // Get the stream id of the root
+        rootId = iStore->Root();
+    
+        // Open the root stream
+        rootStream.ReplaceLC( *iStore, rootId );
+        
+        // Store the changed index
+        StoreIndexL( rootStream );    
+        rootStream.CommitL();
+
+        // Commit the store
+        iStore->CommitL();
+    
+        CleanupStack::PopAndDestroy();  // root stream
+        
+        // Compact and Commit the store
+        iStore->CompactL();
+        iStore->CommitL();             
+        }
+           
+	return iArray.Count();	
+	}
+
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsData::StoreKeyL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::StoreKeyL()
+    {
+    RStoreWriteStream stream;
+    TUint32 size = 0;
+    
+    stream.OpenLC( *iStore, iKeyId );
+    
+    if( iKeyExists ) 
+        {
+        size = KEncryptionKeySize;
+        }
+        
+    stream.WriteUint32L( size );        
+    
+    if( size )
+        {
+        stream.WriteL( iKey, KEncryptionKeySize );        
+        }
+        
+    stream.CommitL();
+    iStore->CommitL();
+        
+    CleanupStack::PopAndDestroy();
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsData::GetKeyL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDRMRightsData::GetKeyL() const
+    {
+    HBufC8* key = NULL;
+    
+    if( iKeyExists )
+        {
+        key = HBufC8::NewL( KEncryptionKeySize );
+        *key = iKey;
+        }
+        
+    return key;
+    }
+        
+// -----------------------------------------------------------------------------
+// CDRMRightsData::FetchKeyL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::FetchKeyL()
+    {
+    RStoreReadStream stream;
+    TUint32 size = 0;
+    
+    // Open the root stream
+    stream.OpenLC( *iStore, iKeyId );
+    
+    size = stream.ReadUint32L();  
+    
+    if( !size ) 
+        {
+        iKeyExists = EFalse;
+        }
+    else 
+        {
+        stream.ReadL( iKey, KEncryptionKeySize );
+        iKeyExists = ETrue;
+        }
+    
+    CleanupStack::PopAndDestroy();    
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsData::CreateAndInitializeStoreL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::CreateAndInitializeStoreL( const TFileName& aRightsStore )
+    {
+    TStreamId rootId;
+    RStoreWriteStream stream;
+    RStoreWriteStream stream2;    
+    RStoreWriteStream rootStream;
+    TUint32 size = 0;    
+    
+    // Create and initialize the permanent file store
+    iStore = CPermanentFileStore::ReplaceL( iFileServer, aRightsStore,
+                                            EFileRead|EFileWrite );                                          
+    iStore->SetTypeL( KPermanentFileStoreLayoutUid );
+    iStore->CommitL(); 
+    
+    // Create the root stream:                                                   
+    rootId = rootStream.CreateLC( *iStore );
+    rootStream.CommitL();
+    iStore->SetRootL( rootId );    
+    iStore->CommitL(); 
+        
+    // Create the common data
+    iCommonId = stream.CreateLC( *iStore );
+    iData->ExternalizeL( stream );
+    stream.CommitL();
+    iStore->CommitL(); 
+        
+    CleanupStack::PopAndDestroy(); // stream
+    
+    // Create the key
+    iKeyId = stream2.CreateLC( *iStore );
+
+    // if the key exists set the key size accordingly
+    if( iKeyExists ) 
+        {
+        size = KEncryptionKeySize;
+        }
+    stream2.WriteUint32L( size );
+
+    if( size )
+        {
+        stream2.WriteL( iKey, KEncryptionKeySize );
+        }
+    stream2.CommitL();
+    iStore->CommitL(); 
+           
+    CleanupStack::PopAndDestroy(); // stream2                                      
+    CleanupStack::PopAndDestroy(); // rootStream  
+    
+    // Create the index now that we have all the data
+    rootId = iStore->Root(); 
+    
+    rootStream.ReplaceLC(*iStore, rootId);
+    StoreIndexL( rootStream );
+    rootStream.CommitL();
+    iStore->CommitL(); 
+        
+    // Commit the changes to the store as well
+    CleanupStack::PopAndDestroy(); // rootStream       
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsData::StoreIndexL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::StoreIndexL( RWriteStream& aStream ) const
+    {
+    // Write the common id to the stream
+    iCommonId.ExternalizeL( aStream );
+    
+    // Write the key id to the stream
+    iKeyId.ExternalizeL( aStream );
+    
+    // Write the array size and possibly the array to the stream
+    aStream.WriteInt32L( iArray.Count() );
+    
+    for( TInt count = 0; count < iArray.Count(); count++ )
+        {
+        aStream.WriteUint32L( iArray[ count ] );
+        }
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsData::FetchIndexL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::FetchIndexL()
+    {
+    TStreamId rootId;
+    RStoreReadStream stream;
+    TInt count = 0;
+    TDRMUniqueID id;
+ 
+    // Get the stream id of the root
+    rootId = iStore->Root();
+    
+    // Open the root stream
+    stream.OpenLC( *iStore, rootId );
+    
+    // Do the actual reading, reading also the key id and the common id
+
+    // Read the common id
+    iCommonId.InternalizeL( stream );
+    
+    // Read the key id 
+    iKeyId.InternalizeL( stream );
+    
+    // read the count of the array:
+    iArray.Reset();
+    
+    count = stream.ReadInt32L();
+    
+    for( ; count > 0; count-- )
+        {
+        id = stream.ReadUint32L();
+        iArray.InsertInUnsignedKeyOrder( id );
+        }
+     
+    // Close the stream
+    CleanupStack::PopAndDestroy();    
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsData::FetchCommonDataL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::FetchCommonDataL()
+    {
+    RStoreReadStream stream;
+    
+    // Open the root stream
+    stream.OpenLC( *iStore, iCommonId );
+    
+    iData->InternalizeL( stream );
+    
+    CleanupStack::PopAndDestroy();
+    };
+    
+
+// -----------------------------------------------------------------------------
+// Default Constructor - First phase.
+// Can be used by itself to generate an empty object
+// -----------------------------------------------------------------------------
+//
+CDRMRightsData::CDRMRightsData( CDRMCommonData* aData, RFs& aFileServer ) :
+    iFileServer( aFileServer ), iData( aData )
+    {
+    };
+
+// -----------------------------------------------------------------------------
+// 2nd phase Constructor
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::ConstructL( const TFileName& aRightsStore )
+    {
+    // Open the file store
+    iStore = CPermanentFileStore::OpenL( iFileServer, aRightsStore, EFileRead|EFileWrite );
+    
+    // Get the index
+    FetchIndexL();
+    
+    // Get the common data
+    FetchCommonDataL();
+    
+    // Get the key
+    FetchKeyL();
+    };
+
+// -----------------------------------------------------------------------------
+// 2nd phase Constructor
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsData::ConstructL( const TFileName& aRightsStore,
+                                 const TDesC8& aKey )
+    {
+    
+    // Check if the key is given or a null desc
+    if( aKey.Length() ) 
+        {
+        iKey = aKey;
+        iKeyExists = ETrue;
+        }
+    else
+        {
+        iKeyExists = EFalse;
+        }    
+    
+    // Creates the required stores and indexes
+    CreateAndInitializeStoreL( aRightsStore );
+    };
+    
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMRightsServer.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1437 @@
+/*
+* Copyright (c) 2003 - 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:  DRM3 Engine manages all DRM related database operations.
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32test.h>
+#include <etelmm.h>
+#include <DrmTypes.h>
+#include <starterclient.h>
+#include <featmgr.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "DRMRightsServer.h"
+#include "DRMRightsDb.h"
+#include "DRMDbSession.h"
+#include "DRMEngineClientServer.h"
+#include "DRMLog.h"
+#include "DRMNotifier.h"
+#include "DrmKeyStorage.h"
+#include "drmnotifierserver.h"
+#include "roapstorageserver.h"
+#include "drmnotifierclientserver.h"
+#include "drmroapclientserver.h"
+#include "DRMXOma.h"
+#include "DRMBackupObserver.h"
+#include "DRMBackup.h"
+#include "flogger.h"
+#include "drmrightsparser.h"
+#include "drmrights.h"
+#include "drmhelpercommon.h"
+
+#include  "wmdrmclientwrapper.h"
+
+
+
+#ifdef __DRM_CLOCK
+#include "DRMClockServer.h"
+#include "drmclockclientserver.h"
+#endif
+
+#include <utf.h>
+#include <DRMIndividualConstraintExtension.h>
+
+/*
+_LIT( KLogDir, "drm");
+_LIT( KLogName, "backup.log");
+*/
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES 
+// CONSTANTS
+LOCAL_C const TUint KMaxHeapsize = 0x7A120;
+
+_LIT8( KImsiId,"IMSI:");
+
+// MACROS
+#ifdef _DRM_TESTING
+_LIT( KDateTimeFormat, "%F%Y%M%D%H%T%S%C" );
+#endif
+
+// LOCAL CONSTANTS AND MACROS
+const TUint8 KMaxStartTries = 30;
+const TInt KWaitingTime = 2000000; // 2 sec
+_LIT( KRightsServerThread, "RightsServer" );
+
+#ifdef RD_MULTIPLE_DRIVE
+
+_LIT( KDbTempPath, "%c:\\system\\temp\\" );
+_LIT( KIndividualConstraintExtensionDll, "%c:\\sys\\bin\\DRMIndividualConstraintExtension.dll" );
+_LIT( KRightsDir, "%c:\\private\\101F51F2\\rdb\\" );
+_LIT( KTimedReplayCacheFile, "%c:\\private\\101F51F2\\timererc.dat" );
+_LIT( KPlainReplayCacheFile, "%c:\\private\\101F51F2\\plainrc.dat" );
+#ifdef RD_DRM_METERING
+_LIT( KMeteringDataBaseFile, "%c:\\private\\101F51F2\\meterdb.dat" );
+#endif
+
+#define USE_RO_IMPORT
+
+#ifdef USE_RO_IMPORT
+_LIT( KInternalImportDir, "%c:\\private\\101F51F2\\import\\" );
+_LIT( KUserDiskImportDir, "%c:\\import\\" ); // usually embedded MMC
+_LIT( KUserRemovableDiskImportDir, "%c:\\import\\" ); // usually external MMC
+_LIT( KDrSuffix, ".dr" );
+#endif
+
+#else
+
+_LIT( KRightsDir, "c:\\private\\101F51F2\\rdb\\" );
+_LIT( KTimedReplayCacheFile, "c:\\private\\101F51F2\\timererc.dat" );
+_LIT( KPlainReplayCacheFile, "c:\\private\\101F51F2\\plainrc.dat" );
+#ifdef RD_DRM_METERING
+_LIT( KMeteringDataBaseFile, "c:\\private\\101F51F2\\meterdb.dat" );
+#endif
+
+#define USE_RO_IMPORT
+
+#ifdef USE_RO_IMPORT
+_LIT( KInternalImportDir, "c:\\private\\101F51F2\\import\\" );
+_LIT( KUserDiskImportDir, "e:\\import\\" );
+_LIT( KDrSuffix, ".dr" );
+#endif
+
+#endif
+
+_LIT(KWmDrmClientWrapperName, "wmdrmclientwrapper.dll");
+
+// MODULE DATA STRUCTURES
+
+NONSHARABLE_STRUCT( TUnloadModule )
+    {
+    RTelServer* iServer;
+    const TDesC* iName;
+    };
+
+// LOCAL FUNCTION PROTOTYPES
+
+LOCAL_C TInt Startup( void );
+LOCAL_C void SignalClient();
+LOCAL_C TInt StartDBServer( void );
+
+#if defined( __WINS__ )
+#else
+#define DRM_USE_SERIALNUMBER_URI
+#include <mmtsy_names.h>
+#endif
+
+
+#ifdef DRM_USE_SERIALNUMBER_URI
+LOCAL_C void DoUnloadPhoneModule( TAny* aAny );
+#endif
+
+// #define USE_RO_IMPORT
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// Function Startup().
+// This function starts the actual DRM Rights server after initializing
+// the cleanup stack and active scheduler.
+// Returns: TInt: Symbian OS error code.
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt Startup( void ) 
+    {
+    TInt error = KErrNone;
+    CTrapCleanup* trap = CTrapCleanup::New();
+    CActiveScheduler* scheduler = new CActiveScheduler();
+    
+    if ( trap && scheduler )
+        {
+        CActiveScheduler::Install( scheduler );
+    
+        error = StartDBServer();
+        }
+    else
+        {
+        error = KErrNoMemory;
+        }
+
+    delete scheduler; 
+    scheduler = NULL;
+    
+    delete trap;
+    trap = NULL;
+    
+    if ( error )
+        {
+        // Something went wrong. Release the client (if any).
+        SignalClient();
+        
+        if ( error == KErrAlreadyExists )
+            {
+            error = KErrNone;
+            }
+        }
+       
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// Function SignalClient().
+// Signal the waiting client (one of them if any exists).
+// -----------------------------------------------------------------------------
+//
+void SignalClient( void )
+    {
+    RSemaphore semaphore;
+    if ( !semaphore.OpenGlobal( DRMEngine::KDRMSemaphore ) )
+        {
+        semaphore.Signal();
+        semaphore.Close();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// Function StartDBServer().
+// This function starts the actual server under TRAP harness and starts
+// waiting for connections. This function returns only if there has been
+// errors during server startup or the server is stopped for some reason.
+// 
+// Returns: TInt: Symbian OS error code.
+// -----------------------------------------------------------------------------
+TInt StartDBServer( void ) 
+    {
+    TInt error = KErrNone;
+    CDRMRightsServer* server = NULL;
+    TUint8 count = 0;
+    
+    do
+        {
+        DRMLOG2( _L( "RightsServer.exe: StartDBServer: %d" ), error );
+        
+        ++count;
+        
+        TRAP( error, ( server = CDRMRightsServer::NewL() ) );
+        
+        if ( error ) 
+            {
+            User::After( TTimeIntervalMicroSeconds32(KWaitingTime) );
+            }
+        
+        } while( error && ( count <= KMaxStartTries ) );
+        
+    if( error ) 
+        {
+        DRMLOG2( _L( "RightsServer.exe: CDRMRightsServer::NewL failed: %d " ), error );
+        // Failed
+        return error;
+        }
+    
+    // Release the semaphore if necessary.
+    SignalClient();
+   
+    // Start waiting for connections
+    CActiveScheduler::Start();
+    
+    // Dying...
+    // Delete CDRMRigntsServer
+        
+    DRMLOG( _L( "RightsServer.exe: DB server dying..." ) );
+
+    delete server;
+    
+    return KErrNone;
+    }
+
+#ifdef DRM_USE_SERIALNUMBER_URI
+// -----------------------------------------------------------------------------
+// Function DoUnloadPhoneModule
+// Unload phone module
+// -----------------------------------------------------------------------------
+//
+void DoUnloadPhoneModule( TAny* aAny )
+    {
+    __ASSERT_DEBUG( aAny, User::Invariant() );
+    TUnloadModule* module = ( TUnloadModule* ) aAny;
+    module->iServer->UnloadPhoneModule( *( module->iName ) );
+    }
+#endif
+
+#ifdef USE_RO_IMPORT
+// -----------------------------------------------------------------------------
+// PointerArrayResetDestroyAndClose
+// Template method used to push RPointerArrays to the cleanup stack. Takes
+// care of deleting all pointers in the array.
+// -----------------------------------------------------------------------------
+//
+template<class S>
+void PointerArrayResetDestroyAndClose(TAny* aPtr)
+    {
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->ResetAndDestroy();
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->Close();
+    }
+#endif    
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMRightsServer* CDRMRightsServer::NewL()
+    {
+    CDRMRightsServer* self = new( ELeave ) CDRMRightsServer();
+    
+    CleanupStack::PushL( self );
+    
+    self->ConstructL();
+    
+    CleanupStack::Pop( self );
+    
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+CDRMRightsServer::~CDRMRightsServer() 
+    {
+    DRMLOG( _L( "CDRMRightsServer::~" ) );
+    
+    delete iIMEI; iIMEI = NULL;
+    
+    delete iIMSI; iIMSI = NULL;
+    
+    delete iDb; iDb = NULL;
+    
+    iClock.Close();
+    iCache.Close();
+    
+    iMeteringDb.Close();
+    
+    iFs.Close();
+    iActiveCountConstraints.ResetAndDestroy();
+    iActiveCountConstraints.Close();
+    
+    delete iBackupObserver;
+    delete iBackupHandler;    
+    delete iActiveBackupClient;
+    delete iDbWatcher;
+
+#if 0    
+    // Close and delete the shared data client
+    if( iSharedDataClient ) 
+        {
+        iSharedDataClient->Close();
+        delete iSharedDataClient;
+        iSharedDataClient = NULL;
+        }
+#endif
+
+    if( iNotifier )
+        {
+        delete iNotifier; iNotifier = NULL;
+        }
+        
+    //An empty semaphore
+    RSemaphore semaphore;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::GetSecureTime
+// Fetch the time from (secure) source.
+// -----------------------------------------------------------------------------
+//
+TBool CDRMRightsServer::GetSecureTime( TTime& aTime ) const
+    {
+    DRMClock::ESecurityLevel secLevel = DRMClock::KInsecure;
+	
+	TInt timezone( 0 );
+	
+    iClock.GetSecureTime( aTime, timezone, secLevel );
+	
+    if( secLevel == DRMClock::KSecure )
+        {
+        DRMLOG( _L( "CDRMRightsServer::GetSecureTime: Time is secure\r\n" ) );
+        return ETrue;		
+        }	
+        
+    DRMLOG( _L( "CDRMRightsServer::GetSecureTime: Time is not secure\r\n" ) );    	
+
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::Notifier
+// Return a handle to DRM Notifier.
+// -----------------------------------------------------------------------------
+//
+CDRMNotifier& CDRMRightsServer::Notifier()
+    {
+    return *iNotifier;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::Notifier
+// Return a handle to DRM Notifier.
+// -----------------------------------------------------------------------------
+//
+CDRMRightsDB& CDRMRightsServer::Database()
+    {
+    return *iDb;
+    }
+
+RFs& CDRMRightsServer::FileServerSession()
+    {
+    return iFs;
+    }
+    
+    
+RDRMReplayCache& CDRMRightsServer::ReplayCache()
+    {
+    return iCache;
+    }
+
+
+RDrmMeteringDb& CDRMRightsServer::MeteringDatabase()
+    {
+    return iMeteringDb;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::HandleNotifyL
+// Forward the event to the database.
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsServer::HandleNotifyL(const TUid /*aUid*/,
+                                     const TDesC& /*aKey*/,
+                                     const TDesC& /*aValue*/)  
+    {   
+    /* XXX Backup via Publish/Subscribe
+    __ASSERT_DEBUG( iDb, User::Invariant() );
+    TInt value = -1;
+    TLex16 parser( aValue );
+
+    if ( aUid == KSDUidSystem )
+        {
+        // Check if it's a backup / restore status event
+        if( !aKey.Compare( KBackupRestoreStatus ) )
+            {
+            User::LeaveIfError( parser.Val( value ) );
+            if( value == 3 ) // Complete
+                {
+                iDb->MergeDBL();
+                }
+            }
+        // Check if it's a drm backup restore status event
+        else if ( aUid == KSDUidSystem )
+            {
+            if( !aKey.Compare( KDRMBackupRestoreStatus ) )
+                {
+                User::LeaveIfError( parser.Val( value ) );
+
+                if( value == 1 ) // PrepareForBackup
+                    {
+                    TRAPD( error, iDb->BackupDBL( KNullDesC, 
+                                                  KNullDesC8 ) );
+                    // Notify that it's done
+                    User::LeaveIfError( iSharedDataClient->AssignToTemporaryFile(
+                                        KSDUidSystem ) );
+                    User::LeaveIfError( iSharedDataClient->SetInt( 
+                                        KDRMBackupRestoreStatus, 0 ) );
+                    iSharedDataClient->Flush();
+                    }
+                }
+            }
+        }
+    */
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::RunErrorL
+// From CActive. Complete the request and restart the scheduler.
+// -----------------------------------------------------------------------------
+//
+TInt CDRMRightsServer::RunError( TInt aError ) 
+    {
+    DRMLOG2( _L( "CDRMRightsServer::RunError: %d" ), aError );
+
+    // Inform the client.
+    if ( !Message().IsNull() )
+        {
+        Message().Complete( aError );
+        }
+    
+    // Restart the scheduler.
+    ReStart();
+    
+    // Error handled.
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::NewSessionL
+// Called when a client requires a new instance.
+// -----------------------------------------------------------------------------
+CSession2* CDRMRightsServer::NewSessionL( const TVersion& aVersion,
+                                          const RMessage2& /*aMessage*/ ) const
+    {
+    DRMLOG( _L( "CDRMRightsServer::NewSessionL" ) );
+
+    if ( ! User::QueryVersionSupported( TVersion( DRMEngine::KServerMajorVersion,
+        DRMEngine::KServerMinorVersion,
+        DRMEngine::KServerBuildVersion ), 
+        aVersion ) ) 
+        {
+        // Sorry, no can do.
+        User::Leave( KErrNotSupported );
+        }
+
+    DRMLOG( _L( "CDRMRightsServer::NewSessionL: Creating a new session" ) );
+
+    return CDRMDbSession::NewL();
+    }
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::CDRMRightsServer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMRightsServer::CDRMRightsServer() : 
+    CServer2( EPriorityStandard ),
+    iIMEI( NULL ),
+    iArmed( EFalse ),    
+    iIMSI( NULL ),
+    iGetImsi( ETrue )
+    {
+    // Nothing
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsServer::ConstructL() 
+    {
+    DRMLOG( _L( "CDRMRightsServer::ConstructL" ) );
+
+    TDRMKey key;
+    RSemaphore semaphore;
+    RProcess currentprocess;
+    
+    // Ignore errors
+    User::RenameThread( KRightsServerThread );
+    User::LeaveIfError( iFs.Connect() );
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    // Ignore errors
+    iFs.MkDirAll( KDRMDbTempPath );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TFileName tempPath;
+    TFileName tempPath2;
+    TFileName tempRemovablePath;
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    TChar driveLetterRemovable;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	iFs.DriveToChar( driveNumber, driveLetter );
+	
+	tempPath.Format( KDbTempPath, (TUint)driveLetter );
+    
+    // Ignore errors
+    iFs.MkDirAll( tempPath );
+    
+#endif
+        
+    DRMLOG( _L( "CDRMRightsServer::ConstructL: SharedDataClient" ) );
+
+    // Create and instance of the shared data client
+    // iSharedDataClient = new (ELeave) RSharedDataClient(this);
+
+    // Connecting to the shared data server
+    // User::LeaveIfError(iSharedDataClient->Connect());
+
+    /* XXX Backup via Publish/Subscribe
+    User::LeaveIfError(iSharedDataClient->NotifyChange(
+        KSDUidSystem, &KBackupRestoreStatus ) );
+    User::LeaveIfError(iSharedDataClient->NotifyChange(
+        KSDUidSystem, &KDRMBackupRestoreStatus) );
+    */  
+      
+      
+    GetDbKeyL( key );
+    
+    
+    DRMLOG( _L( "CDRMRightsServer::ConstructL: database" ) );
+
+    GetIMEIL();
+    
+    // Create the imsi pointer array:
+    iIMSI = CDRMPointerArray<HBufC8>::NewL();
+    iIMSI->SetAutoCleanup(ETrue);
+    
+    GetIMSIL();
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    iDb = CDRMRightsDB::NewL( iFs, KRightsDir, key, *iIMEI );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    tempPath.Format( KRightsDir, (TUint)driveLetter );
+    
+    iDb = CDRMRightsDB::NewL( iFs, tempPath, key, *iIMEI );
+    
+#endif
+        
+    key.FillZ();
+        
+    DRMLOG( _L( "CDRMRightsServer::ConstructL: DB started." ) );
+
+    DRMLOG( _L( "CDRMRightsServer::ConstructL: Starting Notifier ." ) );
+        
+    User::LeaveIfError( semaphore.CreateGlobal( KDRMEngCommonSemaphore, 0 ) );
+    CleanupClosePushL( semaphore );
+    
+    StartThreadL( DRMNotifier::KServerName, StartupNotifier, semaphore );
+    DRMLOG( _L( "CDRMRightsServer::ConstructL: Notifier thread created." ) );
+    
+    StartThreadL( Roap::KServerName, StartupRoapStorage, semaphore );
+    DRMLOG( _L( "CDRMRightsServer::ConstructL: ROAP thread created." ) );
+    
+#ifdef __DRM_CLOCK
+    StartThreadL( DRMClock::KServerName, StartupClock, semaphore );
+    DRMLOG( _L( "CDRMRightsServer::ConstructL: clock thread created." ) );
+#endif
+    
+    CleanupStack::PopAndDestroy(); // semaphore
+    
+    iNotifier = CDRMNotifier::NewL();
+    
+    iCache.Set( iFs );
+
+#ifndef RD_MULTIPLE_DRIVE
+    
+    iCache.InitL( KTimedReplayCacheFile, KPlainReplayCacheFile );
+
+#ifdef RD_DRM_METERING               
+    iMeteringDb.Set( iFs );
+    iMeteringDb.InitL( KMeteringDataBaseFile );
+#endif
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    tempPath.Format( KTimedReplayCacheFile, (TUint)driveLetter );
+    tempPath2.Format( KPlainReplayCacheFile, (TUint)driveLetter );
+    
+    iCache.InitL( tempPath, tempPath2 );
+    
+#ifdef RD_DRM_METERING               
+    
+    tempPath.Format( KMeteringDataBaseFile, (TUint)driveLetter );
+    
+    iMeteringDb.Set( iFs );
+    iMeteringDb.InitL( tempPath );
+
+#endif
+    
+#endif
+    
+    User::LeaveIfError( iClock.Connect() );
+
+    // xoma header list creation
+    iXOmaHeaders = new (ELeave) RPointerArray< CDRMXOma >();
+    
+    // p/s
+    iBackupObserver = CDRMBackupObserver::NewL( *(const_cast<CDRMRightsServer*>(this)));
+    iBackupObserver->Start();
+    
+#ifdef USE_RO_IMPORT
+    // Import any OMA DRM 1.0 RO in the import directory, ignore all errors (except
+    // when checking the default removable mass storage)
+    TInt r = KErrNone;
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    TRAP( r, ImportRightsObjectsL( KInternalImportDir ) );
+    TRAP( r, ImportRightsObjectsL( KUserDiskImportDir ) );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    tempPath.Format( KInternalImportDir, (TUint)driveLetter );
+    
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNumber );
+	iFs.DriveToChar( driveNumber, driveLetter );
+    
+	// Default mass storage is usually eMMC
+    tempPath2.Format( KUserDiskImportDir, (TUint)driveLetter );
+    
+    // Find out if a removable mass storage also exists
+    r = DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRemovableMassStorage, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetterRemovable );
+    
+    // Import is not needed from the default removable mass storage drive if the drive 
+    // letter of the default mass storage and the default removable mass storage are 
+    // the same or the removable mass storage is not supported
+    if ( ( driveLetter != driveLetterRemovable ) && ( r == KErrNone ) ) 
+        {
+        tempRemovablePath.Format( KUserRemovableDiskImportDir, (TUint)driveLetterRemovable );
+        TRAP( r, ImportRightsObjectsL( tempRemovablePath ) );
+        }
+    
+    TRAP( r, ImportRightsObjectsL( tempPath ) );
+    TRAP( r, ImportRightsObjectsL( tempPath2 ) );
+    
+#endif
+    
+#endif
+
+    // Add the server to the scheduler.
+    StartL( DRMEngine::KServerName );
+
+    // Start watching our RDB
+    iDbWatcher = CDbWatcher::NewL( *this );
+    iDbWatcher->StartWatching();
+    
+    // Start watching the helper server
+    iProcWatcher = CProcWatcher::NewL( *this, _L( "*DcfRepSrv*" ), _L( "DcfRepSrv" ) );
+    iProcWatcher->StartWatching();
+    
+    // Ready to watch
+    iArmed = ETrue;
+
+    __UHEAP_MARK;
+    TRAP( r, FeatureManager::InitializeLibL() );
+    if( !r && FeatureManager::FeatureSupported( KFeatureIdWindowsMediaDrm ) ) 
+        {
+        static const TInt KGateOrdinal = 1;
+        RLibrary library;
+        r = library.Load( KWmDrmClientWrapperName );
+        if( !r )
+            {
+            CWmDrmClientWrapper* wrapper = NULL;
+            TLibraryFunction function = library.Lookup( KGateOrdinal );
+            if( function != NULL )
+                {
+                __UHEAP_MARK;
+                TRAP( r, wrapper = reinterpret_cast<CWmDrmClientWrapper*>( function() ) );
+                if( !r )
+                    {
+                    r = wrapper->Connect();
+                    }
+                delete wrapper;
+                __UHEAP_MARKEND;
+                }
+            }
+        library.Close();    
+        }
+    FeatureManager::UnInitializeLib();
+    __UHEAP_MARKEND;  
+    }
+ 
+// -----------------------------------------------------------------------------   
+// CDRMRightsServer::StartThreadL
+// Start a new thread.
+// -----------------------------------------------------------------------------    
+void CDRMRightsServer::StartThreadL( const TDesC& aThreadName,
+                                     TThreadFunction aFunc,
+                                     RSemaphore& aSemaphore )
+    {
+    RThread thread;
+    
+    User::LeaveIfError( 
+          thread.Create( aThreadName,
+                         aFunc, 
+                         KDefaultStackSize,
+                         KMinHeapSize, 
+                         KMaxHeapsize,
+                         NULL ) );
+    
+    thread.Resume();
+    
+    aSemaphore.Wait();
+    
+    thread.Close();
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::GetDbKeyL
+// Fetches the rights database key from Wallet or uses a constant 
+// key if Wallet is not supported.
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsServer::GetDbKeyL( TDRMKey& aKey  ) 
+    {
+    TInt r = KErrNone;
+    
+    DRMLOG( _L( "CDRMRightsServer::GetDbKey" ) );
+    MDrmKeyStorage* storage = DrmKeyStorageNewL();
+    TRAP( r, storage->GetDeviceSpecificKeyL( aKey ) );
+    delete storage;
+    User::LeaveIfError( r );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::GenerateKeyL
+// Generates the actual key based on the given key seed.
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsServer::GenerateKeyL( HBufC*& aKeySeed, 
+                                    TDRMKey& aKey ) const
+    {
+    __ASSERT_ALWAYS( aKeySeed->Size() >= KDRMKeyLength, 
+        User::Leave( KErrUnderflow ) );
+    
+    TPtrC8 key( reinterpret_cast< TUint8* >( const_cast< TUint16* >( aKeySeed->Ptr() ) ),
+                KDRMKeyLength );
+    
+    aKey = key;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::XOmaHeaders()
+// return the pointer of the X-Oma headers list 
+// -----------------------------------------------------------------------------
+//
+RPointerArray< CDRMXOma >& CDRMRightsServer::XOmaHeaders( void )
+	{
+	return *iXOmaHeaders;
+	}
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::GetIMEIL
+// -----------------------------------------------------------------------------
+//
+const TDesC& CDRMRightsServer::GetIMEIL()
+    {
+    if ( iIMEI )
+        {
+        return *iIMEI;
+        }
+    
+#ifdef DRM_USE_SERIALNUMBER_URI
+    TInt error( KErrNone );
+    TInt count( 0 );
+    TInt count2( 0 );
+    TUint32 caps( 0 );
+    TBool found (EFalse);
+    
+    RTelServer etelServer;
+    RMobilePhone phone;
+    
+    TUint KMaxImeiTries = 5;
+    
+    for ( TUint8 i = 0; i < KMaxImeiTries; ++i )
+        {
+        error = etelServer.Connect();
+        if ( error )
+            {
+            User::After( TTimeIntervalMicroSeconds32( KWaitingTime ) );
+            }
+        else 
+            {
+            break;
+            }
+        }
+    
+    User::LeaveIfError( error );
+    CleanupClosePushL( etelServer );
+    
+    User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) );  
+    
+    TUnloadModule unload;
+    unload.iServer = &etelServer;
+    unload.iName = &KMmTsyModuleName;
+    
+    TCleanupItem item( DoUnloadPhoneModule, &unload );
+    CleanupStack::PushL( item );
+    User::LeaveIfError( etelServer.EnumeratePhones( count ) );
+        
+    for ( count2 = 0; count2 < count && !found; ++count2 )
+        {
+        RTelServer::TPhoneInfo phoneInfo;
+        User::LeaveIfError( etelServer.GetTsyName( count2, phoneInfo.iName ) );
+        
+        if ( phoneInfo.iName.CompareF(KMmTsyModuleName()) == 0 )   
+           {
+            User::LeaveIfError( etelServer.GetPhoneInfo( count2, phoneInfo ) );
+            User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) );
+            CleanupClosePushL( phone );
+            found = ETrue;
+            }
+        }
+
+    if ( !found )
+        {
+        // Not found.
+        User::Leave( KErrNotFound );
+        }
+   
+    User::LeaveIfError( phone.GetIdentityCaps( caps ) );
+    if ( caps & RMobilePhone::KCapsGetSerialNumber )
+        {
+        RMobilePhone::TMobilePhoneIdentityV1 id;
+        TRequestStatus status;
+    
+        phone.GetPhoneId( status, id );
+        
+        User::WaitForRequest( status );
+        
+        User::LeaveIfError( status.Int() );
+        
+        iIMEI = id.iSerialNumber.AllocL();
+        
+        CleanupStack::PopAndDestroy( 3 ); // phone, item, etelServer
+        
+        HBufC8* buf = HBufC8::NewL( iIMEI->Size() );
+        TPtr8 ptr( buf->Des() );
+        ptr.Copy( *iIMEI );
+        
+        DRMLOG(_L("IMEI:"));
+        DRMLOGHEX(ptr);
+        delete buf;
+    
+        return *iIMEI;
+        }
+    
+    User::Leave( KErrNotFound );
+    
+    // Never happens...
+    return *iIMEI; 
+    
+#else
+    _LIT( KDefaultSerialNumber, "123456789123456789" );
+    iIMEI = KDefaultSerialNumber().AllocL();
+        
+    return *iIMEI;
+#endif
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::GetIMSIL
+// -----------------------------------------------------------------------------
+//
+const CDRMPointerArray<HBufC8>& CDRMRightsServer::GetIMSIL()
+    {
+    
+    if ( !iGetImsi )
+        {
+        return *iIMSI;
+        }
+
+#ifndef __WINS__   
+    TInt error( KErrNone );
+    TInt count( 0 );
+    TInt count2( 0 );
+    TUint32 caps( 0 );
+    TBool found (EFalse);
+    HBufC8* imsi = NULL;
+    HBufC8* imsiNumber = NULL;
+    
+    RTelServer etelServer;
+    RMobilePhone phone;
+    
+    TUint KMaxImeiTries = 5;    
+    for ( TUint8 i = 0; i < KMaxImeiTries; ++i )
+        {
+        error = etelServer.Connect();
+        if ( error )
+            {
+            User::After( TTimeIntervalMicroSeconds32( KWaitingTime ) );
+            }
+        else 
+            {
+            break;
+            }
+        }
+    
+    User::LeaveIfError( error );
+    CleanupClosePushL( etelServer );     
+    User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) );  
+    
+    TUnloadModule unload;
+    unload.iServer = &etelServer;
+    unload.iName = &KMmTsyModuleName;
+    
+    TCleanupItem item( DoUnloadPhoneModule, &unload );
+    CleanupStack::PushL( item );
+    
+    User::LeaveIfError( etelServer.EnumeratePhones( count ) );
+        
+    for ( count2 = 0; count2 < count && !found; ++count2 )
+        {
+        RTelServer::TPhoneInfo phoneInfo;
+        User::LeaveIfError( etelServer.GetTsyName( count2, phoneInfo.iName ) );
+        
+        if ( phoneInfo.iName.CompareF(KMmTsyModuleName()) == 0 )   
+           {
+            User::LeaveIfError( etelServer.GetPhoneInfo( count2, phoneInfo ) );
+            User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) );
+            CleanupClosePushL( phone );
+            found = ETrue;
+            }
+        }
+
+    if ( !found )
+        {
+        // Not found.
+        User::Leave( KErrNotFound );
+        }
+   
+ 
+    User::LeaveIfError( phone.GetIdentityCaps( caps ) );
+
+    if( caps & RMobilePhone::KCapsGetSubscriberId )
+        {
+        RMobilePhone::TMobilePhoneSubscriberId imsiId;        
+        TRequestStatus status;
+    
+        phone.GetSubscriberId( status, imsiId );
+        
+        User::WaitForRequest( status );
+        
+        if( ! status.Int() )
+            {             
+            imsi = HBufC8::NewMaxLC( imsiId.Length() + KImsiId().Size() );
+            TPtr8 imsiPtr(const_cast<TUint8*>(imsi->Ptr()), 0, imsi->Size());
+      
+            imsiNumber = CnvUtfConverter::ConvertFromUnicodeToUtf8L( imsiId );
+            CleanupStack::PushL( imsiNumber );
+            
+            imsiPtr.Copy( KImsiId() );
+            imsiPtr.Append( *imsiNumber );
+            CleanupStack::PopAndDestroy(); // imsiNumber
+            }
+        else
+            {            
+            imsi = NULL;
+            }
+        }
+    else
+        {         
+        imsi = NULL;
+        } 
+    
+    
+    // Clean up whatever is in there
+    iIMSI->ResetAndDestroy();
+    
+    if( imsi ) 
+        { 
+        // if we got it we wont try again             
+        iIMSI->AppendL( imsi );
+        CleanupStack::Pop(); // imsi
+        iGetImsi = EFalse;            
+        }
+
+    // Check for possible extra IMSI individual constraints
+    AppendExtendedIndividualConstraintsL(&phone);
+    
+    CleanupStack::PopAndDestroy(); // phone
+    CleanupStack::PopAndDestroy(); // cleanup item
+    CleanupStack::PopAndDestroy(); // etel server
+
+    return *iIMSI; 
+    
+#else
+    HBufC8* imsi = NULL;
+    
+    if( iGetImsi ) 
+        {
+        iGetImsi = EFalse;
+        _LIT8( KDefaultSerialNumber, "IMSI:123456789123456789" );
+        imsi = KDefaultSerialNumber().AllocLC();
+        iIMSI->AppendL( imsi );
+        CleanupStack::Pop();        
+        AppendExtendedIndividualConstraintsL();
+        }
+
+        
+    return *iIMSI;
+#endif // __WINS__
+    }
+
+// -----------------------------------------------------------------------------   
+// CDRMRightsServer::AppendExtendedIndividualConstraintsL
+// If the extension DLL exists it is loaded and used to obtain additional
+// valid individual constraints
+// -----------------------------------------------------------------------------    
+void CDRMRightsServer::AppendExtendedIndividualConstraintsL(RMobilePhone* aMobilePhone)
+    {    	    	
+    // Load the externsion DLL
+    RLibrary lib;
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    if (lib.LoadRomLibrary(KDRMIndividualConstraintExtensionDll,KNullDesC)==KErrNone)
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+	iFs.DriveToChar( driveNumber, driveLetter );
+	
+	TFileName individualConstraindExtensionDll;
+	individualConstraindExtensionDll.Format( 
+	                    KIndividualConstraintExtensionDll, (TUint)driveLetter );
+    
+    if ( lib.LoadRomLibrary( individualConstraindExtensionDll, KNullDesC ) == KErrNone )
+    
+#endif
+    
+    	{
+        CleanupClosePushL(lib);
+
+        // Get first exported ordinal - factory method returning 
+        // MDRMIndividualConstraintExtension*
+        TLibraryFunction factory = lib.Lookup(1); 
+
+        if (factory)
+            {
+            // Instantiate object
+            MDRMIndividualConstraintExtension* extendedConstraints = 
+                reinterpret_cast<MDRMIndividualConstraintExtension*>(factory());
+
+            if (extendedConstraints)
+                {
+			    CleanupStack::PushL(TCleanupItem(Release,extendedConstraints));
+                extendedConstraints->AppendConstraintsL(*iIMSI,aMobilePhone);
+			    CleanupStack::PopAndDestroy(extendedConstraints); //calls Release
+                }
+            }
+
+        // unload library
+        CleanupStack::PopAndDestroy(&lib); //close
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::Release
+// -----------------------------------------------------------------------------
+void CDRMRightsServer::Release(TAny* aIndividualConstraintExtension)
+    {
+    MDRMIndividualConstraintExtension* extendedConstraints = 
+    	reinterpret_cast<MDRMIndividualConstraintExtension*>(aIndividualConstraintExtension);
+    extendedConstraints->Release(); //free resources
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::HandleBackupEventL
+// Handle Backup Events
+// -----------------------------------------------------------------------------
+//
+
+void CDRMRightsServer::HandleBackupEventL( TInt aBackupEvent )
+    {
+	//RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::BackupCalled\n\r"));    
+
+    //conn::TBURPartType eventType;
+    //conn::TBackupIncType incType;
+    TDriveList aDriveList;
+    
+    //RFileLogger::WriteFormat(KLogDir, KLogName, EFileLoggingModeAppend, _L8("backupevent: %d"), aBackupEvent);              
+    
+    // If there is no operation going or state is normal
+    // Delete the client and handler
+
+    if( aBackupEvent == conn::EBURUnset ||
+        aBackupEvent & conn::EBURNormal )
+        {
+        /*
+        if( aBackupEvent == conn::EBURUnset )
+            {
+            	        RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Unset\n\r"));                
+            }
+        else 
+            {
+	        RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Normal\n\r"));                
+            } 
+        */                 
+        if( iActiveBackupClient )
+            {
+            delete iActiveBackupClient;
+            iActiveBackupClient = NULL;    
+            }
+        
+        if( iBackupHandler )
+            {
+            delete iBackupHandler;
+            iBackupHandler = NULL;    
+            }
+        }  
+    else if( aBackupEvent & conn::EBURBackupFull ||
+             aBackupEvent & conn::EBURRestoreFull )
+        {
+	    //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Full\n\r"));         
+        // ab handler
+        iBackupHandler = CDRMBackup::NewL( iDb, iFs );
+    
+        // ab client
+        iActiveBackupClient = conn::CActiveBackupClient::NewL( iBackupHandler );
+        
+        // Confirm that we have done everything if there even was anything to do
+	    //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Confirm F \n\r"));         
+        iActiveBackupClient->ConfirmReadyForBURL( KErrNone );        
+        }
+    else if( aBackupEvent & conn::EBURBackupPartial ||
+             aBackupEvent & conn::EBURRestorePartial )
+        {
+	    //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Partial\n\r"));         
+        // ab handler
+        iBackupHandler = CDRMBackup::NewL( iDb, iFs );
+    
+        // ab client
+        iActiveBackupClient = conn::CActiveBackupClient::NewL( iBackupHandler );                
+
+        if( !iActiveBackupClient->DoesPartialBURAffectMeL() ) 
+            {
+	        //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::NotMe\n\r"));             
+            delete iActiveBackupClient;
+            iActiveBackupClient = NULL;    
+
+            delete iBackupHandler;
+            iBackupHandler = NULL;    
+            }
+        else
+            {
+	        //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Confirm P \n\r"));            
+            // Confirm that we have done everything if there even was anything to do
+            iActiveBackupClient->ConfirmReadyForBURL( KErrNone );
+	        //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Confirm P Done \n\r"));                             
+            }    
+        }
+    else 
+        {
+	    //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("Handle::Argument\n\r"));         
+        // Unknown operation
+        User::Leave(KErrArgument);    
+        }
+    };  
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::WatchedObjectChangedL
+// Handle Backup Events
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsServer::WatchedObjectChangedL( const TDesC& aObject )
+    {
+    DRMLOG( _L( "CDRMRightsServer::WatchedObjectChangedL ->" ) );
+    DRMLOG( aObject );
+    
+    if ( aObject.Left( KDirIdentifier().Length() ) == KDirIdentifier &&
+         !iDb->Updating() && iArmed )
+        {
+#ifdef _DEBUG
+        DRMLOG( _L( "RDB modified by outside party (DEBUG mode, not deleting the DB)" ) );
+#else
+        DRMLOG( _L( "RDB modified by outside party, deleting the DB" ) );
+        iDb->MarkAsCorrupted();
+        RStarterSession starter;
+        User::LeaveIfError( starter.Connect() );
+        starter.Reset( RStarterSession::EDRMReset );
+        starter.Close();
+#endif        
+        }
+    else if ( aObject.Left( KProcIdentifier().Length() ) == KProcIdentifier && iArmed )
+        {
+#ifdef _DEBUG
+        DRMLOG( _L( "Peer process killed (DEBUG mode, not rebooting)" ) );
+#else
+        DRMLOG( _L( "Peer process killed, rebooting" ) );
+        RStarterSession starter;
+        User::LeaveIfError( starter.Connect() );
+        starter.Reset( RStarterSession::EDRMReset );
+        starter.Close();
+#endif
+        }
+    
+    DRMLOG( _L( "CDRMRightsServer::WatchedObjectChangedL <-" ) );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::HasActiveCountConstraint
+// Check ID for active count constraint
+// -----------------------------------------------------------------------------
+//
+TBool CDRMRightsServer::HasActiveCountConstraint( const TDesC8& aContentId )
+    {
+    TInt i;
+    TBool r = EFalse;
+    
+    for ( i = 0; r == EFalse && i < iActiveCountConstraints.Count(); i++ )
+        {
+        if ( iActiveCountConstraints[i]->CompareF( aContentId ) == 0 )
+            {
+            r = ETrue;
+            }
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::RemoveActiveCountConstraint
+// Remove ID from count constraint list
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsServer::RemoveActiveCountConstraint( const TDesC8& aContentId )
+    {
+    TInt i;
+    TInt r = KErrNotFound;
+    HBufC8* id = NULL;
+    
+    for ( i = 0; r == KErrNotFound && i < iActiveCountConstraints.Count(); i++ )
+        {
+        if ( iActiveCountConstraints[i]->CompareF( aContentId ) == 0 )
+            {
+            r = i;
+            }
+        }
+    if ( r != KErrNotFound )
+        {
+        id = iActiveCountConstraints[r];	
+        iActiveCountConstraints.Remove( r );
+        delete id;
+        id = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::AddActiveCountConstraint
+// Add ID to count constraint list
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsServer::AddActiveCountConstraintL( const TDesC8& aContentId )
+    {
+    if ( !HasActiveCountConstraint( aContentId ) )
+        {
+        iActiveCountConstraints.AppendL( aContentId.AllocL() );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::StopWatchingL
+// Delete the watchers
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsServer::StopWatchingL()
+    {
+    iArmed = EFalse;
+    }
+
+#ifdef USE_RO_IMPORT
+// -----------------------------------------------------------------------------
+// CDRMRightsServer::ImportRightsObjectsL
+// Open the import directory and add all ROs that can be found there. ROs file
+// names must end with .dr. Only OMA DRM 1.0 ROs in XML format are supported for
+// security reasons
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsServer::ImportRightsObjectsL( const TDesC& aImportDir )
+    {
+    CDrmRightsParser* p;
+    HBufC8* d = NULL;
+    HBufC8* k = NULL;
+    RFs fs;
+    RFile file;
+    TInt size;
+    RPointerArray<CDRMRights> rights;
+    CDir* dir;
+    TFileName name;
+    TPtr8 ptr( NULL, 0 );
+    TInt i;
+    TInt r = KErrNone;
+    TCleanupItem listCleanup(PointerArrayResetDestroyAndClose<CDRMRights>,
+        &rights);
+    TDRMUniqueID id;
+    TTime time;
+    
+    DRMLOG( _L( "CDRMRightsServer::ImportRightsObjectsL" ) );
+    DRMLOG( aImportDir );
+    __UHEAP_MARK;
+    GetSecureTime( time );
+    p = CDrmRightsParser::NewL();
+    CleanupStack::PushL( p );
+    User::LeaveIfError( iFs.GetDir( aImportDir, KEntryAttNormal,
+        ESortNone, dir ) );
+    CleanupStack::PushL( dir );
+    for (i = 0; i < dir->Count(); i++)
+        {
+        name.Copy( aImportDir );
+        name.Append( (*dir)[i].iName );
+        if ( ( name.Length() > 3 && name.Right(3).CompareF( KDrSuffix ) == 0 ) )
+            {
+            User::LeaveIfError( file.Open( iFs, name, EFileRead ) );
+            CleanupClosePushL( file );
+            User::LeaveIfError( file.Size( size ) );
+            d = HBufC8::NewLC( size );
+            ptr.Set( d->Des() );
+            User::LeaveIfError( file.Read( ptr ) );
+            p->ParseL( ptr, rights );
+            if ( rights.Count() > 0 )
+                {
+                k = NULL;
+                CleanupStack::PushL( listCleanup );
+                CDRMPermission& permission = rights[0]->GetPermission();
+                CDRMAsset& asset = rights[0]->GetAsset();
+                
+                // Add RO only if no rights are available at all for this content
+                TRAP( r, k = iDb->GetDecryptionKeyL( *asset.iUid ) );
+                if (k == NULL )
+                    {
+                    iDb->AddDBEntryL( *asset.iUid, permission, asset.iKey, id );
+                    }
+                else
+                    {
+                    delete k;
+                    }
+                CleanupStack::PopAndDestroy(); // listCleanup
+                }
+            CleanupStack::PopAndDestroy( 2 ); // d, file
+            iFs.Delete( name );
+            }
+        }
+    CleanupStack::PopAndDestroy( 2 ); // dir, p
+    __UHEAP_MARKEND;
+    DRMLOG( _L( "CDRMRightsServer::ImportRightsObjectsL done" ) );
+    }
+#endif    
+    
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+
+TInt E32Main() 
+    {
+    return Startup(); 
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMServerStarter.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,167 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This file is used only if RDRMRightsClient starts the
+*                DRM Rights Database server. 
+*
+*/
+
+// INCLUDE FILES
+#include   <e32std.h>
+#include    <e32uid.h>
+#include <f32file.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "drmengineclientserver.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+#ifdef __WINS__
+LOCAL_C const TUint KServerMinHeapSize =  0x1000;  
+LOCAL_C const TUint KServerMaxHeapSize = 0x300000; 
+_LIT( KRightsServerFile, "RightsServer" );
+#else
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT( KRightsServerFile, "%c:\\RightsServer.exe" );
+#else
+_LIT( KRightsServerFile, "e:\\RightsServer.exe" );
+#endif
+#endif
+
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TInt CreateServer( void );
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CreateServer launches the DRM Rights server [process (THUMB/ARMI)|thread (WINS)]. 
+// Returns: KErrNone: No errors.
+//          <KErrNone: Symbian wide error code.
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt CreateServer( void )
+    {
+    TInt error = KErrNone;
+    
+        RProcess server;
+        
+#ifndef RD_MULTIPLE_DRIVE
+    
+        error = server.Create( KRightsServerFile, 
+                               KNullDesC );
+    
+#else //RD_MULTIPLE_DRIVE
+        
+        RFs fs;
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultMassStorage, driveNumber );
+        
+        error = fs.Connect();
+        if( error != KErrNone )
+            {
+            fs.Close();
+            return error;
+            }
+        
+        fs.DriveToChar( driveNumber, driveLetter );
+        fs.Close();
+	
+        TFileName rightsServerFile;
+        rightsServerFile.Format( KRightsServerFile, (TUint)driveLetter );
+    
+        error = server.Create( rightsServerFile, 
+                               KNullDesC );
+    
+#endif
+        
+        if ( !error )
+            {
+            // Give some time to the process to start.
+            User::After( 1000 );
+            
+        // Kick the server up & running.
+        server.Resume();
+            
+        // Local handle not needed anymore.
+        server.Close();
+        }
+        
+    return error;
+    }
+    
+// ============================ MEMBER FUNCTIONS ===============================
+    
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+    
+// -----------------------------------------------------------------------------
+// DRMServerStarter starts the actual server.
+// Returns: KErrNone: All went OK, no errors.
+//          <KErrNone: Symbian wide error code.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt DRMServerStarter()
+    {
+    RSemaphore semaphore;
+    TFindServer server( DRMEngine::KServerName );
+    TFullName name;
+    
+    // Check if the server is already running.
+    TInt error = server.Next( name );
+    
+    if ( !error )
+        {
+        // Yep, it's already running.
+        return KErrNone;
+        }
+
+    error = semaphore.CreateGlobal( DRMEngine::KDRMSemaphore,   // name
+                                    0 ,              // count
+                                    EOwnerThread ); // owner
+    
+    if ( error == KErrAlreadyExists )
+        {
+        error = semaphore.OpenGlobal( DRMEngine::KDRMSemaphore );
+        }
+        
+    if ( !error )
+        {
+        error = CreateServer();
+        if ( !error )
+            {
+            // Wait until server has done all its things.
+            semaphore.Wait();
+            
+            // Signal the (possible) next one waiting in line. Server
+            // only signals the semaphore once but there might be several
+            // clients waiting for this semaphore, in theory.
+            semaphore.Signal();
+            }
+        
+        // Semaphore can be destroyed.
+        semaphore.Close();
+        }
+        
+    return error; 
+    }
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/DRMXOma.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,343 @@
+/*
+* 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:  Datatype for the X-Oma header data
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <s32strm.h>
+#include "DRMXOma.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMXOma* CDRMXOma::NewLC( const TDesC8& aContentID,
+                           const TTime& aTimeStamp,
+                           const TTimeIntervalSeconds& aWaitTime )
+    {
+    CDRMXOma* self = new( ELeave ) CDRMXOma( aTimeStamp, aWaitTime );
+    CleanupStack::PushL( self );
+    self->ConstructL( aContentID );
+    
+    return self;    
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMXOma* CDRMXOma::NewL( const TDesC8& aContentID,
+                          const TTime& aTimeStamp,
+                          const TTimeIntervalSeconds& aWaitTime )
+    {
+    CDRMXOma* self = NewLC( aContentID, 
+                            aTimeStamp, aWaitTime );
+    CleanupStack::Pop();
+    
+    return self;
+    };        
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMXOma* CDRMXOma::NewLC()
+    {
+    CDRMXOma* self = new( ELeave ) CDRMXOma();
+    CleanupStack::PushL( self );
+    
+    return self;    
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMXOma* CDRMXOma::NewL()
+    {
+    CDRMXOma* self = NewLC();
+    CleanupStack::Pop();
+    
+    return self;
+    };          
+
+// -----------------------------------------------------------------------------
+// Default Constructor - First phase.
+// -----------------------------------------------------------------------------
+//
+CDRMXOma::CDRMXOma( const TTime& aTimeStamp, 
+                   const TTimeIntervalSeconds& aWaitTime ) :
+    iTimeStamp( aTimeStamp ),
+    iWaitTime( aWaitTime )
+    {
+    
+    }; 
+
+// -----------------------------------------------------------------------------
+// Default Constructor - First phase.
+// -----------------------------------------------------------------------------
+//
+CDRMXOma::CDRMXOma()
+    {
+    
+    }; 
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CDRMXOma::~CDRMXOma()
+    {
+    if( iContentID )
+        {
+        delete iContentID;
+        iContentID = NULL;
+        }        
+    };
+        
+        
+// -----------------------------------------------------------------------------
+// CDRMXOma::ContentID
+// -----------------------------------------------------------------------------
+//        
+const TDesC8& CDRMXOma::ContentID() const
+    {
+    return *iContentID;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::TimeStamp
+// -----------------------------------------------------------------------------
+//    
+const TTime& CDRMXOma::TimeStamp() const
+    {
+    return iTimeStamp;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::WaitTime
+// -----------------------------------------------------------------------------
+//    
+const TTimeIntervalSeconds& CDRMXOma::WaitTime() const
+    {
+    return iWaitTime;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::SetContentIDL
+// -----------------------------------------------------------------------------
+//         
+void CDRMXOma::SetContentIDL( const TDesC8& aContentID )
+    {
+    HBufC8* newContentID = aContentID.AllocL();
+    
+    if( iContentID )
+        {
+        delete iContentID;
+        iContentID = NULL;
+        }
+    iContentID = newContentID;    
+    };
+    
+// -----------------------------------------------------------------------------
+// CDRMXOma::SetTimeStampL
+// -----------------------------------------------------------------------------
+//         
+void CDRMXOma::SetTimeStampL( const TTime& aTimeStamp )
+    {
+    iTimeStamp = aTimeStamp;    
+    };    
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::SetWaitTimeL
+// -----------------------------------------------------------------------------
+//         
+void CDRMXOma::SetWaitTimeL( const TTimeIntervalSeconds& aWaitTime )
+    {
+    iWaitTime = aWaitTime;    
+    }; 
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::ExternalizeL
+// -----------------------------------------------------------------------------
+// 
+void CDRMXOma::ExternalizeL( RWriteStream& aStream ) const
+    {
+    TInt dataLength = 0;
+    
+    // Write the ContentID
+    dataLength = 0;
+    if( iContentID )
+        {
+        dataLength = iContentID->Length();
+        }
+    aStream.WriteInt32L( dataLength );
+    
+    if( dataLength )
+        {
+        aStream.WriteL( iContentID->Des() );        
+        }
+    
+    // Write the time stamp
+    WriteInt64L( iTimeStamp.Int64(), aStream );
+    
+    // write the wait time
+    aStream.WriteInt32L( iWaitTime.Int() );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::InternalizeL
+// -----------------------------------------------------------------------------
+// 
+void CDRMXOma::InternalizeL( RReadStream& aStream )
+    {
+    TInt64 timeData = 0;    
+    TInt dataLength = 0;
+    HBufC8* dataPart = 0;
+    TPtr8 dataBuffer(NULL,0,0);
+    TPtr16 dataBuffer2(NULL,0,0);
+    
+    // Read the ContentID
+    dataLength = aStream.ReadInt32L();
+    
+    if( dataLength )
+        {
+        // Reserve a new buffer:
+        dataPart = HBufC8::NewMaxLC( dataLength );
+        
+        // Set the read buffer:
+        dataBuffer.Set(const_cast<TUint8*>(dataPart->Ptr()), 0, dataLength);
+        
+        // Read the data:
+        aStream.ReadL( dataBuffer );
+        
+        // Pop the buffer 
+        CleanupStack::Pop(); // dataPart
+                
+        // If an old content identifier exists delete it        
+        if( iContentID )
+            {
+            delete iContentID;
+            iContentID = NULL;
+            }
+        
+        // assign the new content id
+        iContentID = dataPart;    
+        }
+    else
+        {
+        // If an old content identifier exists delete it 
+        if( iContentID )
+            {
+            delete iContentID;
+            iContentID = NULL;
+            }        
+        }           
+        
+    // The Time stamp
+    ReadInt64L( timeData, aStream );
+    iTimeStamp = timeData;    
+                   
+    // The time interval                
+    iWaitTime =  aStream.ReadInt32L();               
+    };   
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::Size
+// -----------------------------------------------------------------------------
+// 
+TInt CDRMXOma::Size() const
+    {
+    TInt size = 0;
+    
+    // Content identifier of the content
+    size += sizeof(TInt32);
+    
+    if( iContentID )
+        {
+        size += iContentID->Size();
+        }
+        
+    // Issuer of the rights
+    size += sizeof(TTime);
+        
+    // Content name
+    size += sizeof(TTimeIntervalSeconds);
+    
+    return size;
+    };    
+ 
+// -----------------------------------------------------------------------------
+// CDRMXOma::ConstructL
+// Second phase constructor
+// -----------------------------------------------------------------------------
+// 
+void CDRMXOma::ConstructL( const TDesC8& aContentID )
+    {
+    iContentID = aContentID.AllocL();
+    };                
+
+
+// -----------------------------------------------------------------------------
+// CDRMXOma::WriteInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMXOma::WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const
+    {
+    TPtr8 output( reinterpret_cast<TUint8*>(const_cast<TInt64*>(&aWrite)), 
+                  sizeof(TInt64), sizeof(TInt64) );
+        
+    aStream.WriteL( output, sizeof(TInt64) );
+    }
+
+// -----------------------------------------------------------------------------
+// CCDRMXOma::ReadInt64L
+// -----------------------------------------------------------------------------
+//
+void CDRMXOma::ReadInt64L( TInt64& aRead, RReadStream& aStream )
+    {
+    TPtr8 input( reinterpret_cast<TUint8*>(&aRead), 0, sizeof(TInt64) );
+    
+    aStream.ReadL( input, sizeof(TInt64) );    
+    };
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/drmconsume.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1138 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the class CDRMConsume.
+*
+*/
+
+
+// INCLUDE FILES
+#include "drmconsume.h"
+#include "drmenginetypedefs.h"
+#include "drmrightsdb.h"
+#include "drmrightsserver.h"
+#include "drmdbsession.h"
+#include "drmlog.h"
+#include "drmeventmodify.h"
+#include "drmnotifier.h"
+#ifdef RD_DRM_METERING
+#include "drmmeteringdb.h"
+#include "drmmeteringdbdata.h"
+#include "roapstorageclient.h"
+#include "drmricontext.h"
+#endif
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES
+// CONSTANTS
+// MACROS
+
+#define NOTIFIER static_cast< CDRMRightsServer* >( const_cast< CServer2* >( \
+           iSession.Server() ) )->Notifier()
+
+#define DB static_cast< CDRMRightsServer* >( const_cast< CServer2* >( \
+           iSession.Server() ) )->Database()
+           
+#define SECURETIME( a ) static_cast< CDRMRightsServer* >\
+           ( const_cast< CServer2* >( \
+           iSession.Server() ) )->GetSecureTime( a )
+           
+#define SERVER static_cast< CDRMRightsServer* >( const_cast< CServer2* >( \
+           iSession.Server() ) )
+           
+#ifdef RD_DRM_METERING
+#define METERINGDB static_cast< CDRMRightsServer* >( const_cast< CServer2* >( \
+           iSession.Server() ) )->MeteringDatabase() 
+#endif
+
+#define SETBIT( a, b ) ( a ) |= ( b )
+#define CLRBIT( a, b ) ( a ) &= ~( 0xff & b )
+#define ISSET( a, b ) ( ( a ) & ( b ) )
+
+// LOCAL CONSTANTS AND MACROS
+// Keeps track about modified permissions for UpdateDBL().
+//static const TUint8 KConsumeParentModified =   0x01;
+static const TUint8 KConsumeChildModified =    0x02;
+
+static const TUint8 KConsumeHasSecureTime =    0x08;
+
+// These keep track whether to decrease timed counters when consuming time
+// based stuff (iTimedCounts member). A used timed count bit is set to zero.
+// In the beginning all of these are set to one.
+//static const TUint8 KParentToplevelCount =     0x01;    
+//static const TUint8 KParentPermCount     =     0x02;
+static const TUint8 KChildToplevelCount  =     0x04;
+static const TUint8 KChildPermCount      =     0x08;
+
+static const TUint16 KConsumeDefaultTimer = 300; // 5mins
+
+// LOCAL FUNCTION PROTOTYPES
+static inline void PickSmaller( TTime& aFirst,
+                                const TTime& aSecond );
+
+// ============================= LOCAL FUNCTIONS ==========================
+
+// ------------------------------------------------------------------------
+// PickSmaller (overloaded)
+//
+// Set the smaller one to aFirst
+// ------------------------------------------------------------------------
+//
+void PickSmaller( TTime& aFirst,
+                  const TTime& aSecond )
+    {
+    if ( aSecond < aFirst )
+        {
+        aFirst = aSecond;
+        }
+    }
+    
+// ------------------------------------------------------------------------
+// PickSmaller (overloaded)
+//
+// Set the smaller one to aFirst
+// ------------------------------------------------------------------------
+//
+void PickSmaller( TTimeIntervalSeconds& aFirst,
+                  const TTimeIntervalSeconds& aSecond )
+    {
+    if ( aSecond < aFirst )
+        {
+        aFirst = aSecond;
+        }
+    }
+    
+// ============================ MEMBER FUNCTIONS ==========================
+
+// ------------------------------------------------------------------------
+// CDRMConsume::NewLC
+// ------------------------------------------------------------------------
+//
+CDRMConsume* CDRMConsume::NewLC( CDRMDbSession& aSession,
+                                 const TDesC8& aURI,
+                                 const TDesC8* aParentId )
+    {
+    DRMLOG( _L( "CDRMConsume::NewLC" ) );
+    CDRMConsume* self = new( ELeave ) CDRMConsume( aSession );
+    
+    CleanupStack::PushL( self );
+    
+    self->ConstructL( aURI, aParentId );
+    
+    DRMLOG( _L( "CDRMConsume::NewLC ok" ) );
+    return self;    
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::~CDRMConsume
+// ------------------------------------------------------------------------
+//
+CDRMConsume::~CDRMConsume()
+    {
+    DRMLOG( _L( "CDRMConsume::~" ) );
+    TInt error( KErrNone );
+    
+    if( IsActive() ) 
+        {
+        Cancel();        
+        }
+    else
+        {
+        TRAP( error, DoCancelL() );
+        }
+    #ifdef RD_DRM_METERING
+        // Update metering count and metering accumulated time to the database.
+        TRAP( error, UpdateMeteringDbL() );
+    #endif
+    // ignore errors
+    //TRAP( error, UpdateDBL() );
+    
+    delete iURI; iURI = NULL;
+    delete iParentId; iParentId = NULL;
+    delete iChild; iChild = NULL;
+    delete iCombined; iCombined = NULL;
+    DRMLOG( _L( "CDRMConsume::~ ok" ) );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::CDRMConsume
+//
+// The internal state members iTimedCounts and iCounters are by default
+// set to 00001111b, and the appropriate bits are lowered when something
+// changes.
+// ------------------------------------------------------------------------
+//
+CDRMConsume::CDRMConsume( CDRMDbSession& aSession ):
+    CTimer( EPriorityHigh ),
+    iSession( aSession ),
+    iIntent( ContentAccess::EUnknown ),
+    iURI( NULL ),
+    iParentId( NULL ),
+    iTimedCounts( 0xf ),
+    iCounters( 0xf ),
+    iCountConstraintActive( EFalse ),
+    iExpired( EFalse ),
+    iCumulativeDelayTop( 0 ),
+    iCumulativeDelayChild( 0 ),
+    iTotalCumulativeTime( 0 ),
+	iUsingTimedCount( 0 )
+    {
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::ConstructL
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::ConstructL( const TDesC8& aURI,
+                              const TDesC8* aParentId )
+    {
+    DRMLOG( _L( "CDRMConsume::ConstructL" ) );
+    CTimer::ConstructL();
+    iURI = aURI.AllocL();
+    if( aParentId )
+        {
+        iParentId = aParentId->AllocL();        
+        }
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::HandleL
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::HandleL( ContentAccess::TIntent aIntent )
+    {
+    DRMLOG( _L( "CDRMConsume::HandleL" ) );
+    
+    TTime time;
+    TBool secure( SECURETIME( time ) );
+    InitializeL( aIntent, secure, time );
+    
+    DRMLOG( _L( "CDRMConsume::HandleL ok" ) );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume:: Pause
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::Pause()
+    {
+    DRMLOG( _L( "CDRMConsume::Pause" ) );
+    
+    Cancel();
+    
+    DRMLOG( _L( "CDRMConsume::Pause ok" ) );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume:: ContinueL
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::ContinueL()
+    {
+    DRMLOG( _L( "CDRMConsume::ContinueL" ) );
+    
+    Cancel();
+    
+    TInt error = KErrNone;
+    TUint32 reason = 0;
+                    
+    CDRMPermission* child = NULL;
+    HBufC8* parent = NULL;
+    
+    // This got removed by Pause()
+    if( iCountConstraintActive )
+        {
+        SERVER->AddActiveCountConstraintL( *iURI );
+        DoContinueL();
+        return;
+        }
+    
+    /* Fetch the RO again in order to manage a situation when another 
+       instance has used the same RO (content has been consumed) while the
+       other instance has not been used (player is paused) but will be 
+       used again (content consumption is to be continued). */   
+    error = iSession.FindRightsObject( iIntent, *iURI, child, parent, reason );
+    
+    /* Check if the RO found from the database matches with the one that was used
+       in the original consumption of the content. If the ROs match, use the
+       (possibly updated) one from the database. */
+    if ( !error && child && iChild && 
+         ( iChild->iUniqueID == child->iUniqueID ) &&
+         ( iChild->iOriginalInsertTime == child->iOriginalInsertTime ) )
+        {
+        if ( iParentId )
+            {
+            delete iParentId; 
+            iParentId = parent;
+            }
+            
+        delete iChild;
+        iChild = child;
+        }      
+    else 
+        {
+        /* The original RO was not found. Delete temporary objects and also
+           delete the iChild and iCombined because the RO is no longer valid and
+           need to be re-fetched using InitializeL method (in DoContinueL).   
+           (in DoContinueL). */  
+        if ( iChild )
+            {
+            delete iChild;
+            iChild = NULL;
+            }
+        
+        if ( iCombined )
+            {
+            delete iCombined;
+            iCombined = NULL;
+            }
+        
+        if ( child ) 
+            {
+            delete child;
+            child = NULL;
+            }
+        if ( parent )
+            {
+            delete parent;
+            parent = NULL;
+            }
+        } 
+          
+    DoContinueL();
+    
+    //HandleL( iIntent );
+    
+    DRMLOG( _L( "CDRMConsume::ContinueL ok" ) );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume:: Stop
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::Stop()
+    {
+    DRMLOG( _L( "CDRMConsume::Stop" ) );
+    
+    Cancel();
+    
+    DRMLOG( _L( "CDRMConsume::Stop ok" ) );
+    }   
+
+// ------------------------------------------------------------------------
+// CDRMConsume:: ActivateL
+//
+// Calculate the smallest end time based on interval, end time, 
+// accumulated time & timed count.
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::ActivateL( TBool aSecureTime,
+                             const TTime& aTrustedTime  )
+    {
+    DRMLOG( _L( "CDRMConsume::ActivateL" ) );
+    
+    __ASSERT_DEBUG( iChild && iCombined, User::Invariant() );
+    TTime endTime( Time::MaxTTime() );
+    TTimeIntervalSeconds timed( KMaxTInt32 );
+    TBool timeUsed( EFalse );
+    TBool endTimeUsed( EFalse );
+    
+    iCurrentDelay = 0;
+    
+    if ( iCombined->iActiveConstraints & EConstraintTimedCounter )
+        {
+        // Take this, even if timed counts have been updated. 
+        // This might cause unnecessary RunL's to be called, but it 
+        // ensures both child & parent will be consumed when needed.
+        // If e.g. it would be checked that iTimedCounts == 0xf, 
+        // either one (child or parent) might not get updated in case of
+        // "Child expired, but parent didn't -> find new child".        
+        PickSmaller( timed, iCombined->iTimedInterval );
+        timeUsed = ETrue;
+        }
+    
+    if ( iCombined->iActiveConstraints & EConstraintAccumulated )
+        {
+        PickSmaller( timed, iCombined->iAccumulatedTime );
+        timeUsed = ETrue;
+        }
+        
+    if ( iCombined->iActiveConstraints & EConstraintInterval )
+        {
+        if ( iCombined->iIntervalStart != Time::NullTTime() )
+            {
+            endTime = iCombined->iIntervalStart;
+            endTime += iCombined->iInterval;
+            endTimeUsed = ETrue;
+            }
+        else
+            {
+            TInt64 tmp( iCombined->iInterval.Int() );
+            
+            PickSmaller( timed, tmp );
+            timeUsed = ETrue;
+            }
+        }
+     
+    if ( iCombined->iActiveConstraints & EConstraintEndTime )
+        {
+        PickSmaller( endTime, iCombined->iEndTime );
+        endTimeUsed = ETrue;
+        }
+        
+    // Put the "smallest time" information to "endTime".
+    if ( timeUsed )
+        {
+        TTime current( aTrustedTime );
+        
+        current += timed;
+        
+        PickSmaller( endTime, current );
+        endTimeUsed = ETrue;
+        }
+        
+     // Interval gets initialised immediately, and so do count constraints.
+     // Timed/accumulated won't: those are consumed after the 
+     // interval if secure time exists.
+     Consume( ETrue, ETrue, EFalse, 0,
+              aSecureTime,
+              aTrustedTime );
+    
+     // In case something was modified, update the db also.
+     UpdateDBL();
+              
+     if ( endTimeUsed )
+        {     
+        // Something exists.
+        TTimeIntervalSeconds secs( 0 );
+        TTime current( aTrustedTime );
+        TInt err( KErrNone );
+        
+        // SecondsFrom returns an error if the difference is too great.
+        err = endTime.SecondsFrom( current, secs );
+        if ( err )
+            {
+            iCurrentDelay = KConsumeDefaultTimer;
+            }
+        else if ( secs.Int() < 0 )
+            {
+            iCurrentDelay = 0; // Already expired.
+            }
+        else if ( secs.Int() < KConsumeDefaultTimer )
+            {
+            iCurrentDelay = secs.Int();
+            }
+        else
+            {
+            iCurrentDelay = KConsumeDefaultTimer;
+            }
+           
+        if ( !IsAdded() )
+            {
+            CActiveScheduler::Add( this );
+            }
+        
+        DRMLOG2( _L( "CDRMConsume::ActivateL: using interval %d" ), 
+                  ( TInt )iCurrentDelay );
+                  
+        // secs -> microsecs. The method sets the AO active.
+        After( TTimeIntervalMicroSeconds32( iCurrentDelay * 1000000 ) );
+        
+        iTime = current;
+      
+        // If we see timed things here, we also have secure time.  
+        //SETBIT( iMask, KConsumeHasSecureTime );
+        }
+    else    // For metering we always need to have this:
+        {
+        iCurrentDelay = KConsumeDefaultTimer;
+        iTime = aTrustedTime;
+ 
+        if ( !IsAdded() )
+            {
+            CActiveScheduler::Add( this );
+            }
+                
+        DRMLOG2( _L( "CDRMConsume::ActivateL: using interval %d" ), 
+                  ( TInt )iCurrentDelay );
+                  
+        // secs -> microsecs. The method sets the AO active.
+        After( TTimeIntervalMicroSeconds32( iCurrentDelay * 1000000 ) );              
+        }    
+        
+    // If we see timed things here, we also have secure time.  
+    if( aTrustedTime != Time::NullTTime())
+        {
+        SETBIT( iMask, KConsumeHasSecureTime );        
+        }      
+    DRMLOG( _L( "CDRMConsume::ActivateL ok" ) );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume:: Consume
+//
+// Consume child & parent. Whether to consume parent's explicit
+// usage permission: the information is returned earlier by 
+// FindRightsObjectL.
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::Consume( TBool aUpdateCounter,
+                           TBool aInitInterval,
+                           TBool aUpdateTimedCount,
+                           const TTimeIntervalSeconds& aElapsedTime,
+                           TBool aSecureTime,
+                           const TTime& aTrustedTime )
+    {
+    DRMLOG( _L( "CDRMConsume::Consume" ) );
+    
+    __ASSERT_DEBUG( iChild && iCombined, User::Invariant() );
+    
+    // Decrease timed counters & regular counters only once.
+    // In the beginning the bitmasks are both 0xF.     
+    if ( iChild->TopLevelConstraint() )
+        {
+        if ( ConsumeConstraint( *( iChild->TopLevelConstraint() ),
+                                ( aUpdateCounter && 
+                                  ISSET( iCounters, KChildToplevelCount ) ),
+                                aInitInterval,
+                                ( aUpdateTimedCount && 
+                                  ISSET( iTimedCounts, 
+                                         KChildToplevelCount ) ),
+                                aElapsedTime,
+                                aSecureTime, 
+                                aTrustedTime,
+                                iCumulativeDelayTop ) )
+            {
+            SETBIT( iMask, KConsumeChildModified );
+            if ( aUpdateTimedCount )
+                {
+                CLRBIT( iTimedCounts, KChildToplevelCount );
+                }
+            if ( aUpdateCounter )
+                {
+                CLRBIT( iCounters, KChildToplevelCount );
+                }
+            }
+        }
+        
+    if ( ConsumeConstraint( *( iChild->ConstraintForIntent( iIntent ) ),
+                            ( aUpdateCounter && 
+                              ISSET( iCounters, KChildPermCount ) ),
+                            aInitInterval,
+                            ( aUpdateTimedCount && 
+                              ISSET( iTimedCounts, KChildPermCount ) ),
+                            aElapsedTime,
+                            aSecureTime,
+                            aTrustedTime,
+                            iCumulativeDelayChild ) )
+        {
+        SETBIT( iMask, KConsumeChildModified );
+        if ( aUpdateTimedCount )
+            {
+            CLRBIT( iTimedCounts, KChildPermCount );
+            }
+        if ( aUpdateCounter )
+            {
+            CLRBIT( iCounters, KChildPermCount );
+            }
+        }
+    
+    DRMLOG( _L( "CDRMConsume::Consume ok" ) );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::RunL
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::RunL()
+    {
+    DRMLOG2( _L( "CDRMConsume::RunL with %d" ), iStatus.Int() );
+    
+    switch ( iStatus.Int() )
+        {
+        case KErrNone:
+            // Normal completition.
+            
+        case KErrUnderflow:
+            // Time already passed.
+            
+        case KErrAbort:
+            // System time changed ==> consume.
+            DoContinueL();
+            break;
+
+        default:
+            // Some other (real) error.
+            // Handled in RunError.
+            User::Leave( iStatus.Int() );
+        };
+        
+    DRMLOG( _L( "CDRMConsume::RunL ok" ) );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::RunError
+// ------------------------------------------------------------------------
+//
+#if defined( _DEBUG ) || defined( _LOGGING )
+TInt CDRMConsume::RunError( TInt aError )
+#else
+TInt CDRMConsume::RunError( TInt /* aError */ )
+#endif
+    {
+    DRMLOG2( _L( "CDRMConsume::RunError: %d" ), aError );
+     
+    Deque();
+    
+    DRMLOG( _L( "CDRMConsume::RunError ok" ) );
+    return 0;
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::DoCancel
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::DoCancel()
+    {
+    DRMLOG( _L( "CDRMConsume::DoCancel" ) );
+    
+    TInt error( KErrNone );
+    TRAP( error, DoCancelL() );
+    
+    DRMLOG2( _L( "CDRMConsume::DoCancel: %d" ), error );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::DoCancelL
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::DoCancelL()
+    {
+    DRMLOG( _L( "CDRMConsume::DoCancelL" ) );
+    
+    if ( iCurrentDelay )
+        {
+        TTimeIntervalSeconds secs;
+        TTime trustedTime;
+        TBool secureTime;
+                        
+        CTimer::DoCancel();
+                
+        secureTime = SECURETIME( trustedTime );
+        trustedTime.SecondsFrom( iTime, secs );
+        
+        #ifdef RD_DRM_METERING
+            // Update total cumulative time for content metering purposes
+            iTotalCumulativeTime = iTotalCumulativeTime.Int() + secs.Int();
+        #endif
+             
+        // If the top level timed counter has not been activated yet
+        // increment the counter
+        if( ISSET( iTimedCounts, KChildToplevelCount ) )
+            {
+            iCumulativeDelayTop = iCumulativeDelayTop.Int() + secs.Int();            
+            }
+
+        // If the child timed counter has not been activated yet
+        // increment the counter            
+        if( ISSET( iTimedCounts, KChildPermCount ) )
+            {
+            iCumulativeDelayChild = iCumulativeDelayChild.Int() + secs.Int();
+            }
+            
+        // Always >= 0.
+        ConsumeTimedItemsL( secs,
+                            secureTime, 
+                            trustedTime );
+        iCurrentDelay = 0;
+        }
+    
+    UpdateDBL();
+    
+    if ( SERVER->HasActiveCountConstraint( *iURI ) )
+        {
+        SERVER->RemoveActiveCountConstraint( *iURI );
+        }
+    
+    DRMLOG( _L( "CDRMConsume::DoCancel ok" ) );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::CombinePermissionsL
+//
+// Combine iChild's & iParent's top level constraints, and merge the usage
+// intention constraint (either one of them).
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::CombinePermissionsL()
+    {
+    DRMLOG( _L( "CDRMConsume::CombinePermissions" ) );
+    
+    __ASSERT_DEBUG( iChild, User::Invariant() );
+    
+    // Reset
+    delete iCombined; iCombined = NULL;
+    iCombined = CDRMConstraint::NewL();
+    
+    if ( iChild->TopLevelConstraint() )
+        {
+        iCombined->Merge( *( iChild->TopLevelConstraint() ) );
+        }
+        
+    iCombined->Merge( *( iChild->ConstraintForIntent( iIntent ) ) );
+    
+    DRMLOG( _L( "CDRMConsume::CombinePermissions ok" ) );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::UpdateDBL
+//
+// Update the DB if something was changed.
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::UpdateDBL()
+    {
+    DRMLOG( _L( "CDRMConsume::UpdateDBL" ) );
+    // __ASSERT_DEBUG( iChild, User::Invariant() );
+        
+    CDRMEventModify* event = NULL;
+    TRequestStatus status;
+        
+    if( ISSET( iMask, KConsumeChildModified ) ) 
+        {
+        event = CDRMEventModify::NewL();
+        }
+    CleanupStack::PushL( event );    
+
+    if ( ISSET( iMask, KConsumeChildModified ) )
+        {
+        DRMLOG( _L( "CDRMConsume: commiting child to DB" ) );
+        
+        if( iParentId )
+            {
+            DB.UpdateDBEntryL( *iParentId, *iChild );
+            // Notify
+            event->SetContentIDL(*iParentId);
+            event->SetUniqueID(iChild->iUniqueID);
+            }
+        else
+            {
+            DB.UpdateDBEntryL( *iURI, *iChild );            
+            // Notify
+            event->SetContentIDL(*iURI);
+            event->SetUniqueID(iChild->iUniqueID);
+            }    
+        
+        // Notify
+        event->SetContentIDL(*iURI);
+        event->SetUniqueID(iChild->iUniqueID);
+        
+        NOTIFIER.SendEventL(*event,status);
+        User::WaitForRequest(status);           
+        
+        CLRBIT( iMask, KConsumeChildModified );
+        }
+    
+    CleanupStack::PopAndDestroy();    
+    DRMLOG( _L( "CDRMConsume::UpdateDBL ok" ) );
+    }
+// ------------------------------------------------------------------------
+// CDRMConsume::ConsumeConstraint
+//
+// Consume child & parent. Whether to consume parent's explicit
+// usage permission: the information is returned earlier by 
+// FindRightsObjectL.
+// ------------------------------------------------------------------------
+//
+TBool CDRMConsume::ConsumeConstraint( CDRMConstraint& aConstraint,
+                                      TBool aUpdateCounter,
+                                      TBool aInitInterval,
+                                      TBool aUpdateTimedCount,
+                                      const TTimeIntervalSeconds& aElapsedTime,
+                                      TBool aSecureTime,
+                                      const TTime& aTrustedTime,
+                                      TTimeIntervalSeconds& aCumulativeTime )
+    {
+    DRMLOG( _L( "CDRMConsume::ConsumeConstraints" ) );
+    
+    TBool res( EFalse );
+    
+    if ( aUpdateCounter && 
+         ( aConstraint.iActiveConstraints & EConstraintCounter ) )
+        {
+        --( aConstraint.iCounter);
+        res = ETrue;
+        iCountConstraintActive = ETrue;
+        TRAP_IGNORE( SERVER->AddActiveCountConstraintL( *iURI ) ); 
+        }
+        
+    if ( aInitInterval &&
+         ( aConstraint.iActiveConstraints & EConstraintInterval ) &&
+         aSecureTime &&
+         aConstraint.iIntervalStart == Time::NullTTime() )
+        {
+        aConstraint.iIntervalStart = aTrustedTime;
+        res = ETrue;
+        }
+        
+    /* change to timed counter, we don't check the latest time, we check the
+    cumulated time */    
+        
+    if ( aUpdateTimedCount &&
+         ( aConstraint.iActiveConstraints & EConstraintTimedCounter &&
+           ( aCumulativeTime >= aConstraint.iTimedInterval ||
+             aElapsedTime >= aConstraint.iTimedInterval  ) ) )
+        {
+        --( aConstraint.iTimedCounter );
+        res = ETrue;
+        iCountConstraintActive = ETrue;
+        TRAP_IGNORE( SERVER->AddActiveCountConstraintL( *iURI ) ); 
+        aCumulativeTime = TTimeIntervalSeconds( 0 );
+        }
+    else if ( aUpdateTimedCount &&
+         ( aConstraint.iActiveConstraints & EConstraintTimedCounter ) )
+        {
+        iUsingTimedCount = ETrue;
+        }
+        
+    
+    if ( aElapsedTime.Int() != 0 &&
+         ( aConstraint.iActiveConstraints & EConstraintAccumulated ) )
+        {
+        __ASSERT_DEBUG( aElapsedTime.Int() > 0, User::Invariant() );
+        
+        if ( aConstraint.iAccumulatedTime < aElapsedTime )
+            {
+            aConstraint.iAccumulatedTime = 0;
+            }
+        else
+            {
+            aConstraint.iAccumulatedTime = aConstraint.iAccumulatedTime.Int() - 
+            	aElapsedTime.Int();
+            }
+        
+        res = ETrue;
+        }
+        
+    if ( !iCountConstraintActive && aConstraint.Expired( aTrustedTime ) )
+        {
+        iExpired = ETrue;
+        }
+    else
+        {
+        iExpired = EFalse;
+        }
+    
+    DRMLOG2( 
+        _L( "CDRMConsume::ConsumeConstraints ok, returning %d" ), 
+        ( TInt )res );
+        
+    return res;
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::ConsumeTimedItemsL
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::ConsumeTimedItemsL( TTimeIntervalSeconds aDelay,
+                                      TBool aSecureTime,
+                                      const TTime& aTrustedTime )
+    {
+    DRMLOG( _L( "CDRMConsume::ConsumeTimedItemsL" ) );
+    
+    // Update accumulated constraints & timed count.
+    Consume( EFalse,
+             ETrue,
+             ETrue,
+             aDelay,
+             aSecureTime,
+             aTrustedTime );
+    
+    DRMLOG( _L( "CDRMConsume::ConsumeTimedItems ok" ) );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::DoContinueL
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::DoContinueL()
+    {
+    DRMLOG( _L( "CDRMConsume::DoContinueL" ) );
+    
+    TTime time;
+    TBool secureTime( EFalse );
+    secureTime = SECURETIME( time );
+    
+    if ( !iChild || !iCombined )
+        {
+        InitializeL( iIntent, secureTime, time );
+        // User::Leave( KErrCANoRights );
+        return;
+        }
+   
+    ConsumeTimedItemsL( iCurrentDelay, secureTime, time );
+    UpdateDBL();
+    iCurrentDelay = 0;
+    
+    CombinePermissionsL();
+    
+    // If the content has expired, find new permissions, unless the expired
+    // constraint was a timed count. In that case, the constraint
+    // did not really expire.
+    if ( SecurityLevelChanged( secureTime ) ||
+         ( iCombined->Expired( time ) && 
+           !SERVER->HasActiveCountConstraint( *iURI ) ) )
+        {
+        InitializeL( iIntent, secureTime, time );
+        }
+    else
+        {
+        ActivateL( secureTime, time );
+        }
+        
+    DRMLOG( _L( "CDRMConsume::DoContinueL ok" ) );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::SecurityLevelChanged
+// ------------------------------------------------------------------------
+//
+TBool CDRMConsume::SecurityLevelChanged( TBool aSecureTime ) const
+    {
+    DRMLOG( _L( "CDRMConsume::SecurityLevelChanged" ) );
+    
+    if ( ( ISSET( iMask, KConsumeHasSecureTime ) && aSecureTime ) ||
+         !( ISSET( iMask, KConsumeHasSecureTime ) || aSecureTime ) )
+        {
+        return EFalse;
+        }
+        
+    return ETrue;
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::InitializeL
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::InitializeL( ContentAccess::TIntent aIntent,
+                               TBool aSecureTime,
+                               const TTime& aTrustedTime )
+    {
+    DRMLOG( _L( "CDRMConsume::InitializeL" ) );
+    
+    // aIntent is either EPlay, EView, EExecute or EPrint.
+    // Store the old  consumption information in case this is 
+    // called in case of "ran out of permissions, find new ones"
+    CDRMPermission* child( iChild );
+    TUint8 timedCounts( iTimedCounts );
+    TUint8 counters( iCounters );
+    TUint32 reason = 0;
+    
+    // Reset.
+    iTimedCounts = 0xf;
+    iCounters = 0xf;
+    iMask = 0x0;
+    iCurrentDelay = 0;
+    
+    iExpired = ETrue;
+    
+    delete iCombined; iCombined = NULL;
+    
+    // Previous child & parent need to be stored in case the internal 
+    // counter states need to be restored.
+    if ( child )
+        {
+        CleanupStack::PushL( child );
+        iChild = NULL;
+        }
+    
+    // If the next call won't leave, we have permissions.
+    User::LeaveIfError( iSession.FindRightsObject( aIntent, 
+                                                   *iURI,
+                                                   iChild,
+                                                   iParentId,
+                                                   reason ) );
+                                
+    User::LeaveIfError( iSession.VerifyCredentials( iURI, iChild, aIntent ) );
+                                
+    iExpired = EFalse;
+
+    // Check whether to restore the internal state.
+    if ( iIntent == aIntent ) 
+        {
+        if ( child && 
+             ( child->iUniqueID == iChild->iUniqueID ) )
+            {
+            DRMLOG( _L( "CDRMConsume: using the previous child" ) );
+            
+            CLRBIT( iTimedCounts, 
+                    ( KChildToplevelCount | KChildPermCount ) & ~timedCounts );
+                    
+            CLRBIT( iCounters,
+                    ( KChildToplevelCount | KChildPermCount ) & ~counters );
+            }
+        }
+    
+    if ( child )
+        {
+        CleanupStack::PopAndDestroy();
+        }
+    
+    iIntent = aIntent;
+    
+    CombinePermissionsL();
+    ActivateL( aSecureTime, aTrustedTime );
+
+    DRMLOG( _L( "CDRMConsume::InitializeL ok" ) );
+    }
+    
+// ------------------------------------------------------------------------
+// CDRMConsume::CountConstraintActive
+// ------------------------------------------------------------------------
+//
+TBool CDRMConsume::CountConstraintActive()
+    {
+    return iCountConstraintActive || SERVER->HasActiveCountConstraint( *iURI );
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::IsExpired
+// ------------------------------------------------------------------------
+//
+TBool CDRMConsume::IsExpired()
+    {
+    return iExpired;
+    }
+
+// ------------------------------------------------------------------------
+// CDRMConsume::GetChild
+// ------------------------------------------------------------------------
+//
+CDRMPermission& CDRMConsume::GetChild()
+    {
+    return *iChild;
+    }
+
+#ifdef RD_DRM_METERING
+
+// ------------------------------------------------------------------------
+// CDRMConsume::UpdateMeteringDbL
+// ------------------------------------------------------------------------
+//
+void CDRMConsume::UpdateMeteringDbL()
+    {
+    DRMLOG( _L( "CDRMConsume::UpdateMeteringDbL" ) ); 
+    TTimeIntervalSeconds graceTime = 0;
+    CDRMConstraint* constraint = NULL;
+             
+    if ( iChild )
+        {
+        constraint = iChild->ConstraintForIntent( iIntent ); 
+        if ( constraint && constraint->iDrmMeteringInfo )  
+            { 
+            
+            graceTime = constraint->iDrmMeteringInfo->iGraceTime;
+            
+            // Grace time exceeded, increase metering count and metering 
+            // accumulated time    
+            if ( iTotalCumulativeTime >= graceTime )  
+                {
+                // Check Rights Issuer rights from Roap storage
+                if ( !CheckRiContextRightsL( iChild->iRiId ) )    
+                    {
+                    return;
+                    }
+                
+                // Update database only if Rights Issuer Id is available
+                if ( ( iChild->iRiId.Length() > 0 ) && 
+                     ( iChild->iRiId.Length() <= KRiIdSize ) ) 
+                    {
+                    
+                    if ( iURI )
+                        {
+                        CDrmMeteringDbData* meteringData = 
+                            CDrmMeteringDbData::NewLC();
+                        meteringData->iContentId = iURI->AllocL();
+                        meteringData->iRiId = iChild->iRiId; 
+                        if( iUsingTimedCount && !iCountConstraintActive ) 
+                            {
+                            meteringData->iCount = 0;                            
+                            }
+                        else
+                            {
+                        meteringData->iCount = 1;
+                            }
+                            
+                        meteringData->iAccumulatedTime = iTotalCumulativeTime;
+                        
+                        if ( iParentId ) 
+                            {
+                            meteringData->iParentUid = iParentId->AllocL();
+                            }
+                 
+                        METERINGDB.AddL( meteringData );
+                        CleanupStack::PopAndDestroy(); // meteringData
+                        }            
+                    }
+                } 
+            }             
+        }
+        DRMLOG( _L( "CDRMConsume::UpdateMeteringDbL ok" ) );
+    }
+    
+// ------------------------------------------------------------------------
+// CDRMConsume::CheckRiContextRightsL
+// ------------------------------------------------------------------------
+//
+
+TBool CDRMConsume::CheckRiContextRightsL( const TDesC8& aRiId )
+    {
+    
+    DRMLOG( _L( "CDRMConsume::CheckRiContextRightsL" ) );
+    
+    CDRMRIContext* riContext = NULL;
+    TBool haveRights = EFalse; 
+  
+    // Connect to the storage of the registered Rights Issuers 
+    
+    if( iSession.ConnectRoapClient() == KErrNone )
+        {
+    riContext = iSession.RoapClient().GetRIContextL( aRiId );
+     
+    if ( riContext == NULL )
+        {
+        DRMLOG( _L ( "RI not registered" ) );
+        User::Leave( KErrRightsServerRiNotRegistered );
+        }
+        
+    // Check (via the Rights Issuer context) whether Rights Issuer 
+    // is allowed to use metering or not
+    if ( riContext->IsMeteringAllowed() )
+        {
+        haveRights = ETrue;
+        }
+        
+    if ( riContext ) 
+        {
+        delete riContext;
+        riContext = NULL;    
+        }
+        }
+        
+    return haveRights;
+    
+    }
+
+#endif
+
+// EOF
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/drmcrypto.c	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,687 @@
+/*
+* Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRM Crypto functionality
+*
+*/
+
+
+
+/*
+
+            DRMCrypto
+            --------------------------
+
+            SW module - ANSI C
+
+Location:           -
+
+Filename:           drmcrypto.c
+
+Document code:      -
+
+/* ------------------------------------------------------------------------- */
+
+/*  1    ABSTRACT
+    1.1    Module type
+    1.2    Functional description
+    1.3    Notes
+
+    2    CONTENTS
+
+    3    GLOSSARY
+
+    4    REFERENCES
+
+    5    EXTERNAL RESOURCES
+    5.1    Mandatory include files
+    5.2    Library include files
+    5.3    Interface include files
+
+    6    LOCAL DEFINITIONS
+    6.1    Local include files
+    6.2    Local constants
+    6.3    Local macros
+    6.3.1    dummy_message_type
+    6.3.2    generate_connection_address
+    6.4    Local data types
+    6.5    Local data structures
+    6.6    Local function prototypes
+
+    7    MODULE CODE
+    7.1     DRMCrypto_Encrypt
+	7.2	    DRMCrypto_Decrypt
+	7.3		DRMCrypto_EncryptRightsDb
+	7.4		DRMCrypto_DecryptRightsVDb
+	7.5		DRMCrypto_AddPadding
+	7.6		DRMCrypto_RemovePadding
+	7.7		DRMCrypto_GenerateKey
+	7.8		DRMCrypto_GenerateIV
+
+
+
+
+
+*/
+
+
+/*  3    GLOSSARY
+		 -
+*/
+
+/*  4    REFERENCES
+
+    Specification reference
+
+    DRM Engine Crypto Interface Specification
+
+
+    Design reference
+
+    -
+
+    Module test specification reference
+
+    -
+*/
+#ifndef C_DRMCRYPTO_CFILE
+#define C_DRMCRYPTO_CFILE
+
+/*  5    EXTERNAL RESOURCES */
+
+/*  5.1    Mandatory include files */
+
+/*  5.2    Library include files */
+
+/*  5.3    Interface include files */
+#include "drmcrypto.h"
+#include "drmenv.h" /* for DRMEnv_GetRandom */
+
+/*  6    LOCAL DEFINITIONS */
+
+/*  6.1    Local include files */
+
+#include "aes_if.h"
+
+/*  6.2    Local constants */
+#define	KEYSEED_NUMBER_OF_INT32		4
+#define KEYSEED_LENGTH				16
+/*  6.3    Local macros */
+
+/*  6.4    Local data types */
+
+/*  6.5    Local data structures */
+
+/*  6.6    Local function prototypes */
+
+/*  7    MODULE CODE */
+
+
+/* ========================================================================= */
+
+/*  7.1 */
+
+/* Functional description
+ *
+ * Encrypt data using specified algorithm
+ *
+ *
+ * Parameters
+ *
+ * Cipher type
+ *
+ cType
+ *
+ * Pointer to encryption key
+ *
+ pszKey
+ *
+ * Encryption key length in bytes
+ *
+ iKeyLen
+ *
+ * Pointer to initializer vector of encryption
+ *
+ pszIV
+ *
+ * Pointer to data to be encrypted
+ *
+ pszIn
+ *
+ * Pointer to encrypted data.
+ * It can be same pointer as pszOut.
+ *
+ pszOut
+ *
+ * Length in bytes of content to be encrypted.
+ *
+ iInLen
+ *
+ * Cipher type(AES encryption modes).
+ *		AES_MODE_CBC ... AES_MODE_ECB
+ *
+ uiParameters
+ *
+ * Return values
+ *
+ * If encryption is OK, return DRM_ENG_OK, 
+ * otherwize DRM_ENG_ERROR.
+ */
+
+/* ---------------------------------------------------------------------- */
+
+#ifdef	ENCRYPT_USED
+uint8 DRMCrypto_Encrypt( 
+		  CipherType				cType, 
+		  uint8*					pszKey, 
+		  uint16					iKeyLen,
+		  uint8*					pszIV,
+		  uint8*					pszIn,
+		  uint8*					pszOut,
+		  uint32					iInLen, 
+		  CipherParamType			uiParameters	)
+	{
+	/* Data structures */
+
+	/* return code
+	 */
+	uint8 ret = 0;
+
+	/* AES encryption mode
+	 */
+	uint8 iMode = 0;
+
+	/*  Code  */
+
+	/* check parameter */
+	if( !pszKey || !pszIV || !pszIn || !pszOut )
+		{
+		return DRM_ENG_INVALID_PARAM;
+		}
+
+	/* Convert uiParameters to inner interface type
+	 */
+	if( uiParameters ==  AES_MODE_CBC)
+		{
+		iMode = AES_CBC;
+		}
+	else if( uiParameters ==  AES_MODE_ECB)
+		{
+		iMode = AES_ECB;
+		}
+	else 
+		{
+		DEBUG("Crypto Error: invalid uiParameters!")
+		return DRM_ENG_ERROR;
+		}
+
+	if( cType == CIPHER_AES )
+		{
+		ret = AESEncrypt( (uint32*)pszKey, (uint16)(iKeyLen*8), (uint32*)pszIV, 
+						  (uint32*)pszIn, (uint32*)pszOut, iInLen, iMode );
+		if( ret==AES_CRYPTO_OK ) 
+			{
+			return DRM_ENG_OK;
+			}
+		else if( ret == AES_CRYPTO_ERR_MEMORY )
+			{
+			return DRM_ENG_MEM_ERROR;
+			}
+		else 
+			{
+			DEBUGD("Crypto Error: AES Encryption Error ", ret)
+			return DRM_ENG_ERROR;
+			}
+		}
+	else
+		{
+		return DRM_ENG_ERROR;
+		}
+	}
+#endif /* #ifdef	ENCRYPT_USED */
+
+
+/*  7.2 */
+
+/* Functional description
+ *
+ * Decrypt data using specified algorithm.
+ *
+ *
+ * Parameters
+ *
+ * Cipher type
+ *
+ cType
+ *
+ * Pointer to encryption key
+ *
+ pszKey
+ *
+ * Encryption key length in bytes
+ *
+ iKeyLen
+ *
+ * Pointer to initializer vector of encryption
+ *
+ pszIV
+ *
+ * Pointer to encrypted data which is to be decrypted
+ *
+ pszIn
+ *
+ * Pointer to decrypted content.
+ * It can be same pointer as pszOut.
+ *
+ pszOut
+ *
+ * Length in bytes of content to be decrypted.
+ *
+ iInLen
+ *
+ * Cipher type(AES encryption modes).
+ *		AES_MODE_CBC ... AES_MODE_ECB
+ *
+ uiParameters
+ *
+ * Return values
+ *
+ * If decryption is OK, return DRM_ENG_OK, 
+ * otherwize DRM_ENG_ERROR.
+ */
+
+/* ---------------------------------------------------------------------- */
+
+
+uint8 DRMCrypto_Decrypt( 
+		  CipherType				cType,
+		  uint8*					pszKey, 
+          uint16					iKeyLen,
+		  uint8*					pszIV,
+		  uint8*					pszIn,
+		  uint8*					pszOut,
+		  uint32					iInLen,
+		  CipherParamType			uiParameters	)
+	{
+	/* Data structures */
+
+	/* return code
+	 */
+	uint8 ret = 0;
+
+	/* AES encryption mode
+	 */
+	uint8 iMode = 0;
+
+	/* Aligned buffer for Key
+	 */
+	/* uint32*			pKeyAligned=NULL; */
+
+	/* Aligned buffer for IV
+	 */
+	/* uint32*			pIVAligned=NULL; */
+
+	/* Aligned buffer for Input data
+	 */
+	/* uint32*			pInAligned=NULL; */
+
+	/* Byte stream pointer
+	 */
+	/* uint8* pBytes = NULL; */
+
+	/*  Code  */
+
+	/* check parameter */
+	if( !pszKey || !pszIV || !pszIn || !pszOut )
+		{
+		return DRM_ENG_INVALID_PARAM;
+		}
+
+	/* Convert uiParameters to inner interface type
+	 */
+	if( uiParameters ==  AES_MODE_CBC)
+		{
+		iMode = AES_CBC;
+		}
+	else if( uiParameters ==  AES_MODE_ECB)
+		{
+		iMode = AES_ECB;
+		}
+	else 
+		{
+		DEBUG("Crypto Error: invalid uiParameters !")
+		return DRM_ENG_ERROR;
+		}
+
+	if( cType == CIPHER_AES )
+		{
+			
+			ret = AESDecrypt( (uint32*)pszKey, (uint16)(iKeyLen*8), (uint32*)pszIV, 
+							  (uint32*)pszIn,  (uint32*)pszOut, iInLen, iMode );
+
+		if( ret==AES_CRYPTO_OK ) 
+			{
+			ret = DRM_ENG_OK;
+			}
+		else if( ret == AES_CRYPTO_ERR_MEMORY )
+			{
+			ret = DRM_ENG_MEM_ERROR;
+			}
+		else 
+			{
+			DEBUGD("Crypto Error: AES Decryption Error ", ret)
+			ret = DRM_ENG_ERROR;
+			}
+		}
+	else
+		{
+		ret = DRM_ENG_ERROR;
+		}
+
+	return ret;
+	}
+
+
+/*  7.5 */
+
+/* Functional description
+ *
+ * Adds padding bytes at the end of data.
+ *
+ *
+ * Parameters
+ *
+ * Pointer to pointer to data.
+ * IN: points to data before adding padding bytes.
+ * OUT: points to data with added padding bytes.
+ * Memory used by input data will be freed inside this function.
+ * New memory will be allocated for output data.
+ *
+ ppData
+ *
+ * Pointer to data length in bytes
+ * IN:  pointer to length of data with padding.
+ * OUT: points to length of data without padding.
+ *
+ pDataLen
+ *
+ * Cipher block size. 
+ * Max 256
+ *
+ CipBlockSize
+ *
+ * Specifies used padding method.
+ *      PADDING_PKCS7
+ *
+ uiPaddingMethod
+ *
+ * Return values
+ *
+ * If operation is OK, return DRM_ENG_OK, 
+ * otherwize DRM_ENG_ERROR.
+ */
+
+/* ---------------------------------------------------------------------- */
+
+
+uint8 DRMCrypto_AddPadding(
+		  uint8**				ppData, 
+		  uint32*				pDataLen,
+		  uint8					CipBlockSize,
+		  PaddingMethodType		uiPaddingMethod	)
+	{
+	/* Data structures */
+
+	/* Number of bytes to add to data
+	 */
+	uint8	padSize=0;
+
+	/* Address of input data
+	 */
+	uint8	*pDataIn;
+
+	/* Iterator
+	 */
+	uint16	i;
+
+	/* return code */
+	uint8 ret = DRM_ENG_OK;
+
+
+	/*  Code  */
+
+	/* check parameter */
+	if( !ppData || !pDataLen )
+		{
+		return DRM_ENG_INVALID_PARAM;
+		}
+
+	if( uiPaddingMethod == PADDING_PKCS7)
+		{
+		/* calculate padding size
+		 */
+		padSize = (uint8)( CipBlockSize-( *pDataLen % CipBlockSize ) );
+	
+		/* record input data address
+		 */
+		pDataIn = *ppData;
+
+		/* allocate memory
+		 */
+		*ppData = (uint8*)DRM_BLOCK_ALLOC( *pDataLen+padSize ) ;
+		if( !(*ppData) )
+			{
+			return DRM_ENG_MEM_ERROR;
+			}
+
+		/* copy data
+		 */
+		DRM_BLOCK_COPY( *ppData, pDataIn, *pDataLen  );
+
+		/* free memory for input data
+		 */
+		DRM_BLOCK_DEALLOC( pDataIn);
+
+		/* add padding
+		 */
+		for( i=0; i<padSize; i++)
+			*( (uint8*)(*ppData) + *pDataLen +i) = padSize;
+
+		/* calculate new data length:
+		 */
+		*pDataLen = *pDataLen+padSize;
+
+		return	DRM_ENG_OK;
+		}
+	else
+		{
+		DEBUG( "Cypto Error: invalid uiPaddingMethod !" )
+		ret = DRM_ENG_ERROR;
+		}
+
+	return ret;
+	}
+
+
+
+/*  7.6 */
+
+/* Functional description
+ *
+ * Remove padding bytes from data.
+ *
+ *
+ * Parameters
+ *
+ * Pointer to pointer to data(with padding bytes).
+ * IN: points to data with padding bytes.
+ * OUT: points to data without padding bytes.
+ *
+ ppData
+ *
+ * Pointer to data length in bytes
+ * IN:  points to length of data with padding.
+ * OUT: points to length of data without padding.
+ *
+ pDataLen
+ *
+ * Specifies used padding method.
+ *      PADDING_PKCS7
+ *
+ uiPaddingMethod
+ *
+ * Return values
+ *
+ * If operation is OK, return DRM_ENG_OK, 
+ * otherwize DRM_ENG_ERROR.
+ */
+
+/* ---------------------------------------------------------------------- */
+
+
+uint8 DRMCrypto_RemovePadding(
+		  uint8**				ppData, 
+		  uint32*				pDataLen,
+		  PaddingMethodType		uiPaddingMethod	)
+	{
+	/* Data structures */
+
+	/* Number of bytes of padding data
+	 */
+	uint8	padSize=0;
+
+		/* return code */
+	uint8 ret = DRM_ENG_OK;
+
+	/*  Code  */
+
+	/* check parameter */
+	if( !ppData || !pDataLen )
+		{
+		return DRM_ENG_INVALID_PARAM;
+		}
+
+	if( uiPaddingMethod == PADDING_PKCS7)
+		{
+		/* calculate padding size
+		 * padding size is equal to last byte value of data
+		 */
+		padSize = *( (*ppData) + (*pDataLen) -1);
+
+		if( padSize<1 || padSize>CRYPTO_BLOCK_SIZE )
+			{
+			DEBUG("Padding Size wrong!")
+			return DRM_ENG_ERROR;
+			}
+
+		/* calculate new data length:
+		 */
+		*pDataLen = *pDataLen-padSize;
+
+		return	DRM_ENG_OK;
+		}
+	else
+		{
+		DEBUG( "Cypto Error: invalid uiPaddingMethod !" )
+		ret = DRM_ENG_ERROR;
+		}
+
+	return ret;
+	}
+
+
+/*  7.8 */
+
+/* Functional description
+ *
+ * Generates an initialization vector for cipher CBC mode. 
+ *
+ *
+ * Parameters
+ *
+ * Lenght of the IV to be generated in bits. Must be a value between 1-16.
+ *
+ ivLen
+ *
+ *
+ * Pointer to pointer to the generated IV.
+ *
+ ppIV
+ *
+ *
+ * Return values
+ *
+ * If operation is OK, return DRM_ENG_OK, 
+ * otherwize DRM_ENG_ERROR.
+ */
+
+/* ---------------------------------------------------------------------- */
+
+uint8 DRMCrypto_GenerateIV(uint32 ivLen, uint8 **ppIV)
+	{
+	/* Data structures */
+
+	/* return code	 */
+	uint8	ret=DRM_ENG_OK;
+
+	/* seed */
+	uint8* pSeed=NULL;
+
+	/*  Code  */
+	
+	/* check parameter */
+	if( ppIV == NULL || ivLen == 0 || ivLen > 16)
+		{
+		return DRM_ENG_INVALID_PARAM;
+		}
+
+	/* allocate memory for IV */
+	*ppIV = DRM_BLOCK_ALLOC( ivLen );
+	
+	if( !(*ppIV) )
+		{
+		return DRM_ENG_MEM_ERROR;
+		}
+
+	/* generate random number as seed */
+	pSeed = DRM_BLOCK_ALLOC( KEYSEED_LENGTH );
+	if( !pSeed )
+		{
+		ret = DRM_ENG_MEM_ERROR;
+		}
+	else
+		{
+		ret = DRMEnv_GetRandom( (uint32*)pSeed, KEYSEED_NUMBER_OF_INT32 );
+		TRANSLATE_ERROR_CODE( ret );
+		}
+
+	/* generate IV by seed */
+	if( ret == DRM_ENG_OK )
+		{
+		/* Just copy the seed as IV. */
+		DRM_BLOCK_COPY(*ppIV, pSeed, ivLen<KEYSEED_LENGTH?ivLen:KEYSEED_LENGTH );
+		}
+	else /* free memory */
+		{
+		DRM_BLOCK_DEALLOC( *ppIV );
+		}
+
+	/* free memory */
+	DRM_BLOCK_DEALLOC( pSeed );
+
+	return ret;
+	}
+
+#endif /* #ifndef C_DRMCRYPTO_CFILE */
+/* End of File */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/drmmeteringdb.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,655 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the Metering database
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <f32file.h>
+#include <S32FILE.H>
+#include <BAUTILS.H>
+#include "drmlog.h"
+#include "drmmeteringdb.h"
+#ifdef RD_DRM_METERING
+#include "drmmeteringdbdata.h"
+#endif
+#include "DRMTypes.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+#ifdef RD_DRM_METERING
+
+_LIT( KCIDColName, "cid" );
+_LIT( KRightIssuerColName, "riid" );
+_LIT( KCountColName, "count" );
+_LIT( KAccumulatedTimeColName, "time" );
+_LIT( KMeteringDataTable, "metering" );
+_LIT( KParentUIDColName, "parent" );
+_LIT( KViewInitQuery, "SELECT * FROM metering ORDER BY riid" );
+
+LOCAL_C const TUint8 KDbViewCIDOrdinal = 1;
+LOCAL_C const TUint8 KDbViewRIIDOrdinal = 2;
+LOCAL_C const TUint8 KDbViewCountOrdinal = 3;
+LOCAL_C const TUint8 KDbViewAccumulatedTimeOrdinal = 4;
+LOCAL_C const TUint8 KDbViewParentUIDOrdinal = 5;
+
+// MODULE DATA STRUCTURES
+NONSHARABLE_STRUCT( TDoDeleteFile )
+    {
+    RFs* iFs;
+    const TDesC* iFile;
+    };
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C void DoRollBack( TAny* aAny );
+LOCAL_C void DoDeleteFile( TAny* aAny );
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// DoRollBack
+//
+// Do a rollback operation to the RDbDatabase*
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void DoRollBack( TAny* aAny )
+    {
+    reinterpret_cast< RDbDatabase* >( aAny )->Rollback();
+    }
+
+// -----------------------------------------------------------------------------
+// DoDeleteFile
+//
+// Delete the file presented by TDoDeleteFile*
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void DoDeleteFile( TAny* aAny )
+    {
+    TDoDeleteFile* s = reinterpret_cast< TDoDeleteFile* >( aAny );
+
+    s->iFs->Delete( *( s->iFile ) );
+    }
+
+#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::RDrmMeteringDb
+//
+// Default constructor
+// -----------------------------------------------------------------------------
+//
+RDrmMeteringDb::RDrmMeteringDb():
+iFs( NULL ),
+iDb()
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::~RDrmMeteringDb
+//
+// Destructor
+// -----------------------------------------------------------------------------
+//
+RDrmMeteringDb::~RDrmMeteringDb()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMMeteringDb::Close
+//
+// Closes the databases.
+// -----------------------------------------------------------------------------
+//
+void RDrmMeteringDb::Close()
+    {
+    // Atomic operations only at the moment, but what about the future.
+    iDb.Close();
+    }
+
+#ifdef RD_DRM_METERING
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::RDrmMeteringDb
+//
+// Constructor
+// -----------------------------------------------------------------------------
+//
+RDrmMeteringDb::RDrmMeteringDb( RFs& aFs ) :
+iFs( &aFs ),
+iDb()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::Set
+//
+// Set iFs to given aFs.
+// -----------------------------------------------------------------------------
+//
+void RDrmMeteringDb::Set( RFs& aFs )
+    {
+    iFs = &aFs;
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::InitL
+//
+// Initialize the databases.
+// -----------------------------------------------------------------------------
+//
+void RDrmMeteringDb::InitL( const TDesC& aFileName )
+    {
+
+    DRMLOG( _L( "RDrmMeteringDb::InitL" ) );
+    TInt error = KErrNone;
+    TBool exists = BaflUtils::FileExists( *iFs, aFileName );
+
+    if ( exists )
+        {
+        TRAP( error, OpenDbL( iDb, aFileName ) );
+        }
+    if ( error || !exists )
+        {
+        ReplaceDbL( iDb, aFileName );
+        }
+    DRMLOG( _L( "RDrmMeteringDb::InitL ok" ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::AddL
+//
+// Add an entry to the database. The method checks whether an entry matching
+// the given Content Id and Rights Issuer Id already exists or not. A new row
+// is added to the database if one does not already exist.
+// -----------------------------------------------------------------------------
+//
+void RDrmMeteringDb::AddL( const CDrmMeteringDbData* aMeteringData )
+    {
+
+    DRMLOG( _L( "RDrmMeteringDb::AddL" ) );
+
+    __ASSERT_DEBUG( aMeteringData, User::Invariant() );
+
+    RDbView view;
+    TBool res = EFalse;
+
+    PushL( iDb );
+
+    InitViewLC( view );
+
+    User::LeaveIfError( iDb.Begin() );
+
+    for ( view.FirstL(); view.AtRow() && !res ; view.NextL() )
+        {
+        view.GetL();
+
+        // Check whether an entry already exists or not.
+        if ( CompareIDL( view, *( aMeteringData->iContentId ),
+             aMeteringData->iRiId ) )
+            {
+
+            view.UpdateL(); // Update count and accumulated time of the rowset
+
+            // Get the structure of rowset
+            CDbColSet* colset = view.ColSetL();
+            CleanupStack::PushL( colset );
+
+            TInt count = 0;
+            TTimeIntervalSeconds accumulatedTime =
+                aMeteringData->iAccumulatedTime.Int();
+
+            count = aMeteringData->iCount +
+                view.ColUint32( KDbViewCountOrdinal );
+
+            view.SetColL( colset->ColNo( KCountColName ), count );
+
+            accumulatedTime = accumulatedTime.Int() +
+                view.ColInt32( KDbViewAccumulatedTimeOrdinal );
+
+            view.SetColL( colset->ColNo( KAccumulatedTimeColName ),
+                accumulatedTime.Int() );
+
+            if ( aMeteringData->iParentUid )
+                {
+                view.SetColL( KDbViewParentUIDOrdinal,
+                              *( aMeteringData->iParentUid ) );
+                }
+
+            view.PutL();
+            iDb.Compact();
+
+            res = ETrue;
+            CleanupStack::PopAndDestroy( colset );
+            }
+
+        }
+
+    // No existing entry was found. Make a new entry to the database.
+    if ( !res )
+        {
+        view.InsertL(); // Add new row to the database
+
+        view.SetColL( KDbViewCIDOrdinal, *( aMeteringData->iContentId ) );
+        view.SetColL( KDbViewRIIDOrdinal, aMeteringData->iRiId );
+        view.SetColL( KDbViewCountOrdinal, aMeteringData->iCount );
+        view.SetColL( KDbViewAccumulatedTimeOrdinal,
+                      aMeteringData->iAccumulatedTime.Int() );
+
+        if ( aMeteringData->iParentUid )
+            {
+            view.SetColL( KDbViewParentUIDOrdinal,
+                          *( aMeteringData->iParentUid ) );
+            }
+
+        view.PutL();
+        }
+
+    CleanupStack::PopAndDestroy(); // view
+
+    User::LeaveIfError( iDb.Commit() );
+
+    Pop(); // iDb
+    DRMLOG( _L( "RDrmMeteringDb::AddL ok" ) );
+
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::GetL
+//
+// Get the metering data list of a Rights Issuer from the database. Return value
+// is ETrue if at least one entry was found. return value is EFalse if no entry
+// was found. Function will leave if an error happens when accessing the
+// database or if the given Rights Issuer Id is either empty or too long.
+// -----------------------------------------------------------------------------
+//
+
+TBool RDrmMeteringDb::GetL( const TDesC8& aRiId,
+                            CDRMPointerArray< CDrmMeteringDbData >&
+                            aMeteringDataList )
+    {
+
+    DRMLOG( _L( "RDrmMeteringDb::GetL" ) );
+
+    // If Rights Issuer Id not available or is too long
+    if ( ( aRiId.Length() == 0 ) || ( aRiId.Length() > KRiIdSize ) )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TBool found = EFalse;
+
+        RDbView view;
+
+        PushL( iDb );
+
+        InitViewLC( view );
+
+        User::LeaveIfError( iDb.Begin() );
+
+        // Examine the whole database for possible entries matching the Rights
+        // Issuer Id
+        for ( view.FirstL(); view.AtRow(); view.NextL() )
+            {
+
+            view.GetL();
+
+            // Check whether the Rights Issuer Id in the current row matches
+            // the given Rights Issuer Id or not.
+            if ( CompareIDL( view, aRiId ) )
+                {
+
+                found = ETrue;
+
+                CDbColSet* colset = view.ColSetL();
+                CleanupStack::PushL( colset );
+
+                // Create a new instance of the Metering information storage
+                // class to be included in the given Metering data pointer
+                // array
+                CDrmMeteringDbData* meteringdata = CDrmMeteringDbData::NewLC();
+                TPtrC8 cid = view.ColDes8( colset->ColNo( KCIDColName ) );
+
+                meteringdata->iContentId = cid.AllocL();
+                meteringdata->iRiId.Copy( aRiId );
+                meteringdata->iCount = view.ColUint32( KDbViewCountOrdinal );
+
+                meteringdata->iAccumulatedTime =
+                    static_cast< TTimeIntervalSeconds >\
+                    ( view.ColInt32( KDbViewAccumulatedTimeOrdinal ) );
+
+                TPtrC8 parentuid =
+                    view.ColDes8( colset->ColNo( KParentUIDColName ) );
+
+                // Alloc has been used instead of AllocL in order not to leave
+                // if an error happens in the memory allocation.
+                meteringdata->iParentUid = parentuid.Alloc();
+
+                // Insert the instance to the Metering data pointer array
+                aMeteringDataList.AppendL( meteringdata );
+
+                CleanupStack::Pop( meteringdata );
+                CleanupStack::PopAndDestroy( colset );
+                }
+
+            }
+
+        User::LeaveIfError( iDb.Commit() );
+
+        CleanupStack::PopAndDestroy(); // view
+
+        Pop(); // iDb
+
+    DRMLOG( _L( "RDrmMeteringDb::GetL ok" ) );
+
+    return found;
+
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::DeleteL
+//
+// Delete all the metering data associated to a Rights Issuer from the database.
+// Return value is ETrue if at least one entry was found. Return value is EFalse
+// if no entry was found. Function will leave if an error happens when accessing
+// the database or if the given Rights Issuer Id is either empty or too long.
+// -----------------------------------------------------------------------------
+//
+TBool RDrmMeteringDb::DeleteL( const TDesC8& aRiId )
+    {
+
+    DRMLOG( _L( "RDrmMeteringDb::DeleteL" ) );
+
+    // If Rights Issuer Id is empty or is not available
+    if ( ( aRiId.Length() == 0 ) || ( aRiId.Length() > KRiIdSize ) )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TBool found = EFalse;
+
+    RDbView view;
+
+    PushL( iDb );
+
+    InitViewLC( view );
+
+    User::LeaveIfError( iDb.Begin() );
+
+    for ( view.FirstL(); view.AtRow(); view.NextL() )
+        {
+
+        view.GetL();
+
+        if ( CompareIDL( view, aRiId ) )
+            {
+            found = ETrue;
+            view.DeleteL();
+            }
+
+        }
+
+    if ( found )
+        {
+        iDb.Compact();
+        }
+
+    User::LeaveIfError( iDb.Commit() );
+
+    CleanupStack::PopAndDestroy(); // view
+
+    Pop(); // iDb
+
+    DRMLOG( _L( "RDrmMeteringDb::DeleteL ok" ) );
+
+    return found;
+
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::OpenDbL
+//
+// Open the database.
+// -----------------------------------------------------------------------------
+//
+void RDrmMeteringDb::OpenDbL( RDbNamedDatabase& aDb,
+                               const TDesC& aFileName )
+    {
+
+    DRMLOG( _L( "RDrmMeteringDb::OpenDbL" ) );
+    CDbTableNames* tables = NULL;
+
+    User::LeaveIfError( aDb.Open( *iFs, aFileName ) );
+    CleanupClosePushL( aDb );
+
+    if ( aDb.IsDamaged() )
+        {
+        User::LeaveIfError( aDb.Recover() );
+        }
+
+    // Sanity check
+    tables = aDb.TableNamesL();
+    CleanupStack::PushL( tables );
+
+    if ( tables->Count() != 1 ||
+         ( *tables )[ 0 ].Compare( KMeteringDataTable ) )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    CleanupStack::PopAndDestroy( tables );
+    CleanupStack::Pop(); // aDb
+    DRMLOG( _L( "RDrmMeteringDb::OpenDbL ok" ) );
+
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::ReplaceDbL
+//
+// Replace the database.
+// -----------------------------------------------------------------------------
+//
+void RDrmMeteringDb::ReplaceDbL( RDbNamedDatabase& aDb,
+                                 const TDesC& aFileName )
+    {
+    DRMLOG( _L( "RDrmMeteringDb::ReplaceDbL" ) );
+
+    CDbColSet*  colSet = NULL;
+
+    // Define column names and their data types
+    TDbCol cidCol( KCIDColName, EDbColText8 );
+    TDbCol riidCol( KRightIssuerColName, EDbColText8 );
+    TDbCol countCol( KCountColName, EDbColUint32  );
+    TDbCol accumulatedTimeCol( KAccumulatedTimeColName, EDbColInt32 );
+    TDbCol parentUIDCol( KParentUIDColName, EDbColText8 );
+
+    TDoDeleteFile deletefile = { iFs, &aFileName };
+
+    TCleanupItem item( DoDeleteFile, &deletefile );
+    CleanupStack::PushL( item );
+
+    User::LeaveIfError( aDb.Replace( *iFs, aFileName ) );
+    CleanupClosePushL( aDb );
+
+    // Add columns
+    colSet = CDbColSet::NewLC();
+    colSet->AddL( cidCol );
+    colSet->AddL( riidCol );
+    colSet->AddL( countCol );
+    colSet->AddL( accumulatedTimeCol );
+    colSet->AddL( parentUIDCol);
+
+    // Create indices
+    TDbKeyCol cidKeyCol( KCIDColName );
+    TDbKeyCol riidKeyCol( KRightIssuerColName );
+
+    CDbKey* key = CDbKey::NewLC();
+    key->AddL( cidKeyCol );
+    key->AddL( riidKeyCol );
+    key->MakeUnique();
+
+    User::LeaveIfError( aDb.Begin() );
+    User::LeaveIfError( aDb.CreateTable( KMeteringDataTable, *colSet ) );
+
+    User::LeaveIfError( aDb.CreateIndex( KMeteringDataTable,
+                                         KMeteringDataTable,
+                                         *key ) );
+
+    User::LeaveIfError( aDb.Commit() );
+
+    CleanupStack::PopAndDestroy( 2, colSet ); // key, colset
+    CleanupStack::Pop(); // aDb
+    CleanupStack::Pop(); // item
+
+    DRMLOG( _L( "RDrmMeteringDb::ReplaceDbL ok" ) );
+
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::InitViewLC
+//
+// Initialize the view.
+// -----------------------------------------------------------------------------
+//
+void RDrmMeteringDb::InitViewLC( RDbView& aView )
+    {
+
+    DRMLOG( _L( "RDrmMeteringDb::InitViewLC" ) );
+
+    User::LeaveIfError(
+        aView.Prepare( iDb,
+                       TDbQuery( KViewInitQuery, EDbCompareCollated ),
+                       RDbRowSet::EUpdatable ) );
+
+    CleanupClosePushL( aView );
+
+    User::LeaveIfError( aView.EvaluateAll() );
+
+    DRMLOG( _L( "RDrmMeteringDb::InitViewLC ok" ) );
+
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::CompareIDL
+//
+// Compare the Rights Issuer Id and Content Id to their counterparts in the current
+// row of the view. Return value is ETrue only if both the Content Id and the Rights
+// Issuer Id match their counterpart Ids in the view.
+// -----------------------------------------------------------------------------
+//
+TBool RDrmMeteringDb::CompareIDL( RDbRowSet& aView,
+                                  const TDesC8& aCID,
+                                  const TDesC8& aRiId )
+    {
+
+    DRMLOG( _L( "RDrmMeteringDb::CompareIDL" ) );
+
+    TBool res = EFalse;
+
+    CDbColSet* colset = aView.ColSetL();
+    CleanupStack::PushL( colset );
+
+    TPtrC8 riid = aView.ColDes8( colset->ColNo( KRightIssuerColName ) );
+    TBuf8< KRiIdSize > buf = riid;
+
+    TPtrC8 cid = aView.ColDes8( colset->ColNo( KCIDColName ) );
+    HBufC8* des = cid.AllocLC();
+
+    if ( ( aRiId.CompareC( buf ) == 0 ) && ( aCID.CompareC( *des ) == 0 ) )
+    {
+    res = ETrue;
+    }
+
+    CleanupStack::PopAndDestroy( des );
+    CleanupStack::PopAndDestroy( colset );
+
+    DRMLOG( _L( "RDrmMeteringDb::CompareIDL ok" ) );
+
+    return res;
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::CompareIDL
+//
+// Compare whether the rowset's ID matches the given ID. For comparison of
+// Rights Issuer ID. Overloaded.
+// -----------------------------------------------------------------------------
+//
+TBool RDrmMeteringDb::CompareIDL( RDbRowSet& aView,
+                                  const TDesC8& aRiId )
+    {
+
+    DRMLOG( _L( "RDrmMeteringDb::CompareIDL" ) );
+
+    TBool res = EFalse;
+
+    CDbColSet* colset = aView.ColSetL();
+    CleanupStack::PushL( colset );
+
+    TPtrC8 riid = aView.ColDes8( colset->ColNo( KRightIssuerColName ) );
+    TBuf8< KRiIdSize > buf = riid;
+
+    if ( aRiId.CompareC( buf ) == 0 )
+    {
+    res = ETrue;
+    }
+
+    CleanupStack::PopAndDestroy( colset );
+
+    DRMLOG( _L( "RDrmMeteringDb::CompareIDL ok" ) );
+
+    return res;
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDb::PushL
+//
+// Push a cleanup item to cleanup stack.
+// -----------------------------------------------------------------------------
+//
+void RDrmMeteringDb::PushL( RDbDatabase& aDb )
+    {
+    TCleanupItem item( DoRollBack, &aDb );
+    CleanupStack::PushL( item );
+    }
+
+// -----------------------------------------------------------------------------
+// RDrmMeteringDB::Pop
+//
+// Pop a cleanup item pushed in by PushL.
+// -----------------------------------------------------------------------------
+//
+void RDrmMeteringDb::Pop()
+    {
+    CleanupStack::Pop();
+    }
+
+#endif
+  
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/drmmeteringdbdata.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,93 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Datatype for the Metering Database Data
+*
+*/
+
+
+// INCLUDE FILES
+#include "drmmeteringdbdata.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDrmMeteringDbData::NewLC
+// Constructor. Leaves the object in the cleanup stack.
+// -----------------------------------------------------------------------------
+//
+CDrmMeteringDbData* CDrmMeteringDbData::NewLC()
+    {
+    CDrmMeteringDbData* self = new ( ELeave ) CDrmMeteringDbData();
+    CleanupStack::PushL( self );
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDrmMeteringDbData::NewL
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CDrmMeteringDbData* CDrmMeteringDbData::NewL()
+    {
+    CDrmMeteringDbData* self = NewLC();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Default Constructor - First phase
+// Can be used by itself to generate an empty object
+// -----------------------------------------------------------------------------
+//
+CDrmMeteringDbData::CDrmMeteringDbData():
+    iContentId( NULL ),
+    iCount( 0 ),
+    iAccumulatedTime( 0 ),
+    iPermission( ContentAccess::EPlay ),
+    iParentUid( NULL )
+    {
+    iRiId.SetLength( KRiIdSize );
+    iRiId.Fill( 0 );
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CDrmMeteringDbData::~CDrmMeteringDbData()
+    {
+    if( iContentId )
+        {
+        delete iContentId;
+        iContentId = NULL;
+        }
+
+    if( iParentUid )
+        {
+        delete iParentUid;
+        iParentUid = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmMeteringDbData::ConstructL
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+//
+void CDrmMeteringDbData::ConstructL()
+    {
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/drmparentstorage.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,192 @@
+/*
+* 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:  Implementation of the parent storage for Decision Making Machine
+*
+*/
+
+
+// INCLUDE FILES
+#include "drmparentstorage.h"
+#include "drmpermission.h"
+#include "drmlog.h"
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+LOCAL_C const TUint KDefaultGranularity = 4;
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+    
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMParentStorage::CDRMParentStorage
+//
+// Default constructor 
+// -----------------------------------------------------------------------------
+//
+CDRMParentStorage::CDRMParentStorage():
+iParents( 1 )
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMParentStorage::~CDRMParentStorage
+//
+// Desetructor.
+// -----------------------------------------------------------------------------
+//
+CDRMParentStorage::~CDRMParentStorage()
+    {
+    if ( iParentIDs )
+        {
+        iParentIDs->Reset();
+        delete iParentIDs;
+        }
+        
+    // The lists inside are autocleaning, so deletion causes
+    // the contents to also be deleted    
+    iParents.ResetAndDestroy();
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMParentStorage::NewLC
+//
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CDRMParentStorage* CDRMParentStorage::NewLC()
+    {
+    CDRMParentStorage* self = new( ELeave ) CDRMParentStorage;
+    CleanupStack::PushL( self );
+    
+    self->ConstructL();
+    
+    return self;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMParentStorage::NewL
+//
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//    
+CDRMParentStorage* CDRMParentStorage::NewL()
+    {
+    CDRMParentStorage* self = CDRMParentStorage::NewLC();
+    CleanupStack::Pop(); // sefl
+    
+    return self;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMParentStorage::ConstructL
+//
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+//
+void CDRMParentStorage::ConstructL()
+    {
+    iParentIDs = new( ELeave ) CDesC8ArraySeg( KDefaultGranularity );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMParentStorage::NewListL
+//
+// Insert a new list to the storage, and return a handle to it.
+// -----------------------------------------------------------------------------
+//    
+CDRMPermissionList& CDRMParentStorage::NewListL()
+    {
+    __ASSERT_DEBUG( iParents.Count() >= iParentIDs->Count(), User::Invariant() );
+        
+    if ( iParents.Count() == iParentIDs->Count() )
+        {
+        // Balanced lists.
+        CDRMPermissionList* newList = CDRMPermissionList::NewLC();
+        newList->SetAutoCleanup( ETrue );
+        
+        iParents.AppendL( newList );
+        CleanupStack::Pop();
+        }
+        
+    return *( iParents[ iParents.Count() - 1 ] );
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMParentStorage::AddL
+//
+// Add an entry to the ID table.
+// -----------------------------------------------------------------------------
+//
+void CDRMParentStorage::AddL( const TDesC8& aCID )
+    {
+    TInt pos = iParentIDs->InsertIsqL( aCID );
+    if ( pos != iParentIDs->Count() - 1 )
+        {
+        // Sort iParents
+        CDRMPermissionList* list = iParents[ iParents.Count() - 1 ];
+        User::LeaveIfError( iParents.Insert( list, pos ) );
+        iParents.Remove( iParents.Count() -1 );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMParentStorage::HasPermissions
+//
+// Check the count of the stored permissions for an id
+// -----------------------------------------------------------------------------
+//    
+TBool CDRMParentStorage::HasPermissions( const TDesC8& aCID )
+    {
+    TBool r = EFalse;
+    TInt pos;
+    
+    if ( iParentIDs->FindIsq( aCID, pos ) == KErrNone )
+        {
+        r = ETrue;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMParentStorage::operator[]
+//
+// Operator.
+// -----------------------------------------------------------------------------
+//    
+CDRMPermissionList& CDRMParentStorage::operator[]( const TDesC8& aCID )
+    {
+    TInt pos;
+    
+    iParentIDs->FindIsq( aCID, pos );
+    return *( iParents[ pos ] );
+    }
+    
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/drmpermissionitem.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,153 @@
+/*
+* 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:  
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "drmpermissionitem.h"
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMPermissionItem* CDRMPermissionItem::NewLC()
+    {
+    CDRMPermissionItem* self = new( ELeave ) CDRMPermissionItem();
+    CleanupStack::PushL( self );
+    self->ConstructL();    
+
+    return self;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMPermissionItem* CDRMPermissionItem::NewL()
+    {
+    CDRMPermissionItem* self = NewLC();
+    CleanupStack::Pop( self );
+
+    return self;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMCommonData::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+// 
+CDRMPermissionItem* CDRMPermissionItem::NewLC( const CDRMConstraint& aNormalized,
+                                               TInt aIndex,
+                                               TInt aParentIndex )
+    {
+    CDRMPermissionItem* self = new( ELeave ) CDRMPermissionItem( aIndex, aParentIndex);
+    CleanupStack::PushL( self );
+    self->ConstructL( aNormalized );    
+
+    return self;    
+    };
+                                      
+// -----------------------------------------------------------------------------
+// CDRMCommonData::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//                                      
+CDRMPermissionItem* CDRMPermissionItem::NewL( const CDRMConstraint& aNormalized,
+                                     TInt aIndex,
+                                     TInt aParentIndex )
+    {
+    CDRMPermissionItem* self = NewLC( aNormalized, aIndex, aParentIndex );
+    CleanupStack::Pop( self );   
+
+    return self;    
+    };                                      
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+// 
+CDRMPermissionItem::CDRMPermissionItem( TInt aIndex,
+                                        TInt aParentIndex ) :
+    CDRMConstraint(), 
+    iIndex( aIndex ),
+    iParent( aParentIndex )
+    {
+    
+    };
+
+// -----------------------------------------------------------------------------
+// Constructor
+// -----------------------------------------------------------------------------
+// 
+CDRMPermissionItem::CDRMPermissionItem() :
+    CDRMConstraint(), 
+    iIndex( -1 ),
+    iParent( -1 )
+    {
+    
+    };
+    
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+// 
+CDRMPermissionItem::~CDRMPermissionItem()
+    {
+    // Nothing
+    };    
+    
+// -----------------------------------------------------------------------------
+// CDRMPermissionItem::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+// 
+void CDRMPermissionItem::ConstructL( const CDRMConstraint& aNormalized )
+    {
+    (const_cast<CDRMPermissionItem*>(this))->DuplicateL( aNormalized );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMPermissionItem::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//  
+void CDRMPermissionItem::ConstructL()
+    {
+    };   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/server/src/drmrightsdb.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,2784 @@
+/*
+* 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:  Implementation of the DRM Rights Database
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <e32std.h>     // RPointerArray
+#include <e32def.h>     // Type definitions
+#include <hash.h>       // MD5 Algorithm
+// #include <SysUtil.h>    // Disk space checking
+#include <f32file.h>
+#include <s32strm.h>
+#include <s32file.h>
+#include <caf/caf.h>
+#include <symmetric.h>  // AES128CBC
+#include <dcfrep.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "DRMCommon.h"  // DRM Error messages
+#include "DRMRightsDB.h"
+#include "DRMRightsData.h"
+#include "DRMCommonData.h"
+#include "DRMPermission.h"
+#include "DRMConstraint.h"
+#include "DRMRightsCleaner.h"
+#include "DRMRightsServer.h"
+#include "DrmKeyStorage.h"
+#include "utf.h" // charconv, ConvertFromUnicodeToUtf8L
+#include "drmlog.h"
+
+#ifdef RD_DRM_RIGHTS_MANAGER_REMOVAL
+#include "drmclockclient.h"
+#endif // RD_DRM_RIGHTS_MANAGER_REMOVAL
+
+/*
+#include "flogger.h"
+
+
+_LIT( KLogDir, "drm");
+_LIT( KLogName, "backup.log");
+*/
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+#ifdef RD_MULTIPLE_DRIVE
+// Backup Directory
+_LIT( KBackupDir, "%c:\\private\\101F51F2\\backup\\" );
+#endif
+
+
+_LIT(KJavaExtension, ".jar");
+_LIT(KSISExtension, ".sis");
+_LIT(KROExtension, ".ro");
+_LIT(KXmlExtension, ".xml");
+
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT(KCIDListTempDir, "%c:\\system\\temp\\");
+#else
+_LIT(KCIDListTempDir, "c:\\system\\temp\\");
+#endif
+
+_LIT(KRODirName, "DomainROs\\");
+_LIT(KCorruptionFlagFile, "invalid");
+
+#ifdef __DRM_OMA2
+const TInt KMaxUDTDataSize = 256;
+const TInt KDeviceDataSize = 256;
+const TInt KDeviceDataBlock = 128;
+#else
+const TInt KMaxUDTDataSize = 0;
+const TInt KDeviceDataSize = 0;
+const TInt KDeviceDataBlock = 0;
+#endif
+const TInt KUdtDataPos = 4 + KDeviceDataSize;
+
+
+const TInt KEncryptionKeySize = 16;
+const TInt KMaxEncryptionSize = 8192;
+
+const TInt KMaxUpdateTime = 3000000; // consider updates to be finished within
+                                     // three seconds
+
+const TUint32 KMaxTIntVal = 2147483647; // 2^31-1
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C void CleanupData( TAny* aPtr );
+LOCAL_C void WriteIntToBlock( TInt aValue, TDes8& aBlock, TInt aOffset );
+LOCAL_C void DeleteObject( TAny* aObject );
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CleanupData
+// Used to catch errors and delete the file if it's needed
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void CleanupData( TAny* aPtr )
+    {
+    CDRMRightsDB* rdb = reinterpret_cast<CDRMRightsDB*>( aPtr );
+
+    rdb->CleanUdtData();
+    }
+
+
+LOCAL_C void WriteIntToBlock( TInt aValue, TDes8& aBlock, TInt aOffset )
+    {
+    aBlock[aOffset] =     (aValue & 0xff000000) >> 24;
+    aBlock[aOffset + 1] = (aValue & 0x00ff0000) >> 16;
+    aBlock[aOffset + 2] = (aValue & 0x0000ff00) >> 8;
+    aBlock[aOffset + 3] = (aValue & 0x000000ff);
+    }
+
+// ----------------------------------------------------------------------------
+// DeleteObject
+// Deletes the file by TFileName presented by aHandle
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void DeleteObject( TAny* aObject )
+    {
+    __ASSERT_DEBUG( aObject, User::Panic( _L( "DeleteObject" ), KErrArgument ) );
+    MDrmKeyStorage* object = reinterpret_cast< MDrmKeyStorage* >( aObject );
+    delete object;
+    object = NULL;
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::CDRMRightsDB
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMRightsDB::CDRMRightsDB( RFs& aFs ) :
+    iFileServer( aFs ),
+    iImei( NULL ),
+    iLastUpdate( Time::NullTTime() )
+    {
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::ConstructL( const TDesC& aDatabasePath,
+                               const TDesC8& aKey,
+                               const TDesC& aImei )
+    {
+    TFileName name;
+    TUint attr;
+
+    DRMLOG( _L( "RDB starting..." ) );
+
+    iDbPath = aDatabasePath.AllocL();
+
+    // create an instance of the Hash algorithm class
+    iHasher = CMD5::NewL();
+
+    // store the key
+    iKey = aKey.AllocL();
+
+    // serial number
+    iImei = aImei.AllocL();
+
+    name.Copy( *iDbPath );
+    name.Append( KCorruptionFlagFile );
+
+    if ( iFileServer.Att( name, attr ) == KErrNone )
+        {
+        iFileServer.RmDir( name );
+        iFileServer.Delete( name );
+        DeleteDBL();
+        }
+
+    InitializeDatabaseL();
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMRightsDB* CDRMRightsDB::NewLC( RFs& aFs,
+                                   const TDesC& aDatabasePath,
+                                   const TDesC8& aKey,
+                                   const TDesC& aImei )
+    {
+    CDRMRightsDB* self = new( ELeave ) CDRMRightsDB( aFs );
+    CleanupStack::PushL( self );
+    self->ConstructL( aDatabasePath, aKey, aImei );
+
+    return self;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMRightsDB* CDRMRightsDB::NewL( RFs& aFs,
+                                  const TDesC& aDatabaseFile,
+                                  const TDesC8& aKey,
+                                  const TDesC& aImei )
+    {
+    CDRMRightsDB* self = NewLC( aFs, aDatabaseFile, aKey, aImei );
+    CleanupStack::Pop();
+
+    return self;
+    };
+
+// Destructor
+CDRMRightsDB::~CDRMRightsDB()
+    {
+    if( iHasher )
+        {
+        delete iHasher;
+        iHasher = NULL;
+        }
+
+    if( iDbPath )
+        {
+        delete iDbPath;
+        iDbPath = NULL;
+        }
+
+    if( iKey )
+        {
+        delete iKey;
+        iKey = NULL;
+        }
+
+    if( iImei )
+        {
+        delete iImei;
+        iImei = NULL;
+        }
+
+    iMemStream.Close();
+
+    DRMLOG( _L( "RDB Closing." ) );
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::GetDBEntryByContentIDL
+// returns the rights objects connected to aContentID
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::GetDBEntryByContentIDL(
+    const TDesC8& aContentID,
+    RPointerArray<CDRMPermission>& aRightsList)
+    {
+    TFileName path;
+    TInt error = KErrNone;
+    CDRMRightsData* rights = NULL;
+
+#ifdef RD_DRM_RIGHTS_MANAGER_REMOVAL
+    TTime time;
+    TBool deleteAllowed = EFalse;
+    TInt timeZone = 0;
+    DRMClock::ESecurityLevel securityLevel;
+#endif // RD_DRM_RIGHTS_MANAGER_REMOVAL
+    
+    GetRightsFileNameL( aContentID, path);
+    
+#ifdef RD_DRM_RIGHTS_MANAGER_REMOVAL
+    // Get the secure time:
+    RDRMClockClient client;
+    error = client.Connect();
+    if( !error )
+        {
+        client.GetSecureTime( time, timeZone, securityLevel);
+        client.Close();
+        if( securityLevel == DRMClock::KInsecure )
+            {
+            time = Time::NullTTime();
+            }
+        }
+    else
+        {
+        time = Time::NullTTime();
+        }
+
+    // Delete expired:
+    TRAP_IGNORE( deleteAllowed = DeleteExpiredL( path, time ) );
+        
+    // Check if it's possible to delete the file as well    
+    if( deleteAllowed )
+        {
+        iFileServer.Delete( path );
+        }
+    
+    error = KErrNone;
+#endif // RD_DRM_RIGHTS_MANAGER_REMOVAL
+
+    TRAP( error, rights = CDRMRightsData::OpenL( path, iFileServer ) );
+    if( rights )
+        {
+        CleanupStack::PushL( rights );
+        }
+    else
+        {
+        if( error == KErrNotFound )
+            {
+            User::Leave( KErrCANoRights );
+            }
+        User::Leave( error );
+        }
+
+    rights->FetchAllPermissionsL( aRightsList );
+
+    CleanupStack::PopAndDestroy(); // rights
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::GetDBEntryByContentIDL
+// returns the rights object connected to aContentID and aUniqueID
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CDRMPermission* CDRMRightsDB::GetDBEntryByContentIDL(
+    const TDesC8& aContentID,
+    const TDRMUniqueID aUniqueID )
+    {
+    TFileName path;
+    TInt error = KErrNone;
+    CDRMRightsData* rights = NULL;
+    CDRMPermission* ro = NULL;
+
+    if( aUniqueID > KMaxTIntVal )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    GetRightsFileNameL( aContentID, path);
+
+    TRAP( error, rights = CDRMRightsData::OpenL( path, iFileServer ) );
+    if( rights )
+        {
+        CleanupStack::PushL( rights );
+        }
+    else
+        {
+        if( error == KErrNotFound )
+            {
+            User::Leave( KErrCANoRights );
+            }
+        User::Leave( error );
+        }
+
+    ro = CDRMPermission::NewLC();
+
+    rights->FetchPermissionL( *ro, aUniqueID );
+
+    CleanupStack::Pop(); // ro
+    CleanupStack::PopAndDestroy(); // rights
+    return ro;
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::AddDBEntryL
+// adds a new rights object into the database and uses the given aUniqueID if
+// possible, if not it generates a new one
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::AddDBEntryL( const TDesC8& aContentID,
+                                CDRMPermission& aRightsObject,
+                                const TDesC8& aEncryptionKey,
+                                TDRMUniqueID& aUniqueID )
+    {
+    TFileName path;
+    TInt error = KErrNone;
+    CDRMRightsData* rights = NULL;
+    TBuf8<16> nullDesc;
+    TBuf<16> nullDesc2;
+    HBufC8* oldKey = NULL;
+
+    DRMLOG( _L( "CDRMRightsDB::AddDBEntryL ->" ) );
+
+    // Indicate that the DB is updated
+    iLastUpdate.HomeTime();
+
+    // the key can either be empty or it can be 16 characters:
+    if( !( aEncryptionKey.Length() == KEncryptionKeySize || aEncryptionKey.Length() == 0 ) )
+        {
+        User::Leave(KErrArgument);
+        }
+        
+    TBuf8<16> keyStore = aEncryptionKey;
+    // TBuf8<16> authStore = aAuthenticationSeed
+
+    // Encrypt the key
+    ModifyKey( keyStore );
+
+    // Modify also the authentication seed
+    // ModifyKey( authStore )
+
+    GetRightsFileNameL( aContentID, path);
+
+    TRAP( error, rights = CDRMRightsData::OpenL( path, iFileServer ) );
+    if( rights )
+        {
+        CleanupStack::PushL( rights );
+
+
+        // Check that the keys match, if not leave with KErrArgument
+        oldKey = rights->GetKeyL();
+        if ( oldKey != NULL )
+            {
+            CleanupStack::PushL( oldKey );
+            if( oldKey->Compare(keyStore) )
+                {
+                User::Leave(KErrArgument);
+                }
+            CleanupStack::PopAndDestroy( oldKey );
+            }
+        }
+
+    if( error == KErrNotFound )
+        {
+        // This would need the other info if it was available:
+        CDRMCommonData* data = CDRMCommonData::NewL( aContentID, nullDesc, aRightsObject.iRiId, nullDesc2, nullDesc );
+
+        rights = CDRMRightsData::NewLC( data, keyStore, path, iFileServer );
+        }
+    else
+        {
+        User::LeaveIfError( error );
+        }
+
+    // Store the RO:
+    rights->StoreNewPermissionL( aRightsObject, aUniqueID );
+
+    CleanupStack::PopAndDestroy(); // rights
+
+    DRMLOG( _L( "CDRMRightsDB::AddDBEntryL <-" ) );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::DeleteDBEntryL
+// deletes the rights object connected to aContentID and aUniqueID
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::DeleteDBEntryL( const TDesC8& aContentID,
+                                   const TDRMUniqueID aUniqueID )
+    {
+    TFileName path;
+    TInt error = KErrNone;
+    CDRMRightsData* rights = NULL;
+
+    DRMLOG( _L( "CDRMRightsDB::DeleteDBEntryL ->" ) );
+
+    if( aUniqueID > KMaxTIntVal )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    GetRightsFileNameL( aContentID, path);
+
+    TRAP( error, rights = CDRMRightsData::OpenL( path, iFileServer ) );
+    if( rights )
+        {
+        CleanupStack::PushL( rights );
+        }
+    else
+        {
+        if( error == KErrNotFound )
+            {
+            User::Leave( DRMCommon::ENoRights );
+            }
+        User::Leave( error );
+        }
+
+    // Indicate that the DB is updated
+    iLastUpdate.HomeTime();
+    rights->DeletePermissionL( aUniqueID );
+
+    CleanupStack::PopAndDestroy(); // rights
+
+    // Check if the file can be deleted:
+    CheckCleanup( path );
+
+    DRMLOG( _L( "CDRMRightsDB::DeleteDBEntryL <-" ) );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::DeleteDBEntryL
+// deletes all rights object connected to aContenID
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::DeleteDBEntryL( const TDesC8& aContentID )
+    {
+    TFileName path;
+    TInt error = KErrNone;
+    CDRMRightsData* rights = NULL;
+
+    DRMLOG( _L( "CDRMRightsDB::DeleteDBEntryL (2) ->" ) );
+
+    GetRightsFileNameL( aContentID, path);
+
+    TRAP( error, rights = CDRMRightsData::OpenL( path, iFileServer ) );
+    if( rights )
+        {
+        CleanupStack::PushL( rights );
+        }
+    else
+        {
+        if( error == KErrNotFound )
+            {
+            User::Leave( DRMCommon::ENoRights );
+            }
+        User::Leave( error );
+        }
+
+    // Indicate that the DB is updated
+    iLastUpdate.HomeTime();
+    rights->DeleteAllPermissionsL();
+
+    CleanupStack::PopAndDestroy(); // rights
+
+    // Check if the file can be deleted:
+    CheckCleanup( path );
+
+    DRMLOG( _L( "CDRMRightsDB::DeleteDBEntryL (2) <-" ) );
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::UpdateDBEntryL
+// updates the requested rights object to the given rights object
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::UpdateDBEntryL( const TDesC8& aContentID,
+                                   const CDRMPermission& aRightsObject )
+    {
+    TFileName path;
+    TInt error = KErrNone;
+    CDRMRightsData* rights = NULL;
+
+    DRMLOG( _L( "CDRMRightsDB::UpdateDBEntryL ->" ) );
+
+    // Should never occur:
+    if( aRightsObject.iUniqueID > KMaxTIntVal )
+        {
+        User::Leave( KErrArgument );
+        }
+
+
+    GetRightsFileNameL( aContentID, path);
+
+    TRAP( error, rights = CDRMRightsData::OpenL( path, iFileServer ) );
+    if( rights )
+        {
+        CleanupStack::PushL( rights );
+        }
+    else
+        {
+        if( error == KErrNotFound )
+            {
+            User::Leave( DRMCommon::ENoRights );
+            }
+        User::Leave( error );
+        }
+
+    // Indicate that the DB is updated
+    iLastUpdate.HomeTime();
+    rights->UpdatePermissionL( aRightsObject );
+
+    CleanupStack::PopAndDestroy(); // rights
+
+    DRMLOG( _L( "CDRMRightsDB::UpdateDBEntryL <-" ) );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::ExportContentIDListL
+// writes each unique content id to the requested file
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::ExportContentIDListL( TFileName& aTempFile )
+    {
+    __UHEAP_MARK;
+    RFileWriteStream stream;
+
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    User::LeaveIfError( stream.Temp( iFileServer,
+                                     KCIDListTempDir,
+                                     aTempFile,
+                                     EFileWrite ) );
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    iFileServer.DriveToChar( driveNumber, driveLetter );
+
+    TFileName cidTemp;
+    cidTemp.Format( KCIDListTempDir, (TUint)driveLetter );
+
+    User::LeaveIfError( stream.Temp( iFileServer,
+                                   cidTemp,
+                                   aTempFile,
+                                   EFileWrite ) );
+
+#endif
+
+    CleanupClosePushL( stream );
+
+    for (TInt i = 0; i < 16; i++)
+        {
+        CDir* files = NULL;
+
+        TFileName path = *iDbPath;
+
+        path.Append(i < 10 ? i + '0' : i + 'a' - 10);
+        path.Append('\\');
+
+        if ( iFileServer.GetDir(path, KEntryAttDir, ESortNone, files) == KErrNone )
+            {
+            TInt j;
+
+            CleanupStack::PushL( files );
+
+            for (j = 0; j < files->Count(); j++)
+                {
+                TFileName tempPath( path );
+
+                tempPath.Append((*files)[j].iName);
+
+                TInt error = KErrNone;
+                CDRMRightsData* rights = NULL;
+
+                TRAP( error, rights = CDRMRightsData::OpenL( tempPath, iFileServer ) );
+                if( rights )
+                    {
+                    CleanupStack::PushL( rights );
+                    }
+                else
+                    {
+                    if( error != KErrNotFound )
+                        {
+                        User::Leave( error );
+                        }
+                    continue;
+                    }
+
+                const CDRMCommonData* data = rights->GetCommonDataL();
+                stream.WriteUint16L( data->ContentID().Length() );
+                stream.WriteL( data->ContentID() );
+
+                CleanupStack::PopAndDestroy(); // rights
+                }
+
+            CleanupStack::PopAndDestroy(); // files
+            }
+        }
+
+    stream.WriteUint16L(0);
+
+    CleanupStack::PopAndDestroy(); // stream
+
+    __UHEAP_MARKEND;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::BackupDBL
+// creates a backupfile of the current rights database and encrypts it using the
+// database encryption key
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+/*
+void CDRMRightsDB::BackupDBL( const TDesC& aWTFile,
+                              const TDesC8& aEncryptionKey )
+    {
+    };
+*/
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::MergeDBL
+// merges the backup database into the current database and deletes the backup
+// file afterwards, any rights objects with counter base rights or non activated
+// intervals are not inserted. If an equal combination of content id and unique
+// id is found that object is not restored
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+/*
+void CDRMRightsDB::MergeDBL()
+    {
+    };
+*/
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::GetDecryptionKeyL
+// returns a pointer to the decryption key of the requested content id
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDRMRightsDB::GetDecryptionKeyL(
+    const TDesC8& aContentID)
+    {
+
+    TFileName path;
+    TInt error = KErrNone;
+    HBufC8* key = NULL;
+    CDRMRightsData* rights = NULL;
+
+    GetRightsFileNameL( aContentID, path);
+
+    TRAP( error, rights = CDRMRightsData::OpenL( path, iFileServer ) );
+    if( rights )
+        {
+        CleanupStack::PushL( rights );
+        }
+    else
+        {
+        if( error == KErrNotFound )
+            {
+            User::Leave( DRMCommon::ENoRights );
+            }
+        User::Leave( error );
+        }
+
+    key = rights->GetKeyL();
+
+    // Decrypt the key
+    ModifyKey( *key );
+
+    CleanupStack::PopAndDestroy(); // rights
+
+    return key;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::DeleteDBL
+// deletes the rights database and creates a new empty one in it's place
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::DeleteDBL( void )
+    {
+    DRMLOG( _L( "CDRMRightsDB::DeleteDBL ->" ) );
+
+    // Indicate that the DB is updated
+    iLastUpdate.HomeTime();
+
+    CFileMan* fileMan = CFileMan::NewL(iFileServer);
+    fileMan->RmDir(*iDbPath);
+    delete fileMan;
+
+    InitializeDatabaseL();
+
+    DRMLOG( _L( "CDRMRightsDB::DeleteDBL <-" ) );
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::GetAmountOfRightsObjectsL
+// returns the amount of different content id's in the database
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt32 CDRMRightsDB::GetAmountOfRightsObjectsL()
+    {
+    TInt32 amount( 0 );
+
+    for (TInt i = 0; i < 16; i++)
+        {
+        CDir* files = NULL;
+
+        TFileName path = *iDbPath;
+
+        path.Append(i < 10 ? i + '0' : i + 'a' - 10);
+        path.Append('\\');
+
+        User::LeaveIfError(
+            iFileServer.GetDir(path, KEntryAttDir, ESortNone, files) );
+
+#ifdef _DEBUG
+        if ( !files )
+            {
+            DRMLOG( _L( "CDRMRightsDB::GetAmountOfRightsObject: GetDir returned NULL pointer!" ) );
+            User::Leave( KErrGeneral );
+            }
+#endif
+
+        amount += files->Count();
+        delete files;
+        }
+
+    return amount;
+    };
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::AddDomainROL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::AddDomainROL( const TDesC8& aRoId, const TDesC8& aXmlData )
+    {
+    RFile file;
+    TFileName path;
+    TPtr8 numWrite(NULL,0);
+    TInt num = 0;
+
+    DRMLOG( _L( "CDRMRightsDB::AddDomainROL ->" ) );
+
+    // Indicate that the DB is updated
+    iLastUpdate.HomeTime();
+
+    // Get the size and if it is zero, leave
+    num = aXmlData.Size();
+    if( !num )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    // Get the filename
+    GetXMLFileNameL( aRoId, path );
+
+    // Replace whatever is in there
+    User::LeaveIfError( file.Replace( iFileServer, path, EFileWrite ) );
+    CleanupClosePushL( file );
+
+    // write the size of the data
+    numWrite.Set(reinterpret_cast<TUint8*>(&num), sizeof(TInt), sizeof(TInt));
+
+    // needs a check if there is enough diskspace for sizeof(TInt) + num bytes
+
+    User::LeaveIfError( file.Write( numWrite ) );
+
+    // write the data
+    User::LeaveIfError( file.Write( aXmlData ) );
+
+    CleanupStack::PopAndDestroy(); // file
+
+    DRMLOG( _L( "CDRMRightsDB::AddDomainROL <-" ) );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::GetDomainROL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDRMRightsDB::GetDomainROL( const TDesC8& aRoId )
+    {
+    RFile file;
+    TFileName path;
+    TPtr8 inRead(NULL,0);
+    TInt num = 0;
+    HBufC8* data = NULL;
+
+    // Get the filename
+    GetXMLFileNameL( aRoId, path );
+
+    // Replace whatever is in there
+    User::LeaveIfError( file.Open( iFileServer, path, EFileRead ) );
+    CleanupClosePushL( file );
+
+    // read the size of the data
+    inRead.Set(reinterpret_cast<TUint8*>(&num), 0, sizeof(TInt));
+    User::LeaveIfError( file.Read( inRead, sizeof(TInt) ) );
+
+    if( num <= 0 )
+        {
+        User::Leave(KErrCorrupt);
+        }
+
+    data = HBufC8::NewMaxLC( num );
+
+    // read the data
+    inRead.Set( const_cast<TUint8*>( data->Ptr() ), 0, num );
+    User::LeaveIfError( file.Read( inRead, num ) );
+
+    CleanupStack::Pop(); // data
+    CleanupStack::PopAndDestroy(); // Close the file
+    return data;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::DeleteDomainROL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::DeleteDomainROL( const TDesC8& aRoId )
+    {
+    TFileName path;
+
+    DRMLOG( _L( "CDRMRightsDB::DeleteDomainROL ->" ) );
+
+    // Indicate that the DB is updated
+    iLastUpdate.HomeTime();
+
+    // Get the filename
+    GetXMLFileNameL( aRoId, path );
+
+    User::LeaveIfError( iFileServer.Delete( path ) );
+
+    DRMLOG( _L( "CDRMRightsDB::DeleteDomainROL <-" ) );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::DeleteExpiredPermissionsL
+// -----------------------------------------------------------------------------
+//
+CDRMRightsCleaner* CDRMRightsDB::DeleteExpiredPermissionsL( const TTime& aTime,
+                                                            TRequestStatus& aStatus )
+    {
+
+
+    CDRMRightsCleaner* cleaner = CDRMRightsCleaner::NewL( iFileServer,
+                                                          const_cast<CDRMRightsDB*>(this),
+                                                          aStatus,
+                                                          *iDbPath,
+                                                          aTime);
+    return cleaner;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::NameContentL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::NameContentL( const TDesC8& aContentId,
+                                 const TDesC& aName )
+    {
+    TFileName path;
+    TInt error = KErrNone;
+    CDRMRightsData* rights = NULL;
+    CDRMCommonData* data = NULL;
+
+    GetRightsFileNameL( aContentId, path);
+
+    TRAP( error, rights = CDRMRightsData::OpenL( path, iFileServer ) );
+    if( rights )
+        {
+        CleanupStack::PushL( rights );
+        }
+    else
+        {
+        User::Leave( error );
+        }
+
+    data = const_cast<CDRMCommonData*>(rights->GetCommonDataL());
+
+    data->SetContentNameL( aName );
+
+    rights->UpdateCommonDataL( data );
+
+    CleanupStack::PopAndDestroy(); // rights
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::ContentNameL
+// -----------------------------------------------------------------------------
+//
+HBufC* CDRMRightsDB::ContentNameLC( const TDesC8& aContentId )
+    {
+    TFileName path;
+    CDRMRightsData* rights( NULL );
+    HBufC* name( NULL );
+
+    GetRightsFileNameL( aContentId, path );
+
+    rights = CDRMRightsData::OpenL( path, iFileServer );
+    CleanupStack::PushL( rights );
+
+    name = const_cast< CDRMCommonData* >( rights->GetCommonDataL() )
+            ->ContentName().AllocL();
+
+    CleanupStack::PopAndDestroy(); // rights
+    CleanupStack::PushL( name );
+
+    return name;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::DeleteExpiredL
+// -----------------------------------------------------------------------------
+//
+TBool CDRMRightsDB::DeleteExpiredL( const TFileName& aFileName,
+                                   const TTime& aTime )
+    {
+    CDRMRightsData* rights = NULL;
+    TInt amountLeft = -1;
+    TBool retVal = EFalse;
+    TBool parents = EFalse;
+
+    DRMLOG( _L( "CDRMRightsDB::DeleteExpiredL ->" ) );
+
+    // Indicate that the DB is updated
+    iLastUpdate.HomeTime();
+
+    // Open the rights file
+    DRMLOG( _L("Opening the file"));
+    rights = CDRMRightsData::OpenLC( aFileName, iFileServer );
+
+    DRMLOG( _L("Running Delete"));
+    amountLeft = rights->DeleteExpiredPermissionsL( aTime, parents );
+
+    DRMLOG2( _L("Checking for left RO:s %d"), amountLeft );
+
+    // See if any permissions are left if not check if the whole file
+    // can be proposed to be deleted or not, Java files require uninstallation
+    // so those need to be checked
+    if( !amountLeft && !parents )
+        {
+        // get the common data
+        const CDRMCommonData* common= rights->GetCommonDataL();
+
+        // If it is a java file, dont allow deletion
+        if( !common->ContentName().Right(4).CompareF(KJavaExtension) )
+            {
+            DRMLOG( _L("Is java file, do not delete"));
+            retVal = EFalse;
+            }
+        else if( !common->ContentName().Right(4).CompareF(KSISExtension) )
+            {
+            DRMLOG( _L("Is an installation package, do not delete"));
+            retVal = EFalse;
+            }
+        else
+            {
+            retVal = ETrue;
+            }
+        }
+    CleanupStack::PopAndDestroy(); // rights
+
+    DRMLOG( _L( "CDRMRightsDB::DeleteExpiredL <-" ) );
+
+    return retVal;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::GetUdtDataLC
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDRMRightsDB::GetUdtDataLC()
+    {
+#ifdef __DRM_OMA2
+    HBufC8* udtData = HBufC8::NewMaxLC( KMaxUDTDataSize );
+    TFileName backupFile;
+    RFile input;
+    TInt pos = KUdtDataPos;
+    TPtr8 inRead( udtData->Des() );
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    backupFile.Copy( KBackupDirectory );
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    iFileServer.DriveToChar( driveNumber, driveLetter );
+
+    TFileName backupDir;
+    backupDir.Format( KBackupDir, (TUint)driveLetter );
+
+    backupFile.Copy( backupDir );
+
+#endif
+
+    backupFile.Append( KRightsDbBackupFile );
+
+    // Open the udt file
+    User::LeaveIfError( input.Open( iFileServer, backupFile, EFileRead ) );
+    CleanupClosePushL( input );
+
+    // Find the correct spot in the file
+    User::LeaveIfError( input.Seek( ESeekStart, pos ) );
+
+    // Read the data from the file
+    User::LeaveIfError( input.Read( inRead, KMaxUDTDataSize ) );
+
+    CleanupStack::PopAndDestroy(); // input
+    return udtData;
+ #else
+    User::Leave(KErrNotSupported);
+    return NULL;
+ #endif
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::InitiateUdtL
+// -----------------------------------------------------------------------------
+//
+#ifdef __DRM_OMA2
+void CDRMRightsDB::InitiateUdtL( const TDesC8& aKey )
+#else
+void CDRMRightsDB::InitiateUdtL( const TDesC8& )
+#endif // __DRM_OMA2
+    {
+#ifdef __DRM_OMA2
+    TFileName backupFile;
+    RFile input;
+    HBufC8* keyData = NULL;
+
+    MDrmKeyStorage* storage = DrmKeyStorageNewL();
+
+    TCleanupItem storageCleanup( DeleteObject, storage );
+    CleanupStack::PushL(storageCleanup);
+
+    keyData = storage->RsaDecryptL( aKey );
+
+    CleanupStack::PopAndDestroy();// storageCleanup
+    CleanupStack::PushL( keyData );
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    backupFile.Copy( KBackupDirectory );
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    iFileServer.DriveToChar( driveNumber, driveLetter );
+
+    TFileName backupDir;
+    backupDir.Format( KBackupDir, (TUint)driveLetter );
+
+    backupFile.Copy( backupDir );
+
+#endif
+
+    backupFile.Append( KRightsDbBackupFile );
+
+    // Open the udt file
+    User::LeaveIfError( input.Open( iFileServer, backupFile, EFileRead ) );
+    CleanupClosePushL( input );
+
+    // Add the cleanup item to the cleanup stack
+    TCleanupItem resetAndDestroy( CleanupData, reinterpret_cast<TAny*>(this) );
+    CleanupStack::PushL( resetAndDestroy );
+
+    // DEBUG DEBUG DEBUG: ignore the error
+    TRAPD( error, RestoreContentFromFileL( input,
+                             keyData->Right(KEncryptionKeySize),
+                             KDRMUDTBackup ) );
+    if( error )
+        {
+        // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("InitiateUdtL: Restore failed\n\r"));
+        User::Leave(error);
+        }
+    CleanupStack::PopAndDestroy( 3 ); // input, cleanup item, keyData
+#else
+    User::Leave(KErrNotSupported);
+#endif // __DRM_OMA2
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::GetContentIDListL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::GetContentIDListL( RPointerArray<HBufC8>& aArray )
+    {
+    HBufC8* contentId = NULL;
+
+    for (TInt i = 0; i < 16; i++)
+        {
+        CDir* files = NULL;
+
+        TFileName path = *iDbPath;
+
+        path.Append(i < 10 ? i + '0' : i + 'a' - 10);
+        path.Append('\\');
+
+        if ( iFileServer.GetDir(path, KEntryAttDir, ESortNone, files) == KErrNone )
+            {
+            CleanupStack::PushL( files );
+
+            for (TInt j = 0; j < files->Count(); j++)
+                {
+                TFileName tempPath( path );
+
+                tempPath.Append((*files)[j].iName);
+
+                TInt error = KErrNone;
+                CDRMRightsData* rights = NULL;
+
+                TRAP( error, rights = CDRMRightsData::OpenL( tempPath, iFileServer ) );
+                if( rights )
+                    {
+                    CleanupStack::PushL( rights );
+                    }
+                else
+                    {
+                    if( error != KErrNotFound )
+                        {
+                        User::Leave( error );
+                        }
+                    continue;
+                    }
+
+                const CDRMCommonData* data = rights->GetCommonDataL();
+
+                contentId = data->ContentID().AllocLC();
+                aArray.AppendL( contentId );
+                CleanupStack::Pop(); // contentId
+
+                CleanupStack::PopAndDestroy(); // rights
+                }
+
+            CleanupStack::PopAndDestroy(); // files
+            }
+        }
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::WriteEncryptedStreamL
+// The file will be opened and closed in CDRMBackup
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::WriteEncryptedStreamL( RWriteStream& aStream,
+                                          const TDesC8& aMessageData,
+                                          TDes8& aIv,
+                                          TDes8& aRemainder,
+                                          HBufC8*& aEncryptionBuffer,
+                                          TInt& aBytesWritten )
+    {
+    TInt i = 0;
+    TInt n = 0;
+    TInt size = 0;
+    TPtr8 ptr(aEncryptionBuffer->Des());
+    TPtrC8 data;
+
+    data.Set(aMessageData);
+    if (aRemainder.Size() > 0 && aRemainder.Size() + data.Size() >= KEncryptionKeySize)
+        {
+        ptr.Copy(aRemainder);
+        n = Min(KEncryptionKeySize - aRemainder.Size(), data.Size());
+        ptr.Append(data.Left(n));
+
+        EncryptL(aIv, ptr, EFalse);
+
+        aStream.WriteL(ptr);
+        aBytesWritten += ptr.Size();
+        aIv.Copy(ptr.Right(KEncryptionKeySize));
+        data.Set(data.Right(data.Size() - n));
+        aRemainder.SetLength(0);
+        }
+
+    size = data.Size();
+    for (i = 0; size > KEncryptionKeySize; i += KMaxEncryptionSize)
+        {
+        n = Min(KMaxEncryptionSize, ((size / KEncryptionKeySize)
+                * KEncryptionKeySize));
+        ptr.Copy(data.Mid(i, n));
+
+        EncryptL(aIv, ptr, EFalse);
+
+        aStream.WriteL(ptr);
+        aBytesWritten += ptr.Size();
+        aIv.Copy(ptr.Right(KEncryptionKeySize));
+        size -= n;
+        }
+    aRemainder.Append(data.Right(size));
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::FinalizeEncryptedStreamL
+// finalize the encryption
+// -----------------------------------------------------------------------------
+void CDRMRightsDB::FinalizeEncryptedStreamL( RWriteStream& aStream,
+                                             TDes8& aIv,
+                                             TDes8& aRemainder,
+                                             HBufC8*& aEncryptionBuffer,
+                                             TInt& aBytesWritten )
+    {
+    TPtr8 ptr(aEncryptionBuffer->Des());
+
+    ptr.Copy(aRemainder);
+    EncryptL(aIv, ptr, ETrue);
+    aStream.WriteL(ptr);
+    aStream.CommitL();
+    aBytesWritten += ptr.Size();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::BackupContentToFileL
+// The file will be opened and closed in CDRMBackup
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::BackupContentToFileL( RFile& aBackupFile,
+                                         const TDesC8& /* aEncryptionKey */,
+                                         const TInt /* aMode */ )
+    {
+    //RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("BackupContentToFileL\n\r"));
+    // In UDT we need to check the mode
+    TInt fileSize = 0;
+
+    TUint permissions = 0;
+    TUint8 continueMarker = 1;
+    RFile copyHandle;
+    TInt error = KErrNone;
+
+    HBufC8* dataBuffer = NULL; // This is the buffer which gets reallocated
+                               // if more space for data is required
+                               // buf only if more space is needed, otherwise
+                               // the size remains the same
+                               // for start reserve as much as for the other buffer
+                               // This is probably enough for all rights object
+                               // But it's best to be sure
+
+    TBuf8<KEncryptionKeySize> encIV;
+    TBuf8<KEncryptionKeySize> remainder;
+    HBufC8* encryptionBuffer = NULL; // The buffer used for the encryption in the middle
+                                     // reserved only once
+    TInt bytesWritten = 0;
+    TPtr8 writeData(NULL,0,0);
+    RMemWriteStream memStream;
+
+    dataBuffer = HBufC8::NewLC( KMaxEncryptionSize );
+    encryptionBuffer = HBufC8::NewLC( KMaxEncryptionSize );
+
+    User::LeaveIfError( copyHandle.Duplicate(aBackupFile) );
+
+    RFileWriteStream stream( copyHandle );
+    CleanupClosePushL( stream );
+
+    // first write the first 4 bytes empty, in the end the size is written there
+    stream.WriteInt32L( fileSize );
+
+#ifdef __DRM_OMA2
+    AddUDTDataL( stream );
+#endif
+
+    encIV.SetLength(KEncryptionKeySize);
+    // fill the iv with rnd data and write it to stream:
+    MDrmKeyStorage* storage = DrmKeyStorageNewL();
+
+    TCleanupItem storageCleanup( DeleteObject, storage );
+    CleanupStack::PushL(storageCleanup);
+
+    storage->RandomDataGetL(encIV,KEncryptionKeySize);
+    CleanupStack::PopAndDestroy();//storageCleanup
+
+    DRMLOG(_L("random encIV:"));
+    DRMLOGHEX(encIV);
+
+
+    stream.WriteL( encIV );
+
+    // loop over all the rights objects and write them to the file
+
+    for (TInt i = 0; i < 16; i++)
+        {
+        CDir* files = NULL;
+
+        TFileName path = *iDbPath;
+
+        path.Append(i < 10 ? i + '0' : i + 'a' - 10);
+        path.Append('\\');
+
+        if ( iFileServer.GetDir(path, KEntryAttDir, ESortNone, files) == KErrNone )
+            {
+            TInt j = 0;
+
+            CleanupStack::PushL( files );
+
+            for (j = 0; j < files->Count(); j++)
+                {
+                TFileName tempPath( path );
+                CDRMPointerArray<CDRMPermission> *permissionArray = CDRMPointerArray<CDRMPermission>::NewLC();
+                permissionArray->SetAutoCleanup( ETrue );
+
+                tempPath.Append((*files)[j].iName);
+
+                CDRMRightsData* rights = NULL;
+
+                rights = CDRMRightsData::OpenLC( tempPath, iFileServer );
+
+                // WRITE THE GENERIC DATA ABOUT THE OBJECT
+                //-----------------------------------------------------------
+                // First count the size we want to use:
+
+
+                writeData.Set(&continueMarker,
+                                sizeof(continueMarker),
+                                sizeof(continueMarker));
+                WriteEncryptedStreamL( stream,
+                                       writeData,
+                                       encIV,
+                                       remainder,
+                                       encryptionBuffer,
+                                       bytesWritten );
+
+                TInt sizeOfBuf = KEncryptionKeySize; // continue marker
+
+                // Get the common data, Externalize it
+                CDRMCommonData* data =
+                  const_cast<CDRMCommonData*>(rights->GetCommonDataL());
+                sizeOfBuf += data->Size();
+
+
+                // Realloc if needed, probably wont be:
+                if( sizeOfBuf > dataBuffer->Des().MaxSize() )
+                    {
+                    dataBuffer->ReAllocL( sizeOfBuf );
+                    }
+
+                // Write the size of the permission, used for decryption
+                writeData.Set( reinterpret_cast<TUint8*>(&sizeOfBuf),
+                               sizeof(sizeOfBuf),
+                               sizeof(sizeOfBuf));
+
+                WriteEncryptedStreamL( stream,
+                                       writeData,
+                                       encIV,
+                                       remainder,
+                                       encryptionBuffer,
+                                       bytesWritten );
+
+
+                memStream.Open( (TAny*)( dataBuffer->Ptr() ), sizeOfBuf );
+                CleanupClosePushL( memStream );
+
+                // The common data
+                data->ExternalizeL( memStream );
+
+                // The key
+                // Get the key, Externalize it
+                HBufC8* encKey = rights->GetKeyL();
+                if( encKey == NULL )
+                    {
+                    encKey = HBufC8::NewMaxL(KEncryptionKeySize);
+                    Mem::FillZ( const_cast<TUint8*>(encKey->Ptr()), KEncryptionKeySize);
+                    }
+                else
+                    {
+                    // Decrypt the key, the file is encrypted, it doesn't need to be twice
+                    ModifyKey( *encKey );
+                    }
+
+                CleanupStack::PushL( encKey );
+
+                memStream.WriteL( *encKey );
+                CleanupStack::PopAndDestroy(); // enc key
+
+                writeData.Set( const_cast<TUint8*>(dataBuffer->Ptr()),
+                               sizeOfBuf, sizeOfBuf );
+
+                WriteEncryptedStreamL( stream,
+                                       writeData,
+                                       encIV,
+                                       remainder,
+                                       encryptionBuffer,
+                                       bytesWritten );
+
+
+                CleanupStack::PopAndDestroy(); // memStream
+
+                // Get the permissions and externalize their amount and them
+                // If there are none ignore the error and just save the normal data
+                TRAP(error, rights->FetchAllPermissionsL( *permissionArray ) );
+                if( error )
+                    {
+                    if( !( error == KErrCANoRights || error == KErrCANoPermission ) )
+                        {
+                        User::LeaveIfError( error );
+                        }
+                    }
+
+                // WRITE THE AMOUNT OF PERMISSIONS
+                //-----------------------------------------------------------
+                permissions = permissionArray->Count();
+
+                writeData.Set(reinterpret_cast<TUint8*>(&permissions),
+                              sizeof(permissions),
+                              sizeof(permissions));
+
+                WriteEncryptedStreamL( stream,
+                                       writeData,
+                                       encIV,
+                                       remainder,
+                                       encryptionBuffer,
+                                       bytesWritten );
+
+                for( TInt count = 0; count < permissions; count++ )
+                    {
+                    // WRITE EACH PERMISSION
+                    //-----------------------------------------------------------
+                    sizeOfBuf = (*permissionArray)[count]->Size();
+
+                    // Realloc if needed, probably wont be:
+                    if( sizeOfBuf > dataBuffer->Des().MaxSize() )
+                        {
+                        dataBuffer->ReAllocL( sizeOfBuf );
+                        }
+
+                    // Write the size of the permission, used for decryption
+                    writeData.Set(reinterpret_cast<TUint8*>(&sizeOfBuf),
+                                  sizeof(sizeOfBuf),
+                                  sizeof(sizeOfBuf));
+
+                    WriteEncryptedStreamL( stream,
+                                           writeData,
+                                           encIV,
+                                           remainder,
+                                           encryptionBuffer,
+                                           bytesWritten );
+
+                    // write the actual data
+                    memStream.Open( (TAny*)( dataBuffer->Ptr() ), sizeOfBuf );
+                    CleanupClosePushL( memStream );
+
+                    (*permissionArray)[count]->ExternalizeL( memStream );
+
+                    writeData.Set( const_cast<TUint8*>(dataBuffer->Ptr()),
+                                   sizeOfBuf, sizeOfBuf );
+                    WriteEncryptedStreamL( stream,
+                                           writeData,
+                                           encIV,
+                                           remainder,
+                                           encryptionBuffer,
+                                           bytesWritten );
+
+                    CleanupStack::PopAndDestroy();  // memstream
+
+                    }
+                CleanupStack::PopAndDestroy(2); // rights, permissionArray
+                }
+
+            CleanupStack::PopAndDestroy(); // files
+            }
+        }
+    continueMarker = 0;
+    writeData.Set(&continueMarker,
+                  sizeof(continueMarker),
+                  sizeof(continueMarker));
+    WriteEncryptedStreamL( stream,
+                           writeData,
+                           encIV,
+                           remainder,
+                           encryptionBuffer,
+                           bytesWritten );
+
+    // Finalize the stream:
+    FinalizeEncryptedStreamL( stream,
+                              encIV,
+                              remainder,
+                              encryptionBuffer,
+                              bytesWritten );
+
+    CleanupStack::PopAndDestroy();// stream
+
+    // Attach it to the file again, set the stream to the beginning
+
+    User::LeaveIfError( copyHandle.Duplicate( aBackupFile ) );
+
+    stream.Attach( copyHandle );
+    CleanupClosePushL( stream );
+
+    aBackupFile.Size( fileSize );
+
+    // write the size of the file including the 4 bytes in the start
+    stream.WriteInt32L( fileSize );
+
+    CleanupStack::PopAndDestroy(3); // stream, databuffer, encryptionbuffer
+    // DEBUG
+    // Perform restore:
+    // RestoreContentFromFileL( aBackupFile, *iKey, 0 );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::RestoreContentFromFileL
+// The file will be opened and closed in CDRMBackup
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::RestoreContentFromFileL( RFile& aBackupFile,
+                                            const TDesC8& aEncryptionKey,
+                                            const TInt aMode )
+    {
+    // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreContentFromFileL\n\r"));
+    TInt8 continueMarker = 1;
+    TBuf8<16> key;
+    TBuf8<16> encryptionKey;
+    TInt permissions = 0;
+    CDRMPermission* permission = CDRMPermission::NewLC();
+    CDRMCommonData *commonData = NULL;
+    CDRMPointerArray<CDRMPermission> *permissionArray = CDRMPointerArray<CDRMPermission>::NewLC();
+    permissionArray->SetAutoCleanup( ETrue );
+    TDRMUniqueID uniqueID = 0;
+    RFile fileHandle;
+    TInt readPos = 0;
+    TInt size = 0;
+    TInt dataLeft = 0;
+    TPtr8 keyData(NULL,0,0);
+
+    // maintain knowledge about stateful rights not being restored
+    TBool stateful = EFalse;
+
+
+    DRMLOG( _L( "CDRMRightsDB::RestoreContentFromFileL ->" ) );
+
+    // Indicate that the DB is updated
+    iLastUpdate.HomeTime();
+
+    key.SetLength( KEncryptionKeySize );
+    fileHandle.Duplicate( aBackupFile );
+    CleanupClosePushL( fileHandle );
+
+    HBufC8* dataBuffer = NULL; // This is the buffer which gets reallocated
+                               // if more space for data is required
+                               // buf only if more space is needed, otherwise
+                               // the size remains the same
+                               // for start reserve as much as for the other buffer
+                               // This is probably enough for all rights object
+                               // But it's best to be sure
+
+    TBuf8<KEncryptionKeySize> encIV;
+
+    TPtr8 readData(NULL,0,0);
+
+    switch( aMode )
+        {
+        case KDRMNormalBackup:
+            {
+            encryptionKey.Copy( *iKey );
+            }
+            break;
+        case KDRMUDTBackup:
+            {
+            encryptionKey.Copy(aEncryptionKey);
+            }
+            break;
+        default:
+            User::Leave( KErrArgument );
+        }
+
+    encryptionKey.SetLength(KEncryptionKeySize);
+
+
+    dataBuffer = HBufC8::NewLC( KMaxEncryptionSize );
+
+    encIV.SetLength( KEncryptionKeySize );
+
+    // Check that the decryption works, if it doesn't then the
+    // key is faulty
+    User::LeaveIfError( aBackupFile.Size( readPos ) );
+    if( readPos < KUdtDataPos+KMaxUDTDataSize+(KEncryptionKeySize*2) )
+        {
+          // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreContentFromFileL : corrupt\n\r"));
+        User::Leave(KErrCorrupt);
+        }
+    readPos -= KEncryptionKeySize*2;
+
+    User::LeaveIfError( fileHandle.Seek( ESeekStart, readPos ) );
+
+    // Read the IV
+    readData.Set( const_cast<TUint8*>(encIV.Ptr()), 0, KEncryptionKeySize );
+    User::LeaveIfError( fileHandle.Read( readData, KEncryptionKeySize ) );
+
+    // Read the data:
+    readData.Set( const_cast<TUint8*>( dataBuffer->Ptr()), 0,
+                  KEncryptionKeySize );
+    User::LeaveIfError( fileHandle.Read( readData, KEncryptionKeySize ) );
+
+    DecryptL( encIV, readData, EFalse, encryptionKey );
+
+    // Check if the padding matches, if not the function will leave
+    CheckPaddingL( readData );
+
+    // End checking
+
+    // Now we are ready to go through the file
+    //-----------------------------------------------------------------------
+
+    // Duplicate file handle
+    readPos = KUdtDataPos+KMaxUDTDataSize;
+    User::LeaveIfError( fileHandle.Seek( ESeekStart, readPos ) );
+    iMemStream.Close();
+
+    ReadDataL( fileHandle, encIV, readData, dataBuffer,
+               dataLeft, size, ETrue, encryptionKey );
+
+    iMemStream.Open( const_cast<TUint8*>( readData.Ptr()), dataLeft);
+
+    // Read data now contains decrypted data which we can go through
+
+    // loop over all the rights objects and merge them to the db
+    while( true )
+        {
+        keyData.Set(const_cast<TUint8*>(key.Ptr()), 0, KEncryptionKeySize);
+
+        if( dataLeft < 1 )
+            {
+            size = 1;
+            iMemStream.Close();
+            ReadDataL( fileHandle, encIV, readData, dataBuffer,
+                       dataLeft, size, EFalse, encryptionKey );
+            iMemStream.Open( const_cast<TUint8*>( readData.Ptr()), dataLeft);
+            }
+
+        continueMarker = iMemStream.ReadInt8L();
+        dataLeft -= 1;
+
+        if( !continueMarker  )
+            {
+            // RFileLogger::Write(KLogDir, KLogName, EFileLoggingModeAppend, _L8("RestoreContentFromFileL : exit from loop\n\r"));
+            break;
+            }
+
+         if( dataLeft < 4 )
+            {
+            size = 4;
+            iMemStream.Close();
+            ReadDataL( fileHandle, encIV, readData, dataBuffer,
+                       dataLeft, size, EFalse, encryptionKey );
+            iMemStream.Open( const_cast<TUint8*>( readData.Ptr()), dataLeft);
+            }
+
+        // Read the size of the data:
+        size = iMemStream.ReadInt32L();
+        dataLeft -= 4;
+
+        if( size > dataLeft )
+            {
+            iMemStream.Close();
+            ReadDataL( fileHandle, encIV, readData, dataBuffer,
+                       dataLeft, size, EFalse, encryptionKey );
+            iMemStream.Open( const_cast<TUint8*>( readData.Ptr()),dataLeft);
+            }
+
+        // Read the common data:
+        commonData = CDRMCommonData::NewLC();
+        commonData->InternalizeL(iMemStream);
+
+        // Read the content encryption key
+        iMemStream.ReadL( keyData, KEncryptionKeySize );
+        dataLeft -= size;
+
+        if( dataLeft < 4 )
+            {
+            size = 4;
+            iMemStream.Close();
+            ReadDataL( fileHandle, encIV, readData, dataBuffer,
+                       dataLeft, size, EFalse, encryptionKey );
+            iMemStream.Open( const_cast<TUint8*>( readData.Ptr()), dataLeft);
+            }
+
+        // read the amount of permissions
+        permissions = iMemStream.ReadInt32L();
+        dataLeft -= 4;
+
+
+        // Create the entry if needed
+        TFileName path;
+        TInt error = KErrNone;
+        CDRMRightsData* rights = NULL;
+        TBuf8<16> nullDesc;
+        TBuf<16> nullDesc2;
+        HBufC8* oldKey = NULL;
+        TInt8 insertPerm = 1;
+        TBool doInsert = ETrue;
+        TBool keyExists = EFalse;
+
+        for( TInt counter = 0; counter < KEncryptionKeySize; counter++ )
+            {
+            if( key[counter] != 0x00 )
+                {
+                keyExists = ETrue;
+                counter = KEncryptionKeySize;
+                }
+            }
+
+
+        // Encrypt the key
+        if( keyExists )
+            {
+            ModifyKey( key );
+            }
+
+        GetRightsFileNameL( commonData->ContentID(), path);
+
+        // Indicate that the DB is updated
+        iLastUpdate.HomeTime();
+
+        TRAP( error, rights = CDRMRightsData::OpenL( path, iFileServer ) );
+
+        if( error == KErrNotFound )
+            {
+            // Indicate that the DB is updated
+            iLastUpdate.HomeTime();
+
+            if( keyExists )
+                {
+                TRAP(error, rights = CDRMRightsData::NewL( commonData, key, path, iFileServer ) );
+                }
+            else
+                {
+                TRAP(error, rights = CDRMRightsData::NewL( commonData, KNullDesC8, path, iFileServer ) );
+                }
+
+            CleanupStack::Pop(); // Pop Common Data
+            CleanupStack::PushL(rights); // Push the rights in:
+            insertPerm = -1;
+            }
+        else
+            {
+            // Destroy common data if it already exits per OpenL
+            CleanupStack::PopAndDestroy();
+
+            // Leave if another error occurred
+            User::LeaveIfError( error );
+
+            if( rights )
+                {
+                CleanupStack::PushL( rights );
+                oldKey = rights->GetKeyL();
+
+                // if there is no key and there is one in the new one
+                if( !oldKey && keyExists )
+                    {
+                    insertPerm = 0;
+                    }
+                else if( oldKey && key.Compare( *oldKey ) ) // If the key is different
+                    {
+                    insertPerm = 0;
+                    }
+                if( oldKey )
+                    {
+                    delete oldKey;
+                    }
+                }
+            }
+
+        if( !rights )
+            {
+            User::Leave( KErrGeneral );
+            }
+
+
+
+
+        if( insertPerm == -1 ) // Add everything no checks needed
+            {
+            for( TInt count = 0; count < permissions; count++ )
+                {
+                if( dataLeft < 4 )
+                    {
+                    size = 4;
+                    iMemStream.Close();
+                    ReadDataL( fileHandle, encIV, readData, dataBuffer,
+                               dataLeft, size, EFalse, encryptionKey );
+                    iMemStream.Open( const_cast<TUint8*>( readData.Ptr()), dataLeft);
+                    }
+
+                // Read the size of the data:
+                size = iMemStream.ReadInt32L();
+                dataLeft -= 4;
+
+                if( size > dataLeft )
+                    {
+                    iMemStream.Close();
+                    ReadDataL( fileHandle, encIV, readData, dataBuffer,
+                               dataLeft, size, EFalse, encryptionKey );
+                    iMemStream.Open( const_cast<TUint8*>( readData.Ptr()), dataLeft);
+                    }
+
+                permission->InternalizeL( iMemStream );
+                dataLeft -= size;
+
+                if( !permission->Stateful() || aMode == KDRMUDTBackup )
+                    {
+                    rights->StoreNewPermissionL( *permission, uniqueID );
+                    }
+                else if( !stateful )
+                    {
+                    stateful = ETrue;
+                    }
+                }
+            }
+        else if( insertPerm == 1) // Add stuff that doesn't match the times
+            {
+            // Indicate that the DB is updated
+            iLastUpdate.HomeTime();
+
+            // If there are no rights that's an ok thing
+            // Fix memory handling
+            TRAP( error, rights->FetchAllPermissionsL( *permissionArray ) );
+            if( error )
+                {
+                if( !( error == KErrCANoRights ||
+                       error == KErrCANoPermission ) )
+                    {
+                    User::LeaveIfError(error);
+                    }
+
+                }
+
+
+            for( TInt count = 0; count < permissions; count++ )
+                {
+                if( dataLeft < 4 )
+                    {
+                    size = 4;
+                    iMemStream.Close();
+                    ReadDataL( fileHandle, encIV, readData, dataBuffer,
+                               dataLeft, size, EFalse, encryptionKey );
+                    iMemStream.Open( const_cast<TUint8*>( readData.Ptr()), dataLeft);
+                    }
+
+                // Read the size of the data:
+                size = iMemStream.ReadInt32L();
+                dataLeft -= 4;
+
+                if( size > dataLeft )
+                    {
+                    iMemStream.Close();
+                    ReadDataL( fileHandle, encIV, readData, dataBuffer,
+                               dataLeft, size, EFalse, encryptionKey );
+                    iMemStream.Open( const_cast<TUint8*>( readData.Ptr()), dataLeft);
+                    }
+
+                permission->InternalizeL( iMemStream );
+                dataLeft -= size;
+
+                doInsert = ETrue;
+
+                for( TInt perm = 0; perm < permissionArray->Count(); perm++)
+                    {
+                    if( (*permissionArray)[perm]->iOriginalInsertTime ==
+                        permission->iOriginalInsertTime )
+                        {
+                        doInsert = EFalse;
+                        break;
+                        }
+                    }
+
+                if( doInsert && (!permission->Stateful() || aMode == KDRMUDTBackup ) )
+                    {
+                    rights->StoreNewPermissionL( *permission, uniqueID );
+                    }
+                else if( doInsert && !stateful )
+                    {
+                    stateful = ETrue;
+                    }
+                }
+                permissionArray->ResetAndDestroy();
+            }
+        else  // Just read it all but dont add anything
+            {
+            // Indicate that the DB is updated
+            iLastUpdate.HomeTime();
+
+            for( TInt count = 0; count < permissions; count++ )
+                {
+                if( dataLeft < 4 )
+                    {
+                    size = 4;
+                    iMemStream.Close();
+                    ReadDataL( fileHandle, encIV, readData, dataBuffer,
+                               dataLeft, size, EFalse, encryptionKey );
+                    iMemStream.Open( const_cast<TUint8*>( readData.Ptr()), dataLeft);
+                    }
+
+                // Read the size of the data:
+                size = iMemStream.ReadInt32L();
+                dataLeft -= 4;
+
+                if( size > dataLeft )
+                    {
+                    iMemStream.Close();
+                    ReadDataL( fileHandle, encIV, readData, dataBuffer,
+                               dataLeft, size, EFalse, encryptionKey );
+                    iMemStream.Open( const_cast<TUint8*>( readData.Ptr()), dataLeft);
+
+                    }
+
+                permission->InternalizeL( iMemStream );
+                dataLeft -= size;
+                }
+            }
+        CleanupStack::PopAndDestroy(); // rights
+        }
+    iMemStream.Close();
+    CleanupStack::PopAndDestroy( 4 ); // permission, permissionArray, fileHandle, dataBuffer
+
+    DRMLOG( _L( "CDRMRightsDB::RestoreContentFromFileL ->" ) );
+
+    // If there are stateful rights not put to the phone, this is always EFalse for
+    // the UDT case leave with the special error case to leave the restored database
+    // to enable UDT
+    if( stateful )
+        {
+        User::Leave( KErrPermissionDenied );
+        }
+    };
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::HashContentID
+// removed the cid: or flk: from the beginning of the content ID before hashing
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::HashContentID( TPtrC8& aHashKey, const TDesC8& aContentID )
+    {
+    TPtrC8 cid;
+    iHasher->Reset();
+
+    if ( !aContentID.Left( KFLKStringLength ).Compare( KFLKString ) )
+        {
+        cid.Set( aContentID.Right( aContentID.Length()-KCIDStringLength ) );
+        }
+    else if ( !aContentID.Left( KCIDStringLength ).Compare( KCIDString ) )
+        {
+        cid.Set( aContentID.Right( aContentID.Length()-KCIDStringLength ) );
+        }
+    else
+        {
+        cid.Set( aContentID );
+        }
+
+    aHashKey.Set( iHasher->Hash( cid ) );
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::GetRightsFileNameL
+//
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::GetRightsFileNameL(
+    const TDesC8& aContentID,
+    TFileName& aPath)
+    {
+    TPtrC8 hash;
+    TInt i;
+    TInt v;
+
+    aPath.Copy(*iDbPath);
+    HashContentID(hash, aContentID);
+    v = hash[0] >> 4;
+    aPath.Append(v < 10 ? v + '0' : v + 'a' - 10);
+    aPath.Append('\\');
+    for (i = 0; i < hash.Length(); i++)
+        {
+        v = hash[i] >> 4;
+        aPath.Append(v < 10 ? v + '0' : v + 'a' - 10);
+        v = hash[i] & 0x0f;
+        aPath.Append(v < 10 ? v + '0' : v + 'a' - 10);
+        }
+    aPath.Append(KROExtension);
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::GetXMLFileNameL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::GetXMLFileNameL(
+    const TDesC8& aRoID,
+    TFileName& aPath)
+    {
+    TPtrC8 hash;
+    TInt i;
+    TInt v;
+
+    aPath.Copy(*iDbPath);
+    HashContentID(hash, aRoID);
+    aPath.Append(KRODirName);
+    for (i = 0; i < hash.Length(); i++)
+        {
+        v = hash[i] >> 4;
+        aPath.Append(v < 10 ? v + '0' : v + 'a' - 10);
+        v = hash[i] & 0x0f;
+        aPath.Append(v < 10 ? v + '0' : v + 'a' - 10);
+        }
+    aPath.Append(KXmlExtension);
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::InitializeDatabaseL
+// initializes the database for use, called before every external interface
+// function ( not NewL, NewLC )
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::InitializeDatabaseL(void)
+    {
+    TInt i;
+    TFileName path;
+
+    DRMLOG( _L( "CDRMRightsDB::InitializeDatabaseL ->" ) );
+
+    iFileServer.MkDirAll(*iDbPath);
+    for (i = 0; i < 16; i++)
+        {
+        // Indicate that the DB is updated
+        iLastUpdate.HomeTime();
+
+        path.Copy(*iDbPath);
+        path.Append(i < 10 ? i + '0' : i + 'a' - 10);
+        path.Append('\\');
+        iFileServer.MkDir(path);
+        }
+
+    // Indicate that the DB is updated
+    iLastUpdate.HomeTime();
+
+    // Domain RO XML dir
+    path.Copy(*iDbPath);
+    path.Append(KRODirName);
+    iFileServer.MkDirAll(path);
+
+    DRMLOG( _L( "CDRMRightsDB::InitializeDatabaseL <-" ) );
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::GetXMLFileNameL
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::ModifyKey( TDesC8& aKey )
+    {
+    TInt* ptrOriginal = NULL;
+    TInt* ptrCryptKey = NULL;
+
+    // Cast into TInt pointers
+    ptrOriginal = reinterpret_cast<TInt*>( const_cast<TUint8*>( aKey.Ptr() ) );
+    ptrCryptKey = reinterpret_cast<TInt*>( const_cast<TUint8*>( iKey->Ptr() ) );
+
+    // XOR the key with the DB key
+    ptrOriginal[0] ^= ptrCryptKey[0];
+    ptrOriginal[1] ^= ptrCryptKey[1];
+    ptrOriginal[2] ^= ptrCryptKey[2];
+    ptrOriginal[3] ^= ptrCryptKey[3];
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::AddUDTDataL
+// EB = 00 || BT || PS || 00 || D
+// -----------------------------------------------------------------------------
+//
+#ifdef __DRM_OMA2
+void CDRMRightsDB::AddUDTDataL( RWriteStream& aStream )
+#else
+void CDRMRightsDB::AddUDTDataL( RWriteStream& )
+#endif // __DRM_OMA2
+    {
+#ifdef __DRM_OMA2
+    TBuf8<MDrmKeyStorage::KRdbSerialNumberLength> serialNumber;
+    TBuf8<KMaxUDTDataSize> buffer;
+    TUint8* ptr = const_cast<TUint8*>(buffer.Ptr());
+    HBufC8* result = NULL;
+    TPtr8 udtData( ptr+KDeviceDataBlock, KDeviceDataBlock, KDeviceDataBlock );
+    HBufC8* phoneSerialNumber = NULL;
+    TInt pos = 0;
+
+    MDrmKeyStorage* storage = DrmKeyStorageNewL();
+    TCleanupItem storageCleanup( DeleteObject, storage );
+    CleanupStack::PushL(storageCleanup);
+
+    storage->GetRdbSerialNumberL( serialNumber );
+
+    // Fill the descriptor with random data
+
+    TPtr8 random( const_cast<TUint8*>(buffer.Ptr()),
+                  KMaxUDTDataSize,
+                  KMaxUDTDataSize );
+
+    storage->RandomDataGetL(random,KMaxUDTDataSize);
+
+    DRMLOG(_L("random UDTData:"));
+    DRMLOGHEX(buffer);
+
+    // Get the serial number:
+    phoneSerialNumber = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *iImei );
+    CleanupStack::PushL( phoneSerialNumber );
+
+    // Device public key encrypted Rights Database Serial Number 128 bytes
+    // Device public key encrypted Rights Database Encryption Key 128 bytes
+    // ----------------------------------------------------------
+    // 00 || 02 || padding || 00 || 16bytes || 16 bytes
+
+    // Construct the 128 bit buffer
+    ptr = const_cast<TUint8*>(udtData.Ptr());
+
+    // Set the first byte to 0
+    // Set the padding type as random padding
+    ptr[0] = 0x00;
+    ptr[1] = 0x02;
+
+    pos = KDeviceDataBlock;
+    pos -= KEncryptionKeySize;
+
+    // insert the key
+    udtData.Replace( pos, KEncryptionKeySize, *iKey );
+
+    pos -= MDrmKeyStorage::KRdbSerialNumberLength;
+
+    // insert the db serial number
+    udtData.Replace( pos, MDrmKeyStorage::KRdbSerialNumberLength, serialNumber );
+
+    // insert the finish padding block
+    pos = pos - 1;
+    ptr[pos] = 0x00;
+
+    result = storage->RsaSignL( udtData );
+    CleanupStack::PushL( result );
+
+    // Write the data to the stream
+    aStream.WriteL( *result, KDeviceDataBlock );
+
+    CleanupStack::PopAndDestroy(); // result
+
+    // Device public key encrypted Device serial number 128 bytes
+    // ----------------------------------------------------------
+    // 00 || 02 || padding || 00 || Size || Imei
+
+    // Construct the 128 bit buffer
+    ptr = const_cast<TUint8*>(buffer.Ptr());
+    udtData.Set( ptr, KDeviceDataBlock, KDeviceDataBlock );
+    ptr = const_cast<TUint8*>(udtData.Ptr());
+
+    // Set the first byte to 0
+    // Set the padding type as random padding
+    ptr[0] = 0x00;
+    ptr[1] = 0x02;
+
+    pos = KDeviceDataBlock;
+    pos -= phoneSerialNumber->Length();
+
+    // insert the phone serial number
+
+    udtData.Replace( pos, phoneSerialNumber->Length(), *phoneSerialNumber );
+
+    pos -= 1;
+
+    // insert the db serial number
+    ptr[pos] = phoneSerialNumber->Length();
+
+    // insert the finish padding block
+    pos -= 1;
+    ptr[pos] = 0x00;
+
+    result = storage->RsaSignL( udtData );
+    CleanupStack::PushL( result );
+
+    // Write the data to the stream
+    aStream.WriteL( *result, KDeviceDataBlock );
+
+    CleanupStack::PopAndDestroy(); // result
+
+    ptr = const_cast<TUint8*>(buffer.Ptr());
+
+    // UDT public key encrypted Rights Database Serial Number 256 bytes
+    // UDT public key encrypted Rights Database Encryption Key 256 bytes
+    // ----------------------------------------------------------
+    // 00 || 02 || padding || 00 || Size || Imei || 16bytes || 16 bytes
+
+    // Fill the descriptor with random data
+    storage->RandomDataGetL(random,KMaxUDTDataSize);
+
+    DRMLOG(_L("random UDTData:"));
+    DRMLOGHEX(buffer);
+
+    // Make the beginning of the buffer correct for use:
+    ptr = const_cast<TUint8*>(buffer.Ptr());
+    udtData.Set( ptr, KMaxUDTDataSize, KMaxUDTDataSize );
+    ptr[0] = 0x00;
+    ptr[1] = 0x02;
+
+    pos = KMaxUDTDataSize;
+    pos -= KEncryptionKeySize;
+
+    // insert the key
+    udtData.Replace( pos, KEncryptionKeySize, *iKey );
+
+    pos -= MDrmKeyStorage::KRdbSerialNumberLength;
+
+    // insert the db serial number
+    udtData.Replace( pos, MDrmKeyStorage::KRdbSerialNumberLength, serialNumber );
+
+    // insert the phone serial number
+    pos -= phoneSerialNumber->Length();
+    udtData.Replace( pos, phoneSerialNumber->Length(), *phoneSerialNumber );
+
+    pos -= 4;
+
+    // insert the size of the phoneSerialNumber field
+    WriteIntToBlock( phoneSerialNumber->Length(), udtData, pos );
+
+    // insert the finish padding block
+    pos -= 1;
+    ptr[pos] = 0x00;
+    TInt error = KErrNone;
+
+    TPtrC8 createData( udtData.Mid(pos+1));
+
+    TRAP( error, result = storage->UdtEncryptL( createData ));
+    // No udt certificate write the block but empty
+    if( error )
+        {
+        result = HBufC8::NewMaxL( 256 );
+        Mem::FillZ( const_cast<TUint8*>(result->Ptr()), 256);
+        }
+    CleanupStack::PushL( result );
+
+    aStream.WriteL( *result, 256 );
+
+    CleanupStack::PopAndDestroy(3); //result,phoneSerialNumber, storageCleanup
+#else
+    User::Leave(KErrNotSupported);
+#endif
+    };
+
+// test function
+void CDRMRightsDB::CreateDummyUDTFileL()
+    {
+#ifdef __DRM_OMA2
+    TFileName backupFile;
+    RFile input;
+    TInt fileSize = 4 + 256 + 256;
+
+    backupFile.Copy( _L("c:\\") );
+    backupFile.Append( KRightsDbBackupFile );
+
+    // Open the udt file
+    User::LeaveIfError( input.Replace( iFileServer, backupFile, EFileRead|EFileWrite ) );
+    RFileWriteStream stream( input, 0);
+
+    stream.WriteInt32L( fileSize );
+    CleanupClosePushL(stream);
+
+    AddUDTDataL( stream );
+    CleanupStack::PopAndDestroy();
+#else
+    User::Leave(KErrNotSupported);
+#endif // __DRM_OMA2
+    };
+
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::CleanUdtData
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::CleanUdtData()
+    {
+#ifdef __DRM_OMA2
+    TFileName backupFile;
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    backupFile.Copy( KBackupDirectory );
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    iFileServer.DriveToChar( driveNumber, driveLetter );
+
+    TFileName backupDir;
+    backupDir.Format( KBackupDir, (TUint)driveLetter );
+
+    backupFile.Copy( backupDir );
+
+#endif
+
+    backupFile.Append( KRightsDbBackupFile );
+
+    // Open the udt file
+    iFileServer.Delete( backupFile );
+#endif // __DRM_OMA2
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::EncryptL
+//
+// -----------------------------------------------------------------------------
+//     // iRdb.Encrypt(aIv, ptr, ETrue);
+void CDRMRightsDB::EncryptL( const TDesC8& aIv,
+                             TPtr8& aData,
+                             TBool aAddPadding )
+    {
+    CAESEncryptor* aes = NULL;
+    CModeCBCEncryptor* cbc = NULL;
+    TInt i;
+    TInt lastBlockStart;
+    TInt dataLength;
+    TInt padding;
+    TPtr8 d(NULL, 0);
+
+    aes = CAESEncryptor::NewLC(*iKey);
+    cbc = CModeCBCEncryptor::NewL(aes, aIv);
+    CleanupStack::Pop(); // aes, now owned by cbc
+    CleanupStack::PushL(cbc);
+
+    dataLength = aData.Length();
+    lastBlockStart = (dataLength / KEncryptionKeySize) * KEncryptionKeySize;
+    for (i = 0; i < lastBlockStart; i += KEncryptionKeySize)
+        {
+        d.Set(aData.MidTPtr (i, KEncryptionKeySize));
+        cbc->Transform(d);
+        }
+
+    if (aAddPadding)
+        {
+        padding = KEncryptionKeySize - (dataLength - lastBlockStart);
+        aData.SetLength(lastBlockStart + KEncryptionKeySize);
+        for (i = dataLength; i < lastBlockStart + KEncryptionKeySize; i++)
+            {
+            aData[i] = padding;
+            }
+        d.Set(aData.MidTPtr (lastBlockStart, KEncryptionKeySize));
+        cbc->Transform(d);
+        }
+    CleanupStack::PopAndDestroy(); // cbc
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::DecryptL
+// Decrypt data and return it to the caller, using the CEK for this session
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::DecryptL( const TDesC8& aIv,
+                             TPtr8& aData,
+                             TBool aRemovePadding,
+                             const TDesC8& aEncryptionKey )
+    {
+    CAESDecryptor* aes = NULL;
+    CModeCBCDecryptor* cbc = NULL;
+    TInt i;
+    TInt n;
+    TPtr8 d(NULL, 0);
+
+    if (iKey->Length() > 0)
+        {
+        aes = CAESDecryptor::NewLC( aEncryptionKey );
+        cbc = CModeCBCDecryptor::NewLC(aes, aIv);
+        CleanupStack::Pop(); // aes, now owned by cbc
+
+        for (i = 0; i < aData.Length(); i += KEncryptionKeySize )
+            {
+            d.Set(aData.MidTPtr (i, KEncryptionKeySize));
+            cbc->Transform(d);
+            }
+        if (aRemovePadding)
+            {
+            n = aData.Length();
+            aData.SetLength(n - aData[n - 1]);
+            }
+        CleanupStack::PopAndDestroy(); // cbc
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::CheckPaddingL
+// Check if the padding matches, aka if they key used for decryption was
+// incorrect leave with KErrPermissionDenied
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::CheckPaddingL( const TDesC8& aData )
+    {
+    TUint8 character = 0;
+    TInt limiter = 0;
+
+    for( TInt i = 15; i >= limiter; i-- )
+        {
+        if( i == 15 )
+            {
+            character = aData[i];
+            if( character < 1 || character > 16 )
+                {
+                User::Leave( KErrPermissionDenied );
+                }
+            limiter = 16 - character;
+            }
+        if( aData[i] != character )
+            {
+            User::Leave( KErrPermissionDenied );
+            }
+        }
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::ReadDataL
+// Read Data from the file, if it doesn't have enough leave
+// Error handling missing
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::ReadDataL( RFile& aStream,
+                              TDes8& aEncIV,
+                              TPtr8& aReadData,
+                              HBufC8*& aDataBuffer,
+                              TInt& aDataLeft,
+                              TInt aSize,
+                              TBool aStart,
+                              const TDesC8& aEncryptionKey )
+    {
+    TPtr8 readData(NULL, 0, 0);
+    HBufC8 *newBuffer = 0;
+    TInt bufferSize = 0;
+    TInt pos = 0;
+    TUint8* currPtr = const_cast<TUint8*>(aDataBuffer->Ptr()) + aDataBuffer->Des().MaxSize();
+    currPtr -= aDataLeft;
+    currPtr -= KEncryptionKeySize;
+    TInt checknum = 0;
+
+    // In the beginning read IV from the stream                             1
+    //------------------------------------------------------------------------
+    if( aStart )
+        {
+        readData.Set( const_cast<TUint8*>(aEncIV.Ptr()), 0, KEncryptionKeySize );
+        User::LeaveIfError(aStream.Read( readData, KEncryptionKeySize ));
+        }
+    else
+        {
+        bufferSize = aDataBuffer->Des().MaxLength()-KEncryptionKeySize;
+        // Copy the old IV to the new IV
+        Mem::Copy( const_cast<TUint8*>( aEncIV.Ptr() ),
+                   const_cast<TUint8*>( aDataBuffer->Ptr() ) +
+                   bufferSize,
+                   KEncryptionKeySize );
+        }
+
+
+    // If the block is too small realloc:                                   2
+    //------------------------------------------------------------------------
+    bufferSize = aDataBuffer->Des().MaxLength()-KEncryptionKeySize;
+
+    if( aSize > bufferSize)
+        {
+        bufferSize = aSize / KEncryptionKeySize;
+        bufferSize *= KEncryptionKeySize;
+        bufferSize += 2 * KEncryptionKeySize;
+        newBuffer = HBufC8::NewLC( bufferSize );
+        }
+
+    // calculate a proper amount of data to copy so that
+    // we stay in increments of 16                                          3
+    //------------------------------------------------------------------------
+    pos = aDataLeft;
+
+    if( aDataLeft % KEncryptionKeySize )
+        {
+        pos = pos - ( pos % KEncryptionKeySize ) + KEncryptionKeySize;
+        }
+
+
+    // Copy the existing data into the buffer                               4
+    //------------------------------------------------------------------------
+    if( !newBuffer )
+        {
+        Mem::Copy( const_cast<TUint8*>( aDataBuffer->Ptr() ),
+                   const_cast<TUint8*>( aDataBuffer->Ptr() ) +
+                   ( aDataBuffer->Des().MaxLength()-KEncryptionKeySize - pos ),
+                   pos );
+        }
+    else
+        {
+        Mem::Copy( const_cast<TUint8*>( newBuffer->Ptr() ),
+                   const_cast<TUint8*>( aDataBuffer->Ptr() ) +
+                   ( aDataBuffer->Des().MaxLength()-KEncryptionKeySize - pos ),
+                   pos );
+        delete aDataBuffer;
+        aDataBuffer = newBuffer;
+        }
+
+    // Read the new data from the file                                      5
+    //------------------------------------------------------------------------
+    readData.Set( const_cast<TUint8*>( aDataBuffer->Ptr() ) + pos, 0,
+              aDataBuffer->Des().MaxLength()-KEncryptionKeySize - pos  );
+
+/*    readData.Set( aDataBuffer->Des().
+             MidTPtr( pos,
+                      aDataBuffer->Des().MaxLength() -
+                        KEncryptionKeySize -
+                        pos ) );
+*/
+    checknum = aStream.Read( readData );
+    User::LeaveIfError( checknum );
+
+    checknum = readData.Length();
+    checknum = pos + readData.Length();
+    checknum = aDataBuffer->Des().MaxLength();
+    checknum = aDataBuffer->Des().MaxLength()-KEncryptionKeySize;
+
+    // Check if we are at the final part                                    6
+    //------------------------------------------------------------------------
+    if( pos + readData.Length() !=
+        aDataBuffer->Des().MaxLength()-KEncryptionKeySize )
+        {
+        DecryptL( aEncIV, readData, ETrue, aEncryptionKey );
+        Mem::FillZ( const_cast<TUint8*>( aEncIV.Ptr() ), KEncryptionKeySize );
+        }
+    else
+        {
+        Mem::Copy( const_cast<TUint8*>( aDataBuffer->Ptr() ) +
+                   aDataBuffer->Des().MaxLength()-KEncryptionKeySize,
+                   const_cast<TUint8*>( aDataBuffer->Ptr() ) +
+                   aDataBuffer->Des().MaxLength()-(KEncryptionKeySize*2),
+                   KEncryptionKeySize );
+
+
+        DecryptL( aEncIV, readData, EFalse, aEncryptionKey );
+
+        }
+
+    // Set the buffer you read from to this:
+    aReadData.Set( const_cast<TUint8*>(aDataBuffer->Ptr()) + pos-aDataLeft,
+                   readData.Length()+aDataLeft,
+                   readData.Length()+aDataLeft);
+
+    // Set the data length
+    aDataLeft = aReadData.Length();
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::SetAuthenticationSeedL
+// Set the seed in the common data
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::SetAuthenticationSeedL( const TDesC8& aContentId,
+                                           const TDesC8& aSeed )
+    {
+    TFileName path;
+    TInt error = KErrNone;
+    CDRMRightsData* rights = NULL;
+    CDRMCommonData* data = NULL;
+
+    GetRightsFileNameL( aContentId, path);
+
+    TRAP( error, rights = CDRMRightsData::OpenL( path, iFileServer ) );
+    if( rights )
+        {
+        CleanupStack::PushL( rights );
+        }
+    else
+        {
+        User::Leave( error );
+        }
+
+    data = const_cast<CDRMCommonData*>(rights->GetCommonDataL());
+
+    data->SetAuthenticationSeedL( aSeed );
+
+    rights->UpdateCommonDataL( data );
+
+    CleanupStack::PopAndDestroy(); // rights
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::GetAuthenticationSeedL
+// Get the seed from the common data
+// -----------------------------------------------------------------------------
+//
+HBufC8* CDRMRightsDB::GetAuthenticationSeedL( const TDesC8& aContentId )
+    {
+    TFileName path;
+    CDRMRightsData* rights( NULL );
+    HBufC8* seed( NULL );
+
+    GetRightsFileNameL( aContentId, path );
+
+    rights = CDRMRightsData::OpenL( path, iFileServer );
+    CleanupStack::PushL( rights );
+
+    seed = const_cast< CDRMCommonData* >( rights->GetCommonDataL() )
+            ->AuthenticationSeed().AllocL();
+
+    CleanupStack::PopAndDestroy(); // rights
+
+    return seed;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::Updating
+// Return the iLastUpdate flag. Updating is considered as something that happens
+// in a specific time window, to acknowledge the fact that e.g. events which are
+// tiggered in the updating process come a bit later through the active
+// scheduled.
+// -----------------------------------------------------------------------------
+//
+TBool CDRMRightsDB::Updating()
+    {
+    TTime now;
+    TBool r = EFalse;
+    TTimeIntervalMicroSeconds interval;
+
+    now.HomeTime();
+    interval = now.MicroSecondsFrom( iLastUpdate );
+
+#ifdef _LOGGING
+    TBuf<256> logBuffer;
+    logBuffer.AppendNum( interval.Int64() );
+    DRMLOG( _L(" CDRMRightsDB::Updating: Update interval: " ) );
+    DRMLOG( logBuffer );
+#endif
+
+    if ( interval < KMaxUpdateTime )
+        {
+        r = ETrue;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::MarkAsCorrupted
+// Mark the DB as corrupted by creating a specific file in the RDB structure. If
+// that file is detected, the RDB gets recreated.
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::MarkAsCorrupted()
+    {
+    TFileName name;
+    RFile file;
+
+    name.Copy( *iDbPath );
+    name.Append( KCorruptionFlagFile );
+    file.Create( iFileServer, name, EFileWrite );
+    file.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMRightsDB::CheckCleanup
+// Delete the db file if it's possible
+// -----------------------------------------------------------------------------
+//
+void CDRMRightsDB::CheckCleanup( const TDesC& aFileName )
+    {
+    TInt canDelete = 0;
+    TInt error = KErrNone;
+
+    TRAP(error, canDelete = DeleteExpiredL( aFileName, Time::NullTTime()));
+
+    if( !error && canDelete )
+        {
+        DRMLOG(_L("File empty, deletion allowed, deleting it:"));
+        DRMLOG( aFileName );
+        iFileServer.Delete( aFileName );
+        }
+    }
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/inc/MultipartHandler.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef MULTIPARTHANDLER_H
+#define MULTIPARTHANDLER_H
+
+// CLASS DECLARATION
+
+/**
+*  TMultipartHandler: parses MIME multipart data
+*
+*  @lib    -
+*  @since  3.0
+*/
+class TMultipartHandler
+    {
+public:
+    static const TInt KMaxBoundaryLength = 80;
+
+    enum TState
+        {
+        EPreamble,
+        EBodyPartHeaders,
+        EBodyPart,
+        EEpilog
+        };
+
+    TMultipartHandler();
+    
+    void WriteL(
+        const TDesC8& aData);
+        
+    virtual void HandleBodyHeaderDataL(
+        const TDesC8& aData);
+
+    virtual void HandleBodyDataL(
+        const TDesC8& aData);
+
+    virtual void StartBodyPartHeadersL();
+    
+    virtual void EndBodyPartHeadersL();
+    
+    virtual void StartBodyPartL();
+    
+    virtual void EndBodyPartL();
+
+protected:
+
+    void HandlePreambleL(
+        const TDesC8& aData);
+
+    void HandleBodyPartHeadersL(
+        const TDesC8& aData);
+
+    void HandleBodyPartL(
+        const TDesC8& aData);
+
+    TBool FindDelimiter(
+        const TDesC8& aBuffer,
+        TInt& aStart,
+        TInt& aEnd);
+        
+    TBool FindHeaderEnd(
+        const TDesC8& aBuffer,
+        TInt& aStart,
+        TInt& aEnd);
+        
+    TBool FindDashBoundary(
+        const TDesC8& aBuffer, 
+        TInt& aStart, 
+        TInt& aEnd);
+        
+protected:
+    
+    TBuf8<KMaxBoundaryLength> iDelimiter;
+    TBuf8<KMaxBoundaryLength> iBuffer;
+    TState iState;
+    
+    };
+    
+#endif      // MULTIPARTHANDLER_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/inc/dbwatcher.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,96 @@
+/*
+* 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:  Declaration of the CDbWatcher class
+*
+*/
+
+
+#ifndef DBWATCHER_H
+#define DBWATCHER_H
+
+#include "dirwatcher.h"
+#include "watcherobserver.h"
+
+/**
+ *  Watches the rights database to detect adding or removing of files
+ *
+ *  Uses change notifications on the RDB directories, restarts the device if
+ *  unauthorized modifications have been detected
+ *
+ *  @since S60 3.0
+ */
+NONSHARABLE_CLASS( CDbWatcher ): public CBase
+    {
+
+public:
+
+    /**  Number of directories to watch */
+    static const TInt KNumDirs = 17;
+
+    static CDbWatcher* NewL( MWatcherObserver& aObserver );
+
+    virtual ~CDbWatcher();
+
+    /**
+     * Start watching the database
+     *
+     * @since S60 3.0
+     */
+    void StartWatching();
+
+protected:
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Cancel outstanding requests
+     *
+     * @since S60 3.0
+     */
+    void DoCancel();
+    
+    /**
+     * From CActive.
+     * Handle events
+     *
+     * @since S60 3.0
+     */
+    void RunL();
+    
+private:
+
+    CDbWatcher();
+
+    void ConstructL( MWatcherObserver& aObserver );
+
+private: // data
+
+    /**
+     * Actual watcher objects
+     */
+    CDirWatcher* iDirWatcher[KNumDirs]; 
+    
+    /**
+     * Array of request status fields
+     */
+    TRequestStatus iRequestStatus[KNumDirs];
+
+    /**
+     * File server instance
+     */
+    RFs iFs;
+    };
+
+#endif // DBWATCHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/inc/dirwatcher.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,83 @@
+/*
+* 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:  Declaration of the CDirWatcher class
+*
+*/
+
+
+#ifndef DIRWATCHER_H
+#define DIRWATCHER_H
+
+#include "watcherobserver.h"
+
+/**  Prefix used when signaling the observer which directory has changed */
+_LIT( KDirIdentifier, "RDB: " );
+
+/**
+ *  Watches a single directory
+ *
+ *  Uses change notifications on the RDB directories, restarts the device if
+ *  unauthorized modifications have been detected
+ *
+ *  @since S60 3.0
+ */
+NONSHARABLE_CLASS( CDirWatcher ): public CActive
+    {
+public:
+
+    static CDirWatcher* NewL( MWatcherObserver& aObserver, RFs& aFs, const TDesC& aDir );
+
+    virtual ~CDirWatcher();
+
+    /**
+     * Start watching the database
+     *
+     * @since S60 3.0
+     */
+    void StartWatching();
+
+protected:
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Cancel outstanding requests
+     *
+     * @since S60 3.0
+     */
+    void DoCancel();
+    
+    /**
+     * From CActive.
+     * Handle events
+     *
+     * @since S60 3.0
+     */
+    void RunL();
+    
+private:
+
+    CDirWatcher( MWatcherObserver& aObserver, RFs& aFs );
+
+    void ConstructL( const TDesC& aDir );
+
+private: // data
+
+    RFs& iFs;
+    TFileName iDir;
+    MWatcherObserver& iObserver;
+    };
+
+#endif // DIRWATCHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/inc/drmaescrypto.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,50 @@
+/*
+* 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:  AES encryptor function for drm engine use
+*
+*/
+
+#ifndef DRMAESCRYPTO_H
+#define DRMAESCRYPTO_H
+
+/**
+*  DrmAesCrypto - utility for encrypting drm content using AES128-CBC
+*  @note for DRM engine internal use only
+*
+*  @lib drmcrypto.dll
+*  @since S60 v5.0
+*/
+NONSHARABLE_CLASS( DrmAesCrypto )
+    {
+public:
+    /**
+    * DrmAesEncryptL
+    *
+    * @since S60 v5.0
+    * @param aKey 16 bytes long encryption key
+    * @param aIV initial vector used in enctypting
+    *            (becomes 1st block of encrypted data)
+    * @param aAddPadding padding addition flag (RFC 2630 padding added if true)
+    * @param aData data to be encrypted
+    * @return encrypted (and possibly padded) data
+    */
+    IMPORT_C static HBufC8* DrmAesEncryptL(
+        const TDesC8& aKey,
+        const TDesC8& aIV,
+        const TBool aAddPadding,
+        const TDesC8& aData );
+
+    };
+
+#endif // DRMAESCRYPTO_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/inc/drmrel2_1stringdict00.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,520 @@
+/*
+* Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  String Dictionary for OMA 2.1 Drm
+*
+*/
+
+
+#ifndef C_DRMREL2_1STRINGDICT00_H
+#define C_DRMREL2_1STRINGDICT00_H
+
+#include <e32std.h>
+#include <stringpool.h>
+#include <xml/plugins/stringdictionary.h>
+
+
+class CDrmRel2_1StringDict00 : public CBase, public Xml::MStringDictionary
+/**
+The DrmRel2_1StringDict00 class is a derived class defining the API of a single string dictionary. 
+
+Derived classes must add all elements, attributes names, and attribute values that belong
+to this string dictionary as static string tables to the StringPool. WBXML token mappings between 
+strings and WBXML tokens should also be maintained.
+
+@internalTechnology
+@interim This is the first drop of this component.
+*/
+	{
+public:
+	static Xml::MStringDictionary* NewL( TAny* aStringPool );
+	virtual ~CDrmRel2_1StringDict00();
+	void ConstructL();
+
+	void ElementL( TInt aToken, RString& aElement ) const;
+	void AttributeL( TInt aToken, RString& aAttribute ) const;
+	void AttributeValuePairL( TInt aToken, RString& aAttribute, RString& aValue ) const;
+	void AttributeValueL( TInt aToken, RString& aValue ) const;
+
+	TBool CompareThisDictionary( const RString& aDictionaryDescription ) const;
+
+	TInt SwitchCodePage( TInt aCodePage );
+	void PublicIdentifier( RString& aPubId );
+	void NamespaceUri( RString& aUri );
+
+	void Release();
+
+public:
+
+	// CodePage tokens.
+	//
+	// Note: There will be correlation between these token values and their
+	// strings via the CDictionaryCodePage using the RStringPool.
+    enum TTagToken
+        {
+		// CodePage 00
+		// -//OMA/DRM 2.1//EN
+        ERoapTrigger = 0x05,
+        ERoapTriggerWithContent = 0x45,
+        ERoapTriggerWithAttributes = 0x85,
+        ERoapTriggerWithContentAndAttributes = 0xC5,
+        ERegistrationRequest = 0x06,
+        ERegistrationRequestWithContent = 0x46,
+        ERegistrationRequestWithAttributes = 0x86,
+        ERegistrationRequestWithContentAndAttributes = 0xC6,
+        EROAcquisition = 0x07,
+        EROAcquisitionWithContent = 0x47,
+        EROAcquisitionWithAttributes = 0x87,
+        EROAcquisitionWithContentAndAttributes = 0xC7,
+        EJoinDomain = 0x08,
+        EJoinDomainWithContent = 0x48,
+        EJoinDomainWithAttributes = 0x88,
+        EJoinDomainWithContentAndAttributes = 0xC8,
+        ELeaveDomain = 0x09,
+        ELeaveDomainWithContent = 0x49,
+        ELeaveDomainWithAttributes = 0x89,
+        ELeaveDomainWithContentAndAttributes = 0xC9,
+        ESignature = 0x0A,
+        ESignatureWithContent = 0x4A,
+        ESignatureWithAttributes = 0x8A,
+        ESignatureWithContentAndAttributes = 0xCA,
+        EEncKey = 0x0B,
+        EEncKeyWithContent = 0x4B,
+        EEncKeyWithAttributes = 0x8B,
+        EEncKeyWithContentAndAttributes = 0xCB,
+        ERiId = 0x0C,
+        ERiIdWithContent = 0x4C,
+        ERiIdWithAttributes = 0x8C,
+        ERiIdWithContentAndAttributes = 0xCC,
+        ERiAlias = 0x0D,
+        ERiAliasWithContent = 0x4D,
+        ERiAliasWithAttributes = 0x8D,
+        ERiAliasWithContentAndAttributes = 0xCD,
+        ENonce = 0x0E,
+        ENonceWithContent = 0x4E,
+        ENonceWithAttributes = 0x8E,
+        ENonceWithContentAndAttributes = 0xCE,
+        ERoapUrl = 0x0F,
+        ERoapUrlWithContent = 0x4F,
+        ERoapUrlWithAttributes = 0x8F,
+        ERoapUrlWithContentAndAttributes = 0xCF,
+        EDomainId = 0x10,
+        EDomainIdWithContent = 0x50,
+        EDomainIdWithAttributes = 0x90,
+        EDomainIdWithContentAndAttributes = 0xD0,
+        EDomainAlias = 0x11,
+        EDomainAliasWithContent = 0x51,
+        EDomainAliasWithAttributes = 0x91,
+        EDomainAliasWithContentAndAttributes = 0xD1,
+        ERoapDomainId = 0x12,
+        ERoapDomainIdWithContent = 0x52,
+        ERoapDomainIdWithAttributes = 0x92,
+        ERoapDomainIdWithContentAndAttributes = 0xD2,
+        ERoId = 0x13,
+        ERoIdWithContent = 0x53,
+        ERoIdWithAttributes = 0x93,
+        ERoIdWithContentAndAttributes = 0xD3,
+        ERoAlias = 0x14,
+        ERoAliasWithContent = 0x54,
+        ERoAliasWithAttributes = 0x94,
+        ERoAliasWithContentAndAttributes = 0xD4,
+        EContentId = 0x15,
+        EContentIdWithContent = 0x55,
+        EContentIdWithAttributes = 0x95,
+        EContentIdWithContentAndAttributes = 0xD5,
+        ERoapX509SPKIHash = 0x16,
+        ERoapX509SPKIHashWithContent = 0x56,
+        ERoapX509SPKIHashWithAttributes = 0x96,
+        ERoapX509SPKIHashWithContentAndAttributes = 0xD6,
+        EKeyIdentifier = 0x17,
+        EKeyIdentifierWithContent = 0x57,
+        EKeyIdentifierWithAttributes = 0x97,
+        EKeyIdentifierWithContentAndAttributes = 0xD7,
+        EHash = 0x18,
+        EHashWithContent = 0x58,
+        EHashWithAttributes = 0x98,
+        EHashWithContentAndAttributes = 0xD8,
+        EDsSignedInfo = 0x19,
+        EDsSignedInfoWithContent = 0x59,
+        EDsSignedInfoWithAttributes = 0x99,
+        EDsSignedInfoWithContentAndAttributes = 0xD9,
+        EDsSignatureValue = 0x1A,
+        EDsSignatureValueWithContent = 0x5A,
+        EDsSignatureValueWithAttributes = 0x9A,
+        EDsSignatureValueWithContentAndAttributes = 0xDA,
+        EDsKeyInfo = 0x1B,
+        EDsKeyInfoWithContent = 0x5B,
+        EDsKeyInfoWithAttributes = 0x9B,
+        EDsKeyInfoWithContentAndAttributes = 0xDB,
+        EDsCanonicalisationMethod = 0x1C,
+        EDsCanonicalisationMethodWithContent = 0x5C,
+        EDsCanonicalisationMethodWithAttributes = 0x9C,
+        EDsCanonicalisationMethodWithContentAndAttributes = 0xDC,
+        EDsSignatureMethod = 0x1D,
+        EDsSignatureMethodWithContent = 0x5D,
+        EDsSignatureMethodWithAttributes = 0x9D,
+        EDsSignatureMethodWithContentAndAttributes = 0xDD,
+        EDsReference = 0x1E,
+        EDsReferenceWithContent = 0x5E,
+        EDsReferenceWithAttributes = 0x9E,
+        EDsReferenceWithContentAndAttributes = 0xDE,
+        EDsRetrievalMethod = 0x1F,
+        EDsRetrievalMethodWithContent = 0x5F,
+        EDsRetrievalMethodWithAttributes = 0x9F,
+        EDsRetrievalMethodWithContentAndAttributes = 0xDF,
+        EDsTransforms = 0x20,
+        EDsTransformsWithContent = 0x60,
+        EDsTransformsWithAttributes = 0xA0,
+        EDsTransformsWithContentAndAttributes = 0xE0,
+        EDsDigestMethod = 0x21,
+        EDsDigestMethodWithContent = 0x61,
+        EDsDigestMethodWithAttributes = 0xA1,
+        EDsDigestMethodWithContentAndAttributes = 0xE1,
+        EDsDigestValue = 0x22,
+        EDsDigestValueWithContent = 0x62,
+        EDsDigestValueWithAttributes = 0xA2,
+        EDsDigestValueWithContentAndAttributes = 0xE2,
+        EDsTransform = 0x23,
+        EDsTransformWithContent = 0x63,
+        EDsTransformWithAttributes = 0xA3,
+        EDsTransformWithContentAndAttributes = 0xE3,
+        EXencEncryptionMethod = 0x24,
+        EXencEncryptionMethodWithContent = 0x64,
+        EXencEncryptionMethodWithAttributes = 0xA4,
+        EXencEncryptionMethodWithContentAndAttributes = 0xE4,
+        EXencCipherData = 0x25,
+        EXencCipherDataWithContent = 0x65,
+        EXencCipherDataWithAttributes = 0xA5,
+        EXencCipherDataWithContentAndAttributes = 0xE5,
+        EXencCipherValue = 0x26,
+        EXencCipherValueWithContent = 0x66,
+        EXencCipherValueWithAttributes = 0xA6,
+        EXencCipherValueWithContentAndAttributes = 0xE6,
+        EExtentedTrigger = 0x27,
+        EExtentedTriggerWithContent = 0x67,
+        EExtentedTriggerWithAttributes = 0xA7,
+        EExtentedTriggerWithContentAndAttributes = 0xE7,
+        ETrgLeaveDomain = 0x28,
+        ETrgLeaveDomainWithContent = 0x68,
+        ETrgLeaveDomainWithAttributes = 0xA8,
+        ETrgLeaveDomainWithContentAndAttributes = 0xE8,
+        EDeviceId = 0x29,
+        EDeviceIdWithContent = 0x69,
+        EDeviceIdWithAttributes = 0xA9,
+        EDeviceIdWithContentAndAttributes = 0xE9
+        };
+
+
+	enum TAttributeToken
+        {
+		// CodePage 00
+		// -//OMA/DRM 2.1//EN
+        EXsiType = 0x05,
+        EXmlnsRoap = 0x06,
+        EXmlnsXsi = 0x07,
+        EXmlnsXenc = 0x08,
+        EXmlnsDs = 0x09,
+        EXmlnsOex = 0x0A,
+        EXmlnsOdd = 0x0B,
+        EXmlnsOmadd = 0x0C,
+        EVersion = 0x0D,
+        EProxy = 0x0E,
+        EId = 0x0F, 
+        EId2 = 0x10,
+        ELCAlgorithm = 0x11,
+        EHCAlgorithm = 0x12,
+        EUri = 0x13,
+        EType = 0x14
+        };
+
+
+
+	enum TAttributeValueToken
+        {
+		// CodePage 00
+		// -//OMA/DRM 2.1//EN
+        EXsiTypeValue = 0x05,
+        EXmlnsRoapValue = 0x06,
+        EXmlnsXsiValue = 0x07,
+        EXmlnsXencValue = 0x08,
+        EXmlnsDsValue = 0x09,
+        EXmlnsOexValue = 0x0A,
+        EXmlnsOddValue = 0x0B,
+        EXmlnsOmaddValue = 0x0C,
+        EVersionValue = 0x0D,
+        EProxyValue = 0x0E,
+        EIdValue = 0x0F, 
+        EId2Value = 0x10,
+        ELCAlgorithmValue = 0x11,
+        EHCAlgorithmValue = 0x12,
+        EUriValue = 0x13,
+        ETypeValue = 0x14,
+        EUrn = 0x85,
+        EOdrlEx = 0x86,
+        EOdrlDd = 0x87,
+        EOmaDd = 0x88,
+        EXmldSig = 0x89,
+        EXmlEnc = 0x8A,
+        EXmlSchema = 0x8B,
+        ERoapX509SPKIHashValue = 0x8C,
+        EXmldSigSha1 = 0x8D,
+        EXmlExcC14 = 0x8E,
+        EXmldSigHmacSha1 = 0x8F,
+        EVersion1 = 0x90,
+        EVersion2 = 0x91,
+        EVersion21 = 0x92,
+        EIdentificationRequest = 0x93,
+        ERoUploadRequest = 0x94,
+        EMeteringReport = 0x95,
+        ELeaveDomainValue = 0x96
+	    };
+
+
+
+private:
+
+	CDrmRel2_1StringDict00( RStringPool* aStringPool );
+
+private:
+
+    /**
+    The StringPool for this string dictionary.
+    We don't own this.
+    */
+	RStringPool				iStringPool;
+
+	Xml::CDictionaryCodePage*	iCodepage00Table;
+
+	TInt					iCodePage;
+
+	};
+
+
+const TInt iTagCodePage00[] = 
+	{
+    CDrmRel2_1StringDict00::ERoapTrigger,
+    CDrmRel2_1StringDict00::ERoapTriggerWithContent,
+    CDrmRel2_1StringDict00::ERoapTriggerWithAttributes,
+    CDrmRel2_1StringDict00::ERoapTriggerWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ERegistrationRequest,
+    CDrmRel2_1StringDict00::ERegistrationRequestWithContent,
+    CDrmRel2_1StringDict00::ERegistrationRequestWithAttributes,
+    CDrmRel2_1StringDict00::ERegistrationRequestWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EROAcquisition,
+    CDrmRel2_1StringDict00::EROAcquisitionWithContent,
+    CDrmRel2_1StringDict00::EROAcquisitionWithAttributes,
+    CDrmRel2_1StringDict00::EROAcquisitionWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EJoinDomain,
+    CDrmRel2_1StringDict00::EJoinDomainWithContent,
+    CDrmRel2_1StringDict00::EJoinDomainWithAttributes,
+    CDrmRel2_1StringDict00::EJoinDomainWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ELeaveDomain,
+    CDrmRel2_1StringDict00::ELeaveDomainWithContent,
+    CDrmRel2_1StringDict00::ELeaveDomainWithAttributes,
+    CDrmRel2_1StringDict00::ELeaveDomainWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ESignature,
+    CDrmRel2_1StringDict00::ESignatureWithContent,
+    CDrmRel2_1StringDict00::ESignatureWithAttributes,
+    CDrmRel2_1StringDict00::ESignatureWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EEncKey,
+    CDrmRel2_1StringDict00::EEncKeyWithContent,
+    CDrmRel2_1StringDict00::EEncKeyWithAttributes,
+    CDrmRel2_1StringDict00::EEncKeyWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ERiId,
+    CDrmRel2_1StringDict00::ERiIdWithContent,
+    CDrmRel2_1StringDict00::ERiIdWithAttributes,
+    CDrmRel2_1StringDict00::ERiIdWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ERiAlias,
+    CDrmRel2_1StringDict00::ERiAliasWithContent,
+    CDrmRel2_1StringDict00::ERiAliasWithAttributes,
+    CDrmRel2_1StringDict00::ERiAliasWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ENonce,
+    CDrmRel2_1StringDict00::ENonceWithContent,
+    CDrmRel2_1StringDict00::ENonceWithAttributes,
+    CDrmRel2_1StringDict00::ENonceWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ERoapUrl,
+    CDrmRel2_1StringDict00::ERoapUrlWithContent,
+    CDrmRel2_1StringDict00::ERoapUrlWithAttributes,
+    CDrmRel2_1StringDict00::ERoapUrlWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDomainId,
+    CDrmRel2_1StringDict00::EDomainIdWithContent,
+    CDrmRel2_1StringDict00::EDomainIdWithAttributes,
+    CDrmRel2_1StringDict00::EDomainIdWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDomainAlias,
+    CDrmRel2_1StringDict00::EDomainAliasWithContent,
+    CDrmRel2_1StringDict00::EDomainAliasWithAttributes,
+    CDrmRel2_1StringDict00::EDomainAliasWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ERoapDomainId,
+    CDrmRel2_1StringDict00::ERoapDomainIdWithContent,
+    CDrmRel2_1StringDict00::ERoapDomainIdWithAttributes,
+    CDrmRel2_1StringDict00::ERoapDomainIdWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ERoId,
+    CDrmRel2_1StringDict00::ERoIdWithContent,
+    CDrmRel2_1StringDict00::ERoIdWithAttributes,
+    CDrmRel2_1StringDict00::ERoIdWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ERoAlias,
+    CDrmRel2_1StringDict00::ERoAliasWithContent,
+    CDrmRel2_1StringDict00::ERoAliasWithAttributes,
+    CDrmRel2_1StringDict00::ERoAliasWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EContentId,
+    CDrmRel2_1StringDict00::EContentIdWithContent,
+    CDrmRel2_1StringDict00::EContentIdWithAttributes,
+    CDrmRel2_1StringDict00::EContentIdWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ERoapX509SPKIHash,
+    CDrmRel2_1StringDict00::ERoapX509SPKIHashWithContent,
+    CDrmRel2_1StringDict00::ERoapX509SPKIHashWithAttributes,
+    CDrmRel2_1StringDict00::ERoapX509SPKIHashWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EKeyIdentifier,
+    CDrmRel2_1StringDict00::EKeyIdentifierWithContent,
+    CDrmRel2_1StringDict00::EKeyIdentifierWithAttributes,
+    CDrmRel2_1StringDict00::EKeyIdentifierWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EHash,
+    CDrmRel2_1StringDict00::EHashWithContent,
+    CDrmRel2_1StringDict00::EHashWithAttributes,
+    CDrmRel2_1StringDict00::EHashWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDsSignedInfo,
+    CDrmRel2_1StringDict00::EDsSignedInfoWithContent,
+    CDrmRel2_1StringDict00::EDsSignedInfoWithAttributes,
+    CDrmRel2_1StringDict00::EDsSignedInfoWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDsSignatureValue,
+    CDrmRel2_1StringDict00::EDsSignatureValueWithContent,
+    CDrmRel2_1StringDict00::EDsSignatureValueWithAttributes,
+    CDrmRel2_1StringDict00::EDsSignatureValueWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDsKeyInfo,
+    CDrmRel2_1StringDict00::EDsKeyInfoWithContent,
+    CDrmRel2_1StringDict00::EDsKeyInfoWithAttributes,
+    CDrmRel2_1StringDict00::EDsKeyInfoWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDsCanonicalisationMethod,
+    CDrmRel2_1StringDict00::EDsCanonicalisationMethodWithContent,
+    CDrmRel2_1StringDict00::EDsCanonicalisationMethodWithAttributes,
+    CDrmRel2_1StringDict00::EDsCanonicalisationMethodWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDsSignatureMethod,
+    CDrmRel2_1StringDict00::EDsSignatureMethodWithContent,
+    CDrmRel2_1StringDict00::EDsSignatureMethodWithAttributes,
+    CDrmRel2_1StringDict00::EDsSignatureMethodWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDsReference,
+    CDrmRel2_1StringDict00::EDsReferenceWithContent,
+    CDrmRel2_1StringDict00::EDsReferenceWithAttributes,
+    CDrmRel2_1StringDict00::EDsReferenceWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDsRetrievalMethod,
+    CDrmRel2_1StringDict00::EDsRetrievalMethodWithContent,
+    CDrmRel2_1StringDict00::EDsRetrievalMethodWithAttributes,
+    CDrmRel2_1StringDict00::EDsRetrievalMethodWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDsTransforms,
+    CDrmRel2_1StringDict00::EDsTransformsWithContent,
+    CDrmRel2_1StringDict00::EDsTransformsWithAttributes,
+    CDrmRel2_1StringDict00::EDsTransformsWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDsDigestMethod,
+    CDrmRel2_1StringDict00::EDsDigestMethodWithContent,
+    CDrmRel2_1StringDict00::EDsDigestMethodWithAttributes,
+    CDrmRel2_1StringDict00::EDsDigestMethodWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDsDigestValue,
+    CDrmRel2_1StringDict00::EDsDigestValueWithContent,
+    CDrmRel2_1StringDict00::EDsDigestValueWithAttributes,
+    CDrmRel2_1StringDict00::EDsDigestValueWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDsTransform,
+    CDrmRel2_1StringDict00::EDsTransformWithContent,
+    CDrmRel2_1StringDict00::EDsTransformWithAttributes,
+    CDrmRel2_1StringDict00::EDsTransformWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EXencEncryptionMethod,
+    CDrmRel2_1StringDict00::EXencEncryptionMethodWithContent,
+    CDrmRel2_1StringDict00::EXencEncryptionMethodWithAttributes,
+    CDrmRel2_1StringDict00::EXencEncryptionMethodWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EXencCipherData,
+    CDrmRel2_1StringDict00::EXencCipherDataWithContent,
+    CDrmRel2_1StringDict00::EXencCipherDataWithAttributes,
+    CDrmRel2_1StringDict00::EXencCipherDataWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EXencCipherValue,
+    CDrmRel2_1StringDict00::EXencCipherValueWithContent,
+    CDrmRel2_1StringDict00::EXencCipherValueWithAttributes,
+    CDrmRel2_1StringDict00::EXencCipherValueWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EExtentedTrigger,
+    CDrmRel2_1StringDict00::EExtentedTriggerWithContent,
+    CDrmRel2_1StringDict00::EExtentedTriggerWithAttributes,
+    CDrmRel2_1StringDict00::EExtentedTriggerWithContentAndAttributes,
+    CDrmRel2_1StringDict00::ETrgLeaveDomain,
+    CDrmRel2_1StringDict00::ETrgLeaveDomainWithContent,
+    CDrmRel2_1StringDict00::ETrgLeaveDomainWithAttributes,
+    CDrmRel2_1StringDict00::ETrgLeaveDomainWithContentAndAttributes,
+    CDrmRel2_1StringDict00::EDeviceId,
+    CDrmRel2_1StringDict00::EDeviceIdWithContent,
+    CDrmRel2_1StringDict00::EDeviceIdWithAttributes,
+    CDrmRel2_1StringDict00::EDeviceIdWithContentAndAttributes,
+	0 // ok to end with zero as this is used by a global token
+    }; 
+
+
+const TInt iAttributeCodePage00[] = 
+	{
+    CDrmRel2_1StringDict00::EXsiType,
+    CDrmRel2_1StringDict00::EXmlnsRoap,
+    CDrmRel2_1StringDict00::EXmlnsXsi,
+    CDrmRel2_1StringDict00::EXmlnsXenc,
+    CDrmRel2_1StringDict00::EXmlnsDs,
+    CDrmRel2_1StringDict00::EXmlnsOex,
+    CDrmRel2_1StringDict00::EXmlnsOdd,
+    CDrmRel2_1StringDict00::EXmlnsOmadd,
+    CDrmRel2_1StringDict00::EVersion,
+    CDrmRel2_1StringDict00::EProxy,
+    CDrmRel2_1StringDict00::EId,
+    CDrmRel2_1StringDict00::EId2,
+    CDrmRel2_1StringDict00::ELCAlgorithm,
+    CDrmRel2_1StringDict00::EHCAlgorithm,
+    CDrmRel2_1StringDict00::EUri,
+    CDrmRel2_1StringDict00::EType,
+	0  // ok to end with zero as this is used by a global token
+    };
+
+
+
+const TInt iAttributeValueCodePage00[] = 
+	{
+	CDrmRel2_1StringDict00::EXsiTypeValue,
+    CDrmRel2_1StringDict00::EXmlnsRoapValue,
+    CDrmRel2_1StringDict00::EXmlnsXsiValue,
+    CDrmRel2_1StringDict00::EXmlnsXencValue,
+    CDrmRel2_1StringDict00::EXmlnsDsValue,
+    CDrmRel2_1StringDict00::EXmlnsOexValue,
+    CDrmRel2_1StringDict00::EXmlnsOddValue,
+    CDrmRel2_1StringDict00::EXmlnsOmaddValue,
+    CDrmRel2_1StringDict00::EVersionValue,
+    CDrmRel2_1StringDict00::EProxyValue,
+    CDrmRel2_1StringDict00::EIdValue,
+    CDrmRel2_1StringDict00::EId2Value,
+    CDrmRel2_1StringDict00::EHCAlgorithmValue,
+    CDrmRel2_1StringDict00::ELCAlgorithmValue,
+    CDrmRel2_1StringDict00::EUriValue,
+    CDrmRel2_1StringDict00::ETypeValue,
+    CDrmRel2_1StringDict00::EUrn,
+    CDrmRel2_1StringDict00::EOdrlEx,
+    CDrmRel2_1StringDict00::EOdrlDd,
+    CDrmRel2_1StringDict00::EOmaDd,
+    CDrmRel2_1StringDict00::EXmldSig,
+    CDrmRel2_1StringDict00::EXmlEnc,
+    CDrmRel2_1StringDict00::EXmlSchema,
+    CDrmRel2_1StringDict00::ERoapX509SPKIHashValue,
+    CDrmRel2_1StringDict00::EXmldSigSha1,
+    CDrmRel2_1StringDict00::EXmlExcC14,
+    CDrmRel2_1StringDict00::EXmldSigHmacSha1,
+    CDrmRel2_1StringDict00::EVersion1,
+    CDrmRel2_1StringDict00::EVersion2,
+    CDrmRel2_1StringDict00::EVersion21,
+    CDrmRel2_1StringDict00::EIdentificationRequest,
+    CDrmRel2_1StringDict00::ERoUploadRequest,
+    CDrmRel2_1StringDict00::EMeteringReport,
+    CDrmRel2_1StringDict00::ELeaveDomainValue,
+	0 // ok to end with zero as this is used by a global token
+    }; 
+
+
+#endif // C_DRMREL2_1STRINGDICT00_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/inc/drmrel2_1stringdict00attributetable.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,73 @@
+/*
+* 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:  String Dictionary for OMA 2.1 Drm
+*
+*/
+
+
+// Autogenerated from epoc32\build\generated\Xml\DrmRel2_1StringDict00AttributeTable.st by the stringtable tool - Do not edit
+
+#ifndef STRINGTABLE_DrmRel2_1StringDict00AttributeTable
+#define STRINGTABLE_DrmRel2_1StringDict00AttributeTable
+
+#include "stringpool.h"
+
+struct TStringTable;
+
+/** A String table */
+class DrmRel2_1StringDict00AttributeTable 
+	{
+public:
+	enum TStrings
+		{
+		// Element names
+		// CodePage 00
+		/** xsi:type */
+		EXsiType,
+		/** xmlns:roap */
+		EXmlnsRoap,
+		/** xmlns:xsi */
+		EXmlnsXsi,
+		/** xmlns:xenc */
+		EXmlnsXenc,
+		/** xmlns:ds */
+		EXmlnsDs,
+		/** xmlns:o-ex */
+		EXmlnsOex,
+		/** xmlns:o-dd */
+		EXmlnsOdd,
+		/** xmlns:oma-dd */
+		EXmlnsOmadd,
+		/** version */
+		EVersion,
+		/** proxy */
+		EProxy,
+		/** id */
+		EId,
+		/** Id */
+		EId2,
+		/** algorithm */
+		ELCAlgorithm,
+		/** Algorithm */
+		EHCAlgorithm,
+		/** URI */
+		EUri,
+		/** type */
+		EType
+		};
+	static const TStringTable Table;	
+	};
+
+#endif // STRINGTABLE_DrmRel2_1StringDict00AttributeTable
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/inc/drmrel2_1stringdict00attributevaluetable.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  String Dictionary for OMA 2.1 Drm
+*
+*/
+
+
+// Autogenerated from DrmRel2_1StringDict00AttributeValueTable.st by the stringtable tool - Do not edit
+
+#ifndef STRINGTABLE_DrmRel2_1StringDict00AttributeValueTable
+#define STRINGTABLE_DrmRel2_1StringDict00AttributeValueTable
+
+#include <stringpool.h>
+
+struct TStringTable;
+
+/** A String table */
+class DrmRel2_1StringDict00AttributeValueTable 
+	{
+public:
+	enum TStrings
+		{
+		// Element names
+		// CodePage 00
+		/**  */
+		EXsiTypeValue,
+		/**  */
+		EXmlnsRoapValue,
+		/**  */
+		EXmlnsXsiValue,
+		/**  */
+		EXmlnsXencValue,
+		/**  */
+		EXmlnsDsValue,
+		/**  */
+		EXmlnsOexValue,
+		/**  */
+		EXmlnsOddValue,
+		/**  */
+		EXmlnsOmaddValue,
+		/**  */
+		EVersionValue,
+		/**  */
+		EProxyValue,
+		/**  */
+		EIdValue,
+		/**  */
+		EId2Value,
+		/**  */
+		ELCAlgorithmValue,
+		/**  */
+		EHCAlgorithmValue,
+		/**  */
+		EUriValue,
+		/**  */
+		ETypeValue,
+		/** urn:oma:bac:dldrm:roap-1.0 */
+		EUrn,
+		/** http://odrl.net/1.1/ODRL-EX */
+		EOdrlEx,
+		/** http://odrl.net/1.1/ODRL-DD */
+		EOdrlDd,
+		/** http://www.openmobilealliance.com/oma-dd */
+		EOmaDd,
+		/** http://www.w3.org/2000/09/xmldsig# */
+		EXmldSig,
+		/** http://www.w3.org/2001/04/xmlenc# */
+		EXmlEnc,
+		/** http://www.w3.org/2001/XMLSchema-instance */
+		EXmlSchema,
+		/** roap:X509SPKIHash */
+		ERoapX509SPKIHashValue,
+		/** http://www.w3.org/2000/09/xmldsig#sha1 */
+		EXmldSigSha1,
+		/** http://www.w3.org/2001/10/xml-exc-c14n# */
+		EXmlExcC14,
+		/** http://www.w3.org/2000/09/xmldsig#hmac-sha1 */
+		EXmldSigHmacSha1,
+		/** 1.1 */
+		EVersion1,
+		/** 2.0 */
+		EVersion2,
+		/** 2.1 */
+		EVersion21,
+		/** identificationRequest */
+		EIdentificationRequest,
+		/** roUploadRequest */
+		ERoUploadRequest,
+		/** meteringReport */
+		EMeteringReport,
+		/** leaveDomain */
+		ELeaveDomainValue
+		};
+	static const TStringTable Table;	
+	};
+
+#endif // STRINGTABLE_DrmRel2_1StringDict00AttributeValueTable
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/inc/drmrel2_1stringdict00tagtable.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,345 @@
+/*
+* Copyright (c) 2007 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  String Dictionary for OMA 2.1 Drm
+*
+*/
+
+
+// Autogenerated from DrmRel2_1StringDict00TagTable.st by the stringtable tool - Do not edit
+
+#ifndef STRINGTABLE_DrmRel2_1StringDict00TagTable
+#define STRINGTABLE_DrmRel2_1StringDict00TagTable
+
+#include <stringpool.h>
+
+struct TStringTable;
+
+/** A String table */
+class DrmRel2_1StringDict00TagTable 
+	{
+public:
+	enum TStrings
+		{
+		// Element names
+		// CodePage 00
+		/** roap:roapTrigger */
+		ERoapTrigger,
+		/** roap:roapTrigger */
+		ERoapTriggerWithContent,
+		/** roap:roapTrigger */
+		ERoapTriggerWithAttributes,
+		/** roap:roapTrigger */
+		ERoapTriggerWithContentAndAttributes,
+		/** registrationRequest */
+		ERegistrationRequest,
+		/** registrationRequest */
+		ERegistrationRequestWithContent,
+		/** registrationRequest */
+		ERegistrationRequestWithAttributes,
+		/** registrationRequest */
+		ERegistrationRequestWithContentAndAttributes,
+		/** roAcquisition */
+		EROAcquisition,
+		/** roAcquisition */
+		EROAcquisitionWithContent,
+		/** roAcquisition */
+		EROAcquisitionWithAttributes,
+		/** roAcquisition */
+		EROAcquisitionWithContentAndAttributes,
+		/** joinDomain */
+		EJoinDomain,
+		/** joinDomain */
+		EJoinDomainWithContent,
+		/** joinDomain */
+		EJoinDomainWithAttributes,
+		/** joinDomain */
+		EJoinDomainWithContentAndAttributes,
+		/** leaveDomain */
+		ELeaveDomain,
+		/** leaveDomain */
+		ELeaveDomainWithContent,
+		/** leaveDomain */
+		ELeaveDomainWithAttributes,
+		/** leaveDomain */
+		ELeaveDomainWithContentAndAttributes,
+		/** signature */
+		ESignature,
+		/** signature */
+		ESignatureWithContent,
+		/** signature */
+		ESignatureWithAttributes,
+		/** signature */
+		ESignatureWithContentAndAttributes,
+		/** encKey */
+		EEncKey,
+		/** encKey */
+		EEncKeyWithContent,
+		/** encKey */
+		EEncKeyWithAttributes,
+		/** encKey */
+		EEncKeyWithContentAndAttributes,
+		/** riID */
+		ERiId,
+		/** riID */
+		ERiIdWithContent,
+		/** riID */
+		ERiIdWithAttributes,
+		/** riID */
+		ERiIdWithContentAndAttributes,
+		/** riAlias */
+		ERiAlias,
+		/** riAlias */
+		ERiAliasWithContent,
+		/** riAlias */
+		ERiAliasWithAttributes,
+		/** riAlias */
+		ERiAliasWithContentAndAttributes,
+		/** nonce */
+		ENonce,
+		/** nonce */
+		ENonceWithContent,
+		/** nonce */
+		ENonceWithAttributes,
+		/** nonce */
+		ENonceWithContentAndAttributes,
+		/** roapURL */
+		ERoapUrl,
+		/** roapURL */
+		ERoapUrlWithContent,
+		/** roapURL */
+		ERoapUrlWithAttributes,
+		/** roapURL */
+		ERoapUrlWithContentAndAttributes,
+		/** domainID */
+		EDomainId,
+		/** domainID */
+		EDomainIdWithContent,
+		/** domainID */
+		EDomainIdWithAttributes,
+		/** domainID */
+		EDomainIdWithContentAndAttributes,
+		/** domainAlias */
+		EDomainAlias,
+		/** domainAlias */
+		EDomainAliasWithContent,
+		/** domainAlias */
+		EDomainAliasWithAttributes,
+		/** domainAlias */
+		EDomainAliasWithContentAndAttributes,
+		/** roap:domainID */
+		ERoapDomainId,
+		/** roap:domainID */
+		ERoapDomainIdWithContent,
+		/** roap:domainID */
+		ERoapDomainIdWithAttributes,
+		/** roap:domainID */
+		ERoapDomainIdWithContentAndAttributes,
+		/** roID */
+		ERoId,
+		/** roID */
+		ERoIdWithContent,
+		/** roID */
+		ERoIdWithAttributes,
+		/** roID */
+		ERoIdWithContentAndAttributes,
+		/** roAlias */
+		ERoAlias,
+		/** roAlias */
+		ERoAliasWithContent,
+		/** roAlias */
+		ERoAliasWithAttributes,
+		/** roAlias */
+		ERoAliasWithContentAndAttributes,
+		/** contentID */
+		EContentId,
+		/** contentID */
+		EContentIdWithContent,
+		/** contentID */
+		EContentIdWithAttributes,
+		/** contentID */
+		EContentIdWithContentAndAttributes,
+		/** roap:X509SPKIHash */
+		ERoapX509SPKIHash,
+		/** roap:X509SPKIHash */
+		ERoapX509SPKIHashWithContent,
+		/** roap:X509SPKIHash */
+		ERoapX509SPKIHashWithAttributes,
+		/** roap:X509SPKIHash */
+		ERoapX509SPKIHashWithContentAndAttributes,
+		/** keyIdentifier */
+		EKeyIdentifier,
+		/** keyIdentifier */
+		EKeyIdentifierWithContent,
+		/** keyIdentifier */
+		EKeyIdentifierWithAttributes,
+		/** keyIdentifier */
+		EKeyIdentifierWithContentAndAttributes,
+		/** hash */
+		EHash,
+		/** hash */
+		EHashWithContent,
+		/** hash */
+		EHashWithAttributes,
+		/** hash */
+		EHashWithContentAndAttributes,
+		/** ds:SignedInfo */
+		EDsSignedInfo,
+		/** ds:SignedInfo */
+		EDsSignedInfoWithContent,
+		/** ds:SignedInfo */
+		EDsSignedInfoWithAttributes,
+		/** ds:SignedInfo */
+		EDsSignedInfoWithContentAndAttributes,
+		/** ds:SignatureValue */
+		EDsSignatureValue,
+		/** ds:SignatureValue */
+		EDsSignatureValueWithContent,
+		/** ds:SignatureValue */
+		EDsSignatureValueWithAttributes,
+		/** ds:SignatureValue */
+		EDsSignatureValueWithContentAndAttributes,
+		/** ds:KeyInfo */
+		EDsKeyInfo,
+		/** ds:KeyInfo */
+		EDsKeyInfoWithContent,
+		/** ds:KeyInfo */
+		EDsKeyInfoWithAttributes,
+		/** ds:KeyInfo */
+		EDsKeyInfoWithContentAndAttributes,
+		/** ds:CanonicalizationMethod */
+		EDsCanonicalisationMethod,
+		/** ds:CanonicalizationMethod */
+		EDsCanonicalisationMethodWithContent,
+		/** ds:CanonicalizationMethod */
+		EDsCanonicalisationMethodWithAttributes,
+		/** ds:CanonicalizationMethod */
+		EDsCanonicalisationMethodWithContentAndAttributes,
+		/** ds:SignatureMethod */
+		EDsSignatureMethod,
+		/** ds:SignatureMethod */
+		EDsSignatureMethodWithContent,
+		/** ds:SignatureMethod */
+		EDsSignatureMethodWithAttributes,
+		/** ds:SignatureMethod */
+		EDsSignatureMethodWithContentAndAttributes,
+		/** ds:Reference */
+		EDsReference,
+		/** ds:Reference */
+		EDsReferenceWithContent,
+		/** ds:Reference */
+		EDsReferenceWithAttributes,
+		/** ds:Reference */
+		EDsReferenceWithContentAndAttributes,
+		/** ds:RetrievalMethod */
+		EDsRetrievalMethod,
+		/** ds:RetrievalMethod */
+		EDsRetrievalMethodWithContent,
+		/** ds:RetrievalMethod */
+		EDsRetrievalMethodWithAttributes,
+		/** ds:RetrievalMethod */
+		EDsRetrievalMethodWithContentAndAttributes,
+		/** ds:Transforms */
+		EDsTransforms,
+		/** ds:Transforms */
+		EDsTransformsWithContent,
+		/** ds:Transforms */
+		EDsTransformsWithAttributes,
+		/** ds:Transforms */
+		EDsTransformsWithContentAndAttributes,
+		/** ds:DigestMethod */
+		EDsDigestMethod,
+		/** ds:DigestMethod */
+		EDsDigestMethodWithContent,
+		/** ds:DigestMethod */
+		EDsDigestMethodWithAttributes,
+		/** ds:DigestMethod */
+		EDsDigestMethodWithContentAndAttributes,
+		/** ds:DigestValue */
+		EDsDigestValue,
+		/** ds:DigestValue */
+		EDsDigestValueWithContent,
+		/** ds:DigestValue */
+		EDsDigestValueWithAttributes,
+		/** ds:DigestValue */
+		EDsDigestValueWithContentAndAttributes,
+		/** ds:Transform */
+		EDsTransform,
+		/** ds:Transform */
+		EDsTransformWithContent,
+		/** ds:Transform */
+		EDsTransformWithAttributes,
+		/** ds:Transform */
+		EDsTransformWithContentAndAttributes,
+		/** xenc:EncryptionMethod */
+		EXencEncryptionMethod,
+		/** xenc:EncryptionMethod */
+		EXencEncryptionMethodWithContent,
+		/** xenc:EncryptionMethod */
+		EXencEncryptionMethodWithAttributes,
+		/** xenc:EncryptionMethod */
+		EXencEncryptionMethodWithContentAndAttributes,
+		/** xenc:CipherData */
+		EXencCipherData,
+		/** xenc:CipherData */
+		EXencCipherDataWithContent,
+		/** xenc:CipherData */
+		EXencCipherDataWithAttributes,
+		/** xenc:CipherData */
+		EXencCipherDataWithContentAndAttributes,
+		/** xenc:CipherValue */
+		EXencCipherValue,
+		/** xenc:CipherValue */
+		EXencCipherValueWithContent,
+		/** xenc:CipherValue */
+		EXencCipherValueWithAttributes,
+		/** xenc:CipherValue */
+		EXencCipherValueWithContentAndAttributes,
+		/** extendedTrigger */
+		EExtentedTrigger,
+		/** extendedTrigger */
+		EExtentedTriggerWithContent,
+		/** extendedTrigger */
+		EExtentedTriggerWithAttributes,
+		/** extendedTrigger */
+		EExtentedTriggerWithContentAndAttributes,
+		/** trgLeaveDomain */
+		ETrgLeaveDomain,
+		/** trgLeaveDomain */
+		ETrgLeaveDomainWithContent,
+		/** trgLeaveDomain */
+		ETrgLeaveDomainWithAttributes,
+		/** trgLeaveDomain */
+		ETrgLeaveDomainWithContentAndAttributes,
+		/** deviceID */
+		EDeviceId,
+		/** deviceID */
+		EDeviceIdWithContent,
+		/** deviceID */
+		EDeviceIdWithAttributes,
+		/** deviceID */
+		EDeviceIdWithContentAndAttributes,
+		// For XML
+		/** -//OMA/DRM 2.1//EN */
+		EUri,
+		// For WBXML
+		/** 13~0 */
+		EPublicId,
+		/** -//OMA/DRM 2.1//EN~0 */
+		EFormalPublicId
+		};
+	static const TStringTable Table;	
+	};
+
+#endif // STRINGTABLE_DrmRel2_1StringDict00TagTable
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/inc/procwatcher.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,84 @@
+/*
+* 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:  Declaration of the CProcWatcher class
+*
+*/
+
+
+#ifndef PROCWATCHER_H
+#define PROCWATCHER_H
+
+#include "watcherobserver.h"
+
+/**  Prefix used when signaling the observer which process was killed */
+_LIT( KProcIdentifier, "PROC: " );
+
+/**
+ *  Watches a process
+ *
+ *  Logs onto a specified process and signals an observer when that process dies.
+ *
+ *  @since S60 3.0
+ */
+NONSHARABLE_CLASS( CProcWatcher ): public CActive
+    {
+public:
+
+    static CProcWatcher* NewL( MWatcherObserver& aObserver, const TDesC& aProcess, const TDesC& aFile );
+
+    virtual ~CProcWatcher();
+
+    /**
+     * Start watching the process
+     *
+     * @since S60 3.0
+     * @return KErrNone if watching started correctly
+     */
+    TInt StartWatching();
+
+protected:
+
+// from base class CActive
+
+    /**
+     * From CActive.
+     * Cancel outstanding requests
+     *
+     * @since S60 3.0
+     */
+    void DoCancel();
+    
+    /**
+     * From CActive.
+     * Handle events
+     *
+     * @since S60 3.0
+     */
+    void RunL();
+    
+private:
+
+    CProcWatcher( MWatcherObserver& aObserver );
+
+    void ConstructL( const TDesC& aProcess, const TDesC& aFile );
+
+private: // data
+
+    TFullName iProcessName;
+    TFileName iFileName;
+    RProcess iProcess;
+    MWatcherObserver& iObserver;
+    };
+
+#endif // DIRWATCHER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/inc/watcherobserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of the Watcher Observer class
+*
+*/
+
+
+#ifndef WATCHEROBSERVER_H
+#define WATCHEROBSERVER_H
+
+/**
+ *  Abstract class for observers of watcher events, e.g. the RDB watcher
+ *
+ *  @since S60 3.0
+ */
+class MWatcherObserver
+    {
+public:
+    /**
+     * Callback called by the peer when a watched object (e.g. the RDB) has
+     * been modified.
+     *
+     * @since S60 3.0
+     * @param aObject Descriptor containing more information
+     */
+    virtual void WatchedObjectChangedL( const TDesC& aObject ) = 0;
+
+    };
+
+#endif // WATCHEROBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/200B48A.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Resource definitions for project DrmRel2_1StringDict
+*
+*/
+
+
+#include "Ecom/RegistryInfo.rh"
+
+RESOURCE REGISTRY_INFO DrmRel2_1StringDict00Info
+{
+dll_uid = 0x2000B48A;
+interfaces = 
+    {
+    INTERFACE_INFO
+        {
+        interface_uid = 0x101FA94F;
+        implementations = 
+            {
+            IMPLEMENTATION_INFO
+                {
+                implementation_uid = 0x2000B490;
+                version_no = 1;
+                display_name = "XML Framework Plugin for OMA DRM 2.1 String Dictionary CodePage 00||Copyright © 2007 Nokia. All Rights Reserved.";
+                default_data = "13~0||-//OMA/DRM 2.1//EN~0";
+                opaque_data = "";
+                }
+            };
+        }
+    };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/Base64.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,208 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "base64.h"
+
+// LOCAL CONSTANTS AND MACROS
+LOCAL_C const TUint8* const KBase64Chars = 
+    _S8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+    "abcdefghijklmnopqrstuvwxyz"
+    "0123456789+/");
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TUint8 FindBase64Char(
+    TUint aChar);
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TUint8 FindBase64Char(
+    TUint aChar)
+    {
+    TUint8 i;
+
+    for (i = 0; i < 64; i++)
+        {
+        if (aChar == KBase64Chars[i]) break;
+        }
+    return i;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* Base64EncodeL(
+    const TDesC8& aInput)
+    {
+    HBufC8* ret;
+    TInt i = 0;
+    TInt j = 0;
+    TUint8 charArray3[3];
+    TUint8 charArray4[4];
+    TInt l = 0;
+    
+    ret = HBufC8::NewL((aInput.Length() * 4 + 1) / 3);
+    TPtr8 des = ret->Des();
+    while (l < aInput.Length())
+        {
+        charArray3[i++] = aInput[l];
+        l++;
+        if (i == 3)
+            {
+            charArray4[0] = static_cast<TUint8>((charArray3[0] & 0xfc) >> 2);
+            charArray4[1] = static_cast<TUint8>(
+                ((charArray3[0] & 0x03) << 4) + ((charArray3[1] & 0xf0) >> 4));
+            charArray4[2] = static_cast<TUint8>(
+                ((charArray3[1] & 0x0f) << 2) + ((charArray3[2] & 0xc0) >> 6));
+            charArray4[3] = static_cast<TUint8>(charArray3[2] & 0x3f);
+        
+            for (i = 0; i <4; i++)
+                {
+                des.Append(KBase64Chars[charArray4[i]]);
+                }
+            i = 0;
+            }
+        }
+    
+    if (i != 0)
+        {
+        for (j = i; j < 3; j++)
+            {
+            charArray3[j] = '\0';
+            }
+        
+        charArray4[0] = static_cast<TUint8>((charArray3[0] & 0xfc) >> 2);
+        charArray4[1] = static_cast<TUint8>(
+            ((charArray3[0] & 0x03) << 4) +((charArray3[1] & 0xf0) >> 4));
+        charArray4[2] = static_cast<TUint8>(
+            ((charArray3[1] & 0x0f) << 2) +((charArray3[2] & 0xc0) >> 6));
+        charArray4[3] = static_cast<TUint8>(charArray3[2] & 0x3f);
+        
+        for (j = 0; j < i + 1; j++)
+            {
+            des.Append(KBase64Chars[charArray4[j]]);
+            }
+        
+        while ((i++ < 3))
+            {
+            des.Append('=');
+            }
+        }
+    
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// ?function_name implements...
+// ?implementation_description.
+// Returns: ?value_1: ?description
+//          ?value_n: ?description
+//                    ?description
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* Base64DecodeL(
+    const TDesC8& aInput)
+    {
+    TInt len = aInput.Length();
+    TInt i = 0;
+    TInt j = 0;
+    TInt in = 0;
+    TUint8 charArray4[4], charArray3[3];
+    HBufC8* ret;
+    
+    ret = HBufC8::NewL((aInput.Length() * 3 + 1) / 4);
+    TPtr8 des = ret->Des();
+    while (len-- && aInput[in] != '=')
+        {
+        if (FindBase64Char(aInput[in]) < 64)
+            {
+            charArray4[i++] = aInput[in]; in++;
+            }
+        else
+            {
+            in++;
+            }
+            
+        if (i == 4)
+            {
+            for (i = 0; i < 4; i++)
+                {
+                charArray4[i] = FindBase64Char(charArray4[i]);
+                }
+            
+            charArray3[0] = static_cast<TUint8>(
+                (charArray4[0] << 2) + ((charArray4[1] & 0x30) >> 4));
+            charArray3[1] = static_cast<TUint8>(
+                ((charArray4[1] & 0xf) << 4) + ((charArray4[2] & 0x3c) >> 2));
+            charArray3[2] = static_cast<TUint8>(
+            ((charArray4[2] & 0x3) << 6) + charArray4[3]);
+            
+            for (i = 0; i < 3; i++)
+                {
+                des.Append(charArray3[i]);
+                }
+            i = 0;
+            }
+        }
+    
+    if (i != 0)
+        {
+        for (j = i; j < 4; j++)
+            {
+            charArray4[j] = 0;
+            }
+    
+        for (j = 0; j < 4; j++)
+            {
+            charArray4[j] = FindBase64Char(charArray4[j]);
+            }
+    
+        charArray3[0] = static_cast<TUint8>(
+            (charArray4[0] << 2) + ((charArray4[1] & 0x30) >> 4));
+        charArray3[1] = static_cast<TUint8>(
+            ((charArray4[1] & 0xf) << 4) + ((charArray4[2] & 0x3c) >> 2));
+        charArray3[2] = static_cast<TUint8>(
+            ((charArray4[2] & 0x3) << 6) + charArray4[3]);
+    
+        for (j = 0; j < i - 1; j++)
+            {
+            des.Append(charArray3[j]);
+            }
+        }
+    
+    return ret;
+    }
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/CmlaCryptoStub.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,175 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <asymmetric.h>
+#include <symmetric.h>
+#include <hash.h>
+#include "OmaCrypto.h"
+#include "CmlaCrypto.h"
+#include "BitStream.h"
+
+// LOCAL CONSTANTS AND MACROS
+
+_LIT8(KOma, "http://www.rsasecurity.com/rsalabs/pkcs/schemas/pkcs-1#rsaes-kem-kdf2-kw-aes128");
+_LIT8(KCmlaIp1, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-1");
+_LIT8(KCmlaIp2, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-2");
+_LIT8(KCmlaIp3, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-3");
+_LIT8(KCmlaIp4, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-4");
+_LIT8(KCmlaIp5, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-5");
+_LIT8(KCmlaIp6, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-6");
+_LIT8(KCmlaIp7, "http://www.cm-la.com/tech/cmlaip/cmlaip#cmlaip-7");
+
+// ==================== LOCAL FUNCTIONS ====================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CmlaCrypto::
+// 
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+// CmlaCrypto::
+// 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CmlaCrypto::SupportedAlgorithmsL(
+    RArray<TPtrC8>& /*aAlgorithmList*/)
+    {
+    return KErrNotSupported;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::DdtPermL(
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::DdtPermInvL(
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::DdtExpL(
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::DdtExpInvL(
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::WrapL(
+    const TDesC8& /*aKek*/,
+    const TDesC8& /*aKey*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::UnwrapL(
+    const TDesC8& /*aKek*/,
+    const TDesC8& /*aWrap*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::KdfL(
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::RsaDecryptCmlaL(
+    MDrmKeyStorage* /*aKeyStorage*/,
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::RsaEncryptCmlaL(
+    CRSAPublicKey* /*aKey*/,
+    const TDesC8& /*aInput*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C void CmlaCrypto::CmlaIpDecryptL(
+    TKeyTransportScheme /*aTransportScheme*/,
+    MDrmKeyStorage* /*aKeyStorage*/,
+    const TDesC8& /*aInput*/,
+    TDes8& /*aRek*/,
+    TDes8& /*aMac*/)
+    {
+    User::Leave(KErrNotSupported);
+    }
+
+EXPORT_C HBufC8* CmlaCrypto::CmlaIpEncryptL(
+    TKeyTransportScheme /*aTransportScheme*/,
+    CRSAPublicKey* /*aKey*/,
+    const TDesC8& /*aRek*/,
+    const TDesC8& /*aMac*/)
+    {
+    return NULL;
+    }
+
+EXPORT_C TKeyTransportScheme CmlaCrypto::AlgorithmIdToTransportScheme(
+    const TDesC8& aAlgorithmId)
+    {
+    if (aAlgorithmId.CompareF(KOma) == 0)
+        {
+        return EOma;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp1) == 0)
+        {
+        return ECmlaIp1;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp2) == 0)
+        {
+        return ECmlaIp2;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp3) == 0)
+        {
+        return ECmlaIp3;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp4) == 0)
+        {
+        return ECmlaIp4;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp5) == 0)
+        {
+        return ECmlaIp5;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp6) == 0)
+        {
+        return ECmlaIp6;
+        }
+    if (aAlgorithmId.CompareF(KCmlaIp7) == 0)
+        {
+        return ECmlaIp7;
+        }
+    return EOma;
+    }
+    
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/DrmRel2_1StringDict00.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,279 @@
+/*
+* 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:  Implementation class for OMA 2.1 Drm String Dictionary
+*
+*/
+
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+#include <xml/plugins/dictionarycodepage.h>
+#include <xml/xmlframeworkerrors.h>
+
+#include "drmrel2_1stringdict00.h"
+#include "drmrel2_1stringdict00tagtable.h"
+#include "drmrel2_1stringdict00attributetable.h"
+#include "drmrel2_1stringdict00attributevaluetable.h"
+
+using namespace Xml;
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::NewL
+// -----------------------------------------------------------------------------
+//
+MStringDictionary* CDrmRel2_1StringDict00::NewL( TAny* aStringPool )
+    {
+    CDrmRel2_1StringDict00* self(
+       new(ELeave) CDrmRel2_1StringDict00( 
+                            reinterpret_cast<RStringPool*>( aStringPool ) ) );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return ( static_cast<MStringDictionary*>( self ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::CDrmRel2_1StringDict00
+// -----------------------------------------------------------------------------
+//
+CDrmRel2_1StringDict00::CDrmRel2_1StringDict00( RStringPool* aStringPool )
+    : iStringPool( *aStringPool ), iCodePage( 0 )
+    {
+    // do nothing;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::ConstructL
+// -----------------------------------------------------------------------------
+//
+void CDrmRel2_1StringDict00::ConstructL()
+    {
+    // we don't own this stringpool
+    iStringPool.OpenL( DrmRel2_1StringDict00TagTable::Table );
+    iStringPool.OpenL( DrmRel2_1StringDict00AttributeTable::Table );
+    iStringPool.OpenL( DrmRel2_1StringDict00AttributeValueTable::Table );
+
+    iCodepage00Table = CDictionaryCodePage::NewL(
+        &DrmRel2_1StringDict00TagTable::Table, 
+        &DrmRel2_1StringDict00AttributeTable::Table, 
+        &DrmRel2_1StringDict00AttributeValueTable::Table, 
+        0 ); // codepage
+
+    // Construct the correlation mapping
+    iCodepage00Table->ConstructIndexMappingL( 
+                            iTagCodePage00,
+                            CDictionaryCodePage::EStringTypeElement );
+
+    iCodepage00Table->ConstructIndexMappingL( 
+                            iAttributeCodePage00,
+                            CDictionaryCodePage::EStringTypeAttribute );
+
+    iCodepage00Table->ConstructIndexMappingL( 
+                            iAttributeValueCodePage00,
+                            CDictionaryCodePage::EStringTypeAttributeValue );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::Release
+// -----------------------------------------------------------------------------
+//
+void CDrmRel2_1StringDict00::Release()
+    {
+    delete ( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::~CCDrmRel2_1StringDict00
+// -----------------------------------------------------------------------------
+//
+CDrmRel2_1StringDict00::~CDrmRel2_1StringDict00()
+    {
+    if ( iCodepage00Table )
+        {
+        delete iCodepage00Table;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::ElementL
+// -----------------------------------------------------------------------------
+//
+void CDrmRel2_1StringDict00::ElementL(
+    TInt aToken, 
+    RString& aElement) const
+    {
+    TInt index( iCodepage00Table->StringPoolIndexFromToken(
+                                aToken, 
+                                CDictionaryCodePage::EStringTypeElement ) );
+
+    if ( index == KErrXmlStringPoolTableNotFound )
+       {
+       User::Leave( KErrXmlUnsupportedElement );
+       }
+
+    aElement = iStringPool.String(
+                    index,
+                    *( iCodepage00Table->StringTable( 
+                                CDictionaryCodePage::EStringTypeElement ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::AttributeL
+// -----------------------------------------------------------------------------
+//
+void CDrmRel2_1StringDict00::AttributeL(
+    TInt aToken, 
+    RString& aAttribute) const
+    {
+    TInt index( iCodepage00Table->StringPoolIndexFromToken(
+                           aToken, 
+                           CDictionaryCodePage::EStringTypeAttribute ) );
+
+    if ( index == KErrXmlStringPoolTableNotFound )
+        {
+        User::Leave( KErrXmlUnsupportedAttribute );
+        }
+
+    aAttribute = iStringPool.String( 
+                        index,
+                        *(iCodepage00Table->StringTable( 
+                            CDictionaryCodePage::EStringTypeAttribute ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::AttributeValuePairL
+// -----------------------------------------------------------------------------
+//
+void CDrmRel2_1StringDict00::AttributeValuePairL(
+    TInt aToken, 
+    RString& aAttribute, 
+    RString& aValue) const
+    {
+    AttributeL( aToken, aAttribute );
+    AttributeValueL( aToken, aValue );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::AttributeValueL
+// -----------------------------------------------------------------------------
+//
+void CDrmRel2_1StringDict00::AttributeValueL( 
+    TInt aToken, 
+    RString& aValue ) const
+    {
+
+    TInt index( iCodepage00Table->StringPoolIndexFromToken(
+                    aToken, CDictionaryCodePage::EStringTypeAttributeValue ) );
+
+    if ( index == KErrXmlStringPoolTableNotFound )
+        {
+        User::Leave( KErrXmlUnsupportedAttributeValue );
+        }
+
+    aValue = iStringPool.String( 
+                    index,
+                    *(iCodepage00Table->StringTable(
+                           CDictionaryCodePage::EStringTypeAttributeValue ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::CompareThisDictionary
+// -----------------------------------------------------------------------------
+//
+TBool CDrmRel2_1StringDict00::CompareThisDictionary(
+    const RString& aDictionaryDescription ) const
+    {
+    // If this string dictionary has many codepages then all these comparisons 
+    // should go here.Remember, the string dictionary loads up all the 
+    // RStringTables into its RStringPool on construction. So if the comparison 
+    // fails we do not have it.
+    return ( ( aDictionaryDescription == 
+                            iStringPool.String( 
+                                DrmRel2_1StringDict00TagTable::EUri,
+                                DrmRel2_1StringDict00TagTable::Table ) ) ||
+
+             ( aDictionaryDescription == 
+                            iStringPool.String( 
+                                 DrmRel2_1StringDict00TagTable::EPublicId, 
+                                 DrmRel2_1StringDict00TagTable::Table ) ) ||
+
+            ( aDictionaryDescription == 
+                            iStringPool.String(
+                                DrmRel2_1StringDict00TagTable::EFormalPublicId, 
+                                DrmRel2_1StringDict00TagTable::Table ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::SwitchCodePage
+// -----------------------------------------------------------------------------
+//
+TInt CDrmRel2_1StringDict00::SwitchCodePage(TInt aCodePage)
+    {
+    // We only have one codepage so can't switch
+    if ( aCodePage != iCodePage )
+        {
+        return KErrXmlMissingStringDictionary;
+        }
+    return iCodePage;
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::PublicIdentifier
+// This method obtains the public identifier from the StringTable.
+// Either the formal or non formal public id will do.
+// The stringDictionary .rss files must list both these as Wbxml
+// documents have one or the other.
+//
+// @param aPubId The public identifier for this string dictionary.
+// -----------------------------------------------------------------------------
+//
+void CDrmRel2_1StringDict00::PublicIdentifier( RString& aPubId )
+    {
+    aPubId = iStringPool.String(
+        DrmRel2_1StringDict00TagTable::EFormalPublicId,
+        *( iCodepage00Table->StringTable( 
+                                CDictionaryCodePage::EStringTypeElement ) ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CDrmRel2_1StringDict00::NamespaceUri
+// The element types in the Device Information DTD are defined within
+// a namespace associated with the Uri/Urn available from the StringTable.
+// The RString need not be closed, but closing is harmless. 
+//
+// @param aUri The associated namespace for this string dictionary.
+// -----------------------------------------------------------------------------
+//
+void CDrmRel2_1StringDict00::NamespaceUri( RString& aUri )
+    {
+    aUri = iStringPool.String(
+           DrmRel2_1StringDict00TagTable::EUri,
+           *( iCodepage00Table->StringTable( 
+                                CDictionaryCodePage::EStringTypeElement ) ) );
+    }
+
+// Exported proxy for instantiation method resolution
+// Define the interface UIDs
+const TImplementationProxy ImplementationTable[] = { 
+                IMPLEMENTATION_PROXY_ENTRY( 0x2000B490, 
+                                            CDrmRel2_1StringDict00::NewL ) };
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( 
+    TInt& aTableCount )
+    {
+    aTableCount = sizeof( ImplementationTable ) / 
+                  sizeof( TImplementationProxy );
+
+    return ImplementationTable;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/DrmRel2_1StringDict00AttributeTable.mak	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,37 @@
+BUILD_DIR=$(EPOCROOT)epoc32\build\generated\Xml
+GENERATED_FILES= \
+	$(BUILD_DIR)\DrmRel2_1StringDict00AttributeTable.cpp
+SOURCE_DIR=.
+
+$(BUILD_DIR)\DrmRel2_1StringDict00AttributeTable.cpp : $(SOURCE_DIR)\DrmRel2_1StringDict00AttributeTable.st
+	perl -S emkdir.pl $(BUILD_DIR)
+	perl -S ecopyfile.pl $(SOURCE_DIR)\DrmRel2_1StringDict00AttributeTable.st $(BUILD_DIR)\DrmRel2_1StringDict00AttributeTable.st
+	perl -S stringtable.pl $(BUILD_DIR)\DrmRel2_1StringDict00AttributeTable.st
+
+do_nothing:
+	@rem do nothing
+
+#
+# The targets invoked by bld...
+#
+
+MAKMAKE : $(GENERATED_FILES)
+
+BLD : MAKMAKE
+
+SAVESPACE : MAKMAKE
+
+CLEAN : 
+	perl -S ermdir.pl $(BUILD_DIR)
+
+FREEZE : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : do_nothing
+
+FINAL : do_nothing
+
+RELEASABLES : $(GENERATED_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/DrmRel2_1StringDict00AttributeTable.st	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+# DrmRel2_1StringDict00AttributeTable.st
+# Copyright © 2008 Nokia.  All rights reserved.
+#
+# NOTE: For WBXML - Direct correlation on ordering of tag entries to the tag values 
+#       the parser defines
+# No empty lines allowed either
+#
+stringtable DrmRel2_1StringDict00AttributeTable
+# //////////////////////////////////////////////////////////////////////
+!// Element names
+!// CodePage 00
+EXsiType xsi:type
+EXmlnsRoap xmlns:roap
+EXmlnsXsi xmlns:xsi
+EXmlnsXenc xmlns:xenc
+EXmlnsDs xmlns:ds
+EXmlnsOex xmlns:o-ex
+EXmlnsOdd xmlns:o-dd
+EXmlnsOmadd xmlns:oma-dd
+EVersion version
+EProxy proxy
+EId id
+EId2 Id
+ELCAlgorithm algorithm
+EHCAlgorithm Algorithm
+EUri URI
+EType type
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/DrmRel2_1StringDict00AttributeValueTable.mak	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,37 @@
+BUILD_DIR=$(EPOCROOT)epoc32\build\generated\Xml
+GENERATED_FILES= \
+	$(BUILD_DIR)\DrmRel2_1StringDict00AttributeValueTable.cpp
+SOURCE_DIR=.
+
+$(BUILD_DIR)\DrmRel2_1StringDict00AttributeValueTable.cpp : $(SOURCE_DIR)\DrmRel2_1StringDict00AttributeValueTable.st
+	perl -S emkdir.pl $(BUILD_DIR)
+	perl -S ecopyfile.pl $(SOURCE_DIR)\DrmRel2_1StringDict00AttributeValueTable.st $(BUILD_DIR)\DrmRel2_1StringDict00AttributeValueTable.st
+	perl -S stringtable.pl $(BUILD_DIR)\DrmRel2_1StringDict00AttributeValueTable.st
+
+do_nothing:
+	@rem do nothing
+
+#
+# The targets invoked by bld...
+#
+
+MAKMAKE : $(GENERATED_FILES)
+
+BLD : MAKMAKE
+
+SAVESPACE : MAKMAKE
+
+CLEAN : 
+	perl -S ermdir.pl $(BUILD_DIR)
+
+FREEZE : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : do_nothing
+
+FINAL : do_nothing
+
+RELEASABLES : $(GENERATED_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/DrmRel2_1StringDict00AttributeValueTable.st	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,45 @@
+# DrmRel2_1StringDict00AttributeValueTable.st
+# Copyright © 2008 Nokia.  All rights reserved..
+#
+# NOTE: For WBXML - Direct correlation on ordering of tag entries to the tag values 
+#       the parser defines
+# No empty lines allowed either
+#
+stringtable DrmRel2_1StringDict00AttributeValueTable
+# //////////////////////////////////////////////////////////////////////
+!// Element names
+!// CodePage 00
+EXsiTypeValue  
+EXmlnsRoapValue  
+EXmlnsXsiValue  
+EXmlnsXencValue  
+EXmlnsDsValue  
+EXmlnsOexValue  
+EXmlnsOddValue  
+EXmlnsOmaddValue  
+EVersionValue  
+EProxyValue  
+EIdValue  
+EId2Value  
+ELCAlgorithmValue  
+EHCAlgorithmValue  
+EUriValue  
+ETypeValue  
+EUrn urn:oma:bac:dldrm:roap-1.0
+EOdrlEx http://odrl.net/1.1/ODRL-EX
+EOdrlDd http://odrl.net/1.1/ODRL-DD
+EOmaDd http://www.openmobilealliance.com/oma-dd
+EXmldSig http://www.w3.org/2000/09/xmldsig#
+EXmlEnc http://www.w3.org/2001/04/xmlenc#
+EXmlSchema http://www.w3.org/2001/XMLSchema-instance
+ERoapX509SPKIHashValue roap:X509SPKIHash
+EXmldSigSha1 http://www.w3.org/2000/09/xmldsig#sha1
+EXmlExcC14 http://www.w3.org/2001/10/xml-exc-c14n#
+EXmldSigHmacSha1 http://www.w3.org/2000/09/xmldsig#hmac-sha1
+EVersion1 1.1
+EVersion2 2.0
+EVersion21 2.1
+EIdentificationRequest identificationRequest
+ERoUploadRequest roUploadRequest
+EMeteringReport meteringReport
+ELeaveDomainValue leaveDomain
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/DrmRel2_1StringDict00TagTable.mak	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,37 @@
+BUILD_DIR=$(EPOCROOT)epoc32\build\generated\Xml
+GENERATED_FILES= \
+	$(BUILD_DIR)\DrmRel2_1StringDict00TagTable.cpp
+SOURCE_DIR=.
+
+$(BUILD_DIR)\DrmRel2_1StringDict00TagTable.cpp : $(SOURCE_DIR)\DrmRel2_1StringDict00TagTable.st
+	perl -S emkdir.pl $(BUILD_DIR)
+	perl -S ecopyfile.pl $(SOURCE_DIR)\DrmRel2_1StringDict00TagTable.st $(BUILD_DIR)\DrmRel2_1StringDict00TagTable.st
+	perl -S stringtable.pl $(BUILD_DIR)\DrmRel2_1StringDict00TagTable.st
+
+do_nothing:
+	@rem do nothing
+
+#
+# The targets invoked by bld...
+#
+
+MAKMAKE : $(GENERATED_FILES)
+
+BLD : MAKMAKE
+
+SAVESPACE : MAKMAKE
+
+CLEAN : 
+	perl -S ermdir.pl $(BUILD_DIR)
+
+FREEZE : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : do_nothing
+
+FINAL : do_nothing
+
+RELEASABLES : $(GENERATED_FILES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/DrmRel2_1StringDict00TagTable.st	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,165 @@
+# DrmRel2_1StringDict00.st
+# Copyright © 2008 Nokia.  All rights reserved..
+#
+# NOTE: For WBXML - Direct correlation on ordering of tag entries to the tag values
+#       the parser defines
+# No empty lines allowed either
+#
+stringtable DrmRel2_1StringDict00TagTable
+# //////////////////////////////////////////////////////////////////////
+!// Element names
+!// CodePage 00
+ERoapTrigger roap:roapTrigger
+ERoapTriggerWithContent roap:roapTrigger
+ERoapTriggerWithAttributes roap:roapTrigger
+ERoapTriggerWithContentAndAttributes roap:roapTrigger
+ERegistrationRequest registrationRequest
+ERegistrationRequestWithContent registrationRequest
+ERegistrationRequestWithAttributes registrationRequest
+ERegistrationRequestWithContentAndAttributes registrationRequest
+EROAcquisition roAcquisition
+EROAcquisitionWithContent roAcquisition
+EROAcquisitionWithAttributes roAcquisition
+EROAcquisitionWithContentAndAttributes roAcquisition
+EJoinDomain joinDomain
+EJoinDomainWithContent joinDomain
+EJoinDomainWithAttributes joinDomain
+EJoinDomainWithContentAndAttributes joinDomain
+ELeaveDomain leaveDomain
+ELeaveDomainWithContent leaveDomain
+ELeaveDomainWithAttributes leaveDomain
+ELeaveDomainWithContentAndAttributes leaveDomain
+ESignature signature
+ESignatureWithContent signature
+ESignatureWithAttributes signature
+ESignatureWithContentAndAttributes signature
+EEncKey encKey
+EEncKeyWithContent encKey
+EEncKeyWithAttributes encKey
+EEncKeyWithContentAndAttributes encKey
+ERiId riID
+ERiIdWithContent riID
+ERiIdWithAttributes riID
+ERiIdWithContentAndAttributes riID
+ERiAlias riAlias
+ERiAliasWithContent riAlias
+ERiAliasWithAttributes riAlias
+ERiAliasWithContentAndAttributes riAlias
+ENonce nonce
+ENonceWithContent nonce
+ENonceWithAttributes nonce
+ENonceWithContentAndAttributes nonce
+ERoapUrl roapURL
+ERoapUrlWithContent roapURL
+ERoapUrlWithAttributes roapURL
+ERoapUrlWithContentAndAttributes roapURL
+EDomainId domainID
+EDomainIdWithContent domainID
+EDomainIdWithAttributes domainID
+EDomainIdWithContentAndAttributes domainID
+EDomainAlias domainAlias
+EDomainAliasWithContent domainAlias
+EDomainAliasWithAttributes domainAlias
+EDomainAliasWithContentAndAttributes domainAlias
+ERoapDomainId roap:domainID
+ERoapDomainIdWithContent roap:domainID
+ERoapDomainIdWithAttributes roap:domainID
+ERoapDomainIdWithContentAndAttributes roap:domainID
+ERoId roID
+ERoIdWithContent roID
+ERoIdWithAttributes roID
+ERoIdWithContentAndAttributes roID
+ERoAlias roAlias
+ERoAliasWithContent roAlias
+ERoAliasWithAttributes roAlias
+ERoAliasWithContentAndAttributes roAlias
+EContentId contentID
+EContentIdWithContent contentID
+EContentIdWithAttributes contentID
+EContentIdWithContentAndAttributes contentID
+ERoapX509SPKIHash roap:X509SPKIHash
+ERoapX509SPKIHashWithContent roap:X509SPKIHash
+ERoapX509SPKIHashWithAttributes roap:X509SPKIHash
+ERoapX509SPKIHashWithContentAndAttributes roap:X509SPKIHash
+EKeyIdentifier keyIdentifier
+EKeyIdentifierWithContent keyIdentifier
+EKeyIdentifierWithAttributes keyIdentifier
+EKeyIdentifierWithContentAndAttributes keyIdentifier
+EHash hash
+EHashWithContent hash
+EHashWithAttributes hash
+EHashWithContentAndAttributes hash
+EDsSignedInfo ds:SignedInfo
+EDsSignedInfoWithContent ds:SignedInfo
+EDsSignedInfoWithAttributes ds:SignedInfo
+EDsSignedInfoWithContentAndAttributes ds:SignedInfo
+EDsSignatureValue ds:SignatureValue
+EDsSignatureValueWithContent ds:SignatureValue
+EDsSignatureValueWithAttributes ds:SignatureValue
+EDsSignatureValueWithContentAndAttributes ds:SignatureValue
+EDsKeyInfo ds:KeyInfo
+EDsKeyInfoWithContent ds:KeyInfo
+EDsKeyInfoWithAttributes ds:KeyInfo
+EDsKeyInfoWithContentAndAttributes ds:KeyInfo
+EDsCanonicalisationMethod ds:CanonicalizationMethod
+EDsCanonicalisationMethodWithContent ds:CanonicalizationMethod
+EDsCanonicalisationMethodWithAttributes ds:CanonicalizationMethod
+EDsCanonicalisationMethodWithContentAndAttributes ds:CanonicalizationMethod
+EDsSignatureMethod ds:SignatureMethod
+EDsSignatureMethodWithContent ds:SignatureMethod
+EDsSignatureMethodWithAttributes ds:SignatureMethod
+EDsSignatureMethodWithContentAndAttributes ds:SignatureMethod
+EDsReference ds:Reference
+EDsReferenceWithContent ds:Reference
+EDsReferenceWithAttributes ds:Reference
+EDsReferenceWithContentAndAttributes ds:Reference
+EDsRetrievalMethod ds:RetrievalMethod
+EDsRetrievalMethodWithContent ds:RetrievalMethod
+EDsRetrievalMethodWithAttributes ds:RetrievalMethod
+EDsRetrievalMethodWithContentAndAttributes ds:RetrievalMethod
+EDsTransforms ds:Transforms
+EDsTransformsWithContent ds:Transforms
+EDsTransformsWithAttributes ds:Transforms
+EDsTransformsWithContentAndAttributes ds:Transforms
+EDsDigestMethod ds:DigestMethod
+EDsDigestMethodWithContent ds:DigestMethod
+EDsDigestMethodWithAttributes ds:DigestMethod
+EDsDigestMethodWithContentAndAttributes ds:DigestMethod
+EDsDigestValue ds:DigestValue
+EDsDigestValueWithContent ds:DigestValue
+EDsDigestValueWithAttributes ds:DigestValue
+EDsDigestValueWithContentAndAttributes ds:DigestValue
+EDsTransform ds:Transform
+EDsTransformWithContent ds:Transform
+EDsTransformWithAttributes ds:Transform
+EDsTransformWithContentAndAttributes ds:Transform
+EXencEncryptionMethod xenc:EncryptionMethod
+EXencEncryptionMethodWithContent xenc:EncryptionMethod
+EXencEncryptionMethodWithAttributes xenc:EncryptionMethod
+EXencEncryptionMethodWithContentAndAttributes xenc:EncryptionMethod
+EXencCipherData xenc:CipherData
+EXencCipherDataWithContent xenc:CipherData
+EXencCipherDataWithAttributes xenc:CipherData
+EXencCipherDataWithContentAndAttributes xenc:CipherData
+EXencCipherValue xenc:CipherValue
+EXencCipherValueWithContent xenc:CipherValue
+EXencCipherValueWithAttributes xenc:CipherValue
+EXencCipherValueWithContentAndAttributes xenc:CipherValue
+EExtentedTrigger extendedTrigger
+EExtentedTriggerWithContent extendedTrigger
+EExtentedTriggerWithAttributes extendedTrigger
+EExtentedTriggerWithContentAndAttributes extendedTrigger
+ETrgLeaveDomain trgLeaveDomain
+ETrgLeaveDomainWithContent trgLeaveDomain
+ETrgLeaveDomainWithAttributes trgLeaveDomain
+ETrgLeaveDomainWithContentAndAttributes trgLeaveDomain
+EDeviceId deviceID
+EDeviceIdWithContent deviceID
+EDeviceIdWithAttributes deviceID
+EDeviceIdWithContentAndAttributes deviceID
+# //////////////////////////////////////////////////////////////////////
+!// For XML
+EUri -//OMA/DRM 2.1//EN
+!// For WBXML
+EPublicId 13~0
+EFormalPublicId -//OMA/DRM 2.1//EN~0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/MultipartHandler.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,335 @@
+/*
+* Copyright (c) 2005 - 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  utility class for handling multipart/related HTTP responses
+*                in ROAP
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <hash.h>
+#include "Base64.h"
+#include "MultipartHandler.h"
+
+#ifdef _DEBUG
+
+#include <e32debug.h>
+#define MULTIPART_DEBUGLIT( a ) RDebug::Print( _L ( a ) );
+
+#else // DEBUG
+
+#define MULTIPART_DEBUGLIT( a )
+
+#endif // DEBUG
+
+// CONSTANTS
+
+_LIT8( KBoundaryPrefix, "--" );
+_LIT8( KCrLf, "\r\n" );
+_LIT8( KCrLfCrLf, "\r\n\r\n" );
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::TMultipartHandler
+// ---------------------------------------------------------------------------
+//
+TMultipartHandler::TMultipartHandler():
+    iState( EPreamble )
+    {
+    MULTIPART_DEBUGLIT( "TMultipartHandler::TMultipartHandler -->" )
+    iBuffer.SetLength( 0 );
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::TMultipartHandler" )
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::WriteL
+// ---------------------------------------------------------------------------
+//
+void TMultipartHandler::WriteL(
+    const TDesC8& aData )
+    {
+    MULTIPART_DEBUGLIT( "TMultipartHandler::WriteL -->" )
+    switch ( iState )
+        {
+        case EPreamble:
+            MULTIPART_DEBUGLIT( "EPreamble" )
+            HandlePreambleL( aData );
+            break;
+        case EBodyPartHeaders:
+            MULTIPART_DEBUGLIT( "EBodyPartHeaders" )
+            HandleBodyPartHeadersL( aData );
+            break;
+        case EBodyPart:
+            MULTIPART_DEBUGLIT( "EBodyPart" )
+            HandleBodyPartL( aData );
+            break;
+        case EEpilog:
+            MULTIPART_DEBUGLIT( "EEpilog" )
+            break;
+        }
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::WriteL" )
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::FindDashBoundary
+// ---------------------------------------------------------------------------
+//
+TBool TMultipartHandler::FindDashBoundary(
+    const TDesC8& aBuffer,
+    TInt& aStart,
+    TInt& aEnd )
+    {
+    MULTIPART_DEBUGLIT( "TMultipartHandler::FindDashBoundary -->" )
+    TBool r( EFalse );
+    const TInt KBoundaryPrefixLength( KBoundaryPrefix().Length() );
+    const TInt KCrLfLength( KCrLf().Length() );
+    aStart = aBuffer.Find( KBoundaryPrefix );
+    if ( aStart >= 0 )
+        {
+        MULTIPART_DEBUGLIT( "TMultipartHandler::FindDashBoundary aStart nonnegative" )
+        aEnd = aBuffer.Mid( aStart ).Find( KCrLf );
+        aEnd += aStart;
+        if ( aEnd > aStart + KBoundaryPrefixLength )
+            {
+            MULTIPART_DEBUGLIT( "TMultipartHandler::FindDashBoundary  aEnd > aStart + (boundary prefix length)" )
+            const TInt delimiterLength( aEnd - aStart + KCrLfLength );
+            __ASSERT_ALWAYS( KMaxBoundaryLength  >= delimiterLength, User::Invariant() );
+            iDelimiter.Copy( KCrLf );
+            iDelimiter.Append( KBoundaryPrefix );
+            iDelimiter.Append( aBuffer.Mid(
+                aStart + KBoundaryPrefixLength,
+                aEnd - aStart - KBoundaryPrefixLength ) );
+            r = ETrue;
+            MULTIPART_DEBUGLIT( "TMultipartHandler::FindDashBoundary  found dash boundary" )
+            }
+        }
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::FindDashBoundary" )
+    return r;
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::FindHeaderEnd
+// ---------------------------------------------------------------------------
+//
+TBool TMultipartHandler::FindHeaderEnd(
+    const TDesC8& aBuffer,
+    TInt& aStart,
+    TInt& aEnd )
+    {
+    MULTIPART_DEBUGLIT( "TMultipartHandler::FindHeaderEnd -->" )
+    TBool r( EFalse );
+
+    aStart = aBuffer.Find( KCrLfCrLf );
+    if ( aStart >= 0 )
+        {
+        aEnd = aStart + KCrLfCrLf().Length();
+        r = ETrue;
+        }
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::FindHeaderEnd" )
+    return r;
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::FindDelimiter
+// ---------------------------------------------------------------------------
+//
+TBool TMultipartHandler::FindDelimiter(
+    const TDesC8& aBuffer,
+    TInt& aStart,
+    TInt& aEnd )
+    {
+    MULTIPART_DEBUGLIT( "TMultipartHandler::FindDelimiter -->" )
+    TBool r( EFalse );
+
+    aStart = aBuffer.Find( iDelimiter );
+    if ( aStart >= 0 )
+        {
+        aEnd = aStart + iDelimiter.Length();
+        r = ETrue;
+        }
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::FindDelimiter" )
+    return r;
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::HandlePreambleL
+// ---------------------------------------------------------------------------
+//
+void TMultipartHandler::HandlePreambleL(
+    const TDesC8& aData )
+    {
+    MULTIPART_DEBUGLIT( "TMultipartHandler::HandlePreambleL -->" )
+    TInt bStart( 0 );
+    TInt bEnd( 0 );
+    HBufC8* buffer( NULL );
+
+    buffer = HBufC8::NewLC( iBuffer.Length() + aData.Length() );
+    buffer->Des().Copy( iBuffer );
+    buffer->Des().Append( aData );
+    if ( !FindDashBoundary( *buffer, bStart, bEnd ) )
+        {
+        iBuffer.Copy( buffer->Right( Min(
+                    KMaxBoundaryLength, buffer->Length() ) ) );
+        }
+    else
+        {
+        iBuffer.SetLength( 0 );
+        iState = EBodyPartHeaders;
+        StartBodyPartHeadersL();
+        HandleBodyPartHeadersL( buffer->Mid( bEnd + KCrLf().Length() ) );
+        }
+    CleanupStack::PopAndDestroy( buffer );
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::HandlePreambleL" )
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::HandleBodyPartHeadersL
+// ---------------------------------------------------------------------------
+//
+void TMultipartHandler::HandleBodyPartHeadersL(
+    const TDesC8& aData )
+    {
+    MULTIPART_DEBUGLIT( "TMultipartHandler::HandleBodyPartHeadersL -->" )
+    TInt bStart( 0 );
+    TInt bEnd( 0 );
+    HBufC8* buffer( HBufC8::NewLC( iBuffer.Length() + aData.Length() ) );
+    buffer->Des().Copy( iBuffer );
+    buffer->Des().Append( aData );
+    iBuffer.Copy( buffer->Right( Min(
+                KMaxBoundaryLength, buffer->Length() ) ) );
+    if ( !FindHeaderEnd( *buffer, bStart, bEnd ) )
+        {
+        const TInt lengthNoBoundary( buffer->Length() - KMaxBoundaryLength );
+        if (  lengthNoBoundary > 0 )
+            {
+            HandleBodyHeaderDataL( buffer->Left( lengthNoBoundary ) );
+            }
+        }
+    else
+        {
+        HandleBodyHeaderDataL( buffer->Left( bStart ) );
+        iBuffer.SetLength( 0 );
+        iState = EBodyPart;
+        StartBodyPartL();
+        HandleBodyPartL( buffer->Mid( bEnd ) );
+        }
+    CleanupStack::PopAndDestroy( buffer );
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::HandleBodyPartHeadersL" )
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::HandleBodyPartL
+// ---------------------------------------------------------------------------
+//
+void TMultipartHandler::HandleBodyPartL(
+    const TDesC8& aData )
+    {
+    MULTIPART_DEBUGLIT( "TMultipartHandler::HandleBodyPartL -->" )
+    TInt bStart( 0 );
+    TInt bEnd( 0 );
+
+    HBufC8* buffer( HBufC8::NewLC( iBuffer.Length() + aData.Length() ) );
+    buffer->Des().Copy( iBuffer );
+    buffer->Des().Append( aData );
+
+    iBuffer.Copy( buffer->Right( Min(
+                KMaxBoundaryLength, buffer->Length() ) ) );
+
+    if ( !FindDelimiter( *buffer, bStart, bEnd ) )
+        {
+        const TInt lengthNoBoundary( buffer->Length() - KMaxBoundaryLength );
+        if ( lengthNoBoundary > 0 )
+            {
+            HandleBodyDataL( buffer->Left( lengthNoBoundary ) );
+            }
+        }
+    else
+        {
+        HandleBodyDataL( buffer->Left( bStart ) );
+        iBuffer.SetLength( 0 );
+        if ( ( *buffer )[ bEnd ] == '-' && ( *buffer )[ bEnd + 1 ] == '-' )
+            {
+            EndBodyPartL();
+            iState = EEpilog;
+            }
+        else
+            {
+            iState = EBodyPartHeaders;
+            StartBodyPartHeadersL();
+            HandleBodyPartHeadersL( buffer->Mid( bEnd + KCrLf().Length() ) );
+            }
+        }
+    CleanupStack::PopAndDestroy( buffer );
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::HandleBodyPartL" )
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::StartBodyPartHeadersL
+// ---------------------------------------------------------------------------
+//
+void TMultipartHandler::StartBodyPartHeadersL()
+    {
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::StartBodyPartHeadersL -->" )
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::EndBodyPartHeadersL
+// ---------------------------------------------------------------------------
+//
+void TMultipartHandler::EndBodyPartHeadersL()
+    {
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::EndBodyPartHeadersL -->" )
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::HandleBodyHeaderDataL
+// ---------------------------------------------------------------------------
+//
+void TMultipartHandler::HandleBodyHeaderDataL(
+    const TDesC8& /*aData*/ )
+    {
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::HandleBodyHeaderDataL -->" )
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::StartBodyPartL
+// ---------------------------------------------------------------------------
+//
+void TMultipartHandler::StartBodyPartL()
+    {
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::StartBodyPartL -->" )
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::EndBodyPartL
+// ---------------------------------------------------------------------------
+//
+void TMultipartHandler::EndBodyPartL()
+    {
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::EndBodyPartL -->" )
+    }
+
+// ---------------------------------------------------------------------------
+// TMultipartHandler::HandleBodyDataL
+// ---------------------------------------------------------------------------
+//
+void TMultipartHandler::HandleBodyDataL(
+    const TDesC8& /*aData*/ )
+    {
+    MULTIPART_DEBUGLIT( "--> TMultipartHandler::HandleBodyDataL -->" )
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/dbwatcher.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the RDB watcher
+*
+*/
+
+
+#include <e32def.h>
+#include <e32base.h>
+#include <f32file.h>
+#include <sysutil.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "dbwatcher.h"
+#include "dirwatcher.h"
+#include "drmlog.h"
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT( KRdbBaseDir, "%c:\\private\\101f51f2\\rdb\\");
+#else
+_LIT( KRdbBaseDir, "c:\\private\\101f51f2\\rdb\\");
+#endif
+
+_LIT( KDomainRoDir, "DomainROs" );
+static const TChar KDirs[CDbWatcher::KNumDirs] = 
+    { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+    
+// ======== MEMBER FUNCTIONS ========
+
+void CDbWatcher::ConstructL( MWatcherObserver& aObserver )
+    {
+    TInt i;
+    TFileName file;
+
+    DRMLOG( _L( "CDbWatcher::ConstructL <-" ) );
+    
+    User::LeaveIfError( iFs.Connect() );
+    for ( i = 0; i < KNumDirs; i++ )
+        {
+        
+#ifndef RD_MULTIPLE_DRIVE
+    
+        // Ignore errors
+        file.Copy( KRdbBaseDir );
+        
+#else //RD_MULTIPLE_DRIVE
+    
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	    iFs.DriveToChar( driveNumber, driveLetter );
+	
+	    TFileName dbBaseDir;
+	    dbBaseDir.Format( KRdbBaseDir, (TUint)driveLetter );
+        
+        // Ignore errors
+        file.Copy( dbBaseDir );
+        
+#endif
+        
+        if ( i < KNumDirs - 1 )
+            {
+            file.Append( KDirs[i] ); 
+            }
+        else
+            {
+            file.Append( KDomainRoDir ); 
+            }
+        iDirWatcher[i] = CDirWatcher::NewL( aObserver, iFs, file );
+        }
+    
+    DRMLOG( _L( "CDbWatcher::ConstructL ->" ) );
+    }
+
+CDbWatcher* CDbWatcher::NewL( MWatcherObserver& aObserver )
+    {
+    CDbWatcher* self = new( ELeave) CDbWatcher;
+    self->ConstructL( aObserver );
+    return self;
+    }
+
+CDbWatcher::CDbWatcher()
+    {
+    DRMLOG( _L( "CDbWatcher::CDbWatcher ->" ) );
+    DRMLOG( _L( "CDbWatcher::CDbWatcher <-" ) );
+    }
+
+CDbWatcher::~CDbWatcher()
+    {
+    TInt i;
+    
+    DRMLOG( _L( "CDbWatcher::~CDbWatcher ->" ) );
+
+    for ( i = 0; i < KNumDirs; i++ )
+        {
+        delete iDirWatcher[i];
+        }    
+    iFs.Close();
+    
+    DRMLOG( _L( "CDbWatcher::~CDbWatcher <-" ) );
+    }
+
+void CDbWatcher::StartWatching()
+    {
+    TInt i;
+    
+    DRMLOG( _L( "CDbWatcher::StartWatching ->" ) );
+    
+    for ( i = 0; i < KNumDirs; i++ )
+        {
+        iDirWatcher[i]->StartWatching();
+        }    
+
+    DRMLOG( _L( "CDbWatcher::StartWatching <-" ) );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/dirwatcher.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Implementation of the RDB watcher
+*
+*/
+
+
+#include <e32def.h>
+#include <e32base.h>
+#include <f32file.h>
+#include <sysutil.h>
+#include "dirwatcher.h"
+#include "dbwatcher.h"
+#include "drmlog.h"
+
+static const TNotifyType KWatchTrigger = ENotifyEntry;
+
+// ======== MEMBER FUNCTIONS ========
+
+void CDirWatcher::ConstructL( const TDesC& aDir )
+    {
+    DRMLOG( _L( "CDirWatcher::ConstructL <-" ) );
+
+    iDir.Copy( aDir );    
+    CActiveScheduler::Add( this );
+    
+    DRMLOG( _L( "CDirWatcher::ConstructL ->" ) );
+    }
+
+CDirWatcher* CDirWatcher::NewL( MWatcherObserver& aObserver, RFs& aFs, const TDesC& aDir )
+    {
+    CDirWatcher* self = new( ELeave ) CDirWatcher( aObserver, aFs );
+    self->ConstructL( aDir );
+    return self;
+    }
+
+CDirWatcher::CDirWatcher( MWatcherObserver& aObserver, RFs& aFs ):
+    CActive( EPriorityStandard ),
+    iFs( aFs ),
+    iObserver( aObserver )
+    {
+    DRMLOG( _L( "CDirWatcher::CDirWatcher ->" ) );
+    DRMLOG( _L( "CDirWatcher::CDirWatcher <-" ) );
+    }
+
+CDirWatcher::~CDirWatcher()
+    {
+    DRMLOG( _L( "CDirWatcher::~CDirWatcher ->" ) );
+
+    Cancel();
+    
+    DRMLOG( _L( "CDirWatcher::~CDirWatcher <-" ) );
+    }
+
+void CDirWatcher::StartWatching()
+    {
+    DRMLOG( _L( "CDirWatcher::StartWatching ->" ) );
+    
+    DRMLOG( iDir );
+    Cancel();
+    iFs.NotifyChangeCancel();
+    iFs.NotifyChange( KWatchTrigger, iStatus, iDir );
+    SetActive();
+
+    DRMLOG( _L( "CDirWatcher::StartWatching <-" ) );
+    }
+    
+void CDirWatcher::DoCancel()
+    {
+    DRMLOG( _L( "CDirWatcher::DoCancel ->" ) );
+    
+    iFs.NotifyChangeCancel();
+    
+    DRMLOG( _L( "CDirWatcher::DoCancel <-" ) );
+    }
+    
+void CDirWatcher::RunL()
+    {
+    TBuf<256> logBuffer;
+    TFileName object;
+    
+    DRMLOG( _L( "CDirWatcher::RunL ->" ) );
+    
+    DRMLOG( iDir );
+    logBuffer.AppendNum( iStatus.Int() );
+    DRMLOG( logBuffer );
+    if ( iStatus == KErrNone )
+        {
+        object.Copy( KDirIdentifier );
+        object.Append( iDir );
+        iObserver.WatchedObjectChangedL( object );
+        }
+    iFs.NotifyChange( KWatchTrigger, iStatus, iDir );
+    SetActive();
+    
+    DRMLOG( _L( "CDirWatcher::RunL <-" ) );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/drmaescrypto.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,98 @@
+/*
+* 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:  AES encryption utility for drm engine use
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+
+#include <symmetric.h>
+#include <rijndael.h>
+
+#include <drmtypes.h>
+
+#include "drmaescrypto.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// DrmAesCrypto::DrmAesEncryptL
+// Encrypt data using a given key and insert initial vector on beginning
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* DrmAesCrypto::DrmAesEncryptL(
+    const TDesC8& aKey,
+    const TDesC8& aIV,
+    const TBool aAddPadding,
+    const TDesC8& aData )
+    {
+
+    HBufC8* retBuf( NULL );
+
+    CModeCBCEncryptor* cbc( NULL );
+    TInt lastBlockStart( 0 );
+    TPtr8 data( NULL, 0, 0 );
+
+    if( aIV.Length() != KDCFKeySize || aKey.Length() != KDCFKeySize )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    cbc = CModeCBCEncryptor::NewL( CAESEncryptor::NewLC( aKey ), aIV );
+    CleanupStack::Pop(); // CAESEncryptor, owned by cbc.
+    CleanupStack::PushL( cbc );
+
+    retBuf = HBufC8::NewLC( aData.Size() + aIV.Size() + KDCFKeySize );
+    data.Set( retBuf->Des() );
+    data.Copy( aIV );
+    data.Append( aData );
+
+    lastBlockStart = data.Length() - ( data.Length() % KDCFKeySize );
+    // Loop through the data, excluding aIV
+    for ( TInt i = KDCFKeySize; i  < lastBlockStart; i+= KDCFKeySize )
+        {
+        data.Set( retBuf->Des().MidTPtr( i, KDCFKeySize ) );
+
+        cbc->Transform( data );
+        }
+
+    if ( aAddPadding )
+        {
+        TInt dataLength = retBuf->Length();
+        TUint8 padding( static_cast< TUint8 >
+            ( lastBlockStart + KDCFKeySize - dataLength ) );
+
+        __ASSERT_DEBUG( lastBlockStart + KDCFKeySize - dataLength <= KDCFKeySize,
+            User::Invariant() );
+
+        retBuf->Des().SetLength( lastBlockStart + KDCFKeySize );
+
+        for ( TInt i = dataLength; i < retBuf->Length(); ++i )
+            {
+            retBuf->Des()[ i ] = padding;
+            }
+
+        data.Set( retBuf->Des().MidTPtr( lastBlockStart, KDCFKeySize ) );
+        cbc->Transform( data );
+        }
+
+    CleanupStack::Pop( retBuf );
+    CleanupStack::PopAndDestroy( cbc );
+    return retBuf;
+
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/drmrel2_1stringdict00attributetable.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  String Dictionary for OMA 2.1 Drm
+*
+*/
+
+// Autogenerated from epoc32\build\generated\Xml\DrmRel2_1StringDict00AttributeTable.st by the stringtable tool - Do not edit
+#include <e32std.h>
+#include "stringpool.h"
+#include "stringtablesupport.h"
+#include "drmrel2_1stringdict00attributetable.h"
+#ifdef _DEBUG
+#undef _DEBUG
+#endif
+
+_STLIT8(K1, "xsi:type");
+_STLIT8(K2, "xmlns:roap");
+_STLIT8(K3, "xmlns:xsi");
+_STLIT8(K4, "xmlns:xenc");
+_STLIT8(K5, "xmlns:ds");
+_STLIT8(K6, "xmlns:o-ex");
+_STLIT8(K7, "xmlns:o-dd");
+_STLIT8(K8, "xmlns:oma-dd");
+_STLIT8(K9, "version");
+_STLIT8(K10, "proxy");
+_STLIT8(K11, "id");
+_STLIT8(K12, "Id");
+_STLIT8(K13, "algorithm");
+_STLIT8(K14, "Algorithm");
+_STLIT8(K15, "URI");
+_STLIT8(K16, "type");
+
+// Intermediate
+const void * const KStringPointers[] =
+	{
+	(const void*)&K1,
+	(const void*)&K2,
+	(const void*)&K3,
+	(const void*)&K4,
+	(const void*)&K5,
+	(const void*)&K6,
+	(const void*)&K7,
+	(const void*)&K8,
+	(const void*)&K9,
+	(const void*)&K10,
+	(const void*)&K11,
+	(const void*)&K12,
+	(const void*)&K13,
+	(const void*)&K14,
+	(const void*)&K15,
+	(const void*)&K16
+	};
+
+const TStringTable DrmRel2_1StringDict00AttributeTable::Table = {16, KStringPointers, ETrue};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/drmrel2_1stringdict00attributevaluetable.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,102 @@
+/*
+* 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:  String Dictionary for OMA 2.1 Drm
+*
+*/
+
+
+// Autogenerated from DrmRel2_1StringDict00AttributeValueTable.st by the stringtable tool - Do not edit
+#include <e32std.h>
+#include <stringpool.h>
+#include <stringtablesupport.h>
+#include "drmrel2_1stringdict00attributevaluetable.h"
+#ifdef _DEBUG
+#undef _DEBUG
+#endif
+
+_STLIT8(K1, "");
+_STLIT8(K2, "");
+_STLIT8(K3, "");
+_STLIT8(K4, "");
+_STLIT8(K5, "");
+_STLIT8(K6, "");
+_STLIT8(K7, "");
+_STLIT8(K8, "");
+_STLIT8(K9, "");
+_STLIT8(K10, "");
+_STLIT8(K11, "");
+_STLIT8(K12, "");
+_STLIT8(K13, "");
+_STLIT8(K14, "");
+_STLIT8(K15, "");
+_STLIT8(K16, "");
+_STLIT8(K17, "urn:oma:bac:dldrm:roap-1.0");
+_STLIT8(K18, "http://odrl.net/1.1/ODRL-EX");
+_STLIT8(K19, "http://odrl.net/1.1/ODRL-DD");
+_STLIT8(K20, "http://www.openmobilealliance.com/oma-dd");
+_STLIT8(K21, "http://www.w3.org/2000/09/xmldsig#");
+_STLIT8(K22, "http://www.w3.org/2001/04/xmlenc#");
+_STLIT8(K23, "http://www.w3.org/2001/XMLSchema-instance");
+_STLIT8(K24, "roap:X509SPKIHash");
+_STLIT8(K25, "http://www.w3.org/2000/09/xmldsig#sha1");
+_STLIT8(K26, "http://www.w3.org/2001/10/xml-exc-c14n#");
+_STLIT8(K27, "http://www.w3.org/2000/09/xmldsig#hmac-sha1");
+_STLIT8(K28, "1.1");
+_STLIT8(K29, "2.0");
+_STLIT8(K30, "2.1");
+_STLIT8(K31, "identificationRequest");
+_STLIT8(K32, "roUploadRequest");
+_STLIT8(K33, "meteringReport");
+_STLIT8(K34, "leaveDomain");
+
+// Intermediate
+const void * const KStringPointers[] =
+	{
+	(const void*)&K1,
+	(const void*)&K2,
+	(const void*)&K3,
+	(const void*)&K4,
+	(const void*)&K5,
+	(const void*)&K6,
+	(const void*)&K7,
+	(const void*)&K8,
+	(const void*)&K9,
+	(const void*)&K10,
+	(const void*)&K11,
+	(const void*)&K12,
+	(const void*)&K13,
+	(const void*)&K14,
+	(const void*)&K15,
+	(const void*)&K16,
+	(const void*)&K17,
+	(const void*)&K18,
+	(const void*)&K19,
+	(const void*)&K20,
+	(const void*)&K21,
+	(const void*)&K22,
+	(const void*)&K23,
+	(const void*)&K24,
+	(const void*)&K25,
+	(const void*)&K26,
+	(const void*)&K27,
+	(const void*)&K28,
+	(const void*)&K29,
+	(const void*)&K30,
+	(const void*)&K31,
+	(const void*)&K32,
+	(const void*)&K33,
+	(const void*)&K34
+	};
+
+const TStringTable DrmRel2_1StringDict00AttributeValueTable::Table = {34, KStringPointers, ETrue};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/drmrel2_1stringdict00tagtable.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,336 @@
+/*
+* 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:  String Dictionary for OMA 2.1 Drm
+*
+*/
+
+
+// Autogenerated from DrmRel2_1StringDict00TagTable.st by the stringtable tool - Do not edit
+#include <e32std.h>
+#include <stringpool.h>
+#include <stringtablesupport.h>
+#include "drmrel2_1stringdict00tagtable.h"
+#ifdef _DEBUG
+#undef _DEBUG
+#endif
+
+_STLIT8(K1, "roap:roapTrigger");
+_STLIT8(K2, "roap:roapTrigger");
+_STLIT8(K3, "roap:roapTrigger");
+_STLIT8(K4, "roap:roapTrigger");
+_STLIT8(K5, "registrationRequest");
+_STLIT8(K6, "registrationRequest");
+_STLIT8(K7, "registrationRequest");
+_STLIT8(K8, "registrationRequest");
+_STLIT8(K9, "roAcquisition");
+_STLIT8(K10, "roAcquisition");
+_STLIT8(K11, "roAcquisition");
+_STLIT8(K12, "roAcquisition");
+_STLIT8(K13, "joinDomain");
+_STLIT8(K14, "joinDomain");
+_STLIT8(K15, "joinDomain");
+_STLIT8(K16, "joinDomain");
+_STLIT8(K17, "leaveDomain");
+_STLIT8(K18, "leaveDomain");
+_STLIT8(K19, "leaveDomain");
+_STLIT8(K20, "leaveDomain");
+_STLIT8(K21, "signature");
+_STLIT8(K22, "signature");
+_STLIT8(K23, "signature");
+_STLIT8(K24, "signature");
+_STLIT8(K25, "encKey");
+_STLIT8(K26, "encKey");
+_STLIT8(K27, "encKey");
+_STLIT8(K28, "encKey");
+_STLIT8(K29, "riID");
+_STLIT8(K30, "riID");
+_STLIT8(K31, "riID");
+_STLIT8(K32, "riID");
+_STLIT8(K33, "riAlias");
+_STLIT8(K34, "riAlias");
+_STLIT8(K35, "riAlias");
+_STLIT8(K36, "riAlias");
+_STLIT8(K37, "nonce");
+_STLIT8(K38, "nonce");
+_STLIT8(K39, "nonce");
+_STLIT8(K40, "nonce");
+_STLIT8(K41, "roapURL");
+_STLIT8(K42, "roapURL");
+_STLIT8(K43, "roapURL");
+_STLIT8(K44, "roapURL");
+_STLIT8(K45, "domainID");
+_STLIT8(K46, "domainID");
+_STLIT8(K47, "domainID");
+_STLIT8(K48, "domainID");
+_STLIT8(K49, "domainAlias");
+_STLIT8(K50, "domainAlias");
+_STLIT8(K51, "domainAlias");
+_STLIT8(K52, "domainAlias");
+_STLIT8(K53, "roap:domainID");
+_STLIT8(K54, "roap:domainID");
+_STLIT8(K55, "roap:domainID");
+_STLIT8(K56, "roap:domainID");
+_STLIT8(K57, "roID");
+_STLIT8(K58, "roID");
+_STLIT8(K59, "roID");
+_STLIT8(K60, "roID");
+_STLIT8(K61, "roAlias");
+_STLIT8(K62, "roAlias");
+_STLIT8(K63, "roAlias");
+_STLIT8(K64, "roAlias");
+_STLIT8(K65, "contentID");
+_STLIT8(K66, "contentID");
+_STLIT8(K67, "contentID");
+_STLIT8(K68, "contentID");
+_STLIT8(K69, "roap:X509SPKIHash");
+_STLIT8(K70, "roap:X509SPKIHash");
+_STLIT8(K71, "roap:X509SPKIHash");
+_STLIT8(K72, "roap:X509SPKIHash");
+_STLIT8(K73, "keyIdentifier");
+_STLIT8(K74, "keyIdentifier");
+_STLIT8(K75, "keyIdentifier");
+_STLIT8(K76, "keyIdentifier");
+_STLIT8(K77, "hash");
+_STLIT8(K78, "hash");
+_STLIT8(K79, "hash");
+_STLIT8(K80, "hash");
+_STLIT8(K81, "ds:SignedInfo");
+_STLIT8(K82, "ds:SignedInfo");
+_STLIT8(K83, "ds:SignedInfo");
+_STLIT8(K84, "ds:SignedInfo");
+_STLIT8(K85, "ds:SignatureValue");
+_STLIT8(K86, "ds:SignatureValue");
+_STLIT8(K87, "ds:SignatureValue");
+_STLIT8(K88, "ds:SignatureValue");
+_STLIT8(K89, "ds:KeyInfo");
+_STLIT8(K90, "ds:KeyInfo");
+_STLIT8(K91, "ds:KeyInfo");
+_STLIT8(K92, "ds:KeyInfo");
+_STLIT8(K93, "ds:CanonicalizationMethod");
+_STLIT8(K94, "ds:CanonicalizationMethod");
+_STLIT8(K95, "ds:CanonicalizationMethod");
+_STLIT8(K96, "ds:CanonicalizationMethod");
+_STLIT8(K97, "ds:SignatureMethod");
+_STLIT8(K98, "ds:SignatureMethod");
+_STLIT8(K99, "ds:SignatureMethod");
+_STLIT8(K100, "ds:SignatureMethod");
+_STLIT8(K101, "ds:Reference");
+_STLIT8(K102, "ds:Reference");
+_STLIT8(K103, "ds:Reference");
+_STLIT8(K104, "ds:Reference");
+_STLIT8(K105, "ds:RetrievalMethod");
+_STLIT8(K106, "ds:RetrievalMethod");
+_STLIT8(K107, "ds:RetrievalMethod");
+_STLIT8(K108, "ds:RetrievalMethod");
+_STLIT8(K109, "ds:Transforms");
+_STLIT8(K110, "ds:Transforms");
+_STLIT8(K111, "ds:Transforms");
+_STLIT8(K112, "ds:Transforms");
+_STLIT8(K113, "ds:DigestMethod");
+_STLIT8(K114, "ds:DigestMethod");
+_STLIT8(K115, "ds:DigestMethod");
+_STLIT8(K116, "ds:DigestMethod");
+_STLIT8(K117, "ds:DigestValue");
+_STLIT8(K118, "ds:DigestValue");
+_STLIT8(K119, "ds:DigestValue");
+_STLIT8(K120, "ds:DigestValue");
+_STLIT8(K121, "ds:Transform");
+_STLIT8(K122, "ds:Transform");
+_STLIT8(K123, "ds:Transform");
+_STLIT8(K124, "ds:Transform");
+_STLIT8(K125, "xenc:EncryptionMethod");
+_STLIT8(K126, "xenc:EncryptionMethod");
+_STLIT8(K127, "xenc:EncryptionMethod");
+_STLIT8(K128, "xenc:EncryptionMethod");
+_STLIT8(K129, "xenc:CipherData");
+_STLIT8(K130, "xenc:CipherData");
+_STLIT8(K131, "xenc:CipherData");
+_STLIT8(K132, "xenc:CipherData");
+_STLIT8(K133, "xenc:CipherValue");
+_STLIT8(K134, "xenc:CipherValue");
+_STLIT8(K135, "xenc:CipherValue");
+_STLIT8(K136, "xenc:CipherValue");
+_STLIT8(K137, "extendedTrigger");
+_STLIT8(K138, "extendedTrigger");
+_STLIT8(K139, "extendedTrigger");
+_STLIT8(K140, "extendedTrigger");
+_STLIT8(K141, "trgLeaveDomain");
+_STLIT8(K142, "trgLeaveDomain");
+_STLIT8(K143, "trgLeaveDomain");
+_STLIT8(K144, "trgLeaveDomain");
+_STLIT8(K145, "deviceID");
+_STLIT8(K146, "deviceID");
+_STLIT8(K147, "deviceID");
+_STLIT8(K148, "deviceID");
+_STLIT8(K149, "-//OMA/DRM 2.1//EN");
+_STLIT8(K150, "13~0");
+_STLIT8(K151, "-//OMA/DRM 2.1//EN~0");
+
+// Intermediate
+const void * const KStringPointers[] =
+	{
+	(const void*)&K1,
+	(const void*)&K2,
+	(const void*)&K3,
+	(const void*)&K4,
+	(const void*)&K5,
+	(const void*)&K6,
+	(const void*)&K7,
+	(const void*)&K8,
+	(const void*)&K9,
+	(const void*)&K10,
+	(const void*)&K11,
+	(const void*)&K12,
+	(const void*)&K13,
+	(const void*)&K14,
+	(const void*)&K15,
+	(const void*)&K16,
+	(const void*)&K17,
+	(const void*)&K18,
+	(const void*)&K19,
+	(const void*)&K20,
+	(const void*)&K21,
+	(const void*)&K22,
+	(const void*)&K23,
+	(const void*)&K24,
+	(const void*)&K25,
+	(const void*)&K26,
+	(const void*)&K27,
+	(const void*)&K28,
+	(const void*)&K29,
+	(const void*)&K30,
+	(const void*)&K31,
+	(const void*)&K32,
+	(const void*)&K33,
+	(const void*)&K34,
+	(const void*)&K35,
+	(const void*)&K36,
+	(const void*)&K37,
+	(const void*)&K38,
+	(const void*)&K39,
+	(const void*)&K40,
+	(const void*)&K41,
+	(const void*)&K42,
+	(const void*)&K43,
+	(const void*)&K44,
+	(const void*)&K45,
+	(const void*)&K46,
+	(const void*)&K47,
+	(const void*)&K48,
+	(const void*)&K49,
+	(const void*)&K50,
+	(const void*)&K51,
+	(const void*)&K52,
+	(const void*)&K53,
+	(const void*)&K54,
+	(const void*)&K55,
+	(const void*)&K56,
+	(const void*)&K57,
+	(const void*)&K58,
+	(const void*)&K59,
+	(const void*)&K60,
+	(const void*)&K61,
+	(const void*)&K62,
+	(const void*)&K63,
+	(const void*)&K64,
+	(const void*)&K65,
+	(const void*)&K66,
+	(const void*)&K67,
+	(const void*)&K68,
+	(const void*)&K69,
+	(const void*)&K70,
+	(const void*)&K71,
+	(const void*)&K72,
+	(const void*)&K73,
+	(const void*)&K74,
+	(const void*)&K75,
+	(const void*)&K76,
+	(const void*)&K77,
+	(const void*)&K78,
+	(const void*)&K79,
+	(const void*)&K80,
+	(const void*)&K81,
+	(const void*)&K82,
+	(const void*)&K83,
+	(const void*)&K84,
+	(const void*)&K85,
+	(const void*)&K86,
+	(const void*)&K87,
+	(const void*)&K88,
+	(const void*)&K89,
+	(const void*)&K90,
+	(const void*)&K91,
+	(const void*)&K92,
+	(const void*)&K93,
+	(const void*)&K94,
+	(const void*)&K95,
+	(const void*)&K96,
+	(const void*)&K97,
+	(const void*)&K98,
+	(const void*)&K99,
+	(const void*)&K100,
+	(const void*)&K101,
+	(const void*)&K102,
+	(const void*)&K103,
+	(const void*)&K104,
+	(const void*)&K105,
+	(const void*)&K106,
+	(const void*)&K107,
+	(const void*)&K108,
+	(const void*)&K109,
+	(const void*)&K110,
+	(const void*)&K111,
+	(const void*)&K112,
+	(const void*)&K113,
+	(const void*)&K114,
+	(const void*)&K115,
+	(const void*)&K116,
+	(const void*)&K117,
+	(const void*)&K118,
+	(const void*)&K119,
+	(const void*)&K120,
+	(const void*)&K121,
+	(const void*)&K122,
+	(const void*)&K123,
+	(const void*)&K124,
+	(const void*)&K125,
+	(const void*)&K126,
+	(const void*)&K127,
+	(const void*)&K128,
+	(const void*)&K129,
+	(const void*)&K130,
+	(const void*)&K131,
+	(const void*)&K132,
+	(const void*)&K133,
+	(const void*)&K134,
+	(const void*)&K135,
+	(const void*)&K136,
+	(const void*)&K137,
+	(const void*)&K138,
+	(const void*)&K139,
+	(const void*)&K140,
+	(const void*)&K141,
+	(const void*)&K142,
+	(const void*)&K143,
+	(const void*)&K144,
+	(const void*)&K145,
+	(const void*)&K146,
+	(const void*)&K147,
+	(const void*)&K148,
+	(const void*)&K149,
+	(const void*)&K150,
+	(const void*)&K151
+	};
+
+const TStringTable DrmRel2_1StringDict00TagTable::Table = {151, KStringPointers, ETrue};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmengine/utils/src/procwatcher.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,134 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the process watcher
+*
+*/
+
+
+#include <e32def.h>
+#include <e32base.h>
+#include <f32file.h>
+#include <sysutil.h>
+#include "procwatcher.h"
+#include "drmlog.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+void CProcWatcher::ConstructL( const TDesC& aProcess, const TDesC& aFile )
+    {
+    DRMLOG( _L( "CProcWatcher::ConstructL <-" ) );
+
+    iProcessName.Copy( aProcess );
+    iFileName.Copy( aFile );
+    CActiveScheduler::Add( this );
+    
+    DRMLOG( _L( "CProcWatcher::ConstructL ->" ) );
+    }
+
+CProcWatcher* CProcWatcher::NewL( MWatcherObserver& aObserver, const TDesC& aProcess, const TDesC& aFile )
+    {
+    CProcWatcher* self = new( ELeave ) CProcWatcher( aObserver);
+    self->ConstructL( aProcess, aFile );
+    return self;
+    }
+
+CProcWatcher::CProcWatcher( MWatcherObserver& aObserver ):
+    CActive( EPriorityStandard ),
+    iObserver( aObserver )
+    {
+    DRMLOG( _L( "CProcWatcher::CProcWatcher ->" ) );
+    DRMLOG( _L( "CProcWatcher::CProcWatcher <-" ) );
+    }
+
+CProcWatcher::~CProcWatcher()
+    {
+    DRMLOG( _L( "CProcWatcher::~CProcWatcher ->" ) );
+    
+    Cancel();
+    
+    DRMLOG( _L( "CProcWatcher::~CProcWatcher <-" ) );
+    }
+
+TInt CProcWatcher::StartWatching()
+    {
+    TFullName name;
+    TFindProcess finder( iProcessName );
+    TInt r = KErrNone;
+    
+    DRMLOG( _L( "CProcWatcher::StartWatching ->" ) );
+    DRMLOG( iProcessName );
+    
+    r = finder.Next( name );
+    if ( r != KErrNone )
+        {
+        r = iProcess.Create( iFileName, KNullDesC );
+        if ( r == KErrNone )
+            {
+            iProcess.Resume();
+            }
+        }
+    else
+        {
+        iProcessName.Copy( name );
+        DRMLOG( iProcessName );
+        r = iProcess.Open( iProcessName );
+        }
+        
+    if ( r == KErrNone )
+        {
+        iProcess.Logon( iStatus );
+        SetActive();
+        DRMLOG( _L( "Active " ) );
+        }
+
+    DRMLOG( _L( "CProcWatcher::StartWatching <-" ) );
+    return r;
+    }
+    
+void CProcWatcher::DoCancel()
+    {
+    DRMLOG( _L( "CProcWatcher::DoCancel ->" ) );
+    
+    DRMLOG( _L( "CProcWatcher::DoCancel <-" ) );
+    }
+    
+void CProcWatcher::RunL()
+    {
+    TBuf<256> logBuffer;
+    TFileName object;
+    
+    DRMLOG( _L( "CProcWatcher::RunL ->" ) );
+    
+    DRMLOG( iProcessName );
+    logBuffer.AppendNum( iStatus.Int() );
+    logBuffer.Append( ' ' );
+    logBuffer.AppendNum( iProcess.ExitType() );
+    DRMLOG( logBuffer );
+    if ( iProcess.ExitType() != EExitPending )
+        {
+        object.Copy( KProcIdentifier );
+        object.Append( iProcessName );
+        iObserver.WatchedObjectChangedL( object );
+        }
+    else
+        {
+        if ( iProcess.Open( iProcessName ) == KErrNone )
+            {
+            iProcess.Logon( iStatus );
+            }
+        }
+    SetActive();
+    
+    DRMLOG( _L( "CProcWatcher::RunL <-" ) );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/BMARM/DRMHELPERDMGRWRAPPERU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1 @@
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/BMARM/DRMHELPERU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,48 @@
+EXPORTS
+	"_._27CDRMHelperRightsConstraints" @ 1 NONAME R3UNUSED ; CDRMHelperRightsConstraints::~CDRMHelperRightsConstraints(void)
+	CanSetAutomated__10CDRMHelperRC7TDesC16Ri @ 2 NONAME R3UNUSED ; CDRMHelper::CanSetAutomated(TDesC16 const &, int &)
+	CheckRightsAmountL__10CDRMHelperRC6TDesC8ii @ 3 NONAME ; CDRMHelper::CheckRightsAmountL(TDesC8 const &, int, int)
+	CheckRightsAmountL__10CDRMHelperRC7TDesC16ii @ 4 NONAME ; CDRMHelper::CheckRightsAmountL(TDesC16 const &, int, int)
+	CheckRightsPercentL__10CDRMHelperRC7TDesC16i @ 5 NONAME R3UNUSED ; CDRMHelper::CheckRightsPercentL(TDesC16 const &, int)
+	ShowAutomatedNote__10CDRMHelperRC6TDesC8 @ 6 NONAME R3UNUSED ; CDRMHelper::ShowAutomatedNote(TDesC8 const &)
+	ShowAutomatedNote__10CDRMHelperRC7TDesC16 @ 7 NONAME R3UNUSED ; CDRMHelper::ShowAutomatedNote(TDesC16 const &)
+	SupportedDataType__10CDRMHelperiR9TDataType @ 8 NONAME R3UNUSED ; CDRMHelper::SupportedDataType(int, TDataType &)
+	UnRegisterDataType__10CDRMHelperi @ 9 NONAME R3UNUSED ; CDRMHelper::UnRegisterDataType(int)
+	"_._10CDRMHelper" @ 10 NONAME R3UNUSED ; CDRMHelper::~CDRMHelper(void)
+	CanSetAutomated__10CDRMHelperRC6TDesC8Ri @ 11 NONAME R3UNUSED ; CDRMHelper::CanSetAutomated(TDesC8 const &, int &)
+	DataTypesCount__10CDRMHelperRi @ 12 NONAME R3UNUSED ; CDRMHelper::DataTypesCount(int &)
+	FullRights__27CDRMHelperRightsConstraints @ 13 NONAME R3UNUSED ; CDRMHelperRightsConstraints::FullRights(void)
+	GetContentURIList__10CDRMHelperRPt13RPointerArray1Z6HBufC8 @ 14 NONAME R3UNUSED ; CDRMHelper::GetContentURIList(RPointerArray<HBufC8> *&)
+	GetCountersL__27CDRMHelperRightsConstraintsRUlT1 @ 15 NONAME R3UNUSED ; CDRMHelperRightsConstraints::GetCountersL(unsigned long &, unsigned long &)
+	GetEndTimeL__27CDRMHelperRightsConstraintsR5TTime @ 16 NONAME R3UNUSED ; CDRMHelperRightsConstraints::GetEndTimeL(TTime &)
+	GetIntervalL__27CDRMHelperRightsConstraintsR20TTimeIntervalSeconds @ 17 NONAME R3UNUSED ; CDRMHelperRightsConstraints::GetIntervalL(TTimeIntervalSeconds &)
+	GetIntervalStartL__27CDRMHelperRightsConstraintsR5TTime @ 18 NONAME R3UNUSED ; CDRMHelperRightsConstraints::GetIntervalStartL(TTime &)
+	GetRightsDetailsL__10CDRMHelperRC7TDesC16UlRiT3RP21CDRMRightsConstraintsN35 @ 19 NONAME ; CDRMHelper::GetRightsDetailsL(TDesC16 const &, unsigned long, int &, int &, CDRMRightsConstraints *&, CDRMRightsConstraints *&, CDRMRightsConstraints *&, CDRMRightsConstraints *&)
+	GetRightsDetailsL__10CDRMHelperRC7TDesC16UlRiT3RP27CDRMHelperRightsConstraintsN35 @ 20 NONAME ; CDRMHelper::GetRightsDetailsL(TDesC16 const &, unsigned long, int &, int &, CDRMHelperRightsConstraints *&, CDRMHelperRightsConstraints *&, CDRMHelperRightsConstraints *&, CDRMHelperRightsConstraints *&)
+	GetStartTimeL__27CDRMHelperRightsConstraintsR5TTime @ 21 NONAME R3UNUSED ; CDRMHelperRightsConstraints::GetStartTimeL(TTime &)
+	HandleErrorL__10CDRMHelperiRC6TDesC8 @ 22 NONAME R3UNUSED ; CDRMHelper::HandleErrorL(int, TDesC8 const &)
+	HandleErrorL__10CDRMHelperiRC7TDesC16 @ 23 NONAME R3UNUSED ; CDRMHelper::HandleErrorL(int, TDesC16 const &)
+	IndicateIdle__10CDRMHelper @ 24 NONAME R3UNUSED ; CDRMHelper::IndicateIdle(void)
+	IsPreview__27CDRMHelperRightsConstraints @ 25 NONAME R3UNUSED ; CDRMHelperRightsConstraints::IsPreview(void)
+	LaunchDetailsViewEmbeddedL__10CDRMHelperPC6HBufC8 @ 26 NONAME R3UNUSED ; CDRMHelper::LaunchDetailsViewEmbeddedL(HBufC8 const *)
+	LaunchDetailsViewEmbeddedL__10CDRMHelperRC6TDesC8 @ 27 NONAME R3UNUSED ; CDRMHelper::LaunchDetailsViewEmbeddedL(TDesC8 const &)
+	LaunchDetailsViewEmbeddedL__10CDRMHelperRC7TDesC16 @ 28 NONAME R3UNUSED ; CDRMHelper::LaunchDetailsViewEmbeddedL(TDesC16 const &)
+	NewLC__10CDRMHelper @ 29 NONAME R3UNUSED ; CDRMHelper::NewLC(void)
+	NewLC__10CDRMHelperR7CCoeEnv @ 30 NONAME R3UNUSED ; CDRMHelper::NewLC(CCoeEnv &)
+	NewL__10CDRMHelper @ 31 NONAME R3UNUSED ; CDRMHelper::NewL(void)
+	NewL__10CDRMHelperR7CCoeEnv @ 32 NONAME R3UNUSED ; CDRMHelper::NewL(CCoeEnv &)
+	RegisterDataType__10CDRMHelperRC9TDataType @ 33 NONAME R3UNUSED ; CDRMHelper::RegisterDataType(TDataType const &)
+	RemoveAutomatedPassive__10CDRMHelperRC6TDesC8 @ 34 NONAME R3UNUSED ; CDRMHelper::RemoveAutomatedPassive(TDesC8 const &)
+	RemoveAutomatedPassive__10CDRMHelperRC7TDesC16 @ 35 NONAME R3UNUSED ; CDRMHelper::RemoveAutomatedPassive(TDesC16 const &)
+	RemoveAutomated__10CDRMHelperRC6TDesC8 @ 36 NONAME R3UNUSED ; CDRMHelper::RemoveAutomated(TDesC8 const &)
+	RemoveAutomated__10CDRMHelperRC7TDesC16 @ 37 NONAME R3UNUSED ; CDRMHelper::RemoveAutomated(TDesC16 const &)
+	SetAutomatedPassive__10CDRMHelperRC6TDesC8 @ 38 NONAME R3UNUSED ; CDRMHelper::SetAutomatedPassive(TDesC8 const &)
+	SetAutomatedPassive__10CDRMHelperRC7TDesC16 @ 39 NONAME R3UNUSED ; CDRMHelper::SetAutomatedPassive(TDesC16 const &)
+	SetAutomatedSilent__10CDRMHelperRC6TDesC8i @ 40 NONAME R3UNUSED ; CDRMHelper::SetAutomatedSilent(TDesC8 const &, int)
+	SetAutomatedSilent__10CDRMHelperRC7TDesC16i @ 41 NONAME R3UNUSED ; CDRMHelper::SetAutomatedSilent(TDesC16 const &, int)
+	SetAutomated__10CDRMHelperRC6TDesC8 @ 42 NONAME R3UNUSED ; CDRMHelper::SetAutomated(TDesC8 const &)
+	SetAutomated__10CDRMHelperRC7TDesC16 @ 43 NONAME R3UNUSED ; CDRMHelper::SetAutomated(TDesC16 const &)
+	SetCountLimitL__10CDRMHelperUi @ 44 NONAME R3UNUSED ; CDRMHelper::SetCountLimitL(unsigned int)
+	SetPercentageLimitL__10CDRMHelperUi @ 45 NONAME R3UNUSED ; CDRMHelper::SetPercentageLimitL(unsigned int)
+	SetTimeLimitL__10CDRMHelperUi @ 46 NONAME R3UNUSED ; CDRMHelper::SetTimeLimitL(unsigned int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/BWINSCW/DRMHelperU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,89 @@
+EXPORTS
+	??1CDRMHelper@@UAE@XZ @ 1 NONAME ; CDRMHelper::~CDRMHelper(void)
+	??1CDRMHelperRightsConstraints@@UAE@XZ @ 2 NONAME ; CDRMHelperRightsConstraints::~CDRMHelperRightsConstraints(void)
+	?ActivateContentL@CDRMHelper@@QAEXAAVCData@ContentAccess@@@Z @ 3 NONAME ; void CDRMHelper::ActivateContentL(class ContentAccess::CData &)
+	?ActivateContentL@CDRMHelper@@QAEXAAVTDesC16@@@Z @ 4 NONAME ; void CDRMHelper::ActivateContentL(class TDesC16 &)
+	?CanSetAutomated@CDRMHelper@@QAEHAAVRFile@@AAH@Z @ 5 NONAME ; int CDRMHelper::CanSetAutomated(class RFile &, int &)
+	?CanSetAutomated@CDRMHelper@@QAEHABVTDesC16@@AAH@Z @ 6 NONAME ; int CDRMHelper::CanSetAutomated(class TDesC16 const &, int &)
+	?CanSetAutomated@CDRMHelper@@QAEHABVTDesC8@@AAH@Z @ 7 NONAME ; int CDRMHelper::CanSetAutomated(class TDesC8 const &, int &)
+	?CheckRightsAmountL@CDRMHelper@@QAEHAAVRFile@@HH@Z @ 8 NONAME ; int CDRMHelper::CheckRightsAmountL(class RFile &, int, int)
+	?CheckRightsAmountL@CDRMHelper@@QAEHABVTDesC16@@HH@Z @ 9 NONAME ; int CDRMHelper::CheckRightsAmountL(class TDesC16 const &, int, int)
+	?CheckRightsAmountL@CDRMHelper@@QAEHABVTDesC8@@HH@Z @ 10 NONAME ; int CDRMHelper::CheckRightsAmountL(class TDesC8 const &, int, int)
+	?CheckRightsPercentL@CDRMHelper@@QAEHAAVRFile@@H@Z @ 11 NONAME ; int CDRMHelper::CheckRightsPercentL(class RFile &, int)
+	?CheckRightsPercentL@CDRMHelper@@QAEHABVTDesC16@@H@Z @ 12 NONAME ; int CDRMHelper::CheckRightsPercentL(class TDesC16 const &, int)
+	?Consume2@CDRMHelper@@QAEHABVTDesC8@@KW4TDRMHelperConsumeAction@1@@Z @ 13 NONAME ; int CDRMHelper::Consume2(class TDesC8 const &, unsigned long, enum CDRMHelper::TDRMHelperConsumeAction)
+	?UnRegisterDataType@CDRMHelper@@QAEHH@Z @ 14 NONAME ; int CDRMHelper::UnRegisterDataType(int)
+	?ConsumeFile2@CDRMHelper@@QAEHAAVRFile@@KW4TDRMHelperConsumeAction@1@@Z @ 15 NONAME ; int CDRMHelper::ConsumeFile2(class RFile &, unsigned long, enum CDRMHelper::TDRMHelperConsumeAction)
+	?ConsumeFile2@CDRMHelper@@QAEHABVTDesC16@@KW4TDRMHelperConsumeAction@1@@Z @ 16 NONAME ; int CDRMHelper::ConsumeFile2(class TDesC16 const &, unsigned long, enum CDRMHelper::TDRMHelperConsumeAction)
+	?SupportedDataType@CDRMHelper@@QAEHHAAVTDataType@@@Z @ 17 NONAME ; int CDRMHelper::SupportedDataType(int, class TDataType &)
+	?DataTypesCount@CDRMHelper@@QAEHAAH@Z @ 18 NONAME ; int CDRMHelper::DataTypesCount(int &)
+	?EmbeddedPreviewCompletedL@CDRMHelper@@QAEHAAVCData@ContentAccess@@@Z @ 19 NONAME ; int CDRMHelper::EmbeddedPreviewCompletedL(class ContentAccess::CData &)
+	?EmbeddedPreviewCompletedL@CDRMHelper@@QAEHAAVTDesC16@@@Z @ 20 NONAME ; int CDRMHelper::EmbeddedPreviewCompletedL(class TDesC16 &)
+	?FullRights@CDRMHelperRightsConstraints@@QAEHXZ @ 21 NONAME ; int CDRMHelperRightsConstraints::FullRights(void)
+	?GetAccumulatedTimeL@CDRMHelperRightsConstraints@@QAEXAAVTTimeIntervalSeconds@@@Z @ 22 NONAME ; void CDRMHelperRightsConstraints::GetAccumulatedTimeL(class TTimeIntervalSeconds &)
+	?GetContentURIList@CDRMHelper@@QAEHAAPAV?$RPointerArray@VHBufC8@@@@@Z @ 23 NONAME ; int CDRMHelper::GetContentURIList(class RPointerArray<class HBufC8> * &)
+	?GetCountersL@CDRMHelperRightsConstraints@@QAEXAAK0@Z @ 24 NONAME ; void CDRMHelperRightsConstraints::GetCountersL(unsigned long &, unsigned long &)
+	?GetEndTimeL@CDRMHelperRightsConstraints@@QAEXAAVTTime@@@Z @ 25 NONAME ; void CDRMHelperRightsConstraints::GetEndTimeL(class TTime &)
+	?GetIntervalL@CDRMHelperRightsConstraints@@QAEXAAVTTimeIntervalSeconds@@@Z @ 26 NONAME ; void CDRMHelperRightsConstraints::GetIntervalL(class TTimeIntervalSeconds &)
+	?GetIntervalStartL@CDRMHelperRightsConstraints@@QAEXAAVTTime@@@Z @ 27 NONAME ; void CDRMHelperRightsConstraints::GetIntervalStartL(class TTime &)
+	?GetPreviewRightsL@CDRMHelper@@QAEXAAVCData@ContentAccess@@@Z @ 28 NONAME ; void CDRMHelper::GetPreviewRightsL(class ContentAccess::CData &)
+	?GetPreviewRightsL@CDRMHelper@@QAEXAAVTDesC16@@@Z @ 29 NONAME ; void CDRMHelper::GetPreviewRightsL(class TDesC16 &)
+	?GetRightsDetailsL@CDRMHelper@@QAEXAAVRFile@@KAAH1AAPAVCDRMHelperRightsConstraints@@222@Z @ 30 NONAME ; void CDRMHelper::GetRightsDetailsL(class RFile &, unsigned long, int &, int &, class CDRMHelperRightsConstraints * &, class CDRMHelperRightsConstraints * &, class CDRMHelperRightsConstraints * &, class CDRMHelperRightsConstraints * &)
+	?GetRightsDetailsL@CDRMHelper@@QAEXABVTDesC16@@KAAH1AAPAVCDRMHelperRightsConstraints@@222@Z @ 31 NONAME ; void CDRMHelper::GetRightsDetailsL(class TDesC16 const &, unsigned long, int &, int &, class CDRMHelperRightsConstraints * &, class CDRMHelperRightsConstraints * &, class CDRMHelperRightsConstraints * &, class CDRMHelperRightsConstraints * &)
+	?GetRightsDetailsL@CDRMHelper@@QAEXABVTDesC16@@KAAH1AAPAVCDRMRightsConstraints@@222@Z @ 32 NONAME ; void CDRMHelper::GetRightsDetailsL(class TDesC16 const &, unsigned long, int &, int &, class CDRMRightsConstraints * &, class CDRMRightsConstraints * &, class CDRMRightsConstraints * &, class CDRMRightsConstraints * &)
+	?GetStartTimeL@CDRMHelperRightsConstraints@@QAEXAAVTTime@@@Z @ 33 NONAME ; void CDRMHelperRightsConstraints::GetStartTimeL(class TTime &)
+	?GetTimedCountL@CDRMHelperRightsConstraints@@QAEXAAK0AAVTTimeIntervalSeconds@@@Z @ 34 NONAME ; void CDRMHelperRightsConstraints::GetTimedCountL(unsigned long &, unsigned long &, class TTimeIntervalSeconds &)
+	?HandleErrorL@CDRMHelper@@QAEHHAAVRFile@@@Z @ 35 NONAME ; int CDRMHelper::HandleErrorL(int, class RFile &)
+	?HandleErrorL@CDRMHelper@@QAEHHABVTDesC16@@@Z @ 36 NONAME ; int CDRMHelper::HandleErrorL(int, class TDesC16 const &)
+	?HandleErrorL@CDRMHelper@@QAEHHABVTDesC8@@@Z @ 37 NONAME ; int CDRMHelper::HandleErrorL(int, class TDesC8 const &)
+	?HasInfoUrlL@CDRMHelper@@QAEHAAVCData@ContentAccess@@AAPAVHBufC8@@@Z @ 38 NONAME ; int CDRMHelper::HasInfoUrlL(class ContentAccess::CData &, class HBufC8 * &)
+	?HasInfoUrlL@CDRMHelper@@QAEHAAVTDesC16@@AAPAVHBufC8@@@Z @ 39 NONAME ; int CDRMHelper::HasInfoUrlL(class TDesC16 &, class HBufC8 * &)
+	?HasPreviewL@CDRMHelper@@QAE?AW4TDRMHelperPreviewType@1@AAVCData@ContentAccess@@AAPAVHBufC8@@@Z @ 40 NONAME ; enum CDRMHelper::TDRMHelperPreviewType CDRMHelper::HasPreviewL(class ContentAccess::CData &, class HBufC8 * &)
+	?HasPreviewL@CDRMHelper@@QAE?AW4TDRMHelperPreviewType@1@AAVTDesC16@@AAPAVHBufC8@@@Z @ 41 NONAME ; enum CDRMHelper::TDRMHelperPreviewType CDRMHelper::HasPreviewL(class TDesC16 &, class HBufC8 * &)
+	?IndicateIdle@CDRMHelper@@QAEXXZ @ 42 NONAME ; void CDRMHelper::IndicateIdle(void)
+	?IsPreview@CDRMHelperRightsConstraints@@QAEHXZ @ 43 NONAME ; int CDRMHelperRightsConstraints::IsPreview(void)
+	?LaunchDetailsViewEmbeddedL@CDRMHelper@@QAEXAAVRFile@@@Z @ 44 NONAME ; void CDRMHelper::LaunchDetailsViewEmbeddedL(class RFile &)
+	?LaunchDetailsViewEmbeddedL@CDRMHelper@@QAEXABVTDesC16@@@Z @ 45 NONAME ; void CDRMHelper::LaunchDetailsViewEmbeddedL(class TDesC16 const &)
+	?LaunchDetailsViewEmbeddedL@CDRMHelper@@QAEXABVTDesC8@@@Z @ 46 NONAME ; void CDRMHelper::LaunchDetailsViewEmbeddedL(class TDesC8 const &)
+	?LaunchDetailsViewEmbeddedL@CDRMHelper@@QAEXPBVHBufC8@@@Z @ 47 NONAME ; void CDRMHelper::LaunchDetailsViewEmbeddedL(class HBufC8 const *)
+	?NewL@CDRMHelper@@SAPAV1@AAVCCoeEnv@@@Z @ 48 NONAME ; class CDRMHelper * CDRMHelper::NewL(class CCoeEnv &)
+	?NewL@CDRMHelper@@SAPAV1@XZ @ 49 NONAME ; class CDRMHelper * CDRMHelper::NewL(void)
+	?NewLC@CDRMHelper@@SAPAV1@AAVCCoeEnv@@@Z @ 50 NONAME ; class CDRMHelper * CDRMHelper::NewLC(class CCoeEnv &)
+	?NewLC@CDRMHelper@@SAPAV1@XZ @ 51 NONAME ; class CDRMHelper * CDRMHelper::NewLC(void)
+	?OpenInfoUrlL@CDRMHelper@@QAEXAAVCData@ContentAccess@@@Z @ 52 NONAME ; void CDRMHelper::OpenInfoUrlL(class ContentAccess::CData &)
+	?OpenInfoUrlL@CDRMHelper@@QAEXAAVTDesC16@@@Z @ 53 NONAME ; void CDRMHelper::OpenInfoUrlL(class TDesC16 &)
+	?RegisterDataType@CDRMHelper@@QAEHABVTDataType@@@Z @ 54 NONAME ; int CDRMHelper::RegisterDataType(class TDataType const &)
+	?RemoveAutomated@CDRMHelper@@QAEHAAVRFile@@@Z @ 55 NONAME ; int CDRMHelper::RemoveAutomated(class RFile &)
+	?RemoveAutomated@CDRMHelper@@QAEHABVTDesC16@@@Z @ 56 NONAME ; int CDRMHelper::RemoveAutomated(class TDesC16 const &)
+	?RemoveAutomated@CDRMHelper@@QAEHABVTDesC8@@@Z @ 57 NONAME ; int CDRMHelper::RemoveAutomated(class TDesC8 const &)
+	?RemoveAutomatedPassive@CDRMHelper@@QAEHAAVRFile@@@Z @ 58 NONAME ; int CDRMHelper::RemoveAutomatedPassive(class RFile &)
+	?RemoveAutomatedPassive@CDRMHelper@@QAEHABVTDesC16@@@Z @ 59 NONAME ; int CDRMHelper::RemoveAutomatedPassive(class TDesC16 const &)
+	?RemoveAutomatedPassive@CDRMHelper@@QAEHABVTDesC8@@@Z @ 60 NONAME ; int CDRMHelper::RemoveAutomatedPassive(class TDesC8 const &)
+	?SetAutomated@CDRMHelper@@QAEHAAVRFile@@@Z @ 61 NONAME ; int CDRMHelper::SetAutomated(class RFile &)
+	?SetAutomated@CDRMHelper@@QAEHABVTDesC16@@@Z @ 62 NONAME ; int CDRMHelper::SetAutomated(class TDesC16 const &)
+	?SetAutomated@CDRMHelper@@QAEHABVTDesC8@@@Z @ 63 NONAME ; int CDRMHelper::SetAutomated(class TDesC8 const &)
+	?SetAutomatedPassive@CDRMHelper@@QAEHAAVRFile@@@Z @ 64 NONAME ; int CDRMHelper::SetAutomatedPassive(class RFile &)
+	?SetAutomatedPassive@CDRMHelper@@QAEHABVTDesC16@@@Z @ 65 NONAME ; int CDRMHelper::SetAutomatedPassive(class TDesC16 const &)
+	?SetAutomatedPassive@CDRMHelper@@QAEHABVTDesC8@@@Z @ 66 NONAME ; int CDRMHelper::SetAutomatedPassive(class TDesC8 const &)
+	?SetAutomatedSilent@CDRMHelper@@QAEHAAVRFile@@H@Z @ 67 NONAME ; int CDRMHelper::SetAutomatedSilent(class RFile &, int)
+	?SetAutomatedSilent@CDRMHelper@@QAEHABVTDesC16@@H@Z @ 68 NONAME ; int CDRMHelper::SetAutomatedSilent(class TDesC16 const &, int)
+	?SetAutomatedSilent@CDRMHelper@@QAEHABVTDesC8@@H@Z @ 69 NONAME ; int CDRMHelper::SetAutomatedSilent(class TDesC8 const &, int)
+	?SetAutomatedType@CDRMHelper@@QAEHW4TDRMHelperAutomatedType@1@@Z @ 70 NONAME ; int CDRMHelper::SetAutomatedType(enum CDRMHelper::TDRMHelperAutomatedType)
+	?SetCountLimitL@CDRMHelper@@QAEXI@Z @ 71 NONAME ; void CDRMHelper::SetCountLimitL(unsigned int)
+	?SetPercentageLimitL@CDRMHelper@@QAEXI@Z @ 72 NONAME ; void CDRMHelper::SetPercentageLimitL(unsigned int)
+	?SetTimeLimitL@CDRMHelper@@QAEXI@Z @ 73 NONAME ; void CDRMHelper::SetTimeLimitL(unsigned int)
+	?ShowAutomatedNote@CDRMHelper@@QAEHAAVRFile@@@Z @ 74 NONAME ; int CDRMHelper::ShowAutomatedNote(class RFile &)
+	?ShowAutomatedNote@CDRMHelper@@QAEHABVTDesC16@@@Z @ 75 NONAME ; int CDRMHelper::ShowAutomatedNote(class TDesC16 const &)
+	?ShowAutomatedNote@CDRMHelper@@QAEHABVTDesC8@@@Z @ 76 NONAME ; int CDRMHelper::ShowAutomatedNote(class TDesC8 const &)
+	?ShowDRMUINotification2L@CDRMHelper@@QAEHW4TDRMHelperNotificationID@1@ABVTDesC16@@@Z @ 77 NONAME ; int CDRMHelper::ShowDRMUINotification2L(enum CDRMHelper::TDRMHelperNotificationID, class TDesC16 const &)
+	?ShowDRMUINotification2L@CDRMHelper@@QAEHW4TDRMHelperNotificationID@1@ABVTDesC8@@@Z @ 78 NONAME ; int CDRMHelper::ShowDRMUINotification2L(enum CDRMHelper::TDRMHelperNotificationID, class TDesC8 const &)
+	?SupportedDRMMethods2@CDRMHelper@@QAEHAAHAAW4TDRMHelperOMALevel@1@@Z @ 79 NONAME ; int CDRMHelper::SupportedDRMMethods2(int &, enum CDRMHelper::TDRMHelperOMALevel &)
+	?NewL@CDRMHelper@@SAPAV1@AAVCCoeEnv@@AAVRFs@@@Z @ 80 NONAME ; class CDRMHelper * CDRMHelper::NewL(class CCoeEnv &, class RFs &)
+	?NewL@CDRMHelper@@SAPAV1@AAVRFs@@@Z @ 81 NONAME ; class CDRMHelper * CDRMHelper::NewL(class RFs &)
+	?NewLC@CDRMHelper@@SAPAV1@AAVCCoeEnv@@AAVRFs@@@Z @ 82 NONAME ; class CDRMHelper * CDRMHelper::NewLC(class CCoeEnv &, class RFs &)
+	?NewLC@CDRMHelper@@SAPAV1@AAVRFs@@@Z @ 83 NONAME ; class CDRMHelper * CDRMHelper::NewLC(class RFs &)
+	?HandleErrorOrPreviewL@CDRMHelper@@QAEHHAAVRFile@@AAPAVHBufC8@@@Z @ 84 NONAME ; int CDRMHelper::HandleErrorOrPreviewL(int, class RFile &, class HBufC8 * &)
+	?SetPreviewMediaType@CDRMHelper@@QAEHW4TDRMHelperPreviewMediaType@@@Z @ 85 NONAME ; int CDRMHelper::SetPreviewMediaType(enum TDRMHelperPreviewMediaType)
+	?HandleErrorOrPreviewL@CDRMHelper@@QAEHHABVTDesC16@@AAPAVHBufC8@@@Z @ 86 NONAME ; int CDRMHelper::HandleErrorOrPreviewL(int, class TDesC16 const &, class HBufC8 * &)
+	?GetRightsDetailsL@CDRMHelper@@QAEXAAVRFile@@KAAH1AAPAVCDRMRightsConstraints@@222@Z @ 87 NONAME ; void CDRMHelper::GetRightsDetailsL(class RFile &, unsigned long, int &, int &, class CDRMRightsConstraints * &, class CDRMRightsConstraints * &, class CDRMRightsConstraints * &, class CDRMRightsConstraints * &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/BWINSCW/drmhelperdmgrwrapperU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?GateFunctionDMgr@@YAPAXXZ @ 1 NONAME ; void * GateFunctionDMgr(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/EABI/DRMHelperU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,99 @@
+EXPORTS
+	_ZN10CDRMHelper16SetAutomatedTypeENS_23TDRMHelperAutomatedTypeE @ 1 NONAME
+	_ZTV27CDRMHelperRightsConstraints @ 2 NONAME ; #<VT>#
+	_ZN10CDRMHelper11HasInfoUrlLER7TDesC16RP6HBufC8 @ 3 NONAME
+	_ZN10CDRMHelper11HasInfoUrlLERN13ContentAccess5CDataERP6HBufC8 @ 4 NONAME
+	_ZN10CDRMHelper11HasPreviewLER7TDesC16RP6HBufC8 @ 5 NONAME
+	_ZN10CDRMHelper11HasPreviewLERN13ContentAccess5CDataERP6HBufC8 @ 6 NONAME
+	_ZN10CDRMHelper12ConsumeFile2ER5RFilemNS_23TDRMHelperConsumeActionE @ 7 NONAME
+	_ZN10CDRMHelper12ConsumeFile2ERK7TDesC16mNS_23TDRMHelperConsumeActionE @ 8 NONAME
+	_ZN10CDRMHelper12HandleErrorLEiR5RFile @ 9 NONAME
+	_ZN10CDRMHelper12HandleErrorLEiRK6TDesC8 @ 10 NONAME
+	_ZN10CDRMHelper12HandleErrorLEiRK7TDesC16 @ 11 NONAME
+	_ZN10CDRMHelper12IndicateIdleEv @ 12 NONAME
+	_ZN10CDRMHelper12OpenInfoUrlLER7TDesC16 @ 13 NONAME
+	_ZN10CDRMHelper12OpenInfoUrlLERN13ContentAccess5CDataE @ 14 NONAME
+	_ZN10CDRMHelper12SetAutomatedER5RFile @ 15 NONAME
+	_ZN10CDRMHelper12SetAutomatedERK6TDesC8 @ 16 NONAME
+	_ZN10CDRMHelper12SetAutomatedERK7TDesC16 @ 17 NONAME
+	_ZN10CDRMHelper13SetTimeLimitLEj @ 18 NONAME
+	_ZN10CDRMHelper14DataTypesCountERi @ 19 NONAME
+	_ZN10CDRMHelper14SetCountLimitLEj @ 20 NONAME
+	_ZN10CDRMHelper15CanSetAutomatedER5RFileRi @ 21 NONAME
+	_ZN10CDRMHelper15CanSetAutomatedERK6TDesC8Ri @ 22 NONAME
+	_ZN10CDRMHelper15CanSetAutomatedERK7TDesC16Ri @ 23 NONAME
+	_ZN10CDRMHelper15RemoveAutomatedER5RFile @ 24 NONAME
+	_ZN10CDRMHelper15RemoveAutomatedERK6TDesC8 @ 25 NONAME
+	_ZN10CDRMHelper15RemoveAutomatedERK7TDesC16 @ 26 NONAME
+	_ZN10CDRMHelper16ActivateContentLER7TDesC16 @ 27 NONAME
+	_ZN10CDRMHelper16ActivateContentLERN13ContentAccess5CDataE @ 28 NONAME
+	_ZN10CDRMHelper16RegisterDataTypeERK9TDataType @ 29 NONAME
+	_ZN10CDRMHelper17GetContentURIListERP13RPointerArrayI6HBufC8E @ 30 NONAME
+	_ZN10CDRMHelper17GetPreviewRightsLER7TDesC16 @ 31 NONAME
+	_ZN10CDRMHelper17GetPreviewRightsLERN13ContentAccess5CDataE @ 32 NONAME
+	_ZN10CDRMHelper17GetRightsDetailsLER5RFilemRiS2_RP27CDRMHelperRightsConstraintsS5_S5_S5_ @ 33 NONAME
+	_ZN10CDRMHelper17GetRightsDetailsLERK7TDesC16mRiS3_RP21CDRMRightsConstraintsS6_S6_S6_ @ 34 NONAME
+	_ZN10CDRMHelper17GetRightsDetailsLERK7TDesC16mRiS3_RP27CDRMHelperRightsConstraintsS6_S6_S6_ @ 35 NONAME
+	_ZN10CDRMHelper17ShowAutomatedNoteER5RFile @ 36 NONAME
+	_ZN10CDRMHelper17ShowAutomatedNoteERK6TDesC8 @ 37 NONAME
+	_ZN10CDRMHelper17ShowAutomatedNoteERK7TDesC16 @ 38 NONAME
+	_ZN10CDRMHelper17SupportedDataTypeEiR9TDataType @ 39 NONAME
+	_ZN10CDRMHelper18CheckRightsAmountLER5RFileii @ 40 NONAME
+	_ZN10CDRMHelper18CheckRightsAmountLERK6TDesC8ii @ 41 NONAME
+	_ZN10CDRMHelper18CheckRightsAmountLERK7TDesC16ii @ 42 NONAME
+	_ZN10CDRMHelper18SetAutomatedSilentER5RFilei @ 43 NONAME
+	_ZN10CDRMHelper18SetAutomatedSilentERK6TDesC8i @ 44 NONAME
+	_ZN10CDRMHelper18SetAutomatedSilentERK7TDesC16i @ 45 NONAME
+	_ZN10CDRMHelper18UnRegisterDataTypeEi @ 46 NONAME
+	_ZN10CDRMHelper19CheckRightsPercentLER5RFilei @ 47 NONAME
+	_ZN10CDRMHelper19CheckRightsPercentLERK7TDesC16i @ 48 NONAME
+	_ZN10CDRMHelper19SetAutomatedPassiveER5RFile @ 49 NONAME
+	_ZN10CDRMHelper19SetAutomatedPassiveERK6TDesC8 @ 50 NONAME
+	_ZN10CDRMHelper19SetAutomatedPassiveERK7TDesC16 @ 51 NONAME
+	_ZN10CDRMHelper19SetPercentageLimitLEj @ 52 NONAME
+	_ZTV27CDRMHelperGlobalNoteWrapper @ 53 NONAME ; #<VT>#
+	_ZN10CDRMHelper20SupportedDRMMethods2ERiRNS_18TDRMHelperOMALevelE @ 54 NONAME
+	_ZN10CDRMHelper22RemoveAutomatedPassiveER5RFile @ 55 NONAME
+	_ZN10CDRMHelper22RemoveAutomatedPassiveERK6TDesC8 @ 56 NONAME
+	_ZN10CDRMHelper22RemoveAutomatedPassiveERK7TDesC16 @ 57 NONAME
+	_ZTI27CDRMHelperRightsConstraints @ 58 NONAME ; #<TI>#
+	_ZTV10CDRMHelper @ 59 NONAME ; #<VT>#
+	_ZN10CDRMHelper23ShowDRMUINotification2LENS_24TDRMHelperNotificationIDERK6TDesC8 @ 60 NONAME
+	_ZN10CDRMHelper23ShowDRMUINotification2LENS_24TDRMHelperNotificationIDERK7TDesC16 @ 61 NONAME
+	_ZN10CDRMHelper25EmbeddedPreviewCompletedLER7TDesC16 @ 62 NONAME
+	_ZN10CDRMHelper25EmbeddedPreviewCompletedLERN13ContentAccess5CDataE @ 63 NONAME
+	_ZN10CDRMHelper26LaunchDetailsViewEmbeddedLEPK6HBufC8 @ 64 NONAME
+	_ZN10CDRMHelper26LaunchDetailsViewEmbeddedLER5RFile @ 65 NONAME
+	_ZN10CDRMHelper26LaunchDetailsViewEmbeddedLERK6TDesC8 @ 66 NONAME
+	_ZN10CDRMHelper26LaunchDetailsViewEmbeddedLERK7TDesC16 @ 67 NONAME
+	_ZN10CDRMHelper4NewLER7CCoeEnv @ 68 NONAME
+	_ZN10CDRMHelper4NewLEv @ 69 NONAME
+	_ZN10CDRMHelper5NewLCER7CCoeEnv @ 70 NONAME
+	_ZN10CDRMHelper5NewLCEv @ 71 NONAME
+	_ZTI27CDRMHelperGlobalNoteWrapper @ 72 NONAME ; #<TI>#
+	_ZN10CDRMHelper8Consume2ERK6TDesC8mNS_23TDRMHelperConsumeActionE @ 73 NONAME
+	_ZN10CDRMHelperD0Ev @ 74 NONAME
+	_ZN10CDRMHelperD1Ev @ 75 NONAME
+	_ZN10CDRMHelperD2Ev @ 76 NONAME
+	_ZN27CDRMHelperRightsConstraints10FullRightsEv @ 77 NONAME
+	_ZN27CDRMHelperRightsConstraints11GetEndTimeLER5TTime @ 78 NONAME
+	_ZN27CDRMHelperRightsConstraints12GetCountersLERmS0_ @ 79 NONAME
+	_ZN27CDRMHelperRightsConstraints12GetIntervalLER20TTimeIntervalSeconds @ 80 NONAME
+	_ZN27CDRMHelperRightsConstraints13GetStartTimeLER5TTime @ 81 NONAME
+	_ZN27CDRMHelperRightsConstraints14GetTimedCountLERmS0_R20TTimeIntervalSeconds @ 82 NONAME
+	_ZN27CDRMHelperRightsConstraints17GetIntervalStartLER5TTime @ 83 NONAME
+	_ZN27CDRMHelperRightsConstraints19GetAccumulatedTimeLER20TTimeIntervalSeconds @ 84 NONAME
+	_ZN27CDRMHelperRightsConstraints9IsPreviewEv @ 85 NONAME
+	_ZN27CDRMHelperRightsConstraintsD0Ev @ 86 NONAME
+	_ZN27CDRMHelperRightsConstraintsD1Ev @ 87 NONAME
+	_ZN27CDRMHelperRightsConstraintsD2Ev @ 88 NONAME
+	_ZTI10CDRMHelper @ 89 NONAME ; #<TI>#
+	_ZN10CDRMHelper4NewLER3RFs @ 90 NONAME
+	_ZN10CDRMHelper4NewLER7CCoeEnvR3RFs @ 91 NONAME
+	_ZN10CDRMHelper5NewLCER3RFs @ 92 NONAME
+	_ZN10CDRMHelper5NewLCER7CCoeEnvR3RFs @ 93 NONAME
+	_ZN10CDRMHelper19SetPreviewMediaTypeE26TDRMHelperPreviewMediaType @ 94 NONAME
+	_ZN10CDRMHelper21HandleErrorOrPreviewLEiR5RFileRP6HBufC8 @ 95 NONAME
+	_ZN10CDRMHelper21HandleErrorOrPreviewLEiRK7TDesC16RP6HBufC8 @ 96 NONAME
+	_ZN10CDRMHelper17GetRightsDetailsLER5RFilemRiS2_RP21CDRMRightsConstraintsS5_S5_S5_ @ 97 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/EABI/drmhelperdmgrwrapperU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z16GateFunctionDMgrv @ 1 NONAME
+	_ZTI21CDRMHelperDMgrWrapper @ 2 NONAME ; #<TI>#
+	_ZTV21CDRMHelperDMgrWrapper @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/bwinscw/DRMHelperServerU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?WinsMain@@YAHXZ @ 1 NONAME ; int WinsMain(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/eabi/DRMHelperServerU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,2 @@
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/group/DRMHelperServer.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,70 @@
+/*
+* Copyright (c) 2003-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:  Makefile of DRM Helper Server
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DRMHelperServer.exe
+TARGETTYPE EXE
+
+UID           0x1000008d 0x101F6DC5
+CAPABILITY      CAP_SERVER 
+VENDORID      VID_DEFAULT
+
+// logging facility (uncomment the macro to get logging)
+//macro _DRM_TESTING
+
+// Default system include paths for middleware layer modules.
+APP_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc
+USERINCLUDE	    ../../../../inc   // ADo level inc dir
+
+SOURCEPATH      ../src
+SOURCE      DRMHelperServer.cpp
+SOURCE      DRMHelperSession.cpp
+SOURCE      EndTimeBased.cpp
+SOURCE      EndTimeFactory.cpp
+SOURCE	    IdleObserver.cpp
+
+#ifdef _DRMHS_CONFIG
+SOURCE	    ConfigObserver.cpp
+#endif
+
+LIBRARY     euser.lib // symbian common 
+LIBRARY     efsrv.lib // RFs, RFile
+LIBRARY     estor.lib // RFileWriteStream. RWriteStream, RFileReadStream, RReadStream
+LIBRARY     DrmServerInterfaces.lib // CDRMNotifier, RDRMRightsClient, MDRMEvent
+LIBRARY     drmrights.lib // CDRMPermission, CDRMConstraint
+LIBRARY     bafl.lib // CEnvironmentChangeNotifier
+LIBRARY     centralrepository.lib // central repository
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY       platformenv.lib
+#endif
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,36 @@
+/*
+* 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:  Build file for DRM Helper Server
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+../inc/DRMHelperCommon.h oem/DRMHelperCommon.h
+../inc/DRMHelperServer.h oem/DRMHelperServer.h
+../inc/DRMHelperSession.h oem/DRMHelperSession.h
+../inc/DRMHelperServerInternalCRKeys.h oem/DRMHelperServerInternalCRKeys.h 
+
+PRJ_MMPFILES
+
+DRMHelperServer.mmp
+
+PRJ_TESTMMPFILES
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/inc/ConfigObserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  observe system idle event
+*
+*/
+
+
+
+#ifndef CONFIGOBSERVER_H
+#define CONFIGOBSERVER_H
+
+//  INCLUDES
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CDRMHelperServer;
+class CRepository;
+
+
+// CLASS DECLARATION
+
+/**
+*  End time based rights storage class
+*  
+*
+*  @lib DRMHelperServer.lib
+*  @since Series60 2.6
+*/
+class CConfigObserver : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CConfigObserver* NewL(CDRMHelperServer& aServer);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CConfigObserver();
+
+
+    public: // New functions
+        /**
+        * StartL starts the system agent and listen to the event
+        * @since Series60 2.6
+        * @param
+        * @return 
+        */
+        void StartL();
+    public: // Functions from base classes
+    protected:  // New functions
+        
+        /**
+        * From CActive
+        * @since Series60 2.6
+        */
+        void RunL();
+
+        /**
+        * From CActive
+        * @since Series60 2.6
+        */
+        void DoCancel();
+
+
+    protected:  // Functions from base classes
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CConfigObserver( CDRMHelperServer& aServer );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        CConfigObserver( const CConfigObserver& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CConfigObserver& operator=( const CConfigObserver& );
+        
+
+        
+
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+        // helper server reference
+        CDRMHelperServer& iServer;
+        // For getting notify on idle screen available event.
+        CRepository* iRepository;
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+        
+
+    };
+
+#endif      // CONFIGOBSERVER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/inc/DRMHelperServerConfigInternalCRKeys.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handling end time based automated content
+*
+*/
+
+
+
+#ifndef DRMHELPERSERVERCONFIGINTERNALCRKEYS_H
+#define DRMHELPERSERVERCONFIGINTERNALCRKEYS_H
+
+//#include <DRMHelperServerConfigSDKCRKeys.h>
+
+const TUid KCRUidDRMHelperServerConfig = {0x10205CA7};
+
+/* Key format: <TUint8>
+0	No notification for RO about to expire
+1..*	permission about to expire notification will come N days before permission expires
+
+  
+*/ 
+
+const TUint32 KDRMHSInformingInterval = 0x00000001;
+
+
+#endif      // DRMHELPERSERVERCONFIGINTERNALCRKEYS_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/inc/EndTimeBased.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,216 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handling end time based automated content
+*
+*/
+
+
+
+#ifndef ENDTIMEBASED_H
+#define ENDTIMEBASED_H
+
+//  INCLUDES
+#include <e32base.h>
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CDRMHelperServer;
+
+// CLASS DECLARATION
+
+/**
+*  End time based rights storage class
+*  
+*
+*  @lib DRMHelperServer.lib
+*  @since Series60 2.6
+*/
+class CEndTimeBased : public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CEndTimeBased* NewL( 
+            const TDesC8& aUri , 
+            const TUint8& aPermType , 
+            const TUint8& aRegType , 
+            const TUint8& aAutoType );
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CEndTimeBased();
+
+    public: // New functions
+        
+        /**
+        * SetIsExpired
+        * set whether the content rights is expired
+        * @since Series60 2.6
+        * @param aIsExpired if expired or not
+        * 
+        */
+        void SetIsExpired( TBool aIsExpired );
+
+        /**
+        * check if the content rights is expired
+        * @since Series60 2.6
+        * @return ETrue if expired otherwise EFalse,
+        */
+        TBool IsExpired() const;
+        
+        /**
+        * Set the value of count
+        * @since Series60 2.6
+        * @param aCount the times the content was handled
+        */
+        void SetCount(TInt8 aCount);
+
+        /**
+        * IncreaseCount the value of count by 1
+        * @since Series60 2.6
+        * 
+        */
+        void IncreaseCount();
+        
+        /**
+        * get the value of count
+        * @since Series60 2.6
+        * @return the value of count
+        */
+        TInt8 Count() const;
+
+        /**
+        * IncreaseRegTimes the value of registered times by 1
+        * @since Series60 2.6
+        * 
+        */
+        void IncreaseRegTimes();
+
+        /**
+        * DecreaseRegTimes the value of registered times by 1
+        * @since Series60 2.6
+        * 
+        */
+        void DecreaseRegTimes();
+
+        /**
+        * Set the value of registered times
+        * @since Series60 2.6
+        * @param aCount the times the content was registered
+        */
+        void SetRegTimes(TInt aRegTimes);
+        
+        /**
+        * get the value of times the content is registered
+        * @since Series60 2.6
+        * @return the value of count
+        */
+        TInt RegTimes() const;
+
+        /**
+        * get the value of register type
+        * @since Series60 2.6
+        * @return the value of register type
+        */
+        TUint8 RegType() const;
+
+        /**
+        * get the value of automated content type
+        * @since Series60 2.6
+        * @return the value of automated content type
+        */
+        TUint8 AutoType() const;
+
+        /**
+        * get the value of permission type
+        * @since Series60 2.6
+        * @return the value of permission type
+        */
+        TUint8 PermType() const;        
+
+        /**
+        * Set the value of end time
+        * @since Series60 2.6
+        * @param aEndTime end time for content rights
+        */
+        void SetEndTime( TTime aEndTime );
+
+        /**
+        * get the value of end time
+        * @since Series60 2.6
+        * @return the value of end time
+        */
+        TTime EndTime() const;
+
+        /**
+        * Set the value of content uri
+        * @since Series60 2.6
+        * @param aUri content uri for the automated content
+        * @return KErrNone if everything works fine.
+        */
+        TInt SetContentUri( const TDesC8& aUri );
+
+        /**
+        * get the value of content uri
+        * @since Series60 2.6
+        * @return the value of content uri
+        */
+        HBufC8* Uri() const;
+
+        
+
+    public: // Functions from base classes
+
+    protected:  // New functions
+        
+    protected:  // Functions from base classes
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CEndTimeBased( 
+            const TUint8& aPermType , 
+            const TUint8& aRegType , 
+            const TUint8& aAutoType );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL( const TDesC8& aUri );
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+        HBufC8* iUri;
+        TTime iEndTime;
+        TBool iIsExpired;
+        TInt8 iCount;
+        TInt iCountReg;
+        TUint8 iPermType;
+        TUint8 iRegType;
+        TUint8 iAutoType;
+    };
+
+#endif      // ENDTIMEBASED_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/inc/EndTimeFactory.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,349 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handling end time based automated content
+*
+*/
+
+
+
+#ifndef ENDTIMEFACTORY_H
+#define ENDTIMEFACTORY_H
+
+//  INCLUDES
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CDRMHelperServer;
+class CEndTimeBased;
+// CLASS DECLARATION
+
+/**
+*  End time based rights storage class
+*  
+*
+*  @lib DRMHelperServer.lib
+*  @since Series60 2.6
+*/
+class CEndTimeFactory : public CTimer
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CEndTimeFactory* NewL(CDRMHelperServer& aServer);
+
+        /**
+        * Destructor.
+        */
+        virtual ~CEndTimeFactory();
+
+    public: // New functions
+
+        /**
+        * Add a specific content uri into list. if the uri is already in the list, 
+        * then update the status.
+        * @since Series60 3.0
+        * @param aUri content uri
+        * @param aPermType permission type
+        * @param aRegType regist type
+        * @param aAutoType automatic type
+        *
+        */
+        void AddL( 
+                const TDesC8& aUri , 
+                TTime aEndTime , 
+                const TUint8& aPermType , 
+                const TUint8& aRegType , 
+                const TUint8& aAutoType );
+
+        /**
+        * update all items in the list. 
+        * @since Series60 2.6
+        * @param 
+        * @return KErrNone if it works OK,
+        */
+        void UpdateL();
+
+        /**
+        * update the end time of a specific content uri in the list. 
+        * @since Series60 3.0
+        * @param aItem the item needs to be updated
+        * @param aEndTime the new end time 
+        * 
+        */
+        void UpdateEndTimeL( CEndTimeBased*& aItem , const TTime& aEndTime );
+
+        /**
+        * update the end time of a specific content uri in the list. 
+        * @since Series60 3.0
+        * @param aUri the specific content uri for this item.
+        * @param aEndTime the new end time         
+        * @param aPermType permission type
+        * @param aRegType regist type
+        */
+        void UpdateEndTimeL( 
+                const TDesC8& aUri , 
+                const TTime& aEndTime , 
+                const TUint8& aPermType , 
+                const TUint8& aRegType );
+
+        /**
+        * update the end time of a specific content uri in the list. 
+        * @since Series60 3.0
+        * @param aUri the specific content uri for this item.
+        * @param aEndTime the new end time         
+        * @param aPermType permission type
+        * @param aRegType regist type
+        * @param aAutoType automatic type
+        */
+        void UpdateEndTimeL( 
+                const TDesC8& aUri , 
+                const TTime& aEndTime , 
+                const TUint8& aPermType , 
+                const TUint8& aRegType ,
+                const TUint8& aAutoType );                
+
+        /**
+        * IsRegisteredL register one item with specific content uri.
+        * @since S60Rel3.0
+        * @param aUri the specific content uri for this item.
+        * @param aPermType permission type
+        * @param aRegType regist type
+        * @param aAutoType automatic type
+        * @return ETrue if registered, otherwise EFalse
+        */
+        TBool IsRegistered( 
+                const TDesC8& aUri , 
+                const TUint8& aPermType , 
+                const TUint8& aRegType , 
+                const TUint8& aAutoType );
+        /**
+        * IsRegisteredL register one item with specific content uri.
+        * @since S60Rel3.0
+        * @param aUri the specific content uri for this item.
+        * @param aPermType permission type
+        * @param aRegType regist type
+        * @return ETrue if registered, otherwise EFalse
+        */
+        TBool IsRegistered( 
+                const TDesC8& aUri , 
+                const TUint8& aPermType , 
+                const TUint8& aRegType );                        
+
+
+        /**
+        * IsRegisteredL register one item with specific content uri.
+        * @since S60Rel3.0
+        * @param aUri the specific content uri for this item.
+        * @param aPermType permission type
+        * @param aRegType regist type
+        * @return ETrue if registered, otherwise EFalse
+        */
+        TBool IsRegistered2( 
+                const TDesC8& aUri , 
+                const TUint8& aRegType,
+                const TUint8& aAutoType );  
+
+        /**
+        * IsRegisteredL register one item with specific content uri.
+        * @since S60Rel3.0
+        * @param aUri the specific content uri for this item.
+        * @return ETrue if registered, otherwise EFalse
+        */
+        TBool IsRegistered( const TDesC8& aUri );      
+
+        /**
+        * Remove a specific content uri into list. 
+        * @since Series60 3.0
+        * @param aUri content uri
+        * @param aPermType permission type
+        * @param aRegType regist type
+        * @param aAutoType automatic type
+        */
+        void Remove( 
+                const TDesC8& aUri , 
+                const TUint8& aPermType , 
+                const TUint8& aRegType , 
+                const TUint8& aAutoType );       
+
+        /**
+        * Handle items about to expire and expired when idle status comes
+        * @since Series60 2.6
+        * @
+        */
+        void HandleIdleL();
+
+        /**
+        * Externalize the list into data file. 
+        * @since Series60 2.6
+        * @param aStream data file stream
+        */
+        void ExternalizeL(RWriteStream& aStream) const;
+
+        /**
+        * Internalize the data from data file. 
+        * @since Series60 2.6
+        * @param aStream data file stream
+        */
+        void InternalizeL(RReadStream& aStream);
+
+        /**
+        * Reset the alarm
+        * @since Series60 2.6
+        */
+        void ResetAlarm();
+
+        /**
+        * Remove all items in the list 
+        * @since Series60 2.6
+        */
+        void RemoveAllL();
+
+        /**
+        * Handle the expiration case for one event
+        * @since Series60 3.0
+        */
+        void HandleExpiredL();
+
+    public: // Functions from base classes
+    protected:  // New functions
+
+        /**
+        * From CActive
+        * @since Series60 2.6
+        */
+        void RunL();
+
+        /**
+        * From CActive
+        * @since Series60 2.6
+        */
+        void DoCancel();
+
+    protected:  // Functions from base classes
+    private:
+
+        /**
+        * C++ default constructor.
+         */
+        CEndTimeFactory( CDRMHelperServer& aServer );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        CEndTimeFactory( const CEndTimeFactory& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CEndTimeFactory& operator=( const CEndTimeFactory& );
+
+
+
+        /**
+        * Find index for a specific content uri into list. 
+        * @since Series60 2.6
+        * @param aUri content uri
+        * @param aPermType permission type
+        * @param aRegType regist type
+        * @param aAutoType automatic type
+        * @return index for content uri in the list
+        */
+        TInt Find(      
+                const TDesC8& aUri , 
+                const TUint8& aPermType , 
+                const TUint8& aRegType , 
+                const TUint8& aAutoType );
+
+        /**
+        * Find index for a specific content uri into list. 
+        * @since Series60 2.6
+        * @param aUri content uri
+        * @param aPermType permission type
+        * @param aRegType regist type
+        * @param aIndex the position to start searching in the list
+        * @return index for content uri in the list
+        */
+        TInt FindNext(
+                const TDesC8& aUri , 
+                const TUint8& aPermType , 
+                const TUint8& aRegType , 
+                const TUint8& aIndex );
+
+        /**
+        * Find index for a specific content uri into list. 
+        * @since Series60 2.6
+        * @param aUri content uri
+        * @param aRegType regist type
+        * @return index for content uri in the list
+        */
+        TInt FindNext(
+                const TDesC8& aUri ,  
+                const TUint8& aindex);
+
+        /**
+        * Find index for a specific content uri into list. 
+        * @since Series60 2.6
+        * @param aUri content uri
+        * @return index for content uri in the list
+        */
+        TInt Exists( 
+                const TDesC8& aUri , 
+                const TUint8& aRegType,
+                const TUint8& aAutoType );
+
+        /**
+        * Reset the expiration status for all items in the list
+        * @since Series60 2.6
+        */
+        void ResetExpired();
+
+
+        /**
+        * Reset registered times for specific content with specific type. 
+        * @since Series60 2.6
+        * @param aUri content uri
+        * @param aPermType permission type
+        * @param aRegType regist type
+        * @param aAutoType automatic type
+        * @param aRegTimes registered times
+        * @return 
+        */
+        void ResetRegTimes( 
+                const TDesC8& aUri , 
+                const TUint8& aPermType , 
+                const TUint8& aRegType , 
+                const TUint8& aAutoType , 
+                const TUint8& aRegTimes );
+
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+        CDRMHelperServer& iServer;
+        RPointerArray<CEndTimeBased> iList;
+        TTime iAlarm;
+        TTime iOverflowedAlarm;
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+
+
+    };
+
+#endif      // ENDTIMEFACTORY_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/inc/IdleObserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  observe system idle event
+*
+*/
+
+
+
+#ifndef IDLEOBSERVER_H
+#define IDLEOBSERVER_H
+
+//  INCLUDES
+#include <e32property.h>
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CDRMHelperServer;
+
+
+// CLASS DECLARATION
+
+/**
+*  End time based rights storage class
+*  
+*
+*  @lib DRMHelperServer.lib
+*  @since Series60 2.6
+*/
+class CIdleObserver : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CIdleObserver* NewL(CDRMHelperServer& aServer);
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CIdleObserver();
+
+
+    public: // New functions
+        /**
+        * StartL starts the system agent and listen to the event
+        * @since Series60 2.6
+        * @param
+        * @return 
+        */
+        void StartL();
+    public: // Functions from base classes
+    protected:  // New functions
+        
+        /**
+        * From CActive
+        * @since Series60 2.6
+        */
+        void RunL();
+
+        /**
+        * From CActive
+        * @since Series60 2.6
+        */
+        void DoCancel();
+
+
+    protected:  // Functions from base classes
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CIdleObserver( CDRMHelperServer& aServer );
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        CIdleObserver( const CIdleObserver& );
+        // Prohibit assigment operator if not deriving from CBase.
+        CIdleObserver& operator=( const CIdleObserver& );
+        
+
+        
+
+    public:     // Data
+    protected:  // Data
+    private:    // Data
+        // helper server reference
+        CDRMHelperServer& iServer;
+        // For getting notify on idle screen available event.
+        RProperty iProperty;
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+        
+
+    };
+
+#endif      // IDLEOBSERVER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/inc/MDRMHelper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,370 @@
+/*
+* 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:  
+*
+*/
+
+
+#ifndef __MDRMHELPER_H__
+#define __MDRMHELPER_H__
+
+//  INCLUDES
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CDRMRightsConstraints;
+class TDataType;
+class CCoeEnv;
+
+// CLASS DECLARATION
+
+class MDRMHelper
+    {
+    public:
+    
+    enum TNotificationID
+        {
+        ETActivateTextId = 1,
+        ETCountBasedErrorTextId = 2 ,
+        ETCountUsageReduceId = 3,
+        ETCountUsageReduceMediaId = 4
+        };
+
+    enum TConsumeAction
+        {
+        EStart,
+        EFinish,
+        };
+
+    enum TOMALevel
+        {
+        EOMA_None, 
+        EOMA_1_0,
+        EOMA_2_0
+        };
+
+    public: // New functions
+        
+        /**
+        * Displays appropriate error note depending on error code.
+        * @param aError: error code returned by DRM engine
+        * @param aURI: URI of the file
+        * @return 
+        * - Button code, if user selected "buy rights" or "launch rights 
+        *   manager" in query.
+        * - 0 if user selected "No", "Back" or "Cancel" (or whatever which 
+        *   just dismiss the query)
+        * - 0 if just a simple error note is displayed
+        */
+        virtual TInt HandleErrorL( TInt aError, 
+           const TDesC8& aURI ) = 0;
+
+        /**
+        * Displays appropriate error note depending on error code.
+        * @param aError: error code returned by DRM engine
+        * @param aFileName: full path to file
+        * @return 
+        * - Button code, if user selected "buy rights" or "launch rights 
+        *   manager" in query.
+        * - 0 if user selected "No", "Back" or "Cancel" (or whatever which 
+        *   just dismiss the query)
+        * - 0 if just a simple error note is displayed
+        */
+        virtual TInt HandleErrorL( TInt aError, 
+           const TDesC& aFileName ) = 0;
+
+        /**
+        * Handle the general UI based error notes 
+        * @param aTextId The code for DRM general notification note.
+        * @param aURI The DRM files URI, that caused the DRM error.
+        * @return KErrnone if everything went ok, else wide scale of Symbian errors
+        */
+        virtual TInt ShowDRMUINotificationL( TNotificationID aTextId,
+            const TDesC8& aURI ) = 0;
+
+        /**
+        * Handle the general UI based error notes 
+        * @param aTextId The code for DRM general notification note.
+        * @param aFileName The DRM file's name and path, that caused the DRM error.
+        * @return KErrnone if everything went ok, else wide scale of Symbian errors
+        */
+        virtual TInt ShowDRMUINotificationL( TNotificationID aTextId,
+            const TDesC& aFileName ) = 0;
+
+        /**
+        * Set count limit for CheckRightsAmountL
+        * @param aCounts: new count limit for displaying the note.
+        * @return -
+        */
+        virtual void SetCountLimitL( TUint aCounts ) = 0;
+        
+        /**
+        * Set time limit in days for CheckRightsAmountL
+        * @param aDays: new time limit for displaying the note.
+        * @return -
+        */
+        virtual void SetTimeLimitL( TUint aDays ) = 0;
+
+        /**
+        * Set percentage limit for CheckRightsAmountL. Applies to both counts and time.
+        * @param aPercentage: new limit for displaying the note.
+        * @return -
+        */
+        virtual void SetPercentageLimitL( TUint aPercentage ) = 0;
+
+        /**
+        * Launches DRM Rights Manager UI embedded with details view related 
+        * to given content.
+        * @param aURI: URI of the file
+        * @return -
+        */
+        virtual void LaunchDetailsViewEmbeddedL( 
+            const TDesC8& aURI ) = 0;
+        
+        /**
+        * Launches DRM Rights Manager UI embedded with details view related 
+        * to given file.
+        * @param aFileName: Full path to file
+        * @return -
+        */      
+        virtual void LaunchDetailsViewEmbeddedL( 
+            const TDesC& aFileName ) = 0;
+
+        /**
+        * Gets details of rights object associated of given file.
+        * @param aFileName: Full path to file
+        * @param aIntent: bitmask of DRMCommon::EPlay, DRMCommon::EDisplay, 
+        *                 DRMCommon::EExecute and DRMCommon::EPrint
+        * @param aExpired: (out) ETrue if rights are expired
+        * @param aSendingAllowed: (out) ETrue if content can be sent
+        * @param aPlay: (out) play constraints, must be deleted by caller
+        * @param aDisplay: (out) display constraints, must be deleted by caller
+        * @param aExecute: (out) execute constraints, must be deleted by caller
+        * @param aPrint: (out) print constraints, must be deleted by caller
+        * @return -
+        */
+        virtual void GetRightsDetailsL( const TDesC& aFileName, 
+            TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed, 
+            CDRMRightsConstraints*& aPlay, 
+            CDRMRightsConstraints*& aDisplay, 
+            CDRMRightsConstraints*& aExecute, 
+            CDRMRightsConstraints*& aPrint ) = 0; 
+
+        /**
+        * Checks whether some content can be used as automated content or not.
+        * @param aURI: URI of the file
+        * @param aValue: (out) result of the query
+        * @return KErrnone if everything went ok, else wide scale of Symbian errors
+        */
+        virtual TInt CanSetAutomated( const TDesC8& aURI, TBool& aValue ) = 0;
+        
+        /**
+        * Checks whether some content can be used as automated content or not.
+        * @param aFileName: Full path to the file
+        * @param aValue: (out) result of the query
+        * @return KErrnone if everything went ok, else wide scale of Symbian errors
+        */
+        virtual TInt CanSetAutomated( const TDesC& aFilename, TBool& aValue ) = 0;
+        
+        /**
+        * Registers some content for automated usage (e.g. default ring tone).
+        * @param aURI: URI of the file
+        * @return KErrnone if everything went ok, else wide scale of Symbian errors
+        */
+        virtual TInt SetAutomated( const TDesC8& aURI ) = 0;
+        
+        /**
+        * Registers some content for automated usage (e.g. default ring tone).
+        * @param aFileName: Full path to the file
+        * @return KErrnone if everything went ok, else wide scale of Symbian errors
+        */
+        virtual TInt SetAutomated( const TDesC& aFilename ) = 0;
+        
+        /**
+        * Removes automated content. Used to indicated that the given content is 
+        * not anymore used automaticallly by the device.
+        * @param aURI: URI of the file
+        * @return KErrnone if everything went ok, else wide scale of Symbian errors
+        */
+        virtual TInt RemoveAutomated( const TDesC8& aURI ) = 0;
+        
+        /**
+        * Removes automated content. Used to indicated that the given content is 
+        * not anymore used automaticallly by the device.
+        * @param aFileName: Full path to the file
+        * @return KErrnone if everything went ok, else wide scale of Symbian errors
+        */
+        virtual TInt RemoveAutomated( const TDesC& aFilename ) = 0;
+
+        /**
+        * Sends an idle-signal to DRM Helper Server. This indicates 
+        * that the device is on idle state to the DRM Helper Server.
+        * @return -
+        */
+        virtual void IndicateIdle() = 0;
+
+        /**
+        * GetContentURIList
+        *
+        * Returns a list of all content URIs that have rights in the rights 
+        * database.
+        *
+        * @since  2.5
+        * @param  aURIList: Out parameter for the URI list.
+        * @return Ok if the URI list could be retreived.
+        */
+        virtual TInt GetContentURIList(
+            RPointerArray<HBufC8>*& aURIList) = 0;
+    
+        /**
+        * DataTypesCount
+        *
+        * Returns the number of previously registered datatypes which are
+        * supported by the DRM system and associated applications.
+        *
+        * @since  2.0
+        * @param  aCount: Out parameter for the datatype count
+        * @return EOk if the number of datatypes has been returned correctly
+        */
+        virtual TInt DataTypesCount(
+            TInt& aCount) = 0;
+    
+        /**
+        * SupportedDataType
+        *
+        * Returns a specific datatype which has been registered before by giving an index
+        *
+        * @since  2.0
+        * @param  aIndex: Number of the datatype to return
+        * @param  aDataType: Out parameter for the datatype
+        * @return EOk if the datatype was returned correctly
+        */
+    
+        virtual TInt SupportedDataType(
+            const TInt aIndex, TDataType& aDataType) = 0;
+    
+        /**
+        * RegisterDataType
+        *
+        * Registers a datatype as a supported datatype.
+        *
+        * @since  2.0
+        * @param  aDataType: Datatype to register
+        * @return EOk if the datatype has been registered
+        */
+    
+        virtual TInt RegisterDataType(
+            const TDataType& aDataType) = 0;
+    
+        /**
+        * UnRegisterDataType
+        *
+        * Unregisters a datatype via its index.
+        *
+        * @since  2.5
+        * @param  aIndex: Number of the datatype to unregister
+        * @return EOk if the datatype has been unregistered
+        */
+    
+        virtual TInt UnRegisterDataType(
+            const TInt aIndex) = 0;
+    
+        /**
+        * SupportedDRMMethods
+        *
+        * Returns the supported DRM protection methods and the OMA compliance
+        * level of the DRM engine
+        *
+        * @since  2.0
+        * @param  aDRMMethod: Out parameter, bit mask containing any 
+        *         combination of EForwardLock, ECombinedDelivery, 
+        *         ESeparateDelivery etc.
+        * @param  aOMALevel: OMA compliance of the DRM engine
+        * @return DRMCommon error code
+        */
+    
+        virtual TInt SupportedDRMMethods(
+            TInt& aDRMMethod, TOMALevel& aOMALevel) = 0;
+
+        /**
+        * Consume
+        *
+        * Overrides any rights consumption. This function must only be used by
+        * applications with user interaction and not by intermediate components.
+        * The main use cases are signalling that content is to be installed
+        * (including thumbnail generation), or that content is to be consumed.
+        * They are characterized as calls to this function with the correct
+        * intent (i.e. EPlay or EInstall) and the corresponding action (i.e.
+        * telling whether the indicated intent is started or finished).
+        * Calls to this function must be the result of a user interaction or
+        * otherwise high level event.
+        *
+        * @since  2.5
+        * @param  aContentURI: URI of the content which will be consumed
+        * @param  aRightsSpec: the consumption intent (EPlay, EDisplay, EPrint,
+        *         EExecute or EInstall)
+        * @param  anAction: the consumption action, telling whether the
+        *         content consumption starts or finishes.
+        * @return EOk if consume action was successfully signalled to the engine.
+        */
+        virtual TInt Consume(
+            const TDesC8& aContentURI,
+            TUint32 aRightsSpec,
+            TConsumeAction anAction) = 0;
+    
+        /**
+        * ConsumeFile
+        *
+        * Overrides any rights consumption. This function must only be used by
+        * applications with user interaction and not by intermediate components.
+        * The main use cases are signalling that content is to be installed
+        * (including thumbnail generation), or that content is to be consumed.
+        * They are characterized as calls to this function with the correct
+        * intent (i.e. EPlay or EInstall) and the corresponding action (i.e.
+        * telling whether the indicated intent is started or finished).
+        * Calls to this function must be the result of a user interaction or
+        * otherwise high level event.
+        *
+        * @since  2.5
+        * @param  
+        * @param  aRightsSpec: the consumption intent (EPlay, EDisplay, EPrint,
+        *         EExecute or EInstall)
+        * @param  anAction: the consumption action, telling whether the
+        *         content consumption starts or finishes.
+        * @return EOk if consume action was successfully signalled to the engine.
+        */
+        virtual TInt ConsumeFile(
+            const TDesC& aFileName,
+            TUint32 aRightsSpec,
+            TConsumeAction anAction) = 0;
+    
+    };
+
+class MDRMHelperFactory
+    {
+public:
+
+    IMPORT_C static MDRMHelper* CreateL(CCoeEnv& aCoeEnv);
+    IMPORT_C static MDRMHelper* CreateLC(CCoeEnv& aCoeEnv);
+
+    IMPORT_C static MDRMHelper* CreateL();
+    IMPORT_C static MDRMHelper* CreateLC();
+
+    };
+
+#endif      // MDRMHELPER_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/src/ConfigObserver.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,234 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  observe the configuration change of DHS through Cenrep
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    <e32base.h>
+#include    <e32std.h>
+#include    <f32file.h>
+#include    <centralrepository.h>
+#include    "ConfigObserver.h"
+#include    "DRMHelperCommon.h"
+#include    "DRMHelperServer.h"
+#include    "DRMHelperServerConfigInternalCRKeys.h"
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+#ifdef _DRM_TESTING
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
+    {
+    RFile file;
+    TInt size;
+    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy(&file); //file
+    }
+
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
+    {
+    _LIT( KLogFile , "c:\\COLog.txt" );
+    WriteFileL( text , aFs , KLogFile );
+    }
+
+LOCAL_C void CreateLogL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    User::LeaveIfError( file.Replace( fs , _L("c:\\COLog.txt") , EFileWrite ) );
+    file.Close();
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append(_L( "\r\n" ));
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteCurrentTimeL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+// Date and Time display
+    TTime time;
+    time.HomeTime();
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    time.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    time.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CConfigObserver::CConfigObserver
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CConfigObserver::CConfigObserver( CDRMHelperServer& aServer ):
+                    CActive(CActive::EPriorityStandard),
+                        iServer( aServer )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CConfigObserver::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CConfigObserver::ConstructL()
+    {
+#ifdef _DRM_TESTING
+    CreateLogL(); //test
+#endif
+
+    iRepository = CRepository::NewL(KCRUidDRMHelperServerConfig);
+    }
+                    
+// -----------------------------------------------------------------------------
+// CConfigObserver::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CConfigObserver* CConfigObserver::NewL(CDRMHelperServer& aServer)
+    {
+    CConfigObserver* self = new( ELeave ) CConfigObserver(aServer);
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    return self;
+    }
+
+    
+// Destructor
+CConfigObserver::~CConfigObserver()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("CConfigObserver-Destruct")) ); 
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+    Cancel();
+    delete iRepository;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CConfigObserver::StartL
+// Start the system agent to listen to the event
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CConfigObserver::StartL()
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("Start"));
+    WriteCurrentTimeL();
+#endif
+    Cancel();
+    User::LeaveIfError(iRepository->NotifyRequest( KDRMHSInformingInterval , iStatus ));
+    SetActive();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CConfigObserver::RunL
+// from CActive
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CConfigObserver::RunL()
+    {
+#ifdef _DRM_TESTING 
+    //test code start
+    WriteL(_L("RunL"));
+    WriteCurrentTimeL();
+    //test code end
+#endif
+    
+    
+    TInt err( iStatus.Int() );
+    TInt val = KAboutToExpireInterval;
+    if (err == KErrNone)
+        {
+        StartL();
+        User::LeaveIfError(iRepository->Get( KDRMHSInformingInterval , val ));
+        iServer.SetInformingInterval(val);
+        }
+    else if (err != KErrCancel || 
+    NCentralRepositoryConstants::KInvalidNotificationId
+    )
+        {
+        StartL();
+        }
+     
+    }
+
+// -----------------------------------------------------------------------------
+// CConfigObserver::DoCancel
+// From CActive
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CConfigObserver::DoCancel()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("DoCancel")) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+    iRepository->NotifyCancel(KDRMHSInformingInterval);
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/src/DRMHelperServer.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1445 @@
+/*
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the Helper Server functionality
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <DRMPermission.h> // CDRMPermission
+#include <DRMConstraint.h> // CDRMConstraint
+#include <s32file.h>
+#include <DRMNotifier.h>
+#include <DRMEventAddRemove.h>
+#include <DRMTypes.h>
+#include <bacntf.h> //CEnvironmentChangeNotifier
+#include <centralrepository.h> // link against centralrepository.lib
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "DRMEventModify.h"
+#include "DRMHelperServerInternalCRKeys.h"
+#include "DRMHelperCommon.h"
+#include "DRMHelperServer.h"
+#include "DRMHelperSession.h"
+#include "EndTimeFactory.h"
+#include "EndTimeBased.h"
+#include "IdleObserver.h"
+
+
+
+
+
+// LOCAL CONSTANTS AND MACROS
+_LIT8(KExpiredMark , "E");
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT( KHelperServerDataStorage , "%c:DRMHS.dat" );
+#else
+_LIT( KHelperServerDataStorage , "c:DRMHS.dat" );
+#endif
+
+// #define _MEM_HEAP_USAGE
+
+
+// ============================ LOCAL FUNCTIONS ===============================
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs );
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName );
+LOCAL_C void CreateLogL();
+LOCAL_C void WriteL( const TDesC8& aText );
+LOCAL_C void WriteTimeL( TTime aTime );
+LOCAL_C void WriteCurrentTimeL();
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr );
+
+#ifdef _MEM_HEAP_USAGE
+LOCAL_C void WriteHeapAllocL();
+#endif //_MEM_HEAP_USAGE
+
+#endif
+
+// -----------------------------------------------------------------------------
+// Testing stuff
+// -----------------------------------------------------------------------------
+//
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
+    {
+    _LIT( KLogFile , "c:\\HSLog.txt" );
+    WriteFileL( text , aFs , KLogFile );
+    }
+
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
+    {
+    RFile file;
+    TInt size;
+    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy(&file); //file
+    }
+
+LOCAL_C void CreateLogL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    TInt err = file.Open( fs , _L("c:\\HSLog.txt") , EFileWrite );
+    if (err)
+        {
+        err = file.Replace( fs , _L("c:\\HSLog.txt") , EFileWrite );
+        }
+    file.Close();
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8("\r\n") );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    WriteCurrentTimeL();
+#ifdef _MEM_HEAP_USAGE
+    WriteHeapAllocL();
+#endif //_MEM_HEAP_USAGE
+    }
+
+LOCAL_C void WriteTimeL( TTime aTime )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+// Date and Time display
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    aTime.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\t\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    aTime.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\t\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteCurrentTimeL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+// Date and Time display
+    TTime time;
+    time.HomeTime();
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    time.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    time.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr )
+    {
+    _LIT8(KErr,": %d");
+    HBufC8* text = HBufC8::NewLC(1000+20);
+    TBuf8<20> num;
+    TPtr8 textptr(text->Des());
+    textptr.Append(aText);
+    num.Format(KErr(),aErr);
+    textptr.Append(num);
+    WriteL(textptr);
+    CleanupStack::PopAndDestroy(text);
+#ifdef _MEM_HEAP_USAGE
+    WriteHeapAllocL();
+#endif //_MEM_HEAP_USAGE
+    }
+
+#ifdef _MEM_HEAP_USAGE
+LOCAL_C void WriteHeapAllocL()
+    {
+    _LIT8(KHeapUsage,"\r\n***** Heap cells allocated: %d *****\r\n");
+    TBuf8<256> string;
+    TInt size = 0;
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    User::Heap().AllocSize(size);
+    string.Format(KHeapUsage(),size);
+    WriteLogL(string , fs);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+#endif //_MEM_HEAP_USAGE
+
+#endif //_DRM_TESTING
+
+
+
+// -----------------------------------------------------------------------------
+// DataFileL
+// return data filename as a TParse
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TParse DataFileL(RFs& aFs)
+    {
+    TBuf<256> path;
+    TParse p;
+    User::LeaveIfError(aFs.PrivatePath(path));
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    p.Set(KHelperServerDataStorage,&path,NULL);
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    aFs.DriveToChar( driveNumber, driveLetter );
+
+    TFileName helperServerDataStorage;
+    helperServerDataStorage.Format(
+                    KHelperServerDataStorage, (TUint)driveLetter );
+
+    p.Set( helperServerDataStorage, &path, NULL );
+
+#endif
+
+    return p;
+    }
+
+// -----------------------------------------------------------------------------
+// CreatePrivatePathL
+// Create private path
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void CreatePrivatePathL(RFs& aFs)
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r , WriteL(_L8("CreatePrivatePathL")) );
+#endif
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    TInt err = aFs.CreatePrivatePath(EDriveC);
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+
+    TInt err = aFs.CreatePrivatePath(driveNumber);
+
+#endif
+
+    if (err == KErrAlreadyExists)
+        {
+        err = KErrNone;
+        }
+    User::LeaveIfError(err);
+
+#ifdef _DRM_TESTING
+    TRAP( r , WriteL(_L8("CreatePrivatePathL->End")) );
+#endif
+    return;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CreateCRKeyL
+// Create CenRep Key
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void CreateCRKeyL()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r , WriteL(_L8("CreateCRKeyL")) );
+#endif
+
+  CRepository* repository = CRepository::NewL(KCRUidDRMHelperServer);
+    CleanupStack::PushL( repository );
+    TInt err = repository->Create(KDRMHelperServerNotification, KNullDesC8);
+    if (err == KErrAlreadyExists)
+        {
+        err = KErrNone;
+        }
+#ifdef _DRM_TESTING
+    TRAP( r , WriteL(_L8("CreateCRKeyL->Create1"),err) );
+#endif
+
+    User::LeaveIfError(err);
+    err = repository->Create(KDRMHelperServerNotificationPassive, KNullDesC8);
+    if (err == KErrAlreadyExists)
+        {
+        err = KErrNone;
+        }
+#ifdef _DRM_TESTING
+    TRAP( r , WriteL(_L8("CreateCRKeyL->Create2"),err) );
+#endif
+    User::LeaveIfError(err);
+    CleanupStack::PopAndDestroy(repository); // repository
+
+#ifdef _DRM_TESTING
+    TRAP( r , WriteL(_L8("CreateCRKeyL->End")) );
+#endif
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::CDRMHelperServer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperServer::CDRMHelperServer() :
+    CServer2( EPriorityStandard ) ,
+                    iEndTimeFactory(NULL) ,
+                    iNotifier(NULL),
+                    iIdleObserver(NULL) ,
+                    iUiTimeNotifier(NULL)
+    {
+    // Nothing
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperServer* CDRMHelperServer::NewLC()
+    {
+
+#ifdef _DRM_TESTING
+    CreateLogL();
+    TRAPD( err , WriteL(_L8("NewLC")) );
+#endif
+    CDRMHelperServer* self = new(ELeave) CDRMHelperServer;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    };
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::ConstructL()
+    {
+    TInt err = 0;
+
+#ifdef _DRM_TESTING
+    TRAPD( r , WriteL(_L8("ConstructL")) );
+#endif
+
+
+    TUint8 waitCount = 0;
+    User::LeaveIfError(iFs.Connect());
+    User::LeaveIfError(iDrm.StartServer());
+    User::LeaveIfError(iDrm.Connect());
+    StartL(KDRMHelperServerName);
+    //ignore errors
+    err = User::RenameProcess( KDRMHSServerFileName );
+    err = User::RenameThread(KDRMHSServerFileName);
+
+
+    CreatePrivatePathL(iFs); // create path for internal data file
+    iEndTimeFactory = CEndTimeFactory::NewL( *this );
+    err = KErrNotFound;
+    while( err!=0 && waitCount < 30 ) // wait maximum of 6s
+        {
+        TRAP( err , iNotifier = CDRMNotifier::NewL() );
+        if ( err ) // wait only if the server isn't running
+            {
+            User::After(200000); // 0.2s
+            waitCount++;
+            }
+        if (iNotifier)
+            {
+            iNotifier->RegisterEventObserverL( *this , KEventTimeChange );
+            }
+        }
+#ifdef _DRM_TESTING
+    TRAP( r , WriteL(_L8("ConstructL->Notifier")) );
+#endif
+    User::LeaveIfError( err ); // None can do, throw an exception.
+
+    iUiTimeNotifier = CEnvironmentChangeNotifier::NewL(
+        EPriorityHigh,
+        TCallBack(UiTimeChanged,this)
+        );
+    iUiTimeNotifier->Start();
+
+    iIdleObserver = CIdleObserver::NewL( *this );
+
+    iIdleObserver->StartL();
+#ifdef _DRM_TESTING
+    TRAP( r , WriteL(_L8("ConstructL->IdleObserver")) );
+#endif
+
+    CreateCRKeyL();
+    RestoreL();
+
+    iEndTimeFactory->HandleExpiredL();
+
+#ifdef _DRM_TESTING
+    TRAP( r , WriteL(_L8("ConstructL->End")) );
+#endif
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::~CDRMHelperServer
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperServer::~CDRMHelperServer()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L8("destructor")) );
+#endif
+
+
+    if ( iEndTimeFactory )
+        {
+        TRAPD( error , StoreL() );
+        TRAP( error , RemoveAllL() );
+        }
+    delete iEndTimeFactory;
+    if (iNotifier)
+        {
+        TRAP_IGNORE( iNotifier->UnRegisterEventObserverL( *this , KEventTimeChange ) );
+        }
+    delete iNotifier;
+    if(iUiTimeNotifier)
+        {
+        iUiTimeNotifier->Cancel();
+        delete iUiTimeNotifier;
+        }
+    delete iIdleObserver;
+    iFs.Close();
+    iDrm.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::NewSessionL
+// Called when a client requires a new instance.
+// -----------------------------------------------------------------------------
+CSession2* CDRMHelperServer::NewSessionL(const TVersion &aVersion,
+                                         const RMessage2& /*aMessage*/ ) const
+    {
+    // check we're the right version
+    if (!User::QueryVersionSupported(TVersion(KDRMHSMajorVersionNumber,
+                                              KDRMHSMinorVersionNumber,
+                                              KDRMHSBuildVersionNumber),
+                                     aVersion))
+        {
+        User::Leave(KErrNotSupported);
+        }
+
+    // make new session
+    return CDRMHelperSession::NewL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::StartupL().
+// This function starts the actual DRM Helper server after initializing
+// the cleanup stack and active scheduler.
+// Returns: TInt: Symbian OS error code.
+// -----------------------------------------------------------------------------
+//
+
+void CDRMHelperServer::StartupL()
+    {
+    // Construct active scheduler
+    CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler;
+    CleanupStack::PushL(activeScheduler) ;
+
+    // Install active scheduler
+    // We don't need to check whether an active scheduler is already installed
+    // as this is a new thread, so there won't be one
+    CActiveScheduler::Install(activeScheduler);
+
+    // Construct our server
+    CDRMHelperServer::NewLC();
+
+    RSemaphore semaphore;
+    User::LeaveIfError(semaphore.OpenGlobal(KDRMHelperServerSemaphoreName));
+
+    // Semaphore opened ok
+    semaphore.Signal();
+    semaphore.Close();
+
+    // Start handling requests
+    CActiveScheduler::Start();
+
+    CleanupStack::PopAndDestroy(2, activeScheduler);    //  anonymous CDRMHelperServer
+    }
+
+
+void CDRMHelperServer::PanicServer(TDRMHelperServPanic aPanic)
+    {
+    User::Panic(KDRMHSServer, aPanic);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::Startup().
+// This function starts the actual DRM Rights server after initializing
+// the cleanup stack and active scheduler.
+// Returns: TInt: Symbian OS error code.
+// -----------------------------------------------------------------------------
+//
+
+TInt CDRMHelperServer::Startup()
+    {
+    CTrapCleanup* cleanupStack = CTrapCleanup::New();
+    if (!cleanupStack)
+        {
+        PanicServer(ECreateTrapCleanup);
+        }
+    TRAPD(err, StartupL());
+    if (err != KErrNone)
+        {
+        PanicServer(ESrvCreateServer);
+        }
+    delete cleanupStack;
+    cleanupStack = NULL;
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::RunError().
+// This function handle errors from CActive
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelperServer::RunError(TInt aError)
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L8("RunError")) );
+#endif
+
+
+    Message().Complete(aError);
+    //
+    // The leave will result in an early return from CServer::RunL(), skipping
+    // the call to request another message. So do that now in order to keep the
+    // server running.
+    ReStart();
+    return KErrNone;    // handled the error fully
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::HandleExpiredL().
+// This function send expiration info out through CenRep
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::HandleExpiredL( CEndTimeBased*& aItem )
+    {
+#ifdef _DRM_TESTING
+    //test
+    _LIT8(KShowTimes , "Informed Times: %d");
+    TBuf8<40> timesBuf;
+    timesBuf.Format(KShowTimes , aItem->Count());
+    WriteL(_L8("HandleExpiredL"));
+    WriteL(aItem->Uri()->Des());
+    WriteL(timesBuf);
+#endif
+
+    HBufC8* buf = NULL;
+    TPtr8 ptr(NULL,0);
+    FormatKeyValueLC( buf , aItem , KExpiredMark ); // buf get pushed into cleanupstack
+    SetKeyValueL( *buf , aItem->RegType() );
+    CleanupStack::PopAndDestroy(buf);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::FormatKeyValueLC().
+// This function format key for CenRep
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::FormatKeyValueLC(
+        HBufC8*& aBuf ,
+        CEndTimeBased*& aItem ,
+        const TDesC8& aMark )
+    {
+    TPtr8 ptr(NULL,0,0);
+
+    aBuf = HBufC8::NewLC( aItem->Uri()->Des().Length() + 4 );
+    ptr.Set(aBuf->Des());
+    ptr.Append(aItem->Count());
+    ptr.Append( aMark );
+    ptr.Append(aItem->PermType());
+    ptr.Append(aItem->AutoType());
+    ptr.Append( aItem->Uri()->Des() );
+
+    // a walk around for the symbian bugs in cenrep
+    TInt length = ptr.Length();
+    if (length&1)
+        {
+        ptr.SetLength(length+1);
+        ptr[length] = 0;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::HandleIdleL().
+// This function is called when phone enter idle status
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::HandleIdleL()
+    {
+#ifdef _DRM_TESTING
+    //test
+    WriteL(_L8("HandleIdleL"));
+#endif
+    iEndTimeFactory->HandleIdleL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::RegisterL().
+// This function register a item
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::RegisterL(
+                        const TDesC8& aUri ,
+                        const TUint8& aPermType ,
+                        const TUint8& aRegType ,
+                        const TUint8& aAutoType )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("RegisterL"));
+    WriteL(aUri);
+#endif
+    TTime endTime = Time::MinTTime();
+    CheckExpirationL( aUri , aPermType , aRegType , endTime );
+    iEndTimeFactory->AddL( aUri , endTime , aPermType , aRegType , aAutoType );
+    GetNotificationL( aUri );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::IsRegistered().
+// This function check if item is registered
+// -----------------------------------------------------------------------------
+//
+TBool CDRMHelperServer::IsRegistered(
+        const TDesC8& aUri ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType ,
+        const TUint8& aAutoType )
+    {
+#ifdef _DRM_TESTING
+    TRAPD(err,WriteL(_L8("IsRegisteredL(uri,perm,reg,auto)")));
+    TRAP(err,WriteL(aUri));
+#endif
+
+    return iEndTimeFactory->IsRegistered( aUri , aPermType , aRegType , aAutoType );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::IsRegistered().
+// This function check if item is registered
+// -----------------------------------------------------------------------------
+//
+TBool CDRMHelperServer::IsRegistered(
+        const TDesC8& aUri ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType )
+    {
+#ifdef _DRM_TESTING
+    TRAPD(err,WriteL(_L8("IsRegisteredL(uri,perm,reg)")));
+    TRAP(err,WriteL(aUri));
+#endif
+
+    return iEndTimeFactory->IsRegistered( aUri , aPermType , aRegType );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::IsRegistered().
+// This function check if item is registered
+// -----------------------------------------------------------------------------
+//
+TBool CDRMHelperServer::IsRegistered2(
+        const TDesC8& aUri ,
+        const TUint8& aRegType,
+        const TUint8& aAutoType )
+    {
+#ifdef _DRM_TESTING
+    TRAPD(err,WriteL(_L8("IsRegisteredL(uri,reg,auto)")));
+    TRAP(err,WriteL(aUri));
+#endif
+
+    return iEndTimeFactory->IsRegistered2( aUri, aRegType, aAutoType );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::UpdateL().
+// This function update all items
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::UpdateL()
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("UpdateL(all)"));
+#endif
+
+    iEndTimeFactory->UpdateL();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::UpdateL().
+// This function update items with a URI
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::UpdateL( const TDesC8& aUri )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("UpdateL(aUri)"));
+    WriteL(aUri);
+#endif
+
+    UpdateL( aUri , ContentAccess::EView);
+    UpdateL( aUri , ContentAccess::EPlay);
+    UpdateL( aUri , ContentAccess::EExecute);
+    UpdateL( aUri , ContentAccess::EPrint);
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::UpdateL().
+// This function update items with a URI and a permission type
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::UpdateL(
+            const TDesC8& aUri ,
+            const TUint8& aPermType )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("UpdateL(aUri,aPerm)"));
+    WriteL(aUri);
+#endif
+
+    UpdateL( aUri , aPermType , CDRMHelperServer::EActive );
+    UpdateL( aUri , aPermType , CDRMHelperServer::EPassive );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::UpdateL().
+// This function update items with a URI, a permission type and a register type
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::UpdateL(
+            const TDesC8& aUri ,
+            const TUint8& aPermType ,
+            const TUint8& aRegType )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("UpdateL(aUri,aPerm,aReg)"));
+    WriteL(aUri);
+#endif
+
+    TTime endTime;
+    TBool reg = IsRegistered(aUri , aPermType , aRegType);
+    if (reg)
+        {
+        CheckExpirationL( aUri , aPermType , aRegType , endTime );
+        iEndTimeFactory->UpdateEndTimeL( aUri , endTime , aPermType , aRegType );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::UpdateL().
+// This function update items with a URI, a permission type and a register type
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::UpdateL(
+            const TDesC8& aUri ,
+            const TUint8& aPermType ,
+            const TUint8& aRegType ,
+            const TUint8& aAutoType )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("UpdateL(aUri,aPerm,aReg,aAutoType)"));
+    WriteL(aUri);
+#endif
+
+    TTime endTime;
+    CheckExpirationL( aUri , aPermType , aRegType , endTime );
+    iEndTimeFactory->UpdateEndTimeL( aUri , endTime , aPermType , aRegType , aAutoType );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::RemoveL().
+// This function update an item
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::RemoveL(
+                        const TDesC8& aUri ,
+                        const TUint8& aPermType ,
+                        const TUint8& aRegType ,
+                        const TUint8& aAutoType )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("RemoveL"));
+    WriteL(aUri);
+#endif
+
+    TBool found = iEndTimeFactory->IsRegistered( aUri , aPermType , aRegType , aAutoType );
+    if (found)
+        {
+        iEndTimeFactory->Remove( aUri , aPermType , aRegType , aAutoType );
+        iEndTimeFactory->ResetAlarm();
+        if ( !iEndTimeFactory->IsRegistered( aUri ) )
+            {
+            RemoveNotificationL( aUri );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::RemoveAllL().
+// This function removes all items
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::RemoveAllL()
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("RemoveAllL"));
+#endif
+
+    iEndTimeFactory->RemoveAllL();
+    }
+
+
+ContentAccess::TIntent CDRMHelperServer::MapPermissionType(TUint8 aPermType)
+    {
+    switch(aPermType)
+        {
+        case ContentAccess::EPlay:
+            return ContentAccess::EPlay;
+        case ContentAccess::EView:
+            return ContentAccess::EView;
+        case ContentAccess::EExecute:
+            return ContentAccess::EExecute;
+        case ContentAccess::EPrint:
+            return ContentAccess::EPrint;
+        default:
+            break;
+        }
+    return ContentAccess::EUnknown;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::CheckPermission().
+// This function check timebased contraints for a permission
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::CheckPermission(
+                CDRMPermission* aPermission ,
+                const TUint8& aPermType ,
+                TTimeBased& aTime ,
+                TTimeIntervalSeconds& aInterval,
+                const RPointerArray<HBufC8>& aIndividual )
+    {
+#ifdef _DRM_TESTING
+    TRAPD(err,WriteL(_L8("CheckPermission")));
+#endif
+
+    CDRMConstraint* c = NULL;
+    ContentAccess::TIntent type = MapPermissionType(aPermType);
+    TTime temp;
+    temp.HomeTime();
+    TUint32 reason( 0 );
+    TBool validity = EFalse;
+
+    aTime.SetStart(Time::MinTTime());
+    aTime.SetEnd(Time::MinTTime());
+    if (aPermission->iAvailableRights & type)
+        {
+        c = aPermission->ConstraintForIntent(type);
+        if (!c)
+            {
+            return;
+            }
+        if (aPermission->iAvailableRights & ERightsTopLevel)
+            {
+            CDRMConstraint* temp = aPermission->TopLevelConstraint();
+            c->Merge(*temp);
+            }
+
+        validity = c->Valid( temp, aIndividual, reason );
+        if ( !validity && reason & EConstraintIndividual )
+            {
+            return;
+            }
+        if (c->iActiveConstraints==EConstraintNone ||
+            c->iActiveConstraints == EConstraintIndividual )
+            {
+            aTime.SetStart(Time::MinTTime());
+            aTime.SetEnd(Time::MaxTTime());
+            return;
+            }
+        if (c->iActiveConstraints & EConstraintInterval)
+            {
+            if (c->iIntervalStart == Time::NullTTime())
+                {
+                aInterval = c->iInterval;
+                }
+            else
+                {
+                aTime.SetStart(c->iIntervalStart);
+                aTime.SetEnd(c->iIntervalStart + c->iInterval);
+                }
+            }
+        if (c->iActiveConstraints & EConstraintStartTime)
+            {
+            if ( !(c->iActiveConstraints & EConstraintInterval ) )
+                {
+                aTime.SetStart( c->iStartTime );
+                if (c->iActiveConstraints&EConstraintEndTime)
+                    {
+                    aTime.SetEnd( c->iEndTime );
+                    }
+                else
+                    {
+                    aTime.SetEnd( Time::MaxTTime() );
+                    }
+                }
+            else
+                {
+                aTime.SetStart( aTime.StartTime() > c->iStartTime ? aTime.StartTime() : c->iStartTime );
+                if (c->iActiveConstraints&EConstraintEndTime)
+                    {
+                    aTime.SetEnd( aTime.EndTime() < c->iEndTime ? aTime.EndTime() : c->iEndTime );
+                    }
+                }
+            }
+        else
+            {
+            if (c->iActiveConstraints==EConstraintEndTime)
+                {
+                if ( !(c->iActiveConstraints & EConstraintInterval ) )
+                    {
+                    aTime.SetStart(Time::MinTTime());
+                    aTime.SetEnd( c->iEndTime );
+                    }
+                else
+                    {
+                    aTime.SetEnd( aTime.EndTime() < c->iEndTime ? aTime.EndTime() : c->iEndTime );
+                    }
+                }
+            }
+        }
+#ifdef _DRM_TESTING
+    TRAP(err,WriteL(_L8("Start Time:")));
+    TRAP(err,WriteTimeL(aTime.StartTime()));
+    TRAP(err,WriteL(_L8("End Time:")));
+    TRAP(err,WriteTimeL(aTime.EndTime()));
+#endif
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::CheckExpirationL().
+// This function check the time for rights to expire
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::CheckExpirationL(
+        const TDesC8& aUri ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType ,
+        TTime& aEndTime )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("CheckExpiration"));
+#endif
+
+
+    RPointerArray<CDRMPermission> rights;
+    RArray<TTimeBased> timeList;
+    TBool stop = EFalse;
+    TInt i = 0;
+    TInt err = 0;
+    TTimeIntervalYears years(KTimeIntervalYears);
+    TTime time = Time::MinTTime();
+    TTimeBased item;
+    TTimeIntervalSeconds interval = 0;
+    RPointerArray<HBufC8> imsi;
+
+    aEndTime = Time::MinTTime();
+
+
+    TRAP( err , iDrm.GetDBEntriesL(aUri, rights) );
+    CleanupClosePushL(rights);
+    if ( err == KErrCANoRights || err == KErrCANoPermission )
+        {
+        aEndTime = Time::MinTTime();
+        err = KErrNone;
+        stop = ETrue;
+        }
+    User::LeaveIfError(err);
+
+    TRAP( err, iDrm.GetSupportedIndividualsL( imsi ) );
+
+    if ( err )
+        {
+        imsi.ResetAndDestroy();
+        }
+
+    time.HomeTime();
+    // Goes through all the rights associated to this specific URI
+    CleanupClosePushL(timeList);
+
+    for (i = 0; i < rights.Count() && !stop; i++)
+        {
+        CheckPermission( rights[i], aPermType, item, interval ,imsi );
+        if (interval.Int()>0 ||
+            (item.StartTime()==Time::MinTTime()&&item.EndTime()==Time::MaxTTime()))
+            {
+            stop = ETrue;
+            aEndTime = Time::MaxTTime();
+            }
+        else
+            {
+            if (aRegType == CDRMHelperServer::EActive && item.StartTime()>time)
+                {
+                // dont count future time for active usage
+                }
+            else
+                {
+                err = timeList.Append( item );
+                if ( err )
+                    {
+                    rights.ResetAndDestroy();
+                    imsi.ResetAndDestroy();
+                    }
+                User::LeaveIfError(err);
+                }
+            }
+        }
+    rights.ResetAndDestroy();
+    imsi.ResetAndDestroy();
+
+    // if there were no inactivated interval- or full-rights then calculate the expiration date
+    // based on what we stored to timeList
+    if( !stop )
+        {
+        time.HomeTime(); // preset time to current time. This is what we compare against.
+        TTime temp;
+        TTime pastTime;
+        temp = time;
+        pastTime = Time::MinTTime();
+
+        TBool action = ETrue;
+
+        // Loop while there are still items in the list and we have done something
+        while( action && timeList.Count() > 0 )
+            {
+            action = EFalse;
+            for ( i = 0 ; i < timeList.Count() ; i++ ) // go through the whole timeList
+                {
+#ifdef _DRM_TESTING
+                _LIT8(KCount , "time list count: %d");
+                TBuf8<40> buf;
+                buf.Format( KCount , timeList.Count());
+                WriteL( buf );
+#endif
+                if ( timeList[i].StartTime() <= time && timeList[i].EndTime() > time )
+                    {
+                    // Case1: valid rights
+                    time = timeList[i].EndTime();
+                    timeList.Remove(i);
+                    action = ETrue;
+#ifdef _DRM_TESTING
+                    WriteL(_L8("case 1:"));
+                    WriteTimeL( time );
+#endif
+                    }
+                else if ( timeList[i].StartTime() <= time && timeList[i].EndTime() <= time )
+                    {
+                    // Case2: expired rights
+                    if (timeList[i].EndTime()>pastTime) // just in case there is no valid rights
+                        {
+                        pastTime = timeList[i].EndTime(); // save the latest end time from the expired rights
+                        }
+                    timeList.Remove(i);
+                    action = ETrue;
+#ifdef _DRM_TESTING
+                    WriteL(_L8("case 2:"));
+#endif
+                    }
+                else if ( timeList[i].StartTime() > time && timeList[i].EndTime() <= time )
+                    {
+                    // Case3: Illegal case. Start time after end-time.
+                    timeList.Remove(i);
+                    action = ETrue;
+#ifdef _DRM_TESTING
+                    WriteL(_L8("case 3:"));
+#endif
+                    }
+                else
+                    {
+                    // Case4: Only thing left is the not yet valid -rights
+#ifdef _DRM_TESTING
+                    WriteL(_L8("case 4:"));
+#endif
+                    }
+                }
+            }
+
+        if (temp<time)
+            {
+            aEndTime = time;   // time has been changed, so we use it, otherwise it means there is no valid rights
+            }
+        else
+            {
+            aEndTime = pastTime;
+            }
+
+
+#ifdef _DRM_TESTING
+        WriteL(_L8("expiration date:"));
+        WriteTimeL( aEndTime );
+#endif
+        }
+
+#ifdef _DRM_TESTING
+    WriteL(_L8("Endtime calculation is done:"));
+    WriteTimeL( aEndTime );
+#endif
+
+    timeList.Reset();
+    CleanupStack::PopAndDestroy(&timeList); // timeList
+    CleanupStack::PopAndDestroy(&rights); // rights
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::SetKeyValueL().
+// This function set CenRep key value
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::SetKeyValueL( const TDesC8& aKeyValue , const TUint8& aRegType )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("SetKeyValueL"));
+    WriteL( aKeyValue );
+#endif
+
+    // Connecting and initialization:
+    CRepository* repository = CRepository::NewL(KCRUidDRMHelperServer);
+    CleanupStack::PushL( repository );
+    if ( aRegType == CDRMHelperServer::EActive )
+        {
+        User::LeaveIfError(repository->Set(KDRMHelperServerNotification, aKeyValue));
+        }
+    else if ( aRegType == CDRMHelperServer::EPassive )
+        {
+        User::LeaveIfError(repository->Set(KDRMHelperServerNotificationPassive, aKeyValue));
+        }
+    CleanupStack::PopAndDestroy(repository); // repository
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::StoreL().
+// This function store internal list into data file
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::StoreL()
+    {
+
+#ifdef _DRM_TESTING
+    WriteL(_L8("StoreL"));
+#endif
+
+    RFileWriteStream file;
+    User::LeaveIfError(file.Replace( iFs , DataFileL(iFs).FullName() , EFileWrite ));
+    file.PushL();
+    ExternalizeL(file);
+    file.CommitL();
+    CleanupStack::PopAndDestroy(&file);//file
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::RestoreL().
+// This function restore internal list from data file
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::RestoreL()
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("RestoreL"));
+#endif
+
+    TInt err = 0;
+    RFileReadStream file;
+
+    RFile test;
+    err = test.Open( iFs , DataFileL(iFs).FullName() , EFileRead );
+    if ( !err )
+        {
+        CleanupClosePushL(test);
+        TInt size = 0;
+        err = test.Size(size);
+        User::LeaveIfError(err);
+        CleanupStack::PopAndDestroy(&test); //test
+        if (size == 0)
+            {
+            StoreL();
+            }
+        }
+    else if ( err == KErrNotFound )
+        {
+        StoreL();
+        }
+    else
+        {
+        User::Leave(err);
+        }
+
+    User::LeaveIfError(file.Open( iFs , DataFileL(iFs).FullName() , EFileRead ));
+    file.PushL();
+    InternalizeL(file);
+    CleanupStack::PopAndDestroy(&file); //file
+
+#ifdef _DRM_TESTING
+    WriteL(_L8("RestoreL->End"));
+#endif
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::ExternalizeL().
+// This function externalize internal list
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::ExternalizeL(RWriteStream& aStream) const
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("ExternalizeL"));
+#endif
+    aStream << *iEndTimeFactory;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::InternalizeL().
+// This function internalizeL internal list
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::InternalizeL(RReadStream& aStream)
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("InternalizeL"));
+#endif
+    iEndTimeFactory->InternalizeL(aStream);
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::GetNotificationL().
+// This function register event listening to DRM notifier
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::GetNotificationL(const TDesC8& aUri)
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("GetNotificationL"));
+#endif
+    iNotifier->RegisterEventObserverL( *this , KEventAddRemove , aUri );
+    iNotifier->RegisterEventObserverL( *this , KEventModify , aUri );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::RemoveNotificationL().
+// This function remove event listening to DRM notifier
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::RemoveNotificationL(const TDesC8& aUri)
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("RemoveNotificationL"));
+#endif
+    iNotifier->UnRegisterEventObserverL( *this , KEventAddRemove , aUri );
+    iNotifier->UnRegisterEventObserverL( *this , KEventModify , aUri );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::HandleEventL().
+// This function handle event from DRM notifier
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperServer::HandleEventL( MDRMEvent* aEvent )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L8("HandleEventL"));
+#endif
+
+    HBufC8* contentID = 0;
+    TDRMEventType event;
+
+    aEvent->GetEventType(event);
+
+#ifdef _DRM_TESTING
+            WriteL(_L8("Notifier:"),event);
+#endif
+    switch(event)
+        {
+        case KEventAddRemove:
+            {
+#ifdef _DRM_TESTING
+            WriteL(_L8("Notifier: EventAddRemove"));
+#endif
+            contentID = REINTERPRET_CAST( CDRMEventAddRemove* , aEvent )->GetContentIDL();
+            CleanupStack::PushL( contentID );
+#ifdef _DRM_TESTING
+            WriteL(contentID->Des());
+#endif
+            switch( REINTERPRET_CAST( CDRMEventAddRemove* , aEvent )->Status() )
+                {
+                case ERightsObjectRecieved:
+                    {
+#ifdef _DRM_TESTING
+                    WriteL(_L8("Notifier: RightsObjectRecieved"));
+#endif
+                    UpdateL( contentID->Des() );
+                    }
+                    break;
+                case ERightsObjectDeleted:
+                    {
+#ifdef _DRM_TESTING
+                    WriteL(_L8("Notifier: RightsObjectDeleted"));
+#endif
+                    UpdateL( contentID->Des() );
+                    }
+                    break;
+                case ERightsObjectDeletedAll:
+                    {
+#ifdef _DRM_TESTING
+                    WriteL(_L8("Notifier: RightsObjectDeletedAll"));
+#endif
+                    UpdateL( contentID->Des() );
+                    }
+                    break;
+                default:
+                    {
+#ifdef _DRM_TESTING
+                    WriteL(_L8("Notifier: Unknown event"));
+#endif
+                    }
+                    break;
+                }
+            CleanupStack::PopAndDestroy( contentID );
+            }
+            break;
+        case KEventModify:
+            {
+#ifdef _DRM_TESTING
+            WriteL(_L8("Notifier: EventModify"));
+#endif
+            contentID = REINTERPRET_CAST( CDRMEventModify* , aEvent )->GetContentIDL();
+            CleanupStack::PushL( contentID );
+#ifdef _DRM_TESTING
+            WriteL(contentID->Des());
+#endif
+            UpdateL( contentID->Des() );
+            CleanupStack::PopAndDestroy( contentID );
+            }
+            break;
+        case KEventTimeChange:
+            {
+#ifdef _DRM_TESTING
+            WriteL(_L8("Notifier: EventTimeChange"));
+#endif
+            UpdateL();
+            }
+            break;
+        default:
+            {
+#ifdef _DRM_TESTING
+            WriteL(_L8("Notifier: Unknown event"));
+#endif
+            }
+            break;
+
+        }
+    return;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperServer::UiTimeChanged
+// CPeriodic callback function to update the clock
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelperServer::UiTimeChanged(void* aPointer)
+    {
+#ifdef _DRM_TESTING
+    TRAPD(r,WriteL(_L8("UiTimeChanged")));
+#endif
+    CDRMHelperServer* current = static_cast<CDRMHelperServer*>(aPointer);
+    TInt err = 0;
+    if(current)
+        {
+        if(current->iUiTimeNotifier->Change() & EChangesSystemTime)
+            {
+            TRAP_IGNORE( current->UpdateL() );
+            }
+        if(current->iUiTimeNotifier->Change() & EChangesLocale)
+            {
+            // time zone is changed
+            }
+        }
+#ifdef _DRM_TESTING
+    TRAP(r,WriteL(_L8("UiTimeChanged:->End"),current->iUiTimeNotifier->Change()));
+#endif
+    return err;
+    };
+
+
+TInt E32Main()
+    {
+    return CDRMHelperServer::Startup();
+    }
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/src/DRMHelperSession.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,402 @@
+/*
+* 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:  Implementation of the Helper Server session functionality 
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <f32file.h>
+#include "DRMHelperCommon.h"
+#include "DRMHelperServer.h"
+#include "DRMHelperSession.h"
+
+
+
+// LOCAL CONSTANTS AND MACROS
+#define SERVER const_cast< CDRMHelperServer* >( \
+    reinterpret_cast< const CDRMHelperServer* >( Server() ) )
+
+
+// ============================ LOCAL FUNCTIONS ===============================
+#ifdef _DRM_TESTING
+LOCAL_C void WriteDownLogL( const TDesC8& text , RFs &aFs );
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName );
+LOCAL_C void CreateLogL();
+LOCAL_C void WriteDownL( const TDesC& aText );
+LOCAL_C void WriteDownL( const TDesC8& aText );
+LOCAL_C void WriteCurrentTimeL();
+#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMHelperSession::CDRMHelperSession
+// Default constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperSession::CDRMHelperSession()
+    // Base class' constructor is called first.
+    : CSession2() 
+    {
+    // Nothing.
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperSession::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperSession* CDRMHelperSession::NewL()
+    {
+    CDRMHelperSession* self = new( ELeave ) CDRMHelperSession();
+    CleanupStack::PushL( self );
+#ifdef _DRM_TESTING
+    CreateLogL();
+#endif
+    CleanupStack::Pop(self); // self
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperSession::~CDRMHelperSession
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperSession::~CDRMHelperSession()
+    {
+    TInt err = KErrNone;	
+    TRAP(err , SERVER->StoreL());
+    // remove warning, and enable logging in the future
+		if( err ) {
+			err = KErrNone;
+	  }
+#ifdef _DRM_TESTING
+    TRAP( err , WriteDownL(_L("destructor")) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperSession::ServiceL
+// This method runs DispatchL() under TRAP harness, since every error case
+// can be handled ==> no need to let this function leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperSession::ServiceL( const RMessage2& aMessage )
+    {
+    
+#ifdef _DRM_TESTING
+    WriteDownL(_L("ServiceL"));
+    WriteCurrentTimeL();
+#endif
+    
+    // Trap possible errors...
+    TRAPD( error, DispatchL( aMessage ) );
+    
+    if ( error )
+        {
+        aMessage.Complete( error );
+        return;
+        }
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperSession::DispatchL
+// Checks which command the user requested, and forwards the request to 
+// appropriate private method. This helps to keep the code more readable.
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperSession::DispatchL( const RMessage2& aMessage ) 
+    {
+#ifdef _DRM_TESTING
+    WriteDownL(_L("DispatchL"));
+    WriteCurrentTimeL();
+#endif
+    switch ( aMessage.Function() )
+        {
+        case ERegister:
+            RegisterL( aMessage );
+            break;
+        case ERemove:
+            RemoveL( aMessage );
+            break;
+        case EIndicateIdle:
+            IndicateIdleL( aMessage );
+            break;
+        case EIsRegistered:
+            IsRegisteredL( aMessage );
+            break;
+        default:
+            User::Leave( KErrNotSupported );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperSession::RegisterL
+// Register the content URI into helper server
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperSession::RegisterL( const RMessage2& aMessage ) 
+    {
+#ifdef _DRM_TESTING
+    WriteDownL(_L("RegisterL"));
+    WriteCurrentTimeL();
+#endif
+
+    TInt size = 0;
+    TInt permType = aMessage.Int0();
+    TInt regType = aMessage.Int1();
+    TInt autoType = aMessage.Int2();
+    
+    HBufC8* cid = NULL;
+    TPtr8 data( NULL , 0 , 0 );
+
+    size = User::LeaveIfError( aMessage.GetDesLength( 3 ) );
+    if (size==0)
+        {
+        aMessage.Complete( KErrArgument );
+        return;
+        }
+
+#ifdef _DRM_TESTING
+    _LIT( KSize , "size = %d");
+    TBuf<20> sizeBuf;
+    sizeBuf.Format(KSize ,  size);
+    WriteDownL(sizeBuf);
+    WriteCurrentTimeL();
+#endif
+
+    cid = HBufC8::NewLC( size );
+    data.Set( cid->Des() );
+    aMessage.ReadL( 3, data );
+
+#ifdef _DRM_TESTING
+    WriteDownL(data);
+    WriteCurrentTimeL();
+#endif
+
+    SERVER->RegisterL( data , permType , regType , autoType );
+    SERVER->StoreL();
+
+    CleanupStack::PopAndDestroy( cid );
+    aMessage.Complete( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperSession::RemoveL
+// Unregister the content URI into helper server
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperSession::RemoveL( const RMessage2& aMessage ) 
+    {
+#ifdef _DRM_TESTING
+    WriteDownL(_L("RemoveL"));
+    WriteCurrentTimeL();
+#endif
+    TInt size = 0;
+    TInt permType = aMessage.Int0();
+    TInt regType = aMessage.Int1();
+    TInt autoType = aMessage.Int2();
+    HBufC8* cid = NULL;
+    TPtr8 data( NULL , 0 , 0 );
+    size = User::LeaveIfError( aMessage.GetDesLength( 3 ) );
+    if (size==0)
+        {
+        aMessage.Complete( KErrArgument );
+        return;
+        }
+    cid = HBufC8::NewLC( size );
+    data.Set( cid->Des() );
+    aMessage.ReadL( 3, data );
+    
+    // If this is execute, means we are using a pip file, unregister all other types as well
+    if( permType == 3 )
+        {
+        // EPlay
+        SERVER->RemoveL( data , 1 , regType , autoType );
+        // EDisplay
+        SERVER->RemoveL( data , 2 , regType , autoType );               
+        }
+    
+    
+    SERVER->RemoveL( data , permType , regType , autoType );
+    SERVER->StoreL();
+    CleanupStack::PopAndDestroy( cid );
+    aMessage.Complete( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperSession::IndicateIdleL
+// Unregister the content URI into helper server
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperSession::IndicateIdleL( const RMessage2& aMessage ) 
+    {
+#ifdef _DRM_TESTING
+    WriteDownL(_L("IndicateIdleL"));
+    WriteCurrentTimeL();
+#endif
+    SERVER->HandleIdleL();
+    aMessage.Complete( KErrNone );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperSession::IsRegisteredL
+// check if content is registered or not
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperSession::IsRegisteredL( const RMessage2& aMessage ) 
+    {
+#ifdef _DRM_TESTING
+    WriteDownL(_L("IsRegisteredL"));
+    WriteCurrentTimeL();
+#endif
+
+    TInt size = 0;
+    TInt permType = aMessage.Int0();
+    TInt regType = aMessage.Int1();
+    TInt autoType = aMessage.Int2();
+    HBufC8* cid = NULL;
+    TPtr8 data( NULL , 0 , 0 );
+    TBool mark = EFalse;
+    TPtr8 ptr(NULL,0,0);
+    size = User::LeaveIfError( aMessage.GetDesLength( 3 ) );
+    if (size==0)
+        {
+        aMessage.Complete( KErrArgument );
+        return;
+        }
+
+
+#ifdef _DRM_TESTING
+    _LIT( KSize , "size = %d");
+    TBuf<20> sizeBuf;
+    sizeBuf.Format(KSize ,  size);
+    WriteDownL(sizeBuf);
+    WriteCurrentTimeL();
+#endif
+
+    cid = HBufC8::NewLC( size );
+    data.Set( cid->Des() );
+    aMessage.ReadL( 3, data );
+
+#ifdef _DRM_TESTING
+    WriteDownL(data);
+    WriteCurrentTimeL();
+#endif
+    mark = SERVER->IsRegistered2( data , regType , autoType  );
+
+    CleanupStack::PopAndDestroy( cid );
+
+    aMessage.Complete( mark );
+    }
+
+
+
+#ifdef _DRM_TESTING
+
+LOCAL_C void WriteDownLogL( const TDesC8& text , RFs &aFs )
+    {
+    _LIT( KLogFile , "c:\\HSSessionLog.txt" );
+    WriteFileL( text , aFs , KLogFile );
+    }
+
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
+    {
+    RFile file;
+    TInt size;
+    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy(&file); //file
+    }
+
+LOCAL_C void CreateLogL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    User::LeaveIfError( file.Replace( fs , _L("c:\\HSSessionLog.txt") , EFileWrite ) );
+    file.Close();
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteDownL( const TDesC& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L("\r\n") );
+    WriteDownLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteDownL( const TDesC8& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8("\r\n") );
+    WriteDownLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+
+LOCAL_C void WriteCurrentTimeL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+// Date and Time display
+    TTime time;
+    time.HomeTime();
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    time.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    time.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteDownLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+#endif
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/src/EndTimeBased.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,260 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  End time based item data structure
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    <e32base.h>
+#include    <e32std.h>
+#include    "EndTimeBased.h"
+#include    "DRMHelperCommon.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::CEndTimeBased
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CEndTimeBased::CEndTimeBased( 
+        const TUint8& aPermType , 
+        const TUint8& aRegType , 
+        const TUint8& aAutoType)
+            :iIsExpired(EFalse),
+                iCount(-1),
+                iCountReg(1),
+                iPermType(aPermType),
+                iRegType(aRegType),
+                iAutoType(aAutoType)
+    {
+    TTimeIntervalYears years(KTimeIntervalYears);
+    iEndTime.HomeTime();
+    iEndTime += years;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CEndTimeBased::ConstructL(const TDesC8& aUri)
+    {
+    iUri = HBufC8::NewL( aUri.Length() );
+    *iUri = aUri;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CEndTimeBased* CEndTimeBased::NewL( 
+            const TDesC8& aUri , 
+            const TUint8& aPermType , 
+            const TUint8& aRegType , 
+            const TUint8& aAutoType )
+    {
+    CEndTimeBased* self = 
+        new( ELeave ) CEndTimeBased(aPermType , aRegType , aAutoType);
+    
+    CleanupStack::PushL( self );
+    self->ConstructL(aUri);
+    CleanupStack::Pop(self);
+
+    return self;
+    }
+
+    
+// Destructor
+CEndTimeBased::~CEndTimeBased()
+    {
+    delete iUri;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::SetIsExpired
+// set whether the content rights is expired
+// -----------------------------------------------------------------------------
+//
+void CEndTimeBased::SetIsExpired( TBool aIsExpired )
+    {
+    iIsExpired = aIsExpired;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::SetIsExpired
+// check if the content rights is expired
+// -----------------------------------------------------------------------------
+//
+TBool CEndTimeBased::IsExpired() const 
+    {
+    return iIsExpired;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::SetCount
+// Set the value of count
+// -----------------------------------------------------------------------------
+//
+void CEndTimeBased::SetCount( TInt8 aCount )
+    {
+    iCount = aCount;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::IncreaseCount
+// Set the value of count
+// -----------------------------------------------------------------------------
+//
+void CEndTimeBased::IncreaseCount()
+    {
+    iCount++;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::Count
+// get the value of count
+// -----------------------------------------------------------------------------
+//
+TInt8 CEndTimeBased::Count() const
+    {
+    return iCount;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::DecreaseRegTimes
+// Set the value of registered times
+// -----------------------------------------------------------------------------
+//
+void CEndTimeBased::DecreaseRegTimes()
+    {
+    iCountReg--;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::IncreaseRegTimes
+// Set the value of registered times
+// -----------------------------------------------------------------------------
+//
+void CEndTimeBased::IncreaseRegTimes()
+    {
+    iCountReg++;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::SetRegTimes
+// Set the value of count
+// -----------------------------------------------------------------------------
+//
+void CEndTimeBased::SetRegTimes( TInt aRegTimes )
+    {
+    iCountReg = aRegTimes;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::RegTimes
+// get the value of registered times
+// -----------------------------------------------------------------------------
+//
+TInt CEndTimeBased::RegTimes() const
+    {
+    return iCountReg;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::RegType
+// get the value of register type
+// -----------------------------------------------------------------------------
+//
+TUint8 CEndTimeBased::RegType() const
+    {
+    return iRegType;
+    }
+    
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::AutoType
+// get the value of automated content type
+// -----------------------------------------------------------------------------
+//
+TUint8 CEndTimeBased::AutoType() const
+    {
+    return iAutoType;
+    }
+    
+// -----------------------------------------------------------------------------
+// CEndTimeBased::PermType
+// get the value of permission type
+// -----------------------------------------------------------------------------
+//
+TUint8 CEndTimeBased::PermType() const 
+    {
+    return iPermType;
+    }    
+    
+// -----------------------------------------------------------------------------
+// CEndTimeBased::SetEndTime
+// Set the value of end time
+// -----------------------------------------------------------------------------
+//
+void CEndTimeBased::SetEndTime( TTime aEndTime )
+    {
+    iEndTime = aEndTime;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::EndTime
+// get the value of end time
+// -----------------------------------------------------------------------------
+//
+TTime CEndTimeBased::EndTime() const
+    {
+    return iEndTime;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeBased::EndTime
+// get the value of content uri
+// -----------------------------------------------------------------------------
+//
+HBufC8* CEndTimeBased::Uri() const
+    {
+    return iUri;      
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/src/EndTimeFactory.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1078 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Handling end time based automated content
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    <e32base.h>
+#include    <e32std.h>
+#include    <s32file.h>
+#include    "DRMHelperServer.h"
+#include    "EndTimeFactory.h"
+#include    "EndTimeBased.h"
+
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES
+// CONSTANTS
+LOCAL_C const TInt KInformingDelay( 1 );
+
+// Maximum amount of times the expired item is handled before 
+// unregistering without client's call.
+// (In order to avoid stale registrations)
+LOCAL_C const TInt KMaxHandlingCount( 50 );
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+#ifdef _DRM_TESTING
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
+    {
+    RFile file;
+    TInt size;
+    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy(&file); //file
+    }
+
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
+    {
+    _LIT( KLogFile , "c:\\ETFLog.txt" );
+    WriteFileL( text , aFs , KLogFile );
+    }
+
+LOCAL_C void CreateLogL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    User::LeaveIfError( file.Replace( fs , _L("c:\\ETFLog.txt") , EFileWrite ) );
+    file.Close();
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append(_L( "\r\n" ));
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append(_L8( "\r\n" ));
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteTimeL( TTime aTime )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+    // Date and Time display
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    aTime.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\t\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    aTime.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\t\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+
+LOCAL_C void WriteCurrentTimeL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+    // Date and Time display
+    TTime time;
+    time.HomeTime();
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    time.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    time.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+    }
+#endif
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::CEndTimeFactory
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CEndTimeFactory::CEndTimeFactory( CDRMHelperServer& aServer ):
+    CTimer(CActive::EPriorityStandard),
+    iServer( aServer ),
+    iOverflowedAlarm( Time::MaxTTime() )
+    {
+    iAlarm.HomeTime();
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::ConstructL()
+    {
+#ifdef _DRM_TESTING
+    CreateLogL(); //test
+#endif
+    CTimer::ConstructL();
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CEndTimeFactory* CEndTimeFactory::NewL(CDRMHelperServer& aServer)
+    {
+    CEndTimeFactory* self = new( ELeave ) CEndTimeFactory(aServer);
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    return self;
+    }
+
+
+// Destructor
+CEndTimeFactory::~CEndTimeFactory()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("CEndTimeFactory-Destruct")) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+
+    iList.ResetAndDestroy();
+    iList.Close();
+    Cancel();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::AddL
+// add a specific content uri into factory
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::AddL(
+        const TDesC8& aUri ,
+        TTime aEndTime ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType ,
+        const TUint8& aAutoType )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("Add"));
+    WriteL(aUri);
+    WriteCurrentTimeL();
+#endif
+
+    CEndTimeBased* newItem = NULL;
+    TTime home;
+    TInt index = 0;
+
+
+    // check if uri is already in the list
+    index = Find( aUri , aPermType , aRegType , aAutoType );
+    if ( index >= 0 )
+        {
+        // if it is in the list then just update the end time.
+        iList[index]->IncreaseRegTimes();
+        UpdateEndTimeL( iList[index] , aEndTime );
+        return;
+        }
+
+    // if not in the list then create one
+    newItem = CEndTimeBased::NewL( aUri , aPermType , aRegType , aAutoType );
+    CleanupStack::PushL(newItem);
+
+    // set end time
+    newItem->SetEndTime(aEndTime);
+
+    // set expiration
+    home.HomeTime();
+    if ( home >= aEndTime )
+        {
+        newItem->SetIsExpired(ETrue);
+        }
+
+    // add the item into list
+    User::LeaveIfError( iList.Append( newItem ) );
+    CleanupStack::Pop(newItem);
+    // change alarm time if necessary
+    if ( home >= iAlarm && !newItem->IsExpired() )
+        {
+#ifdef _DRM_TESTING
+        //test code start
+        WriteL(_L("Add->Change iAlarm-><home"));
+        WriteL(aUri);
+        WriteCurrentTimeL();
+        WriteL(_L("Change Time"));
+        WriteTimeL(aEndTime);
+        //test code end
+#endif
+
+        iAlarm = aEndTime;
+        }
+
+    if ( !newItem->IsExpired() && iAlarm >= aEndTime && iAlarm != Time::MaxTTime() )
+        {
+        iAlarm = aEndTime;
+        Cancel();
+
+#ifdef _DRM_TESTING
+        //test code start
+        WriteL(_L("Add->Change iAlarm->>Change Time"));
+        WriteL(aUri);
+        WriteCurrentTimeL();
+        WriteL(_L("Change Time"));
+        WriteTimeL(iAlarm);
+        WriteL(_L("Add->Trigger iAlarm"));
+        WriteL(aUri);
+        WriteL(_L("Trigger Time"));
+        WriteTimeL(iAlarm);
+        //test code end
+#endif
+
+        CTimer::At(iAlarm+TTimeIntervalSeconds(KInformingDelay));
+
+        }
+
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::UpdateL
+// update a specific content uri in the list
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::UpdateL()
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("UpdateL(all)"));
+    WriteCurrentTimeL();
+#endif
+
+    for( TInt i( 0 ); i < iList.Count(); i++ )
+        {
+        const CEndTimeBased* e( iList[i] );
+        iServer.UpdateL(
+                *e->Uri(), e->PermType(), e->RegType(), e->AutoType() );
+        if ( e->Count() > KMaxHandlingCount )
+            {
+            // Client must have forgotten to unregister item properly.
+            // So let's unregister now.
+            Remove( *e->Uri(), e->PermType(), e->RegType(), e->AutoType() );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::UpdateEndTimeL
+// update the end time of a specific content uri in the list
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::UpdateEndTimeL(
+        const TDesC8& aUri ,
+        const TTime& aEndTime ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType
+        )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("UpdateEndTimeL(uri,endtime,perm,reg)"));
+    WriteL(aUri);
+    WriteCurrentTimeL();
+#endif
+
+    TInt index = 0;
+    index = FindNext(aUri,aPermType,aRegType,index);
+    while ( index >= 0 )
+        {
+        UpdateEndTimeL( iList[index] , aEndTime );
+        index++;
+        index = FindNext(aUri,aPermType,aRegType,index);
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::UpdateEndTimeL
+// update the end time of a specific content uri in the list
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::UpdateEndTimeL(
+        const TDesC8& aUri ,
+        const TTime& aEndTime ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType ,
+        const TUint8& aAutoType
+        )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("UpdateEndTimeL(uri,endtime,perm,reg,autotype)"));
+    WriteL(aUri);
+    WriteCurrentTimeL();
+#endif
+
+    TInt index = 0;
+    index = Find(aUri,aPermType,aRegType,aAutoType);
+    if ( index >= 0 )
+        {
+        UpdateEndTimeL( iList[index] , aEndTime );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::UpdateEndTimeL
+// update the end time of a specific content uri in the list
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::UpdateEndTimeL( CEndTimeBased*& aItem , const TTime& aEndTime )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("UpdateEndTimeL(item,endtime)"));
+    WriteL(aItem->Uri()->Des());
+    WriteCurrentTimeL();
+#endif
+
+    aItem->SetEndTime(aEndTime);
+    ResetAlarm();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::IsRegisteredL
+// check if content uri is registered into list or not
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool CEndTimeFactory::IsRegistered(
+        const TDesC8& aUri ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType ,
+        const TUint8& aAutoType )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("IsRegisteredL(aUri,aPermType,aRegType,aAutoType)")) );
+    TRAP( err , WriteL(aUri) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+
+    // check if it is in the list
+    if ( Find( aUri , aPermType , aRegType , aAutoType ) >= 0 )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::IsRegisteredL
+// check if content uri is registered into list or not
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool CEndTimeFactory::IsRegistered(
+        const TDesC8& aUri ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("IsRegisteredL(aUri,aPermType,aRegType)")) );
+    TRAP( err , WriteL(aUri) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+
+    // check if it is in the list
+    TInt index = 0;
+    if ( FindNext( aUri , aPermType , aRegType , index ) >= 0 )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::IsRegisteredL
+// check if content uri is registered into list or not
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool CEndTimeFactory::IsRegistered2(
+        const TDesC8& aUri ,
+        const TUint8& aRegType,
+        const TUint8& aAutoType )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("IsRegisteredL(aUri,aRegType)")) );
+    TRAP( err , WriteL(aUri) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+
+    // check if it is in the list
+    if ( Exists( aUri, aRegType, aAutoType) >= 0 )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::IsRegisteredL
+// check if content uri is registered into list or not
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool CEndTimeFactory::IsRegistered( const TDesC8& aUri )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("IsRegisteredL(aUri)")) );
+    TRAP( err , WriteL(aUri) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+
+    // check if it is in the list
+    TInt index = 0;
+    if ( FindNext( aUri , index ) >= 0 )
+        {
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::Remove
+// Remove a specific content uri from factory
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::Remove(
+        const TDesC8& aUri ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType ,
+        const TUint8& aAutoType )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("Remove")) );
+    TRAP( err , WriteL(aUri) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+
+    TInt index = Find( aUri , aPermType , aRegType , aAutoType );
+    if ( index >= 0 )
+        {
+        iList[index]->DecreaseRegTimes();
+
+#ifdef _DRM_TESTING
+        TBuf<20> buf;
+        _LIT( KRegTimes , "RegTimes: %d");
+        buf.Format( KRegTimes , iList[index]->RegTimes() );
+        TRAP( err , WriteL(buf) );
+#endif
+
+        if ( iList[index]->RegTimes()<1 )
+            {
+#ifdef _DRM_TESTING
+            TRAPD( err , WriteL(_L("Removing succeeded!")) );
+            TRAP( err , WriteCurrentTimeL() );
+#endif
+            delete iList[index];
+            iList[index] = NULL;
+            iList.Remove(index);
+            iList.Compress();
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::RemoveAllL
+// Remove a specific content uri from factory
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::RemoveAllL()
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("RemoveAllL"));
+    WriteCurrentTimeL();
+#endif
+    TInt i = 0;
+    for(;i<iList.Count();i++)
+        {
+        iServer.RemoveNotificationL( *iList[i]->Uri() );
+        }
+    iList.ResetAndDestroy();
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::RunL
+// from CActive
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::RunL()
+    {
+#ifdef _DRM_TESTING
+    //test code start
+    WriteL(_L("RunL"));
+    WriteL(_L("Current Time"));
+    WriteCurrentTimeL();
+    WriteL(_L("iAlarm"));
+    WriteTimeL(iAlarm);
+    //test code end
+#endif
+
+    TInt error( iStatus.Int() ); // to be used in ResetAlarm
+    if ( error == KErrOverflow )
+        {
+        // Overflow occured, next trial after desired interval / 2
+        // Let's update known overflowed alarm time 1st
+        iOverflowedAlarm = iAlarm;
+        TInt64 alarm( iAlarm.Int64() );
+        iAlarm.HomeTime();
+        TInt64 h( iAlarm.Int64() );
+        TTime newAlarm( alarm / 2 + h / 2 );
+        iAlarm = newAlarm;
+        }
+
+    HandleExpiredL();
+    ResetAlarm();
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::DoCancel
+// From CActive
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::DoCancel()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("DoCancel")) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+    CTimer::DoCancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::Find
+// Find index for content uri
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CEndTimeFactory::Find(
+        const TDesC8& aUri ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType ,
+        const TUint8& aAutoType )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("Find(aUri,aPermType,aRegType,aAutoType)")) );
+    TRAP( err , WriteL(aUri) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+
+    TInt i = 0;
+    for ( ; i < iList.Count() ; i++ )
+        {
+        if ( iList[i]->Uri()->Compare( aUri ) == 0 )
+            {
+            if ( (iList[i]->PermType()==aPermType) )
+                {
+                if ( (iList[i]->RegType()==aRegType) )
+                    {
+                    if ( (iList[i]->AutoType()==aAutoType) )
+                        {
+                        return i;
+                        }
+                    }
+                }
+            }
+        }
+    return KErrNotFound;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::FindNext
+// Find index for content uri
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CEndTimeFactory::FindNext(const TDesC8& aUri,const TUint8& aIndex)
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("FindNext(aUri,aIndex)")) );
+    TRAP( err , WriteL(aUri) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+
+    TInt i = aIndex;
+    for ( ; i < iList.Count() ; i++ )
+        {
+        if ( iList[i]->Uri()->Compare( aUri ) == 0 )
+            {
+            return i;
+            }
+        }
+    return KErrNotFound;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::FindNext
+// Find index for content uri
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CEndTimeFactory::FindNext(
+        const TDesC8& aUri ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType ,
+        const TUint8& aIndex )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("FindNext(aUri,aPermType,aRegType,aIndex)")) );
+    TRAP( err , WriteL(aUri) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+
+    TInt i = aIndex;
+    for ( ; i < iList.Count() ; i++ )
+        {
+        if ( iList[i]->Uri()->Compare( aUri ) == 0 )
+            {
+            if ( (iList[i]->PermType()==aPermType) )
+                {
+                if ( (iList[i]->RegType()==aRegType) )
+                    {
+                    return i;
+                    }
+                }
+            }
+        }
+    return KErrNotFound;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::Exists
+// Find index for content uri
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CEndTimeFactory::Exists(
+        const TDesC8& aUri ,
+        const TUint8& aRegType,
+        const TUint8& aAutoType)
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("Exists(aUri,aRegType)")) );
+    TRAP( err , WriteL(aUri) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+
+    TInt i = 0;
+    for ( ; i < iList.Count() ; i++ )
+        {
+        if ( iList[i]->Uri()->Compare( aUri ) == 0 )
+            {
+            if ( (iList[i]->RegType()==aRegType) )
+                {
+                if ( (iList[i]->AutoType()==aAutoType) )
+                    {
+                    return i;
+                    }
+                }
+            }
+        }
+    return KErrNotFound;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::ResetAlarm
+// Reset the alarm according to the end time based content list
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::ResetAlarm()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("ResetAlarm")) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+    TBool out = EFalse;
+    TInt i = 0;
+    TTime home;
+
+    TTime oldAlarm( iAlarm ); // for overflow checks
+
+    iAlarm.HomeTime();
+    ResetExpired();
+
+    for ( ; i < iList.Count() && !out ; i++ )
+        {
+        if ( !iList[i]->IsExpired() )
+            {
+            iAlarm = iList[i]->EndTime();
+            out = ETrue;
+            }
+        }
+    for ( ; i < iList.Count() ; i++ )
+        {
+        if ( !iList[i]->IsExpired() )
+            {
+            if ( iList[i]->EndTime() < iAlarm )
+                {
+                iAlarm = iList[i]->EndTime();
+#ifdef _DRM_TESTING
+                //test code start
+                TRAP( err , WriteL(_L("ResetAlarm->Change iAlarm")) );
+                TRAP( err , WriteL(iList[i]->Uri()->Des()) );
+                TRAP( err , WriteCurrentTimeL() );
+                TRAP( err , WriteL(_L("Change Time")) );
+                TRAP( err , WriteTimeL(iAlarm) );
+                //test code end
+#endif
+                }
+            }
+
+        }
+    Cancel();
+    home.HomeTime();
+
+    //
+    if ( iAlarm >= iOverflowedAlarm )
+        {
+        // let's keep old alarm, if desired alarm is later than last known overflow
+        iAlarm = oldAlarm;
+        }
+    //
+
+    if ( iAlarm > home && iAlarm != Time::MaxTTime() )
+        {
+#ifdef _DRM_TESTING
+        //test code start
+        TRAP( err , WriteL(_L("ResetAlarm->Trigger iAlarm")) );
+        TRAP( err , WriteCurrentTimeL() );
+        TRAP( err , WriteL(_L("Trigger Time")) );
+        TRAP( err , WriteTimeL(iAlarm) );
+        //test code end
+#endif
+        CTimer::At(iAlarm+TTimeIntervalSeconds(KInformingDelay));
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::ResetExpired
+// Reset the expiration status for all end time items
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::ResetExpired()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("ResetExpired")) );
+    TRAP( err , WriteCurrentTimeL() );
+    TRAP( err , WriteL(_L("Time in the List")) );
+#endif
+    TInt i = 0;
+    TTime home;
+    home.HomeTime();
+    for ( ; i<iList.Count() ; i++ )
+        {
+#ifdef _DRM_TESTING
+        //test code start
+        TRAP( err , WriteTimeL(iList[i]->EndTime()) );
+        //test code end
+#endif
+        if ( !iList[i]->IsExpired() )
+            {
+            if ( iList[i]->EndTime() <= home )
+                {
+                iList[i]->SetCount(-1);
+                iList[i]->SetIsExpired(ETrue);
+                }
+            }
+        else
+            {
+            if ( iList[i]->EndTime() > home )
+                {
+                iList[i]->SetCount(-1);
+                iList[i]->SetIsExpired(EFalse);
+                }
+            }
+
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::HandleExpiredL
+// Reset the expiration status for all end time items
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::HandleExpiredL()
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("HandleExpiredL"));
+    WriteCurrentTimeL();
+#endif
+    TInt i = 0;
+    static TBool firstBoot = ETrue;
+    ResetExpired();
+    for ( ; i<iList.Count() ; i++ )
+        {
+        if ( iList[i]->IsExpired() && iList[i]->Count() < 0 )
+            {
+            iList[i]->IncreaseCount();
+            iServer.HandleExpiredL( iList[i] );
+            }
+        if ( firstBoot && iList[i]->IsExpired() ) // Count 0 means do not give
+            {                                      // note in Profiles
+            iList[i]->IncreaseCount();             // If previous count is 0
+            iServer.HandleExpiredL( iList[i] );    // Give a note with value 1
+            }
+        }
+    firstBoot = EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::HandleIdleL
+// Handle about to expire- and expired- cases after idle
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::HandleIdleL()
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("HandleIdleL"));
+    WriteCurrentTimeL();
+#endif
+    TInt i = 0;
+    iServer.UpdateL();
+    ResetExpired();
+    for ( ; i<iList.Count() ; i++ )
+        {
+        if ( iList[i]->IsExpired() )
+            {
+            iList[i]->IncreaseCount();
+            iServer.HandleExpiredL( iList[i] );
+            if ( iList[i]->Count() == 0 )           // Count 0 means do not give
+                {                                   // note in Profiles
+                iList[i]->IncreaseCount();          // If previous count is 0
+                iServer.HandleExpiredL( iList[i] ); // Give a note with value 1
+                }
+            }
+        }
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::ResetRegTimes
+// reset the registered times for one specific content in the list
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::ResetRegTimes(
+        const TDesC8& aUri ,
+        const TUint8& aPermType ,
+        const TUint8& aRegType ,
+        const TUint8& aAutoType ,
+        const TUint8& aRegTimes )
+
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("ResetRegTimes")) );
+    TRAP( err , WriteL(aUri) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+
+    TInt index = Find( aUri , aPermType , aRegType , aAutoType );
+    if ( index >= 0 )
+        {
+        iList[index]->SetRegTimes(aRegTimes);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::ExternalizeL
+// return ETrue if item is about to expire
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::ExternalizeL( RWriteStream& aStream ) const
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("ExternalizeL"));
+    WriteCurrentTimeL();
+#endif
+    TInt i = 0;
+    HBufC8* buf = NULL;
+    aStream.WriteUint8L(iList.Count());
+    for ( ; i<iList.Count() ; i++ )
+        {
+        buf = iList[i]->Uri();
+        aStream.WriteUint8L(buf->Length());
+        aStream.WriteL(buf->Des());
+        aStream.WriteUint8L(iList[i]->PermType());
+        aStream.WriteUint8L(iList[i]->RegType());
+        aStream.WriteUint8L(iList[i]->AutoType());
+        aStream.WriteInt32L(iList[i]->RegTimes());
+#ifdef _DRM_TESTING
+        //test code start
+        WriteL(buf->Des());
+        //test code end
+#endif
+        aStream.CommitL();
+        buf = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CEndTimeFactory::InternalizeL
+// return ETrue if item is about to expire
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CEndTimeFactory::InternalizeL( RReadStream& aStream )
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("InternalizeL"));
+    WriteCurrentTimeL();
+#endif
+
+    TPtr8 ptr( NULL , 0 , 0 );
+    TUint amount = 0;
+    TUint len = 0;
+    TUint8 permType = 0;
+    TUint8 regType = 0;
+    TUint8 autoType = 0;
+    TInt regTimes = 0;
+    HBufC8* buf = NULL;
+
+    amount = aStream.ReadUint8L();
+
+
+    for ( ; amount>0 ; amount-- )
+        {
+        len = aStream.ReadUint8L();
+#ifdef _DRM_TESTING
+        //test code start
+        TBuf<20>amountBuf;
+        _LIT(KLength , "Length:%d");
+        amountBuf.Format(KLength , len);
+        WriteL(amountBuf);
+        //test code end
+#endif
+        buf = HBufC8::NewLC(len);
+        ptr.Set(buf->Des());
+        ptr.SetLength(len);
+        aStream.ReadL(ptr , len);
+
+#ifdef _DRM_TESTING
+        //test code start
+        WriteL(ptr);
+        //test code end
+#endif
+        permType = aStream.ReadUint8L();
+        regType = aStream.ReadUint8L();
+        autoType = aStream.ReadUint8L();
+#ifdef _DRM_TESTING
+        //test code start
+        _LIT(KPermType , "PermType:%d");
+        amountBuf.Format(KPermType , permType);
+        WriteL(amountBuf);
+        _LIT(KRegType , "RegType:%d");
+        amountBuf.Format(KRegType , regType);
+        WriteL(amountBuf);
+        _LIT(KAutoType , "AutoType:%d");
+        amountBuf.Format(KAutoType , autoType);
+        WriteL(amountBuf);
+
+        //test code end
+#endif
+        iServer.RegisterL( ptr , permType , regType , autoType );
+
+        regTimes = aStream.ReadInt32L();
+#ifdef _DRM_TESTING
+        //test code start
+        _LIT(KRegTimes , "Times:%d");
+        amountBuf.Format(KRegTimes , regTimes);
+        WriteL(amountBuf);
+        //test code end
+#endif
+        ResetRegTimes( ptr , permType , regType , autoType , regTimes );
+        CleanupStack::PopAndDestroy(buf);
+        }
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/drmhelperserver/src/IdleObserver.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,238 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  observe the idle event of system
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    <e32base.h>
+#include    <e32std.h>
+#include    <f32file.h>
+#include    <ActiveIdle2DomainPSKeys.h>
+#include    <e32property.h> //for RProperty
+#include    "IdleObserver.h"
+#include    "DRMHelperServer.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+
+
+#ifdef _DRM_TESTING
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
+	{
+    RFile file;
+	TInt size;
+    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+	User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy(&file); //file
+	}
+
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
+	{
+	_LIT( KLogFile , "c:\\IOLog.txt" );
+	WriteFileL( text , aFs , KLogFile );
+	}
+
+LOCAL_C void CreateLogL()
+	{
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    User::LeaveIfError( file.Replace( fs , _L("c:\\IOLog.txt") , EFileWrite ) );
+    file.Close();
+    CleanupStack::PopAndDestroy(&fs); //fs
+	}
+
+LOCAL_C void WriteL( const TDesC& aText )
+	{
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+	HBufC8* text = HBufC8::NewLC(1000);
+	TPtr8 textptr(text->Des() );
+	textptr.Append( aText );
+    textptr.Append(_L( "\r\n" ));
+	WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+	}
+
+LOCAL_C void WriteCurrentTimeL()
+	{
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+	HBufC8* text = HBufC8::NewLC(100);
+	TPtr8 textptr(text->Des() );
+// Date and Time display
+    TTime time;
+    time.HomeTime();
+	TBuf<256> dateString;
+	_LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+	time.FormatL(dateString,KDate);
+	textptr.Append(_L( "\r\n\t\tData:\t" ) );
+	textptr.Append( dateString );
+	_LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+	time.FormatL(dateString,KTime);
+	textptr.Append(_L( "\r\n\t\tTime:\t" ) );
+	textptr.Append( dateString );
+	textptr.Append(_L( "\r\n" ) );
+	textptr.Append(_L( "\r\n" ) );
+	WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(&fs); //fs
+	}
+#endif
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CIdleObserver::CIdleObserver
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CIdleObserver::CIdleObserver( CDRMHelperServer& aServer ):
+                    CActive(CActive::EPriorityStandard),
+                        iServer( aServer )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CIdleObserver::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CIdleObserver::ConstructL()
+    {
+#ifdef _DRM_TESTING
+    CreateLogL(); //test
+#endif
+    User::LeaveIfError( iProperty.Attach( KPSUidAiInformation, KActiveIdleState ) );
+    }
+                    
+// -----------------------------------------------------------------------------
+// CIdleObserver::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CIdleObserver* CIdleObserver::NewL(CDRMHelperServer& aServer)
+    {
+    CIdleObserver* self = new( ELeave ) CIdleObserver(aServer);
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(self);
+
+    return self;
+    }
+
+    
+// Destructor
+CIdleObserver::~CIdleObserver()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("CIdleObserver-Destruct")) ); 
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+    Cancel();
+    iProperty.Close();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CIdleObserver::StartL
+// Start the system agent to listen to the event
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CIdleObserver::StartL()
+    {
+#ifdef _DRM_TESTING
+    WriteL(_L("Start"));
+    WriteCurrentTimeL();
+#endif
+    Cancel();
+    iProperty.Subscribe( iStatus );
+    SetActive();
+    }
+
+
+// -----------------------------------------------------------------------------
+// CIdleObserver::RunL
+// from CActive
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CIdleObserver::RunL()
+    {
+#ifdef _DRM_TESTING 
+    //test code start
+    WriteL(_L("RunL"));
+    WriteCurrentTimeL();
+    //test code end
+#endif
+    
+    // Resubscribe before processing new value to prevent missing updates
+    TInt idleStauts = 0;
+    TInt err( iStatus.Int() );
+    if (err == KErrNone)
+        {
+        StartL();
+        User::LeaveIfError( iProperty.Get( 
+                KPSUidAiInformation, 
+                KActiveIdleState, idleStauts ) );
+        if ( idleStauts == EPSAiForeground ) 
+            {
+            iServer.HandleIdleL();
+            }
+        }
+    else if ( err != KErrCancel )
+        {
+        StartL();
+        }  
+    }
+
+// -----------------------------------------------------------------------------
+// CIdleObserver::DoCancel
+// From CActive
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CIdleObserver::DoCancel()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("DoCancel")) );
+    TRAP( err , WriteCurrentTimeL() );
+#endif
+    iProperty.Cancel();
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/group/Drmhelper.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,112 @@
+/*
+* Copyright (c) 2003-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:  Project definition file for DRMHelper
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          DRMHelper.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x101F8647
+
+CAPABILITY      CAP_GENERAL_DLL DRM
+VENDORID        VID_DEFAULT
+
+#ifdef __DRM
+SOURCE          ../src/DRMHelper.cpp
+SOURCE          ../src/ConsumeData.cpp
+SOURCE          ../src/RDRMHelper.cpp
+SOURCE          ../src/DRMHelperGlobalNoteWrapper.cpp
+SOURCE          ../src/DRMHelperDownloadManager.cpp
+SOURCE          ../src/DRMHelperInfoNoteWrapper.cpp
+#else
+SOURCE          ../src/DRMHelperStub.cpp
+SOURCE          ../src/RDRMHelperStub.cpp
+SOURCE          ../src/DRMHelperGlobalNoteWrapper.cpp
+#endif
+SOURCE          ../src/DRMHelperDll.cpp
+
+START RESOURCE DRMHelper.rss
+HEADER
+TARGETPATH RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../DRMEngine/Server/inc
+USERINCLUDE     ../../DRMEngine/Roap/inc
+USERINCLUDE     ../../DRMEngine/RoapStorage/inc
+USERINCLUDE        ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+APP_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/ecom    // needed because of SchemeHandler
+// needed for drmhelpersecondarydisplay.h
+
+LIBRARY         euser.lib
+LIBRARY         commonengine.lib
+LIBRARY         cone.lib
+LIBRARY         flogger.lib
+LIBRARY         aknnotify.lib
+LIBRARY         apparc.lib // for launching rights mgr ui embedded
+LIBRARY         avkon.lib
+
+#ifdef __DRM
+LIBRARY         DrmParsers.lib
+LIBRARY         DrmDcf.lib
+LIBRARY         DrmRights.lib
+LIBRARY         DrmServerInterfaces.lib
+LIBRARY         DRMCommon.lib
+LIBRARY         eikdlg.lib
+LIBRARY         StarterClient.lib
+LIBRARY         efsrv.lib // for launching rights mgr ui embedded
+LIBRARY         APGRFX.lib
+LIBRARY         WS32.lib
+LIBRARY         dcfrep.lib
+LIBRARY         centralrepository.lib
+
+LIBRARY         ServiceHandler.lib
+
+LIBRARY         caf.lib
+LIBRARY         cafutils.lib
+LIBRARY         charconv.lib
+LIBRARY         ecom.lib                // for scheme handling
+LIBRARY         cmmanager.lib
+
+LIBRARY         estor.lib   // Cover Display
+LIBRARY         featmgr.lib
+
+LIBRARY         RoapHandler.lib
+LIBRARY         mediatorclient.lib
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY         platformenv.lib
+#endif
+
+#endif
+
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/group/Drmhelper.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1268 @@
+/*
+* Copyright (c) 2003 - 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 file for DRMHelper
+*
+*/
+
+
+
+//  RESOURCE IDENTIFIER
+NAME    DRMH
+
+//  INCLUDES
+#include <eikon.rh>
+#include <eikon.rsg>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.loc>
+#include <avkon.mbg>
+#ifdef __DRM
+#include <DRMCommon.loc>
+#endif
+
+//  CONSTANTS
+
+
+//  MACROS
+
+
+//  RESOURCE DEFINITIONS
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF16 { buf=""; }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_confirmation_query
+// Confirmation query dialog
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_drmhelper_confirmation_query
+    {
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_YES_NO__YES;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                label = " ";
+                };
+            }
+        };
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_waiting_rights_confirmation_query
+// Confirmation query dialog
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_drmhelper_waiting_rights_confirmation_query
+    {
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_OK_EMPTY__OK;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                label = " ";
+                animation = R_QGN_NOTE_INFO_ANIM;
+                };
+            }
+        };
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_usage_rights_expired_buy_new
+// String displayed in query for superdistributable content when rights have
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_usage_rights_expired_buy_new
+    {
+    buf = qtn_drm_sd_rights_exp;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_usage_rights_expired
+// String displayed in query for non-superdistributable content when rights have
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_usage_rights_expired
+    {
+    buf = qtn_drm_info_ro_expired;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_no_usage_rights_buy_new
+// String displayed in query for superdistributable content when there is no
+// rights.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_no_usage_rights_buy_new
+    {
+    buf = qtn_drm_no_rights;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_no_usage_rights
+// String displayed in query for non-superdistributable content when there is no
+// rights.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_no_usage_rights
+    {
+    buf = qtn_drm_prof_rights_missing;
+    }
+
+
+#ifndef RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_usage_rights_to_expire
+// Text displayed in query when rights are about to expire and there is
+// both time and count based rights.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_usage_rights_to_expire
+    {
+    buf = qtn_drm_exp_warn_cnt_and_dt;
+    }
+#endif // RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+
+
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_set_automated
+// Text displayed in query when already activated content is set for automated
+// use.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_set_automated
+    {
+    buf = qtn_drm_query_valid_rights_until;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_activate_and_set_automated
+// Text displayed in query when content, that is not yet activated, is set for
+// automated use.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_activate_and_set_automated
+    {
+    buf = qtn_drm_query_active_rights_until;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_cal_alert_invalid_sim_buy_new
+// Text displayed in query when superdistributable calendar alert is tried to
+// be used with wrong sim.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_cal_alert_invalid_sim_buy_new
+    {
+    buf = qtn_drm_calendar_tone_wrong_sim;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_cal_alert_expired_buy_new
+// Text displayed in query when superdistributable calendar alert is expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_cal_alert_expired_buy_new
+    {
+    buf = qtn_drm_cal_tone_exp_activate;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_cal_alert_expired
+// Text displayed in query when non-superdistributable calendar alert is
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_cal_alert_expired
+    {
+    buf = qtn_drm_info_calendar_tone_exp;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_clock_alarm_invalid_sim_buy_new
+// Text displayed in query when superdistributable clock alarm is tried to be
+// used with wrong sim.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_clock_alarm_invalid_sim_buy_new
+    {
+    buf = qtn_drm_clock_alarm_wrong_sim;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_clock_alarm_expired_buy_new
+// Text displayed in query when superdistributable clock alarm is expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_clock_alarm_expired_buy_new
+    {
+    buf = qtn_drm_clock_alrm_exp_activate;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_clock_alarm_expired
+// Text displayed in query when non-superdistributable clock alarm is
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_clock_alarm_expired
+    {
+    buf = qtn_drm_info_clock_alarm_exp;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_email_tone_expired_buy_new
+// Text displayed in query when superdistributable email tone is expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_email_tone_expired_buy_new
+    {
+    buf = qtn_drm_email_tone_exp_activate;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_email_tone_invalid_sim_buy_new
+// Text displayed in query when superdistributable email tone is tried to use
+// with wrong sim.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_email_tone_invalid_sim_buy_new
+    {
+    buf = qtn_drm_email_alert_wrong_sim;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_email_tone_expired
+// Text displayed in query when non-superdistributable email tone is
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_email_tone_expired
+    {
+    buf = qtn_drm_info_email_tone_exp;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_im_tone_expired_buy_new
+// Text displayed in query when superdistributable IM tone is expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_im_tone_expired_buy_new
+    {
+    buf = qtn_drm_im_tone_exp_activate;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_im_tone_expired
+// Text displayed in query when non-superdistributable IM tone is
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_im_tone_expired
+    {
+    buf = qtn_drm_info_im_alert_tone_exp;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_message_tone_invalid_sim_buy_new
+// Text displayed in query when superdistributable message tone is tried to use
+// with wrong sim.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_message_tone_invalid_sim_buy_new
+    {
+    buf = qtn_drm_message_alert_wrong_sim;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_message_tone_expired_buy_new
+// Text displayed in query when superdistributable message tone is expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_message_tone_expired_buy_new
+    {
+    buf = qtn_drm_msg_tone_exp_activate;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_message_tone_expired
+// Text displayed in query when non-superdistributable message tone is
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_message_tone_expired
+    {
+    buf = qtn_drm_info_msg_tone_exp;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_ringing_tone_expired_buy_new
+// Text displayed in query when superdistributable ringing tone is expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_ringing_tone_expired_buy_new
+    {
+    buf = qtn_drm_ring_tone_exp_activate;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_ringing_tone_invalid_sim_buy_new
+// Text displayed in query when superdistributable ringing tone is tried to use
+// with wrong sim.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_ringing_tone_invalid_sim_buy_new
+    {
+    buf = qtn_drm_ringing_tone_wrong_sim;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_ringing_tone_expired
+// Text displayed in query when non-superdistributable ringing tone is
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_ringing_tone_expired
+    {
+    buf = qtn_drm_info_ring_tone_exp;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_screensaver_invalid_sim_buy_new
+// Text displayed in query when superdistributable screensaver is tried to use
+// with wrong sim.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_screensaver_invalid_sim_buy_new
+    {
+    buf = qtn_drm_screensave_wrong_sim;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_screensaver_expired_buy_new
+// Text displayed in query when superdistributable screensaver is expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_screensaver_expired_buy_new
+    {
+    buf = qtn_drm_screensave_exp_activate;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_screensaver_expired
+// Text displayed in query when non-superdistributable screensaver is
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_screensaver_expired
+    {
+    buf = qtn_drm_info_screensaver_exp;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_wallpaper_invalid_sim_buy_new
+// Text displayed in query when superdistributable wallpaper is tried to use
+// with wrong sim.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_wallpaper_invalid_sim_buy_new
+    {
+    buf = qtn_drm_wallpaper_wrong_sim;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_wallpaper_expired_buy_new
+// Text displayed in query when superdistributable wallpaper is expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_wallpaper_expired_buy_new
+    {
+    buf = qtn_drm_wallpaper_exp_activate;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_wallpaper_expired
+// Text displayed in query when non-superdistributable wallpaper is
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_wallpaper_expired
+    {
+    buf = qtn_drm_info_wallpaper_exp;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_theme_invalid_sim_buy_new
+// Text displayed in query when superdistributable theme is tried to use with
+// wrong sim.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_theme_invalid_sim_buy_new
+    {
+    buf = qtn_drm_theme_wrong_sim;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_theme_expired_buy_new
+// Text displayed in query when superdistributable theme is expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_theme_expired_buy_new
+    {
+    buf = qtn_drm_theme_exp_activate;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_theme_expired
+// Text displayed in query when non-superdistributable theme is
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_theme_expired
+    {
+    buf = qtn_drm_info_theme_exp;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_usage_rights_in_future
+// Text displayed in query when usage rights are not yet valid.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_usage_rights_in_future
+    {
+    buf = qtn_drm_note_ro_valid_on_future;
+    }
+
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_activate_after_preview
+// String displayed in query after embedded preview has been played.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_activate_after_preview
+    {
+    buf = qtn_drm_sd_rights_exp;
+    }
+
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_waiting_for_rights
+// Text displayed in query when usage rights are missing but according to
+// x-oma-separate-delivery header they should have come
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_waiting_for_rights
+    {
+    buf = qtn_drm_query_waiting_for_ro;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_rights_should_have_come
+// Text displayed in query when usage rights are missing but according to
+// x-oma-separate-delivery header they should have come
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_rights_should_have_come
+    {
+    buf = qtn_drm_query_ro_late_activate;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_rights_should_have_come_no_ri
+// Text displayed in query when usage rights for non-superdistributable content
+// are missing but according to x-oma-separate-delivery header they should have
+// come
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_rights_should_have_come_no_ri
+    {
+    buf = qtn_drm_query_ro_late;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_automated_sd_invalid_sim
+// Text displayed in query when superdistributable automated content is tried to
+// use with wrong sim.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_automated_sd_invalid_sim
+    {
+    buf = qtn_drm_automated_wrong_sim;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_automated_sd_expired
+// Text displayed in query when superdistributable automated content is expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_automated_sd_expired
+    {
+    buf = qtn_drm_note_sd_ro_expired;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_automated_cd_expired
+// Text displayed in query when automated content is about to expire in 1 day.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_automated_cd_expired
+    {
+    buf = qtn_drm_note_cd_ro_expired;
+    }
+
+//About to expired notes are about to be removed,
+#ifndef RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_info_exp_1_use
+// Text in information note for 1 count left when rendering a non-superdistributable content
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_info_exp_1_use
+    {
+    buf = qtn_drm_info_exp_1_use;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_info_exp_n_uses
+// Text in information note for more than 1 counts left when rendering a non-superdistributable content
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_info_exp_n_uses
+    {
+    buf = qtn_drm_info_exp_n_uses;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_info_exp_1_day
+// Text in information note for 1 day left when rendering a non-superdistributable content
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_info_exp_1_day
+    {
+    buf = qtn_drm_info_exp_1_day;
+    }
+
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_info_exp_n_days
+// Text in information note for more than 1 days left when rendering a non-superdistributable content
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_info_exp_n_days
+    {
+    buf = qtn_drm_info_exp_n_days;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_query_exp_1_use_get_new
+// Text in confirmation query shown for 1 count left when rendering a superdistributable content
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_query_exp_1_use_get_new
+    {
+    buf = qtn_drm_query_exp_1_use_get_new;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_query_exp_n_use_get_new
+// Text in confirmation query shown for n counts left when rendering a superdistributable content
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_query_exp_n_use_get_new
+    {
+    buf = qtn_drm_query_exp_n_use_get_new;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_query_exp_1_day_get_new
+// Text in confirmation query shown for 1 day left when rendering a superdistributable content
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_query_exp_1_day_get_new
+    {
+    buf = qtn_drm_query_exp_1_day_get_new;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_query_exp_n_day_get_new
+// Text in confirmation query shown for n days left when rendering a superdistributable content
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_query_exp_n_day_get_new
+    {
+    buf = qtn_drm_query_exp_n_day_get_new;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_query_exp_1_min_get_new
+// Text in confirmation query shown for 1 minute left when rendering a superdistributable content
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_query_exp_1_min_get_new
+    {
+    buf = qtn_drm_query_exp_1_min_get_new;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_query_exp_n_min_get_new
+// Text in confirmation query shown for n minutes left when rendering a superdistributable content
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_query_exp_n_min_get_new
+    {
+    buf = qtn_drm_query_exp_n_min_get_new;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_drmhelper_query_exp_many_constr
+// Text in confirmation query shown for multiple constraints when rendering a superdistributable content
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_query_exp_many_constr
+    {
+    buf = qtn_drm_query_exp_many_constr;
+    }
+#endif // RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmhelper_prev_audio_get_list_query
+//    Preview list query for audio with preview rights url.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_drmhelper_prev_audio_get_list_query
+    {
+    softkeys = R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT;
+
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = qtn_drm_prmpt_activate_preview;
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; // not sure if this is needed
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknListQueryMessageBox;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = qtn_drm_desc_activate_or_prvw;
+                };
+            },
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            id = EListQueryControl;
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    flags = EAknListBoxSelectionList;
+                    array_id = r_drmhelper_audio_prev_get_list;
+                    };
+                heading = qtn_drm_prmpt_activate_preview;
+                };
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmhelper_prev_video_get_list_query
+//    Preview list query for video with preview rights url.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_drmhelper_prev_video_get_list_query
+    {
+    softkeys = R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT;
+
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = qtn_drm_prmpt_activate_preview;
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; // not sure if this is needed
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknListQueryMessageBox;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = qtn_drm_desc_act_or_prev_video;
+                };
+            },
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            id = EListQueryControl;
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    flags = EAknListBoxSelectionList;
+                    array_id = r_drmhelper_video_prev_get_list;
+                    };
+                heading = qtn_drm_prmpt_activate_preview;
+                };
+            }
+        };
+    }
+
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmhelper_prev_audio_play_list_query
+//    Preview list query for audio with embedded preview.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_drmhelper_prev_audio_play_list_query
+    {
+    softkeys = R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT;
+
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = qtn_drm_prmpt_activate_preview;
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; // not sure if this is needed
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknListQueryMessageBox;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = qtn_drm_desc_play_preview_audio;
+                };
+            },
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            id = EListQueryControl;
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    flags = EAknListBoxSelectionList;
+                    array_id = r_drmhelper_audio_prev_play_list;
+                    };
+                heading = qtn_drm_prmpt_activate_preview;
+                };
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmhelper_prev_video_play_list_query
+//    Preview list query for video with embedded preview.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE AVKON_LIST_QUERY r_drmhelper_prev_video_play_list_query
+    {
+    softkeys = R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT;
+
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtPopupHeadingPane;
+            id = EAknMessageQueryHeaderId;
+            control = AVKON_HEADING
+                {
+                label = qtn_drm_prmpt_activate_preview;
+                headinglayout = R_AVKON_WML_SIGN_QUERY_HEADING_PANE; // not sure if this is needed
+                };
+            },
+        DLG_LINE
+            {
+            type = EAknCtMessageQuery;
+            id = EAknListQueryMessageBox;
+            control = AVKON_MESSAGE_QUERY
+                {
+                message = qtn_drm_desc_play_preview_video;
+                };
+            },
+
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            id = EListQueryControl;
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSinglePopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    flags = EAknListBoxSelectionList;
+                    array_id = r_drmhelper_video_prev_play_list;
+                    };
+                heading = qtn_drm_prmpt_activate_preview;
+                };
+            }
+        };
+    }
+
+
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmhelper_audio_prev_get_list
+//    Array elements for preview rights of audio dcf.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_drmhelper_audio_prev_get_list
+    {
+    items=
+        {
+        LBUF
+            {
+            txt = qtn_drm_options_activate;
+            },
+        LBUF
+            {
+            txt = qtn_drm_options_get_preview;
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmhelper_video_prev_get_list
+//    Array elements for preview rights of vedio dcf.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_drmhelper_video_prev_get_list
+    {
+    items=
+        {
+        LBUF
+            {
+            txt = qtn_drm_options_get_prev_video;
+            }
+        };
+    }
+
+#endif //RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmhelper_audio_prev_play_list
+//    Array elements for embedded preview of audio dcf.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_drmhelper_audio_prev_play_list
+    {
+    items=
+        {
+        LBUF
+            {
+            txt = qtn_drm_options_play_preview;
+            }
+        };
+    }
+
+//-----------------------------------------------------------------------------
+//
+//    r_drmhelper_video_prev_play_list
+//    Array elements for embedded preview of vedio dcf.
+//
+//-----------------------------------------------------------------------------
+//
+RESOURCE ARRAY r_drmhelper_video_prev_play_list
+    {
+    items=
+        {
+        LBUF
+            {
+            txt = qtn_drm_options_play_prev_video;
+            }
+        };
+    }
+
+// r_drmhelper_invalid_sim
+// Text displayed in query when content cannot be rendered because of wrong SIM.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_invalid_sim
+    {
+    buf = qtn_drm_query_sim_not_allowed;
+    }
+
+// r_drmhelper_activate_account
+// Text displayed in query when domain account has not been activated.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drmhelper_activate_account
+    {
+    buf = qtn_drm_query_activate_account;
+    }
+
+// r_drmhelper_activate_account
+// Text displayed in query when domain account has not been activated.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_info_sim_not_allowed
+    {
+    buf = qtn_drm_info_sim_not_allowed;
+    }
+
+// r_drmhelper_activate_account
+// Text displayed in query when domain account has not been activated.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_non_sd_calend_wrong_sim
+    {
+    buf = qtn_drm_non_sd_calend_wrong_sim;
+    }
+
+// r_drmhelper_activate_account
+// Text displayed in query when domain account has not been activated.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_non_sd_clock_wrong_sim
+    {
+    buf = qtn_drm_non_sd_clock_wrong_sim;
+    }
+
+// r_drmhelper_activate_account
+// Text displayed in query when domain account has not been activated.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_non_sd_email_wrong_sim
+    {
+    buf = qtn_drm_non_sd_email_wrong_sim;
+    }
+
+// r_drmhelper_activate_account
+// Text displayed in query when domain account has not been activated.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_non_sd_msg_al_wrong_sim
+    {
+    buf = qtn_drm_non_sd_msg_al_wrong_sim;
+    }
+
+// r_drmhelper_activate_account
+// Text displayed in query when domain account has not been activated.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_non_sd_rtone_wrong_sim
+    {
+    buf = qtn_drm_non_sd_rtone_wrong_sim;
+    }
+
+// r_drmhelper_activate_account
+// Text displayed in query when domain account has not been activated.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_non_sd_screen_wrong_sim
+    {
+    buf = qtn_drm_non_sd_screen_wrong_sim;
+    }
+
+// r_drmhelper_activate_account
+// Text displayed in query when domain account has not been activated.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_non_sd_theme_wrong_sim
+    {
+    buf = qtn_drm_non_sd_theme_wrong_sim;
+    }
+
+// r_drmhelper_activate_account
+// Text displayed in query when domain account has not been activated.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_non_sd_wallp_wrong_sim
+    {
+    buf = qtn_drm_non_sd_wallp_wrong_sim;
+    }
+
+// r_drmhelper_activate_account
+// Text displayed in query when domain account has not been activated.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_non_sd_gener_wrong_sim
+    {
+    buf = qtn_drm_non_sd_gener_wrong_sim;
+    }
+
+
+// r_drm_qry_connect_to_activate
+// Confirmation query for silent rights acquisition if not allowed in settings
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_qry_connect_to_activate
+    {
+    buf = qtn_drm_qry_connect_to_activate;
+    }
+
+// r_drm_msq_qry_title_registrat
+//Title fo registration query
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_msq_qry_title_registrat
+    {
+    buf = qtn_drm_msq_qry_title_registrat;
+    }
+
+// r_drm_msq_query_registration
+// Info query for reqistration before silent rights acquisition, if not yet reqistered
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_msq_query_registration
+    {
+    buf = qtn_drm_msq_query_registration;
+    }
+
+// r_drm_msq_query_link_more_inf
+// Info query for reqistration before silent rights acquisition, if not yet reqistered
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_msq_query_link_more_inf
+    {
+    buf = qtn_drm_msq_query_link_more_inf;
+    }
+
+// r_drm_sk1_register
+// String for SK1 to be used in registration message query
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_sk1_register
+    {
+    buf = qtn_drm_sk1_register;
+    }
+
+// r_drm_err_opening_fail_perm
+// Info note shown when silent rights activation failed because of permanent type of error.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_err_opening_fail_perm
+    {
+    buf = qtn_drm_err_opening_fail_perm;
+    }
+
+// r_drm_warn_no_conn_defined
+// Info note shown when silent rights activation failed because
+// no access points are defined.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_warn_no_conn_defined
+    {
+    buf = qtn_drm_warn_no_conn_defined;
+    }
+
+// r_drm_warn_invalid_or_no_ap
+// Info note shown when silent rights activation failed because server cannot
+// be contacted either because access point is invalid, packet data context cannot
+// be established, or access point is of wrong type.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_warn_invalid_or_no_ap
+    {
+    buf = qtn_drm_warn_invalid_or_no_ap;
+    }
+
+// r_drm_query_open_error_url
+// Confirmation query for opening error url in ROAP temporary error case.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_query_open_error_url
+    {
+    buf = qtn_drm_query_open_error_url;
+    }
+
+// r_drm_query_set_auto_interval
+// Confirmation query for setting content with interval as automated content.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_drm_query_set_auto_interval
+    {
+    buf = qtn_drm_query_set_auto_interval;
+    }
+
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2003 - 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:  Project definition for DRMHelper
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT -ARMI
+
+PRJ_MMPFILES
+
+drmhelperdmgrwrapper.mmp
+DRMHelper.mmp
+
+//  End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/group/drmhelperdmgrwrapper.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,79 @@
+/*
+* Copyright (c) 2006 - 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:  Project definition file for drmhelperdmgrwrapper
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET         drmhelperdmgrwrapper.dll
+TARGETTYPE     dll
+UID            0x1000008D 0x102823D9
+
+CAPABILITY     CAP_GENERAL_DLL
+VENDORID       VID_DEFAULT
+
+SOURCE         ../src/drmhelperdmgrwrapper.cpp
+
+START RESOURCE drmhelperdmgrwrapper.rss
+HEADER
+TARGETPATH RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+USERINCLUDE    ../inc
+USERINCLUDE    ../../DRMEngine/Roap/inc
+USERINCLUDE    ../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY        euser.lib
+LIBRARY        centralrepository.lib       // Browser default AP
+LIBRARY        cmmanager.lib
+LIBRARY        DownloadMgr.lib
+LIBRARY        RoapHandler.lib
+LIBRARY        efsrv.lib
+LIBRARY        avkon.lib
+LIBRARY        cone.lib
+LIBRARY        commonengine.lib
+LIBRARY        aknnotify.lib
+LIBRARY        eikctl.lib
+LIBRARY        eikcdlg.lib
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY        platformenv.lib
+#endif
+
+DEBUGLIBRARY   flogger.lib
+
+START WINS
+END
+
+START MARM
+END
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/group/drmhelperdmgrwrapper.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,74 @@
+/*
+* 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 file for drmhelperdmgrwrapper
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME    DRMD
+
+//  INCLUDES
+#include <eikon.rh>
+#include <eikon.rsg>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.loc>
+#include <avkon.mbg>
+#ifdef __DRM
+#include <DRMCommon.loc>
+#endif
+
+//  CONSTANTS  
+
+//  MACROS  
+
+//  RESOURCE DEFINITIONS 
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF16 { buf="DRMD"; }
+
+// -----------------------------------------------------------------------------
+//   
+// r_silent_progress_note
+// String displayed while getting silent rights 
+// expired.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_silent_progress_note
+    {
+    flags = EAknProgressNoteFlags;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EGeneralQuery;
+            control= AVKON_NOTE 
+                { 
+                layout = EProgressLayout;
+                singular_label = qtn_drm_progress_opening;
+                imagefile = AVKON_BITMAP_FILE;
+                imageid = EMbmAvkonQgn_note_progress; 
+                imagemask = EMbmAvkonQgn_note_progress_mask; 
+                };
+          }
+        };
+   }
+   
+//End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/inc/ConsumeData.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,119 @@
+/*
+* 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:  the client side class for DRMHelperServer
+*
+*/
+
+
+#ifndef CONSUMEDATA_H
+#define CONSUMEDATA_H
+
+// INCLUDES
+#include <e32base.h>
+#include <caf/caf.h>
+#include <drmrightsclient.h>
+
+// DATA TYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+
+/**
+*  This class provides the client-side interface to the server session
+*
+*  @since Series 60 2.6
+*/
+
+NONSHARABLE_CLASS( CConsumeData )  : public CBase
+    {
+    public:  // Constructors and destructor
+    
+		/**
+        * NewLC
+        *
+		* Created a new instance of the CConsumeData class and leaves
+		* it into the cleanup stack
+		*
+        * @param aUri: Content identifier of the content in question
+		* @return Functional CConsumeData -object
+        */
+        static CConsumeData* NewLC( const TDesC8& aUri );
+
+    
+		/**
+        * NewL
+        *
+		* Created a new instance of the CConsumeData class
+		*
+        * @param aUri: Content identifier of the content in question
+		* @return Functional CConsumeData -object
+        */
+        static CConsumeData* NewL( const TDesC8& aUri );
+        
+        /**
+        * Destructor
+        */
+        ~CConsumeData();
+        
+    public:  // New functions
+    
+ 		/**
+        * Consume
+        *
+		* Calls client consumption, if you call this with stop, the session
+		* is deleted
+		*
+        * @param aIntent: Intent to be used for consumption
+		* @return Symbian OS error code
+        */         
+        TInt Consume( const ContentAccess::TIntent& aIntent );
+
+ 		/**
+        * CompateUri();
+        *
+		* Compares the uri as if compared with string compare
+		*
+        * @param aIntent: Intent to be used for consumption
+		* @return Symbian OS error code
+        */         
+        TInt CompareUri( const TDesC8& aUri ) const;        
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+        CConsumeData();
+
+        /**
+        * Second phase constructor
+        */
+        void ConstructL( const TDesC8& aUri );
+
+        // Content uri of the content being used
+        HBufC8* iContentURI8;
+        
+        // Rights Client instance
+       	RDRMRightsClient iRdb;
+       	
+       	// Connection status
+       	TBool iConnectionStatus;
+    };
+
+
+
+#endif      // CONSUMEDATA_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/inc/DRMHelperDMgrWrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,180 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+#ifndef CDRMHELPERDMGRWRAPPER_H
+#define CDRMHELPERDMGRWRAPPER_H
+
+#include <DownloadMgrClient.h>
+#include <aknprogressdialog.h>
+#include <eikprogi.h>
+
+/**
+* Environment gate function
+*
+* @since S60 3.1
+* @return pointer to DMgr handler
+*/
+IMPORT_C TAny* GateFunctionDMgr();
+
+class MDRMHelperDMgrWrapper
+    {
+
+public:
+    virtual void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl ) = 0;
+
+    virtual void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl,
+                                                CCoeEnv& aCoeEnv ) = 0;
+
+    virtual HBufC8* GetErrorUrlL() = 0;
+
+    };
+
+/**
+*  Class for downloading ROAP triggers
+*
+*  @lib DRMHelperDMgrWrapper
+*  @since S60 v3.1
+*/
+class CDRMHelperDMgrWrapper : CBase,
+                              public MHttpDownloadMgrObserver,
+                              public MDRMHelperDMgrWrapper,
+                              public MProgressDialogCallback
+    {
+
+public:
+
+    static CDRMHelperDMgrWrapper* NewL();
+
+    static CDRMHelperDMgrWrapper* NewLC();
+
+    virtual ~CDRMHelperDMgrWrapper();
+
+    /**
+    * Download a ROAP trigger from URL and handle it
+    *
+    * @since S60 3.1
+    * @param aUrl  URL of ROAP trigger
+    */
+    void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl );
+
+    void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl, CCoeEnv& aCoeEnv );
+
+    HBufC8* GetErrorUrlL();
+
+
+// from base class MHttpDownloadMgrObserver
+
+    /**
+    * From MHttpDownloadMgrObserver.
+    * Handle download manager events
+    *
+    * @since S60 3.1
+    * @param aDownload the download
+    * @param aEvent the event
+    */
+    void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent );
+
+public: // Call back methods of MAknProgressDialogCallback
+
+    /**
+    * ProgressDialog call back method.
+    * Get's called when a dialog is dismissed.
+    *
+    * @since S60 3.2
+    * @param aButtonId ID of the button pressed
+    */
+    void DialogDismissedL( TInt aButtonId );
+
+protected:
+
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CDRMHelperDMgrWrapper();
+
+    void ConstructL();
+
+    /**
+    * Set the browser default access point to be used
+    *
+    * @since S60 3.0
+    */
+    void SetDefaultAccessPointL();
+
+    void DoDownloadAndHandleRoapTriggerL( const HBufC8* aUrl );
+
+    void ShowProgressNoteL( );
+
+    void RemoveProgressNoteL( );
+
+    void HandlePostResponseUrlL();
+
+
+private: // data
+
+    /**
+    * Download manager session
+    */
+    RHttpDownloadMgr iDlMgr;
+
+    /**
+    * Used to make downloads synchronous
+    */
+    CActiveSchedulerWait iWait;
+
+    /**
+    * to store information on download
+    */
+    TBool iDownloadSuccess;
+    TBool iConnectionError;
+
+    TBool iDialogDismissed;
+
+    /**
+    * Progess note dialog and progress info
+    */
+    CAknProgressDialog* iProgressNoteDialog;        // owned
+    CEikProgressInfo* iProgressInfo;                // not owned
+    TInt iCurrentProgressValue;                     // owned
+    TInt iProgressIncrement;                        // owned
+
+    /**
+    * Control environment
+    */
+    CCoeEnv* iCoeEnv;
+
+    /**
+    * Is CoeEnv given
+    */
+    TBool iUseCoeEnv;
+
+    /**
+    * Error url for ROAP temporary error
+    */
+    HBufC8* iErrorUrl;
+
+    /**
+    * Post response url for ROAP prUrl
+    */
+    HBufC8* iPostResponseUrl;
+
+    };
+
+#endif // CDRMHELPERDMGRWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/inc/DRMHelperDMgrWrapperLogger.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,216 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Logger utility.
+*
+*/
+
+
+#ifndef DRMUILOGGER_H
+#define DRMUILOGGER_H
+
+
+// INCLUDES
+
+#include <e32std.h>
+#include <e32def.h>
+#include <eikenv.h>
+#include <flogger.h>
+
+
+#ifdef _DEBUG
+#define __TEST_DRM_LOG__
+#endif // _DEBUG
+
+
+#ifdef __TEST_DRM_LOG__
+
+// CONSTANTS
+
+// DRMUI logging directory.
+_LIT( KDRMUILogDir,                   "DRMUI" );
+// DRMUI log file name.
+_LIT( KDRMUILogFile,                  "DMgrWrapper.log" );
+// Format string: enter function.
+_LIT( KDRMUILogEnterFn,               "-> %S" );
+// Format string: leave function.
+_LIT( KDRMUILogLeaveFn,               "<- %S" );
+// Format string: time.
+_LIT( KDRMUILogTimeFormatString,      "%H:%T:%S:%*C2" );
+// Format string: timestamp.
+_LIT( KDRMUILogTimeStampFormatString, "%S %S" );
+//Banner message
+_LIT( KDRMUILogBanner,                "DRMUI 3.2");
+// Message of exit from app
+_LIT( KDRMUILogExit,                  "DRMUI: Application exit");
+
+// DEFINES
+
+// Create the log
+#define CLOG_CREATE                 { FCreate(); }
+
+// Close the log
+#define CLOG_CLOSE                  \
+    {                               \
+    RFileLogger::Write              \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        KDRMUILogExit               \
+        );                          \
+    }
+
+// Write log: enter function.
+#define CLOG_ENTERFN( a )           \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::WriteFormat        \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        KDRMUILogEnterFn,           \
+        &temp                       \
+        );                          \
+    }
+
+// Write log: leave function.
+#define CLOG_LEAVEFN( a )           \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::WriteFormat        \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        KDRMUILogLeaveFn,           \
+        &temp                       \
+        );                          \
+    }
+
+// Write log: string 'a'.
+#define CLOG_WRITE( a )             \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::Write              \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        temp                        \
+        );                          \
+    }
+
+// Write log: formatted.
+#define CLOG_WRITE_FORMAT( a, b )   \
+    {                               \
+    _LIT( temp, a );                \
+    RFileLogger::WriteFormat        \
+        (                           \
+        KDRMUILogDir,               \
+        KDRMUILogFile,              \
+        EFileLoggingModeAppend,     \
+        temp,                       \
+        b                           \
+        );                          \
+    }
+
+// Write log: timestamp.
+#define CLOG_WRITE_TIMESTAMP( a )                                   \
+    {                                                               \
+    _LIT( temp, a );                                                \
+    TTime time;                                                     \
+    time.HomeTime();                                                \
+    TBuf<32> timeBuf;                                               \
+    TRAPD( err, time.FormatL( timeBuf, KDRMUILogTimeFormatString ) ); \
+    if ( !err )                                                     \
+        {                                                           \
+        RFileLogger::WriteFormat                                    \
+            (                                                       \
+            KDRMUILogDir,                                           \
+            KDRMUILogFile,                                          \
+            EFileLoggingModeAppend,                                 \
+            KDRMUILogTimeStampFormatString,                         \
+            &temp,                                                  \
+            &timeBuf                                                \
+            );                                                      \
+        }                                                           \
+    }
+
+// Write formatted
+#define CLOG_WRITEF                 FPrint
+
+
+inline void FPrint( const TRefByValue<const TDesC> aFmt, ... )
+    {
+    VA_LIST list;
+    VA_START( list, aFmt );
+    RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, 
+                              EFileLoggingModeAppend, aFmt, list );
+    }
+
+
+inline void FPrint( const TDesC& aDes )
+    {
+    RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, 
+                              EFileLoggingModeAppend, aDes );
+    }
+
+
+inline void FCreate()
+    {
+    TFileName path( _L( "c:\\logs\\" ) );
+    path.Append( KDRMUILogDir );
+    path.Append( _L( "\\" ) );
+    RFs& fs = CEikonEnv::Static()->FsSession();
+    fs.MkDirAll( path );
+    RFileLogger::WriteFormat( KDRMUILogDir, KDRMUILogFile, 
+                              EFileLoggingModeOverwrite, KDRMUILogBanner );
+    }
+
+
+#else // not defined __TEST_DRM_LOG__
+
+inline void FPrint( const TRefByValue<const TDesC> /*aFmt*/, ... ) {};
+
+
+// DEFINES
+
+// Empty definition (disable log).
+#define CLOG_CREATE
+
+// Empty definition (disable log).
+#define CLOG_CLOSE
+
+// Empty definition (disable log).
+#define CLOG_ENTERFN( a )
+
+// Empty definition (disable log).
+#define CLOG_LEAVEFN( a )
+
+// Empty definition (disable log).
+#define CLOG_WRITE( a )
+
+// Empty definition (disable log).
+#define CLOG_WRITE_FORMAT( a, b )
+
+// Empty definition (disable log).
+#define CLOG_WRITE_TIMESTAMP( a )
+
+// Empty definition (disable log).
+#define CCDLGLOGGER_WRITEF   1 ? ((void)0) : FPrint
+
+#endif // __TEST_DRM_LOG__
+
+#endif // DRMUILOGGER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/inc/DRMHelperDownloadManager.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2004-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:  DRMHelperDownloadManager declaration
+*
+*/
+
+
+#ifndef CDRMHELPERDOWNLOADMANAGER_H
+#define CDRMHELPERDOWNLOADMANAGER_H
+
+#include <e32base.h>
+#include <ConeResLoader.h>
+
+class CDRMHelperDMgrWrapper;
+
+/**
+ *  This class encapsulates Download manager functionality.
+ *
+ *  @lib DrmHelper.lib
+ *  @since S60 3.0
+ */
+NONSHARABLE_CLASS(CDrmHelperDownloadManager) : public CBase
+    {
+public:
+    
+    static CDrmHelperDownloadManager* NewL();
+    virtual ~CDrmHelperDownloadManager();
+
+    /**
+     * Download a ROAP trigger from URL and handle it
+     *
+     * @since S60 3.0
+     * @param aUrl URL to be downloaded
+     */
+    void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl, CCoeEnv& aCoeEnv );
+
+    void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl );
+    
+    HBufC8* GetErrorUrlL();
+
+
+protected:
+            
+private:
+
+    CDrmHelperDownloadManager();
+    void ConstructL();
+
+private:
+
+    /**
+	 * Download manager handler
+	 */
+    RLibrary iDMgrDll;
+    CDRMHelperDMgrWrapper* iDMgrHandler;
+    };
+
+#endif      // CDRMHELPERDOWNLOADMANAGER_H   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/inc/DRMHelperGlobalNoteWrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,174 @@
+/*
+* Copyright (c) 2004 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Synchronous wrapper for showing global notes
+*
+*/
+
+
+
+#ifndef __DRMHELPERGLOBALNOTEWRAPPER_H__
+#define __DRMHELPERGLOBALNOTEWRAPPER_H__
+
+//  INCLUDES
+#include <e32base.h>
+#include <StringResourceReader.h>
+
+// CONSTANTS
+const TInt KDRMNoteBufferMaxSize ( 256 );
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  Wrapper class for displaying global notes.
+*
+*  @lib drmhelper.lib
+*  @since Series 60 2.6
+*/
+class CDRMHelperGlobalNoteWrapper : public CActive
+    {
+public:  // Constructors and destructor
+
+    /**
+    * Two-phased constructor.
+    */
+    static CDRMHelperGlobalNoteWrapper* NewL(
+        CStringResourceReader* aResourceReader );
+
+    static CDRMHelperGlobalNoteWrapper* NewLC(
+        CStringResourceReader* aResourceReader );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CDRMHelperGlobalNoteWrapper();
+
+public: // New functions
+
+    /**
+    * Synchronous wrapper for showing global note.
+    * @param aTextResourceId resource id of string to be displayed
+    * @param aButtonsId resource id of buttons of note
+    * @return mapped button code
+    * @see MappedButtonId
+    */
+    TInt ShowNoteWithButtonsL( TInt aResourceId, TInt aButtonsId );
+
+    /**
+    * Synchronous wrapper for showing global note.
+    * @param aTextResourceId resource id of string to be displayed
+    * @param aButtonsId resource id of buttons of note
+    * @param aString string which replaces %U in resource string
+    * @return mapped button code
+    * @see MappedButtonId
+    */
+    TInt ShowNoteWithButtonsL( TInt aResourceId, TInt aButtonsId,
+        const TDesC& aString );
+
+    /**
+    * Synchronous wrapper for showing global note.
+    * @param aTextResourceId resource id of string to be displayed
+    * @param aValue integer that replaces %N in resource string
+    * @return mapped button code
+    * @see MappedButtonId
+    */
+    TInt ShowNoteL( TInt aResourceId, TInt aValue );
+
+    /**
+    * Synchronous wrapper for showing global note.
+    * @param aTextResourceId resource id of string to be displayed
+    * @param aString string that replaces %U in resource string
+    * @return mapped button code
+    * @see MappedButtonId
+    */
+    TInt ShowNoteL( TInt aResourceId, const TDesC& aString );
+
+    /**
+    * Synchronous wrapper for showing global note.
+    * @param aTextResourceId resource id of string to be displayed
+    * @param aString string that replaces %U in resource string
+    * @param aValue integer that replaces %N in resource string
+    * @return mapped button code
+    * @see MappedButtonId
+    */
+    TInt ShowNoteL(
+        TInt aResourceId,
+        const TDesC& aString,
+        TInt aValue,
+        TInt aStringPos = -1,
+        TInt aValuePos = -1 );
+
+private: // From CActive
+
+    void DoCancel();
+    void RunL();
+
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CDRMHelperGlobalNoteWrapper();
+
+    /**
+    * By default Symbian 2nd phase constructor is private.
+    */
+    void ConstructL( CStringResourceReader* aResourceReader );
+
+    /**
+    * Do actual displaying of note
+    */
+    TInt DoShowNoteL(TInt aResourceId, const TDesC& aString = KNullDesC,
+        TInt aValue = -1 );
+    /**
+    * @name MappedButtonId
+    * @param aButtonId, raw button id
+    *
+    * @return aButtonId for positive answers ( like EAknSoftkeyOk )
+    *     0 for negative answers ( like EAknSoftkeyCancel, EAknSoftkeyNo )
+    *
+    * @note borrowed from CEikDialog::MappedCommandId
+    *
+    * @see CEikDialog::MappedCommandId
+    */
+    TInt MappedButtonId( TInt aButtonId ) const;
+
+private:    // Data
+
+    // Used to make asynchronous call synchronous
+    CActiveSchedulerWait    iWait;
+
+    // Text buffer used with global notes. Can contain max
+    // KTextBufferMaxSize long string + filename.
+    TBuf<KDRMNoteBufferMaxSize + KMaxFileName> iTextBuffer;
+
+    // used to read resources
+    CStringResourceReader* iResourceReader;
+
+    // Resource id of buttons in confirmation query
+    TInt iButtonsId;
+    };
+
+
+#endif      // __DRMHelperGlobalNoteWrapper_H__
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/inc/DRMHelperInfoNoteWrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,111 @@
+/*
+* 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:  Synchronous wrapper for showing global notes
+*
+*/
+
+
+
+#ifndef __DRMHELPERINFONOTEWRAPPER_H__
+#define __DRMHELPERINFONOTEWRAPPER_H__
+
+//  INCLUDES
+#include <e32base.h>
+#include <aknglobalnote.h>
+// CONSTANTS
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+*  Wrapper class for displaying global notes.
+*
+*  @lib drmhelper.lib
+*  @since Series 60 2.6
+*/
+NONSHARABLE_CLASS ( CDRMHelperInfoNoteWrapper ) : public CActive
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CDRMHelperInfoNoteWrapper* NewL();
+        
+        static CDRMHelperInfoNoteWrapper* NewLC();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CDRMHelperInfoNoteWrapper();
+
+    public: // New functions
+
+
+        /**
+        * Synchronous wrapper for showing global note.
+        * @param aType type of Info note to be displayed
+        * @param aNoteText string containing note text       
+        * @param aResource resource identifier
+        * @param aString is transferred for CoverUi string data     
+        * @param aValue is transferred for CoverUi numerical data
+        * @return button code
+        */
+        void ShowNoteL(  TAknGlobalNoteType aType, 
+                         const TDesC& aNoteText,
+                         TInt aResourceId = -1, 
+                         const TDesC& aString = KNullDesC,
+                         TInt aValue = -1 );
+
+        /**
+        * Synchronous wrapper for showing global note.
+        * @param[inout] aResourceId takes primary display
+        *               resource ID and returns CoverUiId     
+        * @return       boolean if ID was valid CoverUiId
+        */
+        static TBool EvaluateCoverResourceId( TInt& aResourceId );
+    
+    private: // From CActive
+    
+    	void DoCancel();
+    	void RunL();
+        
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CDRMHelperInfoNoteWrapper();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();        
+       
+    private:    // Data
+        CAknGlobalNote* iNote; 
+    };
+
+
+#endif      // __DRMHELPERINFONOTEWRAPPER_H__   
+            
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/src/ConsumeData.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,146 @@
+/*
+* 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:  Implements consume data encapsulation
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "consumedata.h"
+
+// LOCAL CONSTANTS AND MACROS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CConsumeData::ConsumeData
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CConsumeData::CConsumeData() : CBase()
+    {
+    }
+    
+// -----------------------------------------------------------------------------
+// CConsumeData::~ConsumeData
+// C++ default destructor
+// -----------------------------------------------------------------------------
+//    
+CConsumeData::~CConsumeData()
+    {
+    // If the connection is still open call finish
+    if( iConnectionStatus && iContentURI8 ) 
+        {
+        iRdb.Consume( ContentAccess::EStop, *iContentURI8 );    
+        }
+    
+    // Close the connection to the server:
+    iRdb.Close();
+    
+    // Reset the connection status
+    iConnectionStatus = EFalse;
+        
+    // Delete the content id
+    if( iContentURI8 )
+        {
+        delete iContentURI8;
+        iContentURI8 = NULL;    
+        }
+    }
+    
+
+// -----------------------------------------------------------------------------
+// CConsumeData::NewLC
+// 2-phase constructor
+// -----------------------------------------------------------------------------
+//
+CConsumeData* CConsumeData::NewLC( const TDesC8& aUri )
+    {
+    CConsumeData* self = new (ELeave) CConsumeData();
+    CleanupStack::PushL( self );
+    self->ConstructL( aUri );
+    return self;
+    }
+    
+// -----------------------------------------------------------------------------
+// CConsumeData::NewL
+// 2-phase constructor
+// -----------------------------------------------------------------------------
+//
+CConsumeData* CConsumeData::NewL( const TDesC8& aUri )
+    {
+    CConsumeData* self = NewLC( aUri );
+    CleanupStack::Pop( self );
+    return self;        
+    }    
+
+// -----------------------------------------------------------------------------
+// CConsumeData::Consume
+// -----------------------------------------------------------------------------
+//
+TInt CConsumeData::Consume( const ContentAccess::TIntent& aIntent )
+    {
+    TInt retVal = KErrNone;
+    
+    if( !iConnectionStatus )
+        {
+        return KErrNotReady;    
+        }
+        
+    retVal = iRdb.Consume( aIntent, *iContentURI8 );
+
+    if( aIntent == ContentAccess::EStop )
+        {
+        iRdb.Close();
+        iConnectionStatus = EFalse;    
+        }
+        
+    return retVal;    
+    }
+// -----------------------------------------------------------------------------
+// CConsumeData::CompareUri
+// -----------------------------------------------------------------------------
+//
+TInt CConsumeData::CompareUri( const TDesC8& aUri ) const
+    {
+    if( !iContentURI8 )
+        {
+        return KErrNotReady;    
+        }
+        
+    return iContentURI8->Des().Compare( aUri );
+    }
+
+// -----------------------------------------------------------------------------
+// CConsumeData::ConstructL
+// 2nd phase constructor
+// -----------------------------------------------------------------------------
+//
+void CConsumeData::ConstructL( const TDesC8& aUri )
+    {
+    // Connect the rights client
+    User::LeaveIfError( iRdb.Connect() );
+
+    // Set the connection status
+    iConnectionStatus = ETrue;
+    
+    // copy the url for internal use
+    iContentURI8 = aUri.AllocL();    
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/src/DRMHelperClient.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,613 @@
+/*
+* Copyright (c) 2004-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:  Implementation of the Helper Client session functionality 
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32math.h>
+#include <drmcommon.h>
+#include "DRMHelperCommon.h"
+#include "DRMHelperClient.h"
+
+
+// LOCAL CONSTANTS AND MACROS
+// Number of message slots to reserve for this client server session.
+// Since we only communicate synchronously here, we never have any
+// outstanding asynchronous requests.
+LOCAL_C const TUint KDefaultMessageSlots = 0;
+LOCAL_C const TUid KServerUid3 = {0x101F6DC5};
+
+#ifdef __WINS__
+LOCAL_C const TUint KServerMinHeapSize =  0x1000;  //  4K
+LOCAL_C const TUint KServerMaxHeapSize = 0x10000;  // 64K
+#endif
+
+// ============================ LOCAL FUNCTIONS ===============================
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs );
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName );
+LOCAL_C void CreateLogL();
+LOCAL_C void WriteL( const TDesC& aText );
+LOCAL_C void WriteL( const TDesC8& aText );
+LOCAL_C void WriteCurrentTimeL();
+#endif
+
+
+LOCAL_C TInt FromFileNameToUri(const TDesC16& aFileName , HBufC8*& aContentUri );
+LOCAL_C TInt CheckExpiration( const TDesC8& aUri , TTime& aEndTime , TInt& aCountLeft );
+LOCAL_C TInt StartServer();
+LOCAL_C TInt CreateServerProcess();
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::RDRMHelperClient
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C RDRMHelperClient::RDRMHelperClient()
+:   RSessionBase()
+    {
+    // No implementation required
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::Connect
+// 
+// Connect to the server session
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMHelperClient::Connect()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , CreateLogL() );
+    if (err)
+        {
+        return err;
+        }
+    TRAP( err , WriteL(_L("Connect")) );
+    if (err)
+        {
+        return err;
+        }
+    TRAP( err , WriteCurrentTimeL() );
+    if (err)
+        {
+        return err;
+        }
+#endif
+    TInt error = StartServer();
+
+    if (KErrNone == error)
+        {
+
+        error = CreateSession(KDRMHelperServerName,
+                              Version(),
+                              KDefaultMessageSlots);
+        }
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::Version
+// 
+// return server version
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TVersion RDRMHelperClient::Version() const
+    {
+    return(TVersion(KDRMHSMajorVersionNumber,
+                    KDRMHSMinorVersionNumber,
+                    KDRMHSBuildVersionNumber));
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::SetAutomated
+// 
+// Register one content uri to the helper server
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMHelperClient::SetAutomated( const TDesC8& aUri , const TInt& aType ) const
+    {
+    TInt temp = aType;
+    TPtrC8 descriptor(aUri);
+
+    // This call waits for the server to complete the request before 
+    // proceeding. 
+    return SendReceive(ERegister, TIpcArgs( &descriptor, temp ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::SetAutomated
+// 
+// Register one file to the helper server
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMHelperClient::SetAutomated( const TDesC16& aFileName , const TInt& aType ) const
+    {
+    TInt temp = aType;
+    TPtrC8 descriptor( NULL , 0 );
+   
+    descriptor.Set( reinterpret_cast<const TUint8*>( aFileName.Ptr() ), aFileName.Length()*2);
+
+    // This call waits for the server to complete the request before 
+    // proceeding. 
+    return SendReceive(ERegisterFile, TIpcArgs( &descriptor, temp ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::RemoveAutomated
+// 
+// Register one content uri to the helper server
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMHelperClient::RemoveAutomated( const TDesC8& aUri , const TInt& aType ) const
+    {
+    TInt temp = aType;
+    TPtrC8 descriptor(aUri);
+
+    // This call waits for the server to complete the request before 
+    // proceeding.
+    return SendReceive(ERemove, TIpcArgs( &descriptor, temp ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::RemoveAutomated
+// 
+// Register one file to the helper server
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMHelperClient::RemoveAutomated( const TDesC16& aFileName , const TInt& aType ) const
+    {
+    TInt temp = aType;
+    TPtrC8 descriptor( NULL , 0 );
+
+    descriptor.Set( reinterpret_cast<const TUint8*>( aFileName.Ptr() ), aFileName.Length()*2);
+
+    // This call waits for the server to complete the request before 
+    // proceeding. 
+    return SendReceive(ERemoveFile, TIpcArgs( &descriptor ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::IndicateIdle
+// 
+// Register one file to the helper server
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMHelperClient::IndicateIdle() const
+    {
+    return SendReceive(EIndicateIdle, TIpcArgs());
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::CanSetAutomated
+// 
+// Register one content uri to the helper server
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMHelperClient::CanSetAutomated( const TDesC8& aUri , TBool& aValue ) const
+    {
+    TTime endTime;
+    TTime temp;
+    TInt countsLeft = 0;
+    TInt err = 0;
+    temp.Set( KNullDate );
+    endTime.Set( KNullDate );
+
+    err = CheckExpiration( aUri , endTime , countsLeft );
+    if ( endTime != temp )
+        {
+        aValue = ETrue;
+        }
+    else
+        {
+        aValue = EFalse;
+        }
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::CanSetAutomated
+// 
+// Register one file to the helper server
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMHelperClient::CanSetAutomated( const TDesC16& aFileName , TBool& aValue ) const
+    {
+    HBufC8* contentUri = NULL;
+    TInt err = 0;
+    err = FromFileNameToUri( aFileName , contentUri );
+    if (err)
+        {
+        return err;
+        }
+    err = CanSetAutomated( contentUri->Des() , aValue );
+    delete contentUri;
+    return err;
+    }
+
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::IsAutomated
+// 
+// Register one content uri to the helper server
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMHelperClient::IsAutomated( const TDesC8& aUri , TInt& aType , TBool& aIs ) 
+    {
+    TPtr8 type( reinterpret_cast< TUint8* >( &aType ),
+               0, 
+               sizeof( TInt ) );
+    TPtr8 flag( reinterpret_cast< TUint8* >( &aIs ),
+               0, 
+               sizeof( TInt ) );
+
+    TPtrC8 descriptor(aUri);
+
+    // This call waits for the server to complete the request before 
+    // proceeding. 
+    return SendReceive(EIsRegistered, TIpcArgs( &type, &descriptor, &flag ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelperClient::IsAutomated
+// 
+// Register one file to the helper server
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt RDRMHelperClient::IsAutomated( const TDesC16& aFileName , TInt& aType , TBool& aIs ) 
+    {
+    TPtr8 type( reinterpret_cast< TUint8* >( &aType ),
+               0, 
+               sizeof( TInt ) );
+    TPtr8 flag( reinterpret_cast< TUint8* >( &aIs ),
+               0, 
+               sizeof( TInt ) );
+
+    TPtrC8 descriptor( NULL , 0 );
+
+    
+    descriptor.Set( reinterpret_cast<const TUint8*>( aFileName.Ptr() ), aFileName.Length()*2);
+
+    // This call waits for the server to complete the request before 
+    // proceeding. 
+    return SendReceive(EIsRegisteredFile, TIpcArgs( &type, &descriptor, &flag ) );
+
+    }
+
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// StartServer
+// 
+// Start the helper server
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TInt StartServer()
+    {
+
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("StartServer")) );
+    if (err)
+        {
+        return err;
+        }
+    TRAP( err , WriteCurrentTimeL() );
+    if (err)
+        {
+        return err;
+        }
+#endif
+    TInt result = 0;
+
+    TFindServer findHelperServer(KDRMHelperServerName);
+    TFullName name;
+
+    result = findHelperServer.Next(name);
+    if (result == KErrNone)
+        {
+        // Server already running
+        return KErrNone;
+        }
+
+    RSemaphore semaphore;       
+    result = semaphore.CreateGlobal(KDRMHelperServerSemaphoreName, 0);
+    if (result != KErrNone)
+        {
+        return  result;
+        }
+
+    result = CreateServerProcess();
+    if (result != KErrNone)
+        {
+        semaphore.Close(); 
+        return  result;
+        }
+
+    semaphore.Wait();
+    semaphore.Close();       
+
+    return  KErrNone;
+    }
+
+LOCAL_C TInt CreateServerProcess()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( err , WriteL(_L("CreateServerProcess")) );
+    if (err)
+        {
+        return err;
+        }
+    TRAP( err , WriteCurrentTimeL() );
+    if (err)
+        {
+        return err;
+        }
+#endif
+    TInt result;
+
+    const TUidType serverUid(KNullUid, KNullUid, KServerUid3);
+
+#ifdef __WINS__
+
+    RLibrary lib;
+    result = lib.Load( KDRMHSServerFileName , serverUid );
+    if (result != KErrNone)
+        {
+        return  result;
+        }
+
+#ifdef _DRM_TESTING
+    TRAP( err , WriteL(_L("library is loaded")) );
+    if (err)
+        {
+        return err;
+        }
+    TRAP( err , WriteCurrentTimeL() );
+    if (err)
+        {
+        return err;
+        }
+#endif
+
+    //  Get the WinsMain function
+    TLibraryFunction functionWinsMain = lib.Lookup(1);
+
+    //  Call it and cast the result to a thread function
+    TThreadFunction serverThreadFunction = reinterpret_cast<TThreadFunction>(functionWinsMain());
+
+    TName threadName(KDRMHelperServerName);
+
+    // Append a random number to make it unique
+    threadName.AppendNum(Math::Random(), EHex);
+
+    RThread server;
+
+    result = server.Create(threadName,   // create new server thread
+                             serverThreadFunction, // thread's main function
+                             KDefaultStackSize,
+                             NULL,
+                             &lib,
+                             NULL,
+                             KServerMinHeapSize,
+                             KServerMaxHeapSize,
+                             EOwnerProcess);
+
+
+
+    lib.Close();    // if successful, server thread has handle to library now
+
+    if (result != KErrNone)
+        {
+        return  result;
+        }
+#ifdef _DRM_TESTING
+    TRAP( err , WriteL(_L("server thread is created")) );
+    if (err)
+        {
+        return err;
+        }
+    TRAP( err , WriteCurrentTimeL() );
+    if (err)
+        {
+        return err;
+        }
+#endif
+    server.SetPriority(EPriorityMore);
+
+
+#else
+
+    RProcess server;
+    result = server.Create( KDRMHSServerFileName, KNullDesC, serverUid);
+    if (result != KErrNone)
+        {
+        return  result;
+        }
+#ifdef _DRM_TESTING
+    TRAP( err , WriteL(_L("server thread is created")) );
+    if (err)
+        {
+        return err;
+        }
+    TRAP( err , WriteCurrentTimeL() );
+    if (err)
+        {
+        return err;
+        }
+#endif
+
+#endif
+
+    server.Resume();
+    server.Close();
+
+    return  KErrNone;
+    }
+
+LOCAL_C TInt FromFileNameToUri(const TDesC16& aFileName , HBufC8*& aContentUri )
+    {
+    DRMAuthenticated* c = NULL;
+    DRMCommon::TContentProtection protection;
+    HBufC8* mimeType = NULL;
+    TUint dataLen = 0;
+    TRAPD(err , c = DRMAuthenticated::NewL());
+    if (err)
+        {
+        return err;
+        }
+    err = c->GetFileInfo(
+        aFileName,
+        protection,
+        mimeType,
+        aContentUri,
+        dataLen);
+    delete mimeType;
+    if (err)
+        {
+        delete aContentUri;
+        aContentUri = NULL;
+        }
+    return err;
+    }
+
+
+LOCAL_C TInt CheckExpiration( const TDesC8& aUri , TTime& aEndTime , TInt& aCountLeft )
+    {
+    DRMAuthenticated* c = NULL;
+    CDRMRights* right = NULL;
+    TRAPD( err  , c = DRMAuthenticated::NewL() );
+    if (err)
+        {
+        return err;
+        }
+    err = c->GetActiveRights( aUri , 
+        DRMCommon::EPlay | DRMCommon::EExecute | DRMCommon::EPrint | DRMCommon::EDisplay , 
+        right );
+    if (!err)
+        {
+        err = right->GetExpirationDetails(
+            DRMCommon::EPlay | DRMCommon::EExecute | DRMCommon::EPrint | DRMCommon::EDisplay,
+            aEndTime,
+            aCountLeft);
+        }
+    delete right;
+    delete c;
+    return err;
+    }
+
+#ifdef _DRM_TESTING
+
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
+    {
+    _LIT( KLogFile , "c:\\HSClientLog.txt" );
+    WriteFileL( text , aFs , KLogFile );
+    }
+
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
+    {
+    RFile file;
+    TInt size;
+    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy(); //file
+    }
+
+LOCAL_C void CreateLogL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    User::LeaveIfError( file.Replace( fs , _L("c:\\HSClientLog.txt") , EFileWrite ) );
+    file.Close();
+    CleanupStack::PopAndDestroy(); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L("\r\n") );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8("\r\n") );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(); //fs
+    }
+
+
+LOCAL_C void WriteCurrentTimeL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+// Date and Time display
+    TTime time;
+    time.HomeTime();
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    time.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    time.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(); //fs
+    }
+#endif
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// Epoc DLL entry point, return that everything is ok
+GLDEF_C TInt E32Dll(TDllReason)
+    {
+    return KErrNone;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/src/DRMHelperDMgrWrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,723 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Dynamically loadable wrapper for Download manager
+*
+*/
+
+#include <centralrepository.h>
+#include <cdblen.h>
+
+#include <cmconnectionmethod.h>
+#include <cmdestination.h>
+#include <cmconnectionmethoddef.h>
+#include <cmmanager.h>
+
+#ifdef __SERIES60_NATIVE_BROWSER
+#include <browseruisdkcrkeys.h>
+#endif
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <driveinfo.h>
+#endif
+
+#include <stringloader.h>
+#include <data_caging_path_literals.hrh>
+
+#include <coneresloader.h>
+#include <apparc.h>
+
+#include <drmhelperdmgrwrapper.rsg>
+
+#include "roapeng.h"
+#include "roapsyncwrapper.h"
+#include "roapdef.h"
+#include "drmhelperdmgrwrapper.h"
+#include "drmhelperdmgrwrapperlogger.h"
+
+// DEBUG macros
+#ifdef _DEBUG
+#define DRMDEBUGLIT( a, b ) \
+_LIT( a , b )
+#define DRMDEBUG( a ) \
+RDebug::Print( a )
+#define DRMDEBUG2( a, b ) \
+RDebug::Print( a, b )
+#else
+#define DRMDEBUGLIT( a, b )
+#define DRMDEBUG( a )
+#define DRMDEBUG2( a, b )
+#endif
+
+// CONSTANTS
+#ifndef __SERIES60_NATIVE_BROWSER
+const TUid KCRUidBrowser = {0x10008D39};
+const TUint32 KBrowserDefaultAccessPoint = 0x0000000E;
+const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
+#endif
+
+// CONSTANTS
+#ifndef RD_MULTIPLE_DRIVE
+_LIT( KDriveZ, "z:" );
+_LIT( KHelperTriggerFilePath, "d:\\" );
+#endif
+
+_LIT( KCDRMHelperDMgrWrapperResFileName,"DRMHelperDMgrWrapper.rsc" );
+const TInt KProgressInfoFinalValue( 200 );
+const TInt KProgressInfoIncrementSmall( 5 );
+const TInt KProgressInfoIncrementMedium( 10 );
+const TInt KProgressInfoIncrementLarge( 30 );
+
+// ======== LOCAL FUNCTIONS ========
+LOCAL_C void DeleteHttpDowload( TAny* aDownload )
+    {
+    reinterpret_cast< RHttpDownload* >( aDownload )->Delete();
+    }
+
+// ---------------------------------------------------------------------------
+// IapIdOfDefaultSnapL
+// for trapping purposes only
+// ---------------------------------------------------------------------------
+//
+LOCAL_C TUint32 IapIdOfDefaultSnapL(
+    RCmManager& aCmManager,
+    const TUint32 aDefaultSnap )
+    {
+    RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) );
+    CleanupClosePushL( dest );
+    TUint32 iapIdOfDest( 0 );
+
+    if ( dest.ConnectionMethodCount() <= 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
+    CleanupClosePushL( cMeth );
+
+    iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId );
+    CleanupStack::PopAndDestroy( &cMeth );
+    CleanupStack::PopAndDestroy( &dest );
+    return iapIdOfDest;
+    }
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::CDRMHelperDMgrWrapper
+// ---------------------------------------------------------------------------
+//
+CDRMHelperDMgrWrapper::CDRMHelperDMgrWrapper() :
+    iUseCoeEnv( EFalse )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CDRMHelperDMgrWrapper::ConstructL()
+    {
+    CLOG_WRITE( "DMgrWrapper::ConstructL" );
+    const TInt KDrmHelperDMgrWrapperUid = 0x102823D9;
+    iDlMgr.ConnectL( TUid::Uid(KDrmHelperDMgrWrapperUid), *this, EFalse );
+    iProgressInfo = NULL;
+    iProgressNoteDialog = NULL;
+    iDialogDismissed = ETrue;
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::NewL
+// ---------------------------------------------------------------------------
+//
+CDRMHelperDMgrWrapper* CDRMHelperDMgrWrapper::NewL()
+    {
+    CLOG_WRITE( "DMgrWrapper::NewL" );
+    CDRMHelperDMgrWrapper* self( CDRMHelperDMgrWrapper::NewLC() );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::NewLC
+// ---------------------------------------------------------------------------
+//
+CDRMHelperDMgrWrapper* CDRMHelperDMgrWrapper::NewLC()
+    {
+    CLOG_WRITE( "DMgrWrapper::NewLC" );
+    CDRMHelperDMgrWrapper* self( new( ELeave ) CDRMHelperDMgrWrapper() );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::~CDRMHelperDMgrWrapper
+// ---------------------------------------------------------------------------
+//
+CDRMHelperDMgrWrapper::~CDRMHelperDMgrWrapper()
+    {
+    CLOG_WRITE( "DMgrWrapper destructor" );
+    if ( iProgressNoteDialog )
+       {
+       // deletes the dialog
+       TRAPD( err, iProgressNoteDialog->ProcessFinishedL() );
+       if ( err )
+           {
+           delete iProgressNoteDialog;
+           }
+       iProgressNoteDialog = NULL;
+       }
+    delete iErrorUrl;
+    delete iPostResponseUrl;
+
+#ifdef _DEBUG
+
+    if ( iDlMgr.Handle() )
+        {
+        iDlMgr.Close();
+        }
+
+#else
+
+    iDlMgr.Close();
+
+#endif
+
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::DownloadAndHandleRoapTriggerL
+// ---------------------------------------------------------------------------
+//
+void CDRMHelperDMgrWrapper::DownloadAndHandleRoapTriggerL( const HBufC8* aUrl )
+    {
+    CLOG_WRITE( "DMgrWrapper::DownloadAndHandleRoapTriggerL" );
+    iUseCoeEnv = EFalse;
+    DoDownloadAndHandleRoapTriggerL( aUrl );
+    HandlePostResponseUrlL();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::DownloadAndHandleRoapTriggerL
+// ---------------------------------------------------------------------------
+//
+void CDRMHelperDMgrWrapper::DownloadAndHandleRoapTriggerL(
+    const HBufC8* aUrl, CCoeEnv& aCoeEnv )
+    {
+    CLOG_WRITE( "DMgrWrapper::DownloadAndHandleRoapTriggerL" );
+    iCoeEnv = &aCoeEnv;
+    iUseCoeEnv = ETrue;
+    DoDownloadAndHandleRoapTriggerL( aUrl );
+    HandlePostResponseUrlL();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::HandlePostResponseUrlL
+// ---------------------------------------------------------------------------
+//
+void CDRMHelperDMgrWrapper::HandlePostResponseUrlL()
+    {
+    if ( iPostResponseUrl )
+        {
+        DoDownloadAndHandleRoapTriggerL( iPostResponseUrl );
+        // prevent infinite post response fetches.
+        delete iPostResponseUrl;
+        iPostResponseUrl = NULL;
+
+        // Ensure progress note gets deleted.
+        // It remains open if prUrl initialted ROAP operation has PrUrl
+        // (unsupported chained metering report)
+        RemoveProgressNoteL();
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::DoDownloadAndHandleRoapTriggerL
+// ---------------------------------------------------------------------------
+//
+void CDRMHelperDMgrWrapper::DoDownloadAndHandleRoapTriggerL(
+    const HBufC8* aUrl )
+    {
+    RFs fs;
+    RFile roapTrigger;
+    HBufC8* triggerBuf( NULL );
+    TBool result( EFalse );
+    TFileName triggerFileName;
+
+    CLOG_WRITE( "DMgrWrapper::DoDownloadAndHandleRoapTriggerL" );
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    User::LeaveIfError( fs.ShareProtected() );
+
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    User::LeaveIfError( roapTrigger.Temp(
+            fs, KHelperTriggerFilePath, triggerFileName, EFileWrite ) );
+
+#else //RD_MULTIPLE_DRIVE
+
+    _LIT( KDrive, "%c:\\");
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRam, driveNumber );
+    fs.DriveToChar( driveNumber, driveLetter );
+
+    TFileName helperTriggerFilePath;
+
+    helperTriggerFilePath.Format( KDrive, (TUint)driveLetter );
+
+    User::LeaveIfError( roapTrigger.Temp(
+            fs, helperTriggerFilePath, triggerFileName, EFileWrite ) );
+
+#endif
+
+    TPtrC8 KNullPtr8( NULL, 0 );
+    RHttpDownload* downloadPtr( iDlMgr.FindDownload( *aUrl, KNullPtr8 ) );
+    if ( downloadPtr )
+        {
+        // Stale download found.
+        // Remove it, and re-create a new download.
+        downloadPtr->Delete();
+        downloadPtr = NULL;
+        }
+
+    // create and start download
+    RHttpDownload& download = iDlMgr.CreateDownloadL( *aUrl, result );
+    // Put download for proper cleanup.
+    TCleanupItem item( DeleteHttpDowload, &download );
+    CleanupStack::PushL( item );
+
+    CleanupClosePushL( roapTrigger );
+
+    if ( !iPostResponseUrl )
+        {
+        // No post response retieval. Note must be created.
+        ShowProgressNoteL();
+        }
+
+    if ( result )
+        {
+        const TInt KReadBufSize( 512 );
+        TInt triggerFileSize( 0 );
+
+        CLOG_WRITE(
+            "DMgrWrapper::DoDownloadAndHandleRoapTriggerL: download created" );
+        iDownloadSuccess = EFalse;
+        iConnectionError = EFalse;
+
+        SetDefaultAccessPointL();
+
+        User::LeaveIfError( download.SetFileHandleAttribute( roapTrigger ) );
+        User::LeaveIfError(
+            download.SetBoolAttribute( EDlAttrNoContentTypeCheck, ETrue ) );
+        User::LeaveIfError( download.Start() );
+
+        // wait until download is finished
+        iWait.Start();
+
+        // Check success of download
+        CLOG_WRITE(
+            "DMgrWrapper::DoDownloadAndHandleRoapTriggerL: download finished" );
+
+        CleanupStack::Pop( &roapTrigger );
+        roapTrigger.Close();
+        if ( !iDownloadSuccess )
+            {
+            RemoveProgressNoteL();
+            if ( iConnectionError )
+                {
+                User::Leave( KErrCouldNotConnect );
+                }
+            else
+                {
+                User::Leave( KErrGeneral );
+                }
+            }
+        User::LeaveIfError( roapTrigger.Open( fs,
+                                              triggerFileName,
+                                              EFileShareReadersOrWriters ) );
+        CleanupClosePushL( roapTrigger );
+
+        // Get filehandle of ROAP trigger
+        // Read file to buffer
+        User::LeaveIfError( roapTrigger.Size( triggerFileSize ) );
+        triggerBuf = HBufC8::NewLC( triggerFileSize );
+
+        RBuf8 readBuf;
+        readBuf.CleanupClosePushL();
+        readBuf.CreateL( KReadBufSize );
+
+        User::LeaveIfError( roapTrigger.Read( readBuf, KReadBufSize ) );
+        triggerBuf->Des().Copy( readBuf );
+        while ( readBuf.Length() == KReadBufSize )
+            {
+            User::LeaveIfError( roapTrigger.Read( readBuf, KReadBufSize ) );
+            triggerBuf->Des().Append( readBuf );
+            }
+
+        CleanupStack::PopAndDestroy( &readBuf );
+
+        if ( iUseCoeEnv && iProgressInfo )
+            {
+            iProgressInfo->IncrementAndDraw( KProgressInfoIncrementMedium );
+            }
+
+        // And let ROAP handle it...
+        CRoapSyncWrapper* roapWrapper( CRoapSyncWrapper::NewL() );
+        CleanupStack::PushL( roapWrapper );
+        TRAPD( err, roapWrapper->HandleTriggerL( *triggerBuf ) );
+        if ( err )
+            {
+            TInt errorType( 0 );
+            TRAPD( err2, iErrorUrl =
+                roapWrapper->GetErrorUrlL( err, errorType ) );
+            if ( err2 )
+                {
+                RemoveProgressNoteL();
+                delete iErrorUrl;
+                iErrorUrl = NULL;
+                User::Leave( err2 );
+                }
+            else if ( errorType != KErrRoapTemporary )
+                {
+                RemoveProgressNoteL();
+                delete iErrorUrl;
+                iErrorUrl = NULL;
+                User::Leave( err );
+                }
+            else
+                {
+                RemoveProgressNoteL();
+                User::Leave( err );
+                }
+            }
+        if ( iPostResponseUrl )
+            {
+            delete iPostResponseUrl;
+            iPostResponseUrl = NULL;
+            }
+        iPostResponseUrl = roapWrapper->GetPostResponseUrlL();
+        CleanupStack::PopAndDestroy( 2, triggerBuf );
+
+        if ( iUseCoeEnv && iProgressInfo && !iPostResponseUrl )
+            {
+            // No PrUrl found. Progess is complete.
+            iProgressInfo->SetAndDraw( KProgressInfoFinalValue );
+            }
+        }
+
+    // Trick to keep note open long enough during prUrl retrieval
+    if ( !iPostResponseUrl )
+        {
+        RemoveProgressNoteL();
+        }
+    else
+        {
+        if ( iUseCoeEnv && iProgressInfo )
+            {
+            iProgressInfo->IncrementAndDraw( KProgressInfoIncrementMedium );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &roapTrigger );
+    CleanupStack::PopAndDestroy( &download );
+
+    fs.Delete(triggerFileName);
+    CleanupStack::PopAndDestroy(&fs);
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::SetDefaultAccessPointL
+// ---------------------------------------------------------------------------
+//
+void CDRMHelperDMgrWrapper::SetDefaultAccessPointL()
+    {
+    const TInt KDestinationSelectionMode( 2 );
+    CRepository* repository( NULL );
+    TInt ap( 0 );
+    TInt alwaysAsk( 0 );
+    TUint32 iapd32( 0 );
+    TInt defaultSnap( 0 );
+    TInt err( KErrNone );
+
+    CLOG_WRITE( "DMgrWrapper::SetDefaultAccessPointL" );
+    repository = CRepository::NewL( KCRUidBrowser );
+    CleanupStack::PushL( repository );
+    repository->Get( KBrowserDefaultAccessPoint, ap );
+    repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
+    repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
+
+    if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
+        {
+        alwaysAsk = ETrue;
+        }
+    else
+        {
+        RCmManager cmManager;
+        cmManager.OpenLC();
+        if ( !alwaysAsk )
+            {
+            TRAP( err, iapd32 = cmManager.GetConnectionMethodInfoIntL(
+                    ap, CMManager::ECmIapId ) );
+            }
+        else if ( alwaysAsk == KDestinationSelectionMode )
+            {
+            TRAP( err, iapd32 =
+                IapIdOfDefaultSnapL( cmManager, defaultSnap ) );
+            }
+        CleanupStack::PopAndDestroy( &cmManager );
+        }
+    if ( !err && ( !alwaysAsk || alwaysAsk == KDestinationSelectionMode ) )
+        {
+        err = iDlMgr.SetIntAttribute( EDlMgrIap, iapd32 );
+        }
+    CleanupStack::PopAndDestroy( repository );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::GetErrorUrlL
+// ---------------------------------------------------------------------------
+//
+HBufC8* CDRMHelperDMgrWrapper::GetErrorUrlL()
+    {
+    if( iErrorUrl )
+        {
+        return iErrorUrl->AllocL();
+        }
+    return NULL;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MHttpDownloadMgrObserver
+// ---------------------------------------------------------------------------
+//
+void CDRMHelperDMgrWrapper::HandleDMgrEventL(
+    RHttpDownload& aDownload,
+    THttpDownloadEvent aEvent )
+    {
+    _LIT8( KDRMHelperMimeTypeROAPTrigger,
+        "application/vnd.oma.drm.roap-trigger+xml" );
+
+    CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL" );
+    CLOG_WRITE_FORMAT( "iDownLoadState = %d", aEvent.iDownloadState );
+    CLOG_WRITE_FORMAT( "iProgressState = %d", aEvent.iProgressState );
+
+    if ( aEvent.iProgressState == EHttpContentTypeReceived )
+        {
+        // check received mimetype
+        RBuf8 contentType;
+        contentType.CleanupClosePushL();
+        contentType.CreateL( KMaxContentTypeLength );
+        User::LeaveIfError(
+            aDownload.GetStringAttribute( EDlAttrContentType, contentType ) );
+        if ( !contentType.FindF( KDRMHelperMimeTypeROAPTrigger ) )
+            {
+            // ROAP trigger found, continue download
+            User::LeaveIfError( aDownload.Start() );
+            }
+        else
+            {
+            // wrong MIME type, so stop download
+            iDownloadSuccess = EFalse;
+            User::LeaveIfError( aDownload.Delete() );
+            }
+        CleanupStack::PopAndDestroy( &contentType );
+        }
+
+    if ( aEvent.iDownloadState == EHttpDlCreated )
+        {
+        CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlCreated" );
+        if ( iUseCoeEnv )
+            {
+        iProgressInfo->IncrementAndDraw( KProgressInfoIncrementMedium );
+            }
+        }
+    else if ( aEvent.iProgressState == EHttpProgDisconnected )
+        {
+        CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpProgDisconnected" );
+        // store failure
+        iDownloadSuccess = EFalse;
+        iConnectionError = ETrue;
+        // finished
+        iWait.AsyncStop();
+        }
+    else if ( aEvent.iDownloadState == EHttpDlInprogress )
+        {
+        CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlInprogress" );
+        if ( iUseCoeEnv )
+            {
+        iProgressInfo->IncrementAndDraw( KProgressInfoIncrementSmall );
+            }
+        }
+    else if ( aEvent.iDownloadState == EHttpDlCompleted )
+        {
+        // store success
+        CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlCompleted" );
+        iDownloadSuccess = ETrue;
+        if ( iUseCoeEnv )
+            {
+        iProgressInfo->IncrementAndDraw( KProgressInfoIncrementLarge );
+            }
+        // finished
+        iWait.AsyncStop();
+        }
+    else if ( aEvent.iDownloadState == EHttpDlFailed )
+        {
+        TInt32 err( KErrNone );
+
+        CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EHttpDlFailed" );
+        // store failure
+        iDownloadSuccess = EFalse;
+        User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrErrorId, err ) );
+        CLOG_WRITE_FORMAT( "EDlAttrErrorId = %d", err );
+
+        if ( err == EConnectionFailed ||
+             err == ETransactionFailed)
+            {
+            CLOG_WRITE( "DMgrWrapper::HandleDMgrEventL: EConnectionFailed" );
+            iConnectionError = ETrue;
+            }
+
+        // finished
+        iWait.AsyncStop();
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::ShowProgressNoteL
+// ---------------------------------------------------------------------------
+//
+void CDRMHelperDMgrWrapper::ShowProgressNoteL( )
+    {
+    TFileName resFileName;
+
+    CLOG_WRITE( "DMgrWrapper::ShowProgressNoteL" );
+    if ( iUseCoeEnv )
+        {
+        // Initialize the progress note dialog, it's values,
+        // and execute it
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        resFileName.Copy( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDrive, "%c:");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+
+        iCoeEnv->FsSession().DriveToChar( driveNumber, driveLetter );
+
+        resFileName.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+        resFileName.Append( KDC_RESOURCE_FILES_DIR );
+        resFileName.Append( KCDRMHelperDMgrWrapperResFileName );
+        RConeResourceLoader loader( *iCoeEnv );
+        loader.OpenL( resFileName );
+
+        iProgressNoteDialog = new (ELeave) CAknProgressDialog(
+            reinterpret_cast< CEikDialog** >( &iProgressNoteDialog ) );
+        iProgressNoteDialog->PrepareLC( R_SILENT_PROGRESS_NOTE );
+        iProgressNoteDialog->SetCallback( this );
+        iProgressInfo = iProgressNoteDialog->GetProgressInfoL();
+        iProgressInfo->SetFinalValue( KProgressInfoFinalValue );
+        iDialogDismissed = EFalse;
+        iProgressNoteDialog->RunLD();
+
+        loader.Close();
+        }
+
+    }
+
+
+// ---------------------------------------------------------------------------
+// CDRMHelperDMgrWrapper::RemoveProgressNoteL
+// ---------------------------------------------------------------------------
+//
+void CDRMHelperDMgrWrapper::RemoveProgressNoteL( )
+    {
+
+    if ( iUseCoeEnv )
+        {
+        if (iProgressNoteDialog && !iDialogDismissed)
+            {
+            // deletes the dialog
+            TRAPD(err, iProgressNoteDialog->ProcessFinishedL());
+            if (err != KErrNone)
+                {
+                delete iProgressNoteDialog;
+                }
+            iProgressNoteDialog = NULL;
+            }
+        }
+
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MAknProgressDialogCallback
+// ---------------------------------------------------------------------------
+//
+void CDRMHelperDMgrWrapper::DialogDismissedL( TInt /*aButtonId*/ )
+    {
+    iDialogDismissed = ETrue;
+
+    // Already freed, just set to NULL
+    iProgressNoteDialog = NULL;
+    iProgressInfo = NULL;
+
+    if( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+
+    }
+
+
+// ======== GLOBAL FUNCTIONS ========
+
+//------------------------------------------------------------------------------
+// GateFunctionDRM
+// DRM gate function
+//------------------------------------------------------------------------------
+EXPORT_C TAny* GateFunctionDMgr()
+    {
+    CDRMHelperDMgrWrapper* launcher = NULL;
+    TRAPD( err, launcher = CDRMHelperDMgrWrapper::NewL() );
+    if( err != KErrNone )
+        {
+        return NULL;
+        }
+
+    return launcher;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/src/DRMHelperDll.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,54 @@
+/*
+* Copyright (c) 2003, 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:  Entry point of component
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// DLL entry point
+// -----------------------------------------------------------------------------
+//
+
+//  End of File  
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/src/DRMHelperDownloadManager.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,81 @@
+/*
+* Copyright (c) 2004-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:  DRMHelperDownloadManager implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include "DRMHelperDownloadManager.h"
+#include "drmhelperdmgrwrapper.h"
+
+// CONSTANTS
+_LIT( KDRMHelperDMgrHandlerName, "\\system\\libs\\drmhelperdmgrwrapper.dll" );
+
+typedef TAny* (*NewDMgrL)();
+
+const TInt KFirstFunction = 1;
+
+// ======== MEMBER FUNCTIONS ========
+
+CDrmHelperDownloadManager::CDrmHelperDownloadManager()
+    {
+    }
+
+void CDrmHelperDownloadManager::ConstructL()
+    {
+    User::LeaveIfError( iDMgrDll.Load( KDRMHelperDMgrHandlerName ) );
+    NewDMgrL createDMgr = (NewDMgrL) iDMgrDll.Lookup( KFirstFunction );
+    if ( !createDMgr )
+        {
+        User::Leave( KErrGeneral );
+        }
+    // Create the class, leaves in case of failure
+    iDMgrHandler = (CDRMHelperDMgrWrapper*) (*createDMgr)();
+    }
+
+CDrmHelperDownloadManager* CDrmHelperDownloadManager::NewL()
+    {
+    CDrmHelperDownloadManager* self = new( ELeave ) CDrmHelperDownloadManager();
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+CDrmHelperDownloadManager::~CDrmHelperDownloadManager()
+    {
+    delete iDMgrHandler;
+    iDMgrDll.Close();
+    }
+    
+void CDrmHelperDownloadManager::DownloadAndHandleRoapTriggerL(
+    const HBufC8* aUrl, CCoeEnv& aCoeEnv )
+    {
+    iDMgrHandler->DownloadAndHandleRoapTriggerL( aUrl, aCoeEnv );
+    }
+
+void CDrmHelperDownloadManager::DownloadAndHandleRoapTriggerL(
+    const HBufC8* aUrl )
+    {
+    iDMgrHandler->DownloadAndHandleRoapTriggerL( aUrl );
+    }
+
+HBufC8* CDrmHelperDownloadManager::GetErrorUrlL()
+    {
+    return iDMgrHandler->GetErrorUrlL();
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/src/DRMHelperGlobalNoteWrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,297 @@
+/*
+* Copyright (c) 2004 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of CDRMHelperGlobalNoteWrapper class
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "DRMHelperGlobalNoteWrapper.h"
+#include "DRMHelperInfoNoteWrapper.h"
+
+#include <stringloader.h>
+#include <AknGlobalConfirmationQuery.h>
+#include <avkon.hrh> // EAknSoftkeyNo
+
+#include <SecondaryDisplay/DRMHelperSecondaryDisplay.h>
+#include <aknmediatorfacade.h>
+#include <aknsddata.h>
+#include <featmgr.h>
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::CDRMHelperGlobalNoteWrapper
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperGlobalNoteWrapper::CDRMHelperGlobalNoteWrapper() : CActive( EPriorityStandard )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperGlobalNoteWrapper::ConstructL(
+    CStringResourceReader* aResourceReader )
+    {
+    iResourceReader = aResourceReader;
+    iButtonsId = R_AVKON_SOFTKEYS_YES_NO__YES;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperGlobalNoteWrapper* CDRMHelperGlobalNoteWrapper::NewLC(
+    CStringResourceReader* aResourceReader )
+    {
+    CDRMHelperGlobalNoteWrapper* self = new (ELeave) CDRMHelperGlobalNoteWrapper();
+    CleanupStack::PushL( self );
+    self->ConstructL( aResourceReader );
+    return self;
+    }
+
+CDRMHelperGlobalNoteWrapper* CDRMHelperGlobalNoteWrapper::NewL(
+    CStringResourceReader* aResourceReader )
+    {
+    CDRMHelperGlobalNoteWrapper* self = NewLC( aResourceReader );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// Destructor
+CDRMHelperGlobalNoteWrapper::~CDRMHelperGlobalNoteWrapper()
+    {
+    Cancel(); // Cancel active object
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::ShowNoteL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelperGlobalNoteWrapper::ShowNoteWithButtonsL(
+    TInt aResourceId,
+    TInt aButtonsId )
+    {
+    TInt ret;
+
+    iTextBuffer = iResourceReader->ReadResourceString( aResourceId );
+
+    iButtonsId = aButtonsId;
+    ret = DoShowNoteL( aResourceId );
+    iButtonsId = R_AVKON_SOFTKEYS_YES_NO__YES;
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::ShowNoteWithButtonsL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelperGlobalNoteWrapper::ShowNoteWithButtonsL(
+    TInt aResourceId,
+    TInt aButtonsId,
+    const TDesC& aString )
+    {
+    TInt ret;
+
+    TBuf<KDRMNoteBufferMaxSize> srcBuffer =
+        iResourceReader->ReadResourceString( aResourceId );
+
+    StringLoader::Format( iTextBuffer, srcBuffer, -1, aString );
+
+    iButtonsId = aButtonsId;
+    ret = DoShowNoteL( aResourceId, aString );
+    iButtonsId = R_AVKON_SOFTKEYS_YES_NO__YES;
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::ShowNoteL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelperGlobalNoteWrapper::ShowNoteL( TInt aResourceId, TInt aValue )
+    {
+    TBuf<KDRMNoteBufferMaxSize> srcBuffer =
+        iResourceReader->ReadResourceString( aResourceId );
+
+    StringLoader::Format( iTextBuffer, srcBuffer, -1, aValue );
+    return DoShowNoteL( aResourceId, KNullDesC, aValue );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::ShowNoteL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelperGlobalNoteWrapper::ShowNoteL(
+    TInt aResourceId,
+    const TDesC& aString )
+    {
+    TBuf<KDRMNoteBufferMaxSize> srcBuffer =
+        iResourceReader->ReadResourceString( aResourceId );
+
+    StringLoader::Format( iTextBuffer, srcBuffer, -1, aString );
+    return DoShowNoteL( aResourceId, aString );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::ShowNoteL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelperGlobalNoteWrapper::ShowNoteL(
+    TInt aResourceId,
+    const TDesC& aString,
+    TInt aValue,
+    TInt aStringPos,
+    TInt aValuePos)
+    {
+    TBuf<KDRMNoteBufferMaxSize> srcBuffer =
+        iResourceReader->ReadResourceString( aResourceId );
+
+    StringLoader::Format( iTextBuffer, srcBuffer, aValuePos, aValue );
+    srcBuffer = iTextBuffer;
+    StringLoader::Format( iTextBuffer, srcBuffer, aStringPos, aString );
+    return DoShowNoteL( aResourceId, aString, aValue );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::DoCancel
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperGlobalNoteWrapper::DoCancel()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::RunL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperGlobalNoteWrapper::RunL()
+    {
+    iWait.AsyncStop();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::DoShowNoteL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelperGlobalNoteWrapper::DoShowNoteL( TInt aResourceId,
+    const TDesC& aString, TInt aValue)
+    {
+    TPtr bufPtr( 0,0 );
+
+    RProcess myProcess;
+    TUid myProcessUid( KNullUid );
+
+    TInt animation =
+        iButtonsId == R_AVKON_SOFTKEYS_YES_NO__YES ? 0 : R_QGN_NOTE_INFO_ANIM;
+    CAknGlobalConfirmationQuery* globalNote =
+        CAknGlobalConfirmationQuery::NewLC();
+
+    bufPtr.Set( const_cast <TUint16*>( iTextBuffer.Ptr() ), iTextBuffer.Length(),
+        iTextBuffer.Length() );
+    AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+
+    if( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) &&
+        CDRMHelperInfoNoteWrapper::EvaluateCoverResourceId( aResourceId ) )
+        {
+        RThread().Process( myProcess );
+        myProcessUid = myProcess.Identity();
+
+        THelperSDData helperData;
+        helperData.iHelperUid = KUidCoverUiCategoryDRMHelper; // First field is DRMHelper's Uid
+        helperData.iHandlerProcessId = myProcessUid; // ProcessId which uses DRMHelper
+        if( aString.Compare( KNullDesC ) )
+            {
+            // If there is filename given, it's always in the PrimaryString
+            helperData.iStringParam.Append( aString );
+            }
+        if( aValue >= 0 )
+            {
+            // If there is no other than numeric data, put it as SecondaryString
+            helperData.iNumParam.AppendNum( aValue );
+            }
+
+        THelperSDDataPckg pckg( helperData );
+        CAknSDData* sd = CAknSDData::NewL( KUidCoverUiCategoryDRMHelper, aResourceId, pckg );
+        globalNote->SetSecondaryDisplayData( sd ); // ownership to notifier client
+        }
+
+    iStatus = KRequestPending;
+    globalNote->ShowConfirmationQueryL( iStatus, iTextBuffer, iButtonsId,
+        animation );
+    SetActive();
+    iWait.Start();
+    CleanupStack::PopAndDestroy( globalNote );
+    return MappedButtonId( iStatus.Int() );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperGlobalNoteWrapper::MappedButtonId
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelperGlobalNoteWrapper::MappedButtonId( TInt aButtonId ) const
+    {
+    switch ( aButtonId )
+        {
+        // Do not test for case EEikBidCancel;
+        // it is defined to be the same as EAknSoftkeyCancel
+
+        case EAknSoftkeyCancel:
+        case EAknSoftkeyBack:
+        case EAknSoftkeyNo:
+            return 0;
+
+        default:
+            break;
+        }
+
+    // Also process user range:
+
+    if ( aButtonId >= EAknSoftkeyLowestUserRejectId
+        && aButtonId < EAknSoftkeyLowestUserAcceptId )
+        return 0;
+
+    return aButtonId;
+    }
+
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/src/DRMHelperInfoNoteWrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,519 @@
+/*
+* Copyright (c) 2004 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of CDRMHelperInfoNoteWrapper class
+*
+*/
+
+
+
+// INCLUDE FILES
+#include "DRMHelperInfoNoteWrapper.h"
+
+#include <stringloader.h>
+#include <AknGlobalConfirmationQuery.h>
+#include <avkon.hrh> // EAknSoftkeyNo
+#include <aknglobalnote.h>
+
+#include <SecondaryDisplay/DRMHelperSecondaryDisplay.h>
+#include <aknmediatorfacade.h>
+#include <featmgr.h>
+#include <aknsddata.h>
+#include <DrmHelper.h>
+#include <DrmHelper.rsg>
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMHelperInfoNoteWrapper::CDRMHelperInfoNoteWrapper
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperInfoNoteWrapper::CDRMHelperInfoNoteWrapper() : CActive( EPriorityStandard )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperInfoNoteWrapper::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperInfoNoteWrapper::ConstructL()
+    {
+    iNote = CAknGlobalNote::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperInfoNoteWrapper::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperInfoNoteWrapper* CDRMHelperInfoNoteWrapper::NewLC()
+    {
+    CDRMHelperInfoNoteWrapper* self = new (ELeave) CDRMHelperInfoNoteWrapper();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CDRMHelperInfoNoteWrapper* CDRMHelperInfoNoteWrapper::NewL()
+    {
+    CDRMHelperInfoNoteWrapper* self = NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// Destructor
+CDRMHelperInfoNoteWrapper::~CDRMHelperInfoNoteWrapper()
+    {
+    Cancel(); // Cancel active object
+    delete iNote;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperInfoNoteWrapper::ShowNoteL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperInfoNoteWrapper::ShowNoteL( TAknGlobalNoteType aType ,
+                                           const TDesC& aNoteText,
+                                           TInt aResourceId,
+                                           const TDesC& aString,
+                                           TInt aValue )
+    {
+
+    RProcess myProcess;
+    TUid myProcessUid( KNullUid );
+
+    // Convert primary display resource ID to Cover Ui
+    // do nothing if not found
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) &&
+        CDRMHelperInfoNoteWrapper::EvaluateCoverResourceId( aResourceId ) )
+        {
+        RThread().Process( myProcess );
+        myProcessUid = myProcess.Identity();
+
+        THelperSDData helperData;
+        helperData.iHelperUid = KUidCoverUiCategoryDRMHelper; // First field is DRMHelper's Uid
+        helperData.iHandlerProcessId = myProcessUid; // ProcessId which uses DRMHelper
+        if( aNoteText.Compare( KNullDesC ) )
+            {
+            // If there is filename given, it's always in the PrimaryString
+            helperData.iStringParam.Append( aString );
+            }
+        if( aValue > -1 )
+            {
+            // If there is filename given, it's always in the PrimaryString
+            helperData.iStringParam.Append( aValue );
+            }
+
+        THelperSDDataPckg pckg( helperData );
+        CAknSDData* sd = CAknSDData::NewL( KUidCoverUiCategoryDRMHelper, aResourceId, pckg );
+        iNote->SetSecondaryDisplayData( sd ); // ownership to notifier client
+        }
+
+    iNote->ShowNoteL( iStatus , aType , aNoteText );
+    SetActive();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperInfoNoteWrapper::DoCancel
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperInfoNoteWrapper::DoCancel()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperInfoNoteWrapper::RunL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperInfoNoteWrapper::RunL()
+    {
+    }
+
+// ---------------------------------------------------------
+// CDRMHelperInfoNoteWrapper::EvaluateCoverResourceId
+// ---------------------------------------------------------
+//
+TBool CDRMHelperInfoNoteWrapper::EvaluateCoverResourceId( TInt& aResourceId )
+    {
+    switch ( aResourceId )
+        {
+        case R_DRMHELPER_CONFIRMATION_QUERY:
+            {
+            aResourceId = ECover_confirmation_query;
+            }
+            break;
+        case R_DRMHELPER_WAITING_RIGHTS_CONFIRMATION_QUERY:
+            {
+            aResourceId = ECover_waiting_rights_confirmation_query;
+            }
+            break;
+        case R_DRMHELPER_USAGE_RIGHTS_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_usage_rights_expired_buy_new;
+            }
+            break;
+        case R_DRMHELPER_USAGE_RIGHTS_EXPIRED:
+            {
+            aResourceId = ECover_usage_rights_expired;
+            }
+            break;
+        case R_DRMHELPER_NO_USAGE_RIGHTS_BUY_NEW:
+            {
+            aResourceId = ECover_no_usage_rights_buy_new;
+            }
+            break;
+        case R_DRMHELPER_NO_USAGE_RIGHTS:
+            {
+            aResourceId = ECover_no_usage_rights;
+            }
+            break;
+#ifndef RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+        case R_DRMHELPER_USAGE_RIGHTS_TO_EXPIRE:
+            {
+            aResourceId = ECover_usage_rights_to_expire;
+            }
+            break;
+#endif
+        case R_DRMHELPER_SET_AUTOMATED:
+            {
+            aResourceId = ECover_set_automated;
+            }
+            break;
+        case R_DRMHELPER_ACTIVATE_AND_SET_AUTOMATED:
+            {
+            aResourceId = ECover_activate_and_set_automated;
+            }
+            break;
+        case R_DRMHELPER_CAL_ALERT_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_cal_alert_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMHELPER_CAL_ALERT_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_cal_alert_expired_buy_new;
+            }
+            break;
+        case R_DRMHELPER_CAL_ALERT_EXPIRED:
+            {
+            aResourceId = ECover_cal_alert_expired;
+            }
+            break;
+        case R_DRMHELPER_CLOCK_ALARM_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_clock_alarm_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMHELPER_CLOCK_ALARM_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_clock_alarm_expired_buy_new;
+            }
+            break;
+        case R_DRMHELPER_CLOCK_ALARM_EXPIRED:
+            {
+            aResourceId = ECover_clock_alarm_expired;
+            }
+            break;
+        case R_DRMHELPER_EMAIL_TONE_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_email_tone_expired_buy_new;
+            }
+            break;
+        case R_DRMHELPER_EMAIL_TONE_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_email_tone_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMHELPER_EMAIL_TONE_EXPIRED:
+            {
+            aResourceId = ECover_email_tone_expired;
+            }
+            break;
+        case R_DRMHELPER_IM_TONE_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_im_tone_expired_buy_new;
+            }
+            break;
+        case R_DRMHELPER_IM_TONE_EXPIRED:
+            {
+            aResourceId = ECover_im_tone_expired;
+            }
+            break;
+        case R_DRMHELPER_MESSAGE_TONE_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_message_tone_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMHELPER_MESSAGE_TONE_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_message_tone_expired_buy_new;
+            }
+            break;
+        case R_DRMHELPER_MESSAGE_TONE_EXPIRED:
+            {
+            aResourceId = ECover_message_tone_expired;
+            }
+            break;
+        case R_DRMHELPER_RINGING_TONE_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_ringing_tone_expired_buy_new;
+            }
+            break;
+        case R_DRMHELPER_RINGING_TONE_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_ringing_tone_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMHELPER_RINGING_TONE_EXPIRED:
+            {
+            aResourceId = ECover_ringing_tone_expired;
+            }
+            break;
+        case R_DRMHELPER_SCREENSAVER_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_screensaver_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMHELPER_SCREENSAVER_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_screensaver_expired_buy_new;
+            }
+            break;
+        case R_DRMHELPER_SCREENSAVER_EXPIRED:
+            {
+            aResourceId = ECover_screensaver_expired;
+            }
+            break;
+        case R_DRMHELPER_WALLPAPER_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_wallpaper_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMHELPER_WALLPAPER_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_wallpaper_expired_buy_new;
+            }
+            break;
+        case R_DRMHELPER_WALLPAPER_EXPIRED:
+            {
+            aResourceId = ECover_wallpaper_expired;
+            }
+            break;
+        case R_DRMHELPER_THEME_INVALID_SIM_BUY_NEW:
+            {
+            aResourceId = ECover_theme_invalid_sim_buy_new;
+            }
+            break;
+        case R_DRMHELPER_THEME_EXPIRED_BUY_NEW:
+            {
+            aResourceId = ECover_theme_expired_buy_new;
+            }
+            break;
+        case R_DRMHELPER_THEME_EXPIRED:
+            {
+            aResourceId = ECover_theme_expired;
+            }
+            break;
+        case R_DRMHELPER_USAGE_RIGHTS_IN_FUTURE:
+            {
+            aResourceId = ECover_usage_rights_in_future;
+            }
+            break;
+        case R_DRMHELPER_ACTIVATE_AFTER_PREVIEW:
+            {
+            aResourceId = ECover_activate_after_preview;
+            }
+            break;
+        case R_DRMHELPER_WAITING_FOR_RIGHTS:
+            {
+            aResourceId = ECover_waiting_for_rights;
+            }
+            break;
+        case R_DRMHELPER_RIGHTS_SHOULD_HAVE_COME:
+            {
+            aResourceId = ECover_rights_should_have_come;
+            }
+            break;
+        case R_DRMHELPER_RIGHTS_SHOULD_HAVE_COME_NO_RI:
+            {
+            aResourceId = ECover_rights_should_have_come_no_ri;
+            }
+            break;
+        case R_DRMHELPER_AUTOMATED_SD_INVALID_SIM:
+            {
+            aResourceId = ECover_automated_sd_invalid_sim;
+            }
+            break;
+        case R_DRMHELPER_AUTOMATED_SD_EXPIRED:
+            {
+            aResourceId = ECover_automated_sd_expired;
+            }
+            break;
+        case R_DRMHELPER_AUTOMATED_CD_EXPIRED:
+            {
+            aResourceId = ECover_automated_cd_expired;
+            }
+            break;
+#ifndef RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+        case R_DRMHELPER_INFO_EXP_1_USE:
+            {
+            aResourceId = ECover_info_exp_1_use;
+            }
+            break;
+        case R_DRMHELPER_INFO_EXP_N_USES:
+            {
+            aResourceId = ECover_info_exp_n_uses;
+            }
+            break;
+        case R_DRMHELPER_INFO_EXP_1_DAY:
+            {
+            aResourceId = ECover_info_exp_1_day;
+            }
+            break;
+        case R_DRMHELPER_INFO_EXP_N_DAYS:
+            {
+            aResourceId = ECover_info_exp_n_days;
+            }
+            break;
+        case R_DRMHELPER_QUERY_EXP_1_USE_GET_NEW:
+            {
+            aResourceId = ECover_query_exp_1_use_get_new;
+            }
+            break;
+        case R_DRMHELPER_QUERY_EXP_N_USE_GET_NEW:
+            {
+            aResourceId = ECover_query_exp_n_use_get_new;
+            }
+            break;
+        case R_DRMHELPER_QUERY_EXP_1_DAY_GET_NEW:
+            {
+            aResourceId = ECover_query_exp_1_day_get_new;
+            }
+            break;
+        case R_DRMHELPER_QUERY_EXP_N_DAY_GET_NEW:
+            {
+            aResourceId = ECover_query_exp_n_day_get_new;
+            }
+            break;
+        case R_DRMHELPER_QUERY_EXP_1_MIN_GET_NEW:
+            {
+            aResourceId = ECover_query_exp_1_min_get_new;
+            }
+            break;
+        case R_DRMHELPER_QUERY_EXP_N_MIN_GET_NEW:
+            {
+            aResourceId = ECover_query_exp_n_min_get_new;
+            }
+            break;
+        case R_DRMHELPER_QUERY_EXP_MANY_CONSTR:
+            {
+            aResourceId = ECover_query_exp_many_constr;
+            }
+            break;
+#endif //RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+        case R_DRMHELPER_PREV_AUDIO_GET_LIST_QUERY:
+            {
+            aResourceId = ECover_prev_audio_get_list_query;
+            }
+            break;
+        case R_DRMHELPER_PREV_VIDEO_GET_LIST_QUERY:
+            {
+            aResourceId = ECover_prev_video_get_list_query;
+            }
+            break;
+        case R_DRMHELPER_PREV_AUDIO_PLAY_LIST_QUERY:
+            {
+            aResourceId = ECover_prev_audio_play_list_query;
+            }
+            break;
+        case R_DRMHELPER_PREV_VIDEO_PLAY_LIST_QUERY:
+            {
+            aResourceId = ECover_prev_video_play_list_query;
+            }
+            break;
+        case R_DRMHELPER_AUDIO_PREV_GET_LIST:
+            {
+            aResourceId = ECover_audio_prev_get_list;
+            }
+            break;
+        case R_DRMHELPER_VIDEO_PREV_GET_LIST:
+            {
+            aResourceId = ECover_video_prev_get_list;
+            }
+            break;
+#endif //RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+        case R_DRMHELPER_INVALID_SIM:
+            {
+            aResourceId = ECover_invalid_sim;
+            }
+            break;
+        case R_DRMHELPER_AUDIO_PREV_PLAY_LIST:
+            {
+            aResourceId = ECover_audio_prev_play_list;
+            }
+            break;
+        case R_DRMHELPER_VIDEO_PREV_PLAY_LIST:
+            {
+            aResourceId = ECover_video_prev_play_list;
+            }
+            break;
+        case R_DRM_ERR_OPENING_FAIL_PERM:
+            {
+            aResourceId = ECover_err_opening_fail_perm;
+            }
+            break;
+        case R_DRM_WARN_NO_CONN_DEFINED:
+            {
+            aResourceId = ECover_warn_no_conn_defined;
+            }
+            break;
+        case R_DRM_WARN_INVALID_OR_NO_AP:
+            {
+            aResourceId = ECover_warn_invalid_or_no_ap;
+            }
+            break;
+        default:
+            return EFalse; // No proper dialog found, skipping
+        }
+    return ETrue; // Dialog found
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/src/DRMHelperStub.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,992 @@
+/*
+* Copyright (c) 2003, 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:  stub version of DRMHelper.cpp
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    <DRMHelper.h>
+#include    <eikenv.h>
+
+#include <schemehandler.h> // for handling URLs
+#include <aknnotewrappers.h> // information note
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES  
+
+// CONSTANTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::CDRMHelperRightsConstraints
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperRightsConstraints::CDRMHelperRightsConstraints( 
+    CDRMRightsConstraints* /*aConstraints*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperRightsConstraints::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperRightsConstraints* CDRMHelperRightsConstraints::NewLC( 
+    CDRMRightsConstraints* aConstraints )
+    {
+    CDRMHelperRightsConstraints* self = 
+        new (ELeave) CDRMHelperRightsConstraints( aConstraints );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CDRMHelperRightsConstraints* CDRMHelperRightsConstraints::NewL( 
+    CDRMRightsConstraints* aConstraints )
+    {
+    CDRMHelperRightsConstraints* self = NewLC( aConstraints );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+    
+// Destructor
+EXPORT_C CDRMHelperRightsConstraints::~CDRMHelperRightsConstraints()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::FullRights
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelperRightsConstraints::FullRights()
+    {
+    return ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::IsPreview
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelperRightsConstraints::IsPreview()
+    {
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetCountersL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetCountersL(
+    TUint32& /*aCounter*/, 
+    TUint32& /*aOriginalCounter*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetStartTimeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetStartTimeL( TTime& /*aStartTime*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetEndTimeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetEndTimeL( TTime& /*aEndTime*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetIntervalL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetIntervalL( 
+    TTimeIntervalSeconds& /*aInterval*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetIntervalStartL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetIntervalStartL( 
+    TTime& /*aStartTime*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetTimedCountL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetTimedCountL( TUint32& /*aCounter*/,
+    TUint32& /*aOriginalCounter*/, TTimeIntervalSeconds& /*aTimer*/ )
+    {
+  	}
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetTimedCountL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetAccumulatedTimeL( 
+    TTimeIntervalSeconds& /*aAccumulatedTime*/ )
+    {
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CDRMHelper
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMHelper::CDRMHelper( CCoeEnv& aCoeEnv ) :
+    iCoeEnv( &aCoeEnv ),
+    iUseCoeEnv( ETrue ), 
+    iAutomatedType( EAutomatedTypeOther ),
+    iPreviewMediaType(-1)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CDRMHelper
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMHelper::CDRMHelper() :
+    iUseCoeEnv( EFalse ),
+    iAutomatedType( EAutomatedTypeOther )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::ConstructL( RFs* /*aFs*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMHelper* CDRMHelper::NewLC( CCoeEnv& /*aCoeEnv*/ )
+    {
+    CDRMHelper* self = new (ELeave) CDRMHelper();
+    CleanupStack::PushL( self );
+    self->ConstructL( NULL );
+    return self;
+    }
+
+EXPORT_C CDRMHelper* CDRMHelper::NewL( CCoeEnv& aCoeEnv )
+    {
+    CDRMHelper* self = NewLC( aCoeEnv );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+EXPORT_C CDRMHelper* CDRMHelper::NewL()
+    {
+    CDRMHelper* self = NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+EXPORT_C CDRMHelper* CDRMHelper::NewLC()
+    {
+    CDRMHelper* self = new (ELeave) CDRMHelper();
+    CleanupStack::PushL( self );
+    self->ConstructL( NULL );
+    return self;
+    }
+
+EXPORT_C CDRMHelper* CDRMHelper::NewLC( CCoeEnv& aCoeEnv, RFs& aFs )
+    {
+    CDRMHelper* self = new (ELeave) CDRMHelper( aCoeEnv );
+    CleanupStack::PushL( self );
+    self->ConstructL( &aFs );
+    return self;
+    }
+
+EXPORT_C CDRMHelper* CDRMHelper::NewL( CCoeEnv& aCoeEnv, RFs& aFs )
+    {
+    CDRMHelper* self = NewLC( aCoeEnv, aFs );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+EXPORT_C CDRMHelper* CDRMHelper::NewL( RFs& aFs )
+    {
+    CDRMHelper* self = NewLC( aFs );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+EXPORT_C CDRMHelper* CDRMHelper::NewLC( RFs& aFs )
+    {
+    CDRMHelper* self = new (ELeave) CDRMHelper();
+    CleanupStack::PushL( self );
+    self->ConstructL( &aFs );
+    return self;
+    }
+
+// Destructor
+EXPORT_C CDRMHelper::~CDRMHelper()
+    {
+    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HandleErrorL
+// -----------------------------------------------------------------------------
+//
+
+EXPORT_C TInt CDRMHelper::HandleErrorL( TInt aError, 
+    const TDesC8& /*aURI*/ )
+    {
+    User::LeaveIfError( aError );
+    return 0;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMHelper::HandleErrorL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::HandleErrorL( TInt aError, 
+    RFile& /*aFileHandle*/ )
+    {
+    User::LeaveIfError( aError );
+    return 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HandleErrorL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::HandleErrorL( 
+    TInt aError, 
+    const TDesC& /*aFileName*/ )
+    {
+    User::LeaveIfError( aError );
+    return 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HandleErrorOrPreviewL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::HandleErrorOrPreviewL( 
+        TInt aError, 
+        RFile& /*aFile*/, 
+        HBufC8*& /*aEmbeddedPreviewUri*/ )
+    {
+    User::LeaveIfError( aError );
+    return 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HandleErrorOrPreviewL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::HandleErrorOrPreviewL( 
+    TInt aError, 
+    const TDesC& /*aFileName*/, 
+    HBufC8*& /*aEmbeddedPreviewUri*/ )
+    {
+    User::LeaveIfError( aError );
+    return 0;    
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetPreviewMediaType
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetPreviewMediaType( TDRMHelperPreviewMediaType /*aMediaType*/ )
+    {
+    return KErrNotSupported;
+    }
+            
+// -----------------------------------------------------------------------------
+// CDRMHelper::HasPreviewL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMHelper::TDRMHelperPreviewType CDRMHelper::HasPreviewL( 
+    CData& /*aContent*/, 
+    HBufC8*& /*aPreviewUri*/ )
+    {
+    User::Leave(KErrNotSupported);
+    return CDRMHelper::TDRMHelperPreviewType( ENoPreview );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HasPreviewL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMHelper::TDRMHelperPreviewType CDRMHelper::HasPreviewL(
+    TDesC& /*aFileName*/, 
+    HBufC8*& /*aPreviewUri*/ )
+    {
+    User::Leave(KErrNotSupported);
+    return CDRMHelper::TDRMHelperPreviewType( ENoPreview );    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetPreviewRightsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetPreviewRightsL( CData& /*aContent*/ )
+    {
+    User::Leave(KErrNotSupported);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetPreviewRightsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetPreviewRightsL(TDesC& /*aFileName*/ )
+    {
+    User::Leave(KErrNotSupported);    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::EmbeddedPreviewCompletedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelper::EmbeddedPreviewCompletedL( CData& /*aContent*/ )
+    {
+    User::Leave(KErrNotSupported);
+    return EFalse;    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::EmbeddedPreviewCompletedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelper::EmbeddedPreviewCompletedL( TDesC& /*aFileName*/ )
+    {
+    User::Leave(KErrNotSupported);
+    return EFalse;    
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CheckRightsPercentL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CheckRightsPercentL( 
+    const TDesC& /*aFileName*/, 
+    TInt /*aThreshold*/ )
+    {
+    User::Leave(KErrNotSupported);
+    return 0;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMHelper::CheckRightsPercentL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CheckRightsPercentL( 
+    RFile& /*aFileHandle*/, 
+    TInt /*aThreshold*/ )
+    {
+    User::Leave(KErrNotSupported);
+    return 0;      
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CheckRightsAmountL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CheckRightsAmountL( 
+    const TDesC& /*aFileName*/, 
+    TInt /*aCount*/,
+    TInt /*aDays*/ )
+    {
+    return 0;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CheckRightsAmountL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CheckRightsAmountL( 
+    RFile& /*aFileHandle*/, 
+    TInt /*aCount*/,
+    TInt /*aDays*/ )
+    {
+    return 0;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CheckRightsAmountL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CheckRightsAmountL( 
+    const TDesC8& /*aUri*/, 
+    TInt /*aCount*/,
+    TInt /*aDays*/ )
+    {
+    return KErrNone;
+    }
+
+EXPORT_C void CDRMHelper::SetCountLimitL( TUint /*aCounts*/ )
+    {
+    }
+
+EXPORT_C void CDRMHelper::SetTimeLimitL( TUint /*aDays*/ )
+    {
+    }
+
+EXPORT_C void CDRMHelper::SetPercentageLimitL( TUint /*aPercentage*/ )
+    {
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::LaunchDetailsViewEmbeddedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::LaunchDetailsViewEmbeddedL( 
+    const TDesC& /*aFileName*/ )
+    {
+    User::Leave(KErrNotSupported);    
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::LaunchDetailsViewEmbeddedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::LaunchDetailsViewEmbeddedL( 
+    const HBufC8* /*aContentURI*/ )
+    {
+    User::Leave(KErrNotSupported);    
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMHelper::LaunchDetailsViewEmbeddedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::LaunchDetailsViewEmbeddedL( RFile& /*aFileHandle*/ )
+    {
+    User::Leave(KErrNotSupported);
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMHelper::LaunchDetailsViewEmbeddedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::LaunchDetailsViewEmbeddedL( 
+    const TDesC8& /*aURI*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetRightsDetailsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetRightsDetailsL( 
+    const TDesC& /*aFileName*/, 
+    TUint32 /*aIntent*/,
+    TBool& /*aExpired*/, 
+    TBool& /*aSendingAllowed*/, 
+    CDRMHelperRightsConstraints*& /*aPlay*/,
+    CDRMHelperRightsConstraints*& /*aDisplay*/, 
+    CDRMHelperRightsConstraints*& /*aExecute*/,
+    CDRMHelperRightsConstraints*& /*aPrint*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetRightsDetailsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetRightsDetailsL( 
+    RFile& /*aFileHandle*/, 
+    TUint32 /*aIntent*/,
+    TBool& /*aExpired*/, 
+    TBool& /*aSendingAllowed*/, 
+    CDRMHelperRightsConstraints*& /*aPlay*/,
+    CDRMHelperRightsConstraints*& /*aDisplay*/, 
+    CDRMHelperRightsConstraints*& /*aExecute*/,
+    CDRMHelperRightsConstraints*& /*aPrint*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetRightsDetailsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetRightsDetailsL( 
+    const TDesC& /*aFileName*/, 
+    TUint32 /*aIntent*/,
+    TBool& /*aExpired*/, 
+    TBool& /*aSendingAllowed*/, 
+    CDRMRightsConstraints*& /*aPlay*/,
+    CDRMRightsConstraints*& /*aDisplay*/, 
+    CDRMRightsConstraints*& /*aExecute*/,
+    CDRMRightsConstraints*& /*aPrint*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetRightsDetailsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetRightsDetailsL( 
+    RFile& /*aFileHandle*/, 
+    TUint32 /*aIntent*/,
+    TBool& /*aExpired*/, 
+    TBool& /*aSendingAllowed*/, 
+    CDRMRightsConstraints*& /*aPlay*/,
+    CDRMRightsConstraints*& /*aDisplay*/, 
+    CDRMRightsConstraints*& /*aExecute*/,
+    CDRMRightsConstraints*& /*aPrint*/ )
+    {
+    }
+
+
+EXPORT_C TInt CDRMHelper::ShowDRMUINotification2L( TDRMHelperNotificationID /*aTextId*/,
+    const TDesC8& /*aURI*/ )
+    {
+    return KErrNotSupported;
+    }
+
+EXPORT_C TInt CDRMHelper::ShowDRMUINotification2L( TDRMHelperNotificationID /*aTextId*/,
+    const TDesC& /*aFileName*/ )
+    {
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CanSetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CanSetAutomated( 
+    const TDesC& /*aFilename*/, 
+    TBool& aValue )
+    {
+    aValue = EFalse;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CanSetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CanSetAutomated( 
+    RFile& /*aFileHandle*/, 
+    TBool& aValue )
+    {
+    aValue = EFalse;
+    return KErrNone;    
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CanSetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CanSetAutomated( const TDesC8& /*aURI*/, TBool& aValue )
+    {
+    aValue = EFalse;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomated( const TDesC& /*aFilename*/ )
+    {
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomated( RFile& /*aFileHandle*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomated( const TDesC8& /*aURI*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ShowAutomatedNote
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::ShowAutomatedNote( const TDesC& /*aFilename*/ )
+    {
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ShowAutomatedNote
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::ShowAutomatedNote( RFile& /*aFileHandle*/ )
+    {
+    return KErrNotSupported;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMHelper::ShowAutomatedNote
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::ShowAutomatedNote( const TDesC8& /*aURI*/ )
+    {
+    return KErrNotSupported;
+    }        
+    
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedPassive( const TDesC& /*aFilename*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedPassive( RFile& /*aFileHandle*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedPassive( const TDesC8& /*aURI*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomated( const TDesC& /*aFilename*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomated( RFile& /*aFileHandle*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomated( const TDesC8& /*aURI*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomatedPassive( const TDesC& /*aFilename*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomatedPassive( RFile& /*aFileHandle*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomatedPassive( const TDesC8& /*aURI*/ )
+    {
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedType
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedType( 
+    CDRMHelper::TDRMHelperAutomatedType /*aAutomatedType*/ )
+    {
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::IndicateIdle
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::IndicateIdle()
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedSilent
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedSilent( const TDesC& /*aFilename*/, 
+    TBool /*aActive*/ )
+    {
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedSilent
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedSilent( RFile& /*aFileHandle*/, 
+    TBool /*aActive*/ )
+    {
+    return KErrNone;
+    }
+    
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedSilent
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedSilent( const TDesC8& /*aURI*/, 
+    TBool /*aActive*/ )
+    {
+    return KErrNone;
+	}
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::Consume2
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::Consume2(
+	const TDesC8& /*aContentURI*/,
+	TUint32 /*aRightsSpec*/,
+	TDRMHelperConsumeAction /*anAction*/)
+    {
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ConsumeFile2
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::ConsumeFile2(
+	const TDesC& /*aFileName*/,
+	TUint32 /*aRightsSpec*/,
+	TDRMHelperConsumeAction /*anAction*/)
+    {
+    return KErrNotSupported;    
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ConsumeFile2
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::ConsumeFile2(
+	RFile& /*aFileHandle*/,
+	TUint32 /*aRightsSpec*/,
+	TDRMHelperConsumeAction /*anAction*/)
+    {
+    return KErrNotSupported;    
+    }
+// -----------------------------------------------------------------------------
+// CDRMHelper::ActivateContentL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::ActivateContentL( CData& /*aContent*/ )
+    {
+    User::Leave(KErrNotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ActivateContentL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::ActivateContentL( TDesC& /*aFileName*/ )
+    {
+    User::Leave(KErrNotSupported);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HasInfoUrlL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelper::HasInfoUrlL( CData& /*aContent*/, HBufC8*& /*aInfoUrl*/ )
+    {
+    User::Leave(KErrNotSupported);
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HasInfoUrlL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelper::HasInfoUrlL(TDesC& /*aFileName*/, HBufC8*& /*aInfoUrl*/ )
+    {
+    User::Leave(KErrNotSupported);
+    return EFalse;    
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMHelper::OpenInfoUrlL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::OpenInfoUrlL( CData& /*aContent*/ )
+    {
+    User::Leave(KErrNotSupported);
+    }
+    
+// -----------------------------------------------------------------------------
+// CDRMHelper::OpenInfoUrlL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::OpenInfoUrlL(TDesC& /*aFileName*/ )
+    {    
+    User::Leave(KErrNotSupported);
+    }
+
+EXPORT_C TInt CDRMHelper::GetContentURIList(
+    RPointerArray<HBufC8>*& /*aURIList*/)
+    {
+    return KErrNotSupported;
+    }
+    
+EXPORT_C TInt CDRMHelper::DataTypesCount(
+    TInt& /*aCount*/)
+    {
+    return KErrNotSupported;
+    }
+    
+EXPORT_C TInt CDRMHelper::SupportedDataType(
+    const TInt /*aIndex*/, TDataType& /*aDataType*/)
+    {
+    return KErrNotSupported;
+    }
+
+EXPORT_C TInt CDRMHelper::RegisterDataType(
+    const TDataType& /*aDataType*/)
+    {
+    return KErrNotSupported;   
+    }
+    
+EXPORT_C TInt CDRMHelper::UnRegisterDataType(
+    const TInt /*aIndex*/)
+    {
+    return KErrNotSupported;   
+    }
+
+EXPORT_C TInt CDRMHelper::SupportedDRMMethods2(
+    TInt& /*aDRMMethod*/, TDRMHelperOMALevel& /*aOMALevel*/)
+    {
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+//
+// ---------------------------------------------------------
+//
+void CDRMHelper::HandleServerAppExit( TInt aReason )
+    {
+    if ( aReason == EAknCmdExit && !iSchemeHandler )
+        {
+        CAknEnv::RunAppShutter();
+        }
+    
+    if ( iSchemeHandler )
+        {
+        delete iSchemeHandler;
+        iSchemeHandler = NULL;
+        }
+
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    }    
+    
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/src/RDRMHelper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,353 @@
+/*
+* Copyright (c) 2004 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the Helper Client session functionality
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32math.h>
+#include <drmcommon.h>
+#include "drmhelpercommon.h"
+#include "drmhelperserver.h"
+#include "RDRMHelper.h"
+
+// LOCAL CONSTANTS AND MACROS
+
+// Number of message slots to reserve for this client server session.
+// Since we only communicate synchronously here, we never have any
+// outstanding asynchronous requests.
+_LIT( KDRMHelperServerSemaphoreStartingName, "DRMHelperServerSemaphoreStarting" );
+
+const TUint KDefaultMessageSlots = 0;
+const TUid KServerUid3 = { 0x101F6DC5 };
+_LIT_SECURE_ID( KServerSecureId, 0x101F6DC5 );
+
+#ifdef _DEBUG
+    #include <e32svr.h> // RDebug
+    #define TRACE( x ) RDebug::Print( _L( x ) )
+    #define TRACE2( x, y ) RDebug::Print( _L( x ), y )
+    #define TRACE3( x, y, z ) RDebug::Print( _L( x ), y, z )
+#else
+    #define TRACE( x )
+    #define TRACE2( x, y )
+    #define TRACE3( x, y, z )
+#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::RDRMHelper
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+RDRMHelper::RDRMHelper() : RSessionBase()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::Connect
+//
+// Connect to the server session
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::Connect()
+    {
+    TInt error = StartServer();
+    TRACE2( "RDRMHelper::Connect() StartServer(): error: %d", error );
+    if ( !error )
+        {
+        error = CreateSession( KDRMHelperServerName, Version(),
+            KDefaultMessageSlots );
+        TRACE2( "RDRMHelper::Connect() CreateSession(): error: %d", error );
+        }
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::Version
+//
+// return server version
+// -----------------------------------------------------------------------------
+//
+TVersion RDRMHelper::Version() const
+    {
+    return( TVersion( KDRMHSMajorVersionNumber, KDRMHSMinorVersionNumber,
+        KDRMHSBuildVersionNumber ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::SetAutomated
+//
+// Register one content uri to the helper server
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::SetAutomated(
+    const TDesC8& aUri,
+    TBool aActive,
+    TInt aAutomatedType,
+    TInt aIntent ) const
+    {
+    TInt mode =
+        aActive ? CDRMHelperServer::EActive : CDRMHelperServer::EPassive;
+
+    // Create descriptor to enable copying data between
+    // client and server. Note: This can be local since
+    // this is a synchronous call.
+    // Note : Using TPtr8 since this is binary information
+    TPtrC8 descriptor( aUri );
+
+    // This call waits for the server to complete the request before
+    // proceeding.
+    return SendReceive(
+        ERegister, TIpcArgs( aIntent, mode, aAutomatedType, &descriptor ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::RemoveAutomated
+//
+// Unregister one content uri
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::RemoveAutomated(
+    const TDesC8& aUri,
+    TBool aActive,
+    TInt aAutomatedType,
+    TInt aIntent ) const
+    {
+    TInt ret( 0 );
+    TInt mode(
+        aActive ? CDRMHelperServer::EActive : CDRMHelperServer::EPassive );
+
+    // Create descriptor to enable copying data between
+    // client and server. Note: This can be local since
+    // this is a synchronous call.
+    // Note : Using TPtr8 since this is binary information
+    TPtrC8 descriptor( aUri );
+
+    // This call waits for the server to complete the request before
+    // proceeding.
+    ret = SendReceive(
+        ERemove, TIpcArgs( aIntent, mode, aAutomatedType, &descriptor ) );
+
+    if ( ret == KErrNotFound )
+        {
+        // content was never actually registered
+        ret = KErrNone;
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::RemoveAutomatedAll
+//
+// Unregister one content uri
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::RemoveAutomatedAll(
+    const TDesC8& aUri,
+    TBool aActive,
+    TInt aAutomatedType,
+    TInt aIntent ) const
+    {
+    TPtrC8 descriptor( aUri );
+    TInt ret;
+    TInt mode(
+        aActive ? CDRMHelperServer::EActive : CDRMHelperServer::EPassive );
+    TBool automated = EFalse;
+    TInt tempMode( 0 );
+
+    // This call waits for the server to complete the request before
+    // proceeding.
+    ret = SendReceive(
+        ERemove, TIpcArgs( aIntent, mode, aAutomatedType, &descriptor ) );
+    IsAutomated( aUri, aAutomatedType, aIntent, automated, tempMode );
+    while ( automated && tempMode == mode )
+        {
+        // unregister all
+        ret = SendReceive(
+            ERemove, TIpcArgs( aIntent, mode, aAutomatedType, &descriptor ) );
+        IsAutomated( aUri, aAutomatedType, aIntent, automated, tempMode );
+        }
+
+    if ( ret == KErrNotFound )
+        {
+        ret = KErrNone;
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::IndicateIdle
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::IndicateIdle() const
+    {
+    return SendReceive( EIndicateIdle, TIpcArgs() );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::IsAutomated
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::IsAutomated(
+    const TDesC8& aUri,
+    TInt aAutomatedType,
+    TInt aIntent,
+    TBool& aAutomated,
+    TInt& aType ) const
+    {
+    TPtr8 typeptr( reinterpret_cast< TUint8* >( &aType ), 0, sizeof( TInt ) );
+    TPtr8 flag( reinterpret_cast< TUint8* >( &aAutomated ), 0, sizeof( TInt ) );
+    TInt ret( 0 );
+    TInt type = CDRMHelperServer::EActive;
+
+    // Create descriptor to enable copying data between
+    // client and server. Note: This can be local since
+    // this is a synchronous call.
+    // Note : Using TPtr8 since this is binary information
+    TPtrC8 descriptor( aUri );
+
+    // This call waits for the server to complete the request before
+    // proceeding.
+    ret = SendReceive(
+        EIsRegistered,
+        TIpcArgs( aIntent, type, aAutomatedType, &descriptor ) );
+    if ( !ret )
+        {
+        type = CDRMHelperServer::EPassive;
+        ret = SendReceive(
+            EIsRegistered,
+            TIpcArgs( aIntent, type, aAutomatedType, &descriptor ) );
+        }
+    aAutomated = ret > 0 ? ETrue : EFalse;
+    aType = type;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::StartServer
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::StartServer()
+    {
+    RThread currentThread;
+    const TUint32 secureIdAsTuint32( currentThread.SecureId() );
+    TRACE2( "RDRMHelper::StartServer(): currentThread: 0x%08x",
+            secureIdAsTuint32 );
+    if ( currentThread.SecureId() == KServerSecureId )
+        {
+        // HelperServer cannot connect to itself.
+        return KErrCouldNotConnect;
+        }
+
+    TInt result( 0 );
+
+    TFindServer findHelperServer( KDRMHelperServerName );
+    TFullName name;
+
+    result = findHelperServer.Next( name );
+    TRACE2( "RDRMHelper::StartServer(): result: %d", result );
+    if ( result == KErrNone )
+        {
+        // Server already running
+        return KErrNone;
+        }
+
+    RSemaphore semaphoreStarting;
+    TInt semaphoreExist( semaphoreStarting.CreateGlobal(
+            KDRMHelperServerSemaphoreStartingName, 0 ) );
+    TRACE2( "RDRMHelper::StartServer(): semaphoreExist: %d", semaphoreExist );
+
+    if( semaphoreExist != KErrAlreadyExists && semaphoreExist != KErrNone )
+        {
+        return semaphoreExist;
+        }
+
+    // Semaphore exists, wait until server is finished with it's tasks
+    if ( semaphoreExist == KErrAlreadyExists )
+        {
+        TInt openErr( semaphoreStarting.OpenGlobal(
+                KDRMHelperServerSemaphoreStartingName) );
+        TRACE2( "RDRMHelper::StartServer(): openErr: %d", openErr );
+        if ( openErr != KErrNone )
+            {
+            return openErr;
+            }
+
+        TRACE( "RDRMHelper::StartServer(): semaphoreStarting.Wait()" );
+        semaphoreStarting.Wait();
+        TRACE( "RDRMHelper::StartServer(): semaphoreStarting.Wait() - returning" );
+        }
+    else
+        {
+        RSemaphore semaphoreStartServer;
+        TInt result( semaphoreStartServer.CreateGlobal(
+                KDRMHelperServerSemaphoreName, 0 ) );
+        TRACE2( "RDRMHelper::StartServer(): 2 result: %d", result );
+        if ( result != KErrNone )
+            {
+            semaphoreStarting.Close();
+            return result;
+            }
+
+        result = CreateServerProcess();
+        TRACE2( "RDRMHelper::StartServer(): 3 result: %d", result );
+        if ( result != KErrNone )
+            {
+            return  result;
+            }
+
+        semaphoreStartServer.Wait();
+        semaphoreStartServer.Close();
+
+        TRACE( "RDRMHelper::StartServer(): semaphoreStarting.Signal()" );
+
+        semaphoreStarting.Signal();
+        semaphoreStarting.Close();
+        }
+
+    TRACE( "RDRMHelper::StartServer(): return KErrNone" );
+    return  KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::CreateServerProcess
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::CreateServerProcess()
+    {
+    TInt result( 0 );
+
+    const TUidType serverUid( KNullUid, KNullUid, KServerUid3 );
+
+
+    RProcess server;
+    result = server.Create( KDRMHSServerFileName, _L( "" ), serverUid );
+    if ( result != KErrNone )
+        {
+        return  result;
+        }
+
+    server.Resume();
+    server.Close();
+
+    return  KErrNone;
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/src/RDRMHelperStub.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,151 @@
+/*
+* 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:  Implementation of the Helper Client session functionality 
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "RDRMHelper.h"
+#include "drmhelpercommon.h"
+
+// LOCAL CONSTANTS AND MACROS
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::RDRMHelper
+// C++ default constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+RDRMHelper::RDRMHelper() : RSessionBase()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::Connect
+// 
+// Connect to the server session
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::Connect()
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::Version
+// 
+// return server version
+// -----------------------------------------------------------------------------
+//
+TVersion RDRMHelper::Version() const
+    {
+	return( TVersion( KDRMHSMajorVersionNumber, KDRMHSMinorVersionNumber, 
+        KDRMHSBuildVersionNumber ) );
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::SetAutomated
+// 
+// Register one content uri to the helper server
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::SetAutomated( 
+    const TDesC8& /*aUri*/, 
+    TBool /*aActive*/, 
+    TInt /*aAutomatedType*/, 
+    TInt /*aIntent*/ ) const
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::RemoveAutomated
+// 
+// Unregister one content uri 
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::RemoveAutomated( 
+    const TDesC8& /*aUri*/, 
+    TBool /*aActive*/, 
+    TInt /*aAutomatedType*/, 
+    TInt /*aIntent*/ ) const
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::RemoveAutomatedAll
+// 
+// Unregister one content uri 
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::RemoveAutomatedAll( 
+    const TDesC8& /*aUri*/, 
+    TBool /*aActive*/, 
+    TInt /*aAutomatedType*/, 
+    TInt /*aIntent*/ ) const
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::IndicateIdle
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::IndicateIdle() const
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::IsAutomated
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::IsAutomated( 
+    const TDesC8& /*aUri*/, 
+    TInt /*aAutomatedType*/, 
+    TInt /*aIntent*/, 
+    TBool& aAutomated, 
+    TInt& /*aType*/ ) const
+    {
+    aAutomated = EFalse;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::StartServer
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::StartServer()
+    {
+    return  KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// RDRMHelper::CreateServerProcess
+// -----------------------------------------------------------------------------
+//
+TInt RDRMHelper::CreateServerProcess()
+    {
+    return  KErrNone;
+    }
+
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmhelper/src/drmhelper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,7173 @@
+/*
+* Copyright (c) 2003-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:  Implementation of CDRMHelper class
+*
+*/
+
+
+// INCLUDE FILES
+#include "DRMHelper.h"
+
+#include "DRMHelperGlobalNoteWrapper.h"
+#include "DRMHelperInfoNoteWrapper.h"
+#include "DRMRightsClient.h"
+#include "DcfCommon.h"
+#include "DRMHelperDownloadManager.h"
+
+#include <SaCls.h>
+#include <DRMHelper.rsg>
+#include <AknQueryDialog.h>
+#include <DRMCommon.h>
+
+#include <StarterClient.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include <StringLoader.h>
+#include <eikproc.h> //CEikProcess
+#include <eikdoc.h> //CEikDocument
+#include <documenthandler.h> // KDRMErr*
+#include <aknnotewrappers.h> // information note
+#include <aknglobalnote.h> // global info note
+
+#include <drmconstraint.h>
+
+#include <stringresourcereader.h>
+#include <apgcli.h>
+#include <data_caging_path_literals.hrh>
+
+#include <AiwGenericParam.h>
+#include <dcfrep.h>
+#include <DcfEntry.h>
+
+#include <caf/caf.h>
+
+#include <AknLaunchAppService.h> // for launching RMUI embedded
+
+#include <utf.h>
+
+#include <schemehandler.h> // for handling URLs
+#include "drmhelperserver.h"
+#include "consumedata.h"
+#include "drmtypes.h"
+#include "drmclockclient.h"
+#include "DRMPointerArray.h"
+
+#include <SecondaryDisplay/DRMHelperSecondaryDisplay.h> // for secondary display support
+#include <aknmediatorfacade.h>
+#include <mediatoreventprovider.h>
+#include <mediatordomainuids.h>
+#include <featmgr.h>
+
+#include "RoapStorageClient.h"
+
+#include <centralrepository.h>
+#include <e32property.h>
+#ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
+#include "drmsettingsplugininternalcrkeys.h"
+#endif
+#include "DRMRIContext.h"
+#include "DRMDomainContext.h"
+
+#include <cmconnectionmethod.h>
+#include <cmdestination.h>
+#include <cmconnectionmethoddef.h>
+#include <cmmanager.h>
+
+// publish & subrscibe
+#include <E32Property.h>
+#include <PsVariables.h>
+
+#ifdef __SERIES60_NATIVE_BROWSER
+#include <browseruisdkcrkeys.h>
+#endif
+
+#ifndef __SERIES60_NATIVE_BROWSER
+const TUid KCRUidBrowser   = {0x10008D39};
+const TUint32 KBrowserDefaultAccessPoint =  0x0000000E;
+const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
+#endif
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+
+#ifndef RD_MULTIPLE_DRIVE
+_LIT( KDriveZ, "z:" );
+#endif
+
+_LIT( KCDRMHelperResFileName,"DRMHelper.rsc" );
+_LIT( KEncryptedRightsIssuerMatchString, "flk*" );
+_LIT( KDRMHelperClassificationRingingTone, "Ringtone" );
+_LIT( KDRMHelperClassificationVideoTone, "Videotone" );
+
+
+// masks for constaint existence
+const TInt KDRMHelperConstraintCount = 1;
+const TInt KDRMHelperConstraintTime = 2;
+const TInt KDRMHelperConstraintAccumulated = 4;
+
+// Buffer sizes
+const TInt KDRMHelperMaxDateFormatLen = 30;
+const TInt KDRMHelperMaxDateLen = 30;
+const TInt KDRMHelperMaxTimeFormatLen = 30;
+const TInt KDRMHelperMaxTimeLen = 30;
+const TInt KUrlMaxLen = 1024;
+const TInt KDRMHelperMaxETABufSize = 11;
+
+// limit in minutes when start to display 'about to expire' notes for accumulated
+// time content
+#ifndef RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+const TInt KDRMHelperAccumulatedTimeLimit = 15;
+#endif // RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+// MODULE DATA STRUCTURES
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+
+// ============================ auto_handde helper class =======================
+//Auto handle for easening handle release on exceptional exit situations
+template<typename T> class auto_handle
+    {
+public:
+
+    auto_handle() {}
+    auto_handle(T aHandle) : iHandle( aHandle ) {}
+    auto_handle( auto_handle<T>& aHandle) : iHandle( aHandle.release() ) {}
+    ~auto_handle() { iHandle.Close(); }
+    const T& operator()() const { return iHandle; }
+    T& operator()() { return iHandle; }
+    T get() const { return iHandle; }
+    T release() { T temp = iHandle; iHandle = 0; return temp; }
+
+private:
+    T iHandle;
+    };
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// IapIdOfDefaultSnapL
+// for trapping purposes only
+// -----------------------------------------------------------------------------
+//
+LOCAL_C TUint32 IapIdOfDefaultSnapL(
+    RCmManager& aCmManager,
+    const TUint32 aDefaultSnap )
+    {
+    RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) );
+    CleanupClosePushL( dest );
+    TUint32 iapIdOfDest( 0 );
+
+    if ( dest.ConnectionMethodCount() <= 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
+    CleanupClosePushL( cMeth );
+
+    iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId );
+    CleanupStack::PopAndDestroy( &cMeth );
+    CleanupStack::PopAndDestroy( &dest );
+    return iapIdOfDest;
+    }
+
+// -----------------------------------------------------------------------------
+// Creates note for resource text to be viewed,
+// Defaults to information note.
+// -----------------------------------------------------------------------------
+LOCAL_C CAknResourceNoteDialog* CreateNoteForResourceL( TInt aResId )
+    {
+    CAknResourceNoteDialog* r( NULL );
+    switch (aResId)
+        {
+        case R_DRM_ERR_OPENING_FAIL_PERM:
+            r = new ( ELeave ) CAknErrorNote( ETrue );
+            break;
+        case R_DRM_WARN_NO_CONN_DEFINED:
+        case R_DRM_WARN_INVALID_OR_NO_AP:
+            r = new  ( ELeave ) CAknWarningNote( ETrue );
+            break;
+        default:
+            r = new ( ELeave ) CAknInformationNote( ETrue );
+            break;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// Returns note type for globan note to be viewed.
+// Defaults to information note.
+// -----------------------------------------------------------------------------
+LOCAL_C TAknGlobalNoteType GlobalNoteTypeForResource( TInt aResId )
+    {
+    TAknGlobalNoteType t( EAknGlobalInformationNote );
+    switch (aResId)
+        {
+        case R_DRM_ERR_OPENING_FAIL_PERM:
+            t = EAknGlobalErrorNote;
+            break;
+        case R_DRM_WARN_NO_CONN_DEFINED:
+        case R_DRM_WARN_INVALID_OR_NO_AP:
+            t = EAknGlobalWarningNote;
+            break;
+        default:
+            break;
+        }
+    return t;
+
+    }
+
+// -----------------------------------------------------------------------------
+// LeaveIfWrongReturnForHandleErrorOrPreviewL
+// Leaves if error code under test (argument aError) does match those documented
+// for HandleErrorOrPreviewL
+// -----------------------------------------------------------------------------
+LOCAL_C void LeaveIfWrongReturnForHandleErrorOrPreviewL( TInt aError )
+    {
+    switch ( aError )
+        {
+        case KErrNone:
+        case KErrCancel:
+        case KErrCANoRights:
+        case KErrCANoPermission:
+        case KErrCompletion:
+            break;
+        default:
+            User::Leave( aError );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// Checks whether given media type is video type
+// -----------------------------------------------------------------------------
+LOCAL_C TBool IsVideo(const CData* aData)
+    {
+    TPtr mimeDes( NULL, 0);
+    TBool ret( EFalse );
+    HBufC* mimeType( HBufC::New( KMaxDataTypeLength ) );
+    if ( !mimeType )
+        {
+        return ret;
+        }
+    mimeDes.Set( mimeType->Des() );
+
+    //Note mime types borrowed from CDRMHelper::Intent
+    _LIT( KDRMHelperMimeTypeVideo, "Video" );
+    _LIT( KDRMHelperMimeTypeShockwave, "Application/x-shockwave-flash" );
+    _LIT( KDRMHelperMimeTypeRealMedia, "Application/x-pn-realmedia" );
+    _LIT( KDRMHelperMimeTypeVndRealMedia, "Application/vnd.rn-realmedia" );
+
+    if ( aData->GetStringAttribute( EMimeType, mimeDes ) == KErrNone )
+        {
+        ret = !mimeDes.FindF( KDRMHelperMimeTypeShockwave ) ||
+            !mimeDes.FindF( KDRMHelperMimeTypeRealMedia ) ||
+            !mimeDes.FindF( KDRMHelperMimeTypeVndRealMedia ) ||
+            !mimeDes.FindF( KDRMHelperMimeTypeVideo );
+        }
+    delete mimeType;
+    return ret;
+    }
+
+// ---------------------------------------------------------
+// Evaluate media type for preview playback
+// ---------------------------------------------------------
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+LOCAL_C TInt EvaluatePreviewMediaType( CData* aContent )
+    {
+    TInt theType( -1 );
+    _LIT( KDRMHelperMimeTypeAudio, "Audio" );
+    HBufC* mimeType( HBufC::New( KMaxDataTypeLength ) );
+    if ( !mimeType )
+        {
+        return theType;
+        }
+    TPtr ptr = mimeType->Des();
+    TInt error = aContent->GetStringAttribute( EMimeType, ptr );
+    if ( IsVideo( aContent ) )
+        {
+        theType = EPreviewTypeVideo;
+        }
+    else if ( !ptr.FindF( KDRMHelperMimeTypeAudio ) )
+        {
+        theType = EPreviewTypeAudio;
+        }
+    delete mimeType;
+    return theType;
+    }
+
+#endif
+
+#pragma mark -
+// -----------------------------------------------------------------------------
+//
+// Functions related to WMDRM protection check
+//
+// -----------------------------------------------------------------------------
+
+// Some magic constants
+static const TInt KMinContentLength( 16 );
+_LIT8( KWrmHeader, "W\0R\0M\0H\0E\0A\0D\0E\0R\0" );
+_LIT8( KASFHeaderObject, "75B22630668E11CFA6D900AA0062CE6C" );
+
+// -----------------------------------------------------------------------------
+// FormatGUID
+// -----------------------------------------------------------------------------
+LOCAL_C void FormatGUID( TDes8 &aGUID )
+    {
+    TBuf8<16> copyGUID(aGUID);
+    TInt i;
+    for (i = 0; i < 4; i++)
+        {
+        copyGUID[i] = aGUID[3 - i];
+        }
+    for (i = 4; i < 6; i++)
+        {
+        copyGUID[i] = aGUID[9 - i];
+        }
+    for (i = 6; i < 8; i++)
+        {
+        copyGUID[i] = aGUID[13 - i];
+        }
+    for (i = 8; i < 16 ; i++)
+        {
+        copyGUID[i] = aGUID[i];
+        }
+    aGUID.Delete(0, 32);
+    for (i = 0; i <16; i++)
+        {
+        aGUID.AppendNumFixedWidthUC(copyGUID[i], EHex, 2);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// ConvertToInt64
+// -----------------------------------------------------------------------------
+LOCAL_C TInt64 ConvertToInt64( TDesC8& aDes )
+    {
+    TInt64 num = 0;
+    TInt i;
+    for (i = 7 ; i >= 0; i--)
+        {
+        num <<= 8;
+        num |= aDes[i];
+        }
+    return num;
+    }
+
+
+// -----------------------------------------------------------------------------
+// IsProtectedWmDrmL
+// returns ETrue, if file is protected WMDRM file
+//         EFalse if file is not protected WMDRM file
+// Leaves with KErrUnderflow if file has too little data to decide
+//         whether WmDrm or not
+//         may also leave with other system wide error code
+// -----------------------------------------------------------------------------
+LOCAL_C TBool IsProtectedWmDrmL( RFile& aFileHandle )
+    {
+    TInt r( KErrNone );
+    HBufC8* buffer( NULL );
+    TInt pos( 0 );
+    RFile file;
+    TBuf8< 32 > header;
+
+    TInt64 headerSize( 0 );
+    TBool isProtectedWmDrm( EFalse );
+    TPtr8 headerPtr( NULL, 0 );
+
+    // Leave if given handle is invalid
+    if ( !aFileHandle.SubSessionHandle() )
+        {
+        User::Leave( KErrBadHandle );
+        }
+
+    User::LeaveIfError( file.Duplicate( aFileHandle ) );
+    CleanupClosePushL( file );
+
+    User::LeaveIfError( file.Seek( ESeekStart, pos ) );
+
+    // Check if the file is an ASF file
+
+    User::LeaveIfError( file.Read( 0, header, KMinContentLength ) );
+    if ( header.Length() < KMinContentLength )
+        {
+        User::Leave( KErrUnderflow );
+        }
+
+    FormatGUID( header );
+
+    if ( header == KASFHeaderObject )
+        {
+        // It's ASF, check still whether it's WM DRM protected or not
+        file.Read( header,8 );
+        headerSize = ConvertToInt64( header );
+        if ( headerSize <= 30 )
+            {
+            User::Leave( KErrUnderflow );
+            }
+        if ( headerSize > ( ( KMaxTInt32 / 2 ) - 1 ) )
+            {
+            User::Leave( KErrOverflow );
+            }
+        buffer = HBufC8::NewLC( headerSize );
+
+        headerPtr.Set( buffer->Des() );
+        User::LeaveIfError( file.Read( headerPtr, headerSize - 24 ) );
+
+        r = headerPtr.Find( KWrmHeader );
+        if ( r != KErrNotFound )
+            {
+            isProtectedWmDrm = ETrue;
+            }
+        CleanupStack::PopAndDestroy( buffer );
+        }
+    CleanupStack::PopAndDestroy( &file );
+    return isProtectedWmDrm;
+    }
+
+#pragma mark -
+// -----------------------------------------------------------------------------
+//
+// End of Functions related to WMDRM protection check
+//
+// -----------------------------------------------------------------------------
+
+// ---------------------------------------------------------
+// UpdateDCFRepositoryL()
+// Update saved file to DCFRepository
+// ---------------------------------------------------------
+
+LOCAL_C void UpdateDCFRepositoryL( const RFile& aFileHandle )
+    {
+    TFileName fullName;
+    aFileHandle.FullName( fullName );
+
+    CDcfEntry* dcfEntry = NULL;
+    dcfEntry = CDcfEntry::NewL();
+    CleanupStack::PushL( dcfEntry );
+
+    CDcfRep* dcfRep = NULL;
+    dcfRep = CDcfRep::NewL();
+    CleanupStack::PushL( dcfRep );
+
+    dcfEntry->SetLocationL( fullName, 0 );
+    dcfRep->UpdateL( dcfEntry );
+    CleanupStack::PopAndDestroy( dcfRep );
+    CleanupStack::PopAndDestroy( dcfEntry );
+    }
+#pragma mark -
+
+
+// ============================= MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::CDRMHelperRightsConstraints
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperRightsConstraints::CDRMHelperRightsConstraints(
+    CDRMRightsConstraints* aConstraints )
+    {
+    iConstraints = aConstraints;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMHelperRightsConstraints::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CDRMHelperRightsConstraints* CDRMHelperRightsConstraints::NewLC(
+    CDRMRightsConstraints* aConstraints )
+    {
+    CleanupStack::PushL( aConstraints );
+    CDRMHelperRightsConstraints* self =
+        new (ELeave) CDRMHelperRightsConstraints( aConstraints );
+    CleanupStack::Pop( aConstraints );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+CDRMHelperRightsConstraints* CDRMHelperRightsConstraints::NewL(
+    CDRMRightsConstraints* aConstraints )
+    {
+    CDRMHelperRightsConstraints* self = NewLC( aConstraints );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// Destructor
+EXPORT_C CDRMHelperRightsConstraints::~CDRMHelperRightsConstraints()
+    {
+    delete iConstraints;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::FullRights
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelperRightsConstraints::FullRights()
+    {
+    return iConstraints->FullRights();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::IsPreview
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelperRightsConstraints::IsPreview()
+    {
+    return iConstraints->IsPreview();
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetCountersL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetCountersL(
+    TUint32& aCounter,
+    TUint32& aOriginalCounter )
+    {
+    if ( iConstraints->GetCounters( aCounter, aOriginalCounter ) ==
+        DRMCommon::ENoRights )
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetStartTimeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetStartTimeL( TTime& aStartTime )
+    {
+    if ( iConstraints->GetStartTime( aStartTime ) == DRMCommon::ENoRights )
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetEndTimeL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetEndTimeL( TTime& aEndTime )
+    {
+    if ( iConstraints->GetEndTime( aEndTime ) == DRMCommon::ENoRights )
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetIntervalL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetIntervalL(
+    TTimeIntervalSeconds& aInterval )
+    {
+    if ( iConstraints->GetInterval( aInterval ) == DRMCommon::ENoRights )
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetIntervalStartL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetIntervalStartL(
+    TTime& aStartTime )
+    {
+    if ( iConstraints->GetIntervalStart( aStartTime ) == DRMCommon::ENoRights )
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetTimedCountL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetTimedCountL( TUint32& aCounter,
+    TUint32& aOriginalCounter, TTimeIntervalSeconds& aTimer )
+    {
+    if ((iConstraints->GetConstraint()).iActiveConstraints & EConstraintTimedCounter)
+        {
+        aCounter = (iConstraints->GetConstraint()).iTimedCounter;
+        aOriginalCounter = aCounter;
+        aTimer = ( iConstraints->GetConstraint() ).iTimedInterval;
+        }
+    else
+        {
+        User::Leave(KErrNotFound);
+        }
+
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelperRightsConstraints::GetTimedCountL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelperRightsConstraints::GetAccumulatedTimeL(
+    TTimeIntervalSeconds& aAccumulatedTime )
+    {
+    if ((iConstraints->GetConstraint()).iActiveConstraints & EConstraintAccumulated)
+        {
+        aAccumulatedTime = (iConstraints->GetConstraint()).iAccumulatedTime;
+        }
+    else
+        {
+        User::Leave(KErrNotFound);
+        }
+    }
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CDRMHelper
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMHelper::CDRMHelper( CCoeEnv& aCoeEnv ) :
+    iCoeEnv( &aCoeEnv ),
+    iUseCoeEnv( ETrue ),
+    iAutomatedType( EAutomatedTypeOther ),
+    iPreviewMediaType(-1)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CDRMHelper
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMHelper::CDRMHelper() :
+    iUseCoeEnv( EFalse ),
+    iAutomatedType( EAutomatedTypeOther )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::ConstructL( RFs* aFs )
+    {
+    TInt drmMethods;
+    DRMCommon::TOMALevel omaLevel;
+
+    iDRMCommon = DRMCommon::NewL();
+    User::LeaveIfError( iDRMCommon->Connect() );
+    User::LeaveIfError( iHelperServer.Connect() );
+
+    iDRMCommon->SupportedDRMMethods( drmMethods, omaLevel );
+    iOma2 = omaLevel == DRMCommon::EOMA_2_0 ? ETrue : EFalse;
+
+    if ( aFs )
+        {
+        iFs = *aFs;
+        iFsOwned = EFalse;
+        }
+    else
+        {
+        User::LeaveIfError( iFs.Connect() );
+        User::LeaveIfError(iFs.ShareAuto());
+        iFsOwned = ETrue;
+        }
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    TFileName fileName( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+    _LIT( KDrive, "%c:");
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+
+    TFileName fileName;
+
+    fileName.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+    fileName.Append( KDC_RESOURCE_FILES_DIR );
+    fileName.Append( KCDRMHelperResFileName );
+
+    TRAP_IGNORE( FeatureManager::InitializeLibL() );
+
+    iStringResourceReader = CStringResourceReader::NewL( fileName, iFs );
+
+    if ( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) )
+        {
+        iEventProvider = CMediatorEventProvider::NewL();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMHelper* CDRMHelper::NewLC( CCoeEnv& aCoeEnv )
+    {
+    CDRMHelper* self = new (ELeave) CDRMHelper( aCoeEnv );
+    CleanupStack::PushL( self );
+    self->ConstructL( NULL );
+    return self;
+    }
+
+EXPORT_C CDRMHelper* CDRMHelper::NewL( CCoeEnv& aCoeEnv )
+    {
+    CDRMHelper* self = NewLC( aCoeEnv );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+EXPORT_C CDRMHelper* CDRMHelper::NewL()
+    {
+    CDRMHelper* self = NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+EXPORT_C CDRMHelper* CDRMHelper::NewLC()
+    {
+    CDRMHelper* self = new (ELeave) CDRMHelper();
+    CleanupStack::PushL( self );
+    self->ConstructL( NULL );
+    return self;
+    }
+
+EXPORT_C CDRMHelper* CDRMHelper::NewLC( CCoeEnv& aCoeEnv, RFs& aFs )
+    {
+    CDRMHelper* self = new (ELeave) CDRMHelper( aCoeEnv );
+    CleanupStack::PushL( self );
+    self->ConstructL( &aFs );
+    return self;
+    }
+
+EXPORT_C CDRMHelper* CDRMHelper::NewL( CCoeEnv& aCoeEnv, RFs& aFs )
+    {
+    CDRMHelper* self = NewLC( aCoeEnv, aFs );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+EXPORT_C CDRMHelper* CDRMHelper::NewL( RFs& aFs )
+    {
+    CDRMHelper* self = NewLC( aFs );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+EXPORT_C CDRMHelper* CDRMHelper::NewLC( RFs& aFs )
+    {
+    CDRMHelper* self = new (ELeave) CDRMHelper();
+    CleanupStack::PushL( self );
+    self->ConstructL( &aFs );
+    return self;
+    }
+
+// Destructor
+EXPORT_C CDRMHelper::~CDRMHelper()
+    {
+    // closing all rdb sessions is handled in the destructor
+    // of the CConsumeData objects
+    // delete rdb connections array
+    iConsumeList.ResetAndDestroy();
+    iConsumeList.Close();
+    iHelperServer.Close();
+
+    iNoteList.ResetAndDestroy(); // GlobalNoteInfo
+    iNoteList.Close();
+
+    if (iDRMCommon)
+        {
+        iDRMCommon->Disconnect();
+        }
+    delete iStringResourceReader;
+    delete iDRMCommon;
+
+    if ( iFsOwned )
+        {
+        iFs.Close();
+        }
+
+    FeatureManager::UnInitializeLib();
+
+    delete iSchemeHandler;
+    delete iEventProvider;
+    }
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HandleErrorL
+// -----------------------------------------------------------------------------
+//
+
+EXPORT_C TInt CDRMHelper::HandleErrorL( TInt aError,
+    const TDesC8& aURI )
+    {
+    RFile fileHandle;
+    TInt ret( KErrNotFound );
+    CleanupClosePushL( fileHandle );
+
+    if ( GetFileHandleFromURIL( aURI, fileHandle ) == KErrNone )
+        {
+        ret = CDRMHelper::HandleErrorL( aError, fileHandle );
+        }
+    CleanupStack::PopAndDestroy( &fileHandle );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HandleErrorL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::HandleErrorL( TInt aError, RFile& aFileHandle )
+    {
+    TInt ret = KErrNone;
+    HBufC* rightsIssuer = NULL;
+    HBufC* mimeType = NULL;
+    HBufC* contentURI = NULL;
+    HBufC* domainRoUrl = NULL;
+    HBufC* eta = NULL;
+    HBufC8* contentURI8 = NULL;
+    HBufC* riId = NULL;
+    HBufC8* riId8 = NULL;
+    HBufC* domainId = NULL;
+    HBufC8* domainId8 = NULL;
+
+    TInt error;
+    TPtr ptr(NULL, 0);
+    TFileName fileName;
+
+    // To embed Domain RO in superdistribution case, register the content
+    TRAP_IGNORE( UpdateDCFRepositoryL( aFileHandle ) );
+
+    CData* content = CData::NewLC( aFileHandle, KDefaultContentObject, EPeek );
+
+    // get rights-issuer URL
+    TRAP_IGNORE(GetRightsIssuerL( *content, rightsIssuer ) );
+    if ( rightsIssuer )
+        {
+        CleanupStack::PushL( rightsIssuer );
+        }
+
+    mimeType = HBufC::NewLC( KMaxDataTypeLength );
+    contentURI = HBufC::NewLC( KUrlMaxLen );
+    domainRoUrl = HBufC::NewLC( KUrlMaxLen );
+    eta = HBufC::NewLC( KDRMHelperMaxETABufSize );
+    riId = HBufC::NewLC( KUrlMaxLen );
+    domainId = HBufC::NewLC( KUrlMaxLen );
+
+    // create attribute set
+    RStringAttributeSet stringAttributeSet;
+    CleanupClosePushL( stringAttributeSet );
+    // add the attributes we are interested in
+    stringAttributeSet.AddL( EContentID );
+    stringAttributeSet.AddL( EMimeType );
+    stringAttributeSet.AddL( EDomainRightsIssuerUrl );
+    stringAttributeSet.AddL( EPendingRightsETA );
+    stringAttributeSet.AddL( EDomainRightsIssuerId );
+    stringAttributeSet.AddL( EDomainId );
+
+    User::LeaveIfError( content->GetStringAttributeSet( stringAttributeSet ) );
+
+    // pass on values of string attributes
+    ptr.Set( contentURI->Des() );
+    error = stringAttributeSet.GetValue( EContentID, ptr );
+    if ( error == KErrNone )
+        {
+        ptr.Set( domainRoUrl->Des() );
+        stringAttributeSet.GetValue( EDomainRightsIssuerUrl, ptr );
+
+        ptr.Set( mimeType->Des() );
+        error = stringAttributeSet.GetValue( EMimeType, ptr );
+
+        ptr.Set( riId->Des() );
+        stringAttributeSet.GetValue( EDomainRightsIssuerId, ptr );
+
+        ptr.Set( domainId->Des() );
+        stringAttributeSet.GetValue( EDomainId, ptr );
+
+        if ( error == KErrNone )
+            {
+            ptr.Set( eta->Des() );
+            error = stringAttributeSet.GetValue( EPendingRightsETA, ptr );
+            HBufC* etaPtr = error == KErrNone ? eta : NULL;
+            aFileHandle.Name( fileName );
+            contentURI8 = HBufC8::NewLC( contentURI->Length() );
+            contentURI8->Des().Copy( contentURI->Des() );
+            riId8 = HBufC8::NewLC( riId->Length() );
+            riId8->Des().Copy( riId->Des() );
+            domainId8 = HBufC8::NewLC( domainId->Length() );
+            domainId8->Des().Copy( domainId->Des() );
+            ret = DoHandleErrorL( aError,
+                contentURI8,
+                mimeType,
+                rightsIssuer,
+                domainRoUrl,
+                etaPtr,
+                riId8,
+                domainId8,
+                StripPathAndExtension( fileName ) );
+            CleanupStack::PopAndDestroy( 3, contentURI8 ); // contentURI8, riId8
+            }
+        else
+            {
+            User::Leave( KErrArgument );
+            }
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    CleanupStack::PopAndDestroy( 7, mimeType );
+
+    if ( rightsIssuer )
+        {
+        CleanupStack::PopAndDestroy( rightsIssuer );
+        }
+
+    CleanupStack::PopAndDestroy( content );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HandleErrorL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::HandleErrorL( TInt aError, const TDesC& aFileName )
+    {
+    RFile file;
+    TInt r = KErrNone;
+
+    r = file.Open(iFs, aFileName, EFileRead | EFileShareReadersOrWriters);
+
+    if (r == KErrInUse)
+        {
+        r = file.Open(iFs, aFileName, EFileRead | EFileShareAny);
+        if (r == KErrInUse)
+            {
+            r = file.Open(iFs, aFileName, EFileRead | EFileShareReadersOnly);
+            }
+        }
+    User::LeaveIfError(r);
+
+    CleanupClosePushL( file );
+    r = HandleErrorL( aError, file );
+    CleanupStack::PopAndDestroy( &file );
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DoHandleErrorL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DoHandleErrorL(
+    TInt aError,
+    HBufC8* aContentUri,
+    HBufC* aMimeType,
+    HBufC* aRIUrl,
+    HBufC* aDomainRoUrl,
+    HBufC* aEta,
+    HBufC8* aRiId8,
+    HBufC8* aDomainId8,
+    const TDesC& aFileName )
+    {
+    TBool automated( EFalse );
+    TInt error(0);
+    TInt ret(0);
+    TInt resId(0);
+    CDRMRights* rights = NULL;
+    Roap::RRoapStorageClient storage;
+    CDRMRIContext* riContext = NULL;
+    CDRMDomainContext* domainContext = NULL;
+    TBool isRegistered = EFalse;
+    TBool isJoined = EFalse;
+
+    iReturnCancel = EFalse;
+    switch ( aError )
+        {
+        case KErrCAPendingRights:
+        case DRMCommon::ERightsExpired:
+        case DRMCommon::ENoRights:
+        case KDRMErrNoRights:
+            if ( aError == DRMCommon::ENoRights || aError == KDRMErrNoRights )
+                {
+                // check if it is expired situation after all
+                error = GetExpirationDetails(
+                    aContentUri, Intent( aMimeType ), rights );
+                if ( error == CDRMRights::EExpiredRights )
+                    {
+                    aError = DRMCommon::ERightsExpired;
+                    }
+                if ( rights )
+                    {
+                    delete rights;
+                    rights = NULL;
+                    }
+                }
+
+            if ( aRiId8 && aRiId8->Length() && aDomainRoUrl && aDomainRoUrl->Length() )
+                {
+                // Check if we have domain RO
+                User::LeaveIfError( storage.Connect() );
+                CleanupClosePushL( storage );
+                riContext = storage.GetRIContextL( *aRiId8 );
+                if ( riContext )
+                    {
+                    isRegistered = ETrue;
+                    delete riContext;
+                    riContext = NULL;
+                    if ( aDomainId8 && aDomainId8->Length() )
+                        {
+                        domainContext = storage.GetDomainContextL( *aDomainId8 );
+                        if ( domainContext )
+                            {
+                            // last three digits presents the domain generation
+                            TInt generation = 0;
+                            TLex8 lex( aDomainId8->Right( 3 ) );
+                            lex.Val( generation );
+
+                            if ( domainContext->DomainGeneration() >= generation )
+                                {
+                                isJoined = ETrue;
+                                }
+                            delete domainContext;
+                            domainContext = NULL;
+                            }
+                        }
+                    }
+                CleanupStack::PopAndDestroy( &storage );
+                }
+
+            // check if future rights
+            if ( aError != KErrCAPendingRights &&
+                GetExpirationDetails(
+                    aContentUri, Intent( aMimeType ), rights ) ==
+                CDRMRights::EFutureRights )
+                {
+                if ( aContentUri )
+                    {
+                    TRAPD( err,
+                        error = ShowFutureNoteL( aMimeType, rights ) );
+                    if ( err )
+                        {
+                        error = err;
+                        }
+                    }
+                if ( rights )
+                    {
+                    delete rights;
+                    rights = NULL;
+                    }
+                }
+            else
+                {
+                TInt type(0);
+
+                // check if this is automated content
+                if ( aContentUri )
+                    {
+                    error = iHelperServer.IsAutomated(
+                        *aContentUri,
+                        iAutomatedType,
+                        Intent( aMimeType ),
+                        automated,
+                        type );
+                    if (!error && automated)
+                        {
+                        aError = DRMCommon::ERightsExpired;
+                        }
+                    }
+
+                if ( aError == DRMCommon::ERightsExpired )
+                    {
+
+                    if ( !error && automated )
+                        {
+                        // automated content
+                        TBool active = (type ==
+                            CDRMHelperServer::EActive ? ETrue : EFalse);
+                        TUint32 rejectReason = RejectReasonL(
+                            Intent( aMimeType ), *aContentUri );
+                        if ( aRIUrl )
+                            {
+                            // superdistributable
+                            // get resource id
+                            resId = AutomatedResIdL( ETrue, ETrue, rejectReason );
+                            ret = DisplayQueryL( resId, aFileName );
+                            if ( ret == 0 )
+                                {
+                                // Query has been closed with cancel or similar,
+                                // So handleErrorOrPreviewL should return KErrCancel
+                                iReturnCancel = ETrue;
+                                // new rights not bought, unregister content
+                                iHelperServer.RemoveAutomatedAll(
+                                    *aContentUri,
+                                    active,
+                                    iAutomatedType,
+                                    Intent( aMimeType ) );
+                                }
+                            }
+                        else
+                            {
+                            // non-superdistributable, show note and unregister
+                            resId = AutomatedResIdL( ETrue, EFalse, rejectReason );
+                            ret = DisplayQueryWithIdValueL(
+                                resId,
+                                R_DRMHELPER_WAITING_RIGHTS_CONFIRMATION_QUERY,
+                                aFileName );
+
+                            if ( ret == 0 )
+                                {
+                                // Query has been closed with cancel or similar,
+                                // So handleErrorOrPreviewL should return KErrCancel
+                                iReturnCancel = ETrue;
+                                }
+                            iHelperServer.RemoveAutomatedAll(
+                                *aContentUri,
+                                active,
+                                iAutomatedType,
+                                Intent( aMimeType ) );
+                            }
+                        }
+                    else
+                        {
+                        if ( aRIUrl )
+                            {
+                            resId = ErrorResIdL(
+                                *aContentUri, Intent( aMimeType ), ETrue, ETrue );
+                            ret = DisplayQueryWithIdL(
+                                resId,
+                                R_DRMHELPER_CONFIRMATION_QUERY );
+                            if ( ret == 0 )
+                                {
+                                // Query has been closed with cancel or similar,
+                                // So handleErrorOrPreviewL should return KErrCancel
+                                iReturnCancel = ETrue;
+                                }
+                            }
+                        else
+                            {
+                            resId = ErrorResIdL(
+                                *aContentUri, Intent( aMimeType ), EFalse, ETrue );
+                            DisplayInfoNoteL( resId );
+                            }
+                        }
+                    }
+                else
+                    {
+                    // check if rights are expected to arrive
+                    TInt eta(0);
+                    if ( aEta )
+                        {
+                        TLex lexer( *aEta );
+                        error = lexer.Val( eta );
+                        }
+                    if (!error && aError == KErrCAPendingRights && eta == -1)
+                        {
+                        // rights should have come
+                        if ( aRIUrl )
+                            {
+                            ret = DisplayQueryWithIdL(
+                                R_DRMHELPER_RIGHTS_SHOULD_HAVE_COME,
+                                R_DRMHELPER_CONFIRMATION_QUERY );
+                            if ( ret == 0 )
+                                {
+                                // Query has been closed with cancel or similar,
+                                // So handleErrorOrPreviewL should return KErrCancel
+                                iReturnCancel = ETrue;
+                                }
+                            }
+                        else
+                            {
+                            // no Rights-Issuer
+                            DisplayQueryWithIdL(
+                                R_DRMHELPER_RIGHTS_SHOULD_HAVE_COME_NO_RI,
+                                R_DRMHELPER_WAITING_RIGHTS_CONFIRMATION_QUERY );
+                            }
+                        }
+                    else if ( !eta || error || eta == -1 )
+                        { // rights not expected to arrive
+                        if ( aDomainRoUrl && aDomainRoUrl->Length() && isRegistered && !isJoined ) // Domain ro case
+                            {
+                            ret = DisplayQueryWithIdL( R_DRMHELPER_ACTIVATE_ACCOUNT,
+                                R_DRMHELPER_CONFIRMATION_QUERY );
+                            if ( ret == 0 )
+                                {
+                                // Query has been closed with cancel or similar,
+                                // So handleErrorOrPreviewL should return KErrCancel
+                                iReturnCancel = ETrue;
+                                }
+                            }
+                        else if ( aRIUrl ) // Device ro case
+                            {
+                            resId = ErrorResIdL(
+                                *aContentUri, Intent( aMimeType ), ETrue, EFalse );
+                            ret = DisplayQueryL( resId, aFileName );
+                            if ( ret == 0 )
+                                {
+                                // Query has been closed with cancel or similar,
+                                // So handleErrorOrPreviewL should return KErrCancel
+                                iReturnCancel = ETrue;
+                                }
+                            }
+                        else
+                            {
+                            resId = ErrorResIdL(
+                                *aContentUri, Intent( aMimeType ), EFalse, EFalse );
+                            DisplayInfoNoteL( resId );
+                            }
+                        }
+                    else
+                        {
+                        // rights expected to arrive
+                        if ( eta != KErrCAPendingRights )
+                            {
+                            // rights expected to arrive in eta seconds
+                            DisplayQueryWithIdL( R_DRMHELPER_WAITING_FOR_RIGHTS,
+                                R_DRMHELPER_WAITING_RIGHTS_CONFIRMATION_QUERY );
+                            }
+                        else
+                            {
+                            // rights should have come
+                            if ( aRIUrl )
+                                {
+                                ret = DisplayQueryWithIdL(
+                                    R_DRMHELPER_RIGHTS_SHOULD_HAVE_COME,
+                                    R_DRMHELPER_CONFIRMATION_QUERY );
+                                if ( ret == 0 )
+                                    {
+                                    // Query has been closed with cancel or similar,
+                                    // So handleErrorOrPreviewL should return KErrCancel
+                                    iReturnCancel = ETrue;
+                                    }
+                                }
+                            else
+                                {
+                                // no Rights-Issuer
+                                DisplayQueryWithIdL(
+                                    R_DRMHELPER_RIGHTS_SHOULD_HAVE_COME_NO_RI,
+                                    R_DRMHELPER_WAITING_RIGHTS_CONFIRMATION_QUERY );
+                                }
+                            }
+                        }
+                    }
+
+                if ( ret == EAknSoftkeyYes )
+                    {
+                    if ( aDomainRoUrl && aDomainRoUrl->Length() && !isRegistered )
+                        { // Domain RO but not registered
+                        LaunchBrowserL( aDomainRoUrl );
+                        }
+                    else if ( aDomainRoUrl && aDomainRoUrl->Length() && !isJoined )
+                        { // Domain RO but not part of the domain
+                        LaunchBrowserL( aDomainRoUrl );
+                        }
+                    else if (aRIUrl && aRIUrl->Length() )
+                        {
+                        LaunchBrowserL( aRIUrl );
+                        }
+                    }
+                }
+            break;
+
+        case DRMCommon::ERightsDBCorrupted:
+        case KDRMErrRightsDBCorrupted:
+            // flow through
+
+        default:
+            User::LeaveIfError( aError );
+            break;
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ShowFutureNoteL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::ShowFutureNoteL( const HBufC* aMimeType, CDRMRights* aRightsObject)
+    {
+    TInt error( KErrArgument );
+    TInt intent = Intent( aMimeType );
+
+    TTime startTime;
+
+    error = GetStartTime( aRightsObject, intent, startTime );
+    if ( !error )
+        {
+        TBuf<KDRMHelperMaxDateFormatLen> dateFormat;
+        TBuf<KDRMHelperMaxDateLen + KDRMHelperMaxTimeLen + 1> startDateBuf;
+        TBuf<KDRMHelperMaxTimeFormatLen> timeFormat;
+        TBuf<KDRMHelperMaxTimeLen> startTimeBuf;
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        TFileName avkonResFile( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDrive, "%c:");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+        iFs.DriveToChar( driveNumber, driveLetter );
+
+        TFileName avkonResFile;
+
+        avkonResFile.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+        _LIT( KCDRMHelperAvkonResFileName, "avkon.rsc" );
+        _LIT( KSpace, " " );
+
+        avkonResFile.Append( KDC_RESOURCE_FILES_DIR );
+        avkonResFile.Append( KCDRMHelperAvkonResFileName );
+
+        // get date string format
+        CStringResourceReader* avkonResReader =
+            CStringResourceReader::NewLC( avkonResFile );
+
+        dateFormat = avkonResReader->ReadResourceString(
+            R_QTN_DATE_USUAL_WITH_ZERO );
+
+        // get time string format
+        timeFormat = avkonResReader->ReadResourceString(
+            R_QTN_TIME_USUAL_WITH_ZERO );
+
+        CleanupStack::PopAndDestroy( avkonResReader );
+
+        // format date and time
+        startTime.FormatL( startDateBuf, dateFormat );
+        startTime.FormatL( startTimeBuf, timeFormat );
+        startDateBuf.Append( KSpace );
+        startDateBuf.Append( startTimeBuf );
+
+        // display note with start date
+        DisplayInfoNoteL( R_DRMHELPER_USAGE_RIGHTS_IN_FUTURE,
+            startDateBuf );
+        }
+
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ErrorResIdL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::ErrorResIdL(
+    const TDesC8& aContentUri,
+    TInt aIntent,
+    TBool aRightsIssuer,
+    TBool aExpired )
+    {
+    TInt resId(0);
+
+    TUint32 rejectReason = RejectReasonL( aIntent, aContentUri );
+    if ( rejectReason & EConstraintIndividual )
+        {
+        if ( aRightsIssuer )
+            {
+            resId = R_DRMHELPER_INVALID_SIM;
+            }
+        else
+            {
+            resId = R_DRM_INFO_SIM_NOT_ALLOWED;
+            }
+        }
+    else
+        {
+        if ( aExpired )
+            {
+            resId = aRightsIssuer ? R_DRMHELPER_USAGE_RIGHTS_EXPIRED_BUY_NEW :
+                R_DRMHELPER_USAGE_RIGHTS_EXPIRED;
+            }
+        else
+            {
+            // no rights
+            resId = aRightsIssuer ? R_DRMHELPER_NO_USAGE_RIGHTS_BUY_NEW :
+                R_DRMHELPER_NO_USAGE_RIGHTS;
+            }
+        }
+
+    return resId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RejectReasonL
+// -----------------------------------------------------------------------------
+//
+TUint32 CDRMHelper::RejectReasonL( TInt aIntent, const TDesC8& aContentUri )
+    {
+    RDRMRightsClient rightsClient;
+    TUint32 rejectReason(0);
+
+    User::LeaveIfError( rightsClient.Connect() );
+    rightsClient.CheckRights( aIntent, aContentUri, rejectReason );
+    rightsClient.Close();
+
+    return rejectReason;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetExpirationDetails
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::GetExpirationDetails( HBufC8* aContentUri, TInt aIntent,
+    CDRMRights*& aRightsObject )
+    {
+    RPointerArray<CDRMRights>* uriList = NULL;
+    TInt r = KErrNone;
+    TInt expired(0);
+    TInt future(0);
+    TInt valid(0);
+    TTime startTime( Time::NullTTime() );
+    TInt startIndex( -1 );
+    DRMClock::ESecurityLevel secLevel = DRMClock::KInsecure;
+    TUint32 expiration;
+    CDRMRightsConstraints* constraint = NULL;
+    TUint32 rightsType;
+    auto_handle<RDRMClockClient> client; // autohandle deletes on scope end
+    auto_handle<RDRMRightsClient> rclient; // autohandle closes on scope end
+    RPointerArray<HBufC8> individuals;
+    TUint32 retval = 0;
+    TTime time = Time::NullTTime();
+
+    if ( !aContentUri )
+        {
+        return KErrArgument;
+        }
+
+    r = client().Connect();
+
+    if ( !r )
+        {
+        TInt timeZone(0);
+        client().GetSecureTime(time, timeZone, secLevel);
+        }
+
+    // Client to rights client needed to retrieve the individual information:
+    r = rclient().Connect();
+    if ( r )
+        {
+        return r;
+        }
+
+    r = rclient().CheckRights( aIntent, *aContentUri, expiration );
+    if ( r && expiration == EConstraintMetering )
+        {
+        r = CDRMRights::EExpiredRights;
+        return r;
+        }
+
+    r = KErrNone;
+
+    iDRMCommon->GetDetailedContentRights(*aContentUri, uriList);
+
+    if ( !uriList || !uriList->Count() )
+        {
+        delete uriList;
+        uriList = NULL;
+        return KErrCANoRights;
+        }
+
+
+    TRAP( r, r = rclient().GetSupportedIndividualsL( individuals ) );
+    rclient().Close();
+
+    for ( TInt i = 0; i < uriList->Count(); ++i )
+        {
+        switch ( aIntent )
+            {
+            case EPlay:
+                r = (*uriList)[i]->GetPlayRight(constraint);
+                break;
+            case EView:
+                r = (*uriList)[i]->GetDisplayRight(constraint);
+                break;
+            case EExecute:
+                r = (*uriList)[i]->GetExecuteRight(constraint);
+                break;
+            case EPrint:
+                r = (*uriList)[i]->GetPrintRight(constraint);
+                break;
+            default:
+                // Cleanup required when returning and error:
+                // auto_handle closes client
+                uriList->ResetAndDestroy(); //uriList
+                delete uriList;
+                uriList = NULL;
+                return KErrGeneral;
+            }
+        if ( r )
+            {
+            delete constraint;
+            constraint = NULL;
+            continue;
+            }
+        constraint->GetConstraintInfo(expiration, rightsType);
+
+        if ( secLevel != DRMClock::KSecure &&
+            (rightsType & CDRMRights::ETimeBased || rightsType & CDRMRights::EInActiveInterval ))
+            {
+            delete constraint;
+            constraint = NULL;
+            continue;
+            }
+
+        if ( expiration == CDRMRights::EFutureRights )
+            {
+            // We already know it's not valid, ignore the return value of Valid:
+            constraint->GetConstraint().Valid( time, individuals, retval);
+
+            if ( retval & EConstraintIndividual )
+                {
+                ++expired;
+                }
+            else
+                {
+                if ( rightsType & CDRMRights::ETimeBased )
+                    {
+                    TTime tempTime;
+                    if ( constraint->GetStartTime( tempTime ) != DRMCommon::ENoRights )
+                        {
+                        if ( startTime != Time::NullTTime() && tempTime < startTime )
+                            {
+                            startTime = tempTime;
+                            startIndex = i;
+                            }
+                        else if ( startTime == Time::NullTTime() )
+                            {
+                            startTime = tempTime;
+                            startIndex = i;
+                            }
+                        }
+                    }
+                ++future;
+                }
+            }
+        else if ( expiration == CDRMRights::EExpiredRights )
+            {
+            ++expired;
+            }
+        else
+            {
+            if ( !(constraint->GetConstraint().Valid( time, individuals, retval) ) )
+                {
+                ++expired;
+                }
+            else
+                {
+                ++valid;
+                }
+            }
+
+        delete constraint;
+        constraint = NULL;
+        }
+
+    if ( valid )
+        {
+        r = CDRMRights::EValidRights;
+        }
+    else if ( future )
+        {
+        r = CDRMRights::EFutureRights;
+        if ( startIndex >= 0 )
+            {
+            aRightsObject = (*uriList)[startIndex];
+            (*uriList)[startIndex] = NULL;
+            uriList->Remove(startIndex);
+            }
+        }
+    else
+        {
+        r = CDRMRights::EExpiredRights;
+        }
+    // Reset the individuals
+    individuals.ResetAndDestroy();
+    individuals.Close();
+
+    // autohandle closes client
+
+    // Reset the urilist
+    uriList->ResetAndDestroy(); //uriList
+    delete uriList;
+    uriList = NULL;
+
+    return r;
+    }
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HandleErrorOrPreviewL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::HandleErrorOrPreviewL(
+    TInt aError,
+    RFile& aFile,
+    HBufC8*& aEmbeddedPreviewUri )
+    {
+    ContentAccess::CData* content( NULL );
+    TPtr ptr( NULL,0 );
+    TInt previewType = 0;
+    TInt buttonCode = 0;
+    HBufC* previewUri16 = NULL;
+    HBufC* rightsIssuer = NULL;
+    HBufC8* silentUrl( NULL );
+    TInt r( aError );
+
+
+    aEmbeddedPreviewUri = NULL;
+    content = ContentAccess::CData::NewLC(
+            aFile, ContentAccess::KDefaultContentObject, ContentAccess::EPeek );
+
+    // To embed Domain RO in superdistribution case, register the content
+    TRAP_IGNORE( UpdateDCFRepositoryL( aFile ) );
+
+    if (aError != KErrCANoPermission &&
+        aError != KErrCANoRights &&
+        aError != KDRMErrNoRights )
+        {
+        // not a preview case
+        HandleErrorL( aError, aFile );
+        }
+    else if ( !IsVideo( content ) &&
+        ( silentUrl = HasSilentRightsUrlL( content ) ) != NULL )
+        {
+        // get rights silently if we have the URL and if we are registered
+        CleanupStack::PushL( silentUrl );
+        r = GetSilentRightsL( *silentUrl );
+        CleanupStack::PopAndDestroy( silentUrl );
+        if ( r == KErrNone )
+            {
+            // check if we can use the file now
+            HBufC* mimeBuf( HBufC::NewLC( KMaxDataTypeLength ) );
+            TPtr mimePtr( mimeBuf->Des() );
+            User::LeaveIfError( content->GetStringAttribute( EMimeType,
+                mimePtr ) );
+            r = content->EvaluateIntent(
+                static_cast<ContentAccess::TIntent>( Intent( mimeBuf ) ) );
+            CleanupStack::PopAndDestroy( mimeBuf );
+            mimeBuf = NULL;
+
+            LeaveIfWrongReturnForHandleErrorOrPreviewL( r );
+            if ( r != KErrNone )
+                {
+                HandleErrorL( r, aFile );
+                }
+            }
+        else if ( r != KErrCancel )
+            {
+            HandleErrorL( aError, aFile );
+            }
+        }
+    else
+        {
+        CheckPreviewUriL(content,previewUri16,previewType);
+        CleanupStack::PushL(previewUri16);
+
+        // display according to preview type
+        switch (previewType)
+            {
+            case ContentAccess::ENoPreview:
+                // no preview
+                HandleErrorL(aError,aFile);
+                break;
+            case ContentAccess::EInstantPreview:
+            case ContentAccess::EPreviewRights:
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+                if ( iPreviewMediaType < 0 )
+                    { // if no preview type set by application
+                    SetPreviewMediaType( static_cast<TDRMHelperPreviewMediaType>(
+                            EvaluatePreviewMediaType( content ) ) );
+                    if ( iPreviewMediaType < 0 )
+                        { //unable to resolve media type, cancel preview
+                        HandleErrorL( aError, aFile );
+                        break;
+                        }
+                    }
+                buttonCode = DisplayPopupWindowsForPreviewL(previewType);
+                aEmbeddedPreviewUri = HBufC8::NewL( previewUri16->Length() );
+                aEmbeddedPreviewUri->Des().Copy( previewUri16->Des() );
+#else
+                HandleErrorL( aError, aFile );
+#endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+                break;
+            default:
+                break;
+            }
+        CleanupStack::PopAndDestroy(previewUri16);
+        previewUri16 = NULL;
+
+        // behave based on user's action
+        switch (buttonCode)
+            {
+            case 1:
+                // activate rights
+                delete aEmbeddedPreviewUri;
+                aEmbeddedPreviewUri = NULL;
+                GetRightsIssuerL( *content, rightsIssuer );
+                CleanupStack::PushL( rightsIssuer );
+                LaunchBrowserL( rightsIssuer );
+                CleanupStack::PopAndDestroy(rightsIssuer);
+
+                // check if we can use the file now
+                if ( content->EvaluateIntent( ContentAccess::EUnknown ) == KErrNone )
+                    {
+                    r = KErrNone;
+                    }
+                else
+                    {
+                    r = KErrCompletion;
+                    }
+                break;
+            case 2:
+                // get preview or play preview
+                if (previewType == ContentAccess::EPreviewRights)
+                    {
+                    CleanupStack::PushL(aEmbeddedPreviewUri);
+                    CDrmHelperDownloadManager* dlMgr =
+                        CDrmHelperDownloadManager::NewL();
+                    CleanupStack::PushL( dlMgr );
+
+                    if ( iUseCoeEnv )
+                        {
+                        TRAP(r, dlMgr->DownloadAndHandleRoapTriggerL(
+                                aEmbeddedPreviewUri, *iCoeEnv ) );
+                        // ignore error
+                        }
+                    else
+                        {
+                        TRAP(r, dlMgr->DownloadAndHandleRoapTriggerL( aEmbeddedPreviewUri ) );
+                        // ignore error
+                        }
+
+                    CleanupStack::PopAndDestroy( dlMgr );
+                    CleanupStack::PopAndDestroy( aEmbeddedPreviewUri );
+                    aEmbeddedPreviewUri = NULL;
+
+                    // check if we can use the file now
+                    r = content->EvaluateIntent( ContentAccess::EUnknown );
+                    LeaveIfWrongReturnForHandleErrorOrPreviewL( r );
+                    }
+                else
+                    {
+                    r = KErrNone;
+                    }
+                break;
+            case 0:
+            default:
+                // cancelled or no preview
+                delete aEmbeddedPreviewUri;
+                aEmbeddedPreviewUri = NULL;
+                if ( previewType != ContentAccess::ENoPreview )
+                    {
+                    r = KErrCancel;
+                    }
+                break;
+            }
+        }
+    if ( iReturnCancel )
+        {
+        // Cancel pressed in query intitiated from HandleErrorL
+        r = KErrCancel;
+        }
+    CleanupStack::PopAndDestroy(content);
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HandleErrorOrPreviewL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::HandleErrorOrPreviewL(
+    TInt aError,
+    const TDesC& aFileName,
+    HBufC8*& aEmbeddedPreviewUri )
+    {
+    RFile file;
+    TInt r = KErrNone;
+
+    r = file.Open(iFs, aFileName, EFileRead | EFileShareReadersOrWriters);
+
+    if (r == KErrInUse)
+        {
+        r = file.Open(iFs, aFileName, EFileRead | EFileShareAny);
+        if (r == KErrInUse)
+            {
+            r = file.Open(iFs, aFileName, EFileRead | EFileShareReadersOnly);
+            }
+        }
+    User::LeaveIfError(r);
+    CleanupClosePushL( file );
+    r = HandleErrorOrPreviewL( aError, file, aEmbeddedPreviewUri );
+    CleanupStack::PopAndDestroy( &file );
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetPreviewMediaType
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetPreviewMediaType( TDRMHelperPreviewMediaType aMediaType )
+    {
+    iPreviewMediaType = aMediaType;
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CheckPreviewUriL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::CheckPreviewUriL(
+    const CData* aContent,
+    HBufC*& aEmbeddedPreviewUri,
+    TInt& aPreviewType )
+    {
+    TPtr ptr(NULL,0);
+    TInt error = 0;
+    aPreviewType = ContentAccess::ENoPreview;
+    aEmbeddedPreviewUri = HBufC::NewLC( KUrlMaxLen );
+    ptr.Set(aEmbeddedPreviewUri->Des());
+    error = aContent->GetStringAttribute( EInstantPreviewUri , ptr );
+    if (!error && ptr.Length()>0)
+        {
+        // embedded preview
+        aPreviewType = ContentAccess::EInstantPreview;
+        }
+    else
+        {
+        error = aContent->GetStringAttribute( EPreviewRightsUri , ptr );
+        if (!error && ptr.Length()>0)
+            {
+            // preview rights url
+            aPreviewType = ContentAccess::EPreviewRights;
+            }
+        }
+    if (aPreviewType == ContentAccess::ENoPreview)
+        {
+        CleanupStack::PopAndDestroy(aEmbeddedPreviewUri);
+        aEmbeddedPreviewUri = NULL;
+        }
+    else
+        {
+        CleanupStack::Pop(aEmbeddedPreviewUri);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DisplayPopupWindowsForPreviewL
+// -----------------------------------------------------------------------------
+//
+#ifdef RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+TInt CDRMHelper::DisplayPopupWindowsForPreviewL( TInt aPreviewType )
+    {
+    TInt buttonCode = 0;
+    CAknListQueryDialog* dlg;
+    TInt index( 0 );
+    TInt resourceId = -1;
+    TInt answer = 0;
+
+    if (aPreviewType == ContentAccess::EPreviewRights)
+        {
+        // preview rights
+        if (iPreviewMediaType == EPreviewTypeAudio)
+            {
+            resourceId = R_DRMHELPER_PREV_AUDIO_GET_LIST_QUERY;
+            }
+        else if (iPreviewMediaType == EPreviewTypeVideo)
+            {
+            resourceId = R_DRMHELPER_PREV_VIDEO_GET_LIST_QUERY;
+            }
+        }
+    else if (aPreviewType == ContentAccess::EInstantPreview)
+        {
+        // embedded preview
+        if (iPreviewMediaType == EPreviewTypeAudio)
+            {
+            resourceId = R_DRMHELPER_PREV_AUDIO_PLAY_LIST_QUERY;
+            }
+        else if (iPreviewMediaType == EPreviewTypeVideo)
+            {
+            resourceId = R_DRMHELPER_PREV_VIDEO_PLAY_LIST_QUERY;
+            }
+        }
+
+
+    if (resourceId != -1)
+        {
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        TFileName fileName( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDrive, "%c:");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+        iFs.DriveToChar( driveNumber, driveLetter );
+
+        TFileName fileName;
+
+        fileName.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+        fileName.Append( KDC_RESOURCE_FILES_DIR );
+        fileName.Append( KCDRMHelperResFileName );
+        RConeResourceLoader loader( *iCoeEnv );
+        loader.OpenL( fileName );
+        CleanupClosePushL( loader );
+
+        dlg = new( ELeave ) CAknListQueryDialog( &index );
+        CleanupStack::PushL( dlg );
+
+        PrepareSecondaryDisplayL( *dlg, resourceId );
+
+        CleanupStack::Pop( dlg );
+
+        answer = dlg->ExecuteLD( resourceId );
+
+        CancelSecondaryDisplayL( resourceId );
+
+        CleanupStack::PopAndDestroy( &loader );
+        }
+
+    if ( answer )
+        {
+        buttonCode = index+1;
+        }
+    else
+        {
+        buttonCode = 0;
+        }
+
+    iPreviewMediaType = -1; // reset preview type
+    return buttonCode;
+    }
+#else // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+TInt CDRMHelper::DisplayPopupWindowsForPreviewL( TInt /* aPreviewType */ )
+    {
+    return 0;
+    }
+#endif // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HasPreviewL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMHelper::TDRMHelperPreviewType CDRMHelper::HasPreviewL(
+    CData& aContent,
+    HBufC8*& aPreviewUri )
+    {
+    TDRMHelperPreviewType ret( ENoPreview );
+    if ( iOma2 )
+        {
+        TInt error;
+        TInt silent(0);
+        TInt previewRightsType;
+        TBuf<KUrlMaxLen> previewUrl;
+        TInt previewType( ENoPreview );
+        aContent.GetAttribute( EPreviewType, previewType );
+        switch ( previewType )
+            {
+            case EInstantPreview:
+                // get URI of embedded preview
+                error = aContent.GetStringAttribute( EInstantPreviewUri,
+                    previewUrl );
+                if ( !error )
+                    {
+                    ret = EEmbeddedPreview;
+                    aPreviewUri = HBufC8::NewL( previewUrl.Length() );
+                    aPreviewUri->Des().Copy( previewUrl );
+                    }
+                break;
+            case EPreviewRights:
+                // Check if it is silent preview
+                aContent.GetAttribute( ESilentRightsType, silent );
+                previewRightsType =
+                    silent ? ESilentRightsUrl : EPreviewRightsUri;
+                error = aContent.GetStringAttribute( previewRightsType,
+                    previewUrl );
+                if ( !error )
+                    {
+                    ret = EPreviewRights;
+                    aPreviewUri = HBufC8::NewL( previewUrl.Length() );
+                    aPreviewUri->Des().Copy( previewUrl );
+                    }
+                break;
+            default:
+                // no preview
+                break;
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HasPreviewL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMHelper::TDRMHelperPreviewType CDRMHelper::HasPreviewL(
+    TDesC& aFileName,
+    HBufC8*& aPreviewUri )
+    {
+    TDRMHelperPreviewType ret( ENoPreview );
+    if ( iOma2 )
+        {
+        TVirtualPathPtr virtualPath( aFileName );
+
+        CData* content = NULL;
+        TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+        if ( r == KErrInUse )
+            {
+            content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+            }
+        else
+            {
+            User::LeaveIfError( r );
+            }
+
+        CleanupStack::PushL( content );
+
+        ret = HasPreviewL( *content, aPreviewUri );
+        CleanupStack::PopAndDestroy( content );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetPreviewRightsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetPreviewRightsL( CData& aContent )
+    {
+    if ( iOma2 )
+        {
+        HBufC8* previewUri = NULL;
+        TDRMHelperPreviewType previewType = HasPreviewL( aContent, previewUri );
+        CleanupStack::PushL( previewUri );
+        if ( previewType == EPreviewRights )
+            {
+            TInt silent(0);
+            // Check if it is silent preview
+            aContent.GetAttribute( ESilentRightsType, silent );
+            if ( silent )
+                {
+                CDrmHelperDownloadManager* dlMgr =
+                    CDrmHelperDownloadManager::NewL();
+                CleanupStack::PushL( dlMgr );
+
+                if ( iUseCoeEnv )
+                    {
+                    dlMgr->DownloadAndHandleRoapTriggerL( previewUri, *iCoeEnv );
+                    }
+                else
+                    {
+                    dlMgr->DownloadAndHandleRoapTriggerL( previewUri );
+                    }
+
+                CleanupStack::PopAndDestroy( dlMgr );
+                }
+            else
+                {
+                // launch browser
+                LaunchBrowserL( previewUri );
+                }
+            }
+        else
+            {
+            // No preview rights available, this function should not be called
+            User::Leave( KErrArgument );
+            }
+        CleanupStack::PopAndDestroy( previewUri );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetPreviewRightsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetPreviewRightsL(TDesC& aFileName )
+    {
+    if ( iOma2 )
+        {
+        TVirtualPathPtr virtualPath( aFileName );
+
+        CData* content( NULL );
+        TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+        if ( r == KErrInUse )
+            {
+            content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+            }
+        else
+            {
+            User::LeaveIfError( r );
+            }
+
+        CleanupStack::PushL( content );
+
+        GetPreviewRightsL( *content );
+        CleanupStack::PopAndDestroy( content );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::EmbeddedPreviewCompletedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelper::EmbeddedPreviewCompletedL( CData& aContent )
+    {
+    TBool proceeded = EFalse;
+    if ( iOma2 )
+        {
+        TInt error = KErrNone;
+        TInt canPlay;
+        HBufC* rightsIssuer = NULL;
+        TInt buyRights(0);
+
+        error = aContent.GetAttribute( ECanPlay, canPlay );
+        if ( !error && !canPlay )
+            {
+            TFileName fileName;
+
+            // Get RI URL
+            GetRightsIssuerL( aContent, rightsIssuer );
+            CleanupStack::PushL( rightsIssuer );
+            // Ask if user wants to buy rights
+            error = aContent.GetStringAttribute( EFileName, fileName );
+            if ( !error )
+                {
+                if ( buyRights )
+                    {
+                    // launch browser
+                    LaunchBrowserL( rightsIssuer );
+                    proceeded = ETrue;
+                    }
+                else
+                    {
+                    proceeded = EFalse;
+                    }
+                }
+            else
+                {
+                User::Leave( KErrArgument );
+                }
+            CleanupStack::PopAndDestroy( rightsIssuer );
+            }
+        else
+            {
+            User::Leave( KErrArgument );
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    return proceeded;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::EmbeddedPreviewCompletedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelper::EmbeddedPreviewCompletedL( TDesC& aFileName )
+    {
+    TBool proceeded( EFalse );
+    if ( iOma2 )
+        {
+        TVirtualPathPtr virtualPath( aFileName );
+
+        CData* content( NULL );
+        TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+        if ( r == KErrInUse )
+            {
+            content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+            }
+        else
+            {
+            User::LeaveIfError( r );
+            }
+
+        CleanupStack::PushL( content );
+
+        proceeded = EmbeddedPreviewCompletedL( *content );
+        CleanupStack::PopAndDestroy( content );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    return proceeded;
+    }
+
+#ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
+HBufC8* CDRMHelper::HasSilentRightsUrlL( CData* aContent )
+    {
+    HBufC* url = NULL;
+    HBufC8* url8 = NULL;
+    HBufC8* r = NULL;
+    TPtr urlDes( NULL, 0);
+    Roap::RRoapStorageClient storage;
+
+    url = HBufC::NewLC( KMaxPath * 4 );
+    urlDes.Set( url->Des() );
+    if ( aContent->GetStringAttribute( ESilentRightsUrl, urlDes ) == KErrNone )
+        {
+        url8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *url );
+        CleanupStack::PushL( url8 );
+        User::LeaveIfError( storage.Connect() );
+        CleanupClosePushL( storage );
+        // check that SilentRightsUrl is on the white list
+        // URL is not searched from pre-configured white list
+        TBool fromPreConfiguredWhiteList( EFalse );
+        if ( storage.WhiteListURLExistsL( *url8, fromPreConfiguredWhiteList ) )
+            {
+            r = url8->AllocL();
+            }
+        CleanupStack::PopAndDestroy( &storage );
+        CleanupStack::PopAndDestroy( url8 );
+        }
+    CleanupStack::PopAndDestroy( url );
+
+    return r;
+    }
+#else
+HBufC8* CDRMHelper::HasSilentRightsUrlL( CData* /*aContent*/ )
+    {
+    return NULL;
+    }
+#endif
+
+
+TInt CDRMHelper::GetSilentRightsL( const TDesC8& aUrl )
+    {
+    TInt r = KErrCancel;
+#ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
+    TInt buttonCode = EAknSoftkeyYes;
+    HBufC8* url = NULL;
+
+    if ( !SilentRightsAllowedL() )
+        {
+        buttonCode = DisplayQueryWithIdL( R_DRM_QRY_CONNECT_TO_ACTIVATE,
+            R_DRMHELPER_CONFIRMATION_QUERY );
+        }
+    else if ( !BrowserAPDefinedL() )
+        {
+        buttonCode = DisplayQueryWithIdL( R_DRM_QRY_CONNECT_TO_ACTIVATE,
+            R_DRMHELPER_CONFIRMATION_QUERY );
+        }
+
+    if ( buttonCode == EAknSoftkeyYes )
+        {
+        // check if there are any APs defined
+        RCmManager cmManager;
+        cmManager.OpenLC();
+        RArray<TUint32> aps;
+        CleanupClosePushL( aps );
+        cmManager.ConnectionMethodL( aps, EFalse, EFalse, ETrue );
+        TUint32 APs( aps.Count() );
+        CleanupStack::PopAndDestroy( 2, &cmManager ); //aps, cmManager
+        if ( !APs )
+            {
+            // No AP defined
+            DisplayInfoNoteL( R_DRM_WARN_NO_CONN_DEFINED );
+            r = KErrCANoRights;
+            }
+        else
+            {
+            // ok to start download
+            CDrmHelperDownloadManager* dlMgr = CDrmHelperDownloadManager::NewL();
+            CleanupStack::PushL( dlMgr );
+            url = aUrl.AllocLC();
+
+            if ( iUseCoeEnv )
+                {
+                TRAP(r, dlMgr->DownloadAndHandleRoapTriggerL( url, *iCoeEnv ) );
+                }
+            else
+                {
+                TRAP(r, dlMgr->DownloadAndHandleRoapTriggerL( url ) );
+                }
+            CleanupStack::PopAndDestroy( url );
+
+            if ( r != KErrNone )
+                {
+                // rights were tried to get only if the user hasn't cancelled
+                if ( r != KErrCancel )
+                    {
+                    if ( r == KErrCouldNotConnect )
+                        {
+                        // Connection failed with selected AP
+                        DisplayInfoNoteL( R_DRM_WARN_INVALID_OR_NO_AP );
+                        r = KErrCANoRights;
+                        }
+                    else
+                        {
+                        // get error url
+                        HBufC8* errorUrl = NULL;
+                        errorUrl = dlMgr->GetErrorUrlL();
+                        CleanupStack::PushL( errorUrl );
+
+                        // error url is got only if temporary roap error
+                        if ( errorUrl )
+                            {
+                            // ask user whether error url should be opened
+                            buttonCode = DisplayQueryWithIdL( R_DRM_QUERY_OPEN_ERROR_URL,
+                                R_DRMHELPER_CONFIRMATION_QUERY );
+                            if ( buttonCode == EAknSoftkeyYes )
+                                {
+                                // Launch browser
+                                LaunchBrowserL( errorUrl );
+                                }
+                            }
+                        else
+                            {
+                            DisplayInfoNoteL( R_DRM_ERR_OPENING_FAIL_PERM );
+                            }
+
+                        CleanupStack::PopAndDestroy( errorUrl );
+                        }
+                    }
+                }
+            CleanupStack::PopAndDestroy( dlMgr );
+            }
+        }
+#endif // RD_DRM_SILENT_RIGHTS_ACQUISITION
+    return r;
+    }
+
+
+TBool CDRMHelper::SilentRightsAllowedL()
+    {
+#ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
+    TInt value = KErrNone;
+    CRepository* repository = CRepository::NewL( KCRUidDRMSettings );
+    repository->Get( KDRMSettingsSilentRightsAcquisition, value );
+    delete repository;
+    return (value == 0 ? EFalse: ETrue);
+#else
+    return EFalse;
+#endif
+    }
+
+
+TBool CDRMHelper::BrowserAPDefinedL()
+    {
+    const TInt KDestinationSelectionMode( 2 );
+    TInt err( KErrNone );
+    TInt ap( 0 );
+    TInt alwaysAsk( 0 );
+    TInt defaultSnap( 0 );
+
+    CRepository* repository( CRepository::NewL( KCRUidBrowser ) );
+    repository->Get( KBrowserDefaultAccessPoint, ap );
+    repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
+    repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
+    delete repository;
+    if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
+        {
+        alwaysAsk = ETrue;
+        }
+    else
+        {
+        RCmManager cmManager;
+        cmManager.OpenLC();
+        if ( !alwaysAsk )
+            {
+            TRAP( err, cmManager.GetConnectionMethodInfoIntL(
+                    ap, CMManager::ECmIapId ) );
+            }
+        else if ( alwaysAsk == KDestinationSelectionMode )
+            {
+            TRAP( err, IapIdOfDefaultSnapL( cmManager, defaultSnap ) );
+            }
+        CleanupStack::PopAndDestroy( &cmManager );
+        if ( !err && ( !alwaysAsk || alwaysAsk == KDestinationSelectionMode ) )
+            {
+            return ETrue;
+            }
+        }
+    return EFalse;
+    }
+
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CheckRightsPercentL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CheckRightsPercentL(
+    const TDesC& aFileName,
+    TInt aThreshold )
+    {
+    TInt ret(0);
+    HBufC* rightsIssuer = NULL;
+    HBufC* mimeType = NULL;
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TInt error( KErrNone );
+
+    // check that threshold value is within bounds
+    if ( aThreshold < 0 || aThreshold > 100 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TVirtualPathPtr virtualPath( aFileName, KDefaultContentObject );
+
+    CData* content = NULL;
+    TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( r == KErrInUse )
+        {
+        content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+        }
+    else
+        {
+        User::LeaveIfError( r );
+        }
+
+    CleanupStack::PushL( content );
+
+    // get rights-issuer URL
+    TRAPD(err, GetRightsIssuerL( *content, rightsIssuer ) );
+    if (!err )
+        {
+        CleanupStack::PushL( rightsIssuer );
+        }
+
+    mimeType = HBufC::NewLC( KMaxDataTypeLength );
+    contentURI = HBufC::NewLC( KUrlMaxLen );
+
+    // create attribute set
+    RStringAttributeSet stringAttributeSet;
+    CleanupClosePushL( stringAttributeSet );
+    // add the attributes we are interested in
+    stringAttributeSet.AddL( EContentID );
+    stringAttributeSet.AddL( EMimeType );
+
+    User::LeaveIfError( content->GetStringAttributeSet( stringAttributeSet ));
+
+    // pass on values of string attributes
+    TPtr ptr = contentURI->Des();
+    error = stringAttributeSet.GetValue( EContentID, ptr );
+    if ( error == KErrNone )
+        {
+        TPtr ptr2 = mimeType->Des();
+        error = stringAttributeSet.GetValue( EMimeType, ptr2 );
+        if ( error == KErrNone )
+            {
+            contentURI8 = HBufC8::NewLC( contentURI->Length() );
+            contentURI8->Des().Copy( contentURI->Des() );
+            ret = DoCheckRightsPercentL(
+                contentURI8,
+                mimeType,
+                rightsIssuer,
+                StripPathAndExtension( aFileName ),
+                aThreshold );
+            CleanupStack::PopAndDestroy( contentURI8 );
+            }
+        else
+            {
+            User::Leave( KErrArgument );
+            }
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    CleanupStack::PopAndDestroy(3, mimeType); // stringAttributeSet.Close(), contentURI, mimeType
+
+    if ( !err )
+        {
+        CleanupStack::PopAndDestroy( rightsIssuer );
+        }
+
+    CleanupStack::PopAndDestroy( content );
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CheckRightsPercentL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CheckRightsPercentL(
+    RFile& aFileHandle,
+    TInt aThreshold )
+    {
+    TInt ret(0);
+    HBufC* rightsIssuer = NULL;
+    HBufC* mimeType = NULL;
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TFileName fileName;
+    TInt error;
+
+    // check that threshold value is within bounds
+    if ( aThreshold < 0 || aThreshold > 100 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    CData* content = CData::NewLC( aFileHandle, KDefaultContentObject, EPeek );
+
+    // get rights-issuer URL
+    TRAPD(err, GetRightsIssuerL( *content, rightsIssuer ) );
+    if (!err )
+        {
+        CleanupStack::PushL( rightsIssuer );
+        }
+
+    mimeType = HBufC::NewLC( KMaxDataTypeLength );
+    contentURI = HBufC::NewLC( KUrlMaxLen );
+
+    // create attribute set
+    RStringAttributeSet stringAttributeSet;
+    CleanupClosePushL( stringAttributeSet );
+    // add the attributes we are interested in
+    stringAttributeSet.AddL( EContentID );
+    stringAttributeSet.AddL( EMimeType );
+
+    User::LeaveIfError( content->GetStringAttributeSet( stringAttributeSet ));
+
+    // pass on values of string attributes
+    TPtr ptr = contentURI->Des();
+    error = stringAttributeSet.GetValue( EContentID, ptr );
+    if ( error == KErrNone )
+        {
+        TPtr ptr2 = mimeType->Des();
+        error = stringAttributeSet.GetValue( EMimeType, ptr2 );
+        if ( error == KErrNone )
+            {
+            aFileHandle.Name( fileName );
+            contentURI8 = HBufC8::NewLC( contentURI->Length() );
+            contentURI8->Des().Copy( contentURI->Des() );
+            ret = DoCheckRightsPercentL(
+                contentURI8,
+                mimeType,
+                rightsIssuer,
+                StripPathAndExtension( fileName ),
+                aThreshold );
+            CleanupStack::PopAndDestroy( contentURI8 );
+            }
+        else
+            {
+            User::Leave( KErrArgument );
+            }
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    CleanupStack::PopAndDestroy(3, mimeType); // stringAttributeSet.Close(), contentURI, mimeType
+
+    if ( !err )
+        {
+        CleanupStack::PopAndDestroy( rightsIssuer );
+        }
+
+    CleanupStack::PopAndDestroy( content );
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CheckRightsAmountL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CheckRightsAmountL(
+    const TDesC& aFileName,
+    TInt aCount,
+    TInt aDays )
+    {
+    TInt ret(0);
+    HBufC* rightsIssuer = NULL;
+    HBufC* mimeType = NULL;
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TInt error( KErrNone );
+    TInt drmProtected(0);
+
+    // Leave if limit is negative
+    if ( aCount < 0 || aDays < 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TVirtualPathPtr virtualPath( aFileName, KDefaultContentObject );
+
+    CData* content( NULL );
+    TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( r == KErrInUse )
+        {
+        content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+        }
+    else
+        {
+        User::LeaveIfError( r );
+        }
+
+    CleanupStack::PushL( content );
+
+    User::LeaveIfError( content->GetAttribute( EIsProtected, drmProtected ) ) ;
+    if ( drmProtected ) // do nothing if non-DRM file
+        {
+        // get rights-issuer URL
+        TRAPD(err, GetRightsIssuerL( *content, rightsIssuer ) );
+        if (!err )
+            {
+            CleanupStack::PushL( rightsIssuer );
+            }
+
+        mimeType = HBufC::NewLC( KMaxDataTypeLength );
+        contentURI = HBufC::NewLC( KUrlMaxLen );
+
+        // create attribute set
+        RStringAttributeSet stringAttributeSet;
+        CleanupClosePushL( stringAttributeSet );
+        // add the attributes we are interested in
+        stringAttributeSet.AddL( EContentID );
+        stringAttributeSet.AddL( EMimeType );
+
+        User::LeaveIfError( content->GetStringAttributeSet( stringAttributeSet ));
+
+        // pass on values of string attributes
+        TPtr ptr = contentURI->Des();
+        error = stringAttributeSet.GetValue( EContentID, ptr );
+        if ( error == KErrNone )
+            {
+            TPtr ptr2 = mimeType->Des();
+            error = stringAttributeSet.GetValue( EMimeType, ptr2 );
+            if ( error == KErrNone )
+                {
+                contentURI8 = HBufC8::NewLC( contentURI->Length() );
+                contentURI8->Des().Copy( contentURI->Des() );
+                ret = DoCheckRightsAmountL(
+                    contentURI8,
+                    mimeType,
+                    rightsIssuer,
+                    StripPathAndExtension( aFileName ),
+                    aCount,
+                    aDays );
+                CleanupStack::PopAndDestroy( contentURI8 );
+                }
+            else
+                {
+                User::Leave( KErrArgument );
+                }
+            }
+        else
+            {
+            User::Leave( KErrArgument );
+            }
+
+        CleanupStack::PopAndDestroy(3, mimeType); // stringAttributeSet.Close(), contentURI, mimeType
+
+        if ( !err )
+            {
+            CleanupStack::PopAndDestroy( rightsIssuer );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( content );
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CheckRightsAmountL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CheckRightsAmountL(
+    RFile& aFileHandle,
+    TInt aCount,
+    TInt aDays )
+    {
+    TInt ret(0);
+    HBufC* rightsIssuer = NULL;
+    HBufC* mimeType = NULL;
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TFileName fileName;
+    TInt error;
+    TInt drmProtected(0);
+
+    // Leave if limit is negative
+    if ( aCount < 0 || aDays < 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    CData* content = CData::NewLC( aFileHandle, KDefaultContentObject, EPeek );
+    User::LeaveIfError( content->GetAttribute( EIsProtected, drmProtected ) ) ;
+    if ( drmProtected ) // do nothing if non-DRM file
+        {
+        // get rights-issuer URL
+        TRAPD(err, GetRightsIssuerL( *content, rightsIssuer ) );
+        if (!err )
+            {
+            CleanupStack::PushL( rightsIssuer );
+            }
+
+        mimeType = HBufC::NewLC( KMaxDataTypeLength );
+        contentURI = HBufC::NewLC( KUrlMaxLen );
+
+        // create attribute set
+        RStringAttributeSet stringAttributeSet;
+        CleanupClosePushL( stringAttributeSet );
+        // add the attributes we are interested in
+        stringAttributeSet.AddL( EContentID );
+        stringAttributeSet.AddL( EMimeType );
+
+        User::LeaveIfError( content->GetStringAttributeSet( stringAttributeSet ));
+
+        // pass on values of string attributes
+        TPtr ptr = contentURI->Des();
+        error = stringAttributeSet.GetValue( EContentID, ptr );
+        if ( error == KErrNone )
+            {
+            TPtr ptr2 = mimeType->Des();
+            error = stringAttributeSet.GetValue( EMimeType, ptr2 );
+            if ( error == KErrNone )
+                {
+                aFileHandle.Name( fileName );
+                contentURI8 = HBufC8::NewLC( contentURI->Length() );
+                contentURI8->Des().Copy( contentURI->Des() );
+                ret = DoCheckRightsAmountL(
+                    contentURI8,
+                    mimeType,
+                    rightsIssuer,
+                    StripPathAndExtension( fileName ),
+                    aCount,
+                    aDays );
+                CleanupStack::PopAndDestroy( contentURI8 );
+
+                }
+            else
+                {
+                User::Leave( KErrArgument );
+                }
+            }
+        else
+            {
+            User::Leave( KErrArgument );
+            }
+
+        CleanupStack::PopAndDestroy(3, mimeType); // stringAttributeSet.Close(), contentURI, mimeType
+
+        if ( !err )
+            {
+            CleanupStack::PopAndDestroy( rightsIssuer );
+            }
+
+        }
+    CleanupStack::PopAndDestroy( content );
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CheckRightsAmountL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CheckRightsAmountL(
+    const TDesC8& aUri,
+    TInt aCount,
+    TInt aDays )
+    {
+    TInt buttonCode( 0 );
+    RFile fileHandle;
+
+    CleanupClosePushL( fileHandle );
+    if ( !GetFileHandleFromURIL( aUri, fileHandle ) )
+        {
+        buttonCode = CheckRightsAmountL( fileHandle, aCount, aDays );
+        }
+    CleanupStack::PopAndDestroy( &fileHandle );
+    return buttonCode;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DoCheckRightsPercentL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DoCheckRightsPercentL(
+    HBufC8* aContentUri,
+    HBufC* aMimeType,
+    HBufC* aRIUrl,
+    const TDesC& aFileName,
+    TInt aThreshold )
+    {
+    TInt buttonCode(0);
+    TUint32 originalValue(0);
+    TTimeIntervalDays duration(0);
+    CDRMRightsConstraints* constraint = NULL;
+    TInt mask(0);
+    CDRMRights::TRestriction restriction;
+    CDRMRights::TExpiration expiration;
+    TUint32 constType;
+
+    // get original amount of rights
+    if ( aContentUri )
+        {
+        TInt intent = Intent( aMimeType );
+        CDRMRights* rights = NULL; // rights object
+
+        if ( iDRMCommon->GetActiveRights( *aContentUri, intent, rights ) ==
+            DRMCommon::ENoRights )
+            {
+            //no rights for given content URI, handle error
+            buttonCode = DoHandleErrorL( DRMCommon::ENoRights, aContentUri,
+                aMimeType, aRIUrl, NULL, NULL, NULL, NULL, aFileName );
+            }
+        else
+            {
+            User::LeaveIfNull( rights );
+
+            rights->GetRightsInfo( intent, restriction, expiration,
+                constType );
+
+            // No need to do anything for full or preview rights
+            if ( restriction == CDRMRights::ERestrictedRights )
+                {
+                if ( expiration == CDRMRights::EExpiredRights ||
+                    expiration == CDRMRights::EFutureRights )
+                    {
+                    // rights expired or not yet valid for given content URI,
+                    // handle error
+                    buttonCode = DoHandleErrorL( DRMCommon::ERightsExpired,
+                        aContentUri, aMimeType, aRIUrl, NULL, NULL, NULL, NULL, aFileName );
+                    }
+                else
+                    {
+                    if ( (intent == DRMCommon::EPlay) &&
+                        rights->GetPlayRight( constraint ) ==
+                        DRMCommon::EOk )
+                        {
+                        mask = GetCounts( constraint, originalValue,
+                            duration );
+                        }
+                    delete constraint;
+                    constraint = NULL;
+
+                    if ( (intent == DRMCommon::EDisplay) &&
+                        rights->GetDisplayRight( constraint ) ==
+                        DRMCommon::EOk )
+                        {
+                        mask = GetCounts( constraint, originalValue,
+                            duration );
+                        }
+                    delete constraint;
+                    constraint = NULL;
+
+                    if ( (intent == DRMCommon::EPrint) &&
+                        rights->GetPrintRight( constraint ) ==
+                        DRMCommon::EOk )
+                        {
+                        mask = GetCounts( constraint, originalValue,
+                            duration );
+                        }
+                    delete constraint;
+                    constraint = NULL;
+
+                    if ( (intent == DRMCommon::EExecute) &&
+                        rights->GetExecuteRight( constraint ) ==
+                        DRMCommon::EOk )
+                        {
+                        mask = GetCounts( constraint, originalValue,
+                            duration );
+                        }
+                    delete constraint;
+                    constraint = NULL;
+                    }
+                }
+            delete rights;
+            }
+
+        // calculate new threshold values and call next function
+        switch ( mask )
+            {
+            case KDRMHelperConstraintCount:
+                buttonCode = DoCheckRightsAmountL( aContentUri,
+                    aMimeType, aRIUrl, aFileName,
+                    (aThreshold * originalValue) / 100,
+                    KDRMHelperDefaultTimeThreshold );
+                break;
+
+            case KDRMHelperConstraintTime:
+                buttonCode = DoCheckRightsAmountL( aContentUri,
+                    aMimeType, aRIUrl, aFileName,
+                    KDRMHelperDefaultCountThreshold,
+                    (aThreshold * duration.Int()) / 100 );
+                break;
+
+            case (KDRMHelperConstraintCount | KDRMHelperConstraintTime):
+                buttonCode = DoCheckRightsAmountL( aContentUri,
+                    aMimeType, aRIUrl, aFileName,
+                    (aThreshold * originalValue) / 100,
+                    (aThreshold * duration.Int()) / 100 );
+                break;
+
+            default:
+                break;
+            }
+        }
+    return buttonCode;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DoCheckRightsAmountL
+// -----------------------------------------------------------------------------
+//
+#ifndef RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+TInt CDRMHelper::DoCheckRightsAmountL(
+    HBufC8* aContentUri,
+    HBufC* aMimeType,
+    HBufC* aRIUrl,
+    const TDesC& aFileName,
+    TInt aCount,
+    TInt aDays )
+#else // RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+TInt CDRMHelper::DoCheckRightsAmountL(
+    HBufC8* aContentUri,
+    HBufC* aMimeType,
+    HBufC* aRIUrl,
+    const TDesC& aFileName,
+    TInt /* aCount */,
+    TInt /* aDays */ )
+#endif // RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+    {
+    TInt errorButton(0); // button code returned by HandleErrorL
+    TInt buttonCode(0); // button code to be returned
+#ifndef RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+    TUint32 countsLeft(0); // number of counts left
+    TTime endTime; // end time of time-based rights
+    TTimeIntervalDays daysLeft(0); // days until end of time-based rights
+    TTimeIntervalMinutes minutesLeft(0); // minutes until end of time-based rights
+    TInt mask(0); // tells if object has count or time based rights
+#endif // RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+    TTime now; // current time
+    RDRMRightsClient client;
+    CDRMPointerArray<HBufC8>* individual = NULL;
+    TUint32 reason = 0;
+
+    now.HomeTime();
+    if ( aContentUri )
+        {
+        TIntent intent = static_cast<TIntent>( Intent( aMimeType ) );
+        TRightsType type;
+        CDRMPermission* permission = NULL;
+
+        User::LeaveIfError( client.Connect() );
+        CleanupClosePushL( client );
+        permission = client.GetActiveRightsL( intent, *aContentUri, reason );
+
+        if ( !permission )
+            {
+            CleanupStack::PopAndDestroy( &client );
+            //no rights for given content URI, handle error
+            errorButton = DoHandleErrorL( DRMCommon::ENoRights, aContentUri,
+                aMimeType, aRIUrl, NULL, NULL, NULL, NULL, aFileName );
+            }
+        else
+            {
+            // rights object found
+            CleanupStack::PushL( permission );
+            individual = CDRMPointerArray<HBufC8>::NewLC();
+            individual->SetAutoCleanup(ETrue);
+            client.GetSupportedIndividualsL( *individual );
+            switch ( intent )
+                {
+                case EPlay: type = ERightsPlay; break;
+                case EView: type = ERightsDisplay; break;
+                case EPrint: type = ERightsPrint; break;
+                case EExecute: type = ERightsExecute; break;
+                default: type = ERightsAll; break;
+                }
+            if ( !permission->Valid( now, *individual, reason, type ) )
+                {
+                //rights expired for given content URI, handle error
+                errorButton = DoHandleErrorL(
+                    DRMCommon::ERightsExpired, aContentUri,
+                    aMimeType, aRIUrl, NULL, NULL, NULL, NULL, aFileName );
+                }
+#ifndef RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+            else
+                {
+                CDRMConstraint* constraint;
+                constraint = permission->ConstraintForIntent( intent );
+                if ( constraint )
+                    {
+                    _LIT8( KForwardLockCidStartString, "flk:" );
+                    TInt matchFound =
+                        aContentUri->FindF( KForwardLockCidStartString );
+                    // Don't display about to expire note for preview
+                    // note SD with 1 count is not a preview
+                    // unless in FL and not having RI URL
+                    if ( constraint->iOriginalCounter != 1 ||
+                        matchFound == KErrNotFound ||
+                        matchFound > 0 || // flk not found at beginning
+                        ( aRIUrl && aRIUrl->Length() > 0 ) )
+                        {
+                        mask = GetCounts( constraint, countsLeft, endTime );
+                        }
+                    }
+                }
+#endif // RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+            CleanupStack::PopAndDestroy( individual );
+            CleanupStack::PopAndDestroy( permission );
+            CleanupStack::PopAndDestroy( &client );
+            }
+
+#ifndef RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+        // calculate days left in case of time based constraint
+        if ( mask & ( KDRMHelperConstraintTime | KDRMHelperConstraintAccumulated ) )
+            {
+            daysLeft = endTime.DaysFrom( now );
+            endTime.MinutesFrom( now, minutesLeft );
+            }
+
+        // display correct warning note if needed.
+        switch ( mask )
+            {
+            case KDRMHelperConstraintCount:
+                if ( countsLeft == 1 )
+                    {
+                    if ( aRIUrl && aRIUrl->Length() > 0 )
+                        {
+                        buttonCode = DisplayQueryWithIdL(
+                            R_DRMHELPER_QUERY_EXP_1_USE_GET_NEW,
+                            R_DRMHELPER_CONFIRMATION_QUERY );
+                        }
+                    else
+                        {
+                        DisplayInfoNoteL( R_DRMHELPER_INFO_EXP_1_USE );
+                        }
+                    }
+                else
+                    {
+                    if ( countsLeft <= (TUint32)aCount )
+                        {
+                        if ( aRIUrl && aRIUrl->Length() > 0 )
+                            {
+                            buttonCode = DisplayQueryL(
+                                R_DRMHELPER_QUERY_EXP_N_USE_GET_NEW,
+                                countsLeft );
+                            }
+                        else
+                            {
+                            DisplayInfoNoteL( R_DRMHELPER_INFO_EXP_N_USES , countsLeft );
+                            }
+                        }
+
+                    }
+                break;
+
+            case KDRMHelperConstraintTime:
+                if ( daysLeft.Int() == 1 )
+                    {
+                    if ( aRIUrl && aRIUrl->Length() > 0 )
+                        {
+                        buttonCode = DisplayQueryWithIdL(
+                            R_DRMHELPER_QUERY_EXP_1_DAY_GET_NEW,
+                            R_DRMHELPER_CONFIRMATION_QUERY );
+                        }
+                    else
+                        {
+                        DisplayInfoNoteL( R_DRMHELPER_INFO_EXP_1_DAY );
+                        }
+                    }
+                else
+                    {
+                    if ( daysLeft.Int() < aDays )
+                        {
+                        if ( aRIUrl && aRIUrl->Length() > 0 )
+                            {
+                            buttonCode = DisplayQueryL(
+                                R_DRMHELPER_QUERY_EXP_N_DAY_GET_NEW,
+                                daysLeft.Int() );
+                            }
+                        else
+                            {
+                            DisplayInfoNoteL( R_DRMHELPER_INFO_EXP_N_DAYS , daysLeft.Int() );
+                            }
+                        }
+                    }
+                break;
+
+            case KDRMHelperConstraintAccumulated:
+                if ( minutesLeft.Int() == 1 )
+                    {
+                    buttonCode = DisplayQueryWithIdL(
+                        R_DRMHELPER_QUERY_EXP_1_MIN_GET_NEW,
+                        R_DRMHELPER_CONFIRMATION_QUERY );
+                    }
+                else
+                    {
+                    if ( daysLeft.Int() < KDRMHelperAccumulatedTimeLimit )
+                        {
+                        buttonCode = DisplayQueryL(
+                            R_DRMHELPER_QUERY_EXP_N_MIN_GET_NEW,
+                            minutesLeft.Int() );
+                        }
+                    }
+                break;
+
+            case (KDRMHelperConstraintTime | KDRMHelperConstraintAccumulated):
+            case (KDRMHelperConstraintCount | KDRMHelperConstraintAccumulated):
+            case (KDRMHelperConstraintCount | KDRMHelperConstraintTime):
+                if ( countsLeft <= (TUint32)aCount || daysLeft.Int() < aDays )
+            {
+            if ( aRIUrl && aRIUrl->Length() > 0 )
+                {
+                buttonCode = DisplayQueryWithIdL(
+                    R_DRMHELPER_QUERY_EXP_MANY_CONSTR,
+                    R_DRMHELPER_CONFIRMATION_QUERY );
+
+                }
+            else
+                {
+                buttonCode = DisplayQueryWithIdL(
+                    R_DRMHELPER_USAGE_RIGHTS_TO_EXPIRE,
+                    R_DRMHELPER_CONFIRMATION_QUERY );
+                if ( buttonCode )
+                    {
+                    LaunchDetailsViewEmbeddedL( aContentUri );
+                    buttonCode = 0;
+                    }
+                }
+
+            }
+                break;
+
+            default:
+                break;
+            }
+#endif // RD_DRM_REMOVAL_OF_EXPIRATION_WARNING_PROMPTS
+
+        // Launch details view if needed
+        if ( buttonCode == EAknSoftkeyYes )
+            {
+            LaunchBrowserL( aRIUrl );
+            }
+
+        if ( errorButton )
+            {
+            buttonCode = errorButton;
+            }
+        }
+    return buttonCode;
+    }
+
+EXPORT_C void CDRMHelper::SetCountLimitL( TUint /*aCounts*/ )
+    {
+    }
+
+EXPORT_C void CDRMHelper::SetTimeLimitL( TUint /*aDays*/ )
+    {
+    }
+
+EXPORT_C void CDRMHelper::SetPercentageLimitL( TUint /*aPercentage*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetCounts
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::GetCounts(
+    CDRMRightsConstraints* aConstraint,
+    TUint32& aOriginalCount,
+    TTimeIntervalDays& aDuration )
+    {
+    TInt ret(0);
+    TTime startTime;
+    TTime endTime;
+    TUint32 countsLeft;
+    TTimeIntervalSeconds interval;
+    TUint32 count(0);
+
+    aOriginalCount = KMaxTUint32;
+    interval = 0;
+    aDuration = 0;
+    if ( aConstraint->GetCounters( countsLeft, count ) ==
+        DRMCommon::EOk )
+        {
+        ret |= KDRMHelperConstraintCount;
+        aOriginalCount = count;
+        }
+    if ( aConstraint->GetTimedCounters( countsLeft, count ) ==
+        DRMCommon::EOk )
+        {
+        ret |= KDRMHelperConstraintCount;
+        aOriginalCount = Min( count, aOriginalCount );
+        }
+    if ( aConstraint->GetStartTime( startTime ) == DRMCommon::EOk )
+        {
+        aConstraint->GetEndTime( endTime );
+        aDuration = endTime.DaysFrom( startTime );
+        ret |= KDRMHelperConstraintTime;
+        }
+    if ( aConstraint->GetInterval( interval ) == DRMCommon::EOk )
+        {
+        // change to days
+        aDuration = interval.Int() / (60*60*24);
+        ret |= KDRMHelperConstraintTime;
+        }
+    if ( aConstraint->GetAccumulated( interval ) == DRMCommon::EOk )
+        {
+        // change to days
+        aDuration = Min( aDuration.Int(), interval.Int() / (60*60*24) );
+        ret |= KDRMHelperConstraintAccumulated;
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetCounts
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::GetCounts(
+    CDRMRightsConstraints* aConstraint,
+    TUint32& aCountsLeft,
+    TTime& aEndTime )
+    {
+    TInt ret(0);
+    TUint32 originalCount;
+    TTime start;
+    TTimeIntervalSeconds interval;
+    TUint32 count(0);
+
+    aCountsLeft = KMaxTUint32;
+    aEndTime = Time::NullTTime();
+    if ( aConstraint->GetCounters( count, originalCount ) ==
+        DRMCommon::EOk )
+        {
+        ret |= KDRMHelperConstraintCount;
+        aCountsLeft = count;
+        }
+    if ( aConstraint->GetTimedCounters( count, originalCount ) ==
+        DRMCommon::EOk )
+        {
+        ret |= KDRMHelperConstraintCount;
+        aCountsLeft = Min( count, aCountsLeft );
+        }
+    if ( aConstraint->GetEndTime( aEndTime ) == DRMCommon::EOk )
+        {
+        ret |= KDRMHelperConstraintTime;
+        }
+    if ( aConstraint->GetInterval( interval ) == DRMCommon::EOk )
+        {
+        if ( aConstraint->GetIntervalStart( start ) == DRMCommon::ENoRights )
+            {
+            // interval not yet started
+            start.HomeTime();
+            }
+        aEndTime = start + interval;
+        ret |= KDRMHelperConstraintTime;
+        }
+    if ( aConstraint->GetAccumulated( interval ) == DRMCommon::EOk )
+        {
+        if ( aEndTime != Time::NullTTime() &&
+            aEndTime + interval > aEndTime ||
+            aEndTime == Time::NullTTime() )
+            {
+            aEndTime.HomeTime();
+            aEndTime = aEndTime + interval;
+            ret |= KDRMHelperConstraintAccumulated;
+            }
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetCounts
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::GetCounts(
+    CDRMConstraint* aConstraint,
+    TUint32& aOriginalCount,
+    TTimeIntervalDays& aDuration )
+    {
+    TInt ret(0);
+    TTime endTime;
+
+    aOriginalCount = KMaxTUint32;
+    aDuration = 0;
+    if ( aConstraint->iActiveConstraints & EConstraintCounter ||
+        aConstraint->iActiveConstraints & EConstraintTimedCounter )
+        {
+        ret |= KDRMHelperConstraintCount;
+        aOriginalCount = aConstraint->iOriginalCounter;
+        }
+    if ( aConstraint->iActiveConstraints & EConstraintStartTime &&
+        aConstraint->iActiveConstraints & EConstraintEndTime )
+        {
+        aDuration = aConstraint->iEndTime.DaysFrom( aConstraint->iStartTime );
+        ret |= KDRMHelperConstraintTime;
+        }
+    if ( aConstraint->iActiveConstraints & EConstraintInterval )
+        {
+        // change to days
+        aDuration = aConstraint->iInterval.Int() / ( 60 * 60 * 24 );
+        ret |= KDRMHelperConstraintTime;
+        }
+    if ( aConstraint->iActiveConstraints & EConstraintAccumulated )
+        {
+        // change to days
+        aDuration = Min( aDuration.Int(),
+            aConstraint->iAccumulatedTime.Int() / (60*60*24) );
+        ret |= KDRMHelperConstraintAccumulated;
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetCounts
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::GetCounts(
+    CDRMConstraint* aConstraint,
+    TUint32& aCountsLeft,
+    TTime& aEndTime )
+    {
+    TInt ret(0);
+    TTime start;
+
+    aCountsLeft = KDRMCounterMax;
+    aEndTime = Time::NullTTime();
+    if ( aConstraint->iActiveConstraints & EConstraintCounter )
+        {
+        ret |= KDRMHelperConstraintCount;
+        aCountsLeft = aConstraint->iCounter;
+        }
+    if ( aConstraint->iActiveConstraints & EConstraintTimedCounter )
+        {
+        ret |= KDRMHelperConstraintCount;
+        if ( aConstraint->iTimedCounter < aCountsLeft )
+            {
+            aCountsLeft = aConstraint->iTimedCounter;
+            }
+        }
+    if ( aConstraint->iActiveConstraints & EConstraintEndTime )
+        {
+        ret |= KDRMHelperConstraintTime;
+        aEndTime = aConstraint->iEndTime;
+        }
+    if ( aConstraint->iActiveConstraints & EConstraintInterval )
+        {
+        start = aConstraint->iIntervalStart;
+        if ( start == Time::NullTTime() )
+            {
+            start.HomeTime();
+            }
+        aEndTime = start + aConstraint->iInterval;
+        ret |= KDRMHelperConstraintTime;
+        }
+    if ( aConstraint->iActiveConstraints & EConstraintAccumulated )
+        {
+        if ( aEndTime != Time::NullTTime() &&
+            aEndTime + aConstraint->iAccumulatedTime > aEndTime ||
+            aEndTime == Time::NullTTime() )
+            {
+            aEndTime.HomeTime();
+            aEndTime = aEndTime + aConstraint->iAccumulatedTime;
+            ret |= KDRMHelperConstraintAccumulated;
+            }
+        }
+    return ret;
+    }
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::LaunchDetailsViewEmbeddedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::LaunchDetailsViewEmbeddedL( const HBufC8* aContentURI )
+    {
+    CDRMRights* rights = NULL; // rights object
+
+    if ( iDRMCommon->GetActiveRights( *aContentURI, 0, rights ) ==
+        DRMCommon::ENoRights )
+        {
+        //no rights for given content URI, leave
+        User::Leave( DRMCommon::ENoRights );
+        }
+    else
+        {
+        User::LeaveIfNull( rights );
+
+        // get local ID
+        TUint32 localId = rights->GetLocalID();
+        HBufC* launchParam;
+
+
+        // create string needed to launch rights manager ui embedded.
+        CreateLaunchParamL( localId, aContentURI, launchParam );
+        CleanupStack::PushL( launchParam );
+        LaunchRightsManagerUiL( *launchParam );
+        CleanupStack::PopAndDestroy( launchParam );
+
+        }
+
+    // delete rights
+    delete rights;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::LaunchDetailsViewEmbeddedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::LaunchDetailsViewEmbeddedL( const TDesC& aFileName )
+    {
+    HBufC* contentURI( NULL );
+    HBufC8* contentURI8( NULL );
+    TInt error( KErrNone );
+
+    TVirtualPathPtr virtualPath( aFileName, KDefaultContentObject );
+
+    CData* content( NULL );
+    TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( r == KErrInUse )
+        {
+        content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+        }
+    else
+        {
+        User::LeaveIfError( r );
+        }
+
+    CleanupStack::PushL( content );
+
+    contentURI = HBufC::NewLC( KUrlMaxLen );
+    TPtr ptr = contentURI->Des();
+    error = content->GetStringAttribute( EContentID, ptr );
+    if ( !error )
+        {
+        contentURI8 = HBufC8::NewLC( contentURI->Length() );
+        contentURI8->Des().Copy( contentURI->Des() );
+        LaunchDetailsViewEmbeddedL( contentURI8 );
+        CleanupStack::PopAndDestroy( contentURI8 );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    CleanupStack::PopAndDestroy( 2, content ); // contentURI, content
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::LaunchDetailsViewEmbeddedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::LaunchDetailsViewEmbeddedL( RFile& aFileHandle )
+    {
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TInt error;
+
+    CData* content = CData::NewLC( aFileHandle, KDefaultContentObject, EPeek );
+
+    contentURI = HBufC::NewLC( KUrlMaxLen );
+    TPtr ptr = contentURI->Des();
+    error = content->GetStringAttribute( EContentID, ptr );
+    if ( !error )
+        {
+        contentURI8 = HBufC8::NewLC( contentURI->Length() );
+        contentURI8->Des().Copy( contentURI->Des() );
+        LaunchDetailsViewEmbeddedL( contentURI8 );
+        CleanupStack::PopAndDestroy( contentURI8 );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    CleanupStack::PopAndDestroy( 2, content ); // contentURI, content
+    }
+
+EXPORT_C void CDRMHelper::LaunchDetailsViewEmbeddedL(
+    const TDesC8& /*aURI*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CreateLaunchParamL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::CreateLaunchParamL(
+    TUint32 aLocalId,
+    const HBufC8* aUrl,
+    HBufC*& aLaunchParam )
+    {
+    TInt index;
+
+    // MaxInt will fit into 10 characters
+    HBufC* b( HBufC::NewLC( 10 ) );
+    b->Des().NumUC( aLocalId );
+    HBufC* localIDBuf( b->ReAllocL( b->Des().Length() ) );
+    CleanupStack::Pop( b );
+    b = NULL;
+    CleanupStack::PushL( localIDBuf );
+
+    // length of startparam is always 1 and 2 spaces are needed
+    TInt length = 1 + aUrl->Length() + localIDBuf->Des().Length() + 2;
+
+    aLaunchParam = HBufC::NewMaxL( length );
+
+    TPtr ptr( aLaunchParam->Des() );
+    ptr.SetLength( 0 );
+    _LIT( KOne, "1" );
+    _LIT( KTwo, "2" );
+    _LIT( KSpace, " " );
+
+    // start param is 1 for embedded launch and 2 for launching details view
+    // standalone
+    if ( iUseCoeEnv )
+        {
+        ptr.Append( KOne() );
+        }
+    else
+        {
+        ptr.Append( KTwo() );
+        }
+    ptr.Append( KSpace() );
+    ptr.Append( localIDBuf->Des() );
+    ptr.Append( KSpace() );
+
+    index = ptr.Length();
+    ptr.SetLength( length );
+    for ( TInt i = 0 ; i < aUrl->Length(); i++ )
+        {
+        ptr[index++] = ( unsigned char ) (*aUrl)[i];
+        }
+
+    CleanupStack::PopAndDestroy( localIDBuf );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetRightsDetailsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetRightsDetailsL(
+    const TDesC& aFileName,
+    TUint32 aIntent,
+    TBool& aExpired,
+    TBool& aSendingAllowed,
+    CDRMHelperRightsConstraints*& aPlay,
+    CDRMHelperRightsConstraints*& aDisplay,
+    CDRMHelperRightsConstraints*& aExecute,
+    CDRMHelperRightsConstraints*& aPrint )
+    {
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TInt drmProtected(0);
+    TInt intent;
+
+    TVirtualPathPtr virtualPath( aFileName, KDefaultContentObject );
+
+    CData* content( NULL );
+    TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( r == KErrInUse )
+        {
+        content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+        }
+    else
+        {
+        User::LeaveIfError( r );
+        }
+
+    CleanupStack::PushL( content );
+
+    User::LeaveIfError( content->GetAttribute( EIsProtected, drmProtected ) ) ;
+
+    if ( !drmProtected )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    User::LeaveIfError( content->GetAttribute( EIsForwardable, aSendingAllowed ) ) ;
+
+    contentURI = HBufC::NewLC( KUrlMaxLen );
+    TPtr ptr = contentURI->Des();
+    User::LeaveIfError( content->GetStringAttribute( EContentID, ptr ) );
+
+    contentURI8 = HBufC8::NewLC( contentURI->Length() );
+    contentURI8->Des().Copy( contentURI->Des() );
+    if ( aIntent == ContentAccess::EPlay ||
+        aIntent == ContentAccess::EView ||
+        aIntent == ContentAccess::EExecute ||
+        aIntent == ContentAccess::EPrint )
+        {
+        intent = aIntent;
+        }
+    else
+        {
+        // not valid CAF intent, determine intent from mimetype
+        HBufC* mimetype = HBufC::NewLC( KUrlMaxLen );
+        ptr.Set( mimetype->Des() );
+        content->GetStringAttribute( EMimeType, ptr );
+        intent = Intent( mimetype );
+        CleanupStack::PopAndDestroy( mimetype );
+        }
+    DoGetRightsDetailsL( contentURI8, intent, aExpired, aPlay, aDisplay,
+        aExecute, aPrint );
+    CleanupStack::PopAndDestroy( 3, content ); // contentURI8, contentURI, content
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetRightsDetailsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetRightsDetailsL(
+    RFile& aFileHandle,
+    TUint32 aIntent,
+    TBool& aExpired,
+    TBool& aSendingAllowed,
+    CDRMHelperRightsConstraints*& aPlay,
+    CDRMHelperRightsConstraints*& aDisplay,
+    CDRMHelperRightsConstraints*& aExecute,
+    CDRMHelperRightsConstraints*& aPrint )
+    {
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TInt drmProtected(0);
+    TInt intent;
+
+    CData* content = CData::NewLC( aFileHandle, KDefaultContentObject, EPeek );
+
+    User::LeaveIfError( content->GetAttribute( EIsProtected, drmProtected ) ) ;
+
+    if ( !drmProtected )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    User::LeaveIfError( content->GetAttribute( EIsForwardable, aSendingAllowed ) ) ;
+
+    contentURI = HBufC::NewLC( KUrlMaxLen );
+    TPtr ptr = contentURI->Des();
+    User::LeaveIfError( content->GetStringAttribute( EContentID, ptr ) );
+
+    contentURI8 = HBufC8::NewLC( contentURI->Length() );
+    contentURI8->Des().Copy( contentURI->Des() );
+    if ( aIntent == ContentAccess::EPlay ||
+        aIntent == ContentAccess::EView ||
+        aIntent == ContentAccess::EExecute ||
+        aIntent == ContentAccess::EPrint )
+        {
+        intent = aIntent;
+        }
+    else
+        {
+        // not valid CAF intent, determine intent from mimetype
+        HBufC* mimetype = HBufC::NewLC( KUrlMaxLen );
+        ptr.Set( mimetype->Des() );
+        content->GetStringAttribute( EMimeType, ptr );
+        intent = Intent( mimetype );
+        CleanupStack::PopAndDestroy( mimetype );
+        }
+
+    DoGetRightsDetailsL( contentURI8, intent, aExpired, aPlay, aDisplay,
+        aExecute, aPrint );
+
+    CleanupStack::PopAndDestroy( 3, content );  // contentURI8, contentURI, content
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DoGetRightsDetailsL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::DoGetRightsDetailsL(
+    HBufC8* aContentUri,
+    TUint32 aIntent,
+    TBool& aExpired,
+    CDRMHelperRightsConstraints*& aPlay,
+    CDRMHelperRightsConstraints*& aDisplay,
+    CDRMHelperRightsConstraints*& aExecute,
+    CDRMHelperRightsConstraints*& aPrint )
+    {
+    CDRMRights* activeRights = NULL;
+
+    // GetActiveRights returns negative value if rights are not valid
+    if ( iDRMCommon->GetActiveRights( *aContentUri, aIntent, activeRights ) > 0 )
+        {
+        // rights are valid
+        aExpired = EFalse;
+        CleanupStack::PushL( activeRights );
+        GetConstraintsL( *activeRights,
+                aPlay,
+                aDisplay,
+                aExecute,
+                aPrint );
+        CleanupStack::PopAndDestroy( activeRights );
+        }
+    else
+        {
+        // rights are not valid, check if they are future or expired.
+        TInt expiration = GetExpirationDetails(
+            aContentUri, aIntent, activeRights );
+        CleanupStack::PushL( activeRights );
+        switch ( expiration )
+            {
+            case CDRMRights::EExpiredRights:
+                // expired rights
+                aExpired = ETrue;
+                break;
+            case CDRMRights::EFutureRights:
+                // future rights, mark it as "expired" but return also
+                // constraint objects
+                aExpired = ETrue;
+                GetConstraintsL( *activeRights,
+                        aPlay,
+                        aDisplay,
+                        aExecute,
+                        aPrint );
+                break;
+            case KErrCANoRights:
+                // no rights, leave
+                User::Leave( KErrCANoRights );
+                break;
+            default:
+                // something else, should never come here
+                User::Leave( KErrGeneral );
+                break;
+            }
+        CleanupStack::PopAndDestroy( activeRights );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetConstraintsL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::GetConstraintsL(
+    CDRMRights& aRights,
+    CDRMHelperRightsConstraints*& aPlay,
+    CDRMHelperRightsConstraints*& aDisplay,
+    CDRMHelperRightsConstraints*& aExecute,
+    CDRMHelperRightsConstraints*& aPrint )
+    {
+    CDRMRightsConstraints* constraint( NULL );
+    CDRMHelperRightsConstraints* play( NULL );
+    CDRMHelperRightsConstraints* display( NULL );
+    CDRMHelperRightsConstraints* execute( NULL );
+    CDRMHelperRightsConstraints* print( NULL );
+    TInt poppableItems(0);
+
+    aRights.GetPlayRight( constraint );
+    if ( constraint )
+        {
+        // takes ownership of constraint
+        play = CDRMHelperRightsConstraints::NewLC( constraint );
+        poppableItems++;
+        constraint = NULL;
+        }
+    aRights.GetDisplayRight( constraint );
+    if ( constraint )
+        {
+        // takes ownership of constraint
+        display = CDRMHelperRightsConstraints::NewLC( constraint );
+        poppableItems++;
+        constraint = NULL;
+        }
+    aRights.GetExecuteRight( constraint );
+    if ( constraint )
+        {
+        // takes ownership of constraint
+        execute = CDRMHelperRightsConstraints::NewLC( constraint );
+        poppableItems++;
+        constraint = NULL;
+        }
+    aRights.GetPrintRight( constraint );
+    if ( constraint )
+        {
+        // takes ownership of constraint
+        print = CDRMHelperRightsConstraints::NewLC( constraint );
+        poppableItems++;
+        constraint = NULL;
+        }
+    if ( poppableItems )
+        {
+        CleanupStack::Pop( poppableItems );
+        }
+    aPlay = play;
+    aDisplay = display;
+    aExecute = execute;
+    aPrint = print;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetRightsDetailsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetRightsDetailsL( const TDesC& aFileName,
+    TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed,
+    CDRMRightsConstraints*& aPlay,
+    CDRMRightsConstraints*& aDisplay,
+    CDRMRightsConstraints*& aExecute,
+    CDRMRightsConstraints*& aPrint )
+    {
+    TVirtualPathPtr virtualPath( aFileName, KDefaultContentObject );
+    TInt intent;
+
+    CData* content( NULL );
+    TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( r == KErrInUse )
+        {
+        content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+        }
+    else
+        {
+        User::LeaveIfError( r );
+        }
+
+    CleanupStack::PushL( content );
+
+    // if aIntent is not any of CAF intents, use default intent
+    if ( aIntent == ContentAccess::EPlay ||
+        aIntent == ContentAccess::EView ||
+        aIntent == ContentAccess::EExecute ||
+        aIntent == ContentAccess::EPrint )
+        {
+        intent = aIntent;
+        }
+    else
+        {
+        // not valid CAF intent, determine intent from mimetype
+        HBufC* mimetype = HBufC::NewLC( KUrlMaxLen );
+        TPtr ptr = mimetype->Des();
+        content->GetStringAttribute( EMimeType, ptr );
+        intent = Intent( mimetype );
+        CleanupStack::PopAndDestroy( mimetype );
+        }
+
+    DoGetRightsDetailsL( content, intent, aExpired, aSendingAllowed, aPlay,
+        aDisplay, aExecute, aPrint );
+
+    CleanupStack::PopAndDestroy( content ); // content
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetRightsDetailsL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::GetRightsDetailsL( RFile& aFileHandle,
+    TUint32 aIntent, TBool& aExpired, TBool& aSendingAllowed,
+    CDRMRightsConstraints*& aPlay,
+    CDRMRightsConstraints*& aDisplay,
+    CDRMRightsConstraints*& aExecute,
+    CDRMRightsConstraints*& aPrint )
+    {
+    TInt intent;
+    CData* content = CData::NewLC( aFileHandle, KDefaultContentObject, EPeek );
+
+    // if aIntent is not any of CAF intents, use default intent
+    if ( aIntent == ContentAccess::EPlay ||
+        aIntent == ContentAccess::EView ||
+        aIntent == ContentAccess::EExecute ||
+        aIntent == ContentAccess::EPrint )
+        {
+        intent = aIntent;
+        }
+    else
+        {
+        // not valid CAF intent, determine intent from mimetype
+        HBufC* mimetype = HBufC::NewLC( KUrlMaxLen );
+        TPtr ptr = mimetype->Des();
+        content->GetStringAttribute( EMimeType, ptr );
+        intent = Intent( mimetype );
+        CleanupStack::PopAndDestroy( mimetype );
+        }
+    DoGetRightsDetailsL( content, intent, aExpired, aSendingAllowed, aPlay,
+        aDisplay, aExecute, aPrint );
+    CleanupStack::PopAndDestroy( content ); // content
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DoGetRightsDetailsL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::DoGetRightsDetailsL(
+    CData* aContent,
+    TUint32 aIntent,
+    TBool& aExpired,
+    TBool& aSendingAllowed,
+    CDRMRightsConstraints*& aPlay,
+    CDRMRightsConstraints*& aDisplay,
+    CDRMRightsConstraints*& aExecute,
+    CDRMRightsConstraints*& aPrint )
+    {
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TInt drmProtected(0);
+    CDRMRights* activeRights;
+
+    __ASSERT_DEBUG( aContent, User::Invariant() );
+    User::LeaveIfNull( aContent );
+    User::LeaveIfError( aContent->GetAttribute( EIsProtected, drmProtected ) ) ;
+    if ( !drmProtected )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    User::LeaveIfError(
+        aContent->GetAttribute( EIsForwardable, aSendingAllowed ) ) ;
+
+    contentURI = HBufC::NewLC( KUrlMaxLen );
+    TPtr ptr = contentURI->Des();
+    User::LeaveIfError( aContent->GetStringAttribute( EContentID, ptr ) );
+    contentURI8 = HBufC8::NewLC( contentURI->Length() );
+    contentURI8->Des().Copy( contentURI->Des() );
+
+    // GetActiveRights returns negative value if rights are not valid
+    if ( iDRMCommon->GetActiveRights( *contentURI8, aIntent, activeRights ) > 0 )
+        {
+        // rights are valid
+        aExpired = EFalse;
+        CleanupStack::PushL( activeRights );
+        activeRights->GetPlayRight( aPlay );
+        activeRights->GetDisplayRight( aDisplay );
+        activeRights->GetExecuteRight( aExecute );
+        activeRights->GetPrintRight( aPrint );
+        CleanupStack::PopAndDestroy( activeRights );
+        }
+    else
+        {
+        // rights are not valid, check if they are future or expired.
+        TInt expiration = GetExpirationDetails(
+            contentURI8, aIntent, activeRights );
+        CleanupStack::PushL( activeRights );
+        switch ( expiration )
+            {
+            case CDRMRights::EExpiredRights:
+                // expired rights
+                aExpired = ETrue;
+                break;
+            case CDRMRights::EFutureRights:
+                // future rights, mark it as "expired" but return also
+                // constraint objects
+                aExpired = ETrue;
+                activeRights->GetPlayRight( aPlay );
+                activeRights->GetDisplayRight( aDisplay );
+                activeRights->GetExecuteRight( aExecute );
+                activeRights->GetPrintRight( aPrint );
+                break;
+            case KErrCANoRights:
+                // no rights, leave
+                User::Leave( KErrCANoRights );
+                break;
+            default:
+                // something else, should never come here
+#ifdef _DEBUG
+                User::Invariant();
+#endif
+                User::Leave( KErrGeneral );
+                break;
+            }
+        CleanupStack::PopAndDestroy( activeRights );
+        }
+    CleanupStack::PopAndDestroy( 2, contentURI ); // contentURI8, contentURI
+    }
+
+EXPORT_C TInt CDRMHelper::ShowDRMUINotification2L( TDRMHelperNotificationID /*aTextId*/,
+    const TDesC8& /*aURI*/ )
+    {
+    return KErrNotSupported;
+    }
+
+EXPORT_C TInt CDRMHelper::ShowDRMUINotification2L( TDRMHelperNotificationID /*aTextId*/,
+    const TDesC& /*aFileName*/ )
+    {
+    return KErrNotSupported;
+    }
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CanSetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CanSetAutomated(
+    const TDesC& aFilename,
+    TBool& aValue )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    RFile fileHandle;
+    TBool protectedWmDrm( EFalse );
+
+    error = fileHandle.Open( iFs, aFilename,
+        EFileRead | EFileShareReadersOrWriters );
+    if ( error == KErrInUse )
+        {
+        error = fileHandle.Open( iFs, aFilename, EFileRead | EFileShareAny );
+        if ( error == KErrInUse )
+            {
+            error = fileHandle.Open( iFs, aFilename, EFileRead | EFileShareReadersOnly );
+            }
+        }
+
+    if ( error == KErrNone )
+        {
+        // check if file is WMDRM protected
+        TRAP( error, protectedWmDrm = IsProtectedWmDrmL( fileHandle ) );
+        fileHandle.Close();
+        if ( protectedWmDrm || error != KErrNone )
+            {
+            // file is either corrupt or WMDRM protected
+            // so it can not be set as automated
+            aValue = EFalse;
+            return error;
+            }
+        }
+    else
+        {
+        return error;
+        }
+
+    // do other needed checks
+    TVirtualPathPtr virtualPath( aFilename, KDefaultContentObject );
+
+    TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( error == KErrInUse )
+        {
+        TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly ) );
+        }
+
+    if ( error == KErrNone )
+        {
+
+        TRAPD( err, error =  PerformCanSetAutomatedL( *content, aValue ) );
+        if ( err )
+            {
+            error = err;
+            }
+
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CanSetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CanSetAutomated(
+    RFile& aFileHandle,
+    TBool& aValue )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+    TBool protectedWmDrm( EFalse );
+
+    // check if file is WMDRM protected
+    TRAP( error, protectedWmDrm = IsProtectedWmDrmL( aFileHandle ) );
+    if ( protectedWmDrm || error != KErrNone )
+        {
+        // file is either corrupt or WMDRM protected
+        // so it can not be set as automated
+        aValue = EFalse;
+        return error;
+        }
+    // do other checks for given file
+    TRAP(error, content = CData::NewL( aFileHandle, KDefaultContentObject, EPeek ) );
+    if ( error == KErrNone )
+        {
+
+        TRAPD( err, error =  PerformCanSetAutomatedL( *content, aValue ) );
+        if ( err )
+            {
+            error = err;
+            }
+
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CanSetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::CanSetAutomated( const TDesC8& aURI, TBool& aValue )
+    {
+    HBufC* mimeType = NULL;
+    TRAPD( error, mimeType = MimeTypeFromURIL( aURI ) );
+    if ( !error )
+        {
+        error = DoCanSetAutomated( aURI, mimeType, aValue );
+        }
+    delete mimeType;
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomated( const TDesC& aFilename )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TVirtualPathPtr virtualPath( aFilename, KDefaultContentObject );
+
+    TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( error == KErrInUse )
+        {
+        TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly ) );
+        }
+
+    if ( error == KErrNone )
+        {
+
+        TRAPD( err, error =  PerformSetAutomatedL( *content, ETrue ) );
+        if ( err )
+            {
+            error = err;
+            }
+
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomated( RFile& aFileHandle )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TRAP(error, content = CData::NewL( aFileHandle, KDefaultContentObject, EPeek ) );
+    if ( error == KErrNone )
+        {
+
+        TRAPD( err, error =  PerformSetAutomatedL( *content, ETrue ) );
+        if ( err )
+            {
+            error = err;
+            }
+
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomated( const TDesC8& aURI )
+    {
+    TInt error( KErrArgument );
+    HBufC* mimeType = NULL;
+
+    TRAPD( err, mimeType = MimeTypeFromURIL( aURI ) );
+    if ( !err && mimeType )
+        {
+        TRAP( err, error = DoSetAutomatedL( aURI, ETrue, mimeType ) );
+        }
+    if ( err )
+        {
+        error = err;
+        }
+    delete mimeType;
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ShowAutomatedNote
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::ShowAutomatedNote( const TDesC& aFilename )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TVirtualPathPtr virtualPath( aFilename, KDefaultContentObject );
+    TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( error == KErrInUse )
+        {
+        TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly ) );
+        }
+
+    if ( error == KErrNone )
+        {
+
+        TRAPD( err, error =  PerformShowAutomatedNoteL( *content ) );
+        if ( err )
+            {
+            error = err;
+            }
+
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ShowAutomatedNote
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::ShowAutomatedNote( RFile& aFileHandle )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TRAP(error, content = CData::NewL( aFileHandle, KDefaultContentObject, EPeek ) );
+    if ( error == KErrNone )
+        {
+
+        TRAPD( err, error =  PerformShowAutomatedNoteL( *content ) );
+        if ( err )
+            {
+            error = err;
+            }
+
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ShowAutomatedNote
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::ShowAutomatedNote( const TDesC8& aURI )
+    {
+    TInt error ( KErrArgument );
+    HBufC* mimeType = NULL;
+
+    TRAPD( err, mimeType = MimeTypeFromURIL( aURI ) );
+    if ( !err && mimeType )
+        {
+        TRAP( err, error = DoShowAutomatedNoteL( aURI, mimeType ) );
+        }
+    if ( err )
+        {
+        error = err;
+        }
+    delete mimeType;
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedPassive( const TDesC& aFilename )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TVirtualPathPtr virtualPath( aFilename, KDefaultContentObject );
+    TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( error == KErrInUse )
+        {
+        TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly ) );
+        }
+
+    if ( error == KErrNone )
+        {
+
+        TRAPD( err, error =  PerformSetAutomatedL( *content, EFalse ) );
+        if ( err )
+            {
+            error = err;
+            }
+
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedPassive( RFile& aFileHandle )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TRAP(error, content = CData::NewL( aFileHandle, KDefaultContentObject, EPeek ) );
+    if ( error == KErrNone )
+        {
+
+        TRAPD( err, error =  PerformSetAutomatedL( *content, EFalse ) );
+        if ( err )
+            {
+            error = err;
+            }
+
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedPassive( const TDesC8& aURI )
+    {
+    TInt error( KErrArgument );
+    HBufC* mimeType = NULL;
+
+    TRAPD( err, mimeType = MimeTypeFromURIL( aURI ) );
+    if ( !err && mimeType )
+        {
+        TRAP( err, error = DoSetAutomatedL( aURI, EFalse, mimeType ) );
+        }
+    if ( err )
+        {
+        error = err;
+        }
+    delete mimeType;
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedSilent
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedSilent( const TDesC& aFilename,
+    TBool aActive )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TVirtualPathPtr virtualPath( aFilename, KDefaultContentObject );
+    TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( error == KErrInUse )
+        {
+        TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly ) );
+        }
+
+    if ( error == KErrNone )
+        {
+
+        TRAPD( err, error =  PerformSetAutomatedSilentL( *content, aActive ) );
+        if ( err )
+            {
+            error = err;
+            }
+
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedSilent
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedSilent( RFile& aFileHandle,
+    TBool aActive )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TRAP(error, content = CData::NewL( aFileHandle, KDefaultContentObject, EPeek ) );
+    if ( error == KErrNone )
+        {
+        TRAPD( err, error =  PerformSetAutomatedSilentL( *content, aActive ) );
+        if ( err )
+            {
+            error = err;
+            }
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedSilent
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedSilent( const TDesC8& aURI,
+    TBool aActive )
+    {
+    HBufC* mimetype = NULL;
+    TRAPD( err, mimetype = MimeTypeFromURIL( aURI ) );
+    if ( !err )
+        {
+        err = DoSetAutomatedSilent( aURI, aActive, Intent( mimetype ) );
+        }
+    delete mimetype;
+    return err;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomated( const TDesC& aFilename )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TVirtualPathPtr virtualPath( aFilename, KDefaultContentObject );
+    TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( error == KErrInUse )
+        {
+        TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly ) );
+        }
+
+    if ( error == KErrNone )
+        {
+
+        TRAPD( err, error =  PerformRemoveAutomatedL( *content, ETrue ) );
+        if ( err )
+            {
+            error = err;
+            }
+
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomated( RFile& aFileHandle )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TRAP(error, content = CData::NewL( aFileHandle, KDefaultContentObject, EPeek ) );
+    if ( error == KErrNone )
+        {
+        TRAPD( err, error =  PerformRemoveAutomatedL( *content, ETrue ) );
+        if ( err )
+            {
+            error = err;
+            }
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomated
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomated( const TDesC8& aURI )
+    {
+    HBufC* mimetype = NULL;
+    TRAPD( error, mimetype = MimeTypeFromURIL( aURI ) );
+    if ( !error )
+        {
+        error = iHelperServer.RemoveAutomated(
+            aURI, ETrue, iAutomatedType, Intent( mimetype ) );
+        }
+    delete mimetype;
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomatedPassive( const TDesC& aFilename )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TVirtualPathPtr virtualPath( aFilename, KDefaultContentObject );
+    TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+    if ( error == KErrInUse )
+        {
+        TRAP( error, content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly ) );
+        }
+
+    if ( error == KErrNone )
+        {
+        TRAPD( err, error =  PerformRemoveAutomatedL( *content, EFalse ) );
+        if ( err )
+            {
+            error = err;
+            }
+
+        delete content;
+        }
+
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomatedPassive( RFile& aFileHandle )
+    {
+    CData* content( NULL );
+    TInt error( KErrNone );
+
+    TRAP(error, content = CData::NewL( aFileHandle, KDefaultContentObject, EPeek ) );
+    if ( error == KErrNone )
+        {
+        TRAPD( err, error =  PerformRemoveAutomatedL( *content, EFalse ) );
+        if ( err )
+            {
+            error = err;
+            }
+        delete content;
+        }
+
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::RemoveAutomatedPassive
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::RemoveAutomatedPassive( const TDesC8& aURI )
+    {
+    HBufC* mimetype = NULL;
+    TRAPD( error, mimetype = MimeTypeFromURIL( aURI ) );
+    if ( !error )
+        {
+        error = iHelperServer.RemoveAutomated(
+            aURI, EFalse, iAutomatedType, Intent( mimetype ) );
+        }
+    delete mimetype;
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::SetAutomatedType
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMHelper::SetAutomatedType(
+    CDRMHelper::TDRMHelperAutomatedType aAutomatedType )
+    {
+    iAutomatedType = aAutomatedType;
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DoSetAutomatedL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DoSetAutomatedL(
+    const TDesC8& aURI,
+    TBool aActive,
+    const HBufC* aMimeType )
+    {
+    TInt error = DoShowAutomatedNoteL( aURI, aMimeType );
+    if ( !error )
+        {
+        // register with server
+        error = DoSetAutomatedSilent( aURI, aActive, Intent( aMimeType) );
+        }
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DoShowAutomatedNoteL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DoShowAutomatedNoteL(
+    const TDesC8& aURI,
+    const HBufC* aMimeType )
+    {
+    CDRMRights* rights = NULL;
+    TInt error( KErrArgument );
+    TInt intent = Intent( aMimeType );
+    TInt rightsType = iDRMCommon->GetActiveRights( aURI, intent, rights );
+    if ( rightsType == CDRMRights::ERestrictedRights )
+        {
+        CDRMRights::TRestriction restriction;
+        CDRMRights::TExpiration expiration;
+        TUint32 constType( 0 );
+
+        rights->GetRightsInfo( intent, restriction, expiration, constType );
+        if ( !(constType & CDRMRights::ECountBased) &&
+            !(constType & CDRMRights::ETimeIsAccumulatedTime) &&
+            expiration == CDRMRights::EValidRights )
+            {
+            TTime endTime;
+            TBool inactive;
+
+            error = CalculateEndTime( rights, intent, endTime, inactive );
+            if ( !error )
+                {
+                TBuf<KDRMHelperMaxDateFormatLen> dateFormat;
+                TBuf<KDRMHelperMaxDateLen> endDate;
+                TInt buttonCode( 0 );
+
+#ifndef RD_MULTIPLE_DRIVE
+
+                TFileName avkonResFile( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+                _LIT( KDrive, "%c:");
+                TInt driveNumber( -1 );
+                TChar driveLetter;
+                DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+                iFs.DriveToChar( driveNumber, driveLetter );
+
+                TFileName avkonResFile;
+
+                avkonResFile.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+                _LIT( KCDRMHelperAvkonResFileName, "avkon.rsc" );
+
+                avkonResFile.Append( KDC_RESOURCE_FILES_DIR );
+                avkonResFile.Append( KCDRMHelperAvkonResFileName );
+
+                if ( inactive )
+                    {
+                    buttonCode = DisplayQueryWithIdL( R_DRM_QUERY_SET_AUTO_INTERVAL ,
+                        R_DRMHELPER_CONFIRMATION_QUERY );
+                    }
+                else
+                    {
+                    // get date string format
+                    CStringResourceReader* avkonResReader(
+                        CStringResourceReader::NewLC( avkonResFile ) );
+
+                    dateFormat = avkonResReader->ReadResourceString(
+                        R_QTN_DATE_USUAL_WITH_ZERO );
+
+                    CleanupStack::PopAndDestroy( avkonResReader );
+
+                    // format date
+                    endTime.FormatL( endDate, dateFormat );
+                    AknTextUtils::LanguageSpecificNumberConversion( endDate );
+
+                    // display query
+                    buttonCode = DisplayQueryL( R_DRMHELPER_SET_AUTOMATED,
+                        endDate );
+                    }
+                error = buttonCode ? KErrNone : KErrCancel;
+                }
+            else if ( error == KErrNotFound )
+                {
+                // end time not found, this is datetime constraint without end
+                // time
+                error = KErrNone;
+                }
+            }
+        }
+    else
+        {
+        if ( rightsType == CDRMRights::EFullRights )
+            {
+            error = KErrNone;
+            }
+        }
+    delete rights;
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DoSetAutomatedSilent
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DoSetAutomatedSilent(
+    const TDesC8& aURI,
+    TBool aActive,
+    TInt aIntent )
+    {
+    return iHelperServer.SetAutomated( aURI, aActive, iAutomatedType, aIntent );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DoCheckSkinCanSetAutomated
+//
+// Checks all rights constraints for certain RO and checks if interval is the same
+// If not, return EFalse
+// -----------------------------------------------------------------------------
+//
+TBool CDRMHelper::DoCheckSkinCanSetAutomated(CDRMRights* aRights)
+    {
+    TBool Rights[3] = {EFalse, EFalse, EFalse}; //Display, Execute, Play
+    TTimeIntervalSeconds EndTimes[3] = {0, 0, 0}; //Display, Execute, Play
+    TBool interval = EFalse;
+    TTimeIntervalSeconds endTime = 0;
+
+    CDRMRightsConstraints *constraint = NULL;
+
+    // Display rights
+    if ( aRights->GetDisplayRight( constraint ) == KErrNone)
+        {
+        Rights[0] = ETrue;
+        constraint->GetInterval( endTime );
+        EndTimes[0] = endTime;
+        }
+    delete constraint;
+    constraint = NULL;
+    endTime = 0;
+
+    // Execute rights
+    if ( aRights->GetExecuteRight( constraint ) == KErrNone)
+        {
+        Rights[1] = ETrue;
+        constraint->GetInterval( endTime );
+        EndTimes[1] = endTime;
+        }
+    delete constraint;
+    constraint = NULL;
+    endTime = 0;
+
+    // Play rights
+    if ( aRights->GetPlayRight( constraint )  == KErrNone )
+        {
+        Rights[2] = ETrue;
+        constraint->GetInterval( endTime );
+        EndTimes[2] = endTime;
+        }
+    delete constraint;
+    constraint = NULL;
+    endTime = 0;
+
+    for (TInt i = 0; i < 3; ++i)
+        {
+        // we have a interval
+        if (EndTimes[i].Int() != 0)
+            {
+            interval = ETrue;
+            // test if we have endtimes
+            if (EndTimes[i].Int() != 0)
+                {
+                // compare to other
+                for (TInt u = 0; u < 3 ; u++)
+                    {
+                    if ( Rights[u] && (EndTimes[u].Int() != EndTimes[i].Int() ))
+                        {
+                        return EFalse;
+                        }
+                    }
+                }
+            }
+        else if ( interval )
+            {
+            // If no interval but constraint found
+            if (Rights[i])
+                {
+                return EFalse;
+                }
+            }
+        }
+
+    // If time intervals were ok.
+    return ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DoCanSetAutomated
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DoCanSetAutomated(
+    const TDesC8& aURI,
+    const HBufC* aMimeType,
+    TBool& aValue )
+    {
+    TInt rightsType;
+    CDRMRights* rights = NULL;
+    TInt error( KErrNone );
+    TInt intent = Intent( aMimeType );
+
+    rightsType = iDRMCommon->GetActiveRights( aURI, intent, rights );
+    if ( rightsType == CDRMRights::EFullRights )
+        {
+        aValue = ETrue;
+        }
+    else
+        {
+        if ( rights )
+            {
+            CDRMRights::TRestriction restriction;
+            CDRMRights::TExpiration expiration;
+            TUint32 constType;
+
+            rights->GetRightsInfo( intent, restriction, expiration, constType );
+            if ( expiration == CDRMRights::EValidRights )
+                {
+                // Check theme interval rights validity
+                if ( iAutomatedType == EAutomatedTypeTheme)
+                    {
+                    if (!DoCheckSkinCanSetAutomated(rights))
+                        {
+                        delete rights;
+                        aValue = EFalse;
+                        return DRMCommon::EInvalidRights;
+                        }
+                    }
+
+                // if rights are valid and not count or accumulated time
+                // based, content can be set automated
+                aValue = !(constType &
+                    ( CDRMRights::ECountBased | CDRMRights::ETimeIsAccumulatedTime ) );
+                }
+            else
+                {
+                // expired or future rights
+                aValue = EFalse;
+
+                // return expired error code only for content that has
+                // time-based rights
+                if ( !(constType &
+                        ( CDRMRights::ECountBased | CDRMRights::ETimeIsAccumulatedTime ) ) )
+                    {
+                    error = DRMCommon::ERightsExpired;
+                    }
+                }
+            }
+        else
+            {
+            // no rights
+            aValue = EFalse;
+            error = DRMCommon::ENoRights;
+            }
+        }
+    delete rights;
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::PerformCanSetAutomatedL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::PerformCanSetAutomatedL(
+    const CData& aContent,
+    TBool& aValue )
+    {
+    HBufC* mimeType = NULL;
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TInt drmProtected(0);
+    TInt error;
+    TInt dcfType(0);
+
+    error = aContent.GetAttribute( EIsProtected, drmProtected );
+    if ( !error )
+        {
+        if ( !drmProtected )
+            {
+            aValue = ETrue;
+            error = KErrNone;
+            }
+        else
+            {
+            mimeType = HBufC::NewLC( KMaxDataTypeLength );
+            contentURI = HBufC::NewLC( KUrlMaxLen );
+
+            // create attribute set
+            RStringAttributeSet stringAttributeSet;
+            CleanupClosePushL( stringAttributeSet );
+            // add the attributes we are interested in
+            stringAttributeSet.AddL( EContentID );
+            stringAttributeSet.AddL( EMimeType );
+
+            error = aContent.GetStringAttributeSet( stringAttributeSet );
+
+            if ( error == KErrNone )
+                {
+                // pass on values of string attributes
+                TPtr ptr = contentURI->Des();
+                error = stringAttributeSet.GetValue( EContentID, ptr );
+                if ( error == KErrNone )
+                    {
+                    TPtr ptr2 = mimeType->Des();
+                    error = stringAttributeSet.GetValue( EMimeType, ptr2 );
+
+                    //OMA2 content with is not allowed without classification info
+                    if ( error == KErrNone )
+                        {
+                        error = aContent.GetAttribute( EFileType, dcfType );
+                        TInt intent = Intent( mimeType );
+
+                        if (dcfType == EOma2Dcf && intent == EPlay )
+                            {
+
+                            HBufC* classificationInfo = HBufC::NewLC( KUrlMaxLen );
+                            TPtr ptr = classificationInfo->Des();
+                            aContent.GetStringAttribute( EClassificationInfo, ptr);
+
+                            if ( !classificationInfo->FindF(
+                                    KDRMHelperClassificationRingingTone ) ||
+                                !classificationInfo->FindF(
+                                    KDRMHelperClassificationVideoTone ) )
+                                {
+                                aValue = ETrue;
+                                CleanupStack::PopAndDestroy(
+                                    classificationInfo );
+                                }
+                            else
+                                {
+                                aValue = EFalse;
+                                CleanupStack::PopAndDestroy( 4, mimeType );
+                                // classificationInfo, stringAttributeSet.Close(),
+                                // contentURI, mimeType
+                                return error;
+                                }
+                            }
+                        }
+                    if ( error == KErrNone )
+                        {
+                        contentURI8 = HBufC8::NewLC( contentURI->Length() );
+                        contentURI8->Des().Copy( contentURI->Des() );
+                        error = DoCanSetAutomated( *contentURI8, mimeType, aValue );
+                        CleanupStack::PopAndDestroy( contentURI8 );
+                        }
+                    else
+                        {
+                        error = KErrArgument;
+                        }
+                    }
+                else
+                    {
+                    error = KErrArgument;
+                    }
+                }
+            else
+                {
+                error = KErrArgument;
+                }
+            CleanupStack::PopAndDestroy(3, mimeType); // stringAttributeSet.Close(), contentURI, mimeType
+            }
+        }
+    else
+        {
+        error = KErrArgument;
+        }
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::PerformSetAutomatedL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::PerformSetAutomatedL( const CData& aContent, TBool aActive )
+    {
+    HBufC* mimeType = NULL;
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TInt drmProtected(0);
+    TInt error;
+
+    error = aContent.GetAttribute( EIsProtected, drmProtected );
+    if ( !error )
+        {
+        if ( drmProtected )
+            {
+            mimeType = HBufC::NewLC( KMaxDataTypeLength );
+            contentURI = HBufC::NewLC( KUrlMaxLen );
+
+            // create attribute set
+            RStringAttributeSet stringAttributeSet;
+            CleanupClosePushL( stringAttributeSet );
+            // add the attributes we are interested in
+            stringAttributeSet.AddL( EContentID );
+            stringAttributeSet.AddL( EMimeType );
+
+            error = aContent.GetStringAttributeSet( stringAttributeSet );
+
+            if ( error == KErrNone )
+                {
+                // pass on values of string attributes
+                TPtr ptr = contentURI->Des();
+                error = stringAttributeSet.GetValue( EContentID, ptr );
+                if ( error == KErrNone )
+                    {
+                    TPtr ptr2 = mimeType->Des();
+                    error = stringAttributeSet.GetValue( EMimeType, ptr2 );
+                    if ( error == KErrNone )
+                        {
+                        contentURI8 = HBufC8::NewLC( contentURI->Length() );
+                        contentURI8->Des().Copy( contentURI->Des() );
+
+                        TRAPD( err, error = DoSetAutomatedL( *contentURI8, aActive, mimeType ) );
+                        if ( err )
+                            {
+                            error = err;
+                            }
+                        CleanupStack::PopAndDestroy( contentURI8 );
+                        }
+                    else
+                        {
+                        error = KErrArgument;
+                        }
+                    }
+                else
+                    {
+                    error = KErrArgument;
+                    }
+                }
+            else
+                {
+                error = KErrArgument;
+                }
+            CleanupStack::PopAndDestroy(3, mimeType); // stringAttributeSet.Close(), contentURI, mimeType
+            }
+        }
+    else
+        {
+        error = KErrArgument;
+        }
+    return error;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::PerformShowAutomatedNoteL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::PerformShowAutomatedNoteL( const CData& aContent )
+    {
+    HBufC* mimeType = NULL;
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TInt drmProtected(0);
+    TInt error;
+
+    error = aContent.GetAttribute( EIsProtected, drmProtected );
+    if ( !error )
+        {
+        if ( drmProtected )
+            {
+            mimeType = HBufC::NewLC( KMaxDataTypeLength );
+            contentURI = HBufC::NewLC( KUrlMaxLen );
+
+            // create attribute set
+            RStringAttributeSet stringAttributeSet;
+            CleanupClosePushL( stringAttributeSet );
+            // add the attributes we are interested in
+            stringAttributeSet.AddL( EContentID );
+            stringAttributeSet.AddL( EMimeType );
+
+            error = aContent.GetStringAttributeSet( stringAttributeSet );
+
+            if ( error == KErrNone )
+                {
+                // pass on values of string attributes
+                TPtr ptr = contentURI->Des();
+                error = stringAttributeSet.GetValue( EContentID, ptr );
+                if ( error == KErrNone )
+                    {
+                    TPtr ptr2 = mimeType->Des();
+                    error = stringAttributeSet.GetValue( EMimeType, ptr2 );
+                    if ( error == KErrNone )
+                        {
+                        contentURI8 = HBufC8::NewLC( contentURI->Length() );
+                        contentURI8->Des().Copy( contentURI->Des() );
+
+                        TRAPD( err, error = DoShowAutomatedNoteL( *contentURI8, mimeType ) );
+                        if ( err )
+                            {
+                            error = err;
+                            }
+                        CleanupStack::PopAndDestroy( contentURI8 );
+                        }
+                    else
+                        {
+                        error = KErrArgument;
+                        }
+                    }
+                else
+                    {
+                    error = KErrArgument;
+                    }
+                }
+            else
+                {
+                error = KErrArgument;
+                }
+            CleanupStack::PopAndDestroy(3, mimeType); // stringAttributeSet.Close(), contentURI, mimeType
+            }
+        }
+    else
+        {
+        error = KErrArgument;
+        }
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::PerformSetAutomatedSilentL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::PerformSetAutomatedSilentL( const CData& aContent, TBool aActive )
+    {
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TInt drmProtected(0);
+    TInt error;
+
+    error = aContent.GetAttribute( EIsProtected, drmProtected );
+    if ( !error )
+        {
+        if ( drmProtected )
+            {
+            contentURI = HBufC::NewLC( KUrlMaxLen );
+            TPtr ptr = contentURI->Des();
+            error = aContent.GetStringAttribute( EContentID, ptr );
+            if ( !error )
+                {
+                HBufC* mimeType = HBufC::NewLC( KMaxDataTypeLength );
+                TPtr ptr2 = mimeType->Des();
+                error = aContent.GetStringAttribute( EMimeType, ptr2 );
+                if ( !error )
+                    {
+                    contentURI8 = HBufC8::NewLC( contentURI->Length() );
+                    contentURI8->Des().Copy( contentURI->Des() );
+                    error = DoSetAutomatedSilent( *contentURI8, aActive, Intent( mimeType ) );
+                    CleanupStack::PopAndDestroy( contentURI8 );
+                    }
+                CleanupStack::PopAndDestroy( mimeType );
+                }
+            CleanupStack::PopAndDestroy( contentURI );
+            }
+        }
+    else
+        {
+        error = KErrArgument;
+        }
+    return error;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::PerformRemoveAutomatedL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::PerformRemoveAutomatedL( const CData& aContent, TBool aActive )
+    {
+    HBufC* contentURI = NULL;
+    HBufC8* contentURI8 = NULL;
+    TInt drmProtected(0);
+    TInt error;
+
+    error = aContent.GetAttribute( EIsProtected, drmProtected );
+    if ( !error )
+        {
+        if ( !drmProtected )
+            {
+            error = KErrArgument;
+            }
+        else
+            {
+            contentURI = HBufC::NewLC( KUrlMaxLen );
+            TPtr ptr = contentURI->Des();
+            error = aContent.GetStringAttribute( EContentID, ptr );
+            if ( !error )
+                {
+                contentURI8 = HBufC8::NewLC( contentURI->Length() );
+                contentURI8->Des().Copy( contentURI->Des() );
+                if ( aActive )
+                    {
+                    error = RemoveAutomated( *contentURI8 );
+                    }
+                else
+                    {
+                    error = RemoveAutomatedPassive( *contentURI8 );
+                    }
+                CleanupStack::PopAndDestroy( contentURI8 );
+                }
+            CleanupStack::PopAndDestroy( contentURI );
+            }
+        }
+    else
+        {
+        error = KErrArgument;
+        }
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::AutomatedResIdL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::AutomatedResIdL( TBool aExpired, TBool aSecondParameter, TUint32 aRejectReason )
+    {
+    TInt resId(0);
+    TBool invalidImsi( EFalse );
+    invalidImsi = aRejectReason & EConstraintIndividual;
+
+    switch ( iAutomatedType )
+        {
+        case EAutomatedTypeRingingTone:
+            if ( aExpired )
+                {
+                if ( aSecondParameter )
+                    {
+                    resId = invalidImsi ?
+                        R_DRMHELPER_RINGING_TONE_INVALID_SIM_BUY_NEW :
+                        R_DRMHELPER_RINGING_TONE_EXPIRED_BUY_NEW;
+                    }
+                else
+                    {
+                    resId = invalidImsi ?
+                        R_DRM_NON_SD_RTONE_WRONG_SIM :
+                        R_DRMHELPER_RINGING_TONE_EXPIRED;
+                    }
+                }
+            break;
+        case EAutomatedTypeMessageAlert:
+            if ( aExpired )
+                {
+                if ( aSecondParameter )
+                    {
+                    resId = invalidImsi ?
+                        R_DRMHELPER_MESSAGE_TONE_INVALID_SIM_BUY_NEW :
+                        R_DRMHELPER_MESSAGE_TONE_EXPIRED_BUY_NEW;
+                    }
+                else
+                    {
+                    resId = invalidImsi ?
+                        R_DRM_NON_SD_MSG_AL_WRONG_SIM :
+                        R_DRMHELPER_MESSAGE_TONE_EXPIRED;
+                    }
+                }
+            break;
+        case EAutomatedTypeEmailAlert:
+            if ( aExpired )
+                {
+                if ( aSecondParameter )
+                    {
+                    resId = invalidImsi ?
+                        R_DRMHELPER_EMAIL_TONE_INVALID_SIM_BUY_NEW :
+                        R_DRMHELPER_EMAIL_TONE_EXPIRED_BUY_NEW;
+                    }
+                else
+                    {
+                    resId = invalidImsi ?
+                        R_DRM_NON_SD_EMAIL_WRONG_SIM :
+                        R_DRMHELPER_EMAIL_TONE_EXPIRED;
+                    }
+                }
+            break;
+        case EAutomatedTypeIMAlert:
+            if ( aExpired )
+                {
+                if ( aSecondParameter )
+                    {
+                    resId = /* invalidImsi ?
+                               R_DRMHELPER_IM_TONE_INVALID_SIM_BUY_NEW : */
+                        R_DRMHELPER_IM_TONE_EXPIRED_BUY_NEW;
+                    }
+                else
+                    {
+                    resId = R_DRMHELPER_IM_TONE_EXPIRED;
+                    }
+                }
+            break;
+        case EAutomatedTypeCalendarAlarm:
+            if ( aExpired )
+                {
+                if ( aSecondParameter )
+                    {
+                    resId = invalidImsi ?
+                        R_DRMHELPER_CAL_ALERT_INVALID_SIM_BUY_NEW :
+                        R_DRMHELPER_CAL_ALERT_EXPIRED_BUY_NEW;
+                    }
+                else
+                    {
+                    resId = invalidImsi ?
+                        R_DRM_NON_SD_CALEND_WRONG_SIM :
+                        R_DRMHELPER_CAL_ALERT_EXPIRED;
+                    }
+                }
+            break;
+        case EAutomatedTypeScreenSaver:
+            if ( aExpired )
+                {
+                if ( aSecondParameter )
+                    {
+                    resId = invalidImsi ?
+                        R_DRMHELPER_SCREENSAVER_INVALID_SIM_BUY_NEW :
+                        R_DRMHELPER_SCREENSAVER_EXPIRED_BUY_NEW;
+                    }
+                else
+                    {
+                    resId = invalidImsi ?
+                        R_DRM_NON_SD_SCREEN_WRONG_SIM :
+                        R_DRMHELPER_SCREENSAVER_EXPIRED;
+                    }
+                }
+            break;
+        case EAutomatedTypeWallpaper:
+            if ( aExpired )
+                {
+                if ( aSecondParameter )
+                    {
+                    resId = invalidImsi ?
+                        R_DRMHELPER_WALLPAPER_INVALID_SIM_BUY_NEW :
+                        R_DRMHELPER_WALLPAPER_EXPIRED_BUY_NEW;
+                    }
+                else
+                    {
+                    resId = invalidImsi ?
+                        R_DRM_NON_SD_WALLP_WRONG_SIM :
+                        R_DRMHELPER_WALLPAPER_EXPIRED;
+                    }
+                }
+            break;
+        case EAutomatedTypeTheme:
+            if ( aExpired )
+                {
+                if ( aSecondParameter )
+                    {
+                    resId = invalidImsi ?
+                        R_DRMHELPER_THEME_INVALID_SIM_BUY_NEW :
+                        R_DRMHELPER_THEME_EXPIRED_BUY_NEW;
+                    }
+                else
+                    {
+                    resId = invalidImsi ?
+                        R_DRM_NON_SD_THEME_WRONG_SIM :
+                        R_DRMHELPER_THEME_EXPIRED;
+                    }
+                }
+            break;
+        case EAutomatedTypeClockAlarm:
+            if ( aExpired )
+                {
+                if ( aSecondParameter )
+                    {
+                    resId = invalidImsi ?
+                        R_DRMHELPER_CLOCK_ALARM_INVALID_SIM_BUY_NEW :
+                        R_DRMHELPER_CLOCK_ALARM_EXPIRED_BUY_NEW;
+                    }
+                else
+                    {
+                    resId = invalidImsi ?
+                        R_DRM_NON_SD_CLOCK_WRONG_SIM :
+                        R_DRMHELPER_CLOCK_ALARM_EXPIRED;
+                    }
+                }
+            break;
+        case EAutomatedTypeOther:
+            // Flow through to default branch
+        default:
+            if ( aExpired )
+                {
+                if ( aSecondParameter )
+                    {
+                    resId = invalidImsi ?
+                        R_DRMHELPER_AUTOMATED_SD_INVALID_SIM :
+                        R_DRMHELPER_AUTOMATED_SD_EXPIRED;
+                    }
+                else
+                    {
+                    resId = invalidImsi ?
+                        R_DRM_NON_SD_GENER_WRONG_SIM :
+                        R_DRMHELPER_AUTOMATED_CD_EXPIRED;
+                    }
+                }
+            break;
+        }
+
+    return resId;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::IndicateIdle
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::IndicateIdle()
+    {
+    iHelperServer.IndicateIdle();
+    }
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::LaunchBrowserL
+// Launches browser embedded with given URL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::LaunchBrowserL( HBufC8* aUrl )
+    {
+    // URL needs to be unicode
+    HBufC* parameters = HBufC::NewLC( aUrl->Length() );
+    parameters->Des().Copy( *aUrl );
+    LaunchBrowserL( parameters );
+    CleanupStack::PopAndDestroy( parameters );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::LaunchBrowserL
+// Launches browser embedded with given URL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::LaunchBrowserL( HBufC* aUrl )
+    {
+    if ( aUrl )
+        {
+        HBufC* newUrl = NULL;
+        TInt i(0);
+        TPtrC ptr;
+        ptr.Set( *aUrl );
+        TBool space = ptr[i] == ' ' ? ETrue : EFalse;
+        while ( space )
+            {
+            i++;
+            space = ptr[i] == ' ' ? ETrue : EFalse;
+            }
+
+        // if no scheme exists, use http as default scheme
+        _LIT( KColon, ":" );
+        if ( ptr.Find( KColon ) == KErrNotFound )
+            {
+            _LIT( KHttp, "http://" );
+            const TInt KHttpLen(7);
+            newUrl = HBufC::NewLC( KHttpLen + aUrl->Length() );
+            newUrl->Des().Copy( KHttp );
+            newUrl->Des().Append( ptr.Mid( i ) );
+            ptr.Set( *newUrl );
+            i = 0;
+            }
+
+        CSchemeHandler* schemeHandler( CSchemeHandler::NewL( ptr.Mid( i ) ) );
+        CleanupStack::PushL( schemeHandler );
+        if ( iUseCoeEnv )
+            {
+            // launch embedded
+            schemeHandler->Observer( this );
+            schemeHandler->HandleUrlEmbeddedL();
+            CleanupStack::Pop( schemeHandler );
+            iSchemeHandler = schemeHandler;
+            iWait.Start();
+            }
+        else
+            {
+            // no CoeEnv, launch standalone with scheme app
+            schemeHandler->HandleUrlStandaloneL();
+            CleanupStack::PopAndDestroy( schemeHandler );
+            }
+        schemeHandler = NULL;
+
+        // delete newUrl if needed
+        if ( newUrl )
+            {
+            CleanupStack::PopAndDestroy( newUrl );
+            }
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::LaunchRightsManagerUiL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::LaunchRightsManagerUiL( const TDesC& aParam16 )
+    {
+    const TUid KUidDRMUI = {0x101f85c7};
+
+    if ( iUseCoeEnv )
+        {
+        CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC();
+        TAiwVariant variantObject( aParam16 );
+        TAiwGenericParam param( EGenericParamFile, variantObject );
+        paramList->AppendL( param );
+
+        CAknLaunchAppService* launchAppService =
+            CAknLaunchAppService::NewL( KUidDRMUI, this, paramList );
+        iWait.Start();
+        delete launchAppService;
+
+        CleanupStack::PopAndDestroy( paramList ); // paramList
+        }
+    else
+        {
+        // no UI to embed, launch Rights Manager UI stand-alone
+
+        // check if Rights Manager UI is already running
+        RWsSession wsSession;
+        User::LeaveIfError( wsSession.Connect() );
+        CleanupClosePushL( wsSession );
+        TApaTaskList tasklist( wsSession );
+        TApaTask task = tasklist.FindApp( KUidDRMUI );
+        if ( task.Exists() )
+            {
+            // Rights Manager UI is already running
+            HBufC8* param8 = HBufC8::NewLC( aParam16.Length() );
+            TPtr8 parametersPtr = param8->Des();
+            parametersPtr.Copy( aParam16 );
+            task.SendMessage( TUid::Uid( KUidApaMessageSwitchOpenFileValue ), *param8 );
+            CleanupStack::PopAndDestroy( param8 );
+            }
+        else
+            {
+            RApaLsSession appArcSession;
+            User::LeaveIfError( appArcSession.Connect() );
+            TThreadId id;
+            appArcSession.StartDocument( aParam16, KUidDRMUI, id );
+            appArcSession.Close();
+            }
+        CleanupStack::PopAndDestroy( &wsSession );
+        }
+    return;
+    }
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetRightsIssuerL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::GetRightsIssuerL( const CData& aContent, HBufC*& aIssuer )
+    {
+    RDRMRightsClient client;
+    TInt error;
+    HBufC* decodedIssuer = NULL;
+    HBufC* newBuf = NULL;
+    TInt urlLength = KUrlMaxLen;
+
+    // connect to the rights server
+    User::LeaveIfError( client.Connect() );
+    CleanupClosePushL( client );
+
+    HBufC* rightsIssuerBuf = HBufC::NewLC( urlLength );
+    TPtr rightsIssuer(const_cast<TUint16*>(rightsIssuerBuf->Ptr()), 0, urlLength);
+
+    // Get value of rights-issuer header field
+    error = aContent.GetStringAttribute( ERightsIssuerUrl, rightsIssuer );
+
+    while ( error == KErrOverflow )
+        {
+        urlLength += KUrlMaxLen;
+        newBuf = rightsIssuerBuf->ReAllocL( urlLength );
+        CleanupStack::Pop( rightsIssuerBuf );
+        rightsIssuerBuf = newBuf;
+        CleanupStack::PushL( rightsIssuerBuf );
+        rightsIssuer.Set(const_cast<TUint16*>(rightsIssuerBuf->Ptr()), 0, urlLength);
+        error = aContent.GetStringAttribute( ERightsIssuerUrl, rightsIssuer );
+        }
+
+    // If we got no error, and found some rights issuer
+    if ( ( !error  ) && ( rightsIssuer.Length() != 0 ) )
+        {
+        if ( aIssuer )
+            {
+            delete aIssuer;
+            aIssuer = NULL;
+            }
+
+        // check if rights issuer is encrypted
+        if ( rightsIssuer.MatchF( KEncryptedRightsIssuerMatchString ) !=
+            KErrNotFound )
+            {
+            HBufC8* input = NULL;
+            HBufC8* output = NULL;
+
+            input = CnvUtfConverter::ConvertFromUnicodeToUtf8L(rightsIssuer);
+            CleanupStack::PushL( input );
+
+            // encrypted, decrypt
+            User::LeaveIfError( client.DecodeRightsIssuerField( *input,
+                    output ) );
+            CleanupStack::PopAndDestroy( input );
+            CleanupStack::PushL( output );
+
+            decodedIssuer= CnvUtfConverter::ConvertToUnicodeFromUtf8L(*output);
+            CleanupStack::PopAndDestroy( output );
+
+            aIssuer = decodedIssuer;
+            }
+        else
+            {
+            aIssuer = rightsIssuer.AllocL();
+            }
+        }
+    else if ( rightsIssuer.Length() != 0 )
+        {
+        if ( aIssuer )
+            {
+            delete aIssuer;
+            aIssuer = NULL;
+            }
+        User::Leave( KErrNotFound );
+        }
+    CleanupStack::PopAndDestroy( rightsIssuerBuf );
+    CleanupStack::PopAndDestroy( &client );
+    User::LeaveIfError( error );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CalculateEndTime
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::CalculateEndTime(
+    CDRMRights* aRights,
+    TInt aIntent,
+    TTime& aEndTime,
+    TBool& aInactive )
+    {
+    CDRMRightsConstraints* constraint = NULL;
+    TInt error( KErrNotFound );
+
+    if ( aIntent == DRMCommon::EPrint )
+        {
+        if ( aRights->GetPrintRight( constraint ) == DRMCommon::EOk )
+            {
+            error = GetEndTime( constraint, aEndTime, aInactive );
+            }
+        delete constraint;
+        constraint = NULL;
+        }
+
+    if ( aIntent == DRMCommon::EExecute )
+        {
+        if ( aRights->GetExecuteRight( constraint ) == DRMCommon::EOk )
+            {
+            error = GetEndTime( constraint, aEndTime, aInactive );
+            }
+        delete constraint;
+        constraint = NULL;
+        }
+
+    if ( aIntent == DRMCommon::EPlay )
+        {
+        if ( aRights->GetPlayRight( constraint ) == DRMCommon::EOk )
+            {
+            error = GetEndTime( constraint, aEndTime, aInactive );
+            }
+        delete constraint;
+        constraint = NULL;
+        }
+
+    if ( aIntent == DRMCommon::EDisplay )
+        {
+        if ( aRights->GetDisplayRight( constraint ) == DRMCommon::EOk )
+            {
+            error = GetEndTime( constraint, aEndTime, aInactive );
+            }
+        delete constraint;
+        }
+
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetStartTime
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::GetStartTime(
+    CDRMRights* aRights,
+    TInt aIntent,
+    TTime& aStartTime)
+    {
+    CDRMRightsConstraints* constraint = NULL;
+    TInt error( KErrNotFound );
+
+    if ( aIntent == DRMCommon::EPrint )
+        {
+        if ( aRights->GetPrintRight( constraint ) == DRMCommon::EOk )
+            {
+            error = constraint->GetStartTime( aStartTime );
+            }
+        delete constraint;
+        constraint = NULL;
+        }
+
+    if ( aIntent == DRMCommon::EExecute )
+        {
+        if ( aRights->GetExecuteRight( constraint ) == DRMCommon::EOk )
+            {
+            error = constraint->GetStartTime( aStartTime );
+            }
+        delete constraint;
+        constraint = NULL;
+        }
+
+    if ( aIntent == DRMCommon::EPlay )
+        {
+        if ( aRights->GetPlayRight( constraint ) == DRMCommon::EOk )
+            {
+            error = constraint->GetStartTime( aStartTime );
+            }
+        delete constraint;
+        constraint = NULL;
+        }
+
+    if ( aIntent == DRMCommon::EDisplay )
+        {
+        if ( aRights->GetDisplayRight( constraint ) == DRMCommon::EOk )
+            {
+            error = constraint->GetStartTime( aStartTime );
+            }
+        delete constraint;
+        }
+
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetEndTime
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::GetEndTime(
+    CDRMRightsConstraints* aConstraint,
+    TTime& aEndTime,
+    TBool& aInactive )
+    {
+    TTime endTime;
+    TInt error ( KErrNotFound );
+
+    if ( aConstraint->GetEndTime( endTime ) == DRMCommon::EOk )
+        {
+        aEndTime = endTime;
+        error = KErrNone;
+        aInactive = EFalse;
+        }
+    else
+        {
+        TTimeIntervalSeconds interval;
+
+        if ( aConstraint->GetInterval( interval ) == DRMCommon::EOk )
+            {
+            // interval rights
+            TTime start;
+
+            if ( aConstraint->GetIntervalStart( start ) == DRMCommon::EOk )
+                {
+                // activated interval
+                aEndTime = start + interval;
+                aInactive = EFalse;
+                }
+            else
+                {
+                // inactive interval
+                aEndTime.HomeTime();
+                aEndTime += interval;
+                aInactive = ETrue;
+                }
+            error = KErrNone;
+            }
+        }
+    return error;
+    }
+
+
+#pragma mark -
+
+EXPORT_C TInt CDRMHelper::Consume2(
+    const TDesC8& aContentURI,
+    TUint32 aRightsSpec,
+    TDRMHelperConsumeAction anAction)
+    {
+    CConsumeData* newData = NULL;
+    TInt ret = KErrNone;
+    ContentAccess::TIntent intent = ContentAccess::EUnknown;
+    TInt i;
+    TBool found = EFalse;
+
+    // convert rights spec + action -> intent
+    if ( anAction == EStart )
+        {
+        switch ( aRightsSpec )
+            {
+            case CDRMRights::EPlay:
+                intent = ContentAccess::EPlay;
+                break;
+            case CDRMRights::EDisplay:
+                intent = ContentAccess::EView;
+                break;
+            case CDRMRights::EPrint:
+                intent = ContentAccess::EPrint;
+                break;
+            case CDRMRights::EExecute:
+                intent = ContentAccess::EExecute;
+                break;
+            case CDRMRights::EInstall:
+                intent = ContentAccess::EInstall;
+                break;
+            default:
+                break;
+            }
+        }
+    else if ( anAction == EFinish )
+        {
+        intent = ContentAccess::EStop;
+        }
+    else if ( anAction == EPause )
+        {
+        intent = ContentAccess::EPause;
+        }
+    else if ( anAction == EContinue )
+        {
+        intent = ContentAccess::EContinue;
+        }
+
+    // find correct item from list
+    for ( i = 0; i < iConsumeList.Count(); i++ )
+        {
+        if ( iConsumeList[i]->CompareUri( aContentURI ) == 0 )
+            {
+            found = ETrue;
+            break;
+            }
+        }
+
+    if ( intent == ContentAccess::EStop )
+        {
+        if ( found )
+            {
+            // finish consume
+            ret = iConsumeList[i]->Consume( intent );
+
+            // remove from list
+            delete iConsumeList[i];
+            iConsumeList.Remove( i );
+            }
+        else
+            {
+            // not found
+            ret = KErrNotFound;
+            }
+        }
+    else
+        {
+        // start, pause or continue
+        if ( !found )
+            {
+            TInt len = aContentURI.Length();
+            if ( len )
+                {
+                // for pause and continue existing connection is required
+                if ( intent != ContentAccess::EPause &&
+                    intent != ContentAccess::EContinue )
+                    {
+                    // no previous connection with this content
+                    TRAP( ret, newData = CConsumeData::NewL( aContentURI ) );
+
+                    if ( !ret )
+                        {
+                        iConsumeList.Append( newData );
+                        ret = newData->Consume( intent );
+                        }
+                    }
+                else
+                    {
+                    // pause or continue
+                    ret = KErrNotFound;
+                    }
+                }
+            else
+                {
+                // empty content URI
+                ret = KErrArgument;
+                }
+            }
+        else
+            {
+            // we have consume active for this content, just call
+            // consume again
+            ret = iConsumeList[i]->Consume( intent );
+            }
+        }
+    return ret;
+    }
+
+
+EXPORT_C TInt CDRMHelper::ConsumeFile2(
+    const TDesC& aFileName,
+    TUint32 aRightsSpec,
+    TDRMHelperConsumeAction anAction)
+    {
+    CDcfCommon* dcf = NULL;
+    RFile file;
+    TInt r = KErrNone;
+
+    r = file.Open(iFs, aFileName, EFileRead | EFileShareReadersOrWriters);
+
+    if (r == KErrInUse)
+        {
+        r = file.Open(iFs, aFileName, EFileRead | EFileShareAny);
+        if (r == KErrInUse)
+            {
+            r = file.Open(iFs, aFileName, EFileRead | EFileShareReadersOnly);
+            }
+        }
+    if (r == KErrNone)
+        {
+        TRAP(r, dcf = CDcfCommon::NewL(file));
+        if ( dcf )
+            {
+            r = Consume2(*dcf->iContentID, aRightsSpec, anAction);
+            delete dcf;
+            }
+        file.Close();
+        }
+    return r;
+    }
+
+
+EXPORT_C TInt CDRMHelper::ConsumeFile2(
+    RFile& aFileHandle,
+    TUint32 aRightsSpec,
+    TDRMHelperConsumeAction anAction)
+    {
+    CDcfCommon* dcf = NULL;
+    TInt r = KErrNone;
+
+    TRAP(r, dcf = CDcfCommon::NewL(aFileHandle));
+    if ( dcf )
+        {
+        r = Consume2(*dcf->iContentID, aRightsSpec, anAction);
+        delete dcf;
+        }
+    return r;
+    }
+
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ActivateContentL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::ActivateContentL( CData& aContent )
+    {
+    if ( iOma2 )
+        {
+        TInt drmProtected(0);
+        aContent.GetAttribute( EIsProtected, drmProtected );
+        // no need to do anything if content is not protected
+        if ( drmProtected )
+            {
+            TInt expired(0);
+            TInt missing(0);
+
+            // Check if rights are expired or missing
+            aContent.GetAttribute( ERightsHaveExpired, expired );
+            aContent.GetAttribute( ERightsNone, missing );
+            if ( expired || missing )
+                {
+                HBufC* rightsIssuer = NULL;
+
+                // Get RI URL
+                TRAPD( err, GetRightsIssuerL( aContent, rightsIssuer ) );
+                if ( !err )
+                    {
+                    TInt buyRights;
+                    // superdistributable
+                    CleanupStack::PushL( rightsIssuer );
+
+                    if ( expired )
+                        {
+                        buyRights = DisplayQueryWithIdL(
+                            R_DRMHELPER_USAGE_RIGHTS_EXPIRED_BUY_NEW,
+                            R_DRMHELPER_CONFIRMATION_QUERY );
+                        }
+                    else
+                        {
+                        // rights missing
+                        buyRights = DisplayQueryWithIdL(
+                            R_DRMHELPER_NO_USAGE_RIGHTS_BUY_NEW,
+                            R_DRMHELPER_CONFIRMATION_QUERY );
+                        }
+
+                    if ( buyRights )
+                        {
+                        // Launch browser
+                        LaunchBrowserL( rightsIssuer );
+                        }
+                    else
+                        {
+                        User::Leave( KErrCancel );
+                        }
+
+                    CleanupStack::PopAndDestroy( rightsIssuer );
+                    }
+                else
+                    {
+                    // non-superdistributable
+                    if ( expired )
+                        {
+                        // rights expired
+                        DisplayInfoNoteL( R_DRMHELPER_USAGE_RIGHTS_EXPIRED );
+                        }
+                    else
+                        {
+                        // rights missing
+                        DisplayInfoNoteL( R_DRMHELPER_NO_USAGE_RIGHTS );
+                        }
+                    }
+                }
+            else
+                {
+                // If rights are valid or future rights, they should not be
+                // updated
+                User::Leave( KErrArgument );
+                }
+            }
+        else
+            {
+            // this function should be called only for protected content
+            User::Leave( KErrArgument );
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::ActivateContentL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::ActivateContentL( TDesC& aFileName )
+    {
+    if ( iOma2 )
+        {
+        TVirtualPathPtr virtualPath( aFileName );
+
+        CData* content = NULL;
+        TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+        if ( r == KErrInUse )
+            {
+            content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+            }
+        else
+            {
+            User::LeaveIfError( r );
+            }
+        CleanupStack::PushL( content );
+
+        ActivateContentL( *content );
+        CleanupStack::PopAndDestroy( content );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    }
+
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HasInfoUrlL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelper::HasInfoUrlL( CData& aContent, HBufC8*& aInfoUrl )
+    {
+    TBool ret = EFalse;
+
+    if ( iOma2 )
+        {
+        TBuf<KUrlMaxLen> infoUrl;
+
+        TInt error = aContent.GetStringAttribute( EInfoURL, infoUrl );
+        if ( !error )
+            {
+            infoUrl.TrimLeft();
+            if ( infoUrl.Length() > 0 )
+                {
+                aInfoUrl = HBufC8::NewL( infoUrl.Length() );
+                aInfoUrl->Des().Copy( infoUrl );
+                ret = ETrue;
+                }
+            else
+                {
+                ret = EFalse;
+                }
+            }
+        else
+            {
+            ret = EFalse;
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HasInfoUrlL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CDRMHelper::HasInfoUrlL(TDesC& aFileName, HBufC8*& aInfoUrl )
+    {
+    TBool ret = EFalse;
+
+    if ( iOma2 )
+        {
+        TVirtualPathPtr virtualPath( aFileName );
+
+        CData* content( NULL );
+        TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+        if ( r == KErrInUse )
+            {
+            content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+            }
+        else
+            {
+            User::LeaveIfError( r );
+            }
+
+        CleanupStack::PushL( content );
+
+        ret = HasInfoUrlL( *content, aInfoUrl );
+        CleanupStack::PopAndDestroy( content );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    return ret;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::OpenInfoUrlL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::OpenInfoUrlL( CData& aContent )
+    {
+    if ( iOma2 )
+        {
+        HBufC8* infoUrl;
+        if ( HasInfoUrlL( aContent, infoUrl ) )
+            {
+            CleanupStack::PushL( infoUrl );
+            LaunchBrowserL( infoUrl );
+            CleanupStack::PopAndDestroy( infoUrl );
+            }
+        else
+            {
+            User::Leave( KErrArgument );
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::OpenInfoUrlL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDRMHelper::OpenInfoUrlL(TDesC& aFileName )
+    {
+    if ( iOma2 )
+        {
+        TVirtualPathPtr virtualPath( aFileName );
+
+        CData* content( NULL );
+        TRAPD( r, content = CData::NewL( virtualPath, EPeek, EContentShareReadWrite ) );
+        if ( r == KErrInUse )
+            {
+            content = CData::NewL( virtualPath, EPeek, EContentShareReadOnly );
+            }
+        else
+            {
+            User::LeaveIfError( r );
+            }
+
+        CleanupStack::PushL( content );
+
+        OpenInfoUrlL( *content );
+        CleanupStack::PopAndDestroy( content );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+    }
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DisplayQueryL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DisplayQueryWithIdL(
+    TInt aTextResourceId,
+    TInt aQueryResourceId )
+    {
+    TInt button(0);
+    if ( iUseCoeEnv )
+        {
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        TFileName fileName( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDrive, "%c:");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+        iFs.DriveToChar( driveNumber, driveLetter );
+
+        TFileName fileName;
+
+        fileName.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+        fileName.Append( KDC_RESOURCE_FILES_DIR );
+        fileName.Append( KCDRMHelperResFileName );
+        RConeResourceLoader loader( *iCoeEnv );
+        loader.OpenL( fileName );
+        CleanupClosePushL( loader );
+
+        HBufC* msgText = StringLoader::LoadLC( aTextResourceId, iCoeEnv );
+        button = DisplayQueryL( *msgText, aQueryResourceId );
+        CleanupStack::PopAndDestroy( msgText );
+        CleanupStack::PopAndDestroy( &loader );
+        }
+    else
+        {
+        TInt buttonsId =
+            aQueryResourceId == R_DRMHELPER_WAITING_RIGHTS_CONFIRMATION_QUERY ?
+            R_AVKON_SOFTKEYS_OK_EMPTY__OK : R_AVKON_SOFTKEYS_YES_NO__YES;
+        CDRMHelperGlobalNoteWrapper* noteWrapper =
+            CDRMHelperGlobalNoteWrapper::NewLC( iStringResourceReader );
+
+        button = noteWrapper->ShowNoteWithButtonsL( aTextResourceId, buttonsId );
+        CleanupStack::PopAndDestroy( noteWrapper );
+        }
+    return button;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DisplayQueryL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DisplayQueryWithIdValueL(
+    TInt aTextResourceId,
+    TInt aQueryResourceId,
+    const TDesC& aString )
+    {
+    TInt button(0);
+    if ( iUseCoeEnv )
+        {
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        TFileName fileName( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDrive, "%c:");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+        iFs.DriveToChar( driveNumber, driveLetter );
+
+        TFileName fileName;
+
+        fileName.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+        fileName.Append( KDC_RESOURCE_FILES_DIR );
+        fileName.Append( KCDRMHelperResFileName );
+        RConeResourceLoader loader( *iCoeEnv );
+        loader.OpenL( fileName );
+        CleanupClosePushL( loader );
+
+        HBufC* msgText = StringLoader::LoadLC( aTextResourceId, aString, iCoeEnv );
+        button = DisplayQueryL( *msgText, aQueryResourceId );
+        CleanupStack::PopAndDestroy( msgText );
+        CleanupStack::PopAndDestroy( &loader );
+        }
+    else
+        {
+        TInt buttonsId =
+            aQueryResourceId == R_DRMHELPER_WAITING_RIGHTS_CONFIRMATION_QUERY ?
+            R_AVKON_SOFTKEYS_OK_EMPTY__OK : R_AVKON_SOFTKEYS_YES_NO__YES;
+        CDRMHelperGlobalNoteWrapper* noteWrapper =
+            CDRMHelperGlobalNoteWrapper::NewLC( iStringResourceReader );
+
+        button = noteWrapper->ShowNoteWithButtonsL( aTextResourceId, buttonsId, aString );
+        CleanupStack::PopAndDestroy( noteWrapper );
+        }
+    return button;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DisplayQueryL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DisplayQueryL( TInt aTextResourceId, TInt aValue )
+    {
+    TInt buttonCode( 0 );
+    if ( iUseCoeEnv )
+        {
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        TFileName fileName( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDrive, "%c:");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+        iFs.DriveToChar( driveNumber, driveLetter );
+
+        TFileName fileName;
+
+        fileName.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+        fileName.Append( KDC_RESOURCE_FILES_DIR );
+        fileName.Append( KCDRMHelperResFileName );
+        RConeResourceLoader loader( *iCoeEnv );
+        loader.OpenL( fileName );
+        CleanupClosePushL( loader );
+        TPtr bufPtr(0,0);
+
+        HBufC* stringholder = StringLoader::LoadLC( aTextResourceId, aValue,
+            iCoeEnv );
+        CAknQueryDialog* dlg = CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
+        CleanupStack::PushL( dlg );
+
+        bufPtr.Set( stringholder->Des() );
+        AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+        PrepareSecondaryDisplayL( *dlg, aTextResourceId, KNullDesC, aValue );
+
+        CleanupStack::Pop( dlg );
+
+        buttonCode = dlg->ExecuteLD( R_DRMHELPER_CONFIRMATION_QUERY, *stringholder );
+
+        CancelSecondaryDisplayL( aTextResourceId );
+        CleanupStack::PopAndDestroy( stringholder );
+        CleanupStack::PopAndDestroy( &loader );
+        }
+    else
+        {
+        CDRMHelperGlobalNoteWrapper* noteWrapper =
+            CDRMHelperGlobalNoteWrapper::NewLC( iStringResourceReader );
+        buttonCode = noteWrapper->ShowNoteL( aTextResourceId, aValue );
+        CleanupStack::PopAndDestroy( noteWrapper );
+        }
+    return buttonCode;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DisplayQueryL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DisplayQueryL( TInt aTextResourceId, const TDesC& aString )
+    {
+    TInt buttonCode( 0 );
+    if ( iUseCoeEnv )
+        {
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        TFileName fileName( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDrive, "%c:");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+        iFs.DriveToChar( driveNumber, driveLetter );
+
+        TFileName fileName;
+
+        fileName.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+        fileName.Append( KDC_RESOURCE_FILES_DIR );
+        fileName.Append( KCDRMHelperResFileName );
+        RConeResourceLoader loader( *iCoeEnv );
+        loader.OpenL( fileName );
+        CleanupClosePushL( loader );
+        TPtr bufPtr(0,0);
+
+        HBufC* stringholder = StringLoader::LoadLC( aTextResourceId, aString,
+            iCoeEnv );
+        CAknQueryDialog* dlg(
+            CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ) );
+        CleanupStack::PushL( dlg );
+
+        bufPtr.Set( stringholder->Des() );
+        AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+        PrepareSecondaryDisplayL( *dlg, aTextResourceId, aString, -1 );
+        CleanupStack::Pop( dlg );
+
+        buttonCode = dlg->ExecuteLD( R_DRMHELPER_CONFIRMATION_QUERY, *stringholder );
+
+        CancelSecondaryDisplayL( aTextResourceId );
+        CleanupStack::PopAndDestroy( stringholder );
+        CleanupStack::PopAndDestroy( &loader );
+        }
+    else
+        {
+        CDRMHelperGlobalNoteWrapper* noteWrapper =
+            CDRMHelperGlobalNoteWrapper::NewLC( iStringResourceReader );
+        buttonCode = noteWrapper->ShowNoteL( aTextResourceId, aString );
+        CleanupStack::PopAndDestroy( noteWrapper );
+        }
+    return buttonCode;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DisplayQueryL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DisplayQueryL(
+    TInt aTextResourceId,
+    const TDesC& aString,
+    TInt aValue,
+    TInt aStringPos,
+    TInt aValuePos )
+    {
+    TInt buttonCode( 0 );
+    if ( iUseCoeEnv )
+        {
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        TFileName fileName( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDrive, "%c:");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+        iFs.DriveToChar( driveNumber, driveLetter );
+
+        TFileName fileName;
+
+        fileName.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+        fileName.Append( KDC_RESOURCE_FILES_DIR );
+        fileName.Append( KCDRMHelperResFileName );
+        RConeResourceLoader loader( *iCoeEnv );
+        loader.OpenL( fileName );
+        CleanupClosePushL( loader );
+        TPtr bufPtr( 0,0 );
+
+        TBuf<KDRMHelperNoteMaxSize> textBuffer, textBuffer2;
+        StringLoader::Load( textBuffer, aTextResourceId, iCoeEnv );
+        StringLoader::Format( textBuffer2, textBuffer, aValuePos, aValue );
+        textBuffer = textBuffer2;
+        StringLoader::Format( textBuffer2, textBuffer, aStringPos, aString );
+
+        bufPtr.Set( const_cast <TUint16*>( textBuffer2.Ptr() ), textBuffer2.Length(),
+            textBuffer2.Length() );
+        AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+
+        CAknQueryDialog* dlg =
+            CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
+        PrepareSecondaryDisplayL( *dlg, aTextResourceId, aString, aValue );
+        buttonCode =
+            dlg->ExecuteLD( R_DRMHELPER_CONFIRMATION_QUERY, textBuffer2 );
+
+        CancelSecondaryDisplayL( aTextResourceId );
+        CleanupStack::PopAndDestroy( &loader );
+        }
+    else
+        {
+        CDRMHelperGlobalNoteWrapper* noteWrapper =
+            CDRMHelperGlobalNoteWrapper::NewLC( iStringResourceReader );
+        buttonCode = noteWrapper->ShowNoteL( aTextResourceId, aString,
+            aValue, aStringPos, aValuePos );
+        CleanupStack::PopAndDestroy( noteWrapper );
+        }
+    return buttonCode;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DisplayQueryL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::DisplayQueryL( TDesC& aPromptText, TInt aQueryResourceId )
+    {
+    CAknQueryDialog* dlg(
+        new (ELeave) CAknQueryDialog( aPromptText, CAknQueryDialog::ENoTone ) );
+    CleanupStack::PushL( dlg );
+
+    TPtr bufPtr( 0,0 );
+    bufPtr.Set( const_cast <TUint16*>( aPromptText.Ptr() ), aPromptText.Length(),
+        aPromptText.Length() );
+    AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+
+    PrepareSecondaryDisplayL( *dlg, aQueryResourceId, aPromptText, -1 );
+
+    CleanupStack::Pop( dlg );
+
+    TInt ret = dlg->ExecuteLD( aQueryResourceId );
+    CancelSecondaryDisplayL( aQueryResourceId );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DisplayInfoNoteL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::DisplayInfoNoteL( TInt aTextResourceId )
+    {
+    if ( iUseCoeEnv )
+        {
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        TFileName fileName( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDrive, "%c:");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+        iFs.DriveToChar( driveNumber, driveLetter );
+
+        TFileName fileName;
+
+        fileName.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+        fileName.Append( KDC_RESOURCE_FILES_DIR );
+        fileName.Append( KCDRMHelperResFileName );
+        RConeResourceLoader loader( *iCoeEnv );
+        loader.OpenL( fileName );
+        CleanupClosePushL( loader );
+
+        HBufC* msgText = StringLoader::LoadLC( aTextResourceId, iCoeEnv );
+        DisplayInfoNoteL( *msgText, aTextResourceId );
+        CleanupStack::PopAndDestroy( msgText );
+        CleanupStack::PopAndDestroy( &loader );
+        }
+    else
+        {
+
+        TBuf<KDRMHelperNoteMaxSize> buffer =
+            iStringResourceReader->ReadResourceString( aTextResourceId );
+
+        DisplayInfoNoteL( buffer, aTextResourceId );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DisplayInfoNoteL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::DisplayInfoNoteL( TInt aTextResourceId, const TDesC& aString )
+    {
+    if ( iUseCoeEnv )
+        {
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        TFileName fileName( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDrive, "%c:");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+        iFs.DriveToChar( driveNumber, driveLetter );
+
+        TFileName fileName;
+
+        fileName.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+        fileName.Append( KDC_RESOURCE_FILES_DIR );
+        fileName.Append( KCDRMHelperResFileName );
+        RConeResourceLoader loader( *iCoeEnv );
+        loader.OpenL( fileName );
+        CleanupClosePushL( loader );
+
+        HBufC* msgText = StringLoader::LoadLC( aTextResourceId, aString,
+            iCoeEnv );
+        DisplayInfoNoteL( *msgText, aTextResourceId );
+        CleanupStack::PopAndDestroy( msgText );
+        CleanupStack::PopAndDestroy( &loader );
+        }
+    else
+        {
+        TBuf<KDRMHelperNoteMaxSize + KMaxFileName> destBuffer;
+
+
+        TBuf<KDRMHelperNoteMaxSize> buffer =
+            iStringResourceReader->ReadResourceString( aTextResourceId );
+
+
+        StringLoader::Format( destBuffer, buffer, -1, aString );
+        DisplayInfoNoteL( destBuffer, aTextResourceId, aString, -1 );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DisplayInfoNoteL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::DisplayInfoNoteL( TInt aTextResourceId, TInt aValue )
+    {
+    if ( iUseCoeEnv )
+        {
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        TFileName fileName( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDrive, "%c:");
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+        iFs.DriveToChar( driveNumber, driveLetter );
+
+        TFileName fileName;
+
+        fileName.Format( KDrive, (TUint)driveLetter );
+
+#endif
+
+        fileName.Append( KDC_RESOURCE_FILES_DIR );
+        fileName.Append( KCDRMHelperResFileName );
+        RConeResourceLoader loader( *iCoeEnv );
+        loader.OpenL( fileName );
+        CleanupClosePushL( loader );
+
+        HBufC* msgText = StringLoader::LoadLC( aTextResourceId, aValue,
+            iCoeEnv );
+        DisplayInfoNoteL( *msgText, aTextResourceId, KNullDesC, aValue );
+        CleanupStack::PopAndDestroy( msgText );
+        CleanupStack::PopAndDestroy( &loader );
+        }
+    else
+        {
+        TBuf<KDRMHelperNoteMaxSize + KMaxFileName> destBuffer;
+
+
+        TBuf<KDRMHelperNoteMaxSize> buffer =
+            iStringResourceReader->ReadResourceString( aTextResourceId );
+
+
+        StringLoader::Format( destBuffer, buffer, -1, aValue );
+        DisplayInfoNoteL( destBuffer, aTextResourceId, KNullDesC, aValue );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::DisplayInfoNoteL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::DisplayInfoNoteL( TDesC& aPromptText, TInt aResourceId,
+    const TDesC& aString, TInt aValue )
+    {
+    TPtr bufPtr(0,0);
+    bufPtr.Set(
+        const_cast <TUint16*>( aPromptText.Ptr() ),
+        aPromptText.Length(),
+        aPromptText.Length() );
+    AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
+
+    if ( iUseCoeEnv )
+        {
+        CAknResourceNoteDialog* note( CreateNoteForResourceL( aResourceId ) );
+
+        PrepareSecondaryDisplayL( *note, aResourceId, aString, aValue );
+        note->ExecuteLD( aPromptText );
+        CancelSecondaryDisplayL( aResourceId );
+        }
+    else
+        {
+        CDRMHelperInfoNoteWrapper* note = CDRMHelperInfoNoteWrapper::NewLC();
+        User::LeaveIfError(iNoteList.Append(note)); //a list for simultanous notes
+        CleanupStack::Pop( note );
+        note->ShowNoteL( GlobalNoteTypeForResource( aResourceId ),
+            aPromptText,
+            aResourceId,
+            aString,
+            aValue );
+        }
+    }
+
+#pragma mark -
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::StripPathAndExtensionL
+// -----------------------------------------------------------------------------
+//
+TPtrC CDRMHelper::StripPathAndExtension( const TDesC& aFileName )
+    {
+    // find index of last backslash
+    TInt index = aFileName.LocateReverse( '\\' );
+
+    // get filename+extension part
+    TPtrC filenameWithExtension = aFileName.Right(
+        aFileName.Length() - (index + 1) );
+
+    // get index of dot
+    index = filenameWithExtension.Locate( '.' );
+
+    // if dot not found, there's no extension
+    if ( index == KErrNotFound )
+        {
+        index = (filenameWithExtension.Length() - 1);
+        }
+
+    // strip extension
+    return filenameWithExtension.Left( index );
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::GetFileHandleFromURIL
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::GetFileHandleFromURIL( const TDesC8& aURI, RFile& aFileHandle )
+    {
+    CDcfRep* rep = CDcfRep::NewL();
+    CleanupStack::PushL( rep );
+    rep->GetFileHandleL( aURI, aFileHandle, iFs );
+    CleanupStack::PopAndDestroy( rep );
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::Intent
+// -----------------------------------------------------------------------------
+//
+TInt CDRMHelper::Intent( const HBufC* aMimeType )
+    {
+    TInt intent = ContentAccess::EUnknown;
+
+    _LIT( KDRMHelperMimeTypeAudio, "Audio" );
+    _LIT( KDRMHelperMimeTypeVideo, "Video" );
+    _LIT( KDRMHelperMimeTypeImage, "Image" );
+    _LIT( KDRMHelperMimeTypeApplication, "Application" );
+    _LIT( KDRMHelperMimeTypeShockwave, "Application/x-shockwave-flash" );
+    _LIT( KDRMHelperMimeTypeRingingTone, "Application/vnd.nokia.ringing-tone" );
+    _LIT( KDRMHelperMimeTypeSkin, "Application/x-series60-skn" );
+    _LIT( KDRMHelperMimeTypePIP, "Application/x-pip" );
+    _LIT( KDRMHelperMimeTypeSis, "Application/vnd.symbian.install" );
+    _LIT( KDRMHelperMimeTypeRealMedia, "Application/x-pn-realmedia" );
+    _LIT( KDRMHelperMimeTypeVndRealMedia, "Application/vnd.rn-realmedia" );
+
+    if ( iAutomatedType == EAutomatedTypeTheme)
+        {
+        // if automated theme
+        return DRMCommon::EDisplay;
+        }
+
+    if ( aMimeType )
+        {
+        if ( !aMimeType->FindF( KDRMHelperMimeTypeRingingTone ) )
+            {
+            // nokia ringning tone
+            intent = DRMCommon::EPlay;
+            }
+        else if ( !aMimeType->FindF( KDRMHelperMimeTypeSkin ) )
+            {
+            // skin package
+            intent = DRMCommon::EDisplay;
+            }
+        else if ( !aMimeType->FindF( KDRMHelperMimeTypePIP ) )
+            {
+            // PIP package
+            intent = DRMCommon::EExecute;
+            }
+        else if ( !aMimeType->FindF( KDRMHelperMimeTypeSis ) )
+            {
+            // executable application or skin
+            intent = DRMCommon::EExecute;
+            }
+        else if ( !aMimeType->FindF( KDRMHelperMimeTypeShockwave ) )
+            {
+            // shockwave flash
+            intent = DRMCommon::EExecute;
+            }
+        else if ( !aMimeType->FindF( KDRMHelperMimeTypeRealMedia ) ||
+            !aMimeType->FindF( KDRMHelperMimeTypeVndRealMedia ) )
+            {
+            // realmedia
+            intent = DRMCommon::EPlay;
+            }
+        else if ( !aMimeType->FindF( KDRMHelperMimeTypeApplication ) )
+            {
+            // executable application
+            intent = DRMCommon::EExecute;
+            }
+        else if ( !aMimeType->FindF( KDRMHelperMimeTypeImage ) )
+            {
+            // image
+            intent = DRMCommon::EDisplay;
+            }
+        else if ( !aMimeType->FindF( KDRMHelperMimeTypeVideo ) )
+            {
+            // video
+            intent = DRMCommon::EPlay;
+            }
+        else if ( !aMimeType->FindF( KDRMHelperMimeTypeAudio ) )
+            {
+            // audio
+            intent = DRMCommon::EPlay;
+            }
+        }
+    return intent;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::MimeTypeFromURIL
+// -----------------------------------------------------------------------------
+//
+HBufC* CDRMHelper::MimeTypeFromURIL( const TDesC8& aURI )
+    {
+    HBufC* mimeType = NULL;
+    RFile fileHandle;
+    TInt error ( KErrNone );
+    CleanupClosePushL(fileHandle);
+
+    if ( !GetFileHandleFromURIL( aURI, fileHandle ) )
+        {
+        CData* content = CData::NewLC( fileHandle, KDefaultContentObject, EPeek );
+
+        mimeType = HBufC::NewLC( KMaxDataTypeLength );
+        TPtr ptr = mimeType->Des();
+        error = content->GetStringAttribute( EMimeType, ptr );
+        if ( error != KErrNone )
+            {
+            User::Leave( KErrArgument );
+            }
+        CleanupStack::Pop( mimeType );
+        CleanupStack::PopAndDestroy( content );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+    CleanupStack::PopAndDestroy( &fileHandle );
+    return mimeType;
+    }
+
+EXPORT_C TInt CDRMHelper::GetContentURIList(
+    RPointerArray<HBufC8>*& aURIList)
+    {
+    return iDRMCommon->GetContentURIList( aURIList );
+    }
+
+EXPORT_C TInt CDRMHelper::DataTypesCount(
+    TInt& aCount)
+    {
+    return iDRMCommon->DataTypesCount( aCount );
+    }
+
+EXPORT_C TInt CDRMHelper::SupportedDataType(
+    const TInt aIndex, TDataType& aDataType)
+    {
+    return iDRMCommon->SupportedDataType( aIndex, aDataType );
+    }
+
+EXPORT_C TInt CDRMHelper::RegisterDataType(
+    const TDataType& aDataType)
+    {
+    return iDRMCommon->RegisterDataType( aDataType );
+    }
+
+EXPORT_C TInt CDRMHelper::UnRegisterDataType(
+    const TInt aIndex )
+    {
+    return iDRMCommon->UnRegisterDataType( aIndex );
+    }
+
+EXPORT_C TInt CDRMHelper::SupportedDRMMethods2(
+    TInt& aDRMMethod, TDRMHelperOMALevel& aOMALevel)
+    {
+#ifndef __DRM_FULL
+    aDRMMethod = CDRMHelper::EForwardLock;
+#else
+    aDRMMethod =
+        CDRMHelper::EForwardLock |
+        CDRMHelper::ECombinedDelivery |
+        CDRMHelper::ESeparateDelivery |
+        CDRMHelper::ESuperDistribution;
+#ifdef __DRM_OMA2
+    aOMALevel = EOMA_2_0;
+#else
+    aOmaLevel = EOMA_1_0;
+#endif // __DRM_OMA2
+
+#endif // __DRM_FULL
+    return KErrNone;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::HandleServerAppExit
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::HandleServerAppExit( TInt aReason )
+    {
+    if ( aReason == EAknCmdExit && !iSchemeHandler )
+        {
+        CAknEnv::RunAppShutter();
+        }
+
+    if ( iSchemeHandler )
+        {
+        delete iSchemeHandler;
+        iSchemeHandler = NULL;
+        }
+
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::PrepareSecondaryDisplayL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::PrepareSecondaryDisplayL( CEikDialog& aDialog , TInt aResourceId,
+    const TDesC& aString, TInt aValue )
+    {
+
+    // Check if we have cover display and shall we display something
+    if ( !FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ||
+        !CDRMHelperInfoNoteWrapper::EvaluateCoverResourceId( aResourceId ) )
+        {
+        return;
+        }
+
+    RProcess myProcess;
+    TUid myProcessUid( KNullUid );
+
+    RThread().Process( myProcess );
+    myProcessUid = myProcess.Identity();
+
+    aDialog.PublishDialogL( aResourceId, KUidCoverUiCategoryDRMHelper );
+
+    // fetch akn utility for mediator support
+    CAknMediatorFacade* covercl = AknMediatorFacade( &aDialog );
+
+    if ( covercl ) // returns null if cover display is not available
+        {
+        // Package dialog data <oem/SecondaryDisplay/DRMHelperSecondaryDisplay.h>
+        THelperSDData helperData;
+
+        helperData.iHelperUid = KUidCoverUiCategoryDRMHelper;        // First field is DRMHelper's Uid
+        helperData.iHandlerProcessId = myProcessUid; // ProcessId which uses DRMHelper
+        helperData.iCreatorProcessId = User::CreatorSecureId();
+
+        if ( aString.Compare( KNullDesC ) )
+            {
+            // If there is filename given, it's always in the PrimaryString
+            helperData.iStringParam.Append( aString );
+            }
+        if ( aValue >= 0 )
+            {
+            // If there is no other than numeric data, put it as NumericString
+            helperData.iNumParam.AppendNum( aValue );
+            }
+        THelperSDDataPckg pckg( helperData );
+
+        covercl->BufStream() << pckg;   // Write the package data
+        covercl->BufStream().CommitL(); // no more data to send so commit buf
+        }
+    return;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMHelper::CancelSecondaryDisplayL
+// -----------------------------------------------------------------------------
+//
+void CDRMHelper::CancelSecondaryDisplayL( TInt aResourceId )
+    {
+
+    // Check if we have cover display and shall we display something
+    if ( !FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) ||
+        !CDRMHelperInfoNoteWrapper::EvaluateCoverResourceId( aResourceId ) )
+        {
+        return;
+        }
+
+    RProcess myProcess;
+    TUid myProcessUid( KNullUid );
+
+    RThread().Process( myProcess );
+    myProcessUid = myProcess.Identity();
+
+    THelperSDDataCancel cancelData;
+    cancelData.iHandlerProcessId = myProcessUid;
+    cancelData.iCreatorProcessId = User::CreatorSecureId();
+    cancelData.iNoteId = aResourceId;
+
+    TPckgBuf<THelperSDDataCancel> cancel( cancelData );
+
+    HBufC8* buf = HBufC8::NewLC(sizeof(THelperSDDataCancel) + sizeof(TInt));
+    TPtr8 ptr = buf->Des();
+
+    RDesWriteStream stream(ptr);
+    stream << cancel;
+    stream.CommitL();
+
+    iEventProvider->RaiseEvent( KMediatorSecondaryDisplayDomain,
+        KUidCoverUiCategoryDRMHelper,
+        ECover_dialog_cancel,
+        TVersion( 0, 0, 0 ),
+        *buf );
+
+    stream.Close();
+    CleanupStack::PopAndDestroy( buf );
+    }
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/BWINSCW/DRMLICENSECHECKERU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	??1CDRMLicenseChecker@@UAE@XZ @ 1 NONAME ; CDRMLicenseChecker::~CDRMLicenseChecker(void)
+	?CheckLicense@CDRMLicenseChecker@@QAEHABVTDesC16@@AAPAVHBufC8@@@Z @ 2 NONAME ; int CDRMLicenseChecker::CheckLicense(class TDesC16 const &, class HBufC8 * &)
+	?NewL@CDRMLicenseChecker@@SAPAV1@XZ @ 3 NONAME ; class CDRMLicenseChecker * CDRMLicenseChecker::NewL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/BWINSCW/DRMLICENSEMANAGERU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,9 @@
+EXPORTS
+	??1CDRMLicenseManager@@UAE@XZ @ 1 NONAME ; CDRMLicenseManager::~CDRMLicenseManager(void)
+	?ExtractSISFileL@CDRMLicenseManager@@QAEHAAVRFile@@ABVTDesC16@@@Z @ 2 NONAME ; int CDRMLicenseManager::ExtractSISFileL(class RFile &, class TDesC16 const &)
+	?ExtractSISFileL@CDRMLicenseManager@@QAEHABVTDesC16@@0@Z @ 3 NONAME ; int CDRMLicenseManager::ExtractSISFileL(class TDesC16 const &, class TDesC16 const &)
+	?GetSISMemberL@CDRMLicenseManager@@QAEPAVCZipFileMember@@XZ @ 4 NONAME ; class CZipFileMember * CDRMLicenseManager::GetSISMemberL(void)
+	?NewL@CDRMLicenseManager@@SAPAV1@XZ @ 5 NONAME ; class CDRMLicenseManager * CDRMLicenseManager::NewL(void)
+	?ProcessL@CDRMLicenseManager@@QAEHAAVRFile@@ABVTDesC16@@@Z @ 6 NONAME ; int CDRMLicenseManager::ProcessL(class RFile &, class TDesC16 const &)
+	?ProcessL@CDRMLicenseManager@@QAEHABVTDesC16@@0@Z @ 7 NONAME ; int CDRMLicenseManager::ProcessL(class TDesC16 const &, class TDesC16 const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/eabi/DRMLicenseCheckerU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,9 @@
+EXPORTS
+	_ZN18CDRMLicenseChecker12CheckLicenseERK7TDesC16RP6HBufC8 @ 1 NONAME
+	_ZN18CDRMLicenseChecker4NewLEv @ 2 NONAME
+	_ZN18CDRMLicenseCheckerD0Ev @ 3 NONAME
+	_ZN18CDRMLicenseCheckerD1Ev @ 4 NONAME
+	_ZN18CDRMLicenseCheckerD2Ev @ 5 NONAME
+	_ZTI18CDRMLicenseChecker @ 6 NONAME ; #<TI>#
+	_ZTV18CDRMLicenseChecker @ 7 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/eabi/DRMLicenseManagerU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,13 @@
+EXPORTS
+	_ZN18CDRMLicenseManager13GetSISMemberLEv @ 1 NONAME
+	_ZN18CDRMLicenseManager15ExtractSISFileLER5RFileRK7TDesC16 @ 2 NONAME
+	_ZN18CDRMLicenseManager15ExtractSISFileLERK7TDesC16S2_ @ 3 NONAME
+	_ZN18CDRMLicenseManager4NewLEv @ 4 NONAME
+	_ZN18CDRMLicenseManager8ProcessLER5RFileRK7TDesC16 @ 5 NONAME
+	_ZN18CDRMLicenseManager8ProcessLERK7TDesC16S2_ @ 6 NONAME
+	_ZN18CDRMLicenseManagerD0Ev @ 7 NONAME
+	_ZN18CDRMLicenseManagerD1Ev @ 8 NONAME
+	_ZN18CDRMLicenseManagerD2Ev @ 9 NONAME
+	_ZTI18CDRMLicenseManager @ 10 NONAME ; #<TI>#
+	_ZTV18CDRMLicenseManager @ 11 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/group/DRMLicenseChecker.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,58 @@
+/*
+* Copyright (c) 2003-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:  Makefile of DRM License Checker
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DRMLicenseChecker.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x101F6DC6
+VENDORID        VID_DEFAULT
+CAPABILITY      CAP_GENERAL_DLL DRM
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc
+
+USERINCLUDE     ../inc
+USERINCLUDE	    ../../../inc   // ADo level inc dir
+
+SOURCEPATH      ../src
+SOURCE          DRMLicenseChecker.cpp
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         caf.lib
+LIBRARY         cafutils.lib
+
+LIBRARY         DrmParsers.lib
+LIBRARY         DrmDcf.lib
+LIBRARY         DrmRights.lib
+LIBRARY         DrmServerInterfaces.lib
+LIBRARY         DRMCommon.lib
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/group/DRMLicenseManager.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,62 @@
+/*
+* Copyright (c) 2003-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:  Makefile of DRM License Manager
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DRMLicenseManager.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x101F6DC7
+VENDORID        VID_DEFAULT
+CAPABILITY      CAP_GENERAL_DLL DRM
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+SOURCEPATH      ../src
+SOURCE          DRMLicenseManager.cpp
+
+LIBRARY         ezlib.lib
+LIBRARY         ezip.lib
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         estor.lib
+LIBRARY         charconv.lib
+
+LIBRARY         DrmParsers.lib
+LIBRARY         DrmDcf.lib
+LIBRARY         DrmRights.lib
+LIBRARY         DrmServerInterfaces.lib
+LIBRARY         DRMCommon.lib
+LIBRARY         sysutil.lib // SysUtil
+
+
+#if defined(ARMCC)
+deffile ../eabi/
+#elif defined( WINSCW )
+deffile ../bwinscw/
+#elif defined( WINS )
+deffile ../bwins/
+#else
+deffile ../bmarm/
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,33 @@
+/*
+* 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:  Build file for DRM License Manager
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+
+DRMLicenseManager.mmp
+DRMLicenseChecker.mmp
+
+PRJ_TESTMMPFILES
+
+DRM_LM_BAT.mmp
+../internal/tsrc/HelloWorldBasic/group/HelloWorldBasic.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/group/drm_lm_bat.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) 2003-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:  Makefile of DRM License Manager BAT Test
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          DRM_LM_BAT.exe
+TARGETTYPE      EXE
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/libc
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc   // ADo level inc dir
+
+SOURCEPATH      ../internal/tsrc
+SOURCE          DRM_LM_BAT.cpp
+SOURCE          RTest.cpp
+
+LIBRARY         euser.lib bafl.lib caf.lib cafutils.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/src/DRMLicenseChecker.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h>
+#include <s32file.h>
+#include "DRMCommon.h"
+#include "DRMLicenseChecker.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseChecker::CDRMLicenseChecker
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMLicenseChecker::CDRMLicenseChecker()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseChecker::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMLicenseChecker::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseChecker::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMLicenseChecker* CDRMLicenseChecker::NewL()
+    {
+    CDRMLicenseChecker* self = new( ELeave ) CDRMLicenseChecker;
+    
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+    
+// Destructor
+EXPORT_C CDRMLicenseChecker::~CDRMLicenseChecker()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseChecker::CheckLicenseL
+// Open the data file and encrypt it.
+// -----------------------------------------------------------------------------
+//
+void CDRMLicenseChecker::CheckLicenseL(
+    const TDesC& aDataFile,
+    HBufC8*& aDataBuffer)
+    {
+    CData* data = NULL;
+    TInt size;
+    TPtr8 ptr(0, 0);
+    TVirtualPathPtr name(aDataFile, KDefaultContentObject);
+    
+    data = CData::NewLC(name, EView, EContentShareReadOnly);
+    data->DataSizeL(size);
+    aDataBuffer = HBufC8::NewMax(size);
+    User::LeaveIfNull(aDataBuffer);
+    ptr.Set(aDataBuffer->Des());
+    User::LeaveIfError(data->Read(ptr));
+    data->ExecuteIntent(EView);
+    CleanupStack::PopAndDestroy(); // data
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseChecker::CheckLicense
+// Open the data file and encrypt it.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMLicenseChecker::CheckLicense(
+    const TDesC& aDataFile,
+    HBufC8*& aDataBuffer)
+    {
+    TRAPD(r, CheckLicenseL(aDataFile, aDataBuffer));
+    return r;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/src/DRMLicenseManager.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,814 @@
+/*
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the license manager functionality used in the
+*                install process
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32base.h>
+#include <apmstd.h>
+#include <e32math.h>
+#include <f32file.h>
+#include <s32buf.h>
+#include <s32crypt.h>
+#include <utf.h>
+#include <DrmRights.h>
+#include <DrmCommon.h>
+#include <Oma1DcfCreator.h>
+#include <SysUtil.h>     // Disk space checking
+
+#include "ZipFile.h"
+#include "ZipFileMemberIterator.h"
+#include "DRMLicenseManager.h"
+
+// LOCAL CONSTANTS AND MACROS
+_LIT(KDefinitionFileName, "datafiles.def");
+_LIT(KSISSuffix, ".sis");
+_LIT(KSISXSuffix, ".sisx");
+_LIT8(KDefaultMIMEType, "application/binary");
+_LIT8( KIssuer , "Rights-Issuer" );
+
+const TInt KSISBufferSize = 512;
+const TInt KMaxTypeLength = 11 + 2; // Length of "application" + CR + LF
+const TInt KMaxFileDescriptionLength = KMaxPath + KMaxPath + KMaxDataTypeLength;
+
+
+// ============================ LOCAL FUNCTIONS ================================
+// -----------------------------------------------------------------------------
+// DriveOfPathL
+// -----------------------------------------------------------------------------
+LOCAL_C inline TInt DriveOfPathL(
+    RFs& aFs,
+    const TDesC aPathName,
+    TInt aFallbackDrive = KDefaultDrive )
+    {
+    // find drive for destination for free space check
+    TInt driveNumber( KDefaultDrive );
+    TParsePtrC pptr( aPathName );
+    TInt err( KErrNone );
+    if ( pptr.DrivePresent() )
+        {
+        err = RFs::CharToDrive( pptr.Drive()[ 0 ], driveNumber );
+        User::LeaveIfError( err );
+        }
+    else if ( aFallbackDrive != KDefaultDrive )
+        {
+        driveNumber = aFallbackDrive;
+        }
+    else
+        {
+        HBufC* sessionPath( HBufC::NewLC( KMaxPath ) );
+        TPtr pathPtr( sessionPath->Des() );
+        User::LeaveIfError( aFs.SessionPath( pathPtr ) );
+
+        TParsePtrC sPPtr( pathPtr );
+        if ( sPPtr.DrivePresent() )
+            {
+            err = RFs::CharToDrive( sPPtr.Drive()[ 0 ], driveNumber );
+            User::LeaveIfError( err );
+            }
+        else
+            {
+            driveNumber = RFs::GetSystemDrive();
+            }
+        CleanupStack::PopAndDestroy( sessionPath );
+        }
+    return driveNumber;
+    }
+
+// -----------------------------------------------------------------------------
+// CheckNeededFreeSpaceL
+// -----------------------------------------------------------------------------
+LOCAL_C void CheckNeededFreeSpaceL(
+    RFs& aFs,
+    CZipFile*& aZipFile,
+    RPointerArray< TDRMDataFile >& aDataFiles,
+    const TDesC& aDestination,
+    TInt& aError )
+    {
+    static const TInt KExtraSpaceForDcf( 1024 );
+    CArrayFixFlat< TInt >* arrayOfNeededSpaces( NULL );
+    // Get target drive for relative files
+    TInt driveForRelativePath( DriveOfPathL( aFs, aDestination ) );
+
+    arrayOfNeededSpaces = new ( ELeave ) CArrayFixFlat< TInt >( KMaxDrives );
+    CleanupStack::PushL(  arrayOfNeededSpaces );
+
+    arrayOfNeededSpaces->SetReserveL( KMaxDrives );
+    for ( TInt j( 0 ); j < KMaxDrives; ++j )
+        {
+        arrayOfNeededSpaces->AppendL(0);
+        }
+
+    for ( TInt i = 0; i < aDataFiles.Count() && aError == KErrNone; i++ )
+        {
+        TDRMDataFile* dataFile(
+            static_cast< TDRMDataFile* >( aDataFiles[ i ] ) );
+        CZipFileMember* member(
+            aZipFile->CaseInsensitiveMemberL( dataFile->iSourceName ) );
+        if ( member )
+            {
+            CleanupStack::PushL( member );
+            TInt driveNumber( DriveOfPathL(
+                    aFs, dataFile->iTargetName, driveForRelativePath ) );
+            ( *arrayOfNeededSpaces )[ driveNumber ] +=
+                member->UncompressedSize() + KExtraSpaceForDcf;
+            CleanupStack::PopAndDestroy( member );
+            }
+        else
+            {
+            aError = CDRMLicenseManager::EPIPInvalid;
+            }
+        }
+
+    for ( TInt j( 0 ); j < KMaxDrives; ++j )
+        {
+        TUint element( ( *arrayOfNeededSpaces )[ j ] );
+        if ( element && // no need to check if no space required
+            SysUtil::DiskSpaceBelowCriticalLevelL( &aFs, element, j) )
+            {
+            User::Leave( KErrDiskFull );
+            }
+        }
+    CleanupStack::PopAndDestroy( arrayOfNeededSpaces );
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::CDRMLicenseManager
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CDRMLicenseManager::CDRMLicenseManager():
+    iFs(NULL), iRights(NULL), iRightsIssuer(NULL)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CDRMLicenseManager::ConstructL()
+    {
+    iFs = new RFs();
+    User::LeaveIfNull(iFs);
+    User::LeaveIfError(iFs->Connect());
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CDRMLicenseManager* CDRMLicenseManager::NewL()
+    {
+    CDRMLicenseManager* self = new( ELeave ) CDRMLicenseManager;
+
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+
+// Destructor
+EXPORT_C CDRMLicenseManager::~CDRMLicenseManager()
+    {
+    iFs->Close();
+    delete iFs;
+
+    iDataFiles.ResetAndDestroy();
+
+    if (iZipFile)
+        {
+        iZipFile->Close();
+        delete iZipFile;
+        }
+
+    if (iRights)
+        {
+        delete iRights;
+        }
+
+    if (iRightsIssuer)
+        {
+        delete iRightsIssuer;
+        }
+    }
+
+LOCAL_C TBool GetRightsIssuerL(const TFileName aFileName, HBufC8*& aRightsIssuerURL)
+    {
+    TInt err(KErrNotFound);
+
+    HBufC8* name = HBufC8::NewLC(16);
+    TPtr8 headerName( name->Des() );
+    headerName.Copy( KIssuer );
+
+    DRMCommon* c = DRMCommon::NewL();
+    CleanupStack::PushL(c);
+    err = c->GetFileHeader(aFileName, headerName, aRightsIssuerURL);
+    CleanupStack::PopAndDestroy(c);
+    CleanupStack::PopAndDestroy(name);
+
+    if(err == DRMCommon::EOk && aRightsIssuerURL)
+        {
+        return ETrue;
+        }
+
+    return EFalse;
+    }
+
+LOCAL_C TBool GetRightsIssuerL(RFile aFileName, HBufC8*& aRightsIssuerURL)
+    {
+    TInt err(KErrNotFound);
+
+    HBufC8* name = HBufC8::NewLC(16);
+    TPtr8 headerName( name->Des() );
+    headerName.Copy( KIssuer );
+
+    DRMCommon* c = DRMCommon::NewL();
+    CleanupStack::PushL(c);
+    err = c->GetFileHeader(aFileName, headerName, aRightsIssuerURL);
+    CleanupStack::PopAndDestroy(c);
+    CleanupStack::PopAndDestroy(name);
+
+    if(err == DRMCommon::EOk && aRightsIssuerURL)
+        {
+        return ETrue;
+        }
+
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::ProcessL
+// Read the PIP definition file and encrypt each referenced data file
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMLicenseManager::ProcessL(
+    const TDesC& aZIPFile,
+    const TDesC& aDestination)
+    {
+    TInt r = KErrNone;
+    DRMCommon* drm = NULL;
+    RPointerArray<CDRMRights>* rights = NULL;
+
+    // Clean up
+    if (iZipFile)
+        {
+        iZipFile->Close();
+        delete iZipFile;
+        iZipFile = NULL;
+        }
+
+    if (iRights)
+        {
+        delete iRights;
+        iRights = NULL;
+        }
+
+    if (iRightsIssuer)
+        {
+        delete iRightsIssuer;
+        iRightsIssuer = NULL;
+        }
+
+    GetRightsIssuerL(aZIPFile, iRightsIssuer);
+
+    iDataFiles.ResetAndDestroy();
+
+    // Get rights object for the PIP file
+    iZipFile = CZipFile::NewL(*iFs, aZIPFile);
+    drm = DRMCommon::NewL();
+    CleanupStack::PushL(drm);
+    r = drm->GetDetailedFileRights(aZIPFile, rights);
+
+    // Read the definition file
+    if (r == KErrNone)
+        {
+        iRights = (*rights)[0];
+        rights->Remove(0);
+        rights->ResetAndDestroy();
+        delete rights;
+        r = ReadDefinitionFileL();
+        }
+
+    // Process data files
+    if (r == KErrNone)
+        {
+        r = ProcessDataFilesL(aDestination);
+        }
+
+    CleanupStack::PopAndDestroy(drm);
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::ProcessL
+// Read the PIP definition file and encrypt each referenced data file
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMLicenseManager::ProcessL(
+    RFile& aZIPFile,
+    const TDesC& aDestination)
+    {
+    TInt r = KErrNone;
+    DRMCommon* drm = NULL;
+    RPointerArray<CDRMRights>* rights = NULL;
+
+    // Clean up
+    if (iZipFile)
+        {
+        iZipFile->Close();
+        delete iZipFile;
+        iZipFile = NULL;
+        }
+
+    if (iRights)
+        {
+        delete iRights;
+        iRights = NULL;
+        }
+
+    if (iRightsIssuer)
+        {
+        delete iRightsIssuer;
+        iRightsIssuer = NULL;
+        }
+
+    GetRightsIssuerL(aZIPFile, iRightsIssuer);
+
+    iDataFiles.ResetAndDestroy();
+
+    // Get rights object for the PIP file
+    iZipFile = CZipFile::NewL(*iFs, aZIPFile);
+    drm = DRMCommon::NewL();
+    CleanupStack::PushL(drm);
+    r = drm->GetDetailedFileRights(aZIPFile, rights);
+
+    // Read the definition file
+    if (r == KErrNone)
+        {
+        iRights = (*rights)[0];
+        rights->Remove(0);
+        rights->ResetAndDestroy();
+        delete rights;
+        r = ReadDefinitionFileL();
+        }
+
+    // Process data files
+    if (r == KErrNone)
+        {
+        r = ProcessDataFilesL(aDestination);
+        }
+
+    CleanupStack::PopAndDestroy(drm);
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::ExtractSISFileL
+// Find the SIS member of the ZIP file and write it to the target destination.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMLicenseManager::ExtractSISFileL(
+    const TDesC& aZIPFile,
+    const TDesC& aDestination)
+    {
+    CZipFileMember* sisFile = NULL;
+    TInt r = KErrNone;
+
+    if (iZipFile)
+        {
+        iZipFile->Close();
+        delete iZipFile;
+        iZipFile = NULL;
+        }
+
+    if (iRightsIssuer)
+        {
+        delete iRightsIssuer;
+        iRightsIssuer = NULL;
+        }
+
+    GetRightsIssuerL(aZIPFile, iRightsIssuer);
+
+    iZipFile = CZipFile::NewL(*iFs, aZIPFile);
+
+    __UHEAP_MARK;
+    sisFile = GetSISMemberL();
+
+    if (sisFile)
+        {
+        WriteSISMemberL(sisFile, aDestination);
+        delete sisFile;
+        }
+    else
+        {
+        r = ESISNotFound;
+        }
+    __UHEAP_MARKEND;
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::ExtractSISFileL
+// Find the SIS member of the ZIP file and write it to the target destination.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TInt CDRMLicenseManager::ExtractSISFileL(
+    RFile& aZIPFile,
+    const TDesC& aDestination)
+    {
+    CZipFileMember* sisFile = NULL;
+    TInt r = KErrNone;
+
+    if (iZipFile)
+        {
+        iZipFile->Close();
+        delete iZipFile;
+        iZipFile = NULL;
+        }
+
+    if (iRightsIssuer)
+        {
+        delete iRightsIssuer;
+        iRightsIssuer = NULL;
+        }
+
+    GetRightsIssuerL(aZIPFile, iRightsIssuer);
+
+    iZipFile = CZipFile::NewL(*iFs, aZIPFile);
+
+    __UHEAP_MARK;
+    sisFile = GetSISMemberL();
+
+    if (sisFile)
+        {
+        WriteSISMemberL(sisFile, aDestination);
+        delete sisFile;
+        }
+    else
+        {
+        r = ESISNotFound;
+        }
+    __UHEAP_MARKEND;
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::GetSISMemberL
+// Finds the SIS member in the ZIP file by looking for the .sis file ending.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CZipFileMember* CDRMLicenseManager::GetSISMemberL(void)
+    {
+    CZipFileMemberIterator* members = NULL;
+    CZipFileMember* sisFile = NULL;
+    CZipFileMember* member = NULL;
+
+    members = iZipFile->GetMembersL();
+    CleanupStack::PushL(members);
+    
+    member = members->NextL();
+    
+    while (member && !sisFile)
+        {
+        if (member->Name()->Right(4).CompareF(KSISSuffix) == 0)
+            {
+            sisFile = member;
+            }
+        else if (member->Name()->Right(5).CompareF(KSISXSuffix) == 0)
+            {
+            sisFile = member;
+            }
+        else
+            {
+            delete member;
+            member = NULL;
+            member = members->NextL();
+            }
+        }
+    
+    CleanupStack::PopAndDestroy(members);
+
+    if(!sisFile)
+        {
+        User::Leave(KErrNotFound);
+        }
+    
+    return sisFile;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::WriteSISMemberL
+// Write a SIS member to disk.
+// -----------------------------------------------------------------------------
+//
+void CDRMLicenseManager::WriteSISMemberL(
+    CZipFileMember* aSisMember,
+    const TDesC& aDestination)
+    {
+    RZipFileMemberReaderStream* input = NULL;
+    RFileWriteStream output;
+    TBuf8<KSISBufferSize> buffer;
+
+    // Check free space and leave if not enough space available
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL(
+            iFs,
+            aSisMember->UncompressedSize(),
+            DriveOfPathL( *iFs, aDestination ) ) )
+        {
+        User::Leave( KErrDiskFull );
+        }
+
+    iZipFile->GetInputStreamL(aSisMember, input);
+    CleanupStack::PushL(input);
+
+    iFs->SetSessionPath(aDestination);
+    User::LeaveIfError(output.Replace(*iFs, *aSisMember->Name(), EFileWrite));
+    output.PushL();
+    do
+        {
+        input->Read(buffer, KSISBufferSize);
+        if (buffer.Size() > 0)
+            {
+            output.WriteL(buffer);
+            }
+        }
+    while (buffer.Size() > 0);
+    output.Close();
+
+    CleanupStack::PopAndDestroy(&output);
+    CleanupStack::PopAndDestroy(input);
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::ReadDefinitionFileL
+// Read the PIP type and definition lines from the definition file.
+// -----------------------------------------------------------------------------
+//
+TInt CDRMLicenseManager::ReadDefinitionFileL(void)
+    {
+    CZipFileMember* definitionFile = NULL;
+    RZipFileMemberReaderStream* input = NULL;
+    TBuf8<KMaxTypeLength> type;
+    TInt r = KErrNone;
+
+    TRAP(r, definitionFile =
+        iZipFile->CaseInsensitiveMemberL(KDefinitionFileName));
+
+    if (r == KErrNone && definitionFile)
+        {
+        CleanupStack::PushL(definitionFile);
+        iZipFile->GetInputStreamL(definitionFile, input);
+        ReadLine(input, type);
+        while (r == KErrNone)
+            {
+            r = ReadFileDescription(input);
+            }
+        delete input;
+        CleanupStack::PopAndDestroy(definitionFile);
+        }
+    else
+        {
+        r = EPIPInvalid;
+        }
+
+    if (r == KErrEof)
+        {
+        r = KErrNone;
+        }
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::ReadFileDescription
+// Read the name, type and target name of a data file.
+// -----------------------------------------------------------------------------
+//
+TInt CDRMLicenseManager::ReadFileDescription(
+    RZipFileMemberReaderStream* aStream)
+    {
+    TBuf8<KMaxFileDescriptionLength> description;
+    TInt r = KErrNone;
+    TDRMDataFile* dataFile = NULL;
+
+    ReadLine(aStream, description);
+    description.TrimAll();
+    if (description.Length() > 0)
+        {
+        TLex8 lex(description);
+
+        dataFile = new TDRMDataFile();
+        if( !dataFile )
+            {
+            return KErrNoMemory;
+            }
+
+        // Get the original file name
+        lex.SkipSpaceAndMark();
+        lex.SkipCharacters();
+        CnvUtfConverter::ConvertToUnicodeFromUtf8(
+            dataFile->iSourceName, lex.MarkedToken());
+
+        // Get the MIME type. If not present, "application/binary" is used
+        // and the target file name is the source file name
+        lex.SkipSpaceAndMark();
+        lex.SkipCharacters();
+        if (lex.TokenLength() > 0)
+            {
+            dataFile->iMimeType = lex.MarkedToken();
+
+            // Get the target file name. If not present, the target file name
+            // will be the original file name, stored in the install directory.
+            lex.SkipSpaceAndMark();
+            lex.SkipCharacters();
+            if (lex.TokenLength() > 0)
+                {
+                CnvUtfConverter::ConvertToUnicodeFromUtf8(
+                    dataFile->iTargetName, lex.MarkedToken());
+                }
+            else
+                {
+                dataFile->iTargetName = dataFile->iSourceName;
+                }
+            }
+        else
+            {
+            dataFile->iMimeType = KDefaultMIMEType;
+            dataFile->iTargetName = dataFile->iSourceName;
+            }
+
+        iDataFiles.Append(dataFile);
+        }
+    else
+        {
+        r = KErrEof;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::ReadLine
+// Read one line ending with 0x0d or until the input buffer is full.
+// -----------------------------------------------------------------------------
+//
+void CDRMLicenseManager::ReadLine(
+    RZipFileMemberReaderStream* aStream,
+    TDes8& aLine)
+    {
+    TBuf8<1> c;
+    TInt n = 0;
+    TBool done = EFalse;
+
+    while (!done)
+        {
+        if (aLine.Length() < aLine.MaxLength())
+            {
+            aStream->Read(c, 1);
+            if (c.Length() > 0 && c[0] != 0x0d)
+                {
+                aLine.Append(c);
+                n++;
+                if (n == aLine.MaxLength() + 1)
+                    {
+                    done = ETrue;
+                    }
+                }
+            else
+                {
+                done = ETrue;
+                }
+            }
+        else
+            {
+            done = ETrue;
+            }
+        }
+
+    if (c.Length() > 0 && c[0] == 0x0d)
+        {
+        aStream->Read(c, 1);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::ProcessDataFilesL
+// Get all data files from the ZIP file and encrypt them.
+// -----------------------------------------------------------------------------
+//
+TInt CDRMLicenseManager::ProcessDataFilesL(
+    const TDesC& aDestination)
+    {
+    TDRMDataFile* dataFile( NULL );
+    CZipFileMember* member( NULL );
+    TInt r( KErrNone );
+
+    // check if there is enough free space for the process
+    CheckNeededFreeSpaceL( *iFs, iZipFile, iDataFiles, aDestination, r );
+
+    for ( TInt i = 0; i < iDataFiles.Count() && r == KErrNone; i++ )
+        {
+        dataFile = static_cast< TDRMDataFile* >( iDataFiles[ i ] );
+        member = iZipFile->CaseInsensitiveMemberL( dataFile->iSourceName );
+        if ( member )
+            {
+            CleanupStack::PushL(member);
+            EncryptDataFileL(dataFile, aDestination, member);
+            CleanupStack::PopAndDestroy(member);
+            }
+        else
+            {
+            r = EPIPInvalid;
+            }
+        }
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CDRMLicenseManager::EncryptDataFileL
+// Encrypt a single data file, reusing the outer PIP's RO. For application
+// protection, the file is encrypted again.
+// -----------------------------------------------------------------------------
+//
+void CDRMLicenseManager::EncryptDataFileL(
+    TDRMDataFile* aDataFile,
+    const TDesC& aDestination,
+    CZipFileMember* aZipMember)
+    {
+    RZipFileMemberReaderStream* input = NULL;
+    RFileWriteStream output;
+    TBuf8<KSISBufferSize> buffer;
+    COma1DcfCreator* drm = NULL;
+    TFileName outputFile;
+    DRMCommon* common = NULL;
+
+    drm = COma1DcfCreator::NewL();
+    CleanupStack::PushL(drm);
+
+    iZipFile->GetInputStreamL(aZipMember, input);
+    CleanupStack::PushL(input);
+
+    // Set the path so we can use relative paths
+    iFs->SetSessionPath(aDestination);
+
+    output.PushL();
+    // Create the output file stream
+    User::LeaveIfError(output.Replace(*iFs, aDataFile->iTargetName,
+        EFileWrite));
+
+    // Encrypt
+    drm->EncryptInitializeL(output, aDataFile->iMimeType, iRights);
+    do
+        {
+        input->Read(buffer, KSISBufferSize);
+        if (buffer.Size() > 0)
+            {
+            drm->EncryptUpdateL(buffer);
+            }
+        }
+    while (buffer.Size() > 0);
+    drm->EncryptFinalizeL();
+    output.Close();
+    CleanupStack::PopAndDestroy( &output );
+
+    // Add the rights issuer uri to the file if it exists
+    if( iRightsIssuer )
+        {
+        common = DRMCommon::NewL();
+        CleanupStack::PushL(common);
+        outputFile.Append( aDataFile->iTargetName );
+        common->SetFileHeader( outputFile, KIssuer,
+                               iRightsIssuer->Des());
+        CleanupStack::PopAndDestroy(common);
+        }
+    CleanupStack::PopAndDestroy(input);
+    CleanupStack::PopAndDestroy(drm);
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/src/LMSecurity.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,104 @@
+/*
+* 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:  Encryption/Decryption support functions
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32base.h>
+#include <e32math.h>
+#include <s32buf.h>
+#include <s32crypt.h>
+
+#include "LMSecurity.h"
+#include "LMSecurityEncrypt.h"
+#include "LMSecurityDecrypt.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CLMSecurity::NewEncryptL
+// Return a new encryptor
+// -----------------------------------------------------------------------------
+//
+CSecurityEncryptBase* CLMSecurity::NewEncryptL(
+    const TDesC8& init) const
+    {
+    return new CLMSecurityEncrypt(init);
+    };
+
+// -----------------------------------------------------------------------------
+// CLMSecurity::NewDecryptL
+// Return a new decryptor
+// -----------------------------------------------------------------------------
+//
+CSecurityDecryptBase* CLMSecurity::NewDecryptL(
+    const TDesC8& init) const
+    {
+    return new CLMSecurityDecrypt(init);
+    };
+
+// -----------------------------------------------------------------------------
+// CLMSecurity::SetL
+// Password functions not supported (handled via the encrypt/decrypt classes)
+// -----------------------------------------------------------------------------
+//
+void CLMSecurity::SetL(
+    const TDesC& /* aOldPassword */,
+    const TDesC& /* aNewPassword */)
+    {
+    };
+
+// -----------------------------------------------------------------------------
+// CLMSecurity::SecurityData
+// Password functions not supported (handled via the encrypt/decrypt classes)
+// -----------------------------------------------------------------------------
+//
+TPtrC8 CLMSecurity::SecurityData() const
+    {
+    return TPtrC8(0, 0);
+    };
+
+// -----------------------------------------------------------------------------
+// CLMSecurity::PrepareL
+// Password functions not supported (handled via the encrypt/decrypt classes)
+// -----------------------------------------------------------------------------
+//
+void CLMSecurity::PrepareL(
+    const TDesC& /* aPassword */)
+    {
+    };
+
+// -----------------------------------------------------------------------------
+// CLMSecurity::IsEnabled
+// Password functions not supported (handled via the encrypt/decrypt classes)
+// -----------------------------------------------------------------------------
+//
+TInt CLMSecurity::IsEnabled() const
+    {
+    return ETrue;
+    };
+
+// -----------------------------------------------------------------------------
+// CLMSecurity::SetEnabledL
+// Password functions not supported (handled via the encrypt/decrypt classes)
+// -----------------------------------------------------------------------------
+//
+void CLMSecurity::SetEnabledL(
+    const TDesC& /* aPassword */,
+    TBool /* aIsEnabled */)
+    {
+    };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/src/LMSecurityDecrypt.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,65 @@
+/*
+* 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:  Encryption/Decryption support functions
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32base.h>
+#include <e32math.h>
+#include <s32buf.h>
+#include <s32crypt.h>
+
+#include "LMSecurity.h"
+#include "LMSecurityDecrypt.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?classname::?member_function
+// ?implementation_description
+// -----------------------------------------------------------------------------
+//
+CLMSecurityDecrypt::CLMSecurityDecrypt(
+    const TDesC8& init)
+    {
+    TPckg<TUint> p(0);
+
+    p.Copy(init);
+    iKey = p();
+    Math::Rand(iKey);
+    }
+
+// -----------------------------------------------------------------------------
+// ?classname::?member_function
+// ?implementation_description
+// -----------------------------------------------------------------------------
+//
+TInt CLMSecurityDecrypt::DecryptL(
+    TDes8& aOutput,
+    const TDesC8& aInput)
+    {
+    TInt i;
+    TUint8* ptr;
+
+    ptr = const_cast<TUint8*>(aOutput.Ptr());
+    for (i = 0; i < aInput.Size(); i++)
+        {
+        ptr[i] = static_cast<TUint8>(aInput[i] ^ Math::Rand(iKey));
+        }
+    aOutput.SetLength(aInput.Size());
+    return aInput.Size();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmlicensemanager/src/LMSecurityEncrypt.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,77 @@
+/*
+* 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:  Encryption/Decryption support functions
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32base.h>
+#include <e32math.h>
+#include <s32buf.h>
+#include <s32crypt.h>
+
+#include "LMSecurity.h"
+#include "LMSecurityEncrypt.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CLMSecurityEncrypt::CLMSecurityEncrypt
+// Initialize the random key stream from a constant
+// -----------------------------------------------------------------------------
+//
+CLMSecurityEncrypt::CLMSecurityEncrypt(
+    const TDesC8& init)
+    {
+    TPckg<TUint> p(0);
+
+    p.Copy(init);
+    iKey = p();
+    Math::Rand(iKey);
+    }
+
+// -----------------------------------------------------------------------------
+// CLMSecurityEncrypt::EncryptL
+// Encrypt using the key stream
+// -----------------------------------------------------------------------------
+//
+TInt CLMSecurityEncrypt::EncryptL(
+    TDes8& aOutput,
+    const TDesC8& aInput)
+    {
+    TInt i;
+    TUint8* ptr;
+
+    ptr = const_cast<TUint8*>(aOutput.Ptr());
+    for (i = 0; i < aInput.Size(); i++)
+        {
+        ptr[i] = static_cast<TUint8>(aInput[i] ^ Math::Rand(iKey));
+        }
+    aOutput.SetLength(aInput.Size());
+    return aInput.Size();
+    }
+
+// -----------------------------------------------------------------------------
+// CLMSecurityEncrypt::CompleteL
+// Final encryption
+// -----------------------------------------------------------------------------
+//
+TInt CLMSecurityEncrypt::CompleteL(
+    TDes8& aOutput,
+    const TDesC8& aInput)
+    {
+    return EncryptL(aOutput, aInput);
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmfilter/EABI/DRMFilterU.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,9 @@
+EXPORTS
+	_Z24ImplementationGroupProxyRi @ 1 NONAME
+	_ZTI10TDRMMemBuf @ 2 NONAME ; #<TI>#
+	_ZTI14CHTTPFilterDRM @ 3 NONAME ; #<TI>#
+	_ZTI26CHTTPFilterDRMDataSupplier @ 4 NONAME ; #<TI>#
+	_ZTV10TDRMMemBuf @ 5 NONAME ; #<VT>#
+	_ZTV14CHTTPFilterDRM @ 6 NONAME ; #<VT>#
+	_ZTV26CHTTPFilterDRMDataSupplier @ 7 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmfilter/data/101F9710.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,65 @@
+/*
+* 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:  Registration data for transport framework DRM filter interface implementation collection
+*
+*/
+
+
+// application/vnd.oma.drm.message
+// OMA-Download-DRM-v1_0-20020905-a, Version 05-September-2002
+
+#include "Ecom/RegistryInfoV2.rh"
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	// resource format version for ROM-only filter
+	resource_format_version = RESOURCE_FORMAT_VERSION_2;
+
+	dll_uid = 0x101F9710;
+	interfaces=
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x101F446D;
+			implementations = 
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = 0x101F9711;
+					version_no = 1;
+					display_name = "DRMFilter";
+					
+					// For HTTP-TF the default_data must be defined as follows
+					// 1.Protocol identifier
+					//    HTTP-TF uses first part (separated with /-character) to identify
+					//    what protocol this filter will support. It could also be WSP but 
+					//    then HTTP-TF does not load it with any sessions that based on HTTP.
+					// 2.Separator
+					//    /-separator must be always there
+					// 3.Filter category
+					//    + = mandatory (HTTP-TF will panic if installation of this filter fails)
+					//    - = Explicit (Does not install filter)
+					//      = Implicit (Installs filter but traps possible errors and continues)
+
+					default_data = "HTTP/+DRM||WSP/+DRM";
+					opaque_data = "";
+
+					// this implementation CANNOT be overriden by a RAM-based plug-in
+					rom_only = 1;
+					}
+				};
+			}
+		};
+	}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmfilter/group/HTTPFilterDRM.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,71 @@
+/*
+* 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:  DRM HTTP Filter component build configuration
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET HTTPFilterDRM.dll
+TARGETTYPE PLUGIN
+
+CAPABILITY CAP_ECOM_PLUGIN
+
+// ECom Recogniction UID followed by Unique 3rd UID
+UID 0x10009D8D 0x101F9710
+VENDORID VID_DEFAULT
+
+SOURCEPATH ../src
+SOURCE HTTPFilterDRMMain.cpp HTTPFilterDRM.cpp HTTPFilterDRMDataSupplier.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE /epoc32/include/ecom
+
+
+SOURCEPATH ../data
+START RESOURCE 101F9710.rss
+
+TARGET HTTPFilterDRM.rsc
+
+END
+
+LIBRARY euser.lib ecom.lib http.lib bafl.lib estlib.lib efsrv.lib estor.lib cone.lib commonui.lib caf.lib
+
+#ifndef __DRM_NO_BB
+MACRO BLOCK_BY_BLOCK
+#endif
+
+
+//#define _ENABLE_LOGGING  // uncomment this if you want the log
+
+#ifdef _ENABLE_LOGGING
+MACRO DEBUG_LOGGING
+DEBUGLIBRARY flogger.lib charconv.lib
+#endif
+
+#if defined (ARMCC)
+DEFFILE ../EABI/DRMFilter.def
+#endif
+LIBRARY         DrmParsers.lib
+LIBRARY         DrmDcf.lib
+LIBRARY         DrmRights.lib
+LIBRARY         DrmServerInterfaces.lib
+LIBRARY         DRMCommon.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmfilter/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Build file for DRM HTTP Filter
+*
+*/
+
+
+PRJ_PLATFORMS
+
+DEFAULT
+
+PRJ_EXPORTS
+../rom/HTTPFilterDRM.iby    CORE_MW_LAYER_IBY_EXPORT_PATH( HTTPFilterDRM.iby )
+
+PRJ_MMPFILES
+
+HTTPFilterDRM.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmfilter/inc/HTTPFilterDRM.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  Declaration of DRM Http Filter plugin
+ *
+ */
+
+#ifndef __HTTPFILTERDRM_H_
+#define __HTTPFILTERDRM_H_
+
+#include <http/mhttpfilter.h>
+#include <http/rhttpsession.h>
+#include <http/cecomfilter.h>
+#include <http/framework/httplogger.h>
+#include <drmcommon.h>
+
+#include "httpfilterdrmdatasupplier.h"
+
+#ifndef DEBUG_LOGGING
+#undef _LOGGING
+#endif
+
+class RHTTPResponse;
+class RHTTPTransaction;
+class CDRMMessageParser;
+
+/**
+ *  major interface class for DRM HTTP Filter
+ *
+ *  @lib HTTPFilterDRM.lib
+ *  @since 2.6
+ */
+
+class CHTTPFilterDRM : public CEComFilter, public MHTTPFilter
+    {
+public:
+
+    static CEComFilter* InstallFilterL( TAny* aSession );
+
+    virtual ~CHTTPFilterDRM();
+
+    void DeleteDataSupplier( TInt aTransId );
+
+public:
+    // Methods from MHTTPFilterBase
+
+    /// @see MHTTPFilterBase::MHFRunL
+    virtual void MHFRunL( RHTTPTransaction aTransaction,
+        const THTTPEvent& aEvent );
+
+    /// @see MHTTPFilterBase::MHFSessionRunL
+    virtual void MHFSessionRunL( const THTTPSessionEvent& aEvent );
+
+    /// @see MHTTPFilterBase::MHFRunError
+    virtual TInt MHFRunError( TInt aError, RHTTPTransaction aTransaction,
+        const THTTPEvent& aEvent );
+
+    /// @see MHTTPFilterBase::MHFSessionRunError
+    virtual TInt MHFSessionRunError( TInt aError,
+        const THTTPSessionEvent& aEvent );
+
+public:
+    // Methods from MHTTPFilter
+
+    /// @see MHTTPFilter::MHFUnload
+    virtual void MHFUnload( RHTTPSession aSession, THTTPFilterHandle aHandle );
+
+    /// @see MHTTPFilter::MHFLoad
+    virtual void MHFLoad( RHTTPSession aSession, THTTPFilterHandle aHandle );
+
+private:
+
+    CHTTPFilterDRM( RHTTPSession aSession );
+
+    ///ContructL also Installs the filter.
+    void ConstructL( RHTTPSession aSession );
+
+#if defined (_DEBUG) && defined (_LOGGING)
+    void DumpResponseHeadersL( RHTTPResponse& aResponse );
+#endif
+
+    void CheckHeadersL( const RHTTPTransaction& aTrans );
+    void ProcessBodyPartL( RHTTPTransaction& aTrans );
+    TInt GetDRMTransIdx( const RHTTPTransaction& aTrans ) const;
+    void Cleanup( const RHTTPTransaction& aTrans );
+    void CleanupAll();
+
+private:
+    /// A count to make sure we delete at the right time.
+    TInt iLoadCount;
+    RStringPool iStringPool;
+    RHTTPSession iSession;
+
+    // data suppliers, one supplier per transaction
+    RPointerArray<CHTTPFilterDRMDataSupplier> iDataSups;
+
+    TInt iOffset;
+    // used for log purpose
+    __DECLARE_LOG
+    // In order to enable x-oma-drm-separate-delivery
+    TInt iXOmaHeaderVal;
+    };
+
+#endif //__HTTPFILTERDRM_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmfilter/inc/HTTPFilterDRMDataSupplier.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  Declaration of DRM Http Filter Data Supplier
+ *
+ */
+
+#ifndef _HTTPFILTERDRMDATASUPPLIER_H_
+#define _HTTPFILTERDRMDATASUPPLIER_H_
+//-----------------------------------------------------------------------------
+
+#include <s32mem.h>
+#include <http/mhttpdatasupplier.h>
+#include <oma1dcfcreator.h>
+//-----------------------------------------------------------------------------
+
+class CDRMMessageParser;
+class RMemWriteStream;
+class CHTTPFilterDRMDataSupplier;
+class ContentAccess::TAgent;
+class ContentAccess::CManager;
+class CHTTPFilterDRM;
+//-----------------------------------------------------------------------------
+
+// Structure allows distinguishing between standard DRM content and Hutchinson's protection
+enum TProcessedContentType
+    {
+    EStandardDRMContent = 0,
+    EHutchinsonCFMNoFirstChunk,
+    EHutchinsonCFMWithRingingToneNoFirstChunk,
+    EHutchinsonCFMNoContinuation,
+    EUnknownContent
+    };
+
+/**
+ * HeapArray8 - the helper class for memory re-allocation
+ *
+ * @lib DRMFilter.lib
+ * @since 2.6 
+ */
+class HeapArray8
+    {
+public:
+    static HeapArray8* NewMaxL( TInt max_ );
+
+    // operations
+    TBool Append( const TDesC8& src_ );
+    TBool Append( const TUint8* src_, TInt len_ );
+    TBool Insert( TInt index, const TDesC8 &src_ );
+    TBool Insert( TInt index, const TUint8* src_, TInt insertLen );
+
+    TPtr8& GetPtr()
+        {
+        return ptr;
+        }
+    ~HeapArray8();
+
+private:
+    HeapArray8();
+    void ConstructL( TInt );
+
+    HBufC8* buf;
+    TPtr8 ptr;
+    };
+
+/**
+ * TDRMMemBuf - the helper class for memory re-allocation
+ *
+ * @lib DRMFilter.lib
+ * @since 2.6 
+ */
+class TDRMMemBuf : public TMemBuf
+    {
+public:
+    static TDRMMemBuf* NewL( TInt aLength );
+    ~TDRMMemBuf();
+
+protected:
+    virtual void DoWriteL( const TAny* aPtr, TInt aLength );
+    virtual TStreamPos DoSeekL( TMark aMark, TStreamLocation aLocation,
+        TInt anOffset );
+
+private:
+    void ConstructL( TInt aLength );
+
+private:
+    HeapArray8* iBuf;
+    friend class CHTTPFilterDRMDataSupplier;
+    };
+
+/**
+ * a data supplier used for replace the default supplier in response data
+ *
+ * @lib DRMFilter.lib
+ * @since 2.6 
+ */
+class CHTTPFilterDRMDataSupplier : public CBase,
+    public MHTTPDataSupplier,
+    public RMemWriteStream
+    {
+public:
+    // ctor & dtor
+    static CHTTPFilterDRMDataSupplier* NewL( TInt,
+        MHTTPDataSupplier* iDataBody, CHTTPFilterDRM* aOwner );
+    /** Support for Hutchinson's content protection scheme, CFM
+     *  
+     */
+    static CHTTPFilterDRMDataSupplier* NewL( TInt,
+        MHTTPDataSupplier* iDataBody, TProcessedContentType aType,
+        CHTTPFilterDRM* aOwner );
+    /*
+     *
+     */
+    virtual ~CHTTPFilterDRMDataSupplier();
+    //-------------------------------------------------------------------------
+
+    // virtual functions from MHTTPDataSupplier
+    virtual TBool GetNextDataPart( TPtrC8& aDataPart );
+    virtual void ReleaseData();
+    virtual TInt OverallDataSize();
+    virtual TInt Reset();
+    TInt GetTransId() const
+        {
+        return iTransId;
+        }
+    //-------------------------------------------------------------------------
+
+
+    void ProcessDataPartL();
+
+    //-------------------------------------------------------------------------
+
+private:
+    CHTTPFilterDRMDataSupplier( TInt aTransId, MHTTPDataSupplier* iDataBody,
+        CHTTPFilterDRM* aOwner );
+    CHTTPFilterDRMDataSupplier( const CHTTPFilterDRMDataSupplier& ); // not implemented
+    CHTTPFilterDRMDataSupplier& operator=( const CHTTPFilterDRMDataSupplier& ); // not implemented
+    ContentAccess::CManager* GetCafDataL( TAgent& aAgent );
+    //-------------------------------------------------------------------------
+
+    void ConstructL( TInt aSize );
+    /** Support for Hutchinson's content protection scheme, CFM
+     *  
+     */
+    void ConstructL( TInt aSize, TProcessedContentType /*aType*/);
+    /**
+     *
+     */
+    void AppendDataL( const TDesC8& aData );
+    //-------------------------------------------------------------------------
+
+    TInt iTransId;
+    HBufC8* iBuf;
+    TPtr8 iBufPtr;
+    MHTTPDataSupplier *iPHData; // data supplier from protocol handler
+    TBool iSendReady; // ready for sending?
+
+    CDRMMessageParser* iDRMMessageParser;
+    TInt iPrevPos;
+    TDRMMemBuf* iMemBuf;
+    /** Support for Hutchinson's content protection scheme, CFM
+     *
+     */
+private:
+    HBufC8* iContentMimeType;
+    TProcessedContentType iProcessedContentType;
+    COma1DcfCreator *iDRMOma1DcfCreator;
+    CHTTPFilterDRM* iOwner;
+    TInt iDataPartSize;
+public:
+    void SetEstimatedArrivalTime( TInt aXOmaHeaderVal );
+    void SetContentMimeTypeL( const TDesC8& aMimeType );
+    void SetProcessedContentType( TProcessedContentType aType )
+        {
+        iProcessedContentType = aType;
+        }
+    //-------------------------------------------------------------------------
+    };
+//-----------------------------------------------------------------------------
+#endif // !_HTTPFILTERDRMDATASUPPLIER_H_ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmfilter/src/HTTPFilterDRM.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,737 @@
+/*
+ * 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:  Implementation of the DRM Filter HTTP Filter
+ *
+ */
+
+#include <http/rhttptransaction.h>
+#include <http/rhttpheaders.h>
+#include <http/rhttpresponse.h>
+#include <httpstringconstants.h>
+#include <httperr.h>
+#include <bautils.h>
+#include <drmmessageparser.h>
+
+#include "httpfilterdrm.h"
+
+// LOCAL CONSTANTS
+_LIT8( KDRMString1, "application/vnd.oma.drm.message" );
+// FL or CD
+
+_LIT8( KDRMString3, "application/vnd.oma.drm.content" );
+// SD only
+
+_LIT8( KJADString, "text/vnd.sun.j2me.app-descriptor" );
+// Jad files
+
+_LIT8( KXOmaFieldName, "x-oma-drm-separate-delivery");
+// Estimated arrival time for rights of the SD content
+
+_LIT8( KDRMOldContentType, "x-drm-old-content-type");
+// old content type header to be added
+
+_LIT8( KHTTPFilterDRMName, "DRM");
+// Name of filter
+
+_LIT8( KCFMRingtoneStr, "ringtone");
+// cfm ringtone string
+
+_LIT8( KCFMFwdStr, "fwd");
+// cfm forward string
+
+_LIT8( KCFMValStr, "no");
+// cfm negative value string
+
+const TInt KXOmaDefaultValue = 25;
+//default value for the 'x-oma-drm-separate-delivery' header
+
+const TInt KCFMFieldMaxLength( 200 );
+const TInt KBadMimeType( -12002 ); // common error code
+const TInt NW_STAT_FAILURE( -20000 ); // common error code
+
+// format for output of data/time values
+#if defined (_DEBUG) && defined (_LOGGING)
+_LIT(KDateFormat,"%D%M%Y%/0%1%/1%2%/2%3%/3 %:0%H%:1%T%:2%S.%C%:3");
+#endif
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRM::CHTTPFilterDRM
+// Constructor
+// -----------------------------------------------------------------------------
+//
+CHTTPFilterDRM::CHTTPFilterDRM( RHTTPSession aSession ) :
+    iSession( aSession )
+    {
+    iDataSups.Reset();
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRM::InstallFilterL
+// Initialize the filter and register it to sesssion's filter collection
+// -----------------------------------------------------------------------------
+//
+CEComFilter* CHTTPFilterDRM::InstallFilterL( TAny* aSession )
+    {
+    RHTTPSession* session = REINTERPRET_CAST(RHTTPSession*, aSession);
+    CHTTPFilterDRM* filter = new ( ELeave ) CHTTPFilterDRM( *session );
+    CleanupStack::PushL( filter );
+
+    filter->ConstructL( *session );
+    CleanupStack::Pop( filter );
+
+    return filter;
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRM::ConstructL
+// Memory and resource allocation, leaves
+// -----------------------------------------------------------------------------
+//
+void CHTTPFilterDRM::ConstructL( RHTTPSession aSession )
+    {
+    iStringPool = aSession.StringPool();
+
+    const TInt KPriorityDelta( 10 );
+    // register the filter
+    RStringF filterName = iStringPool.OpenFStringL( KHTTPFilterDRMName );
+    CleanupClosePushL( filterName );
+    iSession.FilterCollection().AddFilterL( *this,
+        THTTPEvent::EGotResponseHeaders, // Any transaction event
+        MHTTPFilter::EProtocolHandler + KPriorityDelta, // Priority of filter
+        filterName ); // Name of filter
+    iSession.FilterCollection().AddFilterL( *this,
+        THTTPEvent::EGotResponseBodyData,
+        MHTTPFilter::EProtocolHandler + KPriorityDelta,
+        filterName );
+    iSession.FilterCollection().AddFilterL( *this,
+        THTTPEvent::EResponseComplete,
+        MHTTPFilter::EProtocolHandler + KPriorityDelta,
+        filterName );
+    iSession.FilterCollection().AddFilterL( *this,
+        THTTPEvent::EFailed,
+        MHTTPFilter::EProtocolHandler + KPriorityDelta,
+        filterName );
+    iSession.FilterCollection().AddFilterL( *this,
+        THTTPEvent::EClosed,
+        MHTTPFilter::EProtocolHandler + KPriorityDelta,
+        filterName );
+    CleanupStack::PopAndDestroy( &filterName );
+
+    // log file
+    __OPEN_LOG( "DRM.LOG" );
+    __LOG( _L ( "--Initialize DRM Filter---\n" ) );
+
+    }
+
+//------------------------------------------------------------------------
+// CHTTPFilterDRM::~CHTTPFilterDRM
+// Destructor
+//------------------------------------------------------------------------
+//
+CHTTPFilterDRM::~CHTTPFilterDRM()
+    {
+    // If we've been destroyed from the cleanup stack during creation
+    // of the object, it might still be loaded. So check. (Normaly the
+    // delete is initiated by the 'delete this' in MHFUnload)
+    if ( iLoadCount )
+        {
+        // As we're already in a destructor, MHFUnload must not delete us again
+        iLoadCount = -1;
+        RStringF filterName;
+        TRAPD( error, ( filterName = iStringPool.OpenFStringL( KHTTPFilterDRMName ) ) );
+        if ( error == KErrNone )
+            iSession.FilterCollection().RemoveFilter( filterName );
+        filterName.Close();
+        }
+
+    CleanupAll();
+    iDataSups.Close();
+    }
+
+//------------------------------------------------------------------------
+// CHTTPFilterDRM::DeleteDataSupplier
+//------------------------------------------------------------------------
+//
+void CHTTPFilterDRM::DeleteDataSupplier( TInt aTransId )
+    {
+    __LOG( _L ( "CHTTPFilterDRM::DeleteDataSupplier" ) );
+    TInt idx( KErrNotFound );
+    for ( TInt i = 0; idx == KErrNotFound && i < iDataSups.Count(); ++i )
+        {
+        if ( iDataSups[i]->GetTransId() == aTransId )
+            {
+            idx = i;
+            }
+        }
+
+    if ( idx != KErrNotFound )
+        {
+        __LOG1( _L ( "CHTTPFilterDRM::DeleteDataSupplier: deleting transaction %d." ), aTransId );
+        // remove the problematic data supplier
+        CHTTPFilterDRMDataSupplier* sup = iDataSups[idx];
+        iDataSups.Remove( idx );
+        delete sup;
+        sup = NULL;
+        }
+    }
+
+//------------------------------------------------------------------------
+// CHTTPFilterDRM::MHFLoad
+// See MHTTPFilterBase::MHFRunL
+//------------------------------------------------------------------------
+//
+void CHTTPFilterDRM::MHFLoad( RHTTPSession, THTTPFilterHandle )
+    {
+    __LOG( _L ( "--Load DRM Filter---\n" ) );
+    ++iLoadCount;
+    }
+
+//------------------------------------------------------------------------
+// CHTTPFilterDRM::MHFUnload
+// See MHTTPFilterBase::MHFRunError
+//------------------------------------------------------------------------
+//
+void CHTTPFilterDRM::MHFUnload( RHTTPSession, THTTPFilterHandle )
+    {
+    __LOG( _L ( "--Unload DRM Filter---\n" ) );
+    if ( --iLoadCount )
+        {
+        return;
+        }
+
+    delete this;
+    }
+
+//------------------------------------------------------------------------
+// CHTTPFilterDRM::MHFRunL
+// See MHTTPFilterBase::MHFRunL 
+//------------------------------------------------------------------------
+//
+void CHTTPFilterDRM::MHFRunL( RHTTPTransaction aTransaction,
+    const THTTPEvent& aEvent )
+    {
+    if ( aEvent.iUID != KHTTPUid )
+        return;
+
+    switch ( aEvent.iStatus )
+        {
+        case THTTPEvent::EGotResponseHeaders:
+            {
+            __LOG( _L ( "Event: EGotResponseHeaders\n" ) );
+            CheckHeadersL( aTransaction );
+            }
+            break;
+        case THTTPEvent::EGotResponseBodyData:
+            {
+            __LOG( _L ( "Event: EGotResponseBodyData\n" ) );
+            TInt idx = GetDRMTransIdx( aTransaction );
+            if ( idx != KErrNotFound )
+                {
+                // for x-oma-drm-separate-delivery purpose
+                if ( iXOmaHeaderVal )
+                    {
+                    iDataSups[idx]->SetEstimatedArrivalTime( iXOmaHeaderVal );
+                    iXOmaHeaderVal = 0;
+
+                    //remove the DataSuuplier
+                    delete iDataSups[idx];
+                    iDataSups.Remove( idx );
+                    }
+                else
+                    {
+                    iDataSups[idx]->ProcessDataPartL();
+                    }
+                }
+            }
+            break;
+        case THTTPEvent::EResponseComplete:
+            {
+            __LOG( _L ( "Event: EResponseComplete\n" ) );
+            }
+            break;
+        case THTTPEvent::EFailed:
+            {
+            __LOG( _L ( "Event: EFailed\n" ) );
+            Cleanup( aTransaction );
+            }
+            break;
+        case THTTPEvent::EClosed:
+            {
+            __LOG( _L ( "Event: EClosed\n" ) );
+            }
+            break;
+        default:
+            {
+            __LOG1( _L ( "Unknow Event: ID - %d\n" ), aEvent.iStatus );
+            }
+            break;
+        }
+    }
+
+const static TInt KGlobalErrs[] =
+    {
+        NW_STAT_FAILURE,
+        KBadMimeType,
+        KBadMimeType,
+        NW_STAT_FAILURE,
+        KBadMimeType,
+        KBadMimeType,
+        KBadMimeType,
+        KBadMimeType,
+        KBadMimeType
+    };
+
+//------------------------------------------------------------------------
+// CHTTPFilterDRM::MHFRunError
+// See MHTTPFilterBase::MHFRunError
+//------------------------------------------------------------------------
+//
+TInt CHTTPFilterDRM::MHFRunError( TInt aError, RHTTPTransaction aTransaction,
+    const THTTPEvent& )
+    {
+    TInt error = 0;
+    TInt error2 = KErrNone;
+    // map aError to global error message
+
+    if ( aError >= DRMCommon::EInvalidRights && aError
+        <= DRMCommon::EGeneralError )
+        error = KGlobalErrs[DRMCommon::EGeneralError - aError];
+    else
+        error = aError;
+
+    //to map caf errors and KErrCorrupt to display
+    switch ( aError )
+        {
+        case KErrCANotSupported:
+        case KErrCANoPermission:
+        case KErrCANoRights:
+        case KErrCorrupt:
+            {
+            error = NW_STAT_FAILURE; //Unable to perform operation   
+            }
+            break;
+        case KErrArgument:
+            {
+            error = KBadMimeType;
+            }
+            break;
+        case KErrCANoAgent:
+        case KErrCAOutOfRange:
+        case KErrCAPendingRights:
+        case KErrCASizeNotDetermined:
+        case KErrCANewFileHandleRequired:
+            {
+            error = NW_STAT_FAILURE;
+            }
+            break;
+        default:
+            {
+            error = NW_STAT_FAILURE;
+            }
+            break;
+        }
+
+    // pass the errorcode forward
+    THTTPEvent httpEvent( error );
+        TRAP( error2, aTransaction.SendEventL(httpEvent, THTTPEvent::EIncoming, THTTPFilterHandle::ECurrentFilter ));
+
+    return error2;
+    }
+
+//------------------------------------------------------------------------
+// CHTTPFilterDRM::MHFSessionRunL
+// See MHTTPFilterBase::MHFSessionRunL
+//------------------------------------------------------------------------
+//
+void CHTTPFilterDRM::MHFSessionRunL( const THTTPSessionEvent& )
+    {
+    // do nothing
+    }
+
+//------------------------------------------------------------------------
+// CHTTPFilterDRM::MHFSessionRunL
+// See MHTTPFilterBase::MHFSessionRunL
+//------------------------------------------------------------------------
+//
+TInt CHTTPFilterDRM::MHFSessionRunError( TInt aError,
+    const THTTPSessionEvent& )
+    {
+    // session problem, need to close DRM engine
+    CleanupAll();
+    return aError;
+    }
+
+//------------------------------------------------------------------------
+// CHTTPFilterDRM::DumpResponseHeadersL
+// Dump the response headers to LOG file
+//------------------------------------------------------------------------
+//
+#if defined (_DEBUG) && defined (_LOGGING)
+void CHTTPFilterDRM::DumpResponseHeadersL( RHTTPResponse& aResponse )
+    {
+    __LOG( _L ( "Dump the header...\n" ) );
+
+    RHTTPHeaders headers = aResponse.GetHeaderCollection();
+    RStringPool strP = iSession.StringPool();
+    THTTPHdrFieldIter it = headers.Fields();
+
+    while ( it.AtEnd() == EFalse )
+        {
+        RStringTokenF fieldName = it();
+        RStringF fieldNameStr = strP.StringF( fieldName );
+        THTTPHdrVal fieldVal;
+        TInt fieldParts = 0; // For the case if next the call fails.
+        TRAPD( ignoreErr, fieldParts = headers.FieldPartsL( fieldNameStr ) );
+
+        // dump the first part of  a  header field
+        for ( TInt ii = 0; ii < fieldParts; ii++ )
+            {
+            if ( headers.GetField( fieldNameStr, ii, fieldVal ) == KErrNone )
+                {
+                const TDesC8& fieldNameDesC = fieldNameStr.DesC();
+                __DUMPBIN( fieldNameDesC );
+                __LOG( _L ( " : " ) );
+
+                switch ( fieldVal.Type() )
+                    {
+                    case THTTPHdrVal::KTIntVal:
+                        {
+                        __LOG1( _L ( "%d" ), fieldVal.Int() );
+                        }
+                        break;
+                    case THTTPHdrVal::KStrFVal:
+                        {
+                        RStringF fieldValStr = strP.StringF( fieldVal.StrF() );
+                        const TDesC8& fieldValDesC = fieldValStr.DesC();
+                        __DUMPBIN( fieldValDesC );
+                        }
+                        break;
+                    case THTTPHdrVal::KStrVal:
+                        {
+                        RString fieldValStr = strP.String( fieldVal.Str() );
+                        const TDesC8& fieldValDesC = fieldValStr.DesC();
+                        __DUMPBIN( fieldValDesC );
+                        }
+                        break;
+                    case THTTPHdrVal::KDateVal:
+                        {
+                        const TInt KDateTimeMaxLength( 40 );
+                        TDateTime date = fieldVal.DateTime();
+                        TBuf<KDateTimeMaxLength> dateTimeString;
+                        TTime t( date );
+                        t.FormatL( dateTimeString, KDateFormat );
+                        TBuf8<KDateTimeMaxLength> dtStr;
+                        dtStr.Copy( dateTimeString.Left( KDateTimeMaxLength ) );
+                        __DUMPBIN( dtStr );
+                        }
+                        break;
+                    case THTTPHdrVal::KNoType:
+                    default:
+                        {
+                        __LOG( _L ( "Unrecognized value type.\n" ) );
+                        }
+                        break;
+                    }
+
+                __LOG( _L ( "\n" ) );
+                }
+            }
+
+        ++it;
+        }
+    __LOG( _L ( "Header is Dumped already...\n" ) );
+
+    }
+#endif
+
+//------------------------------------------------------------------------
+// CHTTPFilterDRM::CheckHeadersL
+// Check HTTP headers and extract MIME type
+//------------------------------------------------------------------------
+// 
+void CHTTPFilterDRM::CheckHeadersL( const RHTTPTransaction& aTrans )
+    {
+    // read the header data and check the MIME type here	
+    // check the status and body
+    RHTTPResponse response = aTrans.Response();
+    TInt status = response.StatusCode();
+
+#if defined (_DEBUG) && defined (_LOGGING)
+    DumpResponseHeadersL( response );
+#endif
+
+    THTTPHdrVal fieldVal;
+    // check if the content type is application/vnd.oma.drm.message
+    if ( ( status >= HTTPStatus::EOk ) &&
+        ( status < HTTPStatus::EMultipleChoices ) &&
+        ( status != HTTPStatus::ENoContent ) )
+        {
+        const TBuf8<sizeof( KDRMString1 )> DRMStringBuf1( KDRMString1 );
+        const TBuf8<sizeof( KDRMString3 )> DRMStringBuf3( KDRMString3 );
+        const TBuf8<sizeof( KDRMOldContentType )> DRMHeaderName(
+            KDRMOldContentType );
+
+        RHTTPHeaders headers = response.GetHeaderCollection();
+        RStringPool strP = iSession.StringPool();
+        RStringF fieldNameStr = strP.StringF( HTTP::EContentType,
+            RHTTPSession::GetTable() );
+
+        if ( headers.GetField( fieldNameStr, 0, fieldVal ) == KErrNone )
+            {
+            RStringF fieldValStr = strP.StringF( fieldVal.StrF() );
+
+            RStringF DRMValue1 = strP.OpenFStringL( DRMStringBuf1 );
+            CleanupClosePushL( DRMValue1 );
+
+            RStringF DRMValue3 = strP.OpenFStringL( DRMStringBuf3 );
+            CleanupClosePushL( DRMValue3 );
+
+            RStringF DRMHeaderNameF = strP.OpenFStringL( DRMHeaderName );
+            CleanupClosePushL( DRMHeaderNameF );
+
+            // DRM message
+            if ( DRMValue1 == fieldValStr )
+                {
+                __LOG( _L ("DRM content exists, a new dummy data supplier is created!\n" ) );
+
+                CHTTPFilterDRMDataSupplier* drmData = 0;
+
+                drmData = CHTTPFilterDRMDataSupplier::NewL( aTrans.Id(),
+                    response.Body(), const_cast<CHTTPFilterDRM*> ( this ) );
+                /** Support for Hutchinson's content protection scheme, CFM
+                 *  
+                 */
+                drmData->SetProcessedContentType( EStandardDRMContent );
+                /**
+                 *
+                 */
+                iDataSups.Append( drmData );
+                response.SetBody( *drmData );
+
+                // change the mime type to "application/vnd.oma.drm.content"
+                headers.RemoveField( fieldNameStr );
+                headers.SetFieldL( fieldNameStr, THTTPHdrVal( DRMValue3 ) );
+
+                // add the new header
+                headers.SetFieldL( DRMHeaderNameF, THTTPHdrVal( DRMValue1 ) );
+
+                }
+            else if ( DRMValue3 == fieldValStr )
+                {
+                RStringF xOmaFieldName = strP.OpenFStringL( KXOmaFieldName );
+                if ( headers.GetField( xOmaFieldName, 0, fieldVal )
+                    == KErrNone )
+                    {
+                    iXOmaHeaderVal = KXOmaDefaultValue;
+
+                    switch ( fieldVal.Type() )
+                        {
+                        case THTTPHdrVal::KStrFVal:
+                            {
+                            TLex8 lexer( fieldVal.StrF().DesC() );
+                            lexer.Val( iXOmaHeaderVal );
+                            }
+                            break;
+                        case THTTPHdrVal::KStrVal:
+                            {
+                            TLex8 lexer( fieldVal.Str().DesC() );
+                            lexer.Val( iXOmaHeaderVal );
+                            }
+                            break;
+                        case THTTPHdrVal::KTIntVal:
+                            {
+                            iXOmaHeaderVal = fieldVal.Int();
+                            }
+                            break;
+                        }
+                    }
+                xOmaFieldName.Close();
+                if ( iXOmaHeaderVal ) //if header has value of 0 then will be ignored
+                    {
+                    CHTTPFilterDRMDataSupplier* drmData = 0;
+                    drmData
+                        = CHTTPFilterDRMDataSupplier::NewL( aTrans.Id(),
+                            response.Body(),
+                            const_cast<CHTTPFilterDRM*> ( this ) );
+                    iDataSups.Append( drmData );
+                    }
+
+                }
+
+            CleanupStack::PopAndDestroy( &DRMHeaderNameF );
+            CleanupStack::PopAndDestroy( &DRMValue3 );
+            CleanupStack::PopAndDestroy( &DRMValue1 );
+
+            // dump the header after modification
+#if defined (_DEBUG) && defined (_LOGGING)
+            __LOG( _L ("--- HEADER AFTER CHANGE ---\n") );
+            DumpResponseHeadersL( response );
+#endif
+            }
+
+        // CFM Content protection:
+        //========================
+
+        TInt idx = GetDRMTransIdx( aTrans );
+        if ( idx != KErrNotFound )
+            return;
+
+        TProcessedContentType currentContentType = EUnknownContent;
+
+        RStringF cfmValStr = strP.OpenFStringL( KCFMValStr );
+        CleanupClosePushL( cfmValStr );
+
+        // check "fwd=no"
+        RStringF cfmFwdStr = strP.OpenFStringL( KCFMFwdStr );
+        CleanupClosePushL( cfmFwdStr );
+        if ( headers.GetParam( fieldNameStr, cfmFwdStr, fieldVal )
+            != KErrNotFound )
+            {
+            RStringF fieldValStr = strP.StringF( fieldVal.StrF() );
+            TBufC8<KCFMFieldMaxLength> buf1 = fieldValStr.DesC();
+            if ( fieldValStr == cfmValStr )
+                {
+                currentContentType = EHutchinsonCFMNoFirstChunk;
+                }
+            }
+        CleanupStack::PopAndDestroy( &cfmFwdStr );
+
+        // check "ringtone=no"
+        RStringF cfmRingtoneStr = strP.OpenFStringL( KCFMRingtoneStr );
+        CleanupClosePushL( cfmRingtoneStr );
+
+        if ( headers.GetParam( fieldNameStr, cfmRingtoneStr, fieldVal )
+            != KErrNotFound )
+            {
+            RStringF fieldValStr = strP.StringF( fieldVal.StrF() );
+            TBufC8<KCFMFieldMaxLength> buf1 = fieldValStr.DesC();
+            if ( fieldValStr == cfmValStr )
+                {
+                currentContentType
+                    = EHutchinsonCFMWithRingingToneNoFirstChunk;
+                }
+            }
+        CleanupStack::PopAndDestroy( &cfmRingtoneStr );
+        CleanupStack::PopAndDestroy( &cfmValStr );
+
+        // Do not encrypt JAD files:
+        if ( headers.GetField( fieldNameStr, 0, fieldVal ) == KErrNone )
+            {
+            // If it is a JAD always ignore any of the above:	
+            const TBuf8<sizeof( KJADString )> JADStringBuf( KJADString );
+            RStringF JADValue = strP.OpenFStringL( JADStringBuf );
+            CleanupClosePushL( JADValue );
+
+            RStringF jadFieldValStr = strP.StringF( fieldVal.StrF() );
+            if ( JADValue == jadFieldValStr )
+                {
+                currentContentType = EUnknownContent;
+                }
+            CleanupStack::PopAndDestroy( &JADValue );
+            }
+
+        // Protect the content
+        if ( currentContentType != EUnknownContent ) // content protected
+            {
+            CHTTPFilterDRMDataSupplier* drmData = 0;
+            drmData = CHTTPFilterDRMDataSupplier::NewL( aTrans.Id(),
+                response.Body(), EHutchinsonCFMWithRingingToneNoFirstChunk,
+                const_cast<CHTTPFilterDRM*> ( this ) );
+            drmData->SetProcessedContentType( currentContentType );
+
+            if ( headers.GetField( fieldNameStr, 0, fieldVal ) == KErrNone )
+                {
+                drmData->SetContentMimeTypeL( fieldVal.StrF().DesC() );
+                }
+            else
+                {
+                delete drmData;
+                User::Leave( KErrUnknown );
+                }
+
+            iDataSups.Append( drmData );
+            response.SetBody( *drmData );
+
+            ///			
+            RStringF DRMValue1 = strP.OpenFStringL( DRMStringBuf1 );
+            CleanupClosePushL( DRMValue1 );
+
+            RStringF DRMValue3 = strP.OpenFStringL( DRMStringBuf3 );
+            CleanupClosePushL( DRMValue3 );
+
+            RStringF DRMHeaderNameF = strP.OpenFStringL( DRMHeaderName );
+            CleanupClosePushL( DRMHeaderNameF );
+
+            // change the mime type to "application/vnd.oma.drm.content"
+
+            headers.RemoveField( fieldNameStr );
+            headers.SetFieldL( fieldNameStr, THTTPHdrVal( DRMValue3 ) );
+
+            // add the new header
+            headers.SetFieldL( DRMHeaderNameF, THTTPHdrVal( DRMValue1 ) );
+
+            CleanupStack::PopAndDestroy( &DRMHeaderNameF );
+            CleanupStack::PopAndDestroy( &DRMValue3 );
+            CleanupStack::PopAndDestroy( &DRMValue1 );
+            }
+        }
+    }
+
+//-----------------------------------------------------------------------------
+// CHTTPFilterDRM::GetDRMTransIdx
+// Retrieve the DRM datasupplier
+//-----------------------------------------------------------------------------
+//
+TInt CHTTPFilterDRM::GetDRMTransIdx( const RHTTPTransaction& aTrans ) const
+    {
+    for ( TInt i = 0; i < iDataSups.Count(); ++i )
+        {
+        if ( iDataSups[i]->GetTransId() == aTrans.Id() )
+            {
+            return i;
+            }
+        }
+    return KErrNotFound;
+    }
+
+//-----------------------------------------------------------------------------
+// CHTTPFilterDRM::Cleanup
+// Cleanup the resource related with a transaction
+//-----------------------------------------------------------------------------
+//
+void CHTTPFilterDRM::Cleanup( const RHTTPTransaction& aTrans )
+    {
+    TInt idx = GetDRMTransIdx( aTrans );
+    if ( idx != KErrNotFound )
+        {
+        // remove the problematic data supplier
+        CHTTPFilterDRMDataSupplier* sup = iDataSups[idx];
+        iDataSups.Remove( idx );
+        delete sup;
+        sup = NULL;
+        }
+    }
+
+//-----------------------------------------------------------------------------
+// CHTTPFilterDRM::CleanupAll
+// Cleanup all the DRM transactions, in case a session error happens or a session
+// is closed.
+//-----------------------------------------------------------------------------
+//
+void CHTTPFilterDRM::CleanupAll()
+    {
+    iDataSups.ResetAndDestroy();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmfilter/src/HTTPFilterDRMDataSupplier.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,664 @@
+/*
+ * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include <http/rhttptransaction.h>
+#include <barsc.h>
+#include <drmcommon.h>
+#include <f32file.h>
+#include <s32buf.h>
+#include <drmmessageparser.h>
+#include <caf/caf.h>
+#include <oma2agent.h>
+
+#include "httpfilterdrmdatasupplier.h"
+#include "httpfilterdrm.h"
+
+//------------------------------------------------------------------------
+
+const TInt KMinContentSizeToGetTheURI = 520;
+const TInt KDefaultSize( 2048 );
+const TInt KWholeDataPart( -1 );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::NewL
+// Two-phase constructor
+// -----------------------------------------------------------------------------
+//
+CHTTPFilterDRMDataSupplier* CHTTPFilterDRMDataSupplier::NewL( TInt aTransId,
+    MHTTPDataSupplier* iDataBody, CHTTPFilterDRM* aOwner )
+    {
+    CHTTPFilterDRMDataSupplier* self =
+        new ( ELeave ) CHTTPFilterDRMDataSupplier( aTransId, iDataBody,
+            aOwner );
+
+    CleanupStack::PushL( self );
+    self->ConstructL( KDefaultSize );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::NewL
+// Two-phase constructor, CFM
+// -----------------------------------------------------------------------------
+//	
+CHTTPFilterDRMDataSupplier* CHTTPFilterDRMDataSupplier::NewL( TInt aTransId,
+    MHTTPDataSupplier* iDataBody, TProcessedContentType aType,
+    CHTTPFilterDRM* aOwner )
+    {
+    CHTTPFilterDRMDataSupplier* self =
+        new ( ELeave ) CHTTPFilterDRMDataSupplier( aTransId, iDataBody,
+            aOwner );
+    CleanupStack::PushL( self );
+    self->ConstructL( KDefaultSize, aType );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::CHTTPFilterDRMDataSupplier
+// constructor
+// -----------------------------------------------------------------------------
+//
+CHTTPFilterDRMDataSupplier::CHTTPFilterDRMDataSupplier( TInt aTransId,
+    MHTTPDataSupplier* iDataBody, CHTTPFilterDRM* aOwner ) :
+    iTransId( aTransId ), iBufPtr( 0, 0 ), iPHData( iDataBody ), iSendReady(
+        EFalse ), iOwner( aOwner )
+    {
+    iDRMMessageParser = 0;
+    iPrevPos = 0;
+    iMemBuf = 0;
+    iDataPartSize = KWholeDataPart;
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::ConstructL
+// Data allocation constructor, which leaves
+// -----------------------------------------------------------------------------
+//
+void CHTTPFilterDRMDataSupplier::ConstructL( TInt aSize )
+    {
+    // create the output buffer
+    iBuf = HBufC8::NewMaxL( aSize );
+
+    iBufPtr.Set( iBuf->Des() );
+    iBufPtr.SetLength( 0 );
+
+    // setup the memory buffer
+    iMemBuf = TDRMMemBuf::NewL( aSize );
+
+    // create the DRM client and the writable memory stream
+    iDRMMessageParser = CDRMMessageParser::NewL();
+
+    Attach( iMemBuf );
+
+    iDRMMessageParser->InitializeMessageParserL( *this );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::ConstructL
+// Data allocation constructor, which leaves, CFM
+// -----------------------------------------------------------------------------
+//
+void CHTTPFilterDRMDataSupplier::ConstructL( TInt aSize,
+    TProcessedContentType /*aType*/)
+    {
+    // create the output buffer
+    iBuf = HBufC8::NewMaxL( aSize );
+    iBufPtr.Set( iBuf->Des() );
+    iBufPtr.SetLength( 0 );
+
+    // setup the memory buffer
+    iMemBuf = TDRMMemBuf::NewL( aSize );
+
+    iDRMOma1DcfCreator = COma1DcfCreator::NewL();
+    Attach( iMemBuf );
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::~CHTTPFilterDRMDataSupplier()
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CHTTPFilterDRMDataSupplier::~CHTTPFilterDRMDataSupplier()
+    {
+
+    // First make sure that we have completed everything, before we delete
+    // Anything essential
+    if ( !iSendReady ) // the destructor is called by other filters
+        {
+        if ( iDRMMessageParser )
+            {
+            TRAP_IGNORE( iDRMMessageParser->FinalizeMessageParserL() );
+            }
+        }
+
+    if ( iDRMMessageParser )
+        {
+        delete iDRMMessageParser;
+        iDRMMessageParser = NULL;
+        }
+
+    if ( iMemBuf )
+        {
+        delete iMemBuf;
+        iMemBuf = NULL;
+        }
+
+    // This used to be deleted first, but this of course caused the finalize to fail
+    if ( iBuf )
+        {
+        delete iBuf;
+        iBuf = NULL;
+        }
+
+    iPHData = 0;
+
+    if ( iContentMimeType )
+        {
+        delete iContentMimeType;
+        iContentMimeType = NULL;
+        }
+
+    if ( iDRMOma1DcfCreator )
+        {
+        delete iDRMOma1DcfCreator;
+        iDRMOma1DcfCreator = NULL;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::AppendDataL
+// Append a bulk of data into the supplier's buffer
+// reallocation is needed when buffer is not big enough
+// -----------------------------------------------------------------------------
+//
+void CHTTPFilterDRMDataSupplier::AppendDataL( const TDesC8& aDataPart )
+    {
+    TInt curLen = iBufPtr.Length();
+    TInt reqLen = curLen + aDataPart.Length();
+
+    if ( reqLen > iBufPtr.MaxLength() )
+        {
+        TRAPD( error, ( iBuf = iBuf->ReAllocL( reqLen + aDataPart.Length() ) ) ); // realloc a bit more data, this should not happen often
+        if ( error != KErrNone )
+            User::Leave( KErrNoMemory );
+
+        iBufPtr.Set( iBuf->Des() );
+        iBufPtr.SetLength( curLen );
+        }
+    iBufPtr.Append( aDataPart );
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::EncryptContentL
+// encrypt the content with DRM client
+// -----------------------------------------------------------------------------
+//
+void CHTTPFilterDRMDataSupplier::ProcessDataPartL()
+    {
+    // get the data part
+    TPtrC8 dataPart;
+    TBool lastChunk = iPHData->GetNextDataPart( dataPart );
+
+    /** Support for Hutchinson's content protection scheme, CFM
+     *
+     */
+    // encrypt the data
+    if ( iProcessedContentType == EStandardDRMContent )
+        {
+        TRAPD( err, iDRMMessageParser->ProcessMessageDataL( dataPart ) );
+
+        // error happens
+        if ( err != KErrNone )
+            {
+            iDRMMessageParser->FinalizeMessageParserL();
+            User::Leave( err );
+            }
+
+        if ( lastChunk )
+            {
+            iSendReady = ETrue;
+            iDRMMessageParser->FinalizeMessageParserL();
+            }
+        }
+    else if ( iProcessedContentType
+        == EHutchinsonCFMWithRingingToneNoFirstChunk )
+        {
+        //create rights
+        CDRMRights* rights = CDRMRights::NewL();
+        CleanupStack::PushL( rights );
+
+        // Asset contains the content id
+        // DrmAsset.h
+        CDRMAsset* asset = CDRMAsset::NewLC();
+        _LIT8(KContentURI, "flk:flkS60_3_0_Hutchinson_2005");
+        asset->iUid = KContentURI().AllocL(); // This will be freed by the assets destructor
+
+        // Set the asset to the rights class, it will duplicate the asset
+        rights->SetAssetL( *asset );
+        CleanupStack::PopAndDestroy( asset ); // Asset
+
+        // DRMPermission.h
+        CDRMPermission* permission = CDRMPermission::NewLC();
+
+        // DRMConstraint.h
+        // DRMTypes.h
+        permission->iPlay = CDRMConstraint::NewL();
+        permission->iDisplay = CDRMConstraint::NewL();
+        permission->iExecute = CDRMConstraint::NewL();
+        permission->iPrint = CDRMConstraint::NewL();
+
+        permission->iAvailableRights = ERightsPlay | ERightsDisplay
+            | ERightsExecute | ERightsPrint;
+
+        permission->iRightsObjectVersion.iVersionMain = 1; // major version for Oma 1 Rights Objects		
+
+        // "ringtone=no" present 
+        permission->iInfoBits = ENoRingingTone;
+
+        // Set the permission to the rights class, it will duplicate the permission
+        rights->SetPermissionL( *permission );
+
+        CleanupStack::PopAndDestroy( permission ); // Permission
+
+        //initializing
+        iDRMOma1DcfCreator->EncryptInitializeL( *this,
+            iContentMimeType->Des(), rights );
+        //process current chunk
+        TRAPD(err, iDRMOma1DcfCreator->EncryptUpdateL(dataPart));
+        if ( err )
+            {
+            iDRMOma1DcfCreator->EncryptFinalizeL();
+            User::Leave( err );
+            }
+
+        // if there is only one chunk
+        if ( lastChunk )
+            {
+            iSendReady = ETrue;
+            iDRMOma1DcfCreator->EncryptFinalizeL();
+            }
+
+        CleanupStack::PopAndDestroy( rights );
+        iProcessedContentType = EHutchinsonCFMNoContinuation;
+        }
+    else if ( iProcessedContentType == EHutchinsonCFMNoFirstChunk )
+        {
+        //initializing
+        iDRMOma1DcfCreator->EncryptInitializeL( *this,
+            iContentMimeType->Des(), NULL);
+        //process current chunk
+        TRAPD(err, iDRMOma1DcfCreator->EncryptUpdateL(dataPart));
+        if ( err )
+            {
+            iDRMOma1DcfCreator->EncryptFinalizeL();
+            User::Leave( err );
+            }
+
+        // if there is only one chunk
+        if ( lastChunk )
+            {
+            iSendReady = ETrue;
+            iDRMOma1DcfCreator->EncryptFinalizeL();
+            }
+        iProcessedContentType = EHutchinsonCFMNoContinuation;
+        }
+    else if ( iProcessedContentType == EHutchinsonCFMNoContinuation )
+        {
+        TRAPD(err, iDRMOma1DcfCreator->EncryptUpdateL(dataPart));
+        if ( err )
+            {
+            iDRMOma1DcfCreator->EncryptFinalizeL();
+            User::Leave( err );
+            }
+        if ( lastChunk )
+            {
+            iSendReady = ETrue;
+            iDRMOma1DcfCreator->EncryptFinalizeL();
+            }
+        }
+    else
+        {
+        User::Leave( KErrUnknown );
+        }
+    iPHData->ReleaseData();
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::GetNextDataPart
+// virtual methods from MHTTPDataSupplier
+// -----------------------------------------------------------------------------
+//
+TBool CHTTPFilterDRMDataSupplier::GetNextDataPart( TPtrC8& aDataPart )
+    {
+
+    if ( iDataPartSize == KWholeDataPart )
+        {
+        aDataPart.Set( iMemBuf->iBuf->GetPtr() );
+        iDataPartSize = aDataPart.Length();
+        }
+    else
+        {
+        aDataPart.Set( iMemBuf->iBuf->GetPtr().Left( iDataPartSize ) );
+        }
+
+    return ( iDataPartSize == KWholeDataPart ) ? iSendReady : EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::ReleaseData
+// virtual methods from MHTTPDataSupplier
+// -----------------------------------------------------------------------------
+//
+void CHTTPFilterDRMDataSupplier::ReleaseData()
+    {
+    if ( iDataPartSize == KWholeDataPart )
+        {
+        TRAP_IGNORE( Sink()->SeekL( MStreamBuf::EWrite, TStreamPos(0) ) );
+        if ( iSendReady )
+            {
+            iOwner->DeleteDataSupplier( iTransId );
+            }
+        }
+    else
+        {
+        //Remove only consumed data part
+        HBufC8* b( iMemBuf->iBuf->GetPtr().Mid( iDataPartSize ).AllocLC() );
+        TRAP_IGNORE( Sink()->SeekL( MStreamBuf::EWrite, TStreamPos(0) ) );
+        // Warning: assuming sink is big enough for write of whole b.
+        TRAP_IGNORE( Sink()->WriteL( b->Ptr(), b->Length() ) );
+        CleanupStack::PopAndDestroy( b );
+        // Update data part size to available data.
+        iDataPartSize = KWholeDataPart;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::OverallDataSize
+// virtual methods from MHTTPDataSupplier
+// -----------------------------------------------------------------------------
+//
+TInt CHTTPFilterDRMDataSupplier::OverallDataSize()
+    {
+    return KErrNotFound;
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::Reset
+// virtual methods from MHTTPDataSupplier
+// -----------------------------------------------------------------------------
+//
+TInt CHTTPFilterDRMDataSupplier::Reset()
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::SetContentMimeTypeL
+// Sets the MIME type of comming content - used for ringingtone functionality
+// Caller does not care about freeing this buffer, CFM
+// -----------------------------------------------------------------------------
+//
+void CHTTPFilterDRMDataSupplier::SetContentMimeTypeL( const TDesC8& aMimeType )
+    {
+    //in case someone call this function more than once
+    delete iContentMimeType;
+    iContentMimeType = NULL;
+
+    iContentMimeType = aMimeType.AllocL();
+    }
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::SetEstimatedArrivalTime
+// Sets the estimated arrival time, the x-oma-drm-separate-delivery header
+//-----------------------------------------------------------------------------
+//
+
+#ifdef __DRM_FULL
+void CHTTPFilterDRMDataSupplier::SetEstimatedArrivalTime( TInt aXOmaHeaderVal )
+    {
+    // get the data part
+    ContentAccess::CManager* manager = NULL;
+    ContentAccess::TAgent agent;
+    TRequestStatus status;
+    TInt r = KErrNone;
+    DRMCommon::TContentProtection protection;
+    HBufC8* MIMEType = NULL;
+    HBufC8* contentURI = NULL;
+    HBufC8* xomaData = NULL;
+    TUint dataLength;
+    TPtrC8 dataPart;
+    DRMCommon* drmCommon = NULL;
+
+        TRAP(r, drmCommon = DRMCommon::NewL());
+    if ( r )
+        {
+        return;
+        }
+
+    r = drmCommon->Connect();
+    if ( r )
+        {
+        delete drmCommon;
+        return;
+        }
+
+    iPHData->GetNextDataPart( dataPart );
+
+    //in case the chunk is too short engine would panic
+    if ( dataPart.Length() < KMinContentSizeToGetTheURI )
+        return;
+
+        // Find the caf agent and create manager
+        TRAP( r, manager = GetCafDataL( agent ));
+
+    // if an error occurs, return
+    if ( r )
+        {
+        delete drmCommon;
+        return;
+        }
+
+    // Get the content info, if it fails dont do anything
+    if ( drmCommon->GetContentInfo( dataPart, protection, MIMEType,
+        contentURI, dataLength ) == DRMCommon::EOk && protection
+        != DRMCommon::ENoDCFFile )
+        {
+        // Create a buffer large enough for the time and uri
+        xomaData = HBufC8::NewMax( sizeof(TInt) + contentURI->Size() );
+
+        // if the creation fails free memory and return
+        if ( !xomaData )
+            {
+            delete MIMEType;
+            delete contentURI;
+            delete manager;
+            delete drmCommon;
+            return;
+            }
+
+        // Copy the value of the xoma header:
+        Mem::Copy( const_cast<TUint8*> ( xomaData->Ptr() ), &aXOmaHeaderVal,
+            sizeof(TInt) );
+
+        // Copy the value of the uri:
+        Mem::Copy( const_cast<TUint8*> ( xomaData->Ptr() ) + sizeof(TInt),
+            contentURI->Ptr(), contentURI->Size() );
+
+        TPtr8 temp( NULL, 0, 0 );
+        TPtr8 buffer( xomaData->Des() );
+
+        // ignore any error, we couldn't do anything about it anyway
+        r = manager->AgentSpecificCommand( agent,
+            ContentAccess::ESetPendingRightsETA, buffer, temp );
+        }
+    delete MIMEType;
+    delete contentURI;
+    delete manager;
+    delete xomaData;
+    delete drmCommon;
+    }
+#else
+void CHTTPFilterDRMDataSupplier::SetEstimatedArrivalTime(TInt /*aXOmaHeaderVal*/)
+    {
+    }
+#endif
+
+// -----------------------------------------------------------------------------
+// CHTTPFilterDRMDataSupplier::SetContentMimeTypeL
+// Sets the MIME type of comming content - used for ringingtone functionality
+// Caller does not care about freeing this buffer
+// -----------------------------------------------------------------------------
+//
+ContentAccess::CManager* CHTTPFilterDRMDataSupplier::GetCafDataL(
+    TAgent& aAgent )
+    {
+    TPtr8 ptr( NULL, 0, 0 );
+    RArray<TAgent> agents;
+    TRequestStatus status;
+    TInt i;
+
+    CleanupClosePushL( agents );
+    CManager* manager = CManager::NewLC();
+
+    manager->ListAgentsL( agents );
+
+    for ( i = 0; i < agents.Count(); i++ )
+        {
+        if ( agents[i].Name().Compare( KOmaDrm2AgentName ) == 0 )
+            {
+            aAgent = agents[i];
+            break;
+            }
+        }
+    CleanupStack::Pop( manager );
+    CleanupStack::PopAndDestroy( &agents );        
+    return manager;
+    }
+
+//=============================================================================
+// TDRMMemBuf functions
+//=============================================================================
+TDRMMemBuf* TDRMMemBuf::NewL( TInt aLength )
+    {
+    TDRMMemBuf* self = new ( ELeave ) TDRMMemBuf;
+    CleanupStack::PushL( self );
+    self->ConstructL( aLength );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+TDRMMemBuf::~TDRMMemBuf()
+    {
+    delete iBuf;
+    iBuf = 0;
+    }
+
+void TDRMMemBuf::ConstructL( TInt aLength )
+    {
+    // create the buffer and set it as intermidiate
+    iBuf = HeapArray8::NewMaxL( aLength );
+    TUint8* base = ( TUint8* )( iBuf->GetPtr().Ptr() );
+    Set( base, base + aLength );
+    }
+
+void TDRMMemBuf::DoWriteL( const TAny* aPtr, TInt aLength )
+    {
+    //make sure there is enough room for writing
+    if ( iBuf->Append( ( TUint8* )aPtr, aLength ) )
+        {
+        // re-allocation happened
+        TUint8* base = ( TUint8* )( iBuf->GetPtr().Ptr() );
+        Set( base, base + iBuf->GetPtr().MaxLength() );
+        }
+    }
+
+TStreamPos TDRMMemBuf::DoSeekL( TMark aMark, TStreamLocation aLocation,
+    TInt anOffset )
+    {
+    if ( aMark == MStreamBuf::EWrite && aLocation == EStreamBeginning )
+        iBuf->GetPtr().SetLength( anOffset );
+
+    return TMemBuf::DoSeekL( aMark, aLocation, anOffset );
+    }
+
+//=============================================================================
+// HeapArray functions
+//=============================================================================
+HeapArray8* HeapArray8::NewMaxL( TInt max_ )
+    {
+    HeapArray8* self = new ( ELeave ) HeapArray8();
+    CleanupStack::PushL( self );
+    self->ConstructL( max_ );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+void HeapArray8::ConstructL( TInt max_ )
+    {
+    buf = HBufC8::NewMaxL( max_ );
+    ptr.Set( buf->Des() );
+    ptr.SetLength( 0 );
+    }
+
+HeapArray8::HeapArray8() :
+    buf( 0 ), ptr( 0, 0 )
+    {
+    }
+
+HeapArray8::~HeapArray8()
+    {
+    delete buf;
+    }
+
+TBool HeapArray8::Append( const TDesC8 &src_ )
+    {
+    return Insert( ptr.Length(), src_ );
+    }
+
+TBool HeapArray8::Insert( TInt index, const TDesC8 &src_ )
+    {
+    TInt insertLen = src_.Length();
+    TBool bRellocated = EFalse;
+
+    if ( ptr.Length() + insertLen > ptr.MaxLength() )
+        {
+        TInt oLen = ptr.Length();
+        buf = buf->ReAlloc( ptr.Length() + insertLen * 2 );
+        ptr.Set( buf->Des() );
+        ptr.SetLength( oLen );
+        bRellocated = ETrue;
+        }
+    ptr.Insert( index, src_ );
+    return bRellocated;
+    }
+
+TBool HeapArray8::Insert( TInt index, const TUint8 *src_, TInt insertLen )
+    {
+    TPtrC8 ptr( src_, insertLen );
+    return Insert( index, ptr );
+    }
+
+TBool HeapArray8::Append( const TUint8* src_, TInt len_ )
+    {
+    TPtrC8 p( src_, len_ );
+    return Insert( ptr.Length(), p );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmfilter/src/HTTPFilterDRMMain.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,37 @@
+/*
+* 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:  ?Description
+*
+*/
+
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+#include "HTTPFilterDRM.h"
+
+
+const TImplementationProxy KImplementationTable[] = 
+	{
+	#ifdef __EABI__ 
+		IMPLEMENTATION_PROXY_ENTRY(0x101F9711,CHTTPFilterDRM::InstallFilterL) 
+ 	#else
+		{{0x101F9711}, CHTTPFilterDRM::InstallFilterL}
+ 	#endif
+
+	};
+
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+	{
+	aTableCount = sizeof(KImplementationTable) / sizeof(TImplementationProxy);
+	return KImplementationTable;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrecognizer/group/RecDRM.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Symbian recognizer for OMA DRM protected files
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+target          RECDRM.DLL
+targettype      PLUGIN
+VENDORID        VID_DEFAULT
+
+UID		0x10009D8D 0x101F51F4
+
+capability	CAP_ECOM_PLUGIN TrustedUI ProtServ
+
+SOURCEPATH	    ../SRC
+USERINCLUDE     ../INC
+USERINCLUDE	    ../../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+systeminclude	/epoc32/INCLUDE/Ecom
+
+source		RECDRM.CPP
+
+START RESOURCE 101F51F4.RSS
+TARGET         RECDRM
+
+END
+
+#ifdef __DRM_OMA2
+MACRO       DRM_OMA2_ENABLED
+#endif
+
+library		EUSER.LIB	
+library		APMIME.LIB
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrecognizer/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build file for DRM Recognizer
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../Inc/RecDRM.h
+
+PRJ_MMPFILES
+
+./recdrm.mmp
+
+
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrecognizer/src/101F51F4.RSS	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* 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:  Registration data for transport framework DRM filter interface implementation collection
+*
+*/
+
+
+#include <RegistryInfo.rh>
+RESOURCE REGISTRY_INFO r_registry
+{
+	dll_uid = 0x101F51F4; 		
+interfaces =
+	{
+	INTERFACE_INFO
+		{
+		interface_uid = 0x101F7D87; // Const for all data recognizers
+		implementations =
+			{
+			IMPLEMENTATION_INFO
+				{
+				implementation_uid = 0x101F6DB8; 
+				version_no = 1;
+				display_name = "RECDRM";
+				default_data = "";  
+				opaque_data = "";
+				}
+			};
+		}
+	};
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrecognizer/src/RecDRM.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,248 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Symbian recognizer for DRM protected files
+*
+*/
+
+
+// INCLUDE FILES
+#include <apmrec.h>
+#include <apmstd.h>
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+
+#include "recdrm.h"
+
+#define RECOGNIZE_KEY_CHAIN
+
+// CONSTANTS
+const TUid KUidDRMRecognizer={ 0x101F51F4 };
+
+// Version must be 1 so that it conforms to OMA DRM 1.0 specification
+const TInt KDCFVersionSupported( 1 );
+
+// minimum size of supported mime-type
+const TInt KMinContentTypeLen( 3 );
+
+// maximum amount of buffer space we will ever use
+const TInt KMaxBufferLength=256;
+
+const TInt KDCFHeaderLength=3;
+const TInt KLengthBoxSize = 4;
+const TInt KLengthBoxType = 4;
+const TInt KLengthBoxSize64 = 8;
+const TInt KLengthVersion = 1;
+const TInt KLengthFlags = 3;
+
+_LIT8(KFTypPrefix, "ftyp");
+_LIT8(KODFPrefix, "odcf");
+_LIT8(KRoapTriggerElement, "roap-trigger:roapTrigger"); // before OMA spec CR, ROAP Trigger namespace prefix was roap-trigger 
+_LIT8(KRoapTriggerElement2, "roap:roapTrigger");
+_LIT8(KRoapTriggerType, "application/vnd.oma.drm.roap-trigger+xml");
+
+const TImplementationProxy ImplementationTable[] = 
+	    {
+	    IMPLEMENTATION_PROXY_ENTRY(0x101F6DB8, CApaDRMRecognizer::CreateRecognizerL)
+	    };
+
+#ifdef DRM_OMA2_ENABLED
+TUint32 ReadUint32FromBlock(const TDesC8& aBlock, TInt aOffset)
+    {
+    return (aBlock[aOffset] << 24) +
+        (aBlock[aOffset + 1] << 16) +
+        (aBlock[aOffset + 2] << 8) +
+        aBlock[aOffset + 3];
+    }
+
+TInt ReadIntFromBlock(const TDesC8& aBlock, TInt aOffset)
+    {
+    return (aBlock[aOffset] << 24) +
+        (aBlock[aOffset + 1] << 16) +
+        (aBlock[aOffset + 2] << 8) +
+        aBlock[aOffset + 3];
+    }
+
+TUint16 ReadUint16FromBlock(const TDesC8& aBlock, TInt aOffset)
+    {
+    return ((aBlock[aOffset] << 8) + aBlock[aOffset + 1]);
+    }
+#endif
+
+CApaDRMRecognizer::CApaDRMRecognizer():
+	CApaDataRecognizerType( KUidDRMRecognizer,CApaDataRecognizerType::ENormal )
+{
+	
+	iCountDataTypes = 0;
+	return;
+}
+
+CApaDRMRecognizer::~CApaDRMRecognizer()
+{
+}
+
+
+CApaDataRecognizerType* CApaDRMRecognizer::CreateRecognizerL()
+{
+	return new (ELeave) CApaDRMRecognizer ();
+}
+	
+
+TUint CApaDRMRecognizer::PreferredBufSize()
+{
+	return KMaxBufferLength;
+}
+
+#ifdef _DEBUG
+TDataType CApaDRMRecognizer::SupportedDataTypeL( TInt aIndex ) const
+#else
+TDataType CApaDRMRecognizer::SupportedDataTypeL( TInt /*aIndex*/ ) const
+#endif
+{
+__ASSERT_DEBUG( aIndex >= 0 && aIndex < iCountDataTypes, User::Invariant() );
+	return TDataType( _L8("application/vdn.omd.drm.content") ); // this should never be run
+}
+
+void CApaDRMRecognizer::DoRecognizeL( const TDesC& aName, const TDesC8& aBuffer )
+{
+	if ( aBuffer.Size() < 3) 
+        {
+        return;
+        }
+	
+#ifdef RECOGNIZE_KEY_CHAIN	
+	// Recognize device key chain
+	if ( aName.Length() > 3 && aName.Right(4).CompareF(_L(".dkc")) == 0)
+        {
+        iConfidence = ECertain;
+        iDataType = TDataType( _L8("application/x-device-key-chain") );
+        return;
+        }
+#endif        
+	
+#ifdef DRM_OMA2_ENABLED
+	// Recognize ROAP Trigger
+	if ( RecognizeRoapTrigger( aBuffer ) )
+        {
+        return;
+        }
+	
+	// Recognize DCFv2    
+	if ( RecognizeODF( aBuffer ) )
+        {
+        return;
+        }   
+#endif	
+	// Recognize DCFv1
+	TUint8 version = aBuffer[0];
+	TUint8 contentTypeLen = aBuffer[1];
+	TUint8 contentURILen = aBuffer[2];
+
+	if ( contentTypeLen < KMinContentTypeLen || contentURILen == 0 ) 
+	{
+		return;
+	}
+	if ( version != KDCFVersionSupported ) 
+	{
+		return;
+	}
+
+	// Too little data received
+	if ( aBuffer.Size() < ( contentTypeLen + KDCFHeaderLength ) ) 
+	{
+		return;
+	}
+
+	TPtrC8 mimeType = aBuffer.Mid( KDCFHeaderLength, contentTypeLen );
+	if ( mimeType.Locate( '/' ) != KErrNotFound )
+	{
+		iConfidence = ECertain;
+		iDataType=TDataType( mimeType );	
+	}
+	
+	
+	return;
+}
+
+#ifdef DRM_OMA2_ENABLED
+TBool CApaDRMRecognizer::RecognizeRoapTrigger( const TDesC8& aBuffer )
+{
+        if ( aBuffer.FindF( KRoapTriggerElement() ) != KErrNotFound
+             || aBuffer.FindF( KRoapTriggerElement2() ) != KErrNotFound )
+        {
+            iConfidence = ECertain;
+            iDataType=TDataType( KRoapTriggerType() );
+            return ETrue;
+        }
+	return EFalse;
+}
+
+TBool CApaDRMRecognizer::RecognizeODF( const TDesC8& aBuffer )
+{
+	if ( aBuffer.Size() < 24 ) return EFalse;
+	TPtrC8 ftypPrefix = aBuffer.Mid( 4, KFTypPrefix().Length() );
+	if ( KFTypPrefix().CompareF( ftypPrefix ) == KErrNone )
+	{
+		TPtrC8 odfPrefix = aBuffer.Mid( 8, KODFPrefix().Length() );
+		if ( KODFPrefix().CompareF( odfPrefix ) == KErrNone )
+		{
+			TBuf8<4> buffer;
+    		TUint32 size;
+    		TPtr8 ptr(NULL, 0);
+    		TUint32 offset(20);
+    
+    		// ODRM box header
+    		buffer.Zero();
+    		buffer.Copy( aBuffer.Mid( offset, 4 ));
+    		size = ReadUint32FromBlock( buffer, 0 );
+    		offset += KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags;
+    		
+    		if (size == 1)
+        	{
+        		offset += KLengthBoxSize64;
+        	}
+    		if ( aBuffer.Size() < offset+4 ) return EFalse;
+    		
+    		// Discrete headers box header
+    		buffer.Zero();
+    		buffer.Copy( aBuffer.Mid( offset, 4 ));
+    		size = ReadUint32FromBlock( buffer, 0 );
+    		offset += KLengthBoxSize + KLengthBoxType + KLengthVersion + KLengthFlags;
+    		if ( size == 1 )
+        	{
+        		offset += KLengthBoxSize64;
+        	}
+    		if ( aBuffer.Size() < offset+1 ) return EFalse;
+    		
+    		// Content type
+    		buffer.Zero();
+    		buffer.Copy( aBuffer.Mid( offset, 1 ));
+    		if ( aBuffer.Size() < offset + 1 + buffer[0] ) return EFalse;
+    		TPtrC8 mimeType = aBuffer.Mid( offset+1, buffer[0] );
+   			
+   			iConfidence = ECertain;
+			iDataType=TDataType( mimeType );
+			return ETrue;
+		}
+		
+	}
+	return EFalse;
+}
+#endif
+
+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/omadrm/drmplugins/drmrohandler/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,33 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Information required for building the required abld.bat
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../loc/rohandler.loc MW_LAYER_LOC_EXPORT_PATH( rohandler.loc )
+
+PRJ_MMPFILES
+
+#ifdef __DRM_FULL
+CRohandler.mmp
+#endif
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrohandler/group/crohandler.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,83 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  This is project specification file for the rohandler.dll
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET          RoHandler.dll
+targettype      PLUGIN
+VENDORID        VID_DEFAULT
+// uid2 specifies an ECom dll
+// uid3 specifies a unique identifier
+UID             0x10009D8D 0x101F7B92
+CAPABILITY      CAP_ECOM_PLUGIN DRM
+
+SOURCEPATH      ../src
+SOURCE          CRoHandler.cpp
+SOURCE          StringResourceReader.cpp
+SOURCE          rohandlerdmgrwrapper.cpp
+
+START RESOURCE  101F7B92.RSS
+TARGET          RoHandler
+
+END
+
+#include <data_caging_paths.hrh>
+
+START RESOURCE RoHandler.rss
+HEADER
+TARGETPATH      RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../DRMEngine/Roap/inc
+USERINCLUDE     ../../drmromtm/client/inc
+USERINCLUDE     ../../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         DrmParsers.lib
+LIBRARY         DrmDcf.lib
+LIBRARY         DrmRights.lib
+LIBRARY         DrmServerInterfaces.lib
+LIBRARY         drmroapwbxmlparser.lib // ROAP Wbxml to XML parsers
+
+LIBRARY         centralrepository.lib       // Browser default AP
+LIBRARY         cmmanager.lib
+LIBRARY         DownloadMgr.lib
+
+LIBRARY         euser.lib
+LIBRARY         ecom.lib
+LIBRARY         RoapHandler.lib
+LIBRARY         WapPushUtils.lib
+LIBRARY         msgs.lib        // for MMsvSessionObserver
+
+LIBRARY         efsrv.lib // RFs
+LIBRARY         inetprotutil.lib // TUri16 and so on
+LIBRARY         bafl.lib // RResourceFile
+LIBRARY         flogger.lib
+LIBRARY         sysutil.lib // SysUtil
+LIBRARY         esock.lib
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY         platformenv.lib
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrohandler/inc/CRoHandler.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,249 @@
+/*
+* Copyright (c) 2004-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM plugin for receiving OMA Rights Objects
+*
+*/
+
+
+#ifndef CROHANDLER_H
+#define CROHANDLER_H
+
+//  INCLUDES
+#include <mtclreg.h>                // for CClientMtmRegistry
+#include "RoapEngBase.h"
+#include "wbxmlroaptriggerparser.h"
+
+// CONSTANTS
+const TUid KUidMsgTypeRO = {0x101F6DC2};
+const TInt KWait = 5*60*1000000;  // Timeout value to be used for waiting in "disk full" situation
+
+enum TMessageType
+    {
+    EOma1Ro,
+    EOma2RoapPdu,
+    EOma2RoapTrigger,
+    EOma2RoapTriggerRoAcquisition,
+    EOma2RoapTriggerMetering
+    };
+
+// MACROS
+
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+class CDRMMessageParser;
+
+
+// CLASS DECLARATION
+
+// DESCRIPTION
+//  ECOM listener plugin for DRM server.
+//  Plugin is instantiated by the wap listener in the system watcher.
+//  It delivers rights object to DRM server.
+
+class CRoHandler
+        : public CPushHandlerBase , public MMsvSessionObserver
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Destructor
+        */
+        ~CRoHandler();
+
+        /**
+        * Default 1st phase factory method.
+        * returns created instance of the CRoHandler class
+        */
+        static CRoHandler* NewL();
+
+        /**
+        * Method for handling a received message asynchronously.
+        * param aPushMsg object representing the received push message
+        * param aStatus Status of the asynchronous call
+        */
+        void HandleMessageL( CPushMessage* aPushMsg, TRequestStatus& aStatus );
+
+        /**
+        * Method for handling a received message synchronously.
+        * param aPushMsg object representing the received push message
+        */
+        void HandleMessageL( CPushMessage* aPushMsg );
+
+        /**
+        * Cancels the requested asynchronous message handling.
+        */
+        void CancelHandleMessage();
+
+    protected:  // Functions from base classes
+
+        /**
+        * Performs operations needed for cancelling the message handling.
+        * Called by the Active Scheduler after user calling Cancel().
+        */
+        void DoCancel();
+
+        /**
+        * Performs the actual tasks related to message handling.
+        * Called by the Active Scheduler.
+        */
+        void RunL();
+
+        /**
+        * Performs error handling tasks in case RunL() left.
+        * Called by the Active Scheduler.
+        * Currently does nothing.
+        * param aError specifies the error code related to RunL()'s leave.
+        * return error value after error handling.
+        */
+        TInt RunError( TInt aError );
+
+    private:    // New functions
+
+        /**
+        * Default constructor.
+        */
+        CRoHandler();
+
+        /**
+        * 2nd phase constructor.
+        */
+        void ConstructL();
+
+        /**
+        * Performs basic sanity checks for the received message.
+        * Only the body is checked since header is not of interest to us.
+        * @return standard error code
+        */
+        TInt PerformChecks();
+
+        TMessageType CheckMessageTypeL();
+
+        void HandleRightsMessageL();
+
+        void HandleRoapPduL();
+
+        void HandleRoapTriggerL();
+
+        void HandleMeteringTriggerSilentlyL();
+
+
+        /**
+        * Creates new empty message.
+        */
+        TMsvId CreateNewMessageL();
+
+        /**
+        * Set message entry.
+        */
+        void SetEntryL( TMsvId aEntryId );
+
+        /**
+        * Moves message entry.
+        */
+        TMsvId MoveMessageEntryL( TMsvId aTarget );
+
+        /**
+        * Adds content to the message.
+        */
+        void AddRoContentL( TDesC& aMessageContent );
+
+    private:    // Functions from base classes
+
+        /**
+        * Reserved for future expansion.
+        */
+        void CPushHandlerBase_Reserved1();
+
+        /**
+        * Reserved for future expansion.
+        */
+        void CPushHandlerBase_Reserved2();
+
+        HBufC* ConvertDetailsL( const TDesC8& aFrom );
+
+        HBufC* GetDetailLC();
+
+        HBufC* GetDescriptionLC();
+
+        void ReadFromResourceLC(
+            const TDesC& aFile ,
+            const TInt& aIndex ,
+            HBufC*& aBuf );
+
+        HBufC* ConvertUriToDisplayFormL( const TDesC& aUri );
+
+        /**
+         * Do a synchronous ROAP request.
+         *
+         * @since S60 3.1
+         * @param aTrigger ROAP Trigger
+         * @return ETrue if the ROAP could be started silently, EFalse otherwise (e.g. when
+         *         no RI context exists)
+         */
+        TBool DoRoapL( const TDesC8& aTrigger );
+
+    private: // from MMsvSessionObserver
+
+        /**
+        * Handles session events.
+        */
+        void HandleSessionEventL( TMsvSessionEvent aEvent,
+                                  TAny* aArg1, TAny* aArg2,
+                                  TAny* aArg3 );
+
+        enum TState
+            {
+            ERunning,
+            EFileSystemWait
+            };
+
+        // internal state
+        TState iState;
+        // message type
+        TMessageType iMsgType;
+        // flag to handle message one time.
+        TBool iFirstTime;
+        // uid of the ro handler
+        enum { RoHandlerUid = 0x101F7B92 };
+        // Pushed message
+        CPushMessage* iPushMsg;
+        // The body of the pushed message as HBufC8 descriptor
+        // api to store the OMA 1 RO
+        CDRMMessageParser* iMessageParser;
+        // pointer to message body
+        TPtrC8 iMessageBodyPtr;
+        CMsvSession* iSession;          // Client session on the message server
+        CBaseMtm* iMtm;                 // Message Type Module (sms)
+        CClientMtmRegistry* iMtmReg;    // Mtm client registry for creating new mtms
+        TMsvId iMsvId;                  // message server entry id
+        RFs iFs;
+        Roap::CRoapEngBase* iRoapHandler;
+
+        TBool iMeteringSupported;       // state variable showing whether
+                                        // metering is supported or not
+                                        // initialised at instantiation
+        DRM::CWbxmlRoapTriggerParser* iWbxmlTriggerParser;
+        HBufC8* iParsedXmlTrigger;
+        TBool iPutRightsToInbox;         // whether received RO is put into Inbox as an
+                                        // entry or not. Initialized at instantiation.
+                                        
+    };
+
+#endif CROHANDLER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrohandler/inc/StringResourceReader.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*      Declaration of CStringResourceReader.
+*      
+*
+*/
+
+
+#ifndef STRINGRESOURCEREADER_H
+#define STRINGRESOURCEREADER_H
+
+// INCLUDE FILES
+
+#include <e32base.h>
+#include <e32std.h>
+#include <barsc.h>
+
+// FORWARD DECLARATIONS
+
+class RFs;
+
+// CLASS DECLARATION
+
+/**
+* Utility class that helps reading string resources without CONE.
+* Not intended for derivation.
+*/
+class CStringResourceReader : public CBase
+    {
+    public: // Constructors and destructor
+
+        CStringResourceReader( RFs& aFs, const TDesC& aRscFileWithPathAndDrive );
+
+        ~CStringResourceReader();
+
+    public: // New functions
+
+        /**
+        * Return a given string from resource.
+        * @param aResId Resource ID.
+        * @return See above.
+        */
+        HBufC* AllocReadResourceL( TInt aResId );
+
+    private: // New functions
+
+        void InitializeL();
+
+    private: // Data members
+
+        RFs& iFs;                ///< File server session.
+        TBuf<256> iRscFileName;
+        RResourceFile iResourceFile;
+        TBool iInitialized;
+    };
+
+#endif // STRINGRESOURCEREADER_H
+
+// End of file.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrohandler/inc/rohandlerdmgrwrapper.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,292 @@
+/*
+* 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:  Wrapper class for ROAP trigger download via DL mananger
+*
+*/
+
+
+#ifndef ROHANDLERDMGRWRAPPER_H
+#define ROHANDLERDMGRWRAPPER_H
+
+namespace Roap
+    {
+    class MRoapObserver;
+    }
+
+class CDRMRights;
+
+class MHttpDownloadMgrObserver;
+
+class MRoHandlerDMgrWrapper
+    {
+
+public:
+    virtual void HandleRoapTriggerL( const TDesC8& aTrigger ) = 0;
+
+    virtual void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl ) = 0;
+
+    virtual void DownloadAndHandleRoapTriggerFromPrUrlL( const HBufC8* aUrl ) = 0;
+
+    };
+
+/**
+*  Class for downloading ROAP triggers
+*
+*/
+class CRoHandlerDMgrWrapper:
+    public CActive, // Now active
+    public MHttpDownloadMgrObserver,
+    public Roap::MRoapObserver,
+    public MRoHandlerDMgrWrapper
+    {
+private:
+    enum TMeterState
+        {
+        EInit,
+        EGetMeteringTrigger,
+        ESaveMeteringTrigger,
+        EMeteringReportSubmit,
+        EGetPrUrlTrigger,
+        ESavePrUrlTrigger,
+        EPrRoapRequest,
+        EComplete
+        };
+public:
+
+    static CRoHandlerDMgrWrapper* NewL();
+
+    static CRoHandlerDMgrWrapper* NewLC();
+
+    virtual ~CRoHandlerDMgrWrapper();
+
+    /**
+    * Download a ROAP trigger from URL and handle it
+    *
+    * @since S60 3.2
+    * @param aUrl  URL of ROAP trigger
+    */
+    void HandleRoapTriggerL( const TDesC8& aTrigger );
+
+    void DownloadAndHandleRoapTriggerL( const HBufC8* aUrl );
+
+    void DownloadAndHandleRoapTriggerFromPrUrlL( const HBufC8* aUrl );
+
+
+// from base class MHttpDownloadMgrObserver
+
+    /**
+    * From MHttpDownloadMgrObserver.
+    * Handle download manager events
+    *
+    * @since S60 3.2
+    * @param aDownload the download
+    * @param aEvent the event
+    */
+    void HandleDMgrEventL( RHttpDownload& aDownload, THttpDownloadEvent aEvent );
+
+// From Roap::MRoapObserver
+    /**
+    * ConnectionConfL
+    * @return ETrue: the network can be establish
+    *         EFalse: the ROAP transaction is canceled
+    *
+    * @leave  System wide error code */
+    TBool ConnectionConfL();
+
+    /**
+    * ContactRiConfL
+    * @return ETrue: the user consent is achieved
+    *         EFalse: the user consent is not achieved
+    *
+    * @leave  System wide error code */
+    TBool ContactRiConfL();
+
+    /**
+    * TransIdConfL
+    * @return ETrue: the user consent is achieved
+    *         EFalse: the user consent is not achieved
+    *
+    * @leave  System wide error code */
+
+    TBool TransIdConfL();
+
+    /**
+    * RightsObjectDetailsL
+    *
+    * The function is called after successful completion of RO acquisition
+    * protocol. The passes information about stored rights objects to the
+    * observer.
+    *
+    * @since  3.0
+    * @param aRightsList: A list of pointers to rights objects.
+    *                     Contents of aRightsList are owend by ROAP engine
+    *
+    * @leave  System wide error code */
+    void RightsObjectDetailsL( const RPointerArray<CDRMRights>& aRightsList );
+
+    /**
+    * ContentDownloadInfoL
+    *
+    * The function is called when the ROAP engine notices that it is about to
+    * receive a multipart content as a ROAP response. The method must return via
+    * out-parameter the path to a temp folder where the content is saved during
+    * download. The name that is used as filename when saving the content to
+    * the appropriate palce and the maximum size of the content (a safety upper limit)
+    * must also be provided via out-parameters.
+    *
+    * @since 3.0
+    * @param aTempFolder: (out-param) The path of the temp folder, or KNullDesC
+    * @param aContentName: (out-param) The name of the content, or KNullDesC (defaut name is used)
+    * @param aMaxSize: (out-param) The maximum size of the content, or -1 if not known
+    *
+    * @leave System wide error code */
+
+    void ContentDownloadInfoL( TPath& aTempFolder,
+            TFileName& aContentName,
+            TInt& aMaxSize );
+
+    /**
+    * ContentDetailsL
+    *
+    * The function is called when the ROAP engine has received a DCF content (together
+    * with a ROAP response) The ROAP engine saves the DCF to the appropriate location
+    * and gives out the information about the saved DCF file by calling this method
+    *
+    * @since 3.0
+    * @param aPath: The path andf the filename of the saved DCF file
+    * @param aType: The plain MIME type of the saved DCF file
+    * @param aAppUid: The handler app UID of the saved DCF file
+    *
+    * @leave System wide error code */
+
+    void ContentDetailsL( const TDesC& aPath,
+            const TDesC8& aType,
+            const TUid& aAppUid );
+
+    /**
+    * RoapProgressInfoL
+    *
+    * The function provides progress information about ROAP processing to the
+    * observer
+    *
+    * @since  3.0
+    * @param aProgressInfo: An integer value representing the state of
+    *                       ROAP processing, counting in bytes
+    *
+    * @leave  System wide error code */
+
+    void RoapProgressInfoL( const TInt aProgressInfo );
+
+    /**
+    * ErrorUrlL
+    *
+    * The function is called in ROAP error case and it provides an error URL
+    * for the caller. The calling entity should send an HTTP GET request to
+    * the URL which should then return an HTML page.
+    *
+    * @since  3.0
+    * @param aErrorUrl: The error URL
+    *
+    *
+    * @leave  System wide error code */
+
+    void ErrorUrlL( const TDesC8& aErrorUrl );
+
+    /**
+    * PostResponseUrlL
+    *
+    * The function is called if handled ROAP metering report response
+    * contains PostResponseURL extension. The calling entity should send
+    * an HTTP GET request to the URL, which should return ROAP trigger,
+    * download descriptor or multipart message containing both
+    * download descriptor and ROAP trigger.
+    *
+    * @since  3.2
+    * @param aPostResponseUrl: The URL to be fetched
+    *                          after handling ROAP metering response
+    *                          with PostResponseURL extension.
+    *
+    *
+    * @leave  System wide error code */
+    void PostResponseUrlL( const TDesC8& aPostResponseUrl );
+
+protected:
+    //from Cactive
+    virtual void DoCancel();
+
+    virtual void RunL();
+
+    virtual TInt RunError( TInt aError );
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CRoHandlerDMgrWrapper();
+
+    void ConstructL();
+
+    /**
+    * Set the browser default access point to be used
+    *
+    * @since S60 3.0
+    */
+    void SetDefaultAccessPointL();
+
+    void DoDownloadRoapTriggerL( TMeterState aNextState );
+
+    void DoSaveRoapTriggerL( TMeterState aNextState );
+
+    void DoHandleRoapTriggerL( TMeterState aNextState );
+
+    void Continue( TMeterState aNextState, TInt aError );
+private: // data
+
+    /**
+    * Download manager session
+    */
+    RHttpDownloadMgr iDlMgr;
+
+    /**
+    * Used to make downloads synchronous
+    */
+    CActiveSchedulerWait iWait;
+
+    /**
+    * to store information on download
+    */
+    TBool iDownloadSuccess;
+    TBool iConnectionError;
+
+    /**
+    * Post response url for ROAP prUrl, ()
+    */
+    HBufC8* iTriggerUrl;
+
+    HBufC8* iTriggerBuf;
+    /**
+    * IAP (from ROAP or from UI)
+    */
+    TUint32 iIapId;
+
+    TMeterState iState;
+
+    Roap::CRoapEng* iRoapEng;
+
+    RFs iFs;
+
+    HBufC* iFileName;
+    };
+
+#endif // ROHANDLERDMGRWRAPPER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrohandler/inc/rohandlerinternalcrkeys.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,30 @@
+/*
+* 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:  Handling RO entry visibility in Inbox
+*
+*/
+
+
+
+#ifndef ROHANDLERINTERNALCRKEYS_H
+#define ROHANDLERINTERNALCRKEYS_H
+
+const TUid KCRUidRoHandler = {0x200195AD};
+
+/* Stores the information whether received RO should be visible in the
+   inbox or not */
+const TUint32 KDRMRoHandlerInboxEntryVisible = 0x00000001;
+
+#endif      // ROHANDLERINTERNALCRKEYS_H
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrohandler/loc/RoHandler.loc	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     This file contains the localised strings for RO Handler
+*
+*
+*/
+
+
+//  LOCALISATION STRINGS
+
+//
+// NOTE: Exact layout information syntax for logical names has not been
+//       decided/approved yet.
+//
+
+
+// d: Second line of the Inbox list item
+// l: list_double_graphic_pane_t2_cp2
+// w:
+// r: 3.0
+//
+#define qtn_drm_mgr_inb_title			"Usage rights"
+
+//d: Second line of the Inbox list item
+//d: Shown when device is joining to account or leaving from account.
+//l: list_double_graphic_pane_t2_cp2
+//w:
+//r: 3.0
+//
+#define qtn_drm_roap_trigger_msg_domain "Account configuration"
+
+// End of File
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrohandler/src/101F7B92.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource file needed by ECOM framework
+*
+*/
+
+
+//  RESOURCE IDENTIFIER
+NAME    RO
+
+//  INCLUDES
+#include <ecom/registryinfo.rh>
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+//   
+// RoHandlerInformation
+// This data structure specifies mappings and information needed by
+// the ECOM framework.
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE REGISTRY_INFO RoHandlerInformation
+    {
+    // rohandler.dll's uid3)
+    dll_uid = 0x101F7B92;
+    interfaces = 
+        {
+        INTERFACE_INFO
+            {
+            // KUidPushHandlerBase - CPushHandlerBase UID
+            interface_uid = 0x101F3E5A;
+            implementations = 
+                {
+                IMPLEMENTATION_INFO
+                    {
+                    // RoHandler's implementationUID
+                    implementation_uid = 0x101F7B93;
+                    version_no = 1;
+                    display_name = "CRoHandler||Implements a WAP Push Rights Object Handler Plug-in||Copyright © 2002 Nokia Ltd. All rights reserved.";
+                    default_data = "x-wap-application:drm.ua||0x00000008";
+                    opaque_data = "";
+                    }
+                };
+            }
+        };
+    }
+           
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrohandler/src/CRoHandler.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1773 @@
+/*
+* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ECOM plugin for receiving OMA Rights Objects
+*
+*/
+
+
+// INCLUDE FILES
+#include <txtrich.h>                    // for CRichText
+#include <drmmessageparser.h>           // for CDrmMessageParser
+#include <drmrights.h>                  // for CDRMRights
+#include <ecom/implementationproxy.h>   // for TImplementationProxy
+#include <push/cpushhandlerbase.h>      // for CPushHandlerBase
+#include <push/pluginkiller.h>          // for CPluginKiller
+#include <push/pushmessage.h>           // for CPushMessage
+#include <roapeng.h>                    // for CRoapEng
+#include <roapengbase.h>
+#include <roapobserver.h>
+#include <centralrepository.h>          // link against centralrepository.lib
+#include <msvuids.h>
+#include <msvids.h>
+#include <downloadmgrclient.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <driveinfo.h>
+#endif
+
+#include <uri16.h>                          // TUriParser16
+#include <data_caging_path_literals.hrh>    // KDC_MTM_RESOURCE_DIR
+#include <uriutils.h>                       // UriUtils and so on
+#include <pushmtmui.rsg>                    // for R_PUSHMISC_UNK_SENDER
+#include <rohandler.rsg>                    // for R_QTN_DRM_MGR_INB_TITLE
+#include <sysutil.h>                        // Disk space checking
+
+#include "crohandler.h"
+#include "romtmcli.h"                       // for CRightsObjectMtmClient
+#include "roapsyncwrapper.h"
+
+#include "stringresourcereader.h"
+#include "rohandlerdmgrwrapper.h"
+#include "rohandlerinternalcrkeys.h"
+
+#ifdef _DEBUG
+#define DRMDEBUGLIT( a, b ) _LIT( a, b )
+#define DRMDEBUG( a ) RDebug::Print( a )
+#define DRMDEBUG2( a, b ) RDebug::Print( a, b )
+_LIT( KRoLogDir, "DRM" );
+_LIT( KRoLogFile, "RoHandler.log" );
+#define LOG( a ) RFileLogger::Write( KRoLogDir(), KRoLogFile(), EFileLoggingModeAppend, a );
+#define LOGHEX( ptr, len ) RFileLogger::HexDump( \
+    KRoLogDir(), KRoLogFile(), EFileLoggingModeAppend, _S(""), _S(""), ptr, len );
+#define LOG2( a, b ) RFileLogger::WriteFormat( \
+    KRoLogDir(), KRoLogFile(), EFileLoggingModeAppend, a, b );
+#else
+#define DRMDEBUGLIT( a, b )
+#define DRMDEBUG( a )
+#define DRMDEBUG2( a, b )
+#define LOG( a )
+#define LOGHEX( ptr, len )
+#define LOG2( a, b )
+#endif
+
+using namespace Roap;
+
+
+// EXTERNAL DATA STRUCTURES
+
+// EXTERNAL FUNCTION PROTOTYPES
+
+// CONSTANTS
+const TImplementationProxy ImplementationTable[] =
+    {
+    IMPLEMENTATION_PROXY_ENTRY(0x101F7B93, CRoHandler::NewL)
+    //{{0x101F7B93}, CRoHandler::NewL}
+    };
+
+// For reading the string value of cenrep key Inbox entry visible (for
+// received RO). The size of string "false" is 5.
+const TInt KBooleanStringMaxSize = 5;
+
+// MACROS
+
+// LOCAL CONSTANTS AND MACROS
+
+#ifdef RD_MULTIPLE_DRIVE
+_LIT( KRoHandlerTriggerFilePath, "%c:\\system\\data\\" );
+#else
+_LIT( KDriveZ, "z:" );
+_LIT( KRoHandlerTriggerFilePath, "c:\\system\\data\\" );
+#endif
+
+_LIT( KPushMtmRes, "PushMtmUi.rsc" );
+_LIT( KRoHandlerResourceFile, "RoHandler.rsc" );
+
+_LIT8( KRoapTriggerElement, "roapTrigger" );
+_LIT8( KWbxmlRoapTriggerElement, "\x03\x13j" );
+_LIT8( KRoapTriggerRoAcquisition, "roAcquisition" );
+_LIT8( KRoapTriggerMeteringReport, "meteringReport" );
+_LIT8( KRoapRoPduElement, "roResponse" );
+
+_LIT( KFalse, "false" );
+_LIT( KZero, "0" );
+
+_LIT( KRoAcquisitionPrefix, "ROA:" );
+_LIT( KTriggerPrefix, "TRI:" );
+
+// MODULE DATA STRUCTURES
+
+// Helper class for deleting file with given filename on cleanupstack
+// Note does not own its members
+// Used for cleaning up saved trigger if creating trigger related message
+// inbox entry fails.
+NONSHARABLE_CLASS( CFileDeleter ) : public CBase
+    {
+public:
+    static CFileDeleter* NewLC( RFs& aFs, TFileName& aFileName )
+        {
+        CFileDeleter* self( new ( ELeave ) CFileDeleter( aFs, aFileName ) );
+        CleanupStack::PushL( self );
+        return self;
+        }
+
+    inline void SetDelete()
+        {
+        iDeleteFileOnDestroy = ETrue;
+        }
+
+    inline void SetNoDelete()
+        {
+        iDeleteFileOnDestroy = EFalse;
+        }
+
+    virtual ~CFileDeleter()
+        {
+        if ( iDeleteFileOnDestroy )
+            {
+            iFs.Delete( iFileName );
+            }
+        }
+
+private:
+    CFileDeleter()
+        {
+        }
+    CFileDeleter( const CFileDeleter& )
+        {
+        }
+    CFileDeleter( RFs& aFs, TFileName& aFileName )
+        : iFs( aFs ), iFileName( aFileName )
+        {
+        }
+
+    CFileDeleter& operator=( const CFileDeleter& );
+
+    TBool iDeleteFileOnDestroy;
+    RFs iFs;
+    TFileName iFileName;
+    };
+
+// LOCAL FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text, RFs &aFs );
+LOCAL_C void WriteFileL( const TDesC8& text, RFs &aFs, const TDesC& aName );
+LOCAL_C void CreateLogL();
+LOCAL_C void WriteL( const TDesC8& aText );
+LOCAL_C void WriteL( const TDesC& aText );
+LOCAL_C void WriteL( const TDesC8& aText, TInt aErr );
+LOCAL_C void WriteL( const TDesC& aText, TInt aErr );
+LOCAL_C void WriteCurrentTimeL();
+#endif
+
+// -----------------------------------------------------------------------------
+// Testing stuff
+// -----------------------------------------------------------------------------
+//
+
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text, RFs &aFs )
+    {
+    _LIT( KLogFile, "c:\\CROHandler.txt" );
+    WriteFileL( text, aFs, KLogFile );
+    }
+
+LOCAL_C void WriteFileL( const TDesC8& text, RFs &aFs, const TDesC& aName )
+    {
+    RFile file;
+    TInt size;
+    User::LeaveIfError( file.Open( aFs, aName, EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy( &file );
+    }
+
+LOCAL_C void CreateLogL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    RFile file;
+    User::LeaveIfError( file.Replace( fs, _L( "c:\\CROHandler.txt" ), EFileWrite ) );
+    file.Close();
+    CleanupStack::PopAndDestroy( &fs );
+    }
+
+LOCAL_C void WriteL( const TDesC& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    HBufC8* text = HBufC8::NewLC( 1000 );
+    TPtr8 textptr( text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8( "\r\n" ) );
+    WriteLogL( textptr, fs );
+    CleanupStack::PopAndDestroy( text );
+    CleanupStack::PopAndDestroy( &fs );
+    WriteCurrentTimeL();
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    HBufC8* text = HBufC8::NewLC( 1000 );
+    TPtr8 textptr( text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8( "\r\n" ) );
+    WriteLogL( textptr, fs );
+    CleanupStack::PopAndDestroy( text );
+    CleanupStack::PopAndDestroy( &fs );
+    WriteCurrentTimeL();
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText, TInt aErr )
+    {
+    _LIT8( KErr, ": %d" );
+    HBufC8* text = HBufC8::NewLC( 1000 + 20 );
+    TBuf8<20> num;
+    TPtr8 textptr( text->Des() );
+    textptr.Append( aText );
+    num.Format( KErr(), aErr );
+    textptr.Append( num );
+    WriteL( textptr );
+    CleanupStack::PopAndDestroy( text );
+    }
+
+LOCAL_C void WriteL( const TDesC& aText, TInt aErr )
+    {
+    _LIT8( KErr, ": %d" );
+    HBufC8* text = HBufC8::NewLC( 1000+20 );
+    TBuf8<20> num;
+    TPtr8 textptr( text->Des() );
+    textptr.Append( aText );
+    num.Format( KErr(), aErr );
+    textptr.Append( num );
+    WriteL( textptr );
+    CleanupStack::PopAndDestroy( text );
+    }
+
+LOCAL_C void WriteCurrentTimeL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    HBufC8* text = HBufC8::NewLC( 100 );
+    TPtr8 textptr( text->Des() );
+    // Date and Time display
+    TTime time;
+    time.HomeTime();
+    TBuf<256> dateString;
+    _LIT( KDate, "%*E%*D%X%*N%*Y %1 %2 '%3" );
+    time.FormatL( dateString, KDate );
+    textptr.Append( _L( "\r\n\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT( KTime, "%-B%:0%J%:1%T%:2%S%:3%+B" );
+    time.FormatL( dateString, KTime );
+    textptr.Append( _L( "\r\n\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append( _L( "\r\n" ) );
+    textptr.Append( _L( "\r\n" ) );
+    WriteLogL( textptr, fs );
+    CleanupStack::PopAndDestroy( text );
+    CleanupStack::PopAndDestroy( &fs );
+    }
+#endif
+
+
+// ----------------------------------------------------------------------------
+// DoResetAndDestroy
+// Does RPointerArray< >->ResetAndDestroy() for the given array aPtr.
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void DoResetAndDestroy( TAny* aPtr )
+    {
+    ( reinterpret_cast< RPointerArray< CDRMRights >* >( aPtr ) )->ResetAndDestroy();
+    delete aPtr;
+    aPtr = NULL;
+    }
+
+// ----------------------------------------------------------------------------
+// LeaveIfNullL
+// Leaves with given error or with KErrArgument if aBuf is null
+// ----------------------------------------------------------------------------
+//
+LOCAL_C inline void LeaveIfNullL( const TInt aRet, const HBufC8* aBuf )
+    {
+    if ( !aBuf )
+        {
+        User::LeaveIfError( aRet );
+        User::Leave( KErrArgument );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// IsMeteringSupported
+// ----------------------------------------------------------------------------
+//
+LOCAL_C TBool IsMeteringSupported()
+    {
+#ifdef RD_DRM_METERING
+    return ETrue;
+#else
+    return EFalse;
+#endif
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: NewL
+
+    Description: 1st phase constructor
+
+    Return Value: new CRoHandler
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+CRoHandler* CRoHandler::NewL
+        (
+        //None.
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, CreateLogL() );
+    TRAP( r, WriteL( _L8( "NewL" ) ) );
+#endif
+    CRoHandler* self( new( ELeave ) CRoHandler() );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "NewL-End" ) ) );
+#endif
+    return self;
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: CRoHandler
+
+    Description: C++ default constructor. Initialises the object
+                 with zero/NULL values.
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+CRoHandler::CRoHandler
+        (
+        //None.
+        )
+    : CPushHandlerBase(),
+    iFirstTime( ETrue ), iPushMsg( NULL ), iMsvId( NULL ),
+    iPutRightsToInbox( ETrue )
+    {
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: ConstructL
+
+    Description: Adds the AO to the Active Scheduler. Constructs iDrm object
+                 then connects to drm server
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+void CRoHandler::ConstructL
+        (
+        //None.
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "ConstructL" ) ) );
+#endif
+
+    CRepository* repository( NULL );
+    TInt err( KErrNone );
+
+    User::LeaveIfError( iFs.Connect() );
+
+    // create drm
+    iMessageParser = CDRMMessageParser::NewL();
+
+    // Create wbxml trigger parser instance
+    iWbxmlTriggerParser = DRM::CWbxmlRoapTriggerParser::NewL();
+
+    // Create CMsvSession
+    // new session is opened Synchronously
+    iSession = CMsvSession::OpenSyncL( *this );
+
+    iMtmReg = CClientMtmRegistry::NewL( *iSession );
+
+    // Check if metering feature is active
+    iMeteringSupported = IsMeteringSupported();
+
+    // Check cenrep key in order to find out whether received RO
+    // should be stored to inbox or not.
+    TRAP( err, repository = CRepository::NewL( KCRUidRoHandler ) );
+    if ( !err )
+        {
+        CleanupStack::PushL( repository );
+        TBuf<KBooleanStringMaxSize> string;
+        TInt error = repository->Get( KDRMRoHandlerInboxEntryVisible,
+        string );
+
+        // If the value of the repository key is found either "false" or
+        // "0", do not store rights to an Inbox entry.
+        if ( ( string.CompareF( KFalse ) == 0 ) ||
+            ( string.CompareF( KZero ) == 0 ) )
+        {
+        iPutRightsToInbox = EFalse;
+        }
+
+    CleanupStack::PopAndDestroy( repository );
+        }
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "Repository->Get done" ), iPutRightsToInbox ) );
+    TRAP( r, WriteL( _L8( "ConstructL-End" ) ) );
+#endif
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: ~CRoHandler
+
+    Description: Calls also baseclass destructor which calls
+                 REcomSession::DestroyedImplementation( iDtor_ID_Key).
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+CRoHandler::~CRoHandler
+        (
+        //None.
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "~CRoHandler" ) ) );
+#endif
+
+    iFs.Close();
+    // Delete the necessary instance attributes
+    delete iPushMsg;
+    delete iMessageParser;
+    delete iWbxmlTriggerParser;
+    delete iParsedXmlTrigger;
+    delete iMtm;
+    delete iMtmReg;
+
+    iMsvId = NULL;
+
+    // session must be deleted last (and constructed first)
+    delete iSession;
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "~CRoHandler-End" ) ) );
+#endif
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: AddRoContentL
+
+    Description: Adds Message content and number
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+void CRoHandler::AddRoContentL
+        (
+        TDesC& aMessageContent             //message content descriptor
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "AddRoContentL" ) ) );
+#endif
+    TMsvEntry msvEntry( ( iMtm->Entry() ).Entry() );
+
+    // We get the message body from Mtm and insert a bodytext
+    CRichText& mtmBody( iMtm->Body() );
+    mtmBody.Reset();
+    mtmBody.InsertL( 0, aMessageContent ); // insert our msg tag as the body text
+
+    // set iRecipient into the Details of the entry
+    msvEntry.SetNew( ETrue );              // set New
+    msvEntry.SetUnread( ETrue );
+    msvEntry.SetVisible( ETrue );
+    msvEntry.SetInPreparation( EFalse );   // set inPreparation to false
+    msvEntry.iDate.UniversalTime();        // set time to Universal Time
+
+    // To handle the sms specifics we start using SmsMtm
+    CRightsObjectMtmClient* roMtm( NULL );
+    roMtm = static_cast< CRightsObjectMtmClient* >( iMtm );
+
+    // save message
+    CMsvEntry& entry( iMtm->Entry() );
+    entry.ChangeL( msvEntry );             // make sure that we are handling the right entry
+    roMtm->SaveMessageL();                 // closes the message
+
+    // This moves the message entry to Inbox
+    MoveMessageEntryL( KMsvGlobalInBoxIndexEntryId );
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "AddRoContentL-End" ) ) );
+#endif
+    }
+
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: HandleSessionEventL
+
+    Description: Starts the message handling procedure asynchronously.
+                 Basically all the work is done in RunL method.
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+void CRoHandler::HandleSessionEventL
+        (
+        TMsvSessionEvent /* aEvent*/ ,
+        TAny* /* aArg1*/ ,
+        TAny* /* aArg2 */,
+        TAny* /* aArg3 */
+        )
+    {
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: HandleMessageL
+
+    Description: Asynchronous version of the HandleMessageL().
+                 NOT SUPPORTED
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+void CRoHandler::HandleMessageL
+        (
+        CPushMessage* aPushMsg,  // push message
+        TRequestStatus& aStatus  // status of the request
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "HandleMessageL(2)" ) ) );
+#endif
+    iPushMsg = aPushMsg;
+    SetConfirmationStatus( aStatus );
+    SignalConfirmationStatus( KErrNotSupported );
+    iPluginKiller->KillPushPlugin();
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "HandleMessageL(2)-End" ) ) );
+#endif
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: HandleMessageL
+
+    Description: Synchronous version of the HandleMessageL().
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+void CRoHandler::HandleMessageL
+        (
+        CPushMessage* aPushMsg // push message
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "HandleMessageL(1)" ) ) );
+#endif
+    iPushMsg = aPushMsg;
+    //
+    // Do sanity checks for the message.
+    //
+    User::LeaveIfError( PerformChecks() );
+    iMsgType = CheckMessageTypeL();
+    switch( iMsgType )
+        {
+        case EOma1Ro:
+            {
+            HandleRightsMessageL();
+            break;
+            }
+#ifdef __DRM_OMA2
+        case EOma2RoapTrigger:
+        case EOma2RoapTriggerRoAcquisition:
+            {
+            HandleRoapTriggerL();
+            break;
+            }
+        case EOma2RoapTriggerMetering:
+            {
+            HandleMeteringTriggerSilentlyL();
+            break;
+            }
+        case EOma2RoapPdu:
+            {
+            HandleRoapPduL();
+            break;
+            }
+#endif
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            }
+        }
+
+    iPluginKiller->KillPushPlugin();
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "HandleMessageL(1)-End" ) ) );
+#endif
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: HandleRightsMessageL
+
+    Description: Process rights object and
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+
+void CRoHandler::HandleRightsMessageL()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "HandleRightsMessageL" ) ) );
+#endif
+
+    HBufC16 *number( NULL );
+    HBufC16 *messageContent( NULL );
+    HBufC16* buffer( NULL );
+
+    TInt ret( 0 );
+    if ( iMessageBodyPtr.Size() == 0 )
+        {
+        User::Leave( KErrCorrupt );
+        }
+
+    // Heap desc contains Content URI
+    HBufC8* contentURI( NULL );
+    TUint32 localId( 0 );
+    RPointerArray< CDRMRights >*
+        rights( new ( ELeave ) RPointerArray< CDRMRights > );
+
+    if ( rights )
+        {
+        // process rights
+        ret = iMessageParser->ProcessRightsObject( iMessageBodyPtr, *rights );
+        }
+    else
+        {
+        User::Leave( KErrNoMemory );
+        }
+
+    if ( !ret && rights->Count() )
+        {
+        TCleanupItem cleanup( DoResetAndDestroy, rights );
+        CleanupStack::PushL( cleanup );
+        ret = ( *rights )[ 0 ]->GetContentURI( contentURI );
+        // null contentURI means invalid RO
+        LeaveIfNullL( ret, contentURI );
+        localId = ( *rights )[ 0 ]->GetLocalID();
+        CleanupStack::PopAndDestroy( rights );
+        rights = NULL;
+        CleanupStack::PushL( contentURI );
+        }
+    else
+        {
+        rights->ResetAndDestroy();
+        delete rights;
+        rights = NULL;
+        User::LeaveIfError( ret );
+        }
+
+    if ( iPutRightsToInbox )
+        {
+        buffer = HBufC16::NewL( contentURI->Length() );
+        TPtr uri16( buffer->Des() );
+        uri16.Copy( *contentURI );
+        CleanupStack::PopAndDestroy( contentURI );
+        contentURI = NULL;
+        CleanupStack::PushL( buffer );
+
+        number = HBufC16::NewLC( 11 ); //longer than max of tuint32
+        TPtr ptr( number->Des() );
+        ptr.AppendNum( localId, EDecimal );
+
+        messageContent = HBufC16::NewL( ptr.Length() + uri16.Length() + 4 );
+        TPtr ptrToMz( messageContent->Des() );
+        ptrToMz.Append( _L( "1 " ) );
+        ptrToMz.Append( ptr ); // add localID
+        ptrToMz.Append( _L( " " ) ); // add space
+        ptrToMz.Append( uri16 ); //add uri16
+
+        CleanupStack::PopAndDestroy( number );
+        CleanupStack::PopAndDestroy( buffer );
+        CleanupStack::PushL( messageContent );
+
+        // create empty sms
+        iMsvId = CreateNewMessageL();
+        SetEntryL( iMsvId );
+        // adds content in sms and moves it inbox
+        AddRoContentL( ptrToMz );
+
+        CleanupStack::PopAndDestroy( messageContent );
+        }
+    else
+        {
+        CleanupStack::PopAndDestroy( contentURI );
+        }
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "HandleRightsMessageL-End" ) ) );
+#endif
+    }
+
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: HandleRoapPduL
+
+    Description: Handles OMA 2.0 ROAP RO Response message
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+void CRoHandler::HandleRoapPduL()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "HandleRoapPduL" ) ) );
+#endif
+    Roap::CRoapEngBase* roapHandler( NULL );
+    RPointerArray< CDRMRights > rights;
+
+    roapHandler = CRoapEng::NewL();
+    CleanupStack::PushL( roapHandler );
+
+    TCleanupItem cleanup( DoResetAndDestroy, &rights );
+    CleanupStack::PushL( cleanup );
+
+
+    //Parse received rights.
+#ifdef  _DRM_TESTING
+    TRAPD( err, roapHandler->HandleRoReponseL( iMessageBodyPtr, rights ) );
+    TRAP( r, WriteL( _L8( "HandleRoapPduL->HandleRoReponseL done" ), err ) );
+    User::LeaveIfError( err );
+#else
+    roapHandler->HandleRoReponseL( iMessageBodyPtr, rights );
+#endif
+
+
+    //handle parsed rights and save uri into mtm
+    if ( rights.Count() )
+        {
+        HBufC8* contentURI( NULL );
+        HBufC16* buffer( NULL );
+        HBufC16* number( NULL );
+        HBufC16* messageContent( NULL );
+        TUint32 localId( 0 );
+        TInt ret( KErrNone );
+
+#ifdef  _DRM_TESTING
+        TRAP( r, WriteL( _L8( "HandleRoapPduL->CID" ) ) );
+#endif
+        ret = rights[0]->GetContentURI( contentURI );
+        // null contentURI means invalid RO
+        LeaveIfNullL( ret,  contentURI );
+#ifdef  _DRM_TESTING
+        TRAP( r, WriteL( *contentURI ) );
+#endif
+        localId = rights[0]->GetLocalID();
+        CleanupStack::PushL( contentURI );
+        buffer = HBufC16::NewL( contentURI->Length() );
+        TPtr uri16( buffer->Des() );
+        uri16.Copy( *contentURI );
+        CleanupStack::PopAndDestroy( contentURI );
+        contentURI = NULL;
+        CleanupStack::PushL( buffer );
+        number = HBufC16::NewLC( 11 ); //longer than max of tuint32
+        TPtr ptr( number->Des() );
+        ptr.AppendNum( localId, EDecimal );
+        messageContent = HBufC16::NewL( ptr.Length() + uri16.Length() + 4 );
+        TPtr ptrToMz( messageContent->Des() );
+        ptrToMz.Append( _L( "1 " ) );
+        ptrToMz.Append( ptr ); // add localID
+        ptrToMz.Append( _L( " " ) ); // add space
+        ptrToMz.Append( uri16 ); //add uri16
+        CleanupStack::PopAndDestroy( number );
+        CleanupStack::PopAndDestroy( buffer );
+        CleanupStack::PushL( messageContent );
+        // create empty sms
+        iMsvId = CreateNewMessageL();
+        SetEntryL( iMsvId );
+        // adds content in sms and moves it inbox
+        AddRoContentL( ptrToMz );
+        CleanupStack::PopAndDestroy( messageContent );
+        }
+
+    // Finish up
+    CleanupStack::PopAndDestroy( &rights );
+    CleanupStack::PopAndDestroy( roapHandler );
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "HandleRoapPduL-End" ) ) );
+#endif
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: HandleRoapTriggerL
+
+    Description: Handles OMA 2.0 ROAP Trigger message
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+void CRoHandler::HandleRoapTriggerL()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "HandleRoapTriggerL" ) ) );
+#endif
+
+    _LIT( KFile, "%S%u.tri" );
+    RFile f;
+    TFileName fileName;
+    TPtr ptr( NULL, 0 );
+    HBufC* content( NULL );
+    TInt ret( KErrNone );
+    TInt driveNumber( -1 );
+
+
+    // create empty sms
+    iMsvId = CreateNewMessageL();
+    SetEntryL( iMsvId );
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    driveNumber = EDriveC;
+    ret = iFs.MkDirAll( KRoHandlerTriggerFilePath );
+    fileName.Format( KFile, &KRoHandlerTriggerFilePath, iMsvId );
+
+#else //RD_MULTIPLE_DRIVE
+
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+
+    TFileName roHandlerTriggerFilePath;
+    roHandlerTriggerFilePath.Format(
+                    KRoHandlerTriggerFilePath, ( TUint )driveLetter );
+
+    ret = iFs.MkDirAll( roHandlerTriggerFilePath );
+    fileName.Format( KFile, &roHandlerTriggerFilePath, iMsvId );
+
+#endif
+    if ( ret && ret != KErrAlreadyExists )
+        {
+        User::LeaveIfError( ret );
+        }
+
+    // Create cleanup item for file to be deleted on leave.
+    CFileDeleter* fileDeleter( CFileDeleter::NewLC( iFs, fileName ) );
+
+    // Leave if there is not enough space for file to be created.
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL(
+            &iFs, iMessageBodyPtr.Size(), driveNumber ) )
+        {
+        User::Leave( KErrDiskFull );
+        }
+
+    User::LeaveIfError( f.Replace( iFs, fileName, EFileWrite ) );
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( fileName, iMsvId ) );
+#endif
+    CleanupClosePushL( f );
+    User::LeaveIfError( f.Write( iMessageBodyPtr ) );
+    CleanupStack::PopAndDestroy( &f );
+
+    // Delete created file on leave.
+    fileDeleter->SetDelete();
+
+
+    //format content
+    if ( iMsgType == EOma2RoapTriggerRoAcquisition )
+        {
+#ifdef _DRM_TESTING
+        TRAP( r, WriteL( _L8( "HandleRoapTriggerL->EOma2RoapTriggerRoAcquisition" ) ) );
+#endif
+        content = HBufC::NewLC(
+            fileName.Length() + KRoAcquisitionPrefix().Length() );
+        ptr.Set( content->Des() );
+        ptr.Append( KRoAcquisitionPrefix() );
+        ptr.Append( fileName );
+#ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
+        // do the ROAP silently, but if it fails, create the inbox entry
+        if ( !DoRoapL( iMessageBodyPtr ) )
+            {
+            AddRoContentL( ptr );
+            }
+#else
+        // adds content in sms and moves it inbox
+        AddRoContentL( ptr );
+#endif
+        CleanupStack::PopAndDestroy( content );
+        }
+    else
+        {
+        content = HBufC::NewLC(
+            fileName.Length() + KTriggerPrefix().Length() );
+        ptr.Set( content->Des() );
+        ptr.Append( KTriggerPrefix() );
+        ptr.Append( fileName );
+        AddRoContentL( ptr );
+        CleanupStack::PopAndDestroy( content );
+        }
+    // No leaves. So keep created file.
+    fileDeleter->SetNoDelete();
+    CleanupStack::PopAndDestroy( fileDeleter );
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( ptr ) );
+#endif
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "HandleRoapTriggerL-End" ) ) );
+#endif
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: CancelHandleMessage
+
+    Description: Cancels the pending asynchronous HandleMessageL.
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+void CRoHandler::CancelHandleMessage
+        (
+        //None.
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "CancelHandleMessage" ) ) );
+#endif
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "CancelHandleMessage-End" ) ) );
+#endif
+    }
+
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: CreateNewMessageL
+
+    Description: Creates a new message server entry and set up default values.
+
+    Return values:      TMsvId (the id of created entry)
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+TMsvId CRoHandler::CreateNewMessageL
+        (
+        //None.
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "CreateNewMessageL" ) ) );
+#endif
+    TMsvEntry newEntry;// This represents an entry in the Message Server index
+    newEntry.iMtm = KUidMsgTypeRO;// message type is RO
+    newEntry.iType = KUidMsvMessageEntry;                   // this defines the type of the entry: message
+    newEntry.iServiceId = KMsvLocalServiceIndexEntryId;     // ID of local service (containing the standard folders)
+    newEntry.iDate.UniversalTime();                         // set the date of the entry to Universal time
+    newEntry.SetVisible( EFalse );
+    newEntry.SetUnread( ETrue );                            // a soft notification would come
+
+    HBufC* detail( GetDetailLC() );
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L( "detail" ) ) );
+    TRAP( r, WriteL( *detail, detail->Des().Length() ) );
+#endif
+
+    HBufC* description( GetDescriptionLC() );
+
+    newEntry.iDetails.Set( detail->Des() );
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L( "newEntry.iDetails:" ) ) );
+    TRAP( r, WriteL( newEntry.iDetails, newEntry.iDetails.Length() ) );
+#endif
+
+    newEntry.iDescription.Set( description->Des() );
+
+    newEntry.SetInPreparation( ETrue );                       // a flag that this message is in preparation
+    //----
+    //newEntry.iBioType = 0x1000ffff;                         // define a bio UID if sending a bio message over SMS bearer
+    //----
+
+    // - CMsvEntry accesses and acts upon a particular Message Server entry.
+    // - NewL() does not create a new entry, but simply a new object to access an existing entry.
+    // - It takes in as parameters the client's message server session,
+    //   ID of the entry to access and initial sorting order of the children of the entry.
+    //
+    CMsvEntry* entry( NULL );
+    entry = CMsvEntry::NewL(
+        *iSession, KMsvDraftEntryIdValue, TMsvSelectionOrdering() );
+    CleanupStack::PushL( entry );
+
+    CMsvOperationActiveSchedulerWait* wait( NULL );
+    wait = CMsvOperationActiveSchedulerWait::NewLC();
+    CMsvOperation* oper( entry->CreateL( newEntry, wait->iStatus ) );
+    CleanupStack::PushL( oper );
+    wait->Start();
+
+    // ...and keep track of the progress of the create operation.
+    TMsvLocalOperationProgress progress(
+        McliUtils::GetLocalProgressL( *oper ) );
+    User::LeaveIfError( progress.iError );
+
+    // Set our entry context to the created one
+    entry->SetEntryL( progress.iId ); // operation progress contains the ID of the ceated entry
+    CleanupStack::PopAndDestroy( oper );
+    CleanupStack::PopAndDestroy( wait );
+    CleanupStack::PopAndDestroy( entry );
+    CleanupStack::PopAndDestroy( description );
+    CleanupStack::PopAndDestroy( detail );
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "CreateNewMessageL-End" ) ) );
+#endif
+    return progress.iId;
+    }
+
+
+
+HBufC* CRoHandler::ConvertDetailsL( const TDesC8& aFrom )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "ConvertDetailsL" ) ) );
+#endif
+    HBufC* from( HBufC::NewMaxLC( aFrom.Length() ) );
+    from->Des().Copy( aFrom );
+
+    TUriParser16 pars;
+    User::LeaveIfError( pars.Parse( *from ) );
+
+    HBufC* res( NULL );
+    if ( pars.IsPresent( EUriHost ) )
+        {
+        res = pars.Extract( EUriHost ).AllocL();
+        }
+    else
+        {
+        res = from->AllocL();
+        }
+
+    CleanupStack::PopAndDestroy( from );
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "ConvertDetailsL-End" ) ) );
+#endif
+    return res;
+    }
+
+void CRoHandler::ReadFromResourceLC(
+            const TDesC& aFile,
+            const TInt& aIndex,
+            HBufC*& aBuf )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "ReadFromResourceLC" ) ) );
+#endif
+    RFs fs;
+    if ( aBuf )
+        {
+        delete aBuf;
+        aBuf = NULL;
+        }
+    User::LeaveIfError( fs.Connect() );
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "ReadFromResourceLC-fs.Connect" ) ) );
+#endif
+    CleanupClosePushL( fs );
+    CStringResourceReader* reader(
+        new ( ELeave ) CStringResourceReader( fs, aFile ) );
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "ReadFromResourceLC-CStringResourceReader" ) ) );
+#endif
+    CleanupStack::PushL( reader );
+    aBuf = reader->AllocReadResourceL( aIndex );
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "ReadFromResourceLC-AllocReadResourceL" ) ) );
+#endif
+    CleanupStack::PopAndDestroy( reader );
+    CleanupStack::PopAndDestroy( &fs );
+    CleanupStack::PushL( aBuf );
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "ReadFromResourceLC-End" ) ) );
+#endif
+    }
+
+HBufC* CRoHandler::GetDetailLC()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "GetDetailLC" ) ) );
+#endif
+    // Get server address.
+    TPtrC8 srvAddress;
+    TBool flag( iPushMsg->GetServerAddress( srvAddress ) );
+    HBufC* buf( NULL );
+    HBufC* result( NULL );
+
+    // First line in Inbox: TMsvEntry::iDetails.
+    if ( !flag || srvAddress.Length() == 0 )
+        {
+        // Read from resource.
+
+#ifndef RD_MULTIPLE_DRIVE
+
+        TFileName resourceFile( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+        _LIT( KDriveRoot, "%c:" );
+        TInt driveNumber( -1 );
+        TChar driveLetter;
+        DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+        iFs.DriveToChar( driveNumber, driveLetter );
+
+        TFileName resourceFile;
+        resourceFile.Format( KDriveRoot, (TUint )driveLetter );
+
+#endif
+
+        resourceFile.Append( KDC_MTM_RESOURCE_DIR );
+        resourceFile.Append( KPushMtmRes );
+        ReadFromResourceLC( resourceFile, R_PUSHMISC_UNK_SENDER, result );
+        }
+    else
+        {
+        // Convert the "From" information to the format required by the UI
+        // spec and then decode it.
+#ifdef _DRM_TESTING
+        TRAP( r, WriteL( _L( "From form: " ) ) );
+        TRAP( r, WriteL( srvAddress, srvAddress.Length() ) );
+#endif
+        buf = ConvertDetailsL( srvAddress );
+#ifdef _DRM_TESTING
+        TRAP( r, WriteL( _L( "Uri form: " ) ) );
+        TRAP( r, WriteL( *buf, buf->Length() ) );
+#endif
+        CleanupStack::PushL( buf );
+        result = ConvertUriToDisplayFormL( *buf );
+#ifdef _DRM_TESTING
+        TRAP( r, WriteL( _L( "Final form: " ) ) );
+        TRAP( r, WriteL( *result, result->Length() ) );
+#endif
+        CleanupStack::PopAndDestroy( buf ); // buf
+        buf = NULL;
+        CleanupStack::PushL( result );
+        }
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "GetDetailLC-End" ) ) );
+#endif
+    return result;
+    }
+
+HBufC* CRoHandler::ConvertUriToDisplayFormL( const TDesC& aUri )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "ConvertUriToDisplayFormL" ) ) );
+#endif
+    HBufC8* uri8( HBufC8::NewMaxLC( aUri.Length() ) );
+    uri8->Des().Copy( aUri );
+    TUriParser8 uriParser8;
+    User::LeaveIfError( uriParser8.Parse( *uri8 ) );
+    CUri16* convertedCUri( UriUtils::ConvertToDisplayFormL( uriParser8 ) );
+    CleanupStack::PopAndDestroy( uri8 );
+    CleanupStack::PushL( convertedCUri );
+    HBufC* convertedUri( convertedCUri->Uri().UriDes().AllocL() );
+    CleanupStack::PopAndDestroy( convertedCUri );
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "ConvertUriToDisplayFormL-End" ) ) );
+#endif
+    return convertedUri;
+    }
+
+HBufC* CRoHandler::GetDescriptionLC()
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "GetDescriptionLC" ) ) );
+#endif
+    HBufC* buf( NULL );
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    TFileName resourceFile( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+    _LIT( KDriveRoot, "%c:" );
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+
+    TFileName resourceFile;
+    resourceFile.Format( KDriveRoot, ( TUint )driveLetter );
+
+#endif
+
+    resourceFile.Append( KDC_RESOURCE_FILES_DIR );
+    resourceFile.Append( KRoHandlerResourceFile );
+
+    if ( iMsgType == EOma2RoapTrigger )
+        {
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( resourceFile ) );
+#endif
+        ReadFromResourceLC(
+            resourceFile, R_ROHL_INBOX_DESCRIPTION_ROA, buf );
+        }
+    else
+        {
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( resourceFile ) );
+#endif
+        ReadFromResourceLC( resourceFile, R_ROHL_INBOX_DESCRIPTION, buf );
+        }
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "GetDescriptionLC-End" ) ) );
+#endif
+    return buf;
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: DoCancel
+
+    Description:Cancels the operation.
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+void CRoHandler::DoCancel
+        (
+        //None.
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "DoCancel" ) ) );
+#endif
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "DoCancel-End" ) ) );
+#endif
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: RunL
+
+    Description: Basically all the work is done from/through this method
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+void CRoHandler::RunL
+        (
+        //None.
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "RunL" ) ) );
+#endif
+    // First checking whether cancel has been called
+    if ( iStatus == KErrCancel )
+        {
+        iPluginKiller->KillPushPlugin();
+        return;
+        }
+
+    switch( iMsgType )
+        {
+        case EOma1Ro:
+            {
+            HandleRightsMessageL();
+            break;
+            }
+#ifdef __DRM_OMA2
+        case EOma2RoapTrigger:
+        case EOma2RoapTriggerRoAcquisition:
+            {
+            HandleRoapTriggerL();
+            break;
+            }
+        case EOma2RoapPdu:
+            {
+            HandleRoapPduL();
+            break;
+            }
+#endif
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            }
+        }
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "RunL-End" ) ) );
+#endif
+    }
+/*
+-----------------------------------------------------------------------------
+
+    Method: RunError
+
+    Description: Called by ActiveScheduler in case RunL leaves.
+                 Currently does nothing.
+
+    Return Value: <errorcode>: Currently same as was given as a parameter
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+TInt CRoHandler::RunError
+        (
+        TInt
+#ifdef _DRM_TESTING
+        aError // errorcode
+#endif
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "RunError" ) ) );
+#endif
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "RunError-End" ), aError ) );
+#endif
+    return KErrNone;
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: CPushHandlerBase_Reserved1
+
+    Description: Reserved for future expansion.
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+void CRoHandler::CPushHandlerBase_Reserved1
+        (
+        //None.
+        )
+    {
+    _LIT( KNotSupported, "This method is not supported!" );
+    User::Panic( KNotSupported, KErrNotSupported );
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: CPushHandlerBase_Reserved2
+
+    Description: Reserved for future expansion.
+
+    Return Value: None.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+void CRoHandler::CPushHandlerBase_Reserved2
+        (
+        //None.
+        )
+    {
+    _LIT( KNotSupported, "This method is not supported!" );
+    User::Panic( KNotSupported, KErrNotSupported );
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: PerformChecks
+
+    Description: Checks that message is current type
+
+    Return Value:  TInt: KErrNone if ok else KErrCorrupt.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+TInt CRoHandler::PerformChecks
+        (
+        //None.
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "PerformChecks" ) ) );
+#endif
+    if ( !iPushMsg )
+        {
+        return KErrCorrupt;
+        }
+    // Check that body != NULL
+    TBool bodyPresent( EFalse );
+    // fetch message body
+    bodyPresent = iPushMsg->GetMessageBody( iMessageBodyPtr );
+
+    // 6 == minimum number of message fields. This is a very "mild" check but
+    // at least it guarantees that there is no empty body in the message
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "PerformChecks-End" ) ) );
+#endif
+    if ( ( !bodyPresent ) || ( iMessageBodyPtr.Size() < 6 ) )
+        {
+        return KErrCorrupt;
+        }
+    return KErrNone;
+    }
+
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: CheckMessageTypeL
+
+    Description: Checks the message type
+
+    Return Value:  EOma1Ro, EOma2RoapPdu or EOma2RoapTrigger
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+TMessageType CRoHandler::CheckMessageTypeL
+        (
+        //None.
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "CheckMessageType" ) ) );
+#endif
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "CheckMessageType-End" ) ) );
+#endif
+    TPtrC8 messageBodyPtr( iMessageBodyPtr );
+    TMessageType recognizedMessageType( EOma1Ro );
+    if ( iMessageBodyPtr.FindF( KWbxmlRoapTriggerElement() ) != KErrNotFound  )
+        {
+        iParsedXmlTrigger = iWbxmlTriggerParser->ParseL( iMessageBodyPtr );
+        messageBodyPtr.Set( *iParsedXmlTrigger );
+        }
+    if ( messageBodyPtr.FindF( KRoapTriggerElement() ) != KErrNotFound )
+        {
+        if ( messageBodyPtr.FindF( KRoapTriggerRoAcquisition() ) != KErrNotFound )
+            {
+            recognizedMessageType = EOma2RoapTriggerRoAcquisition;
+            }
+        else if ( messageBodyPtr.FindF( KRoapTriggerMeteringReport() ) != KErrNotFound )
+            {
+            recognizedMessageType = EOma2RoapTriggerMetering;
+            }
+        else
+            {
+            recognizedMessageType = EOma2RoapTrigger;
+            }
+
+        }
+    if ( iMessageBodyPtr.FindF( KRoapRoPduElement() ) != KErrNotFound )
+        {
+        recognizedMessageType = EOma2RoapPdu;
+        }
+    delete iParsedXmlTrigger;
+    iParsedXmlTrigger = NULL;
+    return recognizedMessageType;
+    }
+
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: SetEntryL
+
+    Description: Set up current message entry.
+
+    Note: It can be useful to remember the original entry id for
+          error handling.
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+void  CRoHandler::SetEntryL
+        (
+        TMsvId aEntryId //an entry in the Message Server index
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "SetEntryL" ) ) );
+#endif
+
+    // Get the server entry from our session
+    CMsvEntry* entry( iSession->GetEntryL( aEntryId ) );
+    CleanupStack::PushL( entry );
+
+    // Check if our mtm is different from the mtm set to our entry
+    if ( !iMtm || entry->Entry().iMtm != ( iMtm->Entry() ).Entry().iMtm )
+        {
+        // If so, we delete the old...
+        delete iMtm;
+        iMtm = NULL;
+        // ...and get a new one from the MtmRegistry
+        iMtm = iMtmReg->NewMtmL( entry->Entry().iMtm );
+        }
+    // Set our entry as current.
+    iMtm->SetCurrentEntryL( entry );
+
+    CleanupStack::Pop( entry );
+    entry = NULL;
+
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "SetEntryL-End" ) ) );
+#endif
+    }
+
+/*
+-----------------------------------------------------------------------------
+
+    Method: MoveMessageEntryL
+
+    Description: Moves an entry to another parent.
+
+    Return values: TMsvId of the moved message
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+TMsvId CRoHandler::MoveMessageEntryL
+        (
+        TMsvId aTarget //an entry in the Message Server index
+        )
+    {
+#ifdef _DRM_TESTING
+    TRAPD( r, WriteL( _L8( "MoveMessageEntryL" ) ) );
+#endif
+    TMsvEntry msvEntry( ( iMtm->Entry() ).Entry() );
+    TMsvId id = msvEntry.Id();
+
+    if ( msvEntry.Parent() != aTarget )
+        {
+        TMsvSelectionOrdering sort;
+        sort.SetShowInvisibleEntries( ETrue );    // we want to handle also the invisible entries
+        // Take a handle to the parent entry
+        CMsvEntry* parentEntry(
+            CMsvEntry::NewL( iMtm->Session(), msvEntry.Parent(), sort ) );
+        CleanupStack::PushL( parentEntry );
+
+        // Move original from the parent to the new location
+        CMsvOperationActiveSchedulerWait* wait(
+            CMsvOperationActiveSchedulerWait::NewLC() );
+        CMsvOperation* op(
+            parentEntry->MoveL( msvEntry.Id(), aTarget, wait->iStatus ) );
+        CleanupStack::PushL( op );
+        wait->Start();
+
+        TMsvLocalOperationProgress prog = McliUtils::GetLocalProgressL( *op );
+        User::LeaveIfError( prog.iError );
+        id = prog.iId; // id of the moved entry
+        CleanupStack::PopAndDestroy( op );
+        CleanupStack::PopAndDestroy( wait );
+        CleanupStack::PopAndDestroy( parentEntry );
+        }
+#ifdef _DRM_TESTING
+    TRAP( r, WriteL( _L8( "MoveMessageEntryL-End" ) ) );
+#endif
+    return id;
+    }
+
+TBool CRoHandler::DoRoapL( const TDesC8& aTrigger )
+    {
+    TBool r( EFalse );
+    LOG( _L8( "CRoHandler::DoRoapL ->" ) );
+    LOGHEX( aTrigger.Ptr(), aTrigger.Length() );
+    CRoapSyncWrapper *roap( CRoapSyncWrapper::NewL() );
+    CleanupStack::PushL( roap );
+    r = roap->HandleTriggerSilentlyL( aTrigger );
+    CleanupStack::PopAndDestroy( roap );
+    LOG( _L8( "CRoHandler::DoRoapL <-" ) );
+    return r;
+    }
+
+
+void CRoHandler::HandleMeteringTriggerSilentlyL()
+    {
+    LOG( _L8( "CRoHandler::HandleMeteringTriggerSilentlyL ->" ) );
+    LOGHEX( iMessageBodyPtr.Ptr(), iMessageBodyPtr.Length() );
+
+    if ( iMeteringSupported )
+        {
+        LOG( _L8( "Handling" ) );
+        CRoHandlerDMgrWrapper* dMgrWrapper( CRoHandlerDMgrWrapper::NewL() );
+        CleanupStack::PushL( dMgrWrapper );
+        dMgrWrapper->HandleRoapTriggerL( iMessageBodyPtr );
+        CleanupStack::PopAndDestroy( dMgrWrapper );
+        LOG( _L8( "Handled" ) );
+        }
+    else
+        {
+        LOG( _L8( "Metering trigger not supported --> dropping it" ) );
+        }
+    LOG( _L8( "CRoHandler::HandleMeteringTriggerSilentlyL <-" ) );
+    }
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+/*
+   -----------------------------------------------------------------------------
+
+Method: ImplementationGroupProxy
+
+    Description:
+
+    Return Value: TImplementationProxy*: Implementation table to the
+                  ECOM framework
+
+    Status: Proposal
+
+-----------------------------------------------------------------------------
+*/
+
+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/omadrm/drmplugins/drmrohandler/src/RoHandler.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* 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:  Resources for RO Handler
+*
+*/
+
+
+#include <eikon.rh>
+#include <rohandler.loc>
+
+
+NAME ROHL
+
+//  RESOURCE DEFINITIONS
+// -----------------------------------------------------------------------------
+//
+//    RSS_SIGNATURE
+//
+//    Signature.
+//
+// -----------------------------------------------------------------------------
+//
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF r_rohl_inbox_description
+    {
+    buf=qtn_drm_mgr_inb_title;
+    }
+
+RESOURCE TBUF r_rohl_inbox_description_roa
+    {
+    buf=qtn_drm_roap_trigger_msg_domain;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrohandler/src/StringResourceReader.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,253 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     Implementation of CStringResourceReader
+*
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "StringResourceReader.h"
+#include <f32file.h>
+#include <barsread.h>
+#include <bautils.h>
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+//#define _DRM_TESTING
+
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs );
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName );
+LOCAL_C void CreateLogL();
+LOCAL_C void WriteL( const TDesC8& aText );
+LOCAL_C void WriteL( const TDesC& aText );
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr );
+LOCAL_C void WriteCurrentTimeL();
+#endif
+
+// -----------------------------------------------------------------------------
+// Testing stuff
+// -----------------------------------------------------------------------------
+//
+
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
+    {
+    _LIT( KLogFile , "c:\\StringResourceReader.txt" );
+    WriteFileL( text , aFs , KLogFile );
+    }
+
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
+    {
+    RFile file;
+    TInt size;
+    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy(); //file
+    }
+
+LOCAL_C void CreateLogL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    User::LeaveIfError( file.Replace( fs , _L("c:\\StringResourceReader.txt") , EFileWrite ) );
+    file.Close();
+    CleanupStack::PopAndDestroy(); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8("\r\n") );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(); //fs
+    WriteCurrentTimeL();
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8("\r\n") );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(); //fs
+    WriteCurrentTimeL();
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr )
+    {
+    _LIT8(KErr,": %d");
+    HBufC8* text = HBufC8::NewLC(1000+20);
+    TBuf8<20> num;
+    TPtr8 textptr(text->Des());
+    textptr.Append(aText);
+    num.Format(KErr(),aErr);
+    textptr.Append(num);
+    WriteL(textptr);
+    CleanupStack::PopAndDestroy(text);
+    }
+
+LOCAL_C void WriteCurrentTimeL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+// Date and Time display
+    TTime time;
+    time.HomeTime();
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    time.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    time.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(); //fs
+    }
+#endif
+
+// ================= MEMBER FUNCTIONS =======================
+
+
+// ---------------------------------------------------------
+// CStringResourceReader::CStringResourceReader
+// ---------------------------------------------------------
+//
+CStringResourceReader::CStringResourceReader
+    ( RFs& aFs, const TDesC& aRscFileWithPathAndDrive )
+:   CBase(), iFs( aFs ), iInitialized( EFalse )
+    {
+#ifdef _DRM_TESTING
+	TRAPD(r,CreateLogL());   
+	TRAP(r,WriteL(_L8("CStringResourceReader")));
+#endif 
+    iRscFileName.Copy( aRscFileWithPathAndDrive );
+    }
+
+// ---------------------------------------------------------
+// CStringResourceReader::~CStringResourceReader
+// ---------------------------------------------------------
+//
+CStringResourceReader::~CStringResourceReader()
+    {
+    iResourceFile.Close();
+#ifdef _DRM_TESTING
+	TRAPD(r,WriteL(_L8("~CStringResourceReader")));
+#endif 
+    }
+
+// ---------------------------------------------------------
+// CStringResourceReader::AllocReadResourceL
+// ---------------------------------------------------------
+//
+HBufC* CStringResourceReader::AllocReadResourceL( TInt aResId )
+    {
+#ifdef _DRM_TESTING
+	TRAPD(r,WriteL(_L8("AllocReadResourceL"),aResId));
+#endif 
+
+    InitializeL();
+
+#ifdef _DRM_TESTING
+	TRAP(r,WriteL(_L8("AllocReadResourceL-InitializeL")));
+#endif 
+
+    HBufC8* buf8 = iResourceFile.AllocReadLC( aResId );
+
+#ifdef _DRM_TESTING
+	TRAP(r,WriteL(_L8("AllocReadResourceL-iResourceFile.AllocReadLC")));
+#endif     
+    
+#ifdef _UNICODE
+    const TPtrC buf( (const TUint16*)buf8->Ptr(), buf8->Size()/2 );
+#else
+    const TPtrC buf( buf8->Ptr(), buf8->Size() );
+#endif
+    HBufC* retBuf = buf.AllocL();
+    CleanupStack::PopAndDestroy( buf8 );
+
+#ifdef _DRM_TESTING
+	TRAP(r,WriteL(_L8("AllocReadResourceL-End")));
+#endif 
+    return retBuf;
+    }
+
+// ---------------------------------------------------------
+// CStringResourceReader::InitializeL
+// ---------------------------------------------------------
+//
+void CStringResourceReader::InitializeL()
+    {
+#ifdef _DRM_TESTING
+	TRAPD(r,WriteL(_L8("InitializeL")));
+#endif 
+    if ( !iInitialized )
+        {
+        TFileName resourceFileName( iRscFileName );
+#ifdef _DRM_TESTING
+	TRAP(r,WriteL(_L8("InitializeL-NearestLanguageFile")));
+#endif 
+
+#ifdef _DRM_TESTING
+	TRAP(r,WriteL(resourceFileName));
+#endif 
+        BaflUtils::NearestLanguageFile( iFs, resourceFileName );
+#ifdef _DRM_TESTING
+	TRAP(r,WriteL(_L8("InitializeL-NearestLanguageFile-End")));
+#endif 
+
+        iResourceFile.OpenL( iFs, resourceFileName );
+#ifdef _DRM_TESTING
+	TRAP(r,WriteL(_L8("InitializeL-OpenL-End")));
+#endif 
+
+        iResourceFile.ConfirmSignatureL( iResourceFile.SignatureL() );
+#ifdef _DRM_TESTING
+	TRAP(r,WriteL(_L8("InitializeL-ConfirmSignatureL-End")));
+#endif 
+        iInitialized = ETrue;
+        }
+#ifdef _DRM_TESTING
+	TRAP(r,WriteL(_L8("InitializeL-End")));
+#endif 
+    }
+
+// End of file.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmrohandler/src/rohandlerdmgrwrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,883 @@
+/*
+* Copyright (c) 2008 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  rohandler wrapper for Download manager
+ *
+*/
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <es_enum_partner.h>
+#endif
+#include <centralrepository.h>
+#include <cdblen.h>
+
+#ifdef __SERIES60_NATIVE_BROWSER
+#include <browseruisdkcrkeys.h>
+#endif
+
+#include <cmconnectionmethod.h>
+#include <cmdestination.h>
+#include <cmconnectionmethoddef.h>
+#include <cmmanager.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <driveinfo.h>
+#endif
+
+#include <data_caging_path_literals.hrh>
+
+#include <downloadmgrclient.h>
+
+#include <es_enum.h> // tconnectioninfo
+#include <es_sock.h> // rconnection rsocket
+#include <roapeng.h>
+#include <roapdef.h>
+#include <roapobserver.h>
+#include "roapsyncwrapper.h"
+
+#include "rohandlerdmgrwrapper.h"
+
+#ifdef _DEBUG
+#define DRMDEBUG( a ) RDebug::Print( a )
+#define DRMDEBUG2( a, b ) RDebug::Print( a, b )
+#define DRMDEBUG3( a, b, c ) RDebug::Print( a, b, c )
+
+#define DRMDEBUGMETHOD( a ) RDebug::Print( \
+    RoHdlrDMgrWrDebugLiterals::KMethodFormat(), &( a ) )
+// #define DRMDEBUGMETHODSTART( a ) RDebug::Print( \
+// RoHdlrDMgrWrDebugLiterals::KMethodStartFormat(), &( a ) )
+
+// #define DRMDEBUGMETHODFINISH( a ) RDebug::Print( \
+// RoHdlrDMgrWrDebugLiterals::KMethodFinishFormat(), &( a ) )
+
+// #define LOG( a ) RFileLogger::Write( \
+// KRoLogDir(), KRoLogFile(), EFileLoggingModeAppend, a );
+// #define LOGHEX( ptr, len ) RFileLogger::HexDump( \
+//  KRoLogDir(), KRoLogFile(), EFileLoggingModeAppend, \
+//  _S( "" ), _S( "" ), ptr, len );
+// #define LOG2( a, b ) RFileLogger::WriteFormat( \
+// KRoLogDir(), KRoLogFile(), EFileLoggingModeAppend, a, b );
+
+
+namespace RoHdlrDMgrWrDebugLiterals
+    {
+    // Uncomment following literals if using macros LOG, LOG2 or LOGHEX anywhere
+    //    _LIT( KRoLogDir, "DRM" );
+    //    _LIT( KRoLogFile, "RoHdlDmgrWrapper.log" );
+
+    // method Formatters ( used in macros DRMDEBUGMETHOD )
+    _LIT( KMethodFormat, "CRoHandlerDMgrWrapper::%S" );
+
+    // method Formatters ( used in macro DRMDEBUGMETHODSTART )
+    //    _LIT( KMethodStartFormat, "CRoHandlerDMgrWrapper::%S -->" );
+
+    // method Formatters ( used in macro DRMDEBUGMETHODFINISH )
+    //    _LIT( KMethodFinishFormat, "--> CRoHandlerDMgrWrapper::%S" );
+
+
+    _LIT( KFormatMembValInt, "%S = %d" );
+
+    //Constructors, destructor
+    _LIT( KMethDestructor, "~CRoHandlerDMgrWrapper" );
+    //Methods
+    _LIT( KMethConstructL, "ConstructL" );
+    _LIT( KMethNewL, "NewL" );
+    _LIT( KMethNewLC, "NewLC" );
+    _LIT( KMethDownloadAndHandleRoapTriggerL, "DownloadAndHandleRoapTriggerL" );
+    _LIT( KMethDownloadAndHandleRoapTriggerFromPrUrlL,
+        "DownloadAndHandleRoapTriggerFromPrUrlL" );
+    _LIT( KMethDoDownloadAndHandleRoapTriggerL,
+        "DoDownloadAndHandleRoapTriggerL" );
+    _LIT( KFormatDoDlHdlRoapTrigL, "DoDownloadAndHandleRoapTriggerL: %S" );
+    _LIT( KStrDlCreated, "download created" );
+    _LIT( KStrDlFinished, "download finished" );
+
+    _LIT( KMethSetDefaultAccessPointL, "SetDefaultAccessPointL" );
+    _LIT( KMiIapId, "iIapId" );
+
+    _LIT( KMethHandleDMgrEventL, "HandleDMgrEventL" );
+    _LIT( KFormatMethHandleDMgrEventL, "HandleDMgrEventL %S" );
+    _LIT( KStrEHttpDlCreated, "EHttpDlCreated" );
+    _LIT( KStrEHttpContentTypeReceived, "EHttpContentTypeReceived" );
+    _LIT( KStrEHttpProgDisconnected, "EHttpProgDisconnected" );
+    _LIT( KStrEHttpDlInprogress, "EHttpDlInprogress" );
+    _LIT( KStrEHttpDlCompleted, "EHttpDlCompleted" );
+    _LIT( KStrEHttpDlFailed, "EHttpDlFailed" );
+    _LIT( KStrEConnectionFailed, "EConnectionFailed" );
+    _LIT( KFormatEDlAttrErrorId, "EDlAttrErrorId = %d" );
+
+    _LIT( KMiDownLoadState, "iDownLoadState" );
+    _LIT( KMiProgressState, "iProgressState" );
+
+    }
+
+#else
+#define DRMDEBUG( a )
+#define DRMDEBUG2( a, b )
+#define DRMDEBUG3( a, b, c )
+
+#define DRMDEBUGMETHOD( a )
+//#define DRMDEBUGMETHODSTART( a )
+//#define DRMDEBUGMETHODFINISH( a )
+
+//#define LOG( a )
+//#define LOGHEX( ptr, len )
+//#define LOG2( a, b )
+#endif
+
+#ifndef __SERIES60_NATIVE_BROWSER
+const TUid KCRUidBrowser =
+    {0x10008D39};
+const TUint32 KBrowserDefaultAccessPoint = 0x0000000E;
+const TUint32 KBrowserAccessPointSelectionMode = 0x0000001E;
+const TUint32 KBrowserNGDefaultSnapId = 0x00000053;
+#endif
+
+// CONSTANTS
+#ifndef RD_MULTIPLE_DRIVE
+_LIT( KHelperTriggerFilePath, "d:\\" );
+#endif
+
+// ============================== LOCAL FUNCTIONS ==============================
+
+// ---------------------------------------------------------------------------
+// DoResetAndDestroy
+// Does RPointerArray< typename >->ResetAndDestroy() for the given array aPtr.
+// ---------------------------------------------------------------------------
+//
+template< typename elemType >
+LOCAL_C void DoResetAndDestroy( TAny* aPtr )
+    {
+    ( reinterpret_cast< RPointerArray< elemType >* >( aPtr ) )->
+        ResetAndDestroy();
+    }
+
+// ---------------------------------------------------------------------------
+// DeleteHttpDowload
+// ---------------------------------------------------------------------------
+//
+LOCAL_C void DeleteHttpDowload( TAny* aDownload )
+    {
+    reinterpret_cast< RHttpDownload* >( aDownload )->Delete();
+    }
+
+// ---------------------------------------------------------------------------
+// UpdateBufferL
+// ---------------------------------------------------------------------------
+//
+template< typename bufType, typename descType >
+LOCAL_C void UpdateBufferL( bufType*& aTargetBuf, const descType& aSourceBuf )
+    {
+    if ( aTargetBuf )
+        {
+        delete aTargetBuf;
+        aTargetBuf = NULL;
+        }
+    if ( aSourceBuf.Length() )
+        {
+        aTargetBuf = aSourceBuf.AllocL();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// IapIdOfDefaultSnapL
+// for trapping purposes only
+// ---------------------------------------------------------------------------
+//
+LOCAL_C TUint32 IapIdOfDefaultSnapL(
+    RCmManager& aCmManager,
+    const TUint32 aDefaultSnap )
+    {
+    RCmDestination dest( aCmManager.DestinationL( aDefaultSnap ) );
+    CleanupClosePushL( dest );
+    TUint32 iapIdOfDest( 0 );
+
+    if ( dest.ConnectionMethodCount() <= 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    RCmConnectionMethod cMeth( dest.ConnectionMethodL( 0 ) );
+    CleanupClosePushL( cMeth );
+
+    iapIdOfDest = cMeth.GetIntAttributeL( CMManager::ECmIapId );
+    CleanupStack::PopAndDestroy( &cMeth );
+    CleanupStack::PopAndDestroy( &dest );
+    return iapIdOfDest;
+    }
+
+
+// ============================= MEMBER FUNCTIONS ==============================
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::CRoHandlerDMgrWrapper
+// ---------------------------------------------------------------------------
+//
+CRoHandlerDMgrWrapper::CRoHandlerDMgrWrapper() :
+    CActive( CActive::EPriorityStandard ),
+    iIapId( 0 ), iState( EInit )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::ConstructL()
+    {
+    DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethConstructL() );
+    // Get UID from process
+    const TInt KRoHandlerDMgrWrapperUid = 0x101F7B92;
+    iDlMgr.ConnectL( TUid::Uid( KRoHandlerDMgrWrapperUid ), *this, EFalse );
+    User::LeaveIfError( iFs.Connect() );
+    User::LeaveIfError( iFs.ShareProtected() );
+
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::NewL
+// ---------------------------------------------------------------------------
+//
+CRoHandlerDMgrWrapper* CRoHandlerDMgrWrapper::NewL()
+    {
+    DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethNewL() );
+    CRoHandlerDMgrWrapper* self( CRoHandlerDMgrWrapper::NewLC() );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::NewLC
+// ---------------------------------------------------------------------------
+//
+CRoHandlerDMgrWrapper* CRoHandlerDMgrWrapper::NewLC()
+    {
+    DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethNewLC() );
+    CRoHandlerDMgrWrapper* self( new ( ELeave ) CRoHandlerDMgrWrapper() );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::~CRoHandlerDMgrWrapper
+// ---------------------------------------------------------------------------
+//
+CRoHandlerDMgrWrapper::~CRoHandlerDMgrWrapper()
+    {
+    Cancel();
+
+    DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethDestructor() );
+    delete iTriggerUrl;
+    delete iTriggerBuf;
+    delete iFileName;
+    delete iRoapEng;
+
+#ifdef _DEBUG
+
+    if ( iDlMgr.Handle() )
+        {
+        iDlMgr.Close();
+        }
+
+#else
+
+    iDlMgr.Close();
+
+#endif
+
+    iFs.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::DownloadAndHandleRoapTriggerL
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::HandleRoapTriggerL( const TDesC8& aTrigger )
+    {
+    if ( iState != EInit || iWait.IsStarted() )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    UpdateBufferL< HBufC8, TDesC8 >( iTriggerBuf, aTrigger );
+    Continue( EMeteringReportSubmit, KErrNone );
+    iWait.Start();
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::DownloadAndHandleRoapTriggerL
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::DownloadAndHandleRoapTriggerL( const HBufC8* aUrl )
+    {
+    DRMDEBUGMETHOD(
+        RoHdlrDMgrWrDebugLiterals::KMethDownloadAndHandleRoapTriggerL() );
+    if ( iState != EInit || iWait.IsStarted() )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    UpdateBufferL< HBufC8, TDesC8 >( iTriggerUrl, *aUrl );
+    Continue( EGetMeteringTrigger, KErrNone );
+    iWait.Start();
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::DownloadAndHandleRoapTriggerFromPrUrlL
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::DownloadAndHandleRoapTriggerFromPrUrlL(
+        const HBufC8* aUrl )
+    {
+    DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethDownloadAndHandleRoapTriggerFromPrUrlL() );
+    if ( iState != EInit || iWait.IsStarted() )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    UpdateBufferL< HBufC8, TDesC8 >( iTriggerUrl, *aUrl );
+    Continue( EGetPrUrlTrigger, KErrNone );
+    iWait.Start();
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::DoDownloadRoapTriggerL
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::DoDownloadRoapTriggerL( TMeterState aNextState )
+    {
+    RFile roapTrigger;
+    TBool result( EFalse );
+    TFileName triggerFileName;
+
+    DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethDoDownloadAndHandleRoapTriggerL() );
+    // If no Trigger URL then nothing to download. So finish transaction
+    if ( !iTriggerUrl || iTriggerUrl->Length() <= 0 )
+        {
+        Continue( EComplete, KErrNone );
+        return;
+        }
+
+#ifndef RD_MULTIPLE_DRIVE
+
+    User::LeaveIfError( roapTrigger.Temp(
+            iFs, KHelperTriggerFilePath, triggerFileName, EFileWrite ) );
+
+#else //RD_MULTIPLE_DRIVE
+    _LIT( KDrive, "%c:\\" );
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRam, driveNumber );
+    iFs.DriveToChar( driveNumber, driveLetter );
+
+    TFileName helperTriggerFilePath;
+
+    helperTriggerFilePath.Format( KDrive, ( TUint )driveLetter );
+
+    User::LeaveIfError( roapTrigger.Temp( iFs, helperTriggerFilePath,
+            triggerFileName, EFileWrite ) );
+
+#endif
+    UpdateBufferL< HBufC, TFileName >( iFileName, triggerFileName );
+
+    // create and start download
+    RHttpDownload& download = iDlMgr.CreateDownloadL( *iTriggerUrl, result );
+    // Put download for proper cleanup.
+    TCleanupItem item( DeleteHttpDowload, &download );
+    CleanupStack::PushL( item );
+
+    CleanupClosePushL( roapTrigger );
+
+    if ( result )
+        {
+        DRMDEBUG2(
+            RoHdlrDMgrWrDebugLiterals::KFormatDoDlHdlRoapTrigL(),
+            &RoHdlrDMgrWrDebugLiterals::KStrDlCreated() );
+        iDownloadSuccess = EFalse;
+        iConnectionError = EFalse;
+
+        SetDefaultAccessPointL();
+        User::LeaveIfError( download.SetFileHandleAttribute( roapTrigger ) );
+        User::LeaveIfError( download.SetBoolAttribute(
+                EDlAttrNoContentTypeCheck, ETrue ) );
+        User::LeaveIfError( download.Start() );
+
+        // wait until download is finished
+        iState = aNextState;
+        TRequestStatus* status( &iStatus );
+        *status = KRequestPending;
+        SetActive();
+        }
+    CleanupStack::PopAndDestroy( &roapTrigger );
+    CleanupStack::Pop( &download ); // Left open for DoSaveRoapTrigger
+    }
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::DoSaveRoapTriggerL
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::DoSaveRoapTriggerL( TMeterState aNextState )
+    {
+    // Check success of download
+    DRMDEBUG2(
+        RoHdlrDMgrWrDebugLiterals::KFormatDoDlHdlRoapTrigL(),
+        &RoHdlrDMgrWrDebugLiterals::KStrDlFinished() );
+
+    // Fetch download created in DoDownloadRoapTriggerL
+    RHttpDownload* download = iDlMgr.FindDownload( *iTriggerUrl, KNullDesC8() );
+    // Delete trigger URL so that it is possible to check
+    // whether or not meteringResponse has PrUrl.
+    delete iTriggerUrl;
+    iTriggerUrl = NULL;
+    // Put download for proper cleanup.
+    TCleanupItem item( DeleteHttpDowload, download );
+    CleanupStack::PushL( item );
+    RFile roapTrigger;
+
+    if ( !iDownloadSuccess )
+        {
+            if ( iConnectionError )
+                {
+                User::Leave( KErrCouldNotConnect );
+                }
+            else
+                {
+                User::Leave( KErrGeneral );
+                }
+        }
+    User::LeaveIfError( roapTrigger.Open( iFs, *iFileName, EFileShareReadersOrWriters ) );
+    CleanupClosePushL( roapTrigger );
+    // Get filehandle of ROAP trigger
+    const TInt KReadBufSize = 512;
+
+    RBuf8 readBuf;
+    readBuf.CleanupClosePushL();
+    readBuf.CreateL( KReadBufSize );
+
+    // Read file to buffer
+    TInt triggerFileSize( 0 );
+    User::LeaveIfError( roapTrigger.Size( triggerFileSize ) );
+    if ( iTriggerBuf )
+        {
+        delete iTriggerBuf;
+        iTriggerBuf = NULL;
+        }
+    iTriggerBuf = HBufC8::NewL( triggerFileSize );
+    User::LeaveIfError( roapTrigger.Read( readBuf, KReadBufSize ) );
+    iTriggerBuf->Des().Copy( readBuf );
+    while ( readBuf.Length() == KReadBufSize )
+        {
+        User::LeaveIfError( roapTrigger.Read( readBuf, KReadBufSize ) );
+        iTriggerBuf->Des().Append( readBuf );
+        }
+
+    // And let ROAP handle it...
+    CleanupStack::PopAndDestroy( &readBuf );
+    CleanupStack::PopAndDestroy( &roapTrigger );
+    CleanupStack::PopAndDestroy( download );
+
+    iFs.Delete( *iFileName );
+    delete iFileName;
+    iFileName=NULL;
+    Continue( aNextState, KErrNone );
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::DoHandleRoapTriggerL
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::DoHandleRoapTriggerL( TMeterState aNextState )
+    {
+    Roap::TTriggerType triggerType;
+    Roap::TRiContextStatus contextStatus;
+    Roap::TDomainOperation domainOperation;
+
+    RPointerArray< HBufC8 > contentIds;
+
+    TCleanupItem cleanup( DoResetAndDestroy< HBufC8 >, &contentIds );
+    CleanupStack::PushL( cleanup );
+
+    iRoapEng = Roap::CRoapEng::NewL();
+
+    iRoapEng->SetTriggerL( *iTriggerBuf, NULL, triggerType, contextStatus,
+        domainOperation, contentIds );
+
+    CleanupStack::PopAndDestroy( &contentIds );
+
+    // if we have a valid RI context,
+    // or if there is no user confirmation needed, do the ROAP
+    if ( contextStatus != Roap::EInvalidContext )
+        {
+        iRoapEng->AcceptL( this, &iStatus );
+        iState = aNextState;
+        SetActive();
+        }
+    else
+        {
+        Continue( EComplete, KErrCancel );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::SetDefaultAccessPointL
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::SetDefaultAccessPointL()
+    {
+    const TInt KDestinationSelectionMode( 2 );
+    CRepository* repository( NULL );
+    TInt ap( 0 );
+    TInt alwaysAsk( 0 );
+    TUint32 iapd32( 0 );
+    TInt defaultSnap( 0 );
+    TInt err( KErrNone );
+
+    DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethSetDefaultAccessPointL() );
+
+    if ( !iIapId )
+        {
+        repository = CRepository::NewL( KCRUidBrowser );
+        CleanupStack::PushL( repository );
+        repository->Get( KBrowserDefaultAccessPoint, ap );
+        repository->Get( KBrowserAccessPointSelectionMode, alwaysAsk );
+        repository->Get( KBrowserNGDefaultSnapId, defaultSnap );
+        if ( ap <= KErrNotFound && defaultSnap <= KErrNotFound )
+            {
+            alwaysAsk = ETrue;
+            }
+        else
+            {
+            RCmManager cmManager;
+            cmManager.OpenLC();
+            if ( !alwaysAsk )
+                {
+                TRAP( err, iapd32 = cmManager.GetConnectionMethodInfoIntL(
+                        ap, CMManager::ECmIapId ) );
+                }
+            else if ( alwaysAsk == KDestinationSelectionMode )
+                {
+                TRAP( err, iapd32 = IapIdOfDefaultSnapL(
+                        cmManager, defaultSnap ) );
+                }
+            CleanupStack::PopAndDestroy( &cmManager );
+            }
+        if ( !err && ( !alwaysAsk || alwaysAsk == KDestinationSelectionMode ) )
+            {
+            iIapId = iapd32;
+            DRMDEBUG3( RoHdlrDMgrWrDebugLiterals::KFormatMembValInt(),
+                &RoHdlrDMgrWrDebugLiterals::KMiIapId(), iIapId );
+            err = iDlMgr.SetIntAttribute( EDlMgrIap, iapd32 );
+            }
+        CleanupStack::PopAndDestroy( repository );
+        }
+    else
+        {
+        err = iDlMgr.SetIntAttribute( EDlMgrIap, iIapId );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::Continue
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::Continue(
+    CRoHandlerDMgrWrapper::TMeterState aNextState, TInt aError )
+    {
+    iState = aNextState;
+    TRequestStatus* ownStatus = &iStatus;
+    *ownStatus = KRequestPending;
+    SetActive();
+    User::RequestComplete( ownStatus, aError );
+    }
+
+
+// MHttpDownloadMgrObserver methods
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::HandleDMgrEventL
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::HandleDMgrEventL( RHttpDownload& aDownload,
+        THttpDownloadEvent aEvent )
+    {
+    _LIT8( KDRMHelperMimeTypeROAPTrigger, "application/vnd.oma.drm.roap-trigger+xml" );
+
+    DRMDEBUGMETHOD( RoHdlrDMgrWrDebugLiterals::KMethHandleDMgrEventL() );
+    DRMDEBUG3( RoHdlrDMgrWrDebugLiterals::KFormatMembValInt(),
+            &RoHdlrDMgrWrDebugLiterals::KMiDownLoadState(), aEvent.iDownloadState );
+    DRMDEBUG3( RoHdlrDMgrWrDebugLiterals::KFormatMembValInt(),
+            &RoHdlrDMgrWrDebugLiterals::KMiProgressState(), aEvent.iProgressState );
+
+    if ( aEvent.iProgressState == EHttpContentTypeReceived )
+        {
+        DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(),
+                &RoHdlrDMgrWrDebugLiterals::KStrEHttpContentTypeReceived() );
+        // check received mimetype
+        RBuf8 contentType;
+        contentType.CleanupClosePushL();
+        contentType.CreateL( KMaxContentTypeLength );
+        User::LeaveIfError( aDownload.GetStringAttribute( EDlAttrContentType,
+                contentType ) );
+        if ( !contentType.FindF( KDRMHelperMimeTypeROAPTrigger ) )
+            {
+            // ROAP trigger found, continue download
+            User::LeaveIfError( aDownload.Start() );
+            }
+        else
+            {
+            // wrong MIME type?, stop download
+            iDownloadSuccess = EFalse;
+            User::LeaveIfError( aDownload.Delete() );
+            }
+        CleanupStack::PopAndDestroy( &contentType );
+        }
+
+    if ( aEvent.iDownloadState == EHttpDlCreated )
+        {
+        DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(),
+                &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlCreated() );
+        }
+    else
+        if ( aEvent.iProgressState == EHttpProgDisconnected )
+            {
+            DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(),
+                    &RoHdlrDMgrWrDebugLiterals::KStrEHttpProgDisconnected() );
+            // store failure
+            iDownloadSuccess = EFalse;
+            iConnectionError = ETrue;
+            // finished
+            TRequestStatus* status( &iStatus );
+            User::RequestComplete( status, KErrCancel );
+            }
+        else
+            if ( aEvent.iDownloadState == EHttpDlInprogress )
+                {
+                DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(),
+                        &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlInprogress() );
+                }
+            else
+                if ( aEvent.iDownloadState == EHttpDlCompleted )
+                    {
+                    // store success
+                    DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(),
+                            &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlCompleted() );
+                    iDownloadSuccess = ETrue;
+
+                    // finished
+                    TRequestStatus* status( &iStatus );
+                    User::RequestComplete( status, KErrNone );
+                    }
+                else
+                    if ( aEvent.iDownloadState == EHttpDlFailed )
+                        {
+                        TInt32 err;
+
+                        DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(),
+                                &RoHdlrDMgrWrDebugLiterals::KStrEHttpDlFailed() );
+                        // store failure
+                        iDownloadSuccess = EFalse;
+                        User::LeaveIfError( aDownload.GetIntAttribute(
+                                EDlAttrErrorId, err ) );
+                        DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatEDlAttrErrorId(), err );
+
+                        if ( err == EConnectionFailed || err
+                                == ETransactionFailed )
+                            {
+                            DRMDEBUG2( RoHdlrDMgrWrDebugLiterals::KFormatMethHandleDMgrEventL(),
+                                    &RoHdlrDMgrWrDebugLiterals::KStrEConnectionFailed() );
+                            iConnectionError = ETrue;
+                            }
+
+                        // finished
+                        TRequestStatus* status( &iStatus );
+                        User::RequestComplete( status, KErrCancel );
+                        }
+    }
+
+
+// RoapObserver methods
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::PostResponseUrlL
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::PostResponseUrlL( const TDesC8& aPostResponseUrl )
+    {
+    UpdateBufferL< HBufC8, TDesC8 >( iTriggerUrl, aPostResponseUrl );
+
+    if ( !iIapId )
+        {
+        // Take AP from open conenction
+        RSocketServ socketServer;
+
+        TInt err( KErrNone );
+
+        err = socketServer.Connect();
+
+        RConnection myConnection;
+
+        err = myConnection.Open( socketServer );
+
+        TUint connectionCount( 0 );
+
+        err = myConnection.EnumerateConnections( connectionCount );
+
+        if ( err != KErrNone || connectionCount < 1 )
+            {
+            return;
+            }
+
+        TPckgBuf<TConnectionInfoV2> connectionInfo;
+
+        err = myConnection.GetConnectionInfo( connectionCount,
+                connectionInfo );
+
+        iIapId = connectionInfo().iIapId;
+
+        myConnection.Close();
+        socketServer.Close();
+        }
+    }
+
+// Trivial RoapObserver methods
+TBool CRoHandlerDMgrWrapper::ConnectionConfL()
+    {
+    return ETrue;
+    }
+
+TBool CRoHandlerDMgrWrapper::ContactRiConfL()
+    {
+    return ETrue;
+    }
+
+TBool CRoHandlerDMgrWrapper::TransIdConfL()
+    {
+    return EFalse;
+    }
+
+void CRoHandlerDMgrWrapper::RightsObjectDetailsL(
+        const RPointerArray<CDRMRights>& /*aRightsList*/ )
+    {
+    // do nothing
+    }
+
+void CRoHandlerDMgrWrapper::ContentDownloadInfoL( TPath& /*aTempFolder*/,
+        TFileName& /*aContentName*/, TInt& aMaxSize )
+    {
+    aMaxSize = -1;
+    }
+
+void CRoHandlerDMgrWrapper::ContentDetailsL( const TDesC& /*aPath*/,
+        const TDesC8& /*aType*/, const TUid& /*aAppUid*/ )
+    {
+    }
+
+void CRoHandlerDMgrWrapper::RoapProgressInfoL( const TInt /*aProgressInfo*/ )
+    {
+    // do nothing
+    }
+
+void CRoHandlerDMgrWrapper::ErrorUrlL( const TDesC8& /*aErrorUrl*/ )
+    {
+    // do nothing
+    }
+
+
+
+// CActive methods
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::DoCancel()
+    {
+    delete iRoapEng;
+    iRoapEng = NULL;
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::RunL
+// ---------------------------------------------------------------------------
+//
+void CRoHandlerDMgrWrapper::RunL()
+    {
+    User::LeaveIfError( iStatus.Int() );
+    switch ( iState )
+        {
+        //case EInit:
+        case EGetMeteringTrigger:
+            {
+            DoDownloadRoapTriggerL( ESaveMeteringTrigger );
+            }
+            break;
+        case ESaveMeteringTrigger:
+            {
+            DoSaveRoapTriggerL( EMeteringReportSubmit );
+            }
+            break;
+
+        case EMeteringReportSubmit:
+            {
+            DoHandleRoapTriggerL( EGetPrUrlTrigger );
+            }
+            break;
+        case EGetPrUrlTrigger:
+            {
+            delete iRoapEng;
+            iRoapEng = NULL;
+            DoDownloadRoapTriggerL( ESavePrUrlTrigger );
+            }
+            break;
+        case ESavePrUrlTrigger:
+            {
+            DoSaveRoapTriggerL( EPrRoapRequest );
+            }
+            break;
+        case EPrRoapRequest:
+            {
+            DoHandleRoapTriggerL( EComplete );
+            }
+            break;
+        case EComplete:
+            {
+            delete iRoapEng;
+            iRoapEng = NULL;
+            iWait.AsyncStop();
+            }
+            break;
+
+        default:
+            User::Leave( KErrNotSupported );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CRoHandlerDMgrWrapper::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CRoHandlerDMgrWrapper::RunError( TInt /* aError */ )
+    {
+    //_LIT( KCatchedError, "Catched error" );
+    //User::Panic( KCatchedError, aError );
+    if ( iWait.IsStarted() )
+        {
+        iWait.AsyncStop();
+        }
+    return KErrNone;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/BMARM/ROMTMCLIU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	NewL__22CRightsObjectMtmClientR17CRegisteredMtmDllR11CMsvSession @ 1 NONAME R3UNUSED ; CRightsObjectMtmClient::NewL(CRegisteredMtmDll &, CMsvSession &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/BMARM/ROMTMDATU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	NewMtmUiDataLayerL__FR17CRegisteredMtmDll @ 1 NONAME R3UNUSED ; NewMtmUiDataLayerL(CRegisteredMtmDll &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/BMARM/ROMTMSERU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	NewL__22CRightsObjectServerMtmR17CRegisteredMtmDllP15CMsvServerEntry @ 1 NONAME R3UNUSED ; CRightsObjectServerMtm::NewL(CRegisteredMtmDll &, CMsvServerEntry *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/BMARM/ROMTMUIU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	NewMtmUiL__FR8CBaseMtmR17CRegisteredMtmDll @ 1 NONAME R3UNUSED ; NewMtmUiL(CBaseMtm &, CRegisteredMtmDll &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/BWINS/ROMTMCLIU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewL@CRightsObjectMtmClient@@SAPAV1@AAVCRegisteredMtmDll@@AAVCMsvSession@@@Z @ 1 NONAME ; public: static class CRightsObjectMtmClient * __cdecl CRightsObjectMtmClient::NewL(class CRegisteredMtmDll &,class CMsvSession &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/BWINS/ROMTMDATU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewMtmUiDataLayerL@@YAPAVCBaseMtmUiData@@AAVCRegisteredMtmDll@@@Z @ 1 NONAME ; class CBaseMtmUiData * __cdecl NewMtmUiDataLayerL(class CRegisteredMtmDll &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/BWINS/ROMTMSERU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewL@CRightsObjectServerMtm@@SAPAV1@AAVCRegisteredMtmDll@@PAVCMsvServerEntry@@@Z @ 1 NONAME ; public: static class CRightsObjectServerMtm * __cdecl CRightsObjectServerMtm::NewL(class CRegisteredMtmDll &,class CMsvServerEntry *)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/BWINS/ROMTMUIU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewMtmUiL@@YAPAVCBaseMtmUi@@AAVCBaseMtm@@AAVCRegisteredMtmDll@@@Z @ 1 NONAME ; class CBaseMtmUi * __cdecl NewMtmUiL(class CBaseMtm &,class CRegisteredMtmDll &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/EABI/RoMtmCliU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_ZN22CRightsObjectMtmClient4NewLER17CRegisteredMtmDllR11CMsvSession @ 1 NONAME
+	_ZTI22CRightsObjectMtmClient @ 2 NONAME ; #<TI>#
+	_ZTV22CRightsObjectMtmClient @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/EABI/RoMtmDatU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,7 @@
+EXPORTS
+	_Z18NewMtmUiDataLayerLR17CRegisteredMtmDll @ 1 NONAME
+	_ZTI22CRightsObjectMtmUiData @ 2 NONAME ; #<TI>#
+	_ZTI37CRightsObjectMtmUiDataSessionObserver @ 3 NONAME ; #<TI>#
+	_ZTV22CRightsObjectMtmUiData @ 4 NONAME ; #<VT>#
+	_ZTV37CRightsObjectMtmUiDataSessionObserver @ 5 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/EABI/RoMtmSerU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_ZN22CRightsObjectServerMtm4NewLER17CRegisteredMtmDllP15CMsvServerEntry @ 1 NONAME
+	_ZTI22CRightsObjectServerMtm @ 2 NONAME ; #<TI>#
+	_ZTV22CRightsObjectServerMtm @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/EABI/RoMtmUiU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,5 @@
+EXPORTS
+	_Z9NewMtmUiLR8CBaseMtmR17CRegisteredMtmDll @ 1 NONAME
+	_ZTI18CRightsObjectMtmUi @ 2 NONAME ; #<TI>#
+	_ZTV18CRightsObjectMtmUi @ 3 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/client/inc/RoMTMCC.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,31 @@
+/*
+* Copyright (c) 2002, 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: 
+*     Miscellaneous constants needed by Ro MTM components
+*
+*/
+
+
+#ifndef ROMTMCC_H
+#define ROMTMCC_H
+
+enum TRoMtmCliPanic // RO MTM Client error codes
+    {
+    ERoBadMtmTypeUid = KErrNone+1000,
+    ERoNoCMsvEntrySet,
+    ERoEntryTypeNotSupported
+    };
+#endif      // ROMTMCC_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/client/inc/RoMtmCli.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,208 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of Rights Object Client side MTM
+*
+*/
+
+
+
+#ifndef RIGHTSOBJECTMTMCLIENT_H
+#define RIGHTSOBJECTMTMCLIENT_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <mtclbase.h>
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CRoMessageHeader;
+
+// CLASS DECLARATION
+/**
+*	CRightsObjectMtmClient
+*  
+*  @lib RoMtmCli.lib
+*  @since 2.5
+*/
+class CRightsObjectMtmClient : public CBaseMtm
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CRightsObjectMtmClient* NewL(
+					CRegisteredMtmDll& aRegisteredMtmDll , 
+					CMsvSession& aMsvSession );
+        
+		/**
+        * Destructor.
+        */
+         ~CRightsObjectMtmClient();
+
+   	public: // Functions from base classes
+
+		/*************************************
+		*
+		*		from CBaseMtm
+		*
+		**************************************/
+
+
+		// Store and restore entry data 
+		/**
+        * SaveMessageL
+        * @since 2.5
+        */
+		void SaveMessageL(); 
+
+		/**
+        * LoadMessageL
+        * @since 2.5
+        */
+		void LoadMessageL();
+
+		// Response message creation 
+
+		/**
+        * ReplyL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */	
+		CMsvOperation* ReplyL  ( TMsvId aReplyEntryId , TMsvPartList aPartlist , TRequestStatus& aCompletionStatus );
+
+		/**
+        * ForwardL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */
+		CMsvOperation* ForwardL( TMsvId aForwardEntryId , TMsvPartList aPartList , TRequestStatus& aCompletionStatus );
+
+		// Validation and search 
+		
+		/**
+        * ValidateMessage
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */	
+		TMsvPartList ValidateMessage( TUint aPartList );
+		
+		/**
+        * Find
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */			
+		TMsvPartList Find( const TDesC& aTextToFind , TMsvPartList aPartList );
+
+		// Addresses are not used in this MTM
+		
+		/**
+        * AddAddresseeL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */			
+		void AddAddresseeL( const TDesC& aRealAddress );
+		
+		/**
+        * AddAddresseeL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */			
+		void AddAddresseeL( const TDesC& aRealAddress , const TDesC& aAlias );
+		
+		/**
+        * RemoveAddressee
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */			
+		void RemoveAddressee( TInt aIndex );
+
+		// MTM-specific functionality
+
+		/**
+        * QueryCapability
+        * @since 2.5
+        * 
+		* @param aCapability UID of capability to be queried 
+		* @param aResponse Response value. The format of the response varies according to the capability
+		*
+		* @return KErrNone: aFunctionId is a recognised value and a response is returned KErrNotSupported: aFunctionId is not a recognised value 
+        */	
+		TInt QueryCapability( TUid aCapability , TInt& aResponse );
+
+		/**
+        * InvokeSyncFunctionL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */	
+		void InvokeSyncFunctionL( TInt aFunctionId , const CMsvEntrySelection& aSelection , TDes8& aParameter );
+		
+		/**
+        * InvokeAsyncFunctionL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */			
+		CMsvOperation* InvokeAsyncFunctionL( TInt aFunctionId , const CMsvEntrySelection& aSelection , TDes8& aParameter , TRequestStatus& aCompletionStatus );
+		
+	protected:  
+
+		CRightsObjectMtmClient( CRegisteredMtmDll& aRegisteredMtmDll , CMsvSession& aMsvSession );
+
+		void ConstructL();        
+
+		/*************************************
+		*
+		*		from CBaseMtm
+		*
+		**************************************/
+		void ContextEntrySwitched(); 
+
+    protected:  // Functions from base classes
+    private:
+//		void SetEntryDetailsL();
+//		void SetEntryDescriptionL();
+	public:     // Data
+    protected:  // Data
+    private:    // Data
+//		CRoMessageHeader* iHeader;
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+    };
+
+
+
+#endif      // RIGHTSOBJECTMTMCLIENT_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/client/src/RoMtmCli.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,372 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Rights Object Client side MTM
+*
+*/
+
+
+
+// INCLUDE FILES
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include <mtmuidsdef.hrh>
+#endif
+#include <e32std.h>
+#include <txtrich.h>
+#include <msvreg.h>
+#include <msvstore.h>    // cmsvstore
+#include <msvids.h>      // kmsvlocalserviceindexentryid
+#include <mtmdef.h>      // kmsvmessagepartbody
+#include <msvuids.h>     // kuidmsvmessageentry
+#include <sysutil.h>     // disk space checking
+
+#include    "romtmcli.h"
+#include    "romtmcc.h"
+#include    "romtmcommon.h"
+GLREF_C void Panic( TRoMtmCliPanic aPanic );
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+
+
+/*************************************
+*
+*        Construction and destruction
+*
+**************************************/
+
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::CRightsObjectMtmClient
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRightsObjectMtmClient::CRightsObjectMtmClient(
+    CRegisteredMtmDll& aRegisteredMtmDll ,
+    CMsvSession& aMsvSession
+    )
+: CBaseMtm(aRegisteredMtmDll , aMsvSession )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::ConstructL()
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmClient::ConstructL()
+    {
+    SwitchCurrentEntryL( KMsvRootIndexEntryId );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient* CRightsObjectMtmClient::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CRightsObjectMtmClient* CRightsObjectMtmClient::NewL(
+    CRegisteredMtmDll& aRegisteredMtmDll ,
+    CMsvSession& aMsvSession
+    )
+// Factory function
+    {
+    CRightsObjectMtmClient* self = new ( ELeave ) CRightsObjectMtmClient( aRegisteredMtmDll , aMsvSession );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CRightsObjectMtmClient::~CRightsObjectMtmClient()
+    {
+    }
+
+/*************************************
+*
+*        from CBaseMtm
+*
+**************************************/
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::AddAddresseeL
+//
+// Not supported
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmClient::AddAddresseeL( const TDesC& /*aRealAddress*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::AddAddresseeL
+//
+// Not supported
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmClient::AddAddresseeL( const TDesC& /*aRealAddress*/ ,
+    const TDesC& /*aAlias*/ )
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::RemoveAddressee
+//
+// Not supported
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmClient::RemoveAddressee( TInt /*aIndex*/ )
+    {
+    // Not supported.
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::SaveMessageL
+//
+// Commits cached changes to the storage controlled by the Message Server
+// can only be called on message contexts.
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmClient::SaveMessageL()
+    // Store entry data
+    {
+    TMsvEntry indexEntry( iMsvEntry->Entry() );
+    RFs& fs( Session().FileSession() );
+    const CRichText* body( &Body() );
+
+    if ( !body )
+        {
+        User::Leave( KErrArgument );
+        }
+    // check if there is space for text to be saved
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL(
+            &fs,
+            body->DocumentLength() * sizeof( TText ),
+            RFs::GetSystemDrive() ) )
+        {
+        User::Leave( KErrDiskFull );
+        }
+
+
+    // get an editable message store
+    CMsvStore* store( iMsvEntry->EditStoreL() );
+    CleanupStack::PushL( store );
+
+    switch ( iMsvEntry->Entry().iType.iUid )
+        {
+        case KUidMsvMessageEntryValue:
+                {
+                StoreBodyL( *store );
+                break;
+                }
+        default:
+                {
+                User::Leave( KErrNotSupported );
+                break;
+                }
+        }
+    // commit the index changes.
+    iMsvEntry->ChangeL( indexEntry );
+    store->CommitL();
+    CleanupStack::PopAndDestroy( store );
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::LoadMessageL
+//
+// Loads the cache with the message data for the current context
+// can only be called on message contexts.
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmClient::LoadMessageL()
+    {
+    TMsvEntry indexEntry( iMsvEntry->Entry() );
+    switch ( indexEntry.iType.iUid )
+        {
+        case KUidMsvMessageEntryValue:
+                {
+                // get read-only message store
+                Body().Reset();
+                CMsvStore* store( iMsvEntry->ReadStoreL() );
+                CleanupStack::PushL( store );
+                RestoreBodyL( *store );
+                CleanupStack::PopAndDestroy( store );
+                break;
+                }
+        default:
+            // if we fall through here, we should panic because
+            // we have wrong entry type
+                {
+                User::Leave( KErrNotSupported );
+                break;
+                }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::ReplyL
+//
+// Not supported
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmClient::ReplyL (
+    TMsvId /*aReplyEntryId*/ ,
+    TMsvPartList /*aPartlist*/ ,
+    TRequestStatus& /*aCompletionStatus*/ )
+    {
+    User::Leave( KErrNotSupported );
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::ForwardL
+//
+// Not supported
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmClient::ForwardL(
+    TMsvId /*aForwardEntryId*/ ,
+    TMsvPartList /*aPartList*/ ,
+    TRequestStatus& /*aCompletionStatus*/ )
+    {
+    User::Leave( KErrNotSupported );
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::ValidateMessage
+//
+// Not supported
+// -----------------------------------------------------------------------------
+//
+TMsvPartList CRightsObjectMtmClient::ValidateMessage( TUint /*PartList*/ )
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::Find
+//
+// Not supported
+// -----------------------------------------------------------------------------
+//
+TMsvPartList CRightsObjectMtmClient::Find( const TDesC& /*aTextToFind*/ , TMsvPartList /*aPartList*/ )
+    // Find text in entry
+    {
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::QueryCapability
+//
+// Queries if the MTM supports a particular capability, specified by a UID.
+// -----------------------------------------------------------------------------
+//
+TInt CRightsObjectMtmClient::QueryCapability( TUid aCapability , TInt& aResponse )
+    // Query for capability
+    {
+    TInt error( KErrNone );
+    switch ( aCapability.iUid )
+        {
+        case KUidMtmQueryMaxBodySizeValue:
+        case KUidMtmQueryMaxTotalMsgSizeValue:
+                {
+                aResponse = KMaxRoMessageSize;
+                break;
+                }
+        case KUidMtmQuerySupportedBodyValue:
+                {
+                aResponse = KMtm7BitBody | KMtm8BitBody |
+                    KMtm16BitBody | KMtmBinaryBody;
+                break;
+                }
+        case KUidMtmQuerySupportSubjectValue:
+        case KUidMtmQueryOffLineAllowedValue:
+                {
+                aResponse=ETrue;
+                break;
+                }
+        default:
+                {
+                error = KErrNotSupported;
+                }
+        }
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::InvokeSyncFunctionL
+//
+// Not supported
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmClient::InvokeSyncFunctionL(
+    TInt /*aFunctionId*/ ,
+    const CMsvEntrySelection& /*aSelection*/ ,
+    TDes8& /*aParameter*/ )
+// Call MTM-specific operation synchronously
+    {
+    User::Leave( KErrNotSupported );
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::InvokeAsyncFunctionL
+//
+// Not supported
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmClient::InvokeAsyncFunctionL(
+    TInt /*aFunctionId*/ ,
+    const CMsvEntrySelection& /*aSelection*/ ,
+    TDes8& /*aParameter*/ ,
+    TRequestStatus& /*aCompletionStatus*/ )
+// Call MTM-specific operation asynchronously
+    {
+    User::Leave( KErrNotSupported );
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmClient::ContextEntrySwitched
+//
+// Not supported
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmClient::ContextEntrySwitched()
+    // Context change notification
+    //
+    // No need to know entry changes
+    //
+    {
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/group/RoMtmCli.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Rights Object Client side MTM
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          RoMtmCli.dll
+TARGETTYPE      dll
+UID             0x10003C5F 0x101F6DC0
+TARGETPATH      SHARED_LIB_DIR
+
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../client/src
+SOURCE          RoMtmCli.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../client/inc
+USERINCLUDE     ../../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY   euser.lib
+LIBRARY   msgs.lib
+LIBRARY   sysutil.lib
+LIBRARY   efsrv.lib
+
+SMPSAFE
+
+// EXPORTUNFROZEN
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/group/RoMtmDat.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,64 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          RoMtmDat.dll
+TARGETTYPE      dll
+UID             0x10003C61 0x101F6DBF
+TARGETPATH      SHARED_LIB_DIR
+
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../uiData/src
+SOURCE          RoMtmDat.cpp
+
+START RESOURCE  RoMtmReg.rss
+TARGET          RoMtmReg.rsc
+TARGETPATH      MTM_INFO_FILE_DIR
+LANGUAGE_IDS
+END
+
+START RESOURCE  RoMtmUi.rss
+HEADER
+TARGETPATH      MTM_RESOURCE_DIR
+LANGUAGE_IDS
+END
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../uiData/inc
+USERINCLUDE     ../../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+APP_LAYER_SYSTEMINCLUDE
+
+LIBRARY   euser.lib
+LIBRARY   mtur.lib
+LIBRARY   msgs.lib
+LIBRARY   CommonEngine.lib
+LIBRARY   efsrv.lib
+LIBRARY   AknSkins.lib
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY   platformenv.lib
+#endif
+
+SMPSAFE
+
+// EXPORTUNFROZEN
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/group/RoMtmSer.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          RoMtmSer.dll
+TARGETTYPE      dll
+UID             0x10003C5E 0x101F6DC1
+TARGETPATH      SHARED_LIB_DIR
+
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../server/src
+SOURCE          RoMtmSer.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../server/inc
+USERINCLUDE     ../../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY   euser.lib
+LIBRARY   msgs.lib
+
+SMPSAFE
+
+// EXPORTUNFROZEN
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/group/RoMtmUi.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file
+*
+*/
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          RoMtmUi.dll
+TARGETTYPE      dll
+UID             0x10004845 0x101F6DBE
+TARGETPATH      SHARED_LIB_DIR
+
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../ui/src
+SOURCE          RoMtmui.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../ui/inc
+USERINCLUDE     ../../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY   euser.lib efsrv.lib
+LIBRARY   msgs.lib mtur.lib
+LIBRARY   apparc.lib cone.lib
+LIBRARY   avkon.lib //dialog
+LIBRARY   apgrfx.lib //RApaLsSession
+LIBRARY   ServiceHandler.lib
+LIBRARY   commonui.lib//CDocumentDandler
+LIBRARY   apmime.lib  //TDataType
+LIBRARY   ROAPHandler.lib // CRoapEng
+LIBRARY   commonengine.lib // resource loader
+
+#ifdef RD_MULTIPLE_DRIVE
+LIBRARY   platformenv.lib
+#endif
+
+SMPSAFE
+
+// EXPORTUNFROZEN
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+    DEFAULT -ARMI
+
+
+PRJ_EXPORTS
+../client/inc/romtmcli.h
+../server/inc/romtmser.h
+../loc/romtmui.loc MW_LAYER_LOC_EXPORT_PATH( romtmui.loc )
+
+
+PRJ_MMPFILES
+
+RoMtmCli.mmp
+RoMtmSer.mmp
+RoMtmUi.mmp
+RoMtmDat.mmp
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/inc/RoMTMCommon.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* Copyright (c) 2002, 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: 
+*     Common constants for various RoMTM dll's 
+*
+*/
+
+
+#ifndef ROMTMCOMMON_H
+#define ROMTMCOMMON_H
+
+
+
+// RoMTM UIDs
+LOCAL_D const TInt KUidMsgTypeRoValue = 0x101F6DC2; 
+LOCAL_D const TUid KUidMsgTypeRo = { KUidMsgTypeRoValue};
+LOCAL_D const TInt KUidTechnologyTypeRoValue = 0x10009157;
+LOCAL_D const TUid theTechnologyTypeUid	= { KUidTechnologyTypeRoValue };
+
+LOCAL_D const TUid KUidMsvMtmRoServerDLL	={0x101F6DC1};
+LOCAL_D const TUid KUidMsvMtmRoClientDLL	={0x101F6DC0};
+LOCAL_D const TUid KUidMsvMtmRoUiDLL		={0x101F6DBE};
+LOCAL_D const TUid KUidMsvMtmRoUiDataDLL	={0x101F6DBF};
+
+// Constants
+LOCAL_D const TInt KMaxRoMessageSize = 0xFFFF;
+
+#endif      // ROMTMCOMMON_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/loc/RoMtmUi.loc	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,425 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     This file contains the localised strings for RoMTM
+*
+*
+*/
+
+
+//  LOCALISATION STRINGS
+
+//d: Second line of the Inbox list item
+//d: Shown when device is joining to account or leaving from account.
+//l: list_double_graphic_pane_t2_cp2
+//w:
+//r: 3.0
+//
+#define qtn_drm_roap_trigger_msg_domain "Account configuration"
+
+// d: Second line of the Inbox list item
+// l: list_double_graphic_pane_t2_cp2
+//
+#define qtn_drm_mgr_inb_title			"Usage rights"
+
+// d: Confirmation query - MMS access points are either missing or contain settings that are not valid.
+// d: This query is given when starting to write a new or edit an existing multimedia message.
+// l: popup_note_window
+//
+#define qtn_mce_conf_no_ap              "No access point defined or it is not valid. Modify now?"
+
+// d: Submenu item in mce application that starts writing a multimedia message.
+// l: list_single_popup_submenu_pane_t1
+//
+#define qtn_mce_inbox_write_mms         "Rights Object message"
+
+// d: Popup query item in mce application that starts writing a multimedia message.
+// l: list_single_pane_t1_cp2
+//
+#define qtn_mce_pop_up_mms              "Rights Object message"
+
+// d: Settings dialog item in mce application for multimedia messaging settings.
+// l: list_double_pane_t1_cp2
+//
+#define qtn_mce_settings_mms            "Rights Object message"
+
+// Note: qtn_options_send_via_mms is in avkon.loc
+
+// d: Multimedia message settings dialog title
+// l: title_pane_t2/opt12
+//
+#define qtn_mce_title_settings_mms      "Rights Object message"
+
+// d: Multimedia message sending settings dialog menu item.
+// d: Change selected item.
+// l: list_single_pane_t1_cp2
+//
+#define qtn_mms_om_change               "Change"
+
+// d: Multimedia message settings dialog menu item.
+// d: Change selected item.
+// l: list_single_pane_t1_cp2
+//
+#define qtn_mce_settings_change         "Change"
+
+// d: Multimedia message settings dialog menu item.
+// d: Closes settings dialog.
+// l: list_single_pane_t1_cp2
+//
+#define qtn_mce_settings_exit           "Exit"
+
+
+// d: Multimedia message settings list item.
+// d: If chosen opens a dialog to select a WAP access point.
+// l: list_setting_pane_t1
+//
+#define qtn_mce_mms_pc                  "Connection"
+
+// d: Multimedia message settings list item value
+// d: Means that this access point is not defined.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_none       "None"
+
+// d: Multimedia message settings list item.
+// d: If chosen opens a dialog to select when to receive MMS messages (e.g. enabled in home network).
+// l: list_setting_pane_t1
+//
+#define qtn_mms_stng_mms_reception      "MMS reception"
+
+// d: Multimedia message settings list item.
+// d: If chosen opens a dialog to select what to do when receiving MMS notifications & MMS receiving is enabled (e.g. fetch)
+// l: list_setting_pane_t1
+//
+#define qtn_mms_stng_mms_rctp_enabled   "When Enabled"
+
+// d: Multimedia message settings list item.
+// d: If chosen opens a dialog to select to select receive mode for anonymous (sender unknown) messages.
+// l: list_setting_pane_t1
+//
+#define qtn_mce_mms_fetch_anonymous     "Fetch anonymous messages"
+
+// d: Multimedia message settings list item.
+// d: If chosen opens a dialog to select receive mode for multimedia message advertisements.
+// l: list_setting_pane_t1
+//
+#define qtn_mce_mms_receive_ad          "Receiving of advertisements"
+
+// d: Multimedia message settings list item.
+// d: If chosen opens a dialog to select the default delivery report status (yes/no).
+// l: list_setting_pane_t1
+//
+#define qtn_mce_mms_dr                  "Delivery report"
+
+// d: Multimedia message settings list item.
+// d: If chosen opens a dialog to select the status of allowing sending of delivery reports for received multimedia messages.
+// l: list_setting_pane_t1
+//
+#define qtn_mce_mms_deny_dr             "Deny sending of delivery reports"
+
+// d: Multimedia message settings list item.
+// d: If chosen opens a dialog to select the default validity period.
+// l: list_setting_pane_t1
+//
+#define qtn_mce_mms_validity_period     "Validity period"
+
+// d: Multimedia message settings list item.
+// d: If chosen opens a dialog to select the default image resolution limit.
+// l: list_setting_pane_t1
+//
+#define qtn_mce_mms_image_size          "Image size"
+
+// d: Multimedia message settings list item.
+// d: If chosen opens a dialog to select the default speaker to be used in multimedia message viewing.
+// l: list_setting_pane_t1
+//
+#define qtn_mce_mms_ihf                 "Default speaker"
+
+// d: Confirmation query - user must confirm the made selection.
+// d: Given when "always enabled" has been selected for "MMS reception".
+// l: popup_note_window
+//
+#define qtn_mms_sttng_enabled_conf_q    "Automatic MMS message reception creates network connections independently. This can be more costly while roaming. Do you wish to set this to always enabled?"
+
+// d: Confirmation query - user must accept erroneous settings
+// d: Given when settings are erroneous and user is exiting MMS Settings dialog.
+// l: popup_note_window
+//
+#define qtn_mce_settings_mms_invalid    "Multimedia message doesn't work without Connection. Exit anyway?"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Sets multimedia message receiving to be on in home network & off in roaming.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mms_stng_mms_rcpt_enab_home "Enabled in home network"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Sets multimedia message receiving to be always on, i.e. both in home network & in roaming.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mms_stng_mms_rcpt_enab_alw  "Always enabled"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Sets multimedia message receiving to be always off, i.e. both in home network & in roaming.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mms_stng_mms_rcpt_disenab   "Disabled"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: If MMS receiving is currently on (enabled), sets that multimedia messages are tried to fetch automatically.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mms_stng_rctp_enab_ftch     "Fetch"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: If MMS receiving is currently on (enabled), sets that multimedia messages are not fetched now.
+// d: Multimedia service center is notified that the message is fetched later.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mms_stng_rctp_enab_pstp     "Postpone"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: If MMS receiving is currently on (enabled), sets that multimedia messages are not fetched.
+// d: Multimedia service center is notified that the message can be destroyed. It will not be fetched ever.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mms_stng_rctp_enab_reject   "Reject"
+
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Requests delivery reports for sent messages.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_yes        "Yes"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Does not request delivery reports for sent messages.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_no         "No"
+
+
+//
+// MMS editor sending settings
+//
+
+// d: Multimedia message sending settings list item.
+// d: If chosen opens a dialog to select the delivery report status (yes/no) for the current message.
+// l: list_setting_pane_t1
+//
+#define qtn_mms_setting_delivery_report "Delivery report"
+
+// d: Multimedia message sending settings list item.
+// d: If chosen opens a dialog to select the validity period for the current message.
+// l: list_setting_pane_t1
+//
+#define qtn_mms_setting_validity_period "Validity period"
+
+// d: Multimedia message sending settings list item.
+// d: If chosen opens a dialog to select the image resolution limit for the current message.
+// l: list_setting_pane_t1
+//
+#define qtn_mms_setting_image_size      "Image size"
+
+// d: Title for the multimedia message sending settings dialog.
+// l: title_pane_t2/opt12
+//
+#define qtn_mms_title_sending_options   "Sending options"
+
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Requests vality period time of one hour for sent messages.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_1          "1 h"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Requests vality period time of six hours for sent messages.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_6          "6 h"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Requests vality period time of 1 day for sent messages.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_24         "24 h"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Requests vality period time of three days for sent messages.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_3          "3 days"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Requests vality period time of one week for sent message´s.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_week       "Week"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Requests maximum vality period time for sent messages.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_maximum    "Maximum"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Largest image resolution value to be used in sending images.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_large      "Large"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Smallest image resolution value to be used in sending images.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_small      "Small"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Default value for the audio speaker - integrated handsfree.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_ihf_hf     "Handsfree"
+
+// d: Multimedia message setting item list value. Also a choice item in a select dialog.
+// d: Default value for the audio speaker - handset.
+// l: list_set_graphic_pane_t1
+//
+#define qtn_mce_settings_mms_ihf_hs     "Handset"
+
+
+//
+// Message info
+//
+
+// d: Message info popup item value
+// d: Type of the message.
+// l: list_single_heading_pane_t1_cp2
+//
+#define qtn_mms_msginfo_mms           	"Multimedia message"
+
+// d: Command in options list in Mce. 
+// d: Opens Message info dialog
+// d: Visible when one message selected.
+// l: list_single_pane_t1_cp2
+//
+#define qtn_mce_info                    "Message info"
+
+// d: Message info popup item.
+// d: Sender of the message. Shown in the case of a received message, i.e. a mobile terminated.
+// l: list_single_heading_pane_t2_cp2
+//
+#define qtn_mms_from                    "from"
+
+// d: Message info popup item.
+// d: Subject of the message. Shown empty if there's no subject.
+// l: list_single_heading_pane_t2_cp2
+//
+#define qtn_mms_subject                 "subject"
+
+// d: Message info popup item.
+// d: For mobile terminated messages: the date the message was received in MMSC.
+// d: For mobile originated message: the date the message was last modified (=saved).
+// l: list_single_heading_pane_t2_cp2
+//
+#define qtn_mms_date                    "date"
+
+// d: Message info popup item.
+// d: For mobile terminated messages: the time the message was received in MMSC.
+// d: For mobile originated message: the time the message was last modified (=saved).
+// l: list_single_heading_pane_t2_cp2
+//
+#define qtn_mms_time                    "time"
+
+// d: Message info popup item.
+// d: The type of the message. Always: multimedia message.
+// d: For mobile originated message: the date the message was last modified (=saved).
+// l: list_single_heading_pane_t2_cp2
+//
+#define qtn_mms_type                    "type"
+
+// d: Message info popup item.
+// d: The size of the whole multimedia message including content and the headers.
+// l: loc_type_pane
+//
+#define qtn_mms_size                    "size"
+
+// d: Message info popup item.
+// d: Recipients of the multimedia message.
+// l: list_single_heading_pane_t2_cp2
+//
+#define qtn_mms_to                      "to"
+
+
+// Outbox statuses
+
+// d: A status of the message when waiting for sending in Outbox
+// d: listbox text
+// l: list_double_graphic_pane_t2_cp2
+//
+#define qtn_mce_outbox_status_sending   "Sending"
+
+// d: A status of the message when waiting for sending in Outbox
+// d: listbox text
+// l: list_double_graphic_pane_t2_cp2
+//
+#define qtn_mce_outbox_status_waiting   "Waiting"
+
+// d: A status of the message when waiting for sending in Outbox
+// d: listbox text
+// l: list_double_graphic_pane_t2_cp2
+//
+#define qtn_mce_outbox_status_retry_at  "Retry at %U"
+
+// d: A status of the message when waiting for sending in Outbox
+// d: listbox text
+// l: list_double_graphic_pane_t2_cp2
+//
+#define qtn_mce_outbox_status_suspended "Suspended"
+
+// d: A status of the message when waiting for sending in Outbox
+// d: listbox text
+// l: list_double_graphic_pane_t2_cp2
+//
+#define qtn_mce_outbox_status_queued    "Queued"
+
+// d: A status of the message when waiting for sending in Outbox
+// d: listbox text
+// l: list_double_graphic_pane_t2_cp2
+//
+#define qtn_mce_outbox_status_failed    "Failed"
+
+
+//d:Confirmation query text used when triggering rights acquisition
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_query_rights_acq_msg   "Connect to server to get a licence?"
+
+//d:Confirmation query text used when triggering registration to a domain
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_query_join_domain_msg   "Connect to server to register the phone?"
+
+//d:Confirmation query text used when triggering unregistration to a domain
+//l:popup_note_window
+//w:
+//r:3.0
+//
+#define qtn_drm_query_leave_domain_msg    "Connect to server to unregister the phone?"
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/server/inc/RoMtmSer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,219 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of Rights Object Server side MTM
+*
+*/
+
+
+#ifndef RIGHTSOBJECTSERVERMTM_H
+#define RIGHTSOBJECTSERVERMTM_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <mtclbase.h>
+#include <mtsr.h>
+#include <MSVSTORE.H>
+#include <MSVUIDS.H>
+#include <MSVIDS.H>
+
+
+
+// CONSTANTS
+
+// MACROS
+// DATA TYPES
+
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+/**
+*	CRightsObjectServerMtm
+*  
+*  @lib RoMtmSer.lib
+*  @since 2.5
+*/
+
+
+//
+//	CRightsObjectServerMtm: The Server-side MTM implementation
+//
+class CRightsObjectServerMtm : public CBaseServerMtm
+	{
+	public:
+
+
+
+	// Constructor, initialisation, and destructor 
+
+        /**
+        * Two-phased constructor.
+        */
+		IMPORT_C static CRightsObjectServerMtm* NewL( CRegisteredMtmDll& aRegisteredMtmDll , CMsvServerEntry* aInitialEntry );
+	
+        /**
+        * Destructor.
+        */		
+		~CRightsObjectServerMtm();
+
+		/*************************************
+		*
+		*		from CBaseMtm
+		*
+		**************************************/
+		// Copy and move 
+		
+		/**
+        * CopyToLocalL
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */
+		void CopyToLocalL( const CMsvEntrySelection& aSelection , TMsvId aDestination , TRequestStatus& aStatus );
+
+		/**
+        * CopyFromLocalL
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */
+		void CopyFromLocalL( const CMsvEntrySelection& aSelection , TMsvId aDestination , TRequestStatus& aStatus );
+
+		/**
+        * CopyToLocalL
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */		
+		void CopyWithinServiceL( const CMsvEntrySelection& aSelection , TMsvId aDestination , TRequestStatus& aStatus );
+		
+		/**
+        * MoveToLocalL
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */		
+		void MoveToLocalL( const CMsvEntrySelection& aSelection , TMsvId aDestination , TRequestStatus& aStatus );
+		
+		/**
+        * MoveFromLocalL
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */
+		void MoveFromLocalL( const CMsvEntrySelection& aSelection , TMsvId aDestination , TRequestStatus& aStatus );
+		
+		/**
+        * MoveWithinServiceL
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */
+		void MoveWithinServiceL( const CMsvEntrySelection& aSelection , TMsvId aDestination , TRequestStatus& aStatus );
+
+		// Create, change, delete 
+		
+		/**
+        * DeleteAllL
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */
+		void DeleteAllL( const CMsvEntrySelection& aSelection , TRequestStatus& aStatus );
+		
+		/**
+        * CreateL
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */
+		void CreateL( TMsvEntry aNewEntry , TRequestStatus& aStatus );
+		
+		/**
+        * ChangeL
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */
+		void ChangeL( TMsvEntry aNewEntry , TRequestStatus& aStatus );
+
+		// Command and progress
+		
+		/**
+        * StartCommandL
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */
+		void StartCommandL( CMsvEntrySelection& aSelection , TInt aCommand , 
+			const TDesC8& aParameter , TRequestStatus& aStatus );
+		
+		/**
+        * CommandExpected
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */
+		TBool CommandExpected();
+		
+		
+		/**
+        * Progress
+        * @since 2.5
+        * 
+		* Not Supported
+		*
+        */
+		const TDesC8& Progress();
+
+		// void RunL()
+		// void SetInitialEntry(CMsvServerEntry* aEntry)=0;
+	protected:
+  
+		/*************************************
+		*
+		*		from CActive
+		*
+		**************************************/
+		void DoCancel();
+		/*************************************
+		*
+		*		from CBaseMtm
+		*
+		**************************************/
+		void DoRunL();
+		void DoComplete(TInt aError);
+
+	private:
+		CRightsObjectServerMtm( CRegisteredMtmDll& aRegisteredMtmDll , CMsvServerEntry* aInitialEntry );
+		void ConstructL();
+
+	private:
+	};
+
+#endif      // RIGHTSOBJECTSERVERMTM_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/server/src/RoMtmSer.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,332 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of Rights Object Server side MTM
+*
+*/
+
+
+
+// INCLUDE FILES
+#if !defined(__MSVENTRY_H__)
+#include <msventry.h>
+#endif
+
+#if !defined(__TXTRICH_H__)
+#include <txtrich.h>
+#endif
+
+#include "RoMtmSer.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+//
+// ---------------------------------------------------------
+// E32Dll implements
+// function that is called when a dll is loaded.
+// This function must be present in all dlls.
+// Returns: error code: KErrNone
+//
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::CRightsObjectServerMtm
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRightsObjectServerMtm::CRightsObjectServerMtm( CRegisteredMtmDll& aRegisteredMtmDll , CMsvServerEntry* aInitialEntry )
+	: 	CBaseServerMtm( aRegisteredMtmDll , aInitialEntry )
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::ConstructL()
+	{
+	CActiveScheduler::Add( this );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CRightsObjectServerMtm* CRightsObjectServerMtm::NewL( CRegisteredMtmDll& aRegisteredMtmDll , CMsvServerEntry* aInitialEntry )
+// Exported factory function
+	{
+	CleanupStack::PushL( aInitialEntry );
+	CRightsObjectServerMtm* self=new ( ELeave ) CRightsObjectServerMtm( aRegisteredMtmDll , aInitialEntry );
+	CleanupStack::Pop();
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+// Destructor
+CRightsObjectServerMtm::~CRightsObjectServerMtm()
+	{
+	Cancel();
+	}
+
+//
+// Copy and move functions
+//
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::CopyToLocalL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::CopyToLocalL( const CMsvEntrySelection& /*aSelection*/ , TMsvId /*aDestination*/ , 
+								  TRequestStatus& /*aStatus*/ )
+// Get remote entries (by copying)
+	{
+	User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::CopyFromLocalL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::CopyFromLocalL( const CMsvEntrySelection& /*aSelection*/ , TMsvId /*aDestination*/ , 
+									TRequestStatus& /*aStatus*/ )
+// Transfer to remote (by copying)
+	{
+	User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::CopyWithinServiceL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::CopyWithinServiceL( const CMsvEntrySelection& /*aSelection*/ , TMsvId /*aDestination*/ , 
+										TRequestStatus& /*aStatus*/ )
+// Copy entries within service 
+	{
+	User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::MoveToLocalL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::MoveToLocalL( const CMsvEntrySelection& /*aSelection*/ , TMsvId /*aDestination*/ , 
+								  TRequestStatus& /*aStatus*/ )
+// Get remote entries (by moving)
+	{
+	User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::MoveFromLocalL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::MoveFromLocalL( const CMsvEntrySelection& /*aSelection*/ , TMsvId /*aDestination*/ , 
+									TRequestStatus& /*aStatus*/ )
+// Transfer to remote (by moving)
+	{
+	User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::MoveWithinServiceL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::MoveWithinServiceL( const CMsvEntrySelection& /*aSelection*/ , TMsvId /*aDestination*/ , 
+										TRequestStatus& /*aStatus*/ )
+// Move entries within service 
+	{
+	User::Leave( KErrNotSupported );
+	}
+
+//
+// Create, change, delete functions
+//
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::DeleteAllL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::DeleteAllL( const CMsvEntrySelection& /*aSelection*/ , TRequestStatus& /*aStatus*/ )
+// Delete entries recursively 
+	{
+	User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::CreateL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::CreateL(TMsvEntry /*aNewEntry*/, TRequestStatus& /*aStatus*/ )
+// Remote creation (other than by copying) not supported 
+//
+	{
+	User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::ChangeL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::ChangeL(TMsvEntry /*aNewEntry*/ , TRequestStatus& /*aStatus*/ )
+// Change entry 
+//
+// This function could change file names in the file system. It would then also have
+// to change the details field of all the children of a changed folder name.
+// Not supported for now.
+//
+	{
+	User::Leave( KErrNotSupported );
+	}
+
+
+
+//
+// Command and progress functions
+//
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::StartCommandL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::StartCommandL(
+								CMsvEntrySelection& /*aSelection*/ ,
+								TInt /*aCommand*/ , 
+								const TDesC8& /*aParameter*/, 
+								TRequestStatus& /*aStatus*/ 
+								)
+// Run MTM-specific command on selection of entries 
+// Only command supported is Refresh
+	{
+    User::Leave( KErrNotSupported );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::CommandExpected
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectServerMtm::CommandExpected()
+// Prevent object deletion on command completion
+// Allow unloading
+	{
+	return ETrue;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::Progress
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+const TDesC8& CRightsObjectServerMtm::Progress()
+// Pass-back progress information
+	{
+    return KNullDesC8;
+	}
+
+//
+//  Active object completion functions
+//
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::DoCancel
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::DoCancel()
+// Cancel current operation
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::DoComplete
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::DoComplete(TInt /*aError*/ )
+// Active object complete leave handler
+//
+// Never expect this to be called
+// as CRightsObjectServerMtm::DoRunL() does not leave
+	{
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectServerMtm::DoRunL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectServerMtm::DoRunL()
+// Active object completion
+//
+// Run is used in this object to clean up after operations have finished.
+//
+	{
+	}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/ui/inc/RoMTMUiC.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,35 @@
+/*
+* Copyright (c) 2002, 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: 
+*     
+*
+*/
+
+
+#ifndef ROMTMUIC_H
+#define ROMTMUIC_H
+
+
+_LIT(KRoMtmResourceFile,"RoMtmUI.rsc");
+
+enum TRoMtmUiPanic
+	{
+	ERoMtmUiOnlyWorksWithMessageEntries,
+	ERoMtmUiEmptySelection,
+	ERoMtmUiWrongMtm,
+	ERoMtmUiWrongEntryType
+	};
+#endif      // ROMTMUIC_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/ui/inc/RoMtmUi.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,220 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of Rights Object MTM UI
+*
+*/
+
+
+#ifndef RIGHTSOBJECTMTMUI_H
+#define RIGHTSOBJECTMTMUI_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <mtmuibas.h>
+#include <aknserverapp.h>
+ 
+// CONSTANTS
+// MACRightsObjectS
+// DATA TYPES
+enum TMessageType
+    {
+    ERo, //open RO manager embedded
+    ERoapTrigger, //open roap with file name
+    ERoapTriggerRoAcquisition // remove prefix and open roap with file name.
+    };
+// FUNCTION PROTOTYPES
+
+// FORWARD DECLARATIONS
+class CAknLaunchAppService;
+
+class CDocumentHandler;
+
+
+// CLASS DECLARATION
+/**
+*	CRightsObjectMtmUi
+*  
+*  @lib romtmui.lib
+*  @since 2.5
+*/
+//
+// CRightsObjectMtmUi: User Interface MTM
+//
+class CRightsObjectMtmUi : public CBaseMtmUi , public MAknServerAppExitObserver , public MApaServerAppExitObserver
+	{
+	public:
+		// Construction
+        /**
+        * Two-phased constructor.
+        */
+		static CRightsObjectMtmUi* NewL( CBaseMtm& aBaseMtm , CRegisteredMtmDll& aRegisteredMtmDll );
+
+		// Destruction
+
+        /**
+        * Destructor.
+        */
+		~CRightsObjectMtmUi();
+
+		/*************************************
+		*
+		*		from CBaseMtmUi
+		*
+		**************************************/
+
+
+        /**
+        * CancelL.
+        * @since 2.5
+		*
+		* Not Supported
+		*
+        */
+		CMsvOperation* CancelL( TRequestStatus& aStatus, const CMsvEntrySelection& aSelection );
+
+		// Context-specific
+        /**
+        * OpenL.
+        * @since 2.5
+		*
+		* @param aStatus The request status to be completed when the operation has finished
+		* @return If successful, this is an asynchronously completing open operation. 
+		*         If failed, this is a completed operation, with status set to the relevant error code.
+        */
+		CMsvOperation* OpenL( TRequestStatus& aStatus ); 
+		
+        /**
+        * OpenL.
+        * @since 2.5
+		*
+		* @param aStatus The request status to be completed when the operation has finished
+		* @param aSelection Selection of message entries 
+		* @return If successful, this is an asynchronously completing open operation. 
+		*         If failed, this is a completed operation, with status set to the relevant error code.
+        */
+		CMsvOperation* OpenL( TRequestStatus& aStatus , const CMsvEntrySelection& aSelection ); 
+
+        /**
+        * CloseL.
+        * @since 2.5
+		*
+		* Not Supported
+		*
+        */
+		CMsvOperation* CloseL( TRequestStatus& aStatus ); 
+		
+		/**
+        * CloseL.
+        * @since 2.5
+		*
+		* Not Supported
+		*
+        */
+		CMsvOperation* CloseL( TRequestStatus& aStatus , const CMsvEntrySelection& aSelection );
+
+		// Launches editor/settings dialog as appropriate  
+		/**
+        * EditL.
+        * @since 2.5
+		*
+		* Not Supported
+		*
+        */
+		CMsvOperation* EditL( TRequestStatus& aStatus );
+		
+		/**
+        * EditL.
+        * @since 2.5
+		*
+		* Not Supported
+		*
+        */
+		CMsvOperation* EditL( TRequestStatus& aStatus , const CMsvEntrySelection& aSelection ) ;
+
+		// Launches viewer/settings dialog as appropriate  
+        /**
+        * ViewL.
+        * @since 2.5
+		*
+		* @param aStatus The request status to be completed when the operation has finished
+		* @return If successful, this is an asynchronously completing open operation. 
+		*         If failed, this is a completed operation, with status set to the relevant error code.
+        */
+		CMsvOperation* ViewL( TRequestStatus& aStatus );
+		
+        /**
+        * ViewL.
+        * @since 2.5
+		*
+		* @param aStatus The request status to be completed when the operation has finished
+		* @param aSelection Selection of message entries 
+		* @return If successful, this is an asynchronously completing open operation. 
+		*         If failed, this is a completed operation, with status set to the relevant error code.
+        */		
+		CMsvOperation* ViewL( TRequestStatus& aStatus , const CMsvEntrySelection& aSelection );
+
+		// Reply/forward
+		/**
+        * ReplyL.
+        * @since 2.5
+		*
+		* Not Supported
+		*
+        */
+		CMsvOperation* ReplyL( TMsvId aDestination , TMsvPartList aPartList , TRequestStatus& aCompletionStatus );
+		
+		/**
+        * ForwardL.
+        * @since 2.5
+		*
+		* Not Supported
+		*
+        */
+		CMsvOperation* ForwardL( TMsvId aDestination , TMsvPartList aPartList , TRequestStatus& aCompletionStatus );
+
+
+	public:
+		void HandleServerAppExit(TInt aReason);
+
+
+	protected: 
+		/*************************************
+		*
+		*		from CBaseMtm
+		*
+		**************************************/
+		void GetResourceFileName( TFileName& aFileName ) const;
+
+	protected:
+		CRightsObjectMtmUi( CBaseMtm& aBaseMtm , CRegisteredMtmDll& aRegisteredMtmDll );
+		void ConstructL();
+
+	private:
+		void CheckMessageTypeL();
+		CMsvOperation* LaunchEditorApplicationL( TRequestStatus& aStatus , TMsvId aId , TBool aReadOnly );
+		void SetProgressSuccess( TPckgBuf<TMsvLocalOperationProgress>& aProgress , TMsvId aId );
+		CMsvOperation* CompletedOperationL( TRequestStatus& aObserverStatus );
+        TBool ShowQueryL( TDesC16& aFile );
+        TInt CheckTriggerTypeL( TDesC16& aFile );
+	private:
+		TMessageType iType;
+		CDocumentHandler* iDocHandler;
+		RFs iFs;
+		CEikProcess* iHostProcess;
+    CAknLaunchAppService* iOpenService;
+	};
+
+#endif      // RIGHTSOBJECTMTMUI_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/ui/src/RoMtmUi.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,816 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of Rights Object MTM UI
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <txtrich.h>//CRichText
+#include <eikrted.h> //	CEikRichTextEditor
+#include <eikenv.h>//CEikonEnv
+
+#include <AiwGenericParam.h>
+#include <AknLaunchAppService.h>
+
+#include <eikon.rsg>
+// Messaging includes
+#include <MSVUIDS.H>
+#include <msvids.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include <eikproc.h>
+#include <eikdoc.h>
+#include <akndialog.h>
+#include "RoMtmUi.h"
+#include "RoMtmUiC.h"
+
+
+#include <DocumentHandler.h> // document handler
+#include <apaid.h> //TApaAppInfo
+#include <apgcli.h> //RApaLsSession
+#include <RoapEng.h> // CRoapEng
+#include <data_caging_path_literals.hrh> // KDC_RESOURCE_FILES_DIR
+#include <AknQueryDialog.h> // CAknQueryDialog
+#include <StringLoader.h> //StringLoader
+#include <coneresloader.h> //rconeresloader
+#include <RoMtmUi.rsg> // test
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+_LIT(KRoAcquisitionPrefix, "ROA:");
+_LIT(KTriggerPrefix, "TRI:");
+
+#ifndef RD_MULTIPLE_DRIVE
+_LIT( KDriveZ, "z:" );
+#endif
+                                      
+_LIT( KRoMtmUiResFileName,"RoMtmUi.rsc" );
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+// ============================ LOCAL FUNCTIONS ===============================
+//#define _DRM_TESTING
+
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs );
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName );
+LOCAL_C void CreateLogL();
+LOCAL_C void WriteL( const TDesC8& aText );
+LOCAL_C void WriteL( const TDesC& aText );
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr );
+LOCAL_C void WriteL( const TDesC& aText , TInt aErr );
+LOCAL_C void WriteCurrentTimeL();
+#endif
+
+// -----------------------------------------------------------------------------
+// Testing stuff
+// -----------------------------------------------------------------------------
+//
+#ifdef _DRM_TESTING
+LOCAL_C void WriteLogL( const TDesC8& text , RFs &aFs )
+    {
+    _LIT( KLogFile , "c:\\CRightsObjectMtmUi.txt" );
+    WriteFileL( text , aFs , KLogFile );
+    }
+
+LOCAL_C void WriteFileL( const TDesC8& text , RFs &aFs , const TDesC& aName )
+    {
+    RFile file;
+    TInt size;
+    User::LeaveIfError( file.Open( aFs, aName , EFileWrite ) );
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Size( size ) );
+    User::LeaveIfError( file.Write( size, text ) );
+    CleanupStack::PopAndDestroy(); //file
+    }
+
+LOCAL_C void CreateLogL()
+    {
+    RFs fs;
+    User::LeaveIfError(fs.Connect());
+    CleanupClosePushL(fs);
+    RFile file;
+    User::LeaveIfError( file.Replace( fs , _L("c:\\CRightsObjectMtmUi.txt") , EFileWrite ) );
+    file.Close();
+    CleanupStack::PopAndDestroy(); //fs
+    }
+
+LOCAL_C void WriteL( const TDesC& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8("\r\n") );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(); //fs
+    WriteCurrentTimeL();
+    }
+
+LOCAL_C void WriteL( const TDesC8& aText )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(1000);
+    TPtr8 textptr(text->Des() );
+    textptr.Append( aText );
+    textptr.Append( _L8("\r\n") );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(); //fs
+    WriteCurrentTimeL();
+    }
+    
+LOCAL_C void WriteL( const TDesC8& aText , TInt aErr )
+    {
+    _LIT8(KErr,": %d");
+    HBufC8* text = HBufC8::NewLC(1000+20);
+    TBuf8<20> num;
+    TPtr8 textptr(text->Des());
+    textptr.Append(aText);
+    num.Format(KErr(),aErr);
+    textptr.Append(num);
+    WriteL(textptr);
+    CleanupStack::PopAndDestroy(text);
+    }
+    
+LOCAL_C void WriteL( const TDesC& aText , TInt aErr )
+    {
+    _LIT8(KErr,": %d");
+    HBufC8* text = HBufC8::NewLC(1000+20);
+    TBuf8<20> num;
+    TPtr8 textptr(text->Des());
+    textptr.Append(aText);
+    num.Format(KErr(),aErr);
+    textptr.Append(num);
+    WriteL(textptr);
+    CleanupStack::PopAndDestroy(text);
+    }
+
+LOCAL_C void WriteCurrentTimeL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+    HBufC8* text = HBufC8::NewLC(100);
+    TPtr8 textptr(text->Des() );
+// Date and Time display
+    TTime time;
+    time.HomeTime();
+    TBuf<256> dateString;
+    _LIT(KDate,"%*E%*D%X%*N%*Y %1 %2 '%3");
+    time.FormatL(dateString,KDate);
+    textptr.Append(_L( "\r\n\t\tData:\t" ) );
+    textptr.Append( dateString );
+    _LIT(KTime,"%-B%:0%J%:1%T%:2%S%:3%+B");
+    time.FormatL(dateString,KTime);
+    textptr.Append(_L( "\r\n\t\tTime:\t" ) );
+    textptr.Append( dateString );
+    textptr.Append(_L( "\r\n" ) );
+    textptr.Append(_L( "\r\n" ) );
+    WriteLogL(textptr , fs);
+    CleanupStack::PopAndDestroy(text);
+    CleanupStack::PopAndDestroy(); //fs
+    }
+#endif
+/*************************************
+*
+*		Global function declarations
+*
+**************************************/
+
+EXPORT_C CBaseMtmUi* NewMtmUiL( CBaseMtm& aMtm , CRegisteredMtmDll& aRegisteredDll )
+// Factory function
+	{
+	return CRightsObjectMtmUi::NewL( aMtm , aRegisteredDll );
+	}
+//
+// CRightsObjectMtmUi: User Interface MTM
+//
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+/*************************************
+*
+*		Construction and destruction 
+*
+**************************************/
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::CRightsObjectMtmUi
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRightsObjectMtmUi::CRightsObjectMtmUi( CBaseMtm& aBaseMtm , CRegisteredMtmDll& aRegisteredMtmDll )
+	:	CBaseMtmUi( aBaseMtm , aRegisteredMtmDll )
+	{
+	iOpenService = NULL;
+	iDocHandler = NULL;
+	iHostProcess = NULL;
+	iType = ERo;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmUi::ConstructL()
+	{
+#ifdef _DRM_TESTING
+	CreateLogL();
+	WriteL(_L8("ConstructL"));
+#endif
+	CBaseMtmUi::ConstructL();
+	User::LeaveIfError(iFs.Connect());
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRightsObjectMtmUi* CRightsObjectMtmUi::NewL( CBaseMtm& aBaseMtm , CRegisteredMtmDll& aRegisteredMtmDll )
+	{
+	CRightsObjectMtmUi* self=new ( ELeave ) CRightsObjectMtmUi( aBaseMtm , aRegisteredMtmDll );
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop();
+	return self;
+	}
+
+// Destructor
+CRightsObjectMtmUi::~CRightsObjectMtmUi()
+	{
+#ifdef _DRM_TESTING
+	TRAP(err,WriteL(_L8("~CRightsObjectMtmUi")));
+#endif
+	iFs.Close();
+
+  delete iOpenService;
+	delete iDocHandler;
+	}
+
+
+
+
+/*************************************
+*
+*		from CBaseMtm
+*
+**************************************/
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::CancelL
+//
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::CancelL( TRequestStatus& /*aStatus*/ , const CMsvEntrySelection& /*aSelection*/ )
+	{
+#ifdef _DRM_TESTING
+	WriteL(_L8("CancelL"));
+#endif
+	
+	User::Leave( KErrNotSupported ); // no cancelling
+	return NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::GetResourceFileName
+//
+// Implementations provide this function to set the full path 
+// and name of the resource file associated with the User Interface MTM. 
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmUi::GetResourceFileName( TFileName& aFileName ) const
+// Resource file loading 
+	{ 
+#ifdef _DRM_TESTING
+	TRAPD(err,WriteL(_L8("GetResourceFileName")));
+#endif	
+	aFileName = KRoMtmResourceFile; 
+	}
+
+//
+//	Entry manipulation 
+//
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::OpenL
+//
+// Opens an entry. 
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::OpenL( TRequestStatus& aStatus )
+// Open 
+	{
+#ifdef _DRM_TESTING
+	WriteL(_L8("OpenL(1)"));
+#endif	
+
+    TMsvEntry tEntry = BaseMtm().Entry().Entry();
+    TMsvEntry newEntry( tEntry );
+
+	const TUid type( tEntry.iType );
+    CMsvOperation* operation = NULL;	
+	if ( type == KUidMsvMessageEntry )
+        {
+        operation = ViewL( aStatus );
+        newEntry.SetUnread( EFalse );
+        BaseMtm().Entry().ChangeL( newEntry );
+        }
+    else
+        {
+        User::Leave( KErrNotSupported );
+        }
+	return operation;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::OpenL
+//
+// Opens the first entry in the selections. 
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::OpenL( TRequestStatus& aStatus , const CMsvEntrySelection& aSelection )
+// Open selection
+	{
+#ifdef _DRM_TESTING
+	WriteL(_L8("OpenL(2)"));
+#endif	
+    BaseMtm().SwitchCurrentEntryL( aSelection.At( 0 ) );
+    return OpenL( aStatus );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::CloseL
+//
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::CloseL( TRequestStatus& /*aStatus*/ )
+	{
+// Close 
+#ifdef _DRM_TESTING
+	WriteL(_L8("CloseL(1)"));
+#endif	
+    User::Leave( KErrNotSupported );
+    return NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::CloseL
+//
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::CloseL( TRequestStatus& /*aStatus*/ , const CMsvEntrySelection& /*aSelection*/ )
+	{
+// Close selection
+#ifdef _DRM_TESTING
+	WriteL(_L8("CloseL(2)"));
+#endif	
+
+    User::Leave( KErrNotSupported );
+    return NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::EditL
+//
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::EditL( TRequestStatus& /*aStatus*/ )
+// Edit 
+	{
+#ifdef _DRM_TESTING
+	WriteL(_L8("EditL(1)"));
+#endif		
+    User::Leave( KErrNotSupported );	
+	return NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::EditL
+//
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::EditL( TRequestStatus& aStatus , const CMsvEntrySelection& aSelection )
+// Edit selection
+	{
+#ifdef _DRM_TESTING
+	WriteL(_L8("EditL(2)"));
+#endif	
+	iBaseMtm.SwitchCurrentEntryL( aSelection.At( 0 ) );
+	return EditL( aStatus );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::ViewL
+//
+// Views an entry.
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::ViewL( TRequestStatus& aStatus )
+// View
+	{
+#ifdef _DRM_TESTING
+	WriteL(_L8("ViewL(1)"));
+#endif
+	
+    CheckMessageTypeL();                                       
+	return LaunchEditorApplicationL( aStatus , iBaseMtm.Entry().Entry().Id() , ETrue );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::ViewL
+//
+// Views the first entry in the selection.
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::ViewL( TRequestStatus& aStatus , const CMsvEntrySelection& aSelection )
+// View selection
+	{
+#ifdef _DRM_TESTING
+	WriteL(_L8("ViewL(2)"));
+#endif
+	
+	iBaseMtm.SwitchCurrentEntryL( aSelection.At( 0 ) );
+	return ViewL( aStatus );
+	}
+
+
+//
+//	Message responding
+//
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::ReplyL
+//
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::ReplyL( TMsvId /*aDestination*/ , TMsvPartList /*aPartlist*/ , TRequestStatus& /*aCompletionStatus*/ )
+// Reply to message - no UI support
+	{
+	User::Leave( KErrNotSupported );
+	return NULL;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::ForwardL
+//
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::ForwardL( TMsvId /*aDestination*/ , TMsvPartList /*aPartlist*/ , TRequestStatus& /*aCompletionStatus*/ )
+// Forwarded message - no UI support
+	{
+	User::Leave( KErrNotSupported );
+	return NULL;
+	}
+
+
+//
+// Specific to CRightsObjectMtmUi
+//
+
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::CheckMessageTypeL
+//
+// Check the type of the message
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmUi::CheckMessageTypeL()
+	{
+#ifdef _DRM_TESTING
+		WriteL(_L8("CheckMessageTypeL"));
+#endif	
+	BaseMtm().LoadMessageL(); 
+	CRichText& body = BaseMtm().Body();
+	TPtrC ptr16( body.Read(0) );
+
+#ifdef _DRM_TESTING
+		WriteL(ptr16);
+#endif		
+	if ( ptr16.Length()>4 && ptr16.Left(4).Compare(KRoAcquisitionPrefix())==0 )
+		{
+		iType = ERoapTriggerRoAcquisition;
+		}
+	else if ( ptr16.Length()>4 && ptr16.Left(4).Compare(KTriggerPrefix())==0 )
+		{
+		iType = ERoapTrigger;
+		}
+	else
+		{
+		iType = ERo;	
+		}
+		
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::LaunchEditorApplicationL
+//
+// Launch RO Manager to get information for rights corresponding to the message.
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::LaunchEditorApplicationL( TRequestStatus& aStatus , TMsvId /*aId*/ , 
+													TBool /*aReadOnly*/ )
+	{
+#ifdef _DRM_TESTING
+	WriteL(_L8("LaunchEditorApplicationL-Start"));
+#endif	
+	// get message context
+	BaseMtm().LoadMessageL(); 
+	CRichText& body = BaseMtm().Body();
+	TPtrC ptr16( body.Read(0) );
+    const TUid KUidDRMUI = { 0x101f85c7 };
+
+	if ( iType == ERoapTrigger || iType == ERoapTriggerRoAcquisition )
+		{
+		
+#ifdef _DRM_TESTING
+		WriteL(_L8("LaunchEditorApplicationL-iDocHandler"));
+#endif
+        
+        _LIT8( KRoapTriggerMimeType, "application/vnd.oma.drm.roap-trigger+xml" );
+        TDataType type = TDataType( KRoapTriggerMimeType );
+        HBufC* filename = NULL;
+		TPtr ptr(NULL,0);
+		TBool show;
+		filename = HBufC::NewLC(ptr16.Length()-4);
+		ptr.Set(filename->Des());
+		ptr.Append(ptr16.Right(ptr16.Length()-4));
+		
+		show = ShowQueryL(ptr);
+		if (!show)
+		    {
+		    CleanupStack::PopAndDestroy(filename);
+		    return CompletedOperationL( aStatus );
+		    }
+		
+#ifdef _DRM_TESTING
+		WriteL(ptr,ptr.Length());
+#endif		
+		if (iDocHandler)
+			{
+			delete iDocHandler;
+			iDocHandler = NULL;
+			}
+#ifdef _DRM_TESTING
+		WriteL(_L8("LaunchEditorApplicationL-iDocHandler-NewL"));
+#endif			
+		iDocHandler = CDocumentHandler::NewL();
+#ifdef _DRM_TESTING
+		WriteL(_L8("LaunchEditorApplicationL-iDocHandler-SetExitObserver"));
+#endif		
+		iDocHandler->SetExitObserver(this);
+#ifdef _DRM_TESTING
+		WriteL(_L8("LaunchEditorApplicationL-iDocHandler-OpenFileEmbeddedL"));
+#endif			
+		iDocHandler->OpenFileEmbeddedL(ptr,type);
+		CleanupStack::PopAndDestroy(filename);
+#ifdef _DRM_TESTING
+		WriteL(_L8("LaunchEditorApplicationL-iDocHandler-End"));
+#endif		
+		}
+	else
+		{
+	    if ( iOpenService )
+	        {
+	        delete iOpenService;
+	        iOpenService = NULL;
+	        }
+#ifdef _DRM_TESTING
+		WriteL(_L8("LaunchEditorApplicationL-CAknOpenFileService::NewL"));
+#endif           
+
+		CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC();
+		TAiwVariant variantObject( ptr16 );
+		TAiwGenericParam param( EGenericParamFile, variantObject );
+		paramList->AppendL( param );
+		
+    	TRAPD( err, iOpenService = CAknLaunchAppService::NewL( KUidDRMUI, this, paramList ) );
+    	if (err != KErrNone)
+    		{
+    		// just return to Inbox
+    		}
+
+		CleanupStack::PopAndDestroy( paramList ); // paramList			
+		}	
+
+#ifdef _DRM_TESTING
+	WriteL(_L8("LaunchEditorApplicationL-End"));
+#endif    
+    return CompletedOperationL( aStatus );
+	}
+
+
+void CRightsObjectMtmUi::HandleServerAppExit(TInt aReason)
+	{
+#ifdef _DRM_TESTING
+	TRAP(err,WriteL(_L8("HandleServerAppExit")));
+#endif	
+	MAknServerAppExitObserver::HandleServerAppExit(aReason);
+	}
+	
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUi::CompletedOperationL
+//
+// return completed operation to UI  
+//
+// -----------------------------------------------------------------------------
+//
+CMsvOperation* CRightsObjectMtmUi::CompletedOperationL( TRequestStatus& aObserverStatus )
+    {
+#ifdef _DRM_TESTING
+	WriteL(_L8("CompletedOperationL"));
+#endif      
+	//return completed operation pointer
+    TPckgBuf<TMsvLocalOperationProgress> progress;
+    SetProgressSuccess( progress, BaseMtm().Entry().Entry().Id() );
+    CMsvCompletedOperation* operation = 
+        CMsvCompletedOperation::NewL( Session() , Type() , progress , 
+        KMsvLocalServiceIndexEntryId , aObserverStatus );
+    return operation;
+    }
+
+void CRightsObjectMtmUi::SetProgressSuccess
+( TPckgBuf<TMsvLocalOperationProgress>& aProgress , TMsvId aId )
+    {
+    aProgress().iTotalNumberOfEntries = 1;
+    aProgress().iNumberCompleted = 1;
+    aProgress().iId = aId;
+    }
+
+TBool CRightsObjectMtmUi::ShowQueryL( TDesC16& aFile )
+    {
+#ifdef _DRM_TESTING
+	WriteL(_L8("ShowQueryL"));
+#endif       
+    TBool show = ETrue;
+    TInt type = 0;
+    HBufC* msgText = NULL;
+    type = CheckTriggerTypeL(aFile);    
+    
+#ifndef RD_MULTIPLE_DRIVE
+    
+    TFileName fileName( KDriveZ );
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    _LIT( KDrive, "%c:");
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+	iFs.DriveToChar( driveNumber, driveLetter );
+	
+	TFileName fileName;
+	
+    fileName.Format( KDrive, (TUint)driveLetter );
+    
+#endif
+    
+    fileName.Append( KDC_MTM_RESOURCE_DIR );
+    fileName.Append( KRoMtmUiResFileName );
+    RConeResourceLoader loader( *iCoeEnv );
+    loader.OpenL( fileName );
+    switch(type)
+        {
+        case Roap::ERegistrationTrigger:
+            {
+#ifdef _DRM_TESTING
+	WriteL(_L8("ShowQueryL->ERegistrationTrigger"));
+#endif             
+            loader.Close();
+            return ETrue;              
+            }
+        case Roap::ERoAcquisitionTrigger:
+            {
+#ifdef _DRM_TESTING
+	WriteL(_L8("ShowQueryL->ERoAcquisitionTrigger"));
+#endif
+            msgText = StringLoader::LoadLC( R_ROMTMUI_QUERY_RIGHTS_ACQ_MSG , iCoeEnv ); 
+            }break;
+        case Roap::EJoinDomainTrigger:
+            {
+#ifdef _DRM_TESTING
+	WriteL(_L8("ShowQueryL->EJoinDomainTrigger"));
+#endif            
+            msgText = StringLoader::LoadLC( R_ROMTMUI_QUERY_JOIN_DOMAIN_MSG , iCoeEnv ); 
+            }break;
+        case Roap::ELeaveDomainTrigger:
+            {
+#ifdef _DRM_TESTING
+	WriteL(_L8("ShowQueryL->ELeaveDomainTrigger"));
+#endif            
+            msgText = StringLoader::LoadLC( R_ROMTMUI_QUERY_LEAVE_DOMAIN_MSG , iCoeEnv ); 
+            }break;
+        default:
+            {
+#ifdef _DRM_TESTING
+	WriteL(_L8("ShowQueryL->default"));
+#endif            
+            loader.Close();
+            return EFalse;    
+            }
+        }
+#ifdef _DRM_TESTING
+	WriteL(*msgText);
+#endif           
+    loader.Close();
+    CAknQueryDialog* dlg = new (ELeave) CAknQueryDialog( *msgText,
+        CAknQueryDialog::ENoTone );
+    show = dlg->ExecuteLD( R_ROMTMUI_TRIGGER_CONFIRMATION_QUERY ); 
+    CleanupStack::PopAndDestroy( msgText );
+#ifdef _DRM_TESTING
+	WriteL(_L8("ShowQueryL->End"),show);
+#endif   
+    return show;
+    }
+
+TInt CRightsObjectMtmUi::CheckTriggerTypeL( TDesC16& aFile )
+    {
+#ifdef _DRM_TESTING
+	WriteL(_L8("CheckTriggerTypeL"));
+#endif    
+    Roap::CRoapEng* roap = NULL;
+    RFile file;
+    TInt size = 0;
+    Roap::TTriggerType type;
+    Roap::TRiContextStatus status;
+    Roap::TDomainOperation op;
+    RPointerArray<HBufC8> array;
+    
+    HBufC8* buf =NULL;
+    TPtr8 ptr(NULL,0);
+    User::LeaveIfError(file.Open(iFs, aFile, EFileShareReadersOrWriters));
+    CleanupClosePushL(file);
+    User::LeaveIfError(file.Size(size));
+    buf = HBufC8::NewLC(size);
+    ptr.Set(buf->Des());
+    User::LeaveIfError(file.Read(ptr,size));
+    CleanupStack::Pop(buf);
+    CleanupStack::PopAndDestroy(&file);
+    CleanupStack::PushL(buf);
+    roap = Roap::CRoapEng::NewL();
+    CleanupStack::PushL(roap);
+    roap->SetTriggerL(ptr,NULL,type,status,op,array);
+    array.ResetAndDestroy();
+    array.Close();
+    CleanupStack::PopAndDestroy(roap);
+    CleanupStack::PopAndDestroy(buf);
+    
+#ifdef _DRM_TESTING
+	WriteL(_L8("CheckTriggerTypeL-End"),type);
+#endif     
+    return type;
+    }
+    
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/uiData/inc/RoMTMDaC.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2002, 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: 
+*     
+*
+*/
+
+
+#ifndef ROMTMUIDATACONST_H
+#define ROMTMUIDATACONST_H
+
+
+enum TRoMtmUdPanic
+	{
+	ERoMtmUdWrongMtm,
+	ERoMtmUdFoldersNotSupported,
+	ERoMtmUdAttachmentsNotSupported,
+	ERoMtmUdNoIconForAttachment,
+	ERoMtmUdRootEntryGiven,
+	ERoMtmUdUnknownOperationId
+	};
+
+// Correct path is added to literal when it is used.
+_LIT(KRoMtmUiDataBitmapFile, "z:MUIU.MBM");
+
+LOCAL_C const TInt KBitmapArraySize = 2;
+LOCAL_C const TInt KBitmapIndex = 0;     // only one bitmap for create email
+
+#endif      // ROMTMUIDATACONST_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/uiData/inc/RoMtmCommands.hrh	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declarations command IDs.
+*
+*/
+
+
+
+#ifndef PUSHMTMCOMMANDS_HRH
+#define PUSHMTMCOMMANDS_HRH
+
+// INCLUDE FILES
+
+#include <MTMExtendedCapabilities.hrh>
+
+/**
+* The following enum constants define those Ro MTM specific commands that 
+* are supported by the client or the UI MTM components.
+*/
+enum TRoMtmCommands
+    {
+    ERoMtmCmdLoadService = KMtmUiFirstFreePlatformMTMFunctionId,
+    ERoMtmCmdViewService,
+    ERoMtmCmdCollectGarbage,
+    ERoMtmCmdFetchContent,
+    ERoMtmCmdViewMessage
+    };
+
+#endif // PUSHMTMCOMMANDS_HRH
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/uiData/inc/RoMtmDat.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,317 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of Rights Object MTM UI Data
+*
+*/
+
+
+#ifndef RIGHTSOBJECTMTMUIDATA_H
+#define RIGHTSOBJECTMTMUIDATA_H
+
+//  INCLUDES
+#if !defined(__MSVSTD_H__)
+#include <MSVSTD.H>
+#endif
+
+#if !defined(__MTUDBAS_H__)
+#include <MTUDCBAS.H>
+#endif
+
+// CONSTANTS
+// MACROS
+// DATA TYPES
+// FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+class CRightsObjectMtmUiDataSessionObserver;
+class CMsvSession;
+
+// CLASS DECLARATION
+/**
+*	CRightsObjectMtmUiDataSessionObserver
+*  
+*   CMsvSession Observer
+*
+*  @lib RoMtmDat.lib
+*  @since 2.5
+*/
+class CRightsObjectMtmUiDataSessionObserver : public CBase, public MMsvSessionObserver
+	{
+	public:
+
+        /**
+		* Two-phased constructor.
+		*/
+		static CRightsObjectMtmUiDataSessionObserver* NewL();
+
+		/**
+		* Destructor.
+		*/
+		~CRightsObjectMtmUiDataSessionObserver();
+
+        /**
+        * From MMsvSessionObserver
+        */
+        void HandleSessionEventL( 
+            TMsvSessionEvent aEvent, 
+            TAny* aArg1, 
+            TAny* aArg2, 
+            TAny* aArg3 );
+
+    private:
+        CRightsObjectMtmUiDataSessionObserver();
+        void ConstructL();
+    };
+
+
+// CLASS DECLARATION
+/**
+*	CRightsObjectMtmUiData
+*  
+*  @lib RoMtmDat.lib
+*  @since 2.5
+*/
+class CRightsObjectMtmUiData : public CBaseMtmUiData
+	{
+	public:
+	// Construction, initialisation, and destruction 
+	
+		/**
+		* Two-phased constructor.
+		*/
+		static CRightsObjectMtmUiData* NewL( CRegisteredMtmDll& aRegisteredDll );
+
+		/**
+		* Destructor.
+		*/
+		~CRightsObjectMtmUiData();
+
+		/*************************************
+		*
+		*		from CBaseMtm
+		*
+		**************************************/	
+
+		// Context-specific information 
+
+		/**
+        * CanEditEntryL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */
+		TBool CanEditEntryL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const;
+		
+		/**
+        * CanViewEntryL
+        * @since 2.5
+        * 
+		* @param aContext  The entry to which the operation applies. 
+ 		* @param aReasonResourceId  On return, a resource string ID or 0. 
+ 		*   
+		* @return KErrNone: the operation is appropriate on the entry. KErrNotSupported: the operation is not appropriate on the entry. 
+        */		
+		TBool CanViewEntryL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const;
+		
+		/**
+        * CanOpenEntryL
+        * @since 2.5
+        * 
+		* @param aContext  The entry to which the operation applies. 
+ 		* @param aReasonResourceId  On return, a resource string ID or 0. 
+ 		*   
+		* @return KErrNone: the operation is appropriate on the entry. KErrNotSupported: the operation is not appropriate on the entry. 
+	    */		
+		TBool CanOpenEntryL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const;
+		
+		/**
+        * CanCloseEntryL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */		
+		TBool CanCloseEntryL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const;
+		
+		/**
+        * CanDeleteFromEntryL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */		
+		TBool CanDeleteFromEntryL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const;
+		
+		/**
+        * CanCopyMoveToEntryL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */		
+		TBool CanCopyMoveToEntryL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const;
+		
+		/**
+        * CanCopyMoveFromEntryL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */		
+		TBool CanCopyMoveFromEntryL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const;
+		
+		/**
+        * CanReplyToEntryL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */		
+		TBool CanReplyToEntryL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const;
+		
+		/**
+        * CanForwardEntryL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */		
+		TBool CanForwardEntryL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const;
+		
+		/**
+        * CanCreateEntryL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */		
+		TBool CanCreateEntryL( const TMsvEntry& aContext , TMsvEntry& aNewEntry , TInt& aReasonResourceId ) const;
+		
+		/**
+        * CanDeleteServiceL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */		
+		TBool CanDeleteServiceL( const TMsvEntry& aService , TInt& aReasonResourceId ) const;
+		
+		/**
+        * CanCancelL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+        */		
+		TBool CanCancelL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const;
+
+	// Context-specific icons 
+
+		/**
+        * ContextIcon
+        * @since 2.5
+        * 
+		* @param aContext  Context entry to return the icons for. 
+  		* @param aStateFlags  Flasgs indicating the user interface state of the entry. 
+  		*   
+		* @return Bitmap array for the given context.. 
+	    */	
+		const CBitmapArray& ContextIcon( const TMsvEntry& aContext , TInt aStateFlags ) const;
+
+		/**
+        * GetResourceFileName
+        * @since 2.5
+        * 
+		* @param aFileName Filename buffer to be filled with the resource file path and name 
+	    */	
+		void GetResourceFileName( TFileName& aFileName ) const;	
+		
+		/**
+        * PopulateArraysL
+        * @since 2.5
+        * 
+	    */			
+		void PopulateArraysL();
+
+		
+		/**
+        * StatusTextL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+		*/			
+		HBufC* StatusTextL( const TMsvEntry& aContext ) const;
+
+
+	// MTM-specific functionality 
+
+		/**
+        * OperationSupportedL
+        * @since 2.5
+        * 
+		* Not supported
+		*
+		*/	
+		TInt OperationSupportedL( 
+            TInt aOperationId , 
+            const TMsvEntry& aContext ) const;
+		
+		/**
+        * QueryCapability
+        * @since 2.5
+        * 
+		* @param aCapability UID of capability to be queried 
+		* @param aResponse Response value. The format of the response varies 
+        * according to the capability
+		*
+		* @return KErrNone if aCapability is a recognised value and a response is 
+        * returned KErrNotSupported if aCapability is not a recognised value 
+        */			
+		TInt QueryCapability( TUid aCapability , TInt& aResponse ) const;
+
+
+    protected:
+        /**
+        * Creates skinned icons. Fallbacks are normal icons
+        * @since Series60 2.8
+        * @param aNumZoomStates: amount of elements in vector
+        *        ( bitmap & bitmapmask )
+        */
+        void CreateSkinnedBitmapsL( TInt aNumZoomStates );
+
+	private:
+        void ConstructL();
+
+		CRightsObjectMtmUiData( CRegisteredMtmDll& aRegisteredDll );
+
+        void SetDescriptionL( const TMsvEntry& aContext ) const;
+        
+
+	public:     // Data
+    protected:  // Data
+    private:    // Data
+
+        CRightsObjectMtmUiDataSessionObserver*  iObserver;
+        CMsvSession*                            iSession;
+        
+    public:     // Friend classes
+    protected:  // Friend classes
+    private:    // Friend classes
+
+	};
+
+#endif      // RIGHTSOBJECTMTMUIDATA_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/uiData/inc/RoMtmUi.hrh	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,55 @@
+/*
+* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HRH file for the Mtm Ui  and Mtm Ui Data components
+*
+*/
+
+
+
+#ifndef RoMTMUI_HRH
+#define RoMTMUI_HRH
+
+#include <uikon.hrh>
+#include <avkon.hrh>
+
+enum TRoSettingsDialogCommand
+	{
+	// Dialog specific command ids.
+	//
+	ERoSettingsDialogCmdChangeWithoutSettingPage,
+	ERoSettingsDialogCmdDelete,
+	//
+	// Ui framework defined command ids.
+	//
+	ERoSettingsDialogCmdChange	= EAknSoftkeySelect,// Required by CAknSettingPage::OfferKeyEventL.
+	ERoSettingsDialogCmdOptions	= EAknSoftkeyOptions,// = 3000
+  ERoSettingsDialogCmdHelp      = EAknCmdHelp,      // = 4003
+	ERoSettingsDialogCmdBack		= EAknSoftkeyBack,	// = 3001
+	ERoSettingsDialogCmdExit		= EEikCmdExit,		// = 0x100. Use in HandleCommanL.
+	ERoSettingsDialogCmdAknExit	= EAknCmdExit		// = 4011. Use in resources.
+	};
+
+enum TRoSettingsDialogControl
+	{
+	ERoSettingsDialogCntrlListBox = 1
+	};
+
+enum TRoLoadWaitNoteControl
+	{
+	ERoLoadWaitNoteCntrl = 1
+	};
+
+#endif // RoMTMUI_HRH
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/uiData/src/RoMtmDat.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,601 @@
+/*
+* Copyright (c) 2002 - 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Rights Object MTM UI Data
+*
+*/
+
+
+// Standard includes
+#if !defined(__COEMAIN_H__)
+#include <coemain.h>	// CCoeEnv
+#endif
+
+// Messaging includes
+#if !defined(__MTCLBASE_H__)
+#include <mtclbase.h> 
+#endif
+#if !defined(__MSVSTD_HRH__)
+#include <msvstd.hrh>
+#endif
+#if !defined(__MTMDEF_HRH__)
+#include <mtmdef.hrh>
+#endif
+#if !defined(__MSVUIDS_H__)
+#include <msvuids.h>
+#endif
+#if !defined(__MSVIDS_H__)
+#include <msvids.h>
+#endif
+
+#include <msvapi.h>
+#include <RoMtmUi.rsg>
+#include <muiu.mbg>
+#include <mtmuids.h>
+#include <MTMUIDEF.HRH>
+#include <StringResourceReader.h>
+#include <avkon.rsg>
+#include <data_caging_path_literals.hrh>
+
+#include <stringloader.h>
+#include <aknsutils.h>
+#include <aknsconstants.h>//skinned icon ids
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <DriveInfo.h>
+#endif
+
+#include "RoMtmDat.h"
+#include "RoMtmDaC.h"
+#include "RoMtmCommon.h"
+
+// EXTERNAL DATA STRUCTURES
+// EXTERNAL FUNCTION PROTOTYPES  
+// CONSTANTS
+// MACROS
+// LOCAL CONSTANTS AND MACROS
+// MODULE DATA STRUCTURES
+// LOCAL FUNCTION PROTOTYPES
+// FORWARD DECLARATIONS
+
+// Constants
+#ifndef RD_MULTIPLE_DRIVE
+_LIT( KDriveZ, "z:" );                                      
+#endif
+
+_LIT( KRoMtmUdResourceFile, "RoMtmUi.RSC" );
+
+
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+EXPORT_C CBaseMtmUiData* NewMtmUiDataLayerL( CRegisteredMtmDll& aRegisteredDll )
+// Factory function
+	{
+	return CRightsObjectMtmUiData::NewL( aRegisteredDll );
+	}
+
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiDataSessionObserver::CRightsObjectMtmUiDataSessionObserver
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRightsObjectMtmUiDataSessionObserver::CRightsObjectMtmUiDataSessionObserver()
+	{
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiDataSessionObserver::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRightsObjectMtmUiDataSessionObserver* 
+    CRightsObjectMtmUiDataSessionObserver::NewL()
+	{
+	CRightsObjectMtmUiDataSessionObserver* self = 
+        new ( ELeave ) CRightsObjectMtmUiDataSessionObserver();
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop( self );
+	return self;
+	}
+
+// Destructor
+CRightsObjectMtmUiDataSessionObserver::~CRightsObjectMtmUiDataSessionObserver()
+	{ 
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiDataSessionObserver::ConstructL
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmUiDataSessionObserver::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiDataSessionObserver::HandleSessionEventL
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmUiDataSessionObserver::HandleSessionEventL(
+    TMsvSessionEvent aEvent, 
+    TAny* aArg1, 
+    TAny* /*aArg2*/, 
+    TAny* /*aArg3*/ )
+    {
+    
+#ifdef RD_MULTIPLE_DRIVE
+    _LIT(KRoHandlerTriggerFilePath, "%c:\\system\\data\\"); 
+#else
+    _LIT(KRoHandlerTriggerFilePath, "c:\\system\\data\\");
+#endif
+   
+    if (aEvent == EMsvEntriesDeleted)
+        {
+        TFileName fileName;
+        CMsvEntrySelection* selection = STATIC_CAST( CMsvEntrySelection*, aArg1 );
+        RFs fs;
+        User::LeaveIfError(fs.Connect());
+        CleanupClosePushL(fs);
+        for (TInt i = 0;i<selection->Count();i++)
+            {
+            
+#ifndef RD_MULTIPLE_DRIVE
+    
+            _LIT(KFile,"%S%u.tri");
+            fileName.Format(KFile,&KRoHandlerTriggerFilePath,selection->At(i));
+            fs.Delete(fileName);
+    
+#else //RD_MULTIPLE_DRIVE
+    
+            TInt driveNumber( -1 );
+            TChar driveLetter;
+            DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, driveNumber );
+	        fs.DriveToChar( driveNumber, driveLetter );
+	
+	        TFileName roHandlerTriggerFilePath;
+	        roHandlerTriggerFilePath.Format( 
+	                    KRoHandlerTriggerFilePath, (TUint)driveLetter );
+    
+            _LIT(KFile,"%S%u.tri");
+            fileName.Format( 
+                        KFile, &roHandlerTriggerFilePath, selection->At(i) );
+            fs.Delete(fileName);
+    
+#endif
+            
+            
+            }
+        CleanupStack::PopAndDestroy(&fs);
+        }
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CRightsObjectMtmUiData
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CRightsObjectMtmUiData::CRightsObjectMtmUiData( CRegisteredMtmDll& aRegisteredDll )
+	:	CBaseMtmUiData( aRegisteredDll )
+	{
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CRightsObjectMtmUiData* 
+    CRightsObjectMtmUiData::NewL( CRegisteredMtmDll& aRegisteredDll )
+	{
+	CRightsObjectMtmUiData* base = 
+        new ( ELeave ) CRightsObjectMtmUiData( aRegisteredDll );
+	CleanupStack::PushL( base );
+	base->ConstructL();
+	CleanupStack::Pop();
+	return base;
+	}
+
+// Destructor
+CRightsObjectMtmUiData::~CRightsObjectMtmUiData()
+	{ 
+    delete iSession;
+    delete iObserver;
+	}
+
+
+void CRightsObjectMtmUiData::ConstructL()
+	{ 
+    CBaseMtmUiData::ConstructL();
+    iObserver = CRightsObjectMtmUiDataSessionObserver::NewL();
+    iSession = CMsvSession::OpenSyncL( *iObserver );
+    }
+
+/*************************************
+*
+*		MTM-specific functionality 
+*
+**************************************/
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::GetResourceFileName
+// 
+// Gets the resource file name. 
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmUiData::GetResourceFileName( TFileName& aFileName ) const
+// Resource file loading
+	{ 
+#ifndef RD_MULTIPLE_DRIVE
+    
+    aFileName = KDriveZ;
+    
+#else //RD_MULTIPLE_DRIVE
+    
+    _LIT( KDrive, "%c:");
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, driveNumber );
+	
+	iCoeEnv->FsSession().DriveToChar( driveNumber, driveLetter );
+	
+    aFileName.Format( KDrive, (TUint)driveLetter );
+    
+#endif
+	
+	aFileName.Append( KDC_MTM_RESOURCE_DIR );
+   	aFileName.Append( KRoMtmUdResourceFile );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::PopulateArraysL
+// 
+// Initialises bitmaps and function information. 
+//
+// -----------------------------------------------------------------------------
+//
+void CRightsObjectMtmUiData::PopulateArraysL()
+// Initialise bitmaps and function information 
+	{
+    CreateSkinnedBitmapsL( KBitmapArraySize );
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::PopulateArraysL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TInt CRightsObjectMtmUiData::OperationSupportedL( 
+										TInt /*aOperationId*/ , 
+										const TMsvEntry& /*aContext*/ 
+										) const
+// Context-sensitive operation query 
+	{
+	return R_ROUD_NOT_SUPPORTED;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::QueryCapability
+// 
+// Queries if the MTM supports a particular capability, specified by a UID. 
+//
+// -----------------------------------------------------------------------------
+//
+TInt CRightsObjectMtmUiData::QueryCapability( TUid aCapability , TInt& aResponse ) const
+// Query for capability 
+	{
+	switch ( aCapability.iUid )
+		{
+		case KUidMtmQueryMaxBodySizeValue:
+		case KUidMtmQueryMaxTotalMsgSizeValue:
+			{
+			aResponse = KMaxRoMessageSize;
+			break;
+			}
+		case KUidMtmQuerySupportedBodyValue:
+			{
+			aResponse = KMtm7BitBody | KMtm8BitBody | 
+						   KMtm16BitBody | KMtmBinaryBody;
+			break;
+			}
+		// Supported non-valued capabilities
+		// boolean returns
+		case KUidMtmQuerySupportSubjectValue:
+		case KUidMtmQueryOffLineAllowedValue:
+			{
+			aResponse=ETrue;
+			break;		
+			}
+		default:
+			return KErrNotSupported;
+		};
+	return KErrNone;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::ContextIcon
+// 
+// Gets an array of bitmaps relevant to the passed context entry. 
+//
+// -----------------------------------------------------------------------------
+//
+const CBaseMtmUiData::CBitmapArray& CRightsObjectMtmUiData::ContextIcon(
+											const TMsvEntry& aContext ,
+											TInt /*aStateFlags*/
+											) const
+// Get context-specific icon
+	{
+    return *iIconArrays->At( aContext.Unread() ? 0 : 1 );
+	}
+
+//
+// Context-specific information
+//
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanOpenEntryL
+// 
+// Tests if an entry can be opened.
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanOpenEntryL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const
+	{
+	aReasonResourceId=0;
+	if ( aContext.iType != KUidMsvMessageEntry )
+		{
+		aReasonResourceId = R_ROUD_ONLY_MESSAGES;
+		return KErrNotSupported;
+		}
+	else
+		{
+		return KErrNone;		
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanCloseEntryL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanCloseEntryL( const TMsvEntry& /*aContext*/ , TInt& aReasonResourceId ) const
+	{
+	aReasonResourceId = R_ROUD_NOT_SUPPORTED;
+	return KErrNotSupported;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanViewEntryL
+// 
+// Tests if an entry can be viewed.
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanViewEntryL( const TMsvEntry& aContext , TInt& aReasonResourceId ) const
+	{
+	aReasonResourceId=0;
+	if ( aContext.iType != KUidMsvMessageEntry )
+		{
+		aReasonResourceId = R_ROUD_ONLY_MESSAGES;
+		return KErrNotSupported;
+		}
+	else
+		{
+		return KErrNone;		
+		}
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanEditEntryL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanEditEntryL( const TMsvEntry& /*aContext*/ , TInt& aReasonResourceId ) const
+	{
+	aReasonResourceId = R_ROUD_NOT_SUPPORTED;
+	return KErrNotSupported;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanDeleteFromEntryL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanDeleteFromEntryL( const TMsvEntry& /*aContext*/ , TInt& aReasonResourceId ) const
+	{
+	aReasonResourceId = R_ROUD_NOT_SUPPORTED;
+	return KErrNotSupported;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanCopyMoveToEntryL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanCopyMoveToEntryL( const TMsvEntry& /*aContext*/ , TInt& aReasonResourceId ) const
+	{
+	aReasonResourceId = KErrNone;
+	return KErrNone;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanCopyMoveFromEntryL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanCopyMoveFromEntryL( const TMsvEntry& /*aContext*/ , TInt& aReasonResourceId ) const
+	{
+	aReasonResourceId = KErrNone;
+	return KErrNone;
+	}
+
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanReplyToEntryL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanReplyToEntryL( const TMsvEntry& /*aContext*/ , TInt& aReasonResourceId ) const
+//
+// MTM UI does not support replying.
+//
+    {
+	aReasonResourceId = R_ROUD_NOT_SUPPORTED;
+	return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanForwardEntryL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanForwardEntryL( const TMsvEntry& /*aContext*/ , TInt& aReasonResourceId ) const
+//
+// MTM UI does not supports forwarding.
+//
+    {
+	aReasonResourceId = R_ROUD_NOT_SUPPORTED;
+	return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanCreateEntryL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanCreateEntryL( const TMsvEntry& /*aParent*/ , TMsvEntry& /*aNewEntry*/ , 
+									  TInt& aReasonResourceId ) const
+	{
+	aReasonResourceId = R_ROUD_NOT_SUPPORTED;
+	return KErrNotSupported;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanDeleteServiceL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanDeleteServiceL( 
+    const TMsvEntry& /*aService*/, 
+    TInt& aReasonResourceId ) const
+	{
+	aReasonResourceId = R_ROUD_ONLY_MESSAGES;
+	return KErrNotSupported;
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::CanCancelL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+TBool CRightsObjectMtmUiData::CanCancelL( 
+    const TMsvEntry& /*aContext*/ , 
+    TInt& aReasonResourceId ) const
+	{
+	aReasonResourceId = R_ROUD_NOT_SUPPORTED;
+	return KErrNotSupported;	
+	}
+
+// -----------------------------------------------------------------------------
+// CRightsObjectMtmUiData::StatusTextL
+// 
+// Not supported
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* CRightsObjectMtmUiData::StatusTextL( const TMsvEntry& /*aContext*/ ) const
+	{
+    return NULL;
+	}
+
+
+// ---------------------------------------------------------
+// CRightsObjectMtmUiData::CreateSkinnedBitmapsL
+//
+// ---------------------------------------------------------
+void CRightsObjectMtmUiData::CreateSkinnedBitmapsL( TInt aNumZoomStates )
+    {
+    MAknsSkinInstance* skins = AknsUtils::SkinInstance();
+    TAknsItemID id;
+    CFbsBitmap* bitmap;
+    CFbsBitmap* bitmapMask;
+    CBitmapArray* array = NULL;
+    TParse tp;
+    tp.Set( KRoMtmUiDataBitmapFile, &KDC_APP_BITMAP_DIR, NULL );
+
+    array = new(ELeave) CArrayPtrFlat<CFbsBitmap>( aNumZoomStates );
+    CleanupStack::PushL( array );
+    
+    id.Set( KAknsIIDQgnPropMcePushUnread );
+
+    AknsUtils::CreateIconL( skins, id, bitmap,
+        bitmapMask, tp.FullName(), EMbmMuiuQgn_prop_mce_push_unread,
+        EMbmMuiuQgn_prop_mce_push_unread_mask );
+             
+    array->AppendL( bitmap );
+    bitmap = 0;
+    array->AppendL( bitmapMask );
+    bitmapMask = 0;
+    iIconArrays->AppendL( array );
+    CleanupStack::Pop(); //array
+    
+    array = new(ELeave) CArrayPtrFlat<CFbsBitmap>( aNumZoomStates );
+    CleanupStack::PushL( array );
+    
+    id.Set( KAknsIIDQgnPropMcePushRead );
+
+    AknsUtils::CreateIconL( skins, id, bitmap,
+        bitmapMask, tp.FullName(), EMbmMuiuQgn_prop_mce_push_read,
+        EMbmMuiuQgn_prop_mce_push_read_mask );
+             
+    array->AppendL( bitmap );
+    bitmap = 0;
+    array->AppendL( bitmapMask );
+    bitmapMask = 0;
+    iIconArrays->AppendL( array );
+    CleanupStack::Pop(); //array
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/uiData/src/RoMtmReg.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,139 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*     This file contains Rights Manager Engine MTM info resource.
+*
+*
+*/
+
+
+//  INCLUDES
+#include <mtmconfig.rh>
+#include <romtmui.loc>
+
+
+//  CONSTANTS
+// none
+
+//  MACROS
+// none
+
+
+//  RESOURCE DEFINITIONS
+// ---------------------------------------------------------
+//
+//
+//    MTM info resource for Rights Manager Engine MTM
+//
+// ---------------------------------------------------------
+//
+#ifdef __MESSAGING_API_V2__
+
+#include <e32capability.h>
+
+RESOURCE MTM_INFO_FILE
+    {
+    mtm_type_uid = 0x101F6DC2;
+    technology_type_uid = 0x10009157;
+    components =
+        {
+        MTM_COMPONENT_V2
+            {
+            human_readable_name = qtn_mce_inbox_write_ro;
+            component_uid = KUidMtmServerComponentVal;
+            entry_point = 1;
+            version = VERSION_V2 {};
+            filename = "romtmser.dll";
+            },
+        MTM_COMPONENT_V2
+            {
+            human_readable_name = qtn_mce_inbox_write_ro;
+            component_uid = KUidMtmClientComponentVal;
+            entry_point = 1;
+            version = VERSION_V2 {};
+            filename = "romtmcli.dll";
+            },
+        MTM_COMPONENT_V2
+            {
+            human_readable_name = qtn_mce_inbox_write_ro;
+            component_uid = KUidMtmUiComponentVal;
+            entry_point = 1;
+            version = VERSION_V2 {};
+            filename = "romtmui.dll";
+            },
+        MTM_COMPONENT_V2
+            {
+            human_readable_name = qtn_mce_inbox_write_ro;
+            component_uid = KUidMtmUiDataComponentVal;
+            entry_point = 1;
+            version = VERSION_V2 {};
+            filename = "romtmdat.dll";
+            }
+        };
+    }
+
+RESOURCE MTM_CAPABILITIES
+    {
+    }
+
+RESOURCE MTM_SECURITY_CAPABILITY_SET
+    {
+    capabilities = { ECapabilityNetworkServices };
+    }
+
+#else
+RESOURCE MTM_INFO_FILE
+    {
+    mtm_type_uid = 0x101F6DC2;
+    technology_type_uid = 0x10009157;
+    components =
+        {
+        MTM_COMPONENT
+            {
+            human_readable_name = qtn_mce_inbox_write_ro;
+            component_uid = KUidMtmServerComponentVal;
+            specific_uid = 0x101F6DC1;
+            entry_point = 1;
+            version = VERSION { major = 1; minor = 0; build = 100; };
+            },
+        MTM_COMPONENT
+            {
+            human_readable_name = qtn_mce_inbox_write_ro;
+            component_uid = KUidMtmClientComponentVal;
+            specific_uid = 0x101F6DC0;
+            entry_point = 1;
+            version = VERSION { major = 1; minor = 0; build = 100; };
+            },
+        MTM_COMPONENT
+            {
+            human_readable_name = qtn_mce_inbox_write_ro;
+            component_uid = KUidMtmUiComponentVal;
+            specific_uid = 0x101F6DBE;
+            entry_point = 1;
+            version = VERSION { major = 1; minor = 0; build = 100; };
+            },
+        MTM_COMPONENT
+            {
+            human_readable_name = qtn_mce_inbox_write_ro;
+            component_uid = KUidMtmUiDataComponentVal;
+            specific_uid = 0x101F6DBF;
+            entry_point = 1;
+            version = VERSION { major = 1; minor = 0; build = 100; };
+            }
+        };
+    }
+
+#endif
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmromtm/uiData/src/RoMtmUi.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,130 @@
+/*
+* Copyright (c) 2002 - 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resources for the Mtm Ui Data
+*
+*/
+
+
+
+
+
+//  INCLUDES
+
+#include <romtmui.loc>
+#include <eikon.rh>
+#include <uikon.rh>
+#include <uikon.hrh>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.loc>
+#include <mtud.rh>
+#include <MTMExtendedCapabilities.hrh>
+#include <Muiu.mbg>
+#include <data_caging_paths_strings.hrh>
+
+#include "RoMtmCommands.hrh"
+#include "RoMtmUi.hrh"
+//  RESOURCE DEFINITIONS
+
+NAME ROUI
+
+RESOURCE RSS_SIGNATURE { }
+
+//=============================================================================
+//
+// MTM UI Data framework related resources
+//
+//=============================================================================
+
+
+
+// User information strings
+RESOURCE TBUF80 r_roud_can_not_edit_folders  {buf="Can not edit folders";}
+RESOURCE TBUF80 r_roud_only_messages  {buf="This can only be done on local messages";}
+RESOURCE TBUF80 r_roud_not_supported  {buf="This action is not supported";}
+
+
+RESOURCE AKN_ICON_ARRAY r_ronsm_icons
+    {
+    bmpfile = APP_BITMAP_DIR"\\Muiu.mbm";
+
+    icons =
+        {
+        AKN_ICON { iconId = EMbmMuiuQgn_prop_mce_push_unread;
+                   maskId = EMbmMuiuQgn_prop_mce_push_unread_mask; }
+        };
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_romtmui_trigger_confirmation_query
+// Confirmation query dialog
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE DIALOG r_romtmui_trigger_confirmation_query
+    {
+    flags=EGeneralQueryFlags;
+    buttons=R_AVKON_SOFTKEYS_YES_NO__YES;
+    items=
+        {
+        DLG_LINE
+            {
+            type=EAknCtQuery;
+            id=EGeneralQuery;
+            control= AVKON_CONFIRMATION_QUERY
+                {
+                layout = EConfirmationQueryLayout;
+                label = " ";
+                };
+            }
+        };
+    }
+
+
+// -----------------------------------------------------------------------------
+//
+// r_romtmui_query_rights_acq_msg
+// Confirmation query text used when triggering rights acquisition
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_romtmui_query_rights_acq_msg
+    {
+    buf = qtn_drm_query_rights_acq_msg;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_romtmui_query_join_domain_msg
+// Confirmation query text used when triggering registration to a domain
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_romtmui_query_join_domain_msg
+    {
+    buf = qtn_drm_query_join_domain_msg;
+    }
+
+// -----------------------------------------------------------------------------
+//
+// r_romtmui_query_leave_domain_msg
+// Confirmation query text used when triggering unregistration to a domain
+//
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_romtmui_query_leave_domain_msg
+    {
+    buf =  qtn_drm_query_leave_domain_msg;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmudtmodule/bwinscw/DrmUdtModuleU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,6 @@
+EXPORTS
+	??1CDrmUdtHandler@@UAE@XZ @ 1 NONAME ; CDrmUdtHandler::~CDrmUdtHandler(void)
+	?DoUserDataTransferL@CDrmUdtHandler@@QAEXABVTDesC8@@0PAVMDrmUdtObserver@@AAVTRequestStatus@@@Z @ 2 NONAME ; void CDrmUdtHandler::DoUserDataTransferL(class TDesC8 const &, class TDesC8 const &, class MDrmUdtObserver *, class TRequestStatus &)
+	?NewL@CDrmUdtHandler@@SAPAV1@XZ @ 3 NONAME ; class CDrmUdtHandler * CDrmUdtHandler::NewL(void)
+	?SetPreferredIap@CDrmUdtHandler@@QAEXK@Z @ 4 NONAME ; void CDrmUdtHandler::SetPreferredIap(unsigned long)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmudtmodule/eabi/DrmUdtModuleU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,9 @@
+EXPORTS
+	_ZN14CDrmUdtHandler15SetPreferredIapEm @ 1 NONAME
+	_ZN14CDrmUdtHandler19DoUserDataTransferLERK6TDesC8S2_P15MDrmUdtObserverR14TRequestStatus @ 2 NONAME
+	_ZN14CDrmUdtHandler4NewLEv @ 3 NONAME
+	_ZTI11CDrmUdtConn @ 4 NONAME ; #<TI>#
+	_ZTI14CDrmUdtHandler @ 5 NONAME ; #<TI>#
+	_ZTV11CDrmUdtConn @ 6 NONAME ; #<VT>#
+	_ZTV14CDrmUdtHandler @ 7 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmudtmodule/group/DrmUdtModule.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,67 @@
+/*
+* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+TARGET      DrmUdtModule.dll
+TARGETTYPE  DLL
+UID         0x1000008D 0x10205CAB
+CAPABILITY  CAP_GENERAL_DLL DRM
+VENDORID    VID_DEFAULT
+
+SOURCEPATH  ../src 
+SOURCE      DrmUdtHandler.cpp
+SOURCE      DrmUdtConn.cpp
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../../omadrm/drmengine/RoapStorage/inc
+USERINCLUDE     ../../../../omadrm/drmengine/Utils/inc
+USERINCLUDE	    ../../../../inc   // ADo level inc dir
+
+// Default system include paths for middleware layer modules.
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE /epoc32/include/http
+SYSTEMINCLUDE /epoc32/include/ecom
+
+LIBRARY     euser.lib
+LIBRARY     estor.lib
+LIBRARY     efsrv.lib    
+LIBRARY     commdb.lib
+LIBRARY     bafl.lib 
+LIBRARY     esock.lib
+LIBRARY     http.lib     
+LIBRARY     inetprotutil.lib
+LIBRARY	    apmime.lib
+LIBRARY     random.lib
+LIBRARY     hash.lib
+LIBRARY     etel.lib
+LIBRARY	    etelmm.lib
+LIBRARY     flogger.lib
+LIBRARY     DrmServerInterfaces.lib
+
+#if defined(ARMCC)
+deffile ../eabi/ 
+#elif defined( WINSCW )
+deffile ../bwinscw/ 
+#elif defined( WINS )
+deffile ../bwins/ 
+#else
+deffile ../bmarm/ 
+#endif
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmudtmodule/inc/DrmUdtConn.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,95 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#ifndef DRM_UDT_CONN_H
+#define DRM_UDT_CONN_H
+
+// INCLUDES
+
+#include <e32base.h>
+#include <es_sock.h>
+#include <CommDbConnPref.h>
+
+
+// FORWARD DECLARATIONS
+class MDrmUdtObserver;
+
+// CLASS DECLARATION
+
+class CDrmUdtConn : public CActive
+    {
+    public:     // Constructors and destructor.
+
+        static CDrmUdtConn* NewL();
+
+        CDrmUdtConn();
+
+        ~CDrmUdtConn();
+
+    public:     // new methods
+
+        void ConnectL( TUint32 aIap,
+                       MDrmUdtObserver* aObserver,
+                       TRequestStatus* aStatus );
+
+        void Close();
+
+        TBool IsConnected( TUint32& aIap );
+
+        RSocketServ& SocketServ();
+
+        RConnection& Conn();
+
+    private:
+
+        enum TState
+            {
+            EInit,
+            EConnecting,
+            EConnected
+            };
+
+    private:    // Constructors and destructor.
+
+        void ConstructL();
+
+    private:  // from CActive
+
+        virtual void DoCancel();
+
+        virtual void RunL();
+
+        virtual TInt RunError( TInt aError );
+
+    private:    // new methods
+
+        void DoClose();
+
+        void Done();
+
+    private:    // data
+
+        RSocketServ iSocketServ;
+        RConnection iConnection;
+        TState iState;
+        TRequestStatus* iParentStatus;
+        TCommDbConnPref iConnPref;
+        MDrmUdtObserver* iObserver;
+    };
+
+#endif /* def CONNECTION_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmudtmodule/src/DrmUdtConn.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,311 @@
+/*
+* Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// INCLUDE FILES
+
+#include "DrmUdtConn.h"
+#include "DrmUdtObserver.h"
+
+#include <CommDbConnPref.h>
+#include <commdb.h>
+#include <cdblen.h>
+#include <es_enum.h>
+
+// #include <ApSelect.h> // for checking APs
+
+#ifdef _DEBUG
+#define LOGGING
+#endif
+
+#define LOGGING
+
+#ifdef LOGGING
+_LIT(KLogDir, "DRM");
+_LIT(KLogName, "UDT.log");
+#include "flogger.h"
+#define LOG(string) \
+	RFileLogger::Write(KLogDir, KLogName, \
+		EFileLoggingModeAppend, string);
+#define LOGHEX(buffer) \
+	RFileLogger::HexDump(KLogDir, KLogName, \
+		EFileLoggingModeAppend, _S(""), _S(""), \
+		buffer.Ptr(), buffer.Length());
+#else
+#define LOG
+#define LOGHEX        
+#endif
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CDrmUdtConn::NewL()
+// ---------------------------------------------------------
+//
+CDrmUdtConn* CDrmUdtConn::NewL()
+    {
+    LOG( _L("CDrmUdtConn::NewL") );
+    CDrmUdtConn* conn = new (ELeave) CDrmUdtConn();
+    CleanupStack::PushL( conn );
+    conn->ConstructL();
+    CleanupStack::Pop( conn );
+    return conn;
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtConn::~CDrmUdtConn()
+// ---------------------------------------------------------
+//
+CDrmUdtConn::~CDrmUdtConn()
+    {
+    LOG( _L("CDrmUdtConn::~CDrmUdtConn") );
+    Cancel();
+    iConnection.Close();
+    iSocketServ.Close();
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtConn::ConnectL()
+// ---------------------------------------------------------
+//
+void CDrmUdtConn::ConnectL( TUint32 aIap,
+                            MDrmUdtObserver* aObserver,
+                            TRequestStatus* aStatus )
+    { 
+    LOG( _L("CDrmUdtConn::ConnectL") );
+    
+    iObserver = aObserver;
+    
+    if ( iState == EInit )
+        {
+        // Not connected. Attach to existing connection, or create new one if
+        // allowed.
+        iStatus = KErrGeneral;
+
+        // Make this part atomic by pushing closes on the stack.
+        User::LeaveIfError( iSocketServ.Connect() );
+        CleanupClosePushL<RSocketServ>( iSocketServ );
+        User::LeaveIfError( iConnection.Open( iSocketServ ) );
+        CleanupClosePushL<RConnection>( iConnection );
+                
+        TConnectionInfoBuf connInfo;
+        TUint count;
+        User::LeaveIfError( iConnection.EnumerateConnections( count ) );
+        TUint i;
+        if ( count )
+            {
+            // Select from existing connections. Try to make AP match.
+            for ( i = count; i; i-- )
+                {
+                // Note: GetConnectionInfo expects 1-based index.
+                User::LeaveIfError( iConnection.GetConnectionInfo( i, connInfo ) );
+                if ( aIap == 0 || connInfo().iIapId == aIap )
+                    {
+                    // "Accept any" or AP match. Attach to this one.
+                    break;
+                    }
+                }
+            if ( !i )
+                {
+                // No AP match, select AP with largest index.
+                User::LeaveIfError
+                    ( iConnection.GetConnectionInfo( count, connInfo ) );
+                }
+            User::LeaveIfError
+                ( iConnection.Attach( connInfo, RConnection::EAttachTypeNormal ) );
+            iState = EConnected;
+            iStatus = KErrNone;
+            }
+        else
+            {
+            // No existing connections, create new one.
+#ifdef __WINS__
+            // WINS connection creation does not work if preferences are given.
+            // Defaults are to be used always.
+            iConnection.Start( iStatus );
+#else
+            // Note: the TCommDbConnPref must NOT be stack variable.
+            // It must persist until completion of RConnection::Start().
+            iConnPref.SetDirection( ECommDbConnectionDirectionOutgoing );
+            iConnPref.SetDialogPreference( ECommDbDialogPrefPrompt );
+            iConnPref.SetBearerSet( ECommDbBearerCSD | ECommDbBearerWcdma );
+            // New connection is always created with user-selected AP;
+            // so 0 is used instead of aIap.
+            iConnPref.SetIapId( 0 );
+            iConnection.Start( iConnPref, iStatus );
+#endif
+            if ( iObserver )
+                {
+                iObserver->ConnectionStartedL();
+                }
+
+            iState = EConnecting;
+            SetActive();    // The only path with a real async request.
+            }
+        CleanupStack::Pop( 2 ); // closing iConn and iSockServ
+        // End of atomic part.
+        }
+    else
+        {
+        // Not expecting this to be called in other states.
+        }
+
+    iParentStatus = aStatus;
+    *iParentStatus = KRequestPending;
+
+    if ( !IsActive() )
+        {
+        // Unless we have an outstanding connect request (iConn.Start),
+        // we are done.
+        User::RequestComplete( iParentStatus, iStatus.Int() );
+        iParentStatus = NULL;
+        }
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtConn::Close()
+// ---------------------------------------------------------
+//
+void CDrmUdtConn::Close()
+    {
+    LOG( _L("CDrmUdtConn::Close") );
+    Cancel();
+    iConnection.Close();
+    iSocketServ.Close();
+    iState = EInit;
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtConn::IsConnected()
+// ---------------------------------------------------------
+//
+TBool CDrmUdtConn::IsConnected( TUint32& aIap )
+    {
+    LOG( _L("CDrmUdtConn::IsConnected") );
+    TBool connected( EFalse );
+    if( iState == EConnected )
+        {
+        TBuf<KCommsDbSvrMaxColumnNameLength * 2 + 1> iapId;
+        _LIT( KFormatIapId, "%S\\%S" );
+        TPtrC iap( IAP );
+        TPtrC id( COMMDB_ID );
+        iapId.Format( KFormatIapId, &iap, &id );
+        TInt err = iConnection.GetIntSetting( iapId, aIap );
+        connected = err ? EFalse : ETrue;
+        }
+    return connected;
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtConn::CConnection()
+// ---------------------------------------------------------
+//
+CDrmUdtConn::CDrmUdtConn()
+: CActive( CActive::EPriorityStandard ),
+  iState( EInit )
+    {
+    LOG( _L("CDrmUdtConn::CDrmUdtConn") );
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtConn::ConstructL()
+// ---------------------------------------------------------
+//
+void CDrmUdtConn::ConstructL()
+    {
+    LOG( _L("CDrmUdtConn::ConstructL") );
+    /*
+    TUint32 APs( 0 );
+    CCommsDatabase* commsdb = CCommsDatabase::NewL( EDatabaseTypeIAP );
+    CleanupStack::PushL( commsdb );
+    CApSelect* apSel = CApSelect::NewLC (
+        *commsdb,
+        KEApIspTypeAll,
+        EApBearerTypeAll,
+        KEApSortUidAscending );
+    APs = apSel->Count();
+    CleanupStack::PopAndDestroy( 2 );
+    if ( !APs )
+        {
+        // No AP defined
+        User::Leave( KErrRoapGeneral );
+        }
+     */
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtConn::DoCancel()
+// ---------------------------------------------------------
+//
+void CDrmUdtConn::DoCancel()
+    {
+    LOG( _L("CDrmUdtConn::DoCancel") );
+    iConnection.Close();
+    iSocketServ.Close();
+    User::RequestComplete( iParentStatus, KErrCancel );
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtConn::RunL()
+// ---------------------------------------------------------
+//
+void CDrmUdtConn::RunL()
+    {
+    LOG( _L("CDrmUdtConn::RunL") );
+    User::LeaveIfError( iStatus.Int() );    // Handle errors in RunError().
+
+    iState = EConnected;
+    User::RequestComplete( iParentStatus, iStatus.Int() );
+    iParentStatus = NULL;
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtConn::RunError()
+// ---------------------------------------------------------
+//
+TInt CDrmUdtConn::RunError( TInt  /*aError*/ )
+    {
+    LOG( _L("CDrmUdtConn::RunError") );
+    iConnection.Close();
+    iSocketServ.Close();
+    iState = EInit;
+    User::RequestComplete( iParentStatus, iStatus.Int() );
+    iParentStatus = NULL;
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CRoapConnection::Conn()
+// ---------------------------------------------------------
+//
+RSocketServ& CDrmUdtConn::SocketServ()
+    {
+    LOG( _L("CDrmUdtConn::SocketServ") );
+    return iSocketServ;
+    }
+
+// ---------------------------------------------------------
+// CRoapConnection::Conn()
+// ---------------------------------------------------------
+//
+RConnection& CDrmUdtConn::Conn()
+    {
+    LOG( _L("CDrmUdtConn::Conn") );
+    return iConnection;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmplugins/drmudtmodule/src/DrmUdtHandler.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1228 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the User Data Transfer module
+*
+*/
+
+
+// INCLUDE FILES
+#include "DrmUdtHandler.h"
+#include "DrmUdtConn.h"
+#include "RoapStorageClient.h"
+#include "DrmRightsClient.h"
+#include "DrmUdtObserver.h"
+
+#include <hash.h>
+#include <stringpool.h>
+#include <http/thttphdrval.h>
+#include <etelmm.h> 
+#include <mmtsy_names.h>
+
+#ifdef _DEBUG
+#define LOGGING
+#endif
+
+#define LOGGING
+
+#ifdef LOGGING
+_LIT(KLogDir, "DRM");
+_LIT(KLogName, "UDT.log");
+#include "flogger.h"
+#define LOG(string) \
+	RFileLogger::Write(KLogDir, KLogName, \
+		EFileLoggingModeAppend, string);
+#define LOGINT(string, val) \
+	RFileLogger::WriteFormat(KLogDir, KLogName, \
+		EFileLoggingModeAppend, string, val);
+#define LOGHEX(buffer) \
+	RFileLogger::HexDump(KLogDir, KLogName, \
+		EFileLoggingModeAppend, _S(""), _S(""), \
+		buffer.Ptr(), buffer.Length());
+#else
+#define LOG
+#define LOGHEX        
+#endif
+
+using namespace Roap;
+
+// ================= CONSTANTS ======================
+
+// The time out value in HTTP, 30 sec
+LOCAL_D const TInt KUdtTimeoutValue = 30000000;
+
+LOCAL_D const TInt KMaxSerNumLength = 64;
+LOCAL_D const TInt KRdbKeyLength = 256;
+LOCAL_D const TInt KVersionSize = 1;
+LOCAL_D const TInt KMessageIdSize = 1;
+LOCAL_D const TInt KLengthSize = 4;
+LOCAL_D const TInt KSignatureLength = 128;
+
+LOCAL_D const TInt KVersion = 0;
+
+LOCAL_D const TInt KPadding255 = 1;
+
+_LIT8( KUdtContentType, "application/binary" );
+
+// UDT message identifiers
+LOCAL_D const TUint8 KUdtRequestId = 0;
+LOCAL_D const TUint8 KUdtResponseId = 1;
+LOCAL_D const TUint8 KStatusResponseId = 3;
+LOCAL_D const TUint8 KErrorResponseId = 4;
+LOCAL_D const TUint8 KServerErrorValue = 0;
+LOCAL_D const TUint8 KClientErrorValue = 1;
+
+
+LOCAL_D const TInt KUdtResponseSize = 129;
+
+NONSHARABLE_STRUCT( TUnloadModule )
+    {
+    RTelServer* iServer;
+    const TDesC* iName;
+    };
+
+// ================= LOCAL FUNCTIONS =========================
+
+LOCAL_C void WriteIntToBlock( TInt aValue, TDes8& aBlock, TInt aOffset )
+    {
+    aBlock.SetLength(4);
+    aBlock[aOffset] =     (aValue & 0xff000000) >> 24;
+    aBlock[aOffset + 1] = (aValue & 0x00ff0000) >> 16;
+    aBlock[aOffset + 2] = (aValue & 0x0000ff00) >> 8;
+    aBlock[aOffset + 3] = (aValue & 0x000000ff);
+    }
+
+template<class S>
+void PointerArrayResetDestroyAndClose(TAny* aPtr)
+    {
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->ResetAndDestroy();
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->Close();
+    }
+    
+LOCAL_C void DoUnloadPhoneModule( TAny* aAny )
+    {
+    __ASSERT_DEBUG( aAny, User::Invariant() );
+    TUnloadModule* module = ( TUnloadModule* ) aAny;
+    module->iServer->UnloadPhoneModule( *( module->iName ) );
+    } 
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::NewL()
+// ---------------------------------------------------------
+//
+EXPORT_C CDrmUdtHandler* CDrmUdtHandler::NewL( )
+    {
+    LOG( _L("CDrmUdtHandler:NewL:") );
+    CDrmUdtHandler* handler = new( ELeave ) CDrmUdtHandler();
+    CleanupStack::PushL( handler );
+    handler->ConstructL();
+    CleanupStack::Pop( handler );
+    return handler;
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::~CDrmUdtModule()
+// ---------------------------------------------------------
+//
+CDrmUdtHandler::~CDrmUdtHandler()
+    {
+    LOG( _L("CDrmUdtHandler::~CDrmUdtHandler") );
+    Cancel();
+	iSession.Close();
+	delete iConnection;
+	delete iUri;
+	delete iTimeout;
+    delete iOneTimePassword;
+    delete iUdtRequest;
+    delete iUdtResponse;
+    }
+    
+// ---------------------------------------------------------
+// CDrmUdtHandler::ConstructL()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::ConstructL() 
+    {
+    LOG( _L("CDrmUdtHandler::ConstructL") );
+    iConnection = CDrmUdtConn::NewL();
+    iTimeout = CPeriodic::NewL( CActive::EPriorityUserInput );
+    iRequestType = EUdtRequest;
+    iUdtError = EUdtOk;
+    iStateInfo.iState = TUdtStateInfo::EUdtNotStarted;
+    iStateInfo.iProgress = 0;
+    iStateInfo.iError = EUdtOk;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDrmUdtHandler::DoUserDataTransferL()
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CDrmUdtHandler::DoUserDataTransferL( const TDesC8& aOneTimePassword,
+                                                   const TDesC8& aServiceUrl,
+                                                   MDrmUdtObserver* aObserver,
+                                                   TRequestStatus& aStatus )
+    {
+    LOG( _L("CDrmUdtHandler::DoUserDataTransferL") );
+    __ASSERT_ALWAYS( iState == EInit, User::Invariant() );
+    
+    /*
+    1. fetch original RDB data from the rights client (serial number and key)
+    2. create UDT package with the original RDB data, the one time password,
+       our serial number and our certificate
+    3. open a connection to the service URL
+    4. do a POST to the service URL, sending our UDT package
+    5. receive the anwser with the re-encrypted RDB key
+    6. tell the rights client to do a restore, using the re-encrypted RDB key
+    7. do a POST to the service URL, sendind a success or error notification
+    */
+
+    iOneTimePassword = aOneTimePassword.AllocLC();
+    iUri = aServiceUrl.AllocL();
+    iObserver = aObserver;
+    
+    LOG( _L8("Password: ") );
+    LOG( aOneTimePassword );
+    LOG( _L8("URL: ") );
+    LOG( aServiceUrl );
+    
+    iParentStatus = &aStatus;    
+    *iParentStatus = KRequestPending;
+    iState = EStart;
+    TRequestStatus* ownStatus = &iStatus;    
+    *ownStatus = KRequestPending;
+    iRequestType = EUdtRequest;
+    
+    SetActive();
+    User::RequestComplete( ownStatus, KErrNone );      
+    CleanupStack::Pop(); // iOneTimePassword    
+    }
+    
+// ---------------------------------------------------------
+// CDrmUdtHandler::SetPreferredIap()
+// ---------------------------------------------------------
+EXPORT_C void CDrmUdtHandler::SetPreferredIap( TUint32 aPreferredIap )
+    {
+    LOG( _L("CDrmUdtHandler::SetPreferredIap") );
+    iPreferredIap = aPreferredIap;
+    }    
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::DoCancel()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::DoCancel()
+    {
+    LOG( _L("CDrmUdtHandler::DoCancel") );
+    switch ( iState )
+        {
+        case EStart:
+        case EConnect:
+            {
+            iConnection->Cancel();
+            break;
+            }
+        case EResponseReceived:
+            {
+            iTransaction.Close();
+            SelfComplete( iError );
+            break;
+            }
+        default:
+            {
+            break;
+            }
+        }
+	iError = KErrCancel;
+	Complete();
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::RunL()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::RunL()
+    {
+    LOG( _L("CDrmUdtHandler::RunL") );
+    User::LeaveIfError( iStatus.Int() );
+
+    switch ( iState )
+        {
+        case EStart:
+            {
+            ConnectL();
+            break;
+            }        
+        case EConnect:
+            {
+            CreateSessionL();
+            break;
+            }
+        case ESendMessage:
+            {
+            SendUdtMessageL();
+            break;
+            }
+        case EResponseReceived:
+            {
+            ResponseReceivedL();
+            break;
+            }
+        case EComplete:
+            {
+            iState = EInit;
+    		Complete();
+            break;
+            }
+        case EInit:
+        default:
+            {
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::RunError()
+// ---------------------------------------------------------
+//
+TInt CDrmUdtHandler::RunError( TInt aError )
+    {
+    LOG( _L("CDrmUdtHandler::RunError") );
+    iError = aError;
+    iState = EInit;
+    Complete();
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::ConnectL()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::ConnectL()
+    {
+    LOG( _L("CDrmUdtHandler::ConnectL") );
+    __ASSERT_ALWAYS( iState == EStart, User::Invariant() );
+    
+    iConnection->ConnectL( iPreferredIap, iObserver, &iStatus );
+    iState = EConnect;
+    iError = EUdtOk;
+    SetActive();
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::CreateSessionL()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::CreateSessionL()
+    {
+    LOG( _L("CDrmUdtHandler::CreateSessionL") );
+    __ASSERT_ALWAYS( iState == EConnect, User::Invariant() );
+    
+    TUint32 ap;
+
+    if( !iConnection->IsConnected( ap ) )
+        {
+        User::Leave( KErrGeneral );
+        }
+    
+    iSession.Close();
+    iSession.OpenL();
+
+    RStringPool strPool = iSession.StringPool();
+
+    // Remove first session properties just in case.
+    RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
+    
+    // Clear RConnection and Socket Server instances
+    connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketServ,RHTTPSession::GetTable()));
+    connInfo.RemoveProperty(strPool.StringF(HTTP::EHttpSocketConnection,RHTTPSession::GetTable()));
+    
+#ifdef __WINS__    
+    // Clear the proxy settings
+    RStringF proxy;
+    proxy = strPool.OpenFStringL(_L8("172.22.168.15"));
+    connInfo.SetPropertyL
+        ( 
+        strPool.StringF( HTTP::EProxyAddress, RHTTPSession::GetTable() ), 
+        THTTPHdrVal( proxy ) 
+        );
+    proxy.Close();
+    connInfo.SetPropertyL
+        ( 
+        strPool.StringF( HTTP::EProxyUsage, RHTTPSession::GetTable() ), 
+        THTTPHdrVal( strPool.StringF(HTTP::EUseProxy, RHTTPSession::GetTable() ) )
+        );
+
+#else
+    THTTPHdrVal proxyUsage(strPool.StringF(HTTP::EUseProxy,RHTTPSession::GetTable()));
+    connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyUsage,RHTTPSession::GetTable()));
+    connInfo.RemoveProperty(strPool.StringF(HTTP::EProxyAddress,RHTTPSession::GetTable()));
+#endif
+
+    connInfo.SetPropertyL
+        (
+        strPool.StringF( HTTP::EHttpSocketServ, RHTTPSession::GetTable() ),
+        THTTPHdrVal( iConnection->SocketServ().Handle() )
+        );
+
+    connInfo.SetPropertyL
+        ( 
+        strPool.StringF( HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ), 
+        THTTPHdrVal( REINTERPRET_CAST( TInt, &iConnection->Conn() ) )
+        );
+
+    InstallHttpFiltersL();
+
+    // Complete requests
+    TRequestStatus* ownStatus = &iStatus;    
+    *ownStatus = KRequestPending;
+    iState = ESendMessage;
+    SetActive();
+    User::RequestComplete( ownStatus, KErrNone );
+    }
+
+
+// ---------------------------------------------------------
+// CDrmUdtModule::InstallHttpFilters()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::InstallHttpFiltersL()
+    {
+    LOG( _L("CDrmUdtHandler::InstallHttpFiltersL") );
+ // CHttpUAProfFilterInterface::InstallFilterL( iSession );
+ // CHttpCookieFilter::InstallFilterL( iSession );
+ // InstallAuthenticationL( iSession );
+ // CHttpFilterProxyInterface::InstallFilterL( iSession );
+    }
+
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::SendUdtMessageL()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::SendUdtMessageL()
+    {
+    LOG( _L("CDrmUdtHandler::SendUdtMessageL") );
+    __ASSERT_ALWAYS( iState == ESendMessage, User::Invariant() );
+    
+    TUriParser8 uri;
+    
+    if ( iRequestType == EUdtRequest )
+        {
+        CreateUdtRequestL();
+        }
+    else if( iRequestType == EStatusNotification )
+        {
+        CreateStatusNotificationL();
+        }
+    
+    User::LeaveIfError( uri.Parse( *iUri ) );
+    RStringF POST;
+    POST = iSession.StringPool().StringF( HTTP::EPOST, RHTTPSession::GetTable() );
+    iTransaction = iSession.OpenTransactionL( uri, *this, POST );
+
+    // Set required headers
+    RHTTPHeaders hdrs = iTransaction.Request().GetHeaderCollection();
+    
+    SetHeaderL(hdrs, HTTP::EAccept, KUdtContentType() );
+    
+    SetHeaderL(hdrs, HTTP::EContentType, KUdtContentType() );
+    
+    // Add request body
+    MHTTPDataSupplier* ds = this;
+    iTransaction.Request().SetBody(*ds);
+    
+    iTransaction.SubmitL();
+
+    iState = EResponseReceived;
+    iStatus = KRequestPending;
+    SetActive();
+
+    iTimeout->Cancel();
+    iTimeout->Start( KUdtTimeoutValue,
+    				 KUdtTimeoutValue,
+    				 TCallBack( StaticTimeOut,this ) );
+    }
+    
+    
+// ---------------------------------------------------------
+// CDrmUdtHandler::CreateUdtRequestL()
+// ---------------------------------------------------------
+//    
+void CDrmUdtHandler::CreateUdtRequestL()
+    {
+    RRoapStorageClient client;
+    RPointerArray< HBufC8 > certChain;
+    TCleanupItem listCleanup( PointerArrayResetDestroyAndClose< HBufC8 >,
+        &certChain );
+    HBufC8* certBlock;
+    TInt i;
+    TInt n;
+    TPtr8 ptr( NULL, 0 );
+    TBuf8< sizeof ( TUint32 ) > intBuf;
+    TBuf8< KMaxSerNumLength > targetSer;
+    TBuf8< KRdbKeyLength > rdb_data;
+    TBuf8< KSignatureLength > hash;
+    HBufC8* signature = NULL;
+    TInt udtVersion;
+    CSHA1* hasher = NULL;
+    
+    LOG( _L("CDrmUdtHandler::CreateUdtRequestL") );
+    delete iUdtRequest;
+    
+    if ( iObserver )
+        {
+        iStateInfo.iState = TUdtStateInfo::EUdtReguest;
+        iStateInfo.iProgress = 0;
+        iObserver->UdtProgressInfoL( iStateInfo );
+        }
+    
+    hasher = CSHA1::NewL();
+    CleanupStack::PushL( hasher );
+    User::LeaveIfError( client.Connect() );
+    CleanupClosePushL( client );
+    client.SelectTrustedRootL( KNullDesC8 );
+
+    LOG( _L("  Getting cert chain") );
+    User::LeaveIfError( client.GetDeviceCertificateChainL( certChain ) );
+    CleanupStack::PushL( listCleanup );
+
+    LOG( _L("  Getting UDT data") );
+    ReadUdtDataL( targetSer, udtVersion, rdb_data );
+
+    LOG(_L8("RDB data:"));    
+    LOGHEX(rdb_data)
+    
+    n = 0;
+    for ( i = 0; i < certChain.Count(); i++ )
+        {
+        n = n + KLengthSize + certChain[i]->Size();
+        }
+    certBlock = HBufC8::NewL( n );
+    CleanupStack::PushL( certBlock );
+    ptr.Set( certBlock->Des() );
+    for ( i = 0; i < certChain.Count(); i++ )
+        {
+        WriteIntToBlock( certChain[i]->Size(), intBuf, 0 );
+        ptr.Append( intBuf );
+        ptr.Append( *certChain[i] );
+        }
+
+    n = KVersionSize + 
+        KMessageIdSize + 
+        KLengthSize + 
+        iOneTimePassword->Size() + 
+        KLengthSize +
+        certBlock->Size() + 
+        KLengthSize +
+        targetSer.Size() +
+        rdb_data.Size() + 
+        KLengthSize + 
+        KSignatureLength;
+        
+    iUdtRequest = HBufC8::NewL( n );
+    ptr.Set( iUdtRequest->Des() );
+    WriteIntToBlock( n - (KVersionSize + KMessageIdSize + 
+                     KLengthSize + KSignatureLength), intBuf, 0 );
+    
+    ptr.Append( KVersion );             // 1. version
+    ptr.Append( KUdtRequestId );        // 2. request id
+    ptr.Append( intBuf );               // 3. request length
+    ptr.Append( *iOneTimePassword );    // 4. password
+    WriteIntToBlock( certBlock->Size(), intBuf, 0 );
+    ptr.Append( intBuf );               // 5. ceritificate block length
+    ptr.Append( *certBlock );           // 6. ceritificate block
+    WriteIntToBlock( targetSer.Size(), intBuf, 0 );
+    ptr.Append( intBuf );               // 7. serial number length
+    ptr.Append( targetSer );            // 8. original serial number
+    ptr.Append( rdb_data );             // 9. RDB data
+    WriteIntToBlock( udtVersion, intBuf, 0 );
+    ptr.Append( intBuf );               // 10. UDT key version
+    
+    hasher->Update( ptr );
+    hash.Append( 0 );
+    hash.Append( KPadding255 );
+    for ( i = 2; i < KSignatureLength - SHA1_HASH - 1; i++ )
+        {
+        hash.Append( 255 );
+        }
+    hash.Append( 0 );
+    hash.Append( hasher->Final() );
+    LOG(_L8("Hash:"));
+    LOGHEX(hash);
+    client.RsaSignL( hash, signature );
+    CleanupStack::PushL(signature);
+    ptr.Append( *signature );           // 11. signature
+    LOG(_L8("Signature:"));
+    LOGHEX((*signature));
+    
+    CleanupStack::PopAndDestroy( 5 );   // certBlock, listCleanup,
+                                        // client, hasher, signature
+    if ( iObserver )
+        {
+        iStateInfo.iState = TUdtStateInfo::EUdtReguest;
+        iStateInfo.iProgress += 20;
+        iObserver->UdtProgressInfoL( iStateInfo );
+        }
+        
+    LOG(_L8("Request:"));
+    LOGHEX((*iUdtRequest));
+    }
+    
+    
+// ---------------------------------------------------------
+// CDrmUdtHandler::CreateStatusNotificationL()
+// ---------------------------------------------------------
+//    
+void CDrmUdtHandler::CreateStatusNotificationL()
+    {
+    LOG( _L("CDrmUdtHandler::CreateStatusNotificationL") );
+    
+    if ( iObserver )
+        {
+        iStateInfo.iState = TUdtStateInfo::EUdtStatusNotification;
+        iStateInfo.iProgress += 20;
+        iObserver->UdtProgressInfoL( iStateInfo );
+        }
+    
+    delete iUdtRequest;
+    iUdtRequest = NULL;
+    iUdtRequest = HBufC8::NewL(64);
+    TPtr8 ptr = iUdtRequest->Des();
+    ptr.Append(0);
+    ptr.Append(2);
+    ptr.Append(*iOneTimePassword);
+    iUdtError == EUdtOk ? ptr.Append(1) : ptr.Append(0);
+    }
+    
+    
+// ---------------------------------------------------------
+// CDrmUdtHandler::ResponseReceivedL()
+// ---------------------------------------------------------
+//    
+void CDrmUdtHandler::ResponseReceivedL()
+    {
+    LOG( _L("CDrmUdtHandler::ResponseReceivedL") );
+    __ASSERT_ALWAYS( iState == EResponseReceived, User::Invariant() );
+    __ASSERT_ALWAYS( iUdtResponse, User::Invariant() );
+    
+    TPtrC8 udtRespPtr( *iUdtResponse );
+    HBufC8* origDBKey = NULL;
+    TPtrC8 origDBKeyPtr( KNullDesC8 );
+    RDRMRightsClient rightsClient;
+    TInt error = EUdtOk;
+        
+    LOGHEX((*iUdtResponse));
+    
+    // check response type
+    switch ( udtRespPtr[1] )
+        {
+        case KUdtResponseId:
+            {
+            if ( iObserver )
+                {
+                iStateInfo.iState = TUdtStateInfo::EUdtKeyRestore;
+                iStateInfo.iProgress += 20;
+                iObserver->UdtProgressInfoL( iStateInfo );
+                }
+            
+            if ( udtRespPtr.Length() < KUdtResponseSize )
+                {
+                User::Leave( KErrCorrupt );
+                }
+            origDBKeyPtr.Set( udtRespPtr.Mid( 2 ) );
+            origDBKey = origDBKeyPtr.AllocLC();
+            
+            iUdtError = rightsClient.Connect();
+            CleanupClosePushL( rightsClient );
+            
+            if ( !iUdtError )
+                {
+                iUdtError = rightsClient.InitiateUdt( origDBKeyPtr );
+                }
+         
+            CleanupStack::PopAndDestroy( 2 ); // origDBKey, rightsClient
+            
+            iRequestType = EStatusNotification;
+            iState = ESendMessage;
+            iStatus = KRequestPending;
+            SetActive();
+            SelfComplete( KErrNone );
+            break;
+            }
+        case KStatusResponseId:
+            {
+            if ( iObserver )
+                {
+                iStateInfo.iState = TUdtStateInfo::EUdtStatusNotification;
+                iStateInfo.iProgress += 20;
+                iObserver->UdtProgressInfoL( iStateInfo );
+                }
+            
+            iState = EComplete;
+            iStatus = KRequestPending;
+            SetActive();
+            
+            if ( iUdtError )
+                {
+                error = EUdtKeyRestoreFailed;
+                iUdtError = EUdtOk;
+                }
+            SelfComplete( error );
+            break;
+            }
+        case KErrorResponseId:
+            {
+            if ( udtRespPtr.Length() >= 3 && udtRespPtr[2] == KClientErrorValue )
+                {
+                error = EUdtClientError;
+                }
+            else
+                {
+                error = EUdtServerError;
+                }
+            
+            iState = EComplete;
+            iStatus = KRequestPending;            
+            SetActive();
+            SelfComplete( error );
+            break;
+            }
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            }
+        }  
+    }
+    
+// ---------------------------------------------------------
+// CDrmUdtHandler::SetHeaderL()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, const TDesC8& aHdrValue)
+	{
+    LOG( _L("CDrmUdtHandler::SetHeaderL") );
+    RStringF valStr = iSession.StringPool().OpenFStringL(aHdrValue);
+    THTTPHdrVal val(valStr);
+    aHeaders.SetFieldL(iSession.StringPool().StringF(aHdrField,RHTTPSession::GetTable()), val);
+    valStr.Close();
+	}
+    
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::Complete()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::Complete()
+    {
+    LOG( _L("CDrmUdtHandler::Complete") );
+    
+    delete iUri;
+    iUri = NULL;
+    delete iUdtResponse;
+    iUdtResponse = NULL;
+    delete iUdtRequest;
+    iUdtRequest = NULL;
+    delete iOneTimePassword;
+    iOneTimePassword = NULL;
+    
+    if( iTimeout )
+    	{
+    	iTimeout->Cancel();
+    	}
+    	
+    if ( iObserver )
+        {
+        iStateInfo.iState = TUdtStateInfo::EUdtComplete;
+        iStateInfo.iProgress = 100;
+        iStateInfo.iError = iError;
+        TRAPD(ignore, iObserver->UdtProgressInfoL( iStateInfo ));
+        }  
+    
+    User::RequestComplete( iParentStatus, iError );
+    iParentStatus = NULL;
+    }
+
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::CDrmUdtModule()
+// ---------------------------------------------------------
+//
+CDrmUdtHandler::CDrmUdtHandler(): CActive( CActive::EPriorityStandard )
+    {
+    LOG( _L("CDrmUdtHandler::CDrmUdtHandler") );
+    CActiveScheduler::Add( this );
+    }
+
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::SelfComplete()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::SelfComplete( TInt aResult )
+    {
+    LOG( _L("CDrmUdtHandler::SelfComplete") );
+    if ( iStatus == KRequestPending )
+        {
+        TRequestStatus* ownStatus = &iStatus;
+        User::RequestComplete( ownStatus, aResult );
+        }
+    else
+        {
+        if ( aResult != KErrNone )
+            {
+            iStatus = aResult;
+            }
+        }
+    }
+
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::MHFRunL()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::MHFRunL( RHTTPTransaction  /*aTransaction */, 
+								const THTTPEvent& aEvent )
+    {
+    LOGINT( _L("CDrmUdtHandler::MHFRunL: %d"), aEvent.iStatus );
+    iTimeout->Cancel();
+    iTimeout->Start( KUdtTimeoutValue,
+    				 KUdtTimeoutValue, 
+    				 TCallBack( StaticTimeOut,this ) );    				 
+
+    switch ( aEvent.iStatus )
+        {
+        case THTTPEvent::EGotResponseHeaders:
+            {
+            HandleResponseHeadersL( iTransaction.Response() );
+            break;
+            }
+
+        case THTTPEvent::EGotResponseBodyData:
+            {
+            TInt ret( KErrNone );
+            MHTTPDataSupplier* body = iTransaction.Response().Body();
+            TPtrC8 ptr;
+            body->GetNextDataPart( ptr );
+			ret = AppendResponseData( ptr );
+            body->ReleaseData();
+            User::LeaveIfError( ret );
+            break;
+            }
+
+        case THTTPEvent::EFailed:
+            {
+            if ( iError == KErrNone )
+                {
+                iError = EUdtServerError;
+                }
+        	iTransaction.Close();
+            SelfComplete( iError );
+            break;
+            }
+
+        case THTTPEvent::ESucceeded:
+            {        
+            iTransaction.Close();
+            SelfComplete( iError );
+            break;
+            }
+
+        case THTTPEvent::ERedirectRequiresConfirmation:
+            {
+            iTransaction.SubmitL();
+            }
+
+        default:
+            {
+            if( aEvent.iStatus == KErrHttpRedirectUseProxy )
+                {
+                }
+            else
+                {                
+                User::LeaveIfError( aEvent.iStatus );
+                }
+            break;
+            }
+        }
+
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::MHFRunError()
+// ---------------------------------------------------------
+//
+TInt CDrmUdtHandler::MHFRunError (
+        TInt aError,
+        RHTTPTransaction /* aTransaction */,
+        const THTTPEvent& /* aEvent */
+        )
+    {
+    LOG( _L("CDrmUdtHandler::MHFRunError") );
+    iTransaction.Close();
+    iError = aError;
+    SelfComplete( iError );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::HandleResponseHeadersL()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::HandleResponseHeadersL( RHTTPResponse aHttpResponse )
+    {
+    LOG( _L("CDrmUdtHandler::HandleResponseHeadersL") );
+    RHTTPHeaders headers = aHttpResponse.GetHeaderCollection();
+    
+    TInt httpCode = aHttpResponse.StatusCode();
+    TBool status;
+    
+    status = CheckHttpCode( httpCode );
+    
+    if ( status )
+    	{
+        RStringF contentTypeStr;
+        THTTPHdrVal contentTypeVal;
+        TPtrC8 ptrContentType(KNullDesC8);
+		RStringPool srtPool;
+		srtPool = iSession.StringPool();
+        
+        contentTypeStr = srtPool.StringF( HTTP::EContentType, RHTTPSession::GetTable() );										
+    	User::LeaveIfError( headers.GetField( contentTypeStr, 0, contentTypeVal ) );
+    	
+    	if ( contentTypeVal.StrF().DesC().CompareF( KUdtContentType() ) != KErrNone )
+    	    {
+			User::Leave( KErrNotSupported );
+    	    }
+       
+    	}
+    if ( aHttpResponse.HasBody() )
+        {
+        TInt dataSize = aHttpResponse.Body()->OverallDataSize();
+        if ( dataSize >= 0 )
+            {
+            HBufC8* buf = HBufC8::NewL( dataSize );
+            delete iUdtResponse;
+            iUdtResponse = buf;
+            }
+        }
+    }
+     
+// ---------------------------------------------------------
+// CDrmUdtHandler::CheckHttpCode()
+// ---------------------------------------------------------
+//
+TBool CDrmUdtHandler::CheckHttpCode( TInt aHttpStatus )
+	{
+	LOGINT(_L("CDrmUdtHandler::CheckHttpCode: %d"), aHttpStatus);
+    if ( HTTPStatus::IsInformational( aHttpStatus ) )
+        {
+        // 1xx
+        // Informational messages.
+        iError = EUdtServerError;
+        return EFalse;  
+        }
+    else if ( aHttpStatus == HTTPStatus::EOk ||
+              aHttpStatus == HTTPStatus::ENonAuthoritativeInfo )
+        {
+        // 200 OK
+        // 203 Non-Authoritative Information
+        iError = EUdtOk;
+        return ETrue;        
+        }
+    else if ( HTTPStatus::IsSuccessful( aHttpStatus ) )
+        {
+        // 2xx
+        // Success codes without an usable body.
+        iError = EUdtServerError;
+        return EFalse; 
+        }
+    else if ( aHttpStatus == HTTPStatus::EUnauthorized ||
+              aHttpStatus == HTTPStatus::EProxyAuthenticationRequired )
+        {
+        // 401 Unauthorized
+        // 407 Proxy authentication required
+        iError = EUdtInvalidServerAddress;
+        return EFalse; 
+        }
+    else if ( aHttpStatus == HTTPStatus::ENotFound ||
+              aHttpStatus == HTTPStatus::EGone )
+        {
+        // 404 Not found
+        // 410 Gone
+        iError = EUdtInvalidServerAddress;
+        return EFalse; 
+        }
+    else if ( HTTPStatus::IsClientError( aHttpStatus ) )
+        {
+        // 4xx
+        iError = EUdtInvalidServerAddress;
+        return EFalse; 
+        }
+    else if ( aHttpStatus == HTTPStatus::EHTTPVersionNotSupported )
+        {
+        // 505 HTTP Version Not Supported
+        iError = EUdtServerError;
+        return EFalse; 
+        }
+    else if ( HTTPStatus::IsServerError( aHttpStatus ) )
+        {
+        // 5xx
+        iError = EUdtServerError;
+        return EFalse; 
+        }
+    else 
+        {
+        // Everything else.
+        iError = EUdtServerError;
+        }
+    return EFalse; 
+	}
+
+
+// ---------------------------------------------------------
+// CDrmUdtModule::AppendResponseData()
+// ---------------------------------------------------------
+//
+TInt CDrmUdtHandler::AppendResponseData( const TDesC8& aDataChunk )
+    {
+    LOG( _L("CDrmUdtHandler::AppendResponseData") );
+    TInt needed = iUdtResponse->Des().Length() + aDataChunk.Length();
+    if ( iUdtResponse->Des().MaxLength() < needed )
+        {
+        HBufC8* buf = iUdtResponse->ReAlloc( needed );
+        if ( buf )
+            {
+            iUdtResponse = buf;
+            }
+        else
+            {
+            return KErrNoMemory;
+            }
+        }
+    iUdtResponse->Des().Append( aDataChunk );
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+// CDrmUdtHandler::StaticTimeOut()
+// -----------------------------------------------------------------------------
+//
+TInt CDrmUdtHandler::StaticTimeOut( TAny* aPointer )
+    {  
+    LOG( _L("CDrmUdtHandler::StaticTimeOut") );
+    CDrmUdtHandler* itself = STATIC_CAST(CDrmUdtHandler*, aPointer);
+    if(itself)
+        {
+        itself->TimeOut();
+        }
+    return KErrNone;
+    }
+ 
+    
+// -----------------------------------------------------------------------------
+// CDrmUdtHandler::TimeOut()
+// -----------------------------------------------------------------------------
+//
+void CDrmUdtHandler::TimeOut()
+    {
+    LOG( _L("CDrmUdtHandler::TimeOut") );
+    iTransaction.Close();
+    iError = KErrTimedOut;
+    SelfComplete( iError );
+    }
+
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::GetNextDataPart()
+// ---------------------------------------------------------
+//
+TBool CDrmUdtHandler::GetNextDataPart( TPtrC8& aDataPart )
+    {
+    LOG( _L("CDrmUdtHandler::GetNextDataPart") );
+    aDataPart.Set( iUdtRequest->Des() );
+    return ETrue;
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::ReleaseData()
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::ReleaseData()
+    {
+    LOG( _L("CDrmUdtHandler::ReleaseData") );
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::OverallDataSize()
+// ---------------------------------------------------------
+//
+TInt CDrmUdtHandler::OverallDataSize()
+    {
+    LOG( _L("CDrmUdtHandler::OverallDataSize") );
+    return iUdtRequest->Des().Size();
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::Reset()
+// ---------------------------------------------------------
+//
+TInt CDrmUdtHandler::Reset()
+    {
+    LOG( _L("CDrmUdtHandler::Reset") );
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------
+// CDrmUdtHandler::ReadUdtDataL
+//
+// ---------------------------------------------------------
+//
+void CDrmUdtHandler::ReadUdtDataL(
+    TDes8& aTargetSerialNumber,
+    TInt& aUdtKeyVersion,
+    TDes8& aEncryptedRdbData )
+    {
+    RDRMRightsClient rightsClient;
+    HBufC* serialNum = NULL;
+
+    LOG( _L("CDrmUdtHandler::ReadUdtDataL") );
+    User::LeaveIfError( rightsClient.Connect() );
+    CleanupClosePushL( rightsClient );
+    serialNum = SerialNumberL();
+    
+    aTargetSerialNumber.Copy( *serialNum );
+
+    aUdtKeyVersion = 0;
+    User::LeaveIfError( rightsClient.GetUdtData( aEncryptedRdbData ) );
+    if( !aEncryptedRdbData.Length() )
+        {
+        User::Leave( KErrNotFound );
+        }
+    CleanupStack::PopAndDestroy(); // rightsClient
+    }
+    
+// ---------------------------------------------------------
+// CDrmUdtHandler::ReadUdtDataL
+//
+// ---------------------------------------------------------
+//    
+HBufC* CDrmUdtHandler::SerialNumberL()
+    {
+    TInt error( KErrNone );
+    TInt count( 0 );
+    TInt count2( 0 );
+    TUint32 caps( 0 );
+    HBufC* imei = NULL;
+
+#ifndef __WINS__
+    LOG( _L("CDrmUdtHandler::SerialNumberL") );
+
+    RTelServer etelServer;
+    RMobilePhone phone;
+    
+    for ( TUint8 i = 0; i < 3; ++i )
+        {
+        error = etelServer.Connect();
+        if ( error )
+            {
+            User::After( TTimeIntervalMicroSeconds32( 100000 ) );
+            }
+        }
+    
+    User::LeaveIfError( error );
+    CleanupClosePushL( etelServer );
+
+    LOG( _L("  Connected to ETEL") );
+    
+    User::LeaveIfError( etelServer.LoadPhoneModule( KMmTsyModuleName ) );
+    
+    LOG( _L("  Phone Module loaded") );
+
+    TUnloadModule unload;
+    unload.iServer = &etelServer;
+    unload.iName = &KMmTsyModuleName;
+    
+    TCleanupItem item( DoUnloadPhoneModule, &unload );
+    CleanupStack::PushL( item );
+    
+    User::LeaveIfError( etelServer.EnumeratePhones( count ) );
+    
+    LOG( _L("  Phones enumerated") );
+
+    for ( count2 = 0; count2 < count; ++count2 )
+        {
+        RTelServer::TPhoneInfo phoneInfo;
+        User::LeaveIfError( etelServer.GetTsyName( count2, phoneInfo.iName ) );
+        
+        LOG( _L("    Got TSY module") );
+        LOG( phoneInfo.iName );
+        if ( phoneInfo.iName.CompareF( KMmTsyModuleName ) == 0 )
+            {
+            User::LeaveIfError( etelServer.GetPhoneInfo( count2, phoneInfo ) );
+            LOG( _L("    Got phone info") );
+            User::LeaveIfError( phone.Open( etelServer, phoneInfo.iName ) );
+            LOG( _L("    Opened phone") );
+            CleanupClosePushL( phone );
+            break;
+            }
+        }
+        
+    if ( count2 == count )
+        {
+        // Not found.
+        LOG( _L("  No phone found") );
+        User::Leave( KErrNotFound );
+        }
+    
+    LOG( _L("  Got phone") );
+
+    User::LeaveIfError( phone.GetIdentityCaps( caps ) );
+
+    LOG( _L("  Got Caps") );
+
+    if ( caps & RMobilePhone::KCapsGetSerialNumber )
+        {
+        RMobilePhone::TMobilePhoneIdentityV1 id;
+        TRequestStatus status;
+        
+        phone.GetPhoneId( status, id );
+        User::WaitForRequest( status );
+        
+        User::LeaveIfError( status.Int() );
+        
+        imei = id.iSerialNumber.AllocL();
+        
+        LOG( _L("  Got serial number") );
+
+        CleanupStack::PopAndDestroy( 3 ); // phone, item, etelServer
+        
+        return imei;
+        }
+    
+    User::Leave( KErrNotFound );
+    
+    // Never happens...
+    return imei;
+
+#else
+    _LIT( KDefaultSerialNumber, "123456789123456789" );
+    imei = KDefaultSerialNumber().AllocL();
+        
+    return imei;
+#endif
+    }
+ 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmroapwbxmlparser/bwins/drmroapwbxmlparseru.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,6 @@
+EXPORTS
+	??1CWbxmlRoapTriggerParser@DRM@@UAE@XZ @ 1 NONAME ; DRM::CWbxmlRoapTriggerParser::~CWbxmlRoapTriggerParser(void)
+	?NewL@CWbxmlRoapTriggerParser@DRM@@SAPAV12@XZ @ 2 NONAME ; class DRM::CWbxmlRoapTriggerParser * DRM::CWbxmlRoapTriggerParser::NewL(void)
+	?NewLC@CWbxmlRoapTriggerParser@DRM@@SAPAV12@XZ @ 3 NONAME ; class DRM::CWbxmlRoapTriggerParser * DRM::CWbxmlRoapTriggerParser::NewLC(void)
+	?ParseL@CWbxmlRoapTriggerParser@DRM@@QAEPAVHBufC8@@ABVTDesC8@@@Z @ 4 NONAME ; class HBufC8 * DRM::CWbxmlRoapTriggerParser::ParseL(class TDesC8 const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmroapwbxmlparser/eabi/drmroapwbxmlparseru.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,8 @@
+EXPORTS
+	_ZN3DRM23CWbxmlRoapTriggerParser4NewLEv @ 1 NONAME
+	_ZN3DRM23CWbxmlRoapTriggerParser5NewLCEv @ 2 NONAME
+	_ZN3DRM23CWbxmlRoapTriggerParser6ParseLERK6TDesC8 @ 3 NONAME
+	_ZN3DRM23CWbxmlRoapTriggerParserD0Ev @ 4 NONAME
+	_ZN3DRM23CWbxmlRoapTriggerParserD1Ev @ 5 NONAME
+	_ZN3DRM23CWbxmlRoapTriggerParserD2Ev @ 6 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmroapwbxmlparser/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* 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:  Build information file for project drmroapwbxmlparser
+*
+*/
+
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+drmroapwbxmlparser.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmroapwbxmlparser/group/drmroapwbxmlparser.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,46 @@
+/*
+* 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:  Project definition file for project drmroapwbxmlparser
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  drmroapwbxmlparser.dll
+TARGETTYPE              dll
+UID                     0x1000008d 0x200113BF
+
+CAPABILITY              CAP_GENERAL_DLL DRM   // DRM since RoapHandler
+                                              // uses this library
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  wbxmlroaptriggerparser.cpp
+
+USERINCLUDE             ../../../inc // Ado level include dir
+
+
+MW_LAYER_SYSTEMINCLUDE
+
+
+LIBRARY                 euser.lib
+LIBRARY                 bafl.lib
+LIBRARY                 xmlframework.lib
+
+
+DEFFILE                 drmroapwbxmlparser.def
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/drmroapwbxmlparser/src/wbxmlroaptriggerparser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,317 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of Oma Drm 2.1 WBXML RoapTrigger to XML parser
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <f32file.h>
+#include <xml/parserfeature.h>
+
+#include "wbxmlroaptriggerparser.h"
+
+// CONSTANTS
+_LIT8( KWBXMLParserMimeType, "text/wbxml" );
+_LIT8( KSpace, " " );
+_LIT8( KLess, "<" );
+_LIT8( KMore, ">" );
+_LIT8( KEqual, "=" );
+_LIT8( KQuote, "\"" );
+_LIT8( KSlash, "/" );
+
+const TInt KBufferGran( 512 );
+
+// ============================ LOCAL FUNCTIONS ================================
+
+// -----------------------------------------------------------------------------
+// XmlEscapeL
+// -----------------------------------------------------------------------------
+//
+LOCAL_C void XmlEscapeL( CBufFlat*& aTarget, const TDesC8& aSource )
+    {
+    _LIT8( KEscapedQuote, "&quot;" );
+    _LIT8( KEscapedApostrophe, "&apos;" );
+    _LIT8( KEscapedAmpersand, "&amp;" );
+    _LIT8( KEscapedLessThan, "&lt;" );
+    _LIT8( KEscapedGreaterThan, "&gt;");
+
+    const TInt sourceLength( aSource.Length() );
+    for ( TInt i( 0 ); i < sourceLength; ++i )
+        {
+        switch ( aSource[i] )
+            {
+        case '&':
+            aTarget->InsertL( aTarget->Size(), KEscapedAmpersand() );
+            break;
+        case '<':
+            aTarget->InsertL( aTarget->Size(), KEscapedLessThan() );
+            break;
+        case '>':
+            aTarget->InsertL( aTarget->Size(), KEscapedGreaterThan() );
+            break;
+        case '\"':
+            aTarget->InsertL( aTarget->Size(), KEscapedQuote() );
+            break;
+        case '\'':
+            aTarget->InsertL( aTarget->Size(), KEscapedApostrophe() );
+            break;
+        default:
+            aTarget->InsertL( aTarget->Size(), aSource.Mid( i, 1 ) );
+            break;
+            }
+        }
+    }
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::CWbxmlRoapTriggerParser
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+DRM::CWbxmlRoapTriggerParser::CWbxmlRoapTriggerParser()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::ConstructL()
+    {
+    iParser = Xml::CParser::NewL( KWBXMLParserMimeType, *this );
+    User::LeaveIfError( iParser->EnableFeature( Xml::ERawContent ) );
+    iContent = CBufFlat::NewL( KBufferGran );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CWbxmlRoapTriggerParser* DRM::CWbxmlRoapTriggerParser::NewL()
+    {
+    DRM::CWbxmlRoapTriggerParser* self( NewLC() );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::NewLC
+// Two-phased constructor
+// -----------------------------------------------------------------------------
+//
+EXPORT_C DRM::CWbxmlRoapTriggerParser* DRM::CWbxmlRoapTriggerParser::NewLC()
+    {
+    DRM::CWbxmlRoapTriggerParser* self(
+        new ( ELeave ) DRM::CWbxmlRoapTriggerParser );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// Destructor
+EXPORT_C DRM::CWbxmlRoapTriggerParser::~CWbxmlRoapTriggerParser()
+    {
+    delete iParser;
+    delete iContent;
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::ParseL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* DRM::CWbxmlRoapTriggerParser::ParseL(
+    const TDesC8& aMessage )
+    {
+    TInt i( 0 );
+    TInt n( 0 );
+
+    iParser->ParseBeginL();
+
+    while ( i < aMessage.Length() )
+        {
+        n = Min( aMessage.Length() - i, KBufferGran );
+        iParser->ParseL( aMessage.Mid( i, n ) );
+        i += n;
+        }
+
+    iParser->ParseEndL();
+
+    return iContent->Ptr( 0 ).AllocL();
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnStartDocumentL
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnStartDocumentL(
+    const Xml::RDocumentParameters& /*aDocParam*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnEndDocumentL
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnEndDocumentL(
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnStartElementL
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnStartElementL(
+    const Xml::RTagInfo& aElement,
+    const Xml::RAttributeArray& aAttributes,
+    TInt /*aErrorCode*/)
+    {
+    CBufFlat* escapedValueBuffer( CBufFlat::NewL( KBufferGran ) );
+    CleanupStack::PushL( escapedValueBuffer );
+    // <tag attribute="attribute value">
+    iContent->InsertL( iContent->Size(), KLess );
+    iContent->InsertL( iContent->Size(), aElement.LocalName().DesC() );
+
+    for ( TInt i( 0 ); i < aAttributes.Count(); i++ )
+        {
+        iContent->InsertL( iContent->Size(), KSpace );
+        iContent->InsertL( iContent->Size(),
+                           aAttributes[i].Attribute().LocalName().DesC() );
+        iContent->InsertL( iContent->Size(), KEqual );
+        iContent->InsertL( iContent->Size(), KQuote );
+        XmlEscapeL( escapedValueBuffer, aAttributes[i].Value().DesC() );
+        iContent->InsertL( iContent->Size(), escapedValueBuffer->Ptr( 0 ) );
+        iContent->InsertL( iContent->Size(), KQuote );
+        escapedValueBuffer->Delete( 0, escapedValueBuffer->Size() );
+        }
+
+    iContent->InsertL( iContent->Size(), KMore );
+    CleanupStack::PopAndDestroy( escapedValueBuffer );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnEndElementL
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnEndElementL(
+    const Xml::RTagInfo& aElement,
+    TInt /*aErrorCode*/)
+    {
+    // </tag>
+    iContent->InsertL( iContent->Size(), KLess );
+    iContent->InsertL( iContent->Size(), KSlash );
+    iContent->InsertL( iContent->Size(), aElement.LocalName().DesC() );
+    iContent->InsertL( iContent->Size(), KMore );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnContentL
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnContentL(
+    const TDesC8& aBytes,
+    TInt /*aErrorCode*/)
+    {
+    XmlEscapeL( iContent, aBytes );
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnStartPrefixMappingL
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnStartPrefixMappingL(
+    const RString& /*aPrefix*/,
+    const RString& /*aUri*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnEndPrefixMappingL
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnEndPrefixMappingL(
+    const RString& /*aPrefix*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnIgnorableWhiteSpaceL
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnIgnorableWhiteSpaceL(
+    const TDesC8& /*aBytes*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnSkippedEntityL
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnSkippedEntityL(
+    const RString& /*aName*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnProcessingInstructionL
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnProcessingInstructionL(
+    const TDesC8& /*aTarget*/,
+    const TDesC8& /*aData*/,
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnOutOfData
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnOutOfData()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::OnError
+// -----------------------------------------------------------------------------
+//
+void DRM::CWbxmlRoapTriggerParser::OnError(
+    TInt /*aErrorCode*/)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// DRM::CWbxmlRoapTriggerParser::GetExtendedInterface
+// -----------------------------------------------------------------------------
+//
+TAny* DRM::CWbxmlRoapTriggerParser::GetExtendedInterface(
+    const TInt32 /*aUid*/)
+    {
+    return NULL;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,172 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build file for DRM Engine core
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+../conf/drm5.confml                     MW_LAYER_CONFML(drm5.confml)
+../conf/drm5_10205CA7.crml              MW_LAYER_CRML(drm5_10205CA7.crml)
+../conf/drm5_10205CBF.crml              MW_LAYER_CRML(drm5_10205CBF.crml)
+../conf/drmsettings.confml              MW_LAYER_CONFML(drmsettings.confml)
+../conf/drmsettings_102823B4.crml       MW_LAYER_CRML(drmsettings_102823B4.crml)
+../conf/drm5_200195AD.crml              MW_LAYER_CRML(drm5_200195AD.crml)
+../conf/drmutility.confml               MW_LAYER_CONFML(drmutility.confml)
+../conf/drmutility_20022D51.crml        MW_LAYER_CRML(drmutility_20022D51.crml)
+../drmengine/group/CryptoPrep.flm       /epoc32/tools/makefile_templates/s60/CryptoPrep.flm
+../drmengine/group/CryptoPrep.xml       /epoc32/tools/makefile_templates/s60/CryptoPrep.xml
+../drmengine/server/data/101F51F2.exc		/epoc32/data/Z/private/102073ea/excludes/101F51F2.exc
+
+//Loc files
+// Ro Handler (only used if OMA DRM 1.0 Full is enabled)
+#ifdef __DRM_FULL
+../drmplugins/drmrohandler/loc/rohandler.loc MW_LAYER_LOC_EXPORT_PATH( rohandler.loc )
+#endif
+../drmplugins/drmromtm/loc/romtmui.loc MW_LAYER_LOC_EXPORT_PATH( romtmui.loc )
+
+
+// CMLA RnD keys
+../drmengine/keystorage/data/cmla/DevicePrivateKey.der /epoc32/winscw/c/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DevicePrivateKey.der
+../drmengine/keystorage/data/cmla/DeviceCert.der /epoc32/winscw/c/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DeviceCert.der
+../drmengine/keystorage/data/cmla/SigningCert00.der /epoc32/winscw/c/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert00.der
+../drmengine/keystorage/data/cmla/SigningCert01.der /epoc32/winscw/c/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert01.der
+
+../drmengine/keystorage/data/cmla/DevicePrivateKey.der /epoc32/release/winscw/udeb/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DevicePrivateKey.der
+../drmengine/keystorage/data/cmla/DeviceCert.der /epoc32/release/winscw/udeb/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DeviceCert.der
+../drmengine/keystorage/data/cmla/SigningCert00.der /epoc32/release/winscw/udeb/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert00.der
+../drmengine/keystorage/data/cmla/SigningCert01.der /epoc32/release/winscw/udeb/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert01.der
+
+../drmengine/keystorage/data/cmla/DevicePrivateKey.der /epoc32/release/winscw/urel/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DevicePrivateKey.der
+../drmengine/keystorage/data/cmla/DeviceCert.der /epoc32/release/winscw/urel/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DeviceCert.der
+../drmengine/keystorage/data/cmla/SigningCert00.der /epoc32/release/winscw/urel/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert00.der
+../drmengine/keystorage/data/cmla/SigningCert01.der /epoc32/release/winscw/urel/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert01.der
+
+../drmengine/keystorage/data/cmla/DevicePrivateKey.der /epoc32/data/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DevicePrivateKey.der
+../drmengine/keystorage/data/cmla/DeviceCert.der /epoc32/data/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/DeviceCert.der
+../drmengine/keystorage/data/cmla/SigningCert00.der /epoc32/data/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert00.der
+../drmengine/keystorage/data/cmla/SigningCert01.der /epoc32/data/z/private/101F51F2/PKI/96b7db19a4d05a4bc8e3a51c885088e679354469/SigningCert01.der
+
+// Default UDT Key
+#ifdef __DRM_USER_DATA_TRANSFER
+../drmengine/keystorage/data/UdtCertificate.der /epoc32/winscw/c/private/101F51F2/PKI/UdtCertificate.der
+
+../drmengine/keystorage/data/UdtCertificate.der /epoc32/release/winscw/udeb/z/private/101F51F2/PKI/UdtCertificate.der
+../drmengine/keystorage/data/UdtCertificate.der /epoc32/release/winscw/urel/z/private/101F51F2/PKI/UdtCertificate.der
+
+../drmengine/keystorage/data/UdtCertificate.der /epoc32/data/z/private/101F51F2/PKI/UdtCertificate.der
+#endif
+
+// backup_registration.xml
+../drmengine/group/backup_registration.xml /epoc32/winscw/c/private/101F51F2/backup_registration.xml
+../drmengine/group/backup_registration.xml /epoc32/data/z/private/101F51F2/backup_registration.xml
+
+../drmengine/group/backup_registration.xml /epoc32/release/winscw/udeb/z/private/101F51F2/backup_registration.xml
+../drmengine/group/backup_registration.xml /epoc32/release/winscw/urel/z/private/101F51F2/backup_registration.xml
+
+// SIS stub
+../data/OmaDrm_Stub.SIS /epoc32/data/z/system/install/OmaDrm_Stub.SIS
+
+// IBY files
+../rom/drm5.iby                     CORE_MW_LAYER_IBY_EXPORT_PATH( drm5.iby )
+../rom/drmhelper.iby                CORE_MW_LAYER_IBY_EXPORT_PATH( drmhelper.iby)
+../rom/drmhelperresources.iby       LANGUAGE_MW_LAYER_IBY_EXPORT_PATH( drmhelperresources.iby )
+../rom/drmlicensemanager.iby        CORE_MW_LAYER_IBY_EXPORT_PATH( drmlicensemanager.iby )
+../rom/drmroapwbxmlparser.iby       CORE_MW_LAYER_IBY_EXPORT_PATH( drmroapwbxmlparser.iby )
+../rom/drmrohandlerresources.iby    LANGUAGE_MW_LAYER_IBY_EXPORT_PATH( drmrohandlerresources.iby )
+../rom/drmromtmresources.iby        LANGUAGE_MW_LAYER_IBY_EXPORT_PATH( drmromtmresources.iby )
+../rom/httpfilterdrm.iby            CORE_MW_LAYER_IBY_EXPORT_PATH( httpfilterdrm.iby )
+../rom/romtm.iby                    CORE_MW_LAYER_IBY_EXPORT_PATH( romtm.iby )
+
+PRJ_MMPFILES
+
+// DrmRoapWbxmlParser
+../drmroapwbxmlparser/group/drmroapwbxmlparser.mmp
+
+// RoMTM
+
+../drmplugins/drmromtm/group/RoMtmCli.mmp
+../drmplugins/drmromtm/group/RoMtmSer.mmp
+../drmplugins/drmromtm/group/RoMtmUi.mmp
+../drmplugins/drmromtm/group/RoMtmDat.mmp
+
+// DRMEngine
+
+#ifndef SBSV2
+gnumakefile ../drmengine/group/CryptoPrep.mak // Copy the appropriate DRM crypto implemenation into place
+#endif
+
+../drmengine/group/DrmKeyStorage.mmp
+../drmengine/group/DrmStdKeyStorage.mmp
+../drmengine/group/DrmCrypto.mmp
+../drmengine/group/DrmRights.mmp
+../drmengine/group/DrmDcf.mmp
+../drmengine/group/DrmServerInterfaces.mmp
+../drmengine/group/DcfRep.mmp
+../drmengine/group/DrmParsers.mmp
+../drmengine/group/DRMCommon.mmp
+../drmengine/group/RightsServer.mmp
+../drmengine/group/DrmRel1_0StringDict00.mmp
+../drmengine/group/DrmRel2_1StringDict00.mmp
+../drmengine/group/OmaDrmAgent.mmp
+../drmengine/group/DcfRepSrv.mmp
+../drmengine/group/ROAPHandler.mmp
+
+#ifdef __DRM_USER_DATA_TRANSFER
+../drmplugins/drmudtmodule/group/DrmUdtModule.mmp
+#endif
+
+
+// DRMService API
+../drmengine/group/DrmServiceAPI.mmp
+
+
+// Helper server
+../drmhelper/drmhelperserver/group/DRMHelperServer.mmp
+
+// License manager
+../drmlicensemanager/group/DRMLicenseManager.mmp
+../drmlicensemanager/group/DRMLicenseChecker.mmp
+
+// Recognizer
+../drmplugins/drmrecognizer/group/recdrm.mmp
+
+// Ro Handler (only used if OMA DRM 1.0 Full is enabled)
+#ifdef __DRM_FULL
+../drmplugins/drmrohandler/group/CRohandler.mmp
+#endif
+
+// DRMFilter
+../drmplugins/drmfilter/group/HTTPFilterDRM.mmp
+
+// DRMHelper
+../drmhelper/group/DRMHelper.mmp
+../drmhelper/group/drmhelperdmgrwrapper.mmp
+
+#ifdef SBSV2
+PRJ_EXTENSIONS
+
+START EXTENSION s60/cryptoprep
+END
+#endif
+
+// Testfiles
+PRJ_TESTMMPFILES
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/rom/DRM5.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  IBY file
+*
+*/
+
+
+#ifndef __DRM5_IBY__
+#define __DRM5_IBY__
+
+#include <Xml.iby>
+
+// -------------------------------------------------------------------------------------------------
+// Files that always go into the ROM
+// -------------------------------------------------------------------------------------------------
+
+// DRM Common API
+file=ABI_DIR\BUILD_DIR\DRMCOMMON.DLL                SHARED_LIB_DIR\DRMCOMMON.DLL
+
+// -------------------------------------------------------------------------------------------------
+// Files that are only in ROM when DRM is enabled
+// -------------------------------------------------------------------------------------------------
+
+#ifdef __DRM
+
+// DRM Engine resource file for MIME-types
+data=DATAZ_\RESOURCE_FILES_DIR\DRMCOMMON.RSC        RESOURCE_FILES_DIR\DRMCOMMON.RSC
+
+// DCF Repository Server
+file=ABI_DIR\BUILD_DIR\DcfRep.dll                   PROGRAMS_DIR\DcfRep.dll
+file=ABI_DIR\BUILD_DIR\DcfRepSrv.EXE                PROGRAMS_DIR\DcfRepSrv.EXE
+
+// Helper Server
+file=ABI_DIR\BUILD_DIR\DRMHELPERSERVER.EXE          PROGRAMS_DIR\DRMHELPERSERVER.EXE
+
+// Standard, file based storage for PKI keys
+file=ABI_DIR\BUILD_DIR\DrmKeyStorage.dll            SHARED_LIB_DIR\DrmKeyStorage.dll
+file=ABI_DIR\BUILD_DIR\DrmStdKeyStorage.dll         SHARED_LIB_DIR\DrmStdKeyStorage.dll
+
+// Standard OMA DRM cryptography functions
+file=ABI_DIR\BUILD_DIR\DrmCrypto.DLL                SHARED_LIB_DIR\DrmCrypto.DLL
+
+// Client side libraries
+file=ABI_DIR\BUILD_DIR\DrmDcf.DLL                   SHARED_LIB_DIR\DrmDcf.DLL
+file=ABI_DIR\BUILD_DIR\DrmRights.DLL                SHARED_LIB_DIR\DrmRights.DLL
+file=ABI_DIR\BUILD_DIR\DrmServerInterfaces.DLL      SHARED_LIB_DIR\DrmServerInterfaces.DLL
+file=ABI_DIR\BUILD_DIR\DrmParsers.DLL               SHARED_LIB_DIR\DrmParsers.DLL
+
+// DRM Rights server 
+file=ABI_DIR\BUILD_DIR\RightsServer.EXE             PROGRAMS_DIR\RightsServer.EXE
+
+// DRM Service API
+file=ABI_DIR\BUILD_DIR\DrmServiceAPI.dll            SHARED_LIB_DIR\DrmServiceAPI.dll
+
+// DRM UDT Module
+#ifdef __DRM_USER_DATA_TRANSFER
+file=ABI_DIR\BUILD_DIR\DRMUDTMODULE.DLL                SHARED_LIB_DIR\DRMUDTMODULE.DLL
+#endif
+
+// DRM recognizer for protected contents
+#ifdef __DRM
+//S60_INTEGRATION file=ABI_DIR\BUILD_DIR\RECDRM.DLL         RECOGNISERS_DIR\RECDRM.DLL
+//S60_INTEGRATION data=ZSYSTEM\Libs\Plugins\101F51F4.RSC    RESOURCE_FILES_DIR\101F51F4.RSC
+
+ECOM_PLUGIN(RECDRM.DLL,101F51F4.RSC)
+
+// RFS exclude list
+data=DATAZ_\private\102073ea\excludes\101F51F2.exc	private\102073ea\excludes\101F51F2.exc
+
+#endif
+
+// OMA DRM CAF Agent
+ECOM_PLUGIN(OmaDrmAgent.dll,101F6DB4.rsc)
+
+
+// WBXML String Dictionary Plugin for Oma Drm 1.0
+ECOM_PLUGIN(DrmRel1_0StringDict00.dll,101F6DB6.rsc)
+
+// WBXML String Dictionary Plugin for Oma Drm 2.1
+ECOM_PLUGIN(DrmRel2_1StringDict00.dll,2000B48A.rsc)
+
+// Rights Object Handler (Wap push watcher)
+#ifdef __DRM
+//S60_INTEGRATION file=ABI_DIR\BUILD_DIR\ROHANDLER.DLL      PLUGINS_1_DIR\ROHANDLER.DLL
+//S60_INTEGRATION data=ZSYSTEM\Libs\Plugins\101F7B92.RSC    ECOM_RESOURCE_DIR\101F7B92.RSC
+
+#ifdef __DRM_FULL
+ECOM_PLUGIN(ROHANDLER.DLL,101F7B92.RSC)
+#endif
+
+
+
+#endif
+
+
+// ROAP Handler
+file=ABI_DIR\BUILD_DIR\RoapHandler.DLL              SHARED_LIB_DIR\RoapHandler.DLL
+
+
+#ifndef __HTTPFILTERDRM_IBY_
+#define __HTTPFILTERDRM_IBY_
+
+// ECom DrmFilter
+
+ECOM_PLUGIN(HTTPFilterDRM.dll,101F9710.rsc)
+
+#endif
+
+
+// -------------------------------------------------------------------------------------------------
+// Testing and other files which do not go into the ROM by default
+// -------------------------------------------------------------------------------------------------
+
+// Rights Object MTM
+// file=ABI_DIR\BUILD_DIR\ROMTMCLI.DLL              SHARED_LIB_DIR\ROMTMCLI.DLL
+// file=ABI_DIR\BUILD_DIR\ROMTMDAT.DLL              SHARED_LIB_DIR\ROMTMDAT.DLL
+// file=ABI_DIR\BUILD_DIR\ROMTMSER.DLL              SHARED_LIB_DIR\ROMTMSER.DLL
+// file=ABI_DIR\BUILD_DIR\ROMTMUI.DLL               SHARED_LIB_DIR\ROMTMUI.DLL
+// data=ABI_DIR\BUILD_DIR\ROMTMREG.rsc              MTM_INFO_FILE_DIR\ROMTMREG.rsc
+
+// Testing
+// file=ABI_DIR\BUILD_DIR\DRM_API_BAT.EXE           DRM_API_BAT.EXE
+// End_Testing
+
+// UI Test application includes
+// Take the comments off from the two following lines
+// #include <DRM_API_BAT.iby>
+// #include <DRM_API_BATResources.iby>
+
+// DRMEncryptor iby files
+// #include <DRMEncryptor.iby>
+// #include <DRMEncryptorResources.iby>
+
+// Default CMLA RnD Test Keys
+
+data=ZPRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\DevicePrivateKey.der PRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\DevicePrivateKey.der
+data=ZPRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\DeviceCert.der PRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\DeviceCert.der
+data=ZPRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\SigningCert00.der PRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\SigningCert00.der
+data=ZPRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\SigningCert01.der PRIVATE\101F51F2\PKI\96b7db19a4d05a4bc8e3a51c885088e679354469\SigningCert01.der
+
+// Default UDT key
+#ifdef __DRM_USER_DATA_TRANSFER
+data=ZPRIVATE\101F51F2\PKI\UdtCertificate.der	PRIVATE\101F51F2\PKI\UdtCertificate.der
+#endif
+
+// Backup registration
+data=ZPRIVATE\101F51F2\backup_registration.xml	PRIVATE\101F51F2\backup_registration.xml
+
+// SIS stub for agent upgrades	
+data=ZSYSTEM\Install\OmaDrm_Stub.SIS			\system\install\OmaDrm_Stub.SIS
+
+#endif // DRM
+#endif // __DRM5_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/rom/DRMHelper.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file
+*
+*/
+
+
+#ifndef __DRMHELPER_IBY__
+#define __DRMHELPER_IBY__
+
+file=ABI_DIR\BUILD_DIR\DRMHelperDMgrWrapper.dll SHARED_LIB_DIR\DRMHelperDMgrWrapper.dll
+file=ABI_DIR\BUILD_DIR\DRMHelper.dll            SHARED_LIB_DIR\DRMHelper.dll
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/rom/DRMHelperResources.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file
+*
+*/
+
+
+#ifndef __DRMHELPER_RESOURCES_IBY__
+#define __DRMHELPER_RESOURCES_IBY__
+
+data=DATAZ_\RESOURCE_FILES_DIR\drmhelper.rsc		        RESOURCE_FILES_DIR\drmhelper.rsc
+data=DATAZ_\RESOURCE_FILES_DIR\drmhelperdmgrwrapper.rsc		RESOURCE_FILES_DIR\drmhelperdmgrwrapper.rsc
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/rom/DRMLicenseManager.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file
+*
+*/
+
+
+#ifndef __DRMLICENSEMANAGER_IBY__
+#define __DRMLICENSEMANAGER_IBY__
+
+file=ABI_DIR\BUILD_DIR\DRMLicenseManager.DLL	System\Libs\DRMLicenseManager.DLL
+file=ABI_DIR\BUILD_DIR\DRMLicenseChecker.DLL	System\Libs\DRMLicenseChecker.DLL
+
+#endif  //__DRMLICENSEMANAGER_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/rom/DRMRoHandlerResources.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file
+*
+*/
+
+
+#ifndef __DRMROHANDLER_RESOURCES_IBY__
+#define __DRMROHANDLER_RESOURCES_IBY__
+
+// RO Handler resource file
+#ifdef __DRM_FULL
+data=DATAZ_\RESOURCE_FILES_DIR\RoHandler.RSC        RESOURCE_FILES_DIR\RoHandler.RSC
+#endif
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/rom/DRMRoMtmResources.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file
+*
+*/
+
+
+#ifndef __DRMROMTM_RESOURCES_IBY__
+#define __DRMROMTM_RESOURCES_IBY__
+
+// RO MTM resource file
+data=DATAZ_\MTM_RESOURCE_DIR\ROMTMUI.rsc                        MTM_RESOURCE_DIR\ROMTMUI.rsc
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/rom/HTTPFilterDRM.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file
+*
+*/
+
+
+#ifndef __HTTPFILTERDRM_IBY_
+#define __HTTPFILTERDRM_IBY_
+
+// ECom DrmFilter
+
+ECOM_PLUGIN(HTTPFilterDRM.dll,101F9710.rsc)
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/rom/RoMTM.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,30 @@
+/*
+* 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:  IBY file
+*
+*/
+
+
+#ifndef __ROMTM_IBY__
+#define __ROMTM_IBY__
+
+// Rights Object MTM
+file=ABI_DIR\BUILD_DIR\ROMTMCLI.DLL				SHARED_LIB_DIR\ROMTMCLI.DLL
+file=ABI_DIR\BUILD_DIR\ROMTMDAT.DLL				SHARED_LIB_DIR\ROMTMDAT.DLL
+file=ABI_DIR\BUILD_DIR\ROMTMSER.DLL				SHARED_LIB_DIR\ROMTMSER.DLL
+file=ABI_DIR\BUILD_DIR\ROMTMUI.DLL				SHARED_LIB_DIR\ROMTMUI.DLL
+data=DATAZ_\MTM_INFO_FILE_DIR\ROMTMREG.rsc 			MTM_INFO_FILE_DIR\ROMTMREG.rsc
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/omadrm/rom/drmroapwbxmlparser.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* 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:  Image description file for project drmroapwbxmlparser
+*
+*/
+
+
+#ifndef DRMROAPWBXMLPARSER_IBY
+#define DRMROAPWBXMLPARSER_IBY
+
+#include <data_caging_paths_for_iby.hrh>
+
+// DLLs
+file=ABI_DIR\BUILD_DIR\drmroapwbxmlparser.dll     SHARED_LIB_DIR\drmroapwbxmlparser.dll
+
+#endif // DRMROAPWBXMLPARSER_IBY
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/package_definition.xml	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<SystemDefinition schema="3.0.0">
+  <package id="drm" name="DRM" levels="plugin framework server generic specific">
+    <collection id="commondrm" name="Common DRM" level="generic">
+      <component id="drmencryptor" filter="s60" name="DRM Encryptor">
+		<!-- this should have its own bld.inf or be removed as a component -->
+      </component>
+      <component id="drmsettingsplugin" filter="s60" name="DRM Settings Plugin" class="plugin">
+		<!-- this should have its own bld.inf or be removed as a component -->
+      </component>
+      <component id="drmrightsmanagerui" filter="s60" name="DRM Rights Manager UI">
+        <unit bldFile="commondrm/drmrightsmanagerui/help/group"/>
+      </component>
+      <component id="drmutility" filter="s60" name="DRM Utility">
+        <unit bldFile="commondrm/drmutility/group"/>
+      </component>
+      <component id="drmserviceapiwrapper" filter="s60" name="DRM Service API Wrapper">
+        <unit bldFile="commondrm/drmserviceapiwrapper/group"/>
+      </component>
+      <component id="drmrightsstoringlocation" filter="s60" name="DRM Rights Storing Location">
+        <unit bldFile="commondrm/drmrightsstoringlocation/group"/>
+      </component>
+      <component id="commondrm_build" filter="s60" name="Common DRM Build">
+		<!-- should be split into the above files, or them collapsed into a single component -->
+        <unit bldFile="commondrm/group"/>
+      </component>
+    </collection>
+    <collection id="omadrm" name="OMA DRM" level="server">
+      <component id="drmroapwbxmlparser" filter="s60" name="DRM ROAP WBXML Parser">
+        <!-- <unit bldFile="omadrm/drmroapwbxmlparser/group"/> -->
+      </component>
+      <component id="drmplugins" filter="s60" name="DRM Plugins" class="plugin">
+		<!-- should have a single bld.inf -->
+        <!-- <unit bldFile="omadrm/drmplugins/drmfilter/group"/> -->
+        <!-- <unit bldFile="omadrm/drmplugins/drmrecognizer/group"/> -->
+        <!-- <unit bldFile="omadrm/drmplugins/drmrohandler/group"/> -->
+        <!-- <unit bldFile="omadrm/drmplugins/drmromtm/group"/> -->
+      </component>
+      <component id="drmengine" filter="s60" name="DRM Engine">
+		<!-- this should have its own bld.inf or be removed as a component -->
+      </component>
+      <component id="drmhelper" filter="s60" name="DRM Helper">
+        <!-- <unit bldFile="omadrm/drmhelper/group"/> -->
+		<!-- should drmhelperserver be #included in the above? -->
+        <!-- <unit bldFile="omadrm/drmhelper/drmhelperserver/group"/> -->
+      </component>
+      <component id="drmlicensemanager" filter="s60" name="DRM License Manager">
+        <!-- <unit bldFile="omadrm/drmlicensemanager/group"/> -->
+      </component>
+      <component id="omadrm_build" filter="s60" name="OMA DRM Build">
+		<!-- should be split into the above files, or them collapsed into a single component -->
+        <unit bldFile="omadrm/group"/>
+      </component>
+    </collection>
+    <collection id="wmdrm" name="Windows Media DRM" level="framework">
+      <component id="wmdrmengine" filter="s60" name="WM DRM Engine">
+		<!-- should have a single bld.inf -->
+        <!-- <unit bldFile="wmdrm/wmdrmengine/wmdrmagent/group"/> -->
+        <!-- <unit bldFile="wmdrm/wmdrmengine/wmdrmfileserver/client/group"/> -->
+        <!-- <unit bldFile="wmdrm/wmdrmengine/wmdrmfileserver/server/group"/> -->
+        <!-- <unit bldFile="wmdrm/wmdrmengine/wmdrmserver/client/group"/> -->
+        <!-- <unit bldFile="wmdrm/wmdrmengine/wmdrmserver/clientwrapper/group"/> -->
+        <!-- <unit bldFile="wmdrm/wmdrmengine/wmdrmserver/server/group"/> -->
+      </component>
+      <component id="camese" filter="s60" name="Camese">
+		<!-- should have a single bld.inf -->
+        <!-- <unit bldFile="wmdrm/camese/group"/> -->
+        <!-- <unit bldFile="wmdrm/camese/cameseutility/group"/> -->
+        <!-- <unit bldFile="wmdrm/camese/httpfiltercamese/group"/> -->
+        <!-- <unit bldFile="wmdrm/camese/wmdrmdla/group"/> -->
+        <!-- <unit bldFile="wmdrm/camese/wmdrmdlaapp/group"/> -->
+        <!-- <unit bldFile="wmdrm/camese/wmdrmdladefaulthttpplugin/group"/> -->
+        <!-- <unit bldFile="wmdrm/camese/wmdrmdladefaultuiplugin/group"/> -->
+        <!-- <unit bldFile="wmdrm/camese/wmdrmdlautils/group"/> -->
+        <!-- <unit bldFile="wmdrm/camese/wmdrmdlawrapper/group"/> -->
+      </component>
+      <component id="wmdrm_build" filter="s60" name="WM DRM Build">
+		<!-- should be split into the above files, or them collapsed into a single component -->
+        <unit bldFile="wmdrm/group"/>
+      </component>
+    </collection>
+    <collection id="drm_info" name="DRM Info" level="specific">
+      <component id="drm_pub" filter="s60" name="DRM Public Interfaces" class="api">
+        <unit bldFile="drm_pub/group"/>
+		<!-- do the following need to be #included ? -->
+        <!-- <unit bldFile="drm_pub/drm_helper_api/tsrc/group"/> -->
+        <!-- <unit bldFile="drm_pub/drm_license_checker_api/tsrc/group"/> -->
+        <!-- <unit bldFile="drm_pub/oma_drm_caf_agent_api/tsrc/bc/group"/> -->
+      </component>
+      <component id="drm_plat" filter="s60" name="DRM Platform Interfaces" class="api">
+        <unit bldFile="drm_plat/group"/>
+		<!-- do the following need to be #included ? -->
+        <!-- <unit bldFile="drm_plat/drm_common_api/tsrc/group"/> -->
+        <!-- <unit bldFile="drm_plat/drm_rights_api/tsrc/group"/> -->
+        <!-- <unit bldFile="drm_plat/roap_api/tsrc/group"/> -->
+      </component>
+      <component id="drm_build" filter="s60" name="DRM Build">
+		<!-- is this needed ? -->
+        <unit bldFile="group"/>
+      </component>
+    </collection>
+  </package>
+</SystemDefinition>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sysdef_1_4_0.dtd	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,86 @@
+ <!ELEMENT SystemDefinition (systemModel?, build?)>
+ <!ATTLIST SystemDefinition
+  name CDATA #REQUIRED
+  schema CDATA #REQUIRED>
+ <!ELEMENT systemModel (layer+)>
+ <!ELEMENT layer (logicalset* | module*)*>
+ <!ATTLIST layer
+  name CDATA #REQUIRED
+  levels CDATA #IMPLIED
+  span CDATA #IMPLIED>
+ <!ELEMENT logicalset (logicalsubset* | module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalset name CDATA #REQUIRED>
+ <!ELEMENT logicalsubset (module* | unit* | package* | prebuilt*)*>
+ <!ATTLIST logicalsubset name CDATA #REQUIRED>
+ <!ELEMENT module (component* | unit* | package* | prebuilt*)*>
+ <!ATTLIST module
+  name CDATA #REQUIRED
+  level CDATA #IMPLIED>
+ <!ELEMENT component (unit* | package* | prebuilt*)*>
+ <!ATTLIST component name CDATA #REQUIRED>
+ <!ELEMENT unit EMPTY>
+ <!ATTLIST unit
+  unitID ID #REQUIRED
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  bldFile CDATA #REQUIRED
+  priority CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT package EMPTY>
+ <!ATTLIST package
+  name CDATA #REQUIRED
+  mrp CDATA #REQUIRED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT prebuilt EMPTY>
+ <!ATTLIST prebuilt
+  name CDATA #REQUIRED
+  version CDATA #REQUIRED
+  late (Y|N) #IMPLIED
+  filter CDATA #IMPLIED
+  contract CDATA #IMPLIED>
+ <!ELEMENT build (option* | target+ | targetList+ | unitList+ | configuration+)*>
+ <!ELEMENT unitList (unitRef+)>
+ <!ATTLIST unitList
+  name ID #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT unitRef EMPTY>
+ <!ATTLIST unitRef unit IDREF #REQUIRED>
+ <!ELEMENT targetList EMPTY>
+ <!ATTLIST targetList
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  target IDREFS #REQUIRED>
+ <!ELEMENT target EMPTY>
+ <!ATTLIST target
+  name ID #REQUIRED
+  abldTarget CDATA #REQUIRED
+  description CDATA #REQUIRED>
+ <!ELEMENT option EMPTY>
+ <!ATTLIST option
+  name ID #REQUIRED
+  abldOption CDATA #REQUIRED
+  description CDATA #REQUIRED
+  enable (Y | N | y | n) #REQUIRED>
+ <!ELEMENT configuration (unitListRef+ | layerRef+ | task+)*>
+ <!ATTLIST configuration
+  name ID #REQUIRED
+  description CDATA #REQUIRED
+  filter CDATA #REQUIRED>
+ <!ELEMENT task ( unitListRef* , (buildLayer | specialInstructions))>
+ <!ELEMENT unitListRef EMPTY>
+ <!ATTLIST unitListRef unitList IDREF #REQUIRED>
+ <!ELEMENT layerRef EMPTY>
+ <!ATTLIST layerRef layerName CDATA #REQUIRED>
+ <!ELEMENT buildLayer EMPTY>
+ <!ATTLIST buildLayer
+  command CDATA #REQUIRED
+  targetList IDREFS #IMPLIED
+  unitParallel (Y | N | y | n) #REQUIRED
+  targetParallel (Y | N | y | n) #IMPLIED>
+ <!ELEMENT specialInstructions EMPTY>
+ <!ATTLIST specialInstructions
+  name CDATA #REQUIRED
+  cwd CDATA #REQUIRED
+  command CDATA #REQUIRED>  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/cameseutility/BWINS/cameseutilityU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,12 @@
+EXPORTS
+	??1CCameseUtility@@UAE@XZ @ 1 NONAME ; CCameseUtility::~CCameseUtility(void)
+	?AcquireLicense@CCameseUtility@@QAEXABVRFile@@AAPAVHBufC8@@AAVTRequestStatus@@@Z @ 2 NONAME ; void CCameseUtility::AcquireLicense(class RFile const &, class HBufC8 * &, class TRequestStatus &)
+	?AcquireLicense@CCameseUtility@@QAEXABVRFile@@ABVTDesC8@@AAVTRequestStatus@@@Z @ 3 NONAME ; void CCameseUtility::AcquireLicense(class RFile const &, class TDesC8 const &, class TRequestStatus &)
+	?AcquireLicense@CCameseUtility@@QAEXABVTDesC8@@AAPAVHBufC8@@AAVTRequestStatus@@@Z @ 4 NONAME ; void CCameseUtility::AcquireLicense(class TDesC8 const &, class HBufC8 * &, class TRequestStatus &)
+	?Cancel@CCameseUtility@@QAEXXZ @ 5 NONAME ; void CCameseUtility::Cancel(void)
+	?NewL@CCameseUtility@@SAPAV1@HPAVMCameseObserver@@@Z @ 6 NONAME ; class CCameseUtility * CCameseUtility::NewL(int, class MCameseObserver *)
+	?NewL@CCameseUtility@@SAPAV1@PAVMCameseObserver@@@Z @ 7 NONAME ; class CCameseUtility * CCameseUtility::NewL(class MCameseObserver *)
+	?SendDownloadResult@CCameseUtility@@QAEXABVTDesC8@@HAAVTRequestStatus@@@Z @ 8 NONAME ; void CCameseUtility::SendDownloadResult(class TDesC8 const &, int, class TRequestStatus &)
+	?NewL@CCameseUtility@@SAPAV1@HPAVRConnection@@PAVMCameseObserver@@@Z @ 9 NONAME ; class CCameseUtility * CCameseUtility::NewL(int, class RConnection *, class MCameseObserver *)
+	?SetIapId@CCameseUtility@@QAEXH@Z @ 10 NONAME ; void CCameseUtility::SetIapId(int)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/cameseutility/EABI/cameseutilityU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,14 @@
+EXPORTS
+	_ZN14CCameseUtility14AcquireLicenseERK5RFileRK6TDesC8R14TRequestStatus @ 1 NONAME
+	_ZN14CCameseUtility14AcquireLicenseERK5RFileRP6HBufC8R14TRequestStatus @ 2 NONAME
+	_ZN14CCameseUtility14AcquireLicenseERK6TDesC8RP6HBufC8R14TRequestStatus @ 3 NONAME
+	_ZN14CCameseUtility18SendDownloadResultERK6TDesC8iR14TRequestStatus @ 4 NONAME
+	_ZN14CCameseUtility4NewLEP15MCameseObserver @ 5 NONAME
+	_ZN14CCameseUtility4NewLEiP15MCameseObserver @ 6 NONAME
+	_ZN14CCameseUtility6CancelEv @ 7 NONAME
+	_ZN14CCameseUtilityD0Ev @ 8 NONAME
+	_ZN14CCameseUtilityD1Ev @ 9 NONAME
+	_ZN14CCameseUtilityD2Ev @ 10 NONAME
+	_ZN14CCameseUtility4NewLEiP11RConnectionP15MCameseObserver @ 11 NONAME
+	_ZN14CCameseUtility8SetIapIdEi @ 12 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/cameseutility/group/CameseUtility.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2006-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project camese utility
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  cameseutility.dll
+TARGETTYPE              dll
+UID                     0x1000008D 0x101FFB99
+
+CAPABILITY              CAP_GENERAL_DLL
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  CameseUtility.cpp
+
+USERINCLUDE             ../inc
+USERINCLUDE             ../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE           /epoc32/include/ecom
+
+LIBRARY                 euser.lib
+LIBRARY                 flogger.lib
+LIBRARY                 esock.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/cameseutility/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for the Camese Utility project
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+CameseUtility.mmp
+
+PRJ_TESTEXPORTS
+
+PRJ_TESTMMPFILES
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/cameseutility/src/CameseUtility.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,227 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the Camese Utility class
+*
+*/
+
+
+// INCLUDES
+#include <es_enum.h>
+#include <cameseutility.h>
+#include <e32def.h>
+
+#include "cameselog.h"
+
+// ----------------------------------------------------------------------------
+// CCameseUtility::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+EXPORT_C CCameseUtility* CCameseUtility::NewL(
+    MCameseObserver* aObserver /* = NULL */ )
+    {
+    CAMESE_LOG( "+CCameseUtility::NewL" );
+
+    CCameseUtility* self = new (ELeave) CCameseUtility();
+    CleanupStack::PushL( self );
+    self->ConstructL( 0, aObserver );
+    CleanupStack::Pop( self );
+
+    CAMESE_LOG( "-CCameseUtility::NewL" );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CCameseUtility::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+EXPORT_C CCameseUtility* CCameseUtility::NewL(
+    TInt aIapNumber,
+    MCameseObserver* aObserver /* = NULL */ )
+    {
+    CAMESE_LOG( "+CCameseUtility::NewL" );
+
+    CCameseUtility* self = new (ELeave) CCameseUtility();
+    CleanupStack::PushL( self );
+    self->ConstructL( aIapNumber, aObserver );
+    CleanupStack::Pop( self );
+
+    CAMESE_LOG( "-CCameseUtility::NewL" );
+    return self;
+    }
+// ----------------------------------------------------------------------------
+// CCameseUtility::NewL
+// Two-phased constructor.
+// ----------------------------------------------------------------------------
+//
+EXPORT_C CCameseUtility* CCameseUtility::NewL(
+    TInt /*aSockServHandle*/,
+    RConnection* aConnPtr,
+    MCameseObserver* aObserver /* = NULL */ )
+    {
+    CAMESE_LOG( "+CCameseUtility::NewL" );
+
+    CCameseUtility* self = new (ELeave) CCameseUtility();
+    CleanupStack::PushL( self );
+
+    TInt connectionIapId( 0 );
+     
+    if ( aConnPtr )
+        {
+        TConnectionInfo connectionInfo;
+        TUint count( 0 );
+        User::LeaveIfError( aConnPtr->EnumerateConnections( count ) );
+
+        if ( !count )
+            {
+            User::Leave( KErrNotReady );
+            }
+      
+        TPckg<TConnectionInfo> pkg( connectionInfo );
+        User::LeaveIfError( aConnPtr->GetConnectionInfo( 1, pkg ) );
+        
+        connectionIapId = connectionInfo.iIapId;
+        }
+        
+    self->ConstructL( connectionIapId, aObserver );
+    CleanupStack::Pop( self );
+
+    CAMESE_LOG( "-CCameseUtility::NewL" );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CCameseUtility::~CCameseUtility
+// ----------------------------------------------------------------------------
+//
+EXPORT_C CCameseUtility::~CCameseUtility()
+    {
+    CAMESE_LOG( "+CCameseUtility::~CCameseUtility" );
+
+    CAMESE_LOG( "-CCameseUtility::~CCameseUtility" );
+    }
+
+// ----------------------------------------------------------------------------
+// CCameseUtility::AcquireLicense
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void CCameseUtility::AcquireLicense(
+    const TDesC8& /*aDrmHeader*/,
+    HBufC8*& /*aUrl*/,
+    TRequestStatus& aStatus )
+    {
+    CAMESE_LOG( "+CCameseUtility::AcquireLicense" );
+
+    aStatus = KRequestPending;
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete( status, KErrNotSupported );
+
+    CAMESE_LOG( "-CCameseUtility::AcquireLicense" );
+    }
+
+// ----------------------------------------------------------------------------
+// CCameseUtility::AcquireLicense
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void CCameseUtility::AcquireLicense(
+    const RFile& /*aFileHandle*/,
+    HBufC8*& /*aUrl*/,
+    TRequestStatus& aStatus )
+    {
+    CAMESE_LOG( "+CCameseUtility::AcquireLicense" );
+
+    aStatus = KRequestPending;
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete( status, KErrNotSupported );
+
+    CAMESE_LOG( "-CCameseUtility::AcquireLicense" );
+    }
+
+// ----------------------------------------------------------------------------
+// CCameseUtility::AcquireLicense
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void CCameseUtility::AcquireLicense(
+    const RFile& /*aFileHandle*/,
+    const TDesC8& /*aLicenseResponse*/,
+    TRequestStatus& aStatus )
+    {
+    CAMESE_LOG( "+CCameseUtility::AcquireLicense" );
+
+    aStatus = KRequestPending;
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete( status, KErrNotSupported );
+
+    CAMESE_LOG( "-CCameseUtility::AcquireLicense" );
+    }
+
+
+// ----------------------------------------------------------------------------
+// CCameseUtility::SendDownloadResult
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void CCameseUtility::SendDownloadResult(
+    const TDesC8& /*aContentUrl*/,
+    TInt /*aResult*/,
+    TRequestStatus& aStatus )
+    {
+    CAMESE_LOG( "+CCameseUtility::SendDownloadResult" );
+
+    aStatus = KRequestPending;
+    TRequestStatus* status = &aStatus;
+    User::RequestComplete( status, KErrNotSupported );
+
+    CAMESE_LOG( "-CCameseUtility::SendDownloadResult" );
+    }
+
+// ----------------------------------------------------------------------------
+// CCameseUtility::Cancel
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void CCameseUtility::Cancel()
+    {
+    CAMESE_LOG( "+CCameseUtility::Cancel" );
+
+    CAMESE_LOG( "-CCameseUtility::Cancel" );
+    }
+
+// ----------------------------------------------------------------------------
+// CCameseUtility::SetIapId
+// ----------------------------------------------------------------------------
+//
+EXPORT_C void CCameseUtility::SetIapId( TInt /*aIapId*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CCameseUtility::CCameseUtility
+// ----------------------------------------------------------------------------
+//
+CCameseUtility::CCameseUtility()
+    {
+    CAMESE_LOG( "+CCameseUtility::CCameseUtility" );
+    CAMESE_LOG( "-CCameseUtility::CCameseUtility" );
+    }
+
+// ----------------------------------------------------------------------------
+// CCameseUtility::ConstructL
+// ----------------------------------------------------------------------------
+//
+void CCameseUtility::ConstructL( TInt /*aIapNumber*/, MCameseObserver* /*aObserver*/ )
+    {
+    CAMESE_LOG( "+CCameseUtility::ConstructL" );
+
+    CAMESE_LOG( "-CCameseUtility::ConstructL" );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project wmdrmdla
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+../wmdrmdlaapp/group/wmdrmdlaapp.mmp
+../wmdrmdlautils/group/wmdrmdlautils.mmp
+../wmdrmdla/group/wmdrmdla.mmp
+../wmdrmdlawrapper/group/wmdrmdlawrapper.mmp
+../wmdrmdladefaulthttpplugin/group/wmdrmdladefaulthttpplugin.mmp
+../wmdrmdladefaultuiplugin/group/wmdrmdladefaultuiplugin.mmp
+../cameseutility/group/cameseutility.mmp
+../httpfiltercamese/group/httpfiltercamese.mmp
+
+PRJ_TESTMMPFILES
+../internal/wmdrmdlatest/group/wmdrmdlatest.mmp
+
+PRJ_TESTEXPORTS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/httpfiltercamese/Data/10282936.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,53 @@
+/*
+* 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 file containing the ECom Resource Structure
+*
+*/
+
+
+//  INCLUDES
+#include <ecom/registryinfo.rh>
+#include "../inc/httpfiltercamese.hrh"
+
+//  RESOURCE DEFINITIONS 
+// -----------------------------------------------------------------------------
+// Registry info
+// The UIDs for the filters implemented in this DLL
+// -----------------------------------------------------------------------------
+//
+
+RESOURCE REGISTRY_INFO theInfo
+	{
+	dll_uid = KCameseFiltersDllUid;
+	interfaces=
+		{
+		INTERFACE_INFO
+			{
+			interface_uid = 0x101F446D;
+			implementations = 
+				{
+				IMPLEMENTATION_INFO
+					{
+					implementation_uid = KCameseFilterDrmHeaderImplementationUid;
+					version_no = 1;
+					display_name = "HTTP Camese Filter";
+					default_data = "HTTP/CAMESEDRMHDR";
+					opaque_data = "";
+					}
+   				};
+			}
+		};
+	}
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/httpfiltercamese/Inc/httpfiltercamese.hrh	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* 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:  Definition of filter implementation UIDs
+*
+*/
+
+
+#ifndef HTTPFILTERCAMESE_HRH
+#define HTTPFILTERCAMESE_HRH
+
+// CONSTANTS
+#define KCameseFiltersDllUid 0x10282936
+#define KCameseFilterDrmHeaderImplementationUid 0x10282937
+
+#endif      // HTTPFILTERCAMESE_HRH   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/httpfiltercamese/Inc/httpfiltercamesedatasupplier.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,99 @@
+/*
+* 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:  Provides Data Supplier for responses
+*
+*/
+
+
+#ifndef HTTPFILTERCAMESEDATASUPPLIER_H
+#define HTTPFILTERCAMESEDATASUPPLIER_H
+
+//  INCLUDES
+#include <http/mhttpdatasupplier.h>
+
+// CLASS DECLARATION
+
+/**
+ *  Data supplier to supply response body
+ *
+ *  @since 5.0
+ */
+NONSHARABLE_CLASS(CHttpFilterCameseDataSupplier) : 
+    public CBase, public MHTTPDataSupplier
+{
+public:  // Constructors and destructor
+
+    /**
+    * Two-phased constructor.
+    * @param aOriginalDataSupplier The original data supplier
+    * @param aData the content to be delivered to the http client
+    * @return an instance of the data supplier
+    */
+    static CHttpFilterCameseDataSupplier* NewL(
+        MHTTPDataSupplier* aOriginalDataSupplier,
+        const TDesC8& aData );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CHttpFilterCameseDataSupplier();
+
+public: // Functions from base classes
+
+    /**
+    * @see MHTTPDataSupplier
+    */
+    virtual void ReleaseData();
+
+    /**
+    * @see MHTTPDataSupplier
+    */
+    virtual TInt OverallDataSize();
+    
+    /**
+    * @see MHTTPDataSupplier
+    */
+    virtual TBool GetNextDataPart( TPtrC8& aDataPart );
+
+    /**
+    * @see MHTTPDataSupplier
+    */
+    virtual TInt Reset();
+
+private:
+
+    /**
+    * second-phase constructor
+    * @param aData the content to be delivered to the http client
+    */
+    void ConstructL( const TDesC8& aData );
+
+    /**
+    * C++ constructor.
+    * @param aOriginalDataSupplier The original data supplier
+    */
+    CHttpFilterCameseDataSupplier( MHTTPDataSupplier* aOriginalDataSupplier );
+
+private:    // Data
+
+    HBufC8* iData;                              // owned
+
+    // Original data supplier
+    MHTTPDataSupplier* iOriginalDataSupplier;   // not owned
+
+};
+
+#endif      // HTTPFILTERCAMESEDATASUPPLIER_H   
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/httpfiltercamese/Inc/httpfiltercamesedrmheader.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,194 @@
+/*
+* 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:  Camese DRM Header HTTP filter
+*
+*/
+
+
+
+#ifndef HTTPFILTERCAMESEDRMHEADER_H
+#define HTTPFILTERCAMESEDRMHEADER_H
+
+//  INCLUDES
+#include <http/mhttpfilter.h>
+#include <http/cecomfilter.h>
+
+// FORWARD DECLARATIONS
+class RSocketServ;
+class RConnection;
+class CHttpFilterCameseNoteManager;
+class CHttpFilterCameseDataSupplier;
+class CWmDrmDlaHandler;
+
+// CLASS DECLARATION
+
+/**
+*  Camese Drm Header Filter implementation class.
+*  @since 3.1
+*/
+class CHttpFilterCameseDrmHeader : public CEComFilter,
+                                   public MHTTPFilter
+{
+public:  // Constructors and destructor
+
+    /**
+    * Two-phased constructor.
+    * @param aSession pointer to the http session
+    * @return an instance of the drm header filter
+    */
+    static CHttpFilterCameseDrmHeader* NewL(TAny* aSession);
+
+    /**
+    * Destructor.
+    */
+    virtual ~CHttpFilterCameseDrmHeader();
+
+// From MHTTPFilter
+public:
+
+    /**
+    * @see MHTTPFilter
+    */
+    virtual void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent);
+
+    /**
+    * @see MHTTPFilter
+    */
+    virtual void MHFSessionRunL(const THTTPSessionEvent& aEvent);
+
+    /**
+    * @see MHTTPFilter
+    */
+    virtual TInt MHFRunError(TInt aError,
+                             RHTTPTransaction aTransaction,
+                             const THTTPEvent& aEvent);
+
+    /**
+    * @see MHTTPFilter
+    */
+    virtual TInt MHFSessionRunError(TInt aError, const THTTPSessionEvent& aEvent);
+
+    /**
+    * @see MHTTPFilter
+    */
+    virtual void MHFUnload(RHTTPSession aSession, THTTPFilterHandle aHandle);
+
+    /**
+    * @see MHTTPFilter
+    */
+    virtual void MHFLoad(RHTTPSession aSession, THTTPFilterHandle aHandle);
+
+private:
+    /**
+    * States during Drm Header Capture
+    */
+    enum TState
+        {
+        EIdle,
+        EDrmHeaderCapture,
+        ERequestingLicense       
+        };
+    
+private:
+
+    /**
+    * C++ constructor.
+    * @param aSession pointer to the http session
+    */
+    CHttpFilterCameseDrmHeader(RHTTPSession* aSession);
+
+    /**
+    * By default Symbian 2nd phase constructor is private.
+    */
+    void ConstructL();
+
+private:
+    
+    /**
+    * Parses the response headers to look for the DRM header
+    * mime type.
+    * @param aTrans the HTTP Transaction
+    */
+    void CheckResponseHeadersL( RHTTPTransaction& aTrans );
+    
+    /**
+    * Starts DRM Header capture.
+    * @param aTrans the HTTP Transaction
+    */
+    void StartDrmHeaderCaptureL( RHTTPTransaction& aTrans );
+
+    /**
+    * Captures the DRM header for further processing.
+    * @param aTrans the HTTP Transaction
+    */
+    void CaptureDrmHeaderL( RHTTPTransaction& aTrans );
+    
+    /**
+    * Requests Camese License Processing
+    * @param aTrans the HTTP Transaction
+    */
+    void RequestLicenseL( RHTTPTransaction& aTrans );
+    
+    /**
+    * Handles redirecting the filter to a media download or web page.
+    * @param aResult the result of the license requisition operation.
+    * @param aTrans the HTTP Transaction
+    * @param aContentUrl the URL for redirection.
+    */
+    void HandleRedirectL(TInt aResult,
+                         RHTTPTransaction& aTrans,
+                         HBufC8*& aContentUrl);
+    /**
+    * Reset Filter State machine
+    */
+    void Reset();
+
+    /**
+    * Retrieves the connection access point id to pass in to the Camese Utility.
+    * @param aTrans the HTTP Transaction
+    * @return the AP Id
+    */
+    TInt ConnectionAccessPoint(RHTTPTransaction& aTrans);        
+    
+private:    // Data
+	
+    // Count of how many times this filter has been loaded - used to ensure 
+    // destruction happens at the correct time	
+    TInt iLoadCount;
+
+    // The HTTP Session for which the filter was loaded
+    RHTTPSession*   iSession;                                   // not owned
+    
+    CHttpFilterCameseDataSupplier* iClientDataSupplier;         // not owned
+    RStringPool iStringPool;
+	
+    // Drm Header Transaction Id
+    TInt iTransactionId;
+	
+    // Filter state machine
+    TState iState;
+	
+	// Indicates that the data supplier has been set for the transaction
+	TBool iDataSupplierSet;
+	
+	//WMDRM DLA Handler
+	CWmDrmDlaHandler* iDlaHandler;                              // owned
+	
+    // Drm Header Buffer
+    HBufC8* iDrmHeaderBuffer;                                   // owned
+	};
+
+#endif      // HTTPFILTERCAMESEDRMHEADER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/httpfiltercamese/Src/httpfiltercamesedatasupplier.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,115 @@
+/*
+* 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:  Data supplier for responses
+*
+*/
+
+
+// INCLUDE FILES
+#include "httpfiltercamesedatasupplier.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDataSupplier::CHttpFilterCameseDataSupplier
+// C++ constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CHttpFilterCameseDataSupplier::CHttpFilterCameseDataSupplier(MHTTPDataSupplier* aOriginalDataSupplier)
+      : iOriginalDataSupplier(aOriginalDataSupplier)
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDataSupplier::ConstructL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+void CHttpFilterCameseDataSupplier::ConstructL(const TDesC8& aData)
+    {    
+    iData = aData.AllocL();
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDataSupplier::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CHttpFilterCameseDataSupplier* CHttpFilterCameseDataSupplier::NewL( 
+    MHTTPDataSupplier* aOriginalDataSupplier,
+    const TDesC8& aData )
+    {
+    CHttpFilterCameseDataSupplier* self = 
+        new(ELeave) CHttpFilterCameseDataSupplier( aOriginalDataSupplier );
+    CleanupStack::PushL( self );
+    self->ConstructL( aData );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CHttpFilterCameseDataSupplier::~CHttpFilterCameseDataSupplier()
+    {
+    delete iData;
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDataSupplier::GetNextDataPart
+// Return the next chunk of response body
+// -----------------------------------------------------------------------------
+//
+TBool CHttpFilterCameseDataSupplier::GetNextDataPart(TPtrC8 &aDataChunk)
+    {
+    aDataChunk.Set(iData->Des());    
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDataSupplier::ReleaseData
+// Releases the current data part
+// -----------------------------------------------------------------------------
+//
+void CHttpFilterCameseDataSupplier::ReleaseData()
+    {
+    if (iOriginalDataSupplier)
+        {            
+        iOriginalDataSupplier->ReleaseData();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDataSupplier::OverallDataSize
+// Returns the total data size
+// -----------------------------------------------------------------------------
+//
+TInt CHttpFilterCameseDataSupplier::OverallDataSize ()
+    {
+    return iData->Length();
+    }
+    
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDataSupplier::Reset
+// Resets data supplier.
+// -----------------------------------------------------------------------------
+//    
+TInt CHttpFilterCameseDataSupplier::Reset()
+    {
+    // Not supported
+    return KErrNotFound;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/httpfiltercamese/Src/httpfiltercamesedrmheader.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,624 @@
+/*
+* 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:  Camese DRM Header filter
+*
+*/
+
+
+// INCLUDES
+#include <http.h>
+#include <es_enum.h>
+#include <utf.h>
+#include <centralrepository.h> // - Album Download
+
+#include "httpfiltercamesedrmheader.h"
+#include "httpfiltercamesedatasupplier.h"
+#include "cameselog.h"
+#include "wmdrmdlahandler.h"
+
+// CONSTANTS
+// Filter position: DRM Header needs to be positioned below the client.
+const TInt KCameseDrmHeaderFilterPosition = MHTTPFilter::EClient - 10;
+
+const TUid KCRUidMusicShopSettings = {0x10207BF5}; // copied from MusicWapCenRepKeys.h - Album Download
+const TUint32 KSupportOmaDownloadDescriptor   = 0x00000004; // copied from MusicWapCenRepKeys.h - Album Download
+const TUint32 KMusicServiceFeatureFlagSupport = 0x00000012; // referred from 5.0 MusicWapCenRepKeys.h - Album Download
+
+_LIT8( KCameseDrmHeaderFilterName, "CameseDrmHeader" );
+_LIT8( KDataTypeCameseDRM,"application/vnd.ms-wmdrm.lic-chlg-req" ); 
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::CHttpFilterCameseDrmHeader
+// C++ constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CHttpFilterCameseDrmHeader::CHttpFilterCameseDrmHeader(RHTTPSession* aSession)
+    : iSession(aSession),
+      iTransactionId(KErrNotFound),
+      iState(EIdle),
+      iDataSupplierSet(EFalse)      
+    {
+    }
+
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CHttpFilterCameseDrmHeader::ConstructL()
+    {        
+    iStringPool = iSession->StringPool();
+
+    iStringPool.OpenL(RHTTPSession::GetTable());
+    
+    // Filter Name	
+    RStringF filterName = iStringPool.OpenFStringL( KCameseDrmHeaderFilterName() );
+    CleanupClosePushL( filterName );
+	
+    // Register the filter for the HTTP events we are interested.
+
+    iSession->FilterCollection().AddFilterL(*this,   // The filter to add
+                                            THTTPEvent::EGotResponseHeaders,        
+                                            RStringF(),                              
+                                            KAnyStatusCode,                          
+                                            KCameseDrmHeaderFilterPosition,     
+                                            filterName);
+    
+    iSession->FilterCollection().AddFilterL(*this,   // The filter to add
+                                            THTTPEvent::EGotResponseBodyData,        
+                                            RStringF(),                              
+                                            KAnyStatusCode,                          
+                                            KCameseDrmHeaderFilterPosition,     
+                                            filterName);
+    
+    iSession->FilterCollection().AddFilterL(*this,   // The filter to add
+                                            THTTPEvent::EResponseComplete,           
+                                            RStringF(),                              
+                                            KAnyStatusCode,                          
+                                            KCameseDrmHeaderFilterPosition,     
+                                            filterName);
+                                            
+    iSession->FilterCollection().AddFilterL(*this,   // The filter to add
+                                            THTTPEvent::ECancel,           
+                                            RStringF(),                              
+                                            KAnyStatusCode,                          
+                                            KCameseDrmHeaderFilterPosition,     
+                                            filterName);
+                                            
+    CleanupStack::PopAndDestroy(&filterName);  
+    }
+
+//------------------------------------------------------------------------------
+// Destructor
+//------------------------------------------------------------------------------
+//
+CHttpFilterCameseDrmHeader::~CHttpFilterCameseDrmHeader()
+    {
+    CAMESE_LOG("CHttpFilterCameseDrmHeader::~CHttpFilterCameseDrmHeader");
+
+    Reset();   
+	if ( iLoadCount )
+	    {
+		// As we're already in a destructor, MHFUnload must not delete us again
+		iLoadCount = -1;
+        RStringF filterName;
+		TRAPD( error, filterName = iStringPool.OpenFStringL( 
+            KCameseDrmHeaderFilterName ) );
+		if ( !error && iSession )
+            {
+	    	iSession->FilterCollection().RemoveFilter( filterName );
+            }
+        filterName.Close();  
+	    }
+
+    delete iDlaHandler;
+	}
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CHttpFilterCameseDrmHeader* CHttpFilterCameseDrmHeader::NewL( TAny* aSession )
+    {
+    ASSERT( aSession );
+    CAMESE_LOG( "CHttpFilterCameseDrmHeader::NewL" );
+    
+    CHttpFilterCameseDrmHeader* filter = 
+        new (ELeave) CHttpFilterCameseDrmHeader (reinterpret_cast< RHTTPSession* >( aSession ) );
+    CleanupStack::PushL( filter );
+    filter->ConstructL();
+    CleanupStack::Pop( filter );
+    return filter;
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::MHFLoad
+// -----------------------------------------------------------------------------
+//
+void CHttpFilterCameseDrmHeader::MHFLoad(
+    RHTTPSession /*aSession*/, 
+    THTTPFilterHandle /*aFilterHandler*/ )
+    {
+    CAMESE_LOG( "CHttpFilterCameseDrmHeader::MHFLoad" );
+    ++iLoadCount;
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::MHFUnload
+// -----------------------------------------------------------------------------
+//
+void CHttpFilterCameseDrmHeader::MHFUnload(
+    RHTTPSession /*aSession*/, 
+    THTTPFilterHandle /*aFilterHandler*/ )
+    {
+    CAMESE_LOG( "CHttpFilterCameseDrmHeader::MHFUnload" );
+    ASSERT( iLoadCount > 0 );
+
+	if ( --iLoadCount )
+	    {
+		return;
+        }
+        
+	delete this;
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::MHFRunL
+// -----------------------------------------------------------------------------
+//
+void CHttpFilterCameseDrmHeader::MHFRunL(
+    RHTTPTransaction aTransaction,
+    const THTTPEvent& aEvent )
+    {
+    // Check if we are interested in the transaction
+    if ( (iTransactionId != KErrNotFound ) &&
+         (aTransaction.Id() != iTransactionId) )
+        {        
+        return;
+        }
+
+    CAMESE_LOG1( "CHttpFilterCameseDrmHeader::MHFRunL aEvent=%i", 
+        aEvent.iStatus );            
+    switch( aEvent.iStatus )
+        {
+		case THTTPEvent::EGotResponseHeaders:
+		    // Only interested in headers if in idle state.
+		    if ( iState == EIdle )
+		        {		        		    
+                CheckResponseHeadersL( aTransaction );
+		        }
+			break;
+			
+	    case THTTPEvent::EGotResponseBodyData:
+	        if ( iState == EDrmHeaderCapture )
+	            {
+	            CaptureDrmHeaderL( aTransaction );	            	        
+	            }	        
+	        break;
+                	        
+	    case THTTPEvent::EResponseComplete:
+	        if ( iState == EDrmHeaderCapture )
+	            {
+	            RequestLicenseL( aTransaction );
+	            }
+	        break;  	        
+	    
+        case THTTPEvent::ECancel:
+            CAMESE_LOG( 
+                "CHttpFilterCameseDrmHeader::MHFRunL Handling Cancelation" );
+            if ( iState == ERequestingLicense )
+                {
+                // Asynchronous cancelation while the
+                // filter is blocked.
+                
+                CAMESE_LOG(
+                    "CHttpFilterCameseDrmHeader::MHFRunL Canceling Camese" );
+                // Need to unblock the license request.
+                if ( iDlaHandler )
+                    {
+                    iDlaHandler->CancelLicenseAcquisition();
+                    }    
+                }
+            break;
+            
+		default:
+		    // Stray event
+		    ASSERT( ETrue );
+			break;
+        }
+
+    }
+
+//------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::CheckResponseHeadersL
+//------------------------------------------------------------------------
+// 
+void CHttpFilterCameseDrmHeader::CheckResponseHeadersL( 
+    RHTTPTransaction& aTrans )
+    {    
+	RHTTPHeaders responseHeaders = aTrans.Response().GetHeaderCollection();
+		
+	RStringF contentTypeNameStr = 
+	    iStringPool.StringF( HTTP::EContentType, RHTTPSession::GetTable() );
+
+	// read the first part of content-type field
+	THTTPHdrVal contentTypeVal;
+
+	if( !responseHeaders.GetField( contentTypeNameStr, 0, contentTypeVal ) )
+    	{	    
+        if ( contentTypeVal.StrF().DesC().MatchF( KDataTypeCameseDRM ) != 
+            KErrNotFound )
+	    	{
+	    	CAMESE_LOG( "CHttpFilterCameseDrmHeader::CheckResponseHeaders Found Drm Header" );            
+            StartDrmHeaderCaptureL( aTrans );
+	    	}
+    	}
+    }
+    
+//------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::StartDrmHeaderCaptureL
+//------------------------------------------------------------------------
+// 
+void CHttpFilterCameseDrmHeader::StartDrmHeaderCaptureL( 
+    RHTTPTransaction& aTrans )
+    {    
+    // Start processing the Drm Header Packet.
+    RHTTPHeaders responseHeaders = aTrans.Response().GetHeaderCollection();
+    RStringF contentTypeNameStr = 
+        iStringPool.StringF( HTTP::EContentType, RHTTPSession::GetTable() );
+    RStringF cacheControlStr = 
+        iStringPool.StringF( HTTP::ECacheControl, RHTTPSession::GetTable() );
+    RStringF noCacheVal = 
+        iStringPool.StringF( HTTP::ENoCache, RHTTPSession::GetTable() );
+        		    
+    // Cache the transaction id
+    iTransactionId = aTrans.Id();
+	
+    // Add a Cache-Control field indicating no-cache.
+    // This will keep our response from being cached.
+    responseHeaders.SetFieldL( cacheControlStr, THTTPHdrVal( noCacheVal ) );
+
+    // Set the HTTP Status code as KErrCompletion - 
+    // this will avoid letting download manager finalize
+    // the temporary drm header download.
+  
+    // Album - Album Download
+    
+    TInt value( 0 );
+    TBool omaDdSupported( EFalse );
+    
+    CRepository* repository( NULL );
+
+    TRAPD( err, repository = CRepository::NewL( KCRUidMusicShopSettings ) );
+    if ( !err )
+        {
+        // read value of KMusicServiceFeatureFlagSupport from repository
+        // KCRUidMusicShopSettings and check if KSupportOmaDownloadDescriptor bit is set
+        // in that value
+        
+        err = repository->Get( KMusicServiceFeatureFlagSupport, value );
+        if ( !err )
+            {
+            // check for KSupportOmaDownloadDescriptor if the bit is set in value
+            if ( value & KSupportOmaDownloadDescriptor )
+                {
+                omaDdSupported = ETrue;
+                }
+            }
+        
+        delete repository;
+        }
+
+    if ( !omaDdSupported )
+        {        
+        aTrans.Response().SetStatusCode( KErrCompletion );
+        }
+        
+    // Album - Album Download
+
+    // Change state to DRM Header Capture mode.
+    iState = EDrmHeaderCapture;        
+    }
+
+//------------------------------------------------------------------------
+// CHttpFilterCameseDownloader::ConnectionAccessPoint
+//------------------------------------------------------------------------
+// 
+TInt CHttpFilterCameseDrmHeader::ConnectionAccessPoint(
+    RHTTPTransaction& aTrans )
+    {
+    TInt ap( 0 );
+                                                     
+    // Retrieve connection information from the http session      
+    const RHTTPConnectionInfo& connInfo = aTrans.Session().ConnectionInfo();
+    RConnection* connPtr = NULL;
+                
+    THTTPHdrVal connHeader;
+    TBool hasConnValue = connInfo.Property(
+        iStringPool.StringF( 
+            HTTP::EHttpSocketConnection, RHTTPSession::GetTable() ),
+        connHeader );
+          	                                  
+    // If we have access to the RConnection pointer, try to retrieve the IAP id.                 	                                 
+    if ( hasConnValue )
+        {
+        // Got RConnection Property
+        connPtr = REINTERPRET_CAST( RConnection*, connHeader.Int() );
+        
+        // Now retrieve the access point id.
+        if ( connPtr )
+            {                    
+            TConnectionInfo connectionInfo;
+
+            TUint count = 0;
+            if ( !connPtr->EnumerateConnections(count) )
+                {                            
+                TPckg<TConnectionInfo> pkg(connectionInfo);
+                if ( !connPtr->GetConnectionInfo( 1, pkg ) )
+                    {
+                    ap = connectionInfo.iIapId;
+                    }
+                }
+            }
+        }
+        
+    return ap;        
+    }
+
+//------------------------------------------------------------------------
+// CHttpFilterCameseDownloader::CaptureDrmHeaderL
+//------------------------------------------------------------------------
+// 
+void CHttpFilterCameseDrmHeader::CaptureDrmHeaderL( 
+    RHTTPTransaction& aTrans )
+    {    
+    TPtrC8 ptr;
+
+    MHTTPDataSupplier* dataSupplier = aTrans.Response().Body();			            
+    dataSupplier->GetNextDataPart( ptr );
+
+    // Append to iDrmHeaderBuffer
+    if ( !iDrmHeaderBuffer )
+        {
+    	iDrmHeaderBuffer = ptr.AllocL();
+    	}
+    else
+    	{
+    	iDrmHeaderBuffer = iDrmHeaderBuffer->ReAllocL(
+    	    iDrmHeaderBuffer->Length() + ptr.Length() );
+    	iDrmHeaderBuffer->Des().Append( ptr );
+    	}
+
+    if ( !iDataSupplierSet )    			
+        {            
+        // Feed the actual client with our data supplier, that will feed an empty
+        // descriptor.
+        delete iClientDataSupplier;
+        iClientDataSupplier = NULL;		    	
+        iClientDataSupplier = 
+            CHttpFilterCameseDataSupplier::NewL( aTrans.Response().Body(),
+                KNullDesC8() );
+            
+        aTrans.Response().SetBody( *iClientDataSupplier );
+        iDataSupplierSet = ETrue;
+        }            
+    }
+
+//------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::RequestLicenseL
+//------------------------------------------------------------------------
+// 
+void CHttpFilterCameseDrmHeader::RequestLicenseL( RHTTPTransaction& aTrans )
+    {    
+    ASSERT( iDrmHeaderBuffer );
+    CAMESE_LOG(
+        "CHttpFilterCameseDrmHeader::RequestLicenseL Passing in Drm Header" );
+    
+    if ( !iDlaHandler )
+        {
+        iDlaHandler = CWmDrmDlaHandler::NewL();
+        }
+    
+    // Pass in our current access point to the drm interface.
+    iDlaHandler->SetIapId( ConnectionAccessPoint( aTrans ) );
+    
+    // Use the Camese Interface, passing in
+    // the DRM header url. WMDRM DLA Handler uses it for
+    // error reporting.
+    HBufC8* errorUrl8( aTrans.Request().URI().UriDes().AllocLC() );   
+    HBufC* errorUrl( CnvUtfConverter::ConvertToUnicodeFromUtf8L( *errorUrl8 ) );
+    CleanupStack::PushL( errorUrl );
+    
+    HBufC* contentUrl( NULL );
+    HBufC* htmlData( NULL );
+    
+    // Update state
+    iState = ERequestingLicense;
+    
+    // This call blocks and only returns after Camese is done with the licensing
+    // process.
+    TRAPD( result, iDlaHandler->AcquireLicenseFromDrmHeaderL( *iDrmHeaderBuffer,
+                                                              errorUrl,
+                                                              contentUrl,
+                                                              htmlData ) );
+    
+    CAMESE_LOG("CHttpFilterCameseDrmHeader::RequestLicenseL Unblocked");
+    
+    delete htmlData;
+    
+    HBufC8* contentUrl8( NULL );
+    if ( contentUrl )
+        {
+        CleanupStack::PushL( contentUrl );
+        contentUrl8 = CnvUtfConverter::ConvertFromUnicodeToUtf8L( *contentUrl );
+        CleanupStack::PopAndDestroy( contentUrl );
+        }
+    CleanupStack::PushL( contentUrl8 );
+    
+    
+    // Check if the filter has not been canceled.
+    if ( result != KErrCancel )
+        {        
+        HandleRedirectL( result, aTrans, contentUrl8 );
+        }
+    CleanupStack::PopAndDestroy( 3, errorUrl8 ); //contentUrl8, errorUrl, errorUrl8
+    
+    // Reset state machine.        
+    Reset();        
+    }
+
+//------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::HandleRedirectL
+//------------------------------------------------------------------------
+// 
+void CHttpFilterCameseDrmHeader::HandleRedirectL(
+    TInt aResult,
+    RHTTPTransaction& aTrans,
+    HBufC8*& aContentUrl )
+    {        
+    // Now check if we have a content URL to redirect to,
+    // and if the content URL is not the DRM Header URL we
+    // passed in.
+    if ( aContentUrl && aContentUrl->CompareF( aTrans.Request().URI().UriDes() ) )
+        {                   
+        TUriParser8 uri;
+        TInt err = uri.Parse( *aContentUrl );
+            
+        if ( !err )
+            {   
+            CAMESE_LOG( 
+                "CHttpFilterCameseDrmHeader::RequestLicenseL Redirecting" );
+            CAMESE_LOG8_1( "   > ContentUrl = %S", aContentUrl );         
+            CAMESE_LOG1( "   > Licensing Result = %d", aResult );
+            
+            // Cancel the Transaction.
+            aTrans.Cancel();
+
+            // Set new URI - could be content or error page.
+            aTrans.Request().SetURIL( uri );
+            
+            
+            // update for - Album Download
+            // Manually replace HOST firld in the HTTP header to reflect the new host
+            //
+            RHTTPHeaders headers = aTrans.Request().GetHeaderCollection();
+            RStringF hostStr = aTrans.Session().StringPool().StringF(HTTP::EHost, RHTTPSession::GetTable());
+            CleanupClosePushL(hostStr);
+            TInt error = headers.RemoveField(hostStr);
+            CAMESE_LOG1("   error for removing HOST field from header = %d", error);
+            if (error == KErrNone || error == KErrNotFound)
+	            {
+	            HBufC* host =aTrans.Request().URI().DisplayFormL(EUriHost);
+	            CleanupStack::PushL(host);
+	            HBufC8* host8 = HBufC8::NewL(host->Length());
+	            CleanupStack::PushL(host8);
+	            host8->Des().Copy(*host);
+	            CAMESE_LOG8_1("   > new host = %S", host8);
+	            RStringF hostValueStr = aTrans.Session().StringPool().OpenFStringL(*host8);
+	            CleanupClosePushL<RStringF>(hostValueStr);
+	            headers.SetFieldL( hostStr, THTTPHdrVal(hostValueStr) );
+	            CleanupStack::PopAndDestroy(3, host); // hostValueStr, host8, host
+	            }
+            else
+	            {
+	            User::Leave(error);
+	            }
+            CleanupStack::PopAndDestroy(&hostStr);
+            // update end for - Album Download
+        
+            // Submit the new transaction.		                	                	            
+            aTrans.SubmitL();  
+            }
+        else
+            {
+            CAMESE_LOG( 
+                "CHttpFilterCameseDrmHeader::RequestLicenseL Malformed Url" );
+            // Fail the transaction
+            aTrans.Fail();
+            }                
+        }
+    else
+        {
+        CAMESE_LOG("CHttpFilterCameseDrmHeader::RequestLicenseL No valid redirection Url");
+        // Fail the transaction
+        aTrans.Fail();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::Reset
+// -----------------------------------------------------------------------------
+//
+void CHttpFilterCameseDrmHeader::Reset()
+    { 
+    CAMESE_LOG("CHttpFilterCameseDrmHeader::Reset");   
+    iState = EIdle;
+    iTransactionId = KErrNotFound;
+    
+    delete iDrmHeaderBuffer;
+    iDrmHeaderBuffer = NULL;   
+    
+    delete iClientDataSupplier;
+    iClientDataSupplier = NULL;
+    iDataSupplierSet = EFalse;
+    
+    delete iDlaHandler;
+    iDlaHandler = NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::MHFRunError
+// -----------------------------------------------------------------------------
+//
+TInt CHttpFilterCameseDrmHeader::MHFRunError(
+    TInt aError,
+    RHTTPTransaction aTransaction,
+    const THTTPEvent& aEvent )
+    {
+    // Log errors
+    CAMESE_LOG2("CHttpFilterCameseDrmHeader::MHFRunError Error = %i Event = %i",
+                aError,
+                aEvent.iStatus);
+                  
+    aTransaction.Fail();
+    
+    Reset();
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::MHFSessionRunL
+// -----------------------------------------------------------------------------
+//
+void CHttpFilterCameseDrmHeader::MHFSessionRunL(
+    const THTTPSessionEvent& /*aEvent*/ )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CHttpFilterCameseDrmHeader::MHFSessionRunError
+// -----------------------------------------------------------------------------
+//
+TInt CHttpFilterCameseDrmHeader::MHFSessionRunError(
+    TInt /*aError*/,
+    const THTTPSessionEvent& /*aEvent*/ )
+    {
+    return KErrNone;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/httpfiltercamese/Src/httpfiltercamesemain.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,44 @@
+/*
+* 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:  Camese filters main file
+*
+*/
+
+
+// INCLUDES
+#include <e32std.h>
+#include <ecom/implementationproxy.h>
+#include "httpfiltercamese.hrh"
+#include "httpfiltercamesedrmheader.h"
+
+// CONSTANTS
+const TImplementationProxy KImplementationTable[] =
+    {
+        {{KCameseFilterDrmHeaderImplementationUid}, (TProxyNewLPtr) CHttpFilterCameseDrmHeader::NewL}
+    };
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy
+// Returns the filters implemented in this DLL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
+    {
+    aTableCount = sizeof(KImplementationTable) / sizeof(TImplementationProxy);
+    return KImplementationTable;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/httpfiltercamese/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build Information file for project httpfiltercamese
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+./httpFilterCamese.mmp
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/httpfiltercamese/group/httpfiltercamese.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,60 @@
+/*
+* 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:  Project definition file for project httpfiltercamese
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  httpfiltercamese.dll
+TARGETTYPE              PLUGIN
+
+UID                     0x10009D8D 0x10282936
+
+VENDORID                VID_DEFAULT
+CAPABILITY              CAP_ECOM_PLUGIN
+
+USERINCLUDE             ../inc
+USERINCLUDE             ../../inc 
+USERINCLUDE				../../wmdrmdla/inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH              ../src
+SOURCE                  httpfiltercamesedrmheader.cpp
+SOURCE                  httpfiltercamesemain.cpp
+SOURCE                  httpfiltercamesedatasupplier.cpp
+
+START RESOURCE          ../data/10282936.rss
+HEADER
+TARGET                  httpfiltercamese.rsc
+// *** Uncomment LANGUAGE_IDS below if and only if the resource file needs localisation
+// LANGUAGE_IDS
+END // RESOURCE
+
+LIBRARY                 euser.lib
+LIBRARY                 flogger.lib
+LIBRARY                 bafl.lib
+LIBRARY                 httpfiltercommon.lib
+LIBRARY                 http.lib
+LIBRARY                 inetprotutil.lib
+LIBRARY                 esock.lib
+LIBRARY                 ecom.lib
+LIBRARY         		charconv.lib
+LIBRARY					wmdrmdla.lib
+LIBRARY                 centralrepository.lib // central repository
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/inc/cameselog.h	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Log functions used by the Camese subsystem
+*
+*/
+
+
+#ifndef CAMESELOG_H
+#define CAMESELOG_H
+
+#if defined (_DEBUG)
+
+// INCLUDES
+#include <flogger.h>
+
+// CONSTANTS
+// MUST DEFINE THE FOLLOWING 2 CONSTANTS
+_LIT(KCameseLogFolder,"camese");
+_LIT(KCameseLogFile,"camese.txt");
+
+/**
+ * Logging class
+ * This class allows debugging messages to be logged to file or RDebug port.
+ * @since 3.1
+ */
+NONSHARABLE_CLASS(CameseLog)
+    {
+    public:
+        /**
+        * Write to the log
+        * @param aFmt string
+        */
+        inline static void Printf1(const TDesC& aFmt);
+
+        /**
+        * Write a mulitple argument list to the log
+        * @param aFmt format string
+        */
+        inline static void Printf(TRefByValue<const TDesC> aFmt, ...);
+
+        /**
+        * Write to the log
+        * @param aFmt string
+        */
+        inline static void Printf1(const TDesC8& aFmt);
+
+        /**
+        * Write a mulitple argument list to the log
+        * @param aFmt format string
+        */
+        inline static void Printf(TRefByValue<const TDesC8> aFmt, ...);
+
+        /**
+        * Hex dump to the log
+        * @param aFmt format string
+        */
+        inline static void HexDump(const TText* aHeader, const TText* aMargin,
+            const TUint8* aPtr, TInt aLen);
+    };
+
+// MACROS
+#define CAMESE_LOG_TDES(fmt)            CameseLog::Printf1(fmt)
+#define CAMESE_LOG(fmt)                 CameseLog::Printf1(_L(fmt))
+#define CAMESE_LOG1(fmt,v1)             CameseLog::Printf(_L(fmt),v1)
+#define CAMESE_LOG2(fmt,v1,v2)          CameseLog::Printf(_L(fmt),v1,v2)
+#define CAMESE_LOG3(fmt,v1,v2,v3)       CameseLog::Printf(_L(fmt),v1,v2,v3)
+#define CAMESE_HEX_DUMP(h, m, p, l)     CameseLog::HexDump(h, m, p, l)
+#define CAMESE_LOG8(fmt)                CameseLog::Printf1(_L8(fmt))
+#define CAMESE_LOG8_1(fmt,v1)           CameseLog::Printf(_L8(fmt),v1)
+#define CAMESE_LOG8_2(fmt,v1,v2)        CameseLog::Printf(_L8(fmt),v1,v2)
+#define CAMESE_LOG8_3(fmt,v1,v2,v3)     CameseLog::Printf(_L8(fmt),v1,v2,v3)
+
+/**
+ * Descriptor Overflow Handler for logging.
+ * @since 3.1
+ */
+NONSHARABLE_CLASS(TLogOverflowHandler) : public TDesOverflow
+    {
+    public:
+        inline virtual void Overflow(TDes16 &aDes);
+    };
+
+/**
+ * Descriptor Overflow Handler for logging (8bit).
+ * @since 3.1
+ */
+NONSHARABLE_CLASS(TLogOverflowHandler8) : public TDes8Overflow
+    {
+    public:
+        inline virtual void Overflow(TDes8 &aDes);
+    };
+
+#include "cameselog.inl"
+
+#else
+
+#define CAMESE_LOG_TDES(fmt)
+#define CAMESE_LOG(fmt)
+#define CAMESE_LOG1(fmt,v1)
+#define CAMESE_LOG2(fmt,v1,v2)
+#define CAMESE_LOG3(fmt,v1,v2,v3)
+#define CAMESE_HEX_DUMP(h, m, p, l)
+#define CAMESE_LOG8(fmt)           
+#define CAMESE_LOG8_1(fmt,v1)         
+#define CAMESE_LOG8_2(fmt,v1,v2)     
+#define CAMESE_LOG8_3(fmt,v1,v2,v3)
+
+#endif
+#endif // CAMESELOG_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/inc/cameselog.inl	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,132 @@
+/*
+* 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:  Implement inline functions for the CameseLog module
+*
+*/
+
+
+// INCLUDE FILES
+#include <E32SVR.H>
+
+// ----------------------------------------------------------------------------
+// Write a string to the log - 16 bit version
+// ----------------------------------------------------------------------------
+//
+inline void CameseLog::Printf1(const TDesC& aFmt)
+    {
+    TInt msgSize = aFmt.Length();
+    TInt offSet = 0;
+    TPtrC msgPtr;
+    while(offSet < msgSize)
+        {
+        msgPtr.Set(aFmt.Mid(offSet));
+        RFileLogger::WriteFormat(KCameseLogFolder(), KCameseLogFile(),
+            EFileLoggingModeAppend, msgPtr.Left(100));
+        offSet += 100;  //set to 100
+        };
+    RDebug::Print(aFmt);        
+    }
+
+// ----------------------------------------------------------------------------
+// Write a multiple argument list to the log - 16 bit version
+// ----------------------------------------------------------------------------
+//
+inline void CameseLog::Printf(TRefByValue<const TDesC> aFmt,...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    RFileLogger::WriteFormat(KCameseLogFolder(), KCameseLogFile(),
+        EFileLoggingModeAppend, aFmt, list);
+    TLogOverflowHandler overflow;
+    TBuf<KLogBufferSize> tmpBuf;
+    tmpBuf.AppendFormatList(aFmt, list, &overflow);
+    RDebug::Print(tmpBuf);
+    VA_END(list);
+    }
+
+// ----------------------------------------------------------------------------
+// Write a string to the log - 8 bit version
+// ----------------------------------------------------------------------------
+//
+inline void CameseLog::Printf1(const TDesC8& aFmt)
+    {
+    TInt msgSize = aFmt.Length();
+    TInt offSet = 0;
+    TPtrC8 msgPtr;
+    while(offSet < msgSize)
+        {
+        msgPtr.Set(aFmt.Mid(offSet));
+        RFileLogger::WriteFormat(KCameseLogFolder(), KCameseLogFile(),
+            EFileLoggingModeAppend, msgPtr.Left(100));
+        offSet += 100;  //set to 100
+        };
+    
+    HBufC* buf16 = HBufC::NewLC(aFmt.Length());
+    buf16->Des().Copy(aFmt);
+    RDebug::Print(*buf16);
+    CleanupStack::PopAndDestroy(buf16);    
+    }
+
+// ----------------------------------------------------------------------------
+// Write a multiple argument list to the log - 8 bit version
+// ----------------------------------------------------------------------------
+//
+inline void CameseLog::Printf(TRefByValue<const TDesC8> aFmt,...)
+    {
+    VA_LIST list;
+    VA_START(list,aFmt);
+    RFileLogger::WriteFormat(KCameseLogFolder(), KCameseLogFile(),
+        EFileLoggingModeAppend, aFmt, list);
+
+    TLogOverflowHandler8 overflow;
+    TBuf8<KLogBufferSize> tmpBuf;
+    tmpBuf.AppendFormatList(aFmt, list, &overflow);
+
+    HBufC* buf16 = HBufC::NewLC(tmpBuf.Length());
+    buf16->Des().Copy(tmpBuf);
+    RDebug::Print(*buf16);
+    CleanupStack::PopAndDestroy(buf16);
+
+    VA_END(list);
+    }
+
+// ----------------------------------------------------------------------------
+// Write a hex dump to the log
+// ----------------------------------------------------------------------------
+//
+inline void CameseLog::HexDump(
+    const TText* aHeader,
+    const TText* aMargin,
+    const TUint8* aPtr,
+    TInt aLen)
+    {
+    // Hex Dumps only to file.
+    RFileLogger::HexDump(KCameseLogFolder(), KCameseLogFile(), EFileLoggingModeAppend,
+        aHeader, aMargin, aPtr, aLen);
+    }
+
+// ----------------------------------------------------------------------------
+// Handle overflow without rising a panic
+// ----------------------------------------------------------------------------
+//
+inline void TLogOverflowHandler::Overflow(TDes16& /*aDes*/)
+    {
+    return;
+    }
+
+inline void TLogOverflowHandler8::Overflow(TDes8& /*aDes*/)
+    {
+    return;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/BWINS/wmdrmdlau.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,22 @@
+EXPORTS
+	?SetCancelObserver@CWmDrmDlaUiNotifier@@QAEXPAVMWmDrmDlaCancelObserver@@@Z @ 1 NONAME ; void CWmDrmDlaUiNotifier::SetCancelObserver(class MWmDrmDlaCancelObserver *)
+	?ProcessMeteringCertificate@CWmDrmDlaHandler@@QAEXABVTDesC8@@AAVTRequestStatus@@@Z @ 2 NONAME ; void CWmDrmDlaHandler::ProcessMeteringCertificate(class TDesC8 const &, class TRequestStatus &)
+	?NewLC@CWmDrmDlaHandler@@SAPAV1@XZ @ 3 NONAME ; class CWmDrmDlaHandler * CWmDrmDlaHandler::NewLC(void)
+	?NewL@CWmDrmDlaHandler@@SAPAV1@XZ @ 4 NONAME ; class CWmDrmDlaHandler * CWmDrmDlaHandler::NewL(void)
+	?HandleErrorL@CWmDrmDlaUiNotifier@@QAEXH@Z @ 5 NONAME ; void CWmDrmDlaUiNotifier::HandleErrorL(int)
+	?CancelLicenseAcquisition@CWmDrmDlaHandler@@QAEXXZ @ 6 NONAME ; void CWmDrmDlaHandler::CancelLicenseAcquisition(void)
+	?AcquireLicense@CWmDrmDlaHandler@@QAEXABVRFile@@AAPAVHBufC16@@1AAVTRequestStatus@@@Z @ 7 NONAME ; void CWmDrmDlaHandler::AcquireLicense(class RFile const &, class HBufC16 * &, class HBufC16 * &, class TRequestStatus &)
+	?SetSilent@CWmDrmDlaUiNotifier@@QAEXH@Z @ 8 NONAME ; void CWmDrmDlaUiNotifier::SetSilent(int)
+	?InitializeL@CWmDrmDlaUiNotifier@@QAEXVTUid@@@Z @ 9 NONAME ; void CWmDrmDlaUiNotifier::InitializeL(class TUid)
+	?SilentL@CWmDrmDlaHandler@@QAEHABVRFile@@@Z @ 10 NONAME ; int CWmDrmDlaHandler::SilentL(class RFile const &)
+	?CancelMetering@CWmDrmDlaHandler@@QAEXXZ @ 11 NONAME ; void CWmDrmDlaHandler::CancelMetering(void)
+	?AcquireLicenseFromDrmHeaderL@CWmDrmDlaHandler@@QAEXABVTDesC8@@PAVHBufC16@@AAPAV3@2@Z @ 12 NONAME ; void CWmDrmDlaHandler::AcquireLicenseFromDrmHeaderL(class TDesC8 const &, class HBufC16 *, class HBufC16 * &, class HBufC16 * &)
+	?AcquireLicenseFromDrmHeader@CWmDrmDlaHandler@@QAEXABVTDesC8@@PAVHBufC16@@AAPAV3@2AAVTRequestStatus@@@Z @ 13 NONAME ; void CWmDrmDlaHandler::AcquireLicenseFromDrmHeader(class TDesC8 const &, class HBufC16 *, class HBufC16 * &, class HBufC16 * &, class TRequestStatus &)
+	?SetIapId@CWmDrmDlaHandler@@QAEXH@Z @ 14 NONAME ; void CWmDrmDlaHandler::SetIapId(int)
+	?AcquireLicenseL@CWmDrmDlaHandler@@QAEXABVRFile@@AAPAVHBufC16@@1@Z @ 15 NONAME ; void CWmDrmDlaHandler::AcquireLicenseL(class RFile const &, class HBufC16 * &, class HBufC16 * &)
+	?NewL@CWmDrmDlaUiNotifier@@SAPAV1@XZ @ 16 NONAME ; class CWmDrmDlaUiNotifier * CWmDrmDlaUiNotifier::NewL(void)
+	?InitializeL@CWmDrmDlaUiNotifier@@QAEXAAVTDesC8@@@Z @ 17 NONAME ; void CWmDrmDlaUiNotifier::InitializeL(class TDesC8 &)
+	?SetProgress@CWmDrmDlaUiNotifier@@QAEXH@Z @ 18 NONAME ; void CWmDrmDlaUiNotifier::SetProgress(int)
+	?ProcessMeteringCertificateL@CWmDrmDlaHandler@@QAEXABVTDesC8@@@Z @ 19 NONAME ; void CWmDrmDlaHandler::ProcessMeteringCertificateL(class TDesC8 const &)
+	?NewLC@CWmDrmDlaUiNotifier@@SAPAV1@XZ @ 20 NONAME ; class CWmDrmDlaUiNotifier * CWmDrmDlaUiNotifier::NewLC(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/EABI/wmdrmdlau.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,22 @@
+EXPORTS
+	_ZN16CWmDrmDlaHandler14AcquireLicenseERK5RFileRP7HBufC16S5_R14TRequestStatus @ 1 NONAME
+	_ZN16CWmDrmDlaHandler14CancelMeteringEv @ 2 NONAME
+	_ZN16CWmDrmDlaHandler15AcquireLicenseLERK5RFileRP7HBufC16S5_ @ 3 NONAME
+	_ZN16CWmDrmDlaHandler24CancelLicenseAcquisitionEv @ 4 NONAME
+	_ZN16CWmDrmDlaHandler26ProcessMeteringCertificateERK6TDesC8R14TRequestStatus @ 5 NONAME
+	_ZN16CWmDrmDlaHandler27AcquireLicenseFromDrmHeaderERK6TDesC8P7HBufC16RS4_S5_R14TRequestStatus @ 6 NONAME
+	_ZN16CWmDrmDlaHandler27ProcessMeteringCertificateLERK6TDesC8 @ 7 NONAME
+	_ZN16CWmDrmDlaHandler28AcquireLicenseFromDrmHeaderLERK6TDesC8P7HBufC16RS4_S5_ @ 8 NONAME
+	_ZN16CWmDrmDlaHandler4NewLEv @ 9 NONAME
+	_ZN16CWmDrmDlaHandler5NewLCEv @ 10 NONAME
+	_ZN16CWmDrmDlaHandler7SilentLERK5RFile @ 11 NONAME
+	_ZN16CWmDrmDlaHandler8SetIapIdEi @ 12 NONAME
+	_ZN19CWmDrmDlaUiNotifier11InitializeLE4TUid @ 13 NONAME
+	_ZN19CWmDrmDlaUiNotifier11InitializeLER6TDesC8 @ 14 NONAME
+	_ZN19CWmDrmDlaUiNotifier11SetProgressEi @ 15 NONAME
+	_ZN19CWmDrmDlaUiNotifier12HandleErrorLEi @ 16 NONAME
+	_ZN19CWmDrmDlaUiNotifier17SetCancelObserverEP23MWmDrmDlaCancelObserver @ 17 NONAME
+	_ZN19CWmDrmDlaUiNotifier4NewLEv @ 18 NONAME
+	_ZN19CWmDrmDlaUiNotifier5NewLCEv @ 19 NONAME
+	_ZN19CWmDrmDlaUiNotifier9SetSilentEi @ 20 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* 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:  Build Information file for project wmdrmdla
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+wmdrmdla.mmp
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/group/wmdrmdla.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,60 @@
+/*
+* 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:  Project definition file for project dla framework
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  wmdrmdla.dll
+TARGETTYPE              dll
+UID                     0x1000008D 0x20019573
+
+CAPABILITY              CAP_GENERAL_DLL
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  wmdrmdlahandler.cpp
+SOURCE                  wmdrmdlahandlerimpl.cpp
+SOURCE                  wmdrmdlauinotifier.cpp
+SOURCE                  wmdrmdlauinotifierimpl.cpp
+SOURCE                  wmdrmdlarequest.cpp 
+SOURCE					wmdrmdlahttplicacqpluginfw.cpp
+SOURCE					wmdrmdlahttpmeteringpluginfw.cpp
+SOURCE					wmdrmdlaparser.cpp
+SOURCE					wmdrmdlaplugincontainer.cpp
+SOURCE					wmdrmdlahttpfwpluginresolver.cpp
+
+USERINCLUDE             ../inc
+USERINCLUDE				../../wmdrmdlautils/inc
+USERINCLUDE			    ../../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE           /epoc32/include/ecom
+
+LIBRARY                 euser.lib
+LIBRARY					efsrv.lib
+LIBRARY         		flogger.lib
+LIBRARY					avkon.lib
+LIBRARY					aknicon.lib
+LIBRARY					egul.lib
+LIBRARY		            ecom.lib
+LIBRARY                 bafl.lib 
+LIBRARY					xmlframework.lib
+LIBRARY         		charconv.lib
+LIBRARY					wmdrmdlautils.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/inc/wmdrmdlahandler.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,171 @@
+/*
+* 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:  Interface class for WMDRM DLA functionality
+*
+*/
+
+
+#ifndef C_WMDRMDLAHANDLER_H
+#define C_WMDRMDLAHANDLER_H
+
+#include <e32base.h>
+#include <f32file.h>
+
+class CWmDrmDlaHandlerImpl;
+
+/**
+ *  WMDRM DLA Interface
+ *
+ *  @lib wmdrmdla.lib
+ *  @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaHandler ) : public CBase
+    {
+
+public:
+
+    IMPORT_C static CWmDrmDlaHandler* NewL();
+    IMPORT_C static CWmDrmDlaHandler* NewLC();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CWmDrmDlaHandler();
+
+    /**
+     * Checks if license acquisition for file is silent
+     *
+     * @param   aFile wmdrm file
+     * @return  ETrue if license acquisition is silent
+     * @leave   KErrNotFound if there is no handler for the file
+     */
+    IMPORT_C TBool SilentL( const RFile& aFile );
+
+    /**
+     * Acquire license based on the file handle
+     *
+     * @param   aFile wmdrm file
+     * @param   aContentUrl contains content URL on return. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aHtmlData contains HTML data returned by license server on
+     *                    return. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @leave   KErrNotFound if there is no handler for the file
+     */
+    IMPORT_C void AcquireLicenseL( const RFile& aFile, HBufC*& aContentUrl, 
+                                   HBufC*& aHtmlData );
+
+    /**
+     * Acquire license based on the file handle, asynchronous version
+     *
+     * @param   aFile wmdrm file
+     * @param   aContentUrl contains content URL on completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aHtmlData contains HTML data returned by license server on 
+     *                    completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aStatus Request status. On completion contains the error code.
+     */
+    IMPORT_C void AcquireLicense( const RFile& aFile, HBufC*& aContentUrl, 
+                                  HBufC*& aHtmlData, TRequestStatus& aStatus );
+
+    /**
+     * Acquire license based on the DRM Header
+     *
+     * @param   aDrmHeader DRM Header
+     * @param   aErrorUrl   URL where error code is sent. Can be NULL.
+     * @param   aContentUrl contains content URL on return. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aHtmlData contains HTML data returned by license server on 
+     *                    return. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @leave   KErrNotFound if there is no handler for the file
+     */
+    IMPORT_C void AcquireLicenseFromDrmHeaderL( const TDesC8& aDrmHeader,
+                                                HBufC* aErrorUrl,
+                                                HBufC*& aContentUrl, 
+                                                HBufC*& aHtmlData );
+
+    /**
+     * Acquire license based on the DRM Header, asynchronous version
+     *
+     * @param   aDrmHeader DRM Header
+     * @param   aErrorUrl   URL where error code is sent. Can be NULL.
+     * @param   aContentUrl contains content URL on completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aHtmlData contains HTML data returned by license server on
+     *                    completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aStatus Request status. On completion contains the error code.
+     */
+    IMPORT_C void AcquireLicenseFromDrmHeader( const TDesC8& aDrmHeader, 
+                                               HBufC* aErrorUrl,
+                                               HBufC*& aContentUrl, 
+                                               HBufC*& aHtmlData, 
+                                               TRequestStatus& aStatus );
+
+    /**
+     * Cancels ongoing license acquisition
+     *
+     */
+    IMPORT_C void CancelLicenseAcquisition();
+
+    /**
+     * Handles metering certificate OTA
+     *
+     * @param   aCertificate metering certificate
+     */
+    IMPORT_C void ProcessMeteringCertificateL( const TDesC8& aCertificate );
+
+    /**
+     * Handles metering certificate OTA, asynchronous version
+     *
+     * @param   aCertificate metering certificate
+     * @param   aStatus Request status. On completion contains the error code.
+     */
+    IMPORT_C void ProcessMeteringCertificate( const TDesC8& aCertificate, 
+                                              TRequestStatus& aStatus );
+
+    /**
+     * Cancels ongoing metering
+     *
+     */
+    IMPORT_C void CancelMetering();
+
+    /**
+     * Sets the IAP to be used in the HTTP transactions
+     *
+     * @param   aIapId  Internet Access Point id
+     */
+    IMPORT_C void SetIapId( TInt aIapId );
+
+protected:
+
+private:
+
+    CWmDrmDlaHandler();
+
+    void ConstructL();
+
+private: // data
+
+    /**
+     * Implementation class
+     * Own.
+     */
+    CWmDrmDlaHandlerImpl* iImpl;
+
+    };
+
+#endif // C_WMDRMDLAHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/inc/wmdrmdlahandlerimpl.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,232 @@
+/*
+* 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:  Implementation class for WMDRM DLA Handler
+*
+*/
+
+
+#ifndef C_WMDRMDLAHANDLERIMPL_H
+#define C_WMDRMDLAHANDLERIMPL_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <wmdrmdlatypes.h>
+
+class CWmDrmDlaHttpLicAcqPluginFw;
+class CWmDrmDlaHttpMeteringPluginFw;
+class CWmDrmDlaRequest;
+
+/**
+ *  Implementation class for WMDRM DLA Handler
+ *
+ *  @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaHandlerImpl ) : public CActive
+    {
+
+public:
+
+    static CWmDrmDlaHandlerImpl* NewL();
+    static CWmDrmDlaHandlerImpl* NewLC();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CWmDrmDlaHandlerImpl();
+
+    /**
+     * Checks if license acquisition for file is silent
+     *
+     * @param   aFile wmdrm file
+     * @return  ETrue if license acquisition is silent
+     * @leave   KErrNotFound if there is no handler for the file
+     */
+    TBool SilentL( const RFile& aFile );
+
+    /**
+     * Acquire license based on the file handle
+     *
+     * @param   aFile wmdrm file
+     * @param   aContentUrl contains content URL on return. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aHtmlData contains HTML data returned by license server
+     *                    on return. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     */
+    void AcquireLicenseL( const RFile& aFile, HBufC*& aContentUrl, 
+                          HBufC*& aHtmlData );
+
+    /**
+     * Acquire license based on the file handle, asynchronous version
+     *
+     * @param   aFile wmdrm file
+     * @param   aContentUrl contains content URL on completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aHtmlData contains HTML data returned by license server
+     *                    on completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aStatus Request status. On completion contains the error code.
+     */
+    void AcquireLicense( const RFile& aFile, HBufC*& aContentUrl, 
+                         HBufC*& aHtmlData, TRequestStatus& aStatus );
+
+    /**
+     * Acquire license based on the DRM Header
+     *
+     * @param   aDrmHeader DRM Header
+     * @param   aErrorUrl URL where error code is sent. Can be NULL.
+     * @param   aContentUrl contains content URL on return. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aHtmlData contains HTML data returned by license server
+     *                    on return. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     */
+    void AcquireLicenseFromDrmHeaderL( const TDesC8& aDrmHeader, 
+                                       HBufC* aErrorUrl,
+                                       HBufC*& aContentUrl, 
+                                       HBufC*& aHtmlData );
+
+    /**
+     * Acquire license based on the DRM Header, asynchronous version
+     *
+     * @param   aDrmHeader DRM Header
+     * @param   aErrorUrl URL where error code is sent. Can be NULL.
+     * @param   aContentUrl contains content URL on completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aHtmlData contains HTML data returned by license server
+     *                    on completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aStatus Request status. On completion contains the error code.
+     */
+    void AcquireLicenseFromDrmHeader( const TDesC8& aDrmHeader, 
+                                      HBufC* aErrorUrl,
+                                      HBufC*& aContentUrl, 
+                                      HBufC*& aHtmlData, 
+                                      TRequestStatus& aStatus );
+
+    /*
+     * Cancels current and all queued license acquisition requests
+     */
+    void CancelLicenseAcquisition();
+    
+    /**
+     * Handles metering certificate OTA
+     *
+     * @param   aCertificate metering certificate
+     */
+    void ProcessMeteringCertificateL( const TDesC8& aCertificate );
+
+    /**
+     * Handles metering certificate OTA, asynchronous version
+     *
+     * @param   aCertificate metering certificate
+     * @param   aStatus Request status. On completion contains the error code.
+     */
+    void ProcessMeteringCertificate( const TDesC8& aCertificate, 
+                                     TRequestStatus& aStatus );
+
+    /*
+     * Cancels current and all queued metering requests
+     */
+    void CancelMetering();
+    
+    /**
+     * Sets the IAP to be used in the HTTP transactions
+     *
+     * @param   aIapId  Internet Access Point id
+     */
+    void SetIapId( TInt aIapId );
+    
+protected: // from base class CActive
+
+    /**
+    * From CActive Cancels async request.
+    */
+    void DoCancel();
+
+    /**
+    * From CActive Called when async request completes.
+    */
+    void RunL();
+
+    /**
+    * From CActive Called if RunL leaves.
+    */
+    TInt RunError( TInt aError );
+
+private:
+
+    CWmDrmDlaHandlerImpl();
+    void ConstructL();
+
+    void CompleteSelf();
+    void CompleteClientRequest( TInt aError );
+    void CompleteSyncRequest( TInt aError );
+    
+    /*
+     * Takes next request to handling.
+     * If synchronous request is available, it will be handled first.
+     * Otherwise next async request is taken from the queue and handled.
+     * If there aren't any requests, state is set to idle
+     */
+    void NextRequest();
+    
+    //State handlers
+    
+    /*
+     * Completes current request and retrieves next one, 
+     * if available, to handling
+     */
+    void Completed( TInt aError );
+	
+    /*
+     * Makes asynchronous call to CWmDrmDlaHttpPluginFw to 
+     * acquire license from drm header
+     */
+    void AcquiringLicenseFromDrmHeader();
+    
+    /*
+     * Makes asynchronous call to CWmDrmDlaHttpPluginFw to
+     * acquire license from file
+     */
+    void AcquiringLicense();
+    
+    /*
+     * Makes asynchronous call to CWmDrmDlaHttpPluginFw to
+     * process metering certificate
+     */
+    void ProcessingMeteringCertificate();
+    
+private: // data
+
+    enum TDlaHandlerState
+        {
+        EIdle,
+        EAcquiringLicense,
+        EAcquiringLicenseFromDrmHeader,
+        EProcessingMeteringCertificate,
+        ECompleted
+        };
+
+    TDlaHandlerState iState;
+    CWmDrmDlaHttpLicAcqPluginFw* iLicenseAcquisitionFw;
+    CWmDrmDlaHttpMeteringPluginFw* iMeteringFw;
+    RPointerArray<CWmDrmDlaRequest> iRequests;
+    CWmDrmDlaRequest* iCurrentRequest;
+    CWmDrmDlaRequest* iSyncRequest;
+    TInt iSyncReturnValue;
+    CActiveSchedulerWait* iWait;
+    };
+
+#endif // C_WMDRMDLAHANDLERIMPL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/inc/wmdrmdlahttpfwpluginresolver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,109 @@
+/*
+* 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:  Interface class for WMDRM DLA HTTP FW plugin resolver
+*
+*/
+
+
+#ifndef WMDRMDLAHTTPFWPLUGINRESOLVER_H
+#define WMDRMDLAHTTPFWPLUGINRESOLVER_H
+
+#include <e32base.h>
+#include <implementationinformation.h>
+
+class CWmDrmDlaPluginContainer;
+class CAknIconArray;
+
+/**
+ *  WMDRM DLA HTTP FW Plugin resolver interface
+ *
+ *  @lib wmdrmdla.lib
+ *  @since S60 v9.1
+ */
+class WmDrmDlaHttpFwPluginResolver
+    {
+
+public:
+
+    /**
+     * Resolves HTTP plugin for the WMDRM file
+     *
+     * @param   aFile WMDRM file
+     * @param   aHttpPlugin Contains resolved HTTP Plugin on return. 
+     * @param   aUiNotifier Contains initialized UiNotifier on return. 
+     *                      Can be NULL
+     * @leave   KErrNotFound if there is no handler for the file
+     */
+    static void ResolveHttpPluginL( const RFile& aFile, 
+                                    CWmDrmDlaHttpPluginIf*& aHttpPlugin,
+                                    CWmDrmDlaUiNotifier*& aUiNotifier );
+    
+    /**
+     * Resolves HTTP plugin for the DRM header
+     *
+     * @param   aDrmHeader DRM header
+     * @param   aHttpPlugin Contains resolved HTTP Plugin on return. 
+     * @param   aUiNotifier Contains initialized UiNotifier on return. 
+     *                      Can be NULL
+     * @leave   KErrNotFound if there is no handler for the header
+     */
+    static void ResolveHttpPluginL( const TDesC8& aDrmHeader, 
+                                    CWmDrmDlaHttpPluginIf*& aHttpPlugin,
+                                    CWmDrmDlaUiNotifier*& aUiNotifier );
+    
+    /**
+     * Resolves HTTP plugin for the metering certificate
+     *
+     * @param   aCertificate Metering certificate
+     * @param   aHttpPlugin Contains resolved HTTP Plugin on return. 
+     * @param   aUiNotifier Contains initialized UiNotifier on return. 
+     *                      Can be NULL
+     * @leave   KErrNotFound if there is no handler for the certificate
+     */
+    static void ResolveHttpPluginWithCertificateL( 
+                        const TDesC8& aCertificate,
+                        CWmDrmDlaHttpPluginIf*& aHttpPlugin, 
+                        CWmDrmDlaUiNotifier*& aUiNotifier );
+
+private:
+
+    /**
+     * Selects HTTP plugin from supported plugins. Will query from the user
+     * which plugin to use, if more that one plugin supports the current content.
+     *
+     * @param   aSupportedPluginArray Array of supported plugins
+     * @param   aImplArray Array of plugins that implement WMDRM DLA HTTP
+     *                     plugin interface
+     * @param   aHttpPlugin Contains resolved HTTP Plugin on return. 
+     * @param   aUiNotifier Contains initialized UiNotifier on return. 
+     *                      Can be NULL
+     * @leave   KErrNotFound if there isn't any plugins
+     */
+    static void SelectPluginL( 
+                RPointerArray<CWmDrmDlaPluginContainer>& aSupportedPluginArray,
+                RImplInfoPtrArray& aImplArray,
+                CWmDrmDlaHttpPluginIf*& aHttpPlugin, 
+                CWmDrmDlaUiNotifier*& aUiNotifier );
+    
+    /**
+     * Loads the default icon and appends it to the icon array
+     *
+     * @param   aIconArray Array where loaded default icon is appended
+     * @leave   Standard Symbian error code
+     */
+    static void DefaultIconL( CAknIconArray*& aIconArray );
+    
+    };
+
+#endif // WMDRMDLAHTTPFWPLUGINRESOLVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/inc/wmdrmdlahttplicacqpluginfw.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,204 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HTTP plugin framework interface for WMDRM DLA
+*
+*/
+
+
+#ifndef C_WMDRMDLAHTTPLICACQPLUGINFW_H
+#define C_WMDRMDLAHTTPLICACQPLUGINFW_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <wmdrmdlatypes.h>
+#include <wmdrmdlacancelobserver.h>
+
+class CWmDrmDlaHttpPluginIf;
+class CWmDrmDlaUiNotifier;
+class CWmDrmDlaParser;
+
+/**
+ *  Implementation class for WMDRM DLA HTTP License Acquisition FW
+ *  @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaHttpLicAcqPluginFw ) 
+    : public CActive, public MWmDrmDlaCancelObserver
+    {
+
+public:
+
+    static CWmDrmDlaHttpLicAcqPluginFw* NewL();
+    static CWmDrmDlaHttpLicAcqPluginFw* NewLC();    
+
+    /**
+    * Destructor.
+    */
+    virtual ~CWmDrmDlaHttpLicAcqPluginFw();
+
+    /**
+     * Checks if license acquisition for file is silent
+     *
+     * @param   aFile wmdrm file
+     * @return  ETrue if license acquisition is silent
+     * @leave   KErrNotFound if there is no handler for the file
+     */
+    TBool SilentL( const RFile& aFile );
+
+    /**
+     * Acquire license for given WMDRM file
+     *
+     * @param   aFile wmdrm file
+     * @param   aContentUrl contains content URL on completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aHtmlData contains HTML data returned by license server
+     *                    on completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aStatus Request status. On completion contains the error code.
+     */
+    void AcquireLicense( const RFile& aFile, HBufC*& aContentUrl, 
+                         HBufC*& aHtmlData, TRequestStatus& aStatus );
+
+    /**
+     * Acquire license based on DRM Header
+     *
+     * @param   aDrmHeader DRM Header
+     * @param   aErrorUrl URL where error code is sent. Can be NULL.
+     * @param   aContentUrl contains content URL on completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aHtmlData contains HTML data returned by license server
+     *                    on completion. Can be NULL.
+     * If it's not NULL, it must be freed by caller.  
+     * @param   aStatus Request status. On completion contains the error code.
+     */
+    void AcquireLicenseFromDrmHeader( const TDesC8& aDrmHeader, 
+                                      HBufC* aErrorUrl,
+                                      HBufC*& aContentUrl, 
+                                      HBufC*& aHtmlData, 
+                                      TRequestStatus& aStatus );
+
+    /*
+     * Cancels license acquisition
+     */
+    void CancelLicenseAcquisition();
+    
+    /**
+     * Sets the IAP to be used in the HTTP transactions
+     *
+     * @param   aIapId  Internet Access Point id
+     */
+    void SetIapId( TInt aIapId );
+
+protected:
+
+    // from base class CActive
+
+    /**
+    * From CActive Cancels async request.
+    */
+    void DoCancel();
+
+    /**
+    * From CActive Called when async request completes.
+    */
+    void RunL();
+    
+    /**
+    * From CActive Called if RunL leaves.
+    */
+    TInt RunError( TInt aError );
+
+public: // from MWmDrmDlaCancelObserver
+    
+    void UserCancellation();
+    
+private:
+
+    CWmDrmDlaHttpLicAcqPluginFw();
+    void ConstructL();
+    
+    void CompleteSelf();
+    void CompleteClientRequest( TInt aError );
+    void Reset();
+    
+    TBool SilentHandlerL( const RFile& aFile );
+    void ResolvingHttpPluginFromDRMHeaderHandlerL();
+    void ResolvingHttpPluginFromFileHandleHandlerL();
+    void RetrievingDRMHeaderFromFileHandleHandler();
+    void ProcessingDRMHeaderHandler();
+    void SendingDRMHeaderErrorHandler( TInt aError );
+    void SentDRMHeaderErrorHandlerL();
+    void RetrievingChallengeHandler();
+    void RetrievingLicenseHandler();
+    void AddingLicenseHandlerL();
+    void ProcessingLicenseHandler();
+    void SendingLicenseStorageStatusHandler();
+    void SentLicenseStorageStatusHandler();
+    void LicensingCompleteL();
+    
+    void ResolveHttpPluginL( const RFile& aFile );
+    void ResolveHttpPluginL( const TDesC8& aDrmHeader );
+    
+    void ParseDrmHeaderL( const TDesC8& aDrmHeader, 
+                          HBufC*& aLicenseServerUrl );
+    void ParseLicenseResponseL( const TDesC8& aLicenseResponse, 
+                                HBufC8*& aTid, HBufC*& aContentUrl );
+    
+    void HandleErrorL( TInt aError );
+    
+    static TInt AsyncCancel( TAny* aPtr );
+
+private: // data
+
+    enum THttpLicAcqPluginFwState
+        {
+        EIdle = 0,
+        EResolvingHttpPluginFromDRMHeader,
+        EResolvingHttpPluginFromFileHandle,
+        ERetrievingDRMHeaderFromFileHandle,
+        EProcessingDRMHeader,
+        ESentDRMHeaderError,
+        ERetrievingChallenge,
+        ERetrievingLicense,
+        EAddingLicense,
+        EProcessingLicense,
+        ESendingLicenseStorageStatus,
+        ESentLicenseStorageStatus,
+        ELicensingComplete
+        };
+
+    THttpLicAcqPluginFwState iState;
+    CWmDrmDlaHttpPluginIf* iHttpPlugin;
+    CWmDrmDlaUiNotifier* iUiNotifier;
+    CWmDrmDlaParser* iDlaParser;
+    CActiveSchedulerWait* iWait;
+    CIdle* iIdle;
+    TInt iIapId;
+    TBool iSilentInitialised;
+    
+    HBufC8* iDrmHeader;
+    HBufC* iLicenseServerUrl;
+    HBufC8* iLicenseChallenge;
+    HBufC8* iLicenseResponse;
+    
+    //Not owned
+    HBufC* iErrorUrl;
+    const RFile* iFile;
+    HBufC** iContentUrl;
+    HBufC** iHtmlData;
+    TRequestStatus* iClientStatus;
+    
+    };
+
+
+#endif // C_WMDRMDLAHTTPLICACQPLUGINFW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/inc/wmdrmdlahttpmeteringpluginfw.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,144 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  HTTP plugin framework interface for WMDRM DLA
+*
+*/
+
+
+#ifndef C_WMDRMDLAHTTPMETERINGPLUGINFW_H
+#define C_WMDRMDLAHTTPMETERINGPLUGINFW_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include <wmdrmdlatypes.h>
+#include <wmdrmdlacancelobserver.h>
+
+class CWmDrmDlaHttpPluginIf;
+class CWmDrmDlaUiNotifier;
+
+/**
+ *  Implementation class for WMDRM DLA HTTP Metering FW
+ *  @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaHttpMeteringPluginFw ) 
+    : public CActive, public MWmDrmDlaCancelObserver
+    {
+
+public:
+
+    static CWmDrmDlaHttpMeteringPluginFw* NewL();
+    static CWmDrmDlaHttpMeteringPluginFw* NewLC();    
+
+    /**
+    * Destructor.
+    */
+    virtual ~CWmDrmDlaHttpMeteringPluginFw();
+
+    /**
+     * Handles metering certificate OTA
+     *
+     * @param   aCertificate metering certificate
+     * @param   aStatus Request status. On completion contains the error code.
+     */
+    void ProcessMeteringCertificate( const TDesC8& aCertificate, 
+                                     TRequestStatus& aStatus );
+
+    /*
+     * Cancels metering
+     */
+    void CancelMetering();
+    
+    /**
+     * Sets the IAP to be used in the HTTP transactions
+     *
+     * @param   aIapId  Internet Access Point id
+     */
+    void SetIapId( TInt aIapId );
+
+protected:
+
+    // from base class CActive
+
+    /**
+    * From CActive Cancels async request.
+    */
+    void DoCancel();
+
+    /**
+    * From CActive Called when async request completes.
+    */
+    void RunL();
+    
+    /**
+    * From CActive Called if RunL leaves.
+    */
+    TInt RunError( TInt aError );
+
+public: // from MWmDrmDlaCancelObserver
+    
+    void UserCancellation();    
+    
+private:
+
+    CWmDrmDlaHttpMeteringPluginFw();
+    void ConstructL();
+    
+    void CompleteSelf();
+    void CompleteClientRequest( TInt aError );
+    void Reset();
+    
+    void ResolvingHttpPluginHandlerL();
+    void RetrievingMeteringChallenge();
+    void ProcessingMeteringChallenge();
+    void RetrievingMeteringResponse();
+    void ProcessingMeteringResponse();
+    void MeteringFinished();
+    
+    void ResolveHttpPluginWithCertificateL( const TDesC8& aCertificate );
+    void HandleErrorL( TInt aError );
+
+    static TInt AsyncCancel( TAny* aPtr );
+
+private: // data
+
+    enum THttpMeteringPluginFwState
+        {
+        EIdle = 0,
+        EResolvingHttpPlugin,
+        ERetrievingMeteringChallenge,
+        EProcessingMeteringChallenge,
+        ERetrievingMeteringResponse,
+        EProcessingMeteringResponse,
+        EMeteringFinished
+        };
+
+    THttpMeteringPluginFwState iState;
+    CWmDrmDlaHttpPluginIf* iHttpPlugin;
+    CWmDrmDlaUiNotifier* iUiNotifier;
+    CIdle* iIdle;
+    TInt iIapId;
+    
+    HBufC8* iMeteringChallenge;
+    HBufC* iMeteringUrl;
+    HBufC8* iMeteringResponse;
+    TUint32 iPartialMetering;
+    
+    //Not owned
+    const TDesC8* iCertificate;
+    TRequestStatus* iClientStatus;
+    
+    };
+
+
+#endif // C_WMDRMDLAHTTPMETERINGPLUGINFW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/inc/wmdrmdlaparser.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  DRM Header and License Response Parser
+*
+*/
+
+
+#ifndef C_WMDRMDLAPARSER_H
+#define C_WMDRMDLAPARSER_H
+
+// INCLUDES
+#include <xml/contenthandler.h>
+#include <xml/parser.h>
+
+/**
+*  CWmDrmDlaParser
+*  DRM Header and License Response Parser for the WMDRM DLA
+*
+*  @lib wmdrmdla.dll
+*  @since 9.1
+*/
+NONSHARABLE_CLASS( CWmDrmDlaParser ) 
+    : public CBase, public Xml::MContentHandler
+    {
+    public:
+        /**
+         * Two-phased constructor.
+         * @return address of an instance of this class
+         */
+        static CWmDrmDlaParser* NewL();
+
+        /**
+         * Destructor.
+         */
+        virtual ~CWmDrmDlaParser();
+
+        /**
+         * Extract the TID and content URL from the license response
+         * @param aLicenseResponse The license response to parse
+         * @param aTID The TID that was extracted and returned. 
+         *             If no TID found the parameter is set to NULL
+         * @param aContentUrl The content URL that was extracted and returned. 
+         *                    If no content URL found the parameter is set to NULL
+         */
+        TInt ProcessLicenseResponse( const TDesC8& aLicenseResponse, 
+                                     HBufC8*& aTID, HBufC8*& aContentURL );
+        /**
+         * Extract the server Url from the DRM Heasder
+         * @param aDrmHeader The DRM Header to parse
+         * @param aServerUrl The server URL that was extracted and returned. 
+         *                   If no server URL found the parameter is set to NULL
+         */
+        TInt GetLicenseServerURLFromDRMHeader( const TDesC8& aDrmHeader, 
+                                               HBufC8*& aServerURL );
+
+    private:  // From Xml::MContentHandler
+        virtual void OnStartDocumentL( const Xml::RDocumentParameters& aDocParam, 
+                                       TInt aErrorCode );
+        virtual void OnEndDocumentL( TInt aErrorCode );
+        virtual void OnStartElementL( const Xml::RTagInfo& aElement, 
+                                      const Xml::RAttributeArray& aAttributes,
+                                      TInt aErrorCode );
+        virtual void OnEndElementL( const Xml::RTagInfo& aElement, TInt aErrorCode);
+        virtual void OnContentL( const TDesC8& aBytes, TInt aErrorCode);
+        virtual void OnStartPrefixMappingL( const RString& aPrefix, 
+                                            const RString& aUri, TInt aErrorCode );
+        virtual void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode);
+        virtual void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode);
+        virtual void OnSkippedEntityL( const RString& aName, TInt aErrorCode );
+        virtual void OnProcessingInstructionL( const TDesC8& aTarget, 
+                                               const TDesC8& aData, TInt aErrorCode );
+        virtual void OnError( TInt aErrorCode );
+        virtual TAny* GetExtendedInterface( const TInt32 aUid );
+
+    private:
+        /**
+         * Constructor
+         */
+        CWmDrmDlaParser();
+        /**
+         * Symbian OS 2nd phase constructor.
+         */
+        void ConstructL();
+
+    private:
+        // This member is used when parsing a DRM Header and is not owned by this class 
+        // and should NOT be deleted
+        // If this memebers is filled when parsing a license response it WILL be deleted
+        HBufC8**      iServerUrl;
+
+        // These members are used when parsing a license response and are owned by this 
+        // class and should NOT be deleted
+        // If these memebers are filled when parsing a DRM Header they WILL be deleted
+        HBufC8**      iContentUrl;
+        HBufC8**      iTID;
+
+        // These members are owned by this class and should be deleted
+        Xml::CParser* iParser;
+        HBufC8*       iBuffer;
+        
+        TInt          iErrorCode;
+    };
+
+#endif // C_WMDRMDLAPARSER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/inc/wmdrmdlaplugincontainer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,72 @@
+/*
+* 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:  Interface class for WMDRM DLA plugin container
+*
+*/
+
+
+#ifndef C_WMDRMDLAPLUGINCONTAINER_H
+#define C_WMDRMDLAPLUGINCONTAINER_H
+
+#include <e32base.h>
+
+class CWmDrmDlaHttpPluginIf;
+class CWmDrmDlaUiNotifier;
+
+/**
+ *  WMDRM DLA Plugin Container interface
+ *
+ *  @lib wmdrmdla.lib
+ *  @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaPluginContainer ) : public CBase
+    {
+
+public:
+
+    static CWmDrmDlaPluginContainer* NewL();
+    static CWmDrmDlaPluginContainer* NewLC();
+
+    /**
+    * Destructor.
+    */
+    virtual ~CWmDrmDlaPluginContainer();
+    
+    void SetHttpPlugin( CWmDrmDlaHttpPluginIf* aHttpPlugin );
+    void GetHttpPlugin( CWmDrmDlaHttpPluginIf*& aHttpPlugin );
+    CWmDrmDlaHttpPluginIf* HttpPlugin();
+    
+    void SetUiNotifier( CWmDrmDlaUiNotifier* aUiNotifier );
+    void GetUiNotifier( CWmDrmDlaUiNotifier*& aUiNotifier );
+    
+    void SetIndex( TInt aIndex );
+    TInt Index();
+
+protected:
+
+private:
+
+    CWmDrmDlaPluginContainer();
+
+    void ConstructL();
+
+private: // data
+
+    CWmDrmDlaHttpPluginIf* iHttpPlugin;
+    CWmDrmDlaUiNotifier* iUiNotifier;
+    TInt iIndex;
+    
+    };
+
+#endif // C_WMDRMDLAPLUGINCONTAINER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/inc/wmdrmdlarequest.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Defines the request container class
+*
+*/
+
+
+#ifndef WMDRMDLAREQUEST_H
+#define WMDRMDLAREQUEST_H
+
+// INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+
+/**
+* CWmDrmDlaRequest
+*
+*  @lib wmdrmdla.dll
+*  @since 9.1
+*/
+NONSHARABLE_CLASS( CWmDrmDlaRequest ) : public CBase
+    {
+    
+    public:
+        
+        enum TRequestType
+            {
+            EAcquireLicenseFromDrmHeader,
+            EAcquireLicenseFromFileHandle,
+            EProcessMeteringCertificate
+            };
+
+        //License Pre-delivery
+        static CWmDrmDlaRequest* NewL( const TDesC8& aDrmHeader,  HBufC* aErrorUrl,
+                                       HBufC*& aContentUrl, HBufC*& aHtmlData, 
+                                       TBool aSync, TRequestStatus& aStatus );
+        
+        //License Post-delivery
+        static CWmDrmDlaRequest* NewL( const RFile& aFileHandle, HBufC*& aContentUrl, 
+                                       HBufC*& aHtmlData, TBool aSync, 
+                                       TRequestStatus& aStatus );
+        
+        //Metering
+        static CWmDrmDlaRequest* NewL( const TDesC8& aCertificate, TBool aSync, 
+                                       TRequestStatus& aStatus );
+
+        virtual ~CWmDrmDlaRequest();
+    
+    private:
+        
+        CWmDrmDlaRequest();
+
+        //License Pre-delivery
+        void ConstructL( const TDesC8& aDrmHeader, HBufC* aErrorUrl,
+                         HBufC*& aContentUrl, HBufC*& aHtmlData, 
+                         TBool aSync, TRequestStatus& aStatus );
+        
+        //License Post-delivery
+        void ConstructL( const RFile& aFileHandle, HBufC*& aContentUrl, 
+                         HBufC*& aHtmlData, TBool aSync, 
+                         TRequestStatus& aStatus );
+        
+        //Metering
+        void ConstructL( const TDesC8& aCertificate, TBool aSync, 
+                         TRequestStatus& aStatus );
+        
+    public:
+		
+        TRequestType iType;
+        TBool iSync;
+        
+		//Not owned
+        const TDesC8* iDrmHeader;
+        const TDesC8* iCertificate;
+        const RFile* iFileHandle;
+        TRequestStatus* iStatus;
+        HBufC* iErrorUrl;
+        HBufC** iContentUrl;
+		HBufC** iHtmlData;
+		
+    };
+
+#endif  // WMDRMDLAREQUEST_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/inc/wmdrmdlauinotifierimpl.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,109 @@
+/*
+* 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:  Interface to send notifications from http plugin ui plugin
+*
+*/
+
+
+#ifndef C_WMDRMDLAUINOTIFIERIMPL_H
+#define C_WMDRMDLAUINOTIFIERIMPL_H
+
+#include <e32base.h>
+#include <wmdrmdlatypes.h>
+#include <wmdrmdlacancelobserver.h>
+
+class CWmDrmDlaUiPluginIf;
+
+/**
+ *  WMDRM DLA UiNotifier Impl
+ * 
+ *  @lib wmdrmdla.lib
+ *  @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaUiNotifierImpl ) : public CBase
+    {
+
+public:
+
+    static CWmDrmDlaUiNotifierImpl* NewL();
+    static CWmDrmDlaUiNotifierImpl* NewLC();    
+
+    /**
+    * Destructor.
+    */
+    virtual ~CWmDrmDlaUiNotifierImpl();
+
+    /**
+     * Selects UI plugin based on UID
+     *
+     * @param aUid Uid of the plugin implementation
+     * @leave KErrNotFound if corresponding plugin is not found
+     */
+    void InitializeL( TUid aUid );
+
+    /**
+     * Selects UI plugin based on data
+     * If corresponding plugin is not be found, tries to initialize default
+     * plugin
+     *
+     * @param aOpaqueData Opaque data of the plugin implementation
+     * @leave KErrNotFound if corresponding and default plugin is not found
+     */
+    void InitializeL( TDesC8& aOpaqueData );
+
+    /**
+     * Called by the framework to set cancel observer. UI plugin can use this
+     * to inform framework about user cancelling DLA process from UI component.
+     * 
+     * @param aObserver Cancellation observer
+     */
+    void SetCancelObserver( MWmDrmDlaCancelObserver* aObserver );
+    
+    /**
+     * Informs that license acquisition is silent
+     *
+     * @param aSilent Is license acquisition silent
+     */
+    void SetSilent( TBool aSilent );
+
+    /**
+     * Passes progress information of license acquisition to UI
+     *
+     * @param aState License acquisition progress state
+     * @see wmdrmdlatypes.h
+     */
+    void SetProgress( TInt aState );
+
+    /**
+     * Informs that error happened during the license acquisition
+     *
+     * @param aError Error code
+     */
+    void HandleErrorL( TInt aError );
+
+protected:
+
+private:
+
+    CWmDrmDlaUiNotifierImpl();
+
+    void ConstructL();
+
+private: // data
+
+    CWmDrmDlaUiPluginIf* iUiPlugin;
+
+    };
+
+#endif // C_WMDRMDLAUINOTIFIERIMPL_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/src/wmdrmdlahandler.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,188 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation class for WMDRM DLA functionality
+*
+*/
+
+
+#include "wmdrmdlahandler.h"
+#include "wmdrmdlahandlerimpl.h"
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandler::ConstructL()
+    {
+    iImpl = CWmDrmDlaHandlerImpl::NewL();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::CWmDrmDlaHandler
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHandler::CWmDrmDlaHandler()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::NewL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CWmDrmDlaHandler* CWmDrmDlaHandler::NewL()
+    {
+    CWmDrmDlaHandler* self = CWmDrmDlaHandler::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::NewLC
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CWmDrmDlaHandler* CWmDrmDlaHandler::NewLC()
+    {
+    CWmDrmDlaHandler* self = new( ELeave ) CWmDrmDlaHandler;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::~CWmDrmDlaHandler
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHandler::~CWmDrmDlaHandler()
+    {
+    delete iImpl;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::SilentL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TBool CWmDrmDlaHandler::SilentL( 
+    const RFile& aFile )
+    {
+    return iImpl->SilentL( aFile );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::AcquireLicenseL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaHandler::AcquireLicenseL( 
+    const RFile& aFile, 
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData )
+    {
+    iImpl->AcquireLicenseL( aFile, aContentUrl, aHtmlData );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::AcquireLicense
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaHandler::AcquireLicense( 
+    const RFile& aFile, 
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData, 
+    TRequestStatus& aStatus )
+    {
+    iImpl->AcquireLicense( aFile, aContentUrl, aHtmlData, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::AcquireLicenseFromDrmHeaderL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaHandler::AcquireLicenseFromDrmHeaderL( 
+    const TDesC8& aDrmHeader,
+    HBufC* aErrorUrl,
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData )
+    {
+    iImpl->AcquireLicenseFromDrmHeaderL( aDrmHeader, aErrorUrl, 
+                                         aContentUrl, aHtmlData );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::AcquireLicenseFromDrmHeader
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaHandler::AcquireLicenseFromDrmHeader( 
+    const TDesC8& aDrmHeader,
+    HBufC* aErrorUrl,
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData, 
+    TRequestStatus& aStatus )
+    {
+    iImpl->AcquireLicenseFromDrmHeader( aDrmHeader, aErrorUrl, 
+                                        aContentUrl, aHtmlData, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::CancelLicenseAcquisition
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaHandler::CancelLicenseAcquisition()
+    {
+    iImpl->CancelLicenseAcquisition();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::ProcessMeteringCertificateL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaHandler::ProcessMeteringCertificateL( 
+    const TDesC8& aCertificate )
+    {
+    iImpl->ProcessMeteringCertificateL( aCertificate );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::ProcessMeteringCertificate
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaHandler::ProcessMeteringCertificate( 
+    const TDesC8& aCertificate, 
+    TRequestStatus& aStatus )
+    {
+    iImpl->ProcessMeteringCertificate( aCertificate, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::CancelMetering
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaHandler::CancelMetering()
+    {
+    iImpl->CancelMetering();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandler::SetIapId
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaHandler::SetIapId( 
+    TInt aIapId )
+    {
+    iImpl->SetIapId( aIapId );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/src/wmdrmdlahandlerimpl.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,677 @@
+/*
+* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation class for WMDRM DLA Handler
+*
+*/
+
+
+#include <ecom/ecom.h>
+#include "wmdrmdlahandlerimpl.h"
+#include "wmdrmdlahttplicacqpluginfw.h"
+#include "wmdrmdlahttpmeteringpluginfw.h"
+#include "wmdrmdlarequest.h"
+
+#define _LOGGING_FILE L"wmdrmdla.txt"
+#include "logfn.h"
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::ConstructL" );
+    iLicenseAcquisitionFw = CWmDrmDlaHttpLicAcqPluginFw::NewL();
+    iMeteringFw = CWmDrmDlaHttpMeteringPluginFw::NewL();
+    iWait = new (ELeave) CActiveSchedulerWait;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::CWmDrmDlaHandlerImpl
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHandlerImpl::CWmDrmDlaHandlerImpl() 
+    : CActive( EPriorityStandard ), iState( CWmDrmDlaHandlerImpl::EIdle )
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::CWmDrmDlaHandlerImpl" );
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHandlerImpl* CWmDrmDlaHandlerImpl::NewL()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::NewL" );
+    CWmDrmDlaHandlerImpl* self = CWmDrmDlaHandlerImpl::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::NewLC
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHandlerImpl* CWmDrmDlaHandlerImpl::NewLC()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::NewLC" );
+    CWmDrmDlaHandlerImpl* self = new( ELeave ) CWmDrmDlaHandlerImpl;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::~CWmDrmDlaHandlerImpl
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHandlerImpl::~CWmDrmDlaHandlerImpl()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::~CWmDrmDlaHandlerImpl" );
+    CancelLicenseAcquisition();
+    CancelMetering();
+    iRequests.ResetAndDestroy();
+    iRequests.Close();
+    delete iCurrentRequest;
+    delete iSyncRequest;
+    delete iLicenseAcquisitionFw;
+    delete iMeteringFw;
+    delete iWait;
+    REComSession::FinalClose();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::SilentL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaHandlerImpl::SilentL( 
+    const RFile& aFile )
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::SilentL" );
+    TBool silent( iLicenseAcquisitionFw->SilentL( aFile ) );
+    LOG2( "silent: %d", silent );
+    return silent;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::AcquireLicenseL
+// ---------------------------------------------------------------------------
+///
+void CWmDrmDlaHandlerImpl::AcquireLicenseL( 
+    const RFile& aFile, 
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData )
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::AcquireLicenseL" );
+    if ( iWait->IsStarted() )
+        {
+        User::Leave( KErrInUse );
+        }
+    
+    CWmDrmDlaRequest* request( CWmDrmDlaRequest::NewL( aFile, 
+                                                       aContentUrl, 
+                                                       aHtmlData, 
+                                                       ETrue, 
+                                                       iStatus ) );
+    if ( iState == CWmDrmDlaHandlerImpl::EIdle  )
+        {
+        iCurrentRequest = request;
+        iState = CWmDrmDlaHandlerImpl::EAcquiringLicense;
+        CompleteSelf();
+        }
+    else
+        {
+        iSyncRequest = request;
+        }
+    iWait->Start();
+    LOG2( "iSyncReturnValue: %d", iSyncReturnValue );
+    User::LeaveIfError( iSyncReturnValue );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::AcquireLicense
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::AcquireLicense( 
+    const RFile& aFile, 
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData, 
+    TRequestStatus& aStatus )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaHandlerImpl::AcquireLicense", err );
+    
+    CWmDrmDlaRequest* request( NULL );
+    TRequestStatus *status = &aStatus;
+    aStatus = KRequestPending;
+    
+    TRAP( err, request = CWmDrmDlaRequest::NewL( aFile, 
+                                                 aContentUrl, 
+                                                 aHtmlData, 
+                                                 EFalse, 
+                                                 aStatus ) );
+    if ( err )
+        {
+        User::RequestComplete( status, err );
+        }
+    else if ( iState == CWmDrmDlaHandlerImpl::EIdle  )
+        {
+        iCurrentRequest = request;
+        iState = CWmDrmDlaHandlerImpl::EAcquiringLicense;
+        CompleteSelf();
+        }
+    else
+        {
+        err = iRequests.Append( request );
+        if ( err )
+            {
+            delete request;
+            User::RequestComplete( status, err );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::AcquireLicenseFromDrmHeaderL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::AcquireLicenseFromDrmHeaderL( 
+    const TDesC8& aDrmHeader,
+    HBufC* aErrorUrl,
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData )
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::AcquireLicenseFromDrmHeaderL" );
+    if ( iWait->IsStarted() )
+        {
+        User::Leave( KErrInUse );
+        }
+    
+    CWmDrmDlaRequest* request( CWmDrmDlaRequest::NewL( aDrmHeader,
+                                                       aErrorUrl,
+                                                       aContentUrl, 
+                                                       aHtmlData, 
+                                                       ETrue, 
+                                                       iStatus ) );
+    if ( iState == CWmDrmDlaHandlerImpl::EIdle  )
+        {
+        iCurrentRequest = request;
+        iState = CWmDrmDlaHandlerImpl::EAcquiringLicenseFromDrmHeader;
+        CompleteSelf();
+        }
+    else
+        {
+        iSyncRequest = request;
+        }
+    iWait->Start();
+    LOG2( "iSyncReturnValue: %d", iSyncReturnValue );
+    User::LeaveIfError( iSyncReturnValue );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::AcquireLicenseFromDrmHeader
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::AcquireLicenseFromDrmHeader( 
+    const TDesC8& aDrmHeader, 
+    HBufC* aErrorUrl,
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData, 
+    TRequestStatus& aStatus )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaHandlerImpl::AcquireLicenseFromDrmHeader", err );
+    
+    CWmDrmDlaRequest* request( NULL );
+    TRequestStatus *status = &aStatus;
+    aStatus = KRequestPending;
+    
+    TRAP( err, request = CWmDrmDlaRequest::NewL( aDrmHeader,
+                                                 aErrorUrl,
+                                                 aContentUrl, 
+                                                 aHtmlData, 
+                                                 EFalse, 
+                                                 aStatus ) );
+    if ( err )
+        {
+        User::RequestComplete( status, err );
+        }
+    else if ( iState == CWmDrmDlaHandlerImpl::EIdle  )
+        {
+        iCurrentRequest = request;
+        iState = CWmDrmDlaHandlerImpl::EAcquiringLicenseFromDrmHeader;
+        CompleteSelf();
+        }
+    else
+        {
+        err = iRequests.Append( request );
+        if ( err )
+            {
+            delete request;
+            User::RequestComplete( status, err );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::CancelLicenseAcquisition
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::CancelLicenseAcquisition()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::CancelLicenseAcquisition" );
+    
+    //First check, if we are currently handling license acquisition request.
+    //If we are, then cancel handling and cancel request 
+    if ( iState == CWmDrmDlaHandlerImpl::ECompleted && 
+         iCurrentRequest->iType 
+             != CWmDrmDlaRequest::EProcessMeteringCertificate )
+        {
+        iLicenseAcquisitionFw->CancelLicenseAcquisition();
+        Cancel();
+        CompleteClientRequest( KErrCancel );
+        CompleteSyncRequest( KErrCancel );
+        }
+    else if ( iState == CWmDrmDlaHandlerImpl::EAcquiringLicense || 
+              iState == CWmDrmDlaHandlerImpl::EAcquiringLicenseFromDrmHeader )
+        {
+        Cancel();
+        CompleteClientRequest( KErrCancel );
+        CompleteSyncRequest( KErrCancel );
+        }
+    // Next go through the request queue,
+    // remove all license acquisition requests and cancel them.
+    TInt removed( 0 );
+    for ( TInt i( 0 ); i - removed < iRequests.Count(); ++i )
+        {
+        if ( iRequests[ i - removed ]->iType 
+                != CWmDrmDlaRequest::EProcessMeteringCertificate )
+            {
+            iCurrentRequest = iRequests[ i - removed ];
+            iRequests.Remove( i - removed );
+            ++removed;
+            CompleteClientRequest( KErrCancel );
+            }
+        }
+    if ( !iCurrentRequest )
+        {
+        NextRequest();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::ProcessMeteringCertificateL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::ProcessMeteringCertificateL( 
+    const TDesC8& aCertificate )
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::ProcessMeteringCertificateL" );
+    if ( iWait->IsStarted() )
+        {
+        User::Leave( KErrInUse );
+        }
+    
+    CWmDrmDlaRequest* request( CWmDrmDlaRequest::NewL( aCertificate, 
+                                                       ETrue, 
+                                                       iStatus ) );
+    if ( iState == CWmDrmDlaHandlerImpl::EIdle  )
+        {
+        iCurrentRequest = request;
+        iState = CWmDrmDlaHandlerImpl::EProcessingMeteringCertificate;
+        CompleteSelf();
+        }
+    else
+        {
+        iSyncRequest = request;
+        }
+    iWait->Start();
+    LOG2( "iSyncReturnValue: %d", iSyncReturnValue );
+    User::LeaveIfError( iSyncReturnValue );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::ProcessMeteringCertificate
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::ProcessMeteringCertificate( 
+    const TDesC8& aCertificate,
+    TRequestStatus& aStatus )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaHandlerImpl::ProcessMeteringCertificate", err );
+    
+    CWmDrmDlaRequest* request( NULL );
+    TRequestStatus *status = &aStatus;
+    aStatus = KRequestPending;
+    
+    TRAP( err, request = CWmDrmDlaRequest::NewL( aCertificate, 
+                                                 EFalse, 
+                                                 aStatus ) );
+    if ( err )
+        {
+        User::RequestComplete( status, err );
+        }
+    else if ( iState == CWmDrmDlaHandlerImpl::EIdle  )
+        {
+        iCurrentRequest = request;
+        iState = CWmDrmDlaHandlerImpl::EProcessingMeteringCertificate;
+        CompleteSelf();
+        }
+    else
+        {
+        err = iRequests.Append( request );
+        if ( err )
+            {
+            delete request;
+            User::RequestComplete( status, err );
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::CancelMetering
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::CancelMetering()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::CancelMetering" );
+    
+    //First check, if we are currently handling process metering request.
+    //If we are, then cancel handling and cancel request 
+    if ( iState == CWmDrmDlaHandlerImpl::ECompleted &&
+         iCurrentRequest->iType 
+             == CWmDrmDlaRequest::EProcessMeteringCertificate )
+        {
+        iMeteringFw->CancelMetering();
+        Cancel();
+        CompleteClientRequest( KErrCancel );
+        CompleteSyncRequest( KErrCancel );
+        }
+    else if ( iState == CWmDrmDlaHandlerImpl::EProcessingMeteringCertificate )
+        {
+        Cancel();
+        CompleteClientRequest( KErrCancel );
+        CompleteSyncRequest( KErrCancel );
+        }
+    // Next go through the request queue,
+    // remove all process metering requests and cancel them.
+    TInt removed( 0 );
+    for ( TInt i( 0 ); i - removed < iRequests.Count(); ++i )
+        {
+        if ( iRequests[ i - removed ]->iType 
+                == CWmDrmDlaRequest::EProcessMeteringCertificate )
+            {
+            iCurrentRequest = iRequests[ i - removed ];
+            iRequests.Remove( i - removed );
+            ++removed;
+            CompleteClientRequest( KErrCancel );
+            }
+        }
+    if ( !iCurrentRequest )
+        {
+        NextRequest();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::SetIapId
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::SetIapId( TInt aIapId )
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::SetIapId" );
+    LOG2( "aIapId: %d", aIapId );
+    iLicenseAcquisitionFw->SetIapId( aIapId );
+    iMeteringFw->SetIapId( aIapId );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::DoCancel()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::DoCancel" );
+    //Don't need to do anything, canceling is implemented in
+    //CancelLicenseAcquisiton() and in CancelMetering() -functions
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::RunL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::RunL()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::RunL" );
+    LOG2( "iState: %d", iState );
+    LOG2( "iStatus.Int(): %d", iStatus.Int() );
+    //If some error happened, then set state to completed, in which
+    //the failed client request will be completed with the error code
+    if ( iStatus.Int() )
+        {
+        iState = ECompleted;
+        }
+        
+    switch ( iState )
+	    {
+	    case CWmDrmDlaHandlerImpl::ECompleted:
+	        Completed( iStatus.Int() );
+	        break;
+    	
+    	case CWmDrmDlaHandlerImpl::EAcquiringLicenseFromDrmHeader:
+    	    AcquiringLicenseFromDrmHeader();
+    	    break;
+    	
+    	case CWmDrmDlaHandlerImpl::EAcquiringLicense:
+    	    AcquiringLicense();
+    	    break;
+    	
+    	case CWmDrmDlaHandlerImpl::EProcessingMeteringCertificate:
+    	    ProcessingMeteringCertificate();
+    	    break;
+    	
+    	default:
+            ASSERT( EFalse );
+    	    break;
+    	}
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaHandlerImpl::RunError( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::RunError" );
+    //Shouldn't ever happen, but better to be sure
+    Completed( aError );
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::CompleteSelf
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::CompleteSelf()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::CompleteSelf" );
+    if ( !IsActive() )
+        {
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrNone );
+        SetActive();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::CompleteClientRequest
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::CompleteClientRequest( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::CompleteClientRequest" );
+    LOG2( "aError: %d", aError );
+    if ( iCurrentRequest && !iCurrentRequest->iSync )
+        {
+        User::RequestComplete( iCurrentRequest->iStatus, aError );
+        delete iCurrentRequest;
+        iCurrentRequest = NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::CompleteSyncRequest
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::CompleteSyncRequest( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::CompleteSyncRequest" );
+    LOG2( "aError: %d", aError );
+    if ( iCurrentRequest && iCurrentRequest->iSync )
+        {
+        iSyncReturnValue = aError;
+        delete iCurrentRequest;
+        iCurrentRequest = NULL;
+        if ( iWait->IsStarted() )
+            {
+            iWait->AsyncStop();
+            }
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::NextRequest
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::NextRequest()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::NextRequest" );
+    //If there are queued request, take next one to handling.
+    //Otherwise set state to idle
+    if ( iRequests.Count() > 0 || iSyncRequest )
+        {
+        //synchronous request has higher priority than asynchronous one
+        if ( iSyncRequest )
+            {
+            iCurrentRequest = iSyncRequest;
+            iSyncRequest = NULL;
+            }
+        else
+            {
+            iCurrentRequest = iRequests[0];
+            iRequests.Remove( 0 );
+            }
+        
+        //Switch state to match the current request type
+        switch ( iCurrentRequest->iType )
+            {
+            case CWmDrmDlaRequest::EAcquireLicenseFromDrmHeader:
+                iState = CWmDrmDlaHandlerImpl::EAcquiringLicenseFromDrmHeader;
+                break;
+    
+            case CWmDrmDlaRequest::EAcquireLicenseFromFileHandle:
+                iState = CWmDrmDlaHandlerImpl::EAcquiringLicense;
+                break;
+                
+            case CWmDrmDlaRequest::EProcessMeteringCertificate:
+                iState = CWmDrmDlaHandlerImpl::EProcessingMeteringCertificate;
+                break;
+                    
+            default:
+                ASSERT( EFalse );
+                break;
+            }
+        CompleteSelf();
+        }
+    else
+        {
+        iState = CWmDrmDlaHandlerImpl::EIdle; 
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::Completed
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::Completed( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::Completed" );
+    if ( iCurrentRequest->iSync )
+        {
+        CompleteSyncRequest( aError );
+        }
+    else
+        {
+        CompleteClientRequest( aError );
+        }
+    
+    NextRequest();
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::AcquiringLicenseFromDrmHeader
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::AcquiringLicenseFromDrmHeader()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::AcquiringLicenseFromDrmHeader" );
+    iLicenseAcquisitionFw->
+        AcquireLicenseFromDrmHeader( *iCurrentRequest->iDrmHeader,
+                                     iCurrentRequest->iErrorUrl,
+                                     *iCurrentRequest->iContentUrl,
+                                     *iCurrentRequest->iHtmlData,
+                                     iStatus );
+    SetActive();
+    iState = CWmDrmDlaHandlerImpl::ECompleted; 
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::AcquiringLicense
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::AcquiringLicense()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::AcquiringLicense" );
+    iLicenseAcquisitionFw->AcquireLicense( *iCurrentRequest->iFileHandle,
+                                           *iCurrentRequest->iContentUrl,
+                                           *iCurrentRequest->iHtmlData,
+                                           iStatus );
+    SetActive();
+    iState = CWmDrmDlaHandlerImpl::ECompleted;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::ProcessingMeteringCertificate
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHandlerImpl::ProcessingMeteringCertificate()
+    {
+    LOGFN( "CWmDrmDlaHandlerImpl::ProcessingMeteringCertificate" );
+    iMeteringFw->ProcessMeteringCertificate( *iCurrentRequest->iCertificate,
+                                             iStatus );
+    SetActive();
+    iState = CWmDrmDlaHandlerImpl::ECompleted;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/src/wmdrmdlahttpfwpluginresolver.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,399 @@
+/*
+* 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:  Implementation class for WMDRM DLA HTTP FW plugin resolver
+*
+*/
+
+
+#include <ecom/ecom.h>
+#include <badesca.h>
+#include <akniconutils.h>
+#include <akniconarray.h>
+#include <gulicon.h>
+#include <wmdrmdlatypes.h>
+#include <wmdrmdlahttpplugin.h>
+#include <wmdrmdlauinotifier.h>
+#include <wmdrmdla.mbg>
+#include "wmdrmdlahttpfwpluginresolver.h"
+#include "wmdrmdlaui.h"
+#include "wmdrmdlaplugincontainer.h"
+
+#define _LOGGING_FILE L"wmdrmdla.txt"
+#include "logfn.h"
+
+// CONSTANTS
+_LIT( KMbmFileName, "\\resource\\apps\\wmdrmdla.mbm" );
+_LIT( KTab, "\t" );
+
+const TInt KWmDrmDlaIndexMaxLength( 5 );
+
+// ======== LOCAL FUNCTIONS ========
+
+// -----------------------------------------------------------------------------
+// PointerArrayResetDestroyAndClose
+// Template method used to push RPointerArrays to the cleanup stack. Takes
+// care of deleting all pointers in the array.
+// -----------------------------------------------------------------------------
+//
+template <class T>
+LOCAL_C void PointerArrayResetDestroyAndClose( TAny* aPtr )
+    {
+    (reinterpret_cast<RPointerArray<T>*>(aPtr))->ResetAndDestroy();
+    (reinterpret_cast<RPointerArray<T>*>(aPtr))->Close();
+    }
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginL
+// ---------------------------------------------------------------------------
+//
+void WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginL( 
+    const RFile& aFile,
+    CWmDrmDlaHttpPluginIf*& aHttpPlugin, 
+    CWmDrmDlaUiNotifier*& aUiNotifier )
+    {
+    TInt err( KErrNone );
+
+    LOGFNR( "WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginL", err );
+
+    //Array where all supported plugins are gathered
+    RPointerArray<CWmDrmDlaPluginContainer> supportedPluginArray;
+    CleanupStack::PushL( 
+        TCleanupItem( 
+            PointerArrayResetDestroyAndClose<CWmDrmDlaPluginContainer>, 
+            &supportedPluginArray ) );
+
+    //Array where all http plugin implementation infos are gathered
+    RImplInfoPtrArray implArray;
+    CleanupStack::PushL( 
+        TCleanupItem( 
+            PointerArrayResetDestroyAndClose<CImplementationInformation>,
+            &implArray ) );
+    REComSession::ListImplementationsL( KWmDrmDlaHttpPluginIfUid, implArray );
+
+    //Lets go through all implementation infos and find out what http plugins
+    //support this content
+    for ( TInt i( 0 ); i < implArray.Count(); ++i )
+        {
+        //Only plugins with NOKIA vendor ID are currently allowed
+        if ( implArray[i]->VendorId() == VID_DEFAULT )
+            {
+            CWmDrmDlaUiNotifier* uiNotifier( NULL );
+            CWmDrmDlaHttpPluginIf* httpPlugin( NULL );
+            //Try to initialize http plugin
+            TRAP( err, httpPlugin = 
+                        CWmDrmDlaHttpPluginIf::NewL( 
+                                implArray[i]->ImplementationUid() ) );
+            if ( !err )
+                {
+                CleanupStack::PushL( httpPlugin );
+                TBool supported( EFalse );
+                //Check if current http plugin supports content
+                TRAP( err, supported = 
+                    httpPlugin->SupportedFileL( aFile, uiNotifier ) )
+                CleanupStack::PushL( uiNotifier );
+                //If current http plugin supports content, then
+                //add implementation index, http plugin and ui notifier to 
+                //plugin container.
+                //Otherwise delete current http plugin and ui notifier.
+                if ( !err && supported )
+                    {
+                    CWmDrmDlaPluginContainer* container( 
+                            CWmDrmDlaPluginContainer::NewL() );
+                    container->SetIndex( i );
+                    container->SetHttpPlugin( httpPlugin );
+                    container->SetUiNotifier( uiNotifier );
+                    CleanupStack::Pop( 2, httpPlugin ); //uiNotifier, httpPlugin
+                    CleanupStack::PushL( container );                    
+                    supportedPluginArray.AppendL( container );
+                    CleanupStack::Pop( container );
+                    }
+                else
+                    {
+                    CleanupStack::PopAndDestroy( 2, httpPlugin ); //uiNotifier, httpPlugin
+                    }
+                }
+            }
+        }
+
+    //Select the plugin to be used for license acquisition
+    SelectPluginL( supportedPluginArray, implArray, aHttpPlugin, aUiNotifier );
+    CleanupStack::PopAndDestroy( 2, &supportedPluginArray ); //implArray, supportedPluginArray
+    }
+
+// ---------------------------------------------------------------------------
+// WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginL
+// ---------------------------------------------------------------------------
+//
+void WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginL( 
+    const TDesC8& aDrmHeader,
+    CWmDrmDlaHttpPluginIf*& aHttpPlugin, 
+    CWmDrmDlaUiNotifier*& aUiNotifier )
+    {
+    TInt err( KErrNone );
+
+    LOGFNR( "WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginL", err );
+
+    //Array where all supported plugins are gathered
+    RPointerArray<CWmDrmDlaPluginContainer> supportedPluginArray;
+    CleanupStack::PushL( 
+        TCleanupItem( 
+            PointerArrayResetDestroyAndClose<CWmDrmDlaPluginContainer>, 
+            &supportedPluginArray ) );
+
+    //Array where all http plugin implementation infos are gathered
+    RImplInfoPtrArray implArray;
+    CleanupStack::PushL( 
+        TCleanupItem( 
+            PointerArrayResetDestroyAndClose<CImplementationInformation>, 
+            &implArray ) );
+    REComSession::ListImplementationsL( KWmDrmDlaHttpPluginIfUid, implArray );
+
+    //Lets go through all implementation infos and find out what http plugins
+    //support this content
+    for ( TInt i( 0 ); i < implArray.Count(); ++i )
+        {
+        //Only plugins with NOKIA vendor ID are currently allowed
+        if ( implArray[i]->VendorId() == VID_DEFAULT )
+            {
+            CWmDrmDlaUiNotifier* uiNotifier( NULL );
+            CWmDrmDlaHttpPluginIf* httpPlugin( NULL );
+            //Try to initialize http plugin
+            TRAP( err, httpPlugin = 
+                        CWmDrmDlaHttpPluginIf::NewL( 
+                                implArray[i]->ImplementationUid() ) );
+            if ( !err )
+                {
+                CleanupStack::PushL( httpPlugin );
+                TBool supported( EFalse );
+                //Check if current http plugin supports content
+                TRAP( err, supported = 
+                    httpPlugin->SupportedDrmHeaderL( aDrmHeader, uiNotifier ) )
+                CleanupStack::PushL( uiNotifier );
+                //If current http plugin supports content, then
+                //add implementation index, http plugin and ui notifier to 
+                //plugin container.
+                //Otherwise delete current http plugin and ui notifier.
+                if ( !err && supported )
+                    {
+                    CWmDrmDlaPluginContainer* container( 
+                            CWmDrmDlaPluginContainer::NewL() );
+                    container->SetIndex( i );
+                    container->SetHttpPlugin( httpPlugin );
+                    container->SetUiNotifier( uiNotifier );
+                    CleanupStack::Pop( 2, httpPlugin ); //uiNotifier, httpPlugin
+                    CleanupStack::PushL( container );                    
+                    supportedPluginArray.AppendL( container );
+                    CleanupStack::Pop( container );
+                    }
+                else
+                    {
+                    CleanupStack::PopAndDestroy( 2, httpPlugin ); //uiNotifier, httpPlugin
+                    }
+                }
+            }
+        }
+
+    //Select the plugin to be used for license acquisition
+    SelectPluginL( supportedPluginArray, implArray, aHttpPlugin, aUiNotifier );
+    CleanupStack::PopAndDestroy( 2, &supportedPluginArray ); //implArray, supportedPluginArray
+    }
+
+// ---------------------------------------------------------------------------
+// WmDrmDlaHttpFwPluginResolver::::ResolveHttpPluginWithCertificateL
+// ---------------------------------------------------------------------------
+//
+void WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginWithCertificateL( 
+    const TDesC8& aCertificate,
+    CWmDrmDlaHttpPluginIf*& aHttpPlugin, 
+    CWmDrmDlaUiNotifier*& aUiNotifier )
+    {
+    TInt err( KErrNone );
+
+    LOGFNR( "WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginL", err );
+
+    //Array where all supported plugins are gathered
+    RPointerArray<CWmDrmDlaPluginContainer> supportedPluginArray;
+    CleanupStack::PushL( 
+        TCleanupItem( 
+            PointerArrayResetDestroyAndClose<CWmDrmDlaPluginContainer>,
+            &supportedPluginArray ) );
+
+    //Array where all http plugin implementation infos are gathered
+    RImplInfoPtrArray implArray;
+    CleanupStack::PushL( 
+        TCleanupItem( 
+            PointerArrayResetDestroyAndClose<CImplementationInformation>,
+            &implArray ) );
+    REComSession::ListImplementationsL( KWmDrmDlaHttpPluginIfUid, implArray );
+
+    //Lets go through all implementation infos and find out what http plugins
+    //support this content
+    for ( TInt i( 0 ); i < implArray.Count(); ++i )
+        {
+        //Only plugins with NOKIA vendor ID are currently allowed
+        if ( implArray[i]->VendorId() == VID_DEFAULT )
+            {
+            CWmDrmDlaUiNotifier* uiNotifier( NULL );
+            CWmDrmDlaHttpPluginIf* httpPlugin( NULL );
+            //Try to initialize http plugin
+            TRAP( err, httpPlugin = 
+                        CWmDrmDlaHttpPluginIf::NewL( 
+                                implArray[i]->ImplementationUid() ) );
+            if ( !err )
+                {
+                CleanupStack::PushL( httpPlugin );
+                TBool supported( EFalse );
+                //Check if current http plugin supports content
+                TRAP( err, supported = 
+                    httpPlugin->SupportedMeteringCertificateL( aCertificate, 
+                                                               uiNotifier ) )
+                CleanupStack::PushL( uiNotifier );
+                //If current http plugin supports content, then
+                //add implementation index, http plugin and ui notifier to 
+                //plugin container.
+                //Otherwise delete current http plugin and ui notifier.
+                if ( !err && supported )
+                    {
+                    CWmDrmDlaPluginContainer* container( 
+                            CWmDrmDlaPluginContainer::NewL() );
+                    container->SetIndex( i );
+                    container->SetHttpPlugin( httpPlugin );
+                    container->SetUiNotifier( uiNotifier );
+                    CleanupStack::Pop( 2, httpPlugin ); //uiNotifier, httpPlugin
+                    CleanupStack::PushL( container );                    
+                    supportedPluginArray.AppendL( container );
+                    CleanupStack::Pop( container );
+                    }
+                else
+                    {
+                    CleanupStack::PopAndDestroy( 2, httpPlugin ); //uiNotifier, httpPlugin
+                    }
+                }
+            }
+        }
+
+    //Select the plugin to be used for metering
+    SelectPluginL( supportedPluginArray, implArray, aHttpPlugin, aUiNotifier );
+    CleanupStack::PopAndDestroy( 2, &supportedPluginArray ); //implArray, supportedPluginArray
+    }
+
+// ----------------------------------------------------------------------------
+// WmDrmDlaHttpFwPluginResolver::SelectPluginL
+// ----------------------------------------------------------------------------
+//
+void WmDrmDlaHttpFwPluginResolver::SelectPluginL( 
+    RPointerArray<CWmDrmDlaPluginContainer>& aSupportedPluginArray,
+    RImplInfoPtrArray& aImplArray,
+    CWmDrmDlaHttpPluginIf*& aHttpPlugin, 
+    CWmDrmDlaUiNotifier*& aUiNotifier )
+    {
+    LOGFN( "WmDrmDlaHttpFwPluginResolver::SelectPluginL" );
+    
+    //Find out how many plugins support this content
+    TInt supportedCount( aSupportedPluginArray.Count() );
+    LOG2( "supportedCount: %d", supportedCount );
+    //If more than one plugin supports the content, then query
+    //user to select one to be used
+    if ( supportedCount > 1 )
+        {
+        CWmDrmDlaUi* ui( CWmDrmDlaUi::NewLC() );
+        
+        CAknIconArray* listIcons = new (ELeave) CAknIconArray( 2 );
+        CleanupStack::PushL( listIcons );
+                
+        //Create default icon to be used with plugins that don't
+        //have own icon. Default icon index is always 0.
+        DefaultIconL( listIcons );
+        
+        CPtrC16Array* listItems = new (ELeave) CPtrC16Array( 2 );
+        CleanupStack::PushL( listItems );
+        
+        //Go through supported plugins, try to get their display name
+        //and icon. If plugin doesn't have icon, use default one.
+        for ( TInt i( 0 ); i < supportedCount; ++i )
+            {
+            TInt index( aSupportedPluginArray[i]->Index() ); 
+            TPtrC displayName( aImplArray[index]->DisplayName() ); 
+            HBufC* listItem( HBufC::NewLC( displayName.Length() + 
+                                           KWmDrmDlaIndexMaxLength ) );
+            TPtr listItemPtr( listItem->Des() );
+            CGulIcon* pluginIcon( aSupportedPluginArray[ i ]->
+                                      HttpPlugin()->ServiceIcon() );
+            if ( pluginIcon )
+                {
+                CleanupStack::PushL( pluginIcon );
+                listIcons->AppendL( pluginIcon );
+                CleanupStack::Pop( pluginIcon );
+                listItemPtr.AppendNum( listIcons->Count() - 1 );
+                }
+            else
+                {
+                listItemPtr.AppendNum( 0 );
+                }
+            listItemPtr.Append( KTab );
+            listItemPtr.Append( displayName );
+            listItems->AppendL( listItemPtr );
+            CleanupStack::Pop( listItem );
+            }
+        //listItems and listItems ownership is transferred to ui
+        CleanupStack::Pop( 2, listIcons ); //listItems, listIcons
+        //Query user to make a selection.
+        //Take user selected plugin to use or leave, if user cancels query.
+        TInt selection( ui->ShowListQueryL( listItems, listIcons  ) );
+        LOG2( "selection: %d", selection );
+        if ( selection >= 0 )
+            {
+            aSupportedPluginArray[selection]->GetHttpPlugin( aHttpPlugin );
+            aSupportedPluginArray[selection]->GetUiNotifier( aUiNotifier );
+            }
+        else
+            {
+            User::Leave( KErrNotFound );
+            }
+        CleanupStack::PopAndDestroy( ui );
+        }
+    //Only one supporting http plugin
+    else if ( supportedCount == 1 )
+        {
+        aSupportedPluginArray[0]->GetHttpPlugin( aHttpPlugin );
+        aSupportedPluginArray[0]->GetUiNotifier( aUiNotifier );
+        }
+    //No supporting http plugins
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// WmDrmDlaHttpFwPluginResolver::DefaultIconL
+// ----------------------------------------------------------------------------
+//
+void WmDrmDlaHttpFwPluginResolver::DefaultIconL( 
+    CAknIconArray*& aIconArray )
+    {
+    LOGFN( "WmDrmDlaHttpFwPluginResolver::DefaultIconL" );
+    CFbsBitmap* bitmap( NULL );
+    CFbsBitmap* bitmapMask( NULL );
+    AknIconUtils::CreateIconLC( bitmap, bitmapMask, KMbmFileName,
+                                EMbmWmdrmdlaQgn_prop_drm_valid_large,
+                                EMbmWmdrmdlaQgn_prop_drm_valid_large_mask );
+    CGulIcon* defaultIcon( CGulIcon::NewL( bitmap, bitmapMask ) );
+    CleanupStack::Pop( 2 ); // bitmapMask, bitmap. Icon has now ownership
+    CleanupStack::PushL( defaultIcon );
+    aIconArray->AppendL( defaultIcon );
+    CleanupStack::Pop( defaultIcon );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/src/wmdrmdlahttplicacqpluginfw.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,832 @@
+/*
+* 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:  HTTP plugin framework implementation
+*
+*/
+
+
+#include <utf.h>
+#include <wmdrmdlatypes.h>
+#include <wmdrmdlahttpplugin.h>
+#include <wmdrmdlauinotifier.h>
+#include <wmdrmdlautils.rsg>
+#include "wmdrmdlahttplicacqpluginfw.h"
+#include "wmdrmdlahttpfwpluginresolver.h"
+#include "wmdrmdlaparser.h"
+#include "wmdrmdlaui.h"
+
+#define _LOGGING_FILE L"wmdrmdla.txt"
+#include "logfn.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::ConstructL" );
+    iDlaParser = CWmDrmDlaParser::NewL();
+    iWait = new (ELeave) CActiveSchedulerWait;
+    iIdle =  CIdle::NewL( CActive::EPriorityIdle );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::CWmDrmDlaHttpLicAcqPluginFw
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHttpLicAcqPluginFw::CWmDrmDlaHttpLicAcqPluginFw() 
+    : CActive( EPriorityStandard ), 
+      iState( CWmDrmDlaHttpLicAcqPluginFw::EIdle )
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::CWmDrmDlaHttpLicAcqPluginFw" );
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHttpLicAcqPluginFw* CWmDrmDlaHttpLicAcqPluginFw::NewL()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::NewL" );
+    CWmDrmDlaHttpLicAcqPluginFw* self 
+        = CWmDrmDlaHttpLicAcqPluginFw::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::NewLC
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHttpLicAcqPluginFw* CWmDrmDlaHttpLicAcqPluginFw::NewLC()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::NewLC" );
+    CWmDrmDlaHttpLicAcqPluginFw* self 
+        = new( ELeave ) CWmDrmDlaHttpLicAcqPluginFw;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::~CWmDrmDlaHttpLicAcqPluginFw
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHttpLicAcqPluginFw::~CWmDrmDlaHttpLicAcqPluginFw()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::~CWmDrmDlaHttpLicAcqPluginFw" );
+    CancelLicenseAcquisition();
+    delete iDlaParser;
+    delete iHttpPlugin;
+    delete iUiNotifier;
+    delete iWait;
+    delete iIdle;
+    delete iDrmHeader;
+    delete iLicenseServerUrl;
+    delete iLicenseChallenge;
+    delete iLicenseResponse;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::SilentL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaHttpLicAcqPluginFw::SilentL( 
+    const RFile& aFile )
+    {
+    TInt err( KErrNone );
+    TBool silent( EFalse );
+    
+    LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::SilentL", err );
+    if ( iState != CWmDrmDlaHttpLicAcqPluginFw::EIdle )
+        {
+        User::Leave( KErrInUse );
+        }
+    //Finds out, if current content should be handled silently, also
+    //resolves and initializes plugin that handles this content
+    TRAP( err, silent = SilentHandlerL( aFile ) );
+    if ( err )
+        {
+        HandleErrorL( err );
+        }
+    iSilentInitialised = ETrue;
+    return silent;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::AcquireLicense
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::AcquireLicense( 
+    const RFile& aFile, 
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData, 
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::AcquireLicense" );
+    
+    TRequestStatus *status = &aStatus;
+    aStatus = KRequestPending;
+    if ( iState != CWmDrmDlaHttpLicAcqPluginFw::EIdle )
+        {
+        User::RequestComplete( status, KErrInUse );
+        return;
+        }
+    
+    iClientStatus = &aStatus;
+    iFile = &aFile;
+    iContentUrl = &aContentUrl;
+    iHtmlData = &aHtmlData;
+    //If FW is already initialized, then go straight to license acquisition.
+    //Otherwise try to resolve plugin that handles this content.
+    if ( iSilentInitialised )
+        {
+        iState = 
+            CWmDrmDlaHttpLicAcqPluginFw::ERetrievingDRMHeaderFromFileHandle;
+        }
+    else
+        {
+        iState = 
+            CWmDrmDlaHttpLicAcqPluginFw::EResolvingHttpPluginFromFileHandle;
+        }
+    CompleteSelf();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::AcquireLicenseFromDrmHeader
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::AcquireLicenseFromDrmHeader( 
+    const TDesC8& aDrmHeader,
+    HBufC* aErrorUrl,
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData, 
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::AcquireLicenseFromDrmHeader" );
+    
+    TRequestStatus *status = &aStatus;
+    aStatus = KRequestPending;
+    if ( iState != CWmDrmDlaHttpLicAcqPluginFw::EIdle )
+        {
+        User::RequestComplete( status, KErrInUse );
+        return;
+        }
+    
+    iClientStatus = &aStatus;
+    delete iDrmHeader;
+    iDrmHeader = NULL;
+    iDrmHeader = aDrmHeader.Alloc();
+    if ( !iDrmHeader )
+        {
+        CompleteClientRequest( KErrNoMemory );
+        }
+    else
+        {
+        iErrorUrl = aErrorUrl;
+        iContentUrl = &aContentUrl;
+        iHtmlData = &aHtmlData;
+        iState = 
+            CWmDrmDlaHttpLicAcqPluginFw::EResolvingHttpPluginFromDRMHeader;
+        CompleteSelf();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::SetIapId
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::SetIapId( TInt aIapId )
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SetIapId" );
+    LOG2( "aIapId: %d", aIapId );
+    iIapId = aIapId;
+    if ( iHttpPlugin )
+        {
+        iHttpPlugin->SetIapId( iIapId );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::CancelLicenseAcquisition
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::CancelLicenseAcquisition()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::CancelLicenseAcquisition" );
+    LOG2( "iState: %d", iState );
+    //If we are currently sending header error or license storage status 
+    //to server, then let it finish before cancelling
+    if ( iState == CWmDrmDlaHttpLicAcqPluginFw::ESentDRMHeaderError ||
+         iState == CWmDrmDlaHttpLicAcqPluginFw::ESentLicenseStorageStatus )
+        {
+        iWait->Start();
+        }
+    if ( iHttpPlugin )
+        {
+        iHttpPlugin->CancelLicenseAcquisition();
+        }
+    Cancel();
+    if ( iUiNotifier )
+        {
+        TRAP_IGNORE( iUiNotifier->HandleErrorL( KErrCancel ) );
+        }
+    CompleteClientRequest( KErrCancel );
+    Reset();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::DoCancel()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::DoCancel" );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::RunL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::RunL()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::RunL" );
+    LOG2( "iState: %d", iState );
+    LOG2( "iStatus.Int(): %d", iStatus.Int() );
+    if ( iStatus.Int() != KErrNone )
+        {
+        HandleErrorL( iStatus.Int() );
+        }
+    
+    switch ( iState )
+	    {
+	    case CWmDrmDlaHttpLicAcqPluginFw::EResolvingHttpPluginFromDRMHeader:
+	        ResolvingHttpPluginFromDRMHeaderHandlerL();
+	        break;
+	        
+	    case CWmDrmDlaHttpLicAcqPluginFw::EResolvingHttpPluginFromFileHandle:
+	        ResolvingHttpPluginFromFileHandleHandlerL();
+	        break;
+	        
+    	case CWmDrmDlaHttpLicAcqPluginFw::ERetrievingDRMHeaderFromFileHandle:
+    	    RetrievingDRMHeaderFromFileHandleHandler();
+    	    break;
+    	
+    	case CWmDrmDlaHttpLicAcqPluginFw::EProcessingDRMHeader:
+    	    ProcessingDRMHeaderHandler();
+    	    break;
+
+    	case CWmDrmDlaHttpLicAcqPluginFw::ESentDRMHeaderError:
+    	    SentDRMHeaderErrorHandlerL();
+    	    break;
+    	    
+    	case CWmDrmDlaHttpLicAcqPluginFw::ERetrievingChallenge:
+    	    RetrievingChallengeHandler();
+    	    break;
+    	
+    	case CWmDrmDlaHttpLicAcqPluginFw::ERetrievingLicense:
+    	    RetrievingLicenseHandler();
+    	    break;
+    	
+    	case CWmDrmDlaHttpLicAcqPluginFw::EAddingLicense:
+    	    AddingLicenseHandlerL();
+    	    break;
+    	
+    	case CWmDrmDlaHttpLicAcqPluginFw::ESendingLicenseStorageStatus:
+    	    SendingLicenseStorageStatusHandler();
+    	    break;
+    	
+    	case CWmDrmDlaHttpLicAcqPluginFw::ESentLicenseStorageStatus:
+    	    SentLicenseStorageStatusHandler();
+    	    break;
+    	    
+    	case CWmDrmDlaHttpLicAcqPluginFw::ELicensingComplete:
+    	    LicensingCompleteL();
+    	    break;
+    	
+    	default:
+            ASSERT( EFalse );
+    	    break;
+    	}
+    }    
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaHttpLicAcqPluginFw::RunError( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::RunError" );
+    LOG2( "aError: %d", aError );
+    CompleteClientRequest( aError );
+    Reset();
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::UserCancellation
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::UserCancellation()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::UserCancellation" );
+    //User has cancelled the license acquisition from the UI.
+    //Cancel the license acquisition asynchronously.
+    TCallBack callBack( CWmDrmDlaHttpLicAcqPluginFw::AsyncCancel, 
+                        this );
+    iIdle->Start( callBack );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::CompleteSelf
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::CompleteSelf()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::CompleteSelf" );
+    if ( !IsActive() )
+        {
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrNone );
+        SetActive();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::CompleteClientRequest
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::CompleteClientRequest( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::CompleteClientRequest" );
+    LOG2( "aError: %d", aError );
+    if ( iClientStatus )
+        {
+        User::RequestComplete( iClientStatus, aError );
+        iClientStatus = NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::::Reset
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::Reset()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::Reset" );
+    iSilentInitialised = EFalse;
+    delete iHttpPlugin;
+    iHttpPlugin = NULL;
+    delete iUiNotifier;
+    iUiNotifier = NULL;
+    delete iDrmHeader;
+    iDrmHeader = NULL;
+    delete iLicenseServerUrl;
+    iLicenseServerUrl = NULL;
+    delete iLicenseChallenge;
+    iLicenseChallenge = NULL;
+    delete iLicenseResponse;
+    iLicenseResponse = NULL;
+    iFile = NULL;
+    iContentUrl = NULL;
+    iHtmlData = NULL;
+    iClientStatus = NULL;
+    iState = CWmDrmDlaHttpLicAcqPluginFw::EIdle;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::SilentHandlerL
+// ----------------------------------------------------------------------------
+//
+TBool CWmDrmDlaHttpLicAcqPluginFw::SilentHandlerL(
+    const RFile& aFile )
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SilentHandlerL" );
+    iSilentInitialised = EFalse;
+    ResolveHttpPluginL( aFile );
+    return iHttpPlugin->SilentL( aFile );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromDRMHeaderHandlerL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromDRMHeaderHandlerL()
+    {
+    TInt err( KErrNone );
+       
+    LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromDRMHeaderHandlerL", err );
+    
+    iSilentInitialised = EFalse;
+    TRAP( err, ResolveHttpPluginL( *iDrmHeader ) );
+    if ( err )
+        {
+        HandleErrorL( err );
+        }
+    iState = CWmDrmDlaHttpLicAcqPluginFw::EProcessingDRMHeader;
+    CompleteSelf();
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromFileHandleHandlerL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromFileHandleHandlerL()
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::ResolvingHttpPluginFromFileHandleHandlerL", err );
+    
+    TRAP( err, SilentHandlerL( *iFile ) );
+    if ( err )
+        {
+        HandleErrorL( err );
+        }
+    iState = CWmDrmDlaHttpLicAcqPluginFw::ERetrievingDRMHeaderFromFileHandle;
+    CompleteSelf();
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::RetrievingDRMHeaderFromFileHandleHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::RetrievingDRMHeaderFromFileHandleHandler()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::RetrievingDRMHeaderFromFileHandleHandler" );
+    delete iDrmHeader;
+    iDrmHeader = NULL;
+    SetActive();
+    iState = CWmDrmDlaHttpLicAcqPluginFw::EProcessingDRMHeader;
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNotSupported );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::ProcessingDRMHeaderHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::ProcessingDRMHeaderHandler()
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::ProcessingDRMHeaderHandler", err );
+    
+    TRAP( err, iHttpPlugin->ProcessDrmHeaderL( *iDrmHeader ) );
+    if ( err )
+        {
+        SendingDRMHeaderErrorHandler( err );
+        }
+    delete iLicenseServerUrl;
+    iLicenseServerUrl = NULL;
+    TRAP( err, ParseDrmHeaderL( *iDrmHeader, iLicenseServerUrl ) );
+    if ( err )
+        {
+        SendingDRMHeaderErrorHandler( err );
+        }
+    iState = CWmDrmDlaHttpLicAcqPluginFw::ERetrievingChallenge;
+    CompleteSelf();
+    }        
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::SendingDRMHeaderErrorHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::SendingDRMHeaderErrorHandler( 
+    TInt aError )
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SendingDRMHeaderErrorHandler" );
+    LOG2( "aError: %d", aError );
+    iHttpPlugin->SendDrmHeaderError( *iErrorUrl, aError, iStatus );
+    SetActive();
+    iState = CWmDrmDlaHttpLicAcqPluginFw::ESentDRMHeaderError;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::SentDRMHeaderErrorHandlerL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::SentDRMHeaderErrorHandlerL()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SentDRMHeaderErrorHandlerL" );
+    //If license acquisition is cancelled during the send operation,
+    //then don't continue license acquisition process
+    if ( iWait->IsStarted() )
+        {
+        iWait->AsyncStop();
+        }
+    else
+        {
+        HandleErrorL( KErrCorrupt );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::RetrievingChallengeHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::RetrievingChallengeHandler()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::RetrievingChallengeHandler" );
+    delete iLicenseChallenge;
+    iLicenseChallenge = NULL;
+    SetActive();
+    iState = CWmDrmDlaHttpLicAcqPluginFw::ERetrievingLicense;
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNotSupported );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::RetrievingLicenseHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::RetrievingLicenseHandler()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::RetrievingLicenseHandler" );
+    iHttpPlugin->AcquireLicense( *iLicenseChallenge, 
+                                 iLicenseServerUrl, 
+                                 iStatus );
+    SetActive();
+    iState = CWmDrmDlaHttpLicAcqPluginFw::EAddingLicense;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::AddingLicenseHandlerL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::AddingLicenseHandlerL()
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::AddingLicenseHandler", err );
+    
+    delete iLicenseResponse;
+    iLicenseResponse = NULL;
+    TRAP( err, iLicenseResponse = iHttpPlugin->GetLicenseResponseL() );
+    if ( err )
+        {
+        HandleErrorL( err );
+        }
+    SetActive();
+    iState = CWmDrmDlaHttpLicAcqPluginFw::ESendingLicenseStorageStatus;
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNotSupported );
+    }    
+    
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::SendingLicenseStorageStatusHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::SendingLicenseStorageStatusHandler()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SendingLicenseStorageStatusHandler" );
+    LOG2( "iStatus.Int(): %d", iStatus.Int() );
+    HBufC8* tid( NULL );
+    TRAP_IGNORE( ParseLicenseResponseL( *iLicenseResponse, 
+                                        tid, 
+                                        *iContentUrl ) );
+    //If license couldn't be added succesfully to license store,
+    //then make sure content won't be downloaded
+    if ( iStatus.Int() )
+        {
+        delete *iContentUrl;
+        *iContentUrl = NULL;
+        }
+    iHttpPlugin->SendLicenseStorageStatus( tid, 
+                                           *iLicenseServerUrl, 
+                                           iStatus.Int(), 
+                                           iStatus );
+    delete tid;
+    SetActive();
+    iState = CWmDrmDlaHttpLicAcqPluginFw::ESentLicenseStorageStatus;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::SentLicenseStorageStatusHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::SentLicenseStorageStatusHandler()
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::SentLicenseStorageStatusHandler" );
+    //If license acquisition is cancelled during the send operation,
+    //then don't continue license acquisition process
+    if ( iWait->IsStarted() )
+        {
+        iWait->AsyncStop();
+        }
+    else
+        {
+        iState = CWmDrmDlaHttpLicAcqPluginFw::ELicensingComplete;
+        CompleteSelf();
+        }
+    }
+
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::LicensingCompleteL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::LicensingCompleteL()
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::LicensingComplete", err );
+    
+    //If content URL couldn't be parsed from the license response,
+    //then try to get it from the http plugin
+    if ( !*iContentUrl )
+        {
+        TRAP( err, *iContentUrl = iHttpPlugin->GetContentUrlL() );
+        if ( err )
+            {
+            HandleErrorL( err );
+            }
+        }
+    TRAP( err, *iHtmlData = iHttpPlugin->GetHtmlDataL() );
+    if ( err )
+        {
+        HandleErrorL( err );
+        }
+    CompleteClientRequest( KErrNone );
+    Reset();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL( 
+    const RFile& aFile )
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL" );
+
+    delete iHttpPlugin;
+    iHttpPlugin = NULL;
+    delete iUiNotifier;
+    iUiNotifier = NULL;
+    
+    WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginL( aFile, 
+                                                      iHttpPlugin, 
+                                                      iUiNotifier );
+    
+    //Set cancel observer for ui plugin
+    if ( iUiNotifier )
+        {
+        iUiNotifier->SetCancelObserver( this );
+        }
+    //Set iap for http plugin
+    if ( iIapId )
+        {
+        iHttpPlugin->SetIapId( iIapId );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL( 
+    const TDesC8& aDrmHeader )
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::ResolveHttpPluginL" );
+    
+    delete iHttpPlugin;
+    iHttpPlugin = NULL;
+    delete iUiNotifier;
+    iUiNotifier = NULL;
+    
+    WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginL( aDrmHeader, 
+                                                      iHttpPlugin, 
+                                                      iUiNotifier );
+    
+    //Set cancel observer for ui plugin
+    if ( iUiNotifier )
+        {
+        iUiNotifier->SetCancelObserver( this );
+        }
+    //Set iap for http plugin
+    if ( iIapId )
+        {
+        iHttpPlugin->SetIapId( iIapId );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::ParseDrmHeaderL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::ParseDrmHeaderL( 
+    const TDesC8& aDrmHeader,
+    HBufC*& aLicenseServerUrl )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::ParseDrmHeader", err );
+    
+    HBufC8* licenseServerUrl( NULL );
+    err = iDlaParser->GetLicenseServerURLFromDRMHeader( aDrmHeader, 
+                                                        licenseServerUrl );
+    if ( licenseServerUrl )
+        {
+        CleanupStack::PushL( licenseServerUrl );
+        aLicenseServerUrl 
+            = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *licenseServerUrl );
+        CleanupStack::PopAndDestroy( licenseServerUrl );
+        }
+    User::LeaveIfError( err );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::ParseLicenseResponseL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::ParseLicenseResponseL( 
+    const TDesC8& aLicenseResponse,
+    HBufC8*& aTid,
+    HBufC*& aContentUrl )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::ParseLicenseResponse", err );
+        
+    HBufC8* contentUrl( NULL );
+    err = iDlaParser->ProcessLicenseResponse( aLicenseResponse, 
+                                              aTid, 
+                                              contentUrl );
+    if ( contentUrl )
+        {
+        CleanupStack::PushL( contentUrl );
+        aContentUrl 
+            = CnvUtfConverter::ConvertToUnicodeFromUtf8L( *contentUrl );
+        CleanupStack::PopAndDestroy( contentUrl );
+        }
+    User::LeaveIfError( err );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::HandleErrorL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpLicAcqPluginFw::HandleErrorL( TInt aError )
+    {
+    TInt err( KErrNotFound );
+    
+    LOGFNR( "CWmDrmDlaHttpLicAcqPluginFw::HandleErrorL", err );
+    LOG2( "iState: %d", iState );
+    LOG2( "aError: %d", aError );
+    
+    //First try to let ui plugin to handle the error
+    if ( iUiNotifier )
+        {
+        TRAP( err, iUiNotifier->HandleErrorL( aError ) );
+        }
+    //If ui plugin didn't handle the error and we aren't currently sending
+    //license storage status to server, then try to show the generic
+    //error note.
+    if ( err && 
+         iState != CWmDrmDlaHttpLicAcqPluginFw::ESendingLicenseStorageStatus )
+        {
+        CWmDrmDlaUi* ui( NULL );
+        TRAP_IGNORE( ui = CWmDrmDlaUi::NewL() );
+        if ( ui )
+            {
+            CleanupStack::PushL( ui );
+            ui->ShowErrorNoteL( R_WMDRMDLA_NOTE_AQUISITION_FAILED );
+            CleanupStack::PopAndDestroy( ui );
+            }
+        }
+    //If we aren't currently sending license storage status to server,
+    //the leave with the error code.
+    if ( iState != CWmDrmDlaHttpLicAcqPluginFw::ESendingLicenseStorageStatus )
+        {
+        User::Leave( aError );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpLicAcqPluginFw::AsyncCancel
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaHttpLicAcqPluginFw::AsyncCancel( TAny* aPtr )
+    {
+    LOGFN( "CWmDrmDlaHttpLicAcqPluginFw::AsyncCancel" );
+    CWmDrmDlaHttpLicAcqPluginFw* licAcqFw = 
+        static_cast<CWmDrmDlaHttpLicAcqPluginFw*>( aPtr );
+    licAcqFw->CancelLicenseAcquisition();
+    return EFalse;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/src/wmdrmdlahttpmeteringpluginfw.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,467 @@
+/*
+* 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:  HTTP plugin framework implementation
+*
+*/
+
+
+#include <wmdrmdlatypes.h>
+#include <wmdrmdlahttpplugin.h>
+#include <wmdrmdlauinotifier.h>
+#include "wmdrmdlahttpmeteringpluginfw.h"
+#include "wmdrmdlahttpfwpluginresolver.h"
+#include "wmdrmdlaui.h"
+
+#define _LOGGING_FILE L"wmdrmdla.txt"
+#include "logfn.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::ConstructL" );
+    iIdle =  CIdle::NewL( CActive::EPriorityIdle );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::CWmDrmDlaHttpMeteringPluginFw
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHttpMeteringPluginFw::CWmDrmDlaHttpMeteringPluginFw() 
+    : CActive( EPriorityStandard ), 
+      iState( CWmDrmDlaHttpMeteringPluginFw::EIdle )
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::CWmDrmDlaHttpMeteringPluginFw" );
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHttpMeteringPluginFw* CWmDrmDlaHttpMeteringPluginFw::NewL()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::NewL" );
+    CWmDrmDlaHttpMeteringPluginFw* self = 
+        CWmDrmDlaHttpMeteringPluginFw::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::NewLC
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHttpMeteringPluginFw* CWmDrmDlaHttpMeteringPluginFw::NewLC()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::NewLC" );
+    CWmDrmDlaHttpMeteringPluginFw* self = 
+        new( ELeave ) CWmDrmDlaHttpMeteringPluginFw;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::~CWmDrmDlaHttpMeteringPluginFw
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHttpMeteringPluginFw::~CWmDrmDlaHttpMeteringPluginFw()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::~CWmDrmDlaHttpMeteringPluginFw" );
+    CancelMetering();
+    delete iHttpPlugin;
+    delete iUiNotifier;
+    delete iIdle;
+    delete iMeteringChallenge;
+    delete iMeteringUrl;
+    delete iMeteringResponse;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::ProcessMeteringCertificate
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::ProcessMeteringCertificate( 
+    const TDesC8& aCertificate, 
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::ProcessMeteringCertificate" );
+    
+    TRequestStatus *status = &aStatus;
+    aStatus = KRequestPending;
+    if ( iState != CWmDrmDlaHttpMeteringPluginFw::EIdle )
+        {
+        User::RequestComplete( status, KErrInUse );
+        return;
+        }
+    
+    iClientStatus = &aStatus;
+    iCertificate = &aCertificate;
+    iState = CWmDrmDlaHttpMeteringPluginFw::EResolvingHttpPlugin;
+    CompleteSelf();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::CancelMetering
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::CancelMetering()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::CancelMetering" );
+    if ( iHttpPlugin )
+        {
+        iHttpPlugin->CancelMetering();
+        }
+    Cancel();
+    if ( iUiNotifier )
+        {
+        TRAP_IGNORE( iUiNotifier->HandleErrorL( KErrCancel ) );
+        }
+    CompleteClientRequest( KErrCancel );
+    Reset();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::SetIapId
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::SetIapId( TInt aIapId )
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::SetIapId" );
+    LOG2( "aIapId: %d", aIapId );
+    iIapId = aIapId;
+    if ( iHttpPlugin )
+        {
+        iHttpPlugin->SetIapId( iIapId );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::DoCancel()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::DoCancel" );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::RunL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::RunL()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::RunL" );
+    LOG2( "iState: %d", iState );
+    LOG2( "iStatus.Int(): %d", iStatus.Int() );
+    if ( iStatus.Int() != KErrNone )
+        {
+        HandleErrorL( iStatus.Int() );
+        }
+    
+    switch ( iState )
+	    {
+        case CWmDrmDlaHttpMeteringPluginFw::EResolvingHttpPlugin:
+            ResolvingHttpPluginHandlerL();
+            break;
+	    
+        case CWmDrmDlaHttpMeteringPluginFw::ERetrievingMeteringChallenge:
+    	    RetrievingMeteringChallenge();
+    	    break;
+    	
+    	case CWmDrmDlaHttpMeteringPluginFw::EProcessingMeteringChallenge:
+    	    ProcessingMeteringChallenge();
+    	    break;
+    	
+    	case CWmDrmDlaHttpMeteringPluginFw::ERetrievingMeteringResponse:
+    	    RetrievingMeteringResponse();
+    	    break;
+    	
+    	case CWmDrmDlaHttpMeteringPluginFw::EProcessingMeteringResponse:
+    	    ProcessingMeteringResponse();
+    	    break;
+    	    
+    	case CWmDrmDlaHttpMeteringPluginFw::EMeteringFinished:
+    	    MeteringFinished();
+    	    break;
+    	
+    	default:
+            ASSERT( EFalse );
+    	    break;
+    	}
+    }    
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaHttpMeteringPluginFw::RunError( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::RunError" );
+    LOG2( "aError: %d", aError );
+    CompleteClientRequest( aError );
+    Reset();
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::UserCancellation
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::UserCancellation()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::UserCancellation");
+    TCallBack callBack( CWmDrmDlaHttpMeteringPluginFw::AsyncCancel, 
+                        this );
+    iIdle->Start( callBack );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::CompleteSelf
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::CompleteSelf()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::CompleteSelf" );
+    if ( !IsActive() )
+        {
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrNone );
+        SetActive();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHandlerImpl::CompleteClientRequest
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::CompleteClientRequest( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::CompleteClientRequest" );
+    LOG2( "aError: %d", aError );
+    if ( iClientStatus )
+        {
+        User::RequestComplete( iClientStatus, aError );
+        iClientStatus = NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::::Reset
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::Reset()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::Reset" );
+    delete iHttpPlugin;
+    iHttpPlugin = NULL;
+    delete iUiNotifier;
+    iUiNotifier = NULL;
+    delete iMeteringChallenge;
+    iMeteringChallenge = NULL;
+    delete iMeteringUrl;
+    iMeteringUrl = NULL;
+    delete iMeteringResponse;
+    iMeteringResponse = NULL;
+    iCertificate = NULL;
+    iState = CWmDrmDlaHttpMeteringPluginFw::EIdle;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::ResolvingHttpPluginHandlerL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::ResolvingHttpPluginHandlerL()
+    {
+    TInt err( KErrNone );
+
+    LOGFNR( "CWmDrmDlaHttpMeteringPluginFw::ResolvingHttpPluginHandlerL", err );
+
+    TRAP( err, ResolveHttpPluginWithCertificateL( *iCertificate ) );
+    if ( err )
+        {
+        HandleErrorL( err );
+        }
+    iState = CWmDrmDlaHttpMeteringPluginFw::ERetrievingMeteringChallenge;
+    CompleteSelf();
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::RetrievingMeteringChallengeL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::RetrievingMeteringChallenge()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::RetrievingMeteringChallenge" );
+    delete iMeteringChallenge;
+    iMeteringChallenge = NULL;
+    delete iMeteringUrl;
+    iMeteringUrl = NULL;
+    SetActive();
+    iState = CWmDrmDlaHttpMeteringPluginFw::EProcessingMeteringChallenge;
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNotSupported );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::ProcessingMeteringChallengeL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::ProcessingMeteringChallenge()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::ProcessingMeteringChallenge" );
+    iHttpPlugin->ProcessMeteringChallenge( *iMeteringChallenge, 
+                                           *iMeteringUrl, 
+                                           iStatus );
+    SetActive();
+    iState = CWmDrmDlaHttpMeteringPluginFw::ERetrievingMeteringResponse;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::RetrievingMeteringResponseL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::RetrievingMeteringResponse()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::RetrievingMeteringResponse" );
+    delete iMeteringResponse;
+    iMeteringResponse = NULL;
+    iHttpPlugin->GetMeteringResponse( iMeteringResponse, iStatus );
+    SetActive();
+    iState = CWmDrmDlaHttpMeteringPluginFw::EProcessingMeteringResponse;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::ProcessingMeteringResponseL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::ProcessingMeteringResponse()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::ProcessingMeteringResponse" );
+    SetActive();
+    iState = CWmDrmDlaHttpMeteringPluginFw::EMeteringFinished;
+    TRequestStatus* status = &iStatus;
+    User::RequestComplete( status, KErrNotSupported );
+    }
+    
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::MeteringFinishedL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::MeteringFinished()
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::MeteringFinished" );
+    LOG2( "iPartialMetering: %d", iPartialMetering );
+    if ( iPartialMetering )
+        {
+        iState = CWmDrmDlaHttpMeteringPluginFw::ERetrievingMeteringChallenge;
+        CompleteSelf();
+        }
+    else
+        {
+        iHttpPlugin->MeteringFinished();
+        CompleteClientRequest( KErrNone );
+        Reset();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::::ResolveHttpPluginWithCertificateL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::ResolveHttpPluginWithCertificateL( 
+    const TDesC8& aCertificate )
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::ResolveHttpPluginL" );
+
+    delete iHttpPlugin;
+    iHttpPlugin = NULL;
+    delete iUiNotifier;
+    iUiNotifier = NULL;
+    
+    WmDrmDlaHttpFwPluginResolver::ResolveHttpPluginWithCertificateL( 
+            aCertificate, iHttpPlugin, iUiNotifier );
+    
+    //Set cancel observer for ui plugin
+    if ( iUiNotifier )
+        {
+        iUiNotifier->SetCancelObserver( this );
+        }
+    //Set iap for http plugin
+    if ( iIapId )
+        {
+        iHttpPlugin->SetIapId( iIapId );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::HandleErrorL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaHttpMeteringPluginFw::HandleErrorL( TInt aError )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaHttpMeteringPluginFw::HandleErrorL", err );
+    LOG2( "iState: %d", iState );
+    LOG2( "aError: %d", aError );
+        
+    if ( iUiNotifier )
+        {
+        TRAP( err, iUiNotifier->HandleErrorL( aError ) );
+        }
+    
+    switch ( iState )
+        {
+        case CWmDrmDlaHttpMeteringPluginFw::ERetrievingMeteringChallenge:
+            break;
+
+        case CWmDrmDlaHttpMeteringPluginFw::EProcessingMeteringChallenge:
+            break;
+
+        case CWmDrmDlaHttpMeteringPluginFw::ERetrievingMeteringResponse:
+            break;
+
+        case CWmDrmDlaHttpMeteringPluginFw::EProcessingMeteringResponse:
+            break;
+
+        case CWmDrmDlaHttpMeteringPluginFw::EMeteringFinished:
+            break;
+
+        default:
+            break;
+        }
+    
+    User::Leave( aError );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaHttpMeteringPluginFw::AsyncCancel
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaHttpMeteringPluginFw::AsyncCancel( TAny* aPtr )
+    {
+    LOGFN( "CWmDrmDlaHttpMeteringPluginFw::AsyncCancel");
+    CWmDrmDlaHttpMeteringPluginFw* meteringFw = 
+        static_cast<CWmDrmDlaHttpMeteringPluginFw*>( aPtr );
+    meteringFw->CancelMetering();
+    return EFalse;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/src/wmdrmdlaparser.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,317 @@
+/*
+* 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:  Implementation of the WMDRM DLA Parser
+*
+*/
+
+
+// INCLUDE FILES
+#include <xml/xmlframeworkconstants.h>
+#include "wmdrmdlaparser.h"
+
+#define _LOGGING_FILE L"wmdrmdla.txt"
+#include "logfn.h"
+
+// CONSTANTS
+_LIT8( KLaInfoTag8, "lainfo" );
+_LIT8( KTIDTag8, "tid" );
+_LIT8( KContentUrlTag8, "contenturl" );
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::NewL
+// ----------------------------------------------------------------------------
+//
+CWmDrmDlaParser* CWmDrmDlaParser::NewL()
+    {
+    LOGFN( "CWmDrmDlaParser::NewL" );
+    CWmDrmDlaParser* self = new (ELeave) CWmDrmDlaParser();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::CWmDrmDlaParser
+// ----------------------------------------------------------------------------
+//
+CWmDrmDlaParser::CWmDrmDlaParser()
+    {
+    LOGFN( "CWmDrmDlaParser::CWmDrmDlaParser" );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::~CWmDrmDlaParser
+// ----------------------------------------------------------------------------
+//
+CWmDrmDlaParser::~CWmDrmDlaParser()
+    {
+    LOGFN( "CWmDrmDlaParser::~CWmDrmDlaParser" );
+    delete iParser;
+    delete iBuffer;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::ConstructL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaParser::ConstructL" );
+    // Mime type of the parsed document
+    _LIT8( KXmlMimeType, "text/xml" );
+    // Construct the parser object
+    iParser = Xml::CParser::NewL( KXmlMimeType, *this );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::ProcessLicenseResponse
+// ----------------------------------------------------------------------------
+//
+TInt CWmDrmDlaParser::ProcessLicenseResponse(
+    const TDesC8& aLicenseResponse,
+    HBufC8*& aTID,
+    HBufC8*& aContentURL)
+    {
+    TInt error = KErrNone;
+    
+    LOGFNR( "CWmDrmDlaParser::ProcessLicenseResponse", error );
+    
+    // Find beginning of XML document ('<')
+    TInt pos = aLicenseResponse.Locate( '<' );
+    if ( pos != KErrNotFound )
+      {
+      iContentUrl = &aContentURL;
+      iTID = &aTID;
+      iErrorCode = KErrNone;
+      TPtrC8 ptrUrl = aLicenseResponse.Mid( pos );
+      TRAP( error, Xml::ParseL( *iParser, ptrUrl ) );
+      if ( !error )
+        {
+        error = iErrorCode;
+        }
+
+      iTID = NULL;
+      iContentUrl = NULL;
+
+      delete iServerUrl;
+      iServerUrl = NULL;
+      }
+    else
+      {
+      error = KErrCorrupt;
+      }
+    return error;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::GetLicenseServerURLFromDRMHeader
+// ----------------------------------------------------------------------------
+//
+TInt CWmDrmDlaParser::GetLicenseServerURLFromDRMHeader(
+    const TDesC8& aDrmHeader,
+    HBufC8*& aServerURL )
+    {
+    TInt error( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaParser::GetLicenseServerURLFromDRMHeader", error );
+    
+    // Find beginning of XML document ('<')
+    TInt pos = aDrmHeader.Locate( '<' );
+    if ( pos != KErrNotFound )
+        {
+        iServerUrl = &aServerURL;
+        iErrorCode = KErrNone;
+        TPtrC8 ptrUrl = aDrmHeader.Mid( pos );
+        TRAP( error, Xml::ParseL( *iParser, ptrUrl ) );
+        if ( !error )
+            {
+            error = iErrorCode;
+            }
+
+        iServerUrl = NULL;
+
+        delete iTID;
+        iTID = NULL;
+
+        delete iContentUrl;
+        iContentUrl = NULL;
+        }
+    else
+        {
+        error = KErrCorrupt;
+        }
+
+    return error;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::OnStartDocumentL
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::OnStartDocumentL(
+    const Xml::RDocumentParameters& /*aDocParam*/,
+    TInt /*aErrorCode*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::OnEndDocumentL
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::OnEndDocumentL( TInt /*aErrorCode*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::OnStartElementL
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::OnStartElementL(
+    const Xml::RTagInfo& /*aElement*/,
+    const Xml::RAttributeArray& /*aAttributes*/,
+    TInt /*aErrorCode*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::OnEndElementL
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::OnEndElementL(
+    const Xml::RTagInfo& aElement,
+    TInt aErrorCode)
+    {
+    User::LeaveIfError( aErrorCode );
+    if ( !aElement.LocalName().DesC().CompareF( KLaInfoTag8 ) )
+        {
+        *iServerUrl = iBuffer;
+        iBuffer = NULL;
+        }
+    else if ( !aElement.LocalName().DesC().CompareF( KTIDTag8 ) )
+        {
+        *iTID = iBuffer;
+        iBuffer = NULL;
+        }
+    else if ( !aElement.LocalName().DesC().CompareF( KContentUrlTag8 ) )
+        {
+        *iContentUrl = iBuffer;
+        iBuffer = NULL;
+        }
+    else
+        {
+        delete iBuffer;
+        iBuffer = NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::OnContentL
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::OnContentL( const TDesC8& aBytes, TInt /*aErrorCode*/ )
+    {
+    if ( !iBuffer )
+        {
+        iBuffer = aBytes.AllocL();
+        }
+    else
+        {
+        iBuffer = iBuffer->ReAllocL( iBuffer->Length() + aBytes.Length() );
+        iBuffer->Des().Append( aBytes );
+        }
+ 
+   }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::OnStartPrefixMappingL
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::OnStartPrefixMappingL(
+    const RString& /*aPrefix*/,
+    const RString& /*aUri*/,
+    TInt /*aErrorCode*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::OnEndPrefixMappingL
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::OnEndPrefixMappingL(
+    const RString& /*aPrefix*/,
+    TInt /*aErrorCode*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::OnIgnorableWhiteSpaceL
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::OnIgnorableWhiteSpaceL(
+    const TDesC8& /*aBytes*/,
+    TInt /*aErrorCode*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::OnSkippedEntityL
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::OnSkippedEntityL(
+    const RString& /*aName*/,
+    TInt /*aErrorCode*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::OnProcessingInstructionL
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::OnProcessingInstructionL(
+    const TDesC8& /*aTarget*/,
+    const TDesC8& /*aData*/,
+    TInt /*aErrorCode*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::OnError
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaParser::OnError( TInt aErrorCode )
+    {
+    iErrorCode = aErrorCode;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaParser::GetExtendedInterface
+// From MContentHandler
+// ----------------------------------------------------------------------------
+//
+TAny* CWmDrmDlaParser::GetExtendedInterface( const TInt32 /* aUid */ )
+    {
+    return NULL;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/src/wmdrmdlaplugincontainer.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,160 @@
+/*
+* 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:  Implementation class for WMDRM DLA plugin container
+*
+*/
+
+
+#include <wmdrmdlahttpplugin.h>
+#include <wmdrmdlauinotifier.h>
+#include "wmdrmdlaplugincontainer.h"
+
+#define _LOGGING_FILE L"wmdrmdla.txt"
+#include "logfn.h"
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaPluginContainer::ConstructL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::CWmDrmDlaPluginContainer
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaPluginContainer::CWmDrmDlaPluginContainer()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaPluginContainer* CWmDrmDlaPluginContainer::NewL()
+    {
+    LOGFN( "CWmDrmDlaPluginContainer::NewL" );
+    CWmDrmDlaPluginContainer* self = CWmDrmDlaPluginContainer::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::NewLC
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaPluginContainer* CWmDrmDlaPluginContainer::NewLC()
+    {
+    LOGFN( "CWmDrmDlaPluginContainer::NewLC" );
+    CWmDrmDlaPluginContainer* self = new( ELeave ) CWmDrmDlaPluginContainer;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::~CWmDrmDlaPluginContainer
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaPluginContainer::~CWmDrmDlaPluginContainer()
+    {
+    LOGFN( "CWmDrmDlaPluginContainer::~CWmDrmDlaPluginContainer" );
+    delete iHttpPlugin;
+    delete iUiNotifier;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::SetHttpPlugin
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaPluginContainer::SetHttpPlugin( 
+    CWmDrmDlaHttpPluginIf* aHttpPlugin )
+    {
+    LOGFN( "CWmDrmDlaPluginContainer::SetHttpPlugin" );
+    iHttpPlugin = aHttpPlugin;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::GetHttpPlugin
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaPluginContainer::GetHttpPlugin(
+    CWmDrmDlaHttpPluginIf*& aHttpPlugin )
+    {
+    LOGFN( "CWmDrmDlaPluginContainer::GetHttpPlugin" );
+    aHttpPlugin = iHttpPlugin;
+    iHttpPlugin = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::HttpPlugin
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaHttpPluginIf* CWmDrmDlaPluginContainer::HttpPlugin()
+    {
+    LOGFN( "CWmDrmDlaPluginContainer::HttpPlugin" );
+    return iHttpPlugin;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::SetUiNotifier
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaPluginContainer::SetUiNotifier( 
+    CWmDrmDlaUiNotifier* aUiNotifier )
+    {
+    LOGFN( "CWmDrmDlaPluginContainer::SetUiNotifier" );
+    iUiNotifier = aUiNotifier;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::UiNotifier
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaPluginContainer::GetUiNotifier(
+    CWmDrmDlaUiNotifier*& aUiNotifier )
+    {
+    LOGFN( "CWmDrmDlaPluginContainer::GetUiNotifier" );
+    aUiNotifier = iUiNotifier;
+    iUiNotifier = NULL;
+    }
+    
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::SetIndex
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaPluginContainer::SetIndex( TInt aIndex )
+    {
+    LOGFN( "CWmDrmDlaPluginContainer::SetIndex" );
+    iIndex = aIndex;
+    LOG2( "iIndex: %d", iIndex );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaPluginContainer::Index
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaPluginContainer::Index()
+    {
+    LOGFN( "CWmDrmDlaPluginContainer::Index" );
+    LOG2( "iIndex: %d", iIndex );
+    return iIndex;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/src/wmdrmdlarequest.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,157 @@
+/*
+* 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:  Implementation of request container class
+*
+*/
+
+
+// INCLUDES
+#include "wmdrmdlarequest.h"
+
+#define _LOGGING_FILE L"wmdrmdla.txt"
+#include "logfn.h"
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaRequest::NewL
+// ----------------------------------------------------------------------------
+//
+CWmDrmDlaRequest* CWmDrmDlaRequest::NewL(
+    const TDesC8& aDrmHeader,
+    HBufC* aErrorUrl,
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData,
+    TBool aSync,
+    TRequestStatus& aStatus)
+    {
+    LOGFN( "CWmDrmDlaRequest::NewL(1)" );
+    CWmDrmDlaRequest* self = new (ELeave) CWmDrmDlaRequest();
+    CleanupStack::PushL( self );
+    self->ConstructL( aDrmHeader, aErrorUrl, aContentUrl, 
+                      aHtmlData, aSync, aStatus );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaRequest::NewL
+// ----------------------------------------------------------------------------
+//
+CWmDrmDlaRequest* CWmDrmDlaRequest::NewL(
+    const RFile& aFileHandle, 
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData,
+    TBool aSync,
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaRequest::NewL(2)" );
+    CWmDrmDlaRequest* self = new (ELeave) CWmDrmDlaRequest();
+    CleanupStack::PushL( self );
+    self->ConstructL( aFileHandle, aContentUrl, aHtmlData, aSync, aStatus );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaRequest::NewL
+// ----------------------------------------------------------------------------
+//
+CWmDrmDlaRequest* CWmDrmDlaRequest::NewL( 
+    const TDesC8& aCertificate,
+    TBool aSync,
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaRequest::NewL(3)" );
+    CWmDrmDlaRequest* self = new (ELeave) CWmDrmDlaRequest();
+    CleanupStack::PushL( self );
+    self->ConstructL( aCertificate, aSync, aStatus );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaRequest::~CWmDrmDlaRequest
+// ----------------------------------------------------------------------------
+//
+CWmDrmDlaRequest::~CWmDrmDlaRequest()
+    {
+    LOGFN( "CWmDrmDlaRequest::~CWmDrmDlaRequest" );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaRequest::CWmDrmDlaRequest
+// ----------------------------------------------------------------------------
+//
+CWmDrmDlaRequest::CWmDrmDlaRequest()
+    {
+    LOGFN( "CWmDrmDlaRequest::CWmDrmDlaRequest" );
+    }
+
+// ----------------------------------------------------------------------------
+// CAcquireLicenseFromDrmHeaderRequest::ConstructL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaRequest::ConstructL(
+    const TDesC8& aDrmHeader, 
+    HBufC* aErrorUrl,
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData,
+    TBool aSync,
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaRequest::ConstructL(1)" );
+    iType = EAcquireLicenseFromDrmHeader;
+    iDrmHeader = &aDrmHeader;
+    iErrorUrl = aErrorUrl;
+	iContentUrl = &aContentUrl; 
+	iHtmlData = &aHtmlData;
+	iSync = aSync;
+    iStatus = &aStatus;
+    }
+
+// ----------------------------------------------------------------------------
+// CAcquireLicenseFromDrmHeaderRequest::ConstructL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaRequest::ConstructL(
+    const RFile& aFileHandle, 
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData,
+    TBool aSync,
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaRequest::ConstructL(2)" );
+    iType = EAcquireLicenseFromFileHandle;
+    iFileHandle = &aFileHandle;
+    iContentUrl = &aContentUrl; 
+	iHtmlData = &aHtmlData;
+	iSync = aSync;
+    iStatus = &aStatus;
+    }
+
+// ----------------------------------------------------------------------------
+// CAcquireLicenseFromDrmHeaderRequest::ConstructL
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaRequest::ConstructL(
+    const TDesC8& aCertificate,
+    TBool aSync,
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaRequest::ConstructL(3)" );
+    iType = EProcessMeteringCertificate;
+    iCertificate = &aCertificate;
+    iSync = aSync;
+    iStatus = &aStatus;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/src/wmdrmdlauinotifier.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,136 @@
+/*
+* 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:  Implementation of WMDRM DLA UI Notifier
+*
+*/
+
+
+#include <wmdrmdlauinotifier.h>
+#include <wmdrmdlacancelobserver.h>
+#include "wmdrmdlauinotifierimpl.h"
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifier::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUiNotifier::ConstructL()
+    {
+    iImpl = CWmDrmDlaUiNotifierImpl::NewL();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifier::CWmDrmDlaUiNotifier
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaUiNotifier::CWmDrmDlaUiNotifier()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifier::NewL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CWmDrmDlaUiNotifier* CWmDrmDlaUiNotifier::NewL()
+    {
+    CWmDrmDlaUiNotifier* self = CWmDrmDlaUiNotifier::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifier::NewLC
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CWmDrmDlaUiNotifier* CWmDrmDlaUiNotifier::NewLC()
+    {
+    CWmDrmDlaUiNotifier* self = new( ELeave ) CWmDrmDlaUiNotifier;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifier::~CWmDrmDlaUiNotifier
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaUiNotifier::~CWmDrmDlaUiNotifier()
+    {
+    delete iImpl;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifier::InitializeL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaUiNotifier::InitializeL( 
+    TUid aUid )
+    {
+    iImpl->InitializeL( aUid );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifier::InitializeL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaUiNotifier::InitializeL( 
+    TDesC8& aOpaqueData )
+    {
+    iImpl->InitializeL( aOpaqueData );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifier::SetCancelObserver
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaUiNotifier::SetCancelObserver( 
+    MWmDrmDlaCancelObserver* aObserver )
+    {
+    iImpl->SetCancelObserver( aObserver );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifier::SetSilent
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaUiNotifier::SetSilent( 
+    TBool aSilent )
+    {
+    iImpl->SetSilent( aSilent );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifier::SetLicenseAcquisitionProgress
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaUiNotifier::SetProgress( 
+    TInt aState )
+    {
+    iImpl->SetProgress( aState );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifier::HandleErrorL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaUiNotifier::HandleErrorL( 
+    TInt aError )
+    {
+    iImpl->HandleErrorL( aError );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdla/src/wmdrmdlauinotifierimpl.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,207 @@
+/*
+* 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:  Implementation of WMDRM DLA UI Notifier Impl.
+*
+*/
+
+
+#include <ecom/ecom.h>
+#include <wmdrmdlacancelobserver.h>
+#include "wmdrmdlauinotifierimpl.h"
+#include "wmdrmdlauiplugin.h"
+
+#define _LOGGING_FILE L"wmdrmdla.txt"
+#include "logfn.h"
+
+//CONSTANTS
+const TUid KWmDrmDlaDefaultUiPluginUid = { 0x20019575 };
+
+// ======== LOCAL FUNCTIONS ========
+
+// -----------------------------------------------------------------------------
+// DoResetDestroyAndClose
+// Does ResetAndDestroy() and Close to given RImplInfoPtrArray
+// -----------------------------------------------------------------------------
+LOCAL_C void DoResetDestroyAndClose( TAny* aPtr )
+    {
+    ( reinterpret_cast<RImplInfoPtrArray*>( aPtr ) )->ResetAndDestroy();
+    ( reinterpret_cast<RImplInfoPtrArray*>( aPtr ) )->Close();
+    }
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifierImpl::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUiNotifierImpl::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaUiNotifierImpl::ConstructL" );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifierImpl::CWmDrmDlaUiNotifierImpl
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaUiNotifierImpl::CWmDrmDlaUiNotifierImpl()
+    {
+    LOGFN( "CWmDrmDlaUiNotifierImpl::CWmDrmDlaUiNotifierImpl" );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifierImpl::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaUiNotifierImpl* CWmDrmDlaUiNotifierImpl::NewL()
+    {
+    LOGFN( "CWmDrmDlaUiNotifierImpl::NewL" );
+    CWmDrmDlaUiNotifierImpl* self = CWmDrmDlaUiNotifierImpl::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifierImpl::NewLC
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaUiNotifierImpl* CWmDrmDlaUiNotifierImpl::NewLC()
+    {
+    LOGFN( "CWmDrmDlaUiNotifierImpl::NewLC" );
+    CWmDrmDlaUiNotifierImpl* self = new( ELeave ) CWmDrmDlaUiNotifierImpl;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifierImpl::~CWmDrmDlaUiNotifierImpl
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaUiNotifierImpl::~CWmDrmDlaUiNotifierImpl()
+    {
+    LOGFN( "CWmDrmDlaUiNotifierImpl::~CWmDrmDlaUiNotifierImpl" );
+    delete iUiPlugin;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifierImpl::InitializeL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUiNotifierImpl::InitializeL( 
+    TUid aUid )
+    {
+    LOGFN( "CWmDrmDlaUiNotifierImpl::InitializeL" );
+    LOG2( "aUid: %d", aUid );
+    delete iUiPlugin;
+    iUiPlugin = NULL;
+    iUiPlugin = CWmDrmDlaUiPluginIf::NewL( aUid );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifierImpl::InitializeL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUiNotifierImpl::InitializeL( 
+    TDesC8& aOpaqueData )
+    {
+    TInt err( KErrNotFound );
+    
+    LOGFNR( "CWmDrmDlaUiNotifierImpl::InitializeL", err );
+    LOGHEX( aOpaqueData.Ptr(), aOpaqueData.Length() );
+        
+    delete iUiPlugin;
+    iUiPlugin = NULL;
+    RImplInfoPtrArray implArray;
+    CleanupStack::PushL( TCleanupItem( DoResetDestroyAndClose, &implArray ) );
+    REComSession::ListImplementationsL( KWmDrmDlaUiPluginIfUid, implArray );
+    
+    for ( TInt i( 0 ); i < implArray.Count() && err == KErrNotFound; ++i )
+        {
+        if ( aOpaqueData.CompareF( implArray[i]->OpaqueData() ) == 0 &&
+             implArray[i]->VendorId() == VID_DEFAULT  )
+            {
+            err = KErrNone;
+            iUiPlugin = 
+                CWmDrmDlaUiPluginIf::NewL( implArray[i]->ImplementationUid() );
+            }
+        }
+    if ( err == KErrNotFound )
+        {
+        err = KErrNone;
+        iUiPlugin = CWmDrmDlaUiPluginIf::NewL( KWmDrmDlaDefaultUiPluginUid );
+        }
+    CleanupStack::PopAndDestroy( &implArray );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifierImpl::SetCancelObserver
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUiNotifierImpl::SetCancelObserver( 
+    MWmDrmDlaCancelObserver* aObserver )
+    {
+    LOGFN( "CWmDrmDlaUiNotifierImpl::SetCancelObserver" );
+    if ( iUiPlugin )
+        {
+        iUiPlugin->SetCancelObserver( aObserver );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifierImpl::SetSilent
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUiNotifierImpl::SetSilent( 
+    TBool aSilent )
+    {
+    LOGFN( "CWmDrmDlaUiNotifierImpl::SetSilent" );
+    LOG2( "aSilent: %d", aSilent );
+    if ( iUiPlugin )
+        {
+        iUiPlugin->SetSilent( aSilent );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifierImpl::SetProgress
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUiNotifierImpl::SetProgress( 
+    TInt aState )
+    {
+    LOGFN( "CWmDrmDlaUiNotifierImpl::SetProgress" );
+    LOG2( "aState: %d", aState );
+    if ( iUiPlugin )
+        {
+        iUiPlugin->SetProgress( aState );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUiNotifierImpl::HandleErrorL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUiNotifierImpl::HandleErrorL( 
+    TInt aError )
+    {
+    LOGFN( "CWmDrmDlaUiNotifierImpl::HandleErrorL" );
+    LOG2( "aError: %d", aError );
+    if ( iUiPlugin )
+        {
+        iUiPlugin->HandleErrorL( aError );
+        }
+    }
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/data/wmdrmdlaapp.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for project wmdrmdlaapp
+*
+*/
+
+
+// RESOURCE IDENTIFIER
+NAME DLAB
+
+// INCLUDES
+#include <eikon.rh>
+#include <eikon.rsg>
+#include <avkon.loc>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <appinfo.rh>
+
+// RESOURCE DEFINITIONS 
+
+RESOURCE RSS_SIGNATURE { }
+
+RESOURCE TBUF { buf = ""; }
+
+RESOURCE EIK_APP_INFO
+    {
+    }
+
+RESOURCE AVKON_VIEW r_wmdrmdla_app_browser_view
+    {
+    cba = R_AVKON_SOFTKEYS_CLOSE;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/data/wmdrmdlaapp_reg.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,36 @@
+/*
+* 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:  Resource definitions for project wmdrmdlaapp
+*
+*/
+
+
+#include <appinfo.rh>
+#include <data_caging_paths_strings.hrh>
+#include <wmdrmdlaapp.rsg>
+
+UID2 KUidAppRegistrationResourceFile
+UID3 0x2001E5E1
+
+RESOURCE APP_REGISTRATION_INFO
+    {
+    app_file = "wmdrmdlaapp";
+    localisable_resource_file = APP_RESOURCE_DIR"\\wmdrmdlaapp";
+    hidden = KAppIsHidden;
+    embeddability = KAppEmbeddableOnly;
+    service_list =
+        {
+        SERVICE_INFO { uid = 0x2001E5E3; }
+        };
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* 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:  Build Information file for project wmdrmdlaapp
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+wmdrmdlaapp.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/group/wmdrmdlaapp.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,65 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project wmdrmdlaapp
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET          wmdrmdlaapp.exe
+TARGETTYPE      exe
+UID             0x100039CE 0x2001E5E1
+CAPABILITY      CAP_APPLICATION NetworkControl
+VENDORID        VID_DEFAULT
+
+SOURCEPATH  ../src
+
+SOURCE      wmdrmdlaapp.cpp
+SOURCE      wmdrmdlaappui.cpp
+SOURCE      wmdrmdlaappdocument.cpp
+SOURCE		wmdrmdlabrowserview.cpp
+SOURCE		wmdrmdlabrowsercontainer.cpp
+SOURCE		wmdrmdlaappserver.cpp
+SOURCE		wmdrmdlaappservicesession.cpp
+
+START RESOURCE ../data/wmdrmdlaapp.rss
+HEADER
+TARGETPATH APP_RESOURCE_DIR
+LANGUAGE_IDS
+END
+
+USERINCLUDE     ../inc
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY		euser.lib
+LIBRARY		efsrv.lib
+LIBRARY		flogger.lib
+LIBRARY		apparc.lib
+LIBRARY		cone.lib
+LIBRARY		eikcore.lib
+LIBRARY		avkon.lib
+LIBRARY		bafl.lib
+LIBRARY		commonengine.lib
+LIBRARY     browserengine.lib
+LIBRARY		connectionmanager.lib
+
+START RESOURCE ../data/wmdrmdlaapp_reg.rss
+DEPENDS wmdrmdlaapp.rsg
+// Do not change the UID below.
+TARGETPATH /private/10003a3f/apps
+END
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaapp.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface class for WMDRM DLA App
+*
+*/
+
+
+#ifndef C_WMDRMDLAAPP_H
+#define C_WMDRMDLAAPP_H
+
+// INCLUDES
+#include <aknapp.h>
+
+class CWmDrmDlaApp : public CAknApplication
+    {
+    
+    public:    // from CAknApplication (CApaApplication)
+
+        /**
+        * Create document object.
+        * @return A pointer to the created document object.
+        */
+        CApaDocument* CreateDocumentL();
+        
+        /**
+        * Return application's UID.
+        * @return Application UID.
+        */
+        TUid AppDllUid() const;
+        
+        /**
+         * Sets new application server.
+         * @param aAppServer The server pointer to be set.
+         */
+        void NewAppServerL( CApaAppServer*& aAppServer );
+        
+    };
+
+#endif // C_WMDRMDLAAPP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaappconstants.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface class for WMDRM DLA App Constants
+*
+*/
+
+
+#ifndef WMDRMDLAAPPCONSTANTS_H
+#define WMDRMDLAAPPCONSTANTS_H
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <apaserverapp.h>
+
+//Application UID
+const TUid KWmDrmDlaAppUid = { 0x2001E5E1 };
+
+//Application Server Service ID
+const TUid KWmDrmDlaAppServiceId = { 0x2001E5E3 };
+
+//Browser View ID
+const TUid KWmDrmDlaAppBrowserViewId = { 0x1 };
+
+//Service Commands
+enum TWmDrmDlaServiceCmd
+    {
+    ESetIAP = RApaAppServiceBase::KServiceCmdBase,
+    EPost,
+    EGetLicenseResponseSize,
+    EGetLicenseResponse
+    };
+
+#endif // WMDRMDLAAPPCONSTANTS_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaappdocument.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,67 @@
+/*
+* 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:  Interface class for WMDRM DLA App Document
+*
+*/
+
+
+#ifndef C_WMDRMDLAAPPDOCUMENT_H
+#define C_WMDRMDLAAPPDOCUMENT_H
+
+// INCLUDES
+#include <akndoc.h>
+
+class CWmDrmDlaAppDocument : public CAknDocument
+    {
+
+    public: // Constructors and destructor
+
+        /**
+        * Two-phased constructor. Leaves on failure.
+        * @param aApp Application.
+        * @return The created document.
+        */
+        static CWmDrmDlaAppDocument* NewL( CEikApplication& aApp );
+
+        /**
+        * Destructor.
+        */
+        virtual ~CWmDrmDlaAppDocument();
+
+    public: // from CEikDocument
+
+        /**
+        * Create Application Ui.
+        * @return Pointer to App Ui.
+        */
+        CEikAppUi* CreateAppUiL();
+    
+    public: // Constructors
+
+        /**
+        * Constructor.
+        * @param aApp Application.
+        */
+        CWmDrmDlaAppDocument( CEikApplication& aApp );
+
+        /**
+        * Second phase constructor. Leaves on failure.
+        */
+        void ConstructL();
+
+    private:    // data
+
+    };
+
+#endif // C_WMDRMDLAAPPDOCUMENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaappserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface class for WMDRM DLA App Server
+*
+*/
+
+
+#ifndef C_WMDRMDLAAPPSERVER_H
+#define C_WMDRMDLAAPPSERVER_H
+
+// INCLUDES
+#include <aknserverapp.h>
+
+class CWmDrmDlaAppServer : public CAknAppServer
+    {
+    
+    public: // from CAknAppServer
+        
+        CApaAppServiceBase* CreateServiceL( TUid aServiceType ) const;
+    
+    };
+
+#endif // C_WMDRMDLAAPPSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaappservicesession.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,70 @@
+/*
+* 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:  Interface class for WMDRM DLA App Service Session
+*
+*/
+
+
+#ifndef C_WMDRMDLAAPPSERVICESESSION_H
+#define C_WMDRMDLAAPPSERVICESESSION_H
+
+// INCLUDES
+#include <aknserverapp.h>
+#include "wmdrmdlaappui.h"
+#include "wmdrmdlabrowserview.h"
+
+/**
+* WMDRM DLA Application.
+*/
+class CWmDrmDlaAppServiceSession : public CAknAppServiceBase, 
+                                   public MBrowserViewLicenseReceivedCallback
+    {
+    
+    public:
+    
+        CWmDrmDlaAppServiceSession();
+        virtual ~CWmDrmDlaAppServiceSession();
+    
+    public: // from MBrowserViewLicenseReceivedCallback
+        
+        /**
+         * Called when license is received
+         */
+        void LicenseReceived();
+    
+    protected: // from CSession2
+
+        /**
+         * Override of CSession2::ServiceL().
+         * If further overridden, this function must be base-called.
+         * @param aMessage The client message
+         */
+        void ServiceL( const RMessage2& aMessage );
+
+    private:
+        
+        void SetIapL( const RMessage2& aMessage );
+        void PostL( const RMessage2& aMessage );
+        void LicenseResponseSizeL( const RMessage2& aMessage );
+        void LicenseResponseL( const RMessage2& aMessage );
+        void CompleteMessage( const RMessage2& aMessage, TInt aError );
+        CWmDrmDlaBrowserView* BrowserView();
+    
+    private: //data
+        
+        CActiveSchedulerWait* iWait;
+        
+    };
+
+#endif // C_WMDRMDLAAPPSERVICESESSION_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlaappui.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,68 @@
+/*
+* 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:  Interface class for WMDRM DLA App Ui
+*
+*/
+
+
+#ifndef C_WMDRMDLAAPPUI_H
+#define C_WMDRMDLAAPPUI_H
+
+// INCLUDES
+#include <aknviewappui.h>
+#include <aknserverapp.h>
+
+class CWmDrmDlaBrowserView;
+
+class CWmDrmDlaAppUi : public CAknViewAppUi
+    {
+
+    public:     // Constructors and destructor
+
+        /**
+        * Constructor.
+        */      
+        CWmDrmDlaAppUi();
+        
+        /**
+        * Second phase constructor. Leaves on failure.
+        */      
+        void ConstructL();
+
+        /**
+        * Destructor.
+        */      
+        virtual ~CWmDrmDlaAppUi();
+        
+        /**
+         * Get browser view
+         */
+        CWmDrmDlaBrowserView* BrowserView();
+
+    private: // From CEikAppUi
+
+        /**
+         * From CEikAppUi, takes care of command handling.
+         * @param aCommand command to be handled
+         */
+        void HandleCommandL( TInt aCommand );    
+        
+    private:    // data
+
+        //Not owned
+        CWmDrmDlaBrowserView* iBrowserView;
+        
+    };
+
+#endif // C_WMDRMDLAAPPUI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlabrowsercontainer.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface class for WMDRM DLA Browser Container
+*
+*/
+
+
+#ifndef C_WMDRMDLABROWSERCONTAINER_H
+#define C_WMDRMDLABROWSERCONTAINER_H
+
+#include <coecntrl.h>
+
+class CAknView;
+class MBrCtlSpecialLoadObserver;
+class CBrCtlInterface;
+
+class CWmDrmDlaBrowserContainer : public CCoeControl
+    {
+
+    public:
+
+        static CWmDrmDlaBrowserContainer* NewL( CAknView* aView, 
+                                                MBrCtlSpecialLoadObserver* aObserver );
+        static CWmDrmDlaBrowserContainer* NewLC( CAknView* aView, 
+                                                 MBrCtlSpecialLoadObserver* aObserver );
+
+        /**
+         * Destructor.
+         */
+        virtual ~CWmDrmDlaBrowserContainer();
+        
+        /**
+         * Returns pointer to the CBrCtlInterface owned by the container.
+         * @return A pointer to CBrCtlInterface
+         */        
+        CBrCtlInterface* BrCtlInterface();
+    
+        
+    public: // From CCoeControl
+
+        /**
+         * @see CCoeControl
+         */
+        TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
+        
+        /**
+         * @see CCoeControl
+         */
+        TInt CountComponentControls() const;
+
+        /**
+         * @see CCoeControl
+         */
+        CCoeControl* ComponentControl( TInt aIndex ) const;
+
+        /**
+         * @see CCoeControl
+         */
+        void SizeChanged();
+
+        /**
+         * @see CCoeControl
+         */
+        void FocusChanged( TDrawNow aDrawNow );
+        
+        /**
+         * @see CCoeControl
+         */
+        void HandleResourceChange( TInt aType );    
+    
+    private:
+
+        CWmDrmDlaBrowserContainer( CAknView* aView );
+        void ConstructL( MBrCtlSpecialLoadObserver* aObserver );
+
+    private: // data
+   
+        //Not owned
+        CAknView* iView;
+        
+        CBrCtlInterface* iBrCtlInterface;
+        
+    };
+
+#endif // C_WMDRMDLABROWSERCONTAINER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/inc/wmdrmdlabrowserview.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,141 @@
+/*
+* 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:  Interface class for WMDRM DLA Browser View
+*
+*/
+
+
+#ifndef C_WMDRMDLABROWSERVIEW_H
+#define C_WMDRMDLABROWSERVIEW_H
+
+#include <aknview.h>
+#include <brctlspecialloadobserver.h>
+
+class CWmDrmDlaBrowserContainer;
+class CInternetConnectionManager;
+
+/**
+ * Interface for license received callback.
+ */
+class MBrowserViewLicenseReceivedCallback
+    {
+    public: 
+        
+        virtual void LicenseReceived() = 0;
+
+    };
+
+class CWmDrmDlaBrowserView : public CAknView, 
+                             public MBrCtlSpecialLoadObserver
+    {
+
+    public:
+
+        static CWmDrmDlaBrowserView* NewL();
+        static CWmDrmDlaBrowserView* NewLC();
+
+        /**
+         * Destructor.
+         */
+        virtual ~CWmDrmDlaBrowserView();
+        
+        /**
+         * Set the IAP that is used in network connection
+         * @param aIap - IAP to be used 
+         */
+        void SetIAP( TInt aIap );
+        
+        /**
+         * Make a POST-request
+         * @param aCallback - Callback used to inform when license 
+         *                    response is received
+         * @param aPostUrl - Post URL
+         * @param aPostContentType - Post content type
+         * @param aPostData - Post data
+         * @param aPostContentBoundary - Post content boundary
+         */
+        void PostL( MBrowserViewLicenseReceivedCallback* aCallback,
+                    const TDesC& aPostUrl,
+                    const TDesC8& aPostContentType,
+                    const TDesC8& aPostData,
+                    const TDesC8& aPostContentBoundary );
+        
+        /**
+         * Get the license response
+         * @return License response or NULL
+         */
+        HBufC8* LicenseResponse();
+
+    public: // From CAknView
+
+        /**
+        * @see CAknView
+        */
+        TUid Id() const;
+
+        /**
+        * @see CAknView
+        */
+        void HandleCommandL( TInt aCommand );
+
+        /** 
+        * @see CAknView
+        */
+        void DoActivateL( const TVwsViewId& aPrevViewId,
+                          TUid aCustomMessageId,
+                          const TDesC8& aCustomMessage );
+        /**
+        * @see CAknView
+        */
+        void DoDeactivate();
+
+        /**
+        * @see CAknView
+        */
+        void HandleClientRectChange();    
+    
+    public: // From MBrCtlSpecialLoadObserver
+
+        void NetworkConnectionNeededL( TInt* aConnectionPtr, 
+                                       TInt* aSockSvrHandle, 
+                                       TBool* aNewConn, 
+                                       TApBearerType* aBearerType );
+
+        TBool HandleRequestL( RArray<TUint>* aTypeArray, 
+                              CDesCArrayFlat* aDesArray );
+
+        TBool HandleDownloadL( RArray<TUint>* aTypeArray, 
+                               CDesCArrayFlat* aDesArray );    
+        
+    private:
+
+        CWmDrmDlaBrowserView();
+        void ConstructL();
+        
+        void CreateContainerL();
+        void RemoveContainer();
+        void BrCtlHandleCommandL( TInt aCommand );
+
+    private: // data
+
+        //Not Owned
+        MBrowserViewLicenseReceivedCallback* iCallback;
+        
+        CWmDrmDlaBrowserContainer* iContainer;
+        HBufC8* iLicenseResponse;
+        CInternetConnectionManager* iConMgr;
+        TInt iIap;
+    };
+
+#endif // C_WMDRMDLABROWSERVIEW_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/src/wmdrmdlaapp.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,74 @@
+/*
+* 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:  Implementation class for WMDRM DLA App
+*
+*/
+
+
+// INCLUDE FILES
+#include <eikstart.h>
+#include "wmdrmdlaapp.h"
+#include "wmdrmdlaappdocument.h"
+#include "wmdrmdlaappserver.h"
+#include "wmdrmdlaappconstants.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaApp::CreateDocumentL
+// ---------------------------------------------------------------------------
+//
+CApaDocument* CWmDrmDlaApp::CreateDocumentL()
+    {
+    return CWmDrmDlaAppDocument::NewL( *this );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaApp::AppDllUid
+// ---------------------------------------------------------------------------
+//
+TUid CWmDrmDlaApp::AppDllUid() const
+    {
+    return KWmDrmDlaAppUid;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaApp::NewAppServerL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaApp::NewAppServerL( CApaAppServer*& aAppServer )
+    {
+    aAppServer = new (ELeave) CWmDrmDlaAppServer;
+    }
+
+// ================= OTHER FUNCTIONS ==============
+
+/**
+* Create application object.
+* @return The created application object.
+*/
+LOCAL_C CApaApplication* NewApplication()
+    {
+    return new CWmDrmDlaApp;
+    }
+
+/**
+* Executable entry point.
+* @return Error code.
+*/
+GLDEF_C TInt E32Main()
+    {
+    return EikStart::RunApplication( NewApplication );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/src/wmdrmdlaappdocument.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,71 @@
+/*
+* 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:  Implementation class for WMDRM DLA App Document
+*
+*/
+
+
+// INCLUDE FILES
+#include "wmdrmdlaappdocument.h"
+#include "wmdrmdlaappui.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppDocument::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaAppDocument* CWmDrmDlaAppDocument::NewL( 
+    CEikApplication& aApp )
+    {
+    CWmDrmDlaAppDocument* self = new (ELeave) CWmDrmDlaAppDocument( aApp );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppDocument::~CWmDrmDlaAppDocument
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaAppDocument::~CWmDrmDlaAppDocument()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppDocument::CreateAppUiL
+// ---------------------------------------------------------------------------
+//
+CEikAppUi* CWmDrmDlaAppDocument::CreateAppUiL()
+    {
+    return new (ELeave) CWmDrmDlaAppUi;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppDocument::CWmDrmDlaAppDocument
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaAppDocument::CWmDrmDlaAppDocument( 
+    CEikApplication& aApp ) : CAknDocument( aApp )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppDocument::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaAppDocument::ConstructL()
+    {
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/src/wmdrmdlaappserver.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,38 @@
+/*
+* 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:  Implementation class for WMDRM DLA App Server
+*
+*/
+
+
+// INCLUDE FILES
+#include "wmdrmdlaappserver.h"
+#include "wmdrmdlaappservicesession.h"
+#include "wmdrmdlaappconstants.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppServer::CreateServiceL
+// ---------------------------------------------------------------------------
+//
+CApaAppServiceBase* CWmDrmDlaAppServer::CreateServiceL( 
+    TUid aServiceType ) const
+    {
+    if ( aServiceType == KWmDrmDlaAppServiceId )
+        {
+        return new (ELeave) CWmDrmDlaAppServiceSession;
+        }
+    return CAknAppServer::CreateServiceL( aServiceType );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/src/wmdrmdlaappservicesession.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,246 @@
+/*
+* 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:  Implementation class for WMDRM DLA App Service Session
+*
+*/
+
+
+// INCLUDE FILES
+#include "wmdrmdlaappui.h"
+#include "wmdrmdlabrowserview.h"
+#include "wmdrmdlaappservicesession.h"
+#include "wmdrmdlaappconstants.h"
+
+// CONSTANTS
+const TInt KSanityDataLengthLow = 0;
+const TInt KSanityDataLengthHigh = KMaxTInt32;
+
+// ============================= LOCAL FUNCTIONS ==============================
+
+// ----------------------------------------------------------------------------
+// SanitizeL
+// Performs a sanity check on length parameters
+// ----------------------------------------------------------------------------
+//
+LOCAL_C void SanitizeL( TInt aParam )
+    {
+    if ( aParam <= KSanityDataLengthLow || aParam > KSanityDataLengthHigh )
+        {
+        User::Leave( KErrArgument );
+        }
+    }
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppServiceSession::CWmDrmDlaAppServiceSession
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaAppServiceSession::CWmDrmDlaAppServiceSession()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppServiceSession::~CWmDrmDlaAppServiceSession
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaAppServiceSession::~CWmDrmDlaAppServiceSession()
+    {
+    delete iWait;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppServiceSession::LicenseReceived
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaAppServiceSession::LicenseReceived()
+    {
+    //License received, stop waiting and complete post-service
+    if ( iWait->IsStarted() )
+        {
+        iWait->AsyncStop();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppServiceSession::ServiceL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaAppServiceSession::ServiceL( const RMessage2& aMessage )
+    {
+    switch ( aMessage.Function() )
+        {
+        case ESetIAP:
+            SetIapL( aMessage );
+            break;
+        
+        case EPost:
+            PostL( aMessage );
+            break;
+        
+        case EGetLicenseResponseSize:
+            LicenseResponseSizeL( aMessage );        
+            break;
+            
+        case EGetLicenseResponse:
+            LicenseResponseL( aMessage );        
+            break;    
+            
+        default:
+             CAknAppServiceBase::ServiceL( aMessage );
+             break;
+        }
+     }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppServiceSession::SetIapL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaAppServiceSession::SetIapL( const RMessage2& aMessage )
+    {
+    TInt iap( 0 );
+    TPckg<TInt> iapPckg( iap );
+    
+    SanitizeL( aMessage.GetDesLength( 0 ) );
+    TInt size = aMessage.GetDesLength( 0 );
+    if ( size != sizeof( TInt ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    aMessage.ReadL( 0, iapPckg );
+    
+    BrowserView()->SetIAP( iap );
+    
+    CompleteMessage( aMessage, KErrNone );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppServiceSession::PostL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaAppServiceSession::PostL( const RMessage2& aMessage )
+    {
+    HBufC* postUrl( NULL );
+    TPtr ptr16( NULL, 0 );
+    HBufC8* postContentType( NULL );
+    HBufC8* postData( NULL );
+    HBufC8* postContentBoundary( NULL );
+    TPtr8 ptr8( NULL, 0 );
+    
+    SanitizeL( aMessage.GetDesLength( 0 ) );
+    postUrl = HBufC::NewLC( aMessage.GetDesLength( 0 ) );
+    ptr16.Set( postUrl->Des() );
+    aMessage.ReadL( 0, ptr16 );
+    
+    SanitizeL( aMessage.GetDesLength( 1 ) );
+    postContentType = HBufC8::NewLC( aMessage.GetDesLength( 1 ) );
+    ptr8.Set( postContentType->Des() );
+    aMessage.ReadL( 1, ptr8 );
+
+    SanitizeL( aMessage.GetDesLength( 2 ) );
+    postData = HBufC8::NewLC( aMessage.GetDesLength( 2 ) );
+    ptr8.Set( postData->Des() );
+    aMessage.ReadL( 2, ptr8 );    
+
+    SanitizeL( aMessage.GetDesLength( 3 ) );
+    postContentBoundary = HBufC8::NewLC( aMessage.GetDesLength( 3 ) );
+    ptr8.Set( postContentBoundary->Des() );
+    aMessage.ReadL( 3, ptr8 );
+    
+    BrowserView()->PostL( this, 
+                          *postUrl, 
+                          *postContentType, 
+                          *postData, 
+                          *postContentBoundary );
+    
+    CleanupStack::PopAndDestroy( 4, postUrl ); //postContentBoundary, postData,
+                                               //postContentType, postUrl
+    
+    if ( !iWait )
+        {
+        iWait = new (ELeave) CActiveSchedulerWait;
+        }
+    //Wait until license is received
+    iWait->Start();
+    
+    CompleteMessage( aMessage, KErrNone );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppServiceSession::LicenseResponseSizeL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaAppServiceSession::LicenseResponseSizeL( 
+    const RMessage2& aMessage )
+    {
+    TInt err( KErrNone );
+    
+    HBufC8* licenseResponse( BrowserView()->LicenseResponse() );
+    if ( licenseResponse )
+        {
+        TInt licenseSize( licenseResponse->Size() );
+        aMessage.WriteL( 0, TPckg<TInt>( licenseSize ) );
+        }
+    else
+        {
+        err = KErrArgument;
+        }
+    
+    CompleteMessage( aMessage, err );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppServiceSession::LicenseResponseL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaAppServiceSession::LicenseResponseL( const RMessage2& aMessage )
+    {
+    TInt err( KErrNone );
+    
+    HBufC8* licenseResponse( BrowserView()->LicenseResponse() );
+    if ( licenseResponse )
+        {
+        aMessage.WriteL( 0, *licenseResponse );
+        }
+    else
+        {
+        err = KErrArgument;
+        }
+    
+    CompleteMessage( aMessage, err );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppServiceSession::CompleteMessage
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaAppServiceSession::CompleteMessage( 
+    const RMessage2& aMessage,
+    TInt aError)
+    {
+    if ( !aMessage.IsNull() )
+        {
+        aMessage.Complete( aError );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppServiceSession::BrowserView
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserView* CWmDrmDlaAppServiceSession::BrowserView()
+    {
+    return ((CWmDrmDlaAppUi*)CEikonEnv::Static()->EikAppUi())->BrowserView();
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/src/wmdrmdlaappui.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* 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:  Implementation class for WMDRM DLA App Ui
+*
+*/
+
+
+#include "wmdrmdlaappui.h"
+#include "wmdrmdlabrowserview.h"
+#include "wmdrmdlaappconstants.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppUi::CWmDrmDlaAppUi
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaAppUi::CWmDrmDlaAppUi()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppUi::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaAppUi::ConstructL()
+    {
+    BaseConstructL( EAknEnableSkin | EAknSingleClickCompatible );
+    CWmDrmDlaBrowserView* browserView = CWmDrmDlaBrowserView::NewLC();
+    AddViewL( browserView );
+    CleanupStack::Pop( browserView );
+    iBrowserView = browserView;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppUi::~CWmDrmDlaAppUi
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaAppUi::~CWmDrmDlaAppUi()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppUi::BrowserView
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserView* CWmDrmDlaAppUi::BrowserView()
+    {
+    return iBrowserView;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaAppUi::HandleCommandL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaAppUi::HandleCommandL( TInt aCommand )
+    {
+    switch ( aCommand )
+        {
+        case EAknSoftkeyClose:
+        case EAknSoftkeyExit:
+        case EEikCmdExit:
+            Exit();
+            break;
+        
+        default:
+            break;
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/src/wmdrmdlabrowsercontainer.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,207 @@
+/*
+* 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:  Implementation class for WMDRM DLA Browser Container
+*
+*/
+
+
+// INCLUDE FILES
+#include <akndef.h>
+#include <aknview.h>
+#include <brctlinterface.h>
+#include "wmdrmdlabrowserview.h"
+#include "wmdrmdlabrowsercontainer.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserContainer::ConstructL(
+    MBrCtlSpecialLoadObserver* aObserver )
+    {
+    CreateWindowL();
+    SetRect( iView->ClientRect() );
+    ActivateL();
+    
+    iBrCtlInterface = CreateBrowserControlL(
+            this,                                      // parent control
+            iView->ClientRect(),                       // client rect
+            TBrCtlDefs::ECapabilityLoadHttpFw |
+            TBrCtlDefs::ECapabilityDisplayScrollBar |
+            TBrCtlDefs::ECapabilityUseDlMgr |
+            TBrCtlDefs::ECapabilityCursorNavigation,   // Capabilities
+            TBrCtlDefs::ECommandIdBase,                // command base
+            NULL,                                      // Softkeys observer
+            NULL,                                      // LinkResolver
+            aObserver,                                 // Special load observer
+            NULL,                                      // Layout Observer
+            NULL,                                      // Dialog provider
+            NULL,                                      // window observer
+            NULL                                       // Download observer
+            );
+
+    iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsAutoLoadImages, 
+                                         ETrue );    
+    iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsCookiesEnabled, 
+                                         ETrue );
+    iBrCtlInterface->SetBrowserSettingL( TBrCtlDefs::ESettingsEmbedded, 
+                                         ETrue );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::CWmDrmDlaBrowserContainer
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserContainer::CWmDrmDlaBrowserContainer(
+    CAknView* aView ) : iView( aView )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserContainer* CWmDrmDlaBrowserContainer::NewL(
+    CAknView* aView,
+    MBrCtlSpecialLoadObserver* aObserver )
+    {
+    CWmDrmDlaBrowserContainer* self 
+        = CWmDrmDlaBrowserContainer::NewLC( aView, aObserver );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::NewLC
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserContainer* CWmDrmDlaBrowserContainer::NewLC( 
+    CAknView* aView,
+    MBrCtlSpecialLoadObserver* aObserver )
+    {
+    CWmDrmDlaBrowserContainer* self 
+        = new( ELeave ) CWmDrmDlaBrowserContainer( aView );
+    CleanupStack::PushL( self );
+    self->ConstructL( aObserver );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::~CWmDrmDlaBrowserContainer
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserContainer::~CWmDrmDlaBrowserContainer()
+    {
+    delete iBrCtlInterface;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::BrCtlInterface
+// ---------------------------------------------------------------------------
+//
+CBrCtlInterface* CWmDrmDlaBrowserContainer::BrCtlInterface()
+    {
+    return iBrCtlInterface;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::CountComponentControls
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaBrowserContainer::CountComponentControls() const
+    {
+    if ( iBrCtlInterface )
+        {
+        return 1;
+        }
+    return 0;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::SizeChanged
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserContainer::SizeChanged()
+    {
+    if ( iBrCtlInterface )
+        {            
+        iBrCtlInterface->SetRect( Rect() );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::ComponentControl
+// ---------------------------------------------------------------------------
+//
+CCoeControl* CWmDrmDlaBrowserContainer::ComponentControl(
+    TInt aIndex ) const
+    {
+    switch ( aIndex )
+        {            
+        case 0:
+            return iBrCtlInterface;
+        
+        default:
+            return NULL;
+        }
+    }
+    
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::OfferKeyEventL
+// ---------------------------------------------------------------------------
+//
+TKeyResponse CWmDrmDlaBrowserContainer::OfferKeyEventL( 
+    const TKeyEvent& aKeyEvent,
+    TEventCode aType )
+    {
+    if ( iBrCtlInterface )
+        {
+        return iBrCtlInterface->OfferKeyEventL( aKeyEvent, aType );
+        }
+    return EKeyWasNotConsumed;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::FocusChanged
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserContainer::FocusChanged( 
+    TDrawNow aDrawNow )
+    {
+    iBrCtlInterface->SetFocus( IsFocused() );
+    CCoeControl::FocusChanged( aDrawNow );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserContainer::HandleResourceChange
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserContainer::HandleResourceChange(
+    TInt aType )
+    {
+    if ( iBrCtlInterface )
+        {
+        iBrCtlInterface->HandleResourceChange( aType );
+        }
+    CCoeControl::HandleResourceChange( aType );
+    if ( aType == KEikDynamicLayoutVariantSwitch )
+        {
+        SetRect( iView->ClientRect() );
+        DrawDeferred();
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlaapp/src/wmdrmdlabrowserview.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,322 @@
+/*
+* 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:  Implementation class for WMDRM DLA Browser View
+*
+*/
+
+
+// INCLUDE FILES
+#include <f32file.h>
+#include <bautils.h>
+#include <aknviewappui.h>
+#include <coeaui.h>
+#include <coecntrl.h>
+#include <brctlinterface.h>
+#include <internetconnectionmanager.h>
+#include <wmdrmdlaapp.rsg>
+#include "wmdrmdlabrowserview.h"
+#include "wmdrmdlabrowsercontainer.h"
+#include "wmdrmdlaappconstants.h"
+
+// CONTANTS
+_LIT( KDataTypeLicenseResponse, "application/vnd.ms-wmdrm.lic-resp" );
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserView::ConstructL()
+    {
+    BaseConstructL( R_WMDRMDLA_APP_BROWSER_VIEW );
+    iConMgr = CInternetConnectionManager::NewL( ETrue );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::CWmDrmDlaBrowserView
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserView::CWmDrmDlaBrowserView()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserView* CWmDrmDlaBrowserView::NewL()
+    {
+    CWmDrmDlaBrowserView* self = CWmDrmDlaBrowserView::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::NewLC
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserView* CWmDrmDlaBrowserView::NewLC()
+    {
+    CWmDrmDlaBrowserView* self = new( ELeave ) CWmDrmDlaBrowserView();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::~CWmDrmDlaBrowserView
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserView::~CWmDrmDlaBrowserView()
+    {
+    RemoveContainer();
+    delete iLicenseResponse;
+    delete iConMgr;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::SetIAP
+// ---------------------------------------------------------------------------
+//
+
+void CWmDrmDlaBrowserView::SetIAP( TInt aIap )
+    {
+    iIap = aIap;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::PostL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserView::PostL(
+    MBrowserViewLicenseReceivedCallback* aCallback,
+    const TDesC& aPostUrl,
+    const TDesC8& aPostContentType,
+    const TDesC8& aPostData,
+    const TDesC8& aPostContentBoundary )
+    {
+    iCallback = aCallback;
+    iContainer->BrCtlInterface()->PostUrlL( aPostUrl, 
+                                            aPostContentType, 
+                                            aPostData, 
+                                            &aPostContentBoundary, 
+                                            (TAny*)iContainer );
+    iContainer->BrCtlInterface()->SetFocus( ETrue, EDrawNow );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::LicenseResponse
+// ---------------------------------------------------------------------------
+//
+
+HBufC8* CWmDrmDlaBrowserView::LicenseResponse()
+    {
+    return iLicenseResponse;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::Id
+// ---------------------------------------------------------------------------
+//
+TUid CWmDrmDlaBrowserView::Id() const
+    {
+    return KWmDrmDlaAppBrowserViewId;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::HandleCommandL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserView::HandleCommandL(
+    TInt aCommand )
+    {
+    if ( aCommand >= TBrCtlDefs::ECommandIdBase + 
+                     TBrCtlDefs::ECommandIdWMLBase &&
+         aCommand <= TBrCtlDefs::ECommandIdBase + 
+                     TBrCtlDefs::ECommandIdRange )
+        {
+        BrCtlHandleCommandL( aCommand );
+        }
+    else
+        {
+        AppUi()->HandleCommandL( aCommand );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::DoActivateL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserView::DoActivateL(
+    const TVwsViewId& /*aPrevViewId*/,
+    TUid /*aCustomMessageId*/,
+    const TDesC8& /*aCustomMessage*/ )
+    {  
+    CreateContainerL();
+    AppUi()->AddToStackL( *this, iContainer );
+    HandleClientRectChange();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::DoDeactivate
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserView::DoDeactivate()
+    {
+    RemoveContainer();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::HandleClientRectChange
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserView::HandleClientRectChange()
+    {
+    if ( iContainer )
+        {
+        iContainer->SetRect( ClientRect() );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::CreateContainerL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserView::CreateContainerL()
+    {
+    RemoveContainer();
+    iContainer = CWmDrmDlaBrowserContainer::NewL( this, this );
+    iContainer->SetMopParent( this );    
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::RemoveContainer
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserView::RemoveContainer()
+    {
+    if ( iContainer )
+        {
+        AppUi()->RemoveFromViewStack( *this, iContainer );
+        delete iContainer;
+        iContainer = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::BrCtlHandleCommandL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserView::BrCtlHandleCommandL( TInt aCommand )
+    {
+    iContainer->BrCtlInterface()->HandleCommandL( aCommand );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::NetworkConnectionNeededL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserView::NetworkConnectionNeededL( 
+    TInt* aConnectionPtr, 
+    TInt* aSockSvrHandle, 
+    TBool* aNewConn, 
+    TApBearerType* aBearerType )
+    {
+    TInt ret( 0 );
+    // If not connected, try to start a new connection
+    if ( !iConMgr->Connected() )
+        {
+        iConMgr->SetRequestedAP( iIap );
+        ret = iConMgr->StartConnectionL( ETrue );
+        }
+    
+    // If connected, return needed info to framework
+    if ( !ret )
+        {
+        *aConnectionPtr =  reinterpret_cast<TInt>(&iConMgr->Connection() );
+        *aSockSvrHandle =  iConMgr->SocketServer().Handle();
+        *aNewConn = EFalse;
+        *aBearerType = EApBearerTypeAllBearers;
+        }
+    else 
+        {
+        User::Leave( KErrCancel );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::HandleRequestL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaBrowserView::HandleRequestL( 
+    RArray<TUint>* /*aTypeArray*/, 
+    CDesCArrayFlat* /*aDesArray*/ )
+    {
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserView::HandleDownloadL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaBrowserView::HandleDownloadL( 
+    RArray<TUint>* aTypeArray, 
+    CDesCArrayFlat* aDesArray )
+    {
+    //Check that content type and local file name exists
+    //There must be both, because download manager downloads POST-content 
+    //in advance calling this function
+    TInt contentTypeIndex( aTypeArray->Find( EParamReceivedContentType ) ); 
+    TInt fileNameIndex( aTypeArray->Find( EParamLocalFileName ) );
+    if ( contentTypeIndex != KErrNotFound &&  
+         fileNameIndex != KErrNotFound &&
+         contentTypeIndex < aDesArray->Count() &&
+         fileNameIndex < aDesArray->Count() )
+        {
+        //Check that the downloaded content is license response
+        TPtrC16 dataTypePtr( (*aDesArray)[contentTypeIndex] );
+        if ( dataTypePtr.CompareF( KDataTypeLicenseResponse ) == 0 )
+            {
+            //Get the path to the license response,
+            //read the response, delete the file and 
+            //make a license received - callback
+            TPtrC16 filePathPtr( (*aDesArray)[fileNameIndex] );
+            RFs fs;
+            User::LeaveIfError( fs.Connect() );
+            CleanupClosePushL( fs );
+            RFile file;
+            TInt size( 0 );
+            User::LeaveIfError( file.Open( fs, filePathPtr, EFileRead ) );
+            CleanupClosePushL( file );
+            User::LeaveIfError( file.Size( size ) );
+            delete iLicenseResponse;
+            iLicenseResponse = NULL;
+            iLicenseResponse = HBufC8::NewL( size );
+            TPtr8 licensePtr( iLicenseResponse->Des() );
+            User::LeaveIfError( file.Read( 0, licensePtr, size ) );
+            CleanupStack::PopAndDestroy( &file );
+            User::LeaveIfError( fs.Delete( filePathPtr ) );
+            CleanupStack::PopAndDestroy( &fs );
+            iCallback->LicenseReceived();
+            return ETrue;
+            }
+        }
+    return EFalse;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* 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:  Build Information file for project wmdrmdladefaulthttpplugin
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+wmdrmdladefaulthttpplugin.mmp
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/group/wmdrmdladefaulthttpplugin.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,63 @@
+/*
+* 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:  Project definition file for WMDMR DLA Default Http Plugin
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  wmdrmdladefaulthttpplugin.dll
+TARGETTYPE              PLUGIN
+UID                     0x10009D8D 0x20019574
+
+CAPABILITY              CAP_ECOM_PLUGIN
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  wmdrmdladefaulthttppluginproxy.cpp
+SOURCE                  wmdrmdladefaulthttpplugin.cpp
+SOURCE					wmdrmdladefaultlicacq.cpp
+SOURCE					wmdrmdladefaultmetering.cpp
+SOURCE					wmdrmdladefaultplayready.cpp
+SOURCE                  wmdrmdladefaulthttpmanager.cpp 
+
+USERINCLUDE             ../inc
+USERINCLUDE				../../wmdrmdlautils/inc
+USERINCLUDE			    ../../../inc
+USERINCLUDE				../../../wmdrmengine/asf/inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE           /epoc32/include/ecom
+
+START RESOURCE          20019574.rss
+TARGET                  wmdrmdladefaulthttpplugin.rsc
+END
+
+LIBRARY                 euser.lib
+LIBRARY         		flogger.lib
+LIBRARY		            ecom.lib
+LIBRARY                 bafl.lib 
+LIBRARY					http.lib
+LIBRARY                 inetprotutil.lib
+LIBRARY                 commdb.lib
+LIBRARY                 esock.lib
+LIBRARY                 estor.lib 
+LIBRARY         		charconv.lib
+LIBRARY                 wmdrmdla.lib 
+LIBRARY					wmdrmdlautils.lib
+LIBRARY					drmasf.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaulthttpmanager.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,284 @@
+/*
+* 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:  Defines the CWmDrmDlaDefaultHttpManager class
+*
+*/
+
+
+#ifndef WMDRMDLADEFAULTHTTPMANAGER_H
+#define WMDRMDLADEFAULTHTTPMANAGER_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <es_sock.h>
+#include <es_enum.h>
+#include <in_sock.h>
+
+#include <http/mhttpauthenticationcallback.h>
+#include <http/mhttptransactioncallback.h>
+#include <http/mhttpdatasupplier.h>
+
+#include <commdbconnpref.h>     // TCommDbConnPref (since 7.0s)
+
+#include "wmdrmdladefaulthttpmanagerobserver.h"
+
+/**
+* CWmDrmDlaDefaultHttpManager
+* The HTTP communication handling class
+*/
+NONSHARABLE_CLASS( CWmDrmDlaDefaultHttpManager ) :
+    public CActive,
+    public MHTTPTransactionCallback,
+    public MHTTPAuthenticationCallback
+    {
+    public:
+        /**
+         * THeader - encapsulates an HTTP header id and its value.
+         */
+        struct THeader
+            {
+        public:
+            inline THeader( TInt aField, const TDesC8& aDesC ) : 
+                iField(aField), iVal(aDesC) {};
+        public:
+            TInt iField;            // e.g. 'HTTP::EAccept'
+            const TDesC8& iVal;     // value: e.g. '*/*'
+            };
+
+    public:
+        /**
+         * Constructor.
+         * @param aObserver - reference to observer
+         * @return address of an instance of this class
+         */
+        static CWmDrmDlaDefaultHttpManager* NewL( 
+                    MWmDrmDlaDefaltHttpManagerObserver& aObserver );
+
+        /**
+         * Constructor.
+         * @param aObserver - reference to observer
+         * @param aIapNumber - Internet Access Point to be used
+         * @return address of an instance of this class
+         */
+        static CWmDrmDlaDefaultHttpManager* NewL( 
+                    MWmDrmDlaDefaltHttpManagerObserver& aObserver,
+                    TUint32 aIapNumber );
+
+        /**
+         * Destructor.
+         */
+        virtual ~CWmDrmDlaDefaultHttpManager();
+
+        /**
+         * Called to start the GET transaction using the configured IAP.
+         * @param aUrl - URL to be used for the transaction
+         * @param aHeaders - a list of headers and their values to be 
+         *                   included with the HTTP request
+         */
+        void Get( const TDesC8& aUrl, const RArray<THeader>& aHeaders );
+
+        /**
+         * Called to start the POST transaction using the configured IAP.
+         * @param aUrl - URL to be used for the transaction
+         * @param aHeaders - a list of headers and their values to be 
+         *                   included with the HTTP request
+         * @param aDataSupplier - interface to be used to get the POST data
+         */
+        void Post( const TDesC8& aUrl, const RArray<THeader>& aHeaders, 
+                   MHTTPDataSupplier* aDataSupplier );
+
+        /**
+         * To be called to stop an ongoing transaction instead of Cancel.
+         * Cancel SHOULD NOT BE CALLED by clients.
+         */
+        void Stop();
+
+        /**
+        * Notifies the CWmDrmDlaDefaultHttpManager that another piece of data
+        * is available to be sent as the body of a request.
+        * If the MHTTPDataSupplier::NextDataPart returns EFalse indicating
+        * there is more data available this method needs to be called for the
+        * next piece of data to be requested from the MHTTPDataSupplier.
+        * @leave any of the system wide error codes.
+        */
+        void MoreDataAvailableL();
+
+        /**
+         * If set to true, the connection is not closed when a
+         * transaction ends but when the object is deleted. Default: false.
+         * @param aKeepAlive - value of the KeepAlive property
+         */
+        void SetKeepAlive( TBool aKeepAlive );
+
+        /**
+         * Retrieves the value of the KeepAlive property
+         */
+        TBool KeepAlive() const;
+
+        /**
+         * Retrieves the current connection info.
+         * This method leaves with KErrNotReady if a connection
+         * is not open.
+         */
+        void GetConnectionInfoL( TConnectionInfo& aConnectionInfo );
+
+        /**
+         * Set the IAP connection for the next Get or Post
+         * @param aIapId The IAP connection that will be used
+         */
+        void SetIapId( TInt aIapId );
+        
+        /**
+         * Get the IAP Connection ID
+         */
+        TInt IapId();
+
+    private: // From MHTTPTransactionCallback
+        
+        virtual void MHFRunL( RHTTPTransaction aTransaction, 
+                              const THTTPEvent& aEvent );
+        virtual TInt MHFRunError( TInt aError, RHTTPTransaction aTransaction, 
+                                  const THTTPEvent& aEvent );
+
+    private: // From MHTTPAuthenticationCallback
+        
+        virtual TBool GetCredentialsL( const TUriC8& aURI, RString aRealm, 
+                                       RStringF aAuthenticationType,
+                                       RString& aUsername, 
+                                       RString& aPassword );
+
+    private:    // From CActive
+        
+        void DoCancel();
+        void RunL();
+        TInt RunError(TInt aError);
+
+    private:
+        
+        /**
+         * Contructor
+         * @param aObserver An observer to monitor the HTTP communications
+         * @param aIap An IAP connection to use for HTTP communication
+         */
+        CWmDrmDlaDefaultHttpManager( 
+                MWmDrmDlaDefaltHttpManagerObserver& aObserver, 
+                TUint32 aIapNumber );
+
+        /**
+         * Symbian OS 2nd phase constructor.
+         */
+        void ConstructL();
+
+    private:
+        
+        // State transition handlers
+        /**
+         * Handler for the EStart state.
+         */
+        void InitializeL();
+        /**
+         * Handler for the EInitialize state.
+         */
+        void Open();
+        /**
+         * Handler for the EOpen state.
+         */
+        void SubmitL();
+
+        // Utility methods
+        void DoStartL( const TDesC8& aUrl, const RArray<THeader>& aHeaders );
+        /**
+         * Close HTTP connection and clean up instance variables.
+         */
+        void HandleDownloadComplete( TInt aError );
+        /**
+         * Close HTTP transaction and clean up instance variables.
+         */
+        void CleanupTransaction();
+        /**
+         * Close connection and clean up instance variables.
+         */
+        void CleanupConnection();
+        /**
+         * Complete itself to keep state machine running
+         */
+        void CompleteSelf();
+        /**
+         * Set the HTTP header to send
+         */
+        void SetHeaderL( RHTTPHeaders& aHeaders, TInt aHdrField, 
+                         const TDesC8& aHdrValue ) const;
+        /**
+         * Delete the username and password used in authentication
+         */
+        void DeleteUsernamePassword();
+
+    private:    // Private types
+        
+        // Asynchronous connection states
+        enum TState
+            {
+            EConstructed,
+            EStart,
+            EInitialize,
+            EOpen,
+            ESubmit
+            };
+
+        // HTTP operation: GET or POST
+        enum TOperation
+            {
+            EGet,
+            EPost
+            };
+
+    private: // Data
+        
+        MWmDrmDlaDefaltHttpManagerObserver& iObserver;
+
+        TState iState; // State of the asynch connection
+        TInt iError;
+        TBool iCredentialsOk;
+
+        RSocketServ  iSocketServer;
+        RConnection  iConnection;
+        TCommDbConnPref iCommDbPrefs;
+
+        TUint32 iIapNumber;
+
+        RHTTPSession iHttpSession;
+        RHTTPTransaction iHttpTransaction;
+        MHTTPDataSupplier* iBody;
+
+        TBool iTransactionOpen;
+        TBool iInCallback;
+
+        HBufC8* iSrcAddress;
+        RArray<TInt> iHdrFields;
+        RArray<HBufC8*> iHdrValues;
+
+        HBufC8* iUsername;
+        HBufC8* iPassword;
+
+        TOperation iOperation;
+        MHTTPDataSupplier* iDataSupplier;   // not owned
+
+        TBool iKeepAlive;
+    };
+
+#endif // WMDRMDLADEFAULTHTTPMANAGER_H
+
+// End of File
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaulthttpmanagerobserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,78 @@
+/*
+* 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:  Defines the HTTP observer interface
+*
+*/
+
+
+#ifndef WMDRMDLADEFAULTHTTPMANAGEROBSERVER_H
+#define WMDRMDLADEFAULTHTTPMANAGEROBSERVER_H
+
+// INCLUDES
+#include <e32std.h>
+#include <http/mhttpauthenticationcallback.h>
+#include <http/mhttptransactioncallback.h>
+
+/**
+* MWmDrmDlaDefaltHttpManagerObserver
+* Notification interface used to report HTTP progress.
+*/
+class MWmDrmDlaDefaltHttpManagerObserver
+    {
+    public:
+        /**
+         * Called if authentication is required.
+         * @param aUsername - The username to be used for WWW authentication
+         *                    client. The pointer should be NULL and the 
+         *                    function will allocate new memory to hold the
+         *                    username and return it
+         * @param aPassword - The password to be used for WWW authentication
+         *                    client. the pointer should be NULL and the
+         *                    function will allocate new memory to hold the 
+         *                    username and return it
+         * @return true if the client has provided username and password, 
+         *         false otherwise
+         */
+        virtual TBool OnGetUsernamePasswordL( HBufC8*& aUsername, 
+                                              HBufC8*& aPassword ) = 0;
+
+        /**
+         * Called when server returns response headers.
+         * @param aResponse - HTTP transaction response
+         * @param aHeaders - response headers
+         * @param aStringPool - reference to the string pool belonging
+         *                      to this transaction
+         * @param aHttpStatus - status code of the resonse header
+         */
+        virtual void OnResponseHeadersL( const RHTTPResponse& aResponse, 
+                                         const RHTTPHeaders& aHeaders,
+                                         const RStringPool& aStringPool, 
+                                         TInt aHttpStatus ) = 0;
+
+        /**
+         * Called for each chunk of data returned from server.
+         * @param aDataChunk - data chunk
+         */
+        virtual void OnResponseBodyDataL( const TPtrC8 aDataChunk ) = 0;
+
+        /**
+         * Called upon transaction has been completed.
+         * @param aError - An error returned from the HTTP library
+         */
+        virtual void OnTransactionComplete( TInt aError ) = 0;
+    };
+
+#endif  // WMDRMDLADEFAULTHTTPMANAGEROBSERVER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaulthttpplugin.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,314 @@
+/*
+* 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:  WMDRM DLA Default HTTP Plugin
+*
+*/
+
+
+#ifndef C_WMDRMDLADEFAULTHTTPPLUGIN_H
+#define C_WMDRMDLADEFAULTHTTPPLUGIN_H
+
+#include <wmdrmdlahttpplugin.h>
+
+class CWmDrmDlaDefaultLicAcq;
+class CWmDrmDlaDefaultMetering;
+class CWmDrmDlaDefaultPlayReady;
+class CWmDrmDlaUiNotifier;
+class CGulIcon;
+
+/**
+ * WMDRM DLA Default HTTP Plugin
+ * Reference implementation that only supports MS test server
+ *
+ * @lib wmdrmdladefaulthttpplugin.lib
+ * @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaDefaultHttpPlugin ) : public CWmDrmDlaHttpPluginIf
+    {
+
+public:
+
+    static CWmDrmDlaDefaultHttpPlugin* NewL();
+    ~CWmDrmDlaDefaultHttpPlugin();
+
+public: //From CWmDrmDlaHttpPluginIf
+
+    /**
+     * Get service icon to be used in service selection query, if
+     * more than one service is recognized to support content.
+     * Will be deleted by the caller.
+     *
+     * @return Service icon or NULL
+     */
+    CGulIcon* ServiceIcon();
+    
+    /**
+     * Check if file is supported by this plugin
+     *
+     * @param aFile WMDRM file
+     * @param aUiNotifer If file is supported, contains initialized UI Notifier
+     *                   upon completion. Will be deleted by the caller after 
+     *                   the plugin has been deleted.
+     * @return ETrue if file is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+     TBool SupportedFileL( const RFile& aFile, 
+                           CWmDrmDlaUiNotifier*& aUiNotifier );
+
+    /**
+     * Check if DRM Header is supported by this plugin
+     *
+     * @param aHeader DRM Header
+     * @param aUiNotifer If header is supported, contains initialized UI 
+     *                   Notifier upon completion. Will be deleted by the
+     *                   caller after the plugin has been deleted.
+     * @return ETrue if header is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    TBool SupportedDrmHeaderL( const TDesC8& aHeader, 
+                               CWmDrmDlaUiNotifier*& aUiNotifier );
+
+    /**
+     * Check if metering certificate is supported by this plugin
+     *
+     * @param aCertificate Metering certificate
+     * @param aUiNotifer If certificate is supported, contains initialized UI
+     *                   Notifier upon completion. Will be deleted by the
+     *                   caller after the plugin has been deleted.
+     * @return ETrue if certificate is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    TBool SupportedMeteringCertificateL( const TDesC8& aCertificate, 
+                                         CWmDrmDlaUiNotifier*& aUiNotifier );
+
+    /**
+     * Check if initiator is supported by this plugin
+     * This method is called only for playready content
+     * 
+     * @param aInitiator Initiator
+     * @param aUiNotifer If initiator is supported, contains initialized UI
+     *                   Notifier upon completion. Will be deleted by the
+     *                   caller after the plugin has been deleted.
+     * @return ETrue if initiator is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    TBool SupportedInitiatorL( const TDesC8& aInitiator, 
+                               CWmDrmDlaUiNotifier*& aUiNotifier );
+
+    /**
+     * Check if license acquisition should be silent for this file
+     *
+     * @param aFile WMDRM file
+     * @return ETrue if file is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    TBool SilentL( const RFile& aFile );
+
+    /**
+     * Process DRM Header. This method is used only to pass DRM Header to the
+     * plugin. The framework does not require the plugin to do anything 
+     *
+     * @param aDrmHeader DRM Header
+     * @leave with standard Symbian error code in case of fatal error (the 
+     * framework does not proceed with license acquisition if this method
+     * leaves)
+     */
+    void ProcessDrmHeaderL( const TDesC8& aDrmHeader );
+
+    /**
+     * Process the initiator. This method is used only to pass initiator to the
+     * plugin. The framework does not require the plugin to do anything. 
+     * This method is called only for playready content
+     *
+     * @param aInitiator Initiator
+     * @leave with standard Symbian error code in case of fatal error (the 
+     * framework does not proceed with license acquisition if this method
+     * leaves)
+     */
+    void ProcessInitiatorL( const TDesC8& aInitiator );
+    
+    /**
+    * Acquire License. 
+    *
+    * @param aLicenseChallenge License challenge based on which license will
+    *                          be acquired.
+    * @param aLicenseServerUrl URL where license challenge is sent
+    * @param aStatus Request status, will contain error code upon completion 
+    * including but not limited to:
+    * - KErrCancel if user cancelled the license acquisition at any point
+    * - KErrCommsBreak if network connection was lost during communication with
+    *                  server
+    * - KErrGeneral if unspecified error happened
+    */
+    void AcquireLicense( const TDesC8& aLicenseChallenge, 
+                         HBufC* aLicenseServerUrl,
+                         TRequestStatus& aStatus );
+
+    /**
+     * Get downloaded License. 
+     *
+     * @leave standard Symbian error code in case of error.
+     * @return Buffer containing license data. Will be deleted by the caller.
+     */
+    HBufC8* GetLicenseResponseL();
+
+    /**
+     * Send license storage status. 
+     *
+     * @param aTid Transaction ID parsed from the license response, can be NULL
+     * @param aUrl URL where license storage status is sent
+     * @param aError License storage status.
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    void SendLicenseStorageStatus( HBufC8* aTid, const TDesC& aUrl,
+                                   TInt aError, TRequestStatus& aStatus );
+
+    /**
+     * Send error code to server if drm header parsing failed.
+     *
+     * @param   aErrorUrl   URL where error code is sent
+     * @param   aError      Error code
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    void SendDrmHeaderError( const TDesC& aErrorUrl, TInt aError, 
+                             TRequestStatus& aStatus );
+    
+    /**
+     * Get content url. Called only if framework fails to parse content URL 
+     * from the license response. Needs to be implemented only if the supported
+     * service uses non-standard way to pass the Content URL, otherwise this can
+     * return NULL.
+     *
+     * @return Content URL, can be NULL. Will be deleted by the caller.
+     */
+    HBufC* GetContentUrlL();
+
+    /**
+     * Get HTML data returned by license server. 
+     *
+     * @return HTML data, can be NULL. Will be deleted by the caller.
+     */
+    HBufC* GetHtmlDataL();
+
+    /*
+     * Cancel license acquisition
+     */
+    void CancelLicenseAcquisition();
+    
+    /**
+     * Process metering challenge. 
+     *
+     * @param aMeteringChallenge Metering challenge
+     * @param aUrl Url to be used in metering request
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    void ProcessMeteringChallenge( const TDesC8& aMeteringChallenge, 
+                                   const TDesC& aUrl, 
+                                   TRequestStatus& aStatus );
+
+    /**
+     * Get metering response. 
+     *
+     * @param aResponse Contains metering response upon completion. Will be
+     *                  deleted by the caller.
+     * @param aStatus Request status, will contain error code upon completion
+     */
+    void GetMeteringResponse( HBufC8*& aResponse, TRequestStatus& aStatus );
+
+    /**
+     * Inform plugin that metering finished. 
+     *
+     */
+    void MeteringFinished();
+
+    /*
+     * Cancel metering
+     */
+    void CancelMetering();
+    
+    /*
+     * Process join domain challenge.
+     * This method is called only for playready content
+     *
+     * @param aJoinDomainChallenge Join domain challenge
+     * @param aUrl Url to be used in join domain request
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    void ProcessJoinDomainChallenge( 
+        const TDesC8& aJoinDomainChallenge, 
+        const TDesC& aUrl, 
+        TRequestStatus& aStatus );
+
+    /*
+     * Process leave domain challenge.
+     * This method is called only for playready content
+     *
+     * @param aLeaveDomainChallenge Leave domain challenge
+     * @param aUrl Url to be used in leave domain request
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    void ProcessLeaveDomainChallenge( 
+        const TDesC8& aLeaveDomainChallenge, 
+        const TDesC& aUrl, 
+        TRequestStatus& aStatus );
+
+    /**
+     * Sets the IAP to be used in the HTTP transactions
+     *
+     * @param   aIapId  Internet Access Point id
+     */
+    void SetIapId( TInt aIapId );
+
+    void InitializeUiNotifierL();
+    CWmDrmDlaUiNotifier* UiNotifier();
+    
+    TBool Supported( const TDesC8& aString, const TDesC8& aIdentifier );
+    
+private:
+
+    CWmDrmDlaDefaultHttpPlugin();
+    void ConstructL();
+
+private: // data
+    
+    CWmDrmDlaDefaultLicAcq* iLicenseAcquisition;
+    CWmDrmDlaDefaultMetering* iMetering;
+    CWmDrmDlaDefaultPlayReady* iPlayReady;
+    
+    //Not owned
+    CWmDrmDlaUiNotifier* iUiNotifier;
+
+    };
+
+#endif // C_WMDRMDLADEFAULTHTTPPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaultlicacq.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,253 @@
+/*
+* 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:  WMDRM DLA Default Http License Acquisition
+*
+*/
+
+
+#ifndef C_WMDRMDLADEFAULTLICACQ_H
+#define C_WMDRMDLADEFAULTLICACQ_H
+
+#include "wmdrmdlabrowserobserver.h"
+#include "wmdrmdladefaulthttpmanagerobserver.h"
+
+class CWmDrmDlaDefaultHttpPlugin;
+class CWmDrmDlaUiNotifier;
+class CWmDrmDlaDefaultHttpManager;
+class CWmDrmDlaBrowserViewHandler;
+class CHTTPFormEncoder;
+
+/**
+ * WMDRM DLA Default Http License Acquisition
+ * Reference implementation to demonstrate how to handle license acquisition
+ * with the MS test site.
+ * 
+ * @lib wmdrmdladefaulthttpplugin.lib
+ * @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaDefaultLicAcq ) 
+    : public CBase, 
+      public MWmDrmDlaBrowserObserver,
+      public MWmDrmDlaDefaltHttpManagerObserver
+    {
+
+public:
+
+    static CWmDrmDlaDefaultLicAcq* NewL( CWmDrmDlaDefaultHttpPlugin* aPlugin );
+    ~CWmDrmDlaDefaultLicAcq();
+
+    /**
+     * Check if file is supported by this plugin
+     *
+     * @param aFile WMDRM file
+     * @param aUiNotifer If file is supported, contains initialized UI Notifier
+     *                   upon completion. Will be deleted by the caller after 
+     *                   the plugin has been deleted.
+     * @return ETrue if file is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+     TBool SupportedFileL( const RFile& aFile, 
+                           CWmDrmDlaUiNotifier*& aUiNotifier );
+
+    /**
+     * Check if DRM Header is supported by this plugin
+     *
+     * @param aHeader DRM Header
+     * @param aUiNotifer If header is supported, contains initialized UI
+     *                   Notifier upon completion. Will be deleted by the
+     *                   caller after the plugin has been deleted.
+     * @return ETrue if header is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    TBool SupportedDrmHeaderL( const TDesC8& aHeader, 
+                               CWmDrmDlaUiNotifier*& aUiNotifier );
+
+    /**
+     * Check if license acquisition should be silent for this file
+     *
+     * @param aFile WMDRM file
+     * @return ETrue if file is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    TBool SilentL( const RFile& aFile );
+
+    /**
+     * Process DRM Header. This method is used only to pass DRM Header to the
+     * plugin. The framework does not require the plugin to do anything 
+     *
+     * @param aDrmHeader DRM Header
+     * @leave with standard Symbian error code in case of fatal error (the 
+     * framework does not proceed with license acquisition if this method
+     * leaves)
+     */
+    void ProcessDrmHeaderL( const TDesC8& aDrmHeader );
+
+    /**
+     * Acquire License. 
+     *
+     * @param aLicenseChallenge License challenge based on which license
+     *                          will be acquired.
+     * @param aLicenseServerUrl URL where license challenge is sent
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCancel if user cancelled the license acquisition at any point
+     * - KErrCommsBreak if network connection was lost during communication 
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    void AcquireLicense( const TDesC8& aLicenseChallenge, 
+                         HBufC* aLicenseServerUrl,
+                         TRequestStatus& aStatus );
+
+    /**
+     * Get downloaded License. 
+     *
+     * @leave standard Symbian error code in case of error.
+     * @return Buffer containing license data. Will be deleted by the caller.
+     */
+    HBufC8* GetLicenseResponseL();
+
+    /**
+     * Send license storage status. 
+     *
+     * @param aTid Transaction ID parsed from the license response, can be NULL
+     * @param aUrl URL where license storage status is sent
+     * @param aError License storage status.
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    void SendLicenseStorageStatus( HBufC8* aTid, const TDesC& aUrl,
+                                   TInt aError, TRequestStatus& aStatus );
+    
+    /**
+     * Send error code to server if drm header parsing failed.
+     *
+     * @param   aErrorUrl   URL where error code is sent
+     * @param   aError      Error code
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    void SendDrmHeaderError( const TDesC& aErrorUrl, TInt aError, 
+                             TRequestStatus& aStatus );
+
+    /**
+     * Get content url. Called only if framework fails to parse content URL 
+     * from the license response. Needs to be implemented only if the supported
+     * service uses non-standard way to pass the Content URL, otherwise this
+     * can return NULL.
+     *
+     * @return Content URL, can be NULL. Will be deleted by the caller.
+     */
+    HBufC* GetContentUrlL();
+
+    /**
+     * Get HTML data returned by license server. 
+     *
+     * @return HTML data, can be NULL. Will be deleted by the caller.
+     */
+    HBufC* GetHtmlDataL();
+
+    /*
+     * Cancel license acquisition
+     */
+    void CancelLicenseAcquisition();
+
+    /**
+     * Sets the IAP to be used in the HTTP transactions
+     *
+     * @param   aIapId  Internet Access Point id
+     */
+    void SetIapId( TInt aIapId );
+
+public: // From MWmDrmDlaBrowserObserver
+    
+    const TDesC& PostUrlL();
+    const TDesC8& PostContentTypeL();
+    const TDesC8& PostDataL();
+    const TDesC8& PostContentDataBoundaryL();
+    TInt IapId();
+    void LicenseResponseReceived( const TDesC8& aLicenseResponse );
+    void BrowserExit( TInt aError );
+
+private: // From MWmDrmDlaDefaltHttpManagerObserver
+    
+    TBool OnGetUsernamePasswordL( HBufC8*& aUsername, HBufC8*& aPassword );
+    void OnResponseHeadersL( const RHTTPResponse& aResponse, 
+                             const RHTTPHeaders& aHeaders,
+                             const RStringPool& aStringPool, 
+                             TInt aHttpStatus );
+    void OnResponseBodyDataL( const TPtrC8 aDataChunk );
+    void OnTransactionComplete( TInt aSystemError );
+    
+private:
+
+    CWmDrmDlaDefaultLicAcq( CWmDrmDlaDefaultHttpPlugin* aPlugin );
+    void ConstructL();
+    
+    void CompleteClientRequest( TInt aError );
+    
+    void AcquireLicenseL();
+    void SendLicenseStorageStatusL( const TDesC8& aTid, TInt aError );
+    TInt MakeHRESULT( TInt aError );
+    void SendHRESULTL( const TDesC8& aUrl, const TDesC8& aHeaderField, 
+                       TInt aHRESULT );
+    
+    void HandleRedirectionHeadersL( const RHTTPHeaders& aHeaders,
+                                    const RStringPool& aStringPool );
+    void HandleLicenseAcquistionHeaders( const RHTTPHeaders& aHeaders,
+                                         const RStringPool& aStringPool );
+    
+    void LaunchBrowserViewL();
+    
+    static TInt Redirection( TAny* aPtr );
+    
+private: // data
+    
+    enum TLicAcqState
+        {
+        ENotActive,
+        ESendingLicenseChallenge,
+        ENonSilentLicenseAcquisition,
+        ERedirection,
+        ESendingStorageStatus,
+        EBrowserView
+        };
+    
+    TLicAcqState iState;
+    CWmDrmDlaDefaultHttpManager* iHttpManager;
+    CHTTPFormEncoder* iFormEncoder;
+    CIdle* iIdle;
+    CWmDrmDlaBrowserViewHandler* iBrowserViewHandler;
+    TInt iHttpStatus;
+    TBool iNonSilent;
+    HBufC8* iLicenseChallenge;
+    HBufC8* iPostData;
+    HBufC8* iLicenseResponse;
+    HBufC* iLicenseServerUrl16;
+    HBufC8* iLicenseServerUrl;
+    HBufC* iHtmlData;
+    
+    //Not owned
+    CWmDrmDlaDefaultHttpPlugin* iPlugin;
+    TRequestStatus* iClientStatus;
+    
+    };
+
+#endif // C_WMDRMDLADEFAULTLICACQ_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaultmetering.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,143 @@
+/*
+* 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:  WMDRM DLA Default Metering
+*
+*/
+
+
+#ifndef C_WMDRMDLADEFAULMETERING_H
+#define C_WMDRMDLADEFAULMETERING_H
+
+#include "wmdrmdladefaulthttpmanagerobserver.h"
+
+class CWmDrmDlaDefaultHttpPlugin;
+class CWmDrmDlaUiNotifier;
+class CWmDrmDlaDefaultHttpManager;
+class CHTTPFormEncoder;
+
+/**
+ * WMDRM DLA Default Metering
+ * Reference implementation to demonstrate how to handle metering
+ * with the MS test site.
+ * 
+ * @lib wmdrmdladefaulthttpplugin.lib
+ * @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaDefaultMetering ) 
+    : public CBase, 
+      public MWmDrmDlaDefaltHttpManagerObserver
+    {
+
+public:
+
+    static CWmDrmDlaDefaultMetering* NewL( 
+                CWmDrmDlaDefaultHttpPlugin* aPlugin );
+    ~CWmDrmDlaDefaultMetering();
+
+     /**
+     * Check if metering certificate is supported by this plugin
+     *
+     * @param aCertificate Metering certificate
+     * @param aUiNotifer If certificate is supported, contains initialized UI
+     *                   Notifier upon completion. Will be deleted by the
+     *                   caller after the plugin has been deleted.
+     * @return ETrue if certificate is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    TBool SupportedMeteringCertificateL( const TDesC8& aCertificate, 
+                                         CWmDrmDlaUiNotifier*& aUiNotifier );
+    
+    /**
+     * Process metering challenge. 
+     *
+     * @param aMeteringChallenge Metering challenge
+     * @param aUrl Url to be used in metering request
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    void ProcessMeteringChallenge( const TDesC8& aMeteringChallenge, 
+                                   const TDesC& aUrl, 
+                                   TRequestStatus& aStatus );
+
+    /**
+     * Get metering response. 
+     *
+     * @param aResponse Contains metering response upon completion. 
+     *                  Will be deleted by the caller.
+     * @param aStatus Request status, will contain error code upon completion
+     */
+    void GetMeteringResponse( HBufC8*& aResponse, TRequestStatus& aStatus );
+
+    /**
+     * Inform plugin that metering finished. 
+     *
+     */
+    void MeteringFinished();
+    
+    /*
+     * Cancel metering
+     */
+    void CancelMetering();
+
+    /**
+     * Sets the IAP to be used in the HTTP transactions
+     *
+     * @param   aIapId  Internet Access Point id
+     */
+    void SetIapId( TInt aIapId );
+
+private: // From MWmDrmDlaDefaltHttpManagerObserver
+    
+    TBool OnGetUsernamePasswordL( HBufC8*& aUsername, HBufC8*& aPassword );
+    void OnResponseHeadersL( const RHTTPResponse& aResponse, 
+                             const RHTTPHeaders& aHeaders, 
+                             const RStringPool& aStringPool, 
+                             TInt aHttpStatus );
+    void OnResponseBodyDataL( const TPtrC8 aDataChunk );
+    void OnTransactionComplete( TInt aSystemError );
+
+private:
+
+    CWmDrmDlaDefaultMetering( CWmDrmDlaDefaultHttpPlugin* aPlugin );
+    void ConstructL();
+    
+    void CompleteClientRequest( TInt aError );
+    
+    void ProcessMeteringChallengeL( const TDesC8& aMeteringChallenge );
+    
+private: // data
+    
+    enum TMeteringState
+        {
+        ENotActive,
+        ESendingMeteringChallenge
+        };
+    
+    TMeteringState iState;
+    CWmDrmDlaDefaultHttpManager* iHttpManager;
+    CHTTPFormEncoder* iFormEncoder;
+    TInt iHttpStatus;
+    HBufC8* iMeteringResponse;
+    HBufC* iMeteringServerUrl;
+    
+    //Not owned
+    CWmDrmDlaDefaultHttpPlugin* iPlugin;
+    TRequestStatus* iClientStatus;
+    
+    };
+
+#endif // C_WMDRMDLADEFAULMETERING_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/inc/wmdrmdladefaultplayready.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,148 @@
+/*
+* 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:  WMDRM DLA Default Http PlayReady Implementation
+*
+*/
+
+
+#ifndef C_WMDRMDLADEFAULTPLAYREADY_H
+#define C_WMDRMDLADEFAULTPLAYREADY_H
+
+#include "wmdrmdladefaulthttpmanagerobserver.h"
+
+class CWmDrmDlaDefaultHttpPlugin;
+class CWmDrmDlaUiNotifier;
+class CWmDrmDlaDefaultHttpManager;
+class CHTTPFormEncoder;
+
+/**
+ * WMDRM DLA Default Http PlayReady Implementation
+ *
+ * @lib wmdrmdladefaulthttpplugin.lib
+ * @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaDefaultPlayReady ) 
+    : public CBase, 
+      public MWmDrmDlaDefaltHttpManagerObserver
+    {
+
+public:
+
+    static CWmDrmDlaDefaultPlayReady* NewL( 
+                CWmDrmDlaDefaultHttpPlugin* aPlugin );
+    ~CWmDrmDlaDefaultPlayReady();
+
+    /**
+     * Check if initiator is supported by this plugin
+     * This method is called only for playready content
+     * 
+     * @param aInitiator Initiator
+     * @param aUiNotifer If initiator is supported, contains initialized UI
+     *                   Notifier upon completion. Will be deleted by the
+     *                   caller.
+     * @return ETrue if initiator is supported by this plugin
+     * @leave with standard Symbian error code in case of error
+     */
+    TBool SupportedInitiatorL( const TDesC8& aInitiator, 
+                               CWmDrmDlaUiNotifier*& aUiNotifier );
+
+    /**
+     * Process the initiator. This method is used only to pass initiator to the 
+     * plugin. The framework does not require the plugin to do anything. 
+     * This method is called only for playready content
+     *
+     * @param aInitiator Initiator
+     * @leave with standard Symbian error code in case of fatal error (the 
+     * framework does not proceed with license acquisition if this method
+     * leaves)
+     */
+    void ProcessInitiatorL( const TDesC8& aInitiator );
+
+    /*
+     * Process join domain challenge.
+     * This method is called only for playready content
+     *
+     * @param aJoinDomainChallenge Join domain challenge
+     * @param aUrl Url to be used in join domain request
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    void ProcessJoinDomainChallenge( 
+            const TDesC8& aJoinDomainChallenge, 
+            const TDesC& aUrl, 
+            TRequestStatus& aStatus );
+
+    /*
+     * Process leave domain challenge.
+     * This method is called only for playready content
+     *
+     * @param aLeaveDomainChallenge Leave domain challenge
+     * @param aUrl Url to be used in leave domain request
+     * @param aStatus Request status, will contain error code upon completion
+     * including but not limited to:
+     * - KErrCommsBreak if network connection was lost during communication
+     *                  with server
+     * - KErrGeneral if unspecified error happened
+     */
+    void ProcessLeaveDomainChallenge( 
+            const TDesC8& aLeaveDomainChallenge, 
+            const TDesC& aUrl, 
+            TRequestStatus& aStatus );
+
+    /**
+     * Sets the IAP to be used in the HTTP transactions
+     *
+     * @param   aIapId  Internet Access Point id
+     */
+    void SetIapId( TInt aIapId );
+
+private: // From MWmDrmDlaDefaltHttpManagerObserver
+    
+    TBool OnGetUsernamePasswordL( HBufC8*& aUsername, HBufC8*& aPassword );
+    void OnResponseHeadersL( const RHTTPResponse& aResponse, 
+                             const RHTTPHeaders& aHeaders, 
+                             const RStringPool& aStringPool, 
+                             TInt aHttpStatus );
+    void OnResponseBodyDataL( const TPtrC8 aDataChunk );
+    void OnTransactionComplete( TInt aSystemError );
+
+private:
+
+    CWmDrmDlaDefaultPlayReady( CWmDrmDlaDefaultHttpPlugin* aPlugin );
+    void ConstructL();
+    
+    void CompleteClientRequest( TInt aError );
+        
+private: // data
+    
+    enum TPlayReadyState
+        {
+        ENotActive,
+        };
+    
+    TPlayReadyState iState;
+    CWmDrmDlaDefaultHttpManager* iHttpManager;
+    CHTTPFormEncoder* iFormEncoder;
+    TInt iHttpStatus;
+    
+    //Not owned
+    CWmDrmDlaDefaultHttpPlugin* iPlugin;
+    TRequestStatus* iClientStatus;
+    
+    };
+
+#endif // C_WMDRMDLADEFAULTPLAYREADY_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/src/20019574.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,43 @@
+/*
+* 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:  Declaration of the WMDRM DLA Default HTTP Plugin resource file 
+*
+*/
+
+
+#include "RegistryInfo.rh"
+
+RESOURCE REGISTRY_INFO theInfo
+{
+        dll_uid = 0x20019574;
+        interfaces =
+        {
+                INTERFACE_INFO
+                {
+                interface_uid = 0x20019544; //WMDRM DLA HTTP Plugin interface UID
+                implementations = 
+                        {
+                        IMPLEMENTATION_INFO
+                                {
+                                implementation_uid = 0x20019574;
+                                version_no = 1;
+                                display_name = "MS reference";
+                                default_data = "";
+                                opaque_data = "";
+                                }
+                        };
+                }
+        };
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaulthttpmanager.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,749 @@
+/*
+* 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:  Implements generic HTTP GET and POST functionality
+*
+*/
+
+
+// INCLUDE FILES
+#include <http.h>
+#include <cookiefilterinterface.h>
+#include <uaproffilter_interface.h>
+#include "wmdrmdladefaulthttpmanager.h"
+
+#define _LOGGING_FILE L"wmdrmdladefaulthttpplugin.txt"
+#include "logfn.h"
+
+/**
+ *  HTTP_STRING macro
+ *  To use HTTP_STRING macro you need a variable 'pool' defined (of 
+ *  RStringPool type).
+ *  @param  aStringId  - an ID for string from HTTP Client's string table 
+ *  (e.g. 'HTTP::EAccept')
+ */
+#define HTTP_STRING(aStringId)pool.StringF(aStringId, RHTTPSession::GetTable())
+
+/**
+ *  SET_HTTP_PROPERTY macro
+ *  Sets value for a property of HTTP session
+ *  @param  info    - RHTTPConnectionInfo
+ *  @param  pool    - RStringPool
+ *  @param  property - property ID, a value from HTTP string table
+ *  @param  value   - value to set
+ */
+#define SET_HTTP_PROPERTY(info, pool, property, value) \
+                info.SetPropertyL( HTTP_STRING(property), THTTPHdrVal(value))
+
+
+// ================= MEMBER FUNCTIONS =======================
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::NewL
+// ----------------------------------------------------------------------------
+CWmDrmDlaDefaultHttpManager* CWmDrmDlaDefaultHttpManager::NewL( 
+    MWmDrmDlaDefaltHttpManagerObserver& aObserver )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::NewL(1)" );
+    CWmDrmDlaDefaultHttpManager* self = 
+        new(ELeave) CWmDrmDlaDefaultHttpManager( aObserver, 0 );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::NewL
+// ----------------------------------------------------------------------------
+CWmDrmDlaDefaultHttpManager* CWmDrmDlaDefaultHttpManager::NewL( 
+    MWmDrmDlaDefaltHttpManagerObserver& aObserver,
+    TUint32 aIapNumber )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::NewL(2)" );
+    CWmDrmDlaDefaultHttpManager* self = 
+        new(ELeave) CWmDrmDlaDefaultHttpManager( aObserver, aIapNumber );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::~CWmDrmDlaDefaultHttpManager
+// ----------------------------------------------------------------------------
+CWmDrmDlaDefaultHttpManager::~CWmDrmDlaDefaultHttpManager()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::~CWmDrmDlaDefaultHttpManager" );
+    Stop();
+    }
+
+// ----------------------------------------------------------------------------
+// CpHttpManager::Get
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::Get(
+    const TDesC8& aUrl,
+    const RArray<CWmDrmDlaDefaultHttpManager::THeader>& aHeaders)
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::Get" );
+    // Disallow clients to call this method before it has completed asynch
+    // request
+    ASSERT( !iTransactionOpen );
+
+    iOperation = EGet;
+    iDataSupplier = NULL;
+
+    TRAPD( err, DoStartL( aUrl, aHeaders ) );
+    if ( err )
+        {
+        HandleDownloadComplete( err );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CpHttpManager::Post
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::Post(
+    const TDesC8& aUrl,
+    const RArray<CWmDrmDlaDefaultHttpManager::THeader>& aHeaders,
+    MHTTPDataSupplier* aDataSupplier )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::Post" );
+    // Disallow clients to call this method before it has completed asynch
+    // request
+    ASSERT( !iTransactionOpen );
+    ASSERT( aDataSupplier );
+
+    iOperation = EPost;
+    iDataSupplier = aDataSupplier;
+
+    TRAPD( err, DoStartL( aUrl, aHeaders ) );
+    if ( err )
+        {
+        HandleDownloadComplete( err );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::Stop
+// This method should be used instead of Cancel.
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::Stop()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::Stop" );
+    // Make sure Stop was not called from a callback
+    ASSERT( !iInCallback );
+
+    if ( IsActive() )
+        {
+        // We are still establishing the connection, cancel the active object
+        Cancel();
+        }
+    else
+        {
+        // The active object is not active - we are past the setup phase
+        if ( iTransactionOpen )
+            {
+            iHttpTransaction.Cancel();
+
+            // Only generate the callback if there was a transaction going on,
+            // otherwise the client will get a callback without previously
+            // calling StartL
+            HandleDownloadComplete( KErrCancel );
+            }
+        }
+
+    CleanupConnection();
+    DeleteUsernamePassword();
+    iState = EConstructed;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::MoreDataAvailableL
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::MoreDataAvailableL()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::MoreDataAvailableL" );
+    iHttpTransaction.NotifyNewRequestBodyPartL();
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::SetKeepAlive
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::SetKeepAlive( TBool aKeepAlive )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::SetKeepAlive" );
+    iKeepAlive = aKeepAlive;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::KeepAlive
+// ----------------------------------------------------------------------------
+TBool CWmDrmDlaDefaultHttpManager::KeepAlive() const
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::KeepAlive" );
+    return iKeepAlive;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::GetConnectionInfoL
+// Note: TConnectionInfo& aConnectionInfo creates a PC-Lint warning to make it
+// const but aConnectionInfo is being changed after it has been put into a
+// package and GetConnectionInfo is called on the connection
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::GetConnectionInfoL( 
+    TConnectionInfo& aConnectionInfo )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::GetConnectionInfoL" );
+    if ( (iState != EOpen) && (iState != ESubmit) )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    TUint count( 0 );
+    User::LeaveIfError( iConnection.EnumerateConnections( count ) );
+
+    if ( !count )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    TPckg<TConnectionInfo> pkg( aConnectionInfo );
+    User::LeaveIfError( iConnection.GetConnectionInfo( 1, pkg ) );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::SetIapId
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::SetIapId( TInt aIapId )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::SetIapId" );
+    iIapNumber = aIapId;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::IapId
+// ----------------------------------------------------------------------------
+TInt CWmDrmDlaDefaultHttpManager::IapId()
+    {
+    return iIapNumber;
+    }
+
+// ============================== PRIVATE METHODS ==============================
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::MHFRunL
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::MHFRunL( 
+    RHTTPTransaction aTransaction, 
+    const THTTPEvent& aEvent )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::MHFRunL" );
+    RHTTPResponse response;
+    TPtrC8 dataChunk;
+    
+    // Either ESucceeded or EFailed will eventually occur
+    switch ( aEvent.iStatus )
+        {
+        case THTTPEvent::EGotResponseHeaders:
+            response = aTransaction.Response();
+    
+            iInCallback = ETrue;
+            iObserver.OnResponseHeadersL(
+                response,
+                response.GetHeaderCollection(),
+                iHttpSession.StringPool(),
+                response.StatusCode() );
+    
+            break;
+    
+        case THTTPEvent::EGotResponseBodyData:
+            // A member variable is used to store the body to avoid two 
+            // potential problems:
+            // - OnResponseBodyDataL leaves
+            // - Stop is called from within OnResponseBodyDataL
+            iBody = aTransaction.Response().Body();
+            User::LeaveIfNull( iBody );
+    
+            iBody->GetNextDataPart( dataChunk );
+    
+            iInCallback = ETrue;
+            iObserver.OnResponseBodyDataL( dataChunk );
+    
+            // Verify that iBody wasn't already released
+            // for example by calling Stop within ResponseBodyDataL
+            if ( iBody )
+                {
+                iBody->ReleaseData();
+                iBody = NULL;
+                }
+                
+            break;
+    
+        case THTTPEvent::ESucceeded:
+        case THTTPEvent::EFailed:
+            // Deal with both the same as iError will either be negative or 
+            // KErrNone
+            // If the user cancelled the credentials dialog then make sure we 
+            // return KErrCancel
+            HandleDownloadComplete( iCredentialsOk ? iError : KErrCancel );
+            break;
+    
+        default:
+            // This will capture system and HTTP lib errors
+            // For positive codes iError will remain to KErrNone
+            if ( aEvent.iStatus < KErrNone )
+                {
+                iError = aEvent.iStatus;
+                }
+            break;
+        }
+
+    iInCallback = EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::MHFRunError
+// ----------------------------------------------------------------------------
+TInt CWmDrmDlaDefaultHttpManager::MHFRunError(
+    TInt aError,
+    RHTTPTransaction /*aTransaction*/,
+    const THTTPEvent& /*aEvent*/ )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::MHFRunError" );
+    HandleDownloadComplete( aError );
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::GetCredentialsL
+// This function is NOT currently used as authentication is not current used in
+// this project at the current time
+// ----------------------------------------------------------------------------
+TBool CWmDrmDlaDefaultHttpManager::GetCredentialsL(
+    const TUriC8& /*aURI*/,
+    RString aRealm,
+    RStringF aAuthenticationType,
+    RString& aUsername,
+    RString& aPassword )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::GetCredentialsL" );
+    iCredentialsOk = EFalse;
+    RStringPool pool = aRealm.Pool();
+    if ( aAuthenticationType == HTTP_STRING( HTTP::EBasic ) )
+        {
+        DeleteUsernamePassword();
+
+        // Get the username/password
+        iInCallback = ETrue;
+        iCredentialsOk = 
+            iObserver.OnGetUsernamePasswordL( iUsername, iPassword );
+        iInCallback = EFalse;
+
+        // authentication = iCredentialsOk && iUsername && iPassword
+        // no authentication = !iCredentialsOk && !iUsername && !iPassword
+        ASSERT( (iCredentialsOk && iUsername && iPassword) || 
+            (!iCredentialsOk && !iUsername && !iPassword ) );
+
+        if (iCredentialsOk)
+            {
+            aUsername = pool.OpenStringL( *iUsername );
+            aPassword = pool.OpenStringL( *iPassword );
+            }
+        }
+
+    // If the authentication type is not Basic, we simply return EFalse.
+    return iCredentialsOk;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::RunL
+// Overrides CActive::RunL
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::RunL()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::RunL" );
+    User::LeaveIfError( iStatus.Int() );
+
+    switch (iState)
+        {
+        case EStart:
+            InitializeL();
+            break;
+        case EInitialize:
+            Open();
+            break;
+        case EOpen:
+            SubmitL();
+            break;
+        default:
+            // Panic if called while in ESubmit
+            ASSERT( 0 );
+            break;
+        }
+
+    // Do not advance the state if the transaction was submitted
+    // MHFRunL will be called by the HTTP stack while the transaction 
+    // progresses
+    if ( iState != ESubmit )
+        {
+        // Go to the next state if not finished
+        CompleteSelf();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::DoCancel
+// Called while the state machine is still active. Possible states:
+//
+//  - EStart and EInitialize: iStatus is already completed and CActive::Cancel
+//    will not block
+//  - ESubmit: this method won't be called since the AO is not active.
+//  - EOpen: RConnection::Close will be called from CleanupTransaction,
+//    which will complete the RConnection::Start asynchronous call.
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::DoCancel()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::DoCancel" );
+    ASSERT( iState != ESubmit );
+
+    // Cleanup and generate the callback
+    HandleDownloadComplete( KErrCancel );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::RunError
+// Overrides CActive::RunError
+// ----------------------------------------------------------------------------
+TInt CWmDrmDlaDefaultHttpManager::RunError( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::RunError" );
+    LOG2( "aError: %d", aError ); 
+    // Cleanup and generate the callback
+    HandleDownloadComplete( aError );
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CpHttpManager::CWmDrmDlaDefaultHttpManager
+// ----------------------------------------------------------------------------
+CWmDrmDlaDefaultHttpManager::CWmDrmDlaDefaultHttpManager(
+    MWmDrmDlaDefaltHttpManagerObserver& aObserver,
+    TUint32 aIapNumber ) :
+    CActive( CActive::EPriorityStandard ),
+    iObserver( aObserver ),
+    iState( EConstructed ),
+    iIapNumber( aIapNumber ),
+    iKeepAlive( EFalse )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::CWmDrmDlaDefaultHttpManager" );
+    CActiveScheduler::Add( this );
+    }
+
+// ----------------------------------------------------------------------------
+// CpHttpManager::ConstructL
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::ConstructL" );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::InitializeL
+// Handler for the EStart state.
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::InitializeL()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::InitializeL" );
+    User::LeaveIfError( iSocketServer.Connect() );
+    User::LeaveIfError( iConnection.Open( iSocketServer, KAfInet ) );
+    iState = EInitialize;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::OpenL
+// Handler for the EInitialize state. 
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::Open()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::Open" );
+    // Override dialog preferences
+    // Use if IAP is provided, override the default one
+    if ( iIapNumber )
+        {
+        iCommDbPrefs.SetDialogPreference( ECommDbDialogPrefDoNotPrompt );
+        iCommDbPrefs.SetIapId( iIapNumber );
+        }
+
+    // Start RConnection using specified CommDb preferences overrides
+    // This is async call, thus - signal CWmDrmDlaDefaultHttpManager is active
+    // (SetActive())
+    iCommDbPrefs.SetDirection( ECommDbConnectionDirectionOutgoing );
+    iConnection.Start( iCommDbPrefs, iStatus );
+
+    SetActive();
+    iState = EOpen;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::SubmitL
+// Handler for the EOpen state.
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::SubmitL()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::SubmitL" );
+    
+    TConnectionInfo info;
+    GetConnectionInfoL( info );
+    iIapNumber = info.iIapId;
+    
+    // Open session
+    iHttpSession.OpenL();
+    RStringPool pool = iHttpSession.StringPool();
+    
+    // Associate HTTP session with connection
+    RHTTPConnectionInfo connInfo = iHttpSession.ConnectionInfo();
+    
+    // Specify socket server
+    SET_HTTP_PROPERTY( connInfo, pool, HTTP::EHttpSocketServ, 
+        iSocketServer.Handle() );
+    // Specify connectionn to use
+    TInt connPtr = reinterpret_cast<TInt>(&iConnection);
+    SET_HTTP_PROPERTY( connInfo, pool, HTTP::EHttpSocketConnection, connPtr );
+
+    // Install HTTP authentication filter
+    InstallAuthenticationL( iHttpSession );
+
+    CHttpCookieFilter::InstallFilterL( iHttpSession );
+    
+    RHTTPFilterCollection filterColl = iHttpSession.FilterCollection();
+    filterColl.RemoveFilter( 
+        iHttpSession.StringPool().StringF( 
+            HTTP::ERedirect, RHTTPSession::GetTable() ) );
+    
+    CHttpUAProfFilterInterface::InstallFilterL( iHttpSession );
+    
+    // Parse URI
+    TUriParser8 srcAddress;
+    User::LeaveIfError( srcAddress.Parse( *iSrcAddress ) );
+
+    // Open HTTP transaction
+    iHttpTransaction = iHttpSession.OpenTransactionL( srcAddress, *this,
+        HTTP_STRING( (EGet == iOperation) ? HTTP::EGET : HTTP::EPOST ) );
+    iTransactionOpen = ETrue;
+    
+    // Set the data supplier if a POST operation
+    if ( EPost == iOperation )
+        {
+        iHttpTransaction.Request().SetBody( *iDataSupplier );
+        }
+
+    
+    TInt pos = iSrcAddress->Locate( '?' );
+
+    // If no query ('?') pos is rightmost character
+    pos = (pos != KErrNotFound) ? pos : iSrcAddress->Length();
+    TPtrC8 ptrUrl = iSrcAddress->Left( pos );
+    
+    // Only print if there is a ('?') and something to print after it
+    if ( pos < iSrcAddress->Length() )
+      {
+      TPtrC8 ptrQs = iSrcAddress->Mid( pos );
+      }
+    // Set HTTP headers for the transaction
+    RHTTPHeaders hdr = iHttpTransaction.Request().GetHeaderCollection();
+    TInt nofheaders = iHdrValues.Count();
+
+    for ( TInt i = 0; i < nofheaders; i++ )
+        {
+        TInt field = iHdrFields[i];
+        const TDesC8& fieldStr = HTTP_STRING( field ).DesC();
+        HBufC8* pValue = iHdrValues[i];
+        SetHeaderL( hdr, field, *pValue );
+        }
+
+    // Submit HTTP transaction
+    // This will set in motion the HTTP download
+    iHttpTransaction.SubmitL();
+    iState = ESubmit;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::DoStartL
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::DoStartL(
+    const TDesC8& aUrl,
+    const RArray<CWmDrmDlaDefaultHttpManager::THeader>& aHeaders )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::DoStartL" );
+    CleanupTransaction();
+
+    // Store callers URL
+    iSrcAddress = aUrl.AllocL();
+
+    // Store headers
+    TInt nofheaders = aHeaders.Count();
+    for ( TInt i = 0; i < nofheaders; i++ )
+        {
+        iHdrFields.AppendL( aHeaders[i].iField );
+        iHdrValues.AppendL( aHeaders[i].iVal.AllocL() );
+        }
+
+    if ( (iState == EOpen) && iKeepAlive )
+        {
+        TConnectionInfo connectionInfo;
+        GetConnectionInfoL(connectionInfo);
+        if ( connectionInfo.iIapId != iIapNumber && 
+             iIapNumber != 0 && connectionInfo.iIapId != 0 )
+            {
+            CleanupConnection();
+            iState = EStart;
+            }
+        }
+    else
+        {
+        iState = EConstructed == iState ? EStart : EOpen;
+        }
+
+    iError = KErrNone;
+    iCredentialsOk = ETrue;
+
+    CompleteSelf();
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::HandleDownloadComplete
+// Close HTTP connection and clean up instance variables.
+//
+// Must be called to complete client's request and cleanup, either on 
+// successful download, or some error condition
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::HandleDownloadComplete( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::HandleDownloadComplete" );
+    LOG2( "aError: %d", aError ); 
+    CleanupTransaction();
+
+    iInCallback = ETrue;
+    iObserver.OnTransactionComplete( aError );
+    iInCallback = EFalse;
+
+    if ( iDataSupplier )
+        {
+        iDataSupplier->ReleaseData();
+        iDataSupplier = NULL;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::CleanupTransaction
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::CleanupTransaction()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::CleanupTransaction" );
+    if ( iBody )
+        {
+        iBody->ReleaseData();
+        iBody = NULL;
+        }
+
+    // Release HTTP transaction & session resources
+    delete iSrcAddress;
+    iSrcAddress = NULL;
+
+    TInt nofheaders = iHdrValues.Count();
+    for ( TInt i = 0; i < nofheaders; i++ )
+        {
+        delete iHdrValues[i];
+        }
+
+    // set to empty
+    iHdrValues.Reset();
+    iHdrFields.Reset();
+
+    iHttpTransaction.Close();
+    iHttpSession.Close();
+
+    if ( !iKeepAlive )
+        {
+        CleanupConnection();
+        iState = ESubmit == iState ? EConstructed : iState;
+        }
+    else if ( ESubmit == iState )
+        {
+        // end of a transaction
+        iState = EOpen;
+        }
+    else
+        {
+        // do nothing. This is to get rid of a PC-Lint warning
+        }
+            
+    iTransactionOpen = EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::CleanupConnection
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::CleanupConnection()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::CleanupConnection" );
+    iConnection.Close();
+    iSocketServer.Close();
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::CompleteSelf
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::CompleteSelf()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::CompleteSelf" );
+    if ( !IsActive() ) // else already waiting
+        {
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrNone );
+        SetActive();
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::SetHeaderL
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::SetHeaderL(
+    RHTTPHeaders& aHeaders,
+    TInt aHdrField,
+    const TDesC8& aHdrValue ) const
+    {
+    RStringPool pool = iHttpSession.StringPool();
+    RStringF valStr = pool.OpenFStringL( aHdrValue );
+    CleanupClosePushL( valStr );
+    THTTPHdrVal val( valStr );
+    aHeaders.SetFieldL( HTTP_STRING( aHdrField ), val );
+    CleanupStack::PopAndDestroy( &valStr ); // Close
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpManager::DeleteUsernamePassword
+// This function is NOT currently used as authentication is not current used in
+// this project at the current time
+// ----------------------------------------------------------------------------
+void CWmDrmDlaDefaultHttpManager::DeleteUsernamePassword()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpManager::DeleteUsernamePassword" );
+    delete iUsername;
+    iUsername = NULL;
+    delete iPassword;
+    iPassword = NULL;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaulthttpplugin.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,394 @@
+/*
+* 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:  WMDRM DLA Default HTTP Plugin
+*
+*/
+
+
+#include <gulicon.h>
+#include <wmdrmdlauinotifier.h>
+#include "wmdrmdladefaulthttpplugin.h"
+#include "wmdrmdladefaultlicacq.h"
+#include "wmdrmdladefaultmetering.h"
+#include "wmdrmdladefaultplayready.h"
+
+#define _LOGGING_FILE L"wmdrmdladefaulthttpplugin.txt"
+#include "logfn.h"
+
+// CONSTANTS
+const TUid KWmDrmDlaDefaultUiPluginUid = { 0x20019575 };
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::ConstructL" );
+    iLicenseAcquisition = CWmDrmDlaDefaultLicAcq::NewL( this );
+    iMetering = CWmDrmDlaDefaultMetering::NewL( this );
+    iPlayReady = CWmDrmDlaDefaultPlayReady::NewL( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::CWmDrmDlaDefaultHttpPlugin
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultHttpPlugin::CWmDrmDlaDefaultHttpPlugin()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::CWmDrmDlaDefaultHttpPlugin" );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultHttpPlugin* CWmDrmDlaDefaultHttpPlugin::NewL()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::NewL" );
+    CWmDrmDlaDefaultHttpPlugin* self = 
+        new( ELeave ) CWmDrmDlaDefaultHttpPlugin;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::~CWmDrmDlaDefaultHttpPlugin
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultHttpPlugin::~CWmDrmDlaDefaultHttpPlugin()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::~CWmDrmDlaDefaultHttpPlugin" );
+    delete iLicenseAcquisition;
+    delete iMetering;
+    delete iPlayReady;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::ServiceIcon
+// ---------------------------------------------------------------------------
+//
+CGulIcon* CWmDrmDlaDefaultHttpPlugin::ServiceIcon()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::ServiceIcon" );
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::SupportedFileL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultHttpPlugin::SupportedFileL( 
+    const RFile& aFile,
+    CWmDrmDlaUiNotifier*& aUiNotifier)
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::SupportedFileL" );
+    return iLicenseAcquisition->SupportedFileL( aFile, aUiNotifier );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::SupportedDrmHeaderL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultHttpPlugin::SupportedDrmHeaderL( 
+    const TDesC8& aHeader,
+    CWmDrmDlaUiNotifier*& aUiNotifier )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::SupportedDrmHeaderL" );
+    return iLicenseAcquisition->SupportedDrmHeaderL( aHeader, aUiNotifier );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::SupportedMeteringCertificateL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultHttpPlugin::SupportedMeteringCertificateL( 
+    const TDesC8& aCertificate,
+    CWmDrmDlaUiNotifier*& aUiNotifier )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::SupportedMeteringCertificateL" );
+    return iMetering->SupportedMeteringCertificateL( aCertificate, 
+                                                     aUiNotifier );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::SupportedInitiatorL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultHttpPlugin::SupportedInitiatorL( 
+    const TDesC8& aInitiator, 
+    CWmDrmDlaUiNotifier*& aUiNotifier )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::SupportedInitiatorL" );
+    return iPlayReady->SupportedInitiatorL( aInitiator, aUiNotifier );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::SilentL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultHttpPlugin::SilentL( 
+    const RFile& aFile )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::SilentL" );
+    return iLicenseAcquisition->SilentL( aFile );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::ProcessDrmHeaderL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::ProcessDrmHeaderL( 
+    const TDesC8& aDrmHeader )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::ProcessDrmHeaderL" );
+    iLicenseAcquisition->ProcessDrmHeaderL( aDrmHeader );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::ProcessInitiatorL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::ProcessInitiatorL( 
+    const TDesC8& aInitiator )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::ProcessInitiatorL" );
+    iPlayReady->ProcessInitiatorL( aInitiator );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::AcquireLicense
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::AcquireLicense( 
+    const TDesC8& aLicenseChallenge,
+    HBufC* aLicenseServerUrl,
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::AcquireLicense" );
+    iLicenseAcquisition->AcquireLicense( aLicenseChallenge, 
+                                         aLicenseServerUrl, 
+                                         aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::GetLicenseResponseL
+// ---------------------------------------------------------------------------
+//
+HBufC8* CWmDrmDlaDefaultHttpPlugin::GetLicenseResponseL()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::GetLicenseResponseL" );
+    return iLicenseAcquisition->GetLicenseResponseL();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::SendLicenseStorageStatus
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::SendLicenseStorageStatus( 
+    HBufC8* aTid,
+    const TDesC& aUrl,
+    TInt aError, 
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::SendLicenseStorageStatus" );
+    iLicenseAcquisition->SendLicenseStorageStatus( aTid, 
+                                                   aUrl, 
+                                                   aError, 
+                                                   aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::SendDrmHeaderError
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::SendDrmHeaderError( 
+    const TDesC& aErrorUrl, 
+    TInt aError, 
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::SendDrmHeaderError" );
+    iLicenseAcquisition->SendDrmHeaderError( aErrorUrl, aError, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::GetContentUrlL
+// ---------------------------------------------------------------------------
+//
+HBufC* CWmDrmDlaDefaultHttpPlugin::GetContentUrlL()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::GetContentUrlL" );
+    return iLicenseAcquisition->GetContentUrlL();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::GetHtmlDataL
+// ---------------------------------------------------------------------------
+//
+HBufC* CWmDrmDlaDefaultHttpPlugin::GetHtmlDataL()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::GetHtmlDataL" );
+    return iLicenseAcquisition->GetHtmlDataL();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::CancelLicenseAcquisition
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::CancelLicenseAcquisition()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::CancelLicenseAcquisition" );
+    iLicenseAcquisition->CancelLicenseAcquisition();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::ProcessMeteringChallenge
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::ProcessMeteringChallenge( 
+    const TDesC8& aMeteringChallenge, 
+    const TDesC& aUrl, 
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::ProcessMeteringChallenge" );
+    iMetering->ProcessMeteringChallenge( aMeteringChallenge, aUrl, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::GetMeteringResponse
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::GetMeteringResponse( 
+    HBufC8*& aResponse, 
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::GetMeteringResponse" );
+    iMetering->GetMeteringResponse( aResponse, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::MeteringFinished
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::MeteringFinished()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::MeteringFinished" );
+    iMetering->MeteringFinished();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::CancelMetering
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::CancelMetering()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::CancelMetering" );
+    iMetering->CancelMetering();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::ProcessJoinDomainChallenge
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::ProcessJoinDomainChallenge( 
+    const TDesC8& aJoinDomainChallenge, 
+    const TDesC& aUrl, 
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::ProcessJoinDomainChallenge" );
+    iPlayReady->ProcessJoinDomainChallenge( aJoinDomainChallenge, 
+                                            aUrl, 
+                                            aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::ProcessLeaveDomainChallenge
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::ProcessLeaveDomainChallenge( 
+    const TDesC8& aLeaveDomainChallenge, 
+    const TDesC& aUrl, 
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::ProcessLeaveDomainChallenge" );
+    iPlayReady->ProcessLeaveDomainChallenge( aLeaveDomainChallenge, 
+                                             aUrl, 
+                                             aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::SetIapId
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::SetIapId( TInt aIapId )
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::SetIapId" );
+    iLicenseAcquisition->SetIapId( aIapId );
+    iMetering->SetIapId( aIapId );
+    iPlayReady->SetIapId( aIapId );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::InitializeUiNotifierL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultHttpPlugin::InitializeUiNotifierL()
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::InitializeUiNotifierL" );
+    //Tries to initialize UiNotifier. If UiNotifier can't be created or
+    //initialization fails, then leaves with error code, won't take ownership
+    //of the notifier
+    iUiNotifier = NULL;
+    iUiNotifier = CWmDrmDlaUiNotifier::NewL();
+    TRAPD( err, iUiNotifier->InitializeL( KWmDrmDlaDefaultUiPluginUid ) );
+    if ( err )
+        {
+        delete iUiNotifier;
+        iUiNotifier = NULL;
+        User::Leave( err );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::UiNotifier
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaUiNotifier* CWmDrmDlaDefaultHttpPlugin::UiNotifier()
+    {
+    return iUiNotifier;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::Supported
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultHttpPlugin::Supported( 
+    const TDesC8& aString,
+    const TDesC8& aIdentifier)
+    {
+    LOGFN( "CWmDrmDlaDefaultHttpPlugin::Supported" );
+    TBool supported( EFalse );
+    if ( aString.FindF( aIdentifier ) != KErrNotFound )
+        {
+        supported = ETrue;
+        }
+    LOG2( "supported: %d", supported );
+    return supported;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaulthttppluginproxy.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* 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:  WMDRM DLA Default HTTP Plugin Proxy
+*
+*/
+
+
+#include <ecom/implementationproxy.h>
+#include "wmdrmdladefaulthttpplugin.h"
+
+const TImplementationProxy ImplementationTable[] =
+	{
+#ifdef __EABI__
+		IMPLEMENTATION_PROXY_ENTRY( 0x20019574, CWmDrmDlaDefaultHttpPlugin::NewL )
+#else
+		{ {0x20019574}, CWmDrmDlaDefaultHttpPlugin::NewL }
+#endif
+	}; 
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy: Lookup method required by ECom
+// Returns the ImplementationTable to the  ECom framework
+// -----------------------------------------------------------------------------
+//
+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/wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaultlicacq.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,891 @@
+/*
+* 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:  WMDRM DLA Default Http License Acquisition
+*
+*/
+
+
+#include <chttpformencoder.h>
+#include <httpstringconstants.h>
+#include <httperr.h>
+#include <http/rhttpheaders.h>
+#include <http/thttphdrfielditer.h>
+#include <stringpool.h>
+#include <escapeutils.h>
+#include <wmdrmdlatypes.h>
+#include <wmdrmdlauinotifier.h>
+#include "asf.h"
+#include "wmdrmdladefaultlicacq.h"
+#include "wmdrmdladefaulthttpplugin.h"
+#include "wmdrmdlabrowserviewhandler.h"
+#include "wmdrmdlabrowserobserver.h"
+#include "wmdrmdladefaulthttpmanager.h"
+
+#define _LOGGING_FILE L"wmdrmdladefaulthttpplugin.txt"
+#include "logfn.h"
+
+// CONSTANTS
+_LIT8( KDefaultIdentifier8, "camese" );
+_LIT8( KDefaultIdentifier, "c\0a\0m\0e\0s\0e\0" );
+_LIT8( KNonSilentIdentifier, "n\0o\0n\0s\0i\0l\0e\0n\0t" );
+
+_LIT8( KAcceptHeader8, "*/*" );
+_LIT8( KAcceptLanguageHeader8, "en-us" );
+_LIT8( KPostContentTypeHeader8, "application/x-www-form-urlencoded" );
+
+_LIT8( KDataTypeLicenseResponse, "application/vnd.ms-wmdrm.lic-resp" );
+_LIT8( KDataTypeHtml, "text/html" );
+
+_LIT8( KGetLicenseChallengeParam8, "challenge" );
+_LIT8( KGetNonSilentParam8, "nonsilent" );
+_LIT8( KLicenseStatusParam8, "License1Status" );
+
+_LIT8( KTIDHeader8, "TID=" );
+_LIT8( KQueryTag8, "?" );
+_LIT8( KNonSilentValue, "1" );
+
+_LIT8( KAmpersand, "&" );
+_LIT8( KChallenge, "nonsilent=1&challenge=" );
+
+_LIT8( KHRESULTFormat,"0x%08x" );
+const TInt KHRESULTFormatLength = 10; // '0x' + %08x
+const TUint KHRESULTBase = 0x80000000; 
+const TInt KHRESULTErrorMask = 0x01 << 31 | 0x04 << 16;
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::ConstructL" );
+    iHttpManager = CWmDrmDlaDefaultHttpManager::NewL( *this );
+    iHttpManager->SetKeepAlive( ETrue );
+    iIdle =  CIdle::NewL( CActive::EPriorityIdle );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::CWmDrmDlaDefaultLicAcq
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultLicAcq::CWmDrmDlaDefaultLicAcq(
+    CWmDrmDlaDefaultHttpPlugin* aPlugin ) 
+    : iState( CWmDrmDlaDefaultLicAcq::ENotActive ), iPlugin( aPlugin )
+      
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::CWmDrmDlaDefaultLicAcq" );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultLicAcq* CWmDrmDlaDefaultLicAcq::NewL(
+    CWmDrmDlaDefaultHttpPlugin* aPlugin )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::NewL" );
+    CWmDrmDlaDefaultLicAcq* self 
+        = new( ELeave ) CWmDrmDlaDefaultLicAcq( aPlugin );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::~CWmDrmDlaDefaultLicAcq
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultLicAcq::~CWmDrmDlaDefaultLicAcq()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::~CWmDrmDlaDefaultLicAcq" );
+    delete iIdle;
+    delete iBrowserViewHandler;
+    delete iHttpManager;
+    delete iFormEncoder;
+    delete iPostData;
+    delete iLicenseChallenge;
+    delete iLicenseResponse;
+    delete iLicenseServerUrl16;
+    delete iLicenseServerUrl;
+    delete iHtmlData;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::SupportedFileL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultLicAcq::SupportedFileL( 
+    const RFile& aFile,
+    CWmDrmDlaUiNotifier*& aUiNotifier)
+    {
+    TInt err( KErrNone );
+    TBool supported( EFalse );
+        
+    LOGFNR( "CWmDrmDlaDefaultLicAcq::SupportedFileL", err );
+    
+    //Check that the file is valid ASF-file and that the extented content
+    //encryption object of the file includes MS test site identifier
+    CAsf* asf( NULL );
+    TRAP( err, asf = CAsf::NewL( aFile ) );
+    if ( !err )
+        {
+        supported = iPlugin->Supported( *asf->iExtendedContentEncryptionObject,
+                                        KDefaultIdentifier );
+        delete asf;
+        }
+    
+    //If file is recognized, then initialize UiNotifier and transfer its
+    //ownership to the FW
+    if ( supported )
+        {
+        iPlugin->InitializeUiNotifierL();
+        aUiNotifier = iPlugin->UiNotifier();
+        }
+    LOG2( "supported: %d", supported );     
+    return supported;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::SupportedDrmHeaderL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultLicAcq::SupportedDrmHeaderL( 
+    const TDesC8& aHeader,
+    CWmDrmDlaUiNotifier*& aUiNotifier )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::SupportedDrmHeaderL" );
+    
+    //Check that the drm header includes MS test site identifier
+    TBool supported( iPlugin->Supported( aHeader, KDefaultIdentifier8 ) );
+    //If header is recognized, then initialize UiNotifier and transfer its
+    //ownership to the FW
+    if ( supported )
+        {
+        iPlugin->InitializeUiNotifierL();
+        aUiNotifier = iPlugin->UiNotifier();
+        }
+    LOG2( "supported: %d", supported );    
+    return supported;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::SilentL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultLicAcq::SilentL( 
+    const RFile& aFile )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaDefaultLicAcq::SilentL", err );
+    
+    //Check is the content silent or not by checking that the extented content
+    //encryption object of the file includes MS test site non-silent identifier
+    iNonSilent = EFalse;
+    CAsf* asf( NULL );
+    TRAP( err, asf = CAsf::NewL( aFile ) );
+    if ( !err )
+        {
+        iNonSilent = 
+            iPlugin->Supported( *asf->iExtendedContentEncryptionObject,
+                                KNonSilentIdentifier );
+        delete asf;
+        }
+    iPlugin->UiNotifier()->SetSilent( !iNonSilent );
+    LOG2( "!iNonSilent: %d", !iNonSilent );
+    return !iNonSilent;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::ProcessDrmHeaderL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::ProcessDrmHeaderL( 
+    const TDesC8& /*aDrmHeader*/ )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::ProcessDrmHeaderL" );
+    iPlugin->UiNotifier()->SetProgress( EProcessingDRMHeader );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::AcquireLicense
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::AcquireLicense( 
+    const TDesC8& aLicenseChallenge,
+    HBufC* aLicenseServerUrl,
+    TRequestStatus& aStatus )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaDefaultLicAcq::AcquireLicense", err );
+    
+    iPlugin->UiNotifier()->SetProgress( ERetrievingLicense );
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    
+    delete iLicenseServerUrl;
+    iLicenseServerUrl = NULL;
+    TRAP( err, 
+            iLicenseServerUrl = 
+                EscapeUtils::ConvertFromUnicodeToUtf8L( *aLicenseServerUrl ) );
+    if ( !iLicenseServerUrl )
+        {
+        CompleteClientRequest( err );
+        return;
+        }
+    delete iLicenseChallenge;
+    iLicenseChallenge = NULL;
+    iLicenseChallenge = aLicenseChallenge.Alloc();
+    if ( !iLicenseChallenge )
+        {
+        CompleteClientRequest( KErrNoMemory );
+        return;
+        }
+    TRAP( err, AcquireLicenseL() );
+    if ( err )
+        {
+        CompleteClientRequest( err );
+        return;
+        }
+    iState = CWmDrmDlaDefaultLicAcq::ESendingLicenseChallenge;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::GetLicenseResponseL
+// ---------------------------------------------------------------------------
+//
+HBufC8* CWmDrmDlaDefaultLicAcq::GetLicenseResponseL()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::GetLicenseResponseL" );
+    iPlugin->UiNotifier()->SetProgress( EAddingLicense );
+    if ( iLicenseResponse )
+        {
+        return iLicenseResponse->AllocL();
+        }
+    else
+        {
+        return NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::SendLicenseStorageStatus
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::SendLicenseStorageStatus( 
+    HBufC8* aTid,
+    const TDesC& /*aUrl*/,
+    TInt aError, 
+    TRequestStatus& aStatus )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaDefaultLicAcq::SendLicenseStorageStatus", err );
+    LOG2( "aError: %d", aError );
+    
+    iPlugin->UiNotifier()->SetProgress( ESendingLicenseStorageStatus );
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    
+    if ( !aTid )
+        {
+        CompleteClientRequest( KErrCorrupt );
+        return;
+        }
+    
+    TRAP( err, SendLicenseStorageStatusL( *aTid, aError ) );
+    if ( err )
+        {
+        CompleteClientRequest( err );
+        return;
+        }
+    iState = CWmDrmDlaDefaultLicAcq::ESendingStorageStatus;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::SendDrmHeaderError
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::SendDrmHeaderError( 
+    const TDesC& /*aErrorUrl*/, 
+    TInt /*aError*/, 
+    TRequestStatus& aStatus )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::SendDrmHeaderError" );
+    iPlugin->UiNotifier()->SetProgress( ESendingDrmHeaderStatus );
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    CompleteClientRequest( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::GetContentUrlL
+// ---------------------------------------------------------------------------
+//
+HBufC* CWmDrmDlaDefaultLicAcq::GetContentUrlL()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::GetContentUrlL" );
+    return NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::GetHtmlDataL
+// ---------------------------------------------------------------------------
+//
+HBufC* CWmDrmDlaDefaultLicAcq::GetHtmlDataL()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::GetHtmlDataL" );
+    iPlugin->UiNotifier()->SetProgress( EIdle );
+    if ( iHtmlData )
+        {
+        return iHtmlData->AllocL();
+        }
+    else
+        {
+        return NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::CancelLicenseAcquisition
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::CancelLicenseAcquisition()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::CancelLicenseAcquisition" );
+    iHttpManager->Stop();
+    CompleteClientRequest( KErrCancel );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::SetIapId
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::SetIapId( TInt aIapId )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::SetIapId" );
+    LOG2( "aIapId: %d", aIapId );
+    iHttpManager->SetIapId( aIapId );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::OnGetUsernamePasswordL
+// From MHttpManagerObserver
+// This function is called when using HTTPS authentication. Authentication is 
+// not currently used in the Camese project
+// ----------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultLicAcq::OnGetUsernamePasswordL(
+    HBufC8*& /*aUsername*/,
+    HBufC8*& /*aPassword*/)
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::OnGetUsernamePasswordL" );
+    return EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::OnResponseHeadersL
+// From MHttpManagerObserver
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::OnResponseHeadersL(
+    const RHTTPResponse& /*aResponse*/,
+    const RHTTPHeaders& aHeaders,
+    const RStringPool& aStringPool,
+    TInt aHttpStatus )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::OnResponseHeadersL" );
+    LOG2( "iState: %d", iState );
+    LOG2( "aHttpStatus: %d", aHttpStatus );
+    //Redirection in license acquisition
+    if ( aHttpStatus >= HTTPStatus::EMultipleChoices && 
+         aHttpStatus < HTTPStatus::EBadRequest &&
+         iState == CWmDrmDlaDefaultLicAcq::ESendingLicenseChallenge )
+        {
+        HandleRedirectionHeadersL( aHeaders, aStringPool );
+        }
+    //License acquisition
+    else if ( aHttpStatus == HTTPStatus::EOk &&
+              iState != CWmDrmDlaDefaultLicAcq::ESendingStorageStatus )
+        {
+        HandleLicenseAcquistionHeaders( aHeaders, aStringPool );
+        }
+    //Sending license storage status or error
+    else
+        {
+        iHttpStatus = aHttpStatus;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::OnResponseBodyDataL
+// From MHttpManagerObserver
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::OnResponseBodyDataL( const TPtrC8 aDataChunk )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::OnResponseBodyDataL" );
+    LOG2( "iState: %d", iState );
+    LOG2( "iHttpStatus: %d", iHttpStatus );
+    //If we are acquiring license and response headers are OK,
+    //then save the response.
+    if ( iHttpStatus == HTTPStatus::EOk && 
+         iState == CWmDrmDlaDefaultLicAcq::ESendingLicenseChallenge )
+        {
+        if ( !iLicenseResponse )
+            {
+            iLicenseResponse = HBufC8::NewL( aDataChunk.Length() );
+            }
+        else
+            {
+            iLicenseResponse = 
+                iLicenseResponse->ReAllocL( iLicenseResponse->Length() + 
+                                            aDataChunk.Length() );
+            }
+        iLicenseResponse->Des().Append( aDataChunk );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::OnTransactionComplete
+// From MHttpManagerObserver
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::OnTransactionComplete( TInt aSystemError )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::OnTransactionComplete" );
+    LOG2( "iState: %d", iState );
+    LOG2( "aSystemError: %d", aSystemError );
+    LOG2( "iHttpStatus: %d", iHttpStatus );
+    TInt err( KErrNone );
+    //Transaction succeeded
+    if ( iHttpStatus == HTTPStatus::EOk && !aSystemError )
+        {
+        //If redirection happened, then start a new license acquisition
+        //asynchronously to a new location.
+        if ( iState == CWmDrmDlaDefaultLicAcq::ERedirection )
+            {
+            TCallBack callBack( CWmDrmDlaDefaultLicAcq::Redirection, 
+                                this );
+            iIdle->Start( callBack );
+            iState = CWmDrmDlaDefaultLicAcq::ESendingLicenseChallenge;
+            }
+        //If license acquisition is non-silent, then launch a browser view.
+        else if ( iState == 
+                        CWmDrmDlaDefaultLicAcq::ENonSilentLicenseAcquisition )
+            {
+            TRAP( err, LaunchBrowserViewL() );
+            if ( err )
+                {
+                CompleteClientRequest( err );
+                return;
+                }
+            iPlugin->UiNotifier()->SetProgress( EIdle );
+            iState = CWmDrmDlaDefaultLicAcq::EBrowserView;
+            }
+        //License received silently or license storage status sent succesfully.
+        else 
+            {
+            CompleteClientRequest( aSystemError );
+            }
+        }
+    //Error in transaction
+    else if ( iHttpStatus != HTTPStatus::EOk && 
+              iHttpStatus != KErrNone )
+        {
+        CompleteClientRequest( KErrCommsBreak );
+        }
+    //System error
+    else
+        {
+        CompleteClientRequest( aSystemError );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::CompleteClientRequest
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::CompleteClientRequest( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::CompleteClientRequest" );
+    LOG2( "aError: %d", aError );
+    if ( iClientStatus )
+        {
+        User::RequestComplete( iClientStatus, aError );
+        iClientStatus = NULL;
+        }
+    iState = CWmDrmDlaDefaultLicAcq::ENotActive;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::AcquireLicenseL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::AcquireLicenseL()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::AcquireLicenseL" );
+    // Set headers
+    RArray<CWmDrmDlaDefaultHttpManager::THeader> headers;
+    CleanupClosePushL( headers );
+
+    headers.AppendL( CWmDrmDlaDefaultHttpManager::THeader( HTTP::EAccept, 
+                                                           KAcceptHeader8 ) );
+    headers.AppendL( 
+            CWmDrmDlaDefaultHttpManager::THeader( HTTP::EAcceptLanguage, 
+                                                  KAcceptLanguageHeader8 ) );
+    headers.AppendL( 
+            CWmDrmDlaDefaultHttpManager::THeader( HTTP::EContentType, 
+                                                  KPostContentTypeHeader8 ) );
+
+    // Set POST contents
+    delete iFormEncoder;
+    iFormEncoder = NULL;
+    iFormEncoder = CHTTPFormEncoder::NewL();
+
+    //If license acquisition is non-silent, then add non-silent field to
+    //request
+    if ( iNonSilent )
+        {
+        iFormEncoder->AddFieldL( KGetNonSilentParam8, KNonSilentValue );
+        }
+    
+    iFormEncoder->AddFieldL( KGetLicenseChallengeParam8, *iLicenseChallenge );
+
+    //Post a request, make sure that iLicenseResponse is NULL
+    delete iLicenseResponse;
+    iLicenseResponse = NULL;
+    iHttpManager->Post( *iLicenseServerUrl, headers, iFormEncoder );
+
+    CleanupStack::PopAndDestroy( &headers );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::SendLicenseStorageStatusL
+// ---------------------------------------------------------------------------
+//    
+void CWmDrmDlaDefaultLicAcq::SendLicenseStorageStatusL( 
+    const TDesC8& aTid, 
+    TInt aError )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::SendLicenseStorageStatusL" );
+    LOG2( "aError: %d", aError );
+    TInt licenseHRESULT( MakeHRESULT( aError ) );
+    
+    HBufC8* statusUrl = NULL;
+    TInt pos( iLicenseServerUrl->Locate( '?' ) );
+    // If no query ('?') pos is rightmost character
+    pos = (pos != KErrNotFound) ? pos : iLicenseServerUrl->Length();
+    TPtrC8 ptrUrl( iLicenseServerUrl->Left( pos ) );
+    TInt len( ptrUrl.Length() + KQueryTag8().Length() + 
+              KTIDHeader8().Length() + aTid.Length() );
+
+    statusUrl = HBufC8::NewLC( len );
+    TPtr8 url( statusUrl->Des() );
+    url.Append( ptrUrl );
+    url.Append( KQueryTag8 );
+    url.Append( KTIDHeader8 );
+    url.Append( aTid );
+
+    SendHRESULTL( *statusUrl, KLicenseStatusParam8(), licenseHRESULT );
+
+    CleanupStack::PopAndDestroy( statusUrl );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::MakeHRESULT
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaDefaultLicAcq::MakeHRESULT( 
+    TInt aError )
+    {
+    TInt result( 0 );
+	
+    LOGFNR( "CWmDrmDlaDefaultLicAcq::MakeHRESULT", result );
+        
+    // If there is no error then we need to send 0x00000000
+    if ( !aError )
+        {
+        result = 0;
+        }
+    // Convert Symbian error convert to an HRESULT
+    else if ( static_cast<TUint>(aError) < KHRESULTBase )
+        {
+        result = KHRESULTErrorMask | aError; 
+        }
+    else
+        {
+        // This is already in HRESULT format so use it directly
+        result = aError;
+        }
+    return result;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::SendHRESULTL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::SendHRESULTL( 
+    const TDesC8& aUrl, 
+    const TDesC8& aHeaderField, 
+    TInt aHRESULT )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::SendHRESULTL" );
+    
+    //Set headers
+    RArray<CWmDrmDlaDefaultHttpManager::THeader> headers;
+    CleanupClosePushL( headers );
+
+    headers.AppendL( CWmDrmDlaDefaultHttpManager::THeader( HTTP::EAccept,
+                                                           KAcceptHeader8 ) );
+    headers.AppendL( 
+            CWmDrmDlaDefaultHttpManager::THeader( HTTP::EAcceptLanguage,
+                                                  KAcceptLanguageHeader8 ) );
+    headers.AppendL( 
+            CWmDrmDlaDefaultHttpManager::THeader( HTTP::EContentType, 
+                                                  KPostContentTypeHeader8 ) );
+
+    HBufC8* resultStatus = HBufC8::NewLC( KHRESULTFormatLength );
+    resultStatus->Des().Format( KHRESULTFormat, aHRESULT );
+
+    //Set POST contents
+    delete iFormEncoder;
+    iFormEncoder = NULL;
+    iFormEncoder = CHTTPFormEncoder::NewL();
+
+    iFormEncoder->AddFieldL( aHeaderField, *resultStatus );
+
+    CleanupStack::PopAndDestroy( resultStatus );
+
+    //Post a request
+    iHttpManager->Post( aUrl, headers, iFormEncoder );
+
+    CleanupStack::PopAndDestroy( &headers );
+    } 
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::HandleRedirectionHeadersL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::HandleRedirectionHeadersL( 
+    const RHTTPHeaders& aHeaders,
+    const RStringPool& aStringPool )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::HandleRedirectionHeadersL" );
+    
+    //Get the redirected location
+    RStringF locationStr = aStringPool.StringF( HTTP::ELocation, 
+                                                RHTTPSession::GetTable() );
+    CleanupClosePushL( locationStr );
+    THTTPHdrVal locationValue;
+    if ( !aHeaders.GetField( locationStr, 0, locationValue ) )
+        {
+        //Set new redirected url and change state to redirection
+        delete iLicenseServerUrl;
+        iLicenseServerUrl = NULL;
+        iLicenseServerUrl = locationValue.StrF().DesC().AllocL();
+        iState = CWmDrmDlaDefaultLicAcq::ERedirection;
+        iHttpStatus = HTTPStatus::EOk;
+        }
+    else
+        {
+        iHttpStatus = KErrHttpRedirectNoLocationField;
+        }
+    CleanupStack::PopAndDestroy( &locationStr );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::HandleLicenseAcquistionHeaders
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::HandleLicenseAcquistionHeaders( 
+    const RHTTPHeaders& aHeaders,
+    const RStringPool& aStringPool )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::HandleLicenseAcquistionHeaders" );
+    
+    RStringF contentTypeNameStr = 
+        aStringPool.StringF( HTTP::EContentType, RHTTPSession::GetTable() );
+
+    // read the first part of content-type field
+    THTTPHdrVal contentTypeVal;
+    if( !aHeaders.GetField( contentTypeNameStr, 0, contentTypeVal ) )
+        {
+        //Silent license acquisition
+        if ( iState == CWmDrmDlaDefaultLicAcq::ESendingLicenseChallenge &&
+             contentTypeVal.StrF().DesC().MatchF( KDataTypeLicenseResponse ) !=
+                                                  KErrNotFound )
+            {
+            iHttpStatus = HTTPStatus::EOk;
+            }
+        //Non silent license acquisition
+        else if ( iState == CWmDrmDlaDefaultLicAcq::ESendingLicenseChallenge &&
+                  contentTypeVal.StrF().DesC().MatchF( KDataTypeHtml ) != 
+                                                       KErrNotFound )
+            {
+            iHttpStatus = HTTPStatus::EOk;
+            iNonSilent = ETrue;
+            iState = CWmDrmDlaDefaultLicAcq::ENonSilentLicenseAcquisition;
+            }
+        else
+            {
+            iHttpStatus = KErrHttpDecodeContentType;
+            }
+        }
+    else
+        {
+        iHttpStatus = KErrHttpDecodeContentType;
+        }
+    contentTypeNameStr.Close();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::LaunchBrowserViewL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::LaunchBrowserViewL()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::LaunchBrowserViewL" );
+    
+    if ( !iBrowserViewHandler )
+        {
+        iBrowserViewHandler = CWmDrmDlaBrowserViewHandler::NewL();
+        }
+    iBrowserViewHandler->LaunchBrowserViewL( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::Redirection
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaDefaultLicAcq::Redirection( TAny* aPtr )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaDefaultLicAcq::Redirection", err );
+    
+    CWmDrmDlaDefaultLicAcq* defaultLicAcq = 
+        static_cast<CWmDrmDlaDefaultLicAcq*>( aPtr );
+
+    TRAP( err, defaultLicAcq->AcquireLicenseL() );
+    if ( err )
+        {
+        defaultLicAcq->CompleteClientRequest( err );
+        }
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::PostUrlL
+// ---------------------------------------------------------------------------
+//
+const TDesC& CWmDrmDlaDefaultLicAcq::PostUrlL()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::PostUrlL" );
+    delete iLicenseServerUrl16;
+    iLicenseServerUrl16 = NULL;
+    iLicenseServerUrl16 
+        = EscapeUtils::ConvertToUnicodeFromUtf8L( *iLicenseServerUrl );
+    return *iLicenseServerUrl16;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::PostContentTypeL
+// ---------------------------------------------------------------------------
+//
+const TDesC8& CWmDrmDlaDefaultLicAcq::PostContentTypeL()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::PostContentTypeL" );
+    return KPostContentTypeHeader8;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::PostDataL
+// ---------------------------------------------------------------------------
+//
+const TDesC8& CWmDrmDlaDefaultLicAcq::PostDataL()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::PostDataL" );
+    delete iPostData;
+    iPostData = NULL;
+    iPostData = HBufC8::NewL( KChallenge().Length() + 
+                              iLicenseChallenge->Length() );
+    TPtr8 ptr( iPostData->Des() );
+    ptr.Append( KChallenge() );
+    ptr.Append( *iLicenseChallenge );
+    return *iPostData;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::PostContentDataBoundaryL
+// ---------------------------------------------------------------------------
+//
+const TDesC8& CWmDrmDlaDefaultLicAcq::PostContentDataBoundaryL()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::PostContentDataBoundaryL" );
+    return KAmpersand;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::IapId
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaDefaultLicAcq::IapId()
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::IapId" );
+    return iHttpManager->IapId();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::LicenseResponseReceived
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::LicenseResponseReceived( 
+    const TDesC8& aLicenseResponse )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaDefaultLicAcq::LicenseResponseReceived", err );
+    
+    //Non-silent license response received, allocate the response and complete
+    //client request
+    delete iLicenseResponse;
+    iLicenseResponse = NULL;
+    iLicenseResponse = aLicenseResponse.Alloc();
+    if ( !iLicenseResponse )
+        {
+        err = KErrNoMemory;
+        }
+    CompleteClientRequest( err );
+    iPlugin->UiNotifier()->SetProgress( EProcessingDRMHeader );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultLicAcq::BrowserExit
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultLicAcq::BrowserExit( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaDefaultLicAcq::BrowserExit" );
+    LOG2( "aError: %d", aError );
+    //Browser view closed in non-silent license acquisition, complete
+    //client request with the error code.
+    CompleteClientRequest( aError );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaultmetering.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,388 @@
+/*
+* 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:  WMDRM DLA Default Metering
+*
+*/
+
+
+#include <chttpformencoder.h>
+#include <httpstringconstants.h>
+#include <httperr.h>
+#include <http/rhttpheaders.h>
+#include <http/thttphdrfielditer.h>
+#include <stringpool.h>
+#include <escapeutils.h>
+#include <wmdrmdlatypes.h>
+#include <wmdrmdlauinotifier.h>
+#include "wmdrmdladefaultmetering.h"
+#include "wmdrmdladefaulthttpplugin.h"
+#include "wmdrmdladefaulthttpmanager.h"
+
+#define _LOGGING_FILE L"wmdrmdladefaulthttpplugin.txt"
+#include "logfn.h"
+
+// CONSTANTS
+_LIT8( KDefaultIdentifier, "camese" );
+
+_LIT8( KAcceptHeader8, "*/*" );
+_LIT8( KAcceptLanguageHeader8, "en-us" );
+_LIT8( KPostContentTypeHeader8, "application/x-www-form-urlencoded" );
+
+_LIT8( KDataTypeMeteringResponse, "application/vnd.ms-wmdrm.meter-resp" );
+_LIT8( KGetMeterChallengeParam8, "meterchallenge" );
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultMetering::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::ConstructL" );
+    iHttpManager = CWmDrmDlaDefaultHttpManager::NewL( *this );
+    iHttpManager->SetKeepAlive( ETrue );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::CWmDrmDlaDefaultMetering
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultMetering::CWmDrmDlaDefaultMetering( 
+    CWmDrmDlaDefaultHttpPlugin* aPlugin ) 
+    : iState( CWmDrmDlaDefaultMetering::ENotActive ), iPlugin( aPlugin )
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::CWmDrmDlaDefaultMetering" );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultMetering* CWmDrmDlaDefaultMetering::NewL(
+    CWmDrmDlaDefaultHttpPlugin* aPlugin )
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::NewL" );
+    CWmDrmDlaDefaultMetering* self 
+        = new( ELeave ) CWmDrmDlaDefaultMetering( aPlugin );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::~CWmDrmDlaDefaultMetering
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultMetering::~CWmDrmDlaDefaultMetering()
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::~CWmDrmDlaDefaultMetering" );
+    delete iHttpManager;
+    delete iFormEncoder;
+    delete iMeteringResponse;
+    delete iMeteringServerUrl;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::SupportedMeteringCertificateL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultMetering::SupportedMeteringCertificateL( 
+    const TDesC8& aCertificate,
+    CWmDrmDlaUiNotifier*& aUiNotifier )
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::SupportedMeteringCertificateL" );
+    
+    TBool supported( iPlugin->Supported( aCertificate, KDefaultIdentifier ) );
+    if ( supported )
+        {
+        iPlugin->InitializeUiNotifierL();
+        aUiNotifier = iPlugin->UiNotifier();
+        }
+    LOG2( "supported: %d", supported );     
+    return supported;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::ProcessMeteringChallenge
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultMetering::ProcessMeteringChallenge( 
+    const TDesC8& aMeteringChallenge, 
+    const TDesC& aUrl, 
+    TRequestStatus& aStatus )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaDefaultMetering::ProcessMeteringChallenge", err );
+    
+    iPlugin->UiNotifier()->SetProgress( EProcessingMeteringChallenge );
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    
+    delete iMeteringServerUrl;
+    iMeteringServerUrl = NULL;
+    iMeteringServerUrl = aUrl.Alloc();
+    if ( !iMeteringServerUrl )
+        {
+        CompleteClientRequest( KErrNoMemory );
+        return;
+        }
+    
+    TRAP( err, ProcessMeteringChallengeL( aMeteringChallenge ) );
+    if ( err )
+        {
+        CompleteClientRequest( err );
+        return;
+        }
+    iState = CWmDrmDlaDefaultMetering::ESendingMeteringChallenge;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::GetMeteringResponse
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultMetering::GetMeteringResponse( 
+    HBufC8*& aResponse, 
+    TRequestStatus& aStatus )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaDefaultMetering::GetMeteringResponse", err );
+        
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    
+    if ( iMeteringResponse )
+        {
+        aResponse = iMeteringResponse->Alloc();
+        if ( !aResponse )
+            {
+            err = KErrNoMemory;
+            }
+        }
+    else
+        {
+        aResponse = NULL;
+        }
+    CompleteClientRequest( err );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::MeteringFinished
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultMetering::MeteringFinished()
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::MeteringFinished" );
+    iPlugin->UiNotifier()->SetProgress( EIdle );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::CancelMetering
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultMetering::CancelMetering()
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::CancelMetering" );
+    iHttpManager->Stop();
+    CompleteClientRequest( KErrCancel );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::SetIapId
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultMetering::SetIapId( TInt aIapId )
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::SetIapId" );
+    LOG2( "aIapId: %d", aIapId );
+    iHttpManager->SetIapId( aIapId );
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::OnGetUsernamePasswordL
+// From MHttpManagerObserver
+// This function is called when using HTTPS authentication. Authentication is 
+// not currently used in the Camese project
+// ----------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultMetering::OnGetUsernamePasswordL(
+    HBufC8*& /*aUsername*/,
+    HBufC8*& /*aPassword*/)
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::OnGetUsernamePasswordL" );
+    return EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::OnResponseHeadersL
+// From MHttpManagerObserver
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultMetering::OnResponseHeadersL(
+    const RHTTPResponse& /*aResponse*/,
+    const RHTTPHeaders& aHeaders,
+    const RStringPool& aStringPool,
+    TInt aHttpStatus )
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::OnResponseHeadersL" );
+    LOG2( "iState: %d", iState );
+    LOG2( "aHttpStatus: %d", aHttpStatus );
+    if ( aHttpStatus == HTTPStatus::EOk )
+        {
+        RStringF contentTypeNameStr 
+            = aStringPool.StringF( HTTP::EContentType, 
+                                   RHTTPSession::GetTable() );
+
+        // read the first part of content-type field
+        THTTPHdrVal contentTypeVal;
+        if( !aHeaders.GetField( contentTypeNameStr, 0, contentTypeVal ) )
+            {
+            //Metering
+            if ( iState == 
+                        CWmDrmDlaDefaultMetering::ESendingMeteringChallenge &&
+                 contentTypeVal.StrF().DesC().MatchF( 
+                         KDataTypeMeteringResponse ) != KErrNotFound )
+                {
+                iHttpStatus = HTTPStatus::EOk;
+                }
+            else
+                {
+                iHttpStatus = KErrHttpDecodeContentType;
+                }
+            }
+        else
+            {
+            iHttpStatus = KErrHttpDecodeContentType;
+            }
+        contentTypeNameStr.Close();
+        }
+    else
+        {
+        iHttpStatus = aHttpStatus;
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::OnResponseBodyDataL
+// From MHttpManagerObserver
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultMetering::OnResponseBodyDataL( const TPtrC8 aDataChunk )
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::OnResponseBodyDataL" );
+    LOG2( "iState: %d", iState );
+    LOG2( "iHttpStatus: %d", iHttpStatus );
+    if ( iHttpStatus == HTTPStatus::EOk && 
+         iState == CWmDrmDlaDefaultMetering::ESendingMeteringChallenge )
+        {
+        if ( !iMeteringResponse )
+            {
+            iMeteringResponse = HBufC8::NewL( aDataChunk.Length() );
+            }
+        else
+            {
+            iMeteringResponse 
+                = iMeteringResponse->ReAllocL( iMeteringResponse->Length() + 
+                                               aDataChunk.Length() );
+            }
+        iMeteringResponse->Des().Append( aDataChunk );
+        }
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::OnTransactionComplete
+// From MHttpManagerObserver
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultMetering::OnTransactionComplete( TInt aSystemError )
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::OnTransactionComplete" );
+    LOG2( "iState: %d", iState );
+    LOG2( "aSystemError: %d", aSystemError );
+    LOG2( "iHttpStatus: %d", iHttpStatus );
+    if ( iHttpStatus == HTTPStatus::EOk && !aSystemError )
+        {
+        CompleteClientRequest( aSystemError );
+        }
+    else if ( iHttpStatus != HTTPStatus::EOk )
+        {
+        CompleteClientRequest( KErrCommsBreak );
+        }
+    else
+        {
+        CompleteClientRequest( aSystemError );
+        }
+    iState = CWmDrmDlaDefaultMetering::ENotActive;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::CompleteClientRequest
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultMetering::CompleteClientRequest( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::CompleteClientRequest" );
+    LOG2( "aError: %d", aError );
+    if ( iClientStatus )
+        {
+        User::RequestComplete( iClientStatus, aError );
+        iClientStatus = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultMetering::ProcessMeteringChallengeL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultMetering::ProcessMeteringChallengeL( 
+    const TDesC8& aMeteringChallenge )
+    {
+    LOGFN( "CWmDrmDlaDefaultMetering::ProcessMeteringChallengeL" );
+    // Make an 8-bit URI of the challenge URL.
+    HBufC8* meteringServerUrl8( 
+            EscapeUtils::ConvertFromUnicodeToUtf8L( *iMeteringServerUrl ) );
+    CleanupStack::PushL( meteringServerUrl8 );
+    TUriParser8 uri;
+    User::LeaveIfError( uri.Parse( *meteringServerUrl8 ) );
+    
+    // POST the DrmHeader status to the server
+    // Set headers
+    RArray< CWmDrmDlaDefaultHttpManager::THeader > headers;
+    CleanupClosePushL( headers );
+
+    headers.AppendL( CWmDrmDlaDefaultHttpManager::THeader( HTTP::EAccept,
+                                                           KAcceptHeader8 ) );
+    headers.AppendL( 
+            CWmDrmDlaDefaultHttpManager::THeader( HTTP::EAcceptLanguage, 
+                                                  KAcceptLanguageHeader8 ) );
+    headers.AppendL( 
+            CWmDrmDlaDefaultHttpManager::THeader( HTTP::EContentType, 
+                                                  KPostContentTypeHeader8 ) );
+    
+    // Set POST contents
+    delete iFormEncoder;
+    iFormEncoder = NULL;
+    iFormEncoder = CHTTPFormEncoder::NewL();
+    iFormEncoder->AddFieldL( KGetMeterChallengeParam8, aMeteringChallenge );
+
+    iHttpManager->Post( *meteringServerUrl8, headers, iFormEncoder );
+
+    CleanupStack::PopAndDestroy( 2, meteringServerUrl8 ); //headers, 
+                                                          //meteringServerUrl8
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaulthttpplugin/src/wmdrmdladefaultplayready.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,193 @@
+/*
+* 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:  WMDRM DLA Default Http PlayReady Implementation
+*
+*/
+
+
+#include <chttpformencoder.h>
+#include <httpstringconstants.h>
+#include <httperr.h>
+#include <http/rhttpheaders.h>
+#include <http/thttphdrfielditer.h>
+#include <stringpool.h>
+#include <escapeutils.h>
+#include <wmdrmdlatypes.h>
+#include <wmdrmdlauinotifier.h>
+#include "wmdrmdladefaultplayready.h"
+#include "wmdrmdladefaulthttpplugin.h"
+#include "wmdrmdladefaulthttpmanager.h"
+
+#define _LOGGING_FILE L"wmdrmdladefaulthttpplugin.txt"
+#include "logfn.h"
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultPlayReady::ConstructL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::CWmDrmDlaDefaultPlayReady
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultPlayReady::CWmDrmDlaDefaultPlayReady(
+    CWmDrmDlaDefaultHttpPlugin* aPlugin ) 
+    : iState( CWmDrmDlaDefaultPlayReady::ENotActive ), iPlugin( aPlugin)
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultPlayReady* CWmDrmDlaDefaultPlayReady::NewL(
+    CWmDrmDlaDefaultHttpPlugin* aPlugin )
+    {
+    CWmDrmDlaDefaultPlayReady* self 
+        = new( ELeave ) CWmDrmDlaDefaultPlayReady( aPlugin );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::~CWmDrmDlaDefaultPlayReady
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultPlayReady::~CWmDrmDlaDefaultPlayReady()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::SupportedInitiatorL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultPlayReady::SupportedInitiatorL( 
+    const TDesC8& /*aInitiator*/, 
+    CWmDrmDlaUiNotifier*& /*aUiNotifier*/ )
+    {
+    return EFalse;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::ProcessInitiatorL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultPlayReady::ProcessInitiatorL( 
+    const TDesC8& /*aInitiator*/ )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::ProcessJoinDomainChallenge
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultPlayReady::ProcessJoinDomainChallenge( 
+    const TDesC8& /*aJoinDomainChallenge*/, 
+    const TDesC& /*aUrl*/, 
+    TRequestStatus& aStatus )
+    {
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    CompleteClientRequest( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::ProcessLeaveDomainChallenge
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultPlayReady::ProcessLeaveDomainChallenge( 
+    const TDesC8& /*aLeaveDomainChallenge*/, 
+    const TDesC& /*aUrl*/, 
+    TRequestStatus& aStatus )
+    {
+    aStatus = KRequestPending;
+    iClientStatus = &aStatus;
+    CompleteClientRequest( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultHttpPlugin::SetIapId
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultPlayReady::SetIapId( TInt /*aIapId*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::OnGetUsernamePasswordL
+// From MHttpManagerObserver
+// This function is called when using HTTPS authentication. Authentication is 
+// not currently used in the Camese project
+// ----------------------------------------------------------------------------
+//
+TBool CWmDrmDlaDefaultPlayReady::OnGetUsernamePasswordL(
+    HBufC8*& /*aUsername*/,
+    HBufC8*& /*aPassword*/)
+    {
+    return EFalse;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::OnResponseHeadersL
+// From MHttpManagerObserver
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultPlayReady::OnResponseHeadersL(
+    const RHTTPResponse& /*aResponse*/,
+    const RHTTPHeaders& /*aHeaders*/,
+    const RStringPool& /*aStringPool*/,
+    TInt /*aHttpStatus*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::OnResponseBodyDataL
+// From MHttpManagerObserver
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultPlayReady::OnResponseBodyDataL( 
+    const TPtrC8 /*aDataChunk*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::OnTransactionComplete
+// From MHttpManagerObserver
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultPlayReady::OnTransactionComplete( TInt /*aSystemError*/ )
+    {
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaDefaultPlayReady::CompleteClientRequest
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultPlayReady::CompleteClientRequest( TInt aError )
+    {
+    if ( iClientStatus )
+        {
+        User::RequestComplete( iClientStatus, aError );
+        iClientStatus = NULL;
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaultuiplugin/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* 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:  Build Information file for project wmdrmdladefaultuiplugin
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+wmdrmdladefaultuiplugin.mmp
+
+//  End of File  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaultuiplugin/group/wmdrmdladefaultuiplugin.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,50 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for WMDMR DLA Default UI Plugin
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  wmdrmdladefaultuiplugin.dll
+TARGETTYPE              PLUGIN
+UID                     0x10009D8D 0x20019575
+
+CAPABILITY              CAP_ECOM_PLUGIN
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  wmdrmdladefaultuipluginproxy.cpp
+SOURCE                  wmdrmdladefaultuiplugin.cpp
+
+USERINCLUDE             ../inc
+USERINCLUDE			    ../../../inc
+USERINCLUDE				../../wmdrmdlautils/inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE  	        /epoc32/include/ecom
+
+START RESOURCE          20019575.rss
+TARGET                  wmdrmdladefaultuiplugin.rsc
+END
+
+LIBRARY                 euser.lib
+LIBRARY         		flogger.lib
+LIBRARY		            ecom.lib
+LIBRARY                 wmdrmdla.lib
+LIBRARY					wmdrmdlautils.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaultuiplugin/inc/wmdrmdladefaultuiplugin.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,99 @@
+/*
+* 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:  WMDRM DLA Default UI Plugin
+*
+*/
+
+
+#ifndef C_WMDRMDLADEFAULTUIPLUGIN_H
+#define C_WMDRMDLADEFAULTUIPLUGIN_H
+
+#include <wmdrmdlauiplugin.h>
+#include "wmdrmdlaui.h"
+ 
+/**
+ * WMDRM DLA Default UI Plugin
+ * Shows wait note, when SetProgress is set to EProcessingDRMHeader or 
+ * to EProcessingMeteringChallenge. Removes wait note, if HandleErrorL is
+ * called or SetProgress is set to EIdle. Won't handle any errors, but
+ * always leaves with KErrNotSupported. Supports user cancellation from
+ * wait note. If CCoeEnv isn't available, then wait note can't be shown,
+ * but object creation still succeeds.
+ *
+ *  @lib wmdrmdladefaultuiplugin.lib
+ *  @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaDefaultUiPlugin ) : public CWmDrmDlaUiPluginIf, 
+                                                public MWmDrmDlaWaitNoteCallback
+    {
+
+public:
+
+    static CWmDrmDlaDefaultUiPlugin* NewL();
+    ~CWmDrmDlaDefaultUiPlugin();
+
+public: //From CWmDrmDlaUiPluginIf
+    
+    /**
+     * Called by the framework to set cancel observer. UI plugin can use 
+     * observer to inform framework about user cancelling DLA process from
+     * UI component.
+     * 
+     * @param aObserver Cancellation observer
+     */
+    void SetCancelObserver( MWmDrmDlaCancelObserver* aObserver );
+    
+    /**
+     * Called to inform UI plugin if the license acquisition is silent
+     *
+     * @param aSilent ETrue if license acquisition should be silent
+     */
+    void SetSilent( TBool aSilent );
+
+    /**
+     * Called to inform UI plugin about the license acquisition progress
+     *
+     * @param aState License acquisition progress state
+     */
+    void SetProgress( TInt aState );
+
+    /**
+     * Informs that error happened during the license acquisition
+     *
+     * @param aError Error code
+     */
+    void HandleErrorL( TInt aError );
+
+public: //From MWmDrmDlaWaitNoteCallback    
+    
+    /**
+     * Called if user cancels the wait note
+     */
+    void UserWaitNoteCancellation();
+    
+private:
+
+    CWmDrmDlaDefaultUiPlugin();
+    void ConstructL();
+    
+private: // data
+
+    CWmDrmDlaUi* iUi;
+    
+    //Not owned
+    MWmDrmDlaCancelObserver* iObserver;
+    
+    };
+
+#endif // C_WMDRMDLADEFAULTUIPLUGIN_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaultuiplugin/src/20019575.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,43 @@
+/*
+* 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:  Declaration of the WMDRM DLA Default UI Plugin resource file 
+*
+*/
+
+
+#include "RegistryInfo.rh"
+
+RESOURCE REGISTRY_INFO theInfo
+{
+        dll_uid = 0x20019575;
+        interfaces =
+        {
+                INTERFACE_INFO
+                {
+                interface_uid = 0x20019545; //WMDRM DLA UI Plugin interface UID
+                implementations = 
+                        {
+                        IMPLEMENTATION_INFO
+                                {
+                                implementation_uid = 0x20019575;
+                                version_no = 1;
+                                display_name = "WMDRM DLA Default UI Plugin";
+                                default_data = "";
+                                opaque_data = "Default UI Plugin";
+                                }
+                        };
+                }
+        };
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaultuiplugin/src/wmdrmdladefaultuiplugin.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,165 @@
+/*
+* 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:  WMDRM DLA Default UI Plugin
+*
+*/
+
+
+#include <wmdrmdlautils.rsg>
+#include <wmdrmdlatypes.h>
+#include <wmdrmdlacancelobserver.h>
+#include "wmdrmdlaui.h"
+#include "wmdrmdladefaultuiplugin.h"
+
+#define _LOGGING_FILE L"wmdrmdladefaultuiplugin.txt"
+#include "logfn.h"
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultUiPlugin::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultUiPlugin::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaDefaultUiPlugin::ConstructL" );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultUiPlugin::CWmDrmDlaDefaultUiPlugin
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultUiPlugin::CWmDrmDlaDefaultUiPlugin()
+    {
+    LOGFN( "CWmDrmDlaDefaultUiPlugin::CWmDrmDlaDefaultUiPlugin" );
+    TRAP_IGNORE( iUi = CWmDrmDlaUi::NewL() );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultUiPlugin::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultUiPlugin* CWmDrmDlaDefaultUiPlugin::NewL()
+    {
+    LOGFN( "CWmDrmDlaDefaultUiPlugin::NewL" );
+    CWmDrmDlaDefaultUiPlugin* self = new( ELeave ) CWmDrmDlaDefaultUiPlugin;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultUiPlugin::~CWmDrmDlaDefaultUiPlugin
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaDefaultUiPlugin::~CWmDrmDlaDefaultUiPlugin()
+    {
+    LOGFN( "CWmDrmDlaDefaultUiPlugin::~CWmDrmDlaDefaultUiPlugin" );
+    delete iUi;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultUiPlugin::SetCancelObserver
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultUiPlugin::SetCancelObserver( 
+    MWmDrmDlaCancelObserver* aObserver )
+    {
+    LOGFN( "CWmDrmDlaDefaultUiPlugin::SetCancelObserver" );
+    iObserver = aObserver;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultUiPlugin::SetSilent
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultUiPlugin::SetSilent( 
+    TBool /*aSilent*/ )
+    {
+    LOGFN( "CWmDrmDlaDefaultUiPlugin::SetSilent" );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultUiPlugin::SetProgress
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultUiPlugin::SetProgress( 
+    TInt aState )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "CWmDrmDlaDefaultUiPlugin::SetProgress", err );
+
+    switch( aState )
+        {
+        case EProcessingDRMHeader:
+            if ( iUi )
+                {
+                TRAP( err, 
+                    iUi->ShowWaitNoteL( R_WMDRMDLA_WAIT_NOTE_ACQUIRING_LICENSE,
+                                        this ) );
+                }
+            break;
+
+        case EProcessingMeteringChallenge:
+            if ( iUi )
+                {
+                TRAP( err, 
+                    iUi->ShowWaitNoteL( R_WMDRMDLA_WAIT_NOTE_METERING, 
+                                        this ) );
+                }
+            break;
+
+        case EIdle:
+            if ( iUi )
+                {
+                iUi->RemoveWaitNote();
+                }
+            break;
+
+        default:
+            break;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultUiPlugin::HandleErrorL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultUiPlugin::HandleErrorL( 
+    TInt /*aError*/ )
+    {
+    LOGFN( "CWmDrmDlaDefaultUiPlugin::HandleErrorL" );
+    if ( iUi )
+        {
+        iUi->RemoveWaitNote();
+        }
+    User::Leave( KErrNotSupported );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaDefaultUiPlugin::UserWaitNoteCancellation
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaDefaultUiPlugin::UserWaitNoteCancellation()
+    {
+    LOGFN( "CWmDrmDlaDefaultUiPlugin::UserWaitNoteCancellation" );
+    if ( iObserver )
+        {
+        iObserver->UserCancellation();
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdladefaultuiplugin/src/wmdrmdladefaultuipluginproxy.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,41 @@
+/*
+* 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:  WMDRM DLA Default UI Plugin Proxy
+*
+*/
+
+
+#include <ecom/implementationproxy.h>
+#include "wmdrmdladefaultuiplugin.h"
+
+const TImplementationProxy ImplementationTable[] =
+	{
+#ifdef __EABI__
+		IMPLEMENTATION_PROXY_ENTRY( 0x20019575, CWmDrmDlaDefaultUiPlugin::NewL )
+#else
+		{ {0x20019575}, CWmDrmDlaDefaultUiPlugin::NewL }
+#endif
+	}; 
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy: Lookup method required by ECom
+// Returns the ImplementationTable to the  ECom framework
+// -----------------------------------------------------------------------------
+//
+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/wmdrm/camese/wmdrmdlautils/BWINS/wmdrmdlautilsu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,11 @@
+EXPORTS
+	?NewLC@CWmDrmDlaUi@@SAPAV1@XZ @ 1 NONAME ; class CWmDrmDlaUi * CWmDrmDlaUi::NewLC(void)
+	?RemoveWaitNote@CWmDrmDlaUi@@QAEXXZ @ 2 NONAME ; void CWmDrmDlaUi::RemoveWaitNote(void)
+	?NewL@CWmDrmDlaUi@@SAPAV1@XZ @ 3 NONAME ; class CWmDrmDlaUi * CWmDrmDlaUi::NewL(void)
+	?ShowListQueryL@CWmDrmDlaUi@@QAEHPAVMDesC16Array@@PAV?$CArrayPtr@VCGulIcon@@@@@Z @ 4 NONAME ; int CWmDrmDlaUi::ShowListQueryL(class MDesC16Array *, class CArrayPtr<class CGulIcon> *)
+	?ShowWaitNoteL@CWmDrmDlaUi@@QAEXHPAVMWmDrmDlaWaitNoteCallback@@@Z @ 5 NONAME ; void CWmDrmDlaUi::ShowWaitNoteL(int, class MWmDrmDlaWaitNoteCallback *)
+	?LaunchBrowserViewL@CWmDrmDlaBrowserViewHandler@@QAEXPAVMWmDrmDlaBrowserObserver@@@Z @ 6 NONAME ; void CWmDrmDlaBrowserViewHandler::LaunchBrowserViewL(class MWmDrmDlaBrowserObserver *)
+	?ShowErrorNoteL@CWmDrmDlaUi@@QAEXH@Z @ 7 NONAME ; void CWmDrmDlaUi::ShowErrorNoteL(int)
+	?NewLC@CWmDrmDlaBrowserViewHandler@@SAPAV1@XZ @ 8 NONAME ; class CWmDrmDlaBrowserViewHandler * CWmDrmDlaBrowserViewHandler::NewLC(void)
+	?NewL@CWmDrmDlaBrowserViewHandler@@SAPAV1@XZ @ 9 NONAME ; class CWmDrmDlaBrowserViewHandler * CWmDrmDlaBrowserViewHandler::NewL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlautils/EABI/wmdrmdlautilsu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,11 @@
+EXPORTS
+	_ZN11CWmDrmDlaUi13ShowWaitNoteLEiP25MWmDrmDlaWaitNoteCallback @ 1 NONAME
+	_ZN11CWmDrmDlaUi14RemoveWaitNoteEv @ 2 NONAME
+	_ZN11CWmDrmDlaUi14ShowErrorNoteLEi @ 3 NONAME
+	_ZN11CWmDrmDlaUi14ShowListQueryLEP12MDesC16ArrayP9CArrayPtrI8CGulIconE @ 4 NONAME
+	_ZN11CWmDrmDlaUi4NewLEv @ 5 NONAME
+	_ZN11CWmDrmDlaUi5NewLCEv @ 6 NONAME
+	_ZN27CWmDrmDlaBrowserViewHandler18LaunchBrowserViewLEP24MWmDrmDlaBrowserObserver @ 7 NONAME
+	_ZN27CWmDrmDlaBrowserViewHandler4NewLEv @ 8 NONAME
+	_ZN27CWmDrmDlaBrowserViewHandler5NewLCEv @ 9 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlautils/data/wmdrmdlautils.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for project wmdrmdlautils
+*
+*/
+
+
+// RESOURCE NAME IDENTIFIER
+NAME WDLA // 4 letter ID
+
+// INCLUDES
+#include <eikon.rh>
+#include <uikon.rh>
+#include <avkon.rsg>
+#include <avkon.rh>
+#include <avkon.mbg>
+#include <eikcore.rsg>
+#include <eikon.rsg>
+#include <appinfo.rh>
+#include <avkon.loc>
+#include <avkonicons.hrh>
+#include <data_caging_paths_strings.hrh>
+#include <drmcommon.loc>
+
+
+// RESOURCE IDENTIFIER
+RESOURCE RSS_SIGNATURE {}
+
+RESOURCE TBUF { buf = ""; }
+
+// RESOURCE DEFINITIONS 
+
+// -----------------------------------------------------------------------------
+// r_wmdrmdla_list_query
+// Select service list query
+// -----------------------------------------------------------------------------
+RESOURCE AVKON_LIST_QUERY r_wmdrmdla_list_query
+    {
+    items =
+        {
+        AVKON_LIST_QUERY_DLG_LINE
+            {
+            control = AVKON_LIST_QUERY_CONTROL
+                {
+                listtype = EAknCtSingleGraphicPopupMenuListBox;
+                listbox = AVKON_LIST_QUERY_LIST
+                    {
+                    };
+                heading = qtn_drm_select_service;
+                };
+            }
+        };
+    }
+
+// -----------------------------------------------------------------------------
+// r_wmdrmdla_note_aquisition_failed
+// License Acquisition Failed Error Note
+// -----------------------------------------------------------------------------
+//
+RESOURCE TBUF r_wmdrmdla_note_aquisition_failed
+    {
+    buf = qtn_drm_info_getting_key_failed;
+    }
+
+// ---------------------------------------------------------------------------
+// r_wmdrmdla_wait_note_acquiring_license
+// Note displayed when the license is being acquired for a song
+// ---------------------------------------------------------------------------
+// 
+RESOURCE TBUF r_wmdrmdla_wait_note_acquiring_license
+    {
+    buf = qtn_drm_wait_getting_key;
+    }
+
+// ---------------------------------------------------------------------------
+// r_wmdrmdla_wait_note_metering
+// Note displayed when the metering is being done
+// ---------------------------------------------------------------------------
+// 
+RESOURCE TBUF r_wmdrmdla_wait_note_metering
+    {
+    buf = qtn_drm_wait_getting_key;
+    }
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlautils/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,20 @@
+/*
+* 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:  Build information file for project wmdrmdlautils
+*
+*/
+
+
+PRJ_MMPFILES
+wmdrmdlautils.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlautils/group/wmdrmdlautils.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,57 @@
+/*
+* 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:  Project definition file for project wmdrmdlautils
+*
+*/
+
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGET                  wmdrmdlautils.dll
+TARGETTYPE              dll
+UID                     0x1000008D 0x2001E5E2
+
+CAPABILITY              CAP_GENERAL_DLL
+VENDORID                VID_DEFAULT
+
+SOURCEPATH              ../src
+SOURCE                  wmdrmdlaui.cpp
+SOURCE					wmdrmdlaappclient.cpp
+SOURCE					wmdrmdlabrowserviewhandler.cpp
+
+USERINCLUDE             ../inc
+USERINCLUDE				../../wmdrmdlaapp/inc
+USERINCLUDE			    ../../../inc
+MW_LAYER_SYSTEMINCLUDE
+
+START RESOURCE          ../data/wmdrmdlautils.rss
+HEADER
+TARGETPATH              RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END // RESOURCE
+
+LIBRARY                 euser.lib
+LIBRARY					efsrv.lib
+LIBRARY         		flogger.lib
+LIBRARY					cone.lib
+LIBRARY					eikcore.lib
+LIBRARY					bafl.lib
+LIBRARY					avkon.lib
+LIBRARY					apparc.lib
+LIBRARY         		aknnotify.lib
+LIBRARY					commonengine.lib
+LIBRARY					platformenv.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlautils/inc/wmdrmdlaappclient.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface class for WMDRM DLA App Client
+*
+*/
+
+
+#ifndef R_WMDRMDLAAPPCLIENT_H
+#define R_WMDRMDLAAPPCLIENT_H
+
+#include <e32base.h>
+#include <aknserverapp.h>
+
+/**
+ *  WMDRM DLA App Client Interface
+ *
+ *  @lib wmdrmdlautils.lib
+ *  @since S60 v9.1
+ */
+NONSHARABLE_CLASS( RWmDrmDlaAppClient ) : public RAknAppServiceBase
+    {
+
+    public:
+
+        virtual ~RWmDrmDlaAppClient();
+        
+        /**
+         * Sets IAP to browser view
+         *
+         * @param aIap IAP ID to be used in browser view
+         * @return Error code
+         */
+        TInt SetIAP( TInt aIap );
+        
+        /**
+         * Makes a POST request to browser view
+         *
+         * @param aPostUrl URL, where POST request is done
+         * @param aPostContentType Content type of the POST operation
+         * @param aPostData POST data
+         * @param aPostContentBoundary Boundary of the POST content
+         * @return Error code
+         */
+        TInt Post( const TDesC& aPostUrl,
+                   const TDesC8& aPostContentType,
+                   const TDesC8& aPostData,
+                   const TDesC8& aPostContentBoundary );
+        
+        /**
+         * Gets the license response from the browser view
+         *
+         * @param aLicenseResponse Pointer, where license response is saved.
+         *                         Must be NULL.
+         * @return Error code
+         */
+        TInt LicenseResponse( HBufC8*& aLicenseResponse );
+        
+    private: // from RApaAppServiceBase
+    
+        TUid ServiceUid() const;
+
+    private: // data
+
+    };
+
+#endif // R_WMDRMDLAAPPCLIENT_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlautils/inc/wmdrmdlabrowserobserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Interface class for WMDRM DLA Browser Observer
+*
+*/
+
+
+#ifndef M_WMDRMDLABROWSEROBSERVER_H
+#define M_WMDRMDLABROWSEROBSERVER_H
+
+#include <e32base.h>
+
+/**
+ * Interface for browser observer
+ */
+class MWmDrmDlaBrowserObserver
+    {
+    public:
+        
+        /**
+         * Called when POST URL is required.
+         * @return POST URL
+         */
+        virtual const TDesC& PostUrlL() = 0;
+        
+        /**
+         * Called when POST content type is required.
+         * @return POST content type
+         */
+        virtual const TDesC8& PostContentTypeL() = 0;
+        
+        /**
+         * Called when POST data is required.
+         * @return POST data
+         */
+        virtual const TDesC8& PostDataL() = 0;
+        
+        /**
+         * Called when POST content data boundary is required.
+         * @return POST content data boundary
+         */
+        virtual const TDesC8& PostContentDataBoundaryL() = 0;
+        
+        /**
+         * Called when IAP ID is required.
+         * @return IAP ID
+         */
+        virtual TInt IapId() = 0;
+        
+        /**
+         * Called when license is received.
+         * @param aLicenseResponse - Received license response
+         */
+        virtual void LicenseResponseReceived( 
+                                        const TDesC8& aLicenseResponse ) = 0;
+        
+        /**
+         * Called when browser view is closed with some error.
+         * @param aError - Error or command that closed the browser view
+         */
+        virtual void BrowserExit( TInt aError ) = 0;
+
+    };
+
+
+#endif // M_WMDRMDLABROWSEROBSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlautils/inc/wmdrmdlabrowserviewhandler.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,100 @@
+/*
+* 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:  Interface class for WMDRM DLA Browser View Handler
+*
+*/
+
+
+#ifndef C_WMDRMDLABROWSERVIEWHANDLER_H
+#define C_WMDRMDLABROWSERVIEWHANDLER_H
+
+#include <e32base.h>
+
+class RWmDrmDlaAppClient;
+class MWmDrmDlaBrowserObserver;
+
+/**
+ *  WMDRM DLA Browser View Handler
+ *
+ *  @lib wmdrmdlautils.lib
+ *  @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaBrowserViewHandler ) : public CActive
+    {
+
+    public:
+
+        IMPORT_C static CWmDrmDlaBrowserViewHandler* NewL();
+        IMPORT_C static CWmDrmDlaBrowserViewHandler* NewLC();
+
+        /**
+         * Launches browser view
+         *
+         * @param aObserver Observer used to query needed information for
+         *                  launching and to inform caller about browser
+         *                  view activities.
+         * @leave with KErrArgument, if aObserver is NULL, KErrInUse,
+         *        if browser view is already active, KErrNotSupported,
+         *        if CCoeEnv isn't available, otherwise
+         *        standard Symbian error code in case of error.
+         */
+        IMPORT_C void LaunchBrowserViewL( 
+                                    MWmDrmDlaBrowserObserver* aObserver );
+        
+        /**
+         * Destructor.
+         */
+        virtual ~CWmDrmDlaBrowserViewHandler();
+
+    protected: // from base class CActive
+
+        /**
+         * From CActive Cancels async request.
+         */
+        void DoCancel();
+
+        /**
+         * From CActive Called when async request completes.
+         */
+        void RunL();
+
+        /**
+         * From CActive Called if RunL leaves.
+         */
+        TInt RunError( TInt aError );    
+    
+    private:
+
+        CWmDrmDlaBrowserViewHandler();
+        void ConstructL();
+
+        void CompleteSelf();
+
+    private: // data
+
+        enum TBrowserViewHandlerState
+            {
+            EIdle,
+            ELaunchBrowserView
+            };
+
+        TBrowserViewHandlerState iState;
+        RWmDrmDlaAppClient* iClient;
+                
+        //Not owned
+        MWmDrmDlaBrowserObserver* iObserver;
+        
+    };
+
+#endif // C_WMDRMDLABROWSERVIEWHANDLER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlautils/inc/wmdrmdlaui.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,148 @@
+/*
+* 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:  Interface class for WMDRM DLA UI
+*
+*/
+
+
+#ifndef C_WMDRMDLAUI_H
+#define C_WMDRMDLAUI_H
+
+#include <e32base.h>
+
+class CCoeEnv;
+class CAknGlobalNote;
+class MDesCArray;
+class CGulIcon;
+
+/**
+ * Interface for wait note callback.
+ */
+class MWmDrmDlaWaitNoteCallback
+    {
+    public:
+        
+        /**
+         * Called if user cancels the wait note
+         */
+        virtual void UserWaitNoteCancellation() = 0;
+
+    };
+
+/**
+ *  WMDRM DLA UI Interface
+ *
+ *  @lib wmdrmdlautils.lib
+ *  @since S60 v9.1
+ */
+NONSHARABLE_CLASS( CWmDrmDlaUi ) : public CActive
+    {
+
+    public:
+
+        /**
+         * This class must have an access to CCoeEnv,
+         * otherwise it will leave with KErrNotSupported
+         */
+        IMPORT_C static CWmDrmDlaUi* NewL();
+        IMPORT_C static CWmDrmDlaUi* NewLC();
+
+        /**
+         * Destructor.
+         */
+        virtual ~CWmDrmDlaUi();
+
+        /**
+         * Shows error note
+         *
+         * @param aTextResourceId Resource id of the text to be shown
+         * @leave with standard Symbian error code in case of error
+         */
+        IMPORT_C void ShowErrorNoteL( TInt aTextResourceId );
+        
+        /**
+         * Shows wait note
+         *
+         * @param aTextResourceId Resource id of the text to be shown
+         * @param aCallback Callback that will be called, 
+         *                  if user cancels the wait note. Can be NULL.
+         * @leave with KErrInUse, if wait note is already shown, otherwise
+         *        standard Symbian error code in case of error.
+         */
+        IMPORT_C void ShowWaitNoteL( TInt aTextResourceId, 
+                                     MWmDrmDlaWaitNoteCallback* aCallback );
+        
+        /**
+         * Removes wait note
+         */
+        IMPORT_C void RemoveWaitNote();
+        
+        /**
+         * Shows list query
+         *
+         * @param aItems Item array to be shown, 
+         *               ownership is transferred to the list query.
+         * @param aIcons Icon array to be shown, 
+         *               ownership is transferred to the list query.
+         * @return Index of the user selection or -1, if user cancelled query.
+         * @leave with KErrArgument, if any parameter is NULL, otherwise
+         *        standard Symbian error code in case of error.
+         */
+        IMPORT_C TInt ShowListQueryL( MDesCArray* aItems, 
+                                      CArrayPtr<CGulIcon>* aIcons );
+        
+    protected: // from base class CActive
+
+        /**
+        * From CActive Cancels async request.
+        */
+        void DoCancel();
+
+        /**
+        * From CActive Called when async request completes.
+        */
+        void RunL();
+        
+        /**
+        * From CActive Called if RunL leaves.
+        */
+        TInt RunError( TInt aError );    
+        
+    private:
+
+        CWmDrmDlaUi();
+        void ConstructL();
+        void CancelWaitNote();
+
+    private: // data
+
+        //Control environment, not owned
+        CCoeEnv* iCoeEnv;
+    
+        // Path of the resource file
+        HBufC* iWmdrmDlaUtilsResourceFile;
+
+        // Resource offsets in CoeEnv
+        TInt iWmdrmDlaUtilsResourceFileOffset;
+        
+        CAknGlobalNote* iGlobalNote;
+        TInt iGlobalNoteId;
+        HBufC* iGlobalNoteText;
+        
+        //Not owned
+        MWmDrmDlaWaitNoteCallback* iCallback;
+   
+    };
+
+#endif // C_WMDRMDLAUI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlautils/src/wmdrmdlaappclient.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,113 @@
+/*
+* 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:  Implementation class for WMDRM DLA App Client
+*
+*/
+
+
+// INCLUDE FILES
+#include "wmdrmdlaappclient.h"
+#include "wmdrmdlaappconstants.h"
+
+#define _LOGGING_FILE L"wmdrmdlautils.txt"
+#include "logfn.h"
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// RWmDrmDlaAppClient::~RWmDrmDlaAppClient
+// ---------------------------------------------------------------------------
+//
+RWmDrmDlaAppClient::~RWmDrmDlaAppClient()
+    {
+    LOGFN( "RWmDrmDlaAppClient::~RWmDrmDlaAppClient" );
+    Close();
+    }
+
+// ---------------------------------------------------------------------------
+// RWmDrmDlaAppClient::SetIAP
+// ---------------------------------------------------------------------------
+//
+TInt RWmDrmDlaAppClient::SetIAP( TInt aIap )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "RWmDrmDlaAppClient::SetIAP", err );
+    
+    TPckg<TInt> iapPckg( aIap );
+    err = SendReceive( ESetIAP, TIpcArgs( &iapPckg ) );
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// RWmDrmDlaAppClient::Post
+// ---------------------------------------------------------------------------
+//
+TInt RWmDrmDlaAppClient::Post(
+    const TDesC& aPostUrl,
+    const TDesC8& aPostContentType,
+    const TDesC8& aPostData,
+    const TDesC8& aPostContentBoundary )
+    {
+    TInt err( KErrNone );
+    
+    LOGFNR( "RWmDrmDlaAppClient::Post", err );
+    
+    err = SendReceive( EPost, TIpcArgs( &aPostUrl, 
+                                        &aPostContentType, 
+                                        &aPostData, 
+                                        &aPostContentBoundary ) );
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// RWmDrmDlaAppClient::LicenseResponse
+// ---------------------------------------------------------------------------
+//
+TInt RWmDrmDlaAppClient::LicenseResponse( HBufC8*& aLicenseResponse )
+    {
+    TInt err( KErrNone );
+    TInt size( 0 );
+    TPckg<TInt> sizePckg( size );
+    
+    LOGFNR( "RWmDrmDlaAppClient::LicenseResponse", err );
+    
+    err = SendReceive( EGetLicenseResponseSize, TIpcArgs( &sizePckg )  );
+    if  ( !err && size > 0 )
+        {
+        TRAP( err, aLicenseResponse = HBufC8::NewL( size ) );
+        if ( !err )
+            {
+            TPtr8 ptr( aLicenseResponse->Des() );
+            err = SendReceive( EGetLicenseResponse, TIpcArgs( &ptr ) );
+            if ( err )
+                {
+                delete aLicenseResponse;
+                aLicenseResponse = NULL;
+                }
+            }
+        }
+    return err;
+    }
+
+// ---------------------------------------------------------------------------
+// RWmDrmDlaAppClient::ServiceUid
+// ---------------------------------------------------------------------------
+//
+TUid RWmDrmDlaAppClient::ServiceUid() const
+    {
+    return KWmDrmDlaAppServiceId;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlautils/src/wmdrmdlabrowserviewhandler.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,184 @@
+/*
+* 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:  Implementation class for WMDRM DLA Browser View Handler
+*
+*/
+
+
+// INCLUDE FILES
+#include <coemain.h>
+#include <apaserverapp.h>
+#include "wmdrmdlabrowserviewhandler.h"
+#include "wmdrmdlabrowserobserver.h"
+#include "wmdrmdlaappclient.h"
+#include "wmdrmdlaappconstants.h"
+
+#define _LOGGING_FILE L"wmdrmdlautils.txt"
+#include "logfn.h"
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserViewHandler::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserViewHandler::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaBrowserViewHandler::ConstructL" );
+    iClient = new (ELeave) RWmDrmDlaAppClient;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserViewHandler::CWmDrmDlaBrowserViewHandler
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserViewHandler::CWmDrmDlaBrowserViewHandler() 
+    : CActive( EPriorityStandard ), iState( EIdle )
+    {
+    LOGFN( "CWmDrmDlaBrowserViewHandler::CWmDrmDlaBrowserViewHandler" );
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserViewHandler::NewL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CWmDrmDlaBrowserViewHandler* CWmDrmDlaBrowserViewHandler::NewL()
+    {
+    LOGFN( "CWmDrmDlaBrowserViewHandler::NewL" );
+    CWmDrmDlaBrowserViewHandler* self = CWmDrmDlaBrowserViewHandler::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserViewHandler::NewLC
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CWmDrmDlaBrowserViewHandler* CWmDrmDlaBrowserViewHandler::NewLC()
+    {
+    LOGFN( "CWmDrmDlaBrowserViewHandler::NewLC" );
+    CWmDrmDlaBrowserViewHandler* self 
+        = new( ELeave ) CWmDrmDlaBrowserViewHandler;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserViewHandler::~CWmDrmDlaBrowserViewHandler
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaBrowserViewHandler::~CWmDrmDlaBrowserViewHandler()
+    {
+    LOGFN( "CWmDrmDlaBrowserViewHandler::~CWmDrmDlaBrowserViewHandler" );
+    Cancel();
+    delete iClient;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserViewHandler::LaunchBrowserViewL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaBrowserViewHandler::LaunchBrowserViewL( 
+    MWmDrmDlaBrowserObserver* aObserver )
+    {
+    LOGFN( "CWmDrmDlaBrowserViewHandler::LaunchBrowserViewL" );
+    if ( !CCoeEnv::Static() )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    if ( !aObserver )
+        {
+        User::Leave( KErrArgument );
+        }
+    if ( iState != EIdle )
+        {
+        User::Leave( KErrInUse );
+        }
+    iObserver = aObserver;
+    iClient->ConnectChainedAppL( KWmDrmDlaAppUid );
+    iState = CWmDrmDlaBrowserViewHandler::ELaunchBrowserView;
+    CompleteSelf();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserViewHandler::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserViewHandler::DoCancel()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserViewHandler::RunL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserViewHandler::RunL()
+    {
+    LOGFN( "CWmDrmDlaBrowserViewHandler::RunL" );
+    HBufC8* licenseResponse( NULL );
+    switch ( iState )
+        {
+        case CWmDrmDlaBrowserViewHandler::ELaunchBrowserView:
+            User::LeaveIfError( iClient->SetIAP( iObserver->IapId() ) );
+            User::LeaveIfError( 
+                    iClient->Post( iObserver->PostUrlL(), 
+                                   iObserver->PostContentTypeL(), 
+                                   iObserver->PostDataL(), 
+                                   iObserver->PostContentDataBoundaryL() ) );
+            User::LeaveIfError( iClient->LicenseResponse( licenseResponse ) );
+            iObserver->LicenseResponseReceived( *licenseResponse );
+            delete licenseResponse;
+            iClient->Close();
+            iState = CWmDrmDlaBrowserViewHandler::EIdle;
+            break;
+        
+        default:
+            ASSERT( EFalse );
+            break;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaBrowserViewHandler::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaBrowserViewHandler::RunError( TInt aError )
+    {
+    LOGFN( "CWmDrmDlaBrowserViewHandler::RunError" );
+    LOG2( "aError: %d", aError );
+    iClient->Close();
+    iObserver->BrowserExit( aError );
+    iState = CWmDrmDlaBrowserViewHandler::EIdle;
+    return KErrNone;
+    }
+
+// ----------------------------------------------------------------------------
+// CWmDrmDlaBrowserViewHandler::CompleteSelf
+// ----------------------------------------------------------------------------
+//
+void CWmDrmDlaBrowserViewHandler::CompleteSelf()
+    {
+    if ( !IsActive() )
+        {
+        TRequestStatus* status = &iStatus;
+        User::RequestComplete( status, KErrNone );
+        SetActive();
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlautils/src/wmdrmdlaui.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,319 @@
+/*
+* 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:  Implementation class for WMDRM DLA UI
+*
+*/
+
+
+// INCLUDE FILES
+#include <f32file.h>
+
+#ifdef RD_MULTIPLE_DRIVE
+#include <driveinfo.h>
+#endif
+
+#include <eikfrlb.h>
+#include <eikfrlbd.h>
+#include <coemain.h>
+#include <bautils.h>
+#include <stringloader.h>
+#include <aknnotewrappers.h>
+#include <aknglobalnote.h>
+#include <aknlistquerydialog.h>
+#include <badesca.h>
+#include <gulicon.h>
+
+#include <data_caging_path_literals.hrh>
+#include <wmdrmdlautils.rsg>
+
+#include "wmdrmdlaui.h"
+
+#define _LOGGING_FILE L"wmdrmdlautils.txt"
+#include "logfn.h"
+
+// CONSTANTS
+#ifndef RD_MULTIPLE_DRIVE
+_LIT( KDriveZ, "z:" );
+#else
+_LIT( KRomDriveFormatter, "%c:" );                                      
+#endif
+
+_LIT( KWmdrmDlaUtilsResFileName, "wmdrmdlautils.rsc" );
+
+// ======== LOCAL FUNCTIONS ========
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUi::ConstructL()
+    {
+    LOGFN( "CWmDrmDlaUi::ConstructL" );
+    iCoeEnv = CCoeEnv::Static();
+    if ( !iCoeEnv )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    
+    //Create resource file path
+    TPtr wmdrmDlaUtilsResourcePtr( NULL, 0 );
+    iWmdrmDlaUtilsResourceFile = HBufC::NewL( KMaxFileName );
+    wmdrmDlaUtilsResourcePtr.Set( iWmdrmDlaUtilsResourceFile->Des() );
+
+    //Append rom drive letter to the path
+#ifndef RD_MULTIPLE_DRIVE
+
+    wmdrmDlaUtilsResourcePtr.Append( KDriveZ );
+
+#else //RD_MULTIPLE_DRIVE
+
+    TInt driveNumber( -1 );
+    TChar driveLetter;
+    //Get rom drive number
+    User::LeaveIfError( 
+            DriveInfo::GetDefaultDrive( DriveInfo::EDefaultRom, 
+                                        driveNumber ) );
+    //Get drive letter from the drive number
+    User::LeaveIfError( 
+            iCoeEnv->FsSession().DriveToChar( driveNumber, 
+                                              driveLetter ) );
+    wmdrmDlaUtilsResourcePtr.AppendFormat( KRomDriveFormatter, 
+                                           (TUint)driveLetter );
+
+#endif
+
+    //Append directory to the path
+    wmdrmDlaUtilsResourcePtr.Append( KDC_RESOURCE_FILES_DIR );
+    //Append name of the resource file to the path
+    wmdrmDlaUtilsResourcePtr.Append( KWmdrmDlaUtilsResFileName );
+
+    TFileName resourceFile;
+    resourceFile = *iWmdrmDlaUtilsResourceFile;
+    //Find the correct language file for the resource
+    BaflUtils::NearestLanguageFile( iCoeEnv->FsSession(), 
+                                    resourceFile );
+    //Add resource file to the CCoeEnv. 
+    //Resource file must be removed from the CCoeEnv when we are done
+    iWmdrmDlaUtilsResourceFileOffset 
+        = iCoeEnv->AddResourceFileL( resourceFile );
+    
+    iGlobalNote = CAknGlobalNote::NewL();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::CWmDrmDlaUi
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaUi::CWmDrmDlaUi() : CActive( EPriorityStandard )
+    {
+    LOGFN( "CWmDrmDlaUi::CWmDrmDlaUi" );
+    CActiveScheduler::Add( this );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::NewL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CWmDrmDlaUi* CWmDrmDlaUi::NewL()
+    {
+    LOGFN( "CWmDrmDlaUi::NewL" );
+    CWmDrmDlaUi* self = CWmDrmDlaUi::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::NewLC
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CWmDrmDlaUi* CWmDrmDlaUi::NewLC()
+    {
+    LOGFN( "CWmDrmDlaUi::NewLC" );
+    CWmDrmDlaUi* self = new( ELeave ) CWmDrmDlaUi;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::~CWmDrmDlaUi
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaUi::~CWmDrmDlaUi()
+    {
+    LOGFN( "CWmDrmDlaUi::~CWmDrmDlaUi" );
+    Cancel();
+    delete iGlobalNote;
+    delete iGlobalNoteText;
+    iCoeEnv->DeleteResourceFile( iWmdrmDlaUtilsResourceFileOffset );
+    delete iWmdrmDlaUtilsResourceFile;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::ShowErrorNoteL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaUi::ShowErrorNoteL( 
+    TInt aTextResourceId )
+    {
+    LOGFN( "CWmDrmDlaUi::ShowErrorNoteL" );
+    HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) );
+    CAknResourceNoteDialog* note = new ( ELeave ) CAknErrorNote( ETrue );
+    note->ExecuteLD( *msgText );
+    CleanupStack::PopAndDestroy( msgText );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::ShowWaitNoteL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaUi::ShowWaitNoteL( 
+    TInt aTextResourceId,
+    MWmDrmDlaWaitNoteCallback* aCallback )
+    {
+    LOGFN( "CWmDrmDlaUi::ShowWaitNoteL" );
+    if ( IsActive() )
+        {
+        User::Leave( KErrInUse );
+        }
+    iGlobalNoteText = StringLoader::LoadL( aTextResourceId, iCoeEnv );
+    iGlobalNoteId = iGlobalNote->ShowNoteL( iStatus, 
+                                            EAknGlobalWaitNote, 
+                                            *iGlobalNoteText );
+    iCallback = aCallback;
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::RemoveWaitNote
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CWmDrmDlaUi::RemoveWaitNote()
+    {
+    LOGFN( "CWmDrmDlaUi::RemoveWaitNote" );
+    Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::ShowListQueryL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C TInt CWmDrmDlaUi::ShowListQueryL( 
+    MDesCArray* aItems,
+    CArrayPtr<CGulIcon>* aIcons )
+    {
+    LOGFN( "CWmDrmDlaUi::ShowListQueryL" );
+    
+    //This method takes the ownership of the input parameters
+    //Push the input parameters to the cleanupstack to make sure we won't leak
+    //memory
+    CleanupStack::PushL( aIcons );
+    CleanupStack::PushL( aItems );
+    
+    //Check that both inputs really exist.
+    if ( !aItems || !aIcons )
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    //Create the query with index parameter
+    //Query will take the ownership of the items and icons
+    TInt index( 0 );
+    CAknListQueryDialog* dlg = new (ELeave) CAknListQueryDialog( &index );
+    dlg->PrepareLC( R_WMDRMDLA_LIST_QUERY );
+    
+    //Arrange cleanupstack in a way that query can take the ownership of the
+    //items and icons
+    CleanupStack::Pop( 2, aItems ); //dlg, aItems
+    //Ownership of the items is transferred to query
+    dlg->SetItemTextArray( aItems );
+    dlg->SetOwnershipType( ELbmOwnsItemArray );
+    CleanupStack::PushL( dlg );
+    //Ownership of the icons in transferred to query
+    dlg->SetIconArrayL( aIcons );
+    CleanupStack::Pop( 2, aIcons ); //dlg, aIcons
+    CleanupStack::PushL( dlg );
+    
+    //Enable marquee scrolling for the text items
+    CEikFormattedCellListBox* listbox( 
+            static_cast<CEikFormattedCellListBox*>( dlg->ListBox() ) /* ,
+            EAknListBoxItemSpecificMenuDisabled */ );
+    listbox->ItemDrawer()->ColumnData()->EnableMarqueeL( ETrue );
+    
+    //Launch the query
+    TInt key( dlg->RunLD() );
+    LOG2( "key: %d", key );
+    //If user cancelled query, then return -1
+    //Else return index of the selected service
+    if ( key != EAknSoftkeyOk )
+        {
+        index = -1;
+        }
+    LOG2( "index: %d", index );
+    return index;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::DoCancel
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUi::DoCancel()
+    {
+    LOGFN( "CWmDrmDlaUi::DoCancel" );
+    CancelWaitNote();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::RunL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUi::RunL()
+    {
+    LOGFN( "CWmDrmDlaUi::RunL" );
+    CancelWaitNote();
+    if ( iCallback )
+        {
+        iCallback->UserWaitNoteCancellation();
+        }
+    }    
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::RunError
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDlaUi::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+
+    
+// ---------------------------------------------------------------------------
+// CWmDrmDlaUi::CancelWaitNote
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaUi::CancelWaitNote()
+    {
+    LOGFN( "CWmDrmDlaUi::CancelWaitNote" );
+    if ( iGlobalNoteId )
+        {
+        TRAP_IGNORE( iGlobalNote->CancelNoteL( iGlobalNoteId ) );
+        iGlobalNoteId = 0;
+        delete iGlobalNoteText;
+        iGlobalNoteText = NULL;
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlawrapper/BWINS/wmdrmdlawrapperu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?NewL@CWmDrmDlaWrapper@@SAPAV1@XZ @ 1 NONAME ; class CWmDrmDlaWrapper * CWmDrmDlaWrapper::NewL(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlawrapper/EABI/wmdrmdlawrapperu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	_ZN16CWmDrmDlaWrapper4NewLEv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlawrapper/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,20 @@
+/*
+* 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:  Build information file for project wmdrmdlawrapper
+*
+*/
+
+
+PRJ_MMPFILES
+wmdrmdlawrapper.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlawrapper/group/wmdrmdlawrapper.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project WMDRM DLA Wrapper
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          wmdrmdlawrapper.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x2001E2C6
+
+CAPABILITY      CAP_GENERAL_DLL
+
+SOURCEPATH      ../src
+SOURCE          wmdrmdlawrapper.cpp
+
+USERINCLUDE     ../../../../inc
+USERINCLUDE     ../../wmdrmdla/inc
+MW_LAYER_SYSTEMINCLUDE
+
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         wmdrmdla.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/camese/wmdrmdlawrapper/src/wmdrmdlawrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,173 @@
+/*
+* 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:  Dynamically loadable wrapper for WMDRM DLA
+*
+*/
+
+
+#include "wmdrmdlahandler.h"
+#include "wmdrmdlawrapper.h"
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::CWmDrmDlaWrapper
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaWrapper::CWmDrmDlaWrapper()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaWrapper::ConstructL()
+    {
+    iDlaHandler = CWmDrmDlaHandler::NewL();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::NewL
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CWmDrmDlaWrapper* CWmDrmDlaWrapper::NewL()
+    {
+    CWmDrmDlaWrapper* self = new( ELeave ) CWmDrmDlaWrapper;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::~CWmDrmDlaWrapper
+// ---------------------------------------------------------------------------
+//
+CWmDrmDlaWrapper::~CWmDrmDlaWrapper()
+    {
+    delete iDlaHandler;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::SilentL
+// ---------------------------------------------------------------------------
+//
+TBool CWmDrmDlaWrapper::SilentL( 
+    const RFile& aFile )
+    {
+    return iDlaHandler->SilentL( aFile );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::AcquireLicenseL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaWrapper::AcquireLicenseL( 
+    const RFile& aFile, 
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData )
+    {
+    iDlaHandler->AcquireLicenseL( aFile, aContentUrl, aHtmlData );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::AcquireLicense
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaWrapper::AcquireLicense( 
+    const RFile& aFile, 
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData, 
+    TRequestStatus& aStatus )
+    {
+    iDlaHandler->AcquireLicense( aFile, aContentUrl, aHtmlData, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::AcquireLicenseFromDrmHeaderL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaWrapper::AcquireLicenseFromDrmHeaderL( 
+    const TDesC8& aDrmHeader, 
+    HBufC* aErrorUrl, 
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData )
+    {
+    iDlaHandler->AcquireLicenseFromDrmHeaderL( aDrmHeader, aErrorUrl, 
+                                               aContentUrl, aHtmlData );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::AcquireLicenseFromDrmHeader
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaWrapper::AcquireLicenseFromDrmHeader( 
+    const TDesC8& aDrmHeader, 
+    HBufC* aErrorUrl,
+    HBufC*& aContentUrl, 
+    HBufC*& aHtmlData, 
+    TRequestStatus& aStatus )
+    {
+    iDlaHandler->AcquireLicenseFromDrmHeader( aDrmHeader, aErrorUrl, 
+                                              aContentUrl, aHtmlData, 
+                                              aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::CancelLicenseAcquisition
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaWrapper::CancelLicenseAcquisition()
+    {
+    iDlaHandler->CancelLicenseAcquisition();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::ProcessMeteringCertificateL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaWrapper::ProcessMeteringCertificateL( 
+    const TDesC8& aCertificate )
+    {
+    iDlaHandler->ProcessMeteringCertificateL( aCertificate );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::ProcessMeteringCertificate
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaWrapper::ProcessMeteringCertificate( 
+    const TDesC8& aCertificate, 
+    TRequestStatus& aStatus )
+    {
+    iDlaHandler->ProcessMeteringCertificate( aCertificate, aStatus );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::CancelMetering
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaWrapper::CancelMetering()
+    {
+    iDlaHandler->CancelMetering();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDlaWrapper::SetIapId
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDlaWrapper::SetIapId( 
+    TInt aIapId )
+    {
+    iDlaHandler->SetIapId( aIapId );
+    }
Binary file wmdrm/cenrep/keys_wmdrm.xls has changed
Binary file wmdrm/conf/wmdrm.confml has changed
Binary file wmdrm/conf/wmdrm_20011118.crml has changed
Binary file wmdrm/conf/wmdrm_2001FE55.crml has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,71 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build file for WM DRM agent and plugins
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+#if (defined __WINDOWS_MEDIA_DRM)
+../rom/wmdrm_stub.sis                                       /epoc32/data/z/system/install/wmdrm_stub.sis
+#endif // __WINDOWS_MEDIA_DRM
+
+// IBY files
+../rom/wmdrm.iby            CORE_MW_LAYER_IBY_EXPORT_PATH( wmdrm.iby )
+../rom/wmdrmresources.iby   LANGUAGE_MW_LAYER_IBY_EXPORT_PATH( wmdrmresources.iby )
+
+// Configuration files
+../conf/wmdrm.confml            MW_LAYER_CONFML(wmdrm.confml)
+../conf/wmdrm_20011118.crml     MW_LAYER_CRML(wmdrm_20011118.crml)
+../conf/wmdrm_2001FE55.crml     MW_LAYER_CRML(wmdrm_2001FE55.crml)
+
+// RFS exclude list
+../wmdrmengine/wmdrmserver/server/data/10282F1B.exc	/epoc32/data/Z/private/102073ea/excludes/10282F1B.exc
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+#if (defined __WINDOWS_MEDIA_DRM)
+../wmdrmengine/asf/group/drmasf.mmp
+../wmdrmengine/wmdrmpkserver/serverresources/group/wmdrmpkserverresources.mmp
+../wmdrmengine/wmdrmserver/client/group/wmdrmclient.mmp
+../wmdrmengine/wmdrmserver/server/group/wmdrmserver.mmp
+../wmdrmengine/wmdrmserver/clientwrapper/group/wmdrmclientwrapper.mmp
+#endif // __WINDOWS_MEDIA_DRM
+
+../wmdrmengine/wmdrmfileserver/client/group/wmdrmfileserverclient.mmp
+../wmdrmengine/wmdrmfileserver/server/group/wmdrmfileserver.mmp
+
+#if (defined __WINDOWS_MEDIA_DRM)
+../camese/wmdrmdlaapp/group/wmdrmdlaapp.mmp
+../camese/wmdrmdlautils/group/wmdrmdlautils.mmp
+../camese/wmdrmdlawrapper/group/wmdrmdlawrapper.mmp
+../camese/wmdrmdladefaulthttpplugin/group/wmdrmdladefaulthttpplugin.mmp
+../camese/wmdrmdladefaultuiplugin/group/wmdrmdladefaultuiplugin.mmp
+../camese/httpfiltercamese/group/httpfiltercamese.mmp
+#endif // __WINDOWS_MEDIA_DRM
+
+PRJ_EXTENSIONS
+#if (defined __WINDOWS_MEDIA_DRM)
+START EXTENSION s60/mifconv
+OPTION TARGETFILE wmdrmdla.mif
+OPTION HEADERFILE wmdrmdla.mbg
+OPTION SOURCES -c8,8 qgn_prop_drm_valid_large /*qgn_prop_drm_server*/ //Todo: Take the correct icon into use when available
+END
+#endif // __WINDOWS_MEDIA_DRM
+
+#include "../wmdrmengine/wmdrmaccess/group/bld.inf"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/inc/WMDRMPrivateCRKeys.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,35 @@
+/*
+* 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:  wmdrm private cenrep keys
+*
+*/
+
+
+#ifndef WMDRMPRIVATECRKEYS_H
+#define WMDRMPRIVATECRKEYS_H
+
+const TUid KCRUidWMDRM = {0x20011118};
+
+const TUint32 KWMDRMLicStoreSizeRatio = 0x00000001;
+const TUint32 KWMDRMLicStoreLowMem = 0x00000002;
+const TUint32 KWMDRMLicStoreReservedSpace = 0x00000003;
+
+// The following constants are meant for the internal mass drive
+// of the configured storing of WMDRM rights feature with the
+// WMDRM database split enabled.
+const TUint32 KWMDRM2LicStoreSizeRatio = 0x00000004;
+const TUint32 KWMDRM2LicStoreLowMem = 0x00000005;
+const TUint32 KWMDRM2LicStoreReservedSpace = 0x00000006;
+
+#endif      // WMDRMPRIVATECRKEYS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/inc/logfn.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,150 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+#ifndef LOG_H
+#define LOG_H
+
+#ifdef _DEBUG
+#define _LOGGING
+#endif
+
+#ifdef _LOGGING
+
+#include <e32std.h>
+#include <f32file.h>
+#include <flogger.h>
+
+#ifndef _LOGGING_DIR
+#define _LOGGING_DIR L"wmdrm"
+#endif
+
+#ifndef _LOGGING_FILE
+#define _LOGGING_FILE L"wmdrm.txt"
+#endif
+
+const static TLitC<sizeof(_LOGGING_DIR) / 2> KLogDir =
+    {
+    sizeof(_LOGGING_DIR) / 2 - 1, _LOGGING_DIR
+    };
+const static TLitC<sizeof(_LOGGING_FILE) / 2> KLogFile =
+    {
+    sizeof(_LOGGING_FILE) / 2 - 1, _LOGGING_FILE
+    };
+
+#define LOG( des ) \
+    RFileLogger::Write( KLogDir, KLogFile, EFileLoggingModeAppend, des )
+    
+#define LOG1( AAA ) \
+    RFileLogger::Write( KLogDir, KLogFile, EFileLoggingModeAppend, _L( AAA ) )
+
+#define LOG2( FMT, BBB ) \
+    RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( FMT ), BBB )
+    
+#define LOG3( FMT, BBB, CCC ) \
+    RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( FMT ), BBB, CCC )
+    
+#define LOG4( FMT, BBB, CCC, DDD ) \
+    RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( FMT ), BBB, CCC, DDD )
+    
+#define LOG5( FMT, BBB, CCC, DDD, EEE ) \
+    RFileLogger::WriteFormat( KLogDir, KLogFile, EFileLoggingModeAppend, _L( FMT ), BBB, CCC, DDD, EEE )
+    
+#define LOGHEX( ptr, len ) \
+    RFileLogger::HexDump( KLogDir, KLogFile, EFileLoggingModeAppend, _S(""), _S(""), ptr, len )
+    
+#define LOGFN( AAA ) TLogFn ___tmp( _L( AAA ) )
+#define LOGFNR( AAA, BBB ) TLogFn ___tmp( _L( AAA ), (TInt* ) &( BBB ) )
+
+#define CLEARLOG() {\
+    RFs fs;\
+    TBuf<sizeof( _LOGGING_DIR ) + sizeof( _LOGGING_DIR ) + 32> path;\
+    path.Copy( _L( "c:\\logs\\" ) ); path.Append( KLogDir ); path.Append( '\\' ); path.Append( KLogFile ); \
+    fs.Connect();\
+    fs.Delete( path );\
+    fs.Close();}
+
+/**
+ *  Class for logging funtion calls and exits
+ *
+ *  The constructor logs the entry of the function, the destructor the exit
+ *
+ *  @since S60 3.2
+ */
+NONSHARABLE_CLASS( TLogFn )
+    {
+public:
+    TLogFn( const TDesC& aName, TInt* aResult = NULL ):
+        iResult( aResult)
+        {
+    	RBuf8 data;
+    	
+    	iName.Set( aName );
+    	if ( data.Create( iName.Size() + 8 ) == KErrNone )
+    	    {
+    	    data.Copy( _L( ">> " ) );
+    	    data.Append( iName );
+    	    LOG( data );
+    	    data.Close();
+    	    }
+    	}
+
+    ~TLogFn()
+        {
+    	RBuf8 data;
+    	
+    	if ( data.Create( iName.Size() + 50 ) == KErrNone )
+    	    {
+        	data.Copy( _L( "<< " ) );
+        	data.Append( iName );
+        	if ( iResult )
+        	    {
+        	    data.Append( ' ' );
+        	    data.AppendNum( *iResult );
+        	    data.Append( _L( " 0x" ) );
+        	    data.AppendNum( *iResult, EHex );
+        	    }
+        	LOG( data );
+        	data.Close();
+        	}
+        }
+    
+private: // data
+
+    /**
+     * Name of the function
+     */
+    TPtrC iName;
+    TInt* iResult;
+    };
+
+#else // _LOGGING
+
+#define LOG( des )
+#define LOG1( AAA )
+#define LOG2( FMT, BBB )
+#define LOG3( FMT, BBB, CCC )
+#define LOG4( FMT, BBB, CCC, DDD )
+#define LOG5( FMT, BBB, CCC, DDD, EEE )
+#define LOGHEX( ptr, len )
+#define LOGFN( AAA )	
+#define LOGFNR( AAA, BBB )	
+#define CLEARLOG()
+
+#endif // _LOGGING
+    
+#endif // LOG_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/inc/wmdrmkeystorage.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,233 @@
+/*
+* Copyright (c) 2006-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:  Declaration of the WMDRM key storage
+*
+*/
+
+
+#ifndef WMDRMKEYSTORAGE_H
+#define WMDRMKEYSTORAGE_H
+
+#include <e32std.h>
+#include <e32base.h>
+
+const TInt KDeviceSpecificKeyLength = 16;
+
+/**
+ *  Hardware key storage access via the Security Driver
+ *
+ *  @since S60 3.2
+ */
+NONSHARABLE_CLASS( CWmDrmKeyStorage ): public CBase
+    {
+public:
+
+    /**
+    * NewL
+    * creates an instance of the CWmDrmKeyStorageClass
+    *
+    * @param    aKeyIndex   Index of the key to be used
+    *           Optional parameter, not currently used   
+    * @return   CWmDrmKeyStorage -object
+    * @leave    Symbian OS or internal error code
+    */
+    IMPORT_C static CWmDrmKeyStorage* NewL( TInt aKeyIndex = 0 );
+    
+    /**
+    * GetCertificateL
+    * request the device certificate in 8bit buffer 
+    * caller responsible for releasing the buffer
+    *
+    * @return   Device WMDRM certificate in an 8bit buffer
+    * @leave    Symbian OS or internal error code
+    */
+    virtual HBufC8* GetCertificateL() = 0;
+    
+    /**
+    * GetUniqueIdL
+    *
+    * request a 20byte unique Id such as SHA1 hash of some device 
+    * specific value, single Unique Id per device
+    *
+    * caller is responsible for releasing the buffer 
+    *
+    * @return   Unique Id in an 8bit buffer
+    * @leave    Symbian OS or internal error code
+    */    
+    virtual HBufC8* GetUniqueIdL() = 0;
+    
+    /**
+    * GetUniqueIdRawL
+    *
+    * request a 20byte unique Id such as SHA1 hash of some device 
+    * specific value, single Unique Id per device base 64 encoded
+    * and in a 16bit buffer
+    *
+    * caller is responsible for releasing the buffer 
+    *
+    * @return   Base 64 encoded Unique Id in a 16bit buffer
+    * @leave    Symbian OS or internal error code
+    */     
+    virtual HBufC* GetUniqueIdRawL() = 0;
+    
+    /**
+    * GetUniqueIdL
+    *
+    * request a 20byte unique Id such as SHA1 hash of some device 
+    * specific value, single Unique Id per device result is base 64 encoded
+    *
+    * caller is responsible for releasing the buffer 
+    *
+    * @return   Unique Id in an 8bit buffer base 64 encoded
+    * @leave    Symbian OS or internal error code
+    */  
+    virtual HBufC8* GetUniqueIdB64L() = 0;
+
+    /**
+    * GetPublicKeyL
+    *
+    * request the WMDRM public key of the device in an 8bit descriptor
+    *
+    * caller is responsible for releasing the buffer 
+    *
+    * @return   WMDRM public key in an 8bit buffer
+    * @leave    Symbian OS or internal error code
+    */    
+    virtual HBufC8* GetPublicKeyL() = 0;
+    
+    /**
+    * GetPublicKeyB64L
+    *
+    * request the WMDRM public key of the device in an 8bit descriptor
+    * base 64 encoded
+    *
+    * caller is responsible for releasing the buffer 
+    *
+    * @return   WMDRM public key in an 8bit buffer base 64 encoded
+    * @leave    Symbian OS or internal error code
+    */     
+    virtual HBufC8* GetPublicKeyB64L() = 0;
+
+    /**
+    * SignEcDsaL
+    *
+    * Signs the data using the device WMDRM private key
+    *
+    * caller is responsible for releasing the buffer 
+    *
+    * @param    aData       Data buffer from which the hash is calculated
+    * @return   EcDsa signature in an 8bit descriptor
+    * @leave    Symbian OS or internal error code
+    */     
+    virtual HBufC8* SignEcDsaL( const TDesC8& aData ) = 0;
+    
+    /**
+    * VerifyEcDsaL
+    *
+    * Verifies using the WMDRM public key that the signature is valid
+    *
+    * @param    aData       Data buffer from which the hash is calculated
+    * @param    aSignature  The signature to be checked against
+    * @return   ETrue if the signature check succeeded, 
+                EFalse if the signature check failed
+    * @leave    Symbian OS or internal error code
+    */     
+    virtual TBool VerifyEcDsaL( const TDesC8& aData, const TDesC8& aSignature ) = 0;
+    
+    
+    /**
+    * VerifyEcDsaL
+    *
+    * Verifies using the given key that the signature is valid
+    *
+    * @param    aKey        The key in 8bit buffer to be used for signature
+    *                       calculation
+    * @param    aData       Data buffer from which the hash is calculated
+    * @param    aSignature  The signature to be checked against    
+    * @return   ETrue if the signature check succeeded , 
+                EFalse if the signature check failed
+    * @leave    Symbian OS or internal error code
+    */     
+    virtual TBool VerifyEcDsaL( const TDesC8& aKey, const TDesC8& aData, const TDesC8& aSignature ) = 0;
+    
+    
+    /**
+    * DecryptEcIesL
+    *
+    * Decrypts the EcIes encrypted data using the device private key
+    *
+    * caller is responsible for releasing the buffer 
+    *
+    * @param    aData       Data buffer containing the encrypted data
+    * @return   Decrypted data in 8bit descriptor
+    * @leave    Symbian OS or internal error code
+    */     
+    virtual HBufC8* DecryptEcIesL( const TDesC8& aData ) = 0;
+
+    /**
+    * EncryptEcIesL
+    *
+    * Encrypts the data using the device WMDRM private key
+    *
+    * caller is responsible for releasing the buffer 
+    *
+    * @param    aData       Data buffer to be encrypted
+    * @return   Encrypted data in 8bit descriptor
+    * @leave    Symbian OS or internal error code
+    */
+    virtual HBufC8* EncryptEcIesL( const TDesC8& aData ) = 0;
+    
+    /**
+    * EncryptEcIesL
+    *
+    * Encrypts the data using the given key
+    *
+    * caller is responsible for releasing the buffer 
+    *
+    * @param    aKey        Key to be used for EcIes encryption in an 8bit buffer
+    * @param    aData       Data buffer to be encrypted
+    * @return   Encrypted data in 8bit descriptor
+    * @leave    Symbian OS or internal error code
+    */    
+    virtual HBufC8* EncryptEcIesL( const TDesC8& aKey, const TDesC8& aData ) = 0;
+
+
+    /**
+    * GetDeviceSpecificKeyL
+    *
+    * request a device specific 16 byte key in an 8bit descriptor
+    *
+    * caller is responsible for releasing the buffer 
+    *
+    * @param    aKey    Device specific 16 byte key in an 8bit buffer
+    * @leave    Symbian OS or internal error code
+    */  
+    virtual void GetDeviceSpecificKeyL(
+        TBuf8<KDeviceSpecificKeyLength>& aKey) = 0;
+
+    /**
+    * GetSymmetricKeyL
+    *
+    * request the WMDRM symmetric key from the WMDRM certificate in 
+    * an 8bit descriptor
+    *
+    * caller is responsible for releasing the buffer 
+    *
+    * @return   WMDRM symmetric key in an 8bit buffer
+    * @leave    Symbian OS or internal error code
+    */  
+    virtual HBufC8* GetSymmetricKeyL() = 0;
+    };
+
+#endif // WMDRMKEYSTORAGE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/rom/WMDRM.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  IBY file
+*
+*/
+
+
+#ifndef __WMDRM_IBY__
+#define __WMDRM_IBY__
+
+#include <bldvariant.hrh>
+
+file=ABI_DIR\BUILD_DIR\wmdrmfileserverclient.dll          SHARED_LIB_DIR\wmdrmfileserverclient.dll
+file=ABI_DIR\BUILD_DIR\wmdrmfileserver.exe      PROGRAMS_DIR\wmdrmfileserver.exe
+
+#ifdef __WINDOWS_MEDIA_DRM
+
+file=ABI_DIR\BUILD_DIR\drmasf.dll               SHARED_LIB_DIR\drmasf.dll
+file=ABI_DIR\BUILD_DIR\wmdrmclient.dll          SHARED_LIB_DIR\wmdrmclient.dll
+file=ABI_DIR\BUILD_DIR\wmdrmserver.exe          PROGRAMS_DIR\wmdrmserver.exe
+file=ABI_DIR\BUILD_DIR\wmdrmclientwrapper.dll   SHARED_LIB_DIR\wmdrmclientwrapper.dll
+
+data=ZSYSTEM\install\wmdrm_stub.sis             \system\install\wmdrm_stub.sis
+data=DATAZ_\private\102073ea\excludes\10282F1B.exc	\private\102073ea\excludes\10282F1B.exc
+
+S60_APP_EXE(wmdrmdlaapp)
+data=DATAZ_\private\10003a3f\apps\wmdrmdlaapp_reg.rsc	\private\10003a3f\import\apps\wmdrmdlaapp_reg.rsc
+file=ABI_DIR\BUILD_DIR\wmdrmdlautils.dll        SHARED_LIB_DIR\wmdrmdlautils.dll
+SCALABLE_IMAGE(APP_BITMAP_DIR,APP_BITMAP_DIR,wmdrmdla)
+file=ABI_DIR\BUILD_DIR\wmdrmdlawrapper.dll      SHARED_LIB_DIR\wmdrmdlawrapper.dll
+ECOM_PLUGIN( wmdrmdladefaulthttpplugin.dll, 20019574.rsc )
+ECOM_PLUGIN( wmdrmdladefaultuiplugin.dll, 20019575.rsc )
+ECOM_PLUGIN( httpfiltercamese.dll, 10282936.rsc )
+
+#endif // __WINDOWS_MEDIA_DRM
+
+#endif // __WMDRM_IBY__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/rom/WMDRMResources.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,28 @@
+/*
+* 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:  IBY file
+*
+*/
+
+
+#ifndef __WMDRM_RESOURCES_IBY__
+#define __WMDRM_RESOURCES_IBY__
+
+#ifdef __WINDOWS_MEDIA_DRM
+data=DATAZ_\RESOURCE_FILES_DIR\wmdrmpkserver.rsc                RESOURCE_FILES_DIR\wmdrmpkserver.rsc
+S60_APP_RESOURCE(wmdrmdlaapp)
+data=DATAZ_\RESOURCE_FILES_DIR\wmdrmdlautils.rsc        RESOURCE_FILES_DIR\wmdrmdlautils.rsc
+#endif
+
+#endif
\ No newline at end of file
Binary file wmdrm/rom/wmdrm_stub.sis has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/asf/BWINS/drmasfU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,6 @@
+EXPORTS
+	??1CAsf@@UAE@XZ @ 1 NONAME ; CAsf::~CAsf(void)
+	?IsProtected@CAsf@@SAHABVTDesC8@@@Z @ 2 NONAME ; int CAsf::IsProtected(class TDesC8 const &)
+	?NewL@CAsf@@SAPAV1@ABVRFile@@@Z @ 3 NONAME ; class CAsf * CAsf::NewL(class RFile const &)
+	?NewL@CAsf@@SAPAV1@ABVTDesC16@@@Z @ 4 NONAME ; class CAsf * CAsf::NewL(class TDesC16 const &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/asf/EABI/drmasfU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,10 @@
+EXPORTS
+	_ZN4CAsf11IsProtectedERK6TDesC8 @ 1 NONAME
+	_ZN4CAsf4NewLERK5RFile @ 2 NONAME
+	_ZN4CAsf4NewLERK7TDesC16 @ 3 NONAME
+	_ZN4CAsfD0Ev @ 4 NONAME
+	_ZN4CAsfD1Ev @ 5 NONAME
+	_ZN4CAsfD2Ev @ 6 NONAME
+	_ZTI4CAsf @ 7 NONAME ; #<TI>#
+	_ZTV4CAsf @ 8 NONAME ; #<VT>#
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/asf/group/drmasf.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,39 @@
+/*
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Asf file handling component build configuration
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET          drmasf.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x10205CB7
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+
+USERINCLUDE     ../inc
+USERINCLUDE    	../../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH      ../src
+SOURCE          asf.cpp
+
+LIBRARY         euser.lib XmlFramework.lib hash.lib
+LIBRARY         estor.lib efsrv.lib apmime.lib InetProtUtil.lib bnf.lib
+LIBRARY         cryptography.lib random.lib bafl.lib charconv.lib
+LIBRARY         flogger.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/asf/inc/asf.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,227 @@
+/*
+* 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:
+*
+*/
+
+
+
+#ifndef ASF_H
+#define ASF_H
+
+//  INCLUDES
+#include <f32file.h>
+
+// LOCAL CONSTANTS AND MACROS
+    
+// CLASS DECLARATION
+class CAsfPartInfo;
+/**
+*  Encapsulates an WMDRM file
+*
+*  @lib DrmAsf.lib
+*  @since Series 60 3.1
+*/
+class CAsf: public CBase
+    {
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        IMPORT_C static CAsf* NewL(
+            const RFile& aFile );
+            
+        IMPORT_C static CAsf* NewL(
+            const TDesC& aFileName );
+
+        /**
+        * Destructor.
+        */
+        IMPORT_C virtual ~CAsf();
+        
+    public: // Functions from base classes
+    
+        
+    public: // New functions
+                
+        /**
+		* Validates whether ASF content is DRM protected or not.
+		*/
+        IMPORT_C static TBool IsProtected(
+        	const TDesC8& aAsfHeader);
+
+    protected: 
+
+        /**
+        * C++ default constructor.
+        */
+        CAsf();
+
+        /**
+        * Symbian 2nd phase constructor.
+        */
+        void ConstructL(
+            const RFile& aFile );
+            
+		void ConstructL(
+    		const TDesC& aFileName );
+    
+    private: // New functions
+    
+  		/**
+  		* ValidateL();
+		* Validates whether content is ASF format or not.
+		*/
+		void ValidateL();
+		
+		void InitializeL();
+		
+        /**
+        * FormatGUID(TDes8 &aGUID);
+        * Formats Global UID
+        * @return void
+		*/
+        void FormatGUID( TDes8 &aGUID );
+ 
+    	/**
+        * Parses all entries in Content Description Object
+        * @return void
+		*/
+		void ParseContentDescriptionObjectL();
+
+    	/**
+        * Parses all entries in Content Encryption Object
+        * @return void
+		*/
+		void ParseContentEncryptionObjectL();
+
+		/**
+        * Parses all entries in Extended Content Description Object
+        * @return void
+		*/
+		void ParseExtendedContentDescriptionObjectL();
+
+		/**
+        * read Extended Content Description Object
+        * @return void
+		*/
+		HBufC16* ReadExtendedContentObjectL( TInt aOffset );
+
+    public:    // Data
+        
+        // File to be used for reading
+        RFs iFs;
+        RFile iFile;
+        
+        // Size of the ASF itself
+        TInt iLength;
+        
+        // metadata from Content Description Object
+        // All metadata is UTF-16 format.
+        HBufC* iTitle;
+        HBufC* iAuthor;
+        HBufC* iCopyright;
+        HBufC* iDescription;
+        HBufC* iRating;
+        
+        // metadata from Extended Content Description Object
+        HBufC* iAlbumTitle;
+        HBufC* iPicture;
+        HBufC* iText;
+        HBufC* iComposer;
+        HBufC* iGenre;
+        HBufC* iOriginalArtist;
+        HBufC* iTrackNumber;
+        HBufC* iUniqueFileID;
+        HBufC* iAudioFileUrl;
+        HBufC* iSharedUserRating;
+        HBufC* iDate;
+        HBufC* iYear;
+
+        // DRM protected content
+        TBool iIsDrmProtected;
+        
+        // ASF validated content
+        TBool iIsValidated;
+        
+        // Header data
+		HBufC8* iHeaderData;
+		
+		// Data from ContentEncryption Object
+		HBufC8* iSecretData;
+		HBufC8* iProtectionType;
+		HBufC8* iKeyId;
+		HBufC8* iLicenseUrl;
+
+		// Data from ExtendedContentEncryption Object
+		HBufC8* iExtendedContentEncryptionObject;
+		
+		// Data from DigitalSignature Object
+		HBufC8* iDigitalSignatureObject;
+		HBufC8* iSignedData;
+
+		// Character Set Id used during Unicode conversion
+		
+		// mainly for future use: Nbr of all Objects found from Hdr
+		TInt iNbrOfObjects;
+		TInt iContentDescriptionOffset;
+		TInt iFilePropertiesOffset;
+		TInt iExtendedContentDescriptionOffset;
+		TInt iContentEncryptionOffset;
+		TInt iExtendedContentEncryptionOffset;
+		TInt iDigitalSignatureOffset;
+
+		TInt iExtendedContentDescriptionCount;
+        TInt iHeaderSize;
+		TInt iTitleLength;
+		TInt iAuthorLength;
+		TInt iCopyrightLength;
+		TInt iDescriptionLength;
+		TInt iRatingLength;
+		
+		// Details from Content Encryption Object
+		TInt iSecretDataLength;
+		TInt iProtectionTypeLength;
+		TInt iKeyIDLength;
+		TInt iLicenceUrlLength;
+
+		TBool iContentDescriptionObjectExists;
+		TBool iFilePropertiesObjectExists;
+		TBool iExtendedContentDescriptionObjectExists;
+		TBool iExtendedContentEncryptionObjectExists;
+		TBool iContentEncryptionObjectExists;
+		TBool iDigitalSignatureObjectExists;
+		
+		TPtrC iMimeType;
+
+        // End offset of file properties object
+        // Used to decide start point of signed data
+        TInt iFilePropertiesEndOffset;
+		
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+#endif      // ASF_H   
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/asf/src/asf.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,772 @@
+/*
+* Copyright (c) 2006 - 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:  implementation of asf file handler class
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <f32file.h>
+#include <utf.h>
+#include <caf/caf.h>
+#include "asf.h"
+
+#define _LOGGING_FILE L"asf.txt"
+
+#include "logfn.h"
+
+// LOCAL CONSTANTS AND MACROS
+
+#define M4CC(a) ((a[0] << 24) + (a[1] << 16) + (a[2] << 8) + a[3])
+
+_LIT8 (KASFHeaderObject, "75B22630668E11CFA6D900AA0062CE6C");
+_LIT8 (KASFFilePropertiesObject, "8CABDCA1A94711CF8EE400C00C205365");
+_LIT8 (KASFContentDescriptionObject, "75B22633668E11CFA6D900AA0062CE6C");
+_LIT8 (KASFExtendedContentDescriptionObject, "D2D0A440E30711D297F000A0C95EA850");
+_LIT8 (KASFContentEncryptionObject, "2211B3FBBD2311D2B4B700A0C955FC6E");
+_LIT8 (KASFExtendedContentEncryptionObject, "298AE61426224C17B935DAE07EE9289C");
+_LIT8 (KASFDigitalSignatureObject, "2211B3FCBD2311D2B4B700A0C955FC6E");
+
+_LIT(KWMAlbumTitle,           "WM/AlbumTitle\0");
+_LIT(KWMPicture,              "WM/Picture\0");
+_LIT(KWMText,                 "WM/Text\0");
+_LIT(KWMComposer,             "WM/Composer\0");
+_LIT(KWMGenre,                "WM/Genre\0");
+_LIT(KWMYear,                 "WM/Year\0");
+_LIT(KWMYear1,                "WM/OriginalReleaseYear\0");
+_LIT(KWMOriginalArtist,       "WM/OriginalArtist\0");
+_LIT(KWMTrackNumber,          "WM/TrackNumber\0");
+_LIT(KWMUniqueFileIdentifier, "WM/UniqueFileIdentifier\0");
+_LIT(KWMAudioFileURL,         "WM/AudioFileURL\0");
+_LIT(KWMSharedUserRating,     "WM/SharedUserRating\0");
+_LIT(KWMDate,                 "WM/OriginalReleaseTime\0");
+
+_LIT8(KWrmHeader, "W\0R\0M\0H\0E\0A\0D\0E\0R\0");
+
+_LIT(KAsfMimeType, "application/vnd.drm.asf");
+_LIT(KWmaMimeType, "audio/x-ms-wma");
+_LIT(KWmvMimeType, "video/x-ms-wmv");
+
+_LIT(KAsfExtension, ".asf");
+_LIT(KWmaExtension, ".wma");
+_LIT(KWmvExtension, ".wmv");
+
+#define SET_PTR16(ptr, descriptor, offset, length) \
+    ptr.Set( reinterpret_cast<const TUint16*>( (descriptor).Ptr() + (offset) ), length );
+
+/*
+* 16 B Obj GUID
+* 8  B Obj Size
+* xx B Obj Data
+*/
+const TInt KObjectID( 16 );
+const TInt KObjectSize( 8 );
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+LOCAL_C TUint32 ReadUint64FromBlockL( const TDesC8& aBlock, TInt aOffset );
+LOCAL_C TUint32 ReadUint32FromBlockL( const TDesC8& aBlock, TInt aOffset );
+LOCAL_C TUint16 ReadUint16FromBlockL( const TDesC8& aBlock, TInt aOffset );
+
+LOCAL_C HBufC16* HBuf16FromBlockL(
+    const TDesC8& aBlock,
+    TInt aOffset,
+    TInt aLength );
+
+LOCAL_C TUint32 ReadUint64FromBlockL( const TDesC8& aBlock, TInt aOffset )
+    {
+    if ( aBlock.Length() <= ( aOffset + 3 ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    return ( aBlock[aOffset + 3] << 24 ) +
+           ( aBlock[aOffset + 2] << 16 ) +
+           ( aBlock[aOffset + 1] << 8 ) +
+             aBlock[aOffset];
+    }
+
+LOCAL_C TUint32 ReadUint32FromBlockL( const TDesC8& aBlock, TInt aOffset )
+    {
+    if ( aBlock.Length() <= ( aOffset + 3 ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    return ( aBlock[aOffset + 3] << 24 ) +
+           ( aBlock[aOffset + 2] << 16 ) +
+           ( aBlock[aOffset + 1] << 8 ) +
+             aBlock[aOffset];
+    }
+
+LOCAL_C TUint16 ReadUint16FromBlockL( const TDesC8& aBlock, TInt aOffset )
+    {
+    if ( aBlock.Length() <= ( aOffset + 1 ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    return ( aBlock[aOffset + 1] << 8 ) + 
+             aBlock[aOffset];
+    }
+
+LOCAL_C HBufC16* HBuf16FromBlockL(
+    const TDesC8& aBlock,
+    TInt aOffset,
+    TInt aLength )
+    {
+    if ( aBlock.Length() < ( aOffset + aLength ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    HBufC16* buffer( HBufC16::NewL( aLength / 2 + 1 ) );
+    TPtr ptr( buffer->Des() );
+    
+    for ( TInt i( 0 ) ; i < aLength; i+=2 )
+        {
+        ptr.Append( aBlock[aOffset + i] );
+	    }
+	
+	return buffer;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CAsf::CAsf
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CAsf::CAsf():
+    iTitle( NULL ),
+    iAuthor( NULL ),
+    iCopyright( NULL ),
+    iDescription( NULL ),
+    iRating( NULL ),
+    iAlbumTitle( NULL ),
+    iPicture( NULL ),
+    iText( NULL ),
+    iComposer( NULL ),
+    iGenre( NULL ),
+    iOriginalArtist( NULL ),
+    iTrackNumber( NULL ),
+    iUniqueFileID( NULL ),
+    iAudioFileUrl( NULL ),
+    iSharedUserRating( NULL ),
+    iDate( NULL ),
+    iYear( NULL ),
+    iIsDrmProtected( EFalse ),
+    iIsValidated( EFalse ),
+    iHeaderData( NULL ),
+    iSecretData( NULL ),
+    iProtectionType( NULL ),
+    iKeyId( NULL ),
+    iLicenseUrl( NULL ),
+    iExtendedContentEncryptionObject( NULL ),
+    iContentDescriptionObjectExists( EFalse ),
+    iFilePropertiesObjectExists( EFalse ),
+    iExtendedContentDescriptionObjectExists( EFalse ),
+    iExtendedContentEncryptionObjectExists( EFalse ),
+    iContentEncryptionObjectExists( EFalse ),
+    iMimeType( KAsfMimeType )
+    {
+    LOGFN( "CAsf::CAsf" );
+    }
+
+// -----------------------------------------------------------------------------
+// CAsf::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CAsf::ConstructL( const TDesC& aFileName )
+    {
+    TInt r = KErrNone;
+
+    LOGFN( "CAsf::ConstructL" );
+    LOG( aFileName );
+    User::LeaveIfError( iFs.Connect() );
+    r = iFile.Open( iFs, aFileName, EFileStream | EFileRead | EFileShareReadersOrWriters );
+    if( r == KErrInUse )
+        {
+        r = iFile.Open( iFs, aFileName, EFileStream | EFileRead | EFileShareAny);
+        if ( r == KErrInUse )
+            {
+            r = iFile.Open( iFs, aFileName, EFileStream | EFileRead |
+                EFileShareReadersOnly);
+            }
+        }
+    User::LeaveIfError( r );
+    InitializeL();
+    }
+
+// -----------------------------------------------------------------------------
+// CAsf::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CAsf::ConstructL( const RFile& aFile )
+    {
+    LOGFN( "CAsf::ConstructL (2)" );
+    iFile.Duplicate( aFile );
+    iFile.Size( iLength );
+    InitializeL();
+    }
+
+// -----------------------------------------------------------------------------
+// CAsf::InitializeL
+//
+// -----------------------------------------------------------------------------
+//
+void CAsf::InitializeL()
+    {
+    TFileName name;
+
+    LOGFN( "CAsf::InitializeL" );
+    iFile.FullName( name );
+    if ( name.Right( 4 ).CompareF( KWmaExtension ) == 0 )
+        {
+        iMimeType.Set( KWmaMimeType );
+        }
+    else if ( name.Right( 4 ).CompareF( KWmvExtension ) == 0 ||
+        name.Right( 4 ).CompareF( KAsfExtension ) == 0 )
+        {
+        iMimeType.Set( KWmvMimeType );
+        }
+
+    ValidateL();
+    }
+
+// -----------------------------------------------------------------------------
+// CAsf::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CAsf* CAsf::NewL( const RFile& aFile )
+    {
+    LOGFN( "CAsf::NewL" );
+    CAsf* self = new (ELeave) CAsf;
+    CleanupStack::PushL( self );
+    self->ConstructL( aFile );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CAsf::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CAsf* CAsf::NewL( const TDesC& aFileName )
+    {
+    LOGFN( "CAsf::NewL (2)" );
+    CAsf* self = new (ELeave) CAsf;
+    CleanupStack::PushL( self );
+    self->ConstructL( aFileName );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CAsf::~CAsf
+// Destructor
+// -----------------------------------------------------------------------------
+//
+
+EXPORT_C CAsf::~CAsf()
+    {
+    LOGFN( "CAsf::~CAsf" );
+    if ( iFile.SubSessionHandle() != KNullHandle )
+        {
+        iFile.Close();
+        }
+    if ( iFs.Handle() != KNullHandle )
+        {
+        iFs.Close();
+        }
+
+    delete iHeaderData;
+    delete iSecretData;
+    delete iProtectionType;
+    delete iKeyId;
+    delete iLicenseUrl;
+    delete iExtendedContentEncryptionObject;
+    delete iDigitalSignatureObject;
+    delete iSignedData;
+
+    // Content description Object
+    delete iTitle;
+    delete iAuthor;
+    delete iCopyright;
+    delete iDescription;
+    delete iRating;
+
+    // Extended Content description Object
+    delete iAlbumTitle;
+    delete iPicture;
+    delete iText;
+    delete iComposer;
+    delete iGenre;
+    delete iYear;
+    delete iOriginalArtist;
+    delete iTrackNumber;
+    delete iUniqueFileID;
+    delete iAudioFileUrl;
+    delete iSharedUserRating;
+    delete iDate;
+    }
+
+// -----------------------------------------------------------------------------
+// CAsf::
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C TBool CAsf::IsProtected( const TDesC8& aAsfHeader )
+    {
+    LOGFN( "CAsf::IsProtected" );
+    if ( aAsfHeader.Find( KWrmHeader ) == KErrNotFound )
+        {
+        return EFalse;
+        }
+    else
+        {
+        return ETrue;
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAsf::ValidateL
+//
+// -----------------------------------------------------------------------------
+//
+void CAsf::ValidateL()
+    {
+    // ASF_Header_Object GUID 128 bits.
+    TBuf8<32> header;
+
+    LOGFN( "CAsf::ValidateL" );
+    iFile.Read( 0, header, KObjectID );
+    if ( header.Length() < KObjectID )
+        {
+        User::Leave( KErrOverflow );
+        }
+    FormatGUID( header );
+    if ( header !=  KASFHeaderObject )
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    // read header object size.
+    iFile.Read( header, KObjectSize );
+    iHeaderSize = ReadUint64FromBlockL( header, 0 );
+    if ( iHeaderSize <= 30 || iHeaderSize > KMaxTInt / 2 - 1 )
+        {
+        User::Leave( KErrOverflow );
+        }
+
+    // read header object
+    // 2~31 = 2 GB, size of header would not be greater than this,
+    // also, HBufC does not have a NewL with TInt64 as arguement.
+    iHeaderData = HBufC8::NewL( iHeaderSize );
+    TPtr8 headerPtr = iHeaderData->Des();
+    iFile.Read( headerPtr, iHeaderSize - ( KObjectID + KObjectSize ) );
+
+    iNbrOfObjects = ReadUint32FromBlockL( *iHeaderData, 0 );
+    if ( iNbrOfObjects <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    TInt objOffset( 6 );
+    if ( iHeaderData->Length() < ( objOffset + KObjectID ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    //Read next object GUID
+    TBuf8<32> objGUID = iHeaderData->Mid( objOffset, KObjectID );
+    FormatGUID( objGUID );
+    TBool loop( ETrue );
+
+    //Loop until all needed headers are handled or top level header is finished
+    while ( loop )
+        {
+        //Read current object size
+        TUint32 objSize( ReadUint64FromBlockL( *iHeaderData, objOffset + KObjectID ) );
+        if ( objSize < 24 )
+            {
+            User::Leave( KErrArgument );
+            }
+        
+        if ( !iContentDescriptionObjectExists && objGUID == 
+             KASFContentDescriptionObject )
+            {
+            iContentDescriptionObjectExists = ETrue;
+            iContentDescriptionOffset = objOffset;
+            ParseContentDescriptionObjectL();
+            }
+        else if ( !iFilePropertiesObjectExists && objGUID == 
+             KASFFilePropertiesObject )
+            {
+            iFilePropertiesObjectExists = ETrue; // must exist
+            iFilePropertiesOffset = objOffset;
+            iFilePropertiesEndOffset = iFilePropertiesOffset + objSize;
+            }
+        else if ( !iExtendedContentDescriptionObjectExists && objGUID ==
+             KASFExtendedContentDescriptionObject )
+            {
+            iExtendedContentDescriptionObjectExists = ETrue;
+            iExtendedContentDescriptionOffset = objOffset;
+            ParseExtendedContentDescriptionObjectL();
+            }
+        else if ( !iExtendedContentEncryptionObjectExists && objGUID ==
+             KASFExtendedContentEncryptionObject )
+            {
+            iExtendedContentEncryptionObjectExists = ETrue;
+            iExtendedContentEncryptionOffset = objOffset;
+            iIsDrmProtected = ETrue;
+            TInt eCEODataOffset( objOffset + KObjectID + KObjectSize + 4 );
+            TInt eCEODataLength( objSize - ( KObjectID + KObjectSize + 4 ) );
+            if ( iHeaderData->Length() < eCEODataOffset + eCEODataLength ||
+                 eCEODataLength < 0)
+                {
+                User::Leave( KErrArgument );
+                }
+            iExtendedContentEncryptionObject = iHeaderData->Mid( eCEODataOffset,
+                                                                 eCEODataLength ).AllocL();
+            }
+        else if ( !iContentEncryptionObjectExists && objGUID ==
+             KASFContentEncryptionObject )
+            {
+            iContentEncryptionObjectExists = ETrue;
+            iContentEncryptionOffset = objOffset;
+            iIsDrmProtected = ETrue;
+            ParseContentEncryptionObjectL();
+            }
+        else if ( !iDigitalSignatureObjectExists && objGUID ==
+             KASFDigitalSignatureObject )
+            {
+            iDigitalSignatureObjectExists = ETrue;
+            iDigitalSignatureOffset = objOffset;
+            
+            TInt dSODataOffset( objOffset + KObjectID + KObjectSize + 8 );
+            TInt dSODataLength( objSize - ( KObjectID + KObjectSize + 8 ) );
+            if ( iHeaderData->Length() < dSODataOffset + dSODataLength ||
+                 dSODataLength < 0 )
+                {
+                User::Leave( KErrArgument );
+                }
+            iDigitalSignatureObject = iHeaderData->Mid( dSODataOffset,
+                                                        dSODataLength ).AllocL();
+            
+            if ( iHeaderData->Length() < iFilePropertiesEndOffset + ( iDigitalSignatureOffset - iFilePropertiesEndOffset ) ||
+                 iDigitalSignatureOffset - iFilePropertiesEndOffset < 0 ||
+                 iFilePropertiesEndOffset < 0 )
+                {
+                iDigitalSignatureObjectExists = EFalse;
+                iDigitalSignatureOffset = 0;
+                delete iDigitalSignatureObject;
+                iDigitalSignatureObject = NULL;
+                }
+            else
+                {
+                iSignedData = 
+                    iHeaderData->Mid( iFilePropertiesEndOffset,
+                                      iDigitalSignatureOffset - iFilePropertiesEndOffset ).AllocL();
+                }
+            }
+        
+        //Move object offset to the end of the current header object  
+        objOffset += objSize;
+        //End loop, if top level header is finished or all needed headers are handled
+        if ( objOffset >= iHeaderSize - 30 ||
+            ( iContentDescriptionObjectExists &&
+              iFilePropertiesObjectExists &&
+              iExtendedContentDescriptionObjectExists &&
+              iExtendedContentEncryptionObjectExists &&
+              iDigitalSignatureObjectExists ) )
+            {
+            loop = EFalse;
+            }
+        //Loop isn't finished, read next object GUID
+        else
+            {
+            if ( iHeaderData->Length() < ( objOffset + KObjectID ) || objOffset < 0 )
+                {
+                User::Leave( KErrArgument );
+                }
+            objGUID = iHeaderData->Mid( objOffset, KObjectID );
+            FormatGUID( objGUID );
+            }
+        }
+    if ( iFilePropertiesObjectExists )
+        {
+        iIsValidated = ETrue;
+        }
+    }
+
+
+// -----------------------------------------------------------------------------
+// CAsf::FormatGUID
+// -----------------------------------------------------------------------------
+//
+void CAsf::FormatGUID( TDes8 &aGUID )
+    {
+    LOGFN( "CAsf::FormatGUID" );
+
+    TBuf8<16> copyGUID( aGUID );
+    TInt i;
+    for( i = 0; i < 4; i++ )
+        {
+        copyGUID[i] = aGUID[3-i];
+        }
+    for( i = 4; i < 6; i++ )
+        {
+        copyGUID[i] = aGUID[9 - i];
+        }
+    for ( i = 6; i < 8; i++ )
+        {
+        copyGUID[i] = aGUID[13 - i];
+        }
+    for( i = 8; i < 16 ; i++ )
+        {
+        copyGUID[i] = aGUID[i];
+        }
+    aGUID.Delete( 0, 32 );
+    for( i = 0; i < 16; i++ )
+        {
+        aGUID.AppendNumFixedWidthUC( copyGUID[i], EHex, 2 );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CAsf::ParseContentDescriptionObject
+// -----------------------------------------------------------------------------
+//
+void CAsf::ParseContentDescriptionObjectL()
+    {
+    LOGFN( "CAsf::ParseContentDescriptionObjectL" );
+    TInt offset( iContentDescriptionOffset + KObjectID );
+    TUint32 objSize( ReadUint64FromBlockL( *iHeaderData, offset ) );
+
+    if ( iHeaderData->Length() < iContentDescriptionOffset + objSize )
+        {
+        User::Leave( KErrOverflow );
+        }
+
+    offset += KObjectSize;
+    iTitleLength = ReadUint16FromBlockL( *iHeaderData, offset );
+    offset += 2;
+    iAuthorLength = ReadUint16FromBlockL( *iHeaderData, offset );
+    offset += 2;
+    iCopyrightLength = ReadUint16FromBlockL( *iHeaderData, offset );
+    offset += 2;
+    iDescriptionLength = ReadUint16FromBlockL( *iHeaderData, offset );
+    offset += 2;
+    iRatingLength = ReadUint16FromBlockL( *iHeaderData, offset );
+    offset += 2;
+
+    TInt length( iTitleLength + iAuthorLength + iCopyrightLength + iDescriptionLength + iRatingLength );
+    if ( length > objSize - ( KObjectID + KObjectSize + 10 ) )
+        {
+        User::Leave( KErrOverflow );
+        }
+
+    iTitle = HBuf16FromBlockL( *iHeaderData, offset, iTitleLength );
+    offset += iTitleLength;
+    iAuthor = HBuf16FromBlockL( *iHeaderData, offset, iAuthorLength );
+    offset += iAuthorLength;
+    iCopyright = HBuf16FromBlockL( *iHeaderData, offset, iCopyrightLength );
+    offset += iCopyrightLength;
+    iDescription = HBuf16FromBlockL( *iHeaderData, offset, iDescriptionLength );
+    offset += iDescriptionLength;
+    iRating = HBuf16FromBlockL( *iHeaderData, offset, iRatingLength );
+    offset += iRatingLength;
+    }
+
+// -----------------------------------------------------------------------------
+// CAsf::ParseContentEncryptionObject
+// -----------------------------------------------------------------------------
+//
+void CAsf::ParseContentEncryptionObjectL()
+    {
+    LOGFN( "CAsf::ParseContentEncryptionObject" );
+    TInt offset( iContentEncryptionOffset + KObjectID );
+    TUint32 objSize( ReadUint64FromBlockL( *iHeaderData, offset ) );
+
+    if ( iHeaderData->Length() < iContentEncryptionOffset + objSize ) 
+        {
+        User::Leave( KErrOverflow );
+        }
+
+    offset += KObjectSize;
+    TInt len( ReadUint32FromBlockL( *iHeaderData, offset ) );
+    offset += 4;
+    if ( iHeaderData->Length() < ( offset + len ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    iSecretData = iHeaderData->Mid( offset, len ).AllocL();
+    offset += len;
+
+    len = ReadUint32FromBlockL( *iHeaderData, offset );
+    offset += 4;
+    if ( iHeaderData->Length() < ( offset + len ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    iProtectionType = iHeaderData->Mid( offset, len ).AllocL();
+    offset += len;
+
+    len = ReadUint32FromBlockL( *iHeaderData, offset );
+    offset += 4;
+    if ( iHeaderData->Length() < ( offset + len ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    iKeyId = iHeaderData->Mid( offset, len ).AllocL();
+    offset += len;
+
+    len = ReadUint32FromBlockL( *iHeaderData, offset );
+    offset += 4;
+    if ( iHeaderData->Length() < ( offset + len ) )
+        {
+        User::Leave( KErrArgument );
+        }
+    iLicenseUrl = iHeaderData->Mid( offset, len ).AllocL();
+    }
+
+// -----------------------------------------------------------------------------
+// CAsf::ParseExtendedContentDescriptionObjectL
+// -----------------------------------------------------------------------------
+//
+void CAsf::ParseExtendedContentDescriptionObjectL()
+    {
+    TInt i;
+    
+    LOGFN( "CAsf::ParseExtendedContentDescriptionObjectL" );
+    TInt offset( iExtendedContentDescriptionOffset + KObjectID );
+    TUint32 objSize( ReadUint64FromBlockL( *iHeaderData, offset ) );
+
+    if ( iHeaderData->Length() < iExtendedContentDescriptionOffset + objSize )
+        {
+        User::Leave( KErrOverflow );
+        }
+
+    offset += KObjectSize;
+    iExtendedContentDescriptionCount = ReadUint16FromBlockL( *iHeaderData, offset );
+    offset += 2;
+
+    for ( i = 0 ; i < iExtendedContentDescriptionCount; i++ )
+        {
+        TInt nameLength( ReadUint16FromBlockL( *iHeaderData, offset ) );
+        offset += 2;
+        HBufC16* name16( HBuf16FromBlockL( *iHeaderData, offset, nameLength ) );
+        offset += nameLength;
+        CleanupStack::PushL( name16 );
+        if( !name16->CompareF( KWMAlbumTitle ) )
+            {
+            iAlbumTitle = ReadExtendedContentObjectL( offset );
+            }
+        else if( !name16->CompareF( KWMPicture ) )
+            {
+            iPicture = ReadExtendedContentObjectL( offset );
+            }
+        else if( !name16->CompareF( KWMText) )
+            {
+            iText = ReadExtendedContentObjectL( offset );
+            }
+        else if( !name16->CompareF( KWMComposer ) )
+            {
+            iComposer = ReadExtendedContentObjectL( offset );
+            }
+        else if( !name16->CompareF( KWMGenre ) )
+            {
+            iGenre = ReadExtendedContentObjectL( offset );
+            }
+        else if( !name16->CompareF( KWMYear ) || !name16->CompareF( KWMYear1 ) )
+            {
+            if ( !iYear )
+                {
+                iYear = ReadExtendedContentObjectL( offset );
+                }
+            }
+        else if( !name16->CompareF( KWMOriginalArtist) )
+            {
+            iOriginalArtist = ReadExtendedContentObjectL( offset );
+            }
+        else if( !name16->CompareF( KWMTrackNumber ) )
+            {
+            iTrackNumber = ReadExtendedContentObjectL( offset );
+            }
+        else if( !name16->CompareF( KWMUniqueFileIdentifier ) )
+            {
+            iUniqueFileID = ReadExtendedContentObjectL( offset );
+            }
+        else if( !name16->CompareF( KWMAudioFileURL ) )
+            {
+            iAudioFileUrl = ReadExtendedContentObjectL( offset );
+            }
+        else if( !name16->CompareF( KWMSharedUserRating ) )
+            {
+            iSharedUserRating = ReadExtendedContentObjectL( offset );
+            }
+        else if( !name16->CompareF( KWMDate ) )
+            {
+            iDate = ReadExtendedContentObjectL( offset );
+            }
+        CleanupStack::PopAndDestroy( name16 );
+
+        offset += 2; // data type
+        TInt valueLength( ReadUint16FromBlockL( *iHeaderData, offset ) );
+        offset += 2;
+        offset += valueLength;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CAsf::ReadExtendedContentObjectL
+// -----------------------------------------------------------------------------
+//
+HBufC16* CAsf::ReadExtendedContentObjectL( TInt aOffset )
+    {
+    HBufC16* buffer( NULL );
+
+    LOGFN( "CAsf::ReadExtendedContentObjectL" );
+    TInt dataTypeInt( ReadUint16FromBlockL( *iHeaderData, aOffset ) );
+    if ( dataTypeInt == 0x00 )
+        {
+        TInt length( ReadUint16FromBlockL( *iHeaderData, aOffset + 2 ) );
+        if ( length > 0 )
+            {
+            buffer = HBuf16FromBlockL( *iHeaderData, aOffset + 4, length - 2 );
+            }
+        }
+    else if ( dataTypeInt == 0x02 || dataTypeInt == 0x03 )
+        {
+        TUint32 dword( ReadUint32FromBlockL( *iHeaderData, aOffset + 4 ) );
+        buffer = HBufC::NewL( 16 );
+        TPtr dataString( buffer ->Des() );
+        dataString.Num( dword );
+        }
+    else if ( dataTypeInt == 0x05 )
+        {
+        TUint16 word( ReadUint16FromBlockL( *iHeaderData, aOffset + 4 ) );
+        buffer = HBufC::NewL( 8 );
+        TPtr dataString( buffer->Des() );
+        dataString.Num( word ) ;
+        }
+    return buffer;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmaccess/bwins/wmdrmaccessu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,8 @@
+EXPORTS
+	?Close@CWmDrmAccess@@QAEHXZ @ 1 NONAME ; int CWmDrmAccess::Close(void)
+	?Initialize@CWmDrmAccess@@QAEHABVTDesC8@@@Z @ 2 NONAME ; int CWmDrmAccess::Initialize(class TDesC8 const &)
+	?NewL@CWmDrmAccess@@SAPAV1@XZ @ 3 NONAME ; class CWmDrmAccess * CWmDrmAccess::NewL(void)
+	?Decrypt@CWmDrmAccess@@QAEHAAVTDes8@@@Z @ 4 NONAME ; int CWmDrmAccess::Decrypt(class TDes8 &)
+	?NewLC@CWmDrmAccess@@SAPAV1@XZ @ 5 NONAME ; class CWmDrmAccess * CWmDrmAccess::NewLC(void)
+	??1CWmDrmAccess@@UAE@XZ @ 6 NONAME ; CWmDrmAccess::~CWmDrmAccess(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmaccess/eabi/wmdrmaccessu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,10 @@
+EXPORTS
+	_ZN12CWmDrmAccess10InitializeERK6TDesC8 @ 1 NONAME
+	_ZN12CWmDrmAccess4NewLEv @ 2 NONAME
+	_ZN12CWmDrmAccess5CloseEv @ 3 NONAME
+	_ZN12CWmDrmAccess5NewLCEv @ 4 NONAME
+	_ZN12CWmDrmAccess7DecryptER5TDes8 @ 5 NONAME
+	_ZN12CWmDrmAccessD0Ev @ 6 NONAME
+	_ZN12CWmDrmAccessD1Ev @ 7 NONAME
+	_ZN12CWmDrmAccessD2Ev @ 8 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmaccess/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,29 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*  bld.inf
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_EXPORTS
+../rom/wmdrmaccess.iby      CORE_MW_LAYER_IBY_EXPORT_PATH( wmdrmaccess.iby )
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+wmdrmaccess.mmp
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmaccess/group/wmdrmaccess.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*  wmdrmaccess.mmp
+*
+*/
+
+#include <platform_paths.hrh>
+
+TARGET          wmdrmaccess.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x20026FDE
+
+CAPABILITY      ALL -TCB
+
+DEFFILE         wmdrmaccess.def
+
+SOURCEPATH      ../src
+SOURCE          wmdrmaccess.cpp
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   /epoc32/include/ecom
+
+USERINCLUDE     ../inc
+
+LIBRARY         euser.lib
+LIBRARY         ecom.lib
+LANG            SC
+
+SMPSAFE
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmaccess/rom/wmdrmaccess.iby	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*  wmdrmaccess.iby
+*
+*/
+
+#ifndef _WMDRMACCESS_IBY_
+#define _WMDRMACCESS_IBY_
+#include <data_caging_paths_for_iby.hrh>
+
+#if (defined __WINDOWS_MEDIA_DRM)
+file=ABI_DIR\BUILD_DIR\wmdrmaccess.dll          PROGRAMS_DIR\wmdrmaccess.dll
+#endif // __WINDOWS_MEDIA_DRM
+
+#endif // _WMDRMACCESS_IBY_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmaccess/src/wmdrmaccess.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,118 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*  wmdrmaccess.cpp
+*
+*/
+
+#include <e32base.h>
+#include <ecom.h>
+
+#include <wmdrmaccess.h>
+#include <wmdrmaccessecominterface.h>
+
+// ---------------------------------------------------------------------------
+// CWmDrmAccess::NewL
+// ---------------------------------------------------------------------------
+EXPORT_C CWmDrmAccess* CWmDrmAccess::NewL()
+    {
+    CWmDrmAccess* self(CWmDrmAccess::NewLC());
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmAccess::NewLC
+// ---------------------------------------------------------------------------
+EXPORT_C CWmDrmAccess* CWmDrmAccess::NewLC()
+    {
+    CWmDrmAccess* self(new (ELeave) CWmDrmAccess);
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmAccess::ConstructL
+// ---------------------------------------------------------------------------
+void CWmDrmAccess::ConstructL()
+    {
+    iWmDrmAccessEcomInterface = CWmDrmAccessEcomInterface::NewL();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmAccess::CWmDrmAccess
+// ---------------------------------------------------------------------------
+CWmDrmAccess::CWmDrmAccess()
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmAccess::~CWmDrmAccess
+// ---------------------------------------------------------------------------
+EXPORT_C CWmDrmAccess::~CWmDrmAccess()
+    {
+    if (iWmDrmAccessEcomInterface)
+        {
+        delete iWmDrmAccessEcomInterface;
+        }
+    REComSession::FinalClose();
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmAccess::Initialize
+// ---------------------------------------------------------------------------
+EXPORT_C TInt CWmDrmAccess::Initialize(const TDesC8& aHeader)
+    {
+    TInt retCode(KErrNotReady);
+    if (iWmDrmAccessEcomInterface)
+        {
+        retCode = iWmDrmAccessEcomInterface->Initialize(aHeader);
+        }
+    return retCode;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmAccess::Decrypt
+// ---------------------------------------------------------------------------
+EXPORT_C TInt CWmDrmAccess::Decrypt(TDes8& aBuffer)
+    {
+    TInt retCode = KErrNotReady;
+    if (iWmDrmAccessEcomInterface)
+        {
+        retCode = iWmDrmAccessEcomInterface->Decrypt(aBuffer);
+        }
+    return retCode;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmAccess::Close
+// ---------------------------------------------------------------------------
+EXPORT_C TInt CWmDrmAccess::Close()
+    {
+    TInt retCode(KErrNotReady);
+    if (iWmDrmAccessEcomInterface)
+        {
+        retCode = iWmDrmAccessEcomInterface->Close();
+        }
+    return retCode;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,25 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project WM DRM agent
+*
+*/
+
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_MMPFILES
+wmdrmagent.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/group/wmdrmagent.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  WMDRM agent build configuration
+*
+*/
+
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET      wmdrmagent.dll
+
+
+TARGETTYPE  PLUGIN
+UID         0x10009D8D 0x10205CB6
+CAPABILITY  CAP_ECOM_PLUGIN DRM
+VENDORID    VID_DEFAULT
+
+// Generic MW include paths
+MW_LAYER_SYSTEMINCLUDE
+
+SYSTEMINCLUDE   /epoc32/include/libc
+SYSTEMINCLUDE   /epoc32/include/caf
+SYSTEMINCLUDE   /epoc32/include/Ecom
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+USERINCLUDE     ../../asf/inc
+USERINCLUDE     ../../../../inc
+
+SOURCEPATH      ../src
+SOURCE          wmdrmagentfactory.cpp
+SOURCE          wmdrmagentdata.cpp
+SOURCE          wmdrmagentmanager.cpp
+SOURCE          wmdrmagentcontent.cpp
+SOURCE          wmdrmagentattributes.cpp
+SOURCE          wmdrmagent.cpp
+SOURCE          wmdrmagentimportfile.cpp
+SOURCE          wmdrmagentrightsmanager.cpp
+
+
+start resource 10205CB6.rss
+target      wmdrmagent.rsc
+end
+
+LIBRARY     drmasf.lib
+LIBRARY     euser.lib
+LIBRARY     efsrv.lib
+LIBRARY     apgrfx.lib
+LIBRARY     apmime.lib
+LIBRARY     caf.lib
+LIBRARY     cafutils.lib
+LIBRARY     flogger.lib
+LIBRARY     wmdrmclient.lib
+LIBRARY     sysutil.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentattributes.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  
+*
+*/
+
+
+#ifndef WMDRMAGENTATTRIBUTES_H
+#define WMDRMAGENTATTRIBUTES_H
+
+#include <caf/caftypes.h>
+#include <caf/virtualpathptr.h>
+#include <caf/attributeset.h>
+#include <caf/stringattributeset.h>
+
+class CAsf;
+
+using namespace ContentAccess;
+
+/**
+*  Helper class providing functionality for getting WMDRM specific attributes
+*  using an ASF file and a WMDRM Porting Kit instance
+*
+*  @since S60 3.2
+*/
+NONSHARABLE_CLASS( TWmDrmAgentAttributes )
+    {
+public:
+
+    static TInt GetAttributeL(
+        CAsf* aAsfFile,
+        TInt aAttribute,
+        TInt& aValue,
+        const TVirtualPathPtr& aVirtualPath,
+        TBool aReusePreviousQuery = EFalse );
+
+    static TInt GetAttributeSetL(
+        CAsf* aAsfFile,
+        RAttributeSet& aAttributeSet,
+        const TVirtualPathPtr& aVirtualPath );
+
+    static TInt GetStringAttributeL(
+        CAsf* aAsfFile,
+        TInt aAttribute,
+        TDes& aValue,
+        const TVirtualPathPtr& aVirtualPath,
+        TBool aReusePreviousQuery = EFalse );
+
+    static TInt GetStringAttributeSetL(
+        CAsf* aAsfFile,
+        RStringAttributeSet& aStringAttributeSet,
+        const TVirtualPathPtr& aVirtualPath );
+    };
+
+#endif // WMDRMAGENTATTRIBUTES_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentcontent.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,91 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of the WMDRM CAF Content Agent
+*
+*/
+
+
+#ifndef WMDRMAGENTCONTENT_H
+#define WMDRMAGENTCONTENT_H
+
+//  INCLUDES
+#include <f32file.h>
+#include <caf.h>
+#include <agentinterface.h>
+#include "asf.h"
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+namespace ContentAccess
+    {
+
+/**
+*  WMDRM CAF Content Agent implementation
+*
+*  @lib wmdrmagent.lib
+*  @since Series 60 3.1
+*/
+    class CWmDrmAgentContent : public CAgentContent
+        {
+    public:
+        // Two phase constructor used when the file is opened
+        // using a file name
+        static CWmDrmAgentContent* NewL(const TDesC& aURI, TContentShareMode aShareMode);
+        static CWmDrmAgentContent* NewLC(const TDesC& aUri,TContentShareMode aShareMode);
+
+        // Two phase constructor used when the file is opened with
+        // a file handle
+        static CWmDrmAgentContent* NewL(RFile& aFile);
+        static CWmDrmAgentContent* NewLC(RFile& aFile);
+
+
+        virtual ~CWmDrmAgentContent();
+
+    public:
+        // From CAgentContent
+        virtual TInt OpenContainer(const TDesC& aUniqueId);
+        virtual TInt CloseContainer();
+        virtual void GetEmbeddedObjectsL(RStreamablePtrArray<CEmbeddedObject>& aArray);
+        virtual void GetEmbeddedObjectsL(RStreamablePtrArray<CEmbeddedObject>& aArray, TEmbeddedType aType);
+        virtual TInt Search(RStreamablePtrArray<CEmbeddedObject>& aArray, const TDesC8& aMimeType, TBool aRecursive);
+        virtual TInt GetAttribute(TInt aAttribute, TInt& aValue, const TDesC& aUniqueId);
+        virtual TInt GetAttributeSet(RAttributeSet& aAttributeSet, const TDesC& aUniqueId);
+        virtual TInt GetStringAttribute(TInt aAttribute, TDes& aValue, const TDesC& aUniqueId);
+        virtual TInt GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, const TDesC& aUniqueId);
+        virtual TInt AgentSpecificCommand(TInt aCommand, const TDesC8& aInputBuffer, TDes8& aOutputBuffer);
+        virtual void AgentSpecificCommand(TInt aCommand, const TDesC8& aInputBuffer, TDes8& aOutputBuffer, TRequestStatus& aStatus);
+        virtual void NotifyStatusChange(TEventMask aMask, TRequestStatus& aStatus, const TDesC& aUniqueId);
+        virtual TInt CancelNotifyStatusChange(TRequestStatus& aStatus, const TDesC& aUniqueId);
+        virtual void RequestRights(TRequestStatus& aStatus, const TDesC& aUniqueId);
+        virtual TInt CancelRequestRights(TRequestStatus& aStatus, const TDesC& aUniqueId);
+        virtual void DisplayInfoL(TDisplayInfo aInfo, const TDesC& aUniqueId);
+        virtual TInt SetProperty(TAgentProperty aProperty, TInt aValue);
+
+    private:
+        CWmDrmAgentContent();
+        void ConstructL(const TDesC& aURI, TContentShareMode aShareMode);
+        void ConstructL(RFile& aFile);
+
+    protected:  // Data
+        //TContentShareMode iShareMode;
+        RFs iFs;
+        RFile iFile;
+        HBufC* iURI;
+        CAsf* iAsf;
+        };
+} // namespace ContentAccess
+#endif      // WMDRMAGENTCONTENT_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentdata.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,105 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+
+#ifndef WMDRMAGENTDATA_H
+#define WMDRMAGENTDATA_H
+
+//  INCLUDES
+#include <f32file.h>
+#include <caf.h>
+#include <agentinterface.h>
+#include <caf/attributeset.h>
+#include <caf/stringattributeset.h>
+
+// FORWARD DECLARATIONS
+
+class CAsf;
+
+// CLASS DECLARATION
+namespace ContentAccess
+    {
+    class TVirtualPathPtr;
+
+    /**
+     * WmDrm agent implementation of the CAgentData class used to read
+     *
+     *  @lib ECOM plugin
+     *  @since S60 3.2
+     */
+    class CWmDrmAgentData : public CAgentData
+        {
+    public:  // Constructors and destructor
+        /**
+        * Two-phased constructor.
+        */
+        static CWmDrmAgentData* NewL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode);
+        static CWmDrmAgentData* NewLC(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode);
+        static CWmDrmAgentData* NewL(RFile& aFile, const TDesC& aUniqueId);
+        static CWmDrmAgentData* NewLC(RFile& aFile, const TDesC& aUniqueId);
+
+        /**
+        * Destructor.
+        */
+        ~CWmDrmAgentData();
+
+    public: // From CAgentData
+        TInt Read(TDes8& aDes);
+        TInt Read(TDes8& aDes,TInt aLength);
+        void Read(TDes8& aDes, TRequestStatus& aStatus);
+        void Read(TDes8& aDes, TInt aLength, TRequestStatus& aStatus);
+        void DataSizeL(TInt& aSize);
+        TInt Seek(TSeek aMode,TInt& aPos);
+        TInt SetProperty(TAgentProperty aProperty, TInt aValue);
+        TInt EvaluateIntent(TIntent aIntent);
+        TInt ExecuteIntent(TIntent aIntent);
+        TInt GetAttribute(TInt aAttribute, TInt& aValue);
+        TInt GetAttributeSet(RAttributeSet& aAttributeSet);
+        TInt GetStringAttribute(TInt aAttribute, TDes& aValue);
+        TInt GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet);
+        TInt Read(TInt aPos, TDes8& aDes, TInt aLength, TRequestStatus& aStatus);
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CWmDrmAgentData();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode);
+        void ConstructL(RFile& aFile, const TDesC& aUniqueId);
+
+    protected:  // Data
+
+        /** Handle to the filesystem */
+        RFs iFs;
+
+        /** RFile object */
+        RFile iFile;
+        TVirtualPathPtr iVirtualPath;
+
+        /** The ASF file */
+        CAsf* iAsf;
+        };
+
+} // namespace ContentAccess
+
+#endif // WMDRMAGENTDATA_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentfactory.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,162 @@
+/*
+* 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:  ?Description
+*
+*/
+
+
+
+
+#ifndef WMDRMAGENTFACTORY_H
+#define WMDRMAGENTFACTORY_H
+
+//  INCLUDES
+#include <AgentFactory.h>
+#include "WmDrmAgentContent.h"
+#include "WmDrmAgentData.h"
+#include "WmDrmAgentManager.h"
+#include "WmDrmAgentRightsManager.h"
+#include "WmDrmAgentImportFile.h"
+
+// CONSTANTS
+//const ?type ?constant_var = ?constant;
+
+// MACROS
+//#define ?macro ?macro_def
+
+// DATA TYPES
+//enum ?declaration
+//typedef ?declaration
+//extern ?data_type;
+
+// FUNCTION PROTOTYPES
+//?type ?function_name(?arg_list);
+
+// FORWARD DECLARATIONS
+//class ?FORWARD_CLASSNAME;
+
+namespace ContentAccess
+	{
+// CLASS DECLARATION
+
+/**
+*  ?one_line_short_description.
+*  ?other_description_lines
+*
+*  @lib ?library
+*  @since Series ?XX ?SeriesXX_version
+*/
+	class CWmDrmAgentFactory : public CAgentFactory
+		{
+    public:  // Constructors and destructor
+        
+        /**
+        * Two-phased constructor.
+        */
+        static CWmDrmAgentFactory* NewL();
+        
+        /**
+        * Destructor.
+        */
+        virtual ~CWmDrmAgentFactory();
+
+    public: // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    public: // Functions from base classes
+
+        /**
+        * From ?base_class ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+		CAgentContent* CreateContentBrowserL(const TDesC& aURI, TContentShareMode aShareMode);	
+		CAgentContent* CreateContentBrowserL(RFile& aFile);
+		CAgentData* CreateDataConsumerL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode);
+		CAgentData* CreateDataConsumerL(RFile& aFile, const TDesC& aUniqueId);
+		CAgentManager*  CreateManagerL();
+		CAgentImportFile* CreateImporterL(const TDesC8& aMimeType, const CMetaDataArray& aMetaDataArray, const TDesC& aOutputDirectory, const TDesC& aSuggestedFileName);
+		CAgentImportFile* CreateImporterL(const TDesC8& aMimeType, const CMetaDataArray& aMetaDataArray);
+		CAgentRightsManager* CreateRightsManagerL();	
+
+    protected:  // New functions
+        
+        /**
+        * ?member_description.
+        * @since Series ?XX ?SeriesXX_version
+        * @param ?arg1 ?description
+        * @return ?description
+        */
+        //?type ?member_function( ?type ?arg1 );
+
+    protected:  // Functions from base classes
+        
+        /**
+        * From ?base_class ?member_description
+        */
+        //?type ?member_function();
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CWmDrmAgentFactory();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // Prohibit copy constructor if not deriving from CBase.
+        // CWmDrmAgentFactory( const CWmDrmAgentFactory& );
+        // Prohibit assigment operator if not deriving from CBase.
+        // CWmDrmAgentFactory& operator=( const CWmDrmAgentFactory& );
+
+    public:     // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+    
+    protected:  // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+
+    private:    // Data
+        // ?one_line_short_description_of_data
+        //?data_declaration;
+         
+        // Reserved pointer for future extension
+        //TAny* iReserved;
+
+    public:     // Friend classes
+        //?friend_class_declaration;
+    protected:  // Friend classes
+        //?friend_class_declaration;
+    private:    // Friend classes
+        //?friend_class_declaration;
+
+    };
+
+} // namespace ContentAccess
+#endif // WMDRMAGENTFACTORY_H
+            
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentimportfile.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,129 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of the WmDrmAgentImportFile class
+*
+*/
+
+
+#ifndef WMDRMAGENTIMPORTFILE_H
+#define WMDRMAGENTIMPORTFILE_H
+
+#include <s32file.h>
+#include <WmDrmAgent.h>
+
+#include "agentinterface.h"
+
+using namespace ContentAccess;
+
+
+class CWmDrmAgentImportFile : public CAgentImportFile
+    {
+public:
+
+    enum TImportType
+        {
+        EOma1DrmMessage,
+        EOma1XmlRo,
+        EOma1WbxmlRo,
+        EOma2Ro,
+        EPlainContent
+        };
+
+    static CWmDrmAgentImportFile* NewL(
+        const TDesC8& aMimeType,
+        const CMetaDataArray& aMetaDataArray,
+        const TDesC& aOutputDirectory,
+        const TDesC& aSuggestedFileName);
+        
+    static CWmDrmAgentImportFile* NewL(
+        const TDesC8& aMimeType,
+        const CMetaDataArray& aMetaDataArray);
+        
+    virtual ~CWmDrmAgentImportFile();
+
+public:
+
+    // From CAgentImportFile
+    virtual TInt WriteData(
+        const TDesC8& aData);
+        
+    virtual void WriteData(
+        const TDesC8& aData,
+        TRequestStatus& aStatus);
+        
+    virtual TInt WriteDataComplete();
+    
+    virtual void WriteDataComplete(
+        TRequestStatus& aStatus);
+        
+    virtual TInt OutputFileCountL() const;
+    
+    virtual CSupplierOutputFile& OutputFileL(
+        TInt aIndex);
+        
+    virtual TImportStatus GetImportStatus() const;
+    
+    virtual TInt GetSuggestedOutputFileExtension(
+        TDes& aFileExtension);
+        
+    virtual TInt GetSuggestedOutputFileName(
+        TDes& aFileName);
+        
+    virtual TInt ContinueWithNewOutputFile(
+        RFile& aFile, 
+        const TDesC& aFileName);
+        
+    virtual void ContinueWithNewOutputFile(
+        RFile& aFile, 
+        const TDesC& aFileName, 
+        TRequestStatus& aStatus);
+        
+    virtual void NewMimePartL(
+        const TDesC8& aMimeType, 
+        const CMetaDataArray& aImportMetaData);
+        
+    virtual void EndMimePartL();
+
+private:
+
+    CWmDrmAgentImportFile(
+        TBool aAgentCreatesOutputFiles);
+        
+    void ConstructL(
+        const TDesC8& aMimeType, 
+        const CMetaDataArray& aMetaDataArray, 
+        const TDesC& aOutputDirectory, 
+        const TDesC& aSuggestedFileName);
+        
+    TInt OpenOutputFile();
+    
+    void WriteDataL(const TDesC8& aData);
+    
+private:
+
+    TImportType iImportType;
+    HBufC8 *iMimeType;
+    HBufC *iOutputDirectory;
+    HBufC *iSuggestedFileName;
+    HBufC *iOutputFileName;
+    HBufC8 *iLastWriteData;
+    RFs iFs;
+    RFile iFile;
+    RPointerArray<CSupplierOutputFile> iOutputFiles;
+    TImportStatus iImportStatus;
+    TBool iAgentCreatesOutputFiles;
+    TBool iFileOpen;
+    };
+    
+#endif // WMDRMAGENTIMPORTFILE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentmanager.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,127 @@
+/*
+* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+
+
+#ifndef WMDRMAGENTMANAGER_H
+#define WMDRMAGENTMANAGER_H
+
+//  INCLUDES
+#include <caf.h>
+#include <agentinterface.h>
+#include <caf/attributeset.h>
+#include <caf/stringattributeset.h>
+
+namespace ContentAccess
+    {
+
+// CLASS DECLARATION
+
+    class CWmDrmAgentManager : public CAgentManager
+        {
+    public:  // Constructors and destructor
+        /**
+        * Two-phased constructor.
+        */
+        static CWmDrmAgentManager* NewL();
+        static CWmDrmAgentManager* NewLC();
+
+        /**
+        * Destructor.
+        */
+        ~CWmDrmAgentManager();
+
+    public: // New functions
+
+
+    public: // Functions from base classes
+
+        // From CAgentManagerBase
+        TInt DeleteFile(const TDesC &aFileName);
+        TInt CopyFile(const TDesC& aSource, const TDesC& aDestination);
+        TInt CopyFile(RFile& aSource, const TDesC& aDestination);
+        TInt RenameFile(const TDesC& aSource, const TDesC& aDestination);
+        TInt MkDir(const TDesC& aPath);
+        TInt MkDirAll(const TDesC& aPath);
+        TInt RmDir(const TDesC& aPath);
+        TInt GetDir(const TDesC& aName,TUint anEntryAttMask,TUint anEntrySortKey, CDir*& anEntryList) const;
+        TInt GetDir(const TDesC& aName,TUint anEntryAttMask,TUint anEntrySortKey, CDir*& anEntryList,CDir*& aDirList) const;
+        TInt GetDir(const TDesC& aName,const TUidType& anEntryUid,TUint anEntrySortKey, CDir*& aFileList) const;
+        TInt GetAttribute(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath);
+        TInt GetAttributeSet(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath);
+        TInt GetStringAttributeSet(RStringAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath);
+        TInt GetStringAttribute(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath);
+        void NotifyStatusChange(const TDesC& aURI, TEventMask aMask, TRequestStatus& aStatus);
+        TInt CancelNotifyStatusChange(const TDesC& aURI, TRequestStatus& aStatus);
+        TInt SetProperty(TAgentProperty aProperty, TInt aValue);
+        void DisplayInfoL(TDisplayInfo aInfo, const TVirtualPathPtr& aVirtualPath);
+
+        // From CAgentManager
+        TBool IsRecognizedL(const TDesC& aURI, TContentShareMode aShareMode) const;
+        TBool IsRecognizedL(RFile& aFile) const;
+        TBool RecognizeFileL(const TDesC& aFileName, const TDesC8& aBuffer, TDes8& aFileMimeType, TDes8& aContentMimeType) const;
+        TInt AgentSpecificCommand(TInt aCommand, const TDesC8& aInputBuffer, TDes8& aOutputBuffer);
+        void AgentSpecificCommand(TInt aCommand, const TDesC8& aInputBuffer, TDes8& aOutputBuffer, TRequestStatus& aStatus);
+        void DisplayManagementInfoL();
+        void PrepareHTTPRequestHeaders(RStringPool& aStringPool, RHTTPHeaders& aRequestHeaders) const;
+        TInt RenameDir(const TDesC& aOldName, const TDesC& aNewName);
+
+    protected:
+
+        static TBool IsProtectedL(const TDesC& aFileName);
+        static TBool IsProtectedL(RFile& aFile);
+
+    private:
+        /**
+        * C++ default constructor.
+        */
+        CWmDrmAgentManager();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        /**
+        * Sets up the file manager if it's needed
+        * If unsuccessful return an error code
+        */
+        TInt SetFileMan();
+
+        /**
+        * Combined ASF file object creator and attribute getter methods.
+        * Note: these are added for minimising TRAP harnesses
+        * in nonleaving attribute getter member functions.
+        */
+        TInt CWmDrmAgentManager::GetAttributeCreateFileL(TInt aAttribute, TInt& aValue, const TVirtualPathPtr& aVirtualPath);
+        TInt CWmDrmAgentManager::GetAttributeSetCreateFileL(RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath);
+        TInt CWmDrmAgentManager::GetStringAttributeCreateFileL(TInt aAttribute, TDes& aValue, const TVirtualPathPtr& aVirtualPath);
+        TInt CWmDrmAgentManager::GetStringAttributeSetCreateFileL(RStringAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath);
+
+
+
+    protected:  // Data
+
+    private:
+        RFs iFs;
+        CFileMan *iFileMan;
+        };
+} // namespace ContentAccess
+
+#endif // WMDRMAGENTMANAGER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/inc/wmdrmagentrightsmanager.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,85 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Declaration of the WMDRM Rights Manager CAF Agent
+*
+*/
+
+
+#ifndef WMDRMAGENTRIGHTSMANAGER_H
+#define WMDRMAGENTRIGHTSMANAGER_H
+
+//  INCLUDES
+#include <caf.h>
+#include <agentinterface.h>
+
+namespace ContentAccess
+{
+
+// CLASS DECLARATION
+
+/**
+*  Rights manager implementation for WMDRM
+*
+*  @lib wmdrmagent.dll
+*  @since S60 3.2
+*/
+class CWmDrmAgentRightsManager : public CAgentRightsManager
+    {
+    public:  // Constructors and destructor
+
+        /**
+        * Two-phased constructor.
+        */
+        static CWmDrmAgentRightsManager* NewL();
+        static CWmDrmAgentRightsManager* NewLC();
+
+        /**
+        * Destructor.
+        */
+        ~CWmDrmAgentRightsManager();
+
+    public: // Functions from base classes
+
+        // From CAgentRightsManager
+        void ListAllRightsL(RStreamablePtrArray<CRightsInfo>& aArray) const;
+        void ListRightsL(RStreamablePtrArray<CRightsInfo>& aArray, const TDesC& aUri) const;
+        void ListRightsL(RStreamablePtrArray<CRightsInfo>& aArray, TVirtualPathPtr& aVirtualPath) const;
+        void ListContentL(RStreamablePtrArray<CVirtualPath>& aArray, CRightsInfo& aRightsInfo) const;
+        MAgentRightsBase* GetRightsDataL(const CRightsInfo& aRightsInfo) const;
+        TInt DeleteRightsObject(const CRightsInfo& aRightsInfo);
+        TInt DeleteAllRightsObjects(const TVirtualPathPtr& aVirtualPath);
+        TInt SetProperty(TAgentProperty aProperty, TInt aValue);
+
+    private:
+
+        /**
+        * C++ default constructor.
+        */
+        CWmDrmAgentRightsManager();
+
+        /**
+        * By default Symbian 2nd phase constructor is private.
+        */
+        void ConstructL();
+
+        // New functions
+        // Data
+
+    };
+
+}
+
+#endif      // WMDRMAGENTRIGHTSMANAGER_H
+
+// End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/src/10205CB6.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+// ECOM DLL UID:		    0x10205CB6
+// CA Agent interface UID:	0x10204740
+
+#include "registryinfo.rh"
+RESOURCE REGISTRY_INFO theInfo
+{
+        dll_uid = 0x10205CB6;
+        interfaces =
+        {
+                INTERFACE_INFO
+                {
+                interface_uid = 0x10204740;
+                implementations =
+                        {
+                        IMPLEMENTATION_INFO
+                                {
+                                implementation_uid = 0x10205CB6;
+                                version_no = 1;
+                                display_name = "WM DRM Agent";
+                                default_data = "512|,application/vnd.drm.asf,audio/x-ms-wma,video/x-ms-wmv,application/x-asf.drm.import:application/vnd.drm.asf";
+                                opaque_data = "10205CB6"; // the agent's private directory
+                                }
+                        };
+                }
+        };
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagent.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// INCLUDE FILES
+#include <ecom/ecom.h>
+#include <ecom/implementationproxy.h>
+#include "wmdrmagentfactory.h"
+
+const TImplementationProxy ImplementationTable[] =
+	{
+#ifdef __EABI__
+		IMPLEMENTATION_PROXY_ENTRY(0x10205CB6,
+            ContentAccess::CWmDrmAgentFactory::NewL)
+#else
+		{ {0x10205CB6}, ContentAccess::CWmDrmAgentFactory::NewL}
+#endif
+	}; 
+
+// ========================== OTHER EXPORTED FUNCTIONS =========================
+
+// -----------------------------------------------------------------------------
+// ImplementationGroupProxy: Lookup method required by ECom
+// Returns the ImplementationTable to the  ECom framework
+// -----------------------------------------------------------------------------
+//
+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/wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentattributes.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,366 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Access to content and data attributes
+*
+*/
+
+
+// Includes
+#include <apgcli.h>
+#include <f32file.h>
+#include <charconv.h>
+
+#include <caf.h>
+#include <caf/attributeset.h>
+#include <caf/stringattributeset.h>
+#include <caf/virtualpath.h>
+#include <caf/caferr.h>
+#include <caf/caftypes.h>
+#include <utf.h>
+#include <drmagents.h>
+#include <oma2agent.h>
+#include <wmdrmagent.h>
+#include "wmdrmagentattributes.h"
+#include "asf.h"
+#include "logfn.h"
+
+using namespace ContentAccess;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// PointerArrayResetDestroyAndClose
+// Template method used to push RPointerArrays to the cleanup stack. Takes
+// care of deleting all pointers in the array.
+// -----------------------------------------------------------------------------
+
+template<class S>
+void PointerArrayResetDestroyAndClose(TAny* aPtr)
+        {
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->ResetAndDestroy();
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->Close();
+        }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+TInt TWmDrmAgentAttributes::GetAttributeL(
+    CAsf* /*aAsfFile*/,
+    TInt aAttribute,
+    TInt& aValue,
+    const TVirtualPathPtr& /*aVirtualPath*/,
+    TBool /*aReusePreviousQuery*/ )
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "TWmDrmAgentAttributes::GetAttributeL", r );
+    aValue = ETrue;
+    switch ( aAttribute )
+        {
+        case DRM::EDrmAgentUid:
+            aValue = DRM::EDrmWmAgent;
+            break;
+        case ECanPlay:
+        case ECanView:
+            aValue = EFalse;
+            r = KErrCANotSupported;
+            break;
+        case ERightsStateless:
+        case ERightsConsumable:
+            aValue = EFalse;
+            r = KErrCANotSupported;
+            break;
+        case ECanAutomaticConsume:
+            aValue = EFalse;
+            r = KErrCANotSupported;
+            break;
+        case EIsForwardable:
+        case EIsCopyable:
+        case ECanRewind:
+        case ECopyPaste:
+        case ECanMove:
+        case ECanRename:
+            aValue = ETrue;
+            break;
+        case EIsModifyable:
+        case ECanPrint:
+        case ECanExecute:
+        case EPreviewAvailable:
+            aValue = EFalse;
+            break;
+        case EIsProtected:
+            r = KErrCANotSupported;
+            break;
+        case EContentCDataInUse:
+            aValue = ETrue;
+            break;
+        case EFileType:
+            aValue = EAsf;
+            break;
+        case DRM::EDrmFileType:
+            aValue = DRM::EDrmWMFile;
+            break;
+        case DRM::EDrmAllowedOutputs:
+            aValue = 0;
+            r = KErrCANotSupported;
+           break;
+        default:
+            r = KErrCANotSupported;
+            break;
+        };
+    LOG3( "Attribute: %d, value: %d", aAttribute, aValue );
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+TInt TWmDrmAgentAttributes::GetAttributeSetL(
+    CAsf* aAsfFile,
+    RAttributeSet& aAttributeSet,
+    const TVirtualPathPtr& aVirtualPath )
+    {
+    TInt i = 0;
+    TInt attribute = 0;
+    TInt value=0;
+    TInt err = KErrNone;
+    TInt numAttributes = aAttributeSet.Count();
+
+    LOGFN( "TWmDrmAgentAttributes::GetAttributeSetL" );
+
+    // loop through all the attriutes in the set and find their values
+    for ( i = 0; i < numAttributes && err == KErrNone; i++ )
+        {
+        attribute = aAttributeSet[i];
+        err = GetAttributeL( aAsfFile, attribute,
+            value, aVirtualPath, ETrue );
+        err = aAttributeSet.SetValue( attribute, value, err );
+        }
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+TInt TWmDrmAgentAttributes::GetStringAttributeL(
+    CAsf* aAsfFile,
+    TInt aAttribute,
+    TDes& aValue,
+    const TVirtualPathPtr& /*aVirtualPath*/,
+    TBool /*aReusePreviousQuery*/ )
+    {
+    TInt err = KErrNone;
+    HBufC* b = NULL;
+    HBufC* allocated = NULL;
+    TFileName fileName;
+
+    LOGFNR( "TWmDrmAgentAttributes::GetStringAttributeL", err );
+    // Initialise the attribute value to be zero length in case it's not
+    // supported or an error occurs
+    aValue.SetLength( 0 );
+
+    switch( aAttribute )
+        {
+        case EIconURI:
+        case EPreviewURI:
+        case EContentURI:
+        case EInfoURL:
+        case EPendingRightsETA:
+            err = KErrCANotSupported;
+            break;
+
+        case EMimeType:
+            aValue.Copy( aAsfFile->iMimeType );
+            break;
+        case EDescription:
+            if (aAsfFile->iDescription)
+                {
+                b = aAsfFile->iDescription;
+                }
+            break;
+        case ETitle:
+            if (aAsfFile->iTitle)
+                {
+                b = aAsfFile->iTitle;
+                }
+            break;
+        case EPerformer:
+        case EAuthor:
+            if (aAsfFile->iAuthor)
+                {
+                b = aAsfFile->iAuthor;
+                }
+            break;
+        case EContentID:
+            if (aAsfFile->iUniqueFileID)
+                {
+                b = aAsfFile->iUniqueFileID;
+                }
+            break;
+        case ECopyright:
+            if (aAsfFile->iCopyright)
+                {
+                b = aAsfFile->iCopyright;
+                }
+            break;
+        case ERating:
+        case DRM::EDrmRatingInfo:
+            if (aAsfFile->iRating)
+                {
+                b = aAsfFile->iRating;
+                }
+            break;
+        case EAlbumTitle:
+            if (aAsfFile->iAlbumTitle)
+                {
+                b = aAsfFile->iAlbumTitle;
+                }
+            break;
+        case EPicture:
+            if (aAsfFile->iPicture)
+                {
+                b = aAsfFile->iPicture;
+                }
+            break;
+        case EText:
+            if (aAsfFile->iText)
+                {
+                b = aAsfFile->iText;
+                }
+            break;
+        case EComposer:
+            if (aAsfFile->iComposer)
+                {
+                b = aAsfFile->iComposer;
+                }
+            break;
+        case EGenre:
+            if (aAsfFile->iGenre)
+                {
+                b = aAsfFile->iGenre;
+                }
+            break;
+        case EYear:
+        case DRM::EDrmRecordingYear:
+            if (aAsfFile->iYear)
+                {
+                b = aAsfFile->iYear;
+                }
+            break;
+        case EOriginalArtist:
+        case DRM::EDrmOriginalArtist:
+            if (aAsfFile->iOriginalArtist)
+                {
+                b = aAsfFile->iOriginalArtist;
+                }
+            break;
+        case EWmTrackNumber:
+        case DRM::EDrmTrackNumber:
+            if (aAsfFile->iTrackNumber)
+                {
+                b = aAsfFile->iTrackNumber;
+                }
+            break;
+        case EAudioFileUrl:
+            if (aAsfFile->iAudioFileUrl)
+                {
+                b = aAsfFile->iAudioFileUrl;
+                }
+            break;
+        case ESharedUserRating:
+            if (aAsfFile->iSharedUserRating)
+                {
+                b = aAsfFile->iSharedUserRating;
+                }
+            break;
+        case EDate:
+            if (aAsfFile->iDate)
+                {
+                b = aAsfFile->iDate;
+                }
+            break;
+        case DRM::EDrmAgentName:
+            allocated = DRM::KDrmWMAgentName().AllocL();
+            break;
+        case DRM::EDrmFileName:
+            err = aAsfFile->iFile.Name( fileName );
+            if( aValue.MaxLength() < fileName.Length() )
+                {
+                return KErrOverflow;
+                }
+            aValue.Copy( fileName );
+            break;
+        case DRM::EDrmFullName:
+            err = aAsfFile->iFile.FullName( fileName );
+            if ( aValue.MaxLength() < fileName.Length() )
+                {
+                return KErrOverflow;
+                }
+            aValue.Copy( fileName );
+            break;
+        default:
+            err = KErrCANotSupported;
+            break;
+        };
+
+    if (b != NULL)
+        {
+        if( b->Length() > aValue.MaxLength() )
+            {
+            return KErrOverflow;
+            }
+        err = KErrNone;
+        aValue.Copy(*b);
+        }
+    else if( allocated )
+        {
+        if( allocated->Length() <= aValue.MaxLength() )
+            {
+            err = KErrNone;
+            aValue.Copy(*allocated);
+            }
+        else
+            {
+            err = KErrOverflow;
+            }
+        delete allocated;
+        allocated = NULL;
+        }
+
+    LOG2( "Attribute: %d", aAttribute );
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+TInt TWmDrmAgentAttributes::GetStringAttributeSetL(
+    CAsf* aAsfFile,
+    RStringAttributeSet& aStringAttributeSet,
+    const TVirtualPathPtr& aVirtualPath )
+    {
+    TInt i = 0;
+    TInt attribute = 0;
+    TInt err = KErrNone;
+    TBuf <KMaxDataTypeLength> buf;
+
+    LOGFN( "TWmDrmAgentAttributes::GetStringAttributeSetL" );
+    TInt numAttributes = aStringAttributeSet.Count();
+
+    // loop through all the attriutes in the set and find their values
+    for ( i = 0; i < numAttributes && err==KErrNone; i++ )
+        {
+        buf.SetLength( 0 );
+        attribute = aStringAttributeSet[i];
+        err = GetStringAttributeL( aAsfFile, attribute, buf, aVirtualPath );
+        err = aStringAttributeSet.SetValue(attribute,buf, err);
+        }
+    return err;
+    }
+
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentcontent.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,453 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <caf.h>
+#include <bitset.h>
+#include <attribute.h>
+#include <caf/attributeset.h>
+#include <caf/stringattributeset.h>
+#include <e32test.h>
+#include <utf.h>
+#include "wmdrmagentcontent.h"
+#include "wmdrmagentattributes.h"
+#include "asf.h"
+#include "logfn.h"
+
+using namespace ContentAccess;
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TInt MapContentShareMode(TContentShareMode aMode);
+template<class S>
+LOCAL_C void PointerArrayResetDestroyAndClose(TAny* aPtr);
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// MapContentShareMode
+// Maps the CAF specific file share mode to the RFs/RFile sharing mode
+// -----------------------------------------------------------------------------
+//
+TInt MapContentShareMode(TContentShareMode aMode)
+    {
+    TInt r = EFileRead | EFileShareAny;
+
+    switch (aMode)
+        {
+        case EContentShareReadOnly:
+            r = EFileRead | EFileShareReadersOnly;
+            break;
+        case EContentShareReadWrite:
+            r = EFileRead | EFileShareReadersOrWriters;
+            break;
+        case EContentShareExclusive:
+            r = EFileRead | EFileShareExclusive;
+            break;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// PointerArrayResetDestroyAndClose
+// Template method used to push RPointerArrays to the cleanup stack. Takes
+// care of deleting all pointers in the array.
+// -----------------------------------------------------------------------------
+//
+template<class S>
+void PointerArrayResetDestroyAndClose(TAny* aPtr)
+    {
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->ResetAndDestroy();
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->Close();
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::CWmDrmAgentContent
+// Reset all member variables
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentContent::CWmDrmAgentContent():
+    iURI(NULL),
+    iAsf(NULL)
+    {
+    LOGFN( "CWmDrmAgentContent::CWmDrmAgentContent" );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::NewL
+// Two-phased constructors
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentContent* CWmDrmAgentContent::NewL(const TDesC& aURI, TContentShareMode aShareMode)
+    {
+    LOGFN( "CWmDrmAgentContent::NewL" );
+    CWmDrmAgentContent* self = new (ELeave) CWmDrmAgentContent();
+    CleanupStack::PushL(self);
+    self->ConstructL(aURI, aShareMode);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::NewLC
+// Two-phased constructors
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentContent* CWmDrmAgentContent::NewLC(
+    const TDesC& aUri,
+    TContentShareMode aShareMode)
+    {
+    LOGFN( "CWmDrmAgentContent::NewLC" );
+    CWmDrmAgentContent* self = new (ELeave) CWmDrmAgentContent();
+    CleanupStack::PushL(self);
+    self->ConstructL(aUri, aShareMode);
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::NewL
+// Two-phased constructors
+// -----------------------------------------------------------------------------
+//
+//
+
+CWmDrmAgentContent* CWmDrmAgentContent::NewL(RFile& aFile)
+    {
+    LOGFN( "CWmDrmAgentContent::NewL (2)" );
+    CWmDrmAgentContent* self = new (ELeave) CWmDrmAgentContent();
+    CleanupStack::PushL(self);
+    self->ConstructL(aFile);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::NewLC
+// Two-phased constructors
+// -----------------------------------------------------------------------------
+//
+//
+
+CWmDrmAgentContent* CWmDrmAgentContent::NewLC(RFile& aFile)
+    {
+    LOGFN( "CWmDrmAgentContent::NewLC (2)" );
+    CWmDrmAgentContent* self = new (ELeave) CWmDrmAgentContent();
+    CleanupStack::PushL(self);
+    self->ConstructL(aFile);
+    return self;
+    }
+
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::~CWmDrmAgentContent
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentContent::~CWmDrmAgentContent()
+    {
+    LOGFN( "CWmDrmAgentContent::~CWmDrmAgentContent" );
+    iFile.Close();
+    iFs.Close();
+    delete iURI;
+    delete iAsf;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::ConstructL
+// Initialize the agent from a URI (file name) and file mode, opens the
+// the file and takes membership of the handle
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentContent::ConstructL(const TDesC& aUri, TContentShareMode aShareMode)
+    {
+    LOGFN( "CWmDrmAgentContent::ConstructL" );
+    iURI = aUri.AllocL();
+    User::LeaveIfError(iFs.Connect());
+    User::LeaveIfError(iFile.Open(iFs, aUri, MapContentShareMode(aShareMode)));
+    iAsf = CAsf::NewL(iFile);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::ConstructL
+// Initialize the agent from a file handle, duplicates the handle
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentContent::ConstructL(RFile& aFile)
+    {
+    TFileName name;
+
+    LOGFN( "CWmDrmAgentContent::ConstructL (2)" );
+    User::LeaveIfError(iFile.Duplicate(aFile));
+    User::LeaveIfError(iFs.Connect());
+    iFile.Name(name);
+    iURI = name.AllocL();
+    iAsf = CAsf::NewL(iFile);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::OpenContainer
+// -----------------------------------------------------------------------------
+//
+
+TInt CWmDrmAgentContent::OpenContainer(const TDesC&)
+    {
+    LOGFN( "CWmDrmAgentContent::OpenContainer" );
+    return KErrNotFound;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::CloseContainer
+// -----------------------------------------------------------------------------
+//
+
+TInt CWmDrmAgentContent::CloseContainer()
+    {
+    LOGFN( "CWmDrmAgentContent::CloseContainer" );
+    return KErrNotFound;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::GetEmbeddedObjectsL
+// -----------------------------------------------------------------------------
+//
+
+void CWmDrmAgentContent::GetEmbeddedObjectsL(RStreamablePtrArray<CEmbeddedObject>& /*aArray*/)
+    {
+    LOGFN( "CWmDrmAgentContent::GetEmbeddedObjectsL" );
+    User::Leave(KErrNotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::GetEmbeddedObjectsL
+// -----------------------------------------------------------------------------
+//
+
+void CWmDrmAgentContent::GetEmbeddedObjectsL(RStreamablePtrArray<CEmbeddedObject>& aArray, TEmbeddedType aType)
+    {
+    LOGFN( "CWmDrmAgentContent::GetEmbeddedObjectsL" );
+    // the only embedded object is the file itself
+    if(aType == EContentObject)
+        {
+        // just get the default object since there is only one content object
+        GetEmbeddedObjectsL(aArray);
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::Search
+// -----------------------------------------------------------------------------
+//
+
+TInt CWmDrmAgentContent::Search(RStreamablePtrArray<CEmbeddedObject>& /*aArray*/, const TDesC8& /*aMimeType*/, TBool )
+    {
+    LOGFN( "CWmDrmAgentContent::Search" );
+    return KErrNotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::GetAttribute
+// -----------------------------------------------------------------------------
+//
+
+TInt CWmDrmAgentContent::GetAttribute(TInt aAttribute, TInt& aValue, const TDesC& aUniqueId)
+    {
+    TInt r = KErrNone;
+    TInt err = KErrNone;
+
+    LOGFN( "CWmDrmAgentContent::GetAttribute" );
+    TRAP(err, r = TWmDrmAgentAttributes::GetAttributeL(
+              iAsf, aAttribute, aValue, TVirtualPathPtr(*iURI, aUniqueId)));
+    if (err != KErrNone)
+        {
+        r = err;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::GetAttributeSet
+// -----------------------------------------------------------------------------
+//
+
+TInt CWmDrmAgentContent::GetAttributeSet(RAttributeSet& aAttributeSet, const TDesC& aUniqueId)
+    {
+    TInt r = KErrNone;
+    TInt err = KErrNone;
+
+    LOGFN( "CWmDrmAgentContent::GetAttributeSet" );
+    TRAP(err,r = TWmDrmAgentAttributes::GetAttributeSetL(iAsf, aAttributeSet,
+        TVirtualPathPtr(*iURI, aUniqueId)));
+    if (err != KErrNone)
+        {
+        r = err;
+        }
+    return r;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::GetStringAttribute
+// -----------------------------------------------------------------------------
+//
+
+TInt CWmDrmAgentContent::GetStringAttribute(TInt aAttribute, TDes& aValue, const TDesC& aUniqueId)
+    {
+
+    TInt r = KErrNone;
+    TInt err = KErrNone;
+
+    LOGFN( "CWmDrmAgentContent::GetStringAttribute" );
+    TRAP(err, r = TWmDrmAgentAttributes::GetStringAttributeL(iAsf, aAttribute,
+        aValue, TVirtualPathPtr(*iURI, aUniqueId)));
+    if (err != KErrNone)
+        {
+        r = err;
+        }
+    return r;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::GetStringAttributeSet
+// -----------------------------------------------------------------------------
+//
+
+TInt CWmDrmAgentContent::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet, const TDesC& aUniqueId)
+    {
+    TInt r = KErrNone;
+    TInt err = KErrNone;
+
+    LOGFN( "CWmDrmAgentContent::GetStringAttributeSet" );
+    TRAP(err,r = TWmDrmAgentAttributes::GetStringAttributeSetL(
+        iAsf, aStringAttributeSet,
+        TVirtualPathPtr(*iURI, aUniqueId)));
+    if (err != KErrNone)
+        {
+        r = err;
+        }
+    return r;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::AgentSpecificCommand
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentContent::AgentSpecificCommand(
+    TInt /*aCommand*/,
+    const TDesC8& /*aInputBuffer*/,
+    TDes8& /*aOutputBuffer*/)
+    {
+    LOGFN( "CWmDrmAgentContent::AgentSpecificCommand" );
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::AgentSpecificCommand
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentContent::AgentSpecificCommand(
+    TInt aCommand,
+    const TDesC8& aInputBuffer,
+    TDes8& aOutputBuffer,
+    TRequestStatus& aStatus)
+    {
+    LOGFN( "CWmDrmAgentContent::AgentSpecificCommand (2)" );
+    TRequestStatus *ptr = &aStatus;
+    User::RequestComplete(ptr, AgentSpecificCommand(aCommand, aInputBuffer,
+        aOutputBuffer));
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::NotifyStatusChange
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentContent::NotifyStatusChange(TEventMask , TRequestStatus& aStatus, const TDesC& )
+    {
+    LOGFN( "CWmDrmAgentContent::NotifyStatusChange" );
+    TRequestStatus* ptr = &aStatus;
+    User::RequestComplete(ptr, KErrCANotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::CancelNotifyStatusChange
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentContent::CancelNotifyStatusChange(
+    TRequestStatus& /*aStatus*/,
+    const TDesC& /*aUniqueId*/)
+    {
+    LOGFN( "CWmDrmAgentContent::CancelNotifyStatusChange" );
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::RequestRights
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentContent::RequestRights(TRequestStatus& aStatus, const TDesC& )
+    {
+    LOGFN( "CWmDrmAgentContent::RequestRights" );
+    TRequestStatus* ptr = &aStatus;
+    User::RequestComplete(ptr, KErrCANotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::CancelRequestRights
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentContent::CancelRequestRights(
+    TRequestStatus& aStatus,
+    const TDesC& /*aUniqueId*/)
+    {
+    LOGFN( "CWmDrmAgentContent::CancelRequestRights" );
+    TRequestStatus *ptr = &aStatus;
+    User::RequestComplete(ptr, KErrCANotSupported);
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::DisplayInfoL
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentContent::DisplayInfoL(
+    TDisplayInfo /*aDisplayInfo*/,
+    const TDesC& /*aUniqueId*/)
+    {
+    LOGFN( "CWmDrmAgentContent::DisplayInfoL" );
+    User::Leave(KErrCANotSupported);
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentContent::SetProperty
+// Reset all member variables
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentContent::SetProperty(
+    TAgentProperty /*aProperty*/,
+    TInt /*aValue*/)
+    {
+    LOGFN( "CWmDrmAgentContent::SetProperty" );
+    return KErrCANotSupported;
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentdata.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,372 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the CAF Agent Data class
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <caf.h>
+#include <caf/caferr.h>
+#include <attribute.h>
+#include <e32test.h>
+#include "wmdrmagentdata.h"
+#include "wmdrmagentattributes.h"
+#include "asf.h"
+#include "logfn.h"
+
+using namespace ContentAccess;
+
+// LOCAL FUNCTION PROTOTYPES
+LOCAL_C TInt MapContentShareMode(TContentShareMode aMode);
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// MapContentShareMode
+// Maps the CAF specific file share mode to the RFs/RFile sharing mode
+// -----------------------------------------------------------------------------
+//
+TInt MapContentShareMode(TContentShareMode aMode)
+    {
+    TInt r = EFileRead | EFileShareAny;
+
+    switch (aMode)
+        {
+        case EContentShareReadOnly:
+            r = EFileRead | EFileShareReadersOnly;
+            break;
+        case EContentShareReadWrite:
+            r = EFileRead | EFileShareReadersOrWriters;
+            break;
+        case EContentShareExclusive:
+            r = EFileRead | EFileShareExclusive;
+            break;
+        }
+    return r;
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::CWmDrmAgentData
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentData::CWmDrmAgentData():
+    iVirtualPath( KNullDesC ),
+    iAsf( NULL )
+    {
+    LOGFN( "CWmDrmAgentData::CWmDrmAgentData" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentData* CWmDrmAgentData::NewL(
+    const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode )
+    {
+    LOGFN( "CWmDrmAgentData::NewL" );
+    CWmDrmAgentData* self = new (ELeave) CWmDrmAgentData;
+    CleanupStack::PushL(self);
+    self->ConstructL(aVirtualPath, aShareMode);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::NewLC
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentData* CWmDrmAgentData::NewLC(
+    const TVirtualPathPtr& aVirtualPath,
+    TContentShareMode aShareMode)
+    {
+    LOGFN( "CWmDrmAgentData::NewLC" );
+    CWmDrmAgentData* self=new(ELeave) CWmDrmAgentData();
+    CleanupStack::PushL(self);
+    self->ConstructL(aVirtualPath, aShareMode);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::NewLC
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentData* CWmDrmAgentData::NewL(
+    RFile& aFile, const TDesC& aUniqueId )
+    {
+    LOGFN( "CWmDrmAgentData::NewL (2)" );
+    CWmDrmAgentData* self = new (ELeave) CWmDrmAgentData;
+    CleanupStack::PushL(self);
+    self->ConstructL(aFile, aUniqueId);
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::NewLC
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentData* CWmDrmAgentData::NewLC(
+    RFile& aFile,
+    const TDesC& aUniqueId )
+    {
+    LOGFN( "CWmDrmAgentData::NewLC (2)" );
+    CWmDrmAgentData* self=new(ELeave) CWmDrmAgentData();
+    CleanupStack::PushL(self);
+    self->ConstructL(aFile, aUniqueId);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::~CWmDrmAgentData
+// -----------------------------------------------------------------------------
+//
+
+CWmDrmAgentData::~CWmDrmAgentData()
+    {
+    // Tidy up RFile and RFs
+    LOGFN( "CWmDrmAgentData::~CWmDrmAgentData" );
+    iFile.Close();
+    iFs.Close();
+    delete iAsf;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::ConstructL
+// The porting kit is not initialized here since it is time consuming. It is
+// initialized whenever needed and just allocated at this point.
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentData::ConstructL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode)
+    {
+    LOGFN( "CWmDrmAgentData::ConstructL" );
+    User::LeaveIfError(iFs.Connect());
+    User::LeaveIfError(iFile.Open(iFs, aVirtualPath.URI(),
+        MapContentShareMode(aShareMode)));
+    iAsf = CAsf::NewL(iFile);
+    iVirtualPath = aVirtualPath;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::ConstructL
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentData::ConstructL(RFile& aFile, const TDesC& /*aUniqueId*/)
+    {
+    TInt pos = 0;
+
+    LOGFN( "CWmDrmAgentData::ConstructL (2)" );
+    // When creating a CData from a file handle we must duplicate the file handle
+    // before doing anything
+    User::LeaveIfError(iFs.Connect());
+    User::LeaveIfError(iFile.Duplicate(aFile));
+    User::LeaveIfError(iFile.Seek(ESeekStart, pos));  // reset to start of file
+    iAsf = CAsf::NewL(iFile);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::DataSizeL
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentData::DataSizeL(TInt &aSize)
+    {
+    LOGFN( "CWmDrmAgentData::DataSizeL" );
+    User::LeaveIfError(iFile.Size(aSize));
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::EvaluateIntent
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentData::EvaluateIntent(TIntent /*aIntent*/)
+    {
+    LOGFN( "CWmDrmAgentData::EvaluateIntent" );
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::ExecuteIntent
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentData::ExecuteIntent(TIntent /*aIntent*/)
+    {
+    LOGFN( "CWmDrmAgentData::ExecuteIntent" );
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::Read
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentData::Read(TDes8& aDes)
+    {
+    LOGFN( "CWmDrmAgentData::Read" );
+    return iFile.Read(aDes);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::Read
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentData::Read(TDes8& aDes,TInt aLength)
+    {
+    LOGFN( "CWmDrmAgentData::Read (2)" );
+    return iFile.Read(aDes,aLength);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::Read
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentData::Read(TDes8& aDes,TRequestStatus& aStatus)
+    {
+    LOGFN( "CWmDrmAgentData::Read (3)" );
+    iFile.Read(aDes, aStatus);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::Read
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentData::Read(TDes8& aDes,
+                             TInt aLength,
+                             TRequestStatus& aStatus)
+    {
+    LOGFN( "CWmDrmAgentData::Read (4)" );
+    iFile.Read(aDes, aLength, aStatus);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::Read
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentData::Read(TInt aPos, TDes8& aDes,
+                             TInt aLength,
+                             TRequestStatus& aStatus)
+    {
+    LOGFN( "CWmDrmAgentData::Read (5)" );
+    iFile.Read(aPos, aDes, aLength, aStatus);
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::Seek
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentData::Seek(TSeek aMode, TInt& aPos)
+    {
+    LOGFN( "CWmDrmAgentData::Seek" );
+    return iFile.Seek(aMode, aPos);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::SetProperty
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentData::SetProperty(TAgentProperty /*aProperty*/, TInt /*aValue*/)
+    {
+    LOGFN( "CWmDrmAgentData::SetProperty" );
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::GetAttribute
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentData::GetAttribute(TInt aAttribute, TInt& aValue)
+    {
+    TInt r = KErrNone;
+    TInt err = KErrNone;
+
+    LOGFN( "CWmDrmAgentData::GetAttribute" );
+    TRAP(err,r = TWmDrmAgentAttributes::GetAttributeL(iAsf,
+        aAttribute, aValue, iVirtualPath));
+    if (err != KErrNone)
+        {
+        return err;
+        }
+
+    return r;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::GetAttributeSet
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentData::GetAttributeSet(RAttributeSet& aAttributeSet)
+    {
+    TInt err = KErrNone;
+    TInt r = KErrNone;
+
+    LOGFN( "CWmDrmAgentData::GetAttributeS" );
+    TRAP(err, r = TWmDrmAgentAttributes::GetAttributeSetL(iAsf,
+        aAttributeSet, iVirtualPath) );
+    if (err != KErrNone)
+        {
+        return err;
+        }
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::GetStringAttribute
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentData::GetStringAttribute(TInt aAttribute, TDes& aValue)
+    {
+    TInt err = KErrNone;
+    TInt r = KErrNone;
+
+    LOGFN( "CWmDrmAgentData::GetStringAttribute" );
+    TRAP(err, r = TWmDrmAgentAttributes::GetStringAttributeL(iAsf,
+        aAttribute, aValue, iVirtualPath));
+    if (err != KErrNone)
+        {
+        return err;
+        }
+    return r;
+
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentData::GetStringAttributeSet
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentData::GetStringAttributeSet(RStringAttributeSet& aStringAttributeSet)
+    {
+    TInt err = KErrNone;
+    TInt r = KErrNone;
+
+    LOGFN( "CWmDrmAgentData::GetStringAttributeSet" );
+    TRAP(err,r = TWmDrmAgentAttributes::GetStringAttributeSetL(iAsf,
+        aStringAttributeSet, iVirtualPath));
+    if (err != KErrNone)
+        {
+        return err;
+        }
+    return r;
+
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentfactory.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,160 @@
+/*
+* 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:  ?Description
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <caf.h>
+#include "wmdrmagentfactory.h"
+#include "wmdrmagentimportfile.h"
+#include "wmdrmagentrightsmanager.h"
+#include "logfn.h"
+
+using namespace ContentAccess;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::CWmDrmAgentFactory
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentFactory::CWmDrmAgentFactory()
+    {
+    LOGFN( "CWmDrmAgentFactory::CWmDrmAgentFactory" );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentFactory::ConstructL()
+    {
+    LOGFN( "CWmDrmAgentFactory::ConstructL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentFactory* CWmDrmAgentFactory::NewL()
+    {
+    LOGFN( "CWmDrmAgentFactory::NewL" );
+    CWmDrmAgentFactory* self = new( ELeave ) CWmDrmAgentFactory;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::~CWmDrmAgentFactory
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentFactory::~CWmDrmAgentFactory()
+    {
+    LOGFN( "CWmDrmAgentFactory::~CWmDrmAgentFactory" );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::CreateContentBrowserL
+// -----------------------------------------------------------------------------
+//
+CAgentContent* CWmDrmAgentFactory::CreateContentBrowserL(const TDesC& aURI, TContentShareMode aShareMode)
+    {
+    LOGFN( "CWmDrmAgentFactory::CreateContentBrowserL" );
+    return CWmDrmAgentContent::NewL(aURI, aShareMode);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::CreateContentBrowserL
+// -----------------------------------------------------------------------------
+//
+CAgentContent* CWmDrmAgentFactory::CreateContentBrowserL(RFile& aFile)
+    {
+    LOGFN( "CWmDrmAgentFactory::CreateContentBrowserL (2)" );
+    return CWmDrmAgentContent::NewL(aFile);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::CreateDataConsumerL
+// -----------------------------------------------------------------------------
+//
+CAgentData* CWmDrmAgentFactory::CreateDataConsumerL(const TVirtualPathPtr& aVirtualPath, TContentShareMode aShareMode)
+    {
+    LOGFN( "CWmDrmAgentFactory::CreateDataConsumerL" );
+    return CWmDrmAgentData::NewL(aVirtualPath, aShareMode);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::CreateDataConsumerL
+// -----------------------------------------------------------------------------
+//
+CAgentData* CWmDrmAgentFactory::CreateDataConsumerL(RFile& aFile, const TDesC& aUniqueId)
+    {
+    LOGFN( "CWmDrmAgentFactory::CreateDataConsumerL (2)" );
+    return CWmDrmAgentData::NewL(aFile, aUniqueId);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::CreateManagerL
+// -----------------------------------------------------------------------------
+//
+CAgentManager*  CWmDrmAgentFactory::CreateManagerL()
+    {
+    LOGFN( "CWmDrmAgentFactory::CreateManagerL" );
+    return CWmDrmAgentManager::NewL();
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::CreateImporterL
+// -----------------------------------------------------------------------------
+//
+CAgentImportFile* CWmDrmAgentFactory::CreateImporterL(const TDesC8& aMimeType, const CMetaDataArray& aMetaDataArray, const TDesC& aOutputDirectory, const TDesC& aSuggestedFileName)
+    {
+    LOGFN( "CWmDrmAgentFactory::CreateImporterL" );
+    return CWmDrmAgentImportFile::NewL(aMimeType, aMetaDataArray, aOutputDirectory, aSuggestedFileName);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::CreateImporterL
+// -----------------------------------------------------------------------------
+//
+CAgentImportFile* CWmDrmAgentFactory::CreateImporterL(const TDesC8& aMimeType, const CMetaDataArray& aMetaDataArray)
+    {
+    LOGFN( "CWmDrmAgentFactory::CreateImporterL (2)" );
+    return CWmDrmAgentImportFile::NewL(aMimeType, aMetaDataArray);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentFactory::CreateImporterL
+// -----------------------------------------------------------------------------
+//
+CAgentRightsManager* CWmDrmAgentFactory::CreateRightsManagerL()
+    {
+    LOGFN( "CWmDrmAgentFactory::CreateRightsManagerL" );
+	return CWmDrmAgentRightsManager::NewL();
+    }
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentimportfile.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,404 @@
+/*
+* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  ?Description
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <s32mem.h>
+#include <f32file.h>
+#include <caf/caf.h>
+#include <caf/caferr.h>
+#include <caf/SupplierOutputFile.h>
+#include <WmdrmAgent.h>
+#include "WmDrmAgentImportfile.h"
+#include "logfn.h"
+
+using namespace ContentAccess;
+
+// LOCAL FUNCTION PROTOTYPES
+template<class S>
+LOCAL_C void PointerArrayResetDestroyAndClose(TAny* aPtr);
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// ?function_name ?description.
+// ?description
+// Returns: ?value_1: ?description
+//          ?value_n: ?description_line1
+//                    ?description_line2
+// -----------------------------------------------------------------------------
+//
+template<class S>
+void PointerArrayResetDestroyAndClose(TAny* aPtr)
+    {
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->ResetAndDestroy();
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->Close();
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentImportFile* CWmDrmAgentImportFile::NewL(
+    const TDesC8& aMimeType,
+    const CMetaDataArray& aMetaDataArray,
+    const TDesC& aOutputDirectory,
+    const TDesC& aSuggestedFileName)
+	{
+	LOGFN( "CWmDrmAgentImportFile::NewL" );
+	CWmDrmAgentImportFile* self=new(ELeave) CWmDrmAgentImportFile(EFalse);
+	CleanupStack::PushL(self);
+	self->ConstructL(aMimeType, aMetaDataArray, aOutputDirectory,
+	    aSuggestedFileName);
+	CleanupStack::Pop(self);
+	return self;
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentImportFile* CWmDrmAgentImportFile::NewL(
+    const TDesC8& aMimeType,
+    const CMetaDataArray& aMetaDataArray)
+	{
+	LOGFN( "CWmDrmAgentImportFile::NewL (2)" );
+	CWmDrmAgentImportFile* self=new(ELeave) CWmDrmAgentImportFile(EFalse);
+	CleanupStack::PushL(self);
+	self->ConstructL(aMimeType, aMetaDataArray, KNullDesC(), KNullDesC());
+	CleanupStack::Pop(self);
+	return self;
+	}
+	
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentImportFile::CWmDrmAgentImportFile(
+    TBool aAgentCreatesOutputFiles):
+    iOutputDirectory(NULL),
+    iSuggestedFileName(NULL),
+    iOutputFileName(NULL),
+    iLastWriteData(NULL),
+    iAgentCreatesOutputFiles(aAgentCreatesOutputFiles)
+	{
+	LOGFN( "CWmDrmAgentImportFile::CWmDrmAgentImportFile" );
+	iImportStatus = EInProgress;
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentImportFile::~CWmDrmAgentImportFile()
+	{
+	LOGFN( "CWmDrmAgentImportFile::~CWmDrmAgentImportFile" );
+	if (iFileOpen)
+		{
+		iFile.Close();
+		iFileOpen = EFalse;
+		}
+	iFs.Close();
+	delete iOutputDirectory;
+	delete iSuggestedFileName;
+    delete iOutputFileName;
+	delete iLastWriteData;
+	iOutputFiles.ResetAndDestroy();
+	iOutputFiles.Close();
+	}
+  
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentImportFile::ConstructL(
+    const TDesC8& aMimeType,
+    const CMetaDataArray& /*aMetaDataArray*/,
+    const TDesC& aOutputDirectory,
+    const TDesC& aSuggestedFileName)
+	{
+	LOGFN( "CWmDrmAgentImportFile::ConstructL" );
+
+    iMimeType = aMimeType.AllocL();
+	iOutputDirectory = aOutputDirectory.AllocL();
+	iSuggestedFileName = aSuggestedFileName.AllocL();
+    iOutputFileName = HBufC::NewL(iOutputDirectory->Des().Length() +
+                                  iSuggestedFileName->Des().Length());
+	iAgentCreatesOutputFiles = ETrue;
+
+	User::LeaveIfError(iFs.Connect());
+    User::LeaveIfError(iFs.ShareAuto());
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentImportFile::OpenOutputFile()
+	{
+	TInt r = KErrNone;
+	TPtr fileNamePtr = iOutputFileName->Des();
+	
+	fileNamePtr.Copy(*iOutputDirectory);
+	fileNamePtr.Append(*iSuggestedFileName);
+
+	r = iFile.Create(iFs, fileNamePtr, EFileShareReadersOrWriters  | EFileStream |
+	    EFileWrite);
+	if (r == KErrNone)
+		{
+		iFileOpen = ETrue;
+		}
+    else
+        {
+        r = KErrCANewFileHandleRequired;
+        }
+    return r;
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentImportFile::WriteDataL( const TDesC8& aData )
+    {
+    LOGFN( "CWmDrmAgentImportFile::WriteDataL" );
+    TInt err = KErrNone;
+    
+    if( !iFileOpen ) 
+        {
+        err = OpenOutputFile();
+        if( err )
+            {
+            User::Leave(KErrCANewFileHandleRequired);
+            }
+        }
+    User::LeaveIfError( iFile.Write( aData ) );        
+    }
+    
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentImportFile::WriteData(const TDesC8& aData)
+	{
+	LOGFN( "CWmDrmAgentImportFile::WriteData" );
+	TInt r = KErrNone;
+	TRAP(r, WriteDataL(aData));
+	return r;
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentImportFile::WriteDataComplete()
+	{
+	LOGFN( "CWmDrmAgentImportFile::WriteDataComplete" );
+    TInt r = KErrNone;
+    CSupplierOutputFile *temp = NULL;
+    
+    if( iFileOpen )
+        {
+        iFile.Close();
+        iFileOpen = EFalse;
+        }
+
+    if( iOutputFileName )
+        {
+        TRAP(r, temp = CSupplierOutputFile::NewL( iOutputFileName->Des(), EContent, iMimeType->Des()));
+        if( r == KErrNone )
+            {
+            r = iOutputFiles.Append(temp);
+            if( r != KErrNone )
+                {
+                delete temp;
+                }
+            }
+        }
+	return r;
+	}
+		
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentImportFile::WriteData(
+    const TDesC8& aData,
+    TRequestStatus &aStatus)
+	{
+	LOGFN( "CWmDrmAgentImportFile::WriteData" );
+	TRequestStatus *ptr = &aStatus;
+	TInt r = WriteData(aData);
+	User::RequestComplete(ptr,r);
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentImportFile::WriteDataComplete(
+    TRequestStatus &aStatus)
+	{
+	LOGFN( "CWmDrmAgentImportFile::WriteDataComplete" );
+	TRequestStatus *ptr = &aStatus;
+	TInt r = WriteDataComplete();
+	User::RequestComplete(ptr,r);
+	}
+	
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentImportFile::OutputFileCountL() const
+	{
+	LOGFN( "CWmDrmAgentImportFile::OutputFileCountL" );
+	return iOutputFiles.Count();
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+CSupplierOutputFile& CWmDrmAgentImportFile::OutputFileL(
+    TInt aIndex)
+	{
+	LOGFN( "CWmDrmAgentImportFile::OutputFileL" );
+	return *iOutputFiles[aIndex];
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TImportStatus CWmDrmAgentImportFile::GetImportStatus() const
+	{
+	LOGFN( "CWmDrmAgentImportFile::GetImportStatus" );
+	return iImportStatus;
+	}	
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentImportFile::GetSuggestedOutputFileExtension(
+    TDes& /*aFileExtension*/)
+	{
+	LOGFN( "CWmDrmAgentImportFile::GetSuggestedOutputFileExtension" );
+    return KErrNotSupported;
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentImportFile::GetSuggestedOutputFileName(
+    TDes& /*aFileName*/)
+	{
+	LOGFN( "CWmDrmAgentImportFile::GetSuggestedOutputFileName" );
+	return KErrNotSupported;
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentImportFile::ContinueWithNewOutputFile(
+    RFile& aFile,
+    const TDesC& aFileName)
+	{
+	RFile file;
+	TInt r = KErrNone;
+	LOGFN( "CWmDrmAgentImportFile::ContinueWithNewOutputFile" );
+
+	if (iOutputFileName != NULL)
+	    {
+	    delete iOutputFileName;
+	    iOutputFileName = NULL;
+	    }
+	    
+	TRAP(r, iOutputFileName = aFileName.AllocL());
+	
+	if (r == KErrNone)
+	    {
+	    iFile.Close();
+	    iFile.Duplicate(aFile);
+        iFileOpen = ETrue;
+	    }
+	return r;
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentImportFile::ContinueWithNewOutputFile(
+    RFile& aFile,
+    const TDesC& aFileName,
+    TRequestStatus& aStatus)
+	{
+	LOGFN( "CWmDrmAgentImportFile::ContinueWithNewOutputFile (2)" );
+	TRequestStatus *ptr = &aStatus;
+	TInt r = ContinueWithNewOutputFile(aFile, aFileName);
+	User::RequestComplete(ptr,r);
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentImportFile::NewMimePartL(
+    const TDesC8& /*aMimeType*/,
+    const CMetaDataArray& /*aImportMetaData*/)
+	{
+	LOGFN( "CWmDrmAgentImportFile::NewMimePartL" );
+	User::Leave(KErrCANotSupported);
+	}
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentImportFile::
+// 
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentImportFile::EndMimePartL()
+	{
+	LOGFN( "CWmDrmAgentImportFile::EndMimePartL" );
+	User::Leave(KErrCANotSupported);
+	}
+
+// End of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentmanager.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,768 @@
+/*
+* Copyright (c) 2006 - 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Implementation of the Manager Interface
+*
+*/
+
+
+// INCLUDE FILES
+#include <caf.h>
+#include <http.h>
+#include <http/rhttpheaders.h>
+#include <stringpool.h>
+#include <w32std.h>
+#include <apparc.h>
+#include <apgtask.h>
+#include <apgcli.h>
+#include <apaserverapp.h>
+#include <sysutil.h>
+#include <wmdrmagent.h>
+
+#include "wmdrmclient.h"
+#include "wmdrmagentmanager.h"
+#include "wmdrmagentattributes.h"
+#include "asf.h"
+#include "logfn.h"
+
+using namespace ContentAccess;
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::CWmDrmAgentManager
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentManager::CWmDrmAgentManager()
+    {
+    LOGFN( "CWmDrmAgentManager::CWmDrmAgentManager" );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentManager* CWmDrmAgentManager::NewL()
+    {
+    LOGFN( "CWmDrmAgentManager::NewL" );
+    CWmDrmAgentManager* self=new(ELeave) CWmDrmAgentManager();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentManager* CWmDrmAgentManager::NewLC()
+    {
+    LOGFN( "CWmDrmAgentManager::NewLC" );
+    CWmDrmAgentManager* self=new(ELeave) CWmDrmAgentManager();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::~CWmDrmAgentManager
+// Destructor
+// -----------------------------------------------------------------------------
+//
+
+CWmDrmAgentManager::~CWmDrmAgentManager()
+    {
+    LOGFN( "CWmDrmAgentManager::~CWmDrmAgentManager" );
+    delete iFileMan;
+    iFs.Close();
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentManager::ConstructL()
+    {
+    LOGFN( "CWmDrmAgentManager::ConstructL" );
+    User::LeaveIfError(iFs.Connect());
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::DeleteFile
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::DeleteFile(const TDesC& aFileName)
+    {
+    LOGFN( "CWmDrmAgentManager::DeleteFile" );
+    return iFs.Delete(aFileName);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::CopyFile
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::CopyFile(const TDesC& aSource,
+    const TDesC& aDestination)
+    {
+    LOGFN( "CWmDrmAgentManager::CopyFile" );
+    TInt driveNumber = 0;
+    TChar drive( aDestination[0] );
+    RFile file;
+    TInt size = 0;
+    TInt result = KErrNone;
+
+    TInt r = KErrNone;
+    TBool retval(EFalse);
+
+    // Check the destination drive letter
+    result = iFs.CharToDrive(drive,driveNumber);
+
+    if( result )
+        {
+        return result;
+        }
+
+    // open the file to read the size
+    result = file.Open(iFs, aSource, EFileShareReadersOrWriters|EFileRead);
+
+    if( result )
+        {
+        return result;
+        }
+
+    // read the size
+    result = file.Size( size );
+
+    // close the file
+    file.Close();
+
+    if( result )
+        {
+        return result;
+        }
+    // check that the drive has enough space for the copy operation
+    TRAP(r, retval = SysUtil::DiskSpaceBelowCriticalLevelL( &iFs,
+                                                             size,
+                                                             driveNumber ) );
+
+    if( retval )
+        {
+        return KErrDiskFull;
+        }
+
+    result = SetFileMan();
+
+    if( result )
+        {
+        return result;
+        }
+
+    return iFileMan->Copy(aSource, aDestination);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::CopyFile
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::CopyFile(RFile& aSource,
+    const TDesC& aDestination)
+    {
+    LOGFN( "CWmDrmAgentManager::CopyFile (2)" );
+    TInt driveNumber = 0;
+    TChar drive( aDestination[0] );
+    TInt size = 0;
+    TInt result = KErrNone;
+    RFile output;
+    TFileName fileName;
+    TInt r = KErrNone;
+    TBool retval(EFalse);
+
+    // Same file, do not even try to copy
+    // And since they are the same don't return an error
+    aSource.FullName( fileName );
+
+    if( !aDestination.CompareF( fileName ) )
+        {
+        return KErrNone;
+        }
+
+    // Check the destination drive letter
+    result = iFs.CharToDrive(drive,driveNumber);
+
+    if( result )
+        {
+        return result;
+        }
+
+    // read the size
+    result = aSource.Size( size );
+
+    if( result )
+        {
+        return result;
+        }
+
+    // check that the drive has enough space for the copy operation
+    TRAP(r, retval = SysUtil::DiskSpaceBelowCriticalLevelL( &iFs,
+                                                            size,
+                                                            driveNumber ) );
+    if( retval )
+        {
+        return KErrDiskFull;
+        }
+
+    // Perform the copy:
+
+    // Rewind just in case:
+    size = 0;
+    result = aSource.Seek(ESeekStart, size);
+
+    if( !result )
+        {
+
+        result = SetFileMan();
+
+        if( result )
+            {
+            return result;
+            }
+
+        result = iFileMan->Copy(aSource, aDestination);
+        }
+
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::RenameFile
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::RenameFile(const TDesC& aSource,
+    const TDesC& aDestination)
+    {
+    LOGFN( "CWmDrmAgentManager::RenameFile" );
+    TInt driveNumber = 0;
+    TChar drive( aDestination[0] );
+    RFile file;
+    TInt size = 0;
+    TInt result = KErrNone;
+    TInt r = KErrNone;
+    TBool retval(EFalse);
+
+    result = SetFileMan();
+
+    if( result )
+        {
+        return result;
+        }
+
+    result = iFileMan->Rename(aSource, aDestination);
+
+    // If the files are on a different drive, Rename will fail
+    // Therefore we simulate the Move by doing a Copy, followed by Delete
+    if ( result != KErrNone )
+        {
+        // Check the destination drive letter
+        result = iFs.CharToDrive(drive,driveNumber);
+
+        if( result )
+            {
+            return result;
+            }
+
+        // open the file to read the size
+        result = file.Open(iFs, aSource, EFileShareReadersOrWriters|EFileRead);
+
+        if( result )
+            {
+            return result;
+            }
+
+        // read the size
+        result = file.Size( size );
+
+        // close the file
+        file.Close();
+
+        if( result )
+            {
+            return result;
+            }
+        // check that the drive has enough space for the copy operation
+        TRAP(r, retval = SysUtil::DiskSpaceBelowCriticalLevelL( &iFs,
+                                                                size,
+                                                                driveNumber ) );
+
+        if( retval )
+            {
+            return KErrDiskFull;
+            }
+
+        result = iFileMan->Copy(aSource,aDestination);
+        if (result == KErrNone)
+            {
+            // If the copy was successful try and delete the original
+            result = iFileMan->Delete(aSource);
+            if (result != KErrNone)
+                {
+                // Delete failed so try to cleanup the destination file
+                // as we're going to exit with an error
+                // We can safely ignore any error from this as the previous error
+                // is more important to propagate, since this is just cleanup
+                iFileMan->Delete(aDestination);
+                }
+            }
+        }
+    return result;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::MkDir
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::MkDir(const TDesC& aPath)
+    {
+    LOGFN( "CWmDrmAgentManager::MkDir" );
+    return iFs.MkDir( aPath );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::MkDirAll
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::MkDirAll(const TDesC& aPath)
+    {
+    LOGFN( "CWmDrmAgentManager::MkDirAll" );
+    return iFs.MkDirAll( aPath );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::RmDir
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::RmDir(const TDesC& aPath)
+    {
+    LOGFN( "CWmDrmAgentManager::RmDir" );
+    TInt result = KErrNone;
+
+    result = SetFileMan();
+
+    if( result )
+        {
+        return result;
+        }
+
+    return iFileMan->RmDir( aPath );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::GetDir
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::GetDir(const TDesC& aName, TUint aEntryAttMask,
+    TUint aEntrySortKey, CDir*& aEntryList) const
+    {
+    LOGFN( "CWmDrmAgentManager::GetDir" );
+    return iFs.GetDir( aName, aEntryAttMask, aEntrySortKey, aEntryList );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::GetDir
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::GetDir(const TDesC& aName,TUint aEntryAttMask,
+    TUint aEntrySortKey, CDir*& aEntryList,CDir*& aDirList) const
+    {
+    LOGFN( "CWmDrmAgentManager::GetDir (2)" );
+    return iFs.GetDir( aName, aEntryAttMask, aEntrySortKey, aEntryList, aDirList );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::GetDir
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::GetDir(const TDesC& aName,
+    const TUidType& aEntryUid,TUint aEntrySortKey,
+    CDir*& aFileList) const
+    {
+    LOGFN( "CWmDrmAgentManager::GetDir (3)" );
+    return iFs.GetDir( aName, aEntryUid, aEntrySortKey, aFileList );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::GetAttribute
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::GetAttribute(TInt aAttribute, TInt& aValue,
+    const TVirtualPathPtr& aVirtualPath)
+    {
+
+    TInt r = KErrNone;
+    TInt err = KErrNone;
+
+    LOGFN( "CWmDrmAgentManager::GetAttribute" );
+    TRAP(err, r = CWmDrmAgentManager::GetAttributeCreateFileL(
+            aAttribute, aValue, aVirtualPath));
+
+    if(err != KErrNone)
+        {
+        return err;
+        }
+
+    return r;
+    }
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::GetAttributeCreateFileL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::GetAttributeCreateFileL(TInt aAttribute, TInt& aValue,
+    const TVirtualPathPtr& aVirtualPath)
+    {
+    TInt r = KErrNone;
+
+    CAsf *asfFile = CAsf::NewL(aVirtualPath.URI());
+    CleanupStack::PushL(asfFile);
+    r = TWmDrmAgentAttributes::GetAttributeL(asfFile,
+        aAttribute, aValue, aVirtualPath);
+    CleanupStack::PopAndDestroy();
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::GetAttributeSet
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::GetAttributeSet(RAttributeSet& aAttributeSet,
+    const TVirtualPathPtr& aVirtualPath)
+    {
+
+    TInt r = KErrNone;
+    TInt err = KErrNone;
+
+    LOGFN( "CWmDrmAgentManager::GetAttributeSet" );
+    TRAP(err, r = CWmDrmAgentManager::GetAttributeSetCreateFileL(
+            aAttributeSet, aVirtualPath));
+
+    if(err != KErrNone)
+        {
+        return err;
+        }
+    return r;
+    }
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::GetAttributeSetCreateFileL
+//
+// -----------------------------------------------------------------------------
+TInt CWmDrmAgentManager::GetAttributeSetCreateFileL(
+    RAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath)
+    {
+    TInt r = KErrNone;
+
+    CAsf *asfFile = CAsf::NewL(aVirtualPath.URI());
+    CleanupStack::PushL(asfFile);
+    r = TWmDrmAgentAttributes::GetAttributeSetL(asfFile,
+        aAttributeSet, aVirtualPath);
+    CleanupStack::PopAndDestroy();
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::GetStringAttributeSet
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::GetStringAttributeSet(
+    RStringAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath)
+    {
+    TInt r = KErrNone;
+    TInt err = KErrNone;
+    RFile file;
+
+    LOGFN( "CWmDrmAgentManager::GetStringAttributeSet" );
+    TRAP(err, r = CWmDrmAgentManager::GetStringAttributeSetCreateFileL(
+            aAttributeSet, aVirtualPath ));
+
+    if(err != KErrNone)
+        {
+        return err;
+        }
+    return r;
+    }
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::GetStringAttributeSetCreateFileL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::GetStringAttributeSetCreateFileL(
+    RStringAttributeSet& aAttributeSet, const TVirtualPathPtr& aVirtualPath)
+    {
+    TInt r = KErrNone;
+    CAsf *asfFile = CAsf::NewL(aVirtualPath.URI());
+    CleanupStack::PushL(asfFile);
+    r = TWmDrmAgentAttributes::GetStringAttributeSetL(
+              asfFile, aAttributeSet, aVirtualPath);
+    CleanupStack::PopAndDestroy();
+    return r;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::GetStringAttribute
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::GetStringAttribute(TInt aAttribute, TDes& aValue,
+    const TVirtualPathPtr& aVirtualPath)
+    {
+    TInt r = KErrNone;
+    TInt err = KErrNone;
+
+    LOGFN( "CWmDrmAgentManager::GetStringAttribute" );
+    TRAP(err, r = CWmDrmAgentManager::GetStringAttributeCreateFileL(
+              aAttribute, aValue, aVirtualPath ));
+    if(err != KErrNone)
+        {
+        return err;
+        }
+    return r;
+    }
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::GetStringAttributeCreateFileL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::GetStringAttributeCreateFileL(TInt aAttribute, TDes& aValue,
+    const TVirtualPathPtr& aVirtualPath)
+    {
+    TInt r = KErrNone;
+    CAsf *asfFile = CAsf::NewL(aVirtualPath.URI());
+    CleanupStack::PushL(asfFile);
+    r = TWmDrmAgentAttributes::GetStringAttributeL(
+              asfFile, aAttribute, aValue, aVirtualPath);
+    CleanupStack::PopAndDestroy();
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::NotifyStatusChange
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentManager::NotifyStatusChange(const TDesC& , TEventMask ,
+    TRequestStatus& aStatus)
+    {
+    LOGFN( "CWmDrmAgentManager::NotifyStatusChange" );
+    TRequestStatus* ptr = &aStatus;
+    User::RequestComplete(ptr, KErrCANotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::CancelNotifyStatusChange
+//
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::CancelNotifyStatusChange(const TDesC& ,
+    TRequestStatus& )
+    {
+    LOGFN( "CWmDrmAgentManager::CancelNotifyStatusChange" );
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::SetProperty
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::SetProperty(TAgentProperty /*aProperty*/,
+    TInt /*aValue*/)
+    {
+    LOGFN( "CWmDrmAgentManager::SetProperty" );
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::DisplayInfoL
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentManager::DisplayInfoL(TDisplayInfo /*aInfo*/,
+    const TVirtualPathPtr& /*aVirtualPath*/)
+    {
+    LOGFN( "CWmDrmAgentManager::DisplayInfoL" );
+    User::Leave(KErrCANotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::IsRecognizedL
+// -----------------------------------------------------------------------------
+//
+TBool CWmDrmAgentManager::IsRecognizedL(
+    const TDesC& /*aUri*/,
+    TContentShareMode /*aShareMode*/) const
+    {
+    LOGFN( "CWmDrmAgentManager::IsRecognizedL" );
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::IsRecognizedL
+// -----------------------------------------------------------------------------
+//
+TBool CWmDrmAgentManager::IsRecognizedL(RFile& /*aFile*/) const
+    {
+    LOGFN( "CWmDrmAgentManager::IsRecognizedL (2)" );
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::RecognizeFileL
+// -----------------------------------------------------------------------------
+//
+TBool CWmDrmAgentManager::RecognizeFileL(
+    const TDesC& /*aFileName*/,
+    const TDesC8& /*aBuffer*/,
+    TDes8& /*aFileMimeType*/,
+    TDes8& /*aContentMimeType*/) const
+    {
+    LOGFN( "CWmDrmAgentManager::RecognizeFileL" );
+    return EFalse;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::AgentSpecificCommand
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::AgentSpecificCommand(TInt aCommand,
+                                              const TDesC8& /*iInputBuffer*/,
+                                              TDes8& /*aOutputBuffer*/ )
+    {
+    TInt r = KErrCANotSupported;
+    RWmDrmClient client;
+
+    switch( aCommand )
+        {
+        case DRM::EWmDrmDeleteRights:
+            r = client.Connect();
+            if( !r )
+                {
+                r = client.DeleteRights();
+                }
+            client.Close();
+            break;
+        default:
+            break;
+        }
+
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::AgentSpecificCommand
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentManager::AgentSpecificCommand(TInt , const TDesC8& ,
+    TDes8& , TRequestStatus& aStatus)
+    {
+    LOGFN( "CWmDrmAgentManager::AgentSpecificCommand (2)" );
+    TRequestStatus *ptr = &aStatus;
+    User::RequestComplete(ptr, KErrCANotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentManager::DisplayManagementInfoL()
+    {
+    LOGFN( "CWmDrmAgentManager::DisplayManagementInfoL" );
+    User::Leave(KErrCANotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::PrepareHTTPRequestHeaders
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentManager::PrepareHTTPRequestHeaders(RStringPool& /*aStringPool*/,
+    RHTTPHeaders& /*aRequestHeaders*/) const
+    {
+    LOGFN( "CWmDrmAgentManager::PrepareHTTPRequestHeaders" );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::RenameDir
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::RenameDir(const TDesC& /*aOldName*/,
+    const TDesC& /*aNewName*/)
+    {
+    LOGFN( "CWmDrmAgentManager::RenameDir" );
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::IsProtected
+// -----------------------------------------------------------------------------
+//
+TBool CWmDrmAgentManager::IsProtectedL(const TDesC& aFileName)
+    {
+    TBool r = EFalse;
+    CAsf* asf = NULL;
+    LOGFN( "CWmDrmAgentManager::IsProtectedL" );
+    TRAP_IGNORE(asf = CAsf::NewL(aFileName));
+    if (asf != NULL && asf->iIsDrmProtected)
+        {
+        r = ETrue;
+        }
+    delete asf;
+    return r;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::IsProtected
+// -----------------------------------------------------------------------------
+//
+TBool CWmDrmAgentManager::IsProtectedL(RFile& aFile)
+    {
+    TBool r = EFalse;
+    CAsf* asf = NULL;
+    LOGFN( "CWmDrmAgentManager::IsProtectedL (2)" );
+    TRAP_IGNORE(asf = CAsf::NewL(aFile));
+    if (asf != NULL && asf->iIsDrmProtected)
+        {
+        r = ETrue;
+        }
+    delete asf;
+    return r;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentManager::SetFileMan
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentManager::SetFileMan()
+    {
+    TInt err = KErrNone;
+    if( !iFileMan )
+        {
+        TRAP(err, iFileMan = CFileMan::NewL(iFs) );
+        }
+    return err;
+    }
+
+//  End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmagent/src/wmdrmagentrightsmanager.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,185 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Stub implementation of CAgentRightsManager
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <caf.h>
+#include <utf.h>
+#include "wmdrmagentrightsmanager.h"
+#include "rightsinfo.h"
+#include "asf.h"
+
+#include "logfn.h"
+
+using namespace ContentAccess;
+// ============================ LOCAL FUNCTIONS ================================
+
+// -----------------------------------------------------------------------------
+// PointerArrayResetDestroyAndClose
+// Template method used to push RPointerArrays to the cleanup stack. Takes
+// care of deleting all pointers in the array.
+// -----------------------------------------------------------------------------
+//
+template<class S>
+void PointerArrayResetDestroyAndClose(TAny* aPtr)
+    {
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->ResetAndDestroy();
+    (reinterpret_cast<RPointerArray<S>*>(aPtr))->Close();
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::CWmDrmAgentRightsManager
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentRightsManager::CWmDrmAgentRightsManager()
+    {
+    LOGFN( "CWmDrmAgentRightsManager::CWmDrmAgentRightsManager" );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentRightsManager::ConstructL()
+    {
+    LOGFN( "CWmDrmAgentRightsManager::ConstructL" );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CWmDrmAgentRightsManager* CWmDrmAgentRightsManager::NewL()
+    {
+    LOGFN( "CWmDrmAgentRightsManager::NewL" );
+    CWmDrmAgentRightsManager* self = new( ELeave ) CWmDrmAgentRightsManager;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::~CWmDrmAgentRightsManager
+// Destructor
+// -----------------------------------------------------------------------------
+//
+
+CWmDrmAgentRightsManager::~CWmDrmAgentRightsManager()
+    {
+    LOGFN( "CWmDrmAgentRightsManager::~CWmDrmAgentRightsManager" );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::ListAllRightsL
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentRightsManager::ListAllRightsL(
+    RStreamablePtrArray<CRightsInfo>& /*aArray*/) const
+    {
+    LOGFN( "CWmDrmAgentRightsManager::ListAllRightsL" );
+    User::Leave(KErrNotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::ListRightsL
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentRightsManager::ListRightsL(
+    RStreamablePtrArray<CRightsInfo>& /*aArray*/,
+    const TDesC& /*aUri*/) const
+    {
+    LOGFN( "CWmDrmAgentRightsManager::ListRightsL" );
+    User::Leave(KErrCANotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::ListRightsL
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentRightsManager::ListRightsL(
+    RStreamablePtrArray<CRightsInfo>& aArray,
+    TVirtualPathPtr& aVirtualPath) const
+    {
+    LOGFN( "CWmDrmAgentRightsManager::ListRightsL (2)" );
+    ListRightsL( aArray, aVirtualPath.URI() );
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::ListContentL
+// -----------------------------------------------------------------------------
+//
+void CWmDrmAgentRightsManager::ListContentL(
+    RStreamablePtrArray<CVirtualPath>& /*aArray*/,
+    CRightsInfo& /*aRightsInfo*/) const
+    {
+    LOGFN( "CWmDrmAgentRightsManager::ListContentL" );
+    User::Leave(KErrCANotSupported);
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::GetRightsDataL
+// -----------------------------------------------------------------------------
+//
+MAgentRightsBase* CWmDrmAgentRightsManager::GetRightsDataL(
+    const CRightsInfo& /*aRightsInfo*/) const
+    {
+    LOGFN( "CWmDrmAgentRightsManager::GetRightsDataL" );
+    User::Leave(KErrCANotSupported);
+    return NULL;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::DeleteRightsObject
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentRightsManager::DeleteRightsObject(
+    const CRightsInfo& /*aRightsInfo*/)
+    {
+    LOGFN( "CWmDrmAgentRightsManager::DeleteRightsObject" );
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::DeleteAllRightsObjects
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentRightsManager::DeleteAllRightsObjects(
+    const TVirtualPathPtr& /*aVirtualPath*/)
+    {
+    LOGFN( "CWmDrmAgentRightsManager::DeleteAllRightsObjects" );
+    return KErrCANotSupported;
+    }
+
+// -----------------------------------------------------------------------------
+// CWmDrmAgentRightsManager::SetProperty
+// -----------------------------------------------------------------------------
+//
+TInt CWmDrmAgentRightsManager::SetProperty(
+    TAgentProperty /*aProperty*/,
+    TInt /*aValue*/)
+    {
+    LOGFN( "CWmDrmAgentRightsManager::SetProperty" );
+    return KErrCANotSupported;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/client/BWINS/wmdrmfileserverclientU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,15 @@
+EXPORTS
+	?CloseFile@RWmDrmFileServerClient@@QAEXXZ @ 1 NONAME ; void RWmDrmFileServerClient::CloseFile(void)
+	?Connect@RWmDrmFileServerClient@@QAEHXZ @ 2 NONAME ; int RWmDrmFileServerClient::Connect(void)
+	?Create@RWmDrmFileServerClient@@QAEHABVTDesC16@@@Z @ 3 NONAME ; int RWmDrmFileServerClient::Create(class TDesC16 const &)
+	?Delete@RWmDrmFileServerClient@@QAEHABVTDesC16@@@Z @ 4 NONAME ; int RWmDrmFileServerClient::Delete(class TDesC16 const &)
+	?IsOpen@RWmDrmFileServerClient@@QAEHXZ @ 5 NONAME ; int RWmDrmFileServerClient::IsOpen(void)
+	?MkDirAll@RWmDrmFileServerClient@@QAEHABVTDesC16@@H@Z @ 6 NONAME ; int RWmDrmFileServerClient::MkDirAll(class TDesC16 const &, int)
+	?Open@RWmDrmFileServerClient@@QAEHABVTDesC16@@@Z @ 7 NONAME ; int RWmDrmFileServerClient::Open(class TDesC16 const &)
+	?Read@RWmDrmFileServerClient@@QAEHAAVTDes8@@@Z @ 8 NONAME ; int RWmDrmFileServerClient::Read(class TDes8 &)
+	?RmDir@RWmDrmFileServerClient@@QAEHABVTDesC16@@@Z @ 9 NONAME ; int RWmDrmFileServerClient::RmDir(class TDesC16 const &)
+	?RmDirAll@RWmDrmFileServerClient@@QAEHABVTDesC16@@@Z @ 10 NONAME ; int RWmDrmFileServerClient::RmDirAll(class TDesC16 const &)
+	?Size@RWmDrmFileServerClient@@QAEHAAH@Z @ 11 NONAME ; int RWmDrmFileServerClient::Size(int &)
+	?Write@RWmDrmFileServerClient@@QAEHABVTDesC8@@@Z @ 12 NONAME ; int RWmDrmFileServerClient::Write(class TDesC8 const &)
+	?UpdateSecureTime@RWmDrmFileServerClient@@QAEHAAVTTime@@0@Z @ 13 NONAME ; int RWmDrmFileServerClient::UpdateSecureTime(class TTime &, class TTime &)
+	?DeleteRights@RWmDrmFileServerClient@@QAEHXZ @ 14 NONAME ; int RWmDrmFileServerClient::DeleteRights(void)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/client/EABI/wmdrmfileserverclientU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,15 @@
+EXPORTS
+	_ZN22RWmDrmFileServerClient4OpenERK7TDesC16 @ 1 NONAME
+	_ZN22RWmDrmFileServerClient4ReadER5TDes8 @ 2 NONAME
+	_ZN22RWmDrmFileServerClient4SizeERi @ 3 NONAME
+	_ZN22RWmDrmFileServerClient5RmDirERK7TDesC16 @ 4 NONAME
+	_ZN22RWmDrmFileServerClient5WriteERK6TDesC8 @ 5 NONAME
+	_ZN22RWmDrmFileServerClient6CreateERK7TDesC16 @ 6 NONAME
+	_ZN22RWmDrmFileServerClient6DeleteERK7TDesC16 @ 7 NONAME
+	_ZN22RWmDrmFileServerClient6IsOpenEv @ 8 NONAME
+	_ZN22RWmDrmFileServerClient7ConnectEv @ 9 NONAME
+	_ZN22RWmDrmFileServerClient8MkDirAllERK7TDesC16i @ 10 NONAME
+	_ZN22RWmDrmFileServerClient8RmDirAllERK7TDesC16 @ 11 NONAME
+	_ZN22RWmDrmFileServerClient9CloseFileEv @ 12 NONAME
+	_ZN22RWmDrmFileServerClient16UpdateSecureTimeER5TTimeS1_ @ 13 NONAME
+	_ZN22RWmDrmFileServerClient12DeleteRightsEv @ 14 NONAME
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/client/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,20 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project WMDRM Fileserver Client
+*
+*/
+
+
+PRJ_MMPFILES
+wmdrmfileserverclient.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/client/group/wmdrmfileserverclient.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,44 @@
+/*
+* 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:  Project definition file for project WMDRM Client
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          wmdrmfileserverclient.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x2000B181
+
+CAPABILITY      CAP_GENERAL_DLL
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   .
+USERINCLUDE     ../inc
+USERINCLUDE     ../../server/inc
+USERINCLUDE     ../../../wmdrmpd/inc
+USERINCLUDE     ../../../../inc
+USERINCLUDE		../../../../../inc
+
+SOURCEPATH      ../src
+
+SOURCE          wmdrmfileserverclient.cpp
+
+LIBRARY         euser.lib
+LIBRARY         flogger.lib
+LIBRARY         efsrv.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/client/src/wmdrmfileserverclient.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,209 @@
+/*
+* 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:  WMDRM Fileserver Client implementation
+*
+*/
+
+
+#include "wmdrmfileserverclient.h"
+#include "wmdrmfsclientserver.h"
+
+//#define _LOGGING_FILE L"wmdrmfileserver.txt"
+
+//#include "logfn.h"
+
+// Message slots a client can have open: taken from the global slot pool
+const TInt KServerDefaultMessageSlots = -1;
+
+// Number of times the server is attempted to start if it is not running
+const TInt KServerRetryCount = 3;
+
+// ======== LOCAL FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// Try to start the server if it is not running
+// ---------------------------------------------------------------------------
+//
+static TInt StartServer()
+	{
+	RProcess server;
+	TInt r = server.Create( KWmDrmFileServerImg, KNullDesC );
+	if ( r != KErrNone )
+		return r;
+	TRequestStatus stat;
+	server.Rendezvous( stat );
+	if ( stat != KRequestPending )
+	    {
+		server.Kill( 0 );
+		}
+	else
+	    {
+		server.Resume();
+		}
+	User::WaitForRequest( stat );
+	r = ( server.ExitType() == EExitPanic ) ? KErrGeneral : stat.Int();
+	server.Close();
+	return r;
+	}
+
+// ======== MEMBER FUNCTIONS ========
+
+EXPORT_C TInt RWmDrmFileServerClient::Open( const TDesC& aFilename )
+    {
+    TInt r = KErrNone;
+
+    //LOGFNR( "RWmDrmFileServerClient::Open", r );
+    r = SendReceive( EFsOpen, TIpcArgs( &aFilename ) );
+    return r;
+    }
+
+EXPORT_C TInt RWmDrmFileServerClient::Create( const TDesC& aFilename )
+    {
+    TInt r = KErrNone;
+
+    //LOGFNR( "RWmDrmFileServerClient::Create", r );
+    r = SendReceive( EFsCreate, TIpcArgs( &aFilename ) );
+    return r;
+    }
+
+EXPORT_C TInt RWmDrmFileServerClient::Read( TDes8& aBuffer )
+    {
+    TInt r = KErrNone;
+    TInt amountRead;
+    TPckg<TInt> amountPckg( amountRead );
+
+    //LOGFNR( "RWmDrmFileServerClient::Read", r );
+    r = SendReceive( EFsRead, TIpcArgs( &aBuffer, &amountPckg ) );
+    if ( r == KErrNone )
+        {
+        aBuffer.SetLength( amountRead );
+        }
+    return r;
+    }
+
+EXPORT_C TInt RWmDrmFileServerClient::Write( const TDesC8& aBuffer )
+    {
+    TInt r = KErrNone;
+
+    //LOGFNR( "RWmDrmFileServerClient::Write", r );
+    r = SendReceive( EFsWrite, TIpcArgs( &aBuffer ) );
+    return r;
+    }
+
+EXPORT_C TInt RWmDrmFileServerClient::Size( TInt& aSize )
+    {
+    TInt r = KErrNone;
+    TPckg<TInt> sizePckg( aSize );
+
+    //LOGFNR( "RWmDrmFileServerClient::Size", r );
+    r = SendReceive( EFsSize, TIpcArgs( &sizePckg ) );
+    return r;
+    }
+
+EXPORT_C TInt RWmDrmFileServerClient::Delete( const TDesC& aFilename )
+    {
+    TInt r = KErrNone;
+
+    //LOGFNR( "RWmDrmFileServerClient::Delete", r );
+    r = SendReceive( EFsDelete, TIpcArgs( &aFilename ) );
+    return r;
+    }
+
+EXPORT_C TBool RWmDrmFileServerClient::IsOpen()
+    {
+    TInt r = KErrNone;
+
+    //LOGFNR( "RWmDrmFileServerClient::IsOpen", r );
+    r = SendReceive( EFsIsOpen );
+    return (r == KErrNone ? ETrue : EFalse);
+    }
+
+EXPORT_C void RWmDrmFileServerClient::CloseFile()
+    {
+    //LOGFN( "RWmDrmFileServerClient::CloseFile" );
+    SendReceive( EFsCloseFile );
+    }
+
+EXPORT_C TInt RWmDrmFileServerClient::MkDirAll( const TDesC& aPath, TBool aCreateIfMissing )
+    {
+    TInt r = KErrNone;
+    
+    //LOGFNR( "RWmDrmFileServerClient::MkDirAll", r );
+    r = SendReceive( EFsMkDirAll, TIpcArgs( &aPath, aCreateIfMissing ) );
+    return r;
+    }
+
+EXPORT_C TInt RWmDrmFileServerClient::RmDirAll( const TDesC& aPath )
+    {
+    TInt r = KErrNone;
+    
+    //LOGFNR( "RWmDrmFileServerClient::RmDirAll", r );
+    r = SendReceive( EFsRmDirAll, TIpcArgs( &aPath ) );
+    return r;
+    }
+
+EXPORT_C TInt RWmDrmFileServerClient::RmDir( const TDesC& aPath )
+    {
+    TInt r = KErrNone;
+    
+    //LOGFNR( "RWmDrmFileServerClient::RmDir", r );
+    r = SendReceive( EFsRmDir, TIpcArgs( &aPath ) );
+    return r;
+    }
+
+EXPORT_C TInt RWmDrmFileServerClient::DeleteRights()
+    {
+    TInt r = KErrNone;
+    
+    //LOGFNR( "RWmDrmFileServerClient::DeleteRights", r );
+    r = SendReceive( EFsDeleteRights );
+    return r;
+    }
+
+EXPORT_C TInt RWmDrmFileServerClient::Connect()
+	{
+	TInt r = KErrNone;
+	
+	//LOGFNR( "RWmDrmFileServerClient::Connect", r );
+	TInt retry = KServerRetryCount;
+	for ( ;; )
+		{
+		r = CreateSession( KWmDrmFileServerName, TVersion( 0, 0, 0 ), KServerDefaultMessageSlots );
+		if ( r != KErrNotFound && r != KErrServerTerminated )
+		    {
+			return r;
+			}
+		if ( --retry == 0 )
+		    {
+			return r;
+			}
+		r = StartServer();
+		if ( r != KErrNone && r != KErrAlreadyExists )
+		    {
+			return r;
+			}
+		}
+	}
+
+
+EXPORT_C TInt RWmDrmFileServerClient::UpdateSecureTime( TTime& aHomeTime, TTime& aUTCTime )
+    {
+    TInt r = KErrNone;
+    TPckg<TTime> homeTime( aHomeTime );
+    TPckg<TTime> utcTime( aUTCTime );
+    
+    //LOGFNR( "RWmDrmFileServerClient::UpdateSecureTime", r );
+    r = SendReceive( EFsUpdateSecureTime, TIpcArgs( &homeTime, &utcTime ) );
+    return r;    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/server/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,20 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project WMDRM Fileserver
+*
+*/
+
+
+PRJ_MMPFILES
+wmdrmfileserver.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/server/group/wmdrmfileserver.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* 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:  Project definition file for project WMDRM Server
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          wmdrmfileserver.exe
+TARGETTYPE      EXE
+UID             0x1000008d 0x2000B180
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_SERVER AllFiles TCB
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../client/inc
+USERINCLUDE     ../../../../inc
+USERINCLUDE		../../../../../inc
+
+
+SOURCEPATH      ../src
+SOURCE          wmdrmfileserver.cpp
+SOURCE          wmdrmfileserversession.cpp
+
+LIBRARY         euser.lib
+//DEBUGLIBRARY	flogger.lib
+LIBRARY         efsrv.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/server/inc/wmdrmfileserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,78 @@
+/*
+* 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:  Server definitions
+*
+*/
+
+
+#ifndef __WMDRMFILESERVER_H
+#define __WMDRMFILESERVER_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include "wmdrmfileserver.h"
+#include "wmdrmfileserverclient.h"
+#include "wmdrmfsclientserver.h"
+
+// Max size of the filenames handled by this server
+const TInt KFileNameSize = 128;
+
+// Panic codes for session errors
+enum TWmDrmPanic
+	{
+	EPanicBadDescriptor,
+	EPanicIllegalFunction
+	};
+
+void PanicClient( const RMessagePtr2& aMessage,TWmDrmPanic TWmDrmPanic );
+
+class CWmDrmFileServer : public CServer2
+	{
+public:
+    /* Create a new file server object and push it onto the cleanup stack
+     */
+	static CServer2* NewLC();
+
+    /* Destructor.
+     */
+    ~CWmDrmFileServer();
+
+    /* Return a reference to the shared file server handle
+     *
+     * @return File server handle
+     */
+    RFs& Fs();
+
+private:
+    /* Private constructor.
+     */
+    CWmDrmFileServer();
+    
+    /* Second level constructor.
+     */
+	void ConstructL();
+
+    /* Create a new session
+     *
+     * @param aVersion  Client version
+     * @param aMessage  IPC message (ignored)
+     * @return new session object
+     */
+	CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const;
+
+    // Own: Common file server object
+	RFs iFs;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/server/inc/wmdrmfileserversession.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,155 @@
+/*
+* 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:  Server definitions
+*
+*/
+
+
+#ifndef __WMDRMFILESERVERSESSION_H
+#define __WMDRMFILESERVERSESSION_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include "wmdrmfileserver.h"
+
+class CWmDrmFileServerSession : public CSession2
+	{
+public:
+	CWmDrmFileServerSession();
+
+    /* Create a file
+     *
+     * @param aMessage  IPC message (file name)
+     * @return KErrNone if successful, KErrArgument if the file name is not valid,
+     *         KErrDiskFull if system drive doesn't have enough free space
+     */
+	TInt CreateL( const RMessage2& aMessage );
+
+    /* Open a file
+     *
+     * @param aMessage  IPC message (file name)
+     * @return  KErrNone if successful, KErrNotFound if the file does not exist,
+     *          KErrArgument if the file name is not valid
+     */
+    TInt OpenL( const RMessage2& aMessage );
+
+    /* Close a file
+     *
+     * @param aMessage  IPC message (not used)
+     * @return KErrNone
+     */
+    TInt CloseFileL( const RMessage2& aMessage );
+
+    /* Read the file content into a buffer
+     *
+     * @param aMessage  IPC message (output buffer)
+     * @return  KErrNone if successful, KErrNotReady if the file is not open,
+     *          KErrBadDescriptor if not enough space is available in the buffer.
+     */
+    TInt ReadL( const RMessage2& aMessage );
+
+    /* Write the file content into a buffer
+     *
+     * @param aMessage  IPC message (input buffer)
+     * @return  KErrNone if successful, KErrNotReady if the file is not open,
+     *          KErrDiskFull if system drive doesn't have enough free space
+     */
+    TInt WriteL( const RMessage2& aMessage );
+
+    /* Delete a file
+     *
+     * @param aMessage  IPC message (file name)
+     * @return  KErrNone if successful, KErrArgument if the file name is not valid
+     */
+    TInt DeleteL( const RMessage2& aMessage );
+
+    /* Return the size of a file
+     *
+     * @param aMessage  IPC message (output parameter for the size)
+     * @return KErrNone if successful, KErrNotReady if the file is not open
+     */
+    TInt SizeL( const RMessage2& aMessage );
+
+    /* Checks whether a file is open for this session
+     *
+     * @param aMessage  IPC message (not used)
+     * @return  ETrue if a file is open, EFalse otherwise
+     */
+    TInt IsOpenL( const RMessage2& aMessage );
+
+    /* Creates a full file path
+     *
+     * @param aMessage  IPC message (path, flag indicating whether the path should be
+     *                  created in case it doesn't exist)
+     * @return KErrNone if successful, KErrArgument if the file name is not valid
+     *         KErrDiskFull if system drive doesn't have enough free space
+     */
+    TInt MkDirAllL( const RMessage2& aMessage );
+
+    /* Remove a complete path including contents
+     *
+     * @param aMessage  IPC message (path to remove)
+     * @return  KErrNone if successful, KErrArgument if the file name is not valid
+     */
+    TInt RmDirAllL( const RMessage2& aMessage );
+
+    /* Remove a non-empty directory
+     *
+     * @param aMessage  IPC message (directory name)
+     * @return  KErrNone if successful, KErrArgument if the file name is not valid
+     */
+    TInt RmDirL( const RMessage2& aMessage );
+    
+    /* Update secure time on terminal
+     *
+     * @param aMessage  IPC message ( TTime, TTime )
+     * @return  KErrNone if successful
+     */
+    TInt UpdateSecureTimeL( const RMessage2& aMessage );
+
+    /* Delete all rights files
+     *
+     * @param aMessage Not used
+     * @return  KErrNone if successful
+     */
+    TInt DeleteRightsL( const RMessage2& aMessage );	
+    
+private:
+    /* Desctructor, closes the file
+     */
+	~CWmDrmFileServerSession();
+    
+    /* Returns a reference to the owning server
+     * @return  File server reference
+     */
+	inline CWmDrmFileServer& Server();
+
+    /* Main service function
+     *
+     * @param aMessage  IPC message
+     */
+	void ServiceL( const RMessage2& aMessage );
+    
+    /* Service error handling function, panics the client if necessary.
+     *
+     * @param aMessage  IPC message
+     * @param TInt      Error code to handle
+     */
+	void ServiceError( const RMessage2& aMessage, TInt aError );
+
+    // Handle to the currently opened file
+    RFile iFile;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/server/inc/wmdrmfsclientserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Common client server definitions
+*
+*/
+
+
+#ifndef __WMDRMFSCLIENTSERVER_H
+#define __WMDRMFSCLIENTSERVER_H
+
+#include <e32std.h>
+
+// List of all possible messages to the WMDRM file server
+enum TWmDrmFileServerMessages
+	{
+    EFsOpen,            // Open a file
+    EFsCreate,          // Create a file
+    EFsRead,            // Read the contents of an open file
+    EFsWrite,           // Replace the contents of an open file
+    EFsSize,            // Return the size of an open file
+    EFsDelete,          // Delete a file
+    EFsIsOpen,          // Check whether a file is open
+    EFsCloseFile,       // Close an open file
+    EFsMkDirAll,        // Conditionally create a full file path
+    EFsRmDirAll,        // Remove a full path including content
+    EFsRmDir,           // Remove a non-empty directory
+    EFsUpdateSecureTime,// Update the secure time
+    EFsDeleteRights     // Delete all rights
+	};
+
+#endif //  __WMDRMFSCLIENTSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/server/src/wmdrmfileserver.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  WMDRM File Server implementation
+*
+*/
+
+
+#include "wmdrmfileserversession.h"
+#include "wmdrmfileserver.h"
+
+//#define _LOGGING_FILE L"wmdrmfileserver.txt"
+
+//#include "flogger.h"
+//#include "logfn.h"
+
+CWmDrmFileServer::CWmDrmFileServer():
+	CServer2( CActive::EPriorityStandard,  ESharableSessions )
+	{
+	}
+
+CServer2* CWmDrmFileServer::NewLC()
+	{
+	//LOGFN( "CWmDrmFileServer::NewLC" );
+	CWmDrmFileServer* self = new( ELeave ) CWmDrmFileServer;
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	return self;
+	}
+
+CWmDrmFileServer::~CWmDrmFileServer()
+    {
+	//LOGFN( "CWmDrmFileServer::~CWmDrmFileServer" );
+    iFs.Close();
+    }
+
+void CWmDrmFileServer::ConstructL()
+	{
+	//LOGFN( "CWmDrmFileServer::ConstructL" );
+	StartL( KWmDrmFileServerName );
+	User::LeaveIfError( iFs.Connect() );
+	}
+
+CSession2* CWmDrmFileServer::NewSessionL(
+    const TVersion& /*aVersion*/,
+    const RMessage2& /*aMessage*/ ) const
+	{
+	//LOGFN( "CWmDrmFileServer::NewSessionL" );
+	return new( ELeave ) CWmDrmFileServerSession();
+	}
+
+RFs& CWmDrmFileServer::Fs()
+	{
+	return iFs;
+	}
+
+void PanicClient(
+    const RMessagePtr2& aMessage,
+    TWmDrmPanic aPanic )
+	{
+	//LOGFN( "PanicClient" );
+	_LIT( KPanic, "WmDrmServer" );
+	aMessage.Panic( KPanic, aPanic );
+	}
+
+static void RunServerL()
+	{
+	//LOGFN( "RunServerL" );
+
+	User::LeaveIfError( RThread::RenameMe( KWmDrmFileServerName ) );
+	CActiveScheduler* s = new( ELeave ) CActiveScheduler;
+	CleanupStack::PushL( s );
+	CActiveScheduler::Install( s );
+	CWmDrmFileServer::NewLC();
+	RProcess::Rendezvous( KErrNone );
+	CActiveScheduler::Start();
+	CleanupStack::PopAndDestroy( 2 ); // server, s
+	}
+
+TInt E32Main()
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	TInt r = KErrNoMemory;
+	if ( cleanup )
+		{
+		TRAP( r, RunServerL() );
+		delete cleanup;
+		}
+	__UHEAP_MARKEND;
+	return r;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmfileserver/server/src/wmdrmfileserversession.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,617 @@
+/*
+* 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:  WMDRM Server implementation
+*
+*/
+
+
+#include <f32file.h>
+#include <systemwarninglevels.hrh>
+#include "wmdrmfileserversession.h"
+#include "wmdrmfileserver.h"
+
+#define _LOGGING_FILE L"wmdrmfileserver.txt"
+
+// Due to TCB capability logging can not be used
+// #include "flogger.h"
+// #include "logfn.h"
+
+
+// rights server uid
+const TUint32 KRightsServer = 0x101F51F2;
+_LIT( KSecureStore, "securestore" );
+_LIT( KLicenseStore, "licstore" );
+_LIT( KDefaultNamespace, "hds");
+
+_LIT( KStorePathTemplate, "%c:\\sys\\private\\2000B180\\%S\\%S\\");
+
+// ======== LOCAL FUNCTIONS ========
+
+// Implmentation from securitycheckutil.cpp with some reductions
+
+LOCAL_C TBool CheckFileName(const TFileName& aFileName, TChar aSystemDriveChar)
+    {
+    
+    if (aFileName.Length() > KMaxFileName)
+            {
+            return EFalse;
+            }
+    
+    // Check for full drive and path
+    TChar drive(aFileName[0]);
+    
+    _LIT(KDriveSeparator, ":\\");
+    if (!drive.IsAlpha() || aFileName.Find(KDriveSeparator) != 1)
+            {
+            return EFalse;
+            }
+            
+    // Check for double slashes
+    _LIT(KDoubleSlash, "\\\\");
+    if (aFileName.Find(KDoubleSlash) != KErrNotFound)
+            {
+            return EFalse;
+            }
+    
+    // Check for .. in the path
+    _LIT(KDoubleDotPath, "..\\");
+    if (aFileName.Find(KDoubleDotPath) != KErrNotFound)
+            {
+            return EFalse;
+            }
+            
+    // Check for references to writable SwiCertstore
+    _LIT(KWritableSwiCertStore, ":\\Resource\\SwiCertstore");
+    TBuf<32> writableSwiCertStorePath;
+    writableSwiCertStorePath.Append(aSystemDriveChar);
+    writableSwiCertStorePath.Append(KWritableSwiCertStore);
+    
+    if (aFileName.FindF(writableSwiCertStorePath) != KErrNotFound)
+            {
+            return EFalse;
+            }
+    
+    return ETrue;
+    }
+
+
+
+LOCAL_C TBool IsSubstedDriveL(RFs& aFs, const TFileName& aFileName)
+    {
+    TChar drvCh = aFileName[0];
+    TInt drvNum;
+    User::LeaveIfError(RFs::CharToDrive(drvCh, drvNum));
+    TDriveInfo drvInfo;
+    User::LeaveIfError(aFs.Drive(drvInfo, drvNum));
+    //if the drive is subst'd return true
+    if(drvInfo.iDriveAtt & KDriveAttSubsted)
+        {
+        return ETrue;
+        }
+    return EFalse;  
+    }
+
+
+
+
+// ---------------------------------------------------------------------------
+// Create a safe filename which can be used under the WMDRM file server
+// root by filtering all illegal characters
+// ---------------------------------------------------------------------------
+//
+LOCAL_C void CreateSafeFileNameL( 
+    TFileName& aTarget, 
+    const TBuf<KFileNameSize>& aSource,
+    RFs &aFs )
+    {
+    TInt i;
+    TChar c;
+    TBool suffix = ETrue;
+    
+    TInt driveNumber( RFs::GetSystemDrive() );
+	TChar driveLetter;
+    User::LeaveIfError( RFs::DriveToChar( driveNumber, driveLetter ) );
+    
+	TFileName storeRootFile;
+	storeRootFile.Format( KStoreRoot, (TUint)driveLetter );
+    
+    if ( aSource.Length() + storeRootFile.Length() + 1 > aTarget.MaxLength() - aTarget.Length() )
+        {
+        User::Leave( KErrArgument );
+        }
+   
+    aTarget.Copy( storeRootFile );
+    aTarget.Append( '\\' );
+	for ( i = 0 ; i < aSource.Length(); i++ )
+	    {
+	    c = aSource[i];
+
+        // Change all non-alphanumeric characters to underscores,
+        // except for the colon separating the file suffix
+	    if ( !c.IsAlphaDigit() && !suffix )
+	        {
+	        c = '_';
+	        }
+        
+        // Once the suffix colon has been processed, replace all non-alphanumeric characters
+	    if ( suffix && c == '.' )
+            {
+            suffix = EFalse;
+            }
+	    aTarget.Append( c );
+	    }
+	    
+    if( IsSubstedDriveL( aFs, aTarget ) || !CheckFileName( aTarget, driveLetter ) )
+        {
+        User::Leave(KErrArgument);
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Extract the path components from a full filename
+// ---------------------------------------------------------------------------
+//
+LOCAL_C void GetPath( const TDesC& aFilename, TPtrC& aPath )
+    {
+    TInt i = aFilename.Length() - 1;
+    while ( i >= 0 && aFilename[i] != '\\' )
+        {
+        i--;
+        }
+    if ( aFilename[i] == '\\' )
+        {
+        i++;
+        }
+    return aPath.Set( aFilename.Left( i ) );
+    }
+
+// ---------------------------------------------------------------------------
+// Check if system drive has <= KDRIVECCRITICALTHRESHOLD free space and in 
+// that case leave with KErrDiskFull
+// ---------------------------------------------------------------------------
+//
+LOCAL_C void CheckFreeSpaceL( RFs &aFs, TInt aBytesToWrite )
+    {
+    TVolumeInfo info;
+    User::LeaveIfError( aFs.Volume( info, aFs.GetSystemDrive() ) );
+    if ( info.iFree - aBytesToWrite <= KDRIVECCRITICALTHRESHOLD )
+        {
+        User::Leave( KErrDiskFull );
+        }
+    }
+
+// ======== MEMBER FUNCTIONS ========
+
+CWmDrmFileServerSession::CWmDrmFileServerSession()
+	{
+    //LOGFN( "CWmDrmFileServerSession::CWmDrmFileServerSession" );
+	}
+	
+CWmDrmFileServerSession::~CWmDrmFileServerSession()
+	{
+	//LOGFN( "CWmDrmFileServerSession::~CWmDrmFileServerSession" );
+    iFile.Close();
+	}
+
+TInt CWmDrmFileServerSession::OpenL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TFileName path;
+    TBuf<KFileNameSize> fileName;
+    
+    //LOGFNR( "CWmDrmFileServerSession::OpenL", r );
+    __UHEAP_MARK;
+    if ( aMessage.GetDesLength( 0 ) > KFileNameSize )
+        {
+        User::Leave( KErrArgument );
+        }
+    iFile.Close();
+    aMessage.ReadL( 0, fileName );
+    CreateSafeFileNameL( path, fileName, Server().Fs() );
+    //LOG( path );
+    r = iFile.Open( Server().Fs(), path, EFileRead | EFileWrite );
+    __UHEAP_MARKEND;
+    return r;
+    }
+    
+TInt CWmDrmFileServerSession::CreateL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TFileName path;
+    TBuf<KFileNameSize> fileName;
+    TPtrC folders( NULL, 0 );
+    
+    //LOGFNR( "CWmDrmFileServerSession::CreateL", r );
+    __UHEAP_MARK;
+    if ( aMessage.GetDesLength( 0 ) > KFileNameSize )
+        {
+        User::Leave( KErrArgument );
+        }
+    iFile.Close();
+    aMessage.ReadL( 0, fileName );
+    //LOG( fileName );
+    CreateSafeFileNameL( path, fileName, Server().Fs() );
+    GetPath( path, folders ); 
+    
+    CheckFreeSpaceL( Server().Fs(), 0 );
+    
+    Server().Fs().MkDirAll( folders );
+    //LOG( path );
+    r = iFile.Replace( Server().Fs(), path, EFileRead | EFileWrite );
+    __UHEAP_MARKEND;
+    return r;
+    }
+    
+TInt CWmDrmFileServerSession::ReadL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    RBuf8 buf;
+    TInt amountRead = 0;
+    TInt pos = 0;
+    
+    //LOGFNR( "CWmDrmFileServerSession::ReadL", r );
+    __UHEAP_MARK;
+    if ( iFile.SubSessionHandle() == KNullHandle )
+        {
+        User::Leave( KErrNotReady );
+        }
+    
+    buf.CreateL( aMessage.GetDesMaxLengthL( 0 ) );
+    CleanupClosePushL( buf );
+    iFile.Seek( ESeekStart, pos );
+    r = iFile.Read( buf );
+    if ( r == KErrNone )
+        {
+        aMessage.WriteL( 0, buf );
+        amountRead = buf.Size();
+        }
+    aMessage.WriteL( 1, TPckg<TInt>( amountRead ) );
+    //LOG2( "Read %d bytes", amountRead );
+    CleanupStack::PopAndDestroy(); // buf
+    __UHEAP_MARKEND;
+    return r;
+    }
+    
+TInt CWmDrmFileServerSession::WriteL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    RBuf8 buf;
+    TInt pos = 0;
+    
+    //LOGFNR( "CWmDrmFileServerSession::WriteL", r );
+    __UHEAP_MARK;
+    if ( iFile.SubSessionHandle() == KNullHandle )
+        {
+        User::Leave( KErrNotReady );
+        }
+    
+    CheckFreeSpaceL( Server().Fs(), aMessage.GetDesLengthL( 0 ) );
+    
+    buf.CreateL( aMessage.GetDesLengthL( 0 ) );
+    CleanupClosePushL( buf );
+    aMessage.ReadL( 0, buf );
+    iFile.Seek( ESeekStart, pos );
+    iFile.SetSize( 0 );
+    r = iFile.Write( buf );
+    CleanupStack::PopAndDestroy(); // buf
+    __UHEAP_MARKEND;
+    return r;
+    }
+    
+TInt CWmDrmFileServerSession::SizeL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TInt size;
+    
+    //LOGFNR( "CWmDrmFileServerSession::SizeL", r );
+    __UHEAP_MARK;
+    if ( iFile.SubSessionHandle() == KNullHandle )
+        {
+        User::Leave( KErrNotReady );
+        }
+    r = iFile.Size( size );
+    if ( r == KErrNone )
+        {
+        aMessage.WriteL( 0, TPckg<TInt>( size ) );
+        }
+    __UHEAP_MARKEND;
+    return r;
+    }
+    
+TInt CWmDrmFileServerSession::IsOpenL( const RMessage2& /*aMessage*/ )
+    {
+    TInt r = KErrNone;
+    
+    //LOGFNR( "CWmDrmFileServerSession::IsOpenL", r );
+    if ( iFile.SubSessionHandle() == KNullHandle )
+        {
+        r = KErrNotReady;
+        }
+    return r;
+    }
+    
+TInt CWmDrmFileServerSession::CloseFileL( const RMessage2& /*aMessage*/ )
+    {
+    TInt r = KErrNone;
+    
+    //LOGFNR( "CWmDrmFileServerSession::CloseFileL", r );
+    iFile.Close();
+    return r;
+    }
+    
+TInt CWmDrmFileServerSession::DeleteL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TFileName path;
+    TBuf<KFileNameSize> fileName;
+    
+    //LOGFNR( "CWmDrmFileServerSession::DeleteL", r );
+    __UHEAP_MARK;
+    if ( aMessage.GetDesLength( 0 ) > KFileNameSize )
+        {
+        User::Leave( KErrArgument );
+        }
+    aMessage.ReadL( 0, fileName );
+    CreateSafeFileNameL( path, fileName, Server().Fs() );
+    r = Server().Fs().Delete( path );
+    //LOG( path );
+    __UHEAP_MARKEND;
+    return r;
+    }
+    
+TInt CWmDrmFileServerSession::MkDirAllL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TFileName path;
+    TBuf<KFileNameSize> fileName;
+    TUint att;
+    
+    //LOGFNR( "CWmDrmFileServerSession::MkDirAllL", r );
+    __UHEAP_MARK;
+    if ( aMessage.GetDesLength( 0 ) > KFileNameSize )
+        {
+        User::Leave( KErrArgument );
+        }
+    aMessage.ReadL( 0, fileName );
+    CreateSafeFileNameL( path, fileName, Server().Fs() );
+    //LOG( path );
+    if ( !aMessage.Int1() && ( r = Server().Fs().Att( path, att ) ) != KErrNone )
+        {
+        User::Leave( r );
+        }
+
+    CheckFreeSpaceL( Server().Fs(), 0 );
+    
+    r = Server().Fs().MkDirAll( path );
+    __UHEAP_MARKEND;
+    return r;
+    }
+
+TInt CWmDrmFileServerSession::RmDirAllL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TFileName path;
+    TBuf<KFileNameSize> fileName;
+    CFileMan* fileMan;
+    
+    //LOGFNR( "CWmDrmFileServerSession::RmDirAllL", r );
+    __UHEAP_MARK;
+    if ( aMessage.GetDesLength( 0 ) > KFileNameSize )
+        {
+        User::Leave( KErrArgument );
+        }
+    fileMan = CFileMan::NewL( Server().Fs() );
+    CleanupStack::PushL( fileMan );
+    aMessage.ReadL( 0, fileName );
+    CreateSafeFileNameL( path, fileName, Server().Fs() );
+    r = fileMan->RmDir( path );
+    //LOG( path );
+    CleanupStack::PopAndDestroy(); // fileMan
+    __UHEAP_MARKEND;
+    return r;
+    }
+
+TInt CWmDrmFileServerSession::RmDirL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TFileName path;
+    TBuf<KFileNameSize> fileName;
+    
+    //LOGFNR( "CWmDrmFileServerSession::RmDirL", r );
+    __UHEAP_MARK;
+    if ( aMessage.GetDesLength( 0 ) > KFileNameSize )
+        {
+        User::Leave( KErrArgument );
+        }
+    aMessage.ReadL( 0, fileName );
+    CreateSafeFileNameL( path, fileName, Server().Fs() );
+    r = Server().Fs().RmDir( path );
+    //LOG( path );
+    __UHEAP_MARKEND;
+    return r;
+    }
+
+
+TInt CWmDrmFileServerSession::UpdateSecureTimeL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TTime homeTime;
+    TTime utcTime;
+    RThread client;
+
+    TPckg<TTime> package( homeTime );
+    TPckg<TTime> package2( utcTime );
+   
+    // Get the client:
+    aMessage.ClientL( client );
+    CleanupClosePushL( client );
+        
+    // Check client, if client is not the rights server, access denied:
+    _LIT_SECURITY_POLICY_S0(swSidCheck2, KRightsServer);
+
+    if( !swSidCheck2().CheckPolicy(client) )
+        {
+        User::Leave( KErrAccessDenied );
+        }
+    
+    CleanupStack::PopAndDestroy( &client );
+    
+    aMessage.ReadL( 0, package );
+    aMessage.ReadL( 1, package2 );
+    
+    // Set the secure time:
+    User::LeaveIfError( User::SetUTCTimeSecure( utcTime ) );
+    //User::LeaveIfError( User::SetHomeTimeSecure( homeTime ) ); 
+       
+    return r;
+    }
+
+TInt CWmDrmFileServerSession::DeleteRightsL( const RMessage2& /*aMessage*/ )
+    {
+    TInt r = KErrNone;
+    TInt finalErr = KErrNone;
+	TFileName storeRootFile;
+	CFileMan* fileMan = NULL;
+    
+    //LOGFNR( "CWmDrmFileServerSession::DeleteRightsL", r );
+    __UHEAP_MARK;
+    fileMan = CFileMan::NewL( Server().Fs() );
+    CleanupStack::PushL( fileMan );
+    // Remove the stores:
+    TInt driveNumber( RFs::GetSystemDrive() );
+	TChar driveLetter;
+    User::LeaveIfError( RFs::DriveToChar( driveNumber, driveLetter ) );
+
+	storeRootFile.Format( KStorePathTemplate, (TUint)driveLetter, &KDefaultNamespace, &KLicenseStore );
+	//r = Server().Fs().RmDir( storeRootFile );    
+    r = fileMan->RmDir( storeRootFile );
+    if( r < KErrNone )
+        {
+        finalErr = r;
+        }
+
+	storeRootFile.Format( KStorePathTemplate, (TUint)driveLetter, &KDefaultNamespace, &KSecureStore );
+    //r = Server().Fs().RmDir( storeRootFile );
+    r = fileMan->RmDir( storeRootFile );     
+    if( !finalErr && r < KErrNone )
+        {
+        finalErr = r;
+        }
+    	
+    CleanupStack::PopAndDestroy( fileMan );    	
+    __UHEAP_MARKEND;
+    return finalErr;
+    }
+
+// ---------------------------------------------------------------------------
+// Main service function. All services require DRM capability!
+// ---------------------------------------------------------------------------
+//
+void CWmDrmFileServerSession::ServiceL( const RMessage2& aMessage )
+	{
+	TInt r = KErrNone;
+	TInt trap = KErrNone;
+	_LIT_SECURITY_POLICY_C1(drmCheck, ECapabilityDRM);
+    RThread client;
+	
+	//LOGFNR( "CWmDrmFileServerSession::ServiceL", r );
+#ifdef _LOGGING
+    TInt c;
+    TInt s;
+    c = User::AllocSize(s);
+    //LOG3( "Memory: %d cells, %d bytes allocated", c, s );
+#endif
+
+    aMessage.ClientL( client );
+    if ( !drmCheck().CheckPolicy( client ) )
+        {
+        r = KErrAccessDenied;
+        }
+    else
+        {
+        switch ( aMessage.Function() )
+            {
+            case EFsOpen:
+                TRAP( trap, r = OpenL( aMessage ) );
+                break;
+            case EFsCreate:
+                TRAP( trap, r = CreateL( aMessage ) );
+                break;
+            case EFsRead:
+                TRAP( trap, r = ReadL( aMessage ) );
+                break;
+            case EFsWrite:
+                TRAP( trap, r = WriteL( aMessage ) );
+                break;
+            case EFsSize:
+                TRAP( trap, r = SizeL( aMessage ) );
+                break;
+            case EFsDelete:
+                TRAP( trap, r = DeleteL( aMessage ) );
+                break;
+            case EFsIsOpen:
+                TRAP( trap, r = IsOpenL( aMessage ) );
+                break;
+            case EFsCloseFile:
+                TRAP( trap, r = CloseFileL( aMessage ) );
+                break;
+            case EFsMkDirAll:
+                TRAP( trap, r = MkDirAllL( aMessage ) );
+                break;
+            case EFsRmDirAll:
+                TRAP( trap, r = RmDirAllL( aMessage ) );
+                break;
+            case EFsRmDir:
+                TRAP( trap, r = RmDirL( aMessage ) );
+                break;
+            case EFsUpdateSecureTime:
+                TRAP( trap, r = UpdateSecureTimeL( aMessage ) );
+                break;                
+            case EFsDeleteRights:
+                TRAP( trap, r = DeleteRightsL( aMessage ) );
+                break;
+            default:
+                PanicClient( aMessage, EPanicIllegalFunction );
+                break;
+                }
+        if ( trap != KErrNone )
+            {
+            r = trap;
+            }
+        }
+    client.Close();    
+    if ( !aMessage.IsNull() )
+        {
+        aMessage.Complete( r );
+	    }
+    }
+
+void CWmDrmFileServerSession::ServiceError( const RMessage2& aMessage, TInt aError )
+	{
+	//LOGFN( "CWmDrmFileServerSession::ServiceError" );
+	//LOG2( "** Error: %d", aError );
+	if ( aError == KErrBadDescriptor )
+	    {
+		PanicClient( aMessage, EPanicBadDescriptor );
+		}
+	if ( !aMessage.IsNull() )
+        {
+        CSession2::ServiceError( aMessage, aError );
+	    }
+    }
+
+CWmDrmFileServer& CWmDrmFileServerSession::Server()
+	{
+	return *static_cast<CWmDrmFileServer*>( const_cast<CServer2*>( CSession2::Server() ) );
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmpd_dist/group/wmdrmpd_dist.mak	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,89 @@
+#
+# Check if the binaries exist
+#
+armv5_files = $(wildcard ../armv5/urel/*.dll)
+winscw_files = $(wildcard ../winscw/urel/*.dll)
+key_files = $(wildcard ../data/*.dat)
+
+.PHONY: create_dirs do_nothing clean_armv5 clean_winscw clean_keys MAKMAKE \
+	BLD SAVESPACE CLEAN FREEZE LIB CLEANLIB RESOURCE FINAL RELEASABLES
+#
+# empty action
+#
+do_nothing:
+	@rem do nothing
+
+create_dirs:
+	@perl -S emkdir.pl /epoc32/release/armv5/urel
+	@perl -S emkdir.pl /epoc32/release/armv5/udeb
+	@perl -S emkdir.pl /epoc32/release/winscw/urel
+	@perl -S emkdir.pl /epoc32/release/winscw/udeb
+	@perl -S emkdir.pl /epoc32/data/z/data
+	@perl -S emkdir.pl /epoc32/release/winscw/udeb/z/data
+
+clean_armv5:
+	@perl -S ermdir.pl /epoc32/release/armv5/urel/wmdrmpd.dll \
+	/epoc32/release/armv5/udeb/wmdrmpd.dll \
+	/epoc32/release/armv5/urel/wmdrmkeystorage.dll \
+	/epoc32/release/armv5/udeb/wmdrmkeystorage.dll
+
+clean_winscw:
+	@perl -S ermdir.pl /epoc32/release/winscw/urel/wmdrmpd.dll \
+	 /epoc32/release/winscw/udeb/wmdrmpd.dll
+
+clean_keys:
+	@perl -S ermdir.pl /epoc32/data/z/data/devcert.dat \
+	/epoc32/data/z/data/key.dat \
+	/epoc32/release/winscw/data/z/data/devcert.dat \
+	/epoc32/release/winscw/udeb/z/data/key.dat
+
+#
+# The targets invoked by bld...
+#
+
+MAKMAKE : do_nothing
+
+#
+# during abld bld, copy the binaries to the release dir, if they exist
+#
+BLD : create_dirs
+ifeq ($(armv5_files),)
+	@echo *** Using WMDRM ARMV5 stub
+else
+	@perl -S ecopyfile.pl ../armv5/urel/wmdrmpd.dll /epoc32/release/armv5/urel/wmdrmpd.dll
+	@perl -S ecopyfile.pl ../armv5/udeb/wmdrmpd.dll /epoc32/release/armv5/udeb/wmdrmpd.dll
+	@perl -S ecopyfile.pl ../armv5/urel/wmdrmkeystorage.dll /epoc32/release/armv5/urel/wmdrmkeystorage.dll
+	@perl -S ecopyfile.pl ../armv5/udeb/wmdrmkeystorage.dll /epoc32/release/armv5/udeb/wmdrmkeystorage.dll
+endif
+
+ifeq ($(winscw_files),)
+	@echo *** Using WMDRM WINSCW stub
+else
+	@perl -S ecopyfile.pl ../winscw/urel/wmdrmpd.dll /epoc32/release/winscw/urel/wmdrmpd.dll
+	@perl -S ecopyfile.pl ../winscw/udeb/wmdrmpd.dll /epoc32/release/winscw/udeb/wmdrmpd.dll
+endif
+
+ifeq ($(key_files),)
+	@echo *** Not using any device keys
+else
+	@perl -S ecopyfile.pl ../data/devcert.dat /epoc32/data/z/data/devcert.dat
+	@perl -S ecopyfile.pl ../data/priv.dat /epoc32/data/z/data/priv.dat
+	@perl -S ecopyfile.pl ../data/devcert.dat /epoc32/release/winscw/udeb/z/data/devcert.dat
+	@perl -S ecopyfile.pl ../data/priv.dat /epoc32/release/winscw/udeb/z/data/priv.dat
+endif
+
+SAVESPACE : BLD
+
+CLEAN : clean_armv5 clean_winscw clean_keys
+
+FREEZE : do_nothing
+
+LIB : do_nothing
+
+CLEANLIB : do_nothing
+
+RESOURCE : do_nothing
+
+FINAL : do_nothing
+
+RELEASABLES : do_nothing
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmpkserver/serverresources/data/wmdrmpkserver.rss	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,104 @@
+/*
+* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Resource definitions for project WMDRM PK Server
+*
+*/
+
+
+// RESOURCE IDENTIFIER
+NAME WDRM
+
+//  INCLUDES
+#include <eikon.rh>
+#include <eikon.rsg>
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.loc>
+#include <avkon.mbg>
+#include <drmsettingsplugin.loc>
+
+// RESOURCE DEFINITIONS
+RESOURCE RSS_SIGNATURE { }
+RESOURCE TBUF { buf=""; }
+
+// -----------------------------------------------------------------------------
+// r_drm_note_memory_low
+// 
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_note_memory_low
+    { 
+    buf = qtn_drm_note_memory_low;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_header_license_store_full
+//
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_header_license_store_full
+    { 
+    buf = qtn_drm_header_license_store_full;
+    }
+    
+// -----------------------------------------------------------------------------
+// r_drm_license_store_full
+//
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_license_store_full
+    { 
+    buf = qtn_drm_license_store_full;
+    }
+    
+// -----------------------------------------------------------------------------
+// r_drm_conf_not_out_of_space
+//
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_conf_not_out_of_space
+    { 
+    buf = qtn_drm_conf_not_out_of_space;
+    }
+
+// -----------------------------------------------------------------------------
+// qtn_drm_conf_license_deletion
+//
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_conf_license_deletion
+    { 
+    buf = qtn_drm_conf_license_deletion;
+    }
+    
+// -----------------------------------------------------------------------------
+// r_drm_licenses_deleted
+//
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_licenses_deleted
+    { 
+    buf = qtn_drm_licenses_deleted;
+    }    
+// -----------------------------------------------------------------------------
+// r_drm_license_deletion_prepare
+//
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_license_deletion_prepare
+    { 
+    buf = qtn_gen_note_processing;
+    }
+
+// -----------------------------------------------------------------------------
+// r_drm_license_deletion_wait
+//
+// -----------------------------------------------------------------------------
+RESOURCE TBUF r_drm_license_deletion_wait
+    { 
+    buf = qtn_fldr_deleting_wait_note;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmpkserver/serverresources/group/wmdrmpkserverresources.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,44 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project WMDRM PK Server
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          wmdrmpkserverresources.exe
+TARGETTYPE      EXE
+UID             0x1000008d 0x1028330A
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_SERVER
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc
+
+START RESOURCE ../data/wmdrmpkserver.rss
+HEADER
+TARGETPATH RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END  // RESOURCE
+
+SOURCEPATH      ../src
+SOURCE          wmdrmpkserverresources.cpp
+
+LIBRARY         euser.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmpkserver/serverresources/inc/wmdrmpkserverresources.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Server definitions
+*
+*/
+
+
+#ifndef __WMDRMPKSERVERRESOURCES_H
+#define __WMDRMPKSERVERRESOURCES_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include "wmdrmpkserverresources.h"
+
+_LIT( KWmDrmPkServerName, "!wmdrmpkserver.exe" );
+_LIT( KWmDrmPkServerImg, "wmdrmpkserver" );
+
+class CWmDrmPkServer : public CServer2
+	{
+public:
+	static CServer2* NewLC();
+	void Send( const TDesC& aMessage );
+	~CWmDrmPkServer();
+
+private:
+	CWmDrmPkServer();
+	void ConstructL();
+	CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const;
+private:
+	};
+
+class CWmDrmPkSession : public CSession2
+	{
+public:
+	CWmDrmPkSession();
+	void CreateL();
+	
+private:
+	~CWmDrmPkSession();
+	inline CWmDrmPkServer& Server();
+	void ServiceL(const RMessage2& aMessage);
+	void ServiceError(const RMessage2& aMessage, TInt aError);
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmpkserver/serverresources/src/wmdrmpkserverresources.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,112 @@
+/*
+* 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:  WMDRM PK Server implementation
+*
+*/
+
+#include "wmdrmpkserverresources.h"
+
+// ============================= LOCAL FUNCTIONS ==============================
+
+// ============================= MEMBER FUNCTIONS =============================
+
+void CWmDrmPkSession::CreateL()
+	{
+	}
+
+CWmDrmPkSession::CWmDrmPkSession()
+    {
+	}
+	
+CWmDrmPkSession::~CWmDrmPkSession()
+	{
+	}
+
+void CWmDrmPkSession::ServiceL( const RMessage2& aMessage )
+	{
+	TInt r = KErrNone;
+	
+    if ( !aMessage.IsNull() )
+        {
+        aMessage.Complete( r );
+	    }
+	}
+
+void CWmDrmPkSession::ServiceError( const RMessage2& aMessage, TInt aError )
+	{
+	if ( !aMessage.IsNull() )
+        {
+        CSession2::ServiceError( aMessage, aError );
+	    }
+	}
+
+CServer2* CWmDrmPkServer::NewLC()
+	{
+	CWmDrmPkServer* self = new( ELeave ) CWmDrmPkServer;
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	return self;
+	}
+
+CWmDrmPkServer::CWmDrmPkServer():
+	CServer2( CActive::EPriorityStandard,  ESharableSessions )
+    {
+    }
+
+CWmDrmPkServer::~CWmDrmPkServer()
+    {
+    }
+
+void CWmDrmPkServer::ConstructL()
+	{
+	StartL( KWmDrmPkServerName );
+	}
+
+CSession2* CWmDrmPkServer::NewSessionL(
+    const TVersion& /*aVersion*/,
+    const RMessage2& /*aMessage*/ ) const
+	{
+	return new( ELeave ) CWmDrmPkSession();
+	}
+
+CWmDrmPkServer& CWmDrmPkSession::Server()
+	{
+	return *static_cast<CWmDrmPkServer*>( const_cast<CServer2*>( CSession2::Server() ) );
+	}
+
+static void RunServerL()
+	{
+	User::LeaveIfError( RThread::RenameMe( KWmDrmPkServerName ) );
+	CActiveScheduler* s = new( ELeave ) CActiveScheduler;
+	CleanupStack::PushL( s );
+	CActiveScheduler::Install( s );
+	CWmDrmPkServer::NewLC();
+	RProcess::Rendezvous( KErrNone );
+	CActiveScheduler::Start();
+	CleanupStack::PopAndDestroy( 2 );
+	}
+
+TInt E32Main()
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	TInt r = KErrNoMemory;
+	if ( cleanup )
+		{
+		TRAP( r, RunServerL() );
+		delete cleanup;
+		}
+	__UHEAP_MARKEND;
+	return r;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/client/BWINS/wmdrmclientU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+EXPORTS
+	?Connect@RWmDrmClient@@QAEHXZ @ 1 NONAME ; int RWmDrmClient::Connect(void)
+	?EnumerateDeleteCurrent@RWmDrmClient@@QAEHXZ @ 2 NONAME ; int RWmDrmClient::EnumerateDeleteCurrent(void)
+	?EnumerateEnd@RWmDrmClient@@QAEHXZ @ 3 NONAME ; int RWmDrmClient::EnumerateEnd(void)
+	?EnumerateNext@RWmDrmClient@@QAEHAAVTDes8@@000@Z @ 4 NONAME ; int RWmDrmClient::EnumerateNext(class TDes8 &, class TDes8 &, class TDes8 &, class TDes8 &)
+	?EnumerateReload@RWmDrmClient@@QAEHAAVTDes8@@000@Z @ 5 NONAME ; int RWmDrmClient::EnumerateReload(class TDes8 &, class TDes8 &, class TDes8 &, class TDes8 &)
+	?EnumerateStart@RWmDrmClient@@QAEHABVTDesC8@@00@Z @ 6 NONAME ; int RWmDrmClient::EnumerateStart(class TDesC8 const &, class TDesC8 const &, class TDesC8 const &)
+	?InitNamespace@RWmDrmClient@@QAEHABVTDesC8@@0H@Z @ 7 NONAME ; int RWmDrmClient::InitNamespace(class TDesC8 const &, class TDesC8 const &, int)
+	?InitStore@RWmDrmClient@@QAEHABVTDesC8@@H@Z @ 8 NONAME ; int RWmDrmClient::InitStore(class TDesC8 const &, int)
+	?RemoveNamespace@RWmDrmClient@@QAEHABVTDesC8@@0@Z @ 9 NONAME ; int RWmDrmClient::RemoveNamespace(class TDesC8 const &, class TDesC8 const &)
+	?RemoveStore@RWmDrmClient@@QAEHABVTDesC8@@@Z @ 10 NONAME ; int RWmDrmClient::RemoveStore(class TDesC8 const &)
+	?SlotClose@RWmDrmClient@@QAEHXZ @ 11 NONAME ; int RWmDrmClient::SlotClose(void)
+	?SlotCreate@RWmDrmClient@@QAEHABVTDesC8@@000AAH@Z @ 12 NONAME ; int RWmDrmClient::SlotCreate(class TDesC8 const &, class TDesC8 const &, class TDesC8 const &, class TDesC8 const &, int &)
+	?SlotDelete@RWmDrmClient@@QAEHABVTDesC8@@000@Z @ 13 NONAME ; int RWmDrmClient::SlotDelete(class TDesC8 const &, class TDesC8 const &, class TDesC8 const &, class TDesC8 const &)
+	?SlotOpen@RWmDrmClient@@QAEHABVTDesC8@@000AAH@Z @ 14 NONAME ; int RWmDrmClient::SlotOpen(class TDesC8 const &, class TDesC8 const &, class TDesC8 const &, class TDesC8 const &, int &)
+	?SlotRead@RWmDrmClient@@QAEHAAVTDes8@@@Z @ 15 NONAME ; int RWmDrmClient::SlotRead(class TDes8 &)
+	?SlotResize@RWmDrmClient@@QAEHH@Z @ 16 NONAME ; int RWmDrmClient::SlotResize(int)
+	?SlotSeek@RWmDrmClient@@QAEHAAHW4TSeek@@@Z @ 17 NONAME ; int RWmDrmClient::SlotSeek(int &, enum TSeek)
+	?SlotWrite@RWmDrmClient@@QAEHABVTDesC8@@@Z @ 18 NONAME ; int RWmDrmClient::SlotWrite(class TDesC8 const &)
+	?EmptyCache@RWmDrmClient@@QAEHXZ @ 19 NONAME ; int RWmDrmClient::EmptyCache(void)
+	?LogStats@RWmDrmClient@@QAEHXZ @ 20 NONAME ; int RWmDrmClient::LogStats(void)
+	?TimeValid@RWmDrmClient@@QAEHXZ @ 21 NONAME ; int RWmDrmClient::TimeValid(void)
+	?SetTimeAsValid@RWmDrmClient@@QAEXH@Z @ 22 NONAME ; void RWmDrmClient::SetTimeAsValid(int)
+	?DeleteRights@RWmDrmClient@@QAEHXZ @ 23 NONAME ; int RWmDrmClient::DeleteRights(void)
+	?StoreState@RWmDrmClient@@QAEHAAW4TWmDrmStoreState@@@Z @ 24 NONAME ; int RWmDrmClient::StoreState(enum TWmDrmStoreState &)
+	?GetTime@RWmDrmClient@@QAEHAAVTTime@@AAH@Z @ 25 NONAME ; int RWmDrmClient::GetTime(class TTime &, int &)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/client/EABI/wmdrmclientU.DEF	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,27 @@
+EXPORTS
+	_ZN12RWmDrmClient10SlotCreateERK6TDesC8S2_S2_S2_Ri @ 1 NONAME
+	_ZN12RWmDrmClient10SlotDeleteERK6TDesC8S2_S2_S2_ @ 2 NONAME
+	_ZN12RWmDrmClient10SlotResizeEi @ 3 NONAME
+	_ZN12RWmDrmClient11RemoveStoreERK6TDesC8 @ 4 NONAME
+	_ZN12RWmDrmClient12EnumerateEndEv @ 5 NONAME
+	_ZN12RWmDrmClient13EnumerateNextER5TDes8S1_S1_S1_ @ 6 NONAME
+	_ZN12RWmDrmClient13InitNamespaceERK6TDesC8S2_i @ 7 NONAME
+	_ZN12RWmDrmClient14EnumerateStartERK6TDesC8S2_S2_ @ 8 NONAME
+	_ZN12RWmDrmClient15EnumerateReloadER5TDes8S1_S1_S1_ @ 9 NONAME
+	_ZN12RWmDrmClient15RemoveNamespaceERK6TDesC8S2_ @ 10 NONAME
+	_ZN12RWmDrmClient22EnumerateDeleteCurrentEv @ 11 NONAME
+	_ZN12RWmDrmClient7ConnectEv @ 12 NONAME
+	_ZN12RWmDrmClient8SlotOpenERK6TDesC8S2_S2_S2_Ri @ 13 NONAME
+	_ZN12RWmDrmClient8SlotReadER5TDes8 @ 14 NONAME
+	_ZN12RWmDrmClient8SlotSeekERi5TSeek @ 15 NONAME
+	_ZN12RWmDrmClient9InitStoreERK6TDesC8i @ 16 NONAME
+	_ZN12RWmDrmClient9SlotCloseEv @ 17 NONAME
+	_ZN12RWmDrmClient9SlotWriteERK6TDesC8 @ 18 NONAME
+	_ZN12RWmDrmClient10EmptyCacheEv @ 19 NONAME
+	_ZN12RWmDrmClient8LogStatsEv @ 20 NONAME
+	_ZN12RWmDrmClient9TimeValidEv @ 21 NONAME
+	_ZN12RWmDrmClient14SetTimeAsValidEi @ 22 NONAME
+	_ZN12RWmDrmClient12DeleteRightsEv @ 23 NONAME
+	_ZN12RWmDrmClient10StoreStateER16TWmDrmStoreState @ 24 NONAME
+	_ZN12RWmDrmClient7GetTimeER5TTimeRi @ 25 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/client/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,20 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project WMDRM Client
+*
+*/
+
+
+PRJ_MMPFILES
+wmdrmclient.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/client/group/wmdrmclient.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,44 @@
+/*
+* 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:  Project definition file for project WMDRM Client
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          wmdrmclient.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x10282F1D
+
+CAPABILITY      CAP_GENERAL_DLL
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   .
+USERINCLUDE     ../inc
+USERINCLUDE     ../../server/inc
+USERINCLUDE     ../../../wmdrmpd/inc
+USERINCLUDE     ../../../../inc
+USERINCLUDE     ../../../../../inc
+
+SOURCEPATH      ../src
+
+SOURCE          wmdrmclient.cpp
+
+LIBRARY         euser.lib
+LIBRARY         flogger.lib
+LIBRARY         efsrv.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/client/src/wmdrmclient.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,545 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  WMDRM Client implementation
+*
+*/
+
+
+#include "wmdrmclient.h"
+#include "wmdrmclientserver.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#ifdef _DEBUG
+#define DEBUGATTR( a ) a
+#else
+#define DEBUGATTR( a )
+#endif
+
+#include "logfn.h"
+
+// Constants
+
+const TInt KServerDefaultMessageSlots = -1;
+const TInt KServerRetryCount = 3;
+
+// ======== LOCAL FUNCTIONS ========
+
+
+//---------------------------------------------------------------------------
+// SetupSlotSpecL
+//---------------------------------------------------------------------------
+//
+LOCAL_C void SetupSlotSpecL(
+    RBuf8& aSlotSpec,
+    const TDesC8& aStoreName,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey )
+    {
+    aSlotSpec.CreateL( aStoreName.Length() + aNamespace.Length() + aHashKey.Length() + aUniqueKey.Length() + 4 );
+    aSlotSpec.Append( aStoreName.Length() );
+    aSlotSpec.Append( aStoreName );
+    aSlotSpec.Append( aNamespace.Length() ) ;
+    aSlotSpec.Append( aNamespace );
+    aSlotSpec.Append( aHashKey.Length() );
+    aSlotSpec.Append( aHashKey );
+    aSlotSpec.Append( aUniqueKey.Length() );
+    aSlotSpec.Append( aUniqueKey );
+    }
+
+//---------------------------------------------------------------------------
+// SetupSlotEnumSpecL
+//---------------------------------------------------------------------------
+//
+LOCAL_C void SetupSlotEnumSpecL(
+    RBuf8& aSlotSpec,
+    const TDesC8& aStoreName,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey )
+    {
+    aSlotSpec.CreateL( aStoreName.Length() + aNamespace.Length() + aHashKey.Length() + 3 );
+    aSlotSpec.Append( aStoreName.Length() );
+    aSlotSpec.Append( aStoreName );
+    aSlotSpec.Append( aNamespace.Length() ) ;
+    aSlotSpec.Append( aNamespace );
+    aSlotSpec.Append( aHashKey.Length() );
+    aSlotSpec.Append( aHashKey );
+    }
+
+//---------------------------------------------------------------------------
+// StartServer
+//---------------------------------------------------------------------------
+//
+static TInt StartServer()
+    {
+    RProcess server;
+    TInt r = server.Create( KWmDrmServerImg, KNullDesC );
+    if ( r != KErrNone )
+        return r;
+    TRequestStatus stat;
+    server.Rendezvous( stat );
+    if ( stat != KRequestPending )
+        {
+        server.Kill( 0 );
+        }
+    else
+        {
+        server.Resume();
+        }
+    User::WaitForRequest( stat );
+    r = ( server.ExitType() == EExitPanic ) ? KErrGeneral : stat.Int();
+    server.Close();
+    return r;
+    }
+
+// ======== MEMBER FUNCTIONS ========
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::Connect
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::Connect()
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::Connect", r );
+    TInt retry = KServerRetryCount;
+    for ( ;; )
+        {
+        r = CreateSession( KWmDrmServerName, TVersion( 0, 0, 0 ), KServerDefaultMessageSlots );
+        if ( r != KErrNotFound && r != KErrServerTerminated )
+            {
+            return r;
+            }
+        if ( --retry == 0 )
+            {
+            return r;
+            }
+        r = StartServer();
+        if ( r != KErrNone && r != KErrAlreadyExists )
+            {
+            return r;
+            }
+        }
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::InitStore
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::InitStore(
+    const TDesC8& DEBUGATTR( aStoreName ),
+    TBool /* aCreateIfMissing */ )
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::InitStore", r );
+    LOG( aStoreName );
+
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::RemoveStore
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::RemoveStore(
+    const TDesC8& aStoreName )
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::RemoveStore", r );
+    LOG( aStoreName );
+    r = SendReceive( ERemoveStore, TIpcArgs( &aStoreName ) );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::InitNamespace
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::InitNamespace(
+    const TDesC8& DEBUGATTR( aStoreName ),
+    const TDesC8& DEBUGATTR( aNamespace ),
+    TBool /* aCreateIfMissing */)
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::InitNamespace", r );
+    LOG( aStoreName ); LOG( aNamespace );
+
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::RemoveNamespace
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::RemoveNamespace(
+    const TDesC8& aStoreName,
+    const TDesC8& aNamespace )
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::RemoveNamespace", r );
+    r = SendReceive( ERemoveNamespace, TIpcArgs( &aStoreName, &aNamespace ) );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::SlotOpen
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::SlotOpen(
+    const TDesC8& aStoreName,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey,
+    TInt& aSize )
+    {
+    TInt r = KErrNone;
+    RBuf8 slotSpec;
+    TPckg<TInt> sizePckg( aSize );
+
+    LOGFNR( "RWmDrmClient::SlotOpen", r );
+    LOG( aStoreName ); LOG( aNamespace ); LOG( aHashKey ); LOG( aUniqueKey );
+    TRAP(r, SetupSlotSpecL( slotSpec, aStoreName, aNamespace, aHashKey, aUniqueKey ));
+    if( r )
+        {
+        slotSpec.Close();
+        return r;
+        }
+    r = SendReceive( ESlotOpen, TIpcArgs( &slotSpec, &sizePckg ) );
+    slotSpec.Close();
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::SlotCreate
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::SlotCreate(
+    const TDesC8& aStoreName,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey,
+    TInt& aSize )
+    {
+    TInt r = KErrNone;
+    RBuf8 slotSpec;
+
+    LOGFNR( "RWmDrmClient::SlotCreate", r );
+    LOG( aStoreName ); LOG( aNamespace ); LOG( aHashKey ); LOG( aUniqueKey );
+    TRAP( r, SetupSlotSpecL( slotSpec, aStoreName, aNamespace, aHashKey, aUniqueKey ));
+    if( r )
+        {
+        slotSpec.Close();
+        return r;
+        }    
+    r = SendReceive( ESlotCreate, TIpcArgs( &slotSpec, aSize ) );
+    slotSpec.Close();
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::SlotSeek
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::SlotSeek(
+    TInt& aPos,
+    TSeek aOrigin )
+    {
+    TInt r = KErrNone;
+    TInt newPos;
+    TPckg<TInt> posPckg( newPos );
+
+    LOGFNR( "RWmDrmClient::SlotSeek", r );
+    r = SendReceive( ESlotSeek, TIpcArgs( aPos, aOrigin, &posPckg ) );
+    aPos = newPos;
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::SlotRead
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::SlotRead(
+    TDes8& aData )
+    {
+    TInt r = KErrNone;
+    TInt amountRead;
+    TPckg<TInt> amountPckg( amountRead );
+
+    LOGFNR( "RWmDrmClient::SlotRead", r );
+    r = SendReceive( ESlotRead, TIpcArgs( &aData, &amountPckg ) );
+    if ( r == KErrNone )
+        {
+        aData.SetLength( amountRead );
+        }
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::SlotWrite
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::SlotWrite(
+    const TDesC8& aData )
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::SlotWrite", r );
+    r = SendReceive( ESlotWrite, TIpcArgs( &aData ) );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::SlotDelete
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::SlotDelete(
+    const TDesC8& aStoreName,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey )
+    {
+    TInt r = KErrNone;
+    RBuf8 slotSpec;
+
+    LOGFNR( "RWmDrmClient::SlotDelete", r );
+    TRAP(r, SetupSlotSpecL( slotSpec, aStoreName, aNamespace, aHashKey, aUniqueKey ));
+    if( r )
+        {
+        slotSpec.Close();
+        return r;
+        }
+    r = SendReceive( ESlotDelete, TIpcArgs( &slotSpec ) );
+    slotSpec.Close();
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::SlotResize
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::SlotResize(
+    TInt aSize )
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::SlotResize", r );
+    r = SendReceive( ESlotResize, TIpcArgs( aSize ) );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::SlotClose
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::SlotClose()
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::SlotClose", r );
+    r = SendReceive( ESlotClose );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::EnumerateStart
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::EnumerateStart(
+    const TDesC8& aStoreName,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey )
+    {
+    TInt r = KErrNone;
+    RBuf8 slotSpec;
+
+    LOGFNR( "RWmDrmClient::EnumerateStart", r );
+    TRAP(r, SetupSlotEnumSpecL( slotSpec, aStoreName, aNamespace, aHashKey ));
+    if( r )
+        {
+        slotSpec.Close();
+        return r;
+        }
+    r = SendReceive( EEnumerateStart, TIpcArgs( &slotSpec ) );
+    slotSpec.Close();
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::EnumerateReload
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::EnumerateReload(
+    TDes8& aStoreName,
+    TDes8& aNamespace,
+    TDes8& aHashKey,
+    TDes8& aUniqueKey )
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::EnumerateReload", r );
+    r = SendReceive( EEnumerateReload, TIpcArgs( &aStoreName, &aNamespace, &aHashKey, &aUniqueKey ) );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::EnumerateNext
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::EnumerateNext(
+    TDes8& aStoreName,
+    TDes8& aNamespace,
+    TDes8& aHashKey,
+    TDes8& aUniqueKey )
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::EnumerateNext", r );
+    r = SendReceive( EEnumerateNext, TIpcArgs( &aStoreName, &aNamespace, &aHashKey, &aUniqueKey ) );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::EnumerateDeleteCurrent
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::EnumerateDeleteCurrent()
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::EnumerateDelete", r );
+    r = SendReceive( EEnumerateDelete );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::EnumerateEnd
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::EnumerateEnd()
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::EnumerateEnd", r );
+    r = SendReceive( EEnumerateEnd );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::LogStats
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::LogStats()
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::LogStats", r );
+    r = SendReceive( ELogStats );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::EmptyCache
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::EmptyCache()
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::EmptyCache", r );
+    r = SendReceive( EEmptyCache );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::TimeValid
+//---------------------------------------------------------------------------
+//
+EXPORT_C TBool RWmDrmClient::TimeValid()
+    {
+    TBool r = EFalse;
+
+    LOGFN( "RWmDrmClient::TimeValid" );
+    if ( SendReceive( ETimeValid ) == KErrNone )
+        {
+        LOG1( "Time valid" );
+        r = ETrue;
+        }
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::SetTimeAsValid
+//---------------------------------------------------------------------------
+//
+EXPORT_C void  RWmDrmClient::SetTimeAsValid( TBool aValid )
+    {
+    TInt v = 0;
+
+    if ( aValid )
+        {
+        v = 1;
+        }
+    LOGFN( "RWmDrmClient::SetTimeAsValid" );
+    SendReceive( ESetTimeAsValid, TIpcArgs( v ) );
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::DeleteRights
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::DeleteRights()
+    {
+    TInt r = KErrNone;
+
+    LOGFNR( "RWmDrmClient::DeleteRights", r );
+    r = SendReceive( EDeleteRights );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::StoreState
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::StoreState( TWmDrmStoreState& aState )
+    {
+    TInt r = KErrNone;
+    TPckg<TWmDrmStoreState> statePckg( aState );
+
+    LOGFNR( "RWmDrmClient::StoreState", r );
+    r = SendReceive( EStoreState, TIpcArgs( &statePckg ) );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// RWmDrmClient::GetTime
+//---------------------------------------------------------------------------
+//
+EXPORT_C TInt RWmDrmClient::GetTime( TTime& aTime, TBool& aValid )
+    {
+    TInt r = KErrNone;
+    TPckg<TTime> timePckg( aTime );
+    TPckg<TBool> validPckg( aValid );
+    
+	LOGFNR( "RWmDrmClient::GetTime", r );    
+    r = SendReceive( EGetTime, TIpcArgs( &timePckg, &validPckg ) );
+    return r;    
+    };
+    
+    
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/clientwrapper/BWINS/wmdrmclientwrapperu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	?GateFunctionWmDrmClientWrapper@@YAPAXXZ @ 1 NONAME ; void * GateFunctionWmDrmClientWrapper(void)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/clientwrapper/EABI/wmdrmclientwrapperu.def	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,3 @@
+EXPORTS
+	_Z30GateFunctionWmDrmClientWrapperv @ 1 NONAME
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/clientwrapper/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,20 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project WMDRM Client
+*
+*/
+
+
+PRJ_MMPFILES
+wmdrmclientwrapper.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/clientwrapper/group/wmdrmclientwrapper.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,40 @@
+/*
+* 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:  Project definition file for project WMDRM Client
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          wmdrmclientwrapper.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x2000F8AD
+
+CAPABILITY      CAP_GENERAL_DLL
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   .
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../../../inc
+
+SOURCEPATH      ../src
+
+SOURCE          wmdrmclientwrapper.cpp
+
+LIBRARY         euser.lib
+LIBRARY         wmdrmclient.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/clientwrapper/src/wmdrmclientwrapper.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,103 @@
+/*
+* 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:  Dynamically loadable wrapper for Download manager
+*
+*/
+
+
+#include "WmDrmClientWrapper.h"
+
+// CONSTANTS
+
+// ======== LOCAL FUNCTIONS ========
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+CWmDrmClientWrapper::CWmDrmClientWrapper()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+void CWmDrmClientWrapper::ConstructL()
+    {
+    }
+
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+CWmDrmClientWrapper* CWmDrmClientWrapper::NewL()
+    {
+    CWmDrmClientWrapper* self = CWmDrmClientWrapper::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+CWmDrmClientWrapper* CWmDrmClientWrapper::NewLC()
+    {
+	CWmDrmClientWrapper* self = new( ELeave ) CWmDrmClientWrapper();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+CWmDrmClientWrapper::~CWmDrmClientWrapper()
+    {
+    iClient.Close();
+    }
+
+
+// ---------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmClientWrapper::Connect()
+    {
+    return iClient.Connect();
+    }
+
+
+
+// ======== GLOBAL FUNCTIONS ========
+
+//------------------------------------------------------------------------------
+// GateFunctionDRM
+// DRM gate function
+//------------------------------------------------------------------------------
+EXPORT_C TAny* GateFunctionWmDrmClientWrapper()
+	{
+	CWmDrmClientWrapper* launcher = NULL;
+	TRAPD( err, launcher = CWmDrmClientWrapper::NewL() );
+	if( err != KErrNone )
+	    {
+	    return NULL;
+	    }
+
+	return launcher;
+	}
+
Binary file wmdrm/wmdrmengine/wmdrmserver/server/data/10282F1B.exc has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/group/bld.inf	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,20 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Build information file for project WMDRM Server
+*
+*/
+
+
+PRJ_MMPFILES
+wmdrmserver.mmp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/group/wmdrmserver.mmp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,69 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Project definition file for project WMDRM Server
+*
+*/
+
+
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+
+TARGET          wmdrmserver.exe
+TARGETTYPE      EXE
+UID             0x1000008d 0x10282F1B
+VENDORID        VID_DEFAULT
+
+CAPABILITY      CAP_SERVER DRM AllFiles
+
+FEATUREVARIANT
+
+MW_LAYER_SYSTEMINCLUDE
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../../inc_dist
+USERINCLUDE     ../../client/inc
+USERINCLUDE     ../../../wmdrmfileserver/client/inc
+USERINCLUDE     ../../../../inc
+USERINCLUDE		../../../../../inc
+
+SOURCEPATH      ../src
+
+SOURCE          wmdrmserver.cpp
+SOURCE			clock.cpp
+SOURCE			slotdata.cpp
+SOURCE			slot.cpp
+SOURCE			enumeratordata.cpp
+SOURCE          enumerator.cpp
+SOURCE          namespaceenumerator.cpp
+SOURCE          slotenumerator.cpp
+SOURCE          slotdatacache.cpp
+SOURCE          slotenumeratorcache.cpp
+SOURCE          wmdrmsession.cpp
+SOURCE          wmdrmdatastore.cpp
+SOURCE          wmdrmdb.cpp
+
+LIBRARY         euser.lib
+LIBRARY         flogger.lib
+LIBRARY         efsrv.lib
+LIBRARY         random.lib
+LIBRARY         ezlib.lib
+LIBRARY         bafl.lib
+LIBRARY     	cryptography.lib
+LIBRARY         centralrepository.lib
+LIBRARY         wmdrmkeystorage.lib
+LIBRARY         sqldb.lib
+LIBRARY         wmdrmfileserverclient.lib
+LIBRARY         drmrightsstoringlocation.lib
+LIBRARY         platformenv.lib
+
+SMPSAFE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/clock.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,80 @@
+/*
+* 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:  Server definitions
+*
+*/
+
+
+#ifndef __CLOCK_H
+#define __CLOCK_H
+
+#include <e32base.h>
+#include <f32file.h>
+
+class CWmDrmServer;
+
+namespace DRM
+    {
+    class CDrmServiceApiWrapper;    
+    }
+
+
+class CClock : public CTimer
+	{
+public:
+	static const TInt KClockInterval = 15 * 60 * 1000000;
+
+    static CClock* CClock::NewL( CWmDrmServer* aServer );
+	~CClock();
+	CClock( CWmDrmServer* aServer );
+
+    void ConstructL();
+
+    void Start();
+
+    static TInt ChangeCallback( TAny* aClock );
+
+    void HandleChange();
+
+    TInt ReadTimeL();
+
+    TInt WriteTimeL();
+
+    void EvaluateCurrentTime();
+
+    TBool TimeIsGood();
+
+    void SetTimeAsGoodL( TBool aGood );
+    
+    void GetTimeL( TTime& aTime, TBool& aValid );
+
+protected:
+
+    void RunL();
+
+	CEnvironmentChangeNotifier* iChangeNotifier;
+	TTime iTime;
+	TBool iTimeIsGood;
+	CWmDrmServer* iServer;
+
+private:
+    TInt LoadServiceApi();
+    
+    TBool iServiceApiLoaded;
+	DRM::CDrmServiceApiWrapper* iServiceApi;
+	RLibrary iServiceApiLib;
+
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/enumerator.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,53 @@
+/*
+* 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:  Server definitions
+*
+*/
+
+
+#ifndef __ENUMERATOR_H
+#define __ENUMERATOR_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include "wmdrmserver.h"
+
+class CEnumerator: public CBase
+    {
+public:
+
+    static CEnumerator* NewL(
+        CWmDrmServer* aServer,
+        const TDesC8& aMessageBuffer );
+    
+    virtual ~CEnumerator();
+
+	virtual TInt OpenL();
+	virtual TInt NextL() = 0;
+	virtual void Close();
+
+    void GetHashKey( TDes8& aHashKey );
+
+    void GetUniqueKey( TDes8& aHashKey );
+
+    void DeleteCurrentL();
+
+    TBuf8<KMaxWmDrmStoreNameSize> iStore;
+    TBuf8<KMaxWmDrmNamespaceNameSize> iNamespace;
+    TBuf8<KWmDrmIdSize> iHashKey;
+    TBuf8<KWmDrmIdSize> iUniqueKey;
+    CWmDrmServer* iServer;
+    };
+    
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/enumeratordata.h	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Server definitions
+*
+*/
+
+
+#ifndef __ENUMERATORDATA_H
+#define __ENUMERATORDATA_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include "wmdrmserver.h"
+
+class CEnumeratorData: public CBase
+    {
+public:
+
+    static CEnumeratorData* NewL( 
+        CWmDrmServer* aServer, 
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey );
+
+    void ConstructL( 
+        CWmDrmServer* aServer, 
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey );
+
+    CEnumeratorData();
+    ~CEnumeratorData();
+
+    void Close();
+    
+	CWmDrmServer* iServer;
+	TInt iReferences;
+	TBuf8<KMaxWmDrmStoreNameSize> iStore;
+    TBuf8<KMaxWmDrmNamespaceNameSize> iNamespace;
+    TBuf8<KWmDrmIdSize> iHashKey;
+    RPointerArray<HBufC8> iEntries;
+    };
+    
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/namespaceenumerator.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,45 @@
+/*
+* 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:  Server definitions
+*
+*/
+
+
+#ifndef __NAMESPACEENUMERATOR_H
+#define __NAMESPACEENUMERATOR_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include "wmdrmserver.h"
+#include "enumerator.h"
+
+class CNameSpaceEnumerator: public CEnumerator
+    {
+public:
+
+    static CNameSpaceEnumerator* NewL(
+        CWmDrmServer* aServer,
+        const TDesC8& aStore,
+        const TDesC8& aNameSpace );
+
+    void ConstructL(
+        CWmDrmServer* aServer,
+        const TDesC8& aStore,
+        const TDesC8& aNameSpace );
+
+    TInt NextL();
+    
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/slot.h	Thu Dec 17 08:52:27 2009 +0200
@@ -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:  Server definitions
+*
+*/
+
+
+#ifndef __SLOT_H
+#define __SLOT_H
+
+#include <e32base.h>
+#include "wmdrmserver.h"
+
+class CWmDrmServer;
+class CEnumerator;
+class CSlotData;
+
+class CSlot: public CBase
+    {
+public:
+
+    static CSlot* NewL( CWmDrmServer* aServer, const TDesC8& aMessageBuffer );
+
+    static CSlot* NewL( CWmDrmServer* aServer, CEnumerator* aEnumerator );
+
+    void ConstructL( CWmDrmServer* aServer, const TDesC8& aMessageBuffer );
+
+    void ConstructL( CWmDrmServer* aServer, CEnumerator* aEnumerator );
+
+    ~CSlot();
+    
+    void CreateL( TInt& aInitialSize );
+
+    TInt OpenL( TInt& aCurrentSize );
+
+    TInt SeekL( TInt& aOffset, TSeek aOrigin );
+
+    TInt Read( TDes8& aBuffer );
+
+    TInt WriteL( const TDesC8& aBuffer );
+
+    TInt ResizeL( TInt aNewSize );
+
+    TInt DeleteL();
+
+    TInt Size();
+
+    void Close();
+    
+    TBuf8<KMaxWmDrmStoreNameSize> iStore;
+    TBuf8<KMaxWmDrmNamespaceNameSize> iNamespace;
+    TBuf8<KWmDrmIdSize> iHashKey;
+    TBuf8<KWmDrmIdSize> iUniqueKey;
+	CSlotData* iData;
+	TInt iDataPosition;
+	
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/slotdata.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,83 @@
+/*
+* 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:  Server definitions
+*
+*/
+
+
+#ifndef __SLOTDATA_H
+#define __SLOTDATA_H
+
+#include <e32base.h>
+#include "wmdrmserver.h"
+
+class CSlotData: public CBase
+    {
+public:
+
+    static CSlotData* NewL( 
+        CWmDrmServer* aServer, 
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey );
+    
+    CSlotData( 
+        CWmDrmServer* aServer, 
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey );
+    
+    ~CSlotData();
+
+
+    void CreateL( TInt& aInitialSize );
+
+    TInt OpenL( TInt& aCurrentSize );
+
+    TInt Read( TInt aPosition, TDes8& aBuffer );
+
+    TInt WriteL( TInt aPosition, const TDesC8& aBuffer );
+
+    TInt ResizeL( TInt aNewSize );
+
+    TInt DeleteL();
+
+    TInt Size();
+
+    void Close();
+
+    void CloseFile();
+
+    TBool IsOpen();
+
+    void FlushL();
+	
+	CWmDrmServer* iServer;
+	TBuf8<KMaxWmDrmStoreNameSize> iStore;
+    TBuf8<KMaxWmDrmNamespaceNameSize> iNamespace;
+    TBuf8<KWmDrmIdSize> iHashKey;
+    TBuf8<KWmDrmIdSize> iUniqueKey;
+	TBool iDirty;
+	TBool iExists;
+
+	// Is the file content read into the iData field and valid?
+    TBool iOpen;
+	
+	TInt iReferences;
+	RBuf8 iData;
+    };    
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/slotdatacache.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,64 @@
+/*
+* 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:  Server definitions
+*
+*/
+
+
+#ifndef __SLOTDATACACHE_H
+#define __SLOTDATACACHE_H
+
+#include <e32base.h>
+#include <f32file.h>
+
+class CWmDrmKeyStorage;
+class CWmDrmServer;
+class CSlotData;
+
+class CSlotDataCache: public CBase
+    {
+public:
+    
+    static CSlotDataCache* NewL( CWmDrmServer* aServer );
+
+    void ConstructL();
+    
+    CSlotDataCache( CWmDrmServer* aServer );
+    
+    ~CSlotDataCache();
+    
+
+    CSlotData* GetSlotDataL( 
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey );
+
+    void Claim( CSlotData* aData );
+
+    void Release( CSlotData* aData );
+
+    TInt Delete( CSlotData* aData );
+
+    void Cleanup();
+
+    void FlushL();
+    
+    TInt iMaxCachedSlots;
+	CWmDrmKeyStorage* iKeyStorage;    
+    RPointerArray<CSlotData> iSlotCache;
+    CWmDrmServer* iServer;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/slotenumerator.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,56 @@
+/*
+* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Server definitions
+*
+*/
+
+
+#ifndef __SLOTENUMERATOR_H
+#define __SLOTENUMERATOR_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include "wmdrmserver.h"
+#include "enumerator.h"
+
+class CEnumeratorData;
+
+class CSlotEnumerator: public CEnumerator
+    {
+public:
+
+    static CSlotEnumerator* NewL(
+        CWmDrmServer* aServer,
+        const TDesC8& aStore,
+        const TDesC8& aNameSpace,
+        const TDesC8& aHashKey );
+
+    void ConstructL(
+        CWmDrmServer* aServer,
+        const TDesC8& aStore,
+        const TDesC8& aNameSpace,
+        const TDesC8& aHashKey );
+
+    CSlotEnumerator();
+    ~CSlotEnumerator();
+
+    TInt OpenL();
+    TInt NextL();
+    void Close();
+
+    TInt iPosition;
+    CEnumeratorData* iEnumeratorData;
+    };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/slotenumeratorcache.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,68 @@
+/*
+* 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:  Declaration of the slot enumerator class
+*
+*/
+
+
+#ifndef __SLOTENUMERATORCACHE_H
+#define __SLOTENUMERATORCACHE_H
+
+#include <e32base.h>
+#include <f32file.h>
+
+class CEnumeratorData;
+class CWmDrmServer;
+
+class CSlotEnumeratorCache: public CBase
+    {
+public:
+    
+    static CSlotEnumeratorCache* NewL( CWmDrmServer* aServer );
+
+    void ConstructL();
+
+    CSlotEnumeratorCache( CWmDrmServer* aServer );
+
+    ~CSlotEnumeratorCache();
+
+    CEnumeratorData* GetEnumeratorDataL( 
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey );
+
+    void Claim( CEnumeratorData* aData );
+
+    void Release( CEnumeratorData* aData );
+
+    TInt AddEntryL( 
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey );
+
+    TInt DeleteEntryL( 
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey );
+
+    void Cleanup();
+        
+    TInt iMaxCachedEnumerators;
+    RPointerArray<CEnumeratorData> iEnumeratorCache;
+    CWmDrmServer* iServer;
+    };
+	
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/wmdrmclientserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  Common client server definitions
+*
+*/
+
+
+#ifndef __WMDRMCLIENTSERVER_H
+#define __WMDRMCLIENTSERVER_H
+
+#include <e32std.h>
+
+// Client/server messages
+enum TWmDrmMessages
+	{
+    EInitStore,
+    ERemoveStore,
+    EInitNamespace,
+    ERemoveNamespace,
+    ESlotOpen,
+    ESlotCreate,
+    ESlotSeek,
+    ESlotRead,
+    ESlotWrite,
+    ESlotDelete,
+    ESlotClose,
+    ESlotResize,
+    EEnumerateStart,
+    EEnumerateReload,
+    EEnumerateNext,
+    EEnumerateDelete,
+    EEnumerateEnd,
+    ELogStats,
+    EEmptyCache,
+    ETimeValid,
+    ESetTimeAsValid,
+    EDeleteRights,
+    EStoreState,
+    EGetTime
+	};
+
+#endif //  __WMDRMCLIENTSERVER_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/wmdrmdatastore.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,74 @@
+/*
+* 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:  WMDRM data store 
+*
+*/
+
+
+#ifndef CWMDRMDATASTORE_H
+#define CWMDRMDATASTORE_H
+
+#include <e32base.h>
+#include "wmdrmserver.h"
+
+class CWmDrmDataStore : public CBase
+    {
+    public:
+    
+        static CWmDrmDataStore* NewL( CWmDrmServer* aServer );
+        ~CWmDrmDataStore();
+        
+        TWmDrmStoreState DataStoreStateL();
+        
+        void UpdateDummyDbFileL( TInt aSize, TBool aConfiguredDrive );
+        TInt DummyDBSizeL( TBool aConfiguredDrive );
+        
+    private:
+
+        CWmDrmDataStore( CWmDrmServer* aServer );
+        void ConstructL();
+        
+        void ReadInitialFreeSpaceL( const TDesC& aFileName, TBool& aConfiguredDrive );
+        void WriteInitialFreeSpaceL( const TDesC& aFileName, TBool& aConfiguredDrive );
+        void InitializeDummyDbFileL( const TDesC& aFileName, RFile& aDummyDb, 
+        		TBool& aConfiguredDrive );
+        TInt DataStoreSizeL( TBool aConfiguredDrive );
+        void PrepareInfoFilesL( TBool aConfiguredDrive, TChar aDriveLetter, 
+			RFile& aDummyDb );
+        
+    private:    
+    
+        // Not owned
+        CWmDrmServer* iServer;
+        
+        // The file and variables ending with '2' are used only
+        // in the case when the WM DRM rights are stored to a
+        // configured drive other than the default system drive.  
+        RFile iDummyDb;
+        RFile iDummyDb2;
+        TInt64 iInitialFreeSpace; 
+        TInt64 iInitialFreeSpace2;
+        TInt64 iMinFreeSpace;
+        TInt64 iMinFreeSpace2;
+        TInt iMaxSpaceRatio;
+        TInt iMaxSpaceRatio2;
+        TInt iDummyDbInitialSize;
+        TInt iDummyDbInitialSize2;
+        
+        // Whether WM DRM rights are configured to be stored to an internal
+        // mass drive or not
+        TBool iWmDrmRightsConfigFound;    
+    };
+
+#endif // CWMDRMDATASTORE_H
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/wmdrmdb.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,180 @@
+/*
+* 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:  WMDRM database access interface
+*
+*/
+
+
+#ifndef C_WMDRMDB_H
+#define C_WMDRMDB_H
+
+#include <sqldb.h>
+#include "wmdrmserver.h"
+/**
+ *  Interface class to wmdrm database
+ *
+ *  @since S60 v3.2
+ */
+class CWmDrmDb : public CTimer
+    {
+public:
+
+    /** table type */
+    enum TWmDrmTableType
+        {
+        EWmDrmLicenseTable,
+        EWmDrmSecureTable,
+        EWmDrmSyncTable,
+        EWmDrmMeteringTable
+        };
+        
+    static CWmDrmDb* NewL( CWmDrmServer* aServer );
+    static CWmDrmDb* NewLC( CWmDrmServer* aServer );
+
+    virtual ~CWmDrmDb();
+
+    void InitStoreL( 
+        const TDesC8& aStore,
+        TBool aCreateIfMissing );
+    
+    void InitNameSpaceL( 
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        TBool aCreateIfMissing );
+
+    void RemoveStoreL( const TDesC8& aStore );
+
+    void RemoveNameSpaceL( 
+        const TDesC8& aStore,
+        const TDesC8& aNamespace );
+    
+    void DeleteLicenseStoreL();
+
+    void CreateRecordL(  
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey,
+        const TInt&   aSize );
+
+    void ReadRecordL( 
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey );
+
+    void GetDataSizeL( TInt& aDataSize );
+
+    void DeleteData();
+
+    void DeleteRecordL(  
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey );
+
+    void ReadDataL( TDes8& aData );
+
+    void WriteDataL(  
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        const TDesC8& aUniqueKey, 
+        TDesC8& aData );
+    
+    void EnumerateDataL(  
+        const TDesC8& aStore,
+        const TDesC8& aNamespace,
+        const TDesC8& aHashKey,
+        RPointerArray<HBufC8>& aUniqueKeyEntries );
+    
+    void EnumerateNameSpaceStartL(  
+        const TDesC8& aStore,
+        const TDesC8& aNamespace );
+    
+    void EnumerateNameSpaceNextL(  
+        TBuf8<KWmDrmIdSize>& aHashKey,
+        TBuf8<KWmDrmIdSize>& aUniqueKey );
+
+    TInt DataBaseSize( TBool aConfiguredDrive );
+
+
+protected: // from base class CActive
+    void RunL();
+    TInt RunError( TInt aError );
+
+private: // from base class CActive
+
+private:
+    CWmDrmDb( CWmDrmServer* aServer );
+    void ConstructL();
+    
+    void CreateDatabaseL( TFileName& aFileNamePath, RSqlDatabase& aDatabase, TBool aConfiguredDrive );
+    void CreateTableL( TWmDrmTableType aTableType, RSqlDatabase& aDatabase );
+    void DeleteTableL( TWmDrmTableType aTableType );
+    void SelectNRecordsWithRowIdL( TWmDrmTableType aTableType, TInt aNumber, RArray<TInt64>& aArray );
+    void DeleteRecordsWithRowIdsL( TWmDrmTableType aTableType, RArray<TInt64>& aArray );
+    void DropTableL( TWmDrmTableType aTableType );
+    TWmDrmTableType TableTypeL( const TDesC8& aNamespace );
+    void OpenDatabaseL( TFileName& aFileNamePath, RSqlDatabase& aDatabase, TBool aConfiguredDrive );
+    
+    void ConvertOldLicenseStoreL();
+    
+    // Checks how many SQL statements are prepared (buffered) currently and if either the maximum 
+    // amount of buffered statements is exceeded or an enforced commit is needed, COMMITs the 
+    // statements. The method also starts a new BEGIN statement after the commit operation to 
+    // start a new buffering round of SQL statements. This method also controls a timer for 
+    // triggering enforced commit after a predefined idle period without any prepared SQL statements. 
+    void CheckDatabaseCommitL( TBool aEnforcedCommit );
+    void Activate();
+
+private: // data
+
+    // Not owned
+    CWmDrmServer* iServer;
+    
+    // Located in the system drive
+    RSqlDatabase    iDatabase;
+    // Located in the configured drive (internal mass drive)
+    RSqlDatabase    iDatabase2;
+
+    HBufC8* iData;
+    
+    RSqlStatement iEnumerateNamespaceStmt;
+    TInt iEnumerateNamespaceHashKeyColumnIndex;
+    TInt iEnumerateNamespaceUniqueKeyColumnIndex;
+    TBool iEnumerateNamespaceStarted;
+    
+    // Path in the system drive for the data base
+    TFileName iDatabasePath;
+    // Path in the internal mass drive (configured drive)
+    TFileName iDatabasePath2;
+    
+    // Whether WM DRM rights storing location is found to be
+    // configured to the internal mass drive or not
+    TBool iWmDrmRightsConfigFound;
+    
+    // Amount of cached database import, update or delete operations that will be committed
+    // to the database when certain conditions are met.
+    TInt iAmountOperationsWithoutCommit;
+    
+    // When the flag is on, an SQL BEGIN statement has been issued, but not committed 
+    // with COMMIT statement. The first one is for the database on the system drive and the 
+    // second one is for the database on the configured drive. 
+    TBool iSqlTransactionOngoing;
+    TBool iSqlTransactionOngoing2;
+    
+    };
+
+#endif // ? C_CLASSNAME_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/wmdrmserver.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,174 @@
+/*
+* 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:  Server definitions
+*
+*/
+
+
+#ifndef __WMDRMSERVER_H
+#define __WMDRMSERVER_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include "wmdrmclient.h"
+#include "wmdrmclientserver.h"
+
+class CSlotDataCache;
+class CSlotEnumeratorCache;
+class CClock;
+class CWmDrmDataStore;
+class CWmDrmDb;
+
+// Max length of the slot name
+const TInt KMaxSlotNameSize = KMaxWmDrmStoreNameSize + KMaxWmDrmNamespaceNameSize + 2 * KWmDrmIdSize + 4 * sizeof( TInt );
+
+// Length of the AES key (128 bits)
+const TInt KAESKeyLength = 16;
+
+// Max number of cached enumerators
+const TInt KDefaultMaxCachedEnumerators = 16;
+
+// Max number of cached slots
+const TInt KDefaultMaxCachedSlots = 16;
+
+// Max size of the data in a slot
+const TInt KMaxSlotSize = 64 * 1024;
+
+// Private directory of the WMDRM server
+_LIT( KPrivateDir, "%c:\\private\\10282F1B\\" );
+
+// Filename for the last-known-good time
+_LIT( KTimeSaverFile, "%c:\\private\\10282F1B\\clock.dat" );
+
+// Filename for the initial free space
+_LIT( KInitialFreeSpaceFile, "%c:\\private\\10282F1B\\freespace.dat" );
+
+// Filename for the dummy db file
+_LIT( KDummyDbFile, "%c:\\private\\10282F1B\\dummydb.dat" );
+
+// Default store, sometimes the porting kit does not pass a store name,
+// this is used instead.
+_LIT( KDefaultStore, "hds" );
+
+/* WMDRM Server class, implements slot and namespace access functionality
+ */
+class CWmDrmServer : public CServer2
+	{
+public:
+    /* Create a server object and pushes it onto the cleanup stack.
+     *
+     * @return Server object
+     */
+	static CServer2* NewLC();
+
+    /* Destructor.
+     */
+	~CWmDrmServer();
+
+
+    /* Returns the slot cache object.
+     *
+     * @return Slot cache
+     */
+    CSlotDataCache* Cache();
+
+    /* Returns the enumerator cache object.
+     *
+     * @return Enumerator cache
+     */
+    CSlotEnumeratorCache* EnumeratorCache();
+
+    /* Returns the anti-rollback clock object.
+     *
+     * @return Clock object
+     */
+    CClock* Clock();
+
+    /* Returns a shared file server reference.
+     *
+     * @return Shared file server
+     */
+    RFs& Fs();
+    
+    /* Returns the data store object.
+     *
+     * @return Data store object
+     */
+    CWmDrmDataStore* DataStore();
+    
+    /* Returns the database object.
+     *
+     * @return Database object
+     */
+    CWmDrmDb* Db();
+    
+    /* Flushes and empties the slot and enumerator caches.
+     */
+    void ResetCacheL();
+
+    /* Returns the amount of free space either on the system 
+     * drive or the configured drive for WM DRM rights storage
+     * @return Amount of free space on system drive
+     */
+    TInt64 FreeSpaceL( TBool aConfiguredDrive );
+
+private:
+
+    /* Private constructor.
+     */
+	CWmDrmServer();
+
+    /* Second phase constructor.
+     */
+	void ConstructL();
+
+    /* Creates a new session.
+     *
+     * @param aVersion  Client version
+     * @param aMessage  IPC message
+     * @return New session
+     */
+	CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const;
+
+    // Own: Slot cache
+	CSlotDataCache* iCache;
+    
+    // Own: Enumerator cache
+	CSlotEnumeratorCache* iEnumeratorCache;
+    
+    // Own: Anti-rollback clock
+	CClock* iClock;
+    
+    // Own: File server
+	RFs iFs;
+	
+	// Own: Data store
+	CWmDrmDataStore* iDataStore;
+	
+	// Own: Database
+	CWmDrmDb* iDb;
+	
+	// Drive number for the drive to be used as a storage of WMDRM rights
+	TInt iDriveNumber;
+	
+	// Default system drive number
+	TInt iSystemDriveNumber;
+	
+	// Whether WM DRM rights are configured to be (partly) stored to an internal
+	// drive
+	TBool iWmDrmRightsConfigFound;
+	
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/inc/wmdrmsession.h	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,258 @@
+/*
+* 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:  Declaration of the WMDRM Server Session class
+*
+*/
+
+
+#ifndef __WMDRMSESSION_H
+#define __WMDRMSESSION_H
+
+#include <e32base.h>
+#include <f32file.h>
+#include "wmdrmserver.h"
+
+class CSlot;
+class CEnumerator;
+
+/* Session class for the WMDRM server, implements slot and namespace
+ * access functionality.
+ */
+class CWmDrmSession : public CSession2
+	{
+public:
+	CWmDrmSession();
+
+    /* Initialize a store via a given store name. If the store creation
+     * flag is set, the store is created when missing, otherwise an
+     * error is returned.
+     *
+     * @param aMessage  IPC message (store name, store creation flag)
+     * @return  KErrArgument for incorrect input data, KErrNotFound if
+     *          the store is missing and the store creation flag is not
+     *          set, KErrDiskFull if system drive doesn't have enough 
+     *          free space, KErrNone if successful
+     */
+    TInt InitStoreL( const RMessage2& aMessage );
+
+    /* Removes a named store with all its contents.
+     *
+     * @param aMessage  IPC message (store name)
+     * @return  KErrArgument for incorrect input data, CFileMan error
+     *          codes, KErrNone if successful
+     */
+    TInt RemoveStoreL( const RMessage2& aMessage );
+
+    /* Initialize a namespace via a given namespace name. If the
+     * namespace creation flag is set, the namespace is created when missing,
+     * otherwise an error is returned.
+     *
+     * @param aMessage  IPC message (namespace name, namespace creation flag)
+     * @return  KErrArgument for incorrect input data, KErrNotFound if
+     *          the namespace is missing and the namespace creation flag is not
+     *          set, KErrDiskFull if system drive doesn't have enough free
+     *          space, KErrNone if successful
+     */
+    TInt InitNamespaceL( const RMessage2& aMessage );
+
+    /* Removes a namespace will all its contents.
+     *
+     * @param aMessage  IPC message (store name, namespace name)
+     * @return  KErrArgument for incorrect input data, CFileMan error
+     *          codes, KErrNone if successful
+     */
+    TInt RemoveNamespaceL( const RMessage2& aMessage );
+        
+
+    /* Opens a slot via its full name (store, namespace, slot hash and key ID). 
+     *
+     * @param aMessage  IPC message (all slot name components)
+     * @return  KErrArgument for incorrect input data, KErrNotFound if the slot
+     *          does not exist, KErrNone if successful
+     */
+    TInt SlotOpenL( const RMessage2& aMessage );
+
+    /* Creates a slot via a full slot name and a given initial size.
+     *
+     * @param aMessage  IPC message (all slot name components)
+     * @return  KErrArgument for incorrect input data, KErrDiskFull if system
+     *          drive doesn't have enough free space, KErrNone if successful
+     */
+    TInt SlotCreateL( const RMessage2& aMessage );
+
+    /* Seeks within an opened slot.
+     *
+     * @param aMessage  IPC message (seek starting point, seek offset)
+     * @return  KErrArgument for incorrect input data, KErrNotReady if the
+     *          slot is not open, KErrNone if successful
+     */
+    TInt SlotSeekL( const RMessage2& aMessage );
+
+    /* Read data from an opened slot.
+     *
+     * @param aMessage  IPC message (data buffer)
+     * @return  KErrNotReady if the slot is not open, KErrNone if successful
+     */
+    TInt SlotReadL( const RMessage2& aMessage );
+
+    /* Write data to an opened slot.
+     *
+     * @param aMessage  IPC message (data buffer)
+     * @return  KErrNotReady if the slot is not open, KErrDiskFull if system
+     *          drive doesn't have enough free space, KErrNone if successful
+     */
+    TInt SlotWriteL( const RMessage2& aMessage );
+
+    /* Changes the size of a slot, truncating it if necessary
+     *
+     * @param aMessage  IPC message (new size)
+     * @return  KErrNotReady if the slot is not open, KErrNone if successful
+     */
+    TInt SlotResizeL( const RMessage2& aMessage );
+
+    /* Removes a slot via its full name.
+     *
+     * @param aMessage  IPC message (all slot name components)
+     * @return  KErrArgument for incorrect input data, KErrNone if successful
+     */
+    TInt SlotDeleteL( const RMessage2& aMessage );
+
+    /* Closes an opened slot.
+     *
+     * @param aMessage  IPC message (not used)
+     * @return  KErrNotReady if the slot is not open, otherwise KErrNone
+     */
+    TInt SlotCloseL( const RMessage2& aMessage );
+        
+
+    /* Initiate enumeration over a namespace or slot.
+     *
+     * @param aMessage  IPC message (namespace and/or slot information)
+     * @return  KErrArgument for incorrect input data, KErrNone if successful
+     */
+    TInt EnumerateStartL( const RMessage2& aMessage );
+
+    /* Reload the current slot information to the current
+     * enumerator.
+     *
+     * @param aMessage  IPC message (not used)
+     * @return  KErrNotReady if the enumeration has not started,
+     *          otherwise KErrNone
+     */
+    TInt EnumerateReloadL( const RMessage2& aMessage );
+
+    /* Moves the enumerator to the next slot and updates the slot
+     * information.
+     *
+     * @param aMessage  IPC message (not used)
+     * @return  KErrNotReady if the enumeration has not started, KErrNotFound
+     *          if the enumerator has reached the end, otherwise KErrNone
+     */
+    TInt EnumerateNextL( const RMessage2& aMessage );
+
+    /* Delete the currently enumerated slot.
+     *
+     * @param aMessage  IPC message (full slot information)
+     * @return  KErrNotReady if the enumeration has not started,
+     *          otherwise KErrNone
+     */
+    TInt EnumerateDeleteL( const RMessage2& aMessage );
+
+    /* End the current enumeration.
+     *
+     * @param aMessage  IPC message (not used)
+     * @return  KErrNotReady if the enumeration has not started,
+     *          otherwise KErrNone
+     */
+    TInt EnumerateEndL( const RMessage2& aMessage );
+    
+
+    /* Empties the slot and enumerator caches.
+     *
+     * @param aMessage  IPC message (not used)
+     * @return KErrNone
+     */
+    TInt EmptyCacheL( const RMessage2& aMessage );
+
+    /* Log server statistics.
+     *
+     * @param aMessage  IPC message (not used)
+     * @return KErrNone
+     */
+    TInt LogStats( const RMessage2& aMessage );
+
+    /* Check whether the current time is anti-rollback secure
+     *
+     * @param aMessage  IPC message (not used)
+     * @return KErrNone if the time is secure.
+     */
+    TInt TimeValid( const RMessage2& aMessage );
+
+    /* Sets the current device time as secure
+     *
+     * @param aMessage  IPC message (not used)
+     */
+    void SetTimeAsValidL( const RMessage2& aMessage );
+
+
+    /* Deletes rights from the stores
+     *
+     * @param aMessage  IPC message (not used)
+     */
+    TInt DeleteRightsL( const RMessage2& aMessage );
+    
+    /* Gets store state 
+     *
+     * @param aMessage  IPC message (store state)
+     */
+    void StoreStateL( const RMessage2& aMessage );
+    
+    /* Gets the drm time and validity
+     *
+     * @param aMessage  IPC message (time, validity)
+     */
+    void GetTimeL( const RMessage2& aMessage );    
+    
+private:
+    /* Desctructor.
+     */
+	~CWmDrmSession();
+
+    /* Returns a reference to the associated server object
+     *
+     * @return Reference to the server
+     */
+	inline CWmDrmServer& Server();
+
+    /* Service dispatch function
+     *
+     * @param aMessage  IPC message
+     */
+	void ServiceL(const RMessage2& aMessage);
+
+    /* Service error handler function
+     *
+     * @param aMessage  IPC message
+     * @param aError    Error code
+     */
+	void ServiceError(const RMessage2& aMessage, TInt aError);
+	
+	// Own: reference to the currently opened slot
+	CSlot* iSlot;
+    
+    // Own: reference to the currently active enumerator
+	CEnumerator* iEnumerator;
+	};
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/clock.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,452 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  WMDRM Server implementation
+*
+*/
+
+
+#include <ezlib.h>
+#include <e32math.h>
+#include <symmetric.h>
+#include <bacntf.h>
+
+#include "wmdrmkeystorage.h"
+#include "slotdatacache.h"
+#include "clock.h"
+#include "wmdrmserver.h"
+#include "drmserviceapiwrapper.h"
+#include "drmrightsstoringlocation.h"
+#include "drmutilityinternaltypes.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+
+// Constants
+
+#if defined(FF_PLATFORM_SIMULATOR) || defined(__WINSCW__)
+_LIT8( KDummyKey, "0123456789012345" );
+#endif
+
+_LIT(KDrmServiceApiWrapperName, "drmserviceapiwrapper.dll");
+static const TInt KDrmServiceApiWrapperGateOrdinal = 1;
+
+//---------------------------------------------------------------------------
+// CClock::NewL
+// Second phase constructor
+//---------------------------------------------------------------------------
+//
+CClock* CClock::NewL( CWmDrmServer* aServer )
+    {
+	LOGFN( "CClock::NewL" );
+    CClock* self = new (ELeave) CClock( aServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+//---------------------------------------------------------------------------
+// CClock::CClock
+// Constructor
+//---------------------------------------------------------------------------
+//
+CClock::CClock( CWmDrmServer* aServer ):
+    CTimer( -1 ),
+    iTimeIsGood( EFalse ),
+    iServer( aServer ),
+    iServiceApiLoaded( EFalse ),
+    iServiceApi( NULL )
+	{
+	CActiveScheduler::Add( this );
+	}
+
+//---------------------------------------------------------------------------
+// CClock::~CClock
+// Destructor
+//---------------------------------------------------------------------------
+//
+CClock::~CClock()
+    {
+    delete iChangeNotifier;
+    delete iServiceApi;    
+    iServiceApiLib.Close();
+    }	
+
+//---------------------------------------------------------------------------
+// CClock::TimeIsGood
+//---------------------------------------------------------------------------
+//
+TBool CClock::TimeIsGood()
+    {
+    return iTimeIsGood;
+    }	
+
+//---------------------------------------------------------------------------
+// CClock::SetTimeAsGoodL
+//---------------------------------------------------------------------------
+//
+void CClock::SetTimeAsGoodL( TBool aGood )
+    {
+    iTimeIsGood = aGood;
+    if ( iTimeIsGood )
+        {
+        iTime.UniversalTime();
+        WriteTimeL();
+        }
+    }	
+
+//---------------------------------------------------------------------------
+// CClock::ConstructL
+//---------------------------------------------------------------------------
+//
+void CClock::ConstructL()
+	{
+    TInt r = KErrNone;
+    TInt trap = KErrNone;
+    
+	LOGFN( "CClock::ConstructL" );
+	CTimer::ConstructL();
+	iChangeNotifier = CEnvironmentChangeNotifier::NewL( EPriorityNormal,
+	    TCallBack( CClock::ChangeCallback, this ) );
+    TRAP( trap, r = ReadTimeL() );
+	if ( trap != KErrNone || r != KErrNone )
+	    {
+	    // Init Change: init to a date prior to the manufacturing date:
+	    // 00:00:00:000000 October 2nd, 2007.
+	    // iTime.UniversalTime();
+	    iTime = TDateTime(2007,EOctober,1,0,0,0,0);
+	    WriteTimeL();
+	    }
+	}
+
+//---------------------------------------------------------------------------
+// CClock::Start
+//---------------------------------------------------------------------------
+//
+void CClock::Start()
+	{
+	LOGFN( "CClock::Start" );
+	After( KClockInterval );
+	iChangeNotifier->Start();
+	}
+
+//---------------------------------------------------------------------------
+// CClock::ChangeCallback
+//---------------------------------------------------------------------------
+//	
+TInt CClock::ChangeCallback( TAny* aClock )
+    {
+	LOGFN( "CClock::ChangeCallback" );
+	reinterpret_cast< CClock*>( aClock )->HandleChange();
+	return KErrNone;
+    }
+
+//---------------------------------------------------------------------------
+// CClock::EvaluateCurrentTime
+//---------------------------------------------------------------------------
+//    
+void CClock::EvaluateCurrentTime()
+    {
+    TTime time;
+    TTimeIntervalSeconds delta;
+    TDateTime dateTime;
+
+    LOGFN( "CClock::EvaluateCurrentTime" );
+    time.UniversalTime();
+    dateTime = iTime.DateTime();
+
+    if( time.Int64() < iTime.Int64() ) 
+        {
+        iTimeIsGood = EFalse;
+        LOG1( "Time invalid" );
+        }
+    else
+        {
+        iTimeIsGood = ETrue;
+        LOG1( "Time valid" );
+        }
+    }
+
+//---------------------------------------------------------------------------
+// CClock::ReadTimeL
+//---------------------------------------------------------------------------
+//
+TInt CClock::ReadTimeL()
+    {
+    RFile file;
+    TBuf8<sizeof( TTime ) + 2 * KAESKeyLength> encryptedData;
+    TBuf8<sizeof( TTime ) + 2 * KAESKeyLength> decryptedData;
+    TBuf8<KAESKeyLength> key;
+    TBuf8<KAESKeyLength> iv;
+    CBufferedDecryptor* decryptor = NULL;
+    CModeCBCDecryptor* cbcDecryptor = NULL;
+    CAESDecryptor* aesDecryptor = NULL;
+    CPaddingPKCS7* padding = NULL;
+    TInt r = KErrNone;
+    TInt size = 0;
+    TDrmScheme drmScheme( EDrmSchemeWmDrm );
+    TChar driveLetter;
+    TBool wmDrmRightsConfigFound( EFalse );
+    TFileName timeSaverFile;
+        
+    LOGFNR( "CClock::ReadTimeL", r );    
+    
+    // Check which drive is configured in the Central Repository Key
+    // for the desired storing location of WM DRM rights. Time saver
+    // file should be read from that location, too.
+	wmDrmRightsConfigFound = DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( 
+        iServer->Fs(), drmScheme, driveLetter );
+    
+    if( wmDrmRightsConfigFound )
+        {
+        LOG1( "ReadTimeL: Rights Config Found" );    
+        }
+   
+	timeSaverFile.Format( KTimeSaverFile, (TUint)driveLetter );
+    
+    r = file.Open( iServer->Fs(), timeSaverFile, EFileRead );
+    if ( r == KErrNone )
+    	{
+	    CleanupClosePushL( file );
+	    
+	    User::LeaveIfError( file.Size( size ) );
+	    
+	    if( size != ( 2 * KAESKeyLength ) )
+	        {
+	        User::Leave(KErrCorrupt);
+	        }
+	    
+	    User::LeaveIfError( file.Read( iv ) );
+	    User::LeaveIfError( file.Read( encryptedData ) );
+#if defined(FF_PLATFORM_SIMULATOR) || defined(__WINSCW__)
+	    key.Copy( KDummyKey );
+#else
+	    iServer->Cache()->iKeyStorage->GetDeviceSpecificKeyL( key );
+#endif
+	    
+        aesDecryptor = CAESDecryptor::NewL( key );
+        CleanupStack::PushL( aesDecryptor );
+        
+        cbcDecryptor = CModeCBCDecryptor::NewL( aesDecryptor, iv );
+        CleanupStack::Pop( aesDecryptor );
+        CleanupStack::PushL( cbcDecryptor );
+        
+        padding = CPaddingPKCS7::NewL( KAESKeyLength );
+        CleanupStack::PushL( padding );
+        
+        decryptor = CBufferedDecryptor::NewL( cbcDecryptor, padding );
+        CleanupStack::Pop( 2, cbcDecryptor ); //padding, cbcDecryptor
+        CleanupStack::PushL( decryptor );
+	
+	    decryptor->ProcessFinalL( encryptedData, decryptedData );
+	    TPtr8 ptr( reinterpret_cast<TUint8*>( &iTime ), sizeof( iTime ) );
+	    ptr.Copy( decryptedData.Left( sizeof( TTime ) ) );
+	    EvaluateCurrentTime();
+	    CleanupStack::PopAndDestroy( 2, &file ); //decryptor, file
+    	}
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CClock::WriteTimeL
+//---------------------------------------------------------------------------
+//
+TInt CClock::WriteTimeL()
+    {
+    RFile file;
+    TBuf8<sizeof( TTime ) + 2 * KAESKeyLength> encryptedData;
+    TBuf8<sizeof( TTime ) + 2 * KAESKeyLength> decryptedData;
+    TBuf8<KAESKeyLength> key;
+    TBuf8<KAESKeyLength> iv;
+    CBufferedEncryptor* encryptor = NULL;
+    CModeCBCEncryptor* cbcEncryptor = NULL;
+    CAESEncryptor* aesEncryptor = NULL;
+    CPaddingPKCS7* padding = NULL;
+    TInt r = KErrNone;
+    TInt pos = 0;
+    TDrmScheme drmScheme( EDrmSchemeWmDrm );
+    TChar driveLetter;
+    TBool wmDrmRightsConfigFound( EFalse );
+    TFileName tempFile;
+        
+    LOGFNR( "CClock::WriteTime", r );    
+    
+    // Check which drive is configured in the Central Repository Key
+    // for the desired storing location of WM DRM rights. Time saver
+    // file should be stored to that location, too.
+	wmDrmRightsConfigFound = DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( 
+        iServer->Fs(), drmScheme, driveLetter );
+ 
+    if( wmDrmRightsConfigFound )
+        {
+        LOG1( "WriteTimeL: Rights Config Found" );    
+        }   
+     
+	tempFile.Format( KPrivateDir, (TUint)driveLetter );
+    iServer->Fs().MkDirAll( tempFile );
+    
+    tempFile.Format( KTimeSaverFile, (TUint)driveLetter );
+    User::LeaveIfError( file.Replace( iServer->Fs(), tempFile, EFileRead | EFileWrite ) );
+    CleanupClosePushL( file );
+
+    iv.SetLength( KAESKeyLength );
+    TRandom::RandomL( iv );
+#if defined(FF_PLATFORM_SIMULATOR) || defined(__WINSCW__)
+    key.Copy( KDummyKey );
+#else
+    iServer->Cache()->iKeyStorage->GetDeviceSpecificKeyL( key );
+#endif
+    aesEncryptor = CAESEncryptor::NewL( key );
+    CleanupStack::PushL( aesEncryptor );
+    
+    cbcEncryptor = CModeCBCEncryptor::NewL( aesEncryptor, iv );
+    CleanupStack::Pop( aesEncryptor );
+    CleanupStack::PushL( cbcEncryptor );
+    
+    padding = CPaddingPKCS7::NewL( KAESKeyLength );
+    CleanupStack::PushL( padding );
+    
+    encryptor = CBufferedEncryptor::NewL( cbcEncryptor, padding );
+    CleanupStack::Pop( 2, cbcEncryptor ); //padding, cbcEncryptor
+    CleanupStack::PushL( encryptor );
+        
+    TPtr8 ptr( reinterpret_cast<TUint8*>( &iTime ), sizeof( iTime ), sizeof( iTime ) );
+    decryptedData.Copy( ptr.Left( sizeof( TTime ) ) );
+    encryptor->ProcessFinalL( decryptedData, encryptedData );
+    User::LeaveIfError( file.Seek( ESeekStart, pos ) );
+    User::LeaveIfError( file.SetSize( 0 ) );
+    User::LeaveIfError( file.Write( iv ) );
+    User::LeaveIfError( file.Write( encryptedData ) );
+    iTimeIsGood = ETrue;
+    CleanupStack::PopAndDestroy( 2, &file ); //encryptor, file
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CClock::HandleChange
+//---------------------------------------------------------------------------
+//
+void CClock::HandleChange()
+    {
+    TInt change;
+    
+	LOGFN( "CClock::HandleChange" );
+	change = iChangeNotifier->Change();
+	LOG2( "Change: %d", change );
+	if ( ( change & EChangesSystemTime ) )
+	    {
+	    EvaluateCurrentTime();
+        if ( iTimeIsGood )
+            {
+            iTime.UniversalTime();
+            TRAP_IGNORE( WriteTimeL() );
+            }
+	    }
+    }
+
+
+//---------------------------------------------------------------------------
+// CClock::LoadServiceApi
+//---------------------------------------------------------------------------
+//
+TInt CClock::LoadServiceApi() 
+    {
+#ifdef __DRM_CLOCK    
+    TInt err = KErrNone;
+    
+    if( !iServiceApiLoaded )
+        {
+        err = iServiceApiLib.Load( KDrmServiceApiWrapperName );
+        if( err )
+            {
+            iServiceApiLoaded = EFalse;
+            return err;
+            }
+        iServiceApiLoaded = ETrue;
+        }
+        
+    if( !iServiceApi )
+        {
+        TLibraryFunction function = iServiceApiLib.Lookup( KDrmServiceApiWrapperGateOrdinal );
+        if( function )
+            {
+            iServiceApi = reinterpret_cast<DRM::CDrmServiceApiWrapper*>( function() );
+            if( !iServiceApi )
+                {  
+                iServiceApi = NULL;
+                return KErrGeneral;
+                }
+            }
+        else 
+            {
+            return KErrNotFound;
+            }                
+        }    
+#endif 
+    return KErrNone;               
+    }
+
+//----------------------------------------------------------------------------
+// CClock::GetTimeL
+// This function gets the time from DRM Clock checks the validity and
+// then returns this information
+// flagged for use with DRM Clock, if clock is not there, use the old implementation
+//----------------------------------------------------------------------------
+//
+void CClock::GetTimeL( TTime& aTime, TBool& aValid )
+    {
+    TInt timeZone = 0;
+    
+#ifdef __DRM_CLOCK
+
+    DRMClock::ESecurityLevel secLevel;
+
+    // If it's already loaded then this just returns KErrNone
+	User::LeaveIfError( LoadServiceApi() ); 
+    
+    User::LeaveIfError( iServiceApi->GetSecureTime( aTime, timeZone, secLevel ) );
+
+    if( secLevel == DRMClock::KSecure )
+        {
+        aValid = ETrue;
+        }
+    else
+        {
+        aValid = EFalse;
+        }
+#else
+    aTime.UniversalTime();
+    aValid = EFalse;
+#endif
+    }
+
+//----------------------------------------------------------------------------
+// CClock::RunL
+//----------------------------------------------------------------------------
+//
+void CClock::RunL()
+	{
+	LOGFN( "CClock::RunL" );
+    LOG2( "Status: %d", iStatus.Int() );
+    EvaluateCurrentTime();
+    if ( iTimeIsGood )
+        {
+        iTime.UniversalTime();
+        TRAP_IGNORE( WriteTimeL() );
+        }
+    After( KClockInterval );
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/enumerator.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,156 @@
+/*
+* 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:  WMDRM Server implementation
+*
+*/
+
+
+#include <ezlib.h>
+#include <e32math.h>
+#include <symmetric.h>
+#include <bacntf.h>
+
+#include "enumerator.h"
+#include "namespaceenumerator.h"
+#include "enumeratordata.h"
+#include "slotenumerator.h"
+#include "wmdrmserver.h"
+#include "wmdrmdb.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+_LIT8( KZeroID, "0000000000000000" );
+
+LOCAL_C void ExtractEnumeratorComponentsL(
+    const TDesC8& aMessageBuffer,
+    TDes8& aStore,
+    TDes8& aNamespace,
+    TDes8& aHashKey )
+    {
+    TInt len;
+    TInt offset;
+    TInt total = aMessageBuffer.Length();
+
+	offset = 0;
+	len = aMessageBuffer[offset];
+	if ( len <= 0 || len > KMaxWmDrmStoreNameSize || offset + len + 1> total )
+	    {
+	    User::Leave( KErrArgument );
+	    }
+    aStore.Copy( aMessageBuffer.Mid( offset + 1, len ) );
+    
+    offset += len + 1;
+    if ( offset >= total )
+        {
+        User::Leave( KErrArgument );
+        }
+	len = aMessageBuffer[offset];
+	if ( len <= 0 || len > KMaxWmDrmNamespaceNameSize || offset + len + 1 > total )
+	    {
+	    User::Leave( KErrArgument );
+	    }
+	aNamespace.Copy( aMessageBuffer.Mid( offset + 1, len ) );
+	    
+    offset += len + 1;
+	len = aMessageBuffer[offset];
+    if ( offset >= total )
+        {
+        User::Leave( KErrArgument );
+        }
+	if ( ( len > 0 && len != KWmDrmIdSize ) || offset + len + 1 > total )
+	    {
+	    User::Leave( KErrArgument );
+	    }
+	else if ( len > 0 )
+	    {
+	    aHashKey.Copy( aMessageBuffer.Mid( offset + 1, len ) );
+	    }
+	else
+	    {
+	    aHashKey.SetLength( 0 );
+	    }
+    }
+
+CEnumerator* CEnumerator::NewL(
+    CWmDrmServer* aServer,
+    const TDesC8& aMessageBuffer )	
+    {
+    TBuf8<KMaxWmDrmNamespaceNameSize> nameSpace;
+    TBuf8<KMaxWmDrmStoreNameSize> store;
+    TBuf8<KWmDrmIdSize> hashKey;
+    CEnumerator* self = NULL;
+
+    LOGFN( "CEnumerator::NewL" );
+    ExtractEnumeratorComponentsL( aMessageBuffer, store, nameSpace, hashKey );
+    if ( hashKey.Length() > 0 )
+        {
+        self = CSlotEnumerator::NewL( aServer, store, nameSpace, hashKey );
+        }
+    else
+        {
+        self = CNameSpaceEnumerator::NewL( aServer, store, nameSpace );
+        }
+    return self;
+    }
+
+CEnumerator::~CEnumerator()
+    {
+    LOGFN( "CEnumerator::~CEnumerator" );
+    Close();
+    }
+
+void CEnumerator::GetHashKey( TDes8& aKey )
+    {
+    LOGFN( "CEnumerator::GetHashKey" );
+    aKey.SetLength( 0 );
+    aKey.Copy( iHashKey );
+    }
+
+void CEnumerator::GetUniqueKey( TDes8& aKey )
+    {
+    LOGFN( "CEnumerator::GetUniqueKey" );
+    aKey.SetLength( 0 );
+    if ( iUniqueKey.CompareC( KZeroID ) == 0 )
+        {
+        aKey.Fill( '\0', KWmDrmIdSize );
+        }
+    else
+        {
+        aKey.Copy( iUniqueKey );
+        }
+    }
+
+void CEnumerator::DeleteCurrentL()
+    {
+    LOGFN( "CEnumerator::DeleteCurrentL" );
+	iServer->Db()->DeleteRecordL( iStore,
+	                              iNamespace,
+	                              iHashKey,
+	                              iUniqueKey  );
+	}
+	
+TInt CEnumerator::OpenL()
+    {
+    TInt r = KErrNone;
+    LOGFNR( "CEnumerator::Open", r );
+	return r;
+    }
+	
+void CEnumerator::Close()
+    {
+	LOGFN( "CEnumerator::Close" );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/enumeratordata.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,78 @@
+/*
+* 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:  WMDRM Server implementation
+*
+*/
+
+
+#include <ezlib.h>
+#include <e32math.h>
+#include <symmetric.h>
+#include <bacntf.h>
+
+#include "enumeratordata.h"
+#include "slotenumeratorcache.h"
+#include "wmdrmserver.h"
+#include "wmdrmdb.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+CEnumeratorData* CEnumeratorData::NewL(
+    CWmDrmServer* aServer,
+    const TDesC8& aStore,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey )
+    {
+    CEnumeratorData* self = new (ELeave) CEnumeratorData();
+    CleanupStack::PushL( self );
+    self->ConstructL( aServer, aStore, aNamespace, aHashKey );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+void CEnumeratorData::ConstructL(
+    CWmDrmServer* aServer,
+    const TDesC8& aStore,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey )
+    {
+    LOGFN( "CEnumeratorData::ConstructL" );
+    iServer = aServer;
+    iStore.Copy( aStore );
+    iNamespace.Copy( aNamespace );
+    iHashKey.Copy( aHashKey );
+    iServer->Db()->EnumerateDataL( iStore, iNamespace, iHashKey, iEntries );
+    }
+
+CEnumeratorData::CEnumeratorData():
+    iReferences( 0 )
+    {
+    LOGFN( "CEnumeratorData::CEnumeratorData" );
+    }
+
+CEnumeratorData::~CEnumeratorData()
+    {
+    LOGFN( "CEnumeratorData::~CEnumeratorData" );
+    iEntries.ResetAndDestroy();
+    iEntries.Close();
+    }
+
+void CEnumeratorData::Close()
+    {
+    LOGFN( "CEnumeratorData::Close" );
+    iServer->EnumeratorCache()->Release( this );
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/namespaceenumerator.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,64 @@
+/*
+* 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:  WMDRM Server implementation
+*
+*/
+
+
+#include <e32math.h>
+#include <symmetric.h>
+#include <bacntf.h>
+
+#include "namespaceenumerator.h"
+#include "wmdrmserver.h"
+#include "wmdrmdb.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+CNameSpaceEnumerator* CNameSpaceEnumerator::NewL(
+    CWmDrmServer* aServer,
+    const TDesC8& aStore,
+    const TDesC8& aNameSpace )
+    {
+    CNameSpaceEnumerator* self = new (ELeave) CNameSpaceEnumerator();
+    CleanupStack::PushL( self );
+    self->ConstructL( aServer, aStore, aNameSpace );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+void CNameSpaceEnumerator::ConstructL(
+    CWmDrmServer* aServer,
+    const TDesC8& aStore,
+    const TDesC8& aNameSpace )
+    {
+    LOGFN( "CNameSpaceEnumerator::ConstructL" );
+    iServer = aServer;
+    iStore.Copy( aStore );
+	iNamespace.Copy( aNameSpace );
+    LOG( iNamespace );
+    iServer->Db()->EnumerateNameSpaceStartL( iStore, iNamespace );
+    }
+
+TInt CNameSpaceEnumerator::NextL()
+    {
+    TInt r = KErrNone;
+    LOGFN( "CNameSpaceEnumerator::Next");
+	iServer->Db()->EnumerateNameSpaceNextL( iHashKey, iUniqueKey );
+	LOG3( "Saved slot info %S, %S", &iHashKey, &iUniqueKey );
+	return r;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/slot.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,287 @@
+/*
+* 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:  WMDRM Server implementation
+*
+*/
+
+
+#include <e32std.h>
+#include "slot.h"
+#include "slotdatacache.h"
+#include "enumerator.h"
+#include "slotdata.h"
+#include "wmdrmserver.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+#ifdef __WINSCW__
+_LIT8( KDummyKey, "0123456789012345" );
+#endif
+
+_LIT8( KEmptyID, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" );
+
+LOCAL_C void ExtractSlotComponentsL(
+    const TDesC8& aMessageBuffer,
+    TDes8& aStore,
+    TDes8& aNamespace,
+    TDes8& aHashKey,
+    TDes8& aUniqueKey )
+    {
+    TInt len;
+    TInt offset;
+    TInt total = aMessageBuffer.Length();
+
+	offset = 0;
+	len = aMessageBuffer[offset];
+	if ( len <= 0 || len > KMaxWmDrmStoreNameSize || offset + len + 1 > total )
+	    {
+	    User::Leave( KErrArgument );
+	    }
+    aStore.Copy( aMessageBuffer.Mid( offset + 1, len ) );
+    
+    offset += len + 1;
+    if ( offset >= total )
+        {
+        User::Leave( KErrArgument );
+        }
+	len = aMessageBuffer[offset];
+	if ( len <= 0 || len > KMaxWmDrmNamespaceNameSize || offset + len + 1 > total )
+	    {
+	    User::Leave( KErrArgument );
+	    }
+	aNamespace.Copy( aMessageBuffer.Mid( offset + 1, len ) );
+	    
+    offset += len + 1;
+    if ( offset >= total )
+        {
+        User::Leave( KErrArgument );
+        }
+	len = aMessageBuffer[offset];
+	if ( len != KWmDrmIdSize || offset + len + 1 > total )
+	    {
+	    User::Leave( KErrArgument );
+	    }
+	aHashKey.Copy( aMessageBuffer.Mid( offset + 1, len ) );
+
+    offset += len + 1;
+    if ( offset >= total )
+        {
+        User::Leave( KErrArgument );
+        }
+	len = aMessageBuffer[offset];
+	if ( len != KWmDrmIdSize || offset + len + 1 > total )
+	    {
+	    User::Leave( KErrArgument );
+	    }
+	aUniqueKey.Copy( aMessageBuffer.Mid( offset + 1, len ) );
+	if ( aUniqueKey.CompareC( KEmptyID ) == 0 )
+	    {
+	    aUniqueKey.Fill( '0' );
+	    }
+	}
+    
+CSlot* CSlot::NewL( CWmDrmServer* aServer, const TDesC8& aMessageBuffer )
+    {
+    CSlot* self = new (ELeave) CSlot();
+    CleanupStack::PushL( self );
+    self->ConstructL( aServer, aMessageBuffer );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+CSlot* CSlot::NewL( CWmDrmServer* aServer, CEnumerator* aEnumerator )
+    {
+    CSlot* self = new (ELeave) CSlot();
+    CleanupStack::PushL( self );
+    self->ConstructL( aServer, aEnumerator );
+    CleanupStack::Pop( self );
+    return self;
+    }
+    
+void CSlot::ConstructL(
+    CWmDrmServer* aServer,
+    const TDesC8& aMessageBuffer )
+    {
+    LOGFN( "CSlot::ConstructL" );
+	ExtractSlotComponentsL( aMessageBuffer, iStore, iNamespace, iHashKey, iUniqueKey );
+    iData = aServer->Cache()->GetSlotDataL( iStore, iNamespace, iHashKey, iUniqueKey );
+	iDataPosition = 0;
+    }
+
+void CSlot::ConstructL(
+    CWmDrmServer* aServer,
+    CEnumerator* aEnumerator )
+    {
+    LOGFN( "CSlot::ConstructL (2)" );
+    aEnumerator->GetHashKey( iHashKey );
+    aEnumerator->GetUniqueKey( iUniqueKey );
+    iStore.Copy( aEnumerator->iStore );
+    iNamespace.Copy( aEnumerator->iNamespace );
+    iData = aServer->Cache()->GetSlotDataL( iStore, iNamespace, iHashKey, iUniqueKey );
+	iDataPosition = 0;
+    }
+    
+
+CSlot::~CSlot()
+    {
+    LOGFN( "CSlot::~CSlot" );
+    if ( iData != NULL )
+        {
+        iData->Close();
+        }
+    }
+
+void CSlot::CreateL( TInt& aInitialSize )
+    {
+	LOGFN( "CSlot::CreateL" );
+	iData->CreateL( aInitialSize );
+    }
+    
+TInt CSlot::OpenL( TInt& aCurrentSize )
+    {
+    TInt r = KErrNone;
+    
+	LOGFNR( "CSlot::Open", r );
+	r = iData->OpenL( aCurrentSize );
+	iDataPosition = 0;
+	return r;
+    }
+    
+TInt CSlot::SeekL( TInt& aOffset, TSeek aOrigin )
+    {
+    TInt r = KErrNone;
+    TInt size;
+
+	LOGFNR( "CSlot::Seek", r );
+	if ( iData == NULL )
+	    {
+	    User::Leave( KErrNotReady );
+	    }
+	size = iData->Size();
+	switch ( aOrigin )
+	    {
+	    case ESeekStart:
+	        iDataPosition = aOffset;
+	        break;
+	    case ESeekEnd:
+	        iDataPosition = size + aOffset;
+	        break;
+	    case ESeekCurrent:
+	        iDataPosition += aOffset;
+	        break;
+	    }
+    iDataPosition = Max( iDataPosition, 0 );
+    iDataPosition = Min( iDataPosition, size );
+	LOG5( "Origin: %d, offset: %d, new pos: %d (size: %d)", aOrigin, aOffset, iDataPosition, size );
+	aOffset = iDataPosition;
+    return r;
+    }
+    
+TInt CSlot::Read( TDes8& aBuffer )
+    {
+    TInt r = KErrNone;
+
+	LOGFNR( "CSlot::Read", r );
+	if ( iData == NULL )
+	    {
+	    r = KErrNotReady;
+	    }
+	else
+	    {
+        r = iData->Read( iDataPosition, aBuffer );
+        }
+    if ( r == KErrNone )
+        {
+        iDataPosition += aBuffer.Length();
+        }
+    return r;
+    }
+    
+TInt CSlot::WriteL( const TDesC8& aBuffer )
+    {
+    TInt r = KErrNone;
+
+	LOGFNR( "CSlot::Write", r );
+	r = iData->WriteL( iDataPosition, aBuffer );
+    if ( r == KErrNone )
+        {
+        iDataPosition += aBuffer.Length();
+        }
+    return r;
+    }
+    
+TInt CSlot::ResizeL( TInt aNewSize )
+    {
+    TInt r = KErrNone;
+	LOGFNR( "CSlot::Resize", r );
+
+	if ( iData == NULL )
+	    {
+	    r = KErrNotReady;
+	    }
+	else
+	    {
+        iData->ResizeL( aNewSize );
+        if ( iDataPosition > aNewSize - 1 )
+            {
+            iDataPosition = aNewSize - 1;
+            }
+        }
+    return r;
+    }
+    
+TInt CSlot::DeleteL()
+    {
+    TInt r = KErrNone;
+    
+	LOGFNR( "CSlot::Delete", r );
+	if ( iData == NULL )
+	    {
+	    r = KErrNotReady;
+	    }
+	else
+	    {
+    	r = iData->DeleteL();
+    	}
+	return r;
+    }
+
+TInt CSlot::Size()
+    {
+    TInt r = KErrNone;
+    
+	LOGFNR( "CSlot::Size", r );
+	if ( iData == NULL )
+	    {
+	    r = KErrNotReady;
+	    }
+	else
+	    {
+    	r = iData->Size();
+    	}
+	return r;
+    }
+
+void CSlot::Close()
+    {
+	LOGFN( "CSlot::Close" );
+	if ( iData != NULL )
+        {
+        iData->Close();
+        iData = NULL;    
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/slotdata.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,390 @@
+/*
+* 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:  WMDRM Server implementation
+*
+*/
+
+
+#include <ezlib.h>
+#include <e32math.h>
+#include <symmetric.h>
+#include <bacntf.h>
+#include <random.h>
+
+#include "wmdrmkeystorage.h"
+#include "slotdata.h"
+#include "wmdrmserver.h"
+#include "slotdatacache.h"
+#include "slotenumeratorcache.h"
+#include "wmdrmdb.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+#ifdef __WINSCW__
+_LIT8( KDummyKey, "0123456789012345" );
+#endif
+
+CSlotData* CSlotData::NewL( 
+    CWmDrmServer* aServer, 
+    const TDesC8& aStore,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey )
+    {
+    LOGFN( "CSlotData::NewL" );
+    CSlotData* self = new (ELeave) CSlotData( aServer,
+                                              aStore,
+                                              aNamespace,
+                                              aHashKey,
+                                              aUniqueKey );
+    return self;
+    }
+
+CSlotData::CSlotData( 
+    CWmDrmServer* aServer, 
+    const TDesC8& aStore,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey ) : iServer( aServer ),
+                                 iDirty( EFalse ),
+                                 iExists( ETrue ),
+                                 iReferences( 0 )
+    {
+    LOGFN( "CSlotData::CSlotData" );
+    iStore.Copy( aStore );
+    iNamespace.Copy( aNamespace );
+    LOG( iNamespace );
+    iHashKey.Copy( aHashKey );
+    LOG( iHashKey );
+    iUniqueKey.Copy( aUniqueKey );
+    LOG( iUniqueKey );
+    }
+
+CSlotData::~CSlotData()
+    {
+    LOGFN( "CSlotData::~CSlotData" );
+    //FlushL();
+    iData.Close();
+    }
+
+void CSlotData::CreateL( TInt& aInitialSize )
+    {
+    LOGFN( "CSlotData::CreateL" );
+    LOG2( "Size: %d", aInitialSize );
+    LOG1( "*** Create record" );
+    if ( aInitialSize > KMaxSlotSize )
+        {
+        User::Leave( KErrArgument );
+        }
+	iServer->Db()->CreateRecordL( iStore, iNamespace, iHashKey, iUniqueKey, aInitialSize );
+    iData.Close();
+    iData.CreateL( aInitialSize );
+    iData.SetLength( iData.MaxLength() );
+    iData.FillZ();
+    iDirty = ETrue;
+    iExists = ETrue;
+    iOpen = ETrue;
+	iServer->EnumeratorCache()->AddEntryL( iStore, iNamespace, iHashKey, iUniqueKey );
+    //FlushL();
+    }
+
+TInt CSlotData::OpenL( TInt& aCurrentSize )
+    {
+    TInt r = KErrNone;
+    RBuf8 compressedData;
+    TUint32 uncompressedSize;
+    TPckg<TUint32> pckg( uncompressedSize );
+    RBuf8 encryptedData;
+    CBufferedDecryptor* decryptor = NULL;
+    CModeCBCDecryptor* cbcDecryptor = NULL;
+    CAESDecryptor* aesDecryptor = NULL;
+    CPaddingPKCS7* padding = NULL;
+    TInt size;
+    
+    LOGFN( "CSlotData::OpenL" );
+	LOG3( "Size: %d, data size: %d", aCurrentSize, iData.Length() );
+	if ( !IsOpen() )
+	    {
+	    if ( iExists )
+	        {
+    	    LOG1( "*** Opening record" );
+            TRAP( r, iServer->Db()->ReadRecordL( iStore, iNamespace, iHashKey, iUniqueKey ) );
+    	    if ( !r )
+    	        {
+    	        TBuf8<KAESKeyLength> key;
+    	        TBuf8<KAESKeyLength> iv;
+                RBuf8 buffer;
+
+                iServer->Db()->GetDataSizeL( size );
+                LOG2( "Record size: %d", size );
+                if( size <= 0 )
+                    {
+                    iServer->Db()->DeleteData();
+                    iServer->Db()->DeleteRecordL( iStore, iNamespace, iHashKey, iUniqueKey );
+                    User::Leave( KErrArgument );
+                    }
+                    
+                encryptedData.CreateL( size - sizeof( TUint32 ) - KAESKeyLength );
+                encryptedData.CleanupClosePushL();
+                
+                compressedData.CreateL( size - sizeof( TUint32 ) - KAESKeyLength );
+                compressedData.CleanupClosePushL();
+                
+
+                buffer.CreateL( size );
+                buffer.CleanupClosePushL();
+                iServer->Db()->ReadDataL( buffer );
+                //LOGHEX( buffer.Ptr(), buffer.Size() );
+                pckg.Copy( buffer.Left( sizeof( TUint32 ) ) );
+                LOG2( "Uncompressed size: %d", uncompressedSize );
+                iv.Copy( buffer.Mid ( sizeof( TUint32 ), KAESKeyLength ) );
+                //LOGHEX( iv.Ptr(), iv.Size () );
+                encryptedData.Copy( buffer.Right( size - sizeof( TUint32 ) - KAESKeyLength ) );
+                //LOGHEX( encryptedData.Ptr(), encryptedData.Size() );
+#ifdef __WINSCW__
+                key.Copy( KDummyKey );
+#else
+                iServer->Cache()->iKeyStorage->GetDeviceSpecificKeyL( key );
+#endif
+                aesDecryptor = CAESDecryptor::NewL( key );
+                CleanupStack::PushL( aesDecryptor );
+                
+                cbcDecryptor = CModeCBCDecryptor::NewL( aesDecryptor, iv );
+                CleanupStack::Pop( aesDecryptor );
+                CleanupStack::PushL( cbcDecryptor );
+                
+                padding = CPaddingPKCS7::NewL( KAESKeyLength );
+                CleanupStack::PushL( padding );
+                
+                decryptor = CBufferedDecryptor::NewL( cbcDecryptor, padding );
+                CleanupStack::Pop( 2, cbcDecryptor ); //padding, cbcDecryptor
+                CleanupStack::PushL( decryptor );
+
+                decryptor->ProcessFinalL( encryptedData, compressedData );
+
+                iData.Close();
+                iData.CreateMaxL( uncompressedSize );
+                User::LeaveIfError( uncompress( const_cast<TUint8*>( iData.Ptr() ), &uncompressedSize, 
+                                                                     compressedData.Ptr(), compressedData.Size() ) );
+                CleanupStack::PopAndDestroy( 4, &encryptedData ); //decryptor, buffer, compressedData, encryptedData
+                TRandom::RandomL( key );
+                iOpen = ETrue;
+                }
+            else 
+                {
+                iExists = EFalse;
+                if ( r == KErrPathNotFound )
+                    {
+                    r = KErrNotFound;
+                    }
+                }
+            }
+        else
+            {
+            r = KErrNotFound;
+            }
+        }
+	else
+	    {
+	    LOG1( "Record already open" );
+	    }
+    aCurrentSize = iData.Length();
+
+    return r;
+    }
+
+TInt CSlotData::Read( TInt aPosition, TDes8& aBuffer )
+    {
+    TInt r = KErrNone;
+    TInt length;
+
+    LOGFNR( "CSlotData::Read", r );
+	if ( IsOpen() )
+	    {
+	    length = Min( aBuffer.MaxLength(), iData.Length() - aPosition );
+	    LOG4( "Read %d bytes from %d, buffer size: %d", length, aPosition, aBuffer.MaxLength() );
+        aBuffer.Copy( iData.Mid( aPosition, length ) );
+//        LOGHEX( aBuffer.Ptr(), aBuffer.Size() );
+        }
+    else
+        {
+        r = KErrNotReady;
+        iServer->Cache()->Release( this );
+        }
+    return r;
+    }
+
+TInt CSlotData::WriteL( TInt aPosition, const TDesC8& aBuffer )
+    {
+    TInt r = KErrNone;
+
+	LOGFNR( "CSlotData::Write", r );
+	if ( IsOpen() )
+	    {
+	    LOG3( "Write %d bytes at %d", aBuffer.Length(), aPosition );
+//        LOGHEX( aBuffer.Ptr(), aBuffer.Size() );
+	    if ( aBuffer.Length() + aPosition > iData.Length() )
+	        {
+	        iData.ReAllocL( aBuffer.Length() + aPosition );
+	        iData.SetLength( iData.MaxLength() );
+	        }
+	    iData.Replace( aPosition, aBuffer.Length(), aBuffer );
+	    iDirty = ETrue;
+	    FlushL();
+        }
+    else
+        {
+        r = KErrNotReady;
+        iServer->Cache()->Release( this );
+        }
+    return r;
+    }
+
+TInt CSlotData::ResizeL( TInt aNewSize )
+    {
+    TInt r = KErrNone;
+
+	LOGFNR( "CSlotData::Resize", r );
+	if ( IsOpen() )
+        {
+    	LOG2( "New size: %d", aNewSize );
+    	if ( aNewSize > iData.Size() )
+    	    {
+            iData.ReAllocL( aNewSize );
+            }
+        iData.SetLength( aNewSize );
+        }
+    else
+        {
+        r = KErrNotReady;
+        iServer->Cache()->Release( this );
+        }
+    return r;
+    }
+
+TInt CSlotData::DeleteL()
+    {
+    TInt r = KErrNone;
+    
+	LOGFNR( "CSlotData::Delete", r );
+	iServer->EnumeratorCache()->DeleteEntryL( iStore, iNamespace, iHashKey, iUniqueKey );
+	r = iServer->Cache()->Delete( this );
+	return r;
+    }
+
+TInt CSlotData::Size()
+    {
+    TInt r;
+    
+    LOGFNR( "CSlotData::Size", r );
+	if ( IsOpen() )
+	    {
+	    r = iData.Length();
+	    }
+    else
+        {
+        r = KErrNotReady;
+        iServer->Cache()->Release( this );
+        }
+	return r;
+    }
+
+void CSlotData::Close()
+    {
+    LOGFN( "CSlotData::Close" );
+    iServer->Cache()->Release( this );
+    }
+
+void CSlotData::CloseFile()
+    {
+    LOGFN( "CSlotData::CloseFile" );
+    iOpen = EFalse;
+    }
+
+void CSlotData::FlushL()
+    {
+    LOGFN( "CSlotData::FlushL" );
+    __UHEAP_MARK;
+	if ( IsOpen() && iDirty )
+	    {
+        TBuf8<KAESKeyLength> iv;
+        TBuf8<KAESKeyLength> key;
+        TInt size = iData.Size();
+        RBuf8 compressedData;
+        TUint32 compressedDataLen = size + size / 10 + 12;
+        TUint8* compressedDataPtr;
+        RBuf8 encryptedData;
+        CBufferedEncryptor* encryptor = NULL;
+        CModeCBCEncryptor* cbcEncryptor = NULL;
+        CAESEncryptor* aesEncryptor = NULL;
+        CPaddingPKCS7* padding = NULL;
+        RBuf8 buffer;
+      
+        compressedData.CreateL( compressedDataLen );
+        compressedData.CleanupClosePushL();
+        compressedDataPtr = const_cast<TUint8*>( compressedData.Ptr() );
+        User::LeaveIfError( compress( compressedDataPtr, &compressedDataLen, iData.Ptr(), size ) );
+        compressedData.SetLength( compressedDataLen );
+        
+        encryptedData.CreateL( compressedData.Size() + 2 * KAESKeyLength );
+        encryptedData.CleanupClosePushL();
+
+        iv.SetLength( KAESKeyLength );
+        TRandom::RandomL( iv );
+#ifdef __WINSCW__
+        key.Copy( KDummyKey );
+#else
+        iServer->Cache()->iKeyStorage->GetDeviceSpecificKeyL( key );
+#endif
+        aesEncryptor = CAESEncryptor::NewL( key );
+        CleanupStack::PushL( aesEncryptor );
+        
+        cbcEncryptor = CModeCBCEncryptor::NewL( aesEncryptor, iv );
+        CleanupStack::Pop( aesEncryptor );
+        CleanupStack::PushL( cbcEncryptor );
+        
+        padding = CPaddingPKCS7::NewL( KAESKeyLength );
+        CleanupStack::PushL( padding );
+        
+        encryptor = CBufferedEncryptor::NewL( cbcEncryptor, padding );
+        CleanupStack::Pop( 2, cbcEncryptor ); //padding, cbcEncryptor
+        CleanupStack::PushL( encryptor );
+        
+        encryptor->ProcessFinalL( compressedData, encryptedData );
+        
+        LOG1( "*** Write record" );
+        LOG3( "Uncompressed size: %d, compresseded size: %d", size, encryptedData.Size() );
+        buffer.CreateL( sizeof( TUint32 ) + iv.Size() + encryptedData.Size() );
+        buffer.CleanupClosePushL();
+        buffer.Append( TPckgC<TUint32>( size ) );
+        buffer.Append( iv );
+        buffer.Append( encryptedData );
+        //LOGHEX( buffer.Ptr(), buffer.Size() );
+
+        iServer->Db()->WriteDataL( iStore, iNamespace, iHashKey, iUniqueKey, buffer );
+        iDirty = EFalse;
+        TRandom::RandomL( key );
+        CleanupStack::PopAndDestroy( 4, &compressedData ); //buffer, encryptor, encryptedData, compressedData
+        }
+    __UHEAP_MARKEND;        
+    }
+
+TBool CSlotData::IsOpen()
+    {
+    return iOpen;
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/slotdatacache.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,187 @@
+/*
+* 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:  WMDRM Server implementation
+*
+*/
+
+
+#include "wmdrmserver.h"
+#include "slotdata.h"
+#include "slotdatacache.h"
+#include "wmdrmkeystorage.h"
+#include "wmdrmdb.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+
+CSlotDataCache* CSlotDataCache::NewL( CWmDrmServer* aServer )
+    {
+    CSlotDataCache* self = new (ELeave) CSlotDataCache( aServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+    
+void CSlotDataCache::ConstructL()
+    {
+    LOGFN( "CSlotDataCache::ConstructL" );
+#ifndef __WINSCW__    
+	iKeyStorage = CWmDrmKeyStorage::NewL();
+    if ( !iKeyStorage )
+        {
+        User::Leave( KErrNotSupported );
+        }
+#endif // __WINSCW__
+    iMaxCachedSlots = KDefaultMaxCachedSlots;
+    }
+    
+CSlotDataCache::CSlotDataCache(
+    CWmDrmServer* aServer):
+    iServer( aServer )
+    {
+    }
+
+CSlotDataCache::~CSlotDataCache()
+    {
+    iSlotCache.ResetAndDestroy();
+    iSlotCache.Close();
+    delete iKeyStorage;
+    }
+
+CSlotData* CSlotDataCache::GetSlotDataL( 
+    const TDesC8& aStore,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey )
+    {
+    CSlotData* r = NULL;
+    TInt i = 0;
+    
+    LOGFN( "CSlotDataCache::GetSlotDataL" );
+    LOG( aNamespace );
+    LOG( aHashKey );
+    LOG( aUniqueKey );
+    for ( i = 0; r == NULL && i < iSlotCache.Count(); i++ )
+        {
+        CSlotData* data = iSlotCache[i];
+        if ( /*iSlotCache[i]->iStore == aStore &&*/
+             iSlotCache[i]->iNamespace == aNamespace &&
+             iSlotCache[i]->iHashKey == aHashKey && 
+             iSlotCache[i]->iUniqueKey == aUniqueKey )
+            {
+            r = iSlotCache[i];
+            Claim( r );
+            }
+        }
+    if ( r == NULL )
+        {
+        Cleanup();
+        r = CSlotData::NewL( iServer, 
+                             aStore, 
+                             aNamespace, 
+                             aHashKey, 
+                             aUniqueKey );
+        CleanupStack::PushL( r );
+        iSlotCache.AppendL( r );
+        Claim( r );
+        CleanupStack::Pop( r );
+        }
+    return r;
+    }
+
+void CSlotDataCache::Claim( CSlotData* aSlot )
+    {
+    LOGFN( "CSlotDataCache::ClaimL" );
+    aSlot->iReferences++;
+    }
+
+TInt CSlotDataCache::Delete( CSlotData* aSlot )
+    {
+    TInt r = KErrNone;
+    LOGFNR( "CSlotDataCache::Delete", r );
+    aSlot->CloseFile();
+    TRAP( r, iServer->Db()->DeleteRecordL( aSlot->iStore,
+                                           aSlot->iNamespace,
+                                           aSlot->iHashKey,
+                                           aSlot->iUniqueKey  ) );
+    return r;
+	}
+    
+void CSlotDataCache::Release( CSlotData* aSlot )
+    {
+    TInt i = 0;
+    
+    LOGFN( "CSlotDataCache::ReleaseL" );
+    while ( i < iSlotCache.Count() && iSlotCache[i] != aSlot )
+        {
+        i++;
+        }
+    if ( i < iSlotCache.Count() )
+        {
+        iSlotCache[i]->iReferences--;
+        }
+    }
+
+void CSlotDataCache::Cleanup()
+    {
+    TInt i = 0;
+    TInt minReferencesCount = 0;
+    TInt minReferencesIndex = 0;
+    
+    LOGFN( "CSlotDataCache::CleanupL" );
+    LOG3( "Used: %d, max: %d", iSlotCache.Count(), iMaxCachedSlots );
+    
+    if ( iSlotCache.Count() >= iMaxCachedSlots )
+        {
+        minReferencesCount = iSlotCache[minReferencesIndex]->iReferences;
+        
+        while ( iSlotCache.Count() >= iMaxCachedSlots && i < iMaxCachedSlots ) 
+            {
+            if ( iSlotCache[i]->iReferences == 0 )
+                {
+                LOG2( "Releasing %d", i );
+                delete iSlotCache[i];
+                iSlotCache.Remove( i );
+                }
+            else if ( iSlotCache[i]->iReferences < minReferencesCount )
+                {
+                minReferencesCount = iSlotCache[i]->iReferences;
+                minReferencesIndex = i;
+                }
+            i++;
+            }
+    
+        if ( iSlotCache.Count() >= iMaxCachedSlots ) 
+            {
+            LOG2( "Force Releasing %d", minReferencesIndex );
+            delete iSlotCache[minReferencesIndex];
+            iSlotCache.Remove( minReferencesIndex );
+            }
+        }
+    }
+    
+void CSlotDataCache::FlushL()
+    {
+    TInt i;
+    
+    LOGFN( "CSlotDataCache::FlushL" );
+    for ( i = 0; i < iSlotCache.Count(); i++ )
+        {
+        iSlotCache[i]->FlushL();
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/slotenumerator.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,115 @@
+/*
+* 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:  WMDRM Server implementation
+*
+*/
+
+
+#include <e32std.h>
+
+#include "wmdrmserver.h"
+#include "slotenumerator.h"
+#include "enumeratordata.h"
+#include "slotenumeratorcache.h"
+#include "wmdrmdb.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+CSlotEnumerator* CSlotEnumerator::NewL(
+    CWmDrmServer* aServer,
+    const TDesC8& aStore,
+    const TDesC8& aNameSpace,
+    const TDesC8& aHashKey )
+    {
+    CSlotEnumerator* self = new (ELeave) CSlotEnumerator();
+    CleanupStack::PushL( self );
+    self->ConstructL( aServer, aStore, aNameSpace, aHashKey );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+void CSlotEnumerator::ConstructL(
+    CWmDrmServer* aServer,
+    const TDesC8& aStore,
+    const TDesC8& aNameSpace,
+    const TDesC8& aHashKey )
+    {
+    LOGFN( "CSlotEnumerator::ConstructL" );
+    iServer = aServer;
+    iStore.Copy( aStore );
+	iNamespace.Copy( aNameSpace );
+	LOG( iNamespace );
+	iHashKey.Copy( aHashKey );
+    LOG( iHashKey );
+    }
+
+CSlotEnumerator::CSlotEnumerator():
+    iPosition( 0 ),
+    iEnumeratorData( NULL )
+    {
+    }
+
+CSlotEnumerator::~CSlotEnumerator()
+    {
+    if ( iEnumeratorData != NULL )
+        {
+        iEnumeratorData->Close();
+        }
+    }
+
+TInt CSlotEnumerator::OpenL()
+    {
+    TInt r = KErrNone;
+    
+	LOGFNR( "CSlotEnumerator::Open", r );
+	iEnumeratorData = iServer->EnumeratorCache()->GetEnumeratorDataL( iStore, iNamespace, iHashKey );
+    LOG2( "Slotenumerator entries %d", iEnumeratorData->iEntries.Count() );
+    iPosition = 0;
+    return r;
+    }
+	
+TInt CSlotEnumerator::NextL()
+    {
+    TInt r = KErrNone;
+    
+	LOGFNR( "CSlotEnumerator::Next", r );
+	if ( iEnumeratorData != NULL && iPosition < iEnumeratorData->iEntries.Count() )
+	    {
+        iHashKey.Copy( iEnumeratorData->iHashKey  );
+        iUniqueKey.Copy( *iEnumeratorData->iEntries[iPosition] );
+        iPosition++;
+        LOG3( "Saved slot info %S, %S", &iHashKey, &iUniqueKey );
+        }
+    else
+        {
+        LOG1( "Enumerate finished" );
+        r = KErrNotFound;
+        Close();
+        }
+    return r;
+    }
+	
+void CSlotEnumerator::Close()
+    {
+	LOGFN( "CSlotEnumerator::Close" );
+	if ( iEnumeratorData != NULL )
+	    {
+        iEnumeratorData->Close();
+        iEnumeratorData = NULL;
+        }
+    }
+	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/slotenumeratorcache.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,219 @@
+/*
+* 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:  WMDRM Server implementation
+*
+*/
+
+
+#include "slotenumeratorcache.h"
+#include "enumeratordata.h"
+#include "wmdrmserver.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+CSlotEnumeratorCache* CSlotEnumeratorCache::NewL( CWmDrmServer* aServer )
+    {
+    CSlotEnumeratorCache* self = new (ELeave) CSlotEnumeratorCache( aServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+    return self;
+    }
+
+void CSlotEnumeratorCache::ConstructL()
+    {
+    LOGFN( "CSlotEnumeratorCache::ConstructL" );
+    iMaxCachedEnumerators = KDefaultMaxCachedEnumerators;
+    }
+    
+CSlotEnumeratorCache::CSlotEnumeratorCache(
+    CWmDrmServer* aServer):
+    iServer( aServer )
+    {
+    LOGFN( "CSlotEnumeratorCache::CSlotEnumeratorCache" );
+    }
+
+CSlotEnumeratorCache::~CSlotEnumeratorCache()
+    {
+    LOGFN( "CSlotEnumeratorCache::~CSlotEnumeratorCache" );
+    iEnumeratorCache.ResetAndDestroy();
+    iEnumeratorCache.Close();
+    }
+
+CEnumeratorData* CSlotEnumeratorCache::GetEnumeratorDataL(
+    const TDesC8& aStore,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey )
+    {
+    CEnumeratorData* r = NULL;
+    TInt i = 0;
+    
+    LOGFN( "CSlotEnumeratorCache::GetEnumeratorDataL" );
+    LOG( aNamespace );
+    LOG( aHashKey );
+    for ( i = 0; r == NULL && i < iEnumeratorCache.Count(); i++ )
+        {
+        CEnumeratorData* data = iEnumeratorCache[i];
+        if ( /*data->iStore == aStore &&*/
+             data->iNamespace == aNamespace &&
+             data->iHashKey == aHashKey )
+            {
+            r = iEnumeratorCache[i];
+            Claim( r );
+            }
+        }
+    if ( r == NULL )
+        {
+        Cleanup();
+        r = CEnumeratorData::NewL( iServer, aStore, aNamespace, aHashKey );
+        CleanupStack::PushL( r );
+        iEnumeratorCache.AppendL( r );
+        Claim( r );
+        CleanupStack::Pop( r );
+        }
+    return r;
+    }
+
+void CSlotEnumeratorCache::Claim( CEnumeratorData* aData )
+    {
+    LOGFN( "CSlotEnumeratorCache::ClaimL" );
+    aData->iReferences++;
+    }
+
+void CSlotEnumeratorCache::Release( CEnumeratorData* aData )
+    {
+    LOGFN( "CSlotEnumeratorCache::ReleaseL" );
+    aData->iReferences--;
+    }
+
+TInt CSlotEnumeratorCache::AddEntryL(
+    const TDesC8& /*aStore*/,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey )
+    {
+    TInt r = KErrNone;
+    TInt i;
+    CEnumeratorData* entry = NULL;
+    HBufC8* fileName;
+    
+    LOGFNR( "CSlotEnumeratorCache::AddEntryL", r );
+    LOG( aNamespace );
+    LOG( aHashKey );
+    LOG( aUniqueKey );
+    for ( i = 0; entry == NULL && i < iEnumeratorCache.Count(); i++ )
+        {
+        CEnumeratorData* data = iEnumeratorCache[i];
+        if ( /*data->iStore == aStore &&*/
+             data->iNamespace == aNamespace &&
+             data->iHashKey == aHashKey )
+            {
+            entry = iEnumeratorCache[i];
+            }
+        }
+    if ( entry != NULL )
+        {
+        i = 0;
+        while ( i < entry->iEntries.Count() && *entry->iEntries[i] != aUniqueKey )
+            {
+            i++;
+            }
+        if ( i == entry->iEntries.Count() )
+            {
+            fileName = aUniqueKey.AllocLC();
+            entry->iEntries.AppendL( fileName );
+            CleanupStack::Pop( fileName );
+            }
+        }
+    return r;
+    }
+
+TInt CSlotEnumeratorCache::DeleteEntryL(
+    const TDesC8& /*aStore*/,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey )
+    {
+    TInt r = KErrNone;
+    TInt i;
+    CEnumeratorData* entry = NULL;
+    
+    LOGFNR( "CSlotEnumeratorCache::DeleteEntryL", r );
+    
+    for ( i = 0; entry == NULL && i < iEnumeratorCache.Count(); i++ )
+        {
+        CEnumeratorData* data = iEnumeratorCache[i];
+        if ( /*data->iStore == aStore &&*/
+             data->iNamespace == aNamespace &&
+             data->iHashKey == aHashKey )
+            {
+            entry = iEnumeratorCache[i];
+            }
+        }
+    if ( entry != NULL )
+        {
+        i = 0;
+        while ( i < entry->iEntries.Count() && *entry->iEntries[i] != aUniqueKey )
+            {
+            i++;
+            }
+        if ( i < entry->iEntries.Count() )
+            {
+            delete entry->iEntries[i];
+            entry->iEntries.Remove( i );
+            }
+        }
+    return r;
+    }
+
+void CSlotEnumeratorCache::Cleanup()
+    {
+    TInt i = 0;
+    TInt minReferencesCount = 0;
+    TInt minReferencesIndex = 0;
+    
+    LOGFN( "CSlotEnumeratorCache::CleanupL" );
+    LOG3( "Used: %d, max: %d", iEnumeratorCache.Count(), iMaxCachedEnumerators );
+    
+    if ( iEnumeratorCache.Count() >= iMaxCachedEnumerators )
+        {
+        minReferencesCount = iEnumeratorCache[minReferencesIndex]->iReferences;
+        
+        while ( iEnumeratorCache.Count() >= iMaxCachedEnumerators && i < iMaxCachedEnumerators ) 
+            {
+            if ( iEnumeratorCache[i]->iReferences == 0 )
+                {
+                LOG2( "Releasing %d", i );
+                delete iEnumeratorCache[i];
+                iEnumeratorCache.Remove( i );
+                }
+            else if ( iEnumeratorCache[i]->iReferences < minReferencesCount )
+                {
+                minReferencesCount = iEnumeratorCache[i]->iReferences;
+                minReferencesIndex = i;
+                }
+            i++;
+            }
+    
+        if ( iEnumeratorCache.Count() >= iMaxCachedEnumerators ) 
+            {
+            LOG2( "Force Releasing %d", minReferencesIndex );
+            delete iEnumeratorCache[minReferencesIndex];
+            iEnumeratorCache.Remove( minReferencesIndex );
+            }
+        }
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/wmdrmdatastore.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,603 @@
+/*
+* 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:  WMDRM data store implementation
+*
+*/
+
+
+#include <ezlib.h>
+#include <e32math.h>
+#include <symmetric.h>
+#include <bacntf.h>
+#include <centralrepository.h> 
+
+#include "wmdrmdatastore.h"
+#include "wmdrmprivatecrkeys.h"
+#include "wmdrmkeystorage.h"
+#include "slotdatacache.h"
+#include "wmdrmdb.h"
+#include "drmrightsstoringlocation.h"
+#include "drmutilityinternaltypes.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+const TInt KMegaByte( 1024 * 1024 );
+const TInt KTwoHundredMegaBytes ( 200 * 1024 * 1024 );
+const TInt KMaxSpaceRatio( 85 );
+const TInt KMaxSpaceRatio2( 20 );
+const TInt KMaxTInt64BufLength( 20 );
+const TInt KDummyDbInitialSize( 0 );
+
+#if defined(FF_PLATFORM_SIMULATOR) || defined(__WINSCW__)
+_LIT8( KDummyKey, "0123456789012345" );
+#endif
+
+CWmDrmDataStore* CWmDrmDataStore::NewL( CWmDrmServer* aServer )
+    {
+    LOGFN( "CWmDrmDataStore::NewL" );
+    CWmDrmDataStore* self = new ( ELeave ) CWmDrmDataStore( aServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+CWmDrmDataStore::CWmDrmDataStore( CWmDrmServer* aServer ) 
+    : iServer( aServer ), iMinFreeSpace2( 0 )
+    {
+    LOGFN( "CWmDrmDataStore::CWmDrmDataStore" );
+    }
+
+void CWmDrmDataStore::ConstructL()
+    {
+    TDrmScheme drmScheme( EDrmSchemeWmDrm );
+    TFileName tempFile, tempFile2;
+    TChar driveLetter;
+    
+    LOGFN( "CWmDrmDataStore::ConstructL" );
+    
+    // Check which drive is configured in the Central Repository Key
+    // for the desired storing location of WM DRM rights (license store).
+	iWmDrmRightsConfigFound = DrmRightsStoringLocation::CheckDrmRightsStorageDriveL(
+	    iServer->Fs(), drmScheme, driveLetter );
+    
+    // If the storing location is configured to other drive than the default 
+	// system drive, prepare utility files for that drive, too.
+    if ( iWmDrmRightsConfigFound )
+        {
+        PrepareInfoFilesL( ETrue, driveLetter, iDummyDb2 );
+        }
+    
+    // Prepare the utility files for the default system drive
+    PrepareInfoFilesL( EFalse, (TUint)iServer->Fs().GetSystemDriveChar(), 
+        iDummyDb );
+    }
+
+CWmDrmDataStore::~CWmDrmDataStore()
+    {
+    LOGFN( "CWmDrmDataStore::~CWmDrmDataStore" );
+    iDummyDb.Close();
+    // Close the database on the configured drive
+    if ( iWmDrmRightsConfigFound )
+        {
+        iDummyDb2.Close();
+        }
+    }
+
+void CWmDrmDataStore::ReadInitialFreeSpaceL( const TDesC& aFileName,
+    TBool& aConfiguredDrive )
+    {
+    RFile file;
+    TBuf8<KMaxTInt64BufLength + 2 * KAESKeyLength> encryptedData;
+    TBuf8<KMaxTInt64BufLength + 2 * KAESKeyLength> decryptedData;
+    TBuf8<KAESKeyLength> key;
+    TBuf8<KAESKeyLength> iv;
+    CBufferedDecryptor* decryptor = NULL;
+    CModeCBCDecryptor* cbcDecryptor = NULL;
+    CAESDecryptor* aesDecryptor = NULL;
+    CPaddingPKCS7* padding = NULL;
+    TInt size = 0;
+    
+    LOGFN( "CWmDrmDataStore::ReadInitialFreeSpaceL" );
+    User::LeaveIfError( file.Open( iServer->Fs(), aFileName, EFileRead ) );
+    CleanupClosePushL( file );
+    
+    User::LeaveIfError( file.Size( size ) );
+	    
+	if( size != ( 2 * KAESKeyLength ) )
+	    {
+	    User::Leave(KErrCorrupt);
+	    }
+
+    User::LeaveIfError( file.Read( iv ) );
+	User::LeaveIfError( file.Read( encryptedData ) );
+#if defined(FF_PLATFORM_SIMULATOR) || defined(__WINSCW__)
+	key.Copy( KDummyKey );
+#else
+	iServer->Cache()->iKeyStorage->GetDeviceSpecificKeyL( key );
+#endif
+	aesDecryptor = CAESDecryptor::NewL( key );
+    CleanupStack::PushL( aesDecryptor );
+    
+    cbcDecryptor = CModeCBCDecryptor::NewL( aesDecryptor, iv );
+    CleanupStack::Pop( aesDecryptor );
+    CleanupStack::PushL( cbcDecryptor );
+    
+    padding = CPaddingPKCS7::NewL( KAESKeyLength );
+    CleanupStack::PushL( padding );
+    
+    decryptor = CBufferedDecryptor::NewL( cbcDecryptor, padding );
+    CleanupStack::Pop( 2, cbcDecryptor ); //padding, cbcDecryptor
+    CleanupStack::PushL( decryptor );
+	
+	decryptor->ProcessFinalL( encryptedData, decryptedData );
+	CleanupStack::PopAndDestroy( 2, &file ); //decryptor, file
+	TLex8 lex( decryptedData );
+	
+	if ( aConfiguredDrive )
+	    {
+	    User::LeaveIfError( lex.Val( iInitialFreeSpace2 ) );
+	    }
+	else 
+	    {
+	    User::LeaveIfError( lex.Val( iInitialFreeSpace ) );
+	    }    
+    }
+        
+void CWmDrmDataStore::WriteInitialFreeSpaceL( const TDesC& aFileName,
+    TBool& aConfiguredDrive )
+    {
+    RFile file;
+    TBuf8<KMaxTInt64BufLength + 2 * KAESKeyLength> encryptedData;
+    TBuf8<KMaxTInt64BufLength + 2 * KAESKeyLength> decryptedData;
+    TBuf8<KAESKeyLength> key;
+    TBuf8<KAESKeyLength> iv;
+    CBufferedEncryptor* encryptor = NULL;
+    CModeCBCEncryptor* cbcEncryptor = NULL;
+    CAESEncryptor* aesEncryptor = NULL;
+    CPaddingPKCS7* padding = NULL;
+    
+    LOGFN( "CWmDrmDataStore::WriteInitialFreeSpaceL" );
+    User::LeaveIfError( file.Create( iServer->Fs(), aFileName, EFileWrite ) );
+    CleanupClosePushL( file );
+    if ( aConfiguredDrive )
+        {
+        iInitialFreeSpace2 = iServer->FreeSpaceL( aConfiguredDrive );
+        }
+    else
+        {
+        iInitialFreeSpace = iServer->FreeSpaceL( aConfiguredDrive );
+        }    
+    iv.SetLength( KAESKeyLength );
+    TRandom::RandomL( iv );
+#if defined(FF_PLATFORM_SIMULATOR) || defined(__WINSCW__)
+    key.Copy( KDummyKey );
+#else
+    iServer->Cache()->iKeyStorage->GetDeviceSpecificKeyL( key );
+#endif
+    aesEncryptor = CAESEncryptor::NewL( key );
+    CleanupStack::PushL( aesEncryptor );
+    
+    cbcEncryptor = CModeCBCEncryptor::NewL( aesEncryptor, iv );
+    CleanupStack::Pop( aesEncryptor );
+    CleanupStack::PushL( cbcEncryptor );
+    
+    padding = CPaddingPKCS7::NewL( KAESKeyLength );
+    CleanupStack::PushL( padding );
+    
+    encryptor = CBufferedEncryptor::NewL( cbcEncryptor, padding );
+    CleanupStack::Pop( 2, cbcEncryptor ); //padding, cbcEncryptor
+    CleanupStack::PushL( encryptor );
+    
+    if ( aConfiguredDrive )
+        {
+        decryptedData.AppendNum( iInitialFreeSpace2 );
+        }
+    else
+        {
+        decryptedData.AppendNum( iInitialFreeSpace );
+        }    
+            
+    encryptor->ProcessFinalL( decryptedData, encryptedData );
+    User::LeaveIfError( file.Write( iv ) );
+    User::LeaveIfError( file.Write( encryptedData ) );
+    CleanupStack::PopAndDestroy( 2, &file ); //encryptor, file
+    }
+
+TWmDrmStoreState CWmDrmDataStore::DataStoreStateL()
+    {
+    TWmDrmStoreState state;
+    TInt64 freeSpace( 0 );
+    TInt64 freeSpace2( 0 );
+    TInt dataStoreSize( 0 );
+    TInt dummyDbSize( 0 );
+    TInt ratio( 0 );
+    TInt ratio2( 0 );
+    TBool internalMassDriveNotFull( ETrue );
+    
+    LOGFN( "CWmDrmDataStore::DataStoreStateL" );
+    freeSpace = iServer->FreeSpaceL( EFalse );
+    
+    if ( iWmDrmRightsConfigFound )
+        {
+        // Check free space from the configured drive, too.
+        freeSpace2 = iServer->FreeSpaceL( ETrue );
+        
+        if ( freeSpace2 < iMinFreeSpace2 ) 
+            {
+            internalMassDriveNotFull = EFalse;
+            }
+            
+        dummyDbSize = DummyDBSizeL( ETrue );
+        dataStoreSize = DataStoreSizeL( ETrue );
+        ratio2 = dataStoreSize * 100 / iInitialFreeSpace2;
+        freeSpace2 += dummyDbSize;
+#ifdef _LOGGING        
+        TBuf<KMaxTInt64BufLength> free2;
+        LOG1( "CWmDrmDataStore::DataStoreStateL: Free space (2): ");
+        free2.AppendNumUC( freeSpace2, EDecimal );
+        LOG( free2 );
+        TBuf<KMaxTInt64BufLength> free2Min;
+        LOG1( "CWmDrmDataStore::DataStoreStateL: Minimum free space (2): ");
+        free2Min.AppendNumUC( iMinFreeSpace2, EDecimal );
+        LOG( free2Min );
+#endif             
+        }
+    
+    // Check the system drive storage space next.   
+    dummyDbSize = DummyDBSizeL( EFalse );
+    dataStoreSize = DataStoreSizeL( EFalse );
+    ratio = dataStoreSize * 100 / iInitialFreeSpace;
+    freeSpace += dummyDbSize;
+#ifdef _LOGGING        
+    TBuf<KMaxTInt64BufLength> free;
+    LOG1( "CWmDrmDataStore::DataStoreStateL: Free space: ");
+    free.AppendNumUC( freeSpace, EDecimal );
+    LOG( free );
+    TBuf<KMaxTInt64BufLength> freeMin;
+    LOG1( "CWmDrmDataStore::DataStoreStateL: Minimum free space: ");
+    freeMin.AppendNumUC( iMinFreeSpace, EDecimal );
+    LOG( freeMin );
+#endif      
+    
+    // Select the state of the storage space.      
+    if ( ( freeSpace > iMinFreeSpace ) && internalMassDriveNotFull ) 
+        {
+        LOG1( "CWmDrmDataStore::DataStoreStateL: Store space Ok" );
+        state = EStoreSpaceOK;
+        }
+    else
+        {
+        // The configured drive is running out of space. The system drive 
+        // may also be running out of storage space, but calculate
+        // the ratio of database size to initial free drive space and the
+        // state of the drive storage space from the configured drive because
+        // it is likely to fill up faster since the media files may be synced to it. 
+        if ( !internalMassDriveNotFull )
+            {
+            LOG2( "Ratio (2): %d", ratio2 );
+            if ( ratio2 <= iMaxSpaceRatio2 )
+                {
+                LOG1( "CWmDrmDataStore::DataStoreStateL: Store space low (2)" );
+                state = EStoreSpaceLow;
+                }
+            else
+                {
+                LOG1( "CWmDrmDataStore::DataStoreStateL: Store space full (2)" );
+                state = EStoreSpaceFull;
+                }
+            }
+        else
+            // Only the system drive is running out of storage space. 
+            {
+            LOG2( "Ratio: %d", ratio );
+            if ( ratio <= iMaxSpaceRatio )
+                {
+                LOG1( "CWmDrmDataStore::DataStoreStateL Store space low" );
+                state = EStoreSpaceLow;
+                }
+            else
+                {
+                LOG1( "CWmDrmDataStore::DataStoreStateL Store space full" );
+                state = EStoreSpaceFull;
+                }
+            }    
+        }
+        
+    LOG2( "DataStoreState: %d", state );
+    return state;
+    }
+
+void CWmDrmDataStore::InitializeDummyDbFileL( const TDesC& aFileName,
+    RFile& aDummyDb, TBool& aConfiguredDrive )
+    {
+    TInt r( KErrNone );
+    
+    LOGFN( "CWmDrmDataStore::InitializeDummyDbFileL" );
+    
+    r = aDummyDb.Create( iServer->Fs(), aFileName, EFileWrite );
+    if ( r == KErrAlreadyExists )
+        {
+        User::LeaveIfError( 
+            aDummyDb.Open( iServer->Fs(), aFileName, EFileWrite ) );
+        }
+    else if( !r )
+        {
+        TInt dataStoreSize( DataStoreSizeL( aConfiguredDrive ) );
+        if ( aConfiguredDrive )
+            {
+            if ( dataStoreSize <= iDummyDbInitialSize2 )
+                {
+                User::LeaveIfError( 
+                    aDummyDb.SetSize( iDummyDbInitialSize2 - dataStoreSize ) );
+                }
+            else
+                {
+                User::LeaveIfError( aDummyDb.SetSize( 0 ) );
+                }
+            }
+        else 
+            {
+            if ( dataStoreSize <= iDummyDbInitialSize )
+                {
+                User::LeaveIfError( 
+                    aDummyDb.SetSize( iDummyDbInitialSize - dataStoreSize ) );
+                }
+            else
+                {
+                User::LeaveIfError( aDummyDb.SetSize( 0 ) );
+                }
+            } 
+        }
+    else
+        {
+        User::Leave( r );
+        }
+    }
+
+void CWmDrmDataStore::UpdateDummyDbFileL( TInt aSize, TBool aConfiguredDrive )
+    {
+    LOGFN( "CWmDrmDataStore::UpdateDummyDbFileL" );
+    LOG2( "aSize: %d", aSize );
+    if ( aSize > 0 )
+        {
+        TInt dummyDbSize( DummyDBSizeL( aConfiguredDrive ) );
+        LOG2( "dummyDbSize: %d", dummyDbSize );
+        if ( aSize <= dummyDbSize )
+            {
+            if ( aConfiguredDrive ) 
+                {
+            	User::LeaveIfError( iDummyDb2.SetSize( dummyDbSize - aSize ) );
+            	}
+            else
+            	{	
+            	User::LeaveIfError( iDummyDb.SetSize( dummyDbSize - aSize ) );
+            	}
+           	} 		
+        else
+            {
+            if ( aConfiguredDrive )
+            	{
+            	User::LeaveIfError( iDummyDb2.SetSize( 0 ) );
+            	}
+            else 
+            	{
+            	User::LeaveIfError( iDummyDb.SetSize( 0 ) );	
+          		}
+          	}		
+        }
+    else
+        {
+        TInt dataStoreSize( DataStoreSizeL( aConfiguredDrive ) );
+        LOG2( "dataStoreSize: %d", dataStoreSize );
+        if ( aConfiguredDrive )
+            {
+            if ( dataStoreSize <= iDummyDbInitialSize2 )
+                {
+                User::LeaveIfError( 
+                    iDummyDb2.SetSize( iDummyDbInitialSize2 - dataStoreSize ) );
+            	}
+            else 
+            	{
+            	User::LeaveIfError( iDummyDb2.SetSize( 0 ) );
+            	}
+            }
+        else 
+            {
+            if ( dataStoreSize <= iDummyDbInitialSize )
+                {
+                User::LeaveIfError( 
+                    iDummyDb.SetSize( iDummyDbInitialSize - dataStoreSize ) );
+            	}
+            else 
+            	{
+            	User::LeaveIfError( iDummyDb.SetSize( 0 ) );
+            	}
+            }
+        } 
+    }
+
+TInt CWmDrmDataStore::DataStoreSizeL( TBool aConfiguredDrive )
+    {
+    TInt dataStoreSize( iServer->Db()->DataBaseSize( aConfiguredDrive ) );
+    User::LeaveIfError( dataStoreSize );
+    return dataStoreSize;
+    }
+
+TInt CWmDrmDataStore::DummyDBSizeL( TBool aConfiguredDrive )
+    {
+    TInt dummyDbSize( 0 );
+    if ( aConfiguredDrive )
+        {
+        User::LeaveIfError( iDummyDb2.Size( dummyDbSize ) );
+        }
+    else
+        {
+        User::LeaveIfError( iDummyDb.Size( dummyDbSize ) );
+        }    
+    return dummyDbSize;
+    }
+
+void CWmDrmDataStore::PrepareInfoFilesL( TBool aConfiguredDrive, 
+    TChar aDriveLetter, RFile& aDummyDb )
+    {
+    LOGFN( "CWmDrmDataStore::PrepareInfoFilesL" );
+    CRepository* repository( NULL );
+    TInt r( KErrNone );
+    TFileName dummyDbFile; 
+    TFileName initialFreeSpaceFile;
+    
+    initialFreeSpaceFile.Format( KPrivateDir, (TUint)aDriveLetter );
+    iServer->Fs().MkDirAll( initialFreeSpaceFile );
+    initialFreeSpaceFile.Format( KInitialFreeSpaceFile, (TUint)aDriveLetter );
+    dummyDbFile.Format( KDummyDbFile, (TUint)aDriveLetter );
+    	
+    TRAP( r, WriteInitialFreeSpaceL( initialFreeSpaceFile, 
+        aConfiguredDrive ) );
+    if ( r )
+        {
+        r = KErrNone;
+        
+        // catch the read error
+        TRAP( r, ReadInitialFreeSpaceL( initialFreeSpaceFile, 
+            aConfiguredDrive ) );
+        
+        // if an error occurs, this means that we are unable to read the info, 
+        // thus we need to delete the file and run write again.
+        // hopefully this being a temporary error, but if we fail again we fail
+        // until next ConstructL
+        if( r != KErrNone )
+            {
+            // delete the file:
+            iServer->Fs().Delete( initialFreeSpaceFile );
+            
+            // Calc & Write the new info
+            WriteInitialFreeSpaceL( initialFreeSpaceFile, aConfiguredDrive );
+            }
+        }
+    
+    if ( aConfiguredDrive )
+        {
+#ifdef _LOGGING        
+        TBuf<KMaxTInt64BufLength> freeSpace2;
+        LOG1( "CWmDrmDataStore::DataStoreStateL: Initial free space (2): ");
+        freeSpace2.AppendNumUC( iInitialFreeSpace2, EDecimal );
+        LOG( freeSpace2 );
+#endif          
+        if ( iInitialFreeSpace2 <= 0 )
+            {
+            User::Leave( KErrNotReady );
+            }
+        }
+    else 
+        {
+#ifdef _LOGGING        
+        TBuf<KMaxTInt64BufLength> freeSpace;
+        LOG1( "CWmDrmDataStore::DataStoreStateL: Initial free space: ");
+        freeSpace.AppendNumUC( iInitialFreeSpace, EDecimal );
+        LOG( freeSpace );
+#endif          
+        if ( iInitialFreeSpace <= 0 )
+            {
+            User::Leave( KErrNotReady );
+            }
+        }
+    
+    //LOG1( "CWmDrmDataStore::PrepareInfoFilesL Check Cenrep" );
+    
+    TRAP( r, repository = CRepository::NewL( KCRUidWMDRM ) );
+    if ( repository )
+        {
+        TInt rate( 0 );
+        
+        // Check the cenrep key parameters either for the default system drive
+        // or for the internal mass drive depending whether the WMDRM rights
+        // are configured to be partially stored to the internal mass drive or
+        // not. 
+        if ( !aConfiguredDrive )
+            { 
+            r = repository->Get( KWMDRMLicStoreLowMem, rate );
+            if ( r )
+                {
+                iMinFreeSpace = KMegaByte;      
+                }
+            else
+                {
+                iMinFreeSpace = rate * KMegaByte;   
+                }
+            r = repository->Get( KWMDRMLicStoreSizeRatio, iMaxSpaceRatio );
+            if ( r )
+                {
+                iMaxSpaceRatio = KMaxSpaceRatio;
+                }
+            r = repository->Get( KWMDRMLicStoreReservedSpace, rate );
+            if ( r )
+                {
+                iDummyDbInitialSize = KDummyDbInitialSize;   
+                }
+            else
+                {
+                iDummyDbInitialSize = rate * KMegaByte;     
+                }
+            }
+        else 
+            {
+            r = repository->Get( KWMDRM2LicStoreLowMem, rate );
+            if ( r )
+                {
+                iMinFreeSpace2 = KTwoHundredMegaBytes;      
+                }
+            else
+                {
+                iMinFreeSpace2 = rate * KMegaByte;
+                }
+            r = repository->Get( KWMDRM2LicStoreSizeRatio, iMaxSpaceRatio2 );
+            if ( r )
+                {
+                iMaxSpaceRatio2 = KMaxSpaceRatio2;
+                }
+            r = repository->Get( KWMDRM2LicStoreReservedSpace, rate );
+            if ( r )
+                {
+                iDummyDbInitialSize2 = KDummyDbInitialSize;   
+                }
+            else
+                {
+                iDummyDbInitialSize2 = rate * KMegaByte;     
+                }
+            }          
+        delete repository;
+        }
+    else
+        {
+        if ( !aConfiguredDrive )
+            {
+            iMinFreeSpace = KMegaByte; 
+            iMaxSpaceRatio = KMaxSpaceRatio;
+            iDummyDbInitialSize = KDummyDbInitialSize;
+            }
+        else 
+            {
+            iMinFreeSpace2 = KTwoHundredMegaBytes; 
+            iMaxSpaceRatio2 = KMaxSpaceRatio2;
+            iDummyDbInitialSize2 = KDummyDbInitialSize;            
+            }
+        }
+     
+    InitializeDummyDbFileL( dummyDbFile, aDummyDb, aConfiguredDrive );
+    
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/wmdrmdb.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,1543 @@
+/*
+* 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:  database implementation for WMDRM
+*
+*/
+
+#include <e32std.h>
+
+#include <systemwarninglevels.hrh>
+#include "wmdrmdb.h"
+#include "wmdrmfileserverclient.h"
+#include "wmdrmdatastore.h"
+#include "drmrightsstoringlocation.h"
+#include "drmutilityinternaltypes.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+#define FROM_HEX_DIGIT(x) (x >= 'a' ? x - 'a' + 10 : x - '0')
+#define FROM_HEX(x,y) (FROM_HEX_DIGIT(x) * 16 + FROM_HEX_DIGIT(y))
+
+// For secure, sync and metering stores in the case of differentiation of stores
+// to system drive and internal mass drive or for all the stores in the case of 
+// no differentation
+_LIT( KDatabaseName, "%c:[10282F1B]hds.db" );
+
+// For license store in the case of differentation of stores. Not used
+// if no differentation is applied.                                              
+_LIT( KDatabaseName2, "%c:[10282F1B]hds2.db" );
+_LIT8( KDatabaseConfig, "cache_size=64; page_size=2048; encoding=UTF-8" );
+
+_LIT( KBeginTransaction, "BEGIN TRANSACTION" );
+_LIT( KCommitTransaction, "COMMIT TRANSACTION" );
+
+_LIT( KCreateLicenseTableString, "CREATE TABLE IF NOT EXISTS license_t (hashKey BINARY NOT NULL, uniqueKey BINARY NOT NULL, data BINARY, PRIMARY KEY(hashKey, uniqueKey))" );
+_LIT( KCreateSecureTableString, "CREATE TABLE IF NOT EXISTS secure_t (hashKey BINARY NOT NULL, uniqueKey BINARY NOT NULL, data BINARY, PRIMARY KEY(hashKey, uniqueKey))" );
+_LIT( KCreateSyncTableString, "CREATE TABLE IF NOT EXISTS sync_t (hashKey BINARY NOT NULL, uniqueKey BINARY NOT NULL, data BINARY, PRIMARY KEY(hashKey, uniqueKey))" );
+_LIT( KCreateMeteringTableString, "CREATE TABLE IF NOT EXISTS metering_t (hashKey BINARY NOT NULL, uniqueKey BINARY NOT NULL, data BINARY, PRIMARY KEY(hashKey, uniqueKey))" );
+
+_LIT( KDeleteLicenseTableString, "DROP TABLE IF EXISTS license_t" );
+_LIT( KDeleteSecureTableString, "DROP TABLE IF EXISTS secure_t" );
+_LIT( KDeleteSyncTableString, "DROP TABLE IF EXISTS sync_t" );
+_LIT( KDeleteMeteringTableString, "DROP TABLE IF EXISTS metering_t" );
+
+_LIT( KSelectNRowIDsLicenseTableString, "SELECT RowID FROM license_t LIMIT %d" );
+_LIT( KSelectNRowIDsSecureTableString, "SELECT RowID FROM secure_t LIMIT %d" );
+_LIT( KSelectNRowIDsSyncTableString, "SELECT RowID FROM sync_t LIMIT %d" );
+_LIT( KSelectNRowIDsMeteringTableString, "SELECT RowID FROM metering_t LIMIT %d" );
+
+_LIT( KDeleteWithRowIDLicenseTableString, "DELETE FROM license_t WHERE RowID = :rowID" );
+_LIT( KDeleteWithRowIDSecureTableString, "DELETE FROM secure_t WHERE RowID = :rowID" );
+_LIT( KDeleteWithRowIDSyncTableString, "DELETE FROM sync_t WHERE RowID = :rowID" );
+_LIT( KDeleteWithRowIDMeteringTableString, "DELETE FROM metering_t WHERE RowID = :rowID" );
+
+_LIT( KDeleteLicenseString, "DELETE FROM license_t WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+_LIT( KDeleteSecureString, "DELETE FROM secure_t WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+_LIT( KDeleteSyncString, "DELETE FROM sync_t WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+_LIT( KDeleteMeteringString, "DELETE FROM metering_t WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+
+_LIT( KInsertLicenseString, "INSERT INTO license_t (hashKey, uniqueKey) VALUES (:HashKey, :UniqueKey)" );
+_LIT( KInsertSecureString, "INSERT INTO secure_t (hashKey, uniqueKey) VALUES (:HashKey, :UniqueKey)" );
+_LIT( KInsertSyncString, "INSERT INTO sync_t (hashKey, uniqueKey) VALUES (:HashKey, :UniqueKey)" );
+_LIT( KInsertMeteringString, "INSERT INTO metering_t (hashKey, uniqueKey) VALUES (:HashKey, :UniqueKey)" );
+
+_LIT( KUpdateLicenseDataString, "UPDATE license_t SET data=:Data WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+_LIT( KUpdateSecureDataString, "UPDATE secure_t SET data=:Data WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+_LIT( KUpdateSyncDataString, "UPDATE sync_t SET data=:Data WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+_LIT( KUpdateMeteringDataString, "UPDATE metering_t SET data=:Data WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+
+_LIT( KSelectLicenseString, "SELECT data FROM license_t WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+_LIT( KSelectSecureString, "SELECT data FROM secure_t WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+_LIT( KSelectSyncString, "SELECT data FROM sync_t WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+_LIT( KSelectMeteringString, "SELECT data FROM metering_t WHERE hashKey = :HashKey AND uniqueKey=:UniqueKey" );
+
+_LIT( KSelectLicenseEnumeratorString, "SELECT uniqueKey FROM license_t WHERE hashKey = :HashKey" );
+_LIT( KSelectSecureEnumeratorString, "SELECT uniqueKey FROM secure_t WHERE hashKey = :HashKey" );
+_LIT( KSelectSyncEnumeratorString, "SELECT uniqueKey FROM sync_t WHERE hashKey = :HashKey" );
+_LIT( KSelectMeteringEnumeratorString, "SELECT uniqueKey FROM metering_t WHERE hashKey = :HashKey" );
+
+_LIT( KSelectLicenseNameSpaceEnumeratorString, "SELECT hashKey, uniqueKey FROM license_t" );
+_LIT( KSelectSecureNameSpaceEnumeratorString, "SELECT hashKey, uniqueKey FROM secure_t" );
+_LIT( KSelectSyncNameSpaceEnumeratorString, "SELECT hashKey, uniqueKey FROM sync_t" );
+_LIT( KSelectMeteringNameSpaceEnumeratorString, "SELECT hashKey, uniqueKey FROM metering_t" );
+
+_LIT( KHashKeyColumn, "hashkey" );
+_LIT( KHashKeyParameter, ":HashKey" );
+_LIT( KUniqueKeyColumn, "uniquekey" );
+_LIT( KUniqueKeyParameter, ":UniqueKey" );
+_LIT( KDataColumn, "data" );
+_LIT( KDataParameter, ":Data" );
+_LIT( KRowIDColumn, "rowID" );
+_LIT( KRowIDParameter, ":rowID" );
+
+_LIT8( KSyncStore, "syncstore" );
+_LIT8( KMeteringStore, "meteringstore" );
+_LIT8( KSecureStore, "securestore" );
+_LIT8( KLicenseStore, "licstore" );
+_LIT8( KHds, "hds" );
+
+const TSecureId KWmDrmServerSecureId( 0x10282F1B );
+const TInt KMaxTIntBufLength( 10 );
+const TInt KLicenseSize( 5 * 1024 );
+const TInt KSixtySeconds( 60 );
+const TInt KMaxOperationsUntilCommit( 60 );
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::CWmDrmDb
+// ---------------------------------------------------------------------------
+//
+CWmDrmDb::CWmDrmDb( CWmDrmServer* aServer ) : CTimer( EPriorityHigh ), 
+    iServer( aServer ),
+    iAmountOperationsWithoutCommit( 0 ),
+    iSqlTransactionOngoing( EFalse ),
+    iSqlTransactionOngoing2( EFalse )   
+    {
+    CActiveScheduler::Add( this );
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::ConstructL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::ConstructL()
+    {
+    LOGFN( "CWmDrmDb::ConstructL" );
+    TDrmScheme drmScheme( EDrmSchemeWmDrm );
+    TChar driveLetter;
+	TChar systemDriveLetter;
+    
+    CTimer::ConstructL();
+    
+    // Check which drive is configured in the Central Repository Key
+    // for the desired storing location of WM DRM rights.
+	iWmDrmRightsConfigFound = DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( 
+        iServer->Fs(), drmScheme, driveLetter );
+    
+    // Format the default database path on the system drive and open
+    // the database. If the storing location is not configured, this database
+    // will hold all the four stores, otherwise only the secure and metering
+    // stores.
+	if ( !iWmDrmRightsConfigFound )
+		{
+    	iDatabasePath.Format( KDatabaseName, (TUint)driveLetter );
+    	OpenDatabaseL( iDatabasePath, iDatabase, EFalse );
+    	}
+    else 
+        {
+        // Format the database path also on the internal mass drive and 
+        // open both databases. The database on the default system drive
+        // includes metering and secure stores, whereas the store on the
+        // configured drive includes sync and license stores.
+		iDatabasePath.Format( KDatabaseName, 
+		    (TUint)iServer->Fs().GetSystemDriveChar() );
+        iDatabasePath2.Format( KDatabaseName2, (TUint)driveLetter );
+        OpenDatabaseL( iDatabasePath, iDatabase, EFalse );
+		OpenDatabaseL( iDatabasePath2, iDatabase2, ETrue );
+        }               
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::NewL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDb* CWmDrmDb::NewL( CWmDrmServer* aServer )
+    {
+    LOGFN( "CWmDrmDb::NewL" );
+    CWmDrmDb* self( CWmDrmDb::NewLC( aServer ) );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::NewLC
+// ---------------------------------------------------------------------------
+//
+CWmDrmDb* CWmDrmDb::NewLC( CWmDrmServer* aServer )
+    {
+    LOGFN( "CWmDrmDb::NewLC" );
+    CWmDrmDb* self( new( ELeave ) CWmDrmDb( aServer ) );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::~CWmDrmDb
+// ---------------------------------------------------------------------------
+//
+CWmDrmDb::~CWmDrmDb()
+    {
+    LOGFN( "CWmDrmDb::~CWmDrmDb" );
+    
+    TInt error( KErrNone );
+    
+    if ( IsActive() )
+        {
+        Cancel();
+        }
+    
+    // Checks if there are prepared SQL operations that need to be 
+    // committed before the object is destroyed.
+    TRAP( error, CheckDatabaseCommitL( ETrue ) );
+       
+    delete iData;
+    iEnumerateNamespaceStmt.Close();
+    iDatabase.Close();
+    if ( iWmDrmRightsConfigFound )
+		{
+		iDatabase2.Close();
+		}
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::RunL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::RunL()
+    {
+    LOGFN( "CWmDrmDb::RunL()" );
+    
+    switch ( iStatus.Int() )
+        {
+        case KErrNone:
+            // Normal completition
+            
+        case KErrUnderflow:
+            // Time has already passed.
+            
+        case KErrAbort:
+            // System time changed
+            CheckDatabaseCommitL( ETrue );
+            break;
+
+        default:
+            // Some other (real) error
+            // Handled in RunError
+            User::Leave( iStatus.Int() );
+        }
+    }
+
+// ------------------------------------------------------------------------
+// CWmDrmDb::RunError
+// ------------------------------------------------------------------------
+//
+#if defined( _DEBUG ) || defined( _LOGGING )
+TInt CWmDrmDb::RunError( TInt aError )
+#else
+TInt CWmDrmDb::RunError( TInt /* aError */ )
+#endif
+    {
+    LOG2( "CWmDrmDb::RunError %d", aError );
+    // Continue normally and return KErrNone.
+    return KErrNone;    
+    }
+    
+// ------------------------------------------------------------------------
+// CDRMConsume:: Activate
+// ------------------------------------------------------------------------
+void CWmDrmDb::Activate()
+    {
+    LOGFN( "CWmDrmDb::Activate()" );
+    
+    // Activate one minute timer
+    After( TTimeIntervalMicroSeconds32( KSixtySeconds * 1000000 ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::InitStoreL 
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::InitStoreL( 
+    const TDesC8& aStore,
+    TBool /*aCreateIfMissing*/ )
+    {
+    LOGFN( "CWmDrmDb::InitStoreL" );
+    if ( aStore.CompareC( KHds ) == 0 )
+        {
+        if ( iWmDrmRightsConfigFound )
+            {
+            CreateDatabaseL( iDatabasePath, iDatabase, EFalse );
+            CreateDatabaseL( iDatabasePath2, iDatabase2, ETrue );
+            }
+        else
+            {
+            CreateDatabaseL( iDatabasePath, iDatabase, EFalse );
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::InitNameSpaceL 
+// ---------------------------------------------------------------------------
+//    
+void CWmDrmDb::InitNameSpaceL( 
+    const TDesC8& /*aStore*/,
+    const TDesC8& aNamespace,
+    TBool /*aCreateIfMissing*/ )
+    {
+    LOGFN( "CWmDrmDb::InitializeL" );
+    TWmDrmTableType tableType( TableTypeL( aNamespace ) );
+    if ( ( tableType == EWmDrmLicenseTable ) && iWmDrmRightsConfigFound )
+    		{  
+    		CreateTableL( tableType, iDatabase2 );
+    		}
+    else
+    		{		
+  			CreateTableL( tableType, iDatabase );
+  			}
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::RemoveStoreL 
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::RemoveStoreL( const TDesC8& aStore )
+    {
+    LOGFN( "CWmDrmDb::RemoveStoreL" );
+    if ( aStore.CompareC( KHds ) == 0 )
+        {
+        // Delete databases
+        iDatabase.Close();
+        User::LeaveIfError( RSqlDatabase::Delete( iDatabasePath ) );
+        
+        // If WM DRM rights storing configuration is found -> delete also
+        // the database on the internal mass drive.
+        if ( iWmDrmRightsConfigFound )
+            {
+            iDatabase2.Close();
+            User::LeaveIfError( RSqlDatabase::Delete( iDatabasePath2 ) );
+            CreateDatabaseL( iDatabasePath, iDatabase, EFalse );
+            CreateDatabaseL( iDatabasePath2, iDatabase2, ETrue );
+            }
+        else
+            {
+            CreateDatabaseL( iDatabasePath, iDatabase, EFalse );
+            }
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::RemoveNameSpaceL 
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::RemoveNameSpaceL( 
+    const TDesC8& /*aStore*/,
+    const TDesC8& aNamespace )
+    {
+    LOGFN( "CWmDrmDb::RemoveNameSpaceL" );
+    TWmDrmTableType tableType( TableTypeL( aNamespace ) );
+    DeleteTableL( tableType );
+    if ( ( tableType == EWmDrmLicenseTable ) && iWmDrmRightsConfigFound )
+    		{  
+    		CreateTableL( tableType, iDatabase2 );
+    		}
+    else
+    		{			
+  			CreateTableL( tableType, iDatabase );
+  			}
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::DeleteLicenseStoreL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::DeleteLicenseStoreL()
+    {
+    LOGFN( "CWmDrmDb::DeleteLicenseStoreL" );
+    
+   	DeleteTableL( EWmDrmLicenseTable );
+    DeleteTableL( EWmDrmSecureTable );
+    DeleteTableL( EWmDrmSyncTable );
+    
+    if ( iWmDrmRightsConfigFound )
+    		{
+    		CreateTableL( EWmDrmLicenseTable, iDatabase2 );
+   			}
+    else
+    		{
+    		CreateTableL( EWmDrmLicenseTable, iDatabase );
+    		}
+    CreateTableL( EWmDrmSecureTable, iDatabase );
+	CreateTableL( EWmDrmSyncTable, iDatabase );		
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::CreateRecordL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::CreateRecordL(   
+    const TDesC8& /*aStore*/,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey,
+    const TInt&   aSize )
+    {
+    LOGFN( "CWmDrmDb::CreateRecordL" );
+    TPtrC statementString( NULL, 0 );
+    
+    // Check if we should begin transaction, cache operation or commit
+    // cached operations 
+    CheckDatabaseCommitL( EFalse );
+    
+    // First, find the table where record should be created
+    TWmDrmTableType tableType( TableTypeL( aNamespace ) );
+    
+    // Update the dummy database file at this point.
+    if ( iWmDrmRightsConfigFound && ( tableType == EWmDrmLicenseTable ) )
+        {
+        iServer->DataStore()->UpdateDummyDbFileL( aSize, ETrue );
+        }
+    else 
+    	{
+    	iServer->DataStore()->UpdateDummyDbFileL( aSize, EFalse );
+    	} 	    
+        
+    // bind sql statement to database
+    RSqlStatement stmt;
+    CleanupClosePushL( stmt );
+    
+    //Select correct insert string
+    switch ( tableType )
+        {
+        case EWmDrmLicenseTable:
+            statementString.Set( KInsertLicenseString().Ptr(), 
+                                 KInsertLicenseString().Length() );
+            if ( iWmDrmRightsConfigFound )
+                {
+                stmt.PrepareL( iDatabase2, statementString );
+                }
+            else 
+                {
+                stmt.PrepareL( iDatabase, statementString );
+                }           
+            break;
+        case EWmDrmSecureTable:
+            statementString.Set( KInsertSecureString().Ptr(), 
+                                 KInsertSecureString().Length() );
+            stmt.PrepareL( iDatabase, statementString );                     
+            break;
+        case EWmDrmSyncTable:
+            statementString.Set( KInsertSyncString().Ptr(), 
+                                 KInsertSyncString().Length() );        
+        	stmt.PrepareL( iDatabase, statementString );       
+            break;
+        case EWmDrmMeteringTable:
+            statementString.Set( KInsertMeteringString().Ptr(), 
+                                 KInsertMeteringString().Length() );
+            stmt.PrepareL( iDatabase, statementString );                           
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    // Get index of hash key parameter
+    TInt hashKeyIndex( stmt.ParameterIndex( KHashKeyParameter ) );
+    User::LeaveIfError( hashKeyIndex );
+    
+    // Replace hash key parameter
+    User::LeaveIfError( stmt.BindBinary( hashKeyIndex, aHashKey ) );
+    
+    // Get index of unique key parameter
+    TInt uniqueKeyIndex( stmt.ParameterIndex( KUniqueKeyParameter ) );
+    User::LeaveIfError( uniqueKeyIndex );
+    
+    // Replace unique key parameter
+    User::LeaveIfError( stmt.BindBinary( uniqueKeyIndex, aUniqueKey ) );
+    
+    TInt err( KErrNone );
+    // Execute SQL statement
+    err = stmt.Exec();
+    if ( err == KSqlErrConstraint )
+        {
+        User::Leave( KErrAlreadyExists );
+        }
+    User::LeaveIfError( err );
+    // Close SQL statement
+    CleanupStack::PopAndDestroy( &stmt );
+    
+    // Update the dummy database file at this point.
+    if ( iWmDrmRightsConfigFound && ( tableType == EWmDrmLicenseTable ) )
+        {
+        iServer->DataStore()->UpdateDummyDbFileL( 0, ETrue );
+        }
+    else 
+    	{    
+    	iServer->DataStore()->UpdateDummyDbFileL( 0, EFalse );
+    	}
+    		
+    iAmountOperationsWithoutCommit++;	
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::ReadRecordL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::ReadRecordL(  
+    const TDesC8& /*aStore*/,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey )
+    {
+    LOGFN( "CWmDrmDb::ReadRecordL" );
+    TPtrC statementString( NULL, 0 );
+    // First, find from which table record should be read
+    TWmDrmTableType tableType( TableTypeL( aNamespace ) );
+    
+    // bind sql statement to database
+    RSqlStatement stmt;
+    CleanupClosePushL( stmt );
+    
+    // Select correct insert string
+    switch ( tableType )
+        {
+        case EWmDrmLicenseTable:
+            statementString.Set( KSelectLicenseString().Ptr(), 
+                                 KSelectLicenseString().Length() );
+            if ( iWmDrmRightsConfigFound )
+                {
+                stmt.PrepareL( iDatabase2, statementString );
+                }
+            else 
+                {
+                stmt.PrepareL( iDatabase, statementString );
+                }                                           
+            break;
+        case EWmDrmSecureTable:
+            statementString.Set( KSelectSecureString().Ptr(), 
+                                 KSelectSecureString().Length() );
+            stmt.PrepareL( iDatabase, statementString );
+            break;
+        case EWmDrmSyncTable:
+            statementString.Set( KSelectSyncString().Ptr(), 
+                                 KSelectSyncString().Length() );     
+            stmt.PrepareL( iDatabase, statementString );                      
+            break;
+        case EWmDrmMeteringTable:
+            statementString.Set( KSelectMeteringString().Ptr(), 
+                                 KSelectMeteringString().Length() );
+            stmt.PrepareL( iDatabase, statementString );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+    
+    // Get index of hash key parameter
+    TInt hashKeyIndex( stmt.ParameterIndex( KHashKeyParameter ) );
+    User::LeaveIfError( hashKeyIndex );
+
+    // Replace key parameter
+    User::LeaveIfError( stmt.BindBinary( hashKeyIndex, aHashKey ) );
+
+    TInt uniqueKeyIndex( stmt.ParameterIndex( KUniqueKeyParameter ) );
+    User::LeaveIfError( uniqueKeyIndex );
+    
+    // Replace unique key parameter
+    User::LeaveIfError( stmt.BindBinary( uniqueKeyIndex, aUniqueKey ) );
+    
+    // Read data
+    TInt dataColumnIndex( stmt.ColumnIndex( KDataColumn ) );
+    User::LeaveIfError( dataColumnIndex );
+
+    if ( stmt.Next() == KSqlAtRow )
+        {
+        // If there is previously cached data, delete it
+        delete iData;
+        iData = NULL;
+        
+        TPtrC8 data( NULL, 0 );
+        User::LeaveIfError( stmt.ColumnBinary( dataColumnIndex, data ) );
+        iData = data.AllocL();
+        }
+    else 
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    // Close SQL statement
+    CleanupStack::PopAndDestroy( &stmt );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::GetDataSizeL 
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::GetDataSizeL( TInt& aDataSize )
+    {
+    LOGFN( "CWmDrmDb::GetDataSizeL" );
+    User::LeaveIfNull( iData );
+    aDataSize = iData->Size();
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::DeleteData 
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::DeleteData()
+    {
+    LOGFN( "CWmDrmDb::DeleteData" );
+    delete iData;
+    iData = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::DeleteRecordL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::DeleteRecordL(   
+    const TDesC8& /*aStore*/,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey )
+    {
+    LOGFN( "CWmDrmDb::DeleteRecordL" );
+    TPtrC statementString( NULL, 0 );
+    
+    // Check if we should begin transaction, cache operation or commit
+    // cached operations 
+    CheckDatabaseCommitL( EFalse );
+    
+    // First, find the table where record should be created
+    TWmDrmTableType tableType( TableTypeL( aNamespace ) );
+    
+    // bind sql statement to database
+    RSqlStatement stmt;
+    CleanupClosePushL( stmt );
+    
+    //Select correct insert string
+    switch ( tableType )
+        {
+        case EWmDrmLicenseTable:
+            statementString.Set( KDeleteLicenseString().Ptr(), 
+                                 KDeleteLicenseString().Length() );
+            if ( iWmDrmRightsConfigFound )
+                {
+                stmt.PrepareL( iDatabase2, statementString );
+                }
+            else 
+                {
+                stmt.PrepareL( iDatabase, statementString );
+                }                      
+            break;
+        case EWmDrmSecureTable:
+            statementString.Set( KDeleteSecureString().Ptr(), 
+                                 KDeleteSecureString().Length() );
+            stmt.PrepareL( iDatabase, statementString );                     
+            break;
+        case EWmDrmSyncTable:
+            statementString.Set( KDeleteSyncString().Ptr(), 
+                                 KDeleteSyncString().Length() );
+            stmt.PrepareL( iDatabase, statementString );
+            break;
+        case EWmDrmMeteringTable:
+            statementString.Set( KDeleteMeteringString().Ptr(), 
+                                 KDeleteMeteringString().Length() );
+            stmt.PrepareL( iDatabase, statementString );                     
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    // Get index of hash key parameter
+    TInt hashKeyIndex( stmt.ParameterIndex( KHashKeyParameter ) );
+    User::LeaveIfError( hashKeyIndex );
+    
+    // Replace hash key parameter
+    User::LeaveIfError( stmt.BindBinary( hashKeyIndex, aHashKey ) );
+    
+    // Get index of unique key parameter
+    TInt uniqueKeyIndex( stmt.ParameterIndex( KUniqueKeyParameter ) );
+    User::LeaveIfError( uniqueKeyIndex );
+    
+    // Replace unique key parameter
+    User::LeaveIfError( stmt.BindBinary( uniqueKeyIndex, aUniqueKey ) );
+    
+    // Execute SQL statement
+    User::LeaveIfError( stmt.Exec() );
+    
+    // Update dummy database file at this point.
+    if ( iWmDrmRightsConfigFound && ( tableType == EWmDrmLicenseTable ) )
+        {
+        iServer->DataStore()->UpdateDummyDbFileL( 0, ETrue );
+        }
+    else 
+    	{
+    	iServer->DataStore()->UpdateDummyDbFileL( 0, EFalse );
+    	} 	  
+    
+    // Close SQL statement
+    CleanupStack::PopAndDestroy( &stmt );
+    
+    iAmountOperationsWithoutCommit++;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::ReadDataL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::ReadDataL( TDes8& aData )
+    {
+    LOGFN( "CWmDrmDb::ReadDataL" );
+    User::LeaveIfNull( iData );
+    aData.Copy( *iData );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::WriteDataL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::WriteDataL(   
+    const TDesC8& /*aStore*/,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    const TDesC8& aUniqueKey, 
+    TDesC8& aData )
+    {
+    LOGFN( "CWmDrmDb::WriteDataL" );
+    TPtrC statementString( NULL, 0 );
+    
+    // Check if we should begin transaction, cache operation or commit
+    // cached operations 
+    CheckDatabaseCommitL( EFalse );
+    
+    // First, find from which table record should be read
+    TWmDrmTableType tableType( TableTypeL( aNamespace ) );
+    
+    // Update the dummy database file at this point.
+    if ( iWmDrmRightsConfigFound && ( tableType == EWmDrmLicenseTable ) )
+        {
+        iServer->DataStore()->UpdateDummyDbFileL( aData.Size(), ETrue );
+        }
+    else 
+    	{
+    	iServer->DataStore()->UpdateDummyDbFileL( aData.Size(), EFalse );
+    	} 	  
+    
+    // bind sql statement to database
+    RSqlStatement stmt;
+    CleanupClosePushL( stmt );
+    
+    //Select correct insert string
+    switch ( tableType )
+        {
+        case EWmDrmLicenseTable:
+            statementString.Set( KUpdateLicenseDataString().Ptr(), 
+                                 KUpdateLicenseDataString().Length() );
+            if ( iWmDrmRightsConfigFound )
+                {
+                stmt.PrepareL( iDatabase2, statementString );
+                }
+            else 
+                {
+                stmt.PrepareL( iDatabase, statementString );
+                }                                           
+            break;
+        case EWmDrmSecureTable:
+            statementString.Set( KUpdateSecureDataString().Ptr(), 
+                                 KUpdateSecureDataString().Length() );
+            stmt.PrepareL( iDatabase, statementString );                     
+            break;
+        case EWmDrmSyncTable:
+            statementString.Set( KUpdateSyncDataString().Ptr(), 
+                                 KUpdateSyncDataString().Length() );
+            stmt.PrepareL( iDatabase, statementString );                                          
+            break;
+        case EWmDrmMeteringTable:
+            statementString.Set( KUpdateMeteringDataString().Ptr(), 
+                                 KUpdateMeteringDataString().Length() );
+            stmt.PrepareL( iDatabase, statementString );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+    
+    // Get index of hash key parameter
+    TInt hashKeyIndex( stmt.ParameterIndex( KHashKeyParameter ) );
+    User::LeaveIfError( hashKeyIndex );
+
+    // Replace key parameter
+    User::LeaveIfError( stmt.BindBinary( hashKeyIndex, aHashKey ) );
+
+    // Get index of unique key parameter
+    TInt uniqueKeyIndex( stmt.ParameterIndex( KUniqueKeyParameter ) );
+    User::LeaveIfError( uniqueKeyIndex );
+
+    // Replace key parameter
+    User::LeaveIfError( stmt.BindBinary( uniqueKeyIndex, aUniqueKey ) );
+
+    // Get index of value parameter
+    TInt dataIndex( stmt.ParameterIndex( KDataParameter ) );
+    User::LeaveIfError( dataIndex );
+
+    // Replace value parameter
+    User::LeaveIfError( stmt.BindBinary( dataIndex, aData ) );
+
+    // Execute SQL statement
+    LOG1( "CWmDrmDb::WriteDataL exec" );
+    User::LeaveIfError( stmt.Exec() );
+    LOG1( "CWmDrmDb::WriteDataL exec ok" );
+    
+    // Close SQL statement
+    CleanupStack::PopAndDestroy( &stmt );
+    
+    iAmountOperationsWithoutCommit++;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::EnumerateDataL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::EnumerateDataL(  
+    const TDesC8& /*aStore*/,
+    const TDesC8& aNamespace,
+    const TDesC8& aHashKey,
+    RPointerArray<HBufC8>& aUniqueKeyEntries )
+    {
+    LOGFN( "CWmDrmDb::EnumerateDataL" );
+    TPtrC statementString( NULL, 0 );
+    // First, find from which table record should be read
+    TWmDrmTableType tableType( TableTypeL( aNamespace ) );
+    
+    // bind sql statement to database
+    RSqlStatement stmt;
+    CleanupClosePushL( stmt );
+    
+    //Select correct insert string
+    switch ( tableType )
+        {
+        case EWmDrmLicenseTable:
+            statementString.Set( KSelectLicenseEnumeratorString().Ptr(), 
+                                 KSelectLicenseEnumeratorString().Length() );
+            if ( iWmDrmRightsConfigFound )
+                {
+                stmt.PrepareL( iDatabase2, statementString );
+                }
+            else 
+                {
+                stmt.PrepareL( iDatabase, statementString );
+                }                                                
+            break;
+        case EWmDrmSecureTable:
+            statementString.Set( KSelectSecureEnumeratorString().Ptr(), 
+                                 KSelectSecureEnumeratorString().Length() );
+            stmt.PrepareL( iDatabase, statementString );                     
+            break;
+        case EWmDrmSyncTable:
+            statementString.Set( KSelectSyncEnumeratorString().Ptr(), 
+                                 KSelectSyncEnumeratorString().Length() );
+            stmt.PrepareL( iDatabase, statementString );                       
+            break;
+        case EWmDrmMeteringTable:
+            statementString.Set( KSelectMeteringEnumeratorString().Ptr(), 
+                                 KSelectMeteringEnumeratorString().Length() );
+            stmt.PrepareL( iDatabase, statementString );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+
+    TInt hashKeyIndex( stmt.ParameterIndex( KHashKeyParameter ) );
+    User::LeaveIfError( hashKeyIndex );
+    
+    // Replace hash key parameter
+    User::LeaveIfError( stmt.BindBinary( hashKeyIndex, aHashKey ) );
+
+    TInt uniqueKeyColumnIndex( stmt.ColumnIndex( KUniqueKeyColumn ) );
+    User::LeaveIfError( uniqueKeyColumnIndex );
+
+    TInt err( KErrNone );
+    TInt index( 0 );
+    TPtrC8 uniqueKeyPtr( NULL, 0 );
+    HBufC8* uniquekey( NULL );
+    while( ( err = stmt.Next() ) == KSqlAtRow )
+        {
+        index++;
+        User::LeaveIfError( 
+            stmt.ColumnBinary( uniqueKeyColumnIndex, uniqueKeyPtr ) );
+        uniquekey = uniqueKeyPtr.AllocLC();
+        aUniqueKeyEntries.AppendL( uniquekey );
+        CleanupStack::Pop( uniquekey );
+        }
+    if ( err != KSqlAtEnd )
+        {
+        User::Leave( err );
+        }
+    if ( index == 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    // Close SQL statement
+    CleanupStack::PopAndDestroy( &stmt );
+    }
+    
+// ---------------------------------------------------------------------------
+// CWmDrmDb::EnumerateNameSpaceStartL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::EnumerateNameSpaceStartL(  
+    const TDesC8& /*aStore*/,
+    const TDesC8& aNamespace )
+    {
+    LOGFN( "CWmDrmDb::EnumerateNameSpaceStartL" );
+    TPtrC statementString( NULL, 0 );
+    // First, find from which table record should be read
+    TWmDrmTableType tableType( TableTypeL( aNamespace ) );
+    
+    //Select correct insert string
+    switch ( tableType )
+        {
+        case EWmDrmLicenseTable:
+            statementString.Set( KSelectLicenseNameSpaceEnumeratorString().Ptr(), 
+                                 KSelectLicenseNameSpaceEnumeratorString().Length() );
+            // bind sql statement to database                     
+            iEnumerateNamespaceStmt.Close();
+            if ( iWmDrmRightsConfigFound )
+                {
+                iEnumerateNamespaceStmt.PrepareL( iDatabase2, statementString );
+                }
+            else 
+                {
+                iEnumerateNamespaceStmt.PrepareL( iDatabase, statementString );
+                }                     
+            break;
+        case EWmDrmSecureTable:
+            statementString.Set( KSelectSecureNameSpaceEnumeratorString().Ptr(), 
+                                 KSelectSecureNameSpaceEnumeratorString().Length() );                     
+            iEnumerateNamespaceStmt.Close();
+            iEnumerateNamespaceStmt.PrepareL( iDatabase, statementString );                     
+            break;
+        case EWmDrmSyncTable:
+            statementString.Set( KSelectSyncNameSpaceEnumeratorString().Ptr(), 
+                                 KSelectSyncNameSpaceEnumeratorString().Length() );                     
+            iEnumerateNamespaceStmt.Close();                     
+            iEnumerateNamespaceStmt.PrepareL( iDatabase, statementString );
+            break;
+        case EWmDrmMeteringTable:
+            statementString.Set( KSelectMeteringNameSpaceEnumeratorString().Ptr(), 
+                                 KSelectMeteringNameSpaceEnumeratorString().Length() );                     
+            iEnumerateNamespaceStmt.Close();                     
+            iEnumerateNamespaceStmt.PrepareL( iDatabase, statementString );                     
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+    
+    iEnumerateNamespaceHashKeyColumnIndex = 
+        iEnumerateNamespaceStmt.ColumnIndex( KHashKeyColumn );
+    User::LeaveIfError( iEnumerateNamespaceHashKeyColumnIndex );
+    
+    iEnumerateNamespaceUniqueKeyColumnIndex = 
+        iEnumerateNamespaceStmt.ColumnIndex( KUniqueKeyColumn );
+    User::LeaveIfError( iEnumerateNamespaceUniqueKeyColumnIndex );
+    iEnumerateNamespaceStarted = ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::EnumerateNameSpaceNextL
+// ---------------------------------------------------------------------------
+//    
+void CWmDrmDb::EnumerateNameSpaceNextL(  
+    TBuf8<KWmDrmIdSize>& aHashKey,
+    TBuf8<KWmDrmIdSize>& aUniqueKey )
+    {
+    LOGFN( "CWmDrmDb::EnumerateNameSpaceNextL" );
+    if ( !iEnumerateNamespaceStarted )
+        {
+        User::Leave( KErrNotReady );
+        }
+    if ( iEnumerateNamespaceStmt.Next() == KSqlAtRow )
+        {
+        TPtrC8 hashKey( NULL, 0 );
+        TPtrC8 uniqueKey( NULL, 0 );
+        User::LeaveIfError( 
+            iEnumerateNamespaceStmt.ColumnBinary( 
+                iEnumerateNamespaceHashKeyColumnIndex, hashKey ) );
+        aHashKey.Copy( hashKey );
+        User::LeaveIfError( 
+            iEnumerateNamespaceStmt.ColumnBinary( 
+                iEnumerateNamespaceUniqueKeyColumnIndex, uniqueKey ) );
+        aUniqueKey.Copy( uniqueKey );
+        }
+    else 
+        {
+        iEnumerateNamespaceStmt.Close();
+        iEnumerateNamespaceStarted = EFalse;
+        User::Leave( KErrNotFound );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::DataBaseSize
+// ---------------------------------------------------------------------------
+//
+TInt CWmDrmDb::DataBaseSize( TBool aConfiguredDrive )
+    {
+    // Find the database size for the database which is located in the
+    // configured drive
+    if ( aConfiguredDrive )
+        {
+        return iDatabase2.Size();
+        }
+    else
+        {
+        return iDatabase.Size();
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::CreateDatabaseL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::CreateDatabaseL( TFileName& aFileNamePath, RSqlDatabase&
+    aSqlDatabase, TBool aConfiguredDrive )
+    {
+    LOGFN( "CWmDrmDb::CreateDatabaseL" );
+    TSecurityPolicy defaultPolicy( KWmDrmServerSecureId );
+    RSqlSecurityPolicy securityPolicy;
+    securityPolicy.CreateL( defaultPolicy );
+    CleanupClosePushL( securityPolicy );
+ 
+    aSqlDatabase.CreateL( aFileNamePath, securityPolicy, &KDatabaseConfig );
+ 
+    if ( aConfiguredDrive ) 
+        {
+        // Create the license store to the configured drive
+        CreateTableL( EWmDrmLicenseTable, aSqlDatabase );   
+        }
+    else 
+        {
+        // Secure, metering and sync stores are located on the system drive in
+        // configured and non-configured WM DRM rights storing location case.
+        CreateTableL( EWmDrmSecureTable, aSqlDatabase );
+        CreateTableL( EWmDrmMeteringTable, aSqlDatabase );
+		CreateTableL( EWmDrmSyncTable, aSqlDatabase );
+		
+        if ( !iWmDrmRightsConfigFound )
+            {
+            CreateTableL( EWmDrmLicenseTable, aSqlDatabase );
+            }
+        }
+    
+    CleanupStack::PopAndDestroy( &securityPolicy );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::CreateTableL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::CreateTableL( TWmDrmTableType aTableType, RSqlDatabase& aDatabase )
+    {
+    LOGFN( "CWmDrmDb::CreateTableL" );
+    switch ( aTableType )
+        {
+        case EWmDrmLicenseTable:
+            User::LeaveIfError( aDatabase.Exec( KCreateLicenseTableString ) );
+            break;
+        case EWmDrmSecureTable:
+            User::LeaveIfError( aDatabase.Exec( KCreateSecureTableString ) );
+            break;
+        case EWmDrmSyncTable:
+            User::LeaveIfError( aDatabase.Exec( KCreateSyncTableString ) );
+            break;
+        case EWmDrmMeteringTable:
+            User::LeaveIfError( aDatabase.Exec( KCreateMeteringTableString ) );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::DeleteTableL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::DeleteTableL( TWmDrmTableType aTableType )
+    {
+    LOGFN( "CWmDrmDb::DeleteTableL" );
+    TInt count( 1 );
+    TInt64 freeSpace( 0 );
+    TInt databaseSize( 0 );
+    
+    // Commit the cached database operations before deleting the table
+    CheckDatabaseCommitL( ETrue );
+        
+    // Check the free space from the system drive or internal mass drive
+    // depending on the WM DRM rights storing location configuration and
+    // the table type of the database
+    if ( iWmDrmRightsConfigFound && ( aTableType == EWmDrmLicenseTable ) )
+        {
+        freeSpace = iServer->FreeSpaceL( ETrue );
+        databaseSize = DataBaseSize( ETrue );
+        User::LeaveIfError( databaseSize );
+        
+        //Just to make sure we don't have reserved space in usage
+        iDatabase2.ReleaseReserveAccess();
+        }
+    else 
+        {
+        freeSpace = iServer->FreeSpaceL( EFalse );
+        databaseSize = DataBaseSize( EFalse );
+        User::LeaveIfError( databaseSize );
+        iDatabase.ReleaseReserveAccess();
+        }
+    
+    //If size of the database < freespace or there aren't anymore any 
+    //records in the table, then drop whole table.
+    //Otherwise loop and delete as many records as possible with
+    //current amount of free space.
+    while ( databaseSize > freeSpace && count > 0 )
+        {
+        
+        //Get reserved space to usage
+        if ( iWmDrmRightsConfigFound && ( aTableType == EWmDrmLicenseTable ) )
+            {
+            User::LeaveIfError( iDatabase2.GetReserveAccess() );
+            }
+        else
+            {
+            User::LeaveIfError( iDatabase.GetReserveAccess() );
+            } 
+        
+        //Estimate how many records can be deleted with current amount of free space
+        TInt number( 0 );
+        //Very low free space, OOD-notes shown, target to get off as soon as possible
+        //without risking deletion success
+        if ( freeSpace <= KDRIVECWARNINGTHRESHOLD )
+            {
+            LOG1( "Disk space under warning level" );
+            if ( freeSpace <= KDRIVECCRITICALTHRESHOLD )
+                {
+                LOG1( "Disk space under critical level" );
+                //Use reserved space
+                number = 5;
+                }
+            else
+                {
+                //Use reserved space and space over critical level
+                TInt spaceOverCritical( freeSpace - KDRIVECCRITICALTHRESHOLD );
+                LOG2( "spaceOverCritical: %d", spaceOverCritical );
+                number = spaceOverCritical / KLicenseSize + 5;
+                }
+            }
+        //Disk is still almost full, but we don't wan't to get any OOD-notes anymore
+        else if ( freeSpace <= ( 2 * KDRIVECWARNINGTHRESHOLD ) )
+            {
+            LOG1( "Disk almost full, delete with caution and try to avoid OOD-notes" );
+            TInt spaceOverWarning( freeSpace - KDRIVECWARNINGTHRESHOLD );
+            LOG2( "spaceOverWarning: %d", spaceOverWarning );
+            //Use 1/2 space over warning level, OOD-note might still be shown
+            number = ( spaceOverWarning / 2 ) / KLicenseSize;
+            }
+        //Now there is enough space to delete larger number of records
+        //Make absolutely sure we don't anymore get OOD-notes
+        else
+            {
+            TInt spaceOver2Warnings( freeSpace - 2 * KDRIVECWARNINGTHRESHOLD );
+            LOG2( "spaceOver2Warnings: %d", spaceOver2Warnings );
+            //Use space over 2 * warning level, no OOD-notes
+            number = spaceOver2Warnings / KLicenseSize;
+            }
+        if ( number <= 0 )
+            {
+            number = 5;
+            }
+        
+        LOG2( "number: %d", number );
+        
+        //Array to hold rowIDS of to be deleted records
+        RArray<TInt64> array;
+        CleanupClosePushL( array );
+        
+        //Get number of rowIDs to array 
+        SelectNRecordsWithRowIdL( aTableType, number, array );
+        //Get amount of selected rowIds
+        count = array.Count();
+        
+        //Begin transaction
+        if ( iWmDrmRightsConfigFound && ( aTableType == EWmDrmLicenseTable ) )
+            {
+            User::LeaveIfError( iDatabase2.Exec( KBeginTransaction ) );
+            iSqlTransactionOngoing2 = ETrue;
+            //Execute delete with rowIds
+            DeleteRecordsWithRowIdsL( aTableType, array );
+            //Commit transaction
+            User::LeaveIfError( iDatabase2.Exec( KCommitTransaction ) );
+            iSqlTransactionOngoing2 = EFalse;
+            }
+        else 
+            {
+            User::LeaveIfError( iDatabase.Exec( KBeginTransaction ) );
+            iSqlTransactionOngoing = ETrue;
+            DeleteRecordsWithRowIdsL( aTableType, array );
+            User::LeaveIfError( iDatabase.Exec( KCommitTransaction ) );
+            iSqlTransactionOngoing = EFalse;
+            }
+        
+        CleanupStack::PopAndDestroy( &array );
+        
+        //Prepare for the next round
+        if ( iWmDrmRightsConfigFound && ( aTableType == EWmDrmLicenseTable ) )
+        	{
+        	freeSpace = iServer->FreeSpaceL( ETrue );
+        	databaseSize = DataBaseSize( ETrue );
+        	User::LeaveIfError( databaseSize );
+        
+        	//Release access to reserved space
+        	iDatabase2.ReleaseReserveAccess();
+        	}
+    	else 
+        	{
+        	freeSpace = iServer->FreeSpaceL( EFalse );
+        	databaseSize = DataBaseSize( EFalse );
+        	User::LeaveIfError( databaseSize );
+        	iDatabase.ReleaseReserveAccess();
+        	}
+        }		
+    DropTableL( aTableType );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::SelectNRecordsWithRowIdL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::SelectNRecordsWithRowIdL(
+    TWmDrmTableType aTableType,
+    TInt aNumber,
+    RArray<TInt64>& aArray )
+    {
+    LOGFN( "CWmDrmDb::SelectNRecordsWithRowIdL" );
+    TPtr statementPtr( NULL, 0 );
+    HBufC* statement( NULL );
+    //Select right statement and append number to be the limit in statement
+    
+    //Prepare select statement and get rowID column index
+    RSqlStatement stmt;
+    CleanupClosePushL( stmt );
+    
+    switch ( aTableType )
+        {
+        case EWmDrmLicenseTable:
+            statement = HBufC::NewLC( KSelectNRowIDsLicenseTableString().Length() + 
+                                      KMaxTIntBufLength );
+            statementPtr.Set( statement->Des() );
+            statementPtr.AppendFormat( KSelectNRowIDsLicenseTableString, aNumber );
+             //Prepare select statement
+            if ( iWmDrmRightsConfigFound )
+                {
+                stmt.PrepareL( iDatabase2, statementPtr );
+                }
+            else
+                {
+                stmt.PrepareL( iDatabase, statementPtr );
+                }
+            break;
+        case EWmDrmSecureTable:
+            statement = HBufC::NewLC( KSelectNRowIDsSecureTableString().Length() + 
+                                      KMaxTIntBufLength );
+            statementPtr.Set( statement->Des() );
+            statementPtr.AppendFormat( KSelectNRowIDsSecureTableString, aNumber );
+            stmt.PrepareL( iDatabase, statementPtr );
+            break;
+        case EWmDrmSyncTable:
+            statement = HBufC::NewLC( KSelectNRowIDsSyncTableString().Length() + 
+                                      KMaxTIntBufLength );
+            statementPtr.Set( statement->Des() );
+            statementPtr.AppendFormat( KSelectNRowIDsSyncTableString, aNumber );
+            stmt.PrepareL( iDatabase, statementPtr );
+            break;
+        case EWmDrmMeteringTable:
+            statement = HBufC::NewLC( KSelectNRowIDsMeteringTableString().Length() + 
+                                      KMaxTIntBufLength );
+            statementPtr.Set( statement->Des() );
+            statementPtr.AppendFormat( KSelectNRowIDsMeteringTableString, aNumber );
+            stmt.PrepareL( iDatabase, statementPtr );
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+    
+    //Get rowID column index
+    TInt rowIDColumnIndex( stmt.ColumnIndex( KRowIDColumn ) );
+    User::LeaveIfError( rowIDColumnIndex );
+
+    //Append all selected rowIDs to array
+    TInt err( KErrNone );
+    while ( ( err = stmt.Next() ) == KSqlAtRow )
+        {
+        aArray.AppendL( stmt.ColumnInt64( rowIDColumnIndex ) );
+        }
+
+    LOG2( "err: %d", err );
+    if ( err != KSqlAtEnd )
+        {
+        User::Leave( err );
+        }
+    CleanupStack::PopAndDestroy( 2, statement ); //stmt, statement
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::DeleteRecordsWithRowIdsL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::DeleteRecordsWithRowIdsL(   
+    TWmDrmTableType aTableType,
+    RArray<TInt64>& aArray )
+    {
+    LOGFN( "CWmDrmDb::DeleteRecordsWithRowIdsL" );
+    //Select right statement
+    TPtrC statementString( NULL, 0 );
+    RSqlStatement stmt;
+    CleanupClosePushL( stmt );
+    
+    //Prepare delete statement and get rowID parameter index
+    
+    switch ( aTableType )
+        {
+        case EWmDrmLicenseTable:
+            statementString.Set( KDeleteWithRowIDLicenseTableString().Ptr(), 
+                                 KDeleteWithRowIDLicenseTableString().Length() );
+            //Prepare delete statement
+            if ( iWmDrmRightsConfigFound )
+                {
+                stmt.PrepareL( iDatabase2, statementString );
+                }
+            else
+                {
+                stmt.PrepareL( iDatabase, statementString );
+                }                    
+            break;
+        case EWmDrmSecureTable:
+            statementString.Set( KDeleteWithRowIDSecureTableString().Ptr(), 
+                                 KDeleteWithRowIDSecureTableString().Length() );
+            stmt.PrepareL( iDatabase, statementString );                     
+            break;
+        case EWmDrmSyncTable:
+            statementString.Set( KDeleteWithRowIDSyncTableString().Ptr(), 
+                                 KDeleteWithRowIDSyncTableString().Length() );
+            //Prepare delete statement
+            stmt.PrepareL( iDatabase, statementString );                      
+            break;
+        case EWmDrmMeteringTable:
+            statementString.Set( KDeleteWithRowIDMeteringTableString().Ptr(), 
+                                 KDeleteWithRowIDMeteringTableString().Length() );
+            stmt.PrepareL( iDatabase, statementString );                     
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+    
+    // Get rowID parameter index
+    TInt rowIDIndex( stmt.ParameterIndex( KRowIDParameter ) );
+    User::LeaveIfError( rowIDIndex );
+    
+    //Execute delete statement with every rowID value from the array
+    LOG2( "aArray.Count(): %d", aArray.Count() );
+    for ( TInt i( 0 ); i < aArray.Count(); ++i )
+        {
+        User::LeaveIfError( stmt.BindInt64( rowIDIndex, aArray[i] ) );
+        User::LeaveIfError( stmt.Exec() );
+        User::LeaveIfError( stmt.Reset() );
+        }
+    CleanupStack::PopAndDestroy( &stmt );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::DropTableL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::DropTableL( TWmDrmTableType aTableType )
+    {
+    LOGFN( "CWmDrmDb::DropTableL" );
+    switch ( aTableType )
+        {
+        case EWmDrmLicenseTable:
+            if ( iWmDrmRightsConfigFound )
+                {
+                User::LeaveIfError( iDatabase2.Exec( KDeleteLicenseTableString ) );
+                }
+            else 
+                {
+                User::LeaveIfError( iDatabase.Exec( KDeleteLicenseTableString ) );
+                }
+            break;
+        case EWmDrmSecureTable:
+            User::LeaveIfError( iDatabase.Exec( KDeleteSecureTableString ) );
+            break;
+        case EWmDrmSyncTable:
+        	User::LeaveIfError( iDatabase.Exec( KDeleteSyncTableString ) );
+            break;
+        case EWmDrmMeteringTable:
+            User::LeaveIfError( iDatabase.Exec( KDeleteMeteringTableString ) );
+            break;
+        default:
+            LOG1( "CWmDrmDb::DropTableL error" );
+            User::Leave( KErrArgument );
+            break; 
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::TableTypeL
+// ---------------------------------------------------------------------------
+//
+CWmDrmDb::TWmDrmTableType CWmDrmDb::TableTypeL( const TDesC8& aNamespace )
+    {
+    LOGFN( "CWmDrmDb::TableTypeL" );
+    if ( aNamespace.CompareC( KLicenseStore  ) == 0 )
+        {
+        return EWmDrmLicenseTable;
+        }
+    else if ( aNamespace.CompareC( KSecureStore  ) == 0 )
+        {
+        return EWmDrmSecureTable;
+        }
+    else if ( aNamespace.CompareC( KSyncStore  ) == 0 )
+        {
+        return EWmDrmSyncTable;
+        }
+    else if ( aNamespace.CompareC( KMeteringStore  ) == 0 )
+        {
+        return EWmDrmMeteringTable;
+        }    
+    else
+        {
+        User::Leave( KErrNotFound );
+        return EWmDrmLicenseTable;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::OpenDatabaseL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::OpenDatabaseL( TFileName& aFileNamePath, RSqlDatabase&
+    aSqlDatabase, TBool aConfiguredDrive )
+    {
+    TInt error( aSqlDatabase.Open( aFileNamePath ) );
+    LOG2( "CWmDrmDb: Opening database, status: %d", error );
+    
+    if ( error == KErrNotFound )
+        {
+        // database does not exist, create one
+        CreateDatabaseL( aFileNamePath, aSqlDatabase, aConfiguredDrive );
+		}
+    else if ( error == KSqlErrCorrupt || error == KSqlErrNotDb )
+        {
+        RemoveStoreL( KHds );
+        }
+    else
+        {
+        // Error while opening database
+        User::LeaveIfError( error );
+        }
+    User::LeaveIfError( aSqlDatabase.ReserveDriveSpace( 10 * KLicenseSize ) );
+    }
+
+// ---------------------------------------------------------------------------
+// CWmDrmDb::CheckDatabaseCommitL
+// ---------------------------------------------------------------------------
+//
+void CWmDrmDb::CheckDatabaseCommitL( TBool aEnforcedCommit )
+    {
+    LOGFN( "CWmDrmDb::CheckCommitDatabaseL()" );
+    
+    // Restart the timer for committing the changes to the database
+    if ( !aEnforcedCommit )
+        {
+        if ( IsActive() )
+            {
+            Cancel();
+            }
+        Activate();
+        }
+        
+    // Check if the amount of cached database operations reaches the upper 
+    // limit or if we need to have a forced commit.
+    if ( ( iAmountOperationsWithoutCommit >= KMaxOperationsUntilCommit ) || 
+        aEnforcedCommit )
+        {
+        if ( iWmDrmRightsConfigFound && iSqlTransactionOngoing2 )
+            {
+            User::LeaveIfError( iDatabase2.Exec( KCommitTransaction ) );
+            iSqlTransactionOngoing2 = EFalse;
+            }
+        
+        if ( iSqlTransactionOngoing )
+            {
+            User::LeaveIfError( iDatabase.Exec( KCommitTransaction ) );
+            iSqlTransactionOngoing = EFalse;
+            }
+            
+        // Reset the counter
+        iAmountOperationsWithoutCommit = 0;        
+        }
+    
+    // In case of non-forced commit, execute new BEGIN statement for caching
+    // future SQL statements.
+    if ( ( iAmountOperationsWithoutCommit == 0 ) && !aEnforcedCommit )
+        {
+        if ( iWmDrmRightsConfigFound )
+            {
+            User::LeaveIfError( iDatabase2.Exec( KBeginTransaction ) );
+            iSqlTransactionOngoing2 = ETrue;
+            }
+        User::LeaveIfError( iDatabase.Exec( KBeginTransaction ) );
+        iSqlTransactionOngoing = ETrue;
+        }
+    }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/wmdrmserver.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,187 @@
+/*
+* 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:  WMDRM Server implementation
+*
+*/
+
+#include <bacntf.h>
+#include <DriveInfo.h>
+#include "wmdrmsession.h"
+#include "wmdrmserver.h"
+#include "clock.h"
+#include "slotdatacache.h"
+#include "slotenumeratorcache.h"
+#include "wmdrmdatastore.h"
+#include "wmdrmdb.h"
+#include "drmrightsstoringlocation.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+CWmDrmServer::CWmDrmServer():
+	CServer2( CActive::EPriorityStandard,  ESharableSessions ),
+	iCache( NULL ), iDriveNumber( -1 ), iWmDrmRightsConfigFound( EFalse )
+	{
+	}
+
+CServer2* CWmDrmServer::NewLC()
+	{
+	LOGFN( "CWmDrmServer::NewLC" );
+	CWmDrmServer* self = new( ELeave ) CWmDrmServer;
+	CleanupStack::PushL( self );
+	self->ConstructL();
+	return self;
+	}
+
+CWmDrmServer::~CWmDrmServer()
+    {
+	LOGFN( "CWmDrmServer::~CWmDrmServer" );
+    delete iCache;
+    delete iEnumeratorCache;
+    delete iClock;
+    delete iDb;
+    delete iDataStore;
+    iFs.Close();
+    }
+
+void CWmDrmServer::ConstructL()
+	{
+	LOGFN( "CWmDrmServer::ConstructL" );
+	TDrmScheme drmScheme( EDrmSchemeWmDrm );
+	TChar driveLetter;
+	
+	StartL( KWmDrmServerName );
+	User::LeaveIfError( iFs.Connect() );
+    iCache = NULL;
+	iEnumeratorCache = NULL;
+	ResetCacheL();
+	iClock = CClock::NewL( this );
+	iClock->Start();
+	
+    // Check which drive is configured in the Central Repository Key
+    // for the desired storing location of license and sync stores. 
+	// Convert the drive letter to drive number and store it.
+	iWmDrmRightsConfigFound = 
+	    DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( iFs,
+	        drmScheme, driveLetter );
+	
+	// Check also the system drive
+	DriveInfo::GetDefaultDrive( DriveInfo::EDefaultSystem, iSystemDriveNumber );
+	    
+    iFs.CharToDrive( driveLetter, iDriveNumber );
+	
+	iDb = CWmDrmDb::NewL( this );
+	iDataStore = CWmDrmDataStore::NewL( this );
+	}
+
+void CWmDrmServer::ResetCacheL()
+    {
+    LOGFN( "CWmDrmServer::ResetCacheL" );
+    if ( iCache )
+        {
+        delete iCache;
+        iCache = NULL;
+	    }
+    iCache = CSlotDataCache::NewL( this );
+	if ( iEnumeratorCache )
+	    {
+	    delete iEnumeratorCache;
+	    iEnumeratorCache = NULL;
+	    }
+	iEnumeratorCache = CSlotEnumeratorCache::NewL( this );
+    }
+
+CSession2* CWmDrmServer::NewSessionL(
+    const TVersion& /*aVersion*/,
+    const RMessage2& /*aMessage*/ ) const
+	{
+	LOGFN( "CWmDrmServer::NewSessionL" );
+	return new( ELeave ) CWmDrmSession();
+	}
+
+CSlotDataCache* CWmDrmServer::Cache()
+	{
+	return iCache;
+	}
+
+CSlotEnumeratorCache* CWmDrmServer::EnumeratorCache()
+	{
+    return iEnumeratorCache;
+	}
+
+CClock* CWmDrmServer::Clock()
+	{
+	return iClock;
+	}
+
+RFs& CWmDrmServer::Fs()
+	{
+	return iFs;
+	}
+
+CWmDrmDataStore* CWmDrmServer::DataStore()
+    {
+    return iDataStore;
+    }
+
+CWmDrmDb* CWmDrmServer::Db()
+    {
+    return iDb;
+    }
+
+TInt64 CWmDrmServer::FreeSpaceL( TBool aConfiguredDrive )
+    {
+    TVolumeInfo info;
+    if ( aConfiguredDrive )
+        {
+        // Check the disk space from the configured drive
+        User::LeaveIfError( iFs.Volume( info, iDriveNumber ) );
+        }
+    else 
+        {
+        // Check the disk space from the system drive
+        User::LeaveIfError( iFs.Volume( info, iSystemDriveNumber ) );   
+        }
+    return info.iFree;    
+    } 
+
+static void RunServerL()
+	{
+	LOGFN( "RunServerL" );
+
+	User::LeaveIfError( RThread::RenameMe( KWmDrmServerName ) );
+	CActiveScheduler* s = new( ELeave ) CActiveScheduler;
+	CleanupStack::PushL( s );
+	CActiveScheduler::Install( s );
+    CWmDrmServer::NewLC();
+	RProcess::Rendezvous( KErrNone );
+	CActiveScheduler::Start();
+	CleanupStack::PopAndDestroy( 2 ); // server, s
+	}
+
+TInt E32Main()
+	{
+	__UHEAP_MARK;
+	CTrapCleanup* cleanup = CTrapCleanup::New();
+	TInt r = KErrNoMemory;
+	if ( cleanup )
+		{
+		TRAP( r, RunServerL() );
+		delete cleanup;
+		}
+	__UHEAP_MARKEND;
+	return r;
+	}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wmdrm/wmdrmengine/wmdrmserver/server/src/wmdrmsession.cpp	Thu Dec 17 08:52:27 2009 +0200
@@ -0,0 +1,827 @@
+/*
+* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:  WMDRM Server implementation
+*
+*/
+
+
+#include <bacntf.h>
+#include "wmdrmsession.h"
+#include "wmdrmserver.h"
+#include "clock.h"
+#include "slotdatacache.h"
+#include "slotenumeratorcache.h"
+#include "slot.h"
+#include "slotdata.h"
+#include "enumerator.h"
+#include "enumeratordata.h"
+#include "wmdrmdatastore.h"
+#include "wmdrmdb.h"
+#include "drmrightsstoringlocation.h"
+#include "drmutilityinternaltypes.h"
+
+#define _LOGGING_FILE L"wmdrmserver.txt"
+
+#include "flogger.h"
+#include "logfn.h"
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::CWmDrmSession
+// Constructor
+//---------------------------------------------------------------------------
+//
+CWmDrmSession::CWmDrmSession()
+	{
+	}
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::~CWmDrmSession
+// Destructor
+//---------------------------------------------------------------------------
+//	
+CWmDrmSession::~CWmDrmSession()
+	{
+	LOGFN( "CWmDrmSession::~CWmDrmSession" );
+    //Server().Cache()->FlushL();
+	delete iEnumerator;
+	iEnumerator = NULL;
+    delete iSlot;
+	iSlot = NULL;
+	}
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::InitStoreL
+//---------------------------------------------------------------------------
+//
+TInt CWmDrmSession::InitStoreL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TBuf8<KMaxWmDrmStoreNameSize> store;
+    
+    LOGFNR( "CWmDrmSession::InitStoreL", r );
+    if ( aMessage.GetDesLength( 0 ) > KMaxWmDrmStoreNameSize || aMessage.GetDesLength( 0 ) <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+    aMessage.ReadL( 0, store );
+    TRAP( r, Server().Db()->InitStoreL( store, aMessage.Int1() ) );
+    if ( r == KErrAlreadyExists )
+        {
+        r = KErrNone;
+        }
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::RemoveStoreL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::RemoveStoreL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TBuf8<KMaxWmDrmStoreNameSize> store;
+    
+    LOGFNR( "CWmDrmSession::RemoveStoreL", r );
+    if ( aMessage.GetDesLength( 0 ) > KMaxWmDrmStoreNameSize || aMessage.GetDesLength( 0 ) <= 0  )
+        {
+        User::Leave( KErrArgument );
+        }
+    Server().ResetCacheL();
+    aMessage.ReadL( 0, store );
+    Server().Db()->RemoveStoreL( store );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::InitNamespaceL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::InitNamespaceL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TBuf8<KMaxWmDrmStoreNameSize> store;
+    TBuf8<KMaxWmDrmNamespaceNameSize> nameSpace;
+    
+    LOGFNR( "CWmDrmSession::InitNamespaceL", r );
+    // :KLUDGE: Note: store length of zero is allowed
+    if ( aMessage.GetDesLengthL( 0 ) > KMaxWmDrmStoreNameSize ||
+        aMessage.GetDesLengthL( 1 ) > KMaxWmDrmNamespaceNameSize ||
+        aMessage.GetDesLength( 1 ) <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    if ( aMessage.GetDesLengthL( 0 ) > 0 )
+        {
+        aMessage.ReadL( 0, store );
+        }
+    else
+        {
+        // Use hds as the default store if none given
+        store.Copy( KDefaultStore );
+        }
+    aMessage.ReadL( 1, nameSpace );
+    Server().Db()->InitNameSpaceL( store, nameSpace, aMessage.Int1() );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::RemoveNamespaceL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::RemoveNamespaceL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TBuf8<KMaxWmDrmStoreNameSize> store;
+    TBuf8<KMaxWmDrmNamespaceNameSize> nameSpace;
+    
+    LOGFNR( "CWmDrmSession::RemoveNamespaceL", r );
+    // :KLUDGE: Note: store length of zero is allowed
+    if ( aMessage.GetDesLengthL( 0 ) > KMaxWmDrmStoreNameSize ||
+        aMessage.GetDesLengthL( 1 ) > KMaxWmDrmNamespaceNameSize ||
+        aMessage.GetDesLength( 1 ) <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    if ( aMessage.GetDesLengthL( 0 ) > 0 )
+        {
+        aMessage.ReadL( 0, store );
+        }
+    else
+        {
+        // :KLUDGE: Use hds as the default store if none given
+        store.Copy( KDefaultStore );
+        }
+    aMessage.ReadL( 1, nameSpace );
+    Server().Db()->RemoveNameSpaceL( store, nameSpace );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::SlotOpenL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::SlotOpenL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    RBuf8 messageBuffer;
+	TInt size;
+    
+    LOGFNR( "CWmDrmSession::SlotOpenL", r );
+    if ( aMessage.GetDesLength( 0 ) > KMaxSlotNameSize || aMessage.GetDesLength( 0 ) <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+    messageBuffer.CreateL( aMessage.GetDesLengthL( 0 ) );
+    messageBuffer.CleanupClosePushL();
+    aMessage.ReadL( 0, messageBuffer );
+    if ( iSlot != NULL )
+        {
+        delete iSlot;
+        iSlot = NULL;
+        }
+    iSlot = CSlot::NewL( &Server(), messageBuffer );
+    r = iSlot->OpenL( size );
+    aMessage.WriteL( 1, TPckg<TInt>( size ) );
+    CleanupStack::PopAndDestroy( &messageBuffer );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::SlotCreateL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::SlotCreateL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    RBuf8 messageBuffer;
+	TInt size;
+    
+    LOGFNR( "CWmDrmSession::SlotCreateL", r );
+    if ( aMessage.GetDesLength( 0 ) > KMaxSlotNameSize || aMessage.GetDesLength( 0 ) <= 0  )
+        {
+        User::Leave( KErrArgument );
+        }
+    messageBuffer.CreateL( aMessage.GetDesLengthL( 0 ) );
+    messageBuffer.CleanupClosePushL();
+    aMessage.ReadL( 0, messageBuffer );
+    size = aMessage.Int1();
+    if ( iSlot != NULL )
+        {
+        delete iSlot;
+        iSlot = NULL;
+        }
+    
+    iSlot = CSlot::NewL( &Server(), messageBuffer );
+    iSlot->CreateL( size );
+    CleanupStack::PopAndDestroy( &messageBuffer );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::SlotSeekL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::SlotSeekL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TSeek whence = ESeekStart;
+    TInt pos = aMessage.Int0();
+    TInt size;
+    
+    LOGFNR( "CWmDrmSession::SlotSeekL", r );
+    if ( iSlot == NULL )
+        {
+        User::Leave( KErrNotReady );
+        }
+    switch ( aMessage.Int1() )
+        {
+        case ESeekStart:
+            whence = ESeekStart;
+            break;
+        case ESeekCurrent:
+            whence = ESeekCurrent;
+            break;
+        case ESeekEnd:
+            whence = ESeekEnd;
+            break;
+        default:
+            User::Leave( KErrArgument );
+            break;
+        }
+    r = iSlot->SeekL( pos, whence );
+    if ( r == KErrNone && whence == ESeekStart )
+        {
+        size = iSlot->Size();
+        if ( pos >= size )
+            {
+            pos = 0;
+            r = iSlot->SeekL( pos, ESeekEnd );
+            }
+        }
+    aMessage.WriteL( 2, TPckg<TInt>( pos ) );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::SlotReadL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::SlotReadL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    RBuf8 buf;
+    TInt amountRead = 0;
+    
+    LOGFNR( "CWmDrmSession::SlotReadL", r );
+    if ( iSlot == NULL )
+        {
+        User::Leave( KErrNotReady );
+        }
+    buf.CreateL( aMessage.GetDesMaxLengthL( 0 ) );
+    buf.CleanupClosePushL();
+    r = iSlot->Read( buf );
+    if ( r == KErrNone )
+        {
+        aMessage.WriteL( 0, buf );
+        amountRead = buf.Size();
+        }
+    aMessage.WriteL( 1, TPckg<TInt>( amountRead ) );
+    CleanupStack::PopAndDestroy( &buf );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::SlotWriteL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::SlotWriteL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    RBuf8 buf;
+    
+    LOGFNR( "CWmDrmSession::SlotWriteL", r );
+    if ( iSlot == NULL )
+        {
+        User::Leave( KErrNotReady );
+        }
+    buf.CreateL( aMessage.GetDesLengthL( 0 ) );
+    buf.CleanupClosePushL();
+    aMessage.ReadL( 0, buf );
+    r = iSlot->WriteL( buf );
+    CleanupStack::PopAndDestroy( &buf );
+    return r;
+    }
+    
+TInt CWmDrmSession::SlotResizeL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    
+    LOGFNR( "CWmDrmSession::SlotResizeL", r );
+    if ( iSlot == NULL )
+        {
+        User::Leave( KErrNotReady );
+        }
+    r = iSlot->ResizeL( aMessage.Int0() );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::SlotDeleteL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::SlotDeleteL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    RBuf8 messageBuffer;
+    
+    LOGFNR( "CWmDrmSession::SlotDeleteL", r );
+    if ( aMessage.GetDesLength( 0 ) > KMaxSlotNameSize )
+        {
+        User::Leave( KErrArgument );
+        }
+    messageBuffer.CreateL( aMessage.GetDesLengthL( 0 ) );
+    messageBuffer.CleanupClosePushL();
+    aMessage.ReadL( 0, messageBuffer );
+    if ( iSlot != NULL )
+        {
+        delete iSlot;
+        iSlot = NULL;
+        }
+    iSlot = CSlot::NewL( &Server(), messageBuffer );
+    r = iSlot->DeleteL();
+    delete iSlot;
+    iSlot = NULL;
+    CleanupStack::PopAndDestroy( &messageBuffer );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::SlotCloseL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::SlotCloseL( const RMessage2& /*aMessage*/ )
+    {
+    TInt r = KErrNone;
+    
+    LOGFNR( "CWmDrmSession::SlotCloseL", r );
+    if ( iSlot == NULL )
+        {
+        User::Leave( KErrNotReady );
+        }
+    delete iSlot;
+    iSlot = NULL;
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::EnumerateStartL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::EnumerateStartL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    RBuf8 messageBuffer;
+    
+    LOGFNR( "CWmDrmSession::EnumerateStartL", r );
+    if ( aMessage.GetDesLength( 0 ) > KMaxSlotNameSize || aMessage.GetDesLength( 0 ) <= 0  )
+        {
+        User::Leave( KErrArgument );
+        }
+    messageBuffer.CreateL( aMessage.GetDesLengthL( 0 ) );
+    messageBuffer.CleanupClosePushL();
+    aMessage.ReadL( 0, messageBuffer );
+    if ( iSlot != NULL )
+        {
+        delete iSlot;
+        iSlot = NULL;
+        }
+    if ( iEnumerator != NULL )
+        {
+        delete iEnumerator;
+        iEnumerator = NULL;
+        }
+    iEnumerator = CEnumerator::NewL( &Server(), messageBuffer );
+    r = iEnumerator->OpenL();
+    CleanupStack::PopAndDestroy( &messageBuffer );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::EnumerateReloadL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::EnumerateReloadL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TBuf8<KWmDrmIdSize> hash;
+    TBuf8<KWmDrmIdSize> id;
+    
+    LOGFNR( "CWmDrmSession::EnumerateReloadL", r );
+    if ( iEnumerator == NULL )
+        {
+        User::Leave( KErrNotReady );
+        }
+    iEnumerator->GetHashKey( hash );
+    LOGHEX( hash.Ptr(), hash.Size() );
+    iEnumerator->GetUniqueKey( id );
+    LOGHEX( id.Ptr(), id.Size() );
+    aMessage.WriteL( 0, iEnumerator->iStore);
+    aMessage.WriteL( 1, iEnumerator->iNamespace );
+    aMessage.WriteL( 2, hash );
+    aMessage.WriteL( 3, id );
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::EnumerateNextL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::EnumerateNextL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    TBuf8<KWmDrmIdSize> hash;
+    TBuf8<KWmDrmIdSize> id;
+    
+    LOGFNR( "CWmDrmSession::EnumerateNextL", r );
+    if ( iEnumerator == NULL )
+        {
+        User::Leave( KErrNotReady );
+        }
+    r = iEnumerator->NextL();
+    if ( r == KErrNone )
+        {
+        iEnumerator->GetHashKey( hash );
+        LOGHEX( hash.Ptr(), hash.Size() );
+        iEnumerator->GetUniqueKey( id );
+        LOGHEX( id.Ptr(), id.Size() );
+        aMessage.WriteL( 0, iEnumerator->iStore);
+        aMessage.WriteL( 1, iEnumerator->iNamespace );
+        aMessage.WriteL( 2, hash );
+        aMessage.WriteL( 3, id );
+        }
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::EnumerateDeleteL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::EnumerateDeleteL ( const RMessage2& /*aMessage*/ )
+    {
+    TInt r = KErrNone;
+    
+    LOGFNR( "CWmDrmSession::EnumerateDeleteL", r );
+    if ( iEnumerator == NULL )
+        {
+        User::Leave( KErrNotReady );
+        }
+    iEnumerator->DeleteCurrentL();
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::EnumerateEndL
+//---------------------------------------------------------------------------
+//
+TInt CWmDrmSession::EnumerateEndL ( const RMessage2& /*aMessage*/ )
+    {
+    TInt r = KErrNone;
+    
+    LOGFNR( "CWmDrmSession::EnumerateEndL", r );
+    if ( iEnumerator == NULL )
+        {
+        User::Leave( KErrNotReady );
+        }
+    iEnumerator->Close();
+    delete iEnumerator;
+    iEnumerator = NULL;
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::EmptyCacheL
+//---------------------------------------------------------------------------
+//
+TInt CWmDrmSession::EmptyCacheL( const RMessage2& aMessage )
+    {
+    TInt r = KErrNone;
+    
+    LOGFNR( "CWmDrmSession::EmptyCacheL", r );
+    TRAP_IGNORE( EnumerateEndL( aMessage ) );
+    TRAP_IGNORE( SlotCloseL( aMessage ) );
+    Server().ResetCacheL();
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::LogStats
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::LogStats( const RMessage2& /*aMessage*/ )
+    {
+    TInt r = KErrNone;
+
+#ifdef _LOGGING    
+    TInt cells;
+    TInt amount;
+    TInt i;
+    TInt j;
+    _LIT( KStatsDir, "wmdrm" );
+    _LIT( KStatsFile, "wmdrmserver.txt" );
+    
+    LOGFNR( "CWmDrmSession::LogStatsL", r );
+    cells = User::AllocSize( amount );
+    RFileLogger::Write( KStatsDir, KStatsFile, EFileLoggingModeAppend, _L( "Statistics:" ) );
+    RFileLogger::WriteFormat( KStatsDir, KStatsFile, EFileLoggingModeAppend,
+        _L( "Memory: %d cells, %d bytes allocated" ), cells, amount );
+
+    if (Server().Clock()->TimeIsGood() )
+        {
+        RFileLogger::Write( KStatsDir, KStatsFile, EFileLoggingModeAppend, _L( "Time is valid" ) );
+        }
+    else
+        {
+        RFileLogger::Write( KStatsDir, KStatsFile, EFileLoggingModeAppend, _L( "Time is invalid" ) );
+        }
+
+    RFileLogger::WriteFormat( KStatsDir, KStatsFile, EFileLoggingModeAppend,
+        _L( "Cache: %d out of %d slots used" ),
+        Server().Cache()->iSlotCache.Count(),
+        Server().Cache()->iMaxCachedSlots );
+    for ( i = 0; i < Server().Cache()->iSlotCache.Count(); i++ )
+        {
+        RFileLogger::Write( KStatsDir, KStatsFile, EFileLoggingModeAppend,
+            Server().Cache()->iSlotCache[i]->iHashKey );
+        RFileLogger::Write( KStatsDir, KStatsFile, EFileLoggingModeAppend,
+            Server().Cache()->iSlotCache[i]->iUniqueKey );
+        }
+
+    RFileLogger::WriteFormat( KStatsDir, KStatsFile, EFileLoggingModeAppend,
+        _L( "Enumerators: %d out of %d slots used" ),
+        Server().EnumeratorCache()->iEnumeratorCache.Count(),
+        Server().EnumeratorCache()->iMaxCachedEnumerators );
+    for ( i = 0; i < Server().EnumeratorCache()->iEnumeratorCache.Count(); i++ )
+        {
+        RFileLogger::Write( KStatsDir, KStatsFile, EFileLoggingModeAppend,
+            Server().EnumeratorCache()->iEnumeratorCache[i]->iHashKey );
+        for ( j = 0; j < Server().EnumeratorCache()->iEnumeratorCache[i]->iEntries.Count(); j++ )
+            {
+            RFileLogger::Write( KStatsDir, KStatsFile, EFileLoggingModeAppend,
+                *Server().EnumeratorCache()->iEnumeratorCache[i]->iEntries[j] );
+            }
+        }
+#endif
+    
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::TimeValid
+//---------------------------------------------------------------------------
+//
+TInt CWmDrmSession::TimeValid( const RMessage2& /*aMessage*/ )
+    {
+    TInt r = KErrNone;
+    
+    LOGFNR( "CWmDrmSession::TimeValid", r );
+    r = Server().Clock()->TimeIsGood();
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::SetTimeAsValidL
+//---------------------------------------------------------------------------
+//    
+void CWmDrmSession::SetTimeAsValidL( const RMessage2& aMessage )
+    {
+    LOGFN( "CWmDrmSession::TimeValid" );
+    Server().Clock()->SetTimeAsGoodL( aMessage.Int0() == 0 ? EFalse : ETrue );
+    }
+    
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::DeleteRightsL
+//---------------------------------------------------------------------------
+//    
+TInt CWmDrmSession::DeleteRightsL( const RMessage2& /*aMessage*/ )
+    {
+    TInt r = KErrNone;
+    TBool wmDrmRightsConfigFound( EFalse );
+    TChar driveLetter;
+    TDrmScheme drmScheme( EDrmSchemeWmDrm );
+    
+    LOGFNR( "CWmDrmSession::DeleteRightsL", r );
+    // Close EVERYTHING down, clear cache etc, so that we have nothing going on
+    // When we start to delete stuff
+    Server().ResetCacheL();
+    
+    wmDrmRightsConfigFound = DrmRightsStoringLocation::CheckDrmRightsStorageDriveL(
+	  		Server().Fs(), drmScheme, driveLetter );
+    
+    // If WM DRM rights storage configuration is found, update both databases
+    if ( wmDrmRightsConfigFound )
+        {
+    	Server().DataStore()->UpdateDummyDbFileL( 
+    	    Server().DataStore()->DummyDBSizeL( ETrue ), ETrue );
+    	}
+    Server().DataStore()->UpdateDummyDbFileL( 
+        Server().DataStore()->DummyDBSizeL( EFalse ), EFalse );
+    
+    // Delete license store
+    Server().Db()->DeleteLicenseStoreL();
+    
+    // If WM DRM rights storage configuration is found, update both databases 
+    if ( wmDrmRightsConfigFound )
+    	{
+    	Server().DataStore()->UpdateDummyDbFileL( 0, ETrue );
+    	}	
+    Server().DataStore()->UpdateDummyDbFileL( 0, EFalse );
+    
+    return r;
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::StoreStateL
+//---------------------------------------------------------------------------
+//
+void CWmDrmSession::StoreStateL( const RMessage2& aMessage )
+    {
+    TWmDrmStoreState state;
+    
+    LOGFN( "CWmDrmSession::StoreStateL" );
+    state = Server().DataStore()->DataStoreStateL();
+    aMessage.WriteL( 0, TPckg<TWmDrmStoreState>( state ) );
+    }
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::GetTimeL
+//---------------------------------------------------------------------------
+//
+void CWmDrmSession::GetTimeL( const RMessage2& aMessage )
+    {
+    TTime time = Time::NullTTime();
+    TBool validity = EFalse;
+    TPckg<TTime> timePckg(time);
+    TPckg<TBool> validityPckg(validity);
+    
+    LOGFN( "CWmDrmSession::GetTimeL" );
+    
+    // Get the time from the clock
+    Server().Clock()->GetTimeL( time, validity );
+    
+    aMessage.WriteL(0, timePckg);
+    aMessage.WriteL(1, validityPckg);
+    }
+
+ 
+//---------------------------------------------------------------------------
+// CWmDrmSession::ServiceL
+//---------------------------------------------------------------------------
+//    
+void CWmDrmSession::ServiceL( const RMessage2& aMessage )
+	{
+	TInt r = KErrNone;
+	TInt trap = KErrNone;
+	_LIT_SECURITY_POLICY_C1(drmCheck, ECapabilityDRM);
+    RThread client;
+	
+	LOGFNR( "CWmDrmSession::ServiceL", r );
+#ifdef _LOGGING
+    TInt c;
+    TInt s;
+    c = User::AllocSize(s);
+    LOG3( "Memory: %d cells, %d bytes allocated", c, s );
+#endif
+
+    aMessage.ClientL( client );
+
+    if ( !drmCheck().CheckPolicy( client ) )
+        {
+        r = KErrAccessDenied;
+        }
+    else
+        {
+        switch ( aMessage.Function() )
+            {
+            case EInitStore:
+                TRAP( trap, r = InitStoreL( aMessage ) );
+                break;
+            case ERemoveStore:
+                TRAP( trap, r = RemoveStoreL( aMessage ) );
+                break;
+            case EInitNamespace:
+                TRAP( trap, r = InitNamespaceL( aMessage ) );
+                break;
+            case ERemoveNamespace:
+                TRAP( trap, r = RemoveNamespaceL( aMessage ) );
+                break;
+            case ESlotOpen:
+                TRAP( trap, r = SlotOpenL( aMessage ) );
+                break;
+            case ESlotCreate:
+                TRAP( trap, r = SlotCreateL( aMessage ) );
+                break;
+            case ESlotSeek:
+                TRAP( trap, r = SlotSeekL( aMessage ) );
+                break;
+            case ESlotRead:
+                TRAP( trap, r = SlotReadL( aMessage ) );
+                break;
+            case ESlotWrite:
+                TRAP( trap, r = SlotWriteL( aMessage ) );
+                break;
+            case ESlotDelete:
+                TRAP( trap, r = SlotDeleteL( aMessage ) );
+                break;
+            case ESlotResize:
+                TRAP( trap, r = SlotResizeL( aMessage ) );
+                break;
+            case ESlotClose:
+                TRAP( trap, r = SlotCloseL( aMessage ) );
+                break;
+            case EEnumerateStart:
+                TRAP( trap, r = EnumerateStartL( aMessage ) );
+                break;
+            case EEnumerateReload:
+                TRAP( trap, r = EnumerateReloadL( aMessage ) );
+                break;
+            case EEnumerateNext:
+                TRAP( trap, r = EnumerateNextL( aMessage ) );
+                break;
+            case EEnumerateDelete:
+                TRAP( trap, r = EnumerateDeleteL( aMessage ) );
+                break;
+            case EEnumerateEnd:
+                TRAP( trap, r = EnumerateEndL( aMessage ) );
+                break;
+            case ELogStats:
+                r = LogStats( aMessage );
+                break;
+            case EEmptyCache:
+                TRAP( trap, r = EmptyCacheL( aMessage ) );
+                break;
+            case ETimeValid:
+                r = TimeValid( aMessage );
+                break;
+            case ESetTimeAsValid:
+                TRAP( trap, SetTimeAsValidL( aMessage ) );
+                break;
+            case EDeleteRights:
+                TRAP( trap, DeleteRightsL( aMessage ) );
+                break;
+            case EStoreState:
+                TRAP( trap, StoreStateL( aMessage ) );
+                break;
+            case EGetTime:
+                TRAP( trap, GetTimeL( aMessage ) );
+                break;              
+            default:
+                r = KErrArgument;
+                break;
+                }
+        if ( trap != KErrNone )
+            {
+            r = trap;
+            }
+        if ( r == KErrDiskFull || r == KErrNoMemory )
+            {
+            TRAP_IGNORE( EmptyCacheL( aMessage ) );
+            }
+        }
+    client.Close();
+    LOG2( "** ServiceL error: %d", r );
+    aMessage.Complete( r );
+	}
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::ServiceError
+//---------------------------------------------------------------------------
+//
+void CWmDrmSession::ServiceError( const RMessage2& aMessage, TInt aError )
+	{
+	LOGFN( "CWmDrmSession::ServiceError" );
+	LOG2( "** Error: %d", aError );
+	CSession2::ServiceError( aMessage, aError );
+	}
+
+//---------------------------------------------------------------------------
+// CWmDrmSession::Server
+//---------------------------------------------------------------------------
+//
+CWmDrmServer& CWmDrmSession::Server()
+	{
+	return *static_cast<CWmDrmServer*>( const_cast<CServer2*>( CSession2::Server() ) );
+	}