2 * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "vc_command.h"
21 #include "vc_client.h"
28 bool connection_requesting;
29 bool register_notify_callback_invoked;
30 bool register_feedback_callback_invoked;
32 rpc_port_proxy_vc_proxy_vc_h rpc_h;
33 rpc_port_proxy_vc_proxy_vc_notify_cb_h notify_cb_h;
34 rpc_port_proxy_vc_proxy_vc_feedback_cb_h feedback_cb_h;
39 static GList* g_tidl_infos = NULL;
41 extern int __vc_cb_error(int reason, char* msg);
42 extern void __vc_cb_result();
43 extern int __vc_cb_service_state(int state);
44 extern int __vc_cb_manager_pid(int manager_pid);
45 extern int __vc_cb_tts_streaming(int utt_id, vc_feedback_event_e event, char* buffer, int len);
46 extern int __vc_cb_utterance_status(int utt_id, int utt_status);
49 static vc_tidl_info_s* __get_tidl_info_s(int pid)
52 vc_tidl_info_s* info = NULL;
54 if (g_list_length(g_tidl_infos) > 0) {
55 /* Get a first item */
56 iter = g_list_first(g_tidl_infos);
58 while (NULL != iter) {
61 if (info->pid == pid) {
66 iter = g_list_next(iter);
73 static char* __get_engine_appid(void)
75 char* engine_name = vconf_get_str(VC_ENGINE_DB_DEFAULT);
76 if (NULL == engine_name) {
77 SLOG(LOG_WARN, TAG_VCC, "[WARNING] Fail to get engine name. Please use default engine name.");
78 engine_name = strdup("org.tizen.vc-engine-default");
81 char* appid = strdup(engine_name);
83 SLOG(LOG_INFO, TAG_VCC, "[INFO] VC engine appid(%s)", appid);
90 static void __on_connected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data)
92 unsigned int pid = (uintptr_t)user_data;
94 vc_tidl_info_s* info = __get_tidl_info_s(pid);
95 RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info");
97 info->connected = true;
98 info->connection_requesting = false;
99 info->register_notify_callback_invoked = false;
101 SLOG(LOG_INFO, TAG_VCC, "[INFO] Connected to server");
104 static void __on_disconnected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data)
106 unsigned int pid = (uintptr_t)user_data;
108 vc_tidl_info_s* info = __get_tidl_info_s(pid);
109 RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info");
111 info->connected = false;
112 info->connection_requesting = false;
113 info->register_notify_callback_invoked = false;
115 /* retry to connect */
116 SLOG(LOG_INFO, TAG_VCC, "[INFO] Disconnected to server");
117 if (vc_client_is_listening_started()) {
118 __vc_cb_error(VC_ERROR_SERVICE_RESET, "Server Disconnected");
122 static void __on_rejected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data)
124 unsigned int pid = (uintptr_t)user_data;
126 vc_tidl_info_s* info = __get_tidl_info_s(pid);
127 RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info");
129 info->connection_requesting = false;
130 info->register_notify_callback_invoked = false;
132 SLOG(LOG_INFO, TAG_VCC, "[INFO] Rejected from server(%d)", pid);
136 static rpc_port_proxy_vc_proxy_vc_h __create_rpc_port(int pid, const char* engine_app_id)
138 SLOG(LOG_INFO, TAG_VCC, "[INFO] vc __create_rpc_port");
140 rpc_port_proxy_vc_proxy_vc_callback_s rpc_callback = {
141 .connected = __on_connected,
142 .disconnected = __on_disconnected,
143 .rejected = __on_rejected
146 rpc_port_proxy_vc_proxy_vc_h handle = NULL;
147 uintptr_t ptr_pid = pid;
148 if (0 != rpc_port_proxy_vc_proxy_vc_create(engine_app_id, &rpc_callback, (void*)ptr_pid, &handle)) {
151 SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Succeed rpc_port_proxy_vc_proxy_vc_create");
156 static void __request_tidl_connect(vc_tidl_info_s* info)
158 if (info->connection_requesting) {
159 SLOG(LOG_INFO, TAG_VCC, "[TIDL] Already connection is requested. Skip to call rpc_port_proxy_vc_proxy_vc_connect().");
163 int ret = rpc_port_proxy_vc_proxy_vc_connect(info->rpc_h);
165 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request connection to stub. ret(%d)", ret);
169 SLOG(LOG_INFO, TAG_VCC, "[INFO] Request connection to stub. ret(%d)", ret);
170 info->connection_requesting = true;
173 static int __request_tidl_connect_sync(vc_tidl_info_s* info)
175 int ret = rpc_port_proxy_vc_proxy_vc_connect_sync(info->rpc_h);
176 if (RPC_PORT_ERROR_NONE != ret) {
177 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request connection to stub. ret(%d)", ret);
178 return VC_ERROR_OPERATION_FAILED;
181 SLOG(LOG_INFO, TAG_VCC, "[INFO] Success to connect stub synchronously. ret(%d)", ret);
182 return VC_ERROR_NONE;
186 static void __notify_cb(void* user_data, int pid, bundle* msg)
188 // corresponding to listener_event_callback
191 SLOG(LOG_DEBUG, TAG_VCC, "__notify_cb is invoked pid(%d)", pid);
193 bundle_get_str(msg, VC_BUNDLE_METHOD, &method);
195 if (0 == strncmp(VCD_METHOD_HELLO, method, strlen(VCD_METHOD_HELLO))) {
196 } /* VCD_METHOD_HELLO */
197 else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) {
200 bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &state);
202 __vc_cb_service_state(atoi(state));
204 } /* VCD_METHOD_SET_SERVICE_STATE */
205 else if (0 == strncmp(VCD_METHOD_RESULT, method, strlen(VCD_METHOD_RESULT))) {
206 SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Client Result");
209 } /* VCD_METHOD_RESULT */
210 else if (0 == strncmp(VCD_METHOD_SEND_MANAGER_PID, method, strlen(VCD_METHOD_SEND_MANAGER_PID))) {
212 char* manager_pid = NULL;
213 bundle_get_str(msg, VC_BUNDLE_MANAGER_PID, &manager_pid);
215 SLOG(LOG_DEBUG, TAG_VCC, "@@ manager pid is changed : %d", atoi(manager_pid));
216 __vc_cb_manager_pid(atoi(manager_pid));
218 } /* VCD_METHOD_SEND_MANAGER_PID */
219 else if (0 == strncmp(VCD_METHOD_ERROR, method, strlen(VCD_METHOD_ERROR))) {
223 char* err_msg = NULL;
225 bundle_get_str(msg, VC_BUNDLE_PID, &pid);
226 bundle_get_str(msg, VC_BUNDLE_REASON, &reason);
227 bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg);
229 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), pid(%d), msg(%s)", atoi(reason), atoi(pid), err_msg);
230 __vc_cb_error(atoi(reason), err_msg);
231 } /* VCD_METHOD_ERROR */
232 else if (0 == strncmp(VC_MANAGER_METHOD_UTTERANCE_STATUS, method, strlen(VC_MANAGER_METHOD_UTTERANCE_STATUS))) {
236 char* utt_status = NULL;
238 bundle_get_str(msg, VC_BUNDLE_PID, &pid);
239 bundle_get_str(msg, VC_BUNDLE_UTT_ID, &utt_id);
240 bundle_get_str(msg, VC_BUNDLE_UTT_STATUS, &utt_status);
242 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get utterance status : pid(%d), utt_id(%d), utt_status(%d)", atoi(pid), atoi(utt_id), atoi(utt_status));
243 __vc_cb_utterance_status(atoi(utt_id), atoi(utt_status));
244 } /* VC_MANAGER_METHOD_UTTERANCE_STATUS */
246 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid msg");
250 void __feedback_cb(void *user_data, int utt_id, int event, rpc_port_proxy_vc_proxy_array_char_h pcm_data, int len)
252 // corresponding to listener_event_callback (only for tts_streaming)
253 SLOG(LOG_DEBUG, TAG_VCC, "__feedback_cb is invoked. utt_id(%d), event(%d), pcm_len(%d)", utt_id, event, len);
255 char* data_char = NULL;
256 rpc_port_proxy_vc_proxy_array_char_get(pcm_data, &data_char, &len);
258 /* VCD_METHOD_FEEDBACK_STREAMING */
259 __vc_cb_tts_streaming(utt_id, event, data_char, len);
261 if (NULL != data_char) {
268 static int __create_notify_callback_handle(vc_tidl_info_s* info)
271 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid parameter");
272 return VC_ERROR_INVALID_PARAMETER;
275 if (NULL != info->notify_cb_h) {
276 rpc_port_proxy_vc_proxy_vc_notify_cb_dispose(info->rpc_h, info->notify_cb_h);
277 info->notify_cb_h = NULL;
280 int ret = rpc_port_proxy_vc_proxy_vc_notify_cb_create(&info->notify_cb_h);
281 if (RPC_PORT_ERROR_NONE != ret) {
282 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke rpc_port_proxy_vc_proxy_vc_notify_cb_create(). err(%d)", ret);
283 return VC_ERROR_OUT_OF_MEMORY;
286 rpc_port_proxy_vc_proxy_vc_notify_cb_set_callback(info->notify_cb_h, __notify_cb, NULL);
287 rpc_port_proxy_vc_proxy_vc_notify_cb_set_once(info->notify_cb_h, false);
289 return VC_ERROR_NONE;
292 static int __create_feedback_callback_handle(vc_tidl_info_s* info)
295 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid parameter");
296 return VC_ERROR_INVALID_PARAMETER;
299 if (NULL != info->feedback_cb_h) {
300 rpc_port_proxy_vc_proxy_vc_feedback_cb_dispose(info->rpc_h, info->feedback_cb_h);
301 info->feedback_cb_h = NULL;
304 int ret = rpc_port_proxy_vc_proxy_vc_feedback_cb_create(&info->feedback_cb_h);
305 if (RPC_PORT_ERROR_NONE != ret) {
306 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke rpc_port_proxy_vc_proxy_vc_feedback_cb_create(). err(%d)", ret);
307 return VC_ERROR_OUT_OF_MEMORY;
310 rpc_port_proxy_vc_proxy_vc_feedback_cb_set_callback(info->feedback_cb_h, __feedback_cb, NULL);
311 rpc_port_proxy_vc_proxy_vc_feedback_cb_set_once(info->feedback_cb_h, false);
313 return VC_ERROR_NONE;
316 static int __invoke_register_notify_callback(int pid, vc_tidl_info_s* info)
318 if (info->register_notify_callback_invoked) {
319 SLOG(LOG_ERROR, TAG_VCC, "[INFO] Already register callback is invoked");
320 return VC_ERROR_NONE;
323 int ret = __create_notify_callback_handle(info);
324 if (VC_ERROR_NONE != ret) {
325 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create callback handle. ret(%d)", ret);
326 return VC_ERROR_OPERATION_FAILED;
329 rpc_port_proxy_vc_proxy_vc_invoke_register_notify_cb(info->rpc_h, pid, info->notify_cb_h);
330 info->register_notify_callback_invoked = true;
331 return VC_ERROR_NONE;
334 static int __invoke_register_feedback_callback(int pid, vc_tidl_info_s* info)
336 if (info->register_feedback_callback_invoked) {
337 SLOG(LOG_ERROR, TAG_VCC, "[INFO] Already register callback is invoked");
338 return VC_ERROR_NONE;
341 int ret = __create_feedback_callback_handle(info);
342 if (VC_ERROR_NONE != ret) {
343 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create callback handle. ret(%d)", ret);
344 return VC_ERROR_OPERATION_FAILED;
347 rpc_port_proxy_vc_proxy_vc_invoke_register_feedback_cb(info->rpc_h, pid, info->feedback_cb_h);
348 info->register_feedback_callback_invoked = true;
349 return VC_ERROR_NONE;
352 int vc_tidl_open_connection()
354 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_open_connection");
356 vc_tidl_info_s* info = (vc_tidl_info_s*)calloc(1, sizeof(vc_tidl_info_s));
358 SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create tidl_info_s");
359 return VC_ERROR_OUT_OF_MEMORY;
364 info->engine_appid = __get_engine_appid();
366 info->rpc_h = __create_rpc_port(pid, info->engine_appid);
367 if (NULL == info->rpc_h) {
368 SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create proxy");
370 return VC_ERROR_OPERATION_FAILED;
373 g_tidl_infos = g_list_append(g_tidl_infos, info);
375 SLOG(LOG_ERROR, TAG_VCC, "[TIDL] pid(%d) rpc_h(%p), engine_appid(%s)", pid, info->rpc_h, info->engine_appid);
376 return VC_ERROR_NONE;
380 int vc_tidl_close_connection()
382 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_close_connection");
385 vc_tidl_info_s* info = __get_tidl_info_s(pid);
386 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
388 if (0 != rpc_port_proxy_vc_proxy_vc_destroy(info->rpc_h)) {
389 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to disconnect");
390 return VC_ERROR_OPERATION_FAILED;
394 info->notify_cb_h = NULL;
396 g_tidl_infos = g_list_remove(g_tidl_infos, info);
399 return VC_ERROR_NONE;
402 int vc_tidl_request_hello()
404 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_hello");
407 vc_tidl_info_s* info = __get_tidl_info_s(pid);
408 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
410 if (!info->connected) {
411 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()");
412 __request_tidl_connect(info);
413 return VC_ERROR_OPERATION_FAILED;
416 SLOG(LOG_DEBUG, TAG_VCC, ">>>>> VCC Hello");
417 if (VC_ERROR_NONE != __invoke_register_notify_callback(pid, info)) {
418 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register callback");
419 return VC_ERROR_OPERATION_FAILED;
422 SLOG(LOG_DEBUG, TAG_VCC, "<<<<");
423 return VC_ERROR_NONE;
427 int vc_tidl_request_hello_sync()
429 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_hello");
432 vc_tidl_info_s* info = __get_tidl_info_s(pid);
433 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
435 if (!info->connected) {
436 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()");
437 int ret = __request_tidl_connect_sync(info);
438 if (VC_ERROR_NONE != ret) {
439 SLOG(LOG_ERROR, TAG_VCC, "[TIDL] Fail to connect, ret(%d)", ret);
440 return VC_ERROR_OPERATION_FAILED;
442 SLOG(LOG_ERROR, TAG_VCC, "[TIDL] Stub is connected");
445 SLOG(LOG_DEBUG, TAG_VCC, ">>>>> VCC Hello");
446 if (VC_ERROR_NONE != __invoke_register_notify_callback(pid, info)) {
447 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register callback");
448 return VC_ERROR_OPERATION_FAILED;
451 SLOG(LOG_DEBUG, TAG_VCC, "<<<<");
452 return VC_ERROR_NONE;
455 static int __convert_unhandled_error(int ret)
457 if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) {
458 return VC_ERROR_OPERATION_FAILED;
464 int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid)
466 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_initialize");
468 vc_tidl_info_s* info = __get_tidl_info_s(pid);
469 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
470 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
472 int ret = rpc_port_proxy_vc_proxy_vc_invoke_initialize(info->rpc_h, pid, mgr_pid, service_state, daemon_pid);
473 int exception = get_last_result();
474 if (RPC_PORT_ERROR_NONE != exception) {
475 ret = __convert_unhandled_error(exception);
478 if (VC_ERROR_NONE != ret) {
479 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc initialize : Fail to invoke message. err(%d)", ret);
483 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : mgr = %d service = %d daemon_pid = %d", *mgr_pid, *service_state, *daemon_pid); //LCOV_EXCL_LINE
485 return VC_ERROR_NONE;
488 int vc_tidl_request_finalize(int pid)
490 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_finalize");
492 vc_tidl_info_s* info = __get_tidl_info_s(pid);
493 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
494 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
496 int ret = rpc_port_proxy_vc_proxy_vc_invoke_finalize(info->rpc_h, pid);
497 int exception = get_last_result();
498 if (RPC_PORT_ERROR_NONE != exception) {
499 ret = __convert_unhandled_error(exception);
502 if (VC_ERROR_NONE != ret) {
503 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc finalize : Fail to invoke finalize. err(%d)", ret);
507 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : result = %d", ret);
509 return VC_ERROR_NONE;
512 int vc_tidl_request_set_command(int pid, vc_cmd_type_e cmd_type)
514 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_command");
516 vc_tidl_info_s* info = __get_tidl_info_s(pid);
517 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
518 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
520 int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_command(info->rpc_h, pid, cmd_type);
521 int exception = get_last_result();
522 if (RPC_PORT_ERROR_NONE != exception) {
523 ret = __convert_unhandled_error(exception);
526 if (VC_ERROR_NONE != ret) {
527 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set command : Fail to invoke message. err(%d)", ret);
531 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : pid(%d), cmd_type(%d)", pid, cmd_type);
533 return VC_ERROR_NONE;
536 int vc_tidl_request_unset_command(int pid, vc_cmd_type_e cmd_type)
538 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_unset_command");
540 vc_tidl_info_s* info = __get_tidl_info_s(pid);
541 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
542 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
544 int ret = rpc_port_proxy_vc_proxy_vc_invoke_unset_command(info->rpc_h, pid, cmd_type);
545 int exception = get_last_result();
546 if (RPC_PORT_ERROR_NONE != exception) {
547 ret = __convert_unhandled_error(exception);
550 if (VC_ERROR_NONE != ret) {
551 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc unset command : Fail to invoke message. err(%d)", ret);
555 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : pid(%d), cmd_type(%d)", pid, cmd_type);
557 return VC_ERROR_NONE;
560 int vc_tidl_request_set_foreground(int pid, bool value)
562 // method no reply --> async
563 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_foreground");
565 vc_tidl_info_s* info = __get_tidl_info_s(pid);
566 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
567 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
569 int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_foreground(info->rpc_h, pid, value);
570 int exception = get_last_result();
571 if (RPC_PORT_ERROR_NONE != exception) {
572 ret = __convert_unhandled_error(exception);
575 if (VC_ERROR_NONE != ret) {
576 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set foreground : Fail to invoke message. err(%d)", ret);
580 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground : pid(%d), value(%d)", pid, value);
582 return VC_ERROR_NONE;
585 int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* credential)
587 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_server_dialog");
589 vc_tidl_info_s* info = __get_tidl_info_s(pid);
590 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
591 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
593 int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_server_dialog(info->rpc_h, pid, app_id, credential);
594 int exception = get_last_result();
595 if (RPC_PORT_ERROR_NONE != exception) {
596 ret = __convert_unhandled_error(exception);
599 if (VC_ERROR_NONE != ret) {
600 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set server dialog : Fail to invoke message. err(%d)", ret);
604 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : pid(%d), app_id(%s), credential(%s)", pid, app_id, credential);
606 return VC_ERROR_NONE;
609 int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous)
611 // method no reply --> async
612 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_request_dialog");
614 vc_tidl_info_s* info = __get_tidl_info_s(pid);
615 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
616 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
618 int ret = rpc_port_proxy_vc_proxy_vc_invoke_request_dialog(info->rpc_h, pid, disp_text, utt_text, continuous);
619 int exception = get_last_result();
620 if (RPC_PORT_ERROR_NONE != exception) {
621 ret = __convert_unhandled_error(exception);
624 if (VC_ERROR_NONE != ret) {
625 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request dialog : Fail to invoke message. err(%d)", ret);
629 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous);
631 return VC_ERROR_NONE;
634 int vc_tidl_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid)
636 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_is_system_command_valid");
638 vc_tidl_info_s* info = __get_tidl_info_s(pid);
639 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
640 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
642 int ret = rpc_port_proxy_vc_proxy_vc_invoke_is_system_command_valid(info->rpc_h, pid, is_sys_cmd_valid);
643 int exception = get_last_result();
644 if (RPC_PORT_ERROR_NONE != exception) {
645 ret = __convert_unhandled_error(exception);
648 if (VC_ERROR_NONE != ret) {
649 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc is system command valid : Fail to invoke message. err(%d)", ret);
653 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : pid(%d), is_sys_cmd_valid(%d)", pid, *is_sys_cmd_valid);
655 return VC_ERROR_NONE;
659 int vc_tidl_request_auth_enable(int pid, int mgr_pid)
661 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_enable");
663 vc_tidl_info_s* info = __get_tidl_info_s(pid);
664 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
665 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
667 int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_enable(info->rpc_h, pid, mgr_pid);
668 int exception = get_last_result();
669 if (RPC_PORT_ERROR_NONE != exception) {
670 ret = __convert_unhandled_error(exception);
673 if (VC_ERROR_NONE != ret) {
674 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth enable : Fail to invoke message. err(%d)", ret);
678 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : pid(%d), mgr_pid(%d)", pid, mgr_pid);
680 return VC_ERROR_NONE;
683 int vc_tidl_request_auth_disable(int pid, int mgr_pid)
685 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_disable");
687 vc_tidl_info_s* info = __get_tidl_info_s(pid);
688 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
689 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
691 int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_disable(info->rpc_h, pid, mgr_pid);
692 int exception = get_last_result();
693 if (RPC_PORT_ERROR_NONE != exception) {
694 ret = __convert_unhandled_error(exception);
697 if (VC_ERROR_NONE != ret) {
698 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth disable : Fail to invoke message. err(%d)", ret);
702 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : pid(%d), mgr_pid(%d)", pid, mgr_pid);
704 return VC_ERROR_NONE;
707 int vc_tidl_request_auth_start(int pid, int mgr_pid)
709 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_start");
711 vc_tidl_info_s* info = __get_tidl_info_s(pid);
712 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
713 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
715 int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_start(info->rpc_h, pid, mgr_pid);
716 int exception = get_last_result();
717 if (RPC_PORT_ERROR_NONE != exception) {
718 ret = __convert_unhandled_error(exception);
721 if (VC_ERROR_NONE != ret) {
722 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth start : Fail to invoke message. err(%d)", ret);
726 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : pid(%d), mgr_pid(%d)", pid, mgr_pid);
728 return VC_ERROR_NONE;
731 int vc_tidl_request_auth_stop(int pid, int mgr_pid)
733 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_stop");
735 vc_tidl_info_s* info = __get_tidl_info_s(pid);
736 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
737 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
739 int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_stop(info->rpc_h, pid, mgr_pid);
740 int exception = get_last_result();
741 if (RPC_PORT_ERROR_NONE != exception) {
742 ret = __convert_unhandled_error(exception);
745 if (VC_ERROR_NONE != ret) {
746 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth stop : Fail to invoke message. err(%d)", ret);
750 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : pid(%d), mgr_pid(%d)", pid, mgr_pid);
752 return VC_ERROR_NONE;
755 int vc_tidl_request_auth_cancel(int pid, int mgr_pid)
757 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_cancel");
759 vc_tidl_info_s* info = __get_tidl_info_s(pid);
760 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
761 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
763 int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_cancel(info->rpc_h, pid, mgr_pid);
764 int exception = get_last_result();
765 if (RPC_PORT_ERROR_NONE != exception) {
766 ret = __convert_unhandled_error(exception);
769 if (VC_ERROR_NONE != ret) {
770 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth cancel : Fail to invoke message. err(%d)", ret);
774 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : pid(%d), mgr_pid(%d)", pid, mgr_pid);
776 return VC_ERROR_NONE;
780 int vc_tidl_request_request_tts(int pid, const char* text, const char* language, bool to_vcm, int* utt_id)
782 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_request_tts");
784 vc_tidl_info_s* info = __get_tidl_info_s(pid);
785 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
786 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
788 if (VC_ERROR_NONE != __invoke_register_feedback_callback(pid, info)) {
789 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register feedback callback");
790 return VC_ERROR_OPERATION_FAILED;
793 int ret = rpc_port_proxy_vc_proxy_vc_invoke_request_tts(info->rpc_h, pid, text, language, to_vcm, utt_id);
794 int exception = get_last_result();
795 if (RPC_PORT_ERROR_NONE != exception) {
796 ret = __convert_unhandled_error(exception);
799 if (VC_ERROR_NONE != ret) {
800 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request tts : Fail to invoke message. err(%d)", ret);
804 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request tts : pid(%d)", pid);
806 return VC_ERROR_NONE;
809 int vc_tidl_request_cancel_tts(int pid, int utt_id)
811 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_cancel_tts");
813 vc_tidl_info_s* info = __get_tidl_info_s(pid);
814 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
815 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
817 int ret = rpc_port_proxy_vc_proxy_vc_invoke_cancel_tts(info->rpc_h, pid, utt_id);
818 int exception = get_last_result();
819 if (RPC_PORT_ERROR_NONE != exception) {
820 ret = __convert_unhandled_error(exception);
823 if (VC_ERROR_NONE != ret) {
824 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc cancel tts : Fail to invoke message. err(%d)", ret);
828 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel tts : pid(%d), utt_id(%d)", pid, utt_id);
830 return VC_ERROR_NONE;
833 int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type)
835 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_get_tts_audio_format");
837 vc_tidl_info_s* info = __get_tidl_info_s(pid);
838 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
839 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
841 int ret = rpc_port_proxy_vc_proxy_vc_invoke_get_tts_audio_format(info->rpc_h, pid, rate, (int*)channel, (int*)audio_type);
842 int exception = get_last_result();
843 if (RPC_PORT_ERROR_NONE != exception) {
844 ret = __convert_unhandled_error(exception);
847 if (VC_ERROR_NONE != ret) {
848 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc get tts audio format: Fail to invoke message. err(%d)", ret);
852 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get tts audio format : pid(%d), rate(%d), channel(%d), audio_type(%d)", pid, *rate, *channel, *audio_type);
854 return VC_ERROR_NONE;