2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
19 #include "drm_client.h"
20 #include "drm_client_types.h"
21 #include "drm_trusted_client.h"
22 #include "drm_trusted_client_types.h"
24 #include "download-agent-debug.h"
25 #include "download-agent-plugin-drm.h"
28 void __EDRM_clean_up()
31 ret = drm_trusted_handle_request(DRM_TRUSTED_REQ_TYPE_CLIENT_CLEAN_UP, NULL, NULL);
32 if (DRM_RETURN_SUCCESS == ret) {
33 DA_LOGD( "Clean up successfull");
35 DA_LOGE("ret[%0x%x]",ret);
39 da_bool_t EDRM_convert(const char *in_file_path, char **out_file_path)
41 drm_trusted_conv_info_s input;
42 drm_trusted_conv_resp_info_s output;
46 memset(&input, 0x0, sizeof(drm_trusted_conv_info_s));
47 memset(&output, 0x0, sizeof(drm_trusted_conv_resp_info_s));
49 len = strlen(in_file_path);
50 if (len >= sizeof(input.filePath))
51 len = sizeof(input.filePath) - 1;
52 memcpy(input.filePath, in_file_path, len);
54 ret = drm_trusted_convert_dm(&input, &output);
56 if (DRM_TRUSTED_RETURN_SUCCESS != ret) {
57 DA_LOGE("ret[%0x%x]",ret);
61 DA_SECURE_LOGD("Returned filePath[%s]", output.filePath);
62 *out_file_path = strdup(output.filePath);
68 da_ret_t EDRM_wm_get_license(char *rights_url, char **out_content_url)
72 drm_initiator_info_s init_info;
73 drm_web_server_resp_data_s resp_data;
75 if (rights_url == NULL)
76 return DA_ERR_DRM_FAIL;
78 memset(&init_info, 0, sizeof(init_info));
79 memset(&resp_data, 0, sizeof(resp_data));
80 strncpy(init_info.initiator_url, rights_url,
81 DRM_MAX_LEN_INITIATOR_URL - 1);
82 len = strlen(rights_url);
83 if (len > DRM_MAX_LEN_INITIATOR_URL - 1)
84 init_info.initiator_url_len = (unsigned int)len;
86 init_info.initiator_url_len = DRM_MAX_LEN_INITIATOR_URL;
87 ret = drm_process_request(DRM_REQUEST_TYPE_SUBMIT_INITIATOR_URL,
88 &init_info, &resp_data);
89 if (DRM_RETURN_SUCCESS == ret) {
90 DA_SECURE_LOGD("resp_data.content_url = %s", resp_data.content_url);
91 /* Rights or Domain Certificate are installed successfully */
92 /* Check for contentURL */
93 if (strlen(resp_data.content_url) > 0) {
94 char *content_url = NULL;
95 size_t content_url_len = 0;
96 content_url_len = strlen(resp_data.content_url);
97 content_url = (char *)calloc(1, content_url_len + 1);
99 strncpy(content_url, resp_data.content_url,
101 *out_content_url = content_url;
102 DA_SECURE_LOGD("drm sumitted initiator url "
103 "succeeded with [%s]", *out_content_url);
107 DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
109 return DA_ERR_FAIL_TO_MEMALLOC;
112 DA_LOGV("content_url is NULL.\
113 Join/Leave Domain, Metering case.");
114 *out_content_url = DA_NULL;
119 DA_LOGE("drm_process_request() failed");
121 return DA_ERR_DRM_FAIL;