Add code to handle error 26/191526/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 17 Oct 2018 06:50:29 +0000 (15:50 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 18 Oct 2018 05:08:58 +0000 (14:08 +0900)
Change-Id: I26ad02ffe8d3c015ac32f96f7dc99dcda41747b3
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
client/autofill.c
client/autofill_auth.c
client/autofill_fill_request.c
client/autofill_proxy.c
client/autofill_proxy.h
include/autofill.h
server/autofill_stub.c
server/autofill_stub.h
server/main.c
test/ecore_imf_example.c
tidl/autofill.tidl

index d6e792ef7d46663ff40d6ccea1084f8c8dbe6206..e85119adf9b714cf258dbee2ff89cfd98f9a6fe4 100644 (file)
@@ -237,6 +237,8 @@ EXPORT_API int autofill_deinitialize()
         rpc_port_proxy_AutofillAppPort_destroy(rpc_h);
         rpc_h = NULL;
     }
+    else
+        return AUTOFILL_ERROR_NOT_INITIALIZED;
 
     return AUTOFILL_ERROR_NONE;
 }
@@ -304,9 +306,9 @@ EXPORT_API int autofill_commit(autofill_save_view_info_h vi)
 
     LOGD("app id : %s, view id : %s", vi->app_id, vi->view_id);
 
-    rpc_port_proxy_AutofillAppPort_invoke_commit(rpc_h, vih);
+    int ret = rpc_port_proxy_AutofillAppPort_invoke_commit(rpc_h, vih);
 
     rpc_port_autofill_save_view_info_destroy(vih);
 
-    return AUTOFILL_ERROR_NONE;
+    return ret;
 }
index fa544797ca780bacd2ed684fa7d9e8ef9d7a433b..cdf977532d82cfbe76a2c35b13673b89955df5a9 100644 (file)
@@ -38,6 +38,7 @@ EXPORT_API int autofill_auth_info_request(autofill_view_info_h vi)
 {
     LOGD("app id : %s, view id : %s", vi->app_id, vi->view_id);
 
+    int ret = AUTOFILL_ERROR_NONE;
     rpc_port_autofill_view_info_h vih;
     char *id;
     char *label;
@@ -49,6 +50,11 @@ EXPORT_API int autofill_auth_info_request(autofill_view_info_h vi)
         return AUTOFILL_ERROR_INVALID_PARAMETER;
     }
 
+    if (!rpc_h) {
+        LOGW("Not initialized");
+        return AUTOFILL_ERROR_NOT_INITIALIZED;
+    }
+
     rpc_port_autofill_view_info_create(&vih);
     rpc_port_autofill_view_info_set_view_id(vih, vi->view_id);
 
@@ -86,13 +92,11 @@ EXPORT_API int autofill_auth_info_request(autofill_view_info_h vi)
 
     LOGD("rpc_h : %p", rpc_h);
 
-    if (rpc_h) {
-        rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(rpc_h, vih);
-    }
+    ret = rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(rpc_h, vih);
 
     rpc_port_autofill_view_info_destroy(vih);
 
-    return AUTOFILL_ERROR_NONE;
+    return ret;
 }
 
 EXPORT_API int autofill_auth_info_set_callback(Autofill_Auth_Info_Cb autofill_auth_info_cb, void *data)
index 964b5488db8cdd3bdbf80c04d3dfc709ee76137c..6993dcd9ff9b50a4451362a5d7010b6462914218 100644 (file)
@@ -36,6 +36,7 @@ void *g_autofill_fill_response_data = NULL;
 
 EXPORT_API int autofill_fill_request(autofill_view_info_h vi)
 {
+    int ret = AUTOFILL_ERROR_NONE;
     rpc_port_autofill_view_info_h vih;
     char *id;
     char *label;
@@ -47,6 +48,11 @@ EXPORT_API int autofill_fill_request(autofill_view_info_h vi)
         return AUTOFILL_ERROR_INVALID_PARAMETER;
     }
 
+    if (!rpc_h) {
+        LOGW("Not initialized");
+        return AUTOFILL_ERROR_NOT_INITIALIZED;
+    }
+
     Eina_List *l;
     autofill_item_h it;
 
