diff options
-rwxr-xr-x | alarm-lib.c | 18 | ||||
-rwxr-xr-x | alarm-manager.c | 18 | ||||
-rw-r--r-- | include/alarm.h | 27 | ||||
-rw-r--r-- | packaging/alarm-manager.spec | 2 |
4 files changed, 50 insertions, 15 deletions
diff --git a/alarm-lib.c b/alarm-lib.c index 2bb484a..5977851 100755 --- a/alarm-lib.c +++ b/alarm-lib.c @@ -250,7 +250,7 @@ int alarmmgr_check_next_duetime() return ALARMMGR_RESULT_SUCCESS; } -EXPORT_API int alarmmgr_init(const char *pkg_name) +EXPORT_API int alarmmgr_init(const char *appid) { DBusError derror; int request_name_result = 0; @@ -261,10 +261,10 @@ EXPORT_API int alarmmgr_init(const char *pkg_name) int i = 0; int j = 0; - if (pkg_name == NULL) + if (appid == NULL) return ERR_ALARM_INVALID_PARAM; - if (strlen(pkg_name) >= MAX_PKG_NAME_LEN) + if (strlen(appid) >= MAX_PKG_NAME_LEN) return ERR_ALARM_INVALID_PARAM; if (b_initialized) { @@ -279,7 +279,7 @@ EXPORT_API int alarmmgr_init(const char *pkg_name) return ret; memset(service_name_mod, 'a', MAX_SERVICE_NAME_LEN-1); - strncpy(service_name, pkg_name, MAX_PKG_NAME_LEN); + strncpy(service_name, appid, MAX_PKG_NAME_LEN); j=0; @@ -1022,6 +1022,16 @@ EXPORT_API int alarmmgr_enum_alarm_ids(alarm_enum_fn_t fn, void *user_param) if (return_code != 0) { return return_code; } else { + if (error != NULL) { + ALARM_MGR_LOG_PRINT( + "Alarm server not ready dbus error message %s\n", error->message); + return ERR_ALARM_SYSTEM_FAIL; + } + if (NULL == alarm_array) { + ALARM_MGR_LOG_PRINT( + "alarm server not initilized\n"); + return ERR_ALARM_SYSTEM_FAIL; + } for (i = 0; i < alarm_array->len && i < maxnum_of_ids; i++) { alarm_id = g_array_index(alarm_array, alarm_id_t, i); (*fn) (alarm_id, user_param); diff --git a/alarm-manager.c b/alarm-manager.c index cd900f4..b179683 100755 --- a/alarm-manager.c +++ b/alarm-manager.c @@ -1352,11 +1352,11 @@ static void __alarm_expired() interval = difftime(alarm_context.c_due_time, current_time); ALARM_MGR_LOG_PRINT("[alarm-server]: c_due_time(%d), " - "current_time(%d), interval(%d)\n", alarm_context.c_due_time, + "current_time(%d), interval(%d)\n", alarm_context.c_due_time, current_time, interval); - if (alarm_context.c_due_time <= current_time - 1) { - ALARM_MGR_LOG_PRINT("Wrong alarm is expired\n"); + if (alarm_context.c_due_time > current_time) { + ALARM_MGR_LOG_PRINT("[alarm-server]: False Alarm\n"); goto done; } @@ -1464,7 +1464,7 @@ static void __alarm_expired() dbus_g_connection_get_connection(alarm_context.bus), destination_app_service_name, NULL) == FALSE) { __expired_alarm_t *expire_info; - char pkg_name[MAX_SERVICE_NAME_LEN] = { 0, }; + char appid[MAX_SERVICE_NAME_LEN] = { 0, }; char alarm_id_str[32] = { 0, }; expire_info = malloc(sizeof(__expired_alarm_t)); @@ -1483,22 +1483,22 @@ static void __alarm_expired() if (strncmp (g_quark_to_string(__alarm_info->quark_dst_service_name), "null",4) == 0) { - strncpy(pkg_name,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),strlen(g_quark_to_string(__alarm_info->quark_app_service_name))-6); } else { - strncpy(pkg_name,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),strlen(g_quark_to_string(__alarm_info->quark_dst_service_name))-6); } snprintf(alarm_id_str, 31, "%d", alarm_id); - ALARM_MGR_LOG_PRINT("before aul_launch pkg_name(%s) " - "alarm_id_str(%s)\n", pkg_name, alarm_id_str); + ALARM_MGR_LOG_PRINT("before aul_launch appid(%s) " + "alarm_id_str(%s)\n", appid, alarm_id_str); bundle *kb; kb = bundle_create(); bundle_add(kb, "__ALARM_MGR_ID", alarm_id_str); - aul_launch_app(pkg_name, kb); + aul_launch_app(appid, kb); bundle_free(kb); } else { ALARM_MGR_LOG_PRINT( diff --git a/include/alarm.h b/include/alarm.h index 7f80d3b..63c3940 100644 --- a/include/alarm.h +++ b/include/alarm.h @@ -271,7 +271,32 @@ typedef struct alarm_info_t alarm_entry_t; * @endcode * @limo */ -int alarmmgr_init(const char *pkg_name); +int alarmmgr_init(const char *appid); + +/** + * + * This function de-initializes alarm library. It un-registers the application's service name and dis-connects from system bus. + * + * @param None + * + * @return None + * + * @pre Alarm manager is initialized + * @post Alarm manager is de-initialized + * @remark An application must call this function once it is done with alarmmanger usage + * @par Sample code: + * @code +#include <alarm.h> + +... +{ + // Initialize alarmmanager + // Set alarm + + alarmmgr_fini() ; +} + * @endcode + */ void alarmmgr_fini(); diff --git a/packaging/alarm-manager.spec b/packaging/alarm-manager.spec index f309265..8659b09 100644 --- a/packaging/alarm-manager.spec +++ b/packaging/alarm-manager.spec @@ -1,7 +1,7 @@ Name: alarm-manager Summary: Alarm library Version: 0.4.53 -Release: 2 +Release: 3 Group: System/Libraries License: Apache License, Version 2.0 Source0: %{name}-%{version}.tar.gz |