JBrowserDRMHandler.c
资源名称:mmi.rar [点击查看]
上传用户:lqx1163
上传日期:2014-08-13
资源大小:9183k
文件大小:14k
源码类别:
MTK
开发平台:
C/C++
- /*****************************************************************************
- * Copyright Statement:
- * --------------------
- * This software is protected by Copyright and the information contained
- * herein is confidential. The software may not be copied and the information
- * contained herein may not be used or disclosed except with the written
- * permission of MediaTek Inc. (C) 2005
- *
- * BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
- * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
- * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
- * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
- * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
- * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
- * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
- * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
- * NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
- * SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
- *
- * BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
- * LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
- * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
- * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
- * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
- *
- * THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
- * WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
- * LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
- * RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
- * THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
- *
- *****************************************************************************/
- /*****************************************************************************
- *
- * Filename:
- * ---------
- * jBrowserDRMHandler.c
- *
- * Project:
- * --------
- * MAUI
- *
- * Description:
- * ------------
- * This is DRm handler file for Browser
- *
- * Author:
- * -------
- * -------
- *
- *============================================================================
- * HISTORY
- * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *------------------------------------------------------------------------------
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- * removed!
- * removed!
- * removed!
- *
- *------------------------------------------------------------------------------
- * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
- *============================================================================
- ****************************************************************************/
- #ifndef _JBROWSERDRMHANDLER_C_
- #define _JBROWSERDRMHANDLER_C_
- #include "MMI_features.h"
- #ifdef __DRM_SUPPORT__
- #if defined (JATAAYU_SUPPORT) && defined (WAP_SUPPORT)
- #include "jBrowserDRMHandler.h"
- #include "JBrowserMMITypes.h"
- #include "drm_gprot.h"
- #include "jdd_MessagingConfig.h"
- #include "miscutils.h"
- brw_drm_context_struct g_brw_drm_cntx;
- /*****************************************************************************
- * FUNCTION
- * jBrowser_drm_indication_handler
- * DESCRIPTION
- * -
- * PARAMETERS
- * pvDRMArg [?]
- * pcMimeType [?]
- * pstMimeContent [?]
- * cbResponseHandler [IN]
- * cbMoreContentHandler [IN]
- * pvAppArg [?]
- * puiDRMRefID [?]
- * pstDRMInfo [?]
- * -(?)
- * RETURNS
- * -
- *****************************************************************************/
- JC_RETCODE jBrowser_drm_indication_handler(
- void *pvDRMArg,
- JC_INT8 *pcMimeType,
- ST_MIME_CONTENT *pstMimeContent,
- CB_DRM_RESPONSE_HANDLER cbResponseHandler,
- CB_DRM_MORE_CONTENT_HANDLER cbMoreContentHandler,
- void *pvAppArg,
- JC_UINT32 *puiDRMRefID,
- ST_DRM_PARSED_INFO *pstDRMInfo)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- g_brw_drm_cntx.drm_arg = pvDRMArg;
- g_brw_drm_cntx.drm_content = pstMimeContent;
- g_brw_drm_cntx.drm_response_callback = cbResponseHandler;
- g_brw_drm_cntx.drm_app_arg = pvAppArg;
- if (!jc_strcmp(pcMimeType, "application/vnd.oma.drm.message"))
- {
- g_brw_drm_cntx.drm_type = DRM_TYPE_MESSAGE;
- }
- else if (!jc_strcmp(pcMimeType, "application/vnd.oma.drm.content"))
- {
- g_brw_drm_cntx.drm_type = DRM_TYPE_CONTENT;
- }
- *puiDRMRefID = (JC_UINT32) g_brw_drm_cntx.drm_content->uData.pmFileName;
- g_brw_drm_cntx.drm_ref_id = *puiDRMRefID;
- jBrowser_send_parse_drm_event();
- return JC_ERR_ASYNC_CALL;
- }
- /*****************************************************************************
- * FUNCTION
- * jBrowser_send_parse_drm_event
- * DESCRIPTION
- * -
- * PARAMETERS
- * void
- * -(?)
- * RETURNS
- * -(?)
- *****************************************************************************/
- void jBrowser_send_parse_drm_event(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- JC_RETCODE iRet = JC_OK;
- JC_EVENT_DATA eventData = {0};
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- jc_memset(&eventData, 0, sizeof(JC_EVENT_DATA));
- eventData.pEventInfo = NULL;
- eventData.uiEventInfoSize = 0;
- eventData.iEventType = E_BRW_PARSE_DRM_EVENT;
- eventData.destTaskInfo.iAppID = E_TASK_BROWSER_UI;
- eventData.destTaskInfo.iTaskID = E_TASK_BROWSER_UI;
- eventData.srcTaskInfo.iAppID = E_TASK_BROWSER_UI;
- eventData.srcTaskInfo.iTaskID = E_TASK_BROWSER_UI;
- iRet = jdd_QueueSend(&eventData);
- if (JC_OK != iRet)
- {
- return;
- }
- }
- /*****************************************************************************
- * FUNCTION
- * jBrowser_parse_drm_content
- * DESCRIPTION
- * -
- * PARAMETERS
- * void
- * -(?)
- * RETURNS
- * -(?)
- *****************************************************************************/
- void jBrowser_parse_drm_content(void)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- ST_DRM_PARSED_INFO parsed_drm_info;
- JC_RETCODE eRet = JC_OK;
- JC_CHAR *drm_content_fname;
- JDD_FSHANDLE fs_handle = NULL;
- U32 drm_ret = 0;
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- if (!fs_handle)
- {
- eRet = jdd_FSInitialize(&fs_handle);
- if (eRet != JC_OK)
- {
- goto ERROR_HANDLE;
- }
- }
- parsed_drm_info.pstRightsObject = (ST_DRM_RIGHTS_OBJECT*) jdd_MemAlloc(sizeof(ST_DRM_RIGHTS_OBJECT), 1);
- if (parsed_drm_info.pstRightsObject == NULL)
- {
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto ERROR_HANDLE;
- }
- parsed_drm_info.pstRightsObject->pcContentID = NULL;
- parsed_drm_info.pstRightsObject->eStatusCode = E_DRM_STATUS_OK;
- parsed_drm_info.pstRightsObject->bIsRender = FALSE;
- parsed_drm_info.pstRightsObject->bIsForwardLock = TRUE;
- parsed_drm_info.pstRightsObject->uiStartTime = 0;
- parsed_drm_info.pstRightsObject->uiDuration = 0;
- parsed_drm_info.pstRightsObject->pstNext = NULL;
- parsed_drm_info.pcContentType = NULL;
- parsed_drm_info.stMimeContent.pucHeader = NULL;
- parsed_drm_info.stMimeContent.uiHeaderLen = 0;
- parsed_drm_info.stMimeContent.bIsBinaryHeader = FALSE;
- parsed_drm_info.stMimeContent.eDataType = E_MIME_FILENAME;
- parsed_drm_info.stMimeContent.uData.pucBuffer = NULL;
- parsed_drm_info.stMimeContent.uData.pmFileName = NULL;
- parsed_drm_info.stMimeContent.uiBufferLen = 0;
- parsed_drm_info.stMimeContent.bHasMoreData = FALSE;
- drm_content_fname =
- (JC_CHAR*) jdd_FSFileNameTranslate(fs_handle, (JC_CHAR*) g_brw_drm_cntx.drm_content->uData.pmFileName);
- if (drm_content_fname == NULL)
- {
- eRet = JC_ERR_MEMORY_ALLOCATION;
- goto ERROR_HANDLE;
- }
- if (g_brw_drm_cntx.drm_type == DRM_TYPE_MESSAGE)
- {
- /* JC_CHAR tmp_ext_str[50]; */
- JC_CHAR *encrypted_filename;
- FS_HANDLE file_handle = NULL;
- DRM_RIGHTS_STRUCT *drm_rights = NULL;
- jdd_FSGetDownloadFileName(&encrypted_filename);
- //AnsiiToUnicodeString((PS8)&tmp_ext_str, (PS8)"temp_file.extension");
- //drm_ret = DRM_process_direct_file((kal_uint8*)"application/vnd.oma.drm.message", (kal_wchar*)drm_content_fname, (kal_wchar*)tmp_ext_str, &content_length);
- drm_ret = DRM_process_virtual_file(
- (kal_uint8*) "application/vnd.oma.drm.message",
- (kal_wchar*) drm_content_fname,
- (kal_wchar*) encrypted_filename);
- /* if(drm_ret > DRM_PROC_RESULT_NO_PERMISSION) */
- if (drm_ret == DRM_PROC_RESULT_OK)
- {
- file_handle = DRM_open_file((kal_wchar*) encrypted_filename, FS_READ_ONLY, DRM_PERMISSION_NONE);
- if (file_handle <= 0)
- {
- DRM_close_file(file_handle);
- eRet = JC_ERR_UNKNOWN;
- goto ERROR_HANDLE;
- }
- drm_rights = DRM_get_rights(file_handle);
- parsed_drm_info.pstRightsObject->bIsRender = TRUE;
- parsed_drm_info.stMimeContent.uData.pmFileName = encrypted_filename;
- parsed_drm_info.pcContentType = jdi_UtilsStrdup((JC_INT8*) DRM_get_content_type(file_handle));
- parsed_drm_info.stMimeContent.uiBufferLen = drm_rights->data_len;
- DRM_close_file(file_handle);
- }
- else
- {
- eRet = JC_ERR_UNKNOWN;
- goto ERROR_HANDLE;
- }
- }
- else if (g_brw_drm_cntx.drm_type == DRM_TYPE_CONTENT)
- {
- drm_ret = DRM_process_virtual_file(
- (kal_uint8*) "application/vnd.oma.drm.content",
- (kal_wchar*) drm_content_fname,
- (kal_wchar*) drm_content_fname);
- }
- else
- {
- eRet = JC_ERR_UNKNOWN;
- goto ERROR_HANDLE;
- }
- ERROR_HANDLE:
- if (fs_handle)
- {
- jdd_FSDeinitialize(fs_handle);
- fs_handle = NULL;
- }
- (g_brw_drm_cntx.drm_response_callback) (g_brw_drm_cntx.drm_app_arg, g_brw_drm_cntx.drm_ref_id, &parsed_drm_info);
- }
- /*****************************************************************************
- * FUNCTION
- * jBrowser_drm_rights_update_handler
- * DESCRIPTION
- * -
- * PARAMETERS
- * uiDRMRefID [IN]
- * pstRightsObject [?]
- * bIsRendered [IN]
- * -(?)
- * RETURNS
- * -(?)
- *****************************************************************************/
- void jBrowser_drm_rights_update_handler(
- JC_UINT32 uiDRMRefID,
- ST_DRM_RIGHTS_OBJECT *pstRightsObject,
- JC_BOOLEAN bIsRendered)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return;
- }
- /*****************************************************************************
- * FUNCTION
- * jBrowser_drm_more_content_handler
- * DESCRIPTION
- * -
- * PARAMETERS
- * pvAppArg [?]
- * uiDRMRefID [IN]
- * pucBuffer [?]
- * uiBufferLen [IN]
- * bHasMoreData [IN]
- * -(?)
- * RETURNS
- * -
- *****************************************************************************/
- JC_RETCODE jBrowser_drm_more_content_handler(
- void *pvAppArg,
- JC_UINT32 uiDRMRefID,
- JC_UINT8 *pucBuffer,
- JC_UINT32 uiBufferLen,
- JC_BOOLEAN bHasMoreData)
- {
- /*----------------------------------------------------------------*/
- /* Local Variables */
- /*----------------------------------------------------------------*/
- /*----------------------------------------------------------------*/
- /* Code Body */
- /*----------------------------------------------------------------*/
- return JC_OK;
- }
- #endif /* defined (JATAAYU_SUPPORT) && defined (WAP_SUPPORT) */
- #endif /* __DRM_SUPPORT__ */ /* #ifdef __DRM_SUPPORT__ */
- #endif /* _JBROWSERDRMHANDLER_C_ */