@@ -85,11 +91,11 @@ EXPORT_API int autofill_fill_request(autofill_view_info_h vi)
 
     LOGD("app id : %s, view id : %s", vi->app_id, vi->view_id);
 
-    rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(rpc_h, vih);
+    ret = rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(rpc_h, vih);
 
     rpc_port_autofill_view_info_destroy(vih);
 
-    return AUTOFILL_ERROR_NONE;
+    return ret;
 }
 
 EXPORT_API int autofill_fill_response_set_callback(Autofill_Fill_Response_Cb autofill_response_cb, void *data)
index c41ae7d8ca9dec12f01fac5565c22398d8f4fcd3..b279edf5fc94f8f5129a87c87f001c60aeae4673 100644 (file)
@@ -3294,19 +3294,20 @@ void rpc_port_proxy_AutofillAppPort_invoke_Unregister(rpc_port_proxy_AutofillApp
        set_last_result(r);
 }
 
-void rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi)
+int rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi)
 {
        rpc_port_parcel_h parcel;
        int r;
+       int ret = -1;
 
        if (!h || !vi) {
                _E("Invalid parameter");
-               return;
+               return ret;
        }
 
        if (!h->port) {
                _E("Not connected");
-               return;
+               return ret;
        }
 
        rpc_port_parcel_create(&parcel);
@@ -3320,22 +3321,41 @@ void rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(rpc_port_proxy_Auto
        }
 
        rpc_port_parcel_destroy(parcel);
+
+       g_rec_mutex_lock(&h->mutex);
+       do {
+               rpc_port_parcel_h parcel_received;
+
+               parcel_received = __AutofillAppPort_consume_command(h);
+               if (!parcel_received) {
+                       _E("Invalid protocol");
+                       break;
+               }
+
+               rpc_port_parcel_read_int32(parcel_received, &ret);
+
+               rpc_port_parcel_destroy(parcel_received);
+       } while (0);
+       g_rec_mutex_unlock(&h->mutex);
        set_last_result(r);
+
+       return ret;
 }
 
-void rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi)
+int rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi)
 {
        rpc_port_parcel_h parcel;
        int r;
+       int ret = -1;
 
        if (!h || !vi) {
                _E("Invalid parameter");
-               return;
+               return ret;
        }
 
        if (!h->port) {
                _E("Not connected");
-               return;
+               return ret;
        }
 
        rpc_port_parcel_create(&parcel);
@@ -3349,22 +3369,41 @@ void rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(rpc_port_proxy_Auto
        }
 
        rpc_port_parcel_destroy(parcel);
+
+       g_rec_mutex_lock(&h->mutex);
+       do {
+               rpc_port_parcel_h parcel_received;
+
+               parcel_received = __AutofillAppPort_consume_command(h);
+               if (!parcel_received) {
+                       _E("Invalid protocol");
+                       break;
+               }
+
+               rpc_port_parcel_read_int32(parcel_received, &ret);
+
+               rpc_port_parcel_destroy(parcel_received);
+       } while (0);
+       g_rec_mutex_unlock(&h->mutex);
        set_last_result(r);
+
+       return ret;
 }
 
-void rpc_port_proxy_AutofillAppPort_invoke_commit(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_save_view_info_h vi)
+int rpc_port_proxy_AutofillAppPort_invoke_commit(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_save_view_info_h vi)
 {
        rpc_port_parcel_h parcel;
        int r;
+       int ret = -1;
 
        if (!h || !vi) {
                _E("Invalid parameter");
-               return;
+               return ret;
        }
 
        if (!h->port) {
                _E("Not connected");
-               return;
+               return ret;
        }
 
        rpc_port_parcel_create(&parcel);
@@ -3378,7 +3417,25 @@ void rpc_port_proxy_AutofillAppPort_invoke_commit(rpc_port_proxy_AutofillAppPort
        }
 
        rpc_port_parcel_destroy(parcel);
+
+       g_rec_mutex_lock(&h->mutex);
+       do {
+               rpc_port_parcel_h parcel_received;
+
+               parcel_received = __AutofillAppPort_consume_command(h);
+               if (!parcel_received) {
+                       _E("Invalid protocol");
+                       break;
+               }
+
+               rpc_port_parcel_read_int32(parcel_received, &ret);
+
+               rpc_port_parcel_destroy(parcel_received);
+       } while (0);
+       g_rec_mutex_unlock(&h->mutex);
        set_last_result(r);
+
+       return ret;
 }
 
 static struct AutofillAppPort_s *__create_AutofillAppPort(const char *stub_appid, rpc_port_proxy_AutofillAppPort_callback_s *callback, void *user_data)
