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