3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
32 #include "MmsPluginDrm.h"
33 #include "MmsPluginCodec.h"
34 #include "MsgMmsTypes.h"
35 #include "MsgDrmWrapper.h"
37 #include "drm-service.h"
39 #ifdef __SUPPORT_DRM__
41 MmsDrm2ConvertState mmsDrm2ConvertState;
43 MsgDrmType MsgGetDRMType(MsgType *pMsgType, MsgBody *pMsgBody)
45 MsgDrmType drmType = MSG_DRM_TYPE_NONE;
46 MsgMultipart *pMultipart = NULL;
48 if (MsgIsMultipart(pMsgType->type)) {
49 pMultipart = pMsgBody->body.pMultipart;
51 if (drmType < pMultipart->type.drmInfo.drmType)
52 drmType = pMultipart->type.drmInfo.drmType;
54 pMultipart = pMultipart->pNext;
57 drmType = pMsgType->drmInfo.drmType;
63 void MmsDrm2SetConvertState(MmsDrm2ConvertState newConvertState)
65 mmsDrm2ConvertState = newConvertState;
66 MSG_DEBUG("MmsDrm2SetConvertState: mmsDrm2ConvertState = %d\n", mmsDrm2ConvertState);
69 MmsDrm2ConvertState MmsDrm2GetConvertState(void)
71 return mmsDrm2ConvertState;
74 bool MsgDRM2GetDRMInfo(char *szFilePath, MsgType *pMsgType)
76 if (szFilePath == NULL || pMsgType == NULL) {
77 MSG_DEBUG("Param is NULL szFilePath = %d, pMsgType = %d", szFilePath, pMsgType);
81 char szMimeType[DRM_MAX_TYPE_LEN + 1];
82 char szContentID[DRM_MAX_CID_LEN + 1];
83 MSG_DRM_TYPE drmType = MSG_DRM_NONE;
85 MsgDrmGetDrmType(szFilePath, &drmType);
86 MsgDrmGetMimeTypeEx(szFilePath, szMimeType, DRM_MAX_TYPE_LEN + 1);
87 MsgDrmGetContentID(szFilePath, szContentID, DRM_MAX_CID_LEN + 1);
88 MSG_DEBUG("drmType: %d", drmType);
91 case MSG_DRM_FORWARD_LOCK:
92 pMsgType->drmInfo.drmType = MSG_DRM_TYPE_FL;
93 pMsgType->drmInfo.contentType = (MsgContentType)_MsgGetCode(MSG_TYPE, szMimeType);
94 if (MsgCopyDrmInfo(pMsgType) == false) {
95 MSG_DEBUG("MsgDRM2GetDRMInfo : MsgCopyDrmInfo failed");
100 case MSG_DRM_COMBINED_DELIVERY:
101 pMsgType->drmInfo.drmType = MSG_DRM_TYPE_CD;
102 pMsgType->drmInfo.szContentURI = MsgResolveContentURI(szContentID);
105 case MSG_DRM_SEPARATE_DELIVERY:
106 pMsgType->drmInfo.drmType = MSG_DRM_TYPE_SD;
108 pMsgType->drmInfo.contentType = (MsgContentType)_MsgGetCode(MSG_TYPE, szMimeType);
110 drm_dcf_header_t dcfHdrInfo;
111 drm_svc_get_dcf_header_info(szFilePath, &dcfHdrInfo);
113 if (dcfHdrInfo.version == DRM_OMA_DRMV1_RIGHTS) {
114 pMsgType->drmInfo.szContentName = MsgRemoveQuoteFromFilename(dcfHdrInfo.headerUnion.headerV1.contentName);
115 pMsgType->drmInfo.szContentDescription = MsgStrCopy(dcfHdrInfo.headerUnion.headerV1.contentDescription);
120 pMsgType->drmInfo.drmType = MSG_DRM_TYPE_NONE;
124 pMsgType->drmInfo.szDrm2FullPath = MsgStrCopy(szFilePath);
125 MSG_DEBUG("pMsgType->drmInfo.szDrm2FullPath: %s", pMsgType->drmInfo.szDrm2FullPath);
130 bool MsgDRMIsForwardLockType(MsgDrmType drmType)
133 case MSG_DRM_TYPE_FL:
134 case MSG_DRM_TYPE_CD:
137 case MSG_DRM_TYPE_NONE: //SD & plain can be forwarded
138 case MSG_DRM_TYPE_SD:
144 bool MsgChangeDrm2FileName(char *szFileName)
146 char szTempFileName[MSG_FILENAME_LEN_MAX] = {0,};
148 if (szFileName == NULL || szFileName[0] == '\0')
151 MsgGetFileNameWithoutExtension(szTempFileName, szFileName);
153 if (strrchr(szTempFileName, '.'))
156 strcat(szTempFileName, ".dcf");
157 strcpy(szFileName, szTempFileName);
159 MSG_DEBUG("MsgChangeDrm2FileName: made szFileName = %s \n", szFileName);
164 bool MsgIsDCFFile(char *szFilePath)
168 MSG_DEBUG("MsgIsDCFFile: szFilePath = %s \n", szFilePath);
170 length = MsgStrlen(szFilePath);
171 if (szFilePath[length - 4] == '.' &&
172 (szFilePath[length - 3] == 'd' || szFilePath[length - 3] == 'D') &&
173 (szFilePath[length - 2] == 'c' || szFilePath[length - 2] == 'C') &&
174 (szFilePath[length - 1] == 'f' || szFilePath[length - 1] == 'F'))