summaryrefslogtreecommitdiff
path: root/include/app_ui_notification.h
blob: ba17898eee1987eebc5073842092af7bfe650f73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
/*
 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
 *
 * Licensed under the Apache License, Version 2.0 (the License);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#ifndef __TIZEN_APPFW_UI_NOTIFICATION_H__
#define __TIZEN_APPFW_UI_NOTIFICATION_H__

#include <tizen.h>
#include <time.h>
#include <app_service.h>

#ifdef __cplusplus
extern "C"
{
#endif

 /**
 * @addtogroup CAPI_UI_NOTIFICATION_MODULE
 * @{
 */

/**
 * @brief Notification handle.
 */
typedef struct ui_notification_s *ui_notification_h;

/**
 * @brief Enumerations of error code for notification.
 */
typedef enum {
	UI_NOTIFICATION_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
	UI_NOTIFICATION_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
	UI_NOTIFICATION_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
	UI_NOTIFICATION_ERROR_DB_FAILED = TIZEN_ERROR_APPLICATION_CLASS | 0x31, /**< DB operation failed */
	UI_NOTIFICATION_ERROR_NO_SUCH_FILE = TIZEN_ERROR_NO_SUCH_FILE, /**< No such file */
	UI_NOTIFICATION_ERROR_INVALID_STATE = TIZEN_ERROR_APPLICATION_CLASS | 0x32, /**< Invalid state */
} ui_notification_error_e;

/**
 * @brief Enumeration of progress type for ongoing notification
 */
typedef enum {
	UI_NOTIFICATION_PROGRESS_TYPE_SIZE, /**< Size in bytes */
	UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE, /**< Percentage (between 0.0 and 1.0) */
} ui_notification_progress_type_e;

/**
* @brief Called to retrieve the notifications posted.
* @remarks You should not free @a notification returned by this function.
* @param[in] notification The notification handle
* @param[in] user_data The user data passed from the foreach function
* @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop.
* @pre ui_notification_foreach_notification_posted() will invoke this callback.
* @see ui_notification_foreach_notification_posted()
* @see ui_notification_clone()
*/
typedef bool (*ui_notification_cb)(ui_notification_h notification, void *user_data);

/**
 * @brief Creates a notification handle.
 * @remarks The @a notification must be released with ui_notification_destroy() by you.
 * @param[in] ongoing A boolean value that sets whether this is an ongoing notification.
 * @param[out] notification A UI notification handle to be newly created on success
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_destroy()
 */
int ui_notification_create(bool ongoing, ui_notification_h *notification);

/**
 * @brief Destroys the notification handle and releases all its resources.
 * @param[in] notification The notification handle
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @see ui_notification_create()
 */
int ui_notification_destroy(ui_notification_h notification);

/**
 * @brief Checks whether the notification is ongoing or not
 * @param[in] notification The notification handle
 * @param[out] ongoing A boolean value that sets whether this is an ongoing notification.
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @see ui_notification_create()
 */
int ui_notification_is_ongoing(ui_notification_h notification, bool *ongoing);

/**
 * @brief Sets the full path of the icon image to display in the notification.
 * @remarks The @a path should be the absolute path. If the icon is not set, the icon of the application will be displayed. \n
 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
 * @param[in] notification The notification handle
 * @param[in] path The absolute path to the specified icon \n
 *     If the @a path is NULL, it clears the previous value.
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_get_icon()
 */
int ui_notification_set_icon(ui_notification_h notification, const char *path);

/**
 * @brief Gets the absolute path to the icon to display in the notification.
 * @remarks The @a path must be released with free() by you.
 * @param[in] notification The notification handle
 * @param[out] path The absolute path to the icon
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_set_icon()
 */
int ui_notification_get_icon(ui_notification_h notification, char **path);

/**
 * @brief Sets the time that the notification occurred.
 * @remarks This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
 * @param[in] notification The notification handle
 * @param[in] time The time that the notification occurred \n
 *     If the @a time is NULL, it clears the previous value.
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_get_time()
 */
int ui_notification_set_time(ui_notification_h notification, struct tm *time);

/**
 * @brief Gets the time that the notification occured.
 * @param[in] notification The notification handle
 * @param[out] time The time that the notification occured
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_set_time()
 */
int ui_notification_get_time(ui_notification_h notification, struct tm **time);

/**
 * @brief Sets the title to display in the notification.
 * @remarks If the title is not set, the name of the application will be displayed. \n
 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
 * @param[in] notification The notification handle
 * @param[in] title The title to display in the notification \n
 *     If the @a title is NULL, it clears the previous value.
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_get_title()
 */
