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 FCntContentSearch.cpp
19 * @brief This is the implementation file for the %ContentSearch class.
21 * This is the implementation file for %ContentSearch class.
25 #include <FBaseSysLog.h>
26 #include <FCntContentSearch.h>
27 #include <FBaseColIList.h>
28 #include <FCnt_ContentSearchImpl.h>
29 #include <FSec_AccessController.h>
31 using namespace Tizen::Io;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Security;
36 namespace Tizen { namespace Content
39 static const int MAX_QUERY_PATH = 512;
41 ContentSearch::ContentSearch(void)
47 ContentSearch::~ContentSearch(void)
57 ContentSearch::Construct(ContentType type)
61 SysAssertf(__pImpl == null,
62 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
64 SysTryReturn(NID_CNT, type != CONTENT_TYPE_UNKNOWN, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Construct failed.");
66 _ContentSearchImpl* pContentSearchImpl = new (std::nothrow) _ContentSearchImpl();
67 SysTryReturn(NID_CNT, pContentSearchImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
69 r = pContentSearchImpl->Construct(type);
70 SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
72 __pImpl = pContentSearchImpl;
77 delete pContentSearchImpl;
78 pContentSearchImpl = null;
84 ContentSearch::SearchN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, const String& whereExpr,
85 const String& sortColumn, SortOrder sortOrder) const
92 // Checks the privilege
93 result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
94 SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_PRIVILEGE_DENIED,
95 "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
97 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
99 SysTryReturn(NID_CNT, pageNo > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] pageNo <=0 : SearchN failed.");
100 SysTryReturn(NID_CNT, countPerPage > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] countPerPage <=0: SearchN failed.");
101 SysTryReturn(NID_CNT, whereExpr.GetLength() <= MAX_QUERY_PATH, null, E_INVALID_ARG, "[E_INVALID_ARG] Exceeds query max size : SearchN failed.");
104 return __pImpl->SearchN(pageNo, countPerPage, totalPageCount, totalCount, whereExpr, sortColumn, sortOrder);
109 ContentSearch::GetValueListN(const String& column, SortOrder sortOrder)
113 // Checks the privilege
114 result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
115 SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_PRIVILEGE_DENIED,
116 "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
118 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
120 SysTryReturn(NID_CNT, !column.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The column name is invalid.");
122 return __pImpl->GetValueListN(column, sortOrder);
126 ContentSearch::GetValueListN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount,
127 const String& column, SortOrder sortOrder) const
134 // Checks the privilege
135 result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
136 SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_PRIVILEGE_DENIED,
137 "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
139 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
141 SysTryReturn(NID_CNT, !column.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The column name is invalid: GetValueListN failed.");
142 SysTryReturn(NID_CNT, pageNo > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] pageNo <=0: GetValueListN failed.");
143 SysTryReturn(NID_CNT, countPerPage > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] countPerPage <=0: GetValueListN failed.");
145 return __pImpl->GetValueListN(pageNo, countPerPage, totalPageCount, totalCount, column, sortOrder);