Fix : Search APIs don't return exception despite the content in DB doesn't match...
[platform/framework/native/content.git] / src / FCntContentInfo.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
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  * @file                FCntContentInfo.cpp
18  * @brief               This is the implementation file for the %ContentInfo class.
19  *
20  * This file contains implementation of the %ContentInfo class.
21  */
22
23 #include <new>
24 #include <FBaseSysLog.h>
25 #include <FCntContentInfo.h>
26 #include <FGrpBitmap.h>
27 #include <FApp_AppInfo.h>
28 #include "FCnt_ContentInfoImpl.h"
29 #include "FCnt_ImageContentInfoImpl.h"
30 #include "FCnt_AudioContentInfoImpl.h"
31 #include "FCnt_VideoContentInfoImpl.h"
32 #include "FCnt_OtherContentInfoImpl.h"
33
34 using namespace std;
35 using namespace Tizen::Base;
36 using namespace Tizen::Graphics;
37 using namespace Tizen::Locations;
38
39 namespace Tizen { namespace Content
40 {
41
42 static const int _MAX_CUSTOM_FIELD_COMMON = 45;
43 static const int _MAX_CUSTOM_FIELD_DESCRIPTION = 140;
44
45 ContentInfo::ContentInfo(void)
46         : __pContentInfoImpl(null)
47 {
48
49 }
50
51 ContentInfo::~ContentInfo(void)
52 {
53
54 }
55
56 ContentId
57 ContentInfo::GetContentId(void) const
58 {
59         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
60
61         return __pContentInfoImpl->GetContentId();
62 }
63
64 ContentType
65 ContentInfo::GetContentType(void) const
66 {
67         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
68
69         return __pContentInfoImpl->GetContentType();
70 }
71
72 DateTime
73 ContentInfo::GetDateTime(void) const
74 {
75         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
76
77         return __pContentInfoImpl->GetDateTime();
78 }
79
80 String
81 ContentInfo::GetMimeType(void) const
82 {
83         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
84
85         return __pContentInfoImpl->GetMimeType();
86 }
87
88 unsigned long
89 ContentInfo::GetContentSize(void) const
90 {
91         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
92
93         return __pContentInfoImpl->GetContentSize();
94 }
95
96 String
97 ContentInfo::GetContentName(void) const
98 {
99         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
100
101         return __pContentInfoImpl->GetContentName();
102 }
103
104 String
105 ContentInfo::GetContentPath(void) const
106 {
107         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
108
109         return __pContentInfoImpl->GetContentPath();
110 }
111
112 const Coordinates&
113 ContentInfo::GetCoordinates(void) const
114 {
115         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
116
117         __coordinates = __pContentInfoImpl->GetCoordinates();
118
119         return __coordinates;
120 }
121
122 result
123 ContentInfo::SetCoordinates(const Coordinates& coordinates)
124 {
125         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
126
127         __pContentInfoImpl->SetCoordinates(coordinates);
128
129         return E_SUCCESS;
130 }
131
132 result
133 ContentInfo::SetLocationTag(const String& locationTag)
134 {
135         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
136
137         SysTryReturnResult(NID_CNT, locationTag.GetLength() <= _MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
138                         "The max input length is 45 characters.");
139
140         __pContentInfoImpl->SetLocationTag(locationTag);
141
142         return E_SUCCESS;
143 }
144
145 String
146 ContentInfo::GetLocationTag(void) const
147 {
148         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
149
150         return __pContentInfoImpl->GetLocationTag();
151 }
152
153 result
154 ContentInfo::SetRating(const String& rating)
155 {
156         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
157
158         SysTryReturnResult(NID_CNT, rating.GetLength() <= _MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
159                         "The max input length is 45 characters.");
160
161         __pContentInfoImpl->SetRating(rating);
162
163         return E_SUCCESS;
164 }
165
166 String
167 ContentInfo::GetRating(void) const
168 {
169         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
170
171         return __pContentInfoImpl->GetRating();
172 }
173
174 result
175 ContentInfo::SetCategory(const String& category)
176 {
177         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
178
179         SysTryReturnResult(NID_CNT, category.GetLength() <= _MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
180                         "The max input length is 45 characters.");
181
182         __pContentInfoImpl->SetCategory(category);
183
184         return E_SUCCESS;
185 }
186
187 String
188 ContentInfo::GetCategory(void) const
189 {
190         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
191
192         return __pContentInfoImpl->GetCategory();
193 }
194
195 result
196 ContentInfo::SetDescription(const String& description)
197 {
198         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
199
200         SysTryReturnResult(NID_CNT, description.GetLength() <= _MAX_CUSTOM_FIELD_DESCRIPTION, E_INVALID_ARG,
201                         "The max input length is 140 characters.");
202
203         __pContentInfoImpl->SetDescription(description);
204
205         return E_SUCCESS;
206 }
207
208 String
209 ContentInfo::GetDescription(void) const
210 {
211         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
212
213         return __pContentInfoImpl->GetDescription();
214 }
215
216 Bitmap*
217 ContentInfo::GetThumbnailN(void) const
218 {
219         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
220
221         ClearLastResult();
222
223         Bitmap* pBitmap = __pContentInfoImpl->GetThumbnailN();
224         result r = GetLastResult();
225         SysTryReturn(NID_CNT, !IsFailed(r), null, r, "[%s] GetThumbnailN() failed.", GetErrorMessage(r));
226
227         return pBitmap;
228 }
229
230 bool
231 ContentInfo::IsDrmProtected(void) const
232 {
233         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
234
235         return __pContentInfoImpl->IsDrmProtected();
236 }
237
238 String
239 ContentInfo::GetKeyword(void) const
240 {
241         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
242
243         return __pContentInfoImpl->GetKeyword();
244 }
245
246 result
247 ContentInfo::SetContentName(const String& contentName)
248 {
249         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
250
251         SysTryReturnResult(NID_CNT, contentName.GetLength() <= _MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
252                         "The max input length is 45 characters.");
253
254         __pContentInfoImpl->SetContentName(contentName);
255
256         return E_SUCCESS;
257 }
258
259 result
260 ContentInfo::SetKeyword(const String& keyword)
261 {
262         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
263
264         SysTryReturnResult(NID_CNT, keyword.GetLength() <= _MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
265                         "The max input length is 45 characters.");
266
267         __pContentInfoImpl->SetKeyword(keyword);
268
269         return E_SUCCESS;
270 }
271
272 result
273 ContentInfo::SetAuthor(const String& author)
274 {
275         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
276
277         SysTryReturnResult(NID_CNT, author.GetLength() <= _MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
278                         "The max input length is 45 characters.");
279
280         __pContentInfoImpl->SetAuthor(author);
281
282         return E_SUCCESS;
283 }
284
285 String
286 ContentInfo::GetAuthor(void) const
287 {
288         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
289
290         return __pContentInfoImpl->GetAuthor();
291 }
292
293 result
294 ContentInfo::SetProvider(const String& provider)
295 {
296         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
297
298         SysTryReturnResult(NID_CNT, provider.GetLength() <= _MAX_CUSTOM_FIELD_COMMON, E_INVALID_ARG,
299                         "The max input length is 45 characters.");
300
301         __pContentInfoImpl->SetProvider(provider);
302
303         return E_SUCCESS;
304 }
305
306 String
307 ContentInfo::GetProvider(void) const
308 {
309         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
310
311         return __pContentInfoImpl->GetProvider();
312 }
313
314 String
315 ContentInfo::GetMediaFormat(void) const
316 {
317         SysAssertf(__pContentInfoImpl != null, "Not yet constructed.");
318
319         return __pContentInfoImpl->GetMediaFormat();
320 }
321
322 }}