index 3f296a74a538e94563102f556e1d1b9dad38bb38..2d129f5892dc0f0e7c6935fc45ed26f1d4c27c69 100644 (file)
@@ -283,11 +283,11 @@ int rpc_port_proxy_AutofillAppPort_invoke_Register(rpc_port_proxy_AutofillAppPor
 
 void rpc_port_proxy_AutofillAppPort_invoke_Unregister(rpc_port_proxy_AutofillAppPort_h h);
 
-void rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi);
+int rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi);
 
-void rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi);
+int rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi);
 
-void rpc_port_proxy_AutofillAppPort_invoke_commit(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_save_view_info_h vi);
+int rpc_port_proxy_AutofillAppPort_invoke_commit(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_save_view_info_h vi);
 
 #ifdef __cplusplus
 }
index bb5f73e4123bae7049ec268e00a61d5d3e9722dc..8f6f41837d1e232ae8145e875ac8c8170ce00f12 100644 (file)
@@ -68,8 +68,12 @@ typedef void (*Autofill_Auth_Info_Cb)(autofill_auth_info_h auth_info, void *data
  *
  * @privlevel public
  *
+ * @privilege %http://tizen.org/privilege/appmanager.launch \n
+ *            %http://tizen.org/privilege/datasharing
+ *
  * @return 0 on success, otherwise a negative error value
  * @retval #AUTOFILL_ERROR_NONE No error
+ * @retval #AUTOFILL_ERROR_PERMISSION_DENIED Permission denied
  */
 int autofill_initialize(autofill_connection_status_changed_cb callback, void *user_data);
 
@@ -82,6 +86,7 @@ int autofill_initialize(autofill_connection_status_changed_cb callback, void *us
  *
  * @return 0 on success, otherwise a negative error value
  * @retval #AUTOFILL_ERROR_NONE No error
+ * @retval #AUTOFILL_ERROR_NOT_INITIALIZED Not initialized
  */
 int autofill_deinitialize();
 
@@ -95,6 +100,8 @@ int autofill_deinitialize();
  *
  * @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_NOT_INITIALIZED Not initialized
  */
 int autofill_auth_info_request(autofill_view_info_h vi);
 
@@ -131,6 +138,8 @@ int autofill_auth_info_unset_callback();
  *
  * @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_NOT_INITIALIZED Not initialized
  */
 int autofill_fill_request(autofill_view_info_h vi);
 
@@ -168,6 +177,8 @@ int autofill_fill_response_unset_callback();
  *
  * @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_NOT_INITIALIZED Not initialized
  */
 int autofill_commit(autofill_save_view_info_h vi);
 
index 0afd7991d26f90285c979038ce13dbc3e44ef3a1..2c9de7345eb62b55dc81e8e43ff1a1d77576880e 100644 (file)
@@ -3341,7 +3341,16 @@ static int __AutofillAppPort_method_request_auth_info(rpc_port_h port, rpc_port_
        rpc_port_autofill_view_info_create(&vi);
        rpc_port_parcel_read(parcel, &vi->parcelable, vi);
 
-       context->callback.request_auth_info(context, vi, context->user_data);
+       int ret = context->callback.request_auth_info(context, vi, context->user_data);
+       do {
+               rpc_port_parcel_h result;
+
+               rpc_port_parcel_create(&result);
+               rpc_port_parcel_write_int32(result, AutofillAppPort_METHOD_Result);
+               rpc_port_parcel_write_int32(result, ret);
+               rpc_port_parcel_send(result, port);
+               rpc_port_parcel_destroy(result);
+       } while (0);
 
        rpc_port_autofill_view_info_destroy(vi);
        return 0;
@@ -3364,7 +3373,16 @@ static int __AutofillAppPort_method_send_fill_request(rpc_port_h port, rpc_port_
        rpc_port_autofill_view_info_create(&vi);
        rpc_port_parcel_read(parcel, &vi->parcelable, vi);
 
-       context->callback.send_fill_request(context, vi, context->user_data);
+       int ret = context->callback.send_fill_request(context, vi, context->user_data);
+       do {
+               rpc_port_parcel_h result;
+
+               rpc_port_parcel_create(&result);
+               rpc_port_parcel_write_int32(result, AutofillAppPort_METHOD_Result);
+               rpc_port_parcel_write_int32(result, ret);
+               rpc_port_parcel_send(result, port);
+               rpc_port_parcel_destroy(result);
+       } while (0);
 
        rpc_port_autofill_view_info_destroy(vi);
        return 0;
@@ -3387,7 +3405,16 @@ static int __AutofillAppPort_method_commit(rpc_port_h port, rpc_port_parcel_h pa
        rpc_port_autofill_save_view_info_create(&vi);
        rpc_port_parcel_read(parcel, &vi->parcelable, vi);
 
-       context->callback.commit(context, vi, context->user_data);
+       int ret = context->callback.commit(context, vi, context->user_data);
+       do {
+               rpc_port_parcel_h result;
+
+               rpc_port_parcel_create(&result);
+               rpc_port_parcel_write_int32(result, AutofillAppPort_METHOD_Result);
+               rpc_port_parcel_write_int32(result, ret);
+               rpc_port_parcel_send(result, port);
+               rpc_port_parcel_destroy(result);
+       } while (0);
 
        rpc_port_autofill_save_view_info_destroy(vi);
        return 0;
index 333d6bc97fb81a39c9ef67e5835861be1d24a9a8..132cf3fa2749f34a3c0ed12ee076de2031c94b50 100644 (file)
@@ -273,9 +273,9 @@ typedef struct {
 
        int (*Register)(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_AutofillAppPort_autofill_auth_info_cb_h auth_info_cb, rpc_port_AutofillAppPort_autofill_fill_response_cb_h fill_response_cb, void *user_data);
        void (*Unregister)(rpc_port_stub_AutofillAppPort_context_h context, void *user_data);
-       void (*request_auth_info)(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data);
-       void (*send_fill_request)(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data);
-       void (*commit)(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_save_view_info_h vi, void *user_data);
+       int (*request_auth_info)(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data);
+       int (*send_fill_request)(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data);
+       int (*commit)(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_save_view_info_h vi, void *user_data);
 } rpc_port_stub_AutofillAppPort_callback_s;
 
 int rpc_port_stub_AutofillAppPort_register(rpc_port_stub_AutofillAppPort_callback_s *callback, void *user_data);
index b3d576b4c9006a21c5f7418cf8297aae044daa36..4d311ef71e1410d2eadf5c0c2ab91dce9fee77ca 100644 (file)
@@ -295,7 +295,7 @@ bool __save_item_cb(rpc_port_autofill_save_item_h items, void *user_data)
     return true;
 }
 
-static void __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data)
+static int __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data)
 {
     char *sender = NULL;
     autofill_client_s *sender_client;
@@ -328,9 +328,10 @@ static void __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h conte
 
     rpc_port_autofill_svc_view_info_destroy(svi);
 
+    return 0;
 }
 
-static void __autofill_fill_request_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data)
+static int __autofill_fill_request_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data)
 {
     char *sender = NULL;
     char *view_id = NULL;
@@ -356,9 +357,11 @@ static void __autofill_fill_request_cb(rpc_port_stub_AutofillAppPort_context_h c
         free(view_id);
 
     rpc_port_autofill_svc_view_info_destroy(svi);
+
+    return 0;
 }
 
-static void __commit_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_save_view_info_h vi, void *user_data)
+static int __commit_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_save_view_info_h vi, void *user_data)
 {
     char *sender = NULL;
     autofill_client_s *sender_client;
@@ -388,6 +391,8 @@ static void __commit_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_por
         free(view_id);
 
     rpc_port_autofill_svc_save_view_info_destroy(svi);
+
+    return 0;
 }
 
 bool fill_response_item_cb(rpc_port_autofill_svc_response_item_h response_items, void *user_data)
