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)
58 _AudioContentInfoImpl::~_AudioContentInfoImpl(void)
63 _AudioContentInfoImpl*
64 _AudioContentInfoImpl::GetInstance(AudioContentInfo& audioContentInfo)
66 return audioContentInfo.__pAudioContentInfoImpl;
69 const _AudioContentInfoImpl*
70 _AudioContentInfoImpl::GetInstance(const AudioContentInfo& audioContentInfo)
72 return audioContentInfo.__pAudioContentInfoImpl;
76 _AudioContentInfoImpl::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
79 String tempPath(contentPath);
81 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
83 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
85 // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
86 // it should be converted in 2.0.
87 r = tempPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
88 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
90 else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
92 r = tempPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
93 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
97 SysLogException(NID_CNT, E_INVALID_ARG,
98 "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
104 SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
105 "The contentPath should start with /Media or /Storagecard/Media.");
106 SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
107 "The file corresponding to contentPath could not be found.");
109 if (!thumbnailPath.IsEmpty())
112 "The thumbnailPath is not supported but you can get the thumbnail managed by Tizen from ContentInfo::GetThumbnailN().");
117 SysLog(NID_CNT, "The setGps is not supported.");
120 SetContentPath(tempPath);
121 SetContentType(CONTENT_TYPE_AUDIO);
127 _AudioContentInfoImpl::Construct(const String* pContentPath)
129 result r = E_SUCCESS;
131 if (pContentPath != null)
133 String contentPath(*pContentPath);
135 if (!_AppInfo::IsOspCompat())
137 if (!(contentPath.StartsWith(Environment::GetMediaPath(), 0)
138 || contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
140 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] The path is not supported.");
141 return E_INVALID_ARG;
147 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
149 // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
150 // it should be converted in 2.0.
151 r = contentPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
152 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
154 else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
156 r = contentPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
157 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
161 SysLogException(NID_CNT, E_INVALID_ARG,
162 "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
163 return E_INVALID_ARG;
167 int length = contentPath.GetLength();
168 SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
169 "The length of pContentPath is 0.");
170 SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND,
171 "The file corresponding to pContentPath could not be found.");
173 SetContentPath(contentPath);
174 SetContentType(CONTENT_TYPE_AUDIO);
178 SetContentType(CONTENT_TYPE_AUDIO);
185 _AudioContentInfoImpl::GetGenre(void) const
187 if (__genre.IsEmpty())
189 SysLog(NID_CNT, "Genre is empty.");
190 return String(L"Unknown");
197 _AudioContentInfoImpl::GetArtist(void) const
199 if (__artist.IsEmpty())
201 SysLog(NID_CNT, "Artist is empty.");
202 return String(L"Unknown");
209 _AudioContentInfoImpl::GetAlbumArtist(void) const
211 return __albumArtist;
215 _AudioContentInfoImpl::GetComposer(void) const
217 if (__composer.IsEmpty())
219 SysLog(NID_CNT, "Composer is empty.");
220 return String(L"Unknown");
227 _AudioContentInfoImpl::GetAlbumName(void) const
229 if (__albumName.IsEmpty())
231 SysLog(NID_CNT, "AlbumName is empty.");
232 return String(L"Unknown");
239 _AudioContentInfoImpl::GetReleaseYear(void) const
241 return __releaseYear;
245 _AudioContentInfoImpl::GetBitrate(void) const
251 _AudioContentInfoImpl::GetTitle(void) const
253 if (__title.IsEmpty())
255 SysLog(NID_CNT, "Title is empty.");
256 return String(L"Unknown");
263 _AudioContentInfoImpl::GetCopyright(void) const
265 if (__copyright.IsEmpty())
267 SysLog(NID_CNT, "Copyright is empty.");
268 return String(L"Unknown");
275 _AudioContentInfoImpl::GetTrackInfo(void) const
277 if (__trackInfo.IsEmpty())
279 SysLog(NID_CNT, "TrackInfo is empty.");
280 return String(L"Unknown");
287 _AudioContentInfoImpl::GetDuration(void) const
293 _AudioContentInfoImpl::SetGenre(const Tizen::Base::String& genre)
299 _AudioContentInfoImpl::SetArtist(const Tizen::Base::String& artist)
305 _AudioContentInfoImpl::SetAlbumArtist(const Tizen::Base::String& albumArtist)
307 __albumArtist = albumArtist;
311 _AudioContentInfoImpl::SetComposer(const Tizen::Base::String& composer)
313 __composer = composer;
317 _AudioContentInfoImpl::SetAlbumName(const Tizen::Base::String& albumName)
319 __albumName = albumName;
323 _AudioContentInfoImpl::SetReleaseYear(int releaseYear)
325 __releaseYear = releaseYear;
329 _AudioContentInfoImpl::SetBitrate(int bitrate)
335 _AudioContentInfoImpl::SetTitle(const Tizen::Base::String& title)
341 _AudioContentInfoImpl::SetCopyright(const Tizen::Base::String& copyright)
343 __copyright = copyright;
347 _AudioContentInfoImpl::SetTrackInfo(const Tizen::Base::String& trackInfo)
349 __trackInfo = trackInfo;
353 _AudioContentInfoImpl::SetDuration(long duration)
355 __duration = duration;