6d641c7943021924498b750d2e3a7ce35d86d406
[platform/core/pim/calendar-service.git] / include / calendar_query.h
1 /*
2  * Calendar Service
3  *
4  * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __TIZEN_SOCIAL_CALENDAR_QUERY_H__
21 #define __TIZEN_SOCIAL_CALENDAR_QUERY_H__
22
23 #include <calendar_types.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /**
30  * @file calendar_query.h
31  */
32
33 /**
34  * @addtogroup CAPI_SOCIAL_CALENDAR_SVC_QUERY_MODULE
35  * @{
36  */
37
38 /**
39  * @brief Creates a query handle.
40  *
41  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
42  *
43  * @remarks You must release @a query using calendar_query_destroy().
44  *
45  * @param[in]   view_uri   The view URI of a query
46  * @param[out]  query      The filter handle
47  *
48  * @return  @c 0 on success,
49  *          otherwise a negative error value
50  * @retval  #CALENDAR_ERROR_NONE                Successful
51  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
52  * @retval  #CALENDAR_ERROR_OUT_OF_MEMORY       Out of memory
53  *
54  * @pre     calendar_connect() should be called to initialize.
55  *
56  * @see calendar_query_destroy()
57  */
58 int calendar_query_create(const char* view_uri, calendar_query_h* query);
59
60 /**
61  * @brief Destroys a query handle.
62  *
63  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
64  *
65  * @param[in] query   The query handle
66  *
67  * @return  @c 0 on success,
68  *          otherwise a negative error value
69  * @retval  #CALENDAR_ERROR_NONE               Successful
70  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER  Invalid parameter
71  *
72  * @see calendar_query_create()
73  */
74 int calendar_query_destroy(calendar_query_h query);
75
76 /**
77  * @brief Adds property IDs for projection.
78  *
79  * @details Property IDs can be of one of the properties of view_uri which is used in calendar_query_create().
80  *
81  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
82  *
83  * @param[in]   query               The query handle
84  * @param[in]   property_id_array   The property ID array
85  * @param[in]   count               The number of property IDs
86  *
87  * @return  @c 0 on success,
88  *          otherwise a negative error value
89  * @retval  #CALENDAR_ERROR_NONE                Successful
90  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
91  */
92 int calendar_query_set_projection(calendar_query_h query, unsigned int property_id_array[], int count);
93
94 /**
95  * @brief Sets the "distinct" option for projection.
96  *
97  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
98  *
99  * @param[in]   query   The query handle
100  * @param[in]   set     If @c true it is set,
101  *                      otherwise if @c false it is unset
102  *
103  * @return  @c 0 on success,
104  *          otherwise a negative error value
105  * @retval  #CALENDAR_ERROR_NONE                Successful
106  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
107  */
108 int calendar_query_set_distinct(calendar_query_h query, bool set);
109
110 /**
111  * @brief Sets the filter for a query.
112  *
113  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
114  *
115  * @param[in]  query    The query handle
116  * @param[in]  filter   The filter handle
117  *
118  * @return  @c 0 on success,
119  *          otherwise a negative error value
120  * @retval  #CALENDAR_ERROR_NONE                Successful
121  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
122  * @retval  #CALENDAR_ERROR_NO_DATA             Requested data does not exist
123  *
124  * @see calendar_query_add_operator()
125  */
126 int calendar_query_set_filter(calendar_query_h query, calendar_filter_h filter);
127
128 /**
129  * @brief Sets the sort mode for a query.
130  *
131  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif
132  *
133  * @param[in]   query           The query handle
134  * @param[in]   property_id     The property ID to sort
135  * @param[in]   is_ascending    If @c true it sorts in the ascending order,
136  *                              otherwise if @c false it sorts in the descending order
137  *
138  * @return  @c 0 on success,
139  *          otherwise a negative error value
140  * @retval  #CALENDAR_ERROR_NONE                Successful
141  * @retval  #CALENDAR_ERROR_INVALID_PARAMETER   Invalid parameter
142  */
143 int calendar_query_set_sort(calendar_query_h query, unsigned int property_id, bool is_ascending);
144
145
146 /**
147  * @}
148  */
149
150 #ifdef __cplusplus
151 }
152 #endif
153
154 #endif /* __TIZEN_SOCIAL_CALENDAR_QUERY_H__ */
155