#include <tizen.h>
#include <time.h>
#include <app_control.h>
+#include <notification.h>
#ifdef __cplusplus
extern "C" {
*/
int alarm_get_global(int alarm_id, bool *global);
+
+/**
+ * @brief Sets a notification alarm to be triggered at a specific time.
+ * @details The @a date describes the time of the alarm occurrence.
+ * To cancel the alarm, call alarm_cancel() with @a alarm_id.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/alarm.set
+ * @privilege %http://tizen.org/privilege/notification
+ * @remarks If application is uninstalled after setting an alarm, the alarm is cancelled automatically.
+ * When the alarm goes off, Alarm Manager will turn on LCD to prohibit background jobs.
+ *
+ * @param[in] noti The notification to be posted when the alarm is triggered
+ * @param[in] date The active alarm time
+ * @param[out] alarm_id The ID which uniquely identifies the scheduled alarm
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ALARM_ERROR_INVALID_DATE Triggered date is invalid
+ * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_cancel()
+ * @see alarm_cancel_all()
+ * @see alarm_get_scheduled_date()
+ */
+int alarm_schedule_noti_once_at_date(notification_h noti, struct tm *date, int *alarm_id);
+
+/**
+ * @brief Sets a notification alarm to be triggered after a specific delay.
+ * @details The alarm will first go off after @a delay seconds.
+ * The alarm will then go off every @period seconds until canceled.
+ * To cancel the alarm, call alarm_cancel() with @a alarm_id.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/alarm.set
+ * @privilege %http://tizen.org/privilege/notification
+ * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
+ * This function is a minimally intrusive way to trigger alarms when precision is not important.
+ * The system will adjust the @a delay and @a period requests to suit internal needs; the requests
+ * will be treated as minimum values. Note that @a period cannot be less than 600 seconds, if
+ * a smaller request is supplied it will be silently adjusted to a request of 600.
+ * When the alarm goes off, Alarm Manager will turn on LCD to prohibit background jobs.
+ *
+ * @param[in] noti The notification to be posted when the alarm is triggered
+ * @param[in] delay The amount of time before the first execution (in seconds).
+ * @param[in] period The amount of time between subsequent alarms (in seconds).
+ * @param[out] alarm_id The ID which uniquely identifies the scheduled alarm
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ALARM_ERROR_INVALID_TIME Triggered time is invalid
+ * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_cancel()
+ * @see alarm_cancel_all()
+ * @see alarm_get_scheduled_date()
+ * @see alarm_get_scheduled_period()
+ * @see alarm_schedule_noti_once_after_delay()
+ */
+int alarm_schedule_noti_after_delay(notification_h noti, int delay, int period, int *alarm_id);
+
+/**
+ * @brief Sets a notification alarm to be triggered after a specific delay.
+ * @details The alarm will go off @a delay seconds later.
+ * To cancel the alarm, call alarm_cancel() with @a alarm_id.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/alarm.set
+ * @privilege %http://tizen.org/privilege/notification
+ * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
+ * When the alarm goes off, Alarm Manager will turn on LCD to prohibit background jobs.
+ *
+ * @param[in] noti The notification to be posted when the alarm is triggered
+ * @param[in] delay The amount of time before the execution (in seconds)
+ * @param[out] alarm_id The ID which uniquely identifies the scheduled alarm
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ALARM_ERROR_INVALID_TIME Triggered time is invalid
+ * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_cancel()
+ * @see alarm_cancel_all()
+ * @see alarm_get_scheduled_date()
+ */
+int alarm_schedule_noti_once_after_delay(notification_h noti, int delay, int *alarm_id);
+
+/**
+ * @brief Sets a notification to be triggered periodically, starting at a specific time.
+ * @details The @a date describes the time of the first occurrence.
+ * @a week_flag describes the day(s) of the week when the notification recurs.
+ * If @a week_flag is #ALARM_WEEK_FLAG_TUESDAY, the alarm will repeat every Tuesday at a specific time.
+ * If @a week_flag is less than or equal to zero, the alarm is not repeated.
+ * To cancel the alarm, call alarm_cancel() with @a alarm_id.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/alarm.set
+ * @privilege %http://tizen.org/privilege/notification
+ * @remarks If the application is uninstalled after setting an alarm, the alarm is cancelled automatically.
+ *
+ * @param[in] noti The notification to be posted when the alarm is triggered
+ * @param[in] date The first active alarm time
+ * @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
+ * @param[out] alarm_id The ID which uniquely identifies the scheduled alarm
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ALARM_ERROR_INVALID_DATE Triggered date is invalid
+ * @retval #ALARM_ERROR_CONNECTION_FAIL Failed to connect to an alarm server
+ * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_cancel()
+ * @see alarm_cancel_all()
+ * @see alarm_get_scheduled_recurrence_week_flag()
+ * @see alarm_get_scheduled_date()
+ * @see #alarm_week_flag_e
+ */
+int alarm_schedule_noti_with_recurrence_week_flag(notification_h noti, struct tm *date, int week_flag, int *alarm_id);
+
+/**
+ * @brief Gets the notification to be posted when an alarm is triggered.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/alarm.get
+ * @remarks @a noti must be released using notification_free().
+ *
+ * @param[in] alarm_id The ID which uniquely identifies a scheduled alarm
+ * @param[out] noti The notification to be posted when the alarm is triggered
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #ALARM_ERROR_NONE Successful
+ * @retval #ALARM_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #ALARM_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #ALARM_ERROR_PERMISSION_DENIED Permission denied
+ * @see alarm_schedule_noti_once_at_date()
+ * @see alarm_schedule_noti_after_delay()
+ * @see alarm_schedule_noti_once_after_delay()
+ * @see alarm_schedule_noti_with_recurrence_week_flag()
+ */
+int alarm_get_notification(int alarm_id, notification_h *noti);
+
/**
* @}
*/
#include <app_alarm.h>
#include <app_control_internal.h>
+#include <notification.h>
+
#ifdef LOG_TAG
#undef LOG_TAG
#endif
return convert_error_code_to_alarm(__FUNCTION__, result);
}
+int alarm_schedule_noti_after_delay(notification_h noti, int delay, int period, int *alarm_id)
+{
+ int result;
+
+ if (noti == NULL) {
+ LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+ return ALARM_ERROR_INVALID_PARAMETER;
+ }
+
+ result = alarmmgr_add_alarm_noti(ALARM_TYPE_DEFAULT | ALARM_TYPE_INEXACT, delay, period, noti, alarm_id);
+
+ return convert_error_code_to_alarm(__FUNCTION__, result);
+}
+
int alarm_schedule_at_date(app_control_h app_control, struct tm *date, int period_in_second, int *alarm_id)
{
dlog_print(DLOG_WARN, LOG_TAG, "DEPRECATION WARNING: alarm_schedule_at_date() is deprecated and will be removed from next release. Use alarm_schedule_once_at_date() instead.");
return convert_error_code_to_alarm(__FUNCTION__, result);
}
+int alarm_schedule_noti_once_after_delay(notification_h noti, int delay, int *alarm_id)
+{
+ int result;
+
+ if (noti == NULL) {
+ LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+ return ALARM_ERROR_INVALID_PARAMETER;
+ }
+
+ result = alarmmgr_add_alarm_noti(ALARM_TYPE_DEFAULT, delay, 0, noti, alarm_id);
+
+ return convert_error_code_to_alarm(__FUNCTION__, result);
+}
+
int alarm_schedule_once_at_date(app_control_h app_control, struct tm *date, int *alarm_id)
{
alarm_date_t internal_time;
return ALARM_ERROR_NONE;
}
+int alarm_schedule_noti_once_at_date(notification_h noti, struct tm *date, int *alarm_id)
+{
+ alarm_date_t internal_time;
+ alarm_entry_t *alarm_info;
+ int result;
+
+ if (noti == NULL || date == NULL) {
+ LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+ return ALARM_ERROR_INVALID_PARAMETER;
+ }
+
+ alarm_info = alarmmgr_create_alarm();
+ if (alarm_info == NULL) {
+ LOGE("OUT_OF_MEMORY(0x%08x)", ALARM_ERROR_OUT_OF_MEMORY);
+ return ALARM_ERROR_OUT_OF_MEMORY;
+ }
+
+ internal_time.year = date->tm_year + 1900;
+ internal_time.month = date->tm_mon + 1;
+ internal_time.day = date->tm_mday;
+
+ internal_time.hour = date->tm_hour;
+ internal_time.min = date->tm_min;
+ internal_time.sec = date->tm_sec;
+
+ result = alarmmgr_set_time(alarm_info, internal_time);
+ if (result < 0) {
+ alarmmgr_free_alarm(alarm_info);
+ return convert_error_code_to_alarm(__FUNCTION__, result);
+ }
+
+ result = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_ONCE, 0);
+ if (result < 0) {
+ alarmmgr_free_alarm(alarm_info);
+ return convert_error_code_to_alarm(__FUNCTION__, result);
+ }
+
+ result = alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT);
+ if (result < 0) {
+ alarmmgr_free_alarm(alarm_info);
+ return convert_error_code_to_alarm(__FUNCTION__, result);
+ }
+
+ result = alarmmgr_add_alarm_noti_with_localtime(alarm_info, noti, alarm_id);
+ if (result < 0) {
+ alarmmgr_free_alarm(alarm_info);
+ return convert_error_code_to_alarm(__FUNCTION__, result);
+ }
+
+ alarmmgr_free_alarm(alarm_info);
+ return ALARM_ERROR_NONE;
+}
+
int alarm_cancel(int alarm_id)
{
int result;
return convert_error_code_to_alarm(__FUNCTION__, result);
}
+ if (week_flag > 0) {
+ result = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_WEEKLY, week_flag);
+ if (result < 0) {
+ alarmmgr_free_alarm(alarm_info);
+ return convert_error_code_to_alarm(__FUNCTION__, result);
+ }
+ }
+
+ result = alarmmgr_set_type(alarm_info, ALARM_TYPE_DEFAULT);
+ if (result < 0) {
+ alarmmgr_free_alarm(alarm_info);
+ return convert_error_code_to_alarm(__FUNCTION__, result);
+ }
+
+ result = alarmmgr_add_alarm_appsvc_with_localtime(alarm_info, bundle_data, alarm_id);
+ alarmmgr_free_alarm(alarm_info);
+
+ return convert_error_code_to_alarm(__FUNCTION__, result);
+}
+
+int alarm_schedule_noti_with_recurrence_week_flag(notification_h noti, struct tm *date, int week_flag, int *alarm_id)
+{
+ alarm_date_t internal_time;
+ alarm_entry_t *alarm_info;
+ int result;
+
+ if (noti == NULL || date == NULL) {
+ LOGE("INVALID_PARAMETER(0x%08x)", ALARM_ERROR_INVALID_PARAMETER);
+ return ALARM_ERROR_INVALID_PARAMETER;
+ }
+
+ alarm_info = alarmmgr_create_alarm();
+
+ internal_time.year = date->tm_year + 1900;
+ internal_time.month = date->tm_mon + 1;
+ internal_time.day = date->tm_mday;
+
+ internal_time.hour = date->tm_hour;
+ internal_time.min = date->tm_min;
+ internal_time.sec = date->tm_sec;
+
+ result = alarmmgr_set_time(alarm_info, internal_time);
+ if (result < 0) {
+ alarmmgr_free_alarm(alarm_info);
+ return convert_error_code_to_alarm(__FUNCTION__, result);
+ }
+
if (week_flag > 0)
result = alarmmgr_set_repeat_mode(alarm_info, ALARM_REPEAT_MODE_WEEKLY, week_flag);
return convert_error_code_to_alarm(__FUNCTION__, result);
}
- result = alarmmgr_add_alarm_appsvc_with_localtime(alarm_info, bundle_data, alarm_id);
+ result = alarmmgr_add_alarm_noti_with_localtime(alarm_info, noti, alarm_id);
alarmmgr_free_alarm(alarm_info);
return convert_error_code_to_alarm(__FUNCTION__, result);
return ALARM_ERROR_NONE;
}
+int alarm_get_notification(int alarm_id, notification_h *noti)
+{
+ int error_code = 0;
+
+ error_code = alarmmgr_get_alarm_noti_info(alarm_id, noti);
+ if (error_code != ALARMMGR_RESULT_SUCCESS)
+ return convert_error_code_to_alarm(__FUNCTION__, error_code);
+
+ return ALARM_ERROR_NONE;
+}
+
int alarm_set_global(int alarm_id, bool global)
{
int ret;