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.
24 #include <FBaseSysLog.h>
25 #include <FCntContentSearch.h>
26 #include <FBaseColIList.h>
27 #include <FCnt_ContentSearchImpl.h>
28 #include <FSec_AccessController.h>
30 using namespace Tizen::Io;
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Security;
35 namespace Tizen { namespace Content
38 static const int MAX_QUERY_PATH = 512;
40 ContentSearch::ContentSearch(void)
46 ContentSearch::~ContentSearch(void)
56 ContentSearch::Construct(ContentType type)
60 SysAssertf(__pImpl == null,
61 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
63 SysTryReturn(NID_CNT, type != CONTENT_TYPE_UNKNOWN, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Construct failed.");
65 _ContentSearchImpl* pContentSearchImpl = new (std::nothrow) _ContentSearchImpl();
66 SysTryReturn(NID_CNT, pContentSearchImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
68 r = pContentSearchImpl->Construct(type);
69 SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
71 __pImpl = pContentSearchImpl;
76 delete pContentSearchImpl;
77 pContentSearchImpl = null;
83 ContentSearch::SearchN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, const String& whereExpr,
84 const String& sortColumn, SortOrder sortOrder) const
91 // Checks the privilege
92 result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
93 SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_PRIVILEGE_DENIED,
94 "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
96 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
98 SysTryReturn(NID_CNT, pageNo > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] pageNo <=0 : SearchN failed.");
99 SysTryReturn(NID_CNT, countPerPage > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] countPerPage <=0: SearchN failed.");
100 SysTryReturn(NID_CNT, whereExpr.GetLength() <= MAX_QUERY_PATH, null, E_INVALID_ARG, "[E_INVALID_ARG] Exceeds query max size : SearchN failed.");
103 return __pImpl->SearchN(pageNo, countPerPage, totalPageCount, totalCount, whereExpr, sortColumn, sortOrder);
108 ContentSearch::GetValueListN(const String& column, SortOrder sortOrder)
112 // Checks the privilege
113 result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
114 SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_PRIVILEGE_DENIED,
115 "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
117 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
119 SysTryReturn(NID_CNT, !column.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The column name is invalid.");
121 return __pImpl->GetValueListN(column, sortOrder);
125 ContentSearch::GetValueListN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount,
126 const String& column, SortOrder sortOrder) const
133 // Checks the privilege
134 result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
135 SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_PRIVILEGE_DENIED,
136 "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
138 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
140 SysTryReturn(NID_CNT, !column.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The column name is invalid: GetValueListN failed.");
141 SysTryReturn(NID_CNT, pageNo > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] pageNo <=0: GetValueListN failed.");
142 SysTryReturn(NID_CNT, countPerPage > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] countPerPage <=0: GetValueListN failed.");
144 return __pImpl->GetValueListN(pageNo, countPerPage, totalPageCount, totalCount, column, sortOrder);