Fix : Search APIs don't return exception despite the content in DB doesn't match...
[platform/framework/native/content.git] / src / FCntAudioContentInfo.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 /**
18  * @file                FCntAudioContentInfo.cpp
19  * @brief               This is the implementation file for the %AudioContentInfo class.
20  *
21  * This file contains implementation of the %AudioContentInfo class.
22  */
23
24 #include <FBaseSysLog.h>
25 #include <FCntAudioContentInfo.h>
26 #include "FCnt_AudioContentInfoImpl.h"
27 #include "FCnt_ContentInfoHelper.h"
28
29 using namespace Tizen::Base;
30
31 namespace Tizen { namespace Content
32 {
33
34 AudioContentInfo::AudioContentInfo(void)
35         : __pAudioContentData(null)
36         , __pAudioContentInfoImpl(null)
37 {
38
39 }
40
41 AudioContentInfo::~AudioContentInfo(void)
42 {
43         delete __pAudioContentInfoImpl;
44 }
45
46 result
47 AudioContentInfo::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
48 {
49         result r = E_SUCCESS;
50
51         SysAssertf(__pAudioContentInfoImpl == null || __pAudioContentInfoImpl->IsReconstructable(),
52                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
53
54         _AudioContentInfoImpl* pAudioContentInfoImpl = new (std::nothrow) _AudioContentInfoImpl();
55         SysTryReturnResult(NID_CNT, pAudioContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
56
57         r = pAudioContentInfoImpl->Construct(contentPath, thumbnailPath, setGps);
58         SysTryCatch(NID_CNT, r == E_SUCCESS || r == E_FILE_NOT_FOUND, , r, "[%s] Propagating.", GetErrorMessage(r));
59
60         _ContentInfoHelper::SetContentInfoImpl(this, pAudioContentInfoImpl);
61
62         delete __pAudioContentInfoImpl;
63         __pAudioContentInfoImpl = pAudioContentInfoImpl;
64
65         if (r == E_FILE_NOT_FOUND)
66         {
67                 __pAudioContentInfoImpl->SetReconstructable(true);
68         }
69         else
70         {
71                 __pAudioContentInfoImpl->SetReconstructable(false);
72         }
73
74         return r;
75
76 CATCH:
77         delete pAudioContentInfoImpl;
78
79         return r;
80 }
81
82 result
83 AudioContentInfo::Construct(const String* pContentPath)
84 {
85         result r = E_SUCCESS;
86
87         SysAssertf(__pAudioContentInfoImpl == null || __pAudioContentInfoImpl->IsReconstructable(),
88                         "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
89
90         _AudioContentInfoImpl* pAudioContentInfoImpl = new (std::nothrow) _AudioContentInfoImpl();
91         SysTryReturnResult(NID_CNT, pAudioContentInfoImpl != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
92
93         r = pAudioContentInfoImpl->Construct(pContentPath);
94         SysTryCatch(NID_CNT, r == E_SUCCESS || r == E_FILE_NOT_FOUND, , r, "[%s] Propagating.", GetErrorMessage(r));
95
96         _ContentInfoHelper::SetContentInfoImpl(this, pAudioContentInfoImpl);
97
98         delete __pAudioContentInfoImpl;
99         __pAudioContentInfoImpl = pAudioContentInfoImpl;
100
101         if (r == E_FILE_NOT_FOUND)
102         {
103                 __pAudioContentInfoImpl->SetReconstructable(true);
104         }
105         else
106         {
107                 __pAudioContentInfoImpl->SetReconstructable(false);
108         }
109
110         return r;
111
112 CATCH:
113         delete pAudioContentInfoImpl;
114
115         return r;
116 }
117
118 String
119 AudioContentInfo::GetGenre(void) const
120 {
121         SysAssertf(__pAudioContentInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
122
123         return __pAudioContentInfoImpl->GetGenre();
124 }
125
126 String
127 AudioContentInfo::GetArtist(void) const
128 {
129         SysAssertf(__pAudioContentInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
130
131         return __pAudioContentInfoImpl->GetArtist();
132 }
133
134 String
135 AudioContentInfo::GetComposer(void) const
136 {
137         SysAssertf(__pAudioContentInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
138
139         return __pAudioContentInfoImpl->GetComposer();
140 }
141
142 String
143 AudioContentInfo::GetAlbumName(void) const
144 {
145         SysAssertf(__pAudioContentInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
146
147         return __pAudioContentInfoImpl->GetAlbumName();
148 }
149
150 int
151 AudioContentInfo::GetReleaseYear(void) const
152 {
153         SysAssertf(__pAudioContentInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
154
155         return __pAudioContentInfoImpl->GetReleaseYear();
156 }
157
158 int
159 AudioContentInfo::GetBitrate(void) const
160 {
161         SysAssertf(__pAudioContentInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
162
163         return __pAudioContentInfoImpl->GetBitrate();
164 }
165
166 String
167 AudioContentInfo::GetTitle(void) const
168 {
169         SysAssertf(__pAudioContentInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
170
171         return __pAudioContentInfoImpl->GetTitle();
172 }
173
174 String
175 AudioContentInfo::GetCopyright(void) const
176 {
177         SysAssertf(__pAudioContentInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
178
179         return __pAudioContentInfoImpl->GetCopyright();
180 }
181
182 String
183 AudioContentInfo::GetTrackInfo(void) const
184 {
185         SysAssertf(__pAudioContentInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
186
187         return __pAudioContentInfoImpl->GetTrackInfo();
188 }
189
190 long
191 AudioContentInfo::GetDuration(void) const
192 {
193         SysAssertf(__pAudioContentInfoImpl != null, "Not yet constructed. Construct() should be called before use.");
194
195         return __pAudioContentInfoImpl->GetDuration();
196 }
197
198 }}