Tizen 2.1 base
[apps/home/myfiles.git] / src / common / mf-drm.c
1 /*
2  * Copyright 2013         Samsung Electronics Co., Ltd
3  *
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
7  *
8  *  http://floralicense.org/license/
9  *
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.
15  */
16
17 #include <Eina.h>
18 #include <Evas.h>
19 #include <Ethumb.h>
20 #include <assert.h>
21
22
23 #include <drm_client.h>
24 #include <drm_client_types.h>
25
26 #include "mf-main.h"
27 #include "mf-fs-util.h"
28 #include "mf-drm.h"
29
30 int mf_drm_is_converted_fl(char *path)
31 {
32         drm_bool_type_e is_allowed = 0;
33         drm_action_type_e action = DRM_IS_FORWARDING_ALLOWED;
34         drm_action_allowed_data_s action_data;
35
36         int ret = -1;
37         memset(&action_data,0x0,sizeof(drm_action_allowed_data_s));
38
39         SAFE_STRCPY(action_data.file_path, path);
40
41         ret = drm_is_action_allowed(action,&action_data,&is_allowed);
42         if(DRM_RETURN_SUCCESS == ret && DRM_TRUE == is_allowed){
43                 return true;
44         }else{
45                 return false;
46         }
47 }
48
49 int mf_drm_is_drm_file(const char *file_fullpath)
50 {
51         if (file_fullpath == NULL)
52                 return MYFILE_ERR_DRM_PERMISSION_DENY;
53         drm_bool_type_e drmFlag = DRM_FALSE;
54         int res = 0;
55         res = drm_is_drm_file(file_fullpath, &drmFlag);
56
57         if (res == DRM_RETURN_SUCCESS && drmFlag == DRM_TRUE)
58                 return 0;
59         else
60                 return MYFILE_ERR_DRM_PERMISSION_DENY;
61 }
62
63 drm_file_mime_type_e mf_drm_check_drm_mime_type(char *mime_type)
64 {
65         gchar **result = NULL;
66         if (mime_type != NULL) {
67                 result = g_strsplit(mime_type, "/", 0);
68                 if (result && *result) {
69                         if (g_strcmp0(*result, "audio") == 0) {
70                                 g_strfreev(result);
71                                 return MYFILE_DRM_RINGTONE_FILE;
72                         } else if (g_strcmp0(*result, "image") == 0) {
73                                 g_strfreev(result);
74                                 return MYFILE_DRM_IMAGE_FILE;
75                         } else {
76                                 g_strfreev(result);
77                                 return MYFILE_DRM_UNKNOW_FILE;
78                         }
79                 } else {
80                         g_strfreev(result);
81                         return MYFILE_DRM_UNKNOW_FILE;
82                 }
83         } else {
84                 return MYFILE_DRM_UNKNOW_FILE;
85         }
86 }
87