2 * Copyright (c) 2011 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 __TIZEN_APPFW_UI_NOTIFICATION_H__
19 #define __TIZEN_APPFW_UI_NOTIFICATION_H__
23 #include <app_service.h>
31 * @addtogroup CAPI_UI_NOTIFICATION_MODULE
36 * @brief Notification handle.
38 typedef struct ui_notification_s *ui_notification_h;
41 * @brief Enumerations of error code for notification.
44 UI_NOTIFICATION_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
45 UI_NOTIFICATION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
46 UI_NOTIFICATION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
47 UI_NOTIFICATION_ERROR_DB_FAILED = TIZEN_ERROR_APPLICATION_CLASS | 0x31, /**< DB operation failed */
48 UI_NOTIFICATION_ERROR_NO_SUCH_FILE = TIZEN_ERROR_NO_SUCH_FILE, /**< No such file */
49 UI_NOTIFICATION_ERROR_INVALID_STATE = TIZEN_ERROR_APPLICATION_CLASS | 0x32, /**< Invalid state */
50 } ui_notification_error_e;
53 * @brief Enumeration of progress type for ongoing notification
56 UI_NOTIFICATION_PROGRESS_TYPE_SIZE, /**< Size in bytes */
57 UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE, /**< Percentage (between 0.0 and 1.0) */
58 } ui_notification_progress_type_e;
61 * @brief Called to retrieve the notifications posted.
62 * @remarks You should not free @a notification returned by this function.
63 * @param[in] notification The notification handle
64 * @param[in] user_data The user data passed from the foreach function
65 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
66 * @pre ui_notification_foreach_notification_posted() will invoke this callback.
67 * @see ui_notification_foreach_notification_posted()
68 * @see ui_notification_clone()
70 typedef bool (*ui_notification_cb)(ui_notification_h notification, void *user_data);
73 * @brief Creates a notification handle.
74 * @remarks The @a notification must be released with ui_notification_destroy() by you.
75 * @param[in] ongoing A boolean value that sets whether this is an ongoing notification.
76 * @param[out] notification A UI notification handle to be newly created on success
77 * @return 0 on success, otherwise a negative error value.
78 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
79 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
80 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
81 * @see ui_notification_destroy()
83 int ui_notification_create(bool ongoing, ui_notification_h *notification);
86 * @brief Destroys the notification handle and releases all its resources.
87 * @param[in] notification The notification handle
88 * @return 0 on success, otherwise a negative error value.
89 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
90 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
91 * @see ui_notification_create()
93 int ui_notification_destroy(ui_notification_h notification);
96 * @brief Gets the identifier of the notification unique within the application
97 * @remarks The system assigns an unique identifier to the notification when it is posted. \n
98 * This function returns #UI_NOTIFICATION_ERROR_INVALID_STATE if the notification was not posted.
99 * @param[in] notification The notification handle
100 * @param[out] id The identifier for the notification unique within the application.
101 * @return 0 on success, otherwise a negative error value.
102 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
103 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
104 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
105 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted.
106 * @see ui_notification_post()
108 int ui_notification_get_id(ui_notification_h notification, int *id);
111 * @brief Checks whether the notification is ongoing or not
112 * @param[in] notification The notification handle
113 * @param[out] ongoing A boolean value that sets whether this is an ongoing notification.
114 * @return 0 on success, otherwise a negative error value.
115 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
116 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
117 * @see ui_notification_create()
119 int ui_notification_is_ongoing(ui_notification_h notification, bool *ongoing);
122 * @brief Sets the full path of the icon image to display in the notification.
123 * @remarks The @a path should be the absolute path. If the icon is not set, the icon of the application will be displayed. \n
124 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
125 * @param[in] notification The notification handle
126 * @param[in] path The absolute path to the specified icon \n
127 * If the @a path is NULL, it clears the previous value.
128 * @return 0 on success, otherwise a negative error value.
129 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
130 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
131 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
132 * @see ui_notification_get_icon()
134 int ui_notification_set_icon(ui_notification_h notification, const char *path);
137 * @brief Gets the absolute path to the icon to display in the notification.
138 * @remarks The @a path must be released with free() by you.
139 * @param[in] notification The notification handle
140 * @param[out] path The absolute path to the icon
141 * @return 0 on success, otherwise a negative error value.
142 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
143 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
144 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
145 * @see ui_notification_set_icon()
147 int ui_notification_get_icon(ui_notification_h notification, char **path);
150 * @brief Sets the time that the notification occurred.
151 * @remarks This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
152 * @param[in] notification The notification handle
153 * @param[in] time The time that the notification occurred \n
154 * If the @a time is NULL, it clears the previous value.
155 * @return 0 on success, otherwise a negative error value.
156 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
157 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
158 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
159 * @see ui_notification_get_time()
161 int ui_notification_set_time(ui_notification_h notification, struct tm *time);
164 * @brief Gets the time that the notification occured.
165 * @param[in] notification The notification handle
166 * @param[out] time The time that the notification occured
167 * @return 0 on success, otherwise a negative error value.
168 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
169 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
170 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
171 * @see ui_notification_set_time()
173 int ui_notification_get_time(ui_notification_h notification, struct tm **time);
176 * @brief Sets the title to display in the notification.
177 * @remarks If the title is not set, the name of the application will be displayed. \n
178 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
179 * @param[in] notification The notification handle
180 * @param[in] title The title to display in the notification \n
181 * If the @a title is NULL, it clears the previous value.
182 * @return 0 on success, otherwise a negative error value.
183 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
184 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
185 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
186 * @see ui_notification_get_title()
188 int ui_notification_set_title(ui_notification_h notification, const char *title);
191 * @brief Gets the title to display in the notification.
192 * @remarks The @a title must be released with free() by you.
193 * @param[in] notification The notification handle
194 * @param[out] title The title to display in the notification
195 * @return 0 on success, otherwise a negative error value.
196 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
197 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
198 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
199 * @see ui_notification_set_title()
201 int ui_notification_get_title(ui_notification_h notification, char **title);
204 * @brief Sets the content to display in the notification
205 * @remarks This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
206 * @param[in] notification The notification handle
207 * @param[in] content The content to display in the notification \n
208 * If the @a content is NULL, it clears the previous value.
209 * @return 0 on success, otherwise a negative error value.
210 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
211 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
212 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
213 * @see ui_notification_get_content()
215 int ui_notification_set_content(ui_notification_h notification, const char *content);
218 * @brief Gets the content to display in the notification
219 * @remarks The @a content must be released with free() by you.
220 * @param[in] notification The notification handle
221 * @param[out] content The content to display in the notification
222 * @return 0 on success, otherwise a negative error value.
223 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
224 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
225 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
226 * @see ui_notification_set_content()
228 int ui_notification_get_content(ui_notification_h notification, char **content);
231 * @brief Sets the path of sound file to play when the notification is shown.
232 * @remarks The @a path should be the absolute path. \n
233 * The sound file is only supported wave file format. \n
234 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
235 * @param[in] notification The notification handle
236 * @param[in] path The path of sound file to play when the notification is shown \n
237 * If the @a path is NULL, it clears the previous value.
238 * @return 0 on success, otherwise a negative error value.
239 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
240 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
241 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
242 * @see ui_notification_get_sound()
244 int ui_notification_set_sound(ui_notification_h notification, const char *path);
247 * @brief Gets the path of sound file to play when the notification is shown.
248 * @remarks The @a path must be released with free() by you.
249 * @param[in] notification The notification handle
250 * @param[out] path The path of sound file to play when the notification is shown \n
251 * @return 0 on success, otherwise a negative error value.
252 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
253 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
254 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
255 * @see ui_notification_set_sound()
257 int ui_notification_get_sound(ui_notification_h notification, char **path);
260 * @brief Sets whether to use vibration when the notification is shown.
261 * @remarks This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
262 * @param[in] notification The notification handle
263 * @param[in] value A boolean value that sets whether to use vibration.
264 * @return 0 on success, otherwise a negative error value.
265 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
266 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
267 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
268 * @see ui_notification_get_vibration()
270 int ui_notification_set_vibration(ui_notification_h notification, bool value);
273 * @brief Gets whether to use vibration when the notification is shown.
274 * @param[in] notification The notification handle
275 * @param[out] value A boolean value that sets whether to use vibration.
276 * @return 0 on success, otherwise a negative error value.
277 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
278 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
279 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
280 * @see ui_notification_set_vibration()
282 int ui_notification_get_vibration(ui_notification_h notification, bool *value);
285 * @brief Sets the service to launch when the notification is selected from the notification tray.
286 * @details When the notification is selected from the notification tray, the application which is described by the specified service is launched. \n
287 * If you want to launch the current application, use the explicit launch of the @ref CAPI_SERVICE_MODULE API
288 * @remarks If the service is not set, the selected notification will be cleared from both the notification tray and the status bar without any action. \n
289 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
290 * @param[in] notification The notification handle
291 * @param[in] service The service handle to launch when the notification is selected \n
292 * If the @a service is NULL, it clears the previous value.
293 * @return 0 on success, otherwise a negative error value.
294 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
295 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
296 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
297 * @see ui_notification_get_service()
298 * @see service_create()
300 int ui_notification_set_service(ui_notification_h notification, service_h service);
303 * @brief Gets the service to launch when the notification is selected from the notification tray
304 * @remarks The @a service must be released with service_destroy() by you.
305 * @param[in] notification The notification handle
306 * @param[out] service The service handle to launch when the notification is selected
307 * @return 0 on success, otherwise a negative error value.
308 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
309 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
310 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
311 * @see ui_notification_set_service()
313 int ui_notification_get_service(ui_notification_h notification, service_h *service);
316 * @brief Posts the notification to display in the notification tray and the status bar
317 * @param[in] notification The notification handle
318 * @return 0 on success, otherwise a negative error value.
319 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
320 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
321 * @retval #UI_NOTIFICATION_ERROR_DB_FAILED DB failed
322 * @retval #UI_NOTIFICATION_ERROR_NO_SUCH_FILE DB No such icon file
323 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was already posted
324 * @post The posted notification can be canceled or updated.
325 * @see ui_notification_cancel()
326 * @see ui_notification_cancel_all()
327 * @see ui_notification_update()
328 * @see ui_notification_update_progress()
329 * @see ui_notification_foreach_notification_posted()
331 int ui_notification_post(ui_notification_h notification);
334 * @brief Cancels the previously posted notification.
335 * @details The previously posted notification is removed from the notification tray and the status bar.
336 * @remarks The canceled @a notification is not be released automatically, must be released with ui_notification_destroy() by you.
337 * @param[in] notification The notification handle
338 * @return 0 on success, otherwise a negative error value.
339 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
340 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
341 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was either cleared or canceled.
342 * @pre The notification must be posted before canceling it.
343 * @see ui_notification_post()
344 * @see ui_notification_cancel_all()
346 int ui_notification_cancel(ui_notification_h notification);
349 * @brief Cancels all previously posted notifications by the current application.
350 * @details All previously posted notifications are removed from the notification tray and the status bar.
351 * @remarks The notifications posted by other applications are not canceled from the notification tray and the status bar.
352 * @see ui_notification_post()
353 * @see ui_notification_cancel()
355 void ui_notification_cancel_all(void);
358 * @brief Cancels selected type of previously posted notifications by the current application.
359 * @details Selected type of previously posted notifications are removed from the notification tray and the status bar.
360 * @remarks The notifications posted by other applications are not cancelled from the notification tray and the status bar.
361 * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel.
362 * @see ui_notification_post()
363 * @see ui_notification_cancel()
364 * @see ui_notification_cancel_all()
366 void ui_notification_cancel_all_by_type(bool ongoing);
369 * @brief Cancels selected type of previously posted notifications by the given application.
370 * @details Selected type of previously posted notifications are removed from the notification tray and the status bar.
371 * @remark This function is @b deprecated. Use app_manager_app_context_cb() instead.
372 * @param[in] package The package name of the application to calcel the posted notifications.
373 * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel.
374 * @see ui_notification_post()
375 * @see ui_notification_cancel()
376 * @see ui_notification_cancel_all()
378 void ui_notification_cancel_all_by_package(const char *package, bool ongoing);
381 * @brief Cancels selected type of previously posted notifications by the given application ID.
382 * @details Selected type of previously posted notifications are removed from the notification tray and the status bar.
383 * @param[in] id The ID of the application to calcel the posted notifications.
384 * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel.
385 * @return 0 on success, otherwise a negative error value.
386 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
387 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
388 * @see ui_notification_post()
389 * @see ui_notification_cancel()
390 * @see ui_notification_cancel_all()
392 int ui_notification_cancel_all_by_app_id(const char *app_id, bool ongoing);
395 * @brief Updates the notification posted.
396 * @remarks You cannot update the notification which was cleared or canceled.
397 * @param[in] notification The notification handle
398 * @return 0 on success, otherwise a negative error value.
399 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
400 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
401 * @retval #UI_NOTIFICATION_ERROR_DB_FAILED DB failed
402 * @retval #UI_NOTIFICATION_ERROR_NO_SUCH_FILE DB No such icon file
403 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was either cleared or canceled.
404 * @pre The notification must be posted before updating it.
405 * @see ui_notification_post()
406 * @see ui_notification_update_progress()
408 int ui_notification_update(ui_notification_h notification);
411 * @brief Updates the progress to the specified value
412 * @remarks You cannot update the notification which was cleared or canceled.
413 * @param[in] notification The notification handle \n
414 * It must be ongoing notification. \n
415 * If not, #UI_NOTIFICATION_ERROR_INVALID_PARAMETER will occur
416 * @param[in] type The progress type
417 * @param[in] value The value of the progress \n
418 * The @a value must be greater than or equal to zero. \n
419 * if @a type is #UI_NOTIFICATION_PROGRESS_TYPE_SIZE, it must be in bytes. \n
420 * If @a type is #UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE, It must be a floating-point value between 0.0 and 1.0.
421 * @return 0 on success, otherwise a negative error value.
422 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
423 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
424 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was canceled.
425 * @pre The notification must be posted before updating the progress to the specified value
426 * @see ui_notification_create()
427 * @see ui_notification_post()
428 * @see ui_notification_update()
429 * @see #ui_notification_progress_type_e
431 int ui_notification_update_progress(ui_notification_h notification, ui_notification_progress_type_e type, double value);
434 * @brief Retrieves all posted notifications.
435 * @details This function calls ui_notification_cb() once for each notification which was posted and is being shown. \n
436 * If ui_notification_cb() callback function returns false, then iteration will be finished.
438 * @param [in] ongoing A boolean value that sets whether the type is an ongoing notification.
439 * @param [in] callback The iteration callback function
440 * @param [in] user_data The user data to be passed to the callback function
441 * @return 0 on success, otherwise a negative error value.
442 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
443 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
444 * @post This function invokes ui_notification_cb().
445 * @see ui_notification_cb()
447 int ui_notification_foreach_notification_posted(bool ongoing, ui_notification_cb callback, void *user_data);
450 * @brief Creates and returns a copy of the given notification handle.
452 * @remarks A newly created notification handle should be destroyed by calling ui_notification_destroy() if it is no longer needed.
454 * @param [out] clone If successful, a newly created notification handle will be returned.
455 * @param [in] service The notification handle
456 * @return 0 on success, otherwise a negative error value.
457 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
458 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
459 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
460 * @see ui_notification_create()
461 * @see ui_notification_destroy()
463 int ui_notification_clone(ui_notification_h *clone, ui_notification_h notification);
474 #endif /* __TIZEN_APPFW_UI_NOTIFICATION_H__ */