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.h
19 * @brief This is the header file for the %ContentSearch class.
21 * This header file contains the declarations of the %ContentSearch class.
24 #ifndef _FCNT_CONTENT_SEARCH_H_
25 #define _FCNT_CONTENT_SEARCH_H_
27 #include <FBaseString.h>
28 #include <FCntTypes.h>
30 namespace Tizen { namespace Base { namespace Collection
35 namespace Tizen { namespace Content
38 class _ContentSearchImpl;
41 * @class ContentSearch
42 * @brief This class provides methods for the content search.
46 * The %ContentSearch class provides methods to search content based on conditions and to retrieve the results for a specific
47 * column. It enables searching for content stored on the Tizen device. The local content is stored in the form of database columns.
49 * For more information on the database columns and their corresponding content types, see <a href="../org.tizen.native.appprogramming/html/guide/content/content_search_device.htm">Content Search on the Device</a>.
51 * The following example demonstrates how to use the %ContentSearch class.
54 * #include <FContent.h>
56 * using namespace Tizen::Base;
57 * using namespace Tizen::Base::Collection;
58 * using namespace Tizen::Content;
63 * // Call Construct() of ContentSearch
64 * ContentSearch search;
65 * result r = search.Construct(CONTENT_TYPE_AUDIO);
68 * // Do something for an error
71 * // Call SearchN() of ContentSearch as the first page
73 * int countPerPage = 5;
76 * IList* pContentInfoList = search.SearchN(pageNo, countPerPage, totalPage, totalCount,
77 * L"Artist='rain'", L"Title", SORT_ORDER_ASCENDING);
78 * if (IsFailed(GetLastResult()))
80 * // Do something for an error
84 * pContentInfoList->RemoveAll(true);
85 * delete pContentInfoList;
91 class _OSP_EXPORT_ ContentSearch
92 : virtual public Tizen::Base::Object
97 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
101 * @remarks After creating an instance of this class, one of the Construct() methods must be called explicitly to initialize this instance.
107 * This destructor overrides Tizen::Base::Object::~Object().
111 virtual ~ContentSearch(void);
114 * Initializes this instance of %ContentSearch with the specified parameter.
118 * @return An error code
119 * @param[in] type The content type
120 * @exception E_SUCCESS The method is successful.
121 * @exception E_INVALID_ARG The specified input parameter is invalid.
122 * @exception E_OUT_OF_MEMORY The memory is insufficient.
123 * @exception E_SYSTEM A system error has occurred.
125 * @remarks To search a specific type, use the content type as CONTENT_TYPE_OTHER, CONTENT_TYPE_IMAGE, CONTENT_TYPE_AUDIO, or CONTENT_TYPE_VIDEO.
127 * The following example demonstrates how to use the %Construct() method.
131 * // Call Construct() of ContentSearch
132 * ContentSearch search;
133 * result r = search.Construct(CONTENT_TYPE_IMAGE);
136 * // Do something for an error
141 result Construct(ContentType type);
144 * Searches the content and returns the search result list according to the query.
148 * @privilege %http://tizen.org/privilege/content.read
150 * @return A pointer to a list containing the ContentSearchResult instances @n
151 * An empty list is returned if there is no result and there is no error, @n
152 * else @c null if an exception occurs.
153 * @param[in] pageNo The page number @n
154 * It must be equal to or greater than @c 1.
155 * @param[in] countPerPage The count of the search results per page @n
156 * It must be equal to or greater than @c 1.
157 * @param[out] totalPageCount The total page count of the search result
158 * @param[out] totalCount The total count of the search result
159 * @param[in] whereExpr The search condition like an sql "where" expression style @n
160 * If it uses the default value, L"", it searches for all the content of the content type set in the constructor. @n
161 * In case of the "DateTime" condition, the range starts from '01/01/1970 00:00:00'. @n
162 * Every type of value has to be covered with single quotation marks, even if it is a decimal type.
163 * @param[in] sortColumn The sort <a href="../org.tizen.native.appprogramming/html/guide/content/content_search_device.htm">column</a> @n
164 * The default value is @c L"".
165 * @param[in] sortOrder The sort order
166 * @exception E_SUCCESS The method is successful.
167 * @exception E_OUT_OF_MEMORY The memory is insufficient.
168 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
169 * - The specified @c column is either invalid or empty. @n
170 * - The content is searched with @c type set as CONTENT_TYPE_UNKNOWN. @n
171 * - The length of the specified @c whereExpr parameter exceeds 512 characters.
172 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
173 * @exception E_SYSTEM A system error has occurred.
175 * - The specific error code can be accessed using the GetLastResult() method.
176 * - The return value must be deleted.
177 * - ContentType supports CONTENT_TYPE_OTHER, CONTENT_TYPE_IMAGE, CONTENT_TYPE_AUDIO, and CONTENT_TYPE_VIDEO.
178 * If %ContentType in Construct() uses CONTENT_TYPE_UNKNOWN or an invalid value, E_INVALID_ARG occurs.
180 * The following example demonstrates how to use the %SearchN() method.
184 * // Call Construct() of ContentSearch
185 * ContentSearch search;
186 * result r = search.Construct(CONTENT_TYPE_AUDIO);
189 * // Do something for an error
192 * // Call SearchN() of ContentSearch as the first page
194 * int countPerPage = 5;
196 * int totalCount = 0;
197 * IList* pContentInfoList = search.SearchN(pageNo, countPerPage, totalPage, totalCount,
198 * L"Artist='rain'", L"Title", SORT_ORDER_ASCENDING);
199 * if (IsFailed(GetLastResult()))
201 * // Do something for an error
207 * pContentInfoList->RemoveAll(true);
208 * delete pContentInfoList;
212 Tizen::Base::Collection::IList* SearchN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, const Tizen::Base::String& whereExpr = L"", const Tizen::Base::String& sortColumn = L"", Tizen::Base::SortOrder sortOrder = Tizen::Base::SORT_ORDER_NONE) const;
215 * Gets the value list of the specified column within a specified range.
219 * @privilege %http://tizen.org/privilege/content.read
221 * @return A pointer to a list containing the values of a column @n
222 * The type of value can be Tizen::Base::Float, Tizen::Base::Double, Tizen::Base::LongLong, Tizen::Base::DateTime, or Tizen::Base::String. @n
223 * An empty list is returned if the specified column has no value and there is no error, @n
224 * else @c null if an exception occurs.
225 * @param[in] pageNo The page number @n
226 * It must be equal to or greater than @c 1.
227 * @param[in] countPerPage The count of the value list per page @n
228 * It must be equal to or greater than @c 1.
229 * @param[out] totalPageCount The total page count of the value list
230 * @param[out] totalCount The total count of the value list
231 * @param[in] column The <a href="../org.tizen.native.appprogramming/html/guide/content/content_search_device.htm">column</a> name
232 * @param[in] sortOrder The sort order
233 * @exception E_SUCCESS The method is successful.
234 * @exception E_OUT_OF_MEMORY The memory is insufficient.
235 * @exception E_INVALID_ARG The specified @c column is either invalid or empty, or
236 * the content is searched with @c type set as CONTENT_TYPE_UNKNOWN.
237 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
238 * @exception E_SYSTEM A system error has occurred.
240 * - The specific error code can be accessed using the GetLastResult() method.
241 * - The return value must be deleted. @n
242 * The result of GetValueListN() returns a distinct value.
243 * - ContentType supports CONTENT_TYPE_OTHER, CONTENT_TYPE_IMAGE, CONTENT_TYPE_AUDIO, and CONTENT_TYPE_VIDEO.
244 * If %ContentType in Construct() uses CONTENT_TYPE_UNKNOWN or an invalid value, E_INVALID_ARG occurs.
246 * The following example demonstrates how to use the %GetValueListN() method.
250 * // Call Construct() of ContentSearch
251 * ContentSearch search;
252 * result r = search.Construct(CONTENT_TYPE_AUDIO);
255 * // Do something for an error
258 * // Call GetValueListN() of ContentSearch
260 * int countPerPage = 10;
262 * int totalCount = 0;
263 * IList* pValueList = search.GetValueListN(pageNo, countPerPage, totalPage, totalCount, L"Genre", SORT_ORDER_NONE);
265 * if (IsFailed(GetLastResult()))
267 * // Do something for an error
273 * pValueList->RemoveAll(true);
278 Tizen::Base::Collection::IList* GetValueListN(int pageNo, int countPerPage, int& totalPageCount, int& totalCount, const Tizen::Base::String& column, Tizen::Base::SortOrder sortOrder = Tizen::Base::SORT_ORDER_NONE) const;
282 * Gets the list consisting of values of a specified column in the specified order.
284 * @brief <i> [Deprecated] </i>
285 * @deprecated This method is deprecated. Instead of using this method, it is recommended to use the GetValueListN(int, int, int&, int&, const Tizen::Base::String&, @n
286 * Tizen::Base::SortOrder) method, that gets the value list of the specified column.
289 * @privilege %http://tizen.org/privilege/content.read
291 * @return A pointer to a list containing the values of a column @n
292 * The type of value can be Tizen::Base::Integer, Tizen::Base::Double, Tizen::Base::LongLong, Tizen::Base::DateTime, or Tizen::Base::String. @n
293 * An empty list is returned if the specified column has no value and there is no error, @n
294 * else @c null if an exception occurs.
295 * @param[in] column The <a href="../org.tizen.native.appprogramming/html/guide/content/content_search_device.htm">column</a> name
296 * @param[in] sortOrder The sort order
297 * @exception E_SUCCESS The method is successful.
298 * @exception E_OUT_OF_MEMORY The memory is insufficient.
299 * @exception E_INVALID_ARG The specified @c column is either invalid or empty, or the content is searched with @c type set as CONTENT_TYPE_UNKNOWN.
300 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
301 * @exception E_SYSTEM A system error has occurred.
303 * - The specific error code can be accessed using the GetLastResult() method.
304 * - The return value must be deleted. @n
305 * The result of GetValueListN() returns a distinct value.
306 * - ContentType supports CONTENT_TYPE_OTHER, CONTENT_TYPE_IMAGE, CONTENT_TYPE_AUDIO, and CONTENT_TYPE_VIDEO.
307 * If %ContentType in Construct() uses CONTENT_TYPE_UNKNOWN or an invalid value, E_INVALID_ARG occurs.
309 * The following example demonstrates how to use the %GetValueListN() method.
313 * // Call Construct() of ContentSearch
314 * ContentSearch search;
315 * result r = search.Construct(CONTENT_TYPE_AUDIO);
318 * // Do something for an error
321 * // Call GetValueListN() of ContentSearch
322 * IList* pValueList = search.GetValueListN(L"Artist", SORT_ORDER_NONE);
324 * if (IsFailed(GetLastResult()))
326 * // Do something for an error
332 * pValueList->RemoveAll(true);
338 Tizen::Base::Collection::IList* GetValueListN(const Tizen::Base::String& column, Tizen::Base::SortOrder sortOrder = Tizen::Base::SORT_ORDER_NONE);
341 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
343 ContentSearch(const ContentSearch& rhs);
346 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
348 ContentSearch& operator =(const ContentSearch& rhs);
350 _ContentSearchImpl* __pImpl;
352 friend class _ContentSearchImpl;
353 }; // class ContentSearch
357 #endif // _FCNT_CONTENT_SEARCH_H_