index 28d9d6b063e4cc9e1f7a29e6e7b6616bdc717cee..d838be40c74e21fe1a69615610ece74757df42e8 100644 (file)
@@ -222,19 +222,33 @@ _autofill_auth_info_cb(autofill_auth_info_h auth_info, void *data)
     LOGD("Send fill request");
 
     autofill_fill_response_set_callback(_autofill_fill_response_cb, NULL);
-    autofill_fill_request(autofill_view_info);
+    int ret = autofill_fill_request(autofill_view_info);
+    if (ret == AUTOFILL_ERROR_NONE)
+        LOGD("Succeeded to request fill");
+    else if (ret == AUTOFILL_ERROR_PERMISSION_DENIED)
+        LOGW("permission denied");
+    else
+        LOGW("Failed to request fill : %d", ret);
 }
 
 static void
 _request_autofill_auth_info()
 {
+    int ret;
     autofill_auth_info_set_callback(_autofill_auth_info_cb, NULL);
-    autofill_auth_info_request(autofill_view_info);
+    ret = autofill_auth_info_request(autofill_view_info);
+    if (ret == AUTOFILL_ERROR_NONE)
+        LOGD("Succeeded to request auth info");
+    else if (ret == AUTOFILL_ERROR_PERMISSION_DENIED)
+        LOGW("permission denied");
+    else
+        LOGW("Failed to request auth info. error : %d", ret);
 }
 
 static void
 _save_autofill_info()
 {
+    int ret;
     char *app_id;
     app_get_id(&app_id);
     autofill_save_view_info_h autofill_save_view_info = NULL;
@@ -253,7 +267,13 @@ _save_autofill_info()
     if (app_id)
         free(app_id);
 
-    autofill_commit(autofill_save_view_info);
+    ret = autofill_commit(autofill_save_view_info);
+    if (ret == AUTOFILL_ERROR_NONE)
+        LOGD("Succeeded to request auth info");
+    else if (ret == AUTOFILL_ERROR_PERMISSION_DENIED)
+        LOGW("permission denied");
+    else
+        LOGW("Failed to request auth info. error : %d", ret);
 
     autofill_save_view_info_destroy(autofill_save_view_info);
 }
