2 * Copyright (c) 2000 - 2017 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.
18 #ifndef __BADGE_INTERNAL_DEF_H__
19 #define __BADGE_INTERNAL_DEF_H__
24 #include <sys/types.h>
26 #include "badge_error.h"
30 #define EXPORT_API __attribute__ ((visibility("default")))
34 #define DEPRECATED __attribute__((deprecated))
37 #define BADGE_ERROR (badge_error_quark())
38 GQuark badge_error_quark(void);
42 #endif /* __cplusplus */
44 typedef struct _badge_h badge_h;
46 typedef struct badge_info {
48 unsigned int badge_count;
53 * @brief This function checks whether badge service is ready
54 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
56 * @privilege %http://tizen.org/privilege/notification
57 * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
58 * @return 1 if badge service is ready, other value if badge service isn't ready
59 * @retval BADGE_ERROR_NONE Success
60 * @retval BADGE_ERROR_SERVICE_NOT_READY Service is not ready
61 * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
63 int badge_is_service_ready(void);
67 * @brief This function adds deferred task. the registered task will be executed when badge service become ready
68 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
70 * @privilege %http://tizen.org/privilege/notification
71 * @param[in] badge_add_deferred_task The callback function
72 * @param[in] user_data The user data to be passed to the callback function
73 * @return #BADGE_ERROR_NONE if success, other value if failure
74 * @retval BADGE_ERROR_NONE Success
75 * @retval BADGE_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
76 * @retval BADGE_ERROR_OUT_OF_MEMORY Out of memory
77 * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
79 * @see badge_is_service_ready()
81 int badge_add_deferred_task(
82 void (*badge_add_deferred_task)(void *data), void *user_data);
86 * @brief This function removes deferred task.
87 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
89 * @privilege %http://tizen.org/privilege/notification
90 * @param[in] badge_add_deferred_task The callback function
91 * @return #BADGE_ERROR_NONE if success, other value if failure
92 * @retval BADGE_ERROR_NONE Success
93 * @retval BADGE_ERROR_INVALID_PARAMETER Invalid parameter
94 * @retval BADGE_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
95 * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
97 * @see badge_is_service_ready()
99 int badge_del_deferred_task(
100 void (*badge_add_deferred_task)(void *data));
104 * @brief Tests if the badge for the designated application exists or not.
105 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
107 * @privilege %http://tizen.org/privilege/notification
108 * @param[in] app_id The name of the designated application
109 * @param[out] existing The bool value of badge existence status
110 * @return #BADGE_ERROR_NONE if success, other value if failure
111 * @retval BADGE_ERROR_NONE Success
112 * @retval BADGE_ERROR_INVALID_PARAMETER Invalid parameter
113 * @retval BADGE_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method
114 * @retval BADGE_ERROR_FROM_DB Error from DB
115 * @retval BADGE_ERROR_OUT_OF_MEMORY Out of memory
116 * @retval BADGE_ERROR_NOT_EXIST Not exist
117 * @retval BADGE_ERROR_SERVICE_NOT_READY Service is not ready
118 * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
119 * @see #badge_error_e
121 * @see badge_remove()
127 int err = BADGE_ERROR_NONE;
130 err = badge_is_existing(app_id, &exist);
131 if (err != BADGE_ERROR_NONE) {
138 int badge_is_existing(const char *app_id, bool *existing);
140 char *_badge_get_pkgname_by_pid(void);
142 int _badge_is_existing(const char *pkgname, bool *existing, uid_t uid);
144 int _badge_get_list(GList **badge_list, uid_t uid);
146 int _badge_insert(badge_h *badge, uid_t uid);
148 int _badge_remove(const char *caller, const char *pkgname, uid_t uid, pid_t pid);
150 int _badge_remove_by_pkgname(const char *pkgname, uid_t uid);
152 int _badge_set_count(const char *caller, const char *pkgname,
153 unsigned int count, uid_t uid, pid_t pid);
155 int _badge_get_count(const char *pkgname, unsigned int *count, uid_t uid);
157 int _badge_set_display(const char *pkgname, unsigned int is_display, uid_t uid);
159 int _badge_get_display(const char *pkgname, unsigned int *is_display, uid_t uid);
161 int _badge_free(badge_h *badge);
163 badge_h *_badge_new(const char *pkgname, const char *writable_pkgs,
166 char *_badge_pkgs_new(int *err, const char *pkg1, ...);
168 void badge_changed_cb_call(unsigned int action, const char *pkgname,
169 unsigned int count, uid_t uid);
173 * @brief Creates a badge for the designated package.
174 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
176 * @privilege %http://tizen.org/privilege/notification
177 * @details Creates new badge to display.
178 * @param[in] pkgname The name of the designated package
179 * @param[in] writable_pkg The name of package which is authorized to change the badge
180 * @return #BADGE_ERROR_NONE if success, other value if failure
181 * @retval BADGE_ERROR_NOT_SUPPORTED Not supported
182 * @see #badge_error_e
188 int err = BADGE_ERROR_NONE;
190 err = badge_create("org.tizen.sms", "org.tizen.sms2");
191 if (err != BADGE_ERROR_NONE) {
198 int badge_create(const char *pkgname, const char *writable_pkg);
200 int badge_create_for_uid(const char *pkgname, const char *writable_pkg, uid_t uid);
202 int badge_new_for_uid(const char *writable_app_id, uid_t uid);
204 int badge_add_for_uid(const char *badge_app_id, uid_t uid);
206 int badge_remove_for_uid(const char *app_id, uid_t uid);
208 int badge_is_existing_for_uid(const char *app_id, bool *existing, uid_t uid);
210 int badge_foreach_for_uid(badge_foreach_cb callback, void *user_data, uid_t uid);
212 int badge_set_count_for_uid(const char *app_id, unsigned int count, uid_t uid);
214 int badge_get_count_for_uid(const char *app_id, unsigned int *count, uid_t uid);
216 int badge_set_display_for_uid(const char *app_id, unsigned int is_display, uid_t uid);
218 int badge_get_display_for_uid(const char *app_id, unsigned int *is_display, uid_t uid);
220 int badge_register_changed_cb_for_uid(badge_change_cb callback, void *data, uid_t uid);
222 int badge_unregister_changed_cb_for_uid(badge_change_cb callback, uid_t uid);
227 #endif /* __cplusplus */
229 #endif /* __BADGE_INTERNAL_DEF_H__ */