Update version to 1.70.7
[platform/core/uifw/voice-control.git] / client / vc_widget_tidl.c
index dc2b84b..9b6a80b 100644 (file)
@@ -61,34 +61,33 @@ static void __notify_cb(void *user_data, bundle *msg)
        char* val = NULL;
        SLOG(LOG_DEBUG, TAG_VCW, "__notify_cb is invoked");
 
-       bundle_get_str(msg, VC_WIDGET_BUNDLE_METHOD, &method);
+       bundle_get_str(msg, VC_BUNDLE_METHOD, &method);
 
        if (0 == strncmp(VCD_WIDGET_METHOD_HELLO, method, strlen(VCD_WIDGET_METHOD_HELLO))) {
                SLOG(LOG_INFO, TAG_VCW, "@@@ Get widget hello");
-               bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val);
+               bundle_get_str(msg, VC_BUNDLE_PID, &val);
                if (val) {
                        SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget get hello : pid(%d) ", atoi(val));
                } else {
                        SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget get hello : invalid pid ");
                }
-               SLOG(LOG_DEBUG, TAG_VCW, "@@@");
        } /* VCD_METHOD_HELLO */
 
-       else if (0 == strncmp(VCD_WIDGET_METHOD_SET_SERVICE_STATE, method, strlen(VCD_WIDGET_METHOD_SET_SERVICE_STATE))) {
-               bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val);
+       else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) {
+               bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &val);
                int state = 0;
                if (val) {
                        state = atoi(val);
                        SLOG(LOG_INFO, TAG_VCW, "@@ service state changed : %d", state);
                        __vc_widget_cb_service_state(state);
                }
-       } /* VCD_WIDGET_METHOD_SET_SERVICE_STATE */
+       } /* VCD_METHOD_SET_SERVICE_STATE */
 
        else if (0 == strncmp(VCD_WIDGET_METHOD_SHOW_TOOLTIP, method, strlen(VCD_WIDGET_METHOD_SHOW_TOOLTIP))) {
                SLOG(LOG_DEBUG, TAG_VCW, "@@@ Show / Hide tooltip");
                char* temp_show = NULL;
-               bundle_get_str(msg, VC_WIDGET_BUNDLE_MESSAGE, &val);
-               bundle_get_str(msg, VC_WIDGET_BUNDLE_SHOW, &temp_show);
+               bundle_get_str(msg, VC_BUNDLE_PID, &val);
+               bundle_get_str(msg, VC_BUNDLE_SHOW, &temp_show);
                int pid = 0;
                int show = 0;
 
@@ -105,15 +104,12 @@ static void __notify_cb(void *user_data, bundle *msg)
                } else {
                        SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget show tooltip : invalid pid");
                }
-               SLOG(LOG_DEBUG, TAG_VCW, "@@@");
        } /* VCD_WIDGET_METHOD_SHOW_TOOLTIP */
 
        else if (0 == strncmp(VCD_WIDGET_METHOD_RESULT, method, strlen(VCD_WIDGET_METHOD_RESULT))) {
                SLOG(LOG_DEBUG, TAG_VCW, "@@@ Get widget result");
 
                __vc_widget_cb_result();
-
-               SLOG(LOG_DEBUG, TAG_VCW, "@@@");
        } /* VCD_WIDGET_METHOD_RESULT */
 
        else if (0 == strncmp(VCD_WIDGET_METHOD_ERROR, method, strlen(VCD_WIDGET_METHOD_ERROR))) {
@@ -122,9 +118,9 @@ static void __notify_cb(void *user_data, bundle *msg)
                char* temp_daemon_pid = NULL;
                char* err_msg = NULL;
 
-               bundle_get_str(msg, VC_WIDGET_BUNDLE_REASON, &temp_reason);
-               bundle_get_str(msg, VC_WIDGET_BUNDLE_DAEMON_PID, &temp_daemon_pid);
-               bundle_get_str(msg, VC_WIDGET_BUNDLE_ERROR_MESSAGE, &err_msg);
+               bundle_get_str(msg, VC_BUNDLE_REASON, &temp_reason);
+               bundle_get_str(msg, VC_BUNDLE_DAEMON_PID, &temp_daemon_pid);
+               bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg);
                int reason = 0;
                int daemon_pid = 0;
 
@@ -137,13 +133,13 @@ static void __notify_cb(void *user_data, bundle *msg)
 
                SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget get error message : reason(%d), daemon_pid(%d), msg(%s)", reason, daemon_pid, err_msg);
                __vc_widget_cb_error(reason, daemon_pid, err_msg);
