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.
17 * @file FCnt_ImageContentInfoImpl.cpp
18 * @brief This is the implementation file for the %_ImageContentInfoImpl class.
20 * This file contains implementation of the %_ImageContentInfoImpl class.
23 #include <FBaseSysLog.h>
25 #include <FIoDirectory.h>
26 #include <FSysEnvironment.h>
27 #include <FIo_FileImpl.h>
28 #include <FApp_AppInfo.h>
29 #include "FCnt_ImageContentInfoImpl.h"
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Io;
35 using namespace Tizen::Locations;
36 using namespace Tizen::System;
38 namespace Tizen { namespace Content
41 _ImageContentInfoImpl::_ImageContentInfoImpl(void)
45 , __orientationType(IMAGE_ORIENTATION_TYPE_UNKNOWN)
52 _ImageContentInfoImpl::~_ImageContentInfoImpl(void)
57 _ImageContentInfoImpl*
58 _ImageContentInfoImpl::GetInstance(ImageContentInfo& imageContentInfo)
60 return imageContentInfo.__pImageContentInfoImpl;
63 const _ImageContentInfoImpl*
64 _ImageContentInfoImpl::GetInstance(const ImageContentInfo& imageContentInfo)
66 return imageContentInfo.__pImageContentInfoImpl;
70 _ImageContentInfoImpl::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
73 int contentLength = 0;
74 FileAttributes attribute;
77 contentLength = contentPath.GetLength();
78 SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
79 "The contentPath should start with /Media or /Storagecard/Media.");
80 SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
81 "The file corresponding to contentPath could not be found.");
83 if (!thumbnailPath.IsEmpty())
86 "The thumbnailPath is not supported but you can get the thumbnail managed by Tizen from ContentInfo::GetThumbnailN().");
91 SysLog(NID_CNT, "The setGps is not supported.");
94 SetContentPath(contentPath);
95 SetContentType(CONTENT_TYPE_IMAGE);
101 _ImageContentInfoImpl::Construct(const String* pContentPath)
103 result r = E_SUCCESS;
105 if (pContentPath != null)
107 String contentPath(*pContentPath);
109 if (!_AppInfo::IsOspCompat())
111 if (!(contentPath.StartsWith(Environment::GetMediaPath(), 0)
112 || contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
114 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] The path is not supported.");
115 return E_INVALID_ARG;
121 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
123 // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
124 // it should be converted in 2.0.
125 r = contentPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
126 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
128 else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
130 r = contentPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
131 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
135 SysLogException(NID_CNT, E_INVALID_ARG,
136 "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
137 return E_INVALID_ARG;
141 int length = contentPath.GetLength();
142 SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
143 "The length of pContentPath is 0.");
144 SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
145 "The file corresponding to pContentPath could not be found.");
147 SetContentPath(contentPath);
148 SetContentType(CONTENT_TYPE_IMAGE);
152 SetContentType(CONTENT_TYPE_IMAGE);
159 _ImageContentInfoImpl::GetWidth(void) const
165 _ImageContentInfoImpl::GetHeight(void) const
171 _ImageContentInfoImpl::GetOrientation(void) const
173 return __orientationType;
177 _ImageContentInfoImpl::GetImageTakenDate(void) const
183 _ImageContentInfoImpl::GetTitle(void) const
185 if (__title.IsEmpty())
187 SysLog(NID_CNT, "Title is empty.");
195 _ImageContentInfoImpl::IsBurstShot(void) const
201 _ImageContentInfoImpl::GetBurstShotId(void) const
203 return __burstShotId;
207 _ImageContentInfoImpl::SetWidth(int width)
213 _ImageContentInfoImpl::SetHeight(int height)
219 _ImageContentInfoImpl::SetTitle(const String& title)
225 _ImageContentInfoImpl::SetOrientation(const ImageOrientationType& orientationType)
227 __orientationType = orientationType;
231 _ImageContentInfoImpl::SetImageTakenDate(const DateTime& takenDate)
233 __takenDate = takenDate;
237 _ImageContentInfoImpl::SetBurstShot(const bool isBurst)
243 _ImageContentInfoImpl::SetBurstShotId(const String& burstShotId)
245 __burstShotId = burstShotId;