2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __TIZEN_UIX_STICKER_PROVIDER_H__
18 #define __TIZEN_UIX_STICKER_PROVIDER_H__
20 #include <sticker_error.h>
21 #include <sticker_data.h>
28 * @file sticker_provider.h
29 * @brief This file contains sticker provider's APIs.
33 * @addtogroup CAPI_UIX_STICKER_PROVIDER_MODULE
38 * @brief The sticker provider handle.
41 typedef struct sticker_provider_s *sticker_provider_h;
44 * @brief Called to retrieve all sticker data in the sticker database.
45 * @details The sticker_provider_data_foreach_all() must be called to invoke this callback function, synchronously.
47 * @remarks @a data_handle should not be freed and can be used only in the callback.
48 * If you want to use it outside of the callback, you need to use a clone which can be obtained sticker_data_clone().
49 * @param[in] data_handle The sticker data handle
50 * @param[in] user_data The user data passed from the foreach function
51 * @pre sticker_provider_data_foreach_all() will invoke this callback.
52 * @see sticker_provider_data_foreach_all()
54 typedef void (*sticker_provider_data_foreach_cb)(sticker_data_h data_handle, void *user_data);
57 * @brief Called when inserting sticker data is finished.
58 * @details The following error codes can be received: \n
59 * #STICKER_ERROR_NONE Successful \n
60 * #STICKER_ERROR_OPERATION_FAILED Operation failed \n
62 * @param[in] error The sticker error code
63 * @param[in] user_data The user data passed from the foreach function
64 * @pre sticker_provider_insert_data_by_json_file() will invoke this callback.
65 * @see sticker_provider_insert_data_by_json_file()
67 typedef void (*sticker_provider_insert_finished_cb)(sticker_error_e error, void *user_data);
70 * @brief Creates a sticker provider handle.
72 * @remarks If the function succeeds, @a provider_handle must be released with sticker_provider_destroy().
73 * @param[out] provider_handle The sticker provider handle
74 * @return 0 on success, otherwise a negative error value
75 * @retval #STICKER_ERROR_NONE Successful
76 * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
77 * @retval #STICKER_ERROR_OUT_OF_MEMORY Out of memory
78 * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed
79 * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
80 * @see sticker_provider_destroy()
82 int sticker_provider_create(sticker_provider_h *provider_handle);
85 * @brief Destroys a sticker provider handle.
87 * @param[in] provider_handle The sticker provider handle
88 * @return 0 on success, otherwise a negative error value
89 * @retval #STICKER_ERROR_NONE Successful
90 * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
91 * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed
92 * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
93 * @see sticker_provider_create()
95 int sticker_provider_destroy(sticker_provider_h provider_handle);
98 * @brief Inserts a sticker data to the sticker database.
100 * @remarks All data except thumbnail and description must be set in the @a data_handle to insert the sticker data.
101 * If the uri type is @a STICKER_DATA_URI_LOCAL_PATH, the sticker file is copied to a sticker directory.
102 * It is recommended to delete your sticker file after inserting a sticker data.
103 * @param[in] provider_handle The sticker provider handle
104 * @param[in] data_handle The sticker data handle to be saved
105 * @return 0 on success, otherwise a negative error value
106 * @retval #STICKER_ERROR_NONE Successful
107 * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
108 * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed
109 * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
110 * @see sticker_provider_update_data()
111 * @see sticker_provider_delete_data()
113 int sticker_provider_insert_data(sticker_provider_h provider_handle, sticker_data_h data_handle);
116 * @brief Inserts a sticker data using json file.
117 * @details @a json_path must be a relative path like '/data/message_sticker.json'.
119 * @remarks All data except thumbnail and description must be set in the json file to insert the sticker data.
120 * @a json_path must have a non-null value and must be an existing file. If not, the error as invalid parameter will be returned.
121 * If the uri type is @a STICKER_DATA_URI_LOCAL_PATH, the sticker file is copied to a sticker directory.
122 * It is recommended to delete your sticker files after inserting a sticker data.
123 * @param[in] provider_handle The sticker provider handle
124 * @param[in] json_path The path of json file containing sticker information to be saved
125 * @param[in] callback The callback function to invoke
126 * @param[in] user_data The user data to be passed to the callback function
127 * @return 0 on success, otherwise a negative error value
128 * @retval #STICKER_ERROR_NONE Successful
129 * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
130 * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed
131 * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
132 * @post This function invokes sticker_provider_insert_finished_cb().
133 * @see sticker_provider_insert_finished_cb()
142 "uri" : "/res/face/heart_eyes.png",
143 "keyword" : ["heart eyes", "love", "cute"],
145 "thumbnail" : "/res/face/thumbnail/heart_eyes.png",
146 "description" : "Smiling face with heart eyes emoji."
150 "uri" : "https://samsung.com/example/01/high_five.png",
151 "keyword" : ["smile", "high five"],
154 "description" : "Smiling face with high five emoji."
164 int sticker_provider_insert_data_by_json_file(sticker_provider_h provider_handle, const char *json_path, sticker_provider_insert_finished_cb callback, void *user_data);
167 * @brief Updates a sticker data in the sticker database.
169 * @param[in] provider_handle The sticker provider handle
170 * @param[in] data_handle The sticker data handle to be updated
171 * @return 0 on success, otherwise a negative error value
172 * @retval #STICKER_ERROR_NONE Successful
173 * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
174 * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed
175 * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
176 * @see sticker_provider_insert_data()
177 * @see sticker_provider_delete_data()
179 int sticker_provider_update_data(sticker_provider_h provider_handle, sticker_data_h data_handle);
182 * @brief Deletes a sticker data in the sticker database.
184 * @remarks The @a sticker_id must be the ID of the sticker stored in the sticker database.
185 * @param[in] provider_handle The sticker provider handle
186 * @param[in] data_handle The sticker data handle to be deleted
187 * @return 0 on success, otherwise a negative error value
188 * @retval #STICKER_ERROR_NONE Successful
189 * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
190 * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed
191 * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
192 * @see sticker_provider_insert_data()
193 * @see sticker_provider_update_data()
195 int sticker_provider_delete_data(sticker_provider_h provider_handle, sticker_data_h data_handle);
198 * @brief Gets the count of stickers stored by the provider application.
200 * @param[in] provider_handle The sticker provider handle
201 * @param[out] count The number of stickers
202 * @return 0 on success, otherwise a negative error value
203 * @retval #STICKER_ERROR_NONE Successful
204 * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
205 * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed
206 * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
208 int sticker_provider_get_sticker_count(sticker_provider_h provider_handle, int *count);
211 * @brief Retrieves all sticker data in the sticker database.
212 * @details If you set the @a offset as @c 10 and @a count as @c 10, then only searched data from @c 10 to @c 19 will be invoked.
214 * @remarks It is not an error if @a result is smaller than @a count.
215 * @param[in] provider_handle The sticker provider handle
216 * @param[in] offset The start position (Starting from zero)
217 * @param[in] count The number of stickers to be searched with respect to the offset
218 * @param[out] result The number of stickers retrieved (zero indicates that no data was found)
219 * @param[in] callback The callback function to invoke
220 * @param[in] user_data The user data to be passed to the callback function
221 * @return 0 on success, otherwise a negative error value
222 * @retval #STICKER_ERROR_NONE Successful
223 * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
224 * @retval #STICKER_ERROR_OUT_OF_MEMORY Out of memory
225 * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed
226 * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
227 * @post This function invokes sticker_provider_data_foreach_cb() repeatedly for getting data.
228 * @see sticker_provider_data_foreach_cb()
230 int sticker_provider_data_foreach_all(sticker_provider_h provider_handle, int offset, int count, int *result, sticker_provider_data_foreach_cb callback, void *user_data);
240 #endif /* __TIZEN_UIX_STICKER_PROVIDER_H__ */