Add alarm update API
[platform/core/api/alarm.git] / include / app_alarm.h
1 /*
2  * Copyright (c) 2011 - 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17
18 #ifndef __TIZEN_APPFW_ALARM_H__
19 #define __TIZEN_APPFW_ALARM_H__
20
21 #include <tizen.h>
22 #include <time.h>
23 #include <app_control.h>
24 #include <notification.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /**
31  * @file app_alarm.h
32  */
33
34 /**
35  * @addtogroup CAPI_ALARM_MODULE
36  * @{
37  */
38
39 /**
40  * @brief Definition to app_control extra data : the ID of the alarm registered.
41  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
42  */
43 #define APP_CONTROL_DATA_ALARM_ID "http://tizen.org/appcontrol/data/alarm_id"
44
45 /**
46  * @brief Enumeration for Alarm Error.
47  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
48  */
49 typedef enum {
50         ALARM_ERROR_NONE = TIZEN_ERROR_NONE,    /**< Successful */
51         ALARM_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,  /**< Invalid parameter */
52         ALARM_ERROR_INVALID_TIME = TIZEN_ERROR_APPLICATION | 0x05,      /**< Invalid time */
53         ALARM_ERROR_INVALID_DATE = TIZEN_ERROR_APPLICATION | 0x06,      /**< Invalid date */
54         ALARM_ERROR_CONNECTION_FAIL = TIZEN_ERROR_APPLICATION | 0x07,   /**< The alarm service connection failed */
55         ALARM_ERROR_NOT_PERMITTED_APP = TIZEN_ERROR_APPLICATION | 0x08, /**< Application is not permitted. (Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif) */
56         ALARM_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,  /**< Out of memory */
57         ALARM_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED   /**< Permission denied */
58 } alarm_error_e;
59
60
61 /**
62  * @brief Enumeration for Alarm Week Flag, the days of the week.
63  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
64  */
65 typedef enum {
66         ALARM_WEEK_FLAG_SUNDAY = 0x01,  /**< Sunday */
67         ALARM_WEEK_FLAG_MONDAY = 0x02,  /**< Monday */
68         ALARM_WEEK_FLAG_TUESDAY = 0x04, /**< Tuesday */
69         ALARM_WEEK_FLAG_WEDNESDAY = 0x08,       /**< Wednesday */
70         ALARM_WEEK_FLAG_THURSDAY = 0x10,        /**< Thursday */
71         ALARM_WEEK_FLAG_FRIDAY = 0x20,  /**< Friday */
72         ALARM_WEEK_FLAG_SATURDAY = 0x40 /**< Saturday */
73 } alarm_week_flag_e;
74
75
76 /**
77  * @brief Called once for each scheduled alarm to get the alarm ID.
78  *
79  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
80  * @param[in] alarm_id The alarm ID returned when the alarm is scheduled
81  * @param[in] user_data The user data passed from the foreach function
82  * @return @c true to continue with the next iteration of the loop,
83  *         otherwise @c false to break out of the loop
84  * @pre   alarm_foreach_registered_alarm() will invoke this callback to get all the registered alarm IDs.
85  * @see   alarm_foreach_registered_alarm()
86  */
87 typedef bool (*alarm_registered_alarm_cb)(int alarm_id, void *user_data);
88
89
90 /**
91  * @brief Sets an alarm to be triggered after a specific time.
92  * @details The alarm will first go off @a delay seconds later and then will go off every certain amount of time defined using @a period seconds. To cancel the alarm, call alarm_cancel() with @a alarm_id.
93  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
94  * @privlevel public
95  * @privilege %http://tizen.org/privilege/alarm.set
96  * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
97  *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
98  *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
99  *          Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, this api does not support exact period and delay for minimizing the wakeups of the device. The system can adjust when the alarm expires.
100  *          If you want to trigger an alarm exactly, see @see alarm_schedule_once_after_delay()
101  *          Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif If @a app_control is specified with service-application, the application is only allowed to run on which has Background Category.
102  *          Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif If the appid of @a app_control is not specified, this api is not allowed. In other words, the explicit @a app_control is only allowed.
103  *
104  * @param[in] app_control The destination app_control to perform a specific task when the alarm is triggered
105  * @param[in] delay The amount of time before the first execution (in seconds). Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, Although this is inexact, the alarm will not fire before this time
106  * @param[in] period The amount of time between subsequent alarms (in seconds). Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, This value does not guarantee the accuracy. The actual interval is calculated by the OS. The minimum value is 600sec
107  * @param[out] alarm_id The alarm ID that uniquely identifies an alarm
108  * @return @c 0 on success,
109  *         otherwise a negative error value
110  * @retval #ALARM_ERROR_NONE Successful
111  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
112  * @retval #ALARM_ERROR_INVALID_TIME Triggered time is invalid
113  * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
114  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
115  * @retval #ALARM_ERROR_NOT_PERMITTED_APP @a app_control is not permitted
116  * @see alarm_cancel()
117  * @see alarm_cancel_all()
118  * @see alarm_get_scheduled_date()
119  * @see alarm_get_scheduled_period()
120  * @see alarm_schedule_once_after_delay()
121  */
122 int alarm_schedule_after_delay(app_control_h app_control, int delay, int period, int *alarm_id);
123
124
125 /**
126  * @deprecated Deprecated since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif. [Use alarm_schedule_once_at_date() instead]
127  * @brief Sets an alarm to be triggered at a specific time.
128  * @details The @a date describes the time of the first occurrence.
129  *          If @a period is bigger than @c 0, the alarm will be scheduled after the @a period time.
130  *          If @a period is set to @c 0, the alarm will go off just once without repetition.
131  *          To cancel the alarm, call alarm_cancel() with @a alarm_id.
132  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
133  * @privlevel public
134  * @privilege %http://tizen.org/privilege/alarm.set
135  * @remarks If application is uninstalled after setting an alarm, the alarm is cancelled automatically.
136  *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
137  *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
138  *
139  * @param[in] app_control The destination app_control to perform specific work when the alarm is triggered
140  * @param[in] date The first active alarm time
141  * @param[in] period The amount of time between subsequent alarms(in second)
142  * @param[out] alarm_id The alarm ID that uniquely identifies an alarm
143  * @return @c 0 on success,
144  *         otherwise a negative error value
145  * @retval #ALARM_ERROR_NONE Successful
146  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
147  * @retval #ALARM_ERROR_INVALID_DATE Triggered date is invalid
148  * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
149  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
150  * @see alarm_cancel()
151  * @see alarm_cancel_all()
152  * @see alarm_get_scheduled_date()
153  * @see alarm_get_scheduled_period()
154  */
155 int alarm_schedule_at_date(app_control_h app_control, struct tm *date, int period, int *alarm_id) TIZEN_DEPRECATED_API;
156
157 /**
158  * @brief Sets an alarm to be triggered after a specific time.
159  * @details The alarm will go off @a delay seconds later. To cancel the alarm, call alarm_cancel() with @a alarm_id.
160  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
161  * @privlevel public
162  * @privilege %http://tizen.org/privilege/alarm.set
163  * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
164  *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
165  *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
166  *          If the appid of @a app_control is not specified, this api is not allowed. In other words, the explicit @a app_control is only allowed.
167  *          The @a app_control only supports UI application with this api. If @a app_control is not UI application, #ALARM_ERROR_NOT_PERMITTED_APP returned.
168  *          When the alarm is expired, Alarm Manager will turn on LCD to prohibit background jobs.
169  *
170  * @param[in] app_control The destination app_control to perform a specific task when the alarm is triggered
171  * @param[in] delay The amount of time before the execution (in seconds)
172  * @param[out] alarm_id The alarm ID that uniquely identifies an alarm
173  * @return @c 0 on success,
174  *         otherwise a negative error value
175  * @retval #ALARM_ERROR_NONE Successful
176  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
177  * @retval #ALARM_ERROR_INVALID_TIME Triggered time is invalid
178  * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
179  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
180  * @retval #ALARM_ERROR_NOT_PERMITTED_APP @a app_control is not permitted. @a app_control for UI application is only permitted.
181  * @see alarm_cancel()
182  * @see alarm_cancel_all()
183  * @see alarm_get_scheduled_date()
184  */
185 int alarm_schedule_once_after_delay(app_control_h app_control, int delay, int *alarm_id);
186
187
188 /**
189  * @brief Sets an alarm to be triggered at a specific time.
190  * @details The @a date describes the time of the first occurrence. To cancel the alarm, call alarm_cancel() with @a alarm_id.
191  * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
192  * @privlevel public
193  * @privilege %http://tizen.org/privilege/alarm.set
194  * @remarks If application is uninstalled after setting an alarm, the alarm is cancelled automatically.
195  *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
196  *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
197  *          If the appid of @a app_control is not specified, this api is not allowed. In other words, the explicit @a app_control is only allowed.
198  *          The @a app_control only supports UI application with this api. If @a app_control is not UI application, #ALARM_ERROR_NOT_PERMITTED_APP returned.
199  *          When the alarm is expired, Alarm Manager will turn on LCD to prohibit background jobs.
200  *
201  * @param[in] app_control The destination app_control to perform specific work when the alarm is triggered
202  * @param[in] date The first active alarm time
203  * @param[out] alarm_id The alarm ID that uniquely identifies an alarm
204  * @return @c 0 on success,
205  *         otherwise a negative error value
206  * @retval #ALARM_ERROR_NONE   Successful
207  * @retval #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
208  * @retval #ALARM_ERROR_INVALID_DATE Triggered date is invalid
209  * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
210  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
211  * @retval #ALARM_ERROR_NOT_PERMITTED_APP @a app_control is not permitted. @a app_control for UI application is only permitted.
212  * @see alarm_cancel()
213  * @see alarm_cancel_all()
214  * @see alarm_get_scheduled_date()
215  */
216 int alarm_schedule_once_at_date(app_control_h app_control, struct tm *date, int *alarm_id);
217
218
219 /**
220  * @brief Sets an alarm to be triggered periodically, starting at a specific time.
221  * @details The @a date describes the time of the first occurrence.
222  *          @a week_flag is the repeat value of the days of the week.
223  *          If @a week_flag is #ALARM_WEEK_FLAG_TUESDAY, the alarm will repeat every Tuesday at a specific time.
224  *          To cancel the alarm, call alarm_cancel() with @a alarm_id.
225  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
226  * @privlevel public
227  * @privilege %http://tizen.org/privilege/alarm.set
228  * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
229  *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
230  *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
231  *          Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, The @a app_control only supports UI application with this api. If @a app_control is not UI application, #ALARM_ERROR_NOT_PERMITTED_APP returned.
232  *          When the alarm is expired, Alarm Manager will turn on LCD to prohibit background jobs.
233  *          Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, If the appid of @a app_control is not specified, this api is not allowed. In other words, the explicit @a app_control is only allowed.
234  *
235  * @param[in] app_control The destination app_control to perform specific work when the alarm is triggered
236  * @param[in] date The first active alarm time
237  * @param[in] week_flag The day of the week, @a week_flag may be a combination of days, like #ALARM_WEEK_FLAG_TUESDAY | #ALARM_WEEK_FLAG_FRIDAY
238  * @param[out] alarm_id The alarm ID that uniquely identifies an alarm
239  * @return @c 0 on success,
240  *         otherwise a negative error value
241  * @retval #ALARM_ERROR_NONE Successful
242  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
243  * @retval #ALARM_ERROR_INVALID_DATE Triggered date is invalid
244  * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
245  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
246  * @retval #ALARM_ERROR_NOT_PERMITTED_APP @a app_control is not permitted. @a app_control for UI application is only permitted.
247  * @see alarm_cancel()
248  * @see alarm_cancel_all()
249  * @see alarm_get_scheduled_recurrence_week_flag()
250  * @see alarm_get_scheduled_date()
251  * @see #alarm_week_flag_e
252  */
253 int alarm_schedule_with_recurrence_week_flag(app_control_h app_control, struct tm *date, int week_flag, int *alarm_id);
254
255
256 /**
257  * @brief Gets the recurrence days of the week.
258  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
259  * @privlevel public
260  * @privilege %http://tizen.org/privilege/alarm.get
261  * @remarks If the given @a alarm_id is not obtained by using the alarm_schedule_with_recurrence_week_flag() function,
262  *          an error (error code #ALARM_ERROR_INVALID_PARAMETER) will occur because this alarm is scheduled with no recurrence.
263  *          If the operation of @a app_control is not specified, #APP_CONTROL_OPERATION_DEFAULT is used for the launch request.
264  *          If the operation of @a app_control is #APP_CONTROL_OPERATION_DEFAULT, the package information is mandatory to explicitly launch the application.
265  * @param[in] alarm_id The alarm ID returned when the alarm is scheduled
266  * @param[out] week_flag The recurrence days of the week, @a week_flag may be a combination of days, like #ALARM_WEEK_FLAG_TUESDAY | #ALARM_WEEK_FLAG_FRIDAY
267  * @return @c 0 on success,
268  *         otherwise a negative error value
269  * @retval #ALARM_ERROR_NONE Successful
270  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
271  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
272  * @see alarm_schedule_with_recurrence_week_flag()
273  * @see #alarm_week_flag_e
274  */
275 int alarm_get_scheduled_recurrence_week_flag(int alarm_id, int *week_flag);
276
277
278 /**
279  * @brief Cancels the alarm with the specific alarm ID.
280  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
281  * @privlevel public
282  * @privilege %http://tizen.org/privilege/alarm.set
283  * @param[in] alarm_id The alarm ID that is cancelled
284  * @return @c 0 on success,
285  *         otherwise a negative error value
286  * @retval #ALARM_ERROR_NONE Successful
287  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
288  * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
289  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
290  * @see alarm_schedule_at_date()
291  * @see alarm_schedule_after_delay()
292  * @see alarm_schedule_with_recurrence_week_flag()
293  * @see alarm_cancel_all()
294  */
295 int alarm_cancel(int alarm_id);
296
297
298 /**
299  * @brief Cancels all scheduled alarms that are registered by the application that calls this API.
300  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
301  * @privlevel public
302  * @privilege %http://tizen.org/privilege/alarm.set
303  * @return @c 0 on success,
304  *         otherwise a negative error value
305  * @retval #ALARM_ERROR_NONE Successful
306  * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
307  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
308  * @see alarm_schedule_at_date()
309  * @see alarm_schedule_after_delay()
310  * @see alarm_schedule_with_recurrence_week_flag()
311  * @see alarm_cancel()
312  */
313 int alarm_cancel_all(void);
314
315
316 /**
317  * @brief Retrieves the IDs of all registered alarms by invoking a callback once for each scheduled alarm.
318  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
319  * @privlevel public
320  * @privilege %http://tizen.org/privilege/alarm.get
321  * @param[in] callback The callback function to invoke
322  * @param[in] user_data The user data to be passed to the callback function
323  * @return @c 0 on success,
324  *         otherwise a negative error value
325  * @retval #ALARM_ERROR_NONE Successful
326  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
327  * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
328  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
329  * @post This function invokes alarm_registered_alarm_cb() repeatedly for each registered alarm.
330  * @see alarm_registered_alarm_cb()
331  */
332 int alarm_foreach_registered_alarm(alarm_registered_alarm_cb callback, void *user_data);
333
334
335 /**
336  * @brief Gets the scheduled time from the given alarm ID in C standard time struct.
337  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
338  * @privlevel public
339  * @privilege %http://tizen.org/privilege/alarm.get
340  * @remarks @a date is not needed by the function after the call.
341  * @param[in] alarm_id The alarm ID returned when the alarm is scheduled
342  * @param[out] date The time value of the next alarm event
343  * @return @c 0 on success,
344  *         otherwise a negative error value
345  * @retval #ALARM_ERROR_NONE Successful
346  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
347  * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
348  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
349  * @see alarm_schedule_at_date()
350  * @see alarm_schedule_after_delay()
351  * @see alarm_schedule_with_recurrence_week_flag()
352  */
353 int alarm_get_scheduled_date(int alarm_id, struct tm *date);
354
355
356 /**
357  * @brief Gets the period of time between the recurrent alarms.
358  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
359  * @privlevel public
360  * @privilege %http://tizen.org/privilege/alarm.get
361  * @remarks If the given @a alarm_id is not obtained by using the alarm_schedule_at_date() or alarm_schedule_after_delay() function,
362  *          an error (error code #ALARM_ERROR_INVALID_PARAMETER) will occur.
363  * @param[in] alarm_id The alarm ID returned when the alarm is scheduled
364  * @param[out] period The period of time between recurrent alarms in seconds
365  * @return @c 0 on success,
366  *         otherwise a negative error value
367  * @retval #ALARM_ERROR_NONE Successful
368  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
369  * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
370  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
371  * @see alarm_schedule_at_date()
372  * @see alarm_schedule_after_delay()
373  * @see alarm_schedule_with_recurrence_week_flag()
374  */
375 int alarm_get_scheduled_period(int alarm_id, int *period);
376
377
378 /**
379  * @brief Gets the current system time using C standard time struct.
380  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
381  * @param[out] date The current system time
382  * @return @c 0 on success,
383  *         otherwise a negative error value
384  * @retval #ALARM_ERROR_NONE Successful
385  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
386  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
387  */
388 int alarm_get_current_time(struct tm *date);
389
390
391 /**
392  * @brief Gets the app_control to be invoked when the alarm is triggered.
393  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
394  * @privlevel public
395  * @privilege %http://tizen.org/privilege/alarm.get
396  * @remarks The @a app_control must be released using app_control_destroy().
397  * @param[in] alarm_id The alarm ID uniquely identifies an alarm
398  * @param[out] app_control The app_control handle to launch when the alarm is triggered
399  * @return @c 0 on success,
400  *         otherwise a negative error value
401  * @retval #ALARM_ERROR_NONE Successful
402  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
403  * @retval #ALARM_ERROR_OUT_OF_MEMORY Out of memory
404  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
405  * @see alarm_schedule_at_date()
406  * @see alarm_schedule_after_delay()
407  * @see alarm_schedule_with_recurrence_week_flag()
408  */
409 int alarm_get_app_control(int alarm_id, app_control_h *app_control);
410
411
412 /**
413  * @brief Sets global flag in the alarm.
414  * @details Sets @a global flag to set/unset alarm globally.
415  * @since_tizen 3.0
416  * @privlevel public
417  * @privilege %http://tizen.org/privilege/alarm.set
418  * @remarks The @a alarm_id must be id of alarm which will launch global application.
419  *          The function returns an error (error code #ALARM_ERROR_NOT_PERMITTED_APP) if it is not.
420  *          Note that the application which is launched by global alarm runs in the user session that is logged in currently.
421  *          It doesn't run in the session for the user who registers the global alarm.
422  *          So, if the application uses application's private data for each user to handling the app_control for the alarm, it might not show proper data to the user.
423  *          Therefore, We recommend to contain all the data for the alarm to the app_control handle for the global alarm.
424  *          Then, the launched application would be able to use the data to show proper alarm UX to the user.
425  * @param[in] alarm_id The alarm ID uniquely identifies an alarm
426  * @param[in] global The global flag to set/unset alarm globally
427  * @return @c 0 on success,
428  *         otherwise a negative error value
429  * @retval #ALARM_ERROR_NONE Successful
430  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
431  * @retval #ALARM_ERROR_NOT_PERMITTED_APP @a alarm_id is not permitted
432  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
433  * @see alarm_schedule_at_date()
434  * @see alarm_schedule_after_delay()
435  * @see alarm_schedule_with_recurrence_week_flag()
436  */
437 int alarm_set_global(int alarm_id, bool global);
438
439
440 /**
441  * @brief Gets whether the alarm will launch global application or not.
442  * @since_tizen 3.0
443  * @privlevel public
444  * @privilege %http://tizen.org/privilege/alarm.get
445  * @param[in] alarm_id The alarm ID uniquely identifies an alarm
446  * @param[out] global Whether the alarm will launch global application or not
447  * @return @c 0 on success,
448  *         otherwise a negative error value
449  * @retval #ALARM_ERROR_NONE Successful
450  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
451  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
452  * @see alarm_set_global()
453  */
454 int alarm_get_global(int alarm_id, bool *global);
455
456
457 /**
458  * @brief Sets a notification alarm to be triggered at a specific time.
459  * @details The @a date describes the time of the alarm occurrence.
460  *          To cancel the alarm, call alarm_cancel() with @a alarm_id.
461  * @since_tizen 3.0
462  * @privlevel public
463  * @privilege %http://tizen.org/privilege/alarm.set
464  * @privilege %http://tizen.org/privilege/notification
465  * @remarks If application is uninstalled after setting an alarm, the alarm is cancelled automatically.
466  *          When the alarm goes off, Alarm Manager will turn on LCD to prohibit background jobs.
467  *
468  * @param[in] noti The notification to be posted when the alarm is triggered
469  * @param[in] date The active alarm time
470  * @param[out] alarm_id The ID which uniquely identifies the scheduled alarm
471  * @return @c 0 on success,
472  *         otherwise a negative error value
473  * @retval  #ALARM_ERROR_NONE   Successful
474  * @retval  #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
475  * @retval  #ALARM_ERROR_INVALID_DATE Triggered date is invalid
476  * @retval  #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
477  * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
478  * @see alarm_cancel()
479  * @see alarm_cancel_all()
480  * @see alarm_get_scheduled_date()
481  */
482 int alarm_schedule_noti_once_at_date(notification_h noti, struct tm *date, int *alarm_id);
483
484 /**
485  * @brief Sets a notification alarm to be triggered after a specific delay.
486  * @details The alarm will first go off after @a delay seconds.
487  *          The alarm will then go off every period seconds until canceled.
488  *          To cancel the alarm, call alarm_cancel() with @a alarm_id.
489  * @since_tizen 3.0
490  * @privlevel public
491  * @privilege %http://tizen.org/privilege/alarm.set
492  * @privilege %http://tizen.org/privilege/notification
493  * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
494  *          This function is a minimally intrusive way to trigger alarms when precision is not important.
495  *          The system will adjust the @a delay and @a period requests to suit internal needs; the requests
496  *          will be treated as minimum values. Note that @a period cannot be less than 600 seconds, if
497  *          a smaller request is supplied it will be silently adjusted to a request of 600.
498  *          When the alarm goes off, Alarm Manager will turn on LCD to prohibit background jobs.
499  *
500  * @param[in] noti The notification to be posted when the alarm is triggered
501  * @param[in] delay The amount of time before the first execution (in seconds).
502  * @param[in] period The amount of time between subsequent alarms (in seconds).
503  * @param[out] alarm_id The ID which uniquely identifies the scheduled alarm
504  * @return @c 0 on success,
505  *         otherwise a negative error value
506  * @retval  #ALARM_ERROR_NONE Successful
507  * @retval  #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
508  * @retval  #ALARM_ERROR_INVALID_TIME Triggered time is invalid
509  * @retval  #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
510  * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
511  * @see alarm_cancel()
512  * @see alarm_cancel_all()
513  * @see alarm_get_scheduled_date()
514  * @see alarm_get_scheduled_period()
515  * @see alarm_schedule_noti_once_after_delay()
516  */
517 int alarm_schedule_noti_after_delay(notification_h noti, int delay, int period, int *alarm_id);
518
519 /**
520  * @brief Sets a notification alarm to be triggered after a specific delay.
521  * @details The alarm will go off @a delay seconds later.
522  *          To cancel the alarm, call alarm_cancel() with @a alarm_id.
523  * @since_tizen 3.0
524  * @privlevel public
525  * @privilege %http://tizen.org/privilege/alarm.set
526  * @privilege %http://tizen.org/privilege/notification
527  * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
528  *          When the alarm goes off, Alarm Manager will turn on LCD to prohibit background jobs.
529  *
530  * @param[in] noti The notification to be posted when the alarm is triggered
531  * @param[in] delay The amount of time before the execution (in seconds)
532  * @param[out] alarm_id The ID which uniquely identifies the scheduled alarm
533  * @return @c 0 on success,
534  *         otherwise a negative error value
535  * @retval  #ALARM_ERROR_NONE Successful
536  * @retval  #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
537  * @retval  #ALARM_ERROR_INVALID_TIME Triggered time is invalid
538  * @retval  #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
539  * @retval  #ALARM_ERROR_PERMISSION_DENIED Permission denied
540  * @see alarm_cancel()
541  * @see alarm_cancel_all()
542  * @see alarm_get_scheduled_date()
543  */
544 int alarm_schedule_noti_once_after_delay(notification_h noti, int delay, int *alarm_id);
545
546 /**
547  * @brief Sets a notification to be triggered periodically, starting at a specific time.
548  * @details The @a date describes the time of the first occurrence.
549  *              @a week_flag describes the day(s) of the week when the notification recurs.
550  *              If @a week_flag is #ALARM_WEEK_FLAG_TUESDAY, the alarm will repeat every Tuesday at a specific time.
551  *              If @a week_flag is less than or equal to zero, the alarm is not repeated.
552  *              To cancel the alarm, call alarm_cancel() with @a alarm_id.
553  * @since_tizen 3.0
554  * @privlevel public
555  * @privilege %http://tizen.org/privilege/alarm.set
556  * @privilege %http://tizen.org/privilege/notification
557  * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
558  *
559  * @param[in] noti The notification to be posted when the alarm is triggered
560  * @param[in] date The first active alarm time
561  * @param[in] week_flag The day of the week the notification recurs. @a week_flag may be a combination of days, like #ALARM_WEEK_FLAG_TUESDAY | #ALARM_WEEK_FLAG_FRIDAY
562  * @param[out] alarm_id The ID which uniquely identifies the scheduled alarm
563  * @return @c 0 on success,
564  *         otherwise a negative error value
565  * @retval #ALARM_ERROR_NONE Successful
566  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
567  * @retval #ALARM_ERROR_INVALID_DATE Triggered date is invalid
568  * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
569  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
570  * @see alarm_cancel()
571  * @see alarm_cancel_all()
572  * @see alarm_get_scheduled_recurrence_week_flag()
573  * @see alarm_get_scheduled_date()
574  * @see #alarm_week_flag_e
575  */
576 int alarm_schedule_noti_with_recurrence_week_flag(notification_h noti, struct tm *date, int week_flag, int *alarm_id);
577
578 /**
579  * @brief Gets the notification to be posted when an alarm is triggered.
580  * @since_tizen 3.0
581  * @privlevel public
582  * @privilege %http://tizen.org/privilege/alarm.get
583  * @remarks @a noti must be released using notification_free().
584  *
585  * @param[in] alarm_id The ID which uniquely identifies a scheduled alarm
586  * @param[out] noti The notification to be posted when the alarm is triggered
587  * @return @c 0 on success,
588  *         otherwise a negative error value
589  * @retval #ALARM_ERROR_NONE Successful
590  * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
591  * @retval #ALARM_ERROR_OUT_OF_MEMORY Out of memory
592  * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
593  * @see alarm_schedule_noti_once_at_date()
594  * @see alarm_schedule_noti_after_delay()
595  * @see alarm_schedule_noti_once_after_delay()
596  * @see alarm_schedule_noti_with_recurrence_week_flag()
597  */
598 int alarm_get_notification(int alarm_id, notification_h *noti);
599
600 /**
601  * @brief Updates the delay of the registered alarm.
602  * @details The @a delay is the time (in seconds) before the alarm's first setting off.
603  *          The delay is an exact value, see alarm_schedule_once_after_delay() for details.
604  *          This function can be called for any alarm.
605  *          If the delay was set before, it will be overwritten. If it was not, it will be set.
606  * @since_tizen 4.0
607  * @privlevel public
608  * @privilege %http://tizen.org/privilege/alarm.set
609  * @remarks This function can be called only for alarms whose app control launches an UI application.
610  *          If this condition is not met, #ALARM_ERROR_NOT_PERMITTED_APP is returned.
611  * @param[in] alarm_id  The ID which uniquely identifies the scheduled alarm
612  * @param[in] delay     The amount of time before the first execution (in seconds).
613  * @return @c 0 on success,
614  *         otherwise a negative error value
615  * @retval #ALARM_ERROR_NONE               Successful
616  * @retval #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
617  * @retval #ALARM_ERROR_CONNECTION_FAIL    Failed to connect to an alarm server
618  * @retval #ALARM_ERROR_OUT_OF_MEMORY      Out of memory
619  * @retval #ALARM_ERROR_PERMISSION_DENIED  Permission denied
620  * @retval #ALARM_ERROR_NOT_PERMITTED_APP  App control does not launch an UI application
621  */
622 int alarm_update_delay(int alarm_id, int delay);
623
624 /**
625  * @brief Updates the date of the registered alarm.
626  * @details The @a date describes the date on which the alarm is set off for the first time.
627  *          This function can be called for any alarm.
628  *          If the date was set before, it will be overwritten. If it was not, it will be set.
629  * @since_tizen 4.0
630  * @privlevel public
631  * @privilege %http://tizen.org/privilege/alarm.set
632  * @remarks This function can be called only for alarms whose app control launches an UI application.
633  *          If this condition is not met, #ALARM_ERROR_NOT_PERMITTED_APP is returned.
634  * @param[in] alarm_id  The ID which uniquely identifies the scheduled alarm
635  * @param[in] date      The time value of the next alarm event
636  * @return @c 0 on success,
637  *         otherwise a negative error value
638  * @retval #ALARM_ERROR_NONE               Successful
639  * @retval #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
640  * @retval #ALARM_ERROR_INVALID_TIME       Triggered time is invalid
641  * @retval #ALARM_ERROR_INVALID_DATE       Triggered time is invalid
642  * @retval #ALARM_ERROR_CONNECTION_FAIL    Failed to connect to an alarm server
643  * @retval #ALARM_ERROR_OUT_OF_MEMORY      Out of memory
644  * @retval #ALARM_ERROR_PERMISSION_DENIED  Permission denied
645  * @retval #ALARM_ERROR_NOT_PERMITTED_APP  App control does not launch an UI application
646  */
647 int alarm_update_date(int alarm_id, struct tm *date);
648
649 /**
650  * @brief Updates the period of the registered alarm.
651  * @details The alarm will then go off every @a period seconds until canceled.
652  *          This function can be called for any alarm.
653  *          If the week recurrence flag was set before, it will be removed and the period will be set.
654  *          If the period was set before, it will be overwritten. If it was not, it will be set.
655  *          If the @a period argument is 0 and the period was previously set,
656  *          the period attribute will be cleared and the alarm will be changed to one-time.
657  *          If the @a period argument is 0 and the period was not set,
658  *          or the week recurrence flag was set, the alarm will be unchanged.
659  * @since_tizen 4.0
660  * @privlevel public
661  * @privilege %http://tizen.org/privilege/alarm.set
662  * @param[in] alarm_id  The ID which uniquely identifies the scheduled alarm
663  * @param[in] period    The amount of time between subsequent alarms (in seconds).
664  *                      Since @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif, this
665  *                      value does not guarantee the accuracy. The actual interval
666  *                      is calculated by the OS. The minimum value is 600sec.
667  * @return @c 0 on success,
668  *         otherwise a negative error value
669  * @retval #ALARM_ERROR_NONE               Successful
670  * @retval #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
671  * @retval #ALARM_ERROR_CONNECTION_FAIL    Failed to connect to an alarm server
672  * @retval #ALARM_ERROR_OUT_OF_MEMORY      Out of memory
673  * @retval #ALARM_ERROR_PERMISSION_DENIED  Permission denied
674  */
675 int alarm_update_period(int alarm_id, int period);
676
677 /**
678  * @brief Updates the week recurrence flag of the registered alarm.
679  * @details @a week_flag is the repeat value of the days of the week.
680  *          For example, if @a week_flag is #ALARM_WEEK_FLAG_TUESDAY, the alarm will repeat every
681  *          Tuesday at a specific time.
682  *          This function can be called for any alarm.
683  *          If the period was set before, it will be removed and the week recurrence flag will be set.
684  *          If the week recurrence flag was set before, it will be overwritten. If it was not, it will be set.
685  *          If the @a week_flag argument is 0 and the flag was previously set,
686  *          the flag attribute will be cleared and the alarm will be changed to one-time.
687  *          If the @a week_flag argument is 0 and the flag was not set,
688  *          or the period was set, the alarm will be unchanged.
689  * @since_tizen 4.0
690  * @privlevel public
691  * @privilege %http://tizen.org/privilege/alarm.set
692  * @remarks This function can be called only for alarms whose app control launches an UI application.
693  *          If this condition is not met, #ALARM_ERROR_NOT_PERMITTED_APP is returned.
694  * @param[in] alarm_id   The ID which uniquely identifies the scheduled alarm
695  * @param[in] week_flag  The day of the week, @a week_flag may be a combination
696  *                       of days, like #ALARM_WEEK_FLAG_TUESDAY | #ALARM_WEEK_FLAG_FRIDAY
697  * @return @c 0 on success,
698  *         otherwise a negative error value
699  * @retval #ALARM_ERROR_NONE               Successful
700  * @retval #ALARM_ERROR_INVALID_PARAMETER  Invalid parameter
701  * @retval #ALARM_ERROR_CONNECTION_FAIL    Failed to connect to an alarm server
702  * @retval #ALARM_ERROR_OUT_OF_MEMORY      Out of memory
703  * @retval #ALARM_ERROR_PERMISSION_DENIED  Permission denied
704  * @retval #ALARM_ERROR_NOT_PERMITTED_APP  App control does not launch an UI application
705  */
706 int alarm_update_week_flag(int alarm_id, int week_flag);
707
708 /**
709  * @}
710  */
711
712 #ifdef __cplusplus
713 }
714 #endif
715
716 #endif /* __TIZEN_APPFW_ALARM_H__ */
717