Add error codes
[platform/core/uifw/capi-ui-sticker.git] / include / sticker_data.h
1 /*
2  * Copyright (c) 2019 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_UIX_STICKER_DATA_H__
18 #define __TIZEN_UIX_STICKER_DATA_H__
19
20 #include <sticker_error.h>
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 /**
27  * @file sticker_data.h
28  * @brief This file contains sticker data APIs and related enumeration.
29  */
30
31 /**
32  * @addtogroup CAPI_UIX_STICKER_DATA_MODULE
33  * @{
34  */
35
36 /**
37  * @brief Enumeration for sticker URI type.
38  *
39  * @since_tizen 5.5
40  */
41 typedef enum {
42     STICKER_DATA_URI_LOCAL_PATH = 1, /**< Local path URI */
43     STICKER_DATA_URI_WEB_RESOURCE, /**< Web resource URI */
44 } sticker_data_uri_type_e;
45
46 /**
47  * @brief Enumeration for sticker display type.
48  *
49  * @since_tizen 5.5
50  */
51 typedef enum {
52     STICKER_DATA_DISP_EMOJI = 1, /**< Emoji type */
53     STICKER_DATA_DISP_WALLPAPER, /**< Wallpaper type */
54 } sticker_data_display_type_e;
55
56 /**
57  * @brief The sticker data handle.
58  * @since_tizen 5.5
59  */
60 typedef struct sticker_data_s *sticker_data_h;
61
62 /**
63  * @brief Called to retrieve the keyword of the sticker.
64  * @details The sticker_data_foreach_keyword() must be called to invoke this callback function, synchronously.
65  * @since_tizen 5.5
66  * @remarks @a keyword should not be freed and can be used only in the callback.
67  * @param[in] keyword The sticker keyword
68  * @param[in] user_data The user data passed from the foreach function
69  * @pre sticker_data_foreach_keyword() will invoke this callback.
70  * @see sticker_data_foreach_keyword()
71  */
72 typedef void (*sticker_data_keyword_foreach_cb)(const char *keyword, void *user_data);
73
74 /**
75  * @brief Creates a sticker data handle.
76  * @since_tizen 5.5
77  * @remarks If the function succeeds, @a data_handle must be released with sticker_data_destroy().
78  * @param[out] data_handle The sticker data handle
79  * @return 0 on success, otherwise a negative error value
80  * @retval #STICKER_ERROR_NONE Successful
81  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
82  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
83  * @retval #STICKER_ERROR_OUT_OF_MEMORY Out of memory
84  * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed
85  * @see sticker_data_destroy()
86  */
87 int sticker_data_create(sticker_data_h *data_handle);
88
89 /**
90  * @brief Destroys a sticker data handle.
91  * @since_tizen 5.5
92  * @param[in] data_handle The sticker data handle
93  * @return 0 on success, otherwise a negative error value
94  * @retval #STICKER_ERROR_NONE Successful
95  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
96  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
97  * @see sticker_data_create()
98  */
99 int sticker_data_destroy(sticker_data_h data_handle);
100
101 /**
102  * @brief Clones a sticker data handle.
103  * @since_tizen 5.5
104  * @remarks If the function succeeds, @a target_handle must be released with sticker_data_destroy().
105  * @param[in] origin_handle The sticker data handle
106  * @param[out] target_handle The sticker data handle to be cloned
107  * @return 0 on success, otherwise a negative error value
108  * @retval #STICKER_ERROR_NONE Successful
109  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
110  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
111  * @retval #STICKER_ERROR_OUT_OF_MEMORY Out of memory
112  * @see sticker_data_destroy()
113  */
114 int sticker_data_clone(sticker_data_h origin_handle, sticker_data_h *target_handle);
115
116 /**
117  * @brief Gets the name of the sticker provider application from sticker data handle.
118  * @since_tizen 5.5
119  * @remarks @a app_id must be released using free().
120  * @param[in] data_handle The sticker data handle
121  * @param[out] app_id The name of the application that provides sticker information
122  * @return 0 on success, otherwise a negative error value
123  * @retval #STICKER_ERROR_NONE Successful
124  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
125  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
126  * @retval #STICKER_ERROR_NO_DATA No data available
127  */
128 int sticker_data_get_app_id(sticker_data_h data_handle, char **app_id);
129
130 /**
131  * @brief Sets the URI and URI type of the sticker.
132  * @details @a uri must be a relative path like '/res/smile.png' when the type of URI is local path.
133  * @since_tizen 5.5
134  * @remarks @a uri must have a non-null value and must be an existing file. If not, the error as invalid parameter will be returned.
135  * @param[in] data_handle The sticker data handle
136  * @param[in] type The URI type to be saved
137  * @param[in] uri The URI to be saved
138  * @return 0 on success, otherwise a negative error value
139  * @retval #STICKER_ERROR_NONE Successful
140  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
141  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
142  * @see sticker_data_get_uri()
143  */
144 int sticker_data_set_uri(sticker_data_h data_handle, sticker_data_uri_type_e type, const char *uri);
145
146 /**
147  * @brief Gets the URI and URI type from sticker data handle.
148  * @since_tizen 5.5
149  * @remarks @a uri must be released using free().
150  * @param[in] data_handle The sticker data handle
151  * @param[out] type The URI type
152  * @param[out] uri The URI
153  * @return 0 on success, otherwise a negative error value
154  * @retval #STICKER_ERROR_NONE Successful
155  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
156  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
157  * @retval #STICKER_ERROR_NO_DATA No data available
158  * @see sticker_data_set_uri()
159  */
160 int sticker_data_get_uri(sticker_data_h data_handle, sticker_data_uri_type_e *type, char **uri);
161
162 /**
163  * @brief Retrieves all keywords of the sticker using callback function.
164  * @since_tizen 5.5
165  * @param[in] data_handle The sticker data handle
166  * @param[in] callback The callback function to invoke
167  * @param[in] user_data The user data to be passed to the callback function
168  * @return 0 on success, otherwise a negative error value
169  * @retval #STICKER_ERROR_NONE Successful
170  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
171  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
172  * @retval #STICKER_ERROR_NO_DATA No data available
173  * @post This function invokes sticker_data_keyword_foreach_cb() repeatedly for getting keywords.
174  * @see sticker_data_keyword_foreach_cb()
175  * @see sticker_data_add_keyword()
176  * @see sticker_data_remove_keyword()
177  */
178 int sticker_data_foreach_keyword(sticker_data_h data_handle, sticker_data_keyword_foreach_cb callback, void *user_data);
179
180 /**
181  * @brief Adds a keyword of the sticker to the list.
182  * @since_tizen 5.5
183  * @remarks @a keyword must have a non-null value and can not have duplicate value. If not, the error as invalid parameter will be returned.
184  * @param[in] data_handle The sticker data handle
185  * @param[in] keyword The keyword to be saved
186  * @return 0 on success, otherwise a negative error value
187  * @retval #STICKER_ERROR_NONE Successful
188  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
189  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
190  * @see sticker_data_keyword_foreach_cb()
191  * @see sticker_data_foreach_keyword()
192  * @see sticker_data_remove_keyword()
193  */
194 int sticker_data_add_keyword(sticker_data_h data_handle, const char *keyword);
195
196 /**
197  * @brief Removes a keyword of the sticker from the list.
198  * @since_tizen 5.5
199  * @remarks @a keyword must exist value in the list. If not, the error as invalid parameter will be returned.
200  * @param[in] data_handle The sticker data handle
201  * @param[in] keyword The keyword to be removed
202  * @return 0 on success, otherwise a negative error value
203  * @retval #STICKER_ERROR_NONE Successful
204  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
205  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
206  * @see sticker_data_keyword_foreach_cb()
207  * @see sticker_data_foreach_keyword()
208  * @see sticker_data_add_keyword()
209  */
210 int sticker_data_remove_keyword(sticker_data_h data_handle, const char *keyword);
211
212 /**
213  * @brief Sets the group name of the sticker.
214  * @since_tizen 5.5
215  * @remarks @a group must have a non-null value. If not, the error as invalid parameter will be returned.
216  * @param[in] data_handle The sticker data handle
217  * @param[in] group The group name to be saved
218  * @return 0 on success, otherwise a negative error value
219  * @retval #STICKER_ERROR_NONE Successful
220  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
221  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
222  * @see sticker_data_get_group()
223  */
224 int sticker_data_set_group_name(sticker_data_h data_handle, const char *group);
225
226 /**
227  * @brief Gets the group name from sticker data handle.
228  * @since_tizen 5.5
229  * @remarks @a group must be released using free().
230  * @param[in] data_handle The sticker data handle
231  * @param[out] group The group name
232  * @return 0 on success, otherwise a negative error value
233  * @retval #STICKER_ERROR_NONE Successful
234  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
235  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
236  * @retval #STICKER_ERROR_NO_DATA No data available
237  * @see sticker_data_set_group()
238  */
239 int sticker_data_get_group_name(sticker_data_h data_handle, char **group);
240
241 /**
242  * @brief Sets the thumbnail local path of the sticker.
243  * @details @a thumbnail must be a relative path like '/res/smile_thumbnail.png'.
244  * @since_tizen 5.5
245  * @remarks @a thumbnail must have a non-null value and must be an existing file. If not, the error as invalid parameter will be returned.
246  * @param[in] data_handle The sticker data handle
247  * @param[in] thumbnail The thumbnail path to be saved
248  * @return 0 on success, otherwise a negative error value
249  * @retval #STICKER_ERROR_NONE Successful
250  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
251  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
252  * @see sticker_data_get_thumbnail()
253  */
254 int sticker_data_set_thumbnail(sticker_data_h data_handle, const char *thumbnail);
255
256 /**
257  * @brief Gets the thumbnail local path from sticker data handle.
258  * @details If the thumbnail is empty, the result will be an empty string.
259  * @since_tizen 5.5
260  * @remarks @a thumbnail must be released using free().
261  * @param[in] data_handle The sticker data handle
262  * @param[out] thumbnail The thumbnail path
263  * @return 0 on success, otherwise a negative error value
264  * @retval #STICKER_ERROR_NONE Successful
265  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
266  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
267  * @see sticker_data_set_thumbnail()
268  */
269 int sticker_data_get_thumbnail(sticker_data_h data_handle, char **thumbnail);
270
271 /**
272  * @brief Sets the description of the sticker.
273  * @since_tizen 5.5
274  * @remarks @a description must have a non-null value. If not, the error as invalid parameter will be returned.
275  * @param[in] data_handle The sticker data handle
276  * @param[in] description The description to be saved
277  * @return 0 on success, otherwise a negative error value
278  * @retval #STICKER_ERROR_NONE Successful
279  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
280  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
281  * @see sticker_data_get_description()
282  */
283 int sticker_data_set_description(sticker_data_h data_handle, const char *description);
284
285 /**
286  * @brief Gets the description from sticker data handle.
287  * @details If the description is empty, the result will be an empty string.
288  * @since_tizen 5.5
289  * @remarks @a description must be released using free().
290  * @param[in] data_handle The sticker data handle
291  * @param[out] description The description of the sticker
292  * @return 0 on success, otherwise a negative error value
293  * @retval #STICKER_ERROR_NONE Successful
294  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
295  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
296  * @see sticker_data_set_description()
297  */
298 int sticker_data_get_description(sticker_data_h data_handle, char **description);
299
300 /**
301  * @brief Gets the last updated date from sticker data handle.
302  * @details The format of @a date is YYYY-MM-DD HH:MM:SS.
303  * @since_tizen 5.5
304  * @remarks @a date must be released using free().
305  * @param[in] data_handle The sticker data handle
306  * @param[out] date The last updated date
307  * @return 0 on success, otherwise a negative error value
308  * @retval #STICKER_ERROR_NONE Successful
309  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
310  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
311  * @retval #STICKER_ERROR_NO_DATA No data available
312  */
313 int sticker_data_get_date(sticker_data_h data_handle, char **date);
314
315 /**
316  * @brief Sets the display type of the sticker.
317  * @since_tizen 5.5
318  * @param[in] data_handle The sticker data handle
319  * @param[in] type The display type to be saved
320  * @return 0 on success, otherwise a negative error value
321  * @retval #STICKER_ERROR_NONE Successful
322  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
323  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
324  * @see sticker_data_get_display_type()
325  */
326 int sticker_data_set_display_type(sticker_data_h data_handle, sticker_data_display_type_e type);
327
328 /**
329  * @brief Gets the display type from sticker data handle.
330  * @details If the display type is empty, the result will be a zero.
331  * @since_tizen 5.5
332  * @param[in] data_handle The sticker data handle
333  * @param[out] type The display type of the sticker
334  * @return 0 on success, otherwise a negative error value
335  * @retval #STICKER_ERROR_NONE Successful
336  * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
337  * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
338  * @see sticker_data_set_display_type()
339  */
340 int sticker_data_get_display_type(sticker_data_h data_handle, sticker_data_display_type_e *type);
341
342 /**
343  * @}
344  */
345
346 #ifdef __cplusplus
347 }
348 #endif
349
350 #endif /* __TIZEN_UIX_STICKER_DATA_H__ */