Fix : Search APIs don't return exception despite the content in DB doesn't match...
[platform/framework/native/content.git] / src / FCntAudioMetadata.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                FCntAudioMetadata.cpp
18  * @brief               This is the implementation file for the %AudioMetadata class.
19  *
20  * This file contains implementation of the %AudioMetadata class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FCntAudioMetadata.h>
25 #include <FCnt_AudioMetadataImpl.h>
26
27 using namespace Tizen::Base;
28 using namespace Tizen::Graphics;
29
30 namespace Tizen { namespace Content
31 {
32
33 AudioMetadata::AudioMetadata(void)
34         : Object()
35         , __pImpl(new (std::nothrow) _AudioMetadataImpl())
36 {
37
38 }
39
40 AudioMetadata::~AudioMetadata(void)
41 {
42         if (__pImpl != null)
43         {
44                 delete __pImpl;
45                 __pImpl = null;
46         }
47 }
48
49 AudioMetadata::AudioMetadata(const AudioMetadata& rhs)
50         : Tizen::Base::Object()
51         , __pImpl(new (std::nothrow) _AudioMetadataImpl(*rhs.__pImpl))
52 {
53
54 }
55
56 AudioMetadata&
57 AudioMetadata::operator =(const AudioMetadata& rhs)
58 {
59         // check for self-assignment
60         if (this == &rhs)
61         {
62                 return *this;
63         }
64
65         *__pImpl = *rhs.__pImpl;
66
67         return *this;
68 }
69
70 int
71 AudioMetadata::GetHashCode(void) const
72 {
73         return __pImpl->GetHashCode();
74 }
75
76 bool
77 AudioMetadata::Equals(const Object& rhs) const
78 {
79         const AudioMetadata* pRhs = dynamic_cast <const AudioMetadata*>(&rhs);
80         if (pRhs == null)
81         {
82                 return false;
83         }
84
85         return __pImpl->Equals(*pRhs->__pImpl);
86 }
87
88 String
89 AudioMetadata::GetTitle(void) const
90 {
91         if (__pImpl == null)
92         {
93                 return String();
94         }
95         return __pImpl->GetTitle();
96 }
97
98 int
99 AudioMetadata::GetBitrate(void) const
100 {
101         if (__pImpl == null)
102         {
103                 return 0;
104         }
105         return __pImpl->GetBitrate();
106 }
107
108 int
109 AudioMetadata::GetFrequency(void) const
110 {
111         if (__pImpl == null)
112         {
113                 return 0;
114         }
115         return __pImpl->GetFrequency();
116 }
117
118 String
119 AudioMetadata::GetArtist(void) const
120 {
121         if (__pImpl == null)
122         {
123                 return String();
124         }
125         return __pImpl->GetArtist();
126 }
127
128 String
129 AudioMetadata::GetAlbumName(void) const
130 {
131         if (__pImpl == null)
132         {
133                 return String();
134         }
135         return __pImpl->GetAlbumName();
136 }
137
138 String
139 AudioMetadata::GetComment(void) const
140 {
141         if (__pImpl == null)
142         {
143                 return String();
144         }
145         return __pImpl->GetComment();
146 }
147
148 String
149 AudioMetadata::GetDescription(void) const
150 {
151         if (__pImpl == null)
152         {
153                 return String();
154         }
155         return __pImpl->GetDescription();
156 }
157
158 int
159 AudioMetadata::GetTrack(void) const
160 {
161         if (__pImpl == null)
162         {
163                 return 0;
164         }
165         return __pImpl->GetTrack();
166 }
167
168 String
169 AudioMetadata::GetGenre(void) const
170 {
171         if (__pImpl == null)
172         {
173                 return String();
174         }
175         return __pImpl->GetGenre();
176 }
177
178 String
179 AudioMetadata::GetComposer(void) const
180 {
181         if (__pImpl == null)
182         {
183                 return String();
184         }
185         return __pImpl->GetComposer();
186 }
187
188 String
189 AudioMetadata::GetCopyright(void) const
190 {
191         if (__pImpl == null)
192         {
193                 return String();
194         }
195         return __pImpl->GetCopyright();
196 }
197
198 long
199 AudioMetadata::GetDuration(void) const
200 {
201         if (__pImpl == null)
202         {
203                 return 0;
204         }
205         return __pImpl->GetDuration();
206 }
207
208 int
209 AudioMetadata::GetYear(void) const
210 {
211         if (__pImpl == null)
212         {
213                 return 0;
214         }
215         return __pImpl->GetYear();
216 }
217
218 String
219 AudioMetadata::GetTrackInfo(void) const
220 {
221         if (__pImpl == null)
222         {
223                 return String();
224         }
225         return __pImpl->GetTrackInfo();
226 }
227
228 String
229 AudioMetadata::GetRecordingDate(void) const
230 {
231         if (__pImpl == null)
232         {
233                 return String();
234         }
235         return __pImpl->GetRecordingDate();
236 }
237
238 int
239 AudioMetadata::GetChannelCount(void) const
240 {
241         if (__pImpl == null)
242         {
243                 return 0;
244         }
245         return __pImpl->GetChannelCount();
246 }
247
248 /**
249  * E_SUCCESS
250  * E_DATA_NOT_FOUND
251  * E_OUT_OF_MEMORY
252  */
253 Bitmap*
254 AudioMetadata::GetThumbnailN(void) const
255 {
256         ClearLastResult();
257         result r = E_SUCCESS;
258
259         Bitmap* pBitmap = null;
260         SysTryReturn(NID_CNT, __pImpl != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetThumbnailN failed.");
261
262         pBitmap = __pImpl->GetThumbnailN();
263         r = GetLastResult();
264         SysTryReturn(NID_CNT, pBitmap != null, null, r, "[%s] GetThumbnailN failed.", GetErrorMessage(r));
265
266         return pBitmap;
267 }
268
269 /**
270  * E_SUCCESS
271  * E_DATA_NOT_FOUND
272  * E_OUT_OF_MEMORY
273  */
274 Bitmap*
275 AudioMetadata::GetAlbumArtN(void) const
276 {
277         ClearLastResult();
278         result r = E_SUCCESS;
279
280         Bitmap* pBitmap = null;
281
282         SysTryReturn(NID_CNT, __pImpl != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] GetAlbumArtN failed.");
283
284         pBitmap = __pImpl->GetAlbumArtN();
285         r = GetLastResult();
286         SysTryReturn(NID_CNT, pBitmap != null, null, r, "[%s] GetAlbumArtN failed.", GetErrorMessage(r));
287
288         return pBitmap;
289 }
290 }}