@@ -803,6 +823,7 @@ main(void)
 {
     Ecore_Evas *ee;
     Evas *evas;
+    int ret;
 
     if (!ecore_evas_init())
     {
@@ -812,7 +833,13 @@ main(void)
 
     ecore_imf_init();
 
-    autofill_initialize(connection_status_changed_cb, NULL);
+    ret = autofill_initialize(connection_status_changed_cb, NULL);
+    if (ret == AUTOFILL_ERROR_NONE)
+        LOGD("Succeeded to initialize");
+    else if (ret == AUTOFILL_ERROR_PERMISSION_DENIED)
+        LOGW("permission denied");
+    else
+        LOGW("Failed to initialize. error : %d", ret);
 
     // create a new window, with size=WIDTHxHEIGHT and default engine
     ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
index 3dd15a0b11f7bbaa9454ee01b25ec5b348ec8196..07663e797f8742b59d95d48ad0566d27c6b1c730 100644 (file)
@@ -50,7 +50,7 @@ interface AutofillAppPort {
     int Register(autofill_auth_info_cb auth_info_cb, autofill_fill_response_cb fill_response_cb);
     void Unregister() async;
 
-    void request_auth_info(autofill_view_info vi) async;
-    void send_fill_request(autofill_view_info vi) async;
-    void commit(autofill_save_view_info vi) async;
+    int request_auth_info(autofill_view_info vi);
+    int send_fill_request(autofill_view_info vi);
+    int commit(autofill_save_view_info vi);
 }