Release version 0.4.17
[platform/core/appfw/data-control.git] / include / data_control_bulk.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef __TIZEN_APPFW_DATA_CONTROL_BULK_H__
18 #define __TIZEN_APPFW_DATA_CONTROL_BULK_H__
19
20 #include <data_control_types.h>
21 #include <bundle.h>
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 /**
28  * @file data_control_bulk.h
29  * @brief This is the header file for bulk data feature of the Data Control module. \n
30  *        All callbacks are called in the main loop context, unless stated otherwise.
31  */
32
33
34 /**
35  * @addtogroup CAPI_DATA_CONTROL_CONSUMER_MODULE
36  * @{
37  */
38
39
40 /**
41  * @brief Called when a response is received for a bulk operation from a provider application.
42  * @since_tizen 3.0
43  *
44  * @param[in] request_id The request ID
45  * @param[in] provider The provider handle. @a provider is valid only inside this function. \n
46  *                     @a provider should not be destroyed.
47  * @param[in] bulk_results The result data for each insert request. @a bulk_results is valid only inside this function. \n
48  *                         @a bulk_results should not be freed.
49  * @param[in] provider_result Set to @c true if the data control provider successfully processed, \n
50  *                            otherwise set to @c false
51  * @param[in] error The error message from the data control provider. @a error is valid only inside this function. \n
52  *                  @a error should not be freed.
53  * @param[in] user_data The user data passed from the register function
54  * @see data_control_sql_register_insert_bulk_data_response_cb()
55  * @see data_control_map_register_add_bulk_data_response_cb()
56  */
57 typedef void (*data_control_bulk_cb)(int request_id, data_control_h provider, data_control_bulk_result_data_h bulk_results, bool provider_result, const char *error, void *user_data);
58
59
60 /**
61  * @brief Gets the n-th bundle from bulk data.
62  * @since_tizen 3.0
63  * @remarks The @a data should not be released. \n
64  *          It will be released when data_control_bulk_data_destroy() is called.
65  * @param[in] bulk_data The bulk data handle
66  * @param[in] idx The bundle index. Index starts at 0
67  * @param[out] data The n-th bundle.
68  * @return @c 0 on success,
69  *         otherwise a negative error value
70  * @retval #DATA_CONTROL_ERROR_NONE Successful
71  * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
72  * @see data_control_bulk_data_add()
73  * @see data_control_bulk_data_destroy()
74  */
75 int data_control_bulk_data_get_data(data_control_bulk_data_h bulk_data, int idx, bundle **data);
76
77
78 /**
79  * @brief Gets the bulk data bundle count.
80  * @since_tizen 3.0
81  * @param[in] bulk_data The bulk data handle
82  * @param[out] count The bundle count
83  * @return @c 0 on success,
84  *         otherwise a negative error value
85  * @retval #DATA_CONTROL_ERROR_NONE Successful
86  * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
87  */
88 int data_control_bulk_data_get_count(data_control_bulk_data_h bulk_data, int *count);
89
90
91 /**
92  * @brief Adds a bundle to bulk data.
93  * @since_tizen 3.0
94  * @remarks The order in which bundles are added is preserved. Bundle indexes start from 0.
95  * @param[in] bulk_data The bulk data handle
96  * @param[in] data The bundle
97  * @return @c 0 on success,
98  *         otherwise a negative error value
99  * @retval #DATA_CONTROL_ERROR_NONE Successful
100  * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
101  * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
102  */
103 int data_control_bulk_data_add(data_control_bulk_data_h bulk_data, bundle *data);
104
105
106 /**
107  * @brief Creates bulk data.
108  * @since_tizen 3.0
109  * @remarks The @a bulk_data should be released using data_control_bulk_data_destroy().
110  * @param[out] bulk_data The bulk data handle
111  * @return  @c 0 on success,
112  *          otherwise a negative error value
113  * @retval #DATA_CONTROL_ERROR_NONE Successful
114  * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
115  * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
116  */
117 int data_control_bulk_data_create(data_control_bulk_data_h *bulk_data);
118
119
120 /**
121  * @brief Destroys bulk data.
122  * @since_tizen 3.0
123  * @param[in] bulk_data The bulk data handle
124  * @return @c 0 on success,
125  *         otherwise a negative error value
126  * @retval #DATA_CONTROL_ERROR_NONE Successful
127  * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
128  */
129 int data_control_bulk_data_destroy(data_control_bulk_data_h bulk_data);
130
131
132 /**
133  * @brief Gets the n-th bundle from bulk result data.
134  * @since_tizen 3.0
135  * @remarks The @a data should not be released. \n
136  *          It will be released when data_control_bulk_result_data_destroy() is called.
137  * @param[in] result_data The bulk result data handle
138  * @param[in] idx The bundle index. Index starts at 0
139  * @param[out] data The n-th bundle
140  * @param[out] result Bulk operation result. Possible values and their meaning are defined by the developer.
141  * @return @c 0 on success,
142  *         otherwise a negative error value
143  * @retval #DATA_CONTROL_ERROR_NONE Successful
144  * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
145  * @see data_control_bulk_result_data_add()
146  * @see data_control_bulk_result_data_destroy()
147  */
148 int data_control_bulk_result_data_get_result_data(data_control_bulk_result_data_h result_data, int idx, bundle **data, int *result);
149
150
151 /**
152  * @brief Gets the bulk result data bundle count.
153  * @since_tizen 3.0
154  * @param[in] result_data The bulk result data handle
155  * @param[out] count The bundle count
156  * @return  @c 0 on success,
157  *          otherwise a negative error value
158  * @retval #DATA_CONTROL_ERROR_NONE Successful
159  * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
160  */
161 int data_control_bulk_result_data_get_count(data_control_bulk_result_data_h result_data, int *count);
162
163
164 /**
165  * @brief Adds bulk data.
166  * @since_tizen 3.0
167  * @remarks The order in which bundles are added is preserved. Bundle indexes start from 0.
168  * @param[in] result_data The bulk result data handle
169  * @param[in] data The bundle
170  * @param[in] result Bulk operation result. Possible values and their meaning are defined by the developer.
171  * @return @c 0 on success,
172  *         otherwise a negative error value
173  * @retval #DATA_CONTROL_ERROR_NONE Successful
174  * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
175  * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
176  * @see data_control_bulk_result_data_get_result_data()
177  */
178 int data_control_bulk_result_data_add(data_control_bulk_result_data_h result_data, bundle *data, int result);
179
180
181 /**
182  * @brief Creates bulk result data.
183  * @since_tizen 3.0
184  * @remarks The @a result_data should be released using data_control_bulk_result_data_destroy().
185  * @param[out] result_data The bulk result data handle
186  * @return @c 0 on success,
187  *         otherwise a negative error value
188  * @retval #DATA_CONTROL_ERROR_NONE Successful
189  * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
190  * @retval #DATA_CONTROL_ERROR_OUT_OF_MEMORY Out of memory
191  */
192 int data_control_bulk_result_data_create(data_control_bulk_result_data_h *result_data);
193
194
195 /**
196  * @brief Destroys bulk result data.
197  * @since_tizen 3.0
198  * @param[in] result_data The bulk result data handle
199  * @return @c 0 on success,
200  *         otherwise a negative error value
201  * @retval #DATA_CONTROL_ERROR_NONE Successful
202  * @retval #DATA_CONTROL_ERROR_INVALID_PARAMETER Invalid parameter
203  */
204 int data_control_bulk_result_data_destroy(data_control_bulk_result_data_h result_data);
205
206
207 /**
208 * @}
209 */
210
211
212 #ifdef __cplusplus
213 }
214 #endif
215
216 #endif /* __TIZEN_APPFW_DATA_CONTROL_BULK_H__ */