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 Checks whether the notification is ongoing or not
97 * @param[in] notification The notification handle
98 * @param[out] ongoing A boolean value that sets whether this is an ongoing notification.
99 * @return 0 on success, otherwise a negative error value.
100 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
101 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
102 * @see ui_notification_create()
104 int ui_notification_is_ongoing(ui_notification_h notification, bool *ongoing);
107 * @brief Sets the full path of the icon image to display in the notification.
108 * @remarks The @a path should be the absolute path. If the icon is not set, the icon of the application will be displayed. \n
109 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
110 * @param[in] notification The notification handle
111 * @param[in] path The absolute path to the specified icon \n
112 * If the @a path is NULL, it clears the previous value.
113 * @return 0 on success, otherwise a negative error value.
114 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
115 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
116 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
117 * @see ui_notification_get_icon()
119 int ui_notification_set_icon(ui_notification_h notification, const char *path);
122 * @brief Gets the absolute path to the icon to display in the notification.
123 * @remarks The @a path must be released with free() by you.
124 * @param[in] notification The notification handle
125 * @param[out] path The absolute path to the icon
126 * @return 0 on success, otherwise a negative error value.
127 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
128 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
129 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
130 * @see ui_notification_set_icon()
132 int ui_notification_get_icon(ui_notification_h notification, char **path);
135 * @brief Sets the time that the notification occurred.
136 * @remarks This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
137 * @param[in] notification The notification handle
138 * @param[in] time The time that the notification occurred \n
139 * If the @a time is NULL, it clears the previous value.
140 * @return 0 on success, otherwise a negative error value.
141 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
142 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
143 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
144 * @see ui_notification_get_time()
146 int ui_notification_set_time(ui_notification_h notification, struct tm *time);
149 * @brief Gets the time that the notification occured.
150 * @param[in] notification The notification handle
151 * @param[out] time The time that the notification occured
152 * @return 0 on success, otherwise a negative error value.
153 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
154 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
155 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
156 * @see ui_notification_set_time()
158 int ui_notification_get_time(ui_notification_h notification, struct tm **time);
161 * @brief Sets the title to display in the notification.
162 * @remarks If the title is not set, the name of the application will be displayed. \n
163 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
164 * @param[in] notification The notification handle
165 * @param[in] title The title to display in the notification \n
166 * If the @a title is NULL, it clears the previous value.
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_get_title()
173 int ui_notification_set_title(ui_notification_h notification, const char *title);
176 * @brief Gets the title to display in the notification.
177 * @remarks The @a title must be released with free() by you.
178 * @param[in] notification The notification handle
179 * @param[out] title The title to display in the notification
180 * @return 0 on success, otherwise a negative error value.
181 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
182 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
183 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
184 * @see ui_notification_set_title()
186 int ui_notification_get_title(ui_notification_h notification, char **title);
189 * @brief Sets the content to display in the notification
190 * @remarks This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
191 * @param[in] notification The notification handle
192 * @param[in] content The content to display in the notification \n
193 * If the @a content is NULL, it clears the previous value.
194 * @return 0 on success, otherwise a negative error value.
195 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
196 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
197 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
198 * @see ui_notification_get_content()
200 int ui_notification_set_content(ui_notification_h notification, const char *content);
203 * @brief Gets the content to display in the notification
204 * @remarks The @a content must be released with free() by you.
205 * @param[in] notification The notification handle
206 * @param[out] content The content to display in the notification
207 * @return 0 on success, otherwise a negative error value.
208 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
209 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
210 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
211 * @see ui_notification_set_content()
213 int ui_notification_get_content(ui_notification_h notification, char **content);
216 * @brief Sets the path of sound file to play when the notification is shown.
217 * @remarks The @a path should be the absolute path. \n
218 * The sound file is only supported wave file format. \n
219 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
220 * @param[in] notification The notification handle
221 * @param[in] path The path of sound file to play when the notification is shown \n
222 * If the @a path is NULL, it clears the previous value.
223 * @return 0 on success, otherwise a negative error value.
224 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
225 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
226 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
227 * @see ui_notification_get_sound()
229 int ui_notification_set_sound(ui_notification_h notification, const char *path);
232 * @brief Gets the path of sound file to play when the notification is shown.
233 * @remarks The @a path must be released with free() by you.
234 * @param[in] notification The notification handle
235 * @param[out] path The path of sound file to play when the notification is shown \n
236 * @return 0 on success, otherwise a negative error value.
237 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
238 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
239 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
240 * @see ui_notification_set_sound()
242 int ui_notification_get_sound(ui_notification_h notification, char **path);
245 * @brief Sets whether to use vibration when the notification is shown.
246 * @remarks This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
247 * @param[in] notification The notification handle
248 * @param[in] value A boolean value that sets whether to use vibration.
249 * @return 0 on success, otherwise a negative error value.
250 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
251 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
252 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
253 * @see ui_notification_get_vibration()
255 int ui_notification_set_vibration(ui_notification_h notification, bool value);
258 * @brief Gets whether to use vibration when the notification is shown.
259 * @param[in] notification The notification handle
260 * @param[out] value A boolean value that sets whether to use vibration.
261 * @return 0 on success, otherwise a negative error value.
262 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
263 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
264 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
265 * @see ui_notification_set_vibration()
267 int ui_notification_get_vibration(ui_notification_h notification, bool *value);
270 * @brief Sets the service to launch when the notification is selected from the notification tray.
271 * @details When the notification is selected from the notification tray, the application which is described by the specified service is launched. \n
272 * If you want to launch the current application, use the explicit launch of the @ref CAPI_SERVICE_MODULE API
273 * @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
274 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
275 * @param[in] notification The notification handle
276 * @param[in] service The service handle to launch when the notification is selected \n
277 * If the @a service is NULL, it clears the previous value.
278 * @return 0 on success, otherwise a negative error value.
279 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
280 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
281 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
282 * @see ui_notification_get_service()
283 * @see service_create()
285 int ui_notification_set_service(ui_notification_h notification, service_h service);
288 * @brief Gets the service to launch when the notification is selected from the notification tray
289 * @remarks The @a service must be released with service_destroy() by you.
290 * @param[in] notification The notification handle
291 * @param[out] service The service handle to launch when the notification is selected
292 * @return 0 on success, otherwise a negative error value.
293 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
294 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
295 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
296 * @see ui_notification_set_service()
298 int ui_notification_get_service(ui_notification_h notification, service_h *service);
301 * @brief Posts the notification to display in the notification tray and the status bar
302 * @param[in] notification The notification handle
303 * @return 0 on success, otherwise a negative error value.
304 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
305 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
306 * @retval #UI_NOTIFICATION_ERROR_DB_FAILED DB failed
307 * @retval #UI_NOTIFICATION_ERROR_NO_SUCH_FILE DB No such icon file
308 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was already posted
309 * @post The posted notification can be canceled or updated.
310 * @see ui_notification_cancel()
311 * @see ui_notification_cancel_all()
312 * @see ui_notification_update()
313 * @see ui_notification_update_progress()
314 * @see ui_notification_foreach_notification_posted()
316 int ui_notification_post(ui_notification_h notification);
319 * @brief Cancels the previously posted notification.
320 * @details The previously posted notification is removed from the notification tray and the status bar.
321 * @remarks The canceled @a notification is not be released automatically, must be released with ui_notification_destroy() by you.
322 * @param[in] notification The notification handle
323 * @return 0 on success, otherwise a negative error value.
324 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
325 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
326 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was either cleared or canceled.
327 * @pre The notification must be posted before canceling it.
328 * @see ui_notification_post()
329 * @see ui_notification_cancel_all()
331 int ui_notification_cancel(ui_notification_h notification);
334 * @brief Cancels all previously posted notifications by the current application.
335 * @details All previously posted notifications are removed from the notification tray and the status bar.
336 * @remarks The notifications posted by other applications are not canceled from the notification tray and the status bar.
337 * @see ui_notification_post()
338 * @see ui_notification_cancel()
340 void ui_notification_cancel_all(void);
343 * @brief Cancels selected type of previously posted notifications by the current application.
344 * @details Selected type of previously posted notifications are removed from the notification tray and the status bar.
345 * @remarks The notifications posted by other applications are not cancelled from the notification tray and the status bar.
346 * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel.
347 * @see ui_notification_post()
348 * @see ui_notification_cancel()
349 * @see ui_notification_cancel_all()
351 void ui_notification_cancel_all_by_type(bool ongoing);
354 * @brief Cancels selected type of previously posted notifications by the given application.
355 * @details Selected type of previously posted notifications are removed from the notification tray and the status bar.
356 * @remark This function is @b deprecated. Use app_manager_app_context_cb() instead.
357 * @param[in] package The package name of the application to calcel the posted notifications.
358 * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel.
359 * @see ui_notification_post()
360 * @see ui_notification_cancel()
361 * @see ui_notification_cancel_all()
363 void ui_notification_cancel_all_by_package(const char *package, bool ongoing);
366 * @brief Cancels selected type of previously posted notifications by the given application ID.
367 * @details Selected type of previously posted notifications are removed from the notification tray and the status bar.
368 * @param[in] id The ID of the application to calcel the posted notifications.
369 * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel.
370 * @return 0 on success, otherwise a negative error value.
371 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
372 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
373 * @see ui_notification_post()
374 * @see ui_notification_cancel()
375 * @see ui_notification_cancel_all()
377 int ui_notification_cancel_all_by_app_id(const char *app_id, bool ongoing);
380 * @brief Updates the notification posted.
381 * @remarks You cannot update the notification which was cleared or canceled.
382 * @param[in] notification The notification handle
383 * @return 0 on success, otherwise a negative error value.
384 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
385 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
386 * @retval #UI_NOTIFICATION_ERROR_DB_FAILED DB failed
387 * @retval #UI_NOTIFICATION_ERROR_NO_SUCH_FILE DB No such icon file
388 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was either cleared or canceled.
389 * @pre The notification must be posted before updating it.
390 * @see ui_notification_post()
391 * @see ui_notification_update_progress()
393 int ui_notification_update(ui_notification_h notification);
396 * @brief Updates the progress to the specified value
397 * @remarks You cannot update the notification which was cleared or canceled.
398 * @param[in] notification The notification handle \n
399 * It must be ongoing notification. \n
400 * If not, #UI_NOTIFICATION_ERROR_INVALID_PARAMETER will occur
401 * @param[in] type The progress type
402 * @param[in] value The value of the progress \n
403 * The @a value must be greater than or equal to zero. \n
404 * if @a type is #UI_NOTIFICATION_PROGRESS_TYPE_SIZE, it must be in bytes. \n
405 * If @a type is #UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE, It must be a floating-point value between 0.0 and 1.0.
406 * @return 0 on success, otherwise a negative error value.
407 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
408 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
409 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was canceled.
410 * @pre The notification must be posted before updating the progress to the specified value
411 * @see ui_notification_create()
412 * @see ui_notification_post()
413 * @see ui_notification_update()
414 * @see #ui_notification_progress_type_e
416 int ui_notification_update_progress(ui_notification_h notification, ui_notification_progress_type_e type, double value);
419 * @brief Retrieves all posted notifications.
420 * @details This function calls ui_notification_cb() once for each notification which was posted and is being shown. \n
421 * If ui_notification_cb() callback function returns false, then iteration will be finished.
423 * @param [in] ongoing A boolean value that sets whether the type is an ongoing notification.
424 * @param [in] callback The iteration callback function
425 * @param [in] user_data The user data to be passed to the callback function
426 * @return 0 on success, otherwise a negative error value.
427 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
428 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
429 * @post This function invokes ui_notification_cb().
430 * @see ui_notification_cb()
432 int ui_notification_foreach_notification_posted(bool ongoing, ui_notification_cb callback, void *user_data);
435 * @brief Creates and returns a copy of the given notification handle.
437 * @remarks A newly created notification handle should be destroyed by calling ui_notification_destroy() if it is no longer needed.
439 * @param [out] clone If successful, a newly created notification handle will be returned.
440 * @param [in] service The notification handle
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 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
445 * @see ui_notification_create()
446 * @see ui_notification_destroy()
448 int ui_notification_clone(ui_notification_h *clone, ui_notification_h notification);
459 #endif /* __TIZEN_APPFW_UI_NOTIFICATION_H__ */