2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FCntOtherContentInfo.cpp
19 * @brief This is the implementation file for the %OtherContentInfo class.
21 * This file contains implementation of the %OtherContentInfo class.
24 #include <FBaseSysLog.h>
25 #include <FCntOtherContentInfo.h>
27 #include <FIoDirectory.h>
28 #include <FSysEnvironment.h>
29 #include <FIo_FileImpl.h>
30 #include <FApp_AppInfo.h>
32 using namespace Tizen::Base;
33 using namespace Tizen::Io;
34 using namespace Tizen::Locations;
35 using namespace Tizen::App;
36 using namespace Tizen::System;
38 namespace Tizen { namespace Content
41 OtherContentInfo::OtherContentInfo(void)
49 OtherContentInfo::~OtherContentInfo(void)
62 OtherContentInfo::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
66 SysAssertf(!__isCreated, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
69 _ContentData contentData;
70 int contentLength = 0;
71 FileAttributes attribute;
74 contentLength = contentPath.GetLength();
75 SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
76 "The contentPath should start with /Media or /Storagecard/Media(%ls).", contentPath.GetPointer());
77 SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
78 "The file corresponding to contentPath could not be found.");
80 if (thumbnailPath.GetLength() > 0)
82 SysLog(NID_CNT, "The thumbnailPath is not supported.");
87 SysLog(NID_CNT, "The setGps is not supported.");
90 // Sets the content path
91 contentData.contentPath = contentPath;
93 // Sets the content type
94 contentData.contentType = CONTENT_TYPE_OTHER;
96 // E_INVALID_ARG, E_OUT_OF_MEMORY
97 r = SetContentData(&contentData);
98 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
113 OtherContentInfo::Construct(const String* pContentPath)
117 result r = E_SUCCESS;
118 _ContentData contentData;
120 SysAssertf(!__isCreated,
121 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
123 if (pContentPath != null)
125 if (!_AppInfo::IsOspCompat())
127 if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0) || pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
129 SysLogException(NID_CNT, E_INVALID_ARG,
130 "[E_INVALID_ARG] /Media/ and /Storagecard/Media/ are not supported from Tizen 2.0.");
131 return E_INVALID_ARG;
133 if (!(pContentPath->StartsWith(Environment::GetMediaPath(), 0)
134 || pContentPath->StartsWith(Environment::GetExternalStoragePath(), 0)))
136 SysLogException(NID_CNT, E_INVALID_ARG,
137 "[E_INVALID_ARG] %ls is not supported.", pContentPath->GetPointer());
138 return E_INVALID_ARG;
144 if (pContentPath->StartsWith(OSP_MEDIA_PHONE, 0))
146 // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
147 // it should be converted in 2.0.
148 r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
149 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
151 else if (pContentPath->StartsWith(OSP_MEDIA_MMC, 0))
153 r = (const_cast<String*>(pContentPath))->Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
154 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
158 SysLogException(NID_CNT, E_INVALID_ARG,
159 "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
160 return E_INVALID_ARG;
164 int length = pContentPath->GetLength();
165 SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG, "The length of pContentPath is 0.");
166 SysTryReturnResult(NID_CNT, File::IsFileExist(*pContentPath), E_FILE_NOT_FOUND, "The file corresponding to pContentPath could not be found.");
168 // Sets the content path
169 contentData.contentPath = *pContentPath;
171 // Sets the content type
172 contentData.contentType = CONTENT_TYPE_OTHER;
174 r = SetContentData(&contentData);
175 SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");
179 contentData.contentType = CONTENT_TYPE_OTHER;
181 r = SetContentData(&contentData);
182 SysTryReturnResult(NID_CNT, !IsFailed(r), r, "Construct() failed.");