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 service to launch when the notification is selected from the notification tray.
217 * @details When the notification is selected from the notification tray, the application which is described by the specified service is launched. \n
218 * If you want to launch the current application, use the explicit launch of the @ref CAPI_SERVICE_MODULE API
219 * @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
220 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
221 * @param[in] notification The notification handle
222 * @param[in] service The service handle to launch when the notification is selected \n
223 * If the @a service is NULL, it clears the previous value.
224 * @return 0 on success, otherwise a negative error value.
225 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
226 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
227 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
228 * @see ui_notification_get_service()
229 * @see service_create()
231 int ui_notification_set_service(ui_notification_h notification, service_h service);
234 * @brief Gets the service to launch when the notification is selected from the notification tray
235 * @remarks The @a service must be released with service_destroy() by you.
236 * @param[in] notification The notification handle
237 * @param[out] service The service handle to launch when the notification is selected
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_set_service()
244 int ui_notification_get_service(ui_notification_h notification, service_h *service);
247 * @brief Posts the notification to display in the notification tray and the status bar
248 * @param[in] notification The notification handle
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_DB_FAILED DB failed
253 * @retval #UI_NOTIFICATION_ERROR_NO_SUCH_FILE DB No such icon file
254 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was already posted
255 * @post The posted notification can be canceled or updated.
256 * @see ui_notification_cancel()
257 * @see ui_notification_cancel_all()
258 * @see ui_notification_update()
259 * @see ui_notification_update_progress()
260 * @see ui_notification_foreach_notification_posted()
262 int ui_notification_post(ui_notification_h notification);
265 * @brief Cancels the previously posted notification.
266 * @details The previously posted notification is removed from the notification tray and the status bar.
267 * @remarks The canceled @a notification is not be released automatically, must be released with ui_notification_destroy() by you.
268 * @param[in] notification The notification handle
269 * @return 0 on success, otherwise a negative error value.
270 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
271 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
272 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was either cleared or canceled.
273 * @pre The notification must be posted before canceling it.
274 * @see ui_notification_post()
275 * @see ui_notification_cancel_all()
277 int ui_notification_cancel(ui_notification_h notification);
280 * @brief Cancels all previously posted notifications by the current application.
281 * @details All previously posted notifications are removed from the notification tray and the status bar.
282 * @remarks The notifications posted by other applications are not canceled from the notification tray and the status bar.
283 * @see ui_notification_post()
284 * @see ui_notification_cancel()
286 void ui_notification_cancel_all(void);
289 * @brief Updates the notification posted.
290 * @remarks You cannot update the notification which was cleared or canceled.
291 * @param[in] notification The notification handle
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_DB_FAILED DB failed
296 * @retval #UI_NOTIFICATION_ERROR_NO_SUCH_FILE DB No such icon file
297 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was either cleared or canceled.
298 * @pre The notification must be posted before updating it.
299 * @see ui_notification_post()
300 * @see ui_notification_update_progress()
302 int ui_notification_update(ui_notification_h notification);
305 * @brief Updates the progress to the specified value
306 * @remarks You cannot update the notification which was cleared or canceled.
307 * @param[in] notification The notification handle \n
308 * It must be ongoing notification. \n
309 * If not, #UI_NOTIFICATION_ERROR_INVALID_PARAMETER will occur
310 * @param[in] type The progress type
311 * @param[in] value The value of the progress \n
312 * The @a value must be greater than or equal to zero. \n
313 * if @a type is #UI_NOTIFICATION_PROGRESS_TYPE_SIZE, it must be in bytes. \n
314 * If @a type is #UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE, It must be a floating-point value between 0.0 and 1.0.
315 * @return 0 on success, otherwise a negative error value.
316 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
317 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
318 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was canceled.
319 * @pre The notification must be posted before updating the progress to the specified value
320 * @see ui_notification_create()
321 * @see ui_notification_post()
322 * @see ui_notification_update()
323 * @see #ui_notification_progress_type_e
325 int ui_notification_update_progress(ui_notification_h notification, ui_notification_progress_type_e type, double value);
328 * @brief Retrieves all posted notifications.
329 * @details This function calls ui_notification_cb() once for each notification which was posted and is being shown. \n
330 * If ui_notification_cb() callback function returns false, then iteration will be finished.
332 * @param [in] ongoing A boolean value that sets whether the type is an ongoing notification.
333 * @param [in] callback The iteration callback function
334 * @param [in] user_data The user data to be passed to the callback function
335 * @return 0 on success, otherwise a negative error value.
336 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
337 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
338 * @post This function invokes ui_notification_cb().
339 * @see ui_notification_cb()
341 int ui_notification_foreach_notification_posted(bool ongoing, ui_notification_cb callback, void *user_data);
344 * @brief Creates and returns a copy of the given notification handle.
346 * @remarks A newly created notification handle should be destroyed by calling ui_notification_destroy() if it is no longer needed.
348 * @param [out] clone If successful, a newly created notification handle will be returned.
349 * @param [in] service The notification handle
350 * @return 0 on success, otherwise a negative error value.
351 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
352 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
353 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
354 * @see ui_notification_create()
355 * @see ui_notification_destroy()
357 int ui_notification_clone(ui_notification_h *clone, ui_notification_h notification);
368 #endif /* __TIZEN_APPFW_UI_NOTIFICATION_H__ */