diff options
author | Inkyun Kil <inkyun.kil@samsung.com> | 2019-04-15 16:10:51 +0900 |
---|---|---|
committer | Inkyun Kil <inkyun.kil@samsung.com> | 2019-06-03 06:20:51 +0000 |
commit | 65e9c06ccad0e49bb7e1dfd93026ec6db8acb321 (patch) | |
tree | de74d081a8ebd72dfd79281dce3a486d39b692f0 | |
parent | f77e9585ff4dad4a2acc0da5447b12a08391df2d (diff) | |
download | alarm-manager-65e9c06ccad0e49bb7e1dfd93026ec6db8acb321.tar.gz alarm-manager-65e9c06ccad0e49bb7e1dfd93026ec6db8acb321.tar.bz2 alarm-manager-65e9c06ccad0e49bb7e1dfd93026ec6db8acb321.zip |
Dispensables
- Remove needless comments
- Remove dead codes
- Remove duplicated codes
Change-Id: I6c7400e58551bf73d99e5c3b4fe64e476b097c92
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
-rwxr-xr-x | include/alarm-internal.h | 41 | ||||
-rw-r--r-- | lib/alarm-lib-stub.c | 36 | ||||
-rwxr-xr-x | lib/alarm-lib.c | 324 | ||||
-rw-r--r-- | server/alarm-manager-schedule.c | 49 | ||||
-rw-r--r-- | server/alarm-manager-timer.c | 8 | ||||
-rwxr-xr-x | server/alarm-manager.c | 66 |
6 files changed, 85 insertions, 439 deletions
diff --git a/include/alarm-internal.h b/include/alarm-internal.h index 1c70bd6..17f5f92 100755 --- a/include/alarm-internal.h +++ b/include/alarm-internal.h @@ -50,23 +50,6 @@ extern "C" { #endif #define LOG_TAG "ALARM_MANAGER" -/*Application ID for native application which is not launched by application -server.*/ -#define ALARM_NATIVE_APP_ID 99999 -/* Application Instance ID for native application which is not launched by -application server.*/ -#define ALARM_NATIVE_APP_INST_ID 99999 -/* Prefix of dbus service name of native application.*/ -#define ALARM_NATIVE_APP_DBUS_SVC_NAME_PREFIX "NATIVE" - -/* how to send expire event : gproxy or low level dbus -* if you want to use gproxy for receiving expire_event, please enable -* _EXPIRE_ALARM_INTERFACE_IS_DBUS_GPROXY_ feature -* otherwise, lowlevel dbus interface will be used for receiving expire_event. -* Now we use low level dbus instead of gproxy -*/ -/*#define _EXPIRE_ALARM_INTERFACE_IS_DBUS_GPROXY_ */ - typedef struct { GDBusConnection *connection; GDBusConnection *session_conn; @@ -85,24 +68,10 @@ enum async_param_type { SET_SYSTIME_WITH_PROPAGATION_DELAY, }; -/** -* This enumeration has alarm type - -typedef enum -{ - ALARM_TYPE_DEFAULT = 0x0, - ALARM_TYPE_RELATIVE = 0x01, - ALARM_TYPE_VOLATILE = 0x02, -}alarm_type_t; -*/ #define ALARM_TYPE_RELATIVE 0x80000000 /**< relative */ #define ALARM_TYPE_WITHCB 0x40000000 /**< withcb */ #define ALARM_TYPE_PERIOD 0x10000000 /**< periodic */ -/** -* This struct has the information of an alarm -*/ - bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm, alarm_id_t *id, const char *dst_service_name, const char *dst_service_name_mod, int *error_code); bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info, @@ -206,7 +175,6 @@ bool _save_alarms(__alarm_info_t *__alarm_info); bool _delete_alarms(alarm_id_t alarm_id); bool _update_alarms(__alarm_info_t *__alarm_info); -bool _alarm_destory_timer(timer_t timer); bool _alarm_set_timer(__alarm_server_context_t *alarm_context, int timer, time_t due_time); bool _alarm_disable_timer(__alarm_server_context_t alarm_context); bool _init_scheduled_alarm_list(); @@ -216,18 +184,9 @@ time_t _get_periodic_alarm_standard_time(void); void _update_db_for_disabled_alarm(alarm_id_t alarm_id, bool disabled_by_ups); -#ifdef _DEBUG_MODE_ -#define ALARM_MGR_LOG_PRINT(FMT, ARG...) do { printf("%5d", getpid()); printf - ("%s() : "FMT"\n", __FUNCTION__, ##ARG); } while (false) -#define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...) do { printf("%5d", getpid()); - printf("%s() : "FMT"\n", __FUNCTION__, ##ARG); } while (false) -#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...) LOGD(FMT, ##ARG) #define ALARM_MGR_EXCEPTION_PRINT(FMT, ARG...) LOGW(FMT, ##ARG) #define ALARM_MGR_ASSERT_PRINT(FMT, ARG...) LOGE(FMT, ##ARG) -#endif #define CHECK_NULL_STRING(x) x ? x : "null" #define STRDUP_WITH_NULLCMP(a) strcmp(a, "null") ? strdup(a) : NULL diff --git a/lib/alarm-lib-stub.c b/lib/alarm-lib-stub.c index 96e304f..4740a43 100644 --- a/lib/alarm-lib-stub.c +++ b/lib/alarm-lib-stub.c @@ -98,8 +98,6 @@ bool _send_alarm_create_noti(alarm_context_t context, alarm_info_t *alarm_info, g_variant_unref(noti_gv); if (ret != TRUE) { - /* g_dbus_proxy_call_sync error */ - /* error_code should be set */ ALARM_MGR_EXCEPTION_PRINT( "alarm_manager_call_alarm_create_noti_sync()failed. alarm_id[%d], return_code[%d].", *(int *)alarm_id, return_code); @@ -166,8 +164,6 @@ bool _send_alarm_create_appsvc(alarm_context_t context, alarm_info_t *alarm_info } if (ret != TRUE) { - /* g_dbus_proxy_call_sync error */ - /* error_code should be set */ ALARM_MGR_EXCEPTION_PRINT( "alarm_manager_call_alarm_create_appsvc_sync()failed. alarm_id[%d], return_code[%d].", *(int *)alarm_id, return_code); @@ -230,8 +226,6 @@ bool _send_alarm_create(alarm_context_t context, alarm_info_t *alarm_info, dst_service_name, dst_service_name_mod, alarm_id, &return_code, NULL, &error)) { - /* g_dbus_proxy_call_sync error error */ - /* error_code should be set */ ALARM_MGR_EXCEPTION_PRINT( "alarm_manager_call_alarm_create_sync()failed. alarm_id[%d], return_code[%d]", *(int *)alarm_id, return_code); @@ -308,8 +302,6 @@ bundle *_send_alarm_get_appsvc_info(alarm_context_t context, alarm_id_t alarm_id if (!alarm_manager_call_alarm_get_appsvc_info_sync ((AlarmManager *)context.proxy, alarm_id, &b_data, &return_code, NULL, &error)) { - /* g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_get_appsvc_info_sync() failed. alarm_id[%d], return_code[%d].", (int)alarm_id, return_code); if (error_code) { @@ -355,8 +347,6 @@ notification_h _send_alarm_get_noti_info(alarm_context_t context, alarm_id_t ala if (!alarm_manager_call_alarm_get_noti_info_sync ((AlarmManager *)context.proxy, alarm_id, ¬i_data, &return_code, NULL, &error)) { - /* g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_get_appsvc_info_sync() failed. alarm_id[%d], return_code[%d].", (int)alarm_id, return_code); if (error_code) { @@ -410,8 +400,6 @@ bool _send_alarm_set_rtc_time(alarm_context_t context, alarm_date_t *time, int * if (!alarm_manager_call_alarm_set_rtc_time_sync ((AlarmManager *)context.proxy, time->year, time->month, time->day, time->hour, time->min, time->sec, &return_code, NULL, &error)) { - /* g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_set_rtc_time() failed. return_code[%d]", return_code); if (error_code) { if (error && error->code == G_DBUS_ERROR_ACCESS_DENIED) @@ -443,8 +431,6 @@ bool _send_alarm_delete(alarm_context_t context, alarm_id_t alarm_id, int *error if (!alarm_manager_call_alarm_delete_sync ((AlarmManager *)context.proxy, alarm_id, &return_code, NULL, &error)) { - /* g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_delete_sync() failed. alarm_id[%d], return_code[%d]", (int)alarm_id, return_code); if (error_code) { @@ -477,8 +463,6 @@ bool _send_alarm_delete_all(alarm_context_t context, int *error_code) if (!alarm_manager_call_alarm_delete_all_sync ((AlarmManager *)context.proxy, &return_code, NULL, &error)) { - /* g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_delete_all_sync() failed. return_code[%d]", return_code); if (error_code) { if (error && error->code == G_DBUS_ERROR_ACCESS_DENIED) @@ -514,8 +498,6 @@ bool _send_alarm_get_list_of_ids(alarm_context_t context, int maxnum_of_ids, if (!alarm_manager_call_alarm_get_list_of_ids_sync((AlarmManager *)context.proxy, maxnum_of_ids, &alarm_array, num_of_ids, &return_code, NULL, &error)) { - /* g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT( "alarm_manager_call_alarm_get_list_of_ids_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", *(int *)alarm_id, return_code); @@ -560,8 +542,6 @@ bool _send_alarm_get_number_of_ids(alarm_context_t context, int *num_of_ids, gint return_code = 0; if (!alarm_manager_call_alarm_get_number_of_ids_sync((AlarmManager *)context.proxy, num_of_ids, &return_code, NULL, &error)) { - /* g_dbus_proxy_call_sync error */ - /* error_code should be set */ ALARM_MGR_EXCEPTION_PRINT( "alarm_manager_call_alarm_get_number_of_ids_sync() failed by dbus. return_code[%d]", return_code); @@ -603,8 +583,6 @@ bool _send_alarm_get_info(alarm_context_t context, alarm_id_t alarm_id, &alarm_info->mode.u_interval.day_of_week, (gint *)&alarm_info->mode.repeat, &alarm_info->alarm_type, &alarm_info->reserved_info, &return_code, NULL, &error)) { - /* g_dbus_proxy_call_sync error */ - /* error_code should be set */ ALARM_MGR_EXCEPTION_PRINT( "alarm_manager_call_alarm_get_info_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", (int)alarm_id, return_code); @@ -639,8 +617,6 @@ bool _send_alarm_get_next_duetime(alarm_context_t context, if (!alarm_manager_call_alarm_get_next_duetime_sync((AlarmManager *)context.proxy, alarm_id, (gint *)duetime, &return_code, NULL, &error)) { - /*g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT( "alarm_manager_call_alarm_get_next_duetime_sync() failed by dbus. alarm_id[%d], return_code[%d]\n", (int)alarm_id, return_code); @@ -672,8 +648,6 @@ bool _send_alarm_get_all_info(alarm_context_t context, char **db_path, int *erro int return_code = 0; if (!alarm_manager_call_alarm_get_all_info_sync((AlarmManager *)context.proxy, db_path, &return_code, NULL, &error)) { - /*g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_get_all_info_sync() failed by dbus. return_code[%d]", return_code); if (error_code) { if (error && error->code == G_DBUS_ERROR_ACCESS_DENIED) @@ -703,8 +677,6 @@ bool _send_alarm_set_time(alarm_context_t context, int new_time, int *error_code int return_code = 0; if (!alarm_manager_call_alarm_set_time_sync((AlarmManager *)context.proxy, new_time, &return_code, NULL, &error)) { - /*g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_set_time_sync() failed by dbus. return_code[%d]", return_code); if (error) { ALARM_MGR_EXCEPTION_PRINT("dbus error message: %s", error->message); @@ -772,8 +744,6 @@ bool _send_alarm_set_time_with_propagation_delay(alarm_context_t context, unsign int return_code = 0; if (!alarm_manager_call_alarm_set_time_with_propagation_delay_sync((AlarmManager *)context.proxy, new_sec, new_nsec, req_sec, req_nsec, &return_code, NULL, &error)) { - /*g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_set_time_with_propagation_delay_sync() failed by dbus. return_code[%d]", return_code); if (error_code) { if (error && error->code == G_DBUS_ERROR_ACCESS_DENIED) @@ -846,8 +816,6 @@ bool _send_alarm_set_timezone(alarm_context_t context, char *tzpath_str, int *er int return_code = 0; if (!alarm_manager_call_alarm_set_timezone_sync((AlarmManager *)context.proxy, tzpath_str, &return_code, NULL, &error)) { - /*g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_set_timezone_sync() failed by dbus. return_code[%d]", return_code); if (error_code) { if (error && error->code == G_DBUS_ERROR_ACCESS_DENIED) @@ -877,8 +845,6 @@ bool _send_alarm_set_global(alarm_context_t context, const alarm_id_t alarm_id, int return_code = 0; if (!alarm_manager_call_alarm_set_global_sync((AlarmManager *)context.proxy, alarm_id, global, &return_code, NULL, &error)) { - /*g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_set_global_sync() failed by dbus. return_code[%d]", return_code); if (error_code) { if (error && error->code == G_DBUS_ERROR_ACCESS_DENIED) @@ -909,8 +875,6 @@ bool _send_alarm_get_global(alarm_context_t context, const alarm_id_t alarm_id, gboolean _global; if (!alarm_manager_call_alarm_get_global_sync((AlarmManager *)context.proxy, alarm_id, &_global, &return_code, NULL, &error)) { - /*g_dbus_proxy_call_sync error */ - /*error_code should be set */ ALARM_MGR_EXCEPTION_PRINT("alarm_manager_call_alarm_get_global_sync() failed by dbus. return_code[%d]", return_code); if (error_code) { if (error->code == G_DBUS_ERROR_ACCESS_DENIED) diff --git a/lib/alarm-lib.c b/lib/alarm-lib.c index 383a9b9..4236415 100755 --- a/lib/alarm-lib.c +++ b/lib/alarm-lib.c @@ -98,12 +98,60 @@ static const GDBusInterfaceVTable interface_vtable = { NULL }; -void _initialize_alarm_info(alarm_info_t *alarm) +void _initialize_alarm_info(alarm_info_t *alarm_info, int alarm_type, + time_t trigger_at_time, time_t interval, bool precision) { - memset(alarm, 0, sizeof(alarm_info_t)); + struct timeval current_time; + struct tm duetime_tm; - alarm->mode.repeat = ALARM_REPEAT_MODE_ONCE; - alarm->alarm_type = ALARM_TYPE_DEFAULT; + gettimeofday(¤t_time, NULL); + + memset(alarm_info, 0, sizeof(alarm_info_t)); + + alarm_info->mode.repeat = ALARM_REPEAT_MODE_ONCE; + alarm_info->alarm_type = alarm_type; + + if (current_time.tv_usec > 500 * 1000) { + /* When the millisecond part of the current_time is bigger than 500ms, + * the duetime increases by extra 1sec. */ + current_time.tv_sec += (trigger_at_time + 1); + } else { + current_time.tv_sec += trigger_at_time; + } + alarm_info->reserved_info = current_time.tv_sec; + + tzset(); /* Processes the TZ environment variable, and Set timezone, daylight, and tzname. */ + localtime_r(¤t_time.tv_sec, &duetime_tm); + + alarm_info->start.year = duetime_tm.tm_year + 1900; + alarm_info->start.month = duetime_tm.tm_mon + 1; + alarm_info->start.day = duetime_tm.tm_mday; + + alarm_info->end.year = 0; + alarm_info->end.month = 0; + alarm_info->end.day = 0; + + alarm_info->start.hour = duetime_tm.tm_hour; + alarm_info->start.min = duetime_tm.tm_min; + alarm_info->start.sec = duetime_tm.tm_sec; + + if (interval <= 0) { + alarm_info->mode.repeat = ALARM_REPEAT_MODE_ONCE; + alarm_info->mode.u_interval.interval = 0; + } else { + alarm_info->mode.repeat = ALARM_REPEAT_MODE_REPEAT; + alarm_info->mode.u_interval.interval = interval; + } + + alarm_info->msec = precision ? (int)current_time.tv_usec / 1000 : 0; + + ALARM_MGR_LOG_PRINT("trigger_at_time(%ld), 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, (int)alarm_info->mode.u_interval.interval, + alarm_info->alarm_type); } static void __add_resultcb(alarm_id_t alarm_id, alarm_cb_t cb_func, void *data) @@ -825,7 +873,7 @@ EXPORT_API int alarmmgr_set_rtc_time(alarm_date_t *time) EXPORT_API int alarmmgr_add_alarm_appsvc_with_localtime(alarm_entry_t *alarm, void *bundle_data, alarm_id_t *alarm_id) { - alarm_info_t *alarm_info = NULL; /* = (alarm_info_t*)alarm; */ + alarm_info_t *alarm_info = NULL; const char *operation = NULL; int error_code = 0; const char *appid = NULL; @@ -902,7 +950,7 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm, { char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 }; char dst_service_name_mod[MAX_SERVICE_NAME_LEN] = { 0 }; - alarm_info_t *alarm_info; /* = (alarm_info_t*)alarm; */ + alarm_info_t *alarm_info = NULL; int ret; int i = 0; int j = 0; @@ -981,7 +1029,7 @@ EXPORT_API int alarmmgr_add_alarm_with_localtime(alarm_entry_t *alarm, EXPORT_API int alarmmgr_add_alarm_noti_with_localtime(alarm_entry_t *alarm, notification_h noti, alarm_id_t *alarm_id) { - alarm_info_t *alarm_info = NULL; /* = (alarm_info_t*)alarm; */ + alarm_info_t *alarm_info = NULL; int error_code = 0; if (alarm == NULL) @@ -993,11 +1041,11 @@ EXPORT_API int alarmmgr_add_alarm_noti_with_localtime(alarm_entry_t *alarm, noti } alarm_info = (alarm_info_t *)alarm; - if (alarm_info == NULL || alarm_id == NULL) { ALARM_MGR_EXCEPTION_PRINT("Invalid parameter\n"); return ERR_ALARM_INVALID_PARAM; } + alarm_mode_t *mode = &alarm_info->mode; ALARM_MGR_EXCEPTION_PRINT("start(%d-%d-%d, %02d:%02d:%02d), end(%d-%d-%d), repeat(%d), interval(%d), type(%d)", @@ -1037,8 +1085,6 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, { int error_code = 0; int result = 0; - struct timeval current_time; - struct tm duetime_tm; alarm_info_t alarm_info; const char *operation = NULL; const char *appid = NULL; @@ -1052,8 +1098,6 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, return ERR_ALARM_INVALID_PARAM; } - _initialize_alarm_info(&alarm_info); - operation = appsvc_get_operation(b); if (operation == NULL) appsvc_set_operation(b, APPSVC_OPERATION_DEFAULT); @@ -1077,33 +1121,11 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, if (trigger_at_time < 0) return ERR_ALARM_INVALID_PARAM; - alarm_info.alarm_type = alarm_type; - alarm_info.alarm_type |= ALARM_TYPE_RELATIVE; - - gettimeofday(¤t_time, NULL); - if (current_time.tv_usec > 500 * 1000) { - /* When the millisecond part of the current_time is bigger than 500ms, - * the duetime increases by extra 1sec. */ - current_time.tv_sec += (trigger_at_time + 1); - } else { - current_time.tv_sec += trigger_at_time; - } - alarm_info.reserved_info = current_time.tv_sec; - - tzset(); /* Processes the TZ environment variable, and Set timezone, daylight, and tzname. */ - localtime_r(¤t_time.tv_sec, &duetime_tm); - - alarm_info.start.year = duetime_tm.tm_year + 1900; - alarm_info.start.month = duetime_tm.tm_mon + 1; - alarm_info.start.day = duetime_tm.tm_mday; - - alarm_info.end.year = 0; - alarm_info.end.month = 0; - alarm_info.end.day = 0; + _initialize_alarm_info(&alarm_info, alarm_type, trigger_at_time, interval, + false); - alarm_info.start.hour = duetime_tm.tm_hour; - alarm_info.start.min = duetime_tm.tm_min; - alarm_info.start.sec = duetime_tm.tm_sec; + alarm_info.alarm_type |= ALARM_TYPE_RELATIVE; + ALARM_MGR_LOG_PRINT("alarm_info.type : %d", alarm_info.alarm_type); if (__compare_api_version(&result, getuid()) < 0) return ERR_ALARM_SYSTEM_FAIL; @@ -1112,21 +1134,9 @@ EXPORT_API int alarmmgr_add_alarm_appsvc(int alarm_type, time_t trigger_at_time, alarm_info.alarm_type ^= ALARM_TYPE_INEXACT; } - if ((alarm_type & ALARM_TYPE_INEXACT) && interval < MIN_INEXACT_INTERVAL) - interval = MIN_INEXACT_INTERVAL; - - if (interval <= 0) { - alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE; - alarm_info.mode.u_interval.interval = 0; - } else { - alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT; - alarm_info.mode.u_interval.interval = interval; - } - - ALARM_MGR_LOG_PRINT("trigger_at_time(%ld), 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, (int)alarm_info.mode.u_interval.interval, alarm_info.alarm_type); + if ((alarm_type & ALARM_TYPE_INEXACT) && + alarm_info.mode.u_interval.interval < MIN_INEXACT_INTERVAL) + alarm_info.mode.u_interval.interval = MIN_INEXACT_INTERVAL; if (!_send_alarm_create_appsvc(alarm_context, &alarm_info, alarm_id, b, &error_code)) return error_code; @@ -1139,8 +1149,6 @@ EXPORT_API int alarmmgr_add_alarm_noti(int alarm_type, time_t trigger_at_time, alarm_id_t *alarm_id) { int error_code = 0; - struct timeval current_time; - struct tm duetime_tm; alarm_info_t alarm_info; if (__alarmmgr_init_appsvc() < 0) { @@ -1154,51 +1162,15 @@ EXPORT_API int alarmmgr_add_alarm_noti(int alarm_type, time_t trigger_at_time, if (trigger_at_time < 0) return ERR_ALARM_INVALID_PARAM; - _initialize_alarm_info(&alarm_info); + _initialize_alarm_info(&alarm_info, alarm_type, trigger_at_time, interval, + false); - alarm_info.alarm_type = alarm_type; alarm_info.alarm_type |= ALARM_TYPE_RELATIVE; + ALARM_MGR_LOG_PRINT("alarm_info.type : %d", alarm_info.alarm_type); - gettimeofday(¤t_time, NULL); - if (current_time.tv_usec > 500 * 1000) { - /* When the millisecond part of the current_time is bigger than 500ms, - * the duetime increases by extra 1sec. */ - current_time.tv_sec += (trigger_at_time + 1); - } else { - current_time.tv_sec += trigger_at_time; - } - alarm_info.reserved_info = current_time.tv_sec; - - tzset(); /* Processes the TZ environment variable, and Set timezone, daylight, and tzname. */ - localtime_r(¤t_time.tv_sec, &duetime_tm); - - alarm_info.start.year = duetime_tm.tm_year + 1900; - alarm_info.start.month = duetime_tm.tm_mon + 1; - alarm_info.start.day = duetime_tm.tm_mday; - - alarm_info.end.year = 0; - alarm_info.end.month = 0; - alarm_info.end.day = 0; - - alarm_info.start.hour = duetime_tm.tm_hour; - alarm_info.start.min = duetime_tm.tm_min; - alarm_info.start.sec = duetime_tm.tm_sec; - - if ((alarm_info.alarm_type & ALARM_TYPE_INEXACT) && interval < MIN_INEXACT_INTERVAL) - interval = MIN_INEXACT_INTERVAL; - - if (interval <= 0) { - alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE; - alarm_info.mode.u_interval.interval = 0; - } else { - alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT; - alarm_info.mode.u_interval.interval = interval; - } - - ALARM_MGR_LOG_PRINT("trigger_at_time(%ld), 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, (int)alarm_info.mode.u_interval.interval, alarm_info.alarm_type); + if ((alarm_info.alarm_type & ALARM_TYPE_INEXACT) && + alarm_info.mode.u_interval.interval < MIN_INEXACT_INTERVAL) + alarm_info.mode.u_interval.interval = MIN_INEXACT_INTERVAL; if (!_send_alarm_create_noti(alarm_context, &alarm_info, alarm_id, noti, &error_code)) return error_code; @@ -1216,15 +1188,9 @@ static int _alarmmgr_add_alarm(int alarm_type, int i = 0; int j = 0; int error_code; - struct timeval current_time; - struct tm duetime_tm; alarm_info_t alarm_info; int ret; - gettimeofday(¤t_time, NULL); - - _initialize_alarm_info(&alarm_info); - ret = __sub_init(); if (ret < 0) return ret; @@ -1240,48 +1206,12 @@ static int _alarmmgr_add_alarm(int alarm_type, return ERR_ALARM_INVALID_PARAM; } - alarm_info.alarm_type = alarm_type; - alarm_info.alarm_type |= ALARM_TYPE_RELATIVE; - - - if (current_time.tv_usec > 500 * 1000) { - /* When the millisecond part of the current_time is bigger than 500ms, - * the duetime increases by extra 1sec. */ - current_time.tv_sec += (trigger_at_time + 1); - } else { - current_time.tv_sec += trigger_at_time; - } - alarm_info.reserved_info = current_time.tv_sec; - - tzset(); /* Processes the TZ environment variable, and Set timezone, daylight, and tzname. */ - localtime_r(¤t_time.tv_sec, &duetime_tm); - - alarm_info.start.year = duetime_tm.tm_year + 1900; - alarm_info.start.month = duetime_tm.tm_mon + 1; - alarm_info.start.day = duetime_tm.tm_mday; - - alarm_info.msec = precision ? (int)current_time.tv_usec / 1000 : 0; + _initialize_alarm_info(&alarm_info, alarm_type, trigger_at_time, interval, + precision); - alarm_info.end.year = 0; - alarm_info.end.month = 0; - alarm_info.end.day = 0; - - alarm_info.start.hour = duetime_tm.tm_hour; - alarm_info.start.min = duetime_tm.tm_min; - alarm_info.start.sec = duetime_tm.tm_sec; - - if (interval <= 0) { - alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE; - alarm_info.mode.u_interval.interval = 0; - } else { - alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT; - alarm_info.mode.u_interval.interval = interval; - } + alarm_info.alarm_type |= ALARM_TYPE_RELATIVE; - ALARM_MGR_LOG_PRINT("trigger_at_time(%ld), 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, (int)alarm_info.mode.u_interval.interval, alarm_info.alarm_type); + ALARM_MGR_LOG_PRINT("alarm_info.type : %d", alarm_info.alarm_type); if (destination != NULL) { memset(dst_service_name, 0, @@ -1337,15 +1267,9 @@ static int _alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time, alarm_id_t *alarm_id, bool precision) { int error_code = 0; - struct timeval current_time; - struct tm duetime_tm; alarm_info_t alarm_info; int ret = 0; - gettimeofday(¤t_time, NULL); - - _initialize_alarm_info(&alarm_info); - if (flag_appid_checked == 0) { if (aul_app_get_appid_bypid(getpid(), g_appid, sizeof(g_appid)) != AUL_R_OK) ALARM_MGR_EXCEPTION_PRINT("PID[%d] may not be app. Please call alarmmgr_init(caller name) in advance.", getpid()); @@ -1366,48 +1290,13 @@ static int _alarmmgr_add_alarm_withcb(int alarm_type, time_t trigger_at_time, if (trigger_at_time < 0) return ERR_ALARM_INVALID_PARAM; - alarm_info.alarm_type = alarm_type; + _initialize_alarm_info(&alarm_info, alarm_type, trigger_at_time, interval, + precision); + alarm_info.alarm_type |= ALARM_TYPE_RELATIVE; alarm_info.alarm_type |= ALARM_TYPE_WITHCB; - if (current_time.tv_usec > 500 * 1000) { - /* When the millisecond part of the current_time is bigger than 500ms, */ - /* the duetime increases by extra 1sec. */ - current_time.tv_sec += (trigger_at_time + 1); - } else { - current_time.tv_sec += trigger_at_time; - } - alarm_info.reserved_info = current_time.tv_sec; - - tzset(); /* Processes the TZ environment variable, and Set timezone, daylight, and tzname. */ - localtime_r(¤t_time.tv_sec, &duetime_tm); - - alarm_info.start.year = duetime_tm.tm_year + 1900; - alarm_info.start.month = duetime_tm.tm_mon + 1; - alarm_info.start.day = duetime_tm.tm_mday; - - alarm_info.msec = precision ? (int)current_time.tv_usec / 1000 : 0; - - alarm_info.end.year = 0; - alarm_info.end.month = 0; - alarm_info.end.day = 0; - - alarm_info.start.hour = duetime_tm.tm_hour; - alarm_info.start.min = duetime_tm.tm_min; - alarm_info.start.sec = duetime_tm.tm_sec; - - if (interval <= 0) { - alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE; - alarm_info.mode.u_interval.interval = 0; - } else { - alarm_info.mode.repeat = ALARM_REPEAT_MODE_REPEAT; - alarm_info.mode.u_interval.interval = interval; - } - - ALARM_MGR_LOG_PRINT("trigger_at_time(%ld), 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, (int)alarm_info.mode.u_interval.interval, alarm_info.alarm_type); + ALARM_MGR_LOG_PRINT("alarm_info.type : %d", alarm_info.alarm_type); if (!_send_alarm_create(alarm_context, &alarm_info, alarm_id, "null", "null", &error_code)) return error_code; @@ -1493,7 +1382,6 @@ EXPORT_API int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param) SECURE_LOGD("alarm_manager_call_alarm_get_number_of_ids_sync() is called"); if (!alarm_manager_call_alarm_get_number_of_ids_sync( (AlarmManager *)alarm_context.proxy, &maxnum_of_ids, &return_code, NULL, &error)) { - /* dbus error. error_code should be set */ ALARM_MGR_EXCEPTION_PRINT( "alarm_manager_call_alarm_get_number_of_ids_sync() is failed by dbus. return_code[%d], err message[%s] err code[%d]", return_code, error->message, error->code); @@ -1515,7 +1403,6 @@ EXPORT_API int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param) SECURE_LOGD("alarm_manager_call_alarm_get_list_of_ids_sync() is called"); if (!alarm_manager_call_alarm_get_list_of_ids_sync( (AlarmManager *)alarm_context.proxy, maxnum_of_ids, &alarm_array, &num_of_ids, &return_code, NULL, &error)) { - /* dbus error. error_code should be set */ ALARM_MGR_EXCEPTION_PRINT( "alarm_manager_call_alarm_get_list_of_ids_sync() failed by dbus. num_of_ids[%d], return_code[%d]. err message[%s] err code[%d]", num_of_ids, return_code, error->message, error->code); if (error->code == G_DBUS_ERROR_ACCESS_DENIED) @@ -1572,61 +1459,6 @@ EXPORT_API int alarmmgr_get_info(alarm_id_t alarm_id, alarm_entry_t *alarm) return ALARMMGR_RESULT_SUCCESS; } -int alarmmgr_create(alarm_info_t *alarm_info, char *destination, - alarm_id_t *alarm_id) -{ - char dst_service_name[MAX_SERVICE_NAME_LEN] = { 0 }; - alarm_mode_t *mode = &alarm_info->mode; - int error_code; - - ALARM_MGR_LOG_PRINT("[alarm-lib]:alarm_create() is called\n"); - - if (alarm_info == NULL || alarm_id == NULL) - return ERR_ALARM_INVALID_PARAM; - - 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); - - /* TODO: This should be changed to > ALARM_REPEAT_MODE_MAX ? */ - if (mode->repeat >= ALARM_REPEAT_MODE_MAX) - return ERR_ALARM_INVALID_PARAM; - - if (!__alarm_validate_date(&alarm_info->start, &error_code)) { - ALARM_MGR_EXCEPTION_PRINT("start date error\n"); - return error_code; - } - - if (!__alarm_validate_time(&alarm_info->start, &error_code)) { - ALARM_MGR_EXCEPTION_PRINT("start time error\n"); - return error_code; - } - - if (!__alarm_validate_date(&alarm_info->end, &error_code)) { - ALARM_MGR_EXCEPTION_PRINT("end date error\n"); - return error_code; - } - - if (destination != NULL) { - memset(dst_service_name, 0, - 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", - &error_code)) - return error_code; - } - - /*TODO: Currently this API is not exported. Hence not modifying*/ - if (!_send_alarm_create(alarm_context, alarm_info, alarm_id, - "null", "null", &error_code)) - return error_code; - - return ALARMMGR_RESULT_SUCCESS; -} - int alarmmgr_get_number_of_ids(int *num_of_ids) { int error_code; @@ -1916,7 +1748,7 @@ EXPORT_API int alarmmgr_get_global(const alarm_id_t alarm_id, EXPORT_API int alarmmgr_update_alarm(alarm_id_t alarm_id, alarm_entry_t *alarm, int update_flag) { - alarm_info_t *alarm_info; /* = (alarm_info_t*)alarm; */ + alarm_info_t *alarm_info; int ret; ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_update_alarm() is called\n"); diff --git a/server/alarm-manager-schedule.c b/server/alarm-manager-schedule.c index e19d535..b1fb77d 100644 --- a/server/alarm-manager-schedule.c +++ b/server/alarm-manager-schedule.c @@ -24,8 +24,7 @@ #include"alarm.h" #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; @@ -57,20 +56,7 @@ bool _init_scheduled_alarm_list() bool _add_to_scheduled_alarm_list(__alarm_info_t *__alarm_info) { - /* - * 20080328. Sewook Park(sewook7.park@samsung.com) - * When multiple alarms are expired at same time, dbus rpc call for alarm - * ui should be invoked first.(Ui conflicting manager cannot manage the - * different kinds of alarm popups(wake up alarm/org alarm) correctly, - * when they are displayed at same time)So when arranging the schedule - * alarm list, wake up alarm element is located ahead. - */ - - bool prior = false; - gint count = 0; - GSList *iter = NULL; __scheduled_alarm_t *alarm = NULL; - __scheduled_alarm_t *entry = NULL; alarm = (__scheduled_alarm_t *)g_malloc(sizeof(__scheduled_alarm_t)); if (alarm == NULL) @@ -86,28 +72,7 @@ bool _add_to_scheduled_alarm_list(__alarm_info_t *__alarm_info) __FUNCTION__, alarm->uid, alarm->pid, alarm->__alarm_info->app_service_name); - if (alarm->__alarm_info->app_service_name && - strcmp(WAKEUP_ALARM_APP_ID, alarm->__alarm_info->app_service_name)) { - g_scheduled_alarm_list = g_slist_append(g_scheduled_alarm_list, alarm); - } else { - for (iter = g_scheduled_alarm_list; iter != NULL; iter = g_slist_next(iter)) { - count++; - entry = (__scheduled_alarm_t *)iter->data; - if (entry->__alarm_info->app_service_name && - strcmp(WAKEUP_ALARM_APP_ID, entry->__alarm_info->app_service_name)) { - prior = true; - break; - } - } - - if (!prior) { - g_scheduled_alarm_list = g_slist_append(g_scheduled_alarm_list, alarm); - ALARM_MGR_LOG_PRINT("appended : prior is %d\tcount is %d\n", prior, count); - } else { - g_scheduled_alarm_list = g_slist_insert(g_scheduled_alarm_list, alarm, count - 1); - ALARM_MGR_LOG_PRINT("appended : prior is %d\tcount is %d\n", prior, count); - } - } + g_scheduled_alarm_list = g_slist_append(g_scheduled_alarm_list, alarm); return true; } @@ -167,7 +132,7 @@ static time_t __alarm_next_duetime_once(__alarm_info_t *__alarm_info) due_time = mktime(&duetime_tm); if (!(due_time > current_time)) due_time = due_time + 60 * 60 * 24; - } else /*specific date*/ { + } else { duetime_tm.tm_year = start->year - 1900; duetime_tm.tm_mon = start->month - 1; duetime_tm.tm_mday = start->day; @@ -176,7 +141,7 @@ static time_t __alarm_next_duetime_once(__alarm_info_t *__alarm_info) if (due_time <= current_time) { ALARM_MGR_EXCEPTION_PRINT("duetime is less than or equal to current time. current_dst = %d", current_dst); - duetime_tm.tm_isdst = 0; /* DST off */ + duetime_tm.tm_isdst = 0; due_time_tmp = mktime(&duetime_tm); localtime_r(&due_time_tmp, &tmp_tm); @@ -212,7 +177,6 @@ static time_t __alarm_next_duetime_repeat(__alarm_info_t *__alarm_info) alarm_date_t *start = &alarm_info->start; time(¤t_time); - /*localtime_r(¤t_time, &duetime_tm); */ duetime_tm.tm_hour = start->hour; duetime_tm.tm_min = start->min; @@ -402,8 +366,7 @@ static time_t __alarm_next_duetime_weekly(__alarm_info_t *__alarm_info) wday = before_tm.tm_wday; - /* CQ defect(72810) : only one time alarm function is not working - under all recurrence_disabled. */ + /* Only one time alarm function with recurrence_disabled. */ if (due_time > current_time && mode->u_interval.day_of_week == 0) return due_time; @@ -525,7 +488,7 @@ static bool __find_next_alarm_to_be_scheduled(time_t *min_due_time) interval = difftime(due_time, current_time); - if (interval < 0) /*2008.08.06 when the alarm expires, it may makes an error.*/ { + if (interval < 0) /*When the alarm expires, it may makes an error.*/ { ALARM_MGR_EXCEPTION_PRINT("The duetime of alarm(%d) is OVER.", entry->alarm_id); continue; } diff --git a/server/alarm-manager-timer.c b/server/alarm-manager-timer.c index ee3e7c7..cf86ba2 100644 --- a/server/alarm-manager-timer.c +++ b/server/alarm-manager-timer.c @@ -28,14 +28,6 @@ extern bool g_dummy_timer_is_set; -bool _alarm_destory_timer(timer_t timer) -{ - if (timer_delete(timer) == 0) - return true; - else - return false; -} - bool _alarm_disable_timer(__alarm_server_context_t alarm_context) { struct itimerspec time_spec; diff --git a/server/alarm-manager.c b/server/alarm-manager.c index d735dd4..81d2c47 100755 --- a/server/alarm-manager.c +++ b/server/alarm-manager.c @@ -80,11 +80,6 @@ GSList *g_disabled_alarm_list; #define RTC_WKALM_BOOT_SET _IOW('p', 0x80, struct rtc_wkalrm) #endif -/* - * 2008. 6. 3 sewook7.park - * When the alarm becoms sleeping mode, alarm timer is not expired. - * So using RTC, phone is awaken before alarm rings. - */ #include <errno.h> #include <linux/rtc.h> #include <sys/ioctl.h> @@ -409,7 +404,6 @@ int __set_time(time_t _time) ALARM_MGR_EXCEPTION_PRINT("settimeofday is failed.[%d]", errno); if (_APPFW_FEATURE_WAKEUP_USING_RTC) { - /* Using /dev/alarm, this function changes both OS time and RTC. */ const char *rtc0 = default_rtc; struct rtc_time _rtc_time; #ifdef _APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG @@ -421,7 +415,7 @@ int __set_time(time_t _time) if (gfd < 0) { gfd = open(rtc0, O_RDWR); if (gfd < 0) { - ALARM_MGR_EXCEPTION_PRINT("Opening the /dev/alarm is failed."); + ALARM_MGR_EXCEPTION_PRINT("Opening the /dev/rtc is failed."); perror("\t"); return 1; } @@ -711,62 +705,6 @@ static bool __alarm_set_start_and_end_time(alarm_info_t *alarm_info, return true; } -/* -static bool alarm_get_tz_info(int *gmt_idx, int *dst) -{ - GConfValue *value1 = NULL; - GConfValue *value2 = NULL; - GConfClient* gConfClient = NULL; - GError* err = NULL; - - gConfClient = gconf_client_get_default(); - - if(gConfClient) { - value1 = gconf_client_get(gConfClient, SETTINGS_CLOCKTIMEZONE, - &err); - if (err) { - ALARM_MGR_LOG_PRINT("__on_system_time_changed: - gconf_client_get() failed: - error:[%s]\n", err->message); - g_error_free(err); - err = NULL; - } - *gmt_idx = gconf_value_get_int(value1); - ALARM_MGR_LOG_PRINT("gconf return gmt_idx =%d\n ", *gmt_idx); - - value2 = gconf_client_get(gConfClient, - SETTINGS_DAYLIGHTSTATUS, &err); - if (err) { - ALARM_MGR_LOG_PRINT("__on_system_time_changed: - gconf_client_get() failed: error:[%s]\n", err->message); - g_error_free(err); - err = NULL; - } - - *dst = gconf_value_get_int(value2); - ALARM_MGR_LOG_PRINT("gconf return dst =%d\n ", *dst); - - if(gConfClient != NULL) { - g_object_unref(gConfClient); - gConfClient = NULL; - } - } - else - ALARM_MGR_LOG_PRINT("check the gconf setting failed!!!!! \n "); - - if(value1) { - gconf_value_free(value1); - value1 = NULL; - } - if(value2) { - gconf_value_free(value2); - value2 = NULL; - } - - return true; -} -*/ - gboolean __update_relative_alarms(gpointer user_data) { GSList *iter = NULL; @@ -1770,8 +1708,6 @@ out: return _return; } - - static int __find_login_user(uid_t *uid) { uid_t *uids; |