# HG changeset patch # User hgs # Date 1276260285 -10800 # Node ID c68061d56109561fc025d187e0aaf058af08b6f7 # Parent 5ed7931150e982e810a5d9852ac7ee1c7de10c69 201023_02 diff -r 5ed7931150e9 -r c68061d56109 commondrm/commondrm.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commondrm/commondrm.pro Fri Jun 11 15:44:45 2010 +0300 @@ -0,0 +1,21 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: Commondrm main level project file. +# + +TEMPLATE = subdirs + +SYMBIAN_PLATFORMS = WINSCW ARMV5 + +SUBDIRS += drmqtencryptor/qt_drmencryptor.pro \ No newline at end of file diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/data/DRMEncryptor.rss --- a/commondrm/drmencryptor/data/DRMEncryptor.rss Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,466 +0,0 @@ -/* -* 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 -#include - -#include -#include -#include -#include - -#include - -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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/data/DRMEncryptor_caption.rss --- a/commondrm/drmencryptor/data/DRMEncryptor_caption.rss Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,25 +0,0 @@ -/* -* 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 - -RESOURCE CAPTION_DATA - { - caption = "DRMEncryptor"; - shortcaption = "DRM"; - } diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/data/DRMEncryptor_reg.rss --- a/commondrm/drmencryptor/data/DRMEncryptor_reg.rss Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* -* 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 -#include - -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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/group/DRMEncryptor.mmp --- a/commondrm/drmencryptor/group/DRMEncryptor.mmp Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* -* 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 -#include - -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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/group/DRMEncryptor.pkg --- a/commondrm/drmencryptor/group/DRMEncryptor.pkg Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -; -; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -; All rights reserved. -; This component and the accompanying materials are made available -; under the terms of "Eclipse Public License v1.0" -; which accompanies 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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/group/icon.bmp Binary file commondrm/drmencryptor/group/icon.bmp has changed diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/group/icon_mask_soft.bmp Binary file commondrm/drmencryptor/group/icon_mask_soft.bmp has changed diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/group/qgn_menu_DRMEncryptor.bmp Binary file commondrm/drmencryptor/group/qgn_menu_DRMEncryptor.bmp has changed diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_cxt.bmp Binary file commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_cxt.bmp has changed diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_cxt_mask_soft.bmp Binary file commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_cxt_mask_soft.bmp has changed diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_mask_soft.bmp Binary file commondrm/drmencryptor/group/qgn_menu_DRMEncryptor_mask_soft.bmp has changed diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/inc/DRMEncryptor.hrh --- a/commondrm/drmencryptor/inc/DRMEncryptor.hrh Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,56 +0,0 @@ -/* -* 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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/inc/DRMEncryptor.rh --- a/commondrm/drmencryptor/inc/DRMEncryptor.rh Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* -* 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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/inc/DRMEncryptorApp.h --- a/commondrm/drmencryptor/inc/DRMEncryptorApp.h Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* -* 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 - -// 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 - diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/inc/DRMEncryptorAppUi.h --- a/commondrm/drmencryptor/inc/DRMEncryptorAppUi.h Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,79 +0,0 @@ -/* -* 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 -#include -#include -#include -#include - -// 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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/inc/DRMEncryptorContainer.h --- a/commondrm/drmencryptor/inc/DRMEncryptorContainer.h Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* -* 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 -#include - -// 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* iText; - CArrayPtr* iImages; - CArrayFixFlat* 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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/inc/DRMEncryptorDocument.h --- a/commondrm/drmencryptor/inc/DRMEncryptorDocument.h Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* -* 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 - -// 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 - diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/inc/DRMEncryptorImage.h --- a/commondrm/drmencryptor/inc/DRMEncryptorImage.h Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* -* 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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/inc/DRMPlayServerTest.h --- a/commondrm/drmencryptor/inc/DRMPlayServerTest.h Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* -* 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 -#include - -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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/inc/Performance.h --- a/commondrm/drmencryptor/inc/Performance.h Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* -* 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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/src/DRMEncryptorApp.cpp --- a/commondrm/drmencryptor/src/DRMEncryptorApp.cpp Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* -* 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 - -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 - diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/src/DRMEncryptorAppUi.cpp --- a/commondrm/drmencryptor/src/DRMEncryptorAppUi.cpp Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,257 +0,0 @@ -/* -* 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 -#include - -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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/src/DRMEncryptorContainer.cpp --- a/commondrm/drmencryptor/src/DRMEncryptorContainer.cpp Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,444 +0,0 @@ -/* -* 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#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( 20 ); - // Every image on screen is one entry in this array - iImages = new( ELeave ) CArrayPtrFlat( 1 ); - // This array contains indices for lines that start the subsequent - // screens, for custom scrolling - iScreenStarts = new( ELeave ) CArrayFixFlat( 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* wrappedArray = - new( ELeave ) CArrayFixFlat( 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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/src/DRMEncryptorDocument.cpp --- a/commondrm/drmencryptor/src/DRMEncryptorDocument.cpp Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* -* 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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/src/DRMEncryptorImage.cpp --- a/commondrm/drmencryptor/src/DRMEncryptorImage.cpp Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* -* 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 -#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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/src/DRMPlayServerTest.cpp --- a/commondrm/drmencryptor/src/DRMPlayServerTest.cpp Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* -* 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 - -#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 - diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/src/DrmBb5KeyStorage.cpp --- a/commondrm/drmencryptor/src/DrmBb5KeyStorage.cpp Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,239 +0,0 @@ -/* -* 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 -#include -#include -#include -#include -#include - -#ifdef RD_MULTIPLE_DRIVE -#include -#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 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 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; - } - diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/src/DrmEncryptor.cpp --- a/commondrm/drmencryptor/src/DrmEncryptor.cpp Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,577 +0,0 @@ -/* -* 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -#ifdef RD_MULTIPLE_DRIVE -#include -#endif - -#include -#include -#include -#include -#include -#include "DRMClockClient.h" - -#include -#include - -#include - -#include -#include - -#include - -// 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(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 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 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 diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/src/DrmKeyStorage.cpp --- a/commondrm/drmencryptor/src/DrmKeyStorage.cpp Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,334 +0,0 @@ -/* -* 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 -#include -#include -#include -#include -#include - -#ifdef RD_MULTIPLE_DRIVE -#include -#endif - -#include -#include - -#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 certChain; - RPointerArray 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 certChain; - TInt numCerts; - TInt i; - RZipFileMemberReaderStream* data; - TPtr8 ptr(NULL, 0); - TFileName fileName; - RPointerArray 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( 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; - } - diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmencryptor/src/Performance.cpp --- a/commondrm/drmencryptor/src/Performance.cpp Mon May 31 14:37:41 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,861 +0,0 @@ -/* -* 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 -#include -#include -#include -#include -#include -#include -#include - -#ifdef RD_MULTIPLE_DRIVE -#include -#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\ -\ -1.0\ -\ -cid:content0000@localhost\ -\ -\ -\ -2020-01-01T00:00:001980-01-01T00:00:00\ -\ -\ -\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\ -\ -1.0\ -\ -cid:content0001@localhost\ -\ -\ -1000000\ -\ -\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(); - } diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmqtencryptor/drmencryptor.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commondrm/drmqtencryptor/drmencryptor.h Fri Jun 11 15:44:45 2010 +0300 @@ -0,0 +1,102 @@ +/* +* 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. +* +*/ + +#ifndef DRMENCRYPTOR_H +#define DRMENCRYPTOR_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*namespace Ui +{ + class mainWindow; + class QPushButton; +}*/ + +//forward declarations +class DateTimeDialog; + +class DRMEncryptor : public QMainWindow +{ + Q_OBJECT + +public: + DRMEncryptor(); + ~DRMEncryptor(); + +private: + void ProcessMessageL(const TDesC& aFile, const TDesC& aOutput); + //ContentAccess::CManager* GetCafDataL( ContentAccess::TAgent& aAgent ); + void DeleteWmDrmRdbL(); + + +signals: + +private slots: + void onTextChanged(const QString &); + void setDRMClock(); + void getDRMClock(); + void startEncrypt(); + void deleteWmDrmDB(); + TUint EncryptL(TUint& aEncryptedCount, TUint& aRightsCount, TUint& aMessagesProcessed); + + //void onDateTimeChanged(const QDateTime & datetime ); + +private: + QMenu *iOptionsMenu; + QPushButton *iSetDRMClockButton; + + // Menu options + QAction *iSetDRMClockAct; + QAction *iGetDRMClockAct; + QAction *iEncryptAct; + QAction *iDeleteWMDRMDBAct; + + DateTimeDialog *iDateTimeDialog; + QDateTime iDatetime; +}; + +class DateTimeDialog : public QDialog +{ + Q_OBJECT + +public: + DateTimeDialog(); + ~DateTimeDialog(); + +private slots: + void setDRMClock(); + +private: + QHBoxLayout *iLayout; + QDateTimeEdit *iDateEdit; + /*QDateTimeEdit *iDateEdit; + QPushButton *iOkButton; + QPushButton *iCancelButton;*/ + +}; + + +#endif // DRMENCRYPTOR_H diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmqtencryptor/drmencryptor.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commondrm/drmqtencryptor/drmencryptor.ui Fri Jun 11 15:44:45 2010 +0300 @@ -0,0 +1,37 @@ +/* +* 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. +* +*/ + + + + mainWindow + + + + 0 + 0 + 310 + 498 + + + + DRMEncryptor + + + + + + diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmqtencryptor/drmencyptor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commondrm/drmqtencryptor/drmencyptor.cpp Fri Jun 11 15:44:45 2010 +0300 @@ -0,0 +1,708 @@ +/* +* 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. +* +*/ + +#include "drmencryptor.h" +//#include "ui_dialog.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef RD_MULTIPLE_DRIVE +#include +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "drmserviceapi.h" + +const TInt KBufferSize = 20000; + +DRMEncryptor::DRMEncryptor() +{ + QWidget *widget = new QWidget(); + setCentralWidget(widget); + + setBackgroundRole( QPalette::Window ); + + QVBoxLayout *layout = new QVBoxLayout; + layout->setAlignment(Qt::AlignCenter); + + QLabel *mainWindowLabel = new QLabel("DRM Encryptor"); + layout->addWidget(mainWindowLabel); + + //layout->addStretch(); + + //ui->setupUi(this); + //iOptionsMenu = menuBar()->addMenu(tr("&Options")); + + // Create menu options + iSetDRMClockAct = new QAction(tr("&Set DRM Clock"), this); + iSetDRMClockAct->setStatusTip(tr("Set DRM secure clock time.")); + + iGetDRMClockAct = new QAction(tr("&Get DRM Clock Time"), this); + iGetDRMClockAct->setStatusTip(tr("Get DRM secure clock time.")); + + iEncryptAct = new QAction(tr("&Encrypt"), this); + iEncryptAct->setStatusTip(tr("Encrypt")); + + iDeleteWMDRMDBAct = new QAction(tr("&Delete WMDRM DB"), this); + iDeleteWMDRMDBAct->setStatusTip(tr("Delete WMDRM Database rights.")); + + menuBar()->addAction(iSetDRMClockAct); + menuBar()->addAction(iGetDRMClockAct); + menuBar()->addAction(iEncryptAct); + menuBar()->addAction(iDeleteWMDRMDBAct); + + connect(iSetDRMClockAct, SIGNAL(triggered()), this, SLOT(setDRMClock())); + connect(iGetDRMClockAct, SIGNAL(triggered()), this, SLOT(getDRMClock())); + connect(iEncryptAct, SIGNAL(triggered()), this, SLOT(startEncrypt())); + connect(iDeleteWMDRMDBAct, SIGNAL(triggered()), this, SLOT(deleteWmDrmDB())); + + //setDRMClockButton = new QPushButton("Set DRM Clock", this); + //connect(setDRMClockButton, SIGNAL(clicked()), this, SLOT(setDRMClock())); + //setDRMClockButton->show(); + +/* ui->pushButton->setEnabled(false); + + ui->lineEdit->setValidator(new QDoubleValidator(this)); + ui->lineEdit_2->setValidator(new QDoubleValidator(this)); +*/ + //connect(ui->mainMenu,SIGNAL(onChanged()),this,SLOT(onLaske())); + //connect(ui->lineEdit,SIGNAL(textChanged(const QString &)),this,SLOT(onTextChanged(const QString &))); + //connect(ui->mainMenu,SIGNAL(textChanged(const QString &)),this,SLOT(onTextChanged(const QString &))); + + widget->setLayout(layout); +} + +DRMEncryptor::~DRMEncryptor() +{ + //delete ui; +} + +void DRMEncryptor::setDRMClock() +{ + DateTimeDialog *dateTimeDialog = new DateTimeDialog(); + dateTimeDialog->show(); +} + +void DRMEncryptor::getDRMClock() +{ + TTime time; + TInt timeZone; + TDateTime date; + DRMClock::ESecurityLevel level; + TInt error( KErrNone ); + TBuf< 80 > buf; + + DRM::CDrmServiceApi* service = DRM::CDrmServiceApi::NewLC(); + error = service->GetSecureTime( time, timeZone, level ); + + CleanupStack::PopAndDestroy(); // service + + date = time.DateTime(); + + if(level == 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()); + } + + QGridLayout *layout = new QGridLayout; + layout->setAlignment(Qt::AlignCenter); + setLayout(layout); + + + QString datetimeString((QChar*)buf.Ptr(),buf.Length()); + + QMessageBox *drmClockTime = new QMessageBox(this); + drmClockTime->setWindowTitle(tr("DRM Clock")); + drmClockTime->setText(datetimeString); + + + layout->addWidget(drmClockTime); + drmClockTime->show(); + +} + +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 + } + +void ProcessRightsL(const TDesC& aFile) + { + CDRMMessageParser* c = NULL; + HBufC8* d = NULL; + RFs fs; + RPointerArray 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 DRMEncryptor::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(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 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(); + + } + +void DRMEncryptor::startEncrypt() + { + TUint result = 0; + TUint aEncryptedCount = 0; + TUint aRightsCount = 0; + TUint aMessagesProcessed = 0; + TBuf<128> buffer; + + 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")); + } + + QGridLayout *layout = new QGridLayout; + layout->setAlignment(Qt::AlignCenter); + setLayout(layout); + + QString encryptString((QChar*)buffer.Ptr(),buffer.Length()); + QMessageBox *encrpytMessage = new QMessageBox(this); + encrpytMessage->setWindowTitle(tr("Encrypt")); + encrpytMessage->setText(encryptString); + + layout->addWidget(encrpytMessage); + encrpytMessage->show(); + + } + +TUint DRMEncryptor::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); + + } + +ContentAccess::CManager* GetCafDataL( TAgent& aAgent ) + { + TPtr8 ptr(NULL, 0, 0); + RArray 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; + } + +void DRMEncryptor::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 DRMEncryptor::deleteWmDrmDB() + { + TRAPD(err, DeleteWmDrmRdbL()); + if(!err) + { + QMessageBox::information(this, tr("WMDRM DB"),tr("DRM rights deleted.")); + } + else + { + QMessageBox::information(this, tr("WMDRM DB"),tr("Error deleting WMDRM rights.")); + } + } +/* +void DRMEncryptorsetDRMClock() +{ + + double value1 = ui->lineEdit->text().toDouble(&bOK1); + double value2 = ui->lineEdit_2->text().toDouble(&bOK2); + + ui->lineEdit_3->setText(""); + + if(bOK1 && bOK2) + { + if(value2 != 0) + { + double result = value1 / value2; + ui->lineEdit_3->setText(QString::number(result)); + } + else + { + box.setText("Et voi jakaa nollalla"); + box.exec(); + } + } + else + { + box.setText("Virheellinen syöte"); + box.exec(); + } +} + + void DRMEncryptoronDateTimeChanged(const QDateTime & datetime ) + { + + } +*/ + +void DRMEncryptor::onTextChanged(const QString &) +{ + //ui->pushButton->setEnabled(ui->lineEdit->text() != "" && ui->lineEdit_2->text() != ""); +} + +DateTimeDialog::DateTimeDialog() + { + //iLayout = new QHBoxLayout; + QGridLayout *layout = new QGridLayout; + layout->setAlignment(Qt::AlignCenter); + setLayout(layout); + + iDateEdit = new QDateTimeEdit(QDate::currentDate()); + iDateEdit->setAlignment(Qt::AlignHCenter); + iDateEdit->setDisplayFormat("yyyy.mm.dd hh.mm.ss"); + iDateEdit->setWindowTitle("Set DRM Clock yyyy.MM.dd hh.mm.ss"); + QPushButton *okButton = new QPushButton("OK", this); + QPushButton *cancelButton = new QPushButton("Cancel", this); + + layout->addWidget(iDateEdit); + layout->addWidget(okButton); + layout->addWidget(cancelButton); + + connect(okButton, SIGNAL(clicked()), this, SLOT(setDRMClock())); + connect(cancelButton, SIGNAL(clicked()), this, SLOT(close())); + + //this->setLayout(iLayout); + okButton->show(); + cancelButton->show(); + this->show(); + this->raise(); + } + +DateTimeDialog::~DateTimeDialog() + { + + } + +void DateTimeDialog::setDRMClock() + { + DRM::CDrmServiceApi* service = DRM::CDrmServiceApi::NewLC(); + QString datetimeString = iDateEdit->dateTime().toString("yyyy.mm.dd hh.mm.ss"); + + // datetime in format YYYYMMDD:HHMMSS for TTime + datetimeString.remove(QChar('.')); + datetimeString.replace(" ", ":"); + datetimeString.append(".000000"); + + TPtrC datetimePtr(reinterpret_cast(datetimeString.constData())); + HBufC *datetimeBuf = datetimePtr.AllocLC(); + + TTime inputTime(*datetimeBuf); + TInt timezone = 0; + + // Get secure time from service api to get timezone + DRMClock::ESecurityLevel level; + TInt error( KErrNone ); + + TTime currentTime; + error = service->GetSecureTime(currentTime, timezone, level); + + if(error != KErrNone) + { + return; + } + + error = service->UpdateSecureTime(inputTime, timezone); + + if(error != KErrNone) + { + return; + } + + CleanupStack::PopAndDestroy(2); // datetimeBuf, service + QMessageBox::information(this, tr("DRM Clock"),tr("DRM Clock Set")); + + /* + QGridLayout *layout = new QGridLayout; + layout->setAlignment(Qt::AlignTop); + QLabel *secureTimeSetComplete = new QLabel("DRM Clock Set"); + layout->addWidget(secureTimeSetComplete); + QPushButton *button = new QPushButton("Ok"); + layout->addWidget(button); + button->show(); + secureTimeSetComplete->show(); + connect(button, SIGNAL(clicked()), this, SLOT(close())); + */ + + } + diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmqtencryptor/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commondrm/drmqtencryptor/main.cpp Fri Jun 11 15:44:45 2010 +0300 @@ -0,0 +1,27 @@ +/* +* 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. +* +*/ + +#include +#include "drmencryptor.h" + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + DRMEncryptor w; + w.showMaximized(); + return a.exec(); +} diff -r 5ed7931150e9 -r c68061d56109 commondrm/drmqtencryptor/qt_drmencryptor.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/commondrm/drmqtencryptor/qt_drmencryptor.pro Fri Jun 11 15:44:45 2010 +0300 @@ -0,0 +1,14 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Mon 7. Jun 08:20:39 2010 +###################################################################### + +TEMPLATE = app +TARGET = drmencryptor +DEPENDPATH += . +INCLUDEPATH += . + +# Input +HEADERS += drmencryptor.h +FORMS += drmencryptor.ui +SOURCES += drmencyptor.cpp main.cpp +LIBS += -lplatformenv -ldrmserviceapi -ldcfrep -ldrmparsers -lfbscli -lcone -lestor -lcaf \ No newline at end of file diff -r 5ed7931150e9 -r c68061d56109 commondrm/group/bld.inf --- a/commondrm/group/bld.inf Mon May 31 14:37:41 2010 +0300 +++ b/commondrm/group/bld.inf Fri Jun 11 15:44:45 2010 +0300 @@ -35,7 +35,7 @@ ../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/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 ) @@ -46,9 +46,6 @@ PRJ_MMPFILES -// DRMEncryptor -../drmencryptor/group/DRMEncryptor.mmp - // DRMRightsManagerUi ../drmrightsmanagerui/group/DRMRightsManager.mmp @@ -72,19 +69,6 @@ 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 \ diff -r 5ed7931150e9 -r c68061d56109 drm.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/drm.pro Fri Jun 11 15:44:45 2010 +0300 @@ -0,0 +1,20 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: DRM main level project file. +# + +TEMPLATE = subdirs + +SUBDIRS += commondrm/commondrm.pro + diff -r 5ed7931150e9 -r c68061d56109 drm_plat/drm_common_api/tsrc/data/mmc/DRM/content.dcf diff -r 5ed7931150e9 -r c68061d56109 drm_plat/drm_rights_api/tsrc/data/c/content.dcf diff -r 5ed7931150e9 -r c68061d56109 drm_pub/oma_drm_caf_agent_api/tsrc/bc/DRM_CAF/data/content.dcf diff -r 5ed7931150e9 -r c68061d56109 inc/drmrightsdb.h --- a/inc/drmrightsdb.h Mon May 31 14:37:41 2010 +0300 +++ b/inc/drmrightsdb.h Fri Jun 11 15:44:45 2010 +0300 @@ -57,6 +57,7 @@ class CDRMRightsCleaner; class CDRMRightsServer; class CDcfRep; +class CDRMRightsServer; // FUNCTION PROTOTYPES @@ -91,7 +92,8 @@ static CDRMRightsDB* NewLC( RFs& aFs, const TDesC& aDatabasePath, const TDesC8& aKey, - const TDesC& aImei ); + const TDesC& aImei, + CDRMRightsServer* aServer ); /** * NewL @@ -110,7 +112,8 @@ static CDRMRightsDB* NewL( RFs& aFs, const TDesC& aDatabasePath, const TDesC8& aKey, - const TDesC& aImei ); + const TDesC& aImei, + CDRMRightsServer* aServer ); /** * Destructor @@ -327,6 +330,7 @@ */ CDRMRightsCleaner* DeleteExpiredPermissionsL( const TTime& aTime, TRequestStatus& aStatus ); + /** * NameContentL @@ -369,6 +373,21 @@ */ TBool DeleteExpiredL( const TFileName& aFileName, const TTime& aTime ); + + /** + * 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, + const TDesC8& aContentId ); /** * GetUdtDataL @@ -507,7 +526,7 @@ /** * Default Constructor - First phase. */ - CDRMRightsDB( RFs& aFs ); + CDRMRightsDB( RFs& aFs, CDRMRightsServer* aServer ); /** * ConstructL @@ -675,6 +694,8 @@ // Time stamp of the last update operation TTime iLastUpdate; + + CDRMRightsServer* iRightsServer; }; #endif // DRMRIGHTSDB_H diff -r 5ed7931150e9 -r c68061d56109 layers.sysdef.xml --- a/layers.sysdef.xml Mon May 31 14:37:41 2010 +0300 +++ b/layers.sysdef.xml Fri Jun 11 15:44:45 2010 +0300 @@ -9,6 +9,9 @@ + + + diff -r 5ed7931150e9 -r c68061d56109 omadrm/drmengine/server/inc/DRMRightsServer.h --- a/omadrm/drmengine/server/inc/DRMRightsServer.h Mon May 31 14:37:41 2010 +0300 +++ b/omadrm/drmengine/server/inc/DRMRightsServer.h Fri Jun 11 15:44:45 2010 +0300 @@ -40,7 +40,20 @@ class CDRMBackup; class RMobilePhone; -// CLASS DECLARATION +// CLASS DECLARATIONS + +// Data Class: +NONSHARABLE_CLASS( CUsageUrl ) : public CBase + { + public: + CUsageUrl(); + virtual ~CUsageUrl(); + + public: // Data + HBufC8* iUrl; + TInt iRefCounter; + }; + /** * This class implements the DRM5 Rights Server functionality. @@ -49,7 +62,7 @@ * @since S60Rel2.5 */ NONSHARABLE_CLASS( CDRMRightsServer ) : public CServer2, public MWatcherObserver - { + { public: // Constructors and destructor /** @@ -162,6 +175,34 @@ */ void AddActiveCountConstraintL( const TDesC8& aContentId ); + + /** + * Checks if a content ID is in the list of currently consumed contents + * + * @since 5.2 + * @param aContentId content ID to search for + * @return Index or the Url if the content ID is in the list + * KErrNotFound if the content ID is not in the list + */ + TInt IsAccessingUrl( const TDesC8& aContentId ); + + /** + * Removes a content ID from the list of currently consumed contents + * + * @since 5.2 + * @param aContentId content ID to remove + */ + void RemoveAccessingUrl( const TDesC8& aContentId ); + + /** + * Adds a content ID to the list of currently consumed contents + * + * @since 5.2 + * @param aContentId content ID to add + */ + void AddAccessingUrlL( const TDesC8& aContentId ); + + /** * Import rights objects on startup * @@ -275,6 +316,7 @@ RDRMClockClient iClock; RPointerArray* iXOmaHeaders; RPointerArray iActiveCountConstraints; + RPointerArray iActiveUrls; HBufC* iIMEI; @@ -307,6 +349,7 @@ }; + #endif // CDRMRIGHTSSERVER_H // End of File diff -r 5ed7931150e9 -r c68061d56109 omadrm/drmengine/server/src/DRMDbSession.cpp --- a/omadrm/drmengine/server/src/DRMDbSession.cpp Mon May 31 14:37:41 2010 +0300 +++ b/omadrm/drmengine/server/src/DRMDbSession.cpp Fri Jun 11 15:44:45 2010 +0300 @@ -1743,7 +1743,8 @@ // Count constraints are valid for the duration of the // session after they have been consumed earlier if ( !( iConsume && iConsume->CountConstraintActive() || - SERVER->HasActiveCountConstraint( *CID ) ) ) + SERVER->HasActiveCountConstraint( *CID ) || + SERVER->IsAccessingUrl( *CID ) != KErrNotFound ) ) { CDRMPermission* child( NULL ); HBufC8* uri( NULL ); diff -r 5ed7931150e9 -r c68061d56109 omadrm/drmengine/server/src/DRMRightsServer.cpp --- a/omadrm/drmengine/server/src/DRMRightsServer.cpp Mon May 31 14:37:41 2010 +0300 +++ b/omadrm/drmengine/server/src/DRMRightsServer.cpp Fri Jun 11 15:44:45 2010 +0300 @@ -294,6 +294,29 @@ // ============================ MEMBER FUNCTIONS =============================== +// CUsageUrl: + +//-------------------------------------------------------------------------- +// CUsageUrl::CUsageUrl +// Storage class default constructor +//-------------------------------------------------------------------------- +// +CUsageUrl::CUsageUrl() + { + } + +//-------------------------------------------------------------------------- +// CUsageUrl::~CUsageUrl +// Storage class destructor +//-------------------------------------------------------------------------- +// +CUsageUrl::~CUsageUrl() + { + delete iUrl; + } + +// CDRMRightsServer: + // ----------------------------------------------------------------------------- // CDRMRightsServer::NewLC // Two-phased constructor. @@ -354,6 +377,8 @@ delete iNotifier; iNotifier = NULL; } + iActiveUrls.ResetAndDestroy(); + //An empty semaphore RSemaphore semaphore; } @@ -599,13 +624,13 @@ #ifndef RD_MULTIPLE_DRIVE - iDb = CDRMRightsDB::NewL( iFs, KRightsDir, key, *iIMEI ); + iDb = CDRMRightsDB::NewL( iFs, KRightsDir, key, *iIMEI, const_cast(this) ); #else //RD_MULTIPLE_DRIVE tempPath.Format( KRightsDir, (TUint)driveLetter ); - iDb = CDRMRightsDB::NewL( iFs, tempPath, key, *iIMEI ); + iDb = CDRMRightsDB::NewL( iFs, tempPath, key, *iIMEI, const_cast(this) ); #endif @@ -1337,6 +1362,85 @@ } } + + +// ----------------------------------------------------------------------------- +// CDRMRightsServer::IsAccessingUrl +// Add ID to count constraint list +// ----------------------------------------------------------------------------- +// +TInt CDRMRightsServer::IsAccessingUrl( const TDesC8& aContentId ) + { + for( TInt i = 0; i < iActiveUrls.Count(); i++ ) + { + if( !iActiveUrls[i]->iUrl->Compare( aContentId ) ) + { + return i; + } + } + return KErrNotFound; + } + +// ----------------------------------------------------------------------------- +// CDRMRightsServer::RemoveAccessingUrl +// Add ID to count constraint list +// ----------------------------------------------------------------------------- +// +void CDRMRightsServer::RemoveAccessingUrl( const TDesC8& aContentId ) + { + CUsageUrl* usage = NULL; + TInt index = KErrNotFound; + + index = IsAccessingUrl( aContentId ); + + if( index != KErrNotFound ) + { + // If there are negative or 0 values in the list for some reason + // remove them + if( iActiveUrls[index]->iRefCounter <= 1 ) + { + usage = iActiveUrls[index]; + iActiveUrls.Remove( index ); + delete usage; + } + else + { + iActiveUrls[index]->iRefCounter--; + } + } + } + +// ----------------------------------------------------------------------------- +// CDRMRightsServer::AddAccessingUrlL +// Add ID to count constraint list +// ----------------------------------------------------------------------------- +// +void CDRMRightsServer::AddAccessingUrlL( const TDesC8& aContentId ) + { + CUsageUrl* usage = NULL; + TInt index = KErrNotFound; + + index = IsAccessingUrl( aContentId ); + + if( index == KErrNotFound ) + { + usage = new ( ELeave ) CUsageUrl(); + CleanupStack::PushL( usage ); + usage->iUrl = aContentId.AllocL(); + usage->iRefCounter = 1; + iActiveUrls.AppendL( usage ); + CleanupStack::Pop( usage ); + } + else + { + usage = iActiveUrls[index]; + usage->iRefCounter++; + } + } + + + + // ----------------------------------------------------------------------------- // CDRMRightsServer::StopWatchingL // Delete the watchers @@ -1425,6 +1529,8 @@ } #endif + + // ========================== OTHER EXPORTED FUNCTIONS ========================= diff -r 5ed7931150e9 -r c68061d56109 omadrm/drmengine/server/src/drmconsume.cpp --- a/omadrm/drmengine/server/src/drmconsume.cpp Mon May 31 14:37:41 2010 +0300 +++ b/omadrm/drmengine/server/src/drmconsume.cpp Fri Jun 11 15:44:45 2010 +0300 @@ -140,6 +140,12 @@ CDRMConsume::~CDRMConsume() { DRMLOG( _L( "CDRMConsume::~" ) ); + + if( iURI ) + { + SERVER->RemoveAccessingUrl( *iURI ); + } + TInt error( KErrNone ); if( IsActive() ) @@ -203,6 +209,8 @@ { iParentId = aParentId->AllocL(); } + + SERVER->AddAccessingUrlL( aURI ); } // ------------------------------------------------------------------------ diff -r 5ed7931150e9 -r c68061d56109 omadrm/drmengine/server/src/drmrightsdb.cpp --- a/omadrm/drmengine/server/src/drmrightsdb.cpp Mon May 31 14:37:41 2010 +0300 +++ b/omadrm/drmengine/server/src/drmrightsdb.cpp Fri Jun 11 15:44:45 2010 +0300 @@ -45,6 +45,7 @@ #include "DrmKeyStorage.h" #include "utf.h" // charconv, ConvertFromUnicodeToUtf8L #include "drmlog.h" +#include "DRMRightsServer.h" #ifdef RD_DRM_RIGHTS_MANAGER_REMOVAL #include "DRMClockClient.h" @@ -161,10 +162,11 @@ // might leave. // ----------------------------------------------------------------------------- // -CDRMRightsDB::CDRMRightsDB( RFs& aFs ) : +CDRMRightsDB::CDRMRightsDB( RFs& aFs, CDRMRightsServer* aServer ) : iFileServer( aFs ), iImei( NULL ), - iLastUpdate( Time::NullTTime() ) + iLastUpdate( Time::NullTTime() ), + iRightsServer( aServer ) { }; @@ -215,9 +217,10 @@ CDRMRightsDB* CDRMRightsDB::NewLC( RFs& aFs, const TDesC& aDatabasePath, const TDesC8& aKey, - const TDesC& aImei ) + const TDesC& aImei, + CDRMRightsServer* aServer ) { - CDRMRightsDB* self = new( ELeave ) CDRMRightsDB( aFs ); + CDRMRightsDB* self = new( ELeave ) CDRMRightsDB( aFs, aServer ); CleanupStack::PushL( self ); self->ConstructL( aDatabasePath, aKey, aImei ); @@ -232,9 +235,10 @@ CDRMRightsDB* CDRMRightsDB::NewL( RFs& aFs, const TDesC& aDatabaseFile, const TDesC8& aKey, - const TDesC& aImei ) + const TDesC& aImei, + CDRMRightsServer* aServer ) { - CDRMRightsDB* self = NewLC( aFs, aDatabaseFile, aKey, aImei ); + CDRMRightsDB* self = NewLC( aFs, aDatabaseFile, aKey, aImei, aServer ); CleanupStack::Pop(); return self; @@ -315,7 +319,7 @@ } // Delete expired: - TRAP_IGNORE( deleteAllowed = DeleteExpiredL( path, time ) ); + TRAP_IGNORE( deleteAllowed = DeleteExpiredL( path, time, aContentID ) ); // Check if it's possible to delete the file as well if( deleteAllowed ) @@ -1074,6 +1078,77 @@ // ----------------------------------------------------------------------------- +// CDRMRightsDB::DeleteExpiredL +// ----------------------------------------------------------------------------- +// +TBool CDRMRightsDB::DeleteExpiredL( const TFileName& aFileName, + const TTime& aTime, + const TDesC8& aContentId ) + { + CDRMRightsData* rights = NULL; + TInt amountLeft = -1; + TBool retVal = EFalse; + TBool parents = EFalse; + + DRMLOG( _L( "CDRMRightsDB::DeleteExpiredL(2) ->" ) ); + + // if there is a consumption session ongoing, we can't delete it at all + // or the decryption will not function properly after pause etc + if( iRightsServer->IsAccessingUrl( aContentId ) != KErrNotFound ) + { + return EFalse; + } + + // 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 <-" ) ); + + if( iRightsServer->HasActiveCountConstraint( aContentId )) + { + retVal = EFalse; + } + + return retVal; + } + + +// ----------------------------------------------------------------------------- // CDRMRightsDB::GetUdtDataLC // ----------------------------------------------------------------------------- // diff -r 5ed7931150e9 -r c68061d56109 wmdrm/camese/httpfiltercamese/Src/httpfiltercamesedrmheader.cpp --- a/wmdrm/camese/httpfiltercamese/Src/httpfiltercamesedrmheader.cpp Mon May 31 14:37:41 2010 +0300 +++ b/wmdrm/camese/httpfiltercamese/Src/httpfiltercamesedrmheader.cpp Fri Jun 11 15:44:45 2010 +0300 @@ -31,7 +31,7 @@ // 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 TUid KCRUidMusicShopSettings = {0x101FFB51}; // 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