Add interfaces for canceling fill request 92/213792/3
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 11 Sep 2019 10:20:25 +0000 (19:20 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Mon, 16 Sep 2019 11:08:13 +0000 (20:08 +0900)
Change-Id: I613017fbd0a5a0a7efb37ec59fade2d6a3559f6e
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
client/autofill_fill_request.c
include/autofill.h
include/autofill_service.h
service_lib/autofill_service.c
tidl/autofill.tidl
tidl/autofill_service.tidl

index 2c034ae..1ae6954 100644 (file)
@@ -102,6 +102,79 @@ EXPORT_API int autofill_fill_request(autofill_h ah, autofill_view_info_h vi)
         return AUTOFILL_ERROR_NONE;
 }
 
+EXPORT_API int autofill_cancel_fill_request(autofill_h ah, autofill_view_info_h vi)
+{
+    int ret = AUTOFILL_ERROR_NONE;
+    rpc_port_autofill_view_info_h vih = NULL;
+    char *id = NULL;
+    char *label = NULL;
+    autofill_hint_e autofill_hint;
+    bool sensitive_data = false;
+    Eina_List *l = NULL;
+    autofill_item_h it = NULL;
+
+    if (!ah || !vi) {
+        LOGW("[ERROR] Invalid parameter");
+        return AUTOFILL_ERROR_INVALID_PARAMETER;
+    }
+
+    if (!ah->rpc_h) {
+        return AUTOFILL_ERROR_OPERATION_FAILED;
+    }
+
+    if (!ah->connected) {
+        LOGW("[ERROR] Not connected");
+        return AUTOFILL_ERROR_OPERATION_FAILED;
+    }
+
+    rpc_port_autofill_view_info_create(&vih);
+    rpc_port_autofill_view_info_set_view_id(vih, vi->view_id);
+
+    EINA_LIST_FOREACH(vi->autofill_item_list, l, it)
+    {
+        autofill_item_get_id(it, &id);
+        autofill_item_get_label(it, &label);
+        autofill_item_get_autofill_hint(it, &autofill_hint);
+        autofill_item_get_sensitive_data(it, &sensitive_data);
+
+        LOGD("it : %p, id : %s, label : %s, hint : %d, sensitive : %d", it, id, label, autofill_hint, sensitive_data);
+
+        rpc_port_autofill_item_h aih;
+        rpc_port_autofill_item_create(&aih);
+        rpc_port_autofill_item_set_id(aih, id);
+        rpc_port_autofill_item_set_label(aih, label);
+        rpc_port_autofill_item_set_autofill_hint(aih, (int)autofill_hint);
+        rpc_port_autofill_item_set_is_sensitive_data(aih, sensitive_data);
+
+        rpc_port_autofill_view_info_add_items(vih, aih);
+
+        if (id) {
+            free(id);
+            id = NULL;
+        }
+
+        if (label) {
+            free(label);
+            label = NULL;
+        }
+
+        rpc_port_autofill_item_destroy(aih);
+    }
+
+    LOGD("app id : %s, view id : %s, context id : %d", vi->app_id, vi->view_id, ah->context_id);
+
+    ret = rpc_port_proxy_AutofillAppPort_invoke_cancel_fill_request(ah->rpc_h, ah->context_id, vih);
+
+    rpc_port_autofill_view_info_destroy(vih);
+
+    if (ret != RPC_PORT_ERROR_NONE) {
+        LOGW("[ERROR] Failed to cancel fill request. rpc err = %d", ret);
+        return AUTOFILL_ERROR_OPERATION_FAILED;
+    }
+    else
+        return AUTOFILL_ERROR_NONE;
+}
+
 EXPORT_API int autofill_fill_response_set_received_cb(autofill_h ah, autofill_fill_response_received_cb callback, void *user_data)
 {
     if (!ah || !callback) {
@@ -126,4 +199,4 @@ EXPORT_API int autofill_fill_response_unset_received_cb(autofill_h ah)
     ah->autofill_fill_response_data = NULL;
 
     return AUTOFILL_ERROR_NONE;
-}
+}
\ No newline at end of file
index 0f6b920..eb8bba2 100644 (file)
@@ -178,10 +178,24 @@ int autofill_auth_info_unset_received_cb(autofill_h ah);
  * @retval #AUTOFILL_ERROR_NONE No error
  * @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
  * @retval #AUTOFILL_ERROR_OPERATION_FAILED Operation failure
