diff options
author | Anas Nashif <anas.nashif@intel.com> | 2013-09-25 00:06:55 -0400 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2013-09-25 00:07:03 -0400 |
commit | be15473201938a1b740344bfae69b81871923414 (patch) | |
tree | 999335cfd68c726c645783c23fa83f59ae7e5764 | |
parent | 291571d4cf5ea9f6cfa21baf04a5878b3cfc6f23 (diff) | |
parent | 76fb8007bb8fe5a98fb29df6f8750767704de38e (diff) | |
download | alarm-manager-be15473201938a1b740344bfae69b81871923414.tar.gz alarm-manager-be15473201938a1b740344bfae69b81871923414.tar.bz2 alarm-manager-be15473201938a1b740344bfae69b81871923414.zip |
Merge branch 'tizen_2.2' into tizen
Change-Id: I745d702d4a083a733deafe8a91aef219da9fcf8e
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
-rwxr-xr-x[-rw-r--r--] | alarm-lib-stub.c | 30 | ||||
-rwxr-xr-x | alarm-lib.c | 111 | ||||
-rwxr-xr-x | alarm-manager-schedule.c | 27 | ||||
-rwxr-xr-x | alarm-manager-timer.c | 4 | ||||
-rwxr-xr-x | alarm-manager.c | 290 | ||||
-rwxr-xr-x[-rw-r--r--] | alarm-server.manifest | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | alarm_mgr.xml | 8 | ||||
-rwxr-xr-x | include/alarm-internal.h | 6 | ||||
-rwxr-xr-x | include/alarm.h | 363 | ||||
-rwxr-xr-x | packaging/alarm-manager.spec | 2 |
10 files changed, 514 insertions, 328 deletions
diff --git a/alarm-lib-stub.c b/alarm-lib-stub.c index fd8bea2..b5bfdf9 100644..100755 --- 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 (!org_tizen_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( + "org_tizen_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 63d0c2e..d2bc9ed 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; } @@ -293,7 +293,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 @@ -328,6 +328,7 @@ EXPORT_API int alarmmgr_init(const char *appid) int ret; int i = 0; int j = 0; + int len = 0; if (appid == NULL) return ERR_ALARM_INVALID_PARAM; @@ -347,7 +348,10 @@ EXPORT_API int alarmmgr_init(const char *appid) return ret; memset(service_name_mod, 'a', MAX_SERVICE_NAME_LEN-1); - strncpy(service_name, appid, MAX_PKG_NAME_LEN); + + len = strlen("ALARM."); + strncpy(service_name, "ALARM.", len); + strncpy(service_name + len, appid, strlen(appid)); j=0; @@ -364,10 +368,8 @@ EXPORT_API int alarmmgr_init(const char *appid) j++; } - strncat(service_name, ".ALARM", strlen(".ALARM")); - - strncat(service_name_mod, ".ALARM", strlen(".ALARM")); - + ALARM_MGR_LOG_PRINT("[alarm-lib]: service_name %s\n", service_name); + ALARM_MGR_LOG_PRINT("[alarm-lib]: service_name_mod %s\n", service_name_mod); dbus_error_init(&derror); @@ -582,7 +584,6 @@ static int __alarmmgr_init_appsvc(void) return ALARMMGR_RESULT_SUCCESS; } - dbus_g_thread_init(); ret = __sub_init(); @@ -590,7 +591,7 @@ static int __alarmmgr_init_appsvc(void) return ret; b_initialized = true; - + return ALARMMGR_RESULT_SUCCESS; } @@ -666,6 +667,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; } @@ -676,7 +679,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"); @@ -705,10 +708,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) { @@ -735,7 +739,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; } @@ -754,6 +758,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; } @@ -770,12 +776,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) { @@ -805,8 +810,8 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm, if (destination != NULL) { memset(dst_service_name, 0, - strlen(destination) + strlen(".ALARM") + 2); - snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "%s", + strlen(destination) + strlen("ALARM.") + 2); + snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "ALARM.%s", destination); memset(dst_service_name_mod,'a',MAX_SERVICE_NAME_LEN-1); @@ -827,9 +832,6 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm, j++; } - strncat(dst_service_name, ".ALARM", strlen(".ALARM")); - strncat(dst_service_name_mod, ".ALARM", strlen(".ALARM")); - if (!_send_alarm_create (alarm_context, alarm_info, alarm_id, dst_service_name, dst_service_name_mod, &error_code)) { @@ -857,6 +859,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) @@ -865,7 +869,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"); @@ -886,8 +890,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; } @@ -925,11 +927,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; } @@ -949,14 +956,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; } @@ -999,10 +1004,15 @@ 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); - snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "%s", + strlen(destination) + strlen("ALARM.") + 2); + snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "ALARM.%s", destination); memset(dst_service_name_mod,'a',MAX_SERVICE_NAME_LEN-1); @@ -1022,9 +1032,6 @@ EXPORT_API int alarmmgr_add_alarm(int alarm_type, time_t trigger_at_time, j++; } - strncat(dst_service_name, ".ALARM", strlen(".ALARM")); - strncat(dst_service_name_mod, ".ALARM", strlen(".ALARM")); - if (!_send_alarm_create (alarm_context, &alarm_info, alarm_id, dst_service_name,dst_service_name_mod, &error_code)) { @@ -1053,7 +1060,9 @@ EXPORT_API int alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time, int ret; char appid[256]; - aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)); + ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)); + if (ret != AUL_R_OK) + return ERR_ALARM_SYSTEM_FAIL; ret = alarmmgr_init(appid); if (ret < 0) @@ -1119,7 +1128,7 @@ EXPORT_API int alarmmgr_remove_alarm(alarm_id_t alarm_id) if (ret < 0) return ret; - ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_delete() is called\n"); + ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_delete(%d) is called\n", alarm_id); if (alarm_id <= 0) { return ERR_ALARM_INVALID_ID; @@ -1284,8 +1293,8 @@ int alarmmgr_create(alarm_info_t *alarm_info, char *destination, if (destination != NULL) { memset(dst_service_name, 0, - strlen(destination) + strlen(".ALARM") + 2); - snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "%s.ALARM", + strlen(destination) + strlen("ALARM.") + 2); + snprintf(dst_service_name, MAX_SERVICE_NAME_LEN, "ALARM.%s", destination); if (!_send_alarm_create (alarm_context, alarm_info, alarm_id, dst_service_name,"null", @@ -1341,3 +1350,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..23e78e6 100755 --- a/alarm-manager.c +++ b/alarm-manager.c @@ -104,8 +104,8 @@ static const char power_rtc[] = "/dev/rtc0"; #endif /*__WAKEUP_USING_RTC__*/ -static bool __alarm_add_to_list(__alarm_info_t *__alarm_info, - alarm_id_t *alarm_id); +static bool __alarm_add_to_list(__alarm_info_t *__alarm_info); +static void __alarm_generate_alarm_id(__alarm_info_t *__alarm_info, alarm_id_t *alarm_id); static bool __alarm_update_in_list(int pid, alarm_id_t alarm_id, __alarm_info_t *__alarm_info, int *error_code); @@ -137,7 +137,7 @@ static void __on_system_time_changed(keynode_t *node, void *data); static void __on_system_time_external_changed(keynode_t *node, void *data); static void __initialize_timer(); static void __initialize_alarm_list(); -static void __initialize_scheduled_alarm_lsit(); +static void __initialize_scheduled_alarm_list(); static void __hibernation_leave_callback(); static bool __initialize_noti(); @@ -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; } @@ -315,12 +318,9 @@ bool __alarm_clean_list() return true; } -static bool __alarm_add_to_list(__alarm_info_t *__alarm_info, - alarm_id_t *alarm_id) +static void __alarm_generate_alarm_id(__alarm_info_t *__alarm_info, alarm_id_t *alarm_id) { - bool unique_id = false; - alarm_info_t *alarm_info = &__alarm_info->alarm_info; __alarm_info_t *entry = NULL; GSList *iter = NULL; @@ -341,9 +341,21 @@ static bool __alarm_add_to_list(__alarm_info_t *__alarm_info, unique_id = false; } } - } + *alarm_id = __alarm_info->alarm_id; + + return; +} + +static bool __alarm_add_to_list(__alarm_info_t *__alarm_info) +{ + + alarm_info_t *alarm_info = &__alarm_info->alarm_info; + __alarm_info_t *entry = NULL; + + GSList *iter = NULL; + /* list alarms */ ALARM_MGR_LOG_PRINT("[alarm-server]: before add\n"); for (iter = alarm_context.alarms; iter != NULL; @@ -368,8 +380,6 @@ static bool __alarm_add_to_list(__alarm_info_t *__alarm_info, _save_alarms(__alarm_info); } - *alarm_id = __alarm_info->alarm_id; - return true; } @@ -471,9 +481,9 @@ static bool __alarm_set_start_and_end_time(alarm_info_t *alarm_info, alarm_tm.tm_mon = start->month - 1; alarm_tm.tm_mday = start->day; - alarm_tm.tm_hour = 0; - alarm_tm.tm_min = 0; - alarm_tm.tm_sec = 0; + alarm_tm.tm_hour = start->hour; + alarm_tm.tm_min = start->min; + alarm_tm.tm_sec = start->sec; __alarm_info->start = mktime(&alarm_tm); } else { @@ -485,9 +495,9 @@ static bool __alarm_set_start_and_end_time(alarm_info_t *alarm_info, alarm_tm.tm_mon = end->month - 1; alarm_tm.tm_mday = end->day; - alarm_tm.tm_hour = 23; - alarm_tm.tm_min = 59; - alarm_tm.tm_sec = 59; + alarm_tm.tm_hour = end->hour; + alarm_tm.tm_min = end->min; + alarm_tm.tm_sec = end->sec; __alarm_info->end = mktime(&alarm_tm); } else { @@ -671,6 +681,10 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id int fd = 0; int ret = 0; int i = 0; + bundle *b; + char caller_appid[512]; + bundle_raw *b_data = NULL; + int datalen = 0; __alarm_info_t *__alarm_info = NULL; @@ -729,14 +743,28 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id g_quark_from_string(app_name); } - __alarm_info->quark_bundle=g_quark_from_string(bundle_data); + b = bundle_decode((bundle_raw *)bundle_data, strlen(bundle_data)); + ret = aul_app_get_appid_bypid(pid, caller_appid, 512); + if(ret == 0) { + bundle_add(b, "__ALARM_MGR_CALLER_APPID", caller_appid); + } + bundle_encode(b, &b_data, &datalen); + + __alarm_info->quark_bundle=g_quark_from_string(b_data); __alarm_info->quark_app_service_name = g_quark_from_string("null"); __alarm_info->quark_dst_service_name = g_quark_from_string("null"); __alarm_info->quark_app_service_name_mod = g_quark_from_string("null"); __alarm_info->quark_dst_service_name_mod = g_quark_from_string("null"); + bundle_free(b); + if (b_data) { + free(b_data); + b_data = NULL; + } + __alarm_set_start_and_end_time(alarm_info, __alarm_info); memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t)); + __alarm_generate_alarm_id(__alarm_info, alarm_id); time(¤t_time); @@ -748,7 +776,7 @@ static bool __alarm_create_appsvc(alarm_info_t *alarm_info, alarm_id_t *alarm_id } due_time = _alarm_next_duetime(__alarm_info); - if (__alarm_add_to_list(__alarm_info, alarm_id) == false) { + if (__alarm_add_to_list(__alarm_info) == false) { free(__alarm_info); *error_code = -1; return false; @@ -851,6 +879,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] == ' ') { @@ -885,6 +920,7 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, __alarm_set_start_and_end_time(alarm_info, __alarm_info); memcpy(&(__alarm_info->alarm_info), alarm_info, sizeof(alarm_info_t)); + __alarm_generate_alarm_id(__alarm_info, alarm_id); time(¤t_time); @@ -903,7 +939,7 @@ static bool __alarm_create(alarm_info_t *alarm_info, alarm_id_t *alarm_id, } due_time = _alarm_next_duetime(__alarm_info); - if (__alarm_add_to_list(__alarm_info, alarm_id) == false) { + if (__alarm_add_to_list(__alarm_info) == false) { free(__alarm_info); return false; } @@ -1361,13 +1397,15 @@ static void __alarm_expired() "current_time(%d), interval(%d)\n", alarm_context.c_due_time, current_time, interval); - if (alarm_context.c_due_time > current_time) { - ALARM_MGR_LOG_PRINT("[alarm-server]: False Alarm (time changed to past)\n"); + if (alarm_context.c_due_time > current_time + 1) { + 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"); + // 10 seconds is maximum permitted delay from timer expire to this function + if (alarm_context.c_due_time + 10 < current_time) { + ALARM_MGR_EXCEPTION_PRINT("[alarm-server]: False Alarm. due time is (%d) seconds past\n", + current_time - alarm_context.c_due_time); goto done; } @@ -1508,11 +1546,11 @@ static void __alarm_expired() if (strncmp (g_quark_to_string(__alarm_info->quark_dst_service_name), "null",4) == 0) { - strncpy(appid,g_quark_to_string(__alarm_info->quark_app_service_name),strlen(g_quark_to_string(__alarm_info->quark_app_service_name))-6); + strncpy(appid,g_quark_to_string(__alarm_info->quark_app_service_name)+6,strlen(g_quark_to_string(__alarm_info->quark_app_service_name))-6); } else { - strncpy(appid,g_quark_to_string(__alarm_info->quark_dst_service_name),strlen(g_quark_to_string(__alarm_info->quark_dst_service_name))-6); + strncpy(appid,g_quark_to_string(__alarm_info->quark_dst_service_name)+6,strlen(g_quark_to_string(__alarm_info->quark_dst_service_name))-6); } snprintf(alarm_id_str, 31, "%d", alarm_id); @@ -1640,7 +1678,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 +1686,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 +1723,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); @@ -1761,7 +1797,6 @@ gboolean alarm_manager_alarm_set_rtc_time(void *pObject, int pid, gsize size; int retval = 0; gboolean result = true; - gid_t call_gid; const char *rtc = power_rtc; int fd = 0; @@ -1784,21 +1819,22 @@ gboolean alarm_manager_alarm_set_rtc_time(void *pObject, int pid, return true; } - call_gid = security_server_get_gid("alarm"); - - ALARM_MGR_LOG_PRINT("call_gid : %d\n", call_gid); - - retval = security_server_check_privilege((const char *)cookie, call_gid); + retval = security_server_check_privilege_by_cookie((const char *)cookie, "alarm-manager::alarm", "w"); if (retval < 0) { if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) { ALARM_MGR_EXCEPTION_PRINT( - "%s", "access has been denied\n"); + "%s", "Write access has been denied by smack\n"); } +#ifdef __ALLOW_NO_PRIVILEGE ALARM_MGR_EXCEPTION_PRINT("Error has occurred in security_server_check_privilege()\n"); if (return_code) *return_code = ERR_ALARM_NO_PERMISSION; +#endif } - else { +#ifdef __ALLOW_NO_PRIVILEGE + else +#endif + { /*extract day of the week, day in the year & daylight saving time from system*/ @@ -1897,7 +1933,6 @@ gboolean alarm_manager_alarm_create_appsvc(void *pObject, int pid, guchar *cookie = NULL; gsize size; int retval = 0; - gid_t call_gid; gboolean result = true; alarm_info.start.year = start_year; @@ -1927,21 +1962,22 @@ gboolean alarm_manager_alarm_create_appsvc(void *pObject, int pid, return false; } - call_gid = security_server_get_gid("alarm"); - - ALARM_MGR_LOG_PRINT("call_gid : %d\n", call_gid); - - retval = security_server_check_privilege((const char *)cookie, call_gid); + retval = security_server_check_privilege_by_cookie((const char *)cookie, "alarm-manager::alarm", "w"); if (retval < 0) { if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) { ALARM_MGR_EXCEPTION_PRINT( - "%s", "access has been denied\n"); + "%s", "Write access has been denied by smack\n"); } +#ifdef __ALLOW_NO_PRIVILEGE ALARM_MGR_EXCEPTION_PRINT("Error has occurred in security_server_check_privilege()\n"); *return_code = -1; result = false; +#endif } - else { +#ifdef __ALLOW_NO_PRIVILEGE + else +#endif + { result = __alarm_create_appsvc(&alarm_info, alarm_id, pid, bundle_data, return_code); if (false == result) @@ -1973,7 +2009,6 @@ gboolean alarm_manager_alarm_create(void *pObject, int pid, guchar *cookie; gsize size; int retval; - gid_t call_gid; alarm_info.start.year = start_year; alarm_info.start.month = start_month; @@ -1995,22 +2030,23 @@ gboolean alarm_manager_alarm_create(void *pObject, int pid, *return_code = 0; cookie = g_base64_decode(e_cookie, &size); - call_gid = security_server_get_gid("alarm"); - - ALARM_MGR_LOG_PRINT("call_gid : %d\n", call_gid); - retval = security_server_check_privilege((const char *)cookie, call_gid); + retval = security_server_check_privilege_by_cookie((const char *)cookie, "alarm-manager::alarm", "w"); if (retval < 0) { if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) { ALARM_MGR_EXCEPTION_PRINT( - "%s", "access has been denied\n"); + "%s", "Write access has been denied by smack\n"); } +#ifdef __ALLOW_NO_PRIVILEGE ALARM_MGR_EXCEPTION_PRINT("%s", "Error has occurred\n"); *return_code = -1; +#endif } - - else { +#ifdef __ALLOW_NO_PRIVILEGE + else +#endif + { /* return valule and return_code should be checked */ __alarm_create(&alarm_info, alarm_id, pid, app_service_name,app_service_name_mod, reserved_service_name, reserved_service_name_mod, return_code); @@ -2027,25 +2063,25 @@ gboolean alarm_manager_alarm_delete(void *pObject, int pid, alarm_id_t alarm_id, guchar *cookie; gsize size; int retval; - gid_t call_gid; cookie = g_base64_decode(e_cookie, &size); - call_gid = security_server_get_gid("alarm"); - - ALARM_MGR_LOG_PRINT("call_gid : %d\n", call_gid); - retval = security_server_check_privilege((const char *)cookie, call_gid); + retval = security_server_check_privilege_by_cookie((const char *)cookie, "alarm-manager::alarm", "w"); if (retval < 0) { if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) { - ALARM_MGR_EXCEPTION_PRINT("%s", - "access has been denied\n"); + ALARM_MGR_EXCEPTION_PRINT( + "%s", "Write access has been denied by smack\n"); } +#ifdef __ALLOW_NO_PRIVILEGE ALARM_MGR_EXCEPTION_PRINT("%s", "Error has occurred\n"); *return_code = -1; +#endif } - - else { +#ifdef __ALLOW_NO_PRIVILEGE + else +#endif + { __alarm_delete(pid, alarm_id, return_code); } @@ -2148,6 +2184,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 +2288,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] == ' ') { @@ -2298,7 +2346,6 @@ gboolean alarm_manager_alarm_get_appsvc_info(void *pObject, int pid, alarm_id_t guchar *cookie = NULL; gsize size; int retval = 0; - gid_t call_gid; ALARM_MGR_LOG_PRINT("called for pid(%d) and alarm_id(%d)\n", pid, alarm_id); @@ -2311,16 +2358,14 @@ gboolean alarm_manager_alarm_get_appsvc_info(void *pObject, int pid, alarm_id_t ALARM_MGR_EXCEPTION_PRINT("Unable to decode cookie!!!\n"); return true; } - call_gid = security_server_get_gid("alarm"); - - ALARM_MGR_LOG_PRINT("call_gid : %d\n", call_gid); - retval = security_server_check_privilege((const char *)cookie, call_gid); + retval = security_server_check_privilege_by_cookie((const char *)cookie, "alarm-manager::alarm", "r"); if (retval < 0) { if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) { ALARM_MGR_EXCEPTION_PRINT( - "%s", "access has been denied\n"); + "%s", "Read access has been denied by smack\n"); } +#ifdef __ALLOW_NO_PRIVILEGE ALARM_MGR_EXCEPTION_PRINT("%s", "Error has occurred\n"); if (return_code) @@ -2330,6 +2375,7 @@ gboolean alarm_manager_alarm_get_appsvc_info(void *pObject, int pid, alarm_id_t g_free(cookie); return true; +#endif } if (return_code) @@ -2419,6 +2465,41 @@ 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; + __alarm_info_t *find_item = 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) { + find_item = entry; + break; + } + } + + if (find_item == 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(find_item); + *return_code = 0; + } + return true; +} + #include "alarm-skeleton.h" typedef struct AlarmManagerObject AlarmManagerObject; @@ -2490,7 +2571,7 @@ static void __initialize_alarm_list() #endif } -static void __initialize_scheduled_alarm_lsit() +static void __initialize_scheduled_alarm_list() { _init_scheduled_alarm_list(); } @@ -2499,7 +2580,7 @@ static void __initialize_scheduled_alarm_lsit() static void __hibernation_leave_callback() { - __initialize_scheduled_alarm_lsit(); + __initialize_scheduled_alarm_list(); __alarm_clean_list(); @@ -2568,6 +2649,8 @@ static DBusHandlerResult __alarm_server_filter(DBusConnection *connection, if (entry->data) { expire_info = (__expired_alarm_t *) entry->data; + ALARM_MGR_LOG_PRINT("service_name(%s), service(%s)", expire_info->service_name, service); + if (strcmp(expire_info->service_name, service) == 0) { ALARM_MGR_EXCEPTION_PRINT( @@ -2758,15 +2841,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 @@ -2775,7 +2881,7 @@ static void __initialize() "alarm-server cannot be runned.\n"); exit(1); } - __initialize_scheduled_alarm_lsit(); + __initialize_scheduled_alarm_list(); __initialize_db(); __initialize_alarm_list(); __initialize_noti(); diff --git a/alarm-server.manifest b/alarm-server.manifest index 2468250..56dc572 100644..100755 --- a/alarm-server.manifest +++ b/alarm-server.manifest @@ -3,6 +3,7 @@ <domain name="alarm-server"/> <provide> <label name="alarm-server::db"/> + <label name="alarm-server::alarm"/> </provide> </define> <request> diff --git a/alarm_mgr.xml b/alarm_mgr.xml index 92a83f2..6641ac0 100644..100755 --- a/alarm_mgr.xml +++ b/alarm_mgr.xml @@ -62,7 +62,7 @@ <method name="alarm_check_next_duetime"> <arg type="i" name="pid" direction="in" /> <arg type="i" name="alarm_info_return_code" direction="out" /> - </method> + </method> <method name="alarm_update"> <arg type="i" name="pid" direction="in" /> <arg type="s" name="app_service_name" direction="in" /> @@ -130,5 +130,11 @@ <arg type="s" name="cookie" direction="in" /> <arg type="i" name="return_code" direction="out" /> </method> + <method name="alarm_get_next_duetime"> + <arg type="i" name="pid" direction="in" /> + <arg type="i" name="alarm_id" direction="in" /> + <arg type="i" name="duetime" direction="out" /> + <arg type="i" name="return_code" direction="out" /> + </method> </interface> </node> 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<stdio.h> #include<stdlib.h> @@ -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, /**<Invalid time. */ ERR_ALARM_INVALID_DATE, /**<Invalid date. */ ERR_ALARM_NO_SERVICE_NAME, - /**<there is no alarm service + /**<there is no alarm service for this applicaation. */ ERR_ALARM_INVALID_TYPE, /*Invalid type*/ ERR_ALARM_NO_PERMISSION, /*No permission*/ @@ -204,9 +204,9 @@ typedef enum { * This enumeration has repeat mode of alarm */ typedef enum { - ALARM_REPEAT_MODE_ONCE = 0, /**<once : the alarm will be expired + ALARM_REPEAT_MODE_ONCE = 0, /**<once : the alarm will be expired only one time. */ - ALARM_REPEAT_MODE_REPEAT, /**<repeat : the alarm will be expired + ALARM_REPEAT_MODE_REPEAT, /**<repeat : the alarm will be expired repeatly*/ ALARM_REPEAT_MODE_WEEKLY, /**<weekly*/ ALARM_REPEAT_MODE_MONTHLY, /**< monthly*/ @@ -238,16 +238,16 @@ typedef struct alarm_info_t alarm_entry_t; /** * - * This function initializes alarm library. It connects to system bus and registers the application's service name. + * This function initializes alarm library. It connects to system bus and registers the application's service name. * * @param [in] pkg_name a package of application * - * @return On success, ALARMMGR_RESULT_SUCCESS is returned. On error, a negative number is returned + * @return On success, ALARMMGR_RESULT_SUCCESS is returned. On error, a negative number is returned * * @pre None. * @post None. * @see None. - * @remark An application must call this function before using other alarm APIs. + * @remark An application must call this function before using other alarm APIs. * @par Sample code: * @code #include <alarm.h> @@ -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 <alarm.h> ... -// 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 <alarm.h> - + ... { 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 <alarm.h> - + ... { 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 <alarm.h> - + ... { 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 <alarm.h> - + ... { 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 <alarm.h> - + ... { 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 <alarm.h> - ... + ... { 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 <alarm.h> - ... + ... { 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 <alarm.h> - ... + ... { 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 <alarm.h> - ... + ... { 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 <alarm.h> - ... + ... { 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 <alarm.h> - ... + ... { 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 <alarm.h> - ... + ... { 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 <alarm.h> - + 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 ac7894c..910f6f7 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.84 Release: 1 Group: System/Libraries License: Apache License, Version 2.0 |