4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Youngjoo Park <yjoo93.park@samsung.com>,
7 * Seungtaek Chung <seungtaek.chung@samsung.com>, Youngsub Ko <ys4610.ko@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the License);
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an AS IS BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 #ifndef __BADGE_DEF_H__
24 #define __BADGE_DEF_H__
27 #include <badge_error.h>
31 #endif /* __cplusplus */
35 * @brief This file contains the badge APIs
39 * @addtogroup BADGE_TYPE
44 * @brief Enumeration for Badge action
47 BADGE_ACTION_CREATE = 0,
50 BADGE_ACTION_CHANGED_DISPLAY,
51 BADGE_ACTION_SERVICE_READY,
56 * @brief Called to retrieve the badge existed.
57 * @param[in] pkgname The name of package
58 * @param[in] count The count of badge
59 * @param[in] user_data The user data passed from the foreach function
60 * @pre badge_foreach_existed() will invoke this callback.
61 * @see badge_foreach_existed()
63 typedef void (*badge_cb)(const char *pkgname, unsigned int count, void *data);
67 * @brief Called when badge information is changed.
68 * @param[in] action The type of changing
69 * @param[in] pkgname The name of package
70 * @param[in] count The count of badge
71 * @param[in] user_data The user data passed from the callback register function
72 * @pre badge_register_changed_cb() will invoke this callback.
73 * @see badge_unregister_changed_cb()
75 typedef void (*badge_change_cb)(unsigned int action, const char *pkgname,
76 unsigned int count, void *data);
83 * @addtogroup BADGE_MODULE
88 * @brief This function creates badge for designated package.
89 * @details Creates new badge to display.
90 * @param[in] pkgname The name of designated package
91 * @param[in] writable_pkg The name of package which is authorized to change badge
92 * @return #BADGE_ERROR_NONE if success, other value if failure
99 badge_error_e err = BADGE_ERROR_NONE;
101 err = badge_create("org.tizen.sms", "org.tizen.sms2");
102 if(err != BADGE_ERROR_NONE) {
109 badge_error_e badge_create(const char *pkgname, const char *writable_pkg);
113 * @brief This function removes badge for designated package.
114 * @param[in] pkgname The name of designated package
115 * @return #BADGE_ERROR_NONE if success, other value if failure
116 * @see #badge_error_e
122 badge_error_e err = BADGE_ERROR_NONE;
124 err = badge_remove("org.tizen.sms");
125 if(err != BADGE_ERROR_NONE) {
132 badge_error_e badge_remove(const char *pkgname);
135 * @brief This function sets badge count for designated package.
136 * @param[in] pkgname The name of designated package
137 * @param[in] count The count of badge
138 * @return #BADGE_ERROR_NONE if success, other value if failure
139 * @see #badge_error_e
140 * @see badge_create()
146 badge_error_e err = BADGE_ERROR_NONE;
148 err = badge_set_count("org.tizen.sms", 1);
149 if(err != BADGE_ERROR_NONE) {
156 badge_error_e badge_set_count(const char *pkgname, unsigned int count);
159 * @brief This function gets badge count for designated package.
160 * @param[in] pkgname The name of designated package
161 * @param[out] count The count of badge
162 * @return #BADGE_ERROR_NONE if success, other value if failure
163 * @see #badge_error_e
164 * @see badge_create()
165 * @see badge_set_count()
171 badge_error_e err = BADGE_ERROR_NONE;
173 err = badge_get_count("org.tizen.sms", 1);
174 if(err != BADGE_ERROR_NONE) {
181 badge_error_e badge_get_count(const char *pkgname, unsigned int *count);
184 * @brief This function sets displaying option for designated package.
185 * @param[in] pkgname The name of designated package
186 * @param[in] is_display The displaying option, 1 = display 0 = not display
187 * @return #BADGE_ERROR_NONE if success, other value if failure
188 * @see #badge_error_e
189 * @see badge_create()
195 badge_error_e err = BADGE_ERROR_NONE;
197 err = badge_set_display("org.tizen.sms", 1);
198 if(err != BADGE_ERROR_NONE) {
205 badge_error_e badge_set_display(const char *pkgname, unsigned int is_display);
208 * @brief This function gets displaying option for designated package.
209 * @param[in] pkgname The name of designated package
210 * @param[out] is_display The displaying option, 1 = display 0 = not display
211 * @return #BADGE_ERROR_NONE if success, other value if failure
212 * @see #badge_error_e
213 * @see badge_create()
214 * @see badge_set_count()
221 badge_error_e err = BADGE_ERROR_NONE;
223 err = badge_get_display("org.tizen.sms", &is_display);
224 if(err != BADGE_ERROR_NONE) {
231 badge_error_e badge_get_display(const char *pkgname, unsigned int *is_display);
234 * @brief This function tests badge for designated package is existed or not.
235 * @param[in] pkgname The name of designated package
236 * @param[out] existing The bool value of badge existing status
237 * @return #BADGE_ERROR_NONE if success, other value if failure
238 * @see #badge_error_e
239 * @see badge_create()
240 * @see badge_remove()
246 badge_error_e err = BADGE_ERROR_NONE;
249 err = badge_is_existing("org.tizen.sms", &exist);
250 if(err != BADGE_ERROR_NONE) {
257 badge_error_e badge_is_existing(const char *pkgname, bool *existing);
260 * @brief This function retrieves all badges which are existed.
261 * @param[in] callback The callback function
262 * @param[in] data The user data to be passed to the callback function
263 * @return #BADGE_ERROR_NONE if success, other value if failure
264 * @see #badge_error_e
265 * @see badge_get_count()
266 * @see badge_is_existing()
268 badge_error_e badge_foreach_existed(badge_cb callback, void *data);
271 * @brief This function registers callback function to receive badge changed event.
272 * @param[in] callback The callback function
273 * @param[in] data The user data to be passed to the callback function
274 * @return #BADGE_ERROR_NONE if success, other value if failure
275 * @see #badge_error_e
276 * @see badge_create()
277 * @see badge_remove()
278 * @see badge_set_count()
280 badge_error_e badge_register_changed_cb(badge_change_cb callback, void *data);
283 * @brief This function unregisters callback function to receive badge changed event.
284 * @param[in] callback The callback function
285 * @return #BADGE_ERROR_NONE if success, other value if failure
286 * @see #badge_error_e
287 * @see badge_register_changed_cb()
289 badge_error_e badge_unregister_changed_cb(badge_change_cb callback);
295 int badge_is_service_ready(void);
297 badge_error_e badge_add_deffered_task(
298 void (*deffered_task_cb)(void *data), void *user_data);
300 badge_error_e badge_del_deffered_task(
301 void (*deffered_task_cb)(void *data));
305 #endif /* __cplusplus */
307 #endif /* __BADGE_DEF_H__ */