+ * @see autofill_cancel_fill_request()
  */
 int autofill_fill_request(autofill_h ah, autofill_view_info_h vi);
 
 /**
+ * @brief Cancels fill request to fill out each input form.
+ * @since_tizen 5.5
+ * @param[in] ah The autofill handle
+ * @param[in] vi The autofill view info handle
+ * @return 0 on success, otherwise a negative error value
+ * @retval #AUTOFILL_ERROR_NONE No error
+ * @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #AUTOFILL_ERROR_OPERATION_FAILED Operation failure
+ * @see autofill_fill_request()
+ */
+int autofill_cancel_fill_request(autofill_h ah, autofill_view_info_h vi);
+
+/**
  * @brief Sets the callback to receive autofill fill response.
  * @since_tizen 5.5
  * @param[in] ah The autofill handle
index 7ccb1fe..d423df8 100644 (file)
@@ -56,6 +56,17 @@ typedef void (*autofill_service_auth_info_requested_cb)(int context_id, autofill
 typedef void (*autofill_service_fill_requested_cb)(int context_id, autofill_view_info_h vi, void *user_data);
 
 /**
+ * @brief Called when receiving the cancellation of fill request.
+ * @since_tizen 5.5
+ * @remarks @a vi should not be freed and can be used only in the callback.
+ * @param[in] context_id The autofill context identification value of an associated autofill client handle
+ * @param[in] vi The autofill view info handle
+ * @param[in] user_data The user data passed from the callback function
+ * @see autofill_service_set_cancel_fill_requested_cb()
+ */
+typedef void (*autofill_service_cancel_fill_requested_cb)(int context_id, autofill_view_info_h vi, void *user_data);
+
+/**
  * @brief Called when receiving commit request.
  * @since_tizen 5.5
  * @remarks @a vi should not be freed and can be used only in the callback.
@@ -140,6 +151,25 @@ int autofill_service_set_fill_requested_cb(autofill_service_fill_requested_cb ca
 int autofill_service_unset_fill_requested_cb(void);
 
 /**
+ * @brief Sets the callback to receive the cancellation of fill 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_cancel_fill_requested_cb(autofill_service_cancel_fill_requested_cb callback, void *user_data);
+
+/**
+ * @brief Unsets the callback to receive the cancellation of fill request.
+ * @since_tizen 5.5
+ * @return 0 on success, otherwise a negative error value
+ * @retval #AUTOFILL_ERROR_NONE No error
+ */
+int autofill_service_unset_cancel_fill_requested_cb(void);
+
+/**
  * @brief Sends the fill response.
  * @since_tizen 5.5
  * @param[in] context_id The autofill context identification value of an associated autofill client handle
index 1ecad76..b867902 100644 (file)
@@ -37,6 +37,9 @@
 static autofill_service_fill_requested_cb g_autofill_service_fill_requested_cb = NULL;
 static void *g_autofill_service_fill_request_data = NULL;
 
+static autofill_service_cancel_fill_requested_cb g_autofill_service_cancel_fill_requested_cb = NULL;
+static void *g_autofill_service_cancel_fill_request_data = NULL;
+
 static autofill_service_auth_info_requested_cb g_autofill_service_auth_info_requested_cb = NULL;
 static void *g_autofill_service_auth_info_request_data = NULL;
 
@@ -223,6 +226,35 @@ static void __autofill_fill_request_cb(rpc_port_stub_AutofillSvcPort_context_h c
         free(view_id);
 }
 
+static void __autofill_cancel_fill_request_cb(rpc_port_stub_AutofillSvcPort_context_h context, int context_id, rpc_port_autofill_svc_view_info_h vi, void *user_data)
+{
+    char *app_id = NULL;
+    char *view_id = NULL;
+
+    rpc_port_autofill_svc_view_info_get_app_id(vi, &app_id);
+    rpc_port_autofill_svc_view_info_get_view_id(vi, &view_id);
+
+    LOGD("app id : %s, view id : %s", app_id, view_id);
+
+    autofill_view_info_h view_info;
+    autofill_view_info_create(&view_info);
+    autofill_view_info_set_app_id(view_info, app_id);
+    autofill_view_info_set_view_id(view_info, view_id);
+
+    rpc_port_autofill_svc_view_info_foreach_items(vi, __autofill_item_cb, view_info);
+
+    if (g_autofill_service_cancel_fill_requested_cb)
+        g_autofill_service_cancel_fill_requested_cb(context_id, view_info, g_autofill_service_cancel_fill_request_data);
+
+    autofill_view_info_destroy(view_info);
+
+    if (app_id)
+        free(app_id);
+
+    if (view_id)
+        free(view_id);
+}
+
 static void __autofill_commit_cb(rpc_port_stub_AutofillSvcPort_context_h context, int context_id, rpc_port_autofill_svc_save_view_info_h vi, void *user_data)
 {
     char *app_id = NULL;
@@ -414,7 +446,8 @@ EXPORT_API int autofill_service_initialize(void)
         __auth_info_request_cb,
         __autofill_fill_request_cb,
         __autofill_commit_cb,
-        __terminate_received_cb
+        __terminate_received_cb,
+        __autofill_cancel_fill_request_cb,
     };
 
     ret = rpc_port_stub_AutofillSvcPort_register(&callback, NULL);
@@ -542,6 +575,28 @@ EXPORT_API int autofill_service_unset_fill_requested_cb()
     return AUTOFILL_ERROR_NONE;
 }
 
+// cancel fill request
+EXPORT_API int autofill_service_set_cancel_fill_requested_cb(autofill_service_cancel_fill_requested_cb callback, void *user_data)
+{
+    if (!callback) {
+        LOGW("[ERROR] Invalid parameter");
+        return AUTOFILL_ERROR_INVALID_PARAMETER;
+    }
+
+    g_autofill_service_cancel_fill_requested_cb = callback;
+    g_autofill_service_cancel_fill_request_data = user_data;
+
+    return AUTOFILL_ERROR_NONE;
+}
+
+EXPORT_API int autofill_service_unset_cancel_fill_requested_cb()
+{
+    g_autofill_service_cancel_fill_requested_cb = NULL;
+    g_autofill_service_cancel_fill_request_data = NULL;
+
+    return AUTOFILL_ERROR_NONE;
+}
+
 bool __fill_response_item_cb(autofill_fill_response_item_h it, void * user_data)
 {
     char *id = NULL;
index 803697e..58020d4 100644 (file)
@@ -68,4 +68,5 @@ interface AutofillAppPort {
     int request_auth_info(int context_id, autofill_view_info vi);
     int send_fill_request(int context_id, autofill_view_info vi);
     int commit(int context_id, autofill_save_view_info vi);
+    int cancel_fill_request(int context_id, autofill_view_info vi);
 }
index 06d1aa3..78241ad 100644 (file)
@@ -71,4 +71,5 @@ interface AutofillSvcPort {
     void send_fill_request(int context_id, autofill_svc_view_info vi) async;
     void commit(int context_id, autofill_svc_save_view_info si) async;
     void request_terminate() async;
+    void cancel_fill_request(int context_id, autofill_svc_view_info vi) async;
 }