diff options
author | inkyun.kil <inkyun.kil@samsung.com> | 2015-11-26 14:07:20 +0900 |
---|---|---|
committer | Jiwoong Im <jiwoong.im@samsung.com> | 2015-12-08 10:09:44 +0900 |
commit | bb5484a3a939f06edb4bb5478cc234aa995af52b (patch) | |
tree | 738d9e450776c34bce658545e3d831e8af2eb66e /src | |
parent | 03531adba4e99b162a5a58f04af3da39c59ac5f2 (diff) | |
download | alarm-manager-bb5484a3a939f06edb4bb5478cc234aa995af52b.tar.gz alarm-manager-bb5484a3a939f06edb4bb5478cc234aa995af52b.tar.bz2 alarm-manager-bb5484a3a939f06edb4bb5478cc234aa995af52b.zip |
Add new apis to support global alarm
- add api 'alarmmgr_set_global()' and 'alarmmgr_get_global()'
- add privilege check for added method call in alarm-server
- find login user in launching global alarm
Change-Id: I43d22b28d1c36f8817233d4e985027791cb4d1f7
Diffstat (limited to 'src')
-rw-r--r-- | src/alarm-lib-stub.c | 62 | ||||
-rw-r--r-- | src/alarm-lib.c | 32 |
2 files changed, 94 insertions, 0 deletions
diff --git a/src/alarm-lib-stub.c b/src/alarm-lib-stub.c index 9234328..81eb4b9 100644 --- a/src/alarm-lib-stub.c +++ b/src/alarm-lib-stub.c @@ -614,3 +614,65 @@ bool _send_alarm_set_timezone(alarm_context_t context, char *tzpath_str, int *er return true; } + +bool _send_alarm_set_global(alarm_context_t context, const alarm_id_t alarm_id, bool global, int *error_code) +{ + GError *error = NULL; + 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][%s]", return_code, error->message); + ALARM_MGR_EXCEPTION_PRINT("error->message is %s(%d)", error->message, error->code); + if (error_code) { + if (error->code == G_DBUS_ERROR_ACCESS_DENIED) + *error_code = ERR_ALARM_NO_PERMISSION; + else + *error_code = ERR_ALARM_SYSTEM_FAIL; + } + g_error_free(error); + return false; + } + + if (return_code != ALARMMGR_RESULT_SUCCESS) { + if (error_code) { + *error_code = return_code; + } + return false; + } + + return true; +} + +bool _send_alarm_get_global(alarm_context_t context, const alarm_id_t alarm_id, bool *global, int *error_code) +{ + GError *error = NULL; + int return_code = 0; + bool _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][%s]", return_code, error->message); + ALARM_MGR_EXCEPTION_PRINT("error->message is %s(%d)", error->message, error->code); + if (error_code) { + if (error->code == G_DBUS_ERROR_ACCESS_DENIED) + *error_code = ERR_ALARM_NO_PERMISSION; + else + *error_code = ERR_ALARM_SYSTEM_FAIL; + } + g_error_free(error); + return false; + } + + if (return_code != ALARMMGR_RESULT_SUCCESS) { + if (error_code) { + *error_code = return_code; + } + return false; + } + + *global = _global; + return true; +} diff --git a/src/alarm-lib.c b/src/alarm-lib.c index 887d799..b829fcf 100644 --- a/src/alarm-lib.c +++ b/src/alarm-lib.c @@ -1586,3 +1586,35 @@ EXPORT_API int alarmmgr_set_timezone(char *tzpath_str) ALARM_MGR_LOG_PRINT("[alarm-lib]: successfully set the timezone(%s) by pid(%d)", tzpath_str, getpid()); return ALARMMGR_RESULT_SUCCESS; } + +EXPORT_API int alarmmgr_set_global(const alarm_id_t alarm_id, + bool global) +{ + int error_code; + ALARM_MGR_LOG_PRINT("[alarm-lib]:alarmmgr_set_global() is called."); + + if (!_send_alarm_set_global(alarm_context, alarm_id, global, &error_code)) { + return error_code; + } + + return ALARMMGR_RESULT_SUCCESS; +} + + +EXPORT_API int alarmmgr_get_global(const alarm_id_t alarm_id, + bool *global) +{ + bool _global; + int error_code; + + if (global == NULL) { + return ERR_ALARM_INVALID_PARAM; + } + + if (!_send_alarm_get_global(alarm_context, alarm_id, &_global, &error_code)) { + return error_code; + } + + return ALARMMGR_RESULT_SUCCESS; +} + |