-
-               SLOG(LOG_DEBUG, TAG_VCW, "@@@");
        } /* VCD_WIDGET_METHOD_ERROR */
 
        else {
                SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Invalid msg");
        }
+
+       SLOG(LOG_DEBUG, TAG_VCW, "@@@ __notify_cb DONE");
 }
 
 static void __on_connected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void *user_data)
@@ -163,8 +159,7 @@ static void __on_disconnected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void
 
        SLOG(LOG_INFO, TAG_VCW, "Disonnected to server");
 
-       SLOG(LOG_INFO, TAG_VCW, "Re-connection start");
-       __vc_widget_cb_error(VC_ERROR_SERVICE_RESET, -1, "Server Disconnected, re-launch");
+       __vc_widget_cb_error(VC_ERROR_SERVICE_RESET, -1, "Server Disconnected");
 }
 
 static void __on_rejected(rpc_port_proxy_vc_widget_proxy_vc_widget_h h, void *user_data)
@@ -351,6 +346,15 @@ int vc_widget_tidl_close_connection()
        return VC_ERROR_NONE;
 }
 
+static int __convert_unhandled_error(int ret)
+{
+       if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) {
+               return VC_ERROR_OPERATION_FAILED;
+       }
+
+       return ret;
+}
+
 static void __request_tidl_connect()
 {
        if (g_proxy_tidl_info->connection_requesting) {
@@ -453,7 +457,12 @@ int vc_widget_tidl_request_initialize(int pid, int* service_state, int* daemon_p
        int temp_service_state = 0;
        int temp_daemon_pid = 0;
        int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_initialize(g_proxy_tidl_info->rpc_h, pid, &temp_service_state, &temp_daemon_pid);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (VC_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget initialize : Fail to invoke message, error(%d)", ret);
                pthread_mutex_unlock(&g_w_init_mutex);
                return ret;
@@ -486,8 +495,25 @@ int vc_widget_tidl_request_finalize(int pid)
        }
 
        int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_finalize(g_proxy_tidl_info->rpc_h, pid);
-       if (RPC_PORT_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget finalize : Fail to invoke message, error(%d)", ret);
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (VC_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget finalize : Fail to invoke finalize, error(%d)", ret);
+               pthread_mutex_unlock(&g_w_init_mutex);
+               return ret;
+       }
+
+       ret = rpc_port_proxy_vc_widget_proxy_vc_widget_disconnect(g_proxy_tidl_info->rpc_h);
+       exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (VC_ERROR_NONE != ret) {
+               SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget finalize : Fail to disconnect, error(%d)", ret);
                pthread_mutex_unlock(&g_w_init_mutex);
                return ret;
        }
@@ -511,7 +537,12 @@ int vc_widget_tidl_request_start_recording(int pid, bool command)
        }
 
        int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_start_recording(g_proxy_tidl_info->rpc_h, pid, (int)command);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (VC_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget start recording : Fail to invoke message, error(%d)", ret);
                return ret;
        }
@@ -554,7 +585,12 @@ int vc_widget_tidl_request_enable_asr_result(int pid, bool enable)
        }
 
        int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_enable_asr_result(g_proxy_tidl_info->rpc_h, pid, (int)enable);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (VC_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget enable asr result : Fail to invoke message, error(%d)", ret);
                return ret;
        }
@@ -577,7 +613,12 @@ int vc_widget_tidl_request_start(int pid, int silence)
        }
 
        int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_start(g_proxy_tidl_info->rpc_h, pid, silence);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (VC_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget start : Fail to invoke message, error(%d)", ret);
                return ret;
        }
@@ -600,7 +641,12 @@ int vc_widget_tidl_request_stop(int pid)
        }
 
        int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_stop(g_proxy_tidl_info->rpc_h, pid);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (VC_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget stop : Fail to invoke message, error(%d)", ret);
                return ret;
        }
@@ -623,7 +669,12 @@ int vc_widget_tidl_request_cancel(int pid)
        }
 
        int ret = rpc_port_proxy_vc_widget_proxy_vc_widget_invoke_cancel(g_proxy_tidl_info->rpc_h, pid);
-       if (RPC_PORT_ERROR_NONE != ret) {
+       int exception = get_last_result();
+       if (RPC_PORT_ERROR_NONE != exception) {
+               ret = __convert_unhandled_error(exception);
+       }
+
+       if (VC_ERROR_NONE != ret) {
                SLOG(LOG_ERROR, TAG_VCW, "[TIDL ERROR] Request vc widget cancel : Fail to invoke message, error(%d)", ret);
                return ret;
        }