[content] Fix bug on ContentDirectory
[platform/framework/native/content.git] / src / FCntContentManagerUtil.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file                FCntContentManagerUtil.cpp
19  * @brief               This is the implementation file for the %ContentManagerUtil class.
20  *
21  * This file contains implementation of the %ContentManagerUtil class.
22  */
23
24 #include <FBaseSysLog.h>
25 #include <FCntContentManagerUtil.h>
26 #include <FCntImageMetadata.h>
27 #include <FCntAudioMetadata.h>
28 #include <FCntVideoMetadata.h>
29 #include <FCnt_ContentManagerUtilImpl.h>
30
31 using namespace Tizen::Base;
32
33 namespace Tizen { namespace Content
34 {
35
36 ImageMetadata*
37 ContentManagerUtil::GetImageMetaN(const String& filePath)
38 {
39         ClearLastResult();
40
41         result r = E_SUCCESS;
42         ImageMetadata* pImageMetadata = null;
43
44         pImageMetadata = _ContentManagerUtilImpl::GetImageMetaN(filePath);
45         r = GetLastResult();
46         SysTryReturn(NID_CNT, pImageMetadata != null, null, r, "[%s] GetImageMetaN failed.", GetErrorMessage(r));
47
48         return pImageMetadata;
49 }
50
51 AudioMetadata*
52 ContentManagerUtil::GetAudioMetaN(const String& filePath)
53 {
54         ClearLastResult();
55
56         result r = E_SUCCESS;
57         AudioMetadata* pAudioMetadata = null;
58
59         pAudioMetadata = _ContentManagerUtilImpl::GetAudioMetaN(filePath);
60         r = GetLastResult();
61         SysTryReturn(NID_CNT, pAudioMetadata != null, null, r, "[%s] GetAudioMetaN failed.", GetErrorMessage(r));
62
63         return pAudioMetadata;
64 }
65
66 VideoMetadata*
67 ContentManagerUtil::GetVideoMetaN(const String& filePath)
68 {
69         ClearLastResult();
70
71         result r = E_SUCCESS;
72         VideoMetadata* pVideoMetadata = null;
73
74         pVideoMetadata = _ContentManagerUtilImpl::GetVideoMetaN(filePath);
75         r = GetLastResult();
76         SysTryReturn(NID_CNT, pVideoMetadata != null, null, r, "[%s] GetVideoMetaN failed.", GetErrorMessage(r));
77
78         return pVideoMetadata;
79 }
80
81 ImageMetadata*
82 ContentManagerUtil::GetImageMetaN(const ByteBuffer& byteBuffer)
83 {
84         ClearLastResult();
85
86         result r = E_SUCCESS;
87         ImageMetadata* pImageMetadata = null;
88
89         pImageMetadata = _ContentManagerUtilImpl::GetImageMetaN(byteBuffer);
90         r = GetLastResult();
91         SysTryReturn(NID_CNT, pImageMetadata != null, null, r, "[%s] GetImageMetaN failed.", GetErrorMessage(r));
92
93         return pImageMetadata;
94 }
95
96 AudioMetadata*
97 ContentManagerUtil::GetAudioMetaN(const ByteBuffer& byteBuffer)
98 {
99         ClearLastResult();
100
101         result r = E_SUCCESS;
102         AudioMetadata* pAudioMetadata = null;
103
104         pAudioMetadata = _ContentManagerUtilImpl::GetAudioMetaN(byteBuffer);
105         r = GetLastResult();
106         SysTryReturn(NID_CNT, pAudioMetadata != null, null, r, "[%s] GetAudioMetaN failed.", GetErrorMessage(r));
107
108         return pAudioMetadata;
109 }
110
111 VideoMetadata*
112 ContentManagerUtil::GetVideoMetaN(const ByteBuffer& byteBuffer)
113 {
114         ClearLastResult();
115
116         result r = E_SUCCESS;
117         VideoMetadata* pVideoMetadata = null;
118
119         pVideoMetadata = _ContentManagerUtilImpl::GetVideoMetaN(byteBuffer);
120         r = GetLastResult();
121         SysTryReturn(NID_CNT, pVideoMetadata != null, null, r, "[%s] GetVideoMetaN failed.", GetErrorMessage(r));
122
123         return pVideoMetadata;
124 }
125
126 ContentType
127 ContentManagerUtil::CheckContentType(const String& filePath)
128 {
129         ClearLastResult();
130
131         result r = E_SUCCESS;
132         ContentType contentType = CONTENT_TYPE_UNKNOWN;
133
134         contentType = _ContentManagerUtilImpl::CheckContentType(filePath);
135         r = GetLastResult();
136         SysTryReturn(NID_CNT, contentType != CONTENT_TYPE_UNKNOWN, CONTENT_TYPE_UNKNOWN, r,
137                            "[%s] CheckContentType failed.", GetErrorMessage(r));
138
139         return contentType;
140 }
141
142 result
143 ContentManagerUtil::CopyToMediaDirectory(const String& srcFilePath, const String& destFilePath)
144 {
145         ClearLastResult();
146
147         result r = E_SUCCESS;
148
149         r = _ContentManagerUtilImpl::CopyToMediaDirectory(srcFilePath, destFilePath);
150         SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] CopyToMediaDirectory failed.", GetErrorMessage(r));
151
152         return r;
153 }
154
155 result
156 ContentManagerUtil::MoveToMediaDirectory(const String& srcFilePath, const String& destFilePath)
157 {
158         ClearLastResult();
159
160         result r = E_SUCCESS;
161
162         r = _ContentManagerUtilImpl::MoveToMediaDirectory(srcFilePath, destFilePath);
163         SysTryReturn(NID_CNT, !IsFailed(r), r, r, "[%s] MoveToMediaDirectory failed.", GetErrorMessage(r));
164
165         return r;
166 }
167 }}