int ui_notification_set_title(ui_notification_h notification, const char *title);

/**
 * @brief Gets the title to display in the notification.
 * @remarks The @a title must be released with free() by you.
 * @param[in] notification The notification handle
 * @param[out] title The title to display in the notification
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_set_title()
 */
int ui_notification_get_title(ui_notification_h notification, char **title);

/**
 * @brief Sets the content to display in the notification
 * @remarks This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
 * @param[in] notification The notification handle
 * @param[in] content The content to display in the notification \n
 *     If the @a content is NULL, it clears the previous value.
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_get_content()
 */
int ui_notification_set_content(ui_notification_h notification, const char *content);

/**
 * @brief Gets the content to display in the notification
 * @remarks The @a content must be released with free() by you.
 * @param[in] notification The notification handle
 * @param[out] content The content to display in the notification
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_set_content()
 */
int ui_notification_get_content(ui_notification_h notification, char **content);

/**
 * @brief Sets the path of sound file to play when the notification is shown.
 * @remarks The @a path should be the absolute path. \n
 * The sound file is only supported wave file format. \n
 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
 * @param[in] notification The notification handle
 * @param[in] path The path of sound file to play when the notification is shown \n
 *     If the @a path is NULL, it clears the previous value.
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_get_sound()
 */
int ui_notification_set_sound(ui_notification_h notification, const char *path);

/**
 * @brief Gets the path of sound file to play when the notification is shown.
 * @remarks The @a path must be released with free() by you.
 * @param[in] notification The notification handle
 * @param[out] path The path of sound file to play when the notification is shown \n
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_set_sound()
 */
int ui_notification_get_sound(ui_notification_h notification, char **path);

/**
 * @brief Sets whether to use vibration when the notification is shown.
 * @remarks This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
 * @param[in] notification The notification handle
 * @param[in] value A boolean value that sets whether to use vibration.
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_get_vibration()
 */
int ui_notification_set_vibration(ui_notification_h notification, bool value);

/**
 * @brief Gets whether to use vibration when the notification is shown.
 * @param[in] notification The notification handle
 * @param[out] value A boolean value that sets whether to use vibration.
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_set_vibration()
 */
int ui_notification_get_vibration(ui_notification_h notification, bool *value);

/**
 * @brief Sets the service to launch when the notification is selected from the notification tray.
 * @details When the notification is selected from the notification tray, the application which is described by the specified service is launched. \n
 * If you want to launch the current application, use the explicit launch of the @ref CAPI_SERVICE_MODULE API
 * @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
 * This function should be called before posting or updating the notification (see ui_notification_post(), ui_notification_update()).
 * @param[in] notification The notification handle
 * @param[in] service The service handle to launch when the notification is selected \n
 *     If the @a service is NULL, it clears the previous value.
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_get_service()
 * @see service_create()
 */
int ui_notification_set_service(ui_notification_h notification, service_h service);

/**
 * @brief Gets the service to launch when the notification is selected from the notification tray
 * @remarks The @a service must be released with service_destroy() by you.
 * @param[in] notification The notification handle
 * @param[out] service The service handle to launch when the notification is selected
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_set_service()
 */
int ui_notification_get_service(ui_notification_h notification, service_h *service);

/**
 * @brief Posts the notification to display in the notification tray and the status bar
 * @param[in] notification The notification handle
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_DB_FAILED DB failed
 * @retval #UI_NOTIFICATION_ERROR_NO_SUCH_FILE DB No such icon file
 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was already posted
 * @post The posted notification can be canceled or updated.
 * @see ui_notification_cancel()
 * @see ui_notification_cancel_all()
 * @see ui_notification_update()
 * @see ui_notification_update_progress()
 * @see ui_notification_foreach_notification_posted()
 */
int ui_notification_post(ui_notification_h notification);

/**
 * @brief Cancels the previously posted notification.
 * @details The previously posted notification is removed from the notification tray and the status bar.
 * @remarks The canceled @a notification is not be released automatically, must be released with ui_notification_destroy() by you.
 * @param[in] notification The notification handle
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was either cleared or canceled.
 * @pre The notification must be posted before canceling it.
 * @see ui_notification_post()
 * @see ui_notification_cancel_all()
 */
int ui_notification_cancel(ui_notification_h notification);

/**
 * @brief Cancels all previously posted notifications by the current application.
 * @details All previously posted notifications are removed from the notification tray and the status bar.
 * @remarks The notifications posted by other applications are not canceled from the notification tray and the status bar.
 * @see ui_notification_post()
 * @see ui_notification_cancel()
 */
