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 FCntOtherContentInfo.cpp
18 * @brief This is the implementation file for the %OtherContentInfo class.
20 * This file contains implementation of the %OtherContentInfo class.
23 #include <FBaseSysLog.h>
24 #include <FCntOtherContentInfo.h>
26 #include <FIoDirectory.h>
27 #include <FSysEnvironment.h>
28 #include <FIo_FileImpl.h>
29 #include <FApp_AppInfo.h>
31 using namespace Tizen::Base;
32 using namespace Tizen::Io;
33 using namespace Tizen::Locations;
34 using namespace Tizen::App;
35 using namespace Tizen::System;
37 namespace Tizen { namespace Content
40 OtherContentInfo::OtherContentInfo(void)
48 OtherContentInfo::~OtherContentInfo(void)
61 OtherContentInfo::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
65 SysAssertf(!__isCreated, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
68 _ContentData contentData;
69 int contentLength = 0;
70 FileAttributes attribute;
73 contentLength = contentPath.GetLength();
74 SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
75 "The contentPath should start with /Media or /Storagecard/Media.");
76 SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
77 "The file corresponding to contentPath could not be found.");
79 if (thumbnailPath.GetLength() > 0)
81 SysLog(NID_CNT, "The thumbnailPath is not supported.");
86 SysLog(NID_CNT, "The setGps is not supported.");
89 // Sets the content path
90 contentData.contentPath = contentPath;
92 // Sets the content type
93 contentData.contentType = CONTENT_TYPE_OTHER;
95 // E_INVALID_ARG, E_OUT_OF_MEMORY
96 r = SetContentData(&contentData);
97 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
112 OtherContentInfo::Construct(const String* pContentPath)
116 result r = E_SUCCESS;
117 _ContentData contentData;
119 SysAssertf(!__isCreated,
120 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
122 if (pContentPath != null)
124 if (!_AppInfo::IsOspCompat())
126 if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0) || pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
128 SysLogException(NID_CNT, E_INVALID_ARG,
129 "[E_INVALID_ARG] /Media/ and /Storagecard/Media/ are not supported from Tizen 2.0.");
130 return E_INVALID_ARG;
132 if (!(pContentPath->StartsWith(Environment::GetMediaPath(), 0)
133 || pContentPath->StartsWith(Environment::GetExternalStoragePath(), 0)))
135 SysLogException(NID_CNT, E_INVALID_ARG,
136 "[E_INVALID_ARG] %ls is not supported.", pContentPath->GetPointer());
137 return E_INVALID_ARG;
143 if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0))
145 // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
146 // it should be converted in 2.0.
147 r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
148 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
150 else if (pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
152 r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
153 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
157 SysLogException(NID_CNT, E_INVALID_ARG,
158 "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
159 return E_INVALID_ARG;
163 int length = pContentPath->GetLength();
164 SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG, "The length of pContentPath is 0.");
165 SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND, "The file corresponding to pContentPath could not be found.");
167 // Sets the content path
168 contentData.contentPath = *pContentPath;
170 // Sets the content type
171 contentData.contentType = CONTENT_TYPE_OTHER;
173 r = SetContentData(&contentData);
174 SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
178 contentData.contentType = CONTENT_TYPE_OTHER;
180 r = SetContentData(&contentData);
181 SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");