Add terminate callback in service 40/194040/5
authorJihoon Kim <jihoon48.kim@samsung.com>
Fri, 23 Nov 2018 10:32:18 +0000 (19:32 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Fri, 30 Nov 2018 09:16:01 +0000 (18:16 +0900)
Change-Id: I884cbd21d8fb632a1f706292c0d9904b5481a68a
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
include/autofill_service.h
service_lib/CMakeLists.txt
service_lib/autofill_service.c
tidl/autofill_service.tidl

index 9fbc847..e6f103a 100644 (file)
@@ -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);
+
+/**
  * @}
  */
 
index e01c999..723c553 100644 (file)
@@ -7,7 +7,7 @@ SET(maintainer "Jihoon Kim <jihoon48.kim@samsung.com>")
 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
index bd597cd..6bee76f 100644 (file)
@@ -23,6 +23,7 @@
 #include <rpc-port.h>
 #include <glib.h>
 #include <Eina.h>
+#include <Ecore.h>
 
 #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;
+}
index 7b3bd5e..f1423fd 100644 (file)
@@ -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;
 }