From b1242119f99c8b4be71d6875d32d7c8629850692 Mon Sep 17 00:00:00 2001 From: SeungYeup Kim Date: Wed, 22 May 2013 10:16:00 +0900 Subject: [PATCH] add alarmmgr_get_next_duetime api --- alarm-lib-stub.c | 30 ++++ alarm-lib.c | 76 ++++++--- alarm-manager-schedule.c | 27 ++-- alarm-manager-timer.c | 4 +- alarm-manager.c | 130 ++++++++++++---- alarm_mgr.xml | 8 +- include/alarm-internal.h | 6 +- include/alarm.h | 363 ++++++++++++++++++++++--------------------- packaging/alarm-manager.spec | 2 +- 9 files changed, 403 insertions(+), 243 deletions(-) mode change 100644 => 100755 alarm-lib-stub.c mode change 100644 => 100755 alarm_mgr.xml diff --git a/alarm-lib-stub.c b/alarm-lib-stub.c old mode 100644 new mode 100755 index fd8bea2..61d74d1 --- a/alarm-lib-stub.c +++ b/alarm-lib-stub.c @@ -620,3 +620,33 @@ bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id, return true; } + +bool _send_alarm_get_next_duetime(alarm_context_t context, + alarm_id_t alarm_id, time_t* duetime, + int *error_code) +{ + GError *error = NULL; + int return_code = 0; + + if (!com_samsung_alarm_manager_alarm_get_next_duetime(context.proxy, + context.pid, alarm_id, duetime, &return_code, &error)) { + /*dbus-glib error */ + /*error_code should be set */ + ALARM_MGR_EXCEPTION_PRINT( + "com_samsung_alarm_manager_alarm_get_next_duetime() failed. " + "alarm_id[%d], return_code[%d]\n", alarm_id, return_code); + if (error_code) + *error_code = -1; /*-1 means that system + failed internally.*/ + + return false; + } + + if (return_code != 0) { + if (error_code) + *error_code = return_code; + return false; + } + return true; +} + diff --git a/alarm-lib.c b/alarm-lib.c index 1d8e1d7..65bd6f8 100755 --- a/alarm-lib.c +++ b/alarm-lib.c @@ -252,7 +252,7 @@ static int __sub_init() GError *error = NULL; if (sub_initialized) { - ALARM_MGR_EXCEPTION_PRINT("__sub_init was already called.\n"); + //ALARM_MGR_LOG_PRINT("__sub_init was already called.\n"); return ALARMMGR_RESULT_SUCCESS; } @@ -294,7 +294,7 @@ bool alarm_power_off(int *error_code) "[alarm-lib]:ALARM_BOOT feature is not supported. " "so we return false.\n"); if (error_code) - *error_code = -1; /*-1 means that system failed + *error_code = -1; /*-1 means that system failed internally.*/ return false; #endif @@ -584,7 +584,7 @@ static int __alarmmgr_init_appsvc(void) } g_thread_init(NULL); - + dbus_g_thread_init(); ret = __sub_init(); @@ -592,7 +592,7 @@ static int __alarmmgr_init_appsvc(void) return ret; b_initialized = true; - + return ALARMMGR_RESULT_SUCCESS; } @@ -668,6 +668,8 @@ EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, vo bundle *b=(bundle *)bundle_data; + ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n"); + if (alarm == NULL) { return ERR_ALARM_INVALID_PARAM; } @@ -678,7 +680,7 @@ EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, vo return ERR_ALARM_INVALID_PARAM; } operation = appsvc_get_operation(b); - + if (NULL == operation) { ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle [appsvc operation not present]\n"); @@ -707,10 +709,11 @@ EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, vo } alarm_mode_t *mode = &alarm_info->mode; - ALARM_MGR_LOG_PRINT("alarm_info->start.year(%d), " - "alarm_info->start.month(%d), alarm_info->start.day(%d)", - alarm_info->start.year, alarm_info->start.month, - alarm_info->start.day); + ALARM_MGR_LOG_PRINT("start(%d-%d-%d, %02d:%02d:%02d), end(%d-%d-%d), repeat(%d), interval(%d), type(%d)", + alarm_info->start.day, alarm_info->start.month, alarm_info->start.year, + alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec, + alarm_info->end.year, alarm_info->end.month, alarm_info->end.day, + alarm_info->mode.repeat, alarm_info->mode.u_interval, alarm_info->alarm_type); /* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */ if (mode->repeat >= ALARM_REPEAT_MODE_MAX) { @@ -737,7 +740,7 @@ EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, vo (alarm_context, alarm_info, alarm_id, b, &error_code)) { return error_code; - } + } return ALARMMGR_RESULT_SUCCESS; } @@ -756,6 +759,8 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm, int i = 0; int j = 0; + ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n"); + if (alarm == NULL) { return ERR_ALARM_INVALID_PARAM; } @@ -772,12 +777,11 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm, if (ret < 0) return ret; - ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n"); - - ALARM_MGR_LOG_PRINT("alarm_info->start.year(%d), " - "alarm_info->start.month(%d), alarm_info->start.day(%d)", - alarm_info->start.year, alarm_info->start.month, - alarm_info->start.day); + ALARM_MGR_LOG_PRINT("start(%d-%d-%d, %02d:%02d:%02d), end(%d-%d-%d), repeat(%d), interval(%d), type(%d)", + alarm_info->start.day, alarm_info->start.month, alarm_info->start.year, + alarm_info->start.hour, alarm_info->start.min, alarm_info->start.sec, + alarm_info->end.year, alarm_info->end.month, alarm_info->end.day, + alarm_info->mode.repeat, alarm_info->mode.u_interval, alarm_info->alarm_type); /* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */ if (mode->repeat >= ALARM_REPEAT_MODE_MAX) { @@ -859,6 +863,8 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, const char *operation = NULL; char *appid = NULL; + ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n"); + bundle *b=(bundle *)bundle_data; if (NULL == b) @@ -867,7 +873,7 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, return ERR_ALARM_INVALID_PARAM; } operation = appsvc_get_operation(b); - + if (NULL == operation) { ALARM_MGR_EXCEPTION_PRINT("Invalid parameter bundle [appsvc operation not present]\n"); @@ -888,8 +894,6 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, return ERR_ALARM_SYSTEM_FAIL; } - ALARM_MGR_LOG_PRINT("interval(%d)", interval); - if (alarm_id == NULL) { return ERR_ALARM_INVALID_PARAM; } @@ -927,11 +931,16 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, alarm_info.mode.u_interval.interval = interval; } + ALARM_MGR_LOG_PRINT("trigger_at_time(%d), start(%d-%d-%d, %02d:%02d:%02d), repeat(%d), interval(%d), type(%d)", + trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year, + alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec, + alarm_info.mode.repeat, alarm_info.mode.u_interval, alarm_info.alarm_type); + if (!_send_alarm_create_appsvc (alarm_context, &alarm_info, alarm_id, b, &error_code)) { return error_code; - } + } return ALARMMGR_RESULT_SUCCESS; } @@ -951,14 +960,12 @@ EXPORT_API int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time, alarm_info_t alarm_info; int ret; + ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n"); + ret = __sub_init(); if (ret < 0) return ret; - ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n"); - - ALARM_MGR_LOG_PRINT("interval(%d)", interval); - if (alarm_id == NULL) { return ERR_ALARM_INVALID_PARAM; } @@ -1001,6 +1008,11 @@ EXPORT_API int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time, alarm_info.mode.u_interval.interval = interval; } + ALARM_MGR_LOG_PRINT("trigger_at_time(%d), start(%d-%d-%d, %02d:%02d:%02d), repeat(%d), interval(%d), type(%d)", + trigger_at_time, alarm_info.start.day, alarm_info.start.month, alarm_info.start.year, + alarm_info.start.hour, alarm_info.start.min, alarm_info.start.sec, + alarm_info.mode.repeat, alarm_info.mode.u_interval, alarm_info.alarm_type); + if (destination != NULL) { memset(dst_service_name, 0, strlen(destination) + strlen(".ALARM") + 2); @@ -1343,3 +1355,19 @@ int alarmmgr_get_list_of_ids(int maxnum_of_ids, alarm_id_t *alarm_id, return ALARMMGR_RESULT_SUCCESS; } + +EXPORT_API int alarmmgr_get_next_duetime(alarm_id_t alarm_id, time_t* duetime) +{ + int error_code; + ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_get_next_duetime() is called\n"); + + if (duetime == NULL) { + return ERR_ALARM_INVALID_PARAM; + } + + if (!_send_alarm_get_next_duetime + (alarm_context, alarm_id, duetime, &error_code)) + return error_code; + + return ALARMMGR_RESULT_SUCCESS; +} diff --git a/alarm-manager-schedule.c b/alarm-manager-schedule.c index 0203749..a38eaaa 100755 --- a/alarm-manager-schedule.c +++ b/alarm-manager-schedule.c @@ -38,6 +38,7 @@ #include"alarm-internal.h" #define WAKEUP_ALARM_APP_ID "org.tizen.alarm.ALARM" /*alarm ui application's alarm's dbus_service name instead of 21 value */ +#define DST_TIME_DIFF 1 extern __alarm_server_context_t alarm_context; extern GSList *g_scheduled_alarm_list; @@ -185,14 +186,12 @@ static time_t __alarm_next_duetime_once(__alarm_info_t *__alarm_info) time_t due_time = 0; time_t current_time = 0; struct tm duetime_tm; - int wday; alarm_info_t *alarm_info = &__alarm_info->alarm_info; alarm_date_t *start = &alarm_info->start; time(¤t_time); localtime_r(¤t_time, &duetime_tm); - wday = duetime_tm.tm_wday; duetime_tm.tm_hour = start->hour; duetime_tm.tm_min = start->min; duetime_tm.tm_sec = start->sec; @@ -259,14 +258,12 @@ static time_t __alarm_next_duetime_annually(__alarm_info_t *__alarm_info) time_t due_time = 0; time_t current_time = 0; struct tm duetime_tm; - int wday; alarm_info_t *alarm_info = &__alarm_info->alarm_info; alarm_date_t *start = &alarm_info->start; time(¤t_time); localtime_r(¤t_time, &duetime_tm); - wday = duetime_tm.tm_wday; duetime_tm.tm_hour = start->hour; duetime_tm.tm_min = start->min; duetime_tm.tm_sec = start->sec; @@ -294,14 +291,12 @@ static time_t __alarm_next_duetime_monthly(__alarm_info_t *__alarm_info) time_t due_time = 0; time_t current_time = 0; struct tm duetime_tm; - int wday; alarm_info_t *alarm_info = &__alarm_info->alarm_info; alarm_date_t *start = &alarm_info->start; time(¤t_time); localtime_r(¤t_time, &duetime_tm); - wday = duetime_tm.tm_wday; duetime_tm.tm_hour = start->hour; duetime_tm.tm_min = start->min; duetime_tm.tm_sec = start->sec; @@ -374,13 +369,11 @@ static time_t __alarm_next_duetime_weekly(__alarm_info_t *__alarm_info) if (current_time >= due_time || !(mode->u_interval.day_of_week & 1 << wday)) { int day = wday + 1; - int next_week = 0; int interval = 1; /*this week */ if (day == 7) { day = 0; - next_week = 1; } while (!(mode->u_interval.day_of_week & 1 << day) @@ -390,7 +383,6 @@ static time_t __alarm_next_duetime_weekly(__alarm_info_t *__alarm_info) if (day == 7) { day = 0; - next_week = 1; } } @@ -404,14 +396,19 @@ static time_t __alarm_next_duetime_weekly(__alarm_info_t *__alarm_info) time_t _alarm_next_duetime(__alarm_info_t *__alarm_info) { - + int is_dst=0; time_t current_time = 0; time_t due_time = 0; + struct tm *cur_tm = NULL ; + struct tm *due_tm = NULL ; alarm_info_t *alarm_info = &__alarm_info->alarm_info; alarm_mode_t *mode = &alarm_info->mode; time(¤t_time); + cur_tm = localtime(¤t_time); + if (cur_tm->tm_isdst > 0) + is_dst = 1; ALARM_MGR_LOG_PRINT("mode->repeat is %d\n", mode->repeat); @@ -431,6 +428,16 @@ time_t _alarm_next_duetime(__alarm_info_t *__alarm_info) return 0; } + due_tm = localtime(&due_time); + if (is_dst==0 && due_tm->tm_isdst==1){ + ALARM_MGR_LOG_PRINT("DST alarm found, enable\n"); + due_tm->tm_hour = due_tm->tm_hour - DST_TIME_DIFF; + } else if (is_dst==1 && due_tm->tm_isdst==0){ + ALARM_MGR_LOG_PRINT("DST alarm found. disable\n"); + due_tm->tm_hour = due_tm->tm_hour + DST_TIME_DIFF; + } + due_time = mktime(due_tm); + ALARM_MGR_LOG_PRINT("due_time %d\n", due_time); if (__alarm_info->end != 0 && __alarm_info->end < due_time) { diff --git a/alarm-manager-timer.c b/alarm-manager-timer.c index bf847b3..5e0f73b 100755 --- a/alarm-manager-timer.c +++ b/alarm-manager-timer.c @@ -137,7 +137,6 @@ bool _alarm_set_timer(__alarm_server_context_t *alarm_context, timer_t timer, int _set_sys_time(time_t _time) { - struct tm *_tm; struct tm result; /* Ignore return value of gmtime_r(). */ (void) gmtime_r(&_time, &result); @@ -150,8 +149,7 @@ int _set_sys_time(time_t _time) int _set_time(time_t _time) { ALARM_MGR_LOG_PRINT("ENTER FUNC _set_time(%d)", _time); - int ret = 1; - ret = _set_rtc_time(_time); + _set_rtc_time(_time); _set_sys_time(_time); /* inoti (broadcasting without data diff --git a/alarm-manager.c b/alarm-manager.c index 951b96b..51506b6 100755 --- a/alarm-manager.c +++ b/alarm-manager.c @@ -154,6 +154,7 @@ static void __rtc_set() #ifdef __WAKEUP_USING_RTC__ const char *rtc = default_rtc; + const char *rtc0 = power_rtc; int fd = 0; struct rtc_time rtc_tm; struct rtc_wkalrm rtc_wk; @@ -168,8 +169,11 @@ static void __rtc_set() fd = open(rtc, O_RDONLY); if (fd == -1) { - ALARM_MGR_EXCEPTION_PRINT("RTC open failed.\n"); - return; + fd = open(rtc0, O_RDONLY); + if (fd == -1) { + ALARM_MGR_EXCEPTION_PRINT("RTC open failed.\n"); + return; + } } /* Read the RTC time/date */ @@ -189,7 +193,7 @@ static void __rtc_set() alarm_context.c_due_time); if (alarm_context.c_due_time != -1) { - time_t due_time = alarm_context.c_due_time - 1; + time_t due_time = alarm_context.c_due_time; gmtime_r(&due_time, &due_tm); rtc_tm.tm_mday = due_tm.tm_mday; @@ -245,7 +249,6 @@ int _set_rtc_time(time_t _time) struct rtc_time rtc_tm = { 0, }; const char *rtc0 = power_rtc; const char *rtc1 = default_rtc; - struct tm *_tm = NULL; struct tm time_r = { 0, }; fd0 = open(rtc0, O_RDONLY); @@ -258,7 +261,7 @@ int _set_rtc_time(time_t _time) if (fd1 == -1) { ALARM_MGR_LOG_PRINT("error to open /dev/rtc1."); - perror("\t"); +// perror("\t"); } memset(&rtc_tm, 0, sizeof(struct rtc_time)); @@ -288,17 +291,17 @@ int _set_rtc_time(time_t _time) if (fd0 != -1) close(fd0); - retval1 = ioctl(fd1, RTC_SET_TIME, &rtc_tm); + if (fd1 != -1) { + retval1 = ioctl(fd1, RTC_SET_TIME, &rtc_tm); - if (retval1 == -1) { - if (fd1 != -1) - close(fd1); - ALARM_MGR_LOG_PRINT("error to ioctl fd1."); - perror("\t"); - } - if (fd1 != -1) + if (retval1 == -1) { + if (fd1 != -1) + close(fd1); + ALARM_MGR_LOG_PRINT("error to ioctl fd1."); + perror("\t"); + } close(fd1); - + } return 1; } @@ -851,6 +854,13 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, return false; } else { ret = read(fd, process_name, 512); + if (ret < 0 ) { + *error_code = -1; /*-1 means that system failed + internally.*/ + free(__alarm_info); + close(fd); + return false; + } close(fd); while (process_name[i] != '\0') { if (process_name[i] == ' ') { @@ -1362,12 +1372,14 @@ static void __alarm_expired() current_time, interval); if (alarm_context.c_due_time > current_time) { - ALARM_MGR_LOG_PRINT("[alarm-server]: False Alarm (time changed to past)\n"); + ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: False Alarm. due time is (%d) seconds future\n", + alarm_context.c_due_time - current_time); goto done; } // 3 seconds is maximum permitted delay from timer expire to this function if (alarm_context.c_due_time + 3 < current_time) { - ALARM_MGR_LOG_PRINT("[alarm-server]: False Alarm (time changed to future)\n"); + ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: False Alarm. due time is (%d) seconds past\n", + current_time - alarm_context.c_due_time); goto done; } @@ -1640,7 +1652,7 @@ static void __on_system_time_changed(keynode_t *node, void *data) tzset(); - ALARM_MGR_ASSERT_PRINT("diff_time is %f\n", diff_time); + ALARM_MGR_EXCEPTION_PRINT("New time is %s, diff_time is %f\n", ctime(&_time), diff_time); ALARM_MGR_LOG_PRINT("[alarm-server] System time has been changed\n"); ALARM_MGR_LOG_PRINT("1.alarm_context.c_due_time is %d\n", @@ -1648,7 +1660,6 @@ static void __on_system_time_changed(keynode_t *node, void *data) _set_time(_time); - vconf_set_dbl(VCONFKEY_SYSTEM_TIMEDIFF, diff_time); vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED,(int)diff_time); __alarm_update_due_time_of_all_items_in_list(diff_time); @@ -1686,18 +1697,17 @@ static void __on_system_time_external_changed(keynode_t *node, void *data) } tzset(); + time(&cur_time); - ALARM_MGR_ASSERT_PRINT("diff_time is %f\n", diff_time); + ALARM_MGR_EXCEPTION_PRINT("diff_time is %f, New time is %s\n", diff_time, ctime(&cur_time)); ALARM_MGR_LOG_PRINT("[alarm-server] System time has been changed externally\n"); ALARM_MGR_LOG_PRINT("1.alarm_context.c_due_time is %d\n", alarm_context.c_due_time); // set rtc time only because the linux time is set externally - time(&cur_time); _set_rtc_time(cur_time); - vconf_set_dbl(VCONFKEY_SYSTEM_TIMEDIFF, diff_time); vconf_set_int(VCONFKEY_SYSTEM_TIME_CHANGED,(int)diff_time); __alarm_update_due_time_of_all_items_in_list(diff_time); @@ -2148,6 +2158,12 @@ gboolean alarm_manager_alarm_get_number_of_ids(void *pObject, int pid, return true; } else { ret = read(fd, process_name, 512); + if (ret <0 ) { + *return_code = -1; /* -1 means that system + failed internally. */ + close(fd); + return false; + } close(fd); while (process_name[i] != '\0') { if (process_name[i] == ' ') { @@ -2246,6 +2262,12 @@ gboolean alarm_manager_alarm_get_list_of_ids(void *pObject, int pid, return true; } else { ret = read(fd, process_name, 512); + if (ret <0 ) { + *return_code = -1; + /* -1 means that system failed internally. */ + close(fd); + return true; + } close(fd); while (process_name[i] != '\0') { if (process_name[i] == ' ') { @@ -2419,6 +2441,39 @@ gboolean alarm_manager_alarm_get_info(void *pObject, int pid, return true; } +gboolean alarm_manager_alarm_get_next_duetime(void *pObject, int pid, + alarm_id_t alarm_id, time_t* duetime, + int *return_code) +{ + ALARM_MGR_LOG_PRINT("called for pid(%d) and alarm_id(%d)\n", pid, + alarm_id); + + GSList *gs_iter = NULL; + __alarm_info_t *entry = NULL; + + *return_code = 0; + + for (gs_iter = alarm_context.alarms; gs_iter != NULL; + gs_iter = g_slist_next(gs_iter)) { + entry = gs_iter->data; + if (entry->alarm_id == alarm_id) { + break; + } + } + + if (entry == NULL) + { + ALARM_MGR_EXCEPTION_PRINT("alarm id(%d) was not found\n", + alarm_id); + *return_code = ERR_ALARM_INVALID_ID; + } else { + ALARM_MGR_LOG_PRINT("alarm was found\n"); + *duetime = _alarm_next_duetime(entry); + *return_code = 0; + } + return true; +} + #include "alarm-skeleton.h" typedef struct AlarmManagerObject AlarmManagerObject; @@ -2758,15 +2813,38 @@ static void __initialize() return; } retval = ioctl(fd, RTC_RD_TIME, &rtc_tm); + if (retval == -1) { + ALARM_MGR_EXCEPTION_PRINT("RTC_RD_TIME ioctl failed"); + close(fd); + return; + } close(fd); fd2 = open(default_rtc, O_RDWR); - if (fd2 < 0) { - ALARM_MGR_EXCEPTION_PRINT("cannot open /dev/rtc1\n"); - return; + if (fd2 >= 0) { + retval = ioctl(fd2, RTC_SET_TIME, &rtc_tm); + if (retval == -1) { + ALARM_MGR_EXCEPTION_PRINT("RTC_SET_TIME ioctl failed"); + close(fd2); + return; + } + close(fd2); +// ALARM_MGR_EXCEPTION_PRINT("cannot open /dev/rtc1\n"); +// return; + } else { + fd = open(power_rtc, O_RDWR); + if (fd < 0) { + ALARM_MGR_EXCEPTION_PRINT("cannot open /dev/rtc0\n"); + return; + } + retval = ioctl(fd, RTC_SET_TIME, &rtc_tm); + if (retval == -1) { + ALARM_MGR_EXCEPTION_PRINT("RTC_SET_TIME ioctl failed"); + close(fd); + return; + } + close(fd); } - retval = ioctl(fd2, RTC_SET_TIME, &rtc_tm); - close(fd2); __initialize_timer(); if (__initialize_dbus() == false) { /* because dbus's initialize diff --git a/alarm_mgr.xml b/alarm_mgr.xml old mode 100644 new mode 100755 index 92a83f2..6641ac0 --- a/alarm_mgr.xml +++ b/alarm_mgr.xml @@ -62,7 +62,7 @@ - + @@ -130,5 +130,11 @@ + + + + + + diff --git a/include/alarm-internal.h b/include/alarm-internal.h index 33a588e..e6e1367 100755 --- a/include/alarm-internal.h +++ b/include/alarm-internal.h @@ -227,9 +227,9 @@ int _set_time(time_t _time); #define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) do { printf("%5d", getpid()); printf ("%s() : "FMT"\n", __FUNCTION__, ##ARG); } while (false) #else -#define ALARM_MGR_LOG_PRINT(FMT, ARG...) SLOGD(FMT, ##ARG); -#define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...) SLOGW(FMT, ##ARG); -#define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) SLOGE(FMT, ##ARG); +#define ALARM_MGR_LOG_PRINT(FMT, ARG...) LOGI(FMT, ##ARG); +#define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...) LOGW(FMT, ##ARG); +#define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) LOGE(FMT, ##ARG); #endif /* int alarmmgr_check_next_duetime();*/ diff --git a/include/alarm.h b/include/alarm.h index ee1a27e..2039e72 100755 --- a/include/alarm.h +++ b/include/alarm.h @@ -33,9 +33,9 @@ * * @defgroup Alarm Alarm * @version 0.4.2 - * * - * Alarm supports APIs that add, delete, and update an alarm. + * + * Alarm supports APIs that add, delete, and update an alarm. * @n An application can use alarm APIs by including @c alarm.h. The definitions * of APIs are defined as follows: * @@ -54,11 +54,11 @@ * @li @c #alarmmgr_remove_alarm remove an alarm from alarm server * @li @c #alarmmgr_enum_alarm_ids get the list of alarm ids * @li @c #alarmmgr_get_info get the information of an alarm - * * - * The following code shows how to initialize alarm library, how to register the alarm handler, and how to add an alarm. It first calls alarm_init to initialize the alarm library and sets the callback to handle an alarm event it received. In create_test fucnction, the application add an alarm which will be expired in one minute from it execute and will expire everyday at same time. * - * + * The following code shows how to initialize alarm library, how to register the alarm handler, and how to add an alarm. It first calls alarm_init to initialize the alarm library and sets the callback to handle an alarm event it received. In create_test fucnction, the application add an alarm which will be expired in one minute from it execute and will expire everyday at same time. + * + * * @code #include #include @@ -66,12 +66,12 @@ #include "alarm.h" -int callback(alarm_id_t alarm_id, void *user_param) +int callback(alarm_id_t alarm_id, void *user_param) { int error; time_t current_time; time(¤t_time); - + printf("Alarm[%d] has expired at %s\n", alarm_id, ctime(¤t_time)); return 0; } @@ -94,7 +94,7 @@ void create_test() test_time.year = current_tm.tm_year+1900; test_time.month = current_tm.tm_mon+1; - test_time.day = current_tm.tm_mday; + test_time.day = current_tm.tm_mday; test_time.hour = current_tm.tm_hour; test_time.min = current_tm.tm_min+1; test_time.sec = 0; @@ -104,32 +104,32 @@ void create_test() ALARM_WDAY_MONDAY| \ ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \ ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY ); - + alarmmgr_set_type(alarm_info,ALARM_TYPE_VOLATILE); alarmmgr_add_alarm_with_localtime(alarm_info,NULL,&alarm_id); - + if(result != ALARMMGR_RESULT_SUCCESS) printf("fail to alarmmgr_create : error_code : %d\n",result); - + } -int main(int argc, char** argv) +int main(int argc, char** argv) { int error_code; GMainLoop *mainloop; int result; g_type_init(); - + mainloop = g_main_loop_new(NULL, FALSE); result = alarmmgr_init("org.tizen.test"); if(result != ALARMMGR_RESULT_SUCCESS) { printf("fail to alarmmgr_init : error_code : %d\n",result); - } + } else { result = alarmmgr_set_cb(callback,NULL); if(result != ALARMMGR_RESULT_SUCCESS) { - printf("fail to alarmmgr_set_cb : error_code : + printf("fail to alarmmgr_set_cb : error_code : %d\n",result); } else { @@ -192,7 +192,7 @@ typedef enum { ERR_ALARM_INVALID_TIME, /** @@ -309,20 +309,20 @@ void alarmmgr_fini(); * @param [in] handler Callback function * @param [in] user_param User Parameter * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre alarmmgr_init(). * @post None. * @see None. - * @remark An application can have only one alarm handler. If an application + * @remark An application can have only one alarm handler. If an application * calls this function more than one times, the handler regitered during the - * last call of this funiction will be called when an alarm event has occured. + * last call of this funiction will be called when an alarm event has occured. * @par Sample code: * @code #include ... -// Call back function +// Call back function int callback(alarm_id_t alarm_id,void* user_param) { time_t current_time; @@ -359,7 +359,7 @@ int alarmmgr_set_cb(alarm_cb_t handler, void *user_param); /** * This function creates a new alarm entry, will not be known to the server until alarmmgr_add_alarm is called. * - * @return This function returns the pointer of alarm_entry_t + * @return This function returns the pointer of alarm_entry_t * * @pre None. * @post None. @@ -381,7 +381,7 @@ int alarmmgr_set_cb(alarm_cb_t handler, void *user_param); } else { - //alarmmgr_create_alarm () failed + //alarmmgr_create_alarm () failed } } @@ -393,11 +393,11 @@ alarm_entry_t *alarmmgr_create_alarm(void); /** - * This function frees an alarm entry. + * This function frees an alarm entry. * * @param [in] alarm alarm entry * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -407,20 +407,20 @@ alarm_entry_t *alarmmgr_create_alarm(void); * @par Sample code: * @code #include - + ... { int ret_val = ALARMMGR_RESULT_SUCCESS; alarm_entry_t* alarm; - + alarm = alarmmgr_create_alarm() ; if(alarm == NULL) { - //alarmmgr_create_alarm () failed + //alarmmgr_create_alarm () failed } else { - + ret_val = alarmmgr_free_alarm( alarm) ; if(ret_val == ALARMMGR_RESULT_SUCCESS) { @@ -429,10 +429,10 @@ alarm_entry_t *alarmmgr_create_alarm(void); else { //alarmmgr_free_alarm() failed - } + } } - } - + } + * @endcode * @limo */ @@ -445,7 +445,7 @@ int alarmmgr_free_alarm(alarm_entry_t *alarm); * @param [in] alarm alarm entry * @param [in] time time the alarm should first go off * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -455,7 +455,7 @@ int alarmmgr_free_alarm(alarm_entry_t *alarm); * @par Sample code: * @code #include - + ... { int ret_val = ALARMMGR_RESULT_SUCCESS; @@ -463,15 +463,15 @@ int alarmmgr_free_alarm(alarm_entry_t *alarm); time_t current_time; struct tm current_tm; alarm_date_t test_time; - - + + time(¤t_time); localtime_r(¤t_time, ¤t_tm); - + alarm = alarmmgr_create_alarm(); if(alarm == NULL) { - //alarmmgr_create_alarm () failed + //alarmmgr_create_alarm () failed } else { test_time.year = current_tm.tm_year; @@ -481,7 +481,7 @@ int alarmmgr_free_alarm(alarm_entry_t *alarm); test_time.hour = current_tm.tm_hour; test_time.min = current_tm.tm_min+1; test_time.sec = 0; - + ret_val=alarmmgr_set_time(alarm,test_time); if(ret_val == ALARMMGR_RESULT_SUCCESS) { @@ -494,7 +494,7 @@ int alarmmgr_free_alarm(alarm_entry_t *alarm); alarmmgr_free_alarm( alarm) ; } } - + * @endcode * @limo */ @@ -506,35 +506,35 @@ int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time); * @param [in] alarm alarm entry * @param [out] time time the alarm should first go off * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. * @see None. - * @remark But an application does not need to specify year, month, and day field of alarm_info. If an application sets + * @remark But an application does not need to specify year, month, and day field of alarm_info. If an application sets * those fields with zero, the function sets them with proper values. * * @par Sample code: * @code #include - + ... { int ret_val = ALARMMGR_RESULT_SUCCESS; alarm_entry_t* alarm; - + time_t current_time; struct tm current_tm; alarm_date_t test_time; alarm_date_t new_time; - - + + time(¤t_time); localtime_r(¤t_time, ¤t_tm); - + alarm = alarmmgr_create_alarm(); if(alarm == NULL) { - //alarmmgr_create_alarm () failed + //alarmmgr_create_alarm () failed } else { test_time.year = current_tm.tm_year; @@ -570,18 +570,18 @@ int alarmmgr_set_time(alarm_entry_t *alarm, alarm_date_t time); int alarmmgr_get_time(const alarm_entry_t *alarm, alarm_date_t *time); /** - * This function sets an alarm repeat mode + * This function sets an alarm repeat mode * * @param [in] alarm alarm entry - * @param [in] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT, + * @param [in] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT, * ALARM_REPEAT_MODE_WEEKLY, ALARM_REPEAT_MODE_MONTHLY or ALARM_REPEAT_MODE_ANNUALLY. * @param [in] repeat_value the ALARM_REPEAT_MODE_REPEAT mode : interval between subsequent repeats of the alarm. * the ALARM_REPEAT_MODE_WEEKLY mode : days of a week - * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY, + * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY, * ALARM_WDAY_THURSDAY, ALARM_WDAY_FRIDAY, ALARM_WDAY_SATURDAY) * the others : this parameter is ignored. * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -591,29 +591,29 @@ int alarmmgr_get_time(const alarm_entry_t *alarm, alarm_date_t *time); * @par Sample code: * @code #include - + ... { int ret_val = ALARMMGR_RESULT_SUCCESS; - alarm_entry_t* alarm; - alarm_repeat_mode_t repeat_mode =ALARM_REPEAT_MODE_WEEKLY; + alarm_entry_t* alarm; + alarm_repeat_mode_t repeat_mode =ALARM_REPEAT_MODE_WEEKLY; int interval = ALARM_WDAY_MONDAY; //| ALARM_WDAY_TUESDAY| ALARM_WDAY_WEDNESDAY| ALARM_WDAY_THURSDAY|ALARM_WDAY_FRIDAY ; - - + + alarm = alarmmgr_create_alarm(); if(alarm == NULL) { - //alarmmgr_create_alarm () failed + //alarmmgr_create_alarm () failed } else { ret_val = alarmmgr_set_repeat_mode (alarm, repeat_mode,interval); - + if(ret_val == ALARMMGR_RESULT_SUCCESS) { - //alarmmgr_set_repeat_mode() is successful + //alarmmgr_set_repeat_mode() is successful } else { @@ -622,7 +622,7 @@ int alarmmgr_get_time(const alarm_entry_t *alarm, alarm_date_t *time); alarmmgr_free_alarm( alarm) ; } } - + * @endcode * @limo */ @@ -631,18 +631,18 @@ int alarmmgr_set_repeat_mode(alarm_entry_t *alarm, int repeat_value); /** - * This function gives an application an alarm mode + * This function gives an application an alarm mode * * @param [in] alarm alarm entry - * @param [out] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT, + * @param [out] repeat_mode one of ALARM_REPEAT_MODE_ONCE, ALARM_REPEAT_MODE_REPEAT, * ALARM_REPEAT_MODE_WEEKLY, ALARM_REPEAT_MODE_MONTHLY or ALARM_REPEAT_MODE_ANNUALLY. * @param [out] repeat_value the ALARM_REPEAT_MODE_REPEAT mode : interval between subsequent repeats of the alarm. * the ALARM_REPEAT_MODE_WEEKLY mode : days of a week - * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY, + * (ALARM_WDAY_SUNDAY, ALARM_WDAY_MONDAY, ALARM_WDAY_TUESDAY, ALARM_WDAY_WEDNESDAY, * ALARM_WDAY_THURSDAY, ALARM_WDAY_FRIDAY, ALARM_WDAY_SATURDAY) * the others : this parameter is ignored. * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -652,23 +652,23 @@ int alarmmgr_set_repeat_mode(alarm_entry_t *alarm, * @par Sample code: * @code #include - + ... { int ret_val = ALARMMGR_RESULT_SUCCESS; alarm_entry_t* alarm; alarm_repeat_mode_t repeat; int interval; - + alarm = alarmmgr_create_alarm(); if(alarm == NULL) { - //alarmmgr_create_alarm () failed + //alarmmgr_create_alarm () failed } else { ret_val =alarmmgr_get_repeat_mode (alarm, &repeat, &interval) ; - if(ret_val == ALARMMGR_RESULT_SUCCESS + if(ret_val == ALARMMGR_RESULT_SUCCESS && repeat == ALARM_REPEAT_MODE_ONCE) { //alarmmgr_get_repeat_mode() is successful } @@ -687,13 +687,13 @@ int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm, int *repeat_value); /** - * This function sets an alarm mode + * This function sets an alarm mode * * @param [in] alarm alarm entry * @param [in] alarm_type one of ALARM_TYPE_DEFAULT : After the device reboot, the alarm still works. * ALARM_TYPE_VOLATILE : After the device reboot, the alarm does not work. * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -704,23 +704,23 @@ int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm, * @code #include - ... + ... { int ret_val = ALARMMGR_RESULT_SUCCESS; alarm_entry_t* alarm; int alarm_type = ALARM_TYPE_VOLATILE; - + alarm = alarmmgr_create_alarm(); if(alarm == NULL) { - //alarmmgr_create_alarm () failed + //alarmmgr_create_alarm () failed } else - { + { ret_val = alarmmgr_set_type(alarm, alarm_type); if(ret_val == ALARMMGR_RESULT_SUCCESS) { - //alarmmgr_set_type() is successful + //alarmmgr_set_type() is successful } else { @@ -729,19 +729,19 @@ int alarmmgr_get_repeat_mode(const alarm_entry_t *alarm, alarmmgr_free_alarm( alarm) ; } } - + * @endcode * @limo */ int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type); /** - * This function gives an application an alarm mode + * This function gives an application an alarm mode * * @param [in] alarm alarm entry * @param [out] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -752,19 +752,19 @@ int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type); * @code #include - ... + ... { int ret_val = ALARMMGR_RESULT_SUCCESS; - alarm_entry_t* alarm; + alarm_entry_t* alarm; int alarm_type; - + alarm = alarmmgr_create_alarm(); if(alarm == NULL) { //alarmmgr_create_alarm () failed } else { ret_val = alarmmgr_get_type( alarm, &alarm_type); - if(ret_val == ALARMMGR_RESULT_SUCCESS && alarm_type + if(ret_val == ALARMMGR_RESULT_SUCCESS && alarm_type == ALARM_TYPE_DEFAULT ) { //alarmmgr_get_type() is successful } @@ -774,18 +774,18 @@ int alarmmgr_set_type(alarm_entry_t *alarm, int alarm_type); alarmmgr_free_alarm( alarm) ; } } - + * @endcode * @limo */ int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type); /** - * This function adds an alarm entry to the server. + * This function adds an alarm entry to the server. * Server will remember this entry, and generate alarm events for it when necessary. * Server will call app-svc interface to sent notification to destination application. Destination information * should be available in the input bundle. - * Alarm entries registered with the server cannot be changed. + * Alarm entries registered with the server cannot be changed. * Remove from server before changing. * Before the application calls alarmmgr_add_alarm_appsvc_with_localtime(), the application have to call alarmmgr_set_time(). * The time set is localtime. @@ -795,9 +795,9 @@ int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type); * * @param [in] alarm the entry of an alarm to be created. * @param [in] bundle_data bundle which contains information about the destination. - * @param [out] alarm_id the id of the alarm added. + * @param [out] alarm_id the id of the alarm added. * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -808,7 +808,7 @@ int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type); * @code #include - ... + ... { time_t current_time; struct tm current_tm; @@ -835,18 +835,18 @@ int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type); printf("current time: %s\n", ctime(¤t_time)); localtime_r(¤t_time, ¤t_tm); - + alarm_info = alarmmgr_create_alarm(); - - test_time.year = current_tm.tm_year; - test_time.month = current_tm.tm_mon; - test_time.day = current_tm.tm_mday; - + + test_time.year = current_tm.tm_year; + test_time.month = current_tm.tm_mon; + test_time.day = current_tm.tm_mday; + test_time.hour = current_tm.tm_hour; test_time.min = current_tm.tm_min+1; test_time.sec = 5; - + alarmmgr_set_time(alarm_info,test_time); alarmmgr_set_repeat_mode(alarm_info,ALARM_REPEAT_MODE_WEEKLY,ALARM_WDAY_MONDAY| \ ALARM_WDAY_TUESDAY|ALARM_WDAY_WEDNESDAY| \ @@ -870,9 +870,9 @@ int alarmmgr_get_type(const alarm_entry_t *alarm, int *alarm_type); int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm,void *bundle_data, alarm_id_t *alarm_id); /** - * This function adds an alarm entry to the server. + * This function adds an alarm entry to the server. * Server will remember this entry, and generate alarm events for it when necessary. - * Alarm entries registered with the server cannot be changed. + * Alarm entries registered with the server cannot be changed. * Remove from server before changing. * Before the application calls alarmmgr_add_alarm_with_localtime(), the application have to call alarmmgr_set_time(). * The time set is localtime. @@ -882,9 +882,9 @@ int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm,void *bundle_d * * @param [in] alarm the entry of an alarm to be created. * @param [in] destination the packname of application that the alarm will be expired. - * @param [out] alarm_id the id of the alarm added. + * @param [out] alarm_id the id of the alarm added. * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -895,53 +895,53 @@ int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm,void *bundle_d * @code #include - ... + ... { int ret_val = ALARMMGR_RESULT_SUCCESS; - alarm_entry_t* alarm; - const char* destination = NULL; + alarm_entry_t* alarm; + const char* destination = NULL; alarm_id_t alarm_id; - + time_t current_time; struct tm current_tm; alarm_date_t test_time; - + const char* pkg_name = "org.tizen.test"; - + g_type_init(); - + ret_val =alarmmgr_init(pkg_name) ; if(ret_val != ALARMMGR_RESULT_SUCCESS) { //alarmmgr_init () failed return; } - + time(¤t_time); - + printf("current time: %s\n", ctime(¤t_time)); localtime_r(¤t_time, ¤t_tm); - + alarm = alarmmgr_create_alarm(); - + test_time.year = 0; test_time.month = 0;test_time.day = 0; - + test_time.hour = current_tm.tm_hour; test_time.min = current_tm.tm_min+1; test_time.sec = 0; - - + + alarmmgr_set_time(alarm,test_time); alarmmgr_set_repeat_mode(alarm,ALARM_REPEAT_MODE_WEEKLY, \ ALARM_WDAY_MONDAY); alarmmgr_set_type(alarm,ALARM_TYPE_VOLATILE); - - + + ret_val=alarmmgr_add_alarm_with_localtime(alarm,destination,&alarm_id); - + if(ret_val == ALARMMGR_RESULT_SUCCESS) { - //alarmmgr_add_alarm_with_localtime() is successful + //alarmmgr_add_alarm_with_localtime() is successful } else { @@ -958,11 +958,11 @@ int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm, /** - * This function adds an alarm entry to the server. + * This function adds an alarm entry to the server. * Server will remember this entry, and generate alarm events for it when necessary. * Server will call app-svc interface to sent notification to destination application. Destination information * should be available in the input bundle. - * Alarm entries registered with the server cannot be changed. + * Alarm entries registered with the server cannot be changed. * Remove from server before changing. * After the trigger_at_time seconds from now, the alarm will be expired. * If the interval is zero, the repeat_mode is ALARM_REPEAT_MODE_ONCE. @@ -970,12 +970,12 @@ int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm, * The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm. * * @param [in] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE - * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time. - * @param [in] interval Interval between subsequent repeats of the alarm + * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time. + * @param [in] interval Interval between subsequent repeats of the alarm * @param [in] bundle_data bundle which contains information about the destination. - * @param [out] alarm_id the id of the alarm added. + * @param [out] alarm_id the id of the alarm added. * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -986,7 +986,7 @@ int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm, * @code #include - ... + ... { int result; alarm_id_t alarm_id; @@ -1009,7 +1009,7 @@ int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm, printf("Unable to add alarm. Alarmmgr alarm no is %d\n", result); else printf("Alarm added successfully. Alarm Id is %d\n", alarm_id); - return; + return; } @@ -1022,9 +1022,9 @@ int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, /** - * This function adds an alarm entry to the server. + * This function adds an alarm entry to the server. * Server will remember this entry, and generate alarm events for it when necessary. - * Alarm entries registered with the server cannot be changed. + * Alarm entries registered with the server cannot be changed. * Remove from server before changing. * After the trigger_at_time seconds from now, the alarm will be expired. * If the interval is zero, the repeat_mode is ALARM_REPEAT_MODE_ONCE. @@ -1032,12 +1032,12 @@ int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, * The id of the new alarm will be copied to alarm_id if the fuction successes to create an alarm. * * @param [in] alarm_type one of ALARM_TYPE_DEFAULT, ALARM_TYPE_VOLATILE - * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time. - * @param [in] interval Interval between subsequent repeats of the alarm + * @param [in] trigger_at_time time interval to be triggered from now(sec). an alarm also will be expired at triggering time. + * @param [in] interval Interval between subsequent repeats of the alarm * @param [in] destination the packname of application that the alarm will be expired. - * @param [out] alarm_id the id of the alarm added. + * @param [out] alarm_id the id of the alarm added. * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -1048,32 +1048,32 @@ int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, * @code #include - ... + ... { int ret_val = ALARMMGR_RESULT_SUCCESS; - + int alarm_type = ALARM_TYPE_VOLATILE; - time_t trigger_at_time = 10; - time_t interval = 10; + time_t trigger_at_time = 10; + time_t interval = 10; const char* destination = NULL; alarm_id_t alarm_id; - + const char* pkg_name = "org.tizen.test"; - + g_type_init(); - + ret_val =alarmmgr_init(pkg_name) ; if(ret_val != ALARMMGR_RESULT_SUCCESS) { //alarmmgr_init () failed return; } - - ret_val = alarmmgr_add_alarm( alarm_type, trigger_at_time, interval, + + ret_val = alarmmgr_add_alarm( alarm_type, trigger_at_time, interval, destination, &alarm_id); if(ret_val == ALARMMGR_RESULT_SUCCESS) { - //alarmmgr_add_alarm() is successful + //alarmmgr_add_alarm() is successful } else { @@ -1092,9 +1092,9 @@ int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time, /** * This function deletes the alarm associated with the given alarm_id. * - * @param [in] alarm_id Specifies the ID of the alarm to be deleted. + * @param [in] alarm_id Specifies the ID of the alarm to be deleted. * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -1105,28 +1105,28 @@ int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time, * @code #include - ... + ... { int ret_val = ALARMMGR_RESULT_SUCCESS; int alarm_type = ALARM_TYPE_VOLATILE; - time_t trigger_at_time = 10; - time_t interval = 10; + time_t trigger_at_time = 10; + time_t interval = 10; const char* destination = NULL; alarm_id_t alarm_id; - + const char* pkg_name = "org.tizen.test"; - + g_type_init(); - + ret_val =alarmmgr_init(pkg_name) ; if(ret_val != ALARMMGR_RESULT_SUCCESS) { //alarmmgr_init () failed return; } - alarmmgr_add_alarm( alarm_type, trigger_at_time, interval, + alarmmgr_add_alarm( alarm_type, trigger_at_time, interval, destination, &alarm_id); - + ret_val =alarmmgr_remove_alarm( alarm_id) ; if(ret_val == ALARMMGR_RESULT_SUCCESS) { /alarmmgr_remove_alarm() is successful @@ -1135,7 +1135,7 @@ int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time, //alarmmgr_remove_alarm() failed } } - + * @endcode * @limo */ @@ -1147,7 +1147,7 @@ int alarmmgr_remove_alarm(alarm_id_t alarm_id); * @param [in] fn a user callback function * @param [in] user_param user parameter * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -1157,7 +1157,7 @@ int alarmmgr_remove_alarm(alarm_id_t alarm_id); * @par Sample code: * @code #include - + int callback_2(alarm_id_t id, void* user_param) { int* n = (int*)user_param; @@ -1166,26 +1166,26 @@ int alarmmgr_remove_alarm(alarm_id_t alarm_id); return 0; } -... +... { int ret_val = ALARMMGR_RESULT_SUCCESS; int n = 1; - + const char* pkg_name = "org.tizen.test"; - + g_type_init(); - + ret_val =alarmmgr_init(pkg_name) ; if(ret_val != ALARMMGR_RESULT_SUCCESS) { //alarmmgr_init() failed return; } - + ret_val = alarmmgr_enum_alarm_ids( callback_2, (void*)&n) ; if(ret_val == ALARMMGR_RESULT_SUCCESS) { - //alarmmgr_enum_alarm_ids() is successful + //alarmmgr_enum_alarm_ids() is successful } else { @@ -1201,12 +1201,12 @@ int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param); /** * This function gets the information of the alarm assosiated with alarm_id to alarm_info. The application - * must allocate alarm_info before calling this function. + * must allocate alarm_info before calling this function. * * @param [in] alarm_id the id of the alarm * @param [out] alarm the buffer alarm informaiton will be copied to - * - * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. * * @pre None. * @post None. @@ -1221,29 +1221,29 @@ int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param); { int ret_val = ALARMMGR_RESULT_SUCCESS; int alarm_type = ALARM_TYPE_VOLATILE; - time_t trigger_at_time = 10; - time_t interval = ALARM_WDAY_SUNDAY; + time_t trigger_at_time = 10; + time_t interval = ALARM_WDAY_SUNDAY; const char* destination = NULL; alarm_id_t alarm_id; alarm_entry_t *alarm; const char* pkg_name = "org.tizen.test_get_info1"; - + g_type_init(); - + ret_val =alarmmgr_init(pkg_name) ; if(ret_val != ALARMMGR_RESULT_SUCCESS) { //alarmmgr_init() failed return; - } + } ret_val = alarmmgr_add_alarm( alarm_type,trigger_at_time,interval, destination, &alarm_id); if(ret_val != ALARMMGR_RESULT_SUCCESS) { //alarmmgr_add_alarm() failed return; - } + } ret_val = alarmmgr_get_info(alarm_id, alarm); if(ret_val == ALARMMGR_RESULT_SUCCESS) { //alarmmgr_get_info() is successful @@ -1322,7 +1322,20 @@ int main(int argc,char **argv { */ void *alarmmgr_get_alarm_appsvc_info(alarm_id_t alarm_id, int *return_code); - +/** + * This function gets the scheduled time of the alarm assosiated with alarm_id. + * + * @param [in] alarm_id the id of the alarm + * @param [out] duetime the scheduled time of the alarm + * + * @return This function returns ALARMMGR_RESULT_SUCCESS on success or a negative number on failure. + * + * @pre None. + * @post None. + * @see None + * @remark None. + */ + int alarmmgr_get_next_duetime(alarm_id_t alarm_id, time_t* duetime); /** * This function sets power RTC (which can power on the system). diff --git a/packaging/alarm-manager.spec b/packaging/alarm-manager.spec index 7ee7d8c..18e4a41 100755 --- a/packaging/alarm-manager.spec +++ b/packaging/alarm-manager.spec @@ -1,6 +1,6 @@ Name: alarm-manager Summary: Alarm library -Version: 0.4.70 +Version: 0.4.77 Release: 1 Group: System/Libraries License: Apache License, Version 2.0 -- 2.7.4