Update version to 1.70.7
[platform/core/uifw/voice-control.git] / client / vc_widget_tidl.c
index dbe49de..9b6a80b 100644 (file)
@@ -73,7 +73,7 @@ static void __notify_cb(void *user_data, bundle *msg)
                }
        } /* VCD_METHOD_HELLO */
 
-       else if (0 == strncmp(VCD_WIDGET_METHOD_SET_SERVICE_STATE, method, strlen(VCD_WIDGET_METHOD_SET_SERVICE_STATE))) {
+       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) {
@@ -81,7 +81,7 @@ static void __notify_cb(void *user_data, bundle *msg)
                        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");
@@ -159,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)
@@ -347,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) {
@@ -449,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;
@@ -482,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;
        }
@@ -507,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;
        }
@@ -550,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;
        }
@@ -573,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;
        }
@@ -596,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;
        }
@@ -619,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;
        }