From e64d499a579b076d49f3157f4d82c3a0a63810ab Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 23 Nov 2018 19:32:18 +0900 Subject: [PATCH] Add terminate callback in service Change-Id: I884cbd21d8fb632a1f706292c0d9904b5481a68a Signed-off-by: Jihoon Kim --- include/autofill_service.h | 27 +++++++++++++++++++++++++++ service_lib/CMakeLists.txt | 2 +- service_lib/autofill_service.c | 31 +++++++++++++++++++++++++++++++ tidl/autofill_service.tidl | 1 + 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/include/autofill_service.h b/include/autofill_service.h index 9fbc847..e6f103a 100644 --- a/include/autofill_service.h +++ b/include/autofill_service.h @@ -64,6 +64,14 @@ typedef void (*autofill_service_fill_requested_cb)(autofill_view_info_h vi, void typedef void (*autofill_service_commited_cb)(autofill_save_view_info_h vi, void *user_data); /** + * @brief Called when receiving terminate request. + * @since_tizen 5.5 + * @param[in] user_data The user data passed from the callback function + * @see autofill_service_set_terminate_received_cb() + */ +typedef void (*autofill_service_terminate_received_cb)(void *user_data); + +/** * @brief Initializes autofill service library. * @since_tizen 5.5 * @return 0 on success, otherwise a negative error value @@ -157,6 +165,25 @@ int autofill_service_set_commited_cb(autofill_service_commited_cb callback, void int autofill_service_unset_commited_cb(void); /** + * @brief Sets the callback to receive the terminate request. + * @since_tizen 5.5 + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + * @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter + */ +int autofill_service_set_terminate_received_cb(autofill_service_terminate_received_cb callback, void *user_data); + +/** + * @brief Unsets the callback to receive the terminate request. + * @since_tizen 5.5 + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_service_unset_terminate_received_cb(void); + +/** * @} */ diff --git a/service_lib/CMakeLists.txt b/service_lib/CMakeLists.txt index e01c999..723c553 100644 --- a/service_lib/CMakeLists.txt +++ b/service_lib/CMakeLists.txt @@ -7,7 +7,7 @@ SET(maintainer "Jihoon Kim ") SET(description "Autofill Service APIs") SET(service "ui") SET(submodule "autofill-service") -SET(dependents "dlog eina glib-2.0 rpc-port") +SET(dependents "dlog eina glib-2.0 rpc-port ecore") SET(LIBDIR ${LIB_INSTALL_DIR}) SET(Services diff --git a/service_lib/autofill_service.c b/service_lib/autofill_service.c index bd597cd..6bee76f 100644 --- a/service_lib/autofill_service.c +++ b/service_lib/autofill_service.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "autofill_service.h" #include "autofill_private.h" @@ -42,6 +43,9 @@ static void *g_autofill_service_auth_info_request_data = NULL; static autofill_service_commited_cb g_autofill_service_commited_cb; static void *g_autofill_service_commit_data = NULL; +static autofill_service_terminate_received_cb g_autofill_service_terminate_received_cb; +static void *g_autofill_service_terminate_received_data = NULL; + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h g_auth_info_cb; rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h g_fill_response_received_cb; @@ -239,6 +243,16 @@ static void __autofill_commit_cb(rpc_port_stub_AutofillSvcPort_context_h context } } +static void __terminate_received_cb(rpc_port_stub_AutofillSvcPort_context_h context, void *user_data) +{ + LOGD(""); + + if (g_autofill_service_terminate_received_cb) + g_autofill_service_terminate_received_cb(g_autofill_service_terminate_received_data); + + ecore_main_loop_quit(); +} + static autofill_svc_s *__create_client(const char *app_id, rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb, rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_received_cb) @@ -386,6 +400,7 @@ EXPORT_API int autofill_service_initialize(void) __auth_info_request_cb, __autofill_fill_request_cb, __autofill_commit_cb, + __terminate_received_cb }; ret = rpc_port_stub_AutofillSvcPort_register(&callback, NULL); @@ -612,3 +627,19 @@ EXPORT_API int autofill_service_unset_commited_cb(void) return AUTOFILL_ERROR_NONE; } + +EXPORT_API int autofill_service_set_terminate_received_cb(autofill_service_terminate_received_cb callback, void *user_data) +{ + g_autofill_service_terminate_received_cb = callback; + g_autofill_service_terminate_received_data = user_data; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_service_unset_terminate_received_cb(void) +{ + g_autofill_service_terminate_received_cb = NULL; + g_autofill_service_terminate_received_data = NULL; + + return AUTOFILL_ERROR_NONE; +} diff --git a/tidl/autofill_service.tidl b/tidl/autofill_service.tidl index 7b3bd5e..f1423fd 100644 --- a/tidl/autofill_service.tidl +++ b/tidl/autofill_service.tidl @@ -61,4 +61,5 @@ interface AutofillSvcPort { void request_auth_info(autofill_svc_view_info vi) async; void send_fill_request(autofill_svc_view_info vi) async; void commit(autofill_svc_save_view_info si) async; + void request_terminate() async; } -- 2.7.4