void ui_notification_cancel_all(void);

/**
 * @brief Cancels selected type of previously posted notifications by the current application.
 * @details Selected type of previously posted notifications are removed from the notification tray and the status bar.
 * @remarks The notifications posted by other applications are not cancelled from the notification tray and the status bar.
 * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel.
 * @see ui_notification_post()
 * @see ui_notification_cancel()
 * @see ui_notification_cancel_all()
 */
void ui_notification_cancel_all_by_type(bool ongoing);

/**
 * @brief Cancels selected type of previously posted notifications by the given application.
 * @details Selected type of previously posted notifications are removed from the notification tray and the status bar.
 * @remark This function is @b deprecated. Use app_manager_app_context_cb() instead.
 * @param[in] package The package name of the application to calcel the posted notifications.
 * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel.
 * @see ui_notification_post()
 * @see ui_notification_cancel()
 * @see ui_notification_cancel_all()
 */
void ui_notification_cancel_all_by_package(const char *package, bool ongoing);

/**
 * @brief Cancels selected type of previously posted notifications by the given application ID.
 * @details Selected type of previously posted notifications are removed from the notification tray and the status bar.
 * @param[in] id The ID of the application to calcel the posted notifications.
 * @param[in] ongoing A boolean value that indicates whether the notification type is ongoing to cancel.
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @see ui_notification_post()
 * @see ui_notification_cancel()
 * @see ui_notification_cancel_all()
 */
int ui_notification_cancel_all_by_app_id(const char *app_id, bool ongoing);

/**
 * @brief Updates the notification posted.
 * @remarks You cannot update the notification which was cleared or canceled.
 * @param[in] notification The notification handle
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_DB_FAILED DB failed
 * @retval #UI_NOTIFICATION_ERROR_NO_SUCH_FILE DB No such icon file
 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was either cleared or canceled.
 * @pre The notification must be posted before updating it.
 * @see ui_notification_post()
 * @see ui_notification_update_progress()
 */
int ui_notification_update(ui_notification_h notification);

/**
 * @brief Updates the progress to the specified value
 * @remarks You cannot update the notification which was cleared or canceled.
 * @param[in] notification The notification handle \n
 *	It must be ongoing notification. \n
 *	If not, #UI_NOTIFICATION_ERROR_INVALID_PARAMETER will occur
 * @param[in] type The progress type
 * @param[in] value The value of the progress \n
 *    The @a value must be greater than or equal to zero. \n
 *    if @a type is #UI_NOTIFICATION_PROGRESS_TYPE_SIZE, it must be in bytes. \n
 *    If @a type is #UI_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE, It must be a floating-point value between 0.0 and 1.0.
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_INVALID_STATE The notification was not posted or the notification was canceled.
 * @pre The notification must be posted before updating the progress to the specified value
 * @see ui_notification_create()
 * @see ui_notification_post()
 * @see ui_notification_update()
 * @see #ui_notification_progress_type_e
 */
int ui_notification_update_progress(ui_notification_h notification, ui_notification_progress_type_e type, double value);

/**
 * @brief Retrieves all posted notifications.
 * @details This function calls ui_notification_cb() once for each notification which was posted and is being shown. \n
 * If ui_notification_cb() callback function returns false, then iteration will be finished.
 *
 * @param [in] ongoing A boolean value that sets whether the type is an ongoing notification.
 * @param [in] callback The iteration callback function
 * @param [in] user_data The user data to be passed to the callback function
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @post This function invokes ui_notification_cb().
 * @see ui_notification_cb()
 */
int ui_notification_foreach_notification_posted(bool ongoing, ui_notification_cb callback, void *user_data);

/**
 * @brief Creates and returns a copy of the given notification handle.
 *
 * @remarks A newly created notification handle should be destroyed by calling ui_notification_destroy() if it is no longer needed.
 *
 * @param [out] clone If successful, a newly created notification handle will be returned.
 * @param [in] service The notification handle
 * @return 0 on success, otherwise a negative error value.
 * @retval #UI_NOTIFICATION_ERROR_NONE Successful
 * @retval #UI_NOTIFICATION_ERROR_INVALID_PARAMETER Invalid parameter
 * @retval #UI_NOTIFICATION_ERROR_OUT_OF_MEMORY Out of memory
 * @see ui_notification_create()
 * @see ui_notification_destroy()
 */
int ui_notification_clone(ui_notification_h *clone, ui_notification_h notification);


/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* __TIZEN_APPFW_UI_NOTIFICATION_H__ */