2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <drm_client_types.h>
19 #include <drm_client.h>
20 #include "MsgMmsTypes.h"
21 #include "MsgDrmWrapper.h"
22 #include "MmsPluginDrm.h"
23 #include "MmsPluginCodec.h"
24 #include "MmsPluginMIME.h"
25 #include "MmsPluginDebug.h"
26 #include "MmsPluginUtil.h"
28 #ifdef __SUPPORT_DRM__
30 MmsDrm2ConvertState mmsDrm2ConvertState;
32 MsgDrmType MsgGetDRMType(MsgType *pMsgType, MsgBody *pMsgBody)
34 MsgDrmType drmType = MSG_DRM_TYPE_NONE;
35 MsgMultipart *pMultipart = NULL;
37 if (MsgIsMultipart(pMsgType->type)) {
38 pMultipart = pMsgBody->body.pMultipart;
40 if (drmType < pMultipart->type.drmInfo.drmType)
41 drmType = pMultipart->type.drmInfo.drmType;
43 pMultipart = pMultipart->pNext;
46 drmType = pMsgType->drmInfo.drmType;
52 void MmsDrm2SetConvertState(MmsDrm2ConvertState newConvertState)
54 mmsDrm2ConvertState = newConvertState;
55 MSG_DEBUG("MmsDrm2SetConvertState: mmsDrm2ConvertState = %d\n", mmsDrm2ConvertState);
58 MmsDrm2ConvertState MmsDrm2GetConvertState(void)
60 return mmsDrm2ConvertState;
63 bool MsgDRM2GetDRMInfo(char *szFilePath, MsgType *pMsgType)
65 if (szFilePath == NULL || pMsgType == NULL) {
66 MSG_DEBUG("Param is NULL szFilePath = %d, pMsgType = %d", szFilePath, pMsgType);
70 char szMimeType[DRM_MAX_LEN_MIME + 1];
71 char szContentID[DRM_MAX_LEN_CID + 1];
72 MSG_DRM_TYPE drmType = MSG_DRM_NONE;
75 MsgDrmGetDrmType(szFilePath, &drmType);
76 MsgDrmGetMimeTypeEx(szFilePath, szMimeType, sizeof(szMimeType));
77 MsgDrmGetContentID(szFilePath, szContentID, sizeof(szContentID));
78 MSG_DEBUG("drmType: %d", drmType);
81 case MSG_DRM_FORWARD_LOCK:
82 pMsgType->drmInfo.drmType = MSG_DRM_TYPE_FL;
83 pMsgType->drmInfo.contentType = (MimeType)_MsgGetCode(MSG_TYPE, szMimeType);
84 if (MsgCopyDrmInfo(pMsgType) == false) {
85 MSG_DEBUG("MsgDRM2GetDRMInfo : MsgCopyDrmInfo failed");
90 case MSG_DRM_COMBINED_DELIVERY:
91 pMsgType->drmInfo.drmType = MSG_DRM_TYPE_CD;
92 pMsgType->drmInfo.szContentURI = MsgResolveContentURI(szContentID);
95 case MSG_DRM_SEPARATE_DELIVERY:
96 pMsgType->drmInfo.drmType = MSG_DRM_TYPE_SD;
98 pMsgType->drmInfo.contentType = (MimeType)_MsgGetCode(MSG_TYPE, szMimeType);
100 drm_content_info_s dcfHdrInfo;
101 bzero(&dcfHdrInfo, sizeof(drm_content_info_s));
102 ret = drm_get_content_info(szFilePath, &dcfHdrInfo);
103 MSG_DEBUG("drm_get_content_info is failed, ret=[%d]", ret);
105 drm_file_info_s fileInfo;
106 bzero(&fileInfo, sizeof(drm_file_info_s));
107 ret = drm_get_file_info(szFilePath, &fileInfo);
108 MSG_DEBUG("drm_get_file_info is failed, ret=[%d]", ret);
110 if (fileInfo.oma_info.version == DRM_OMA_DRMV1_RIGHTS) {
111 pMsgType->drmInfo.szContentName = MsgRemoveQuoteFromFilename(dcfHdrInfo.title);
112 pMsgType->drmInfo.szContentDescription = MsgStrCopy(dcfHdrInfo.description);
117 pMsgType->drmInfo.drmType = MSG_DRM_TYPE_NONE;
121 pMsgType->drmInfo.szDrm2FullPath = MsgStrCopy(szFilePath);
122 MSG_DEBUG("pMsgType->drmInfo.szDrm2FullPath: %s", pMsgType->drmInfo.szDrm2FullPath);
127 bool MsgDRMIsForwardLockType(MsgDrmType drmType)
130 case MSG_DRM_TYPE_FL:
131 case MSG_DRM_TYPE_CD:
134 case MSG_DRM_TYPE_NONE: //SD & plain can be forwarded
135 case MSG_DRM_TYPE_SD:
141 bool MsgChangeDrm2FileName(char *szFileName)
143 char szTempFileName[MSG_FILENAME_LEN_MAX] = {0,};
145 if (szFileName == NULL || szFileName[0] == '\0')
148 MsgGetFileNameWithoutExtension(szTempFileName, szFileName);
150 if (strrchr(szTempFileName, '.'))
153 strcat(szTempFileName, ".dcf");
154 strcpy(szFileName, szTempFileName);
156 MSG_DEBUG("MsgChangeDrm2FileName: made szFileName = %s \n", szFileName);
161 bool MsgIsDCFFile(char *szFilePath)
165 MSG_DEBUG("MsgIsDCFFile: szFilePath = %s \n", szFilePath);
167 length = MsgStrlen(szFilePath);
168 if (szFilePath[length - 4] == '.' &&
169 (szFilePath[length - 3] == 'd' || szFilePath[length - 3] == 'D') &&
170 (szFilePath[length - 2] == 'c' || szFilePath[length - 2] == 'C') &&
171 (szFilePath[length - 1] == 'f' || szFilePath[length - 1] == 'F'))