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 FCntContentSearch.cpp
18 * @brief This is the implementation file for the %ContentSearch class.
20 * This is the implementation file for %ContentSearch class.
23 #include <FBaseSysLog.h>
24 #include <FCntContentSearch.h>
25 #include <FBaseColIList.h>
26 #include <FCnt_ContentSearchImpl.h>
27 #include <FSec_AccessController.h>
29 using namespace Tizen::Io;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Security;
34 namespace Tizen { namespace Content
37 static const int MAX_QUERY_PATH = 512;
39 ContentSearch::ContentSearch(void)
45 ContentSearch::~ContentSearch(void)
55 ContentSearch::Construct(ContentType type)
59 SysAssertf(__pImpl == null,
60 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
62 SysTryReturn(NID_CNT, type != CONTENT_TYPE_UNKNOWN, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Construct failed.");
64 _ContentSearchImpl* pContentSearchImpl = new (std::nothrow) _ContentSearchImpl();
65 SysTryReturn(NID_CNT, pContentSearchImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Construct failed.");
67 r = pContentSearchImpl->Construct(type);
68 SysTryCatch(NID_CNT, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
70 __pImpl = pContentSearchImpl;
75 delete pContentSearchImpl;
76 pContentSearchImpl = null;
82 ContentSearch::SearchN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, const String& whereExpr,
83 const String& sortColumn, SortOrder sortOrder) const
90 // Checks the privilege
91 result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
92 SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_PRIVILEGE_DENIED,
93 "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
95 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
97 SysTryReturn(NID_CNT, pageNo > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] pageNo <=0 : SearchN failed.");
98 SysTryReturn(NID_CNT, countPerPage > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] countPerPage <=0: SearchN failed.");
99 SysTryReturn(NID_CNT, whereExpr.GetLength() <= MAX_QUERY_PATH, null, E_INVALID_ARG, "[E_INVALID_ARG] Exceeds query max size : SearchN failed.");
102 return __pImpl->SearchN(pageNo, countPerPage, totalPageCount, totalCount, whereExpr, sortColumn, sortOrder);
107 ContentSearch::GetValueListN(const String& column, SortOrder sortOrder)
111 // Checks the privilege
112 result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
113 SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_PRIVILEGE_DENIED,
114 "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
116 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
118 SysTryReturn(NID_CNT, !column.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The column name is invalid.");
120 return __pImpl->GetValueListN(column, sortOrder);
124 ContentSearch::GetValueListN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount,
125 const String& column, SortOrder sortOrder) const
132 // Checks the privilege
133 result r = _AccessController::CheckUserPrivilege(_PRV_CONTENT_READ);
134 SysTryReturn(NID_CNT, r == E_SUCCESS, null, E_PRIVILEGE_DENIED,
135 "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
137 SysAssertf(__pImpl != null, "Not yet constructed. Construct() should be called before use.");
139 SysTryReturn(NID_CNT, !column.IsEmpty(), null, E_INVALID_ARG, "[E_INVALID_ARG] The column name is invalid: GetValueListN failed.");
140 SysTryReturn(NID_CNT, pageNo > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] pageNo <=0: GetValueListN failed.");
141 SysTryReturn(NID_CNT, countPerPage > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] countPerPage <=0: GetValueListN failed.");
143 return __pImpl->GetValueListN(pageNo, countPerPage, totalPageCount, totalCount, column, sortOrder);