2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FCnt_AudioContentInfoImpl.cpp
19 * @brief This is the implementation file for the %_AudioContentInfoImpl class.
21 * This file contains implementation of the %_AudioContentInfoImpl class.
24 #include <FBaseSysLog.h>
26 #include <FIoDirectory.h>
27 #include <FSysEnvironment.h>
28 #include <FIo_FileImpl.h>
29 #include <FApp_AppInfo.h>
30 #include "FCnt_AudioContentInfoImpl.h"
33 using namespace Tizen::App;
34 using namespace Tizen::Base;
35 using namespace Tizen::Io;
36 using namespace Tizen::Locations;
37 using namespace Tizen::System;
39 namespace Tizen { namespace Content
42 _AudioContentInfoImpl::_AudioContentInfoImpl(void)
57 _AudioContentInfoImpl::~_AudioContentInfoImpl(void)
62 _AudioContentInfoImpl*
63 _AudioContentInfoImpl::GetInstance(AudioContentInfo& audioContentInfo)
65 return audioContentInfo.__pAudioContentInfoImpl;
68 const _AudioContentInfoImpl*
69 _AudioContentInfoImpl::GetInstance(const AudioContentInfo& audioContentInfo)
71 return audioContentInfo.__pAudioContentInfoImpl;
75 _AudioContentInfoImpl::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
78 String tempPath(contentPath);
80 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
82 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
84 // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
85 // it should be converted in 2.0.
86 r = tempPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
87 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
89 else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
91 r = tempPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
92 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
96 SysLogException(NID_CNT, E_INVALID_ARG,
97 "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
103 SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
104 "The contentPath should start with /Media or /Storagecard/Media.");
105 SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
106 "The file corresponding to contentPath could not be found.");
108 if (!thumbnailPath.IsEmpty())
111 "The thumbnailPath is not supported but you can get the thumbnail managed by Tizen from ContentInfo::GetThumbnailN().");
116 SysLog(NID_CNT, "The setGps is not supported.");
119 SetContentPath(tempPath);
120 SetContentType(CONTENT_TYPE_AUDIO);
126 _AudioContentInfoImpl::Construct(const String* pContentPath)
128 result r = E_SUCCESS;
130 if (pContentPath != null)
132 String contentPath(*pContentPath);
134 if (!_AppInfo::IsOspCompat())
136 if (!(contentPath.StartsWith(Environment::GetMediaPath(), 0)
137 || contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
139 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] The path is not supported.");
140 return E_INVALID_ARG;
146 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
148 // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
149 // it should be converted in 2.0.
150 r = contentPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
151 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
153 else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
155 r = contentPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
156 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
160 SysLogException(NID_CNT, E_INVALID_ARG,
161 "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
162 return E_INVALID_ARG;
166 int length = contentPath.GetLength();
167 SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
168 "The length of pContentPath is 0.");
169 SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND,
170 "The file corresponding to pContentPath could not be found.");
172 SetContentPath(contentPath);
173 SetContentType(CONTENT_TYPE_AUDIO);
177 SetContentType(CONTENT_TYPE_AUDIO);
184 _AudioContentInfoImpl::GetGenre(void) const
186 if (__genre.IsEmpty())
188 SysLog(NID_CNT, "Genre is empty.");
189 return String(L"Unknown");
196 _AudioContentInfoImpl::GetArtist(void) const
198 if (__artist.IsEmpty())
200 SysLog(NID_CNT, "Artist is empty.");
201 return String(L"Unknown");
208 _AudioContentInfoImpl::GetComposer(void) const
210 if (__composer.IsEmpty())
212 SysLog(NID_CNT, "Composer is empty.");
213 return String(L"Unknown");
220 _AudioContentInfoImpl::GetAlbumName(void) const
222 if (__albumName.IsEmpty())
224 SysLog(NID_CNT, "AlbumName is empty.");
225 return String(L"Unknown");
232 _AudioContentInfoImpl::GetReleaseYear(void) const
234 return __releaseYear;
238 _AudioContentInfoImpl::GetBitrate(void) const
244 _AudioContentInfoImpl::GetTitle(void) const
246 if (__title.IsEmpty())
248 SysLog(NID_CNT, "Title is empty.");
249 return String(L"Unknown");
256 _AudioContentInfoImpl::GetCopyright(void) const
258 if (__copyright.IsEmpty())
260 SysLog(NID_CNT, "Copyright is empty.");
261 return String(L"Unknown");
268 _AudioContentInfoImpl::GetTrackInfo(void) const
270 if (__trackInfo.IsEmpty())
272 SysLog(NID_CNT, "TrackInfo is empty.");
273 return String(L"Unknown");
280 _AudioContentInfoImpl::GetDuration(void) const
286 _AudioContentInfoImpl::SetGenre(const Tizen::Base::String& genre)
292 _AudioContentInfoImpl::SetArtist(const Tizen::Base::String& artist)
298 _AudioContentInfoImpl::SetComposer(const Tizen::Base::String& composer)
300 __composer = composer;
304 _AudioContentInfoImpl::SetAlbumName(const Tizen::Base::String& albumName)
306 __albumName = albumName;
310 _AudioContentInfoImpl::SetReleaseYear(int releaseYear)
312 __releaseYear = releaseYear;
316 _AudioContentInfoImpl::SetBitrate(int bitrate)
322 _AudioContentInfoImpl::SetTitle(const Tizen::Base::String& title)
328 _AudioContentInfoImpl::SetCopyright(const Tizen::Base::String& copyright)
330 __copyright = copyright;
334 _AudioContentInfoImpl::SetTrackInfo(const Tizen::Base::String& trackInfo)
336 __trackInfo = trackInfo;
340 _AudioContentInfoImpl::SetDuration(long duration)
342 __duration = duration;