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_OtherContentInfoImpl.cpp
18 * @brief This is the implementation file for the %_OtherContentInfoImpl class.
20 * This file contains implementation of the %_OtherContentInfoImpl class.
23 #include <FBaseSysLog.h>
24 #include <FIoDirectory.h>
26 #include <FSysEnvironment.h>
27 #include <FApp_AppInfo.h>
28 #include <FIo_FileImpl.h>
29 #include "FCnt_OtherContentInfoImpl.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Io;
34 using namespace Tizen::System;
36 namespace Tizen { namespace Content
39 _OtherContentInfoImpl::_OtherContentInfoImpl(void)
44 _OtherContentInfoImpl::~_OtherContentInfoImpl(void)
49 _OtherContentInfoImpl*
50 _OtherContentInfoImpl::GetInstance(OtherContentInfo& otherContentInfo)
52 return otherContentInfo.__pOtherContentInfoImpl;
55 const _OtherContentInfoImpl*
56 _OtherContentInfoImpl::GetInstance(const OtherContentInfo& otherContentInfo)
58 return otherContentInfo.__pOtherContentInfoImpl;
62 _OtherContentInfoImpl::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
65 String tempPath(contentPath);
67 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
69 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
71 // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
72 // it should be converted in 2.0.
73 r = tempPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
74 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
76 else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
78 r = tempPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
79 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
83 SysLogException(NID_CNT, E_INVALID_ARG,
84 "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
90 SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
91 "The contentPath should start with /Media or /Storagecard/Media.");
92 SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
93 "The file corresponding to contentPath could not be found.");
95 if (thumbnailPath.GetLength() > 0)
97 SysLog(NID_CNT, "The thumbnailPath is not supported.");
102 SysLog(NID_CNT, "The setGps is not supported.");
105 SetContentPath(tempPath);
106 SetContentType(CONTENT_TYPE_OTHER);
112 _OtherContentInfoImpl::Construct(const String* pContentPath)
114 result r = E_SUCCESS;
116 if (pContentPath != null)
118 String contentPath(*pContentPath);
120 if (!_AppInfo::IsOspCompat())
122 if (!(contentPath.StartsWith(Environment::GetMediaPath(), 0)
123 || contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
125 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] The path is not supported.");
126 return E_INVALID_ARG;
132 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
134 // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
135 // it should be converted in 2.0.
136 r = contentPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
137 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
139 else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
141 r = contentPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
142 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
146 SysLogException(NID_CNT, E_INVALID_ARG,
147 "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
148 return E_INVALID_ARG;
152 int length = contentPath.GetLength();
153 SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
154 "The length of pContentPath is 0.");
155 SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND,
156 "The file corresponding to pContentPath could not be found.");
158 SetContentPath(contentPath);
159 SetContentType(CONTENT_TYPE_OTHER);
163 SetContentType(CONTENT_TYPE_OTHER);