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 = (intptr_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 = (intptr_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");
123 static void __on_rejected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data)
125 unsigned int pid = (intptr_t)user_data;
127 vc_tidl_info_s* info = __get_tidl_info_s(pid);
128 RETM_IF(NULL == info, TAG_VCC, "[ERROR] Fail to get tidl info");
130 info->connection_requesting = false;
131 info->register_notify_callback_invoked = false;
133 SLOG(LOG_INFO, TAG_VCC, "[INFO] Rejected from server(%d)", pid);
138 static rpc_port_proxy_vc_proxy_vc_h __create_rpc_port(int pid, const char* engine_app_id)
140 SLOG(LOG_INFO, TAG_VCC, "[INFO] vc __create_rpc_port");
142 rpc_port_proxy_vc_proxy_vc_callback_s rpc_callback = {
143 .connected = __on_connected,
144 .disconnected = __on_disconnected,
145 .rejected = __on_rejected
148 rpc_port_proxy_vc_proxy_vc_h handle = NULL;
149 intptr_t ptr_pid = pid;
150 if (0 != rpc_port_proxy_vc_proxy_vc_create(engine_app_id, &rpc_callback, (void*)ptr_pid, &handle)) {
153 SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] Succeed rpc_port_proxy_vc_proxy_vc_create");
158 static void __request_tidl_connect(vc_tidl_info_s* info)
160 if (info->connection_requesting) {
161 SLOG(LOG_INFO, TAG_VCC, "[TIDL] Already connection is requested. Skip to call rpc_port_proxy_vc_proxy_vc_connect().");
165 int ret = rpc_port_proxy_vc_proxy_vc_connect(info->rpc_h);
167 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request connection to stub. ret(%d)", ret);
171 SLOG(LOG_INFO, TAG_VCC, "[INFO] Request connection to stub. ret(%d)", ret);
172 info->connection_requesting = true;
175 static int __request_tidl_connect_sync(vc_tidl_info_s* info)
177 int ret = rpc_port_proxy_vc_proxy_vc_connect_sync(info->rpc_h);
178 if (RPC_PORT_ERROR_NONE != ret) {
179 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request connection to stub. ret(%d)", ret);
180 return VC_ERROR_OPERATION_FAILED;
183 SLOG(LOG_INFO, TAG_VCC, "[INFO] Success to connect stub synchronously. ret(%d)", ret);
184 return VC_ERROR_NONE;
189 static void __notify_cb(void* user_data, int pid, bundle* msg)
191 // corresponding to listener_event_callback
194 SLOG(LOG_DEBUG, TAG_VCC, "__notify_cb is invoked pid(%d)", pid);
196 bundle_get_str(msg, VC_BUNDLE_METHOD, &method);
198 if (0 == strncmp(VCD_METHOD_HELLO, method, strlen(VCD_METHOD_HELLO))) {
199 } /* VCD_METHOD_HELLO */
200 else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) {
203 bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &state);
205 __vc_cb_service_state(atoi(state));
207 } /* VCD_METHOD_SET_SERVICE_STATE */
208 else if (0 == strncmp(VCD_METHOD_RESULT, method, strlen(VCD_METHOD_RESULT))) {
209 SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Client Result");
212 } /* VCD_METHOD_RESULT */
213 else if (0 == strncmp(VCD_METHOD_SEND_MANAGER_PID, method, strlen(VCD_METHOD_SEND_MANAGER_PID))) {
215 char* manager_pid = NULL;
216 bundle_get_str(msg, VC_BUNDLE_MANAGER_PID, &manager_pid);
218 SLOG(LOG_DEBUG, TAG_VCC, "@@ manager pid is changed : %d", atoi(manager_pid));
219 __vc_cb_manager_pid(atoi(manager_pid));
221 } /* VCD_METHOD_SEND_MANAGER_PID */
222 else if (0 == strncmp(VCD_METHOD_ERROR, method, strlen(VCD_METHOD_ERROR))) {
226 char* err_msg = NULL;
228 bundle_get_str(msg, VC_BUNDLE_PID, &pid);
229 bundle_get_str(msg, VC_BUNDLE_REASON, &reason);
230 bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg);
232 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), pid(%d), msg(%s)", atoi(reason), atoi(pid), err_msg);
233 __vc_cb_error(atoi(reason), err_msg);
234 } /* VCD_METHOD_ERROR */
235 else if (0 == strncmp(VC_MANAGER_METHOD_UTTERANCE_STATUS, method, strlen(VC_MANAGER_METHOD_UTTERANCE_STATUS))) {
239 char* utt_status = NULL;
241 bundle_get_str(msg, VC_BUNDLE_PID, &pid);
242 bundle_get_str(msg, VC_BUNDLE_UTT_ID, &utt_id);
243 bundle_get_str(msg, VC_BUNDLE_UTT_STATUS, &utt_status);
245 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));
246 __vc_cb_utterance_status(atoi(utt_id), atoi(utt_status));
247 } /* VC_MANAGER_METHOD_UTTERANCE_STATUS */
249 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid msg");
253 void __feedback_cb(void *user_data, int utt_id, int event, rpc_port_proxy_vc_proxy_array_char_h pcm_data, int len)
255 // corresponding to listener_event_callback (only for tts_streaming)
256 SLOG(LOG_DEBUG, TAG_VCC, "__feedback_cb is invoked. utt_id(%d), event(%d), pcm_len(%d)", utt_id, event, len);
258 char* data_char = NULL;
259 rpc_port_proxy_vc_proxy_array_char_get(pcm_data, &data_char, &len);
261 /* VCD_METHOD_FEEDBACK_STREAMING */
262 __vc_cb_tts_streaming(utt_id, event, data_char, len);
264 if (NULL != data_char) {
272 static int __create_notify_callback_handle(vc_tidl_info_s* info)
275 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid parameter");
276 return VC_ERROR_INVALID_PARAMETER;
279 if (NULL != info->notify_cb_h) {
280 rpc_port_proxy_vc_proxy_vc_notify_cb_dispose(info->rpc_h, info->notify_cb_h);
281 info->notify_cb_h = NULL;
284 int ret = rpc_port_proxy_vc_proxy_vc_notify_cb_create(&info->notify_cb_h);
285 if (RPC_PORT_ERROR_NONE != ret) {
286 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke rpc_port_proxy_vc_proxy_vc_notify_cb_create(). err(%d)", ret);
287 return VC_ERROR_OUT_OF_MEMORY;
290 rpc_port_proxy_vc_proxy_vc_notify_cb_set_callback(info->notify_cb_h, __notify_cb, NULL);
291 rpc_port_proxy_vc_proxy_vc_notify_cb_set_once(info->notify_cb_h, false);
293 return VC_ERROR_NONE;
297 static int __create_feedback_callback_handle(vc_tidl_info_s* info)
300 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid parameter");
301 return VC_ERROR_INVALID_PARAMETER;
304 if (NULL != info->feedback_cb_h) {
305 rpc_port_proxy_vc_proxy_vc_feedback_cb_dispose(info->rpc_h, info->feedback_cb_h);
306 info->feedback_cb_h = NULL;
309 int ret = rpc_port_proxy_vc_proxy_vc_feedback_cb_create(&info->feedback_cb_h);
310 if (RPC_PORT_ERROR_NONE != ret) {
311 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke rpc_port_proxy_vc_proxy_vc_feedback_cb_create(). err(%d)", ret);
312 return VC_ERROR_OUT_OF_MEMORY;
315 rpc_port_proxy_vc_proxy_vc_feedback_cb_set_callback(info->feedback_cb_h, __feedback_cb, NULL);
316 rpc_port_proxy_vc_proxy_vc_feedback_cb_set_once(info->feedback_cb_h, false);
318 return VC_ERROR_NONE;
322 static int __invoke_register_notify_callback(int pid, vc_tidl_info_s* info)
324 if (info->register_notify_callback_invoked) {
325 SLOG(LOG_ERROR, TAG_VCC, "[INFO] Already register callback is invoked");
326 return VC_ERROR_NONE;
329 int ret = __create_notify_callback_handle(info);
330 if (VC_ERROR_NONE != ret) {
331 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create callback handle. ret(%d)", ret);
332 return VC_ERROR_OPERATION_FAILED;
335 rpc_port_proxy_vc_proxy_vc_invoke_register_notify_cb(info->rpc_h, pid, info->notify_cb_h);
336 info->register_notify_callback_invoked = true;
337 return VC_ERROR_NONE;
341 static int __invoke_register_feedback_callback(int pid, vc_tidl_info_s* info)
343 if (info->register_feedback_callback_invoked) {
344 SLOG(LOG_ERROR, TAG_VCC, "[INFO] Already register callback is invoked");
345 return VC_ERROR_NONE;
348 int ret = __create_feedback_callback_handle(info);
349 if (VC_ERROR_NONE != ret) {
350 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create callback handle. ret(%d)", ret);
351 return VC_ERROR_OPERATION_FAILED;
354 rpc_port_proxy_vc_proxy_vc_invoke_register_feedback_cb(info->rpc_h, pid, info->feedback_cb_h);
355 info->register_feedback_callback_invoked = true;
356 return VC_ERROR_NONE;
360 int vc_tidl_open_connection()
362 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_open_connection");
364 vc_tidl_info_s* info = (vc_tidl_info_s*)calloc(1, sizeof(vc_tidl_info_s));
366 SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create tidl_info_s");
367 return VC_ERROR_OUT_OF_MEMORY;
372 info->engine_appid = __get_engine_appid();
374 info->rpc_h = __create_rpc_port(pid, info->engine_appid);
375 if (NULL == info->rpc_h) {
376 SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create proxy");
378 return VC_ERROR_OPERATION_FAILED;
381 g_tidl_infos = g_list_append(g_tidl_infos, info);
383 SLOG(LOG_ERROR, TAG_VCC, "[TIDL] pid(%d) rpc_h(%p), engine_appid(%s)", pid, info->rpc_h, info->engine_appid);
384 return VC_ERROR_NONE;
388 int vc_tidl_close_connection()
390 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_close_connection");
393 vc_tidl_info_s* info = __get_tidl_info_s(pid);
394 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
396 if (0 != rpc_port_proxy_vc_proxy_vc_destroy(info->rpc_h)) {
397 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to disconnect");
398 return VC_ERROR_OPERATION_FAILED;
402 info->notify_cb_h = NULL;
404 g_tidl_infos = g_list_remove(g_tidl_infos, info);
407 return VC_ERROR_NONE;
410 int vc_tidl_request_hello()
412 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_hello");
415 vc_tidl_info_s* info = __get_tidl_info_s(pid);
416 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
418 if (!info->connected) {
419 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()");
420 __request_tidl_connect(info);
421 return VC_ERROR_OPERATION_FAILED;
424 SLOG(LOG_DEBUG, TAG_VCC, ">>>>> VCC Hello");
425 if (VC_ERROR_NONE != __invoke_register_notify_callback(pid, info)) {
426 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register callback");
427 return VC_ERROR_OPERATION_FAILED;
430 SLOG(LOG_DEBUG, TAG_VCC, "<<<<");
431 return VC_ERROR_NONE;
435 int vc_tidl_request_hello_sync()
437 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_hello");
440 vc_tidl_info_s* info = __get_tidl_info_s(pid);
441 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
443 if (!info->connected) {
444 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()");
445 int ret = __request_tidl_connect_sync(info);
446 if (VC_ERROR_NONE != ret) {
447 SLOG(LOG_ERROR, TAG_VCC, "[TIDL] Fail to connect, ret(%d)", ret);
448 return VC_ERROR_OPERATION_FAILED;
450 SLOG(LOG_ERROR, TAG_VCC, "[TIDL] Stub is connected");
453 SLOG(LOG_DEBUG, TAG_VCC, ">>>>> VCC Hello");
454 if (VC_ERROR_NONE != __invoke_register_notify_callback(pid, info)) {
455 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register callback");
456 return VC_ERROR_OPERATION_FAILED;
459 SLOG(LOG_DEBUG, TAG_VCC, "<<<<");
460 return VC_ERROR_NONE;
464 static int __convert_unhandled_error(int ret)
466 if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) {
467 return VC_ERROR_OPERATION_FAILED;
474 int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid)
476 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_initialize");
478 vc_tidl_info_s* info = __get_tidl_info_s(pid);
479 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
480 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
482 int ret = rpc_port_proxy_vc_proxy_vc_invoke_initialize(info->rpc_h, pid, mgr_pid, service_state, daemon_pid);
483 int exception = get_last_result();
484 if (RPC_PORT_ERROR_NONE != exception) {
485 ret = __convert_unhandled_error(exception);
488 if (VC_ERROR_NONE != ret) {
489 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc initialize : Fail to invoke message. err(%d)", ret);
493 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : mgr = %d service = %d daemon_pid = %d", *mgr_pid, *service_state, *daemon_pid);
495 return VC_ERROR_NONE;
498 int vc_tidl_request_finalize(int pid)
500 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_finalize");
502 vc_tidl_info_s* info = __get_tidl_info_s(pid);
503 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
504 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
506 int ret = rpc_port_proxy_vc_proxy_vc_invoke_finalize(info->rpc_h, pid);
507 int exception = get_last_result();
508 if (RPC_PORT_ERROR_NONE != exception) {
509 ret = __convert_unhandled_error(exception);
512 if (VC_ERROR_NONE != ret) {
513 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc finalize : Fail to invoke finalize. err(%d)", ret);
517 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : result = %d", ret);
519 return VC_ERROR_NONE;
522 int vc_tidl_request_set_command(int pid, vc_cmd_type_e cmd_type)
524 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_command");
526 vc_tidl_info_s* info = __get_tidl_info_s(pid);
527 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
528 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
530 int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_command(info->rpc_h, pid, cmd_type);
531 int exception = get_last_result();
532 if (RPC_PORT_ERROR_NONE != exception) {
533 ret = __convert_unhandled_error(exception);
536 if (VC_ERROR_NONE != ret) {
537 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set command : Fail to invoke message. err(%d)", ret);
541 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : pid(%d), cmd_type(%d)", pid, cmd_type);
543 return VC_ERROR_NONE;
546 int vc_tidl_request_unset_command(int pid, vc_cmd_type_e cmd_type)
548 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_unset_command");
550 vc_tidl_info_s* info = __get_tidl_info_s(pid);
551 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
552 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
554 int ret = rpc_port_proxy_vc_proxy_vc_invoke_unset_command(info->rpc_h, pid, cmd_type);
555 int exception = get_last_result();
556 if (RPC_PORT_ERROR_NONE != exception) {
557 ret = __convert_unhandled_error(exception);
560 if (VC_ERROR_NONE != ret) {
561 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc unset command : Fail to invoke message. err(%d)", ret);
565 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : pid(%d), cmd_type(%d)", pid, cmd_type);
567 return VC_ERROR_NONE;
571 int vc_tidl_request_set_foreground(int pid, bool value)
573 // method no reply --> async
574 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_foreground");
576 vc_tidl_info_s* info = __get_tidl_info_s(pid);
577 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
578 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
580 int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_foreground(info->rpc_h, pid, value);
581 int exception = get_last_result();
582 if (RPC_PORT_ERROR_NONE != exception) {
583 ret = __convert_unhandled_error(exception);
586 if (VC_ERROR_NONE != ret) {
587 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set foreground : Fail to invoke message. err(%d)", ret);
591 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground : pid(%d), value(%d)", pid, value);
593 return VC_ERROR_NONE;
597 int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* credential)
599 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_server_dialog");
601 vc_tidl_info_s* info = __get_tidl_info_s(pid);
602 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
603 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
605 int ret = rpc_port_proxy_vc_proxy_vc_invoke_set_server_dialog(info->rpc_h, pid, app_id, credential);
606 int exception = get_last_result();
607 if (RPC_PORT_ERROR_NONE != exception) {
608 ret = __convert_unhandled_error(exception);
611 if (VC_ERROR_NONE != ret) {
612 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set server dialog : Fail to invoke message. err(%d)", ret);
616 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : pid(%d), app_id(%s), credential(%s)", pid, app_id, credential);
618 return VC_ERROR_NONE;
621 int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous)
623 // method no reply --> async
624 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_request_dialog");
626 vc_tidl_info_s* info = __get_tidl_info_s(pid);
627 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
628 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
630 int ret = rpc_port_proxy_vc_proxy_vc_invoke_request_dialog(info->rpc_h, pid, disp_text, utt_text, continuous);
631 int exception = get_last_result();
632 if (RPC_PORT_ERROR_NONE != exception) {
633 ret = __convert_unhandled_error(exception);
636 if (VC_ERROR_NONE != ret) {
637 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request dialog : Fail to invoke message. err(%d)", ret);
641 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous);
643 return VC_ERROR_NONE;
646 int vc_tidl_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid)
648 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_is_system_command_valid");
650 vc_tidl_info_s* info = __get_tidl_info_s(pid);
651 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
652 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
654 int ret = rpc_port_proxy_vc_proxy_vc_invoke_is_system_command_valid(info->rpc_h, pid, is_sys_cmd_valid);
655 int exception = get_last_result();
656 if (RPC_PORT_ERROR_NONE != exception) {
657 ret = __convert_unhandled_error(exception);
660 if (VC_ERROR_NONE != ret) {
661 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc is system command valid : Fail to invoke message. err(%d)", ret);
665 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : pid(%d), is_sys_cmd_valid(%d)", pid, *is_sys_cmd_valid);
667 return VC_ERROR_NONE;
672 int vc_tidl_request_auth_enable(int pid, int mgr_pid)
674 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_enable");
676 vc_tidl_info_s* info = __get_tidl_info_s(pid);
677 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
678 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
680 int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_enable(info->rpc_h, pid, mgr_pid);
681 int exception = get_last_result();
682 if (RPC_PORT_ERROR_NONE != exception) {
683 ret = __convert_unhandled_error(exception);
686 if (VC_ERROR_NONE != ret) {
687 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth enable : Fail to invoke message. err(%d)", ret);
691 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : pid(%d), mgr_pid(%d)", pid, mgr_pid);
693 return VC_ERROR_NONE;
696 int vc_tidl_request_auth_disable(int pid, int mgr_pid)
698 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_disable");
700 vc_tidl_info_s* info = __get_tidl_info_s(pid);
701 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
702 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
704 int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_disable(info->rpc_h, pid, mgr_pid);
705 int exception = get_last_result();
706 if (RPC_PORT_ERROR_NONE != exception) {
707 ret = __convert_unhandled_error(exception);
710 if (VC_ERROR_NONE != ret) {
711 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth disable : Fail to invoke message. err(%d)", ret);
715 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : pid(%d), mgr_pid(%d)", pid, mgr_pid);
717 return VC_ERROR_NONE;
720 int vc_tidl_request_auth_start(int pid, int mgr_pid)
722 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_start");
724 vc_tidl_info_s* info = __get_tidl_info_s(pid);
725 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
726 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
728 int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_start(info->rpc_h, pid, mgr_pid);
729 int exception = get_last_result();
730 if (RPC_PORT_ERROR_NONE != exception) {
731 ret = __convert_unhandled_error(exception);
734 if (VC_ERROR_NONE != ret) {
735 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth start : Fail to invoke message. err(%d)", ret);
739 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : pid(%d), mgr_pid(%d)", pid, mgr_pid);
741 return VC_ERROR_NONE;
744 int vc_tidl_request_auth_stop(int pid, int mgr_pid)
746 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_stop");
748 vc_tidl_info_s* info = __get_tidl_info_s(pid);
749 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
750 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
752 int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_stop(info->rpc_h, pid, mgr_pid);
753 int exception = get_last_result();
754 if (RPC_PORT_ERROR_NONE != exception) {
755 ret = __convert_unhandled_error(exception);
758 if (VC_ERROR_NONE != ret) {
759 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth stop : Fail to invoke message. err(%d)", ret);
763 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : pid(%d), mgr_pid(%d)", pid, mgr_pid);
765 return VC_ERROR_NONE;
768 int vc_tidl_request_auth_cancel(int pid, int mgr_pid)
770 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_cancel");
772 vc_tidl_info_s* info = __get_tidl_info_s(pid);
773 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
774 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
776 int ret = rpc_port_proxy_vc_proxy_vc_invoke_auth_cancel(info->rpc_h, pid, mgr_pid);
777 int exception = get_last_result();
778 if (RPC_PORT_ERROR_NONE != exception) {
779 ret = __convert_unhandled_error(exception);
782 if (VC_ERROR_NONE != ret) {
783 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth cancel : Fail to invoke message. err(%d)", ret);
787 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : pid(%d), mgr_pid(%d)", pid, mgr_pid);
789 return VC_ERROR_NONE;
793 int vc_tidl_request_request_tts(int pid, const char* text, const char* language, bool to_vcm, int* utt_id)
795 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_request_tts");
797 vc_tidl_info_s* info = __get_tidl_info_s(pid);
798 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
799 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
801 if (VC_ERROR_NONE != __invoke_register_feedback_callback(pid, info)) {
802 SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register feedback callback");
803 return VC_ERROR_OPERATION_FAILED;
806 int ret = rpc_port_proxy_vc_proxy_vc_invoke_request_tts(info->rpc_h, pid, text, language, to_vcm, utt_id);
807 int exception = get_last_result();
808 if (RPC_PORT_ERROR_NONE != exception) {
809 ret = __convert_unhandled_error(exception);
812 if (VC_ERROR_NONE != ret) {
813 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request tts : Fail to invoke message. err(%d)", ret);
817 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request tts : pid(%d)", pid);
819 return VC_ERROR_NONE;
822 int vc_tidl_request_cancel_tts(int pid, int utt_id)
824 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_cancel_tts");
826 vc_tidl_info_s* info = __get_tidl_info_s(pid);
827 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
828 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
830 int ret = rpc_port_proxy_vc_proxy_vc_invoke_cancel_tts(info->rpc_h, pid, utt_id);
831 int exception = get_last_result();
832 if (RPC_PORT_ERROR_NONE != exception) {
833 ret = __convert_unhandled_error(exception);
836 if (VC_ERROR_NONE != ret) {
837 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc cancel tts : Fail to invoke message. err(%d)", ret);
841 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel tts : pid(%d), utt_id(%d)", pid, utt_id);
843 return VC_ERROR_NONE;
846 int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type)
848 SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_get_tts_audio_format");
850 vc_tidl_info_s* info = __get_tidl_info_s(pid);
851 RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info");
852 RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, TAG_VCC, "[ERROR] Not Connected");
854 int ret = rpc_port_proxy_vc_proxy_vc_invoke_get_tts_audio_format(info->rpc_h, pid, rate, (int*)channel, (int*)audio_type);
855 int exception = get_last_result();
856 if (RPC_PORT_ERROR_NONE != exception) {
857 ret = __convert_unhandled_error(exception);
860 if (VC_ERROR_NONE != ret) {
861 SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc get tts audio format: Fail to invoke message. err(%d)", ret);
865 SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get tts audio format : pid(%d), rate(%d), channel(%d), audio_type(%d)", pid, *rate, *channel, *audio_type);
867 return VC_ERROR_NONE;