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 FSclAddressbookFilter.h
19 * @brief This is the header file for the %AddressbookFilter class.
21 * This header file contains the declarations of the %AddressbookFilter class.
23 #ifndef _FSCL_ADDRESSBOOK_FILTER_H_
24 #define _FSCL_ADDRESSBOOK_FILTER_H_
26 #include <FBaseTypes.h>
27 #include <FBaseObject.h>
28 #include <FSclTypes.h>
30 namespace Tizen { namespace Base
36 namespace Tizen { namespace Social
40 * @class AddressbookFilter
41 * @brief This class represents the condition for searching the specific item on addressbook.
45 * @final This class is not intended for extension.
47 * The %AddressbookFilter class represents the condition for searching the specific item on addressbook.
48 * The type of the filter decides which item will be searched. (such as addressbook, contacts, persons, categories) @n
49 * The filter can consist of multiple filtering expressions and conjunctive operators.
50 * A filtering expression consists of a filter property, comparison operator and value.
51 * The filter property must be an element of the enumerator that corresponds with the type of the filter. @n
54 * <th> Filter type </th>
55 * <th> Filter Property </th>
56 * <th> Search result </th>
59 * <td> AB_FI_TYPE_ADDRESSBOOK </td>
60 * <td> AddressbookFilterProperty </td>
61 * <td> A list of Addressbook </td>
64 * <td> AB_FI_TYPE_PERSON </td>
65 * <td> PersonFilterProperty </td>
66 * <td> A list of Person </td>
69 * <td> AB_FI_TYPE_CONTACT </td>
70 * <td> ContactFilterProperty </td>
71 * <td> A list of Contact </td>
74 * <td> AB_FI_TYPE_CATEGORY </td>
75 * <td> CategoryFilterProperty </td>
76 * <td> A list of Category </td>
79 * <td> AB_FI_TYPE_PHONE_CONTACT </td>
80 * <td> PhoneContactFilterProperty </td>
81 * <td> A list of PhoneNumberContact </td>
84 * <td> AB_FI_TYPE_EMAIL_CONTACT </td>
85 * <td> EmailContactFilterProperty </td>
86 * <td> A list of EmailContact </td>
90 * The following example demonstrates how to use the %AddressbookFilter class.
92 // Search condition: (addressbookId=0 OR addressbookId=1) AND (display name LIKE '%John%')
93 AddressbookFilter subFilter(AB_FI_TYPE_CONTACT);
94 subFilter.AppendInt(FI_CONJ_OP_NONE, CONTACT_FI_PR_ADDRESSBOOK_ID, FI_CMP_OP_EQUAL, 0);
95 subFilter.AppendInt(FI_CONJ_OP_OR, CONTACT_FI_PR_ADDRESSBOOK_ID, FI_CMP_OP_EQUAL, 1);
97 AddressbookFilter mainFilter(AB_FI_TYPE_CONTACT);
98 mainFilter.Append(FI_CONJ_OP_NONE, subFilter);
99 mainFilter.Append(FI_CONJ_OP_AND, CONTACT_FI_PR_DISPLAY_NAME, FI_STR_OP_CONTAIN, L"John");
101 AddressbookManager* pAddressbookManager = AddressbookManager::GetInstance();
103 IList* pEventList = pAddressbookManager->SearchN(mainFilter, CONTACT_FI_PR_DISPLAY_NAME, SORT_ORDER_ASCENDING);
107 class _OSP_EXPORT_ AddressbookFilter
108 : public Tizen::Base::Object
112 * Initializes an instance of %AddressbookFilter with the specified type.
116 * @param[in] type The type of the filter @n It decides the type of item to search.
118 AddressbookFilter(AddressbookFilterType type);
121 * This destructor overrides Tizen::Base::Object::~Object().
125 virtual ~AddressbookFilter(void);
128 * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
132 * @return @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
134 * @param[in] rhs An instance of Tizen::Base::Object to compare
136 virtual bool Equals(const Tizen::Base::Object& rhs) const;
139 * Gets the hash value of the current instance.
143 * @return The hash value of the current instance
145 virtual int GetHashCode(void) const;
148 * Appends the filtering expression for the integer value. @n
149 * Firstly, this method appends the conjunctive operator.
150 * Then, this method puts the filtering expression in parentheses and appends it. @n
151 * The filtering expression consists of the filter property, comparison operator, and value.
152 * The specified @c filterProperty must be an element of the enumerator that corresponds with the type of this filter.
156 * @return The error code
157 * @param[in] conjunctiveOperator The conjunctive operator to append the filtering expression @n
158 * If there is no filtering expression or filter has been appended before, #FI_CONJ_OP_NONE must be used. Otherwise #FI_CONJ_OP_AND or #FI_CONJ_OP_OR can be used.
159 * @param[in] filterProperty The filter property
160 * @param[in] comparisonOperator The comparison operator
161 * @param[in] value The integer value for comparison
162 * @exception E_SUCCESS The method is successful.
163 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
164 * - The @c filterProperty is not an element of the enumerator that corresponds with the type of this filter. @n
165 * - The type of the @c filterProperty is not @c int. @n
166 * - The specified @c conjuctiveOperator is invalid.
168 result AppendInt(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, int value);
171 * Appends the filtering expression for the @c bool value. @n
172 * Firstly, this method appends the conjunctive operator.
173 * Then, this method puts the filtering expression in parentheses and appends it. @n
174 * The filtering expression consists of the filter property, comparison operator, and value.
175 * The specified @c filterProperty must be an element of the enumerator that corresponds with the type of this filter.
179 * @return The error code
180 * @param[in] conjunctiveOperator The conjunctive operator to append the filtering expression @n
181 * If there is no filtering expression or filter has been appended before, #FI_CONJ_OP_NONE must be used. Otherwise #FI_CONJ_OP_AND or #FI_CONJ_OP_OR can be used.
182 * @param[in] filterProperty The filter property
183 * @param[in] comparisonOperator The comparison operator #FI_CMP_OP_EQUAL is only permitted
184 * @param[in] value The @c bool value for comparison
185 * @exception E_SUCCESS The method is successful.
186 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
187 * - The @c filterProperty is not an element of the enumerator that corresponds with the type of this filter. @n
188 * - The type of the @c filterProperty is not @c bool. @n
189 * - The @c comparisonOperator is no #FI_CMP_OP_EQUAL. @n
190 * - The specified @c conjuctiveOperator is invalid.
191 * @remarks If the filtering expression is appended firstly, the @c conjunctiveOperator is ignored.
193 result AppendBool(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterComparisonOperator comparisonOperator, bool value);
196 * Appends the filtering expression for the Tizen::Base::String value. @n
197 * Firstly, this method appends the conjunctive operator.
198 * Then, this method puts the filtering expression in parentheses and appends it. @n
199 * The filtering expression consists of the filter property, comparison operator, and value.
200 * The specified @c filterProperty must be an element of the enumerator that corresponds with the type of this filter.
204 * @return The error code
205 * @param[in] conjunctiveOperator The conjunctive operator to append the filtering expression @n
206 * If there is no filtering expression or filter has been appended before, #FI_CONJ_OP_NONE must be used. Otherwise #FI_CONJ_OP_AND or #FI_CONJ_OP_OR can be used.
207 * @param[in] filterProperty The filter property
208 * @param[in] comparisonOperator The comparison operator
209 * @param[in] value The Tizen::Base::String value for matching
210 * @exception E_SUCCESS The method is successful.
211 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
212 * - The @c filterProperty is not an element of the enumerator that corresponds with the type of this filter. @n
213 * - The type of the @c filterProperty is not Tizen::Base::String. @n
214 * - The specified @c conjuctiveOperator is invalid.
216 result AppendString(FilterConjunctiveOperator conjunctiveOperator, unsigned long filterProperty, FilterStringOperator comparisonOperator, const Tizen::Base::String& value);
219 * Appends the filter. @n
220 * Firstly, this method appends the conjunctive operator.
221 * Then, this method puts the filtering expressions of the specified filter in parentheses and appends it. @n
222 * The type of the specified @c filter must be same with the type of this filter.
226 * @return The error code
227 * @param[in] conjunctiveOperator The conjunctive operator to append the filtering expression @n
228 * If there is no filtering expression or filter has been appended before, #FI_CONJ_OP_NONE must be used. Otherwise #FI_CONJ_OP_AND or #FI_CONJ_OP_OR can be used.
229 * @param[in] filter The filter to append
230 * @exception E_SUCCESS The method is successful.
231 * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
232 * - The type of the specified @c filter is not same with the type of this filter. @n
233 * - The specified @c filter is empty. @n
234 * - The specified @c conjuctiveOperator is invalid.
236 result AppendFilter(FilterConjunctiveOperator conjunctiveOperator, const AddressbookFilter& filter);
240 * This default constructor is intentionally declared as private so that only the platform can create an instance.
244 AddressbookFilter(void);
247 * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
251 AddressbookFilter(const AddressbookFilter& rhs);
254 * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
258 AddressbookFilter & operator =(const AddressbookFilter & rhs);
261 friend class _AddressbookFilterImpl;
262 class _AddressbookFilterImpl* __pAddressbookFilterImpl;
263 }; // AddressbookFilter
267 #endif // _FSCL_ADDRESSBOOK_FILTER_H_