vc.c
vc_data.cpp
vc_client.c
- vc_dbus.c
+# vc_dbus.c
+ vc_tidl.c
../common/vc_cmd_db.c
../common/vc_command.c
../common/vc_command_util.c
#include "vc_command.h"
#include "vc_config_mgr.h"
#include "vc_data.h"
-#include "vc_dbus.h"
+// #include "vc_dbus.h"
+#include "vc_tidl.h"
#include "vc_info_parser.h"
#include "vc_json_parser.h"
#include "vc_main.h"
int ret;
if (ECORE_WL2_EVENT_FOCUS_IN == type) {
SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set foreground");
- ret = vc_dbus_set_foreground(getpid(), true);
+ ret = vc_tidl_request_set_foreground(getpid(), true);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret);
}
}
} else if (ECORE_WL2_EVENT_FOCUS_OUT == type) {
SLOG(LOG_DEBUG, TAG_VCW, "@@@ Set background");
- ret = vc_dbus_set_foreground(getpid(), false);
+ ret = vc_tidl_request_set_foreground(getpid(), false);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (false) : %d", ret);
}
return VC_ERROR_NONE; //LCOV_EXCL_LINE
}
- if (0 != vc_dbus_open_connection()) {
+ if (0 != vc_tidl_open_connection()) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to open connection"); //LCOV_EXCL_LINE
return VC_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
}
}
}
- int ret = vc_dbus_request_finalize(g_vc->handle);
+ int ret = vc_tidl_request_finalize(g_vc->handle);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request finalize : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE
}
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to finalize DB, ret(%d)", ret); //LCOV_EXCL_LINE
}
- if (0 != vc_dbus_close_connection()) {
+ if (0 != vc_tidl_close_connection()) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to close connection"); //LCOV_EXCL_LINE
}
if (0 != ret)
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_FOREGROUND, ret); //LCOV_EXCL_LINE
- ret = vc_dbus_request_initialize(g_vc->handle, &mgr_pid, &service_state, &g_daemon_pid);
+ ret = vc_tidl_request_initialize(g_vc->handle, &mgr_pid, &service_state, &g_daemon_pid);
//LCOV_EXCL_START
if (VC_ERROR_ENGINE_NOT_FOUND == ret) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize : %s", __vc_get_error_code(ret));
int status = aul_app_get_status(appid);
if (STATUS_FOCUS == status) {
SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set foreground"); //LCOV_EXCL_LINE
- ret = vc_dbus_set_foreground(getpid(), true);
+ ret = vc_tidl_request_set_foreground(getpid(), true);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret); //LCOV_EXCL_LINE
}
return;
}
- ret = vc_dbus_request_hello();
+ ret = vc_tidl_request_hello();
if (ret == 0) {
SLOG(LOG_DEBUG, TAG_VCC, "Success to request hello. retry count(%d)", retry_count);
break;
int ret = -1;
bool is_prepared = false;
do {
- ret = vc_dbus_request_is_system_command_valid(g_vc->handle, &is_sys_cmd_valid);
+ ret = vc_tidl_request_is_system_command_valid(g_vc->handle, &is_sys_cmd_valid);
if (0 != ret) {
//LCOV_EXCL_START
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
int count = 0;
bool is_prepared = false;
do {
- ret = vc_dbus_request_set_command(g_vc->handle, (vc_cmd_type_e)type);
+ ret = vc_tidl_request_set_command(g_vc->handle, (vc_cmd_type_e)type);
if (0 != ret) {
//LCOV_EXCL_START
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
int ret = -1;
bool is_prepared = false;
while (0 != ret) {
- ret = vc_dbus_request_unset_command(g_vc->handle, (vc_cmd_type_e)type);
+ ret = vc_tidl_request_unset_command(g_vc->handle, (vc_cmd_type_e)type);
if (0 != ret) {
//LCOV_EXCL_START
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
int count = 0;
bool is_prepared = false;
do {
- ret = vc_dbus_request_set_command(g_vc->handle, (vc_cmd_type_e)type);
+ ret = vc_tidl_request_set_command(g_vc->handle, (vc_cmd_type_e)type);
if (0 != ret) {
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
int count = 0;
bool is_prepared = false;
do {
- ret = vc_dbus_set_server_dialog(pid, tmp_appid, credential);
+ ret = vc_tidl_request_set_server_dialog(pid, tmp_appid, credential);
if (0 != ret) {
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
bool is_prepared = false;
char* credential = strdup("#NULL");
do {
- ret = vc_dbus_set_server_dialog(pid, tmp_appid, credential);
+ ret = vc_tidl_request_set_server_dialog(pid, tmp_appid, credential);
if (0 != ret) {
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
}
SLOG(LOG_DEBUG, TAG_VCC, "Request dialog : pid(%d) disp_text(%s), utt_text(%s), auto_start(%d)", getpid(), disp_text, utt_text, auto_start);
- int ret = vc_dbus_request_dialog(getpid(), disp_text, utt_text, auto_start);
+ int ret = vc_tidl_request_request_dialog(getpid(), disp_text, utt_text, auto_start);
if (0 != ret) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request dialog, ret(%d)", ret);
return VC_ERROR_OPERATION_FAILED;
return VC_ERROR_OPERATION_FAILED;
}
- if (0 != vc_dbus_request_auth_enable(g_vc->handle, mgr_pid)) {
+ if (0 != vc_tidl_request_auth_enable(g_vc->handle, mgr_pid)) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to authority enabled");
return VC_ERROR_OPERATION_FAILED;
}
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to unset state changed cb");
}
- /* request return authority by dbus */
+ /* request return authority by tidl */
int mgr_pid = -1;
if (0 != vc_client_get_mgr_pid(g_vc, &mgr_pid)) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get mgr info");
return VC_ERROR_OPERATION_FAILED;
}
- if (0 != vc_dbus_request_auth_disable(g_vc->handle, mgr_pid)) {
+ if (0 != vc_tidl_request_auth_disable(g_vc->handle, mgr_pid)) {
SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to authority disable");
return VC_ERROR_OPERATION_FAILED;
}
bool is_prepared = false;
/* Request */
while (0 != ret) {
- ret = vc_dbus_request_auth_start(g_vc->handle, mgr_pid);
+ ret = vc_tidl_request_auth_start(g_vc->handle, mgr_pid);
if (0 != ret) {
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
bool is_prepared = false;
/* do request */
while (0 != ret) {
- ret = vc_dbus_request_auth_stop(g_vc->handle, mgr_pid);
+ ret = vc_tidl_request_auth_stop(g_vc->handle, mgr_pid);
if (0 != ret) {
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
int count = 0;
bool is_prepared = false;
while (0 != ret) {
- ret = vc_dbus_request_auth_cancel(g_vc->handle, mgr_pid);
+ ret = vc_tidl_request_auth_cancel(g_vc->handle, mgr_pid);
if (0 != ret) {
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
int count = 0;
bool is_prepared = false;
do {
- ret = vc_dbus_request_tts(pid, text, language, to_vc_manager, utt_id);
+ ret = vc_tidl_request_request_tts(pid, text, language, to_vc_manager, utt_id);
if (0 != ret) {
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
int count = 0;
bool is_prepared = false;
do {
- ret = vc_dbus_cancel_tts(pid, utt_id);
+ ret = vc_tidl_request_cancel_tts(pid, utt_id);
if (0 != ret) {
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
int count = 0;
bool is_prepared = false;
do {
- ret = vc_dbus_get_tts_audio_format(pid, rate, channel, audio_type);
+ ret = vc_tidl_request_get_tts_audio_format(pid, rate, channel, audio_type);
if (0 != ret) {
if (VC_ERROR_INVALID_PARAMETER == ret && false == is_prepared) {
vc_client_set_client_state(g_vc, VC_STATE_INITIALIZED);
--- /dev/null
+/*
+ * Generated by tidlc 1.8.1.
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <libgen.h>
+#include <glib.h>
+#include <dlog.h>
+#include <rpc-port.h>
+#include <rpc-port-parcel.h>
+
+#include "vc_proxy.h"
+
+#undef LOG_TAG
+#define LOG_TAG "RPC_PORT_PROXY"
+
+#undef _E
+#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _W
+#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _I
+#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _D
+#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#ifndef TIDL_VERSION
+#define TIDL_VERSION "1.8.1"
+#endif
+
+#ifndef nullptr
+#define nullptr NULL
+#endif
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
+
+#ifndef STRING_GET
+#define STRING_GET(x) ((x) ? x : "")
+#endif
+
+typedef void (*rpc_port_proxy_delegate_cb)(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id);
+
+typedef struct rpc_port_proxy_array_char_s {
+ rpc_port_parcelable_t parcelable;
+ char *value;
+ int size;
+} rpc_port_proxy_array_char_t;
+
+typedef struct rpc_port_proxy_vc_notify_cb_s {
+ rpc_port_parcelable_t parcelable;
+ int id;
+ int seq_id;
+ bool once;
+ rpc_port_proxy_vc_notify_cb_cb callback;
+ void *user_data;
+} rpc_port_proxy_vc_notify_cb_t;
+
+typedef struct rpc_port_proxy_vc_feedback_cb_s {
+ rpc_port_parcelable_t parcelable;
+ int id;
+ int seq_id;
+ bool once;
+ rpc_port_proxy_vc_feedback_cb_cb callback;
+ void *user_data;
+} rpc_port_proxy_vc_feedback_cb_t;
+
+typedef struct rpc_port_proxy_vc_s {
+ char *stub_appid;
+ rpc_port_proxy_h proxy;
+ rpc_port_h port;
+ rpc_port_h callback_port;
+ rpc_port_proxy_vc_callback_s callback;
+ void *user_data;
+ GList *delegates;
+ GRecMutex mutex;
+} rpc_port_proxy_vc_t;
+
+static void __rpc_port_proxy_array_char_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_array_char_h h = data;
+ int i;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_array_count(parcel, h->size);
+
+ for (i = 0; i < h->size; ++i)
+ rpc_port_parcel_write_byte(parcel, h->value[i]);
+}
+
+static void __rpc_port_proxy_array_char_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_array_char_h h = data;
+ char value;
+ int ret;
+ int i;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ ret = rpc_port_parcel_read_array_count(parcel, &h->size);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read array count. error(%d)", ret);
+ set_last_result(ret);
+ return;
+ }
+
+ h->value = calloc(h->size, sizeof(char));
+ if (h->value == nullptr) {
+ _E("Out of memory");
+ set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY);
+ return;
+ }
+
+ for (i = 0; i < h->size; ++i) {
+ rpc_port_parcel_read_byte(parcel, &value);
+ h->value[i] = value;
+ }
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_proxy_array_char_create(rpc_port_proxy_array_char_h *h)
+{
+ rpc_port_proxy_array_char_t *handle;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_proxy_array_char_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_proxy_array_char_to;
+ handle->parcelable.from = __rpc_port_proxy_array_char_from;
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_array_char_destroy(rpc_port_proxy_array_char_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->value)
+ free(h->value);
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_array_char_clone(rpc_port_proxy_array_char_h h, rpc_port_proxy_array_char_h *clone)
+{
+ rpc_port_proxy_array_char_h handle;
+ rpc_port_parcel_h parcel;
+ int ret;
+
+ if (h == nullptr || clone == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_proxy_array_char_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ ret = rpc_port_parcel_create(&parcel);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret);
+ rpc_port_proxy_array_char_destroy(handle);
+ return ret;
+ }
+
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_read(parcel, &handle->parcelable, handle);
+ ret = get_last_result();
+ rpc_port_parcel_destroy(parcel);
+
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read data. error(%d)", ret);
+ rpc_port_proxy_array_char_destroy(handle);
+ return ret;
+ }
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_array_char_set(rpc_port_proxy_array_char_h h, char *value, int size)
+{
+ rpc_port_proxy_array_char_h handle;
+ rpc_port_proxy_array_char_h clone;
+ int ret;
+
+ if (h == nullptr || value == nullptr || size <= 0) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_proxy_array_char_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ handle->value = (char *)value;
+ handle->size = size;
+
+ ret = rpc_port_proxy_array_char_clone(handle, &clone);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to clone handle. error(%d)", ret);
+ handle->value = nullptr;
+ handle->size = 0;
+ rpc_port_proxy_array_char_destroy(handle);
+ return ret;
+ }
+
+ handle->value = h->value;
+ handle->size = h->size;
+ rpc_port_proxy_array_char_destroy(handle);
+
+ h->value = clone->value;
+ h->size = clone->size;
+
+ clone->value = nullptr;
+ clone->size = 0;
+ rpc_port_proxy_array_char_destroy(clone);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_array_char_get(rpc_port_proxy_array_char_h h, char **value, int *size)
+{
+ rpc_port_proxy_array_char_h handle;
+ int ret;
+
+ if (h == nullptr || value == nullptr || size == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_proxy_array_char_clone(h, &handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to clone handle. error(%d)", ret);
+ return ret;
+ }
+
+ *value = handle->value;
+ *size = handle->size;
+
+ handle->value = nullptr;
+ handle->size = 0;
+ rpc_port_proxy_array_char_destroy(handle);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+typedef enum {
+ RPC_PORT_PROXY_VC_DELEGATE_NOTIFY_CB = 1,
+ RPC_PORT_PROXY_VC_DELEGATE_FEEDBACK_CB = 2,
+} rpc_port_proxy_vc_delegate_e;
+
+static void __rpc_port_proxy_vc_notify_cb_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_vc_notify_cb_h h = data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->id);
+
+ rpc_port_parcel_write_int32(parcel, h->seq_id);
+
+ rpc_port_parcel_write_bool(parcel, h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+}
+
+static void __rpc_port_proxy_vc_notify_cb_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_vc_notify_cb_h h = data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->id);
+
+ rpc_port_parcel_read_int32(parcel, &h->seq_id);
+
+ rpc_port_parcel_read_bool(parcel, &h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_proxy_vc_notify_cb_create(rpc_port_proxy_vc_notify_cb_h *h)
+{
+ rpc_port_proxy_vc_notify_cb_t *handle;
+ static int seq_num;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_proxy_vc_notify_cb_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_proxy_vc_notify_cb_to;
+ handle->parcelable.from = __rpc_port_proxy_vc_notify_cb_from;
+ handle->id = RPC_PORT_PROXY_VC_DELEGATE_NOTIFY_CB;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ _I("id(%d), seq_id(%d)", handle->id, handle->seq_id);
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_notify_cb_destroy(rpc_port_proxy_vc_notify_cb_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_notify_cb_clone(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_h *clone)
+{
+ rpc_port_proxy_vc_notify_cb_h handle;
+ rpc_port_parcel_h parcel;
+ int ret;
+
+ if (h == nullptr || clone == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_proxy_vc_notify_cb_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ ret = rpc_port_parcel_create(&parcel);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret);
+ rpc_port_proxy_vc_notify_cb_destroy(handle);
+ return ret;
+ }
+
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_read(parcel, &handle->parcelable, handle);
+ ret = get_last_result();
+ rpc_port_parcel_destroy(parcel);
+
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read data. error(%d)", ret);
+ rpc_port_proxy_vc_notify_cb_destroy(handle);
+ return ret;
+ }
+
+ handle->callback = h->callback;
+ handle->user_data = h->user_data;
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_notify_cb_set_callback(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_cb callback, void *user_data)
+{
+ if (h == nullptr || callback == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ h->callback = callback;
+ h->user_data = user_data;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_notify_cb_set_once(rpc_port_proxy_vc_notify_cb_h h, bool once)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ h->once = once;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_notify_cb_get_id(rpc_port_proxy_vc_notify_cb_h h, int *id)
+{
+ if (h == nullptr || id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *id = h->id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_notify_cb_get_seq_id(rpc_port_proxy_vc_notify_cb_h h, int *seq_id)
+{
+ if (h == nullptr || seq_id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *seq_id = h->seq_id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_notify_cb_is_once(rpc_port_proxy_vc_notify_cb_h h, bool *once)
+{
+ if (h == nullptr || once == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *once = h->once;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_notify_cb_get_tag(rpc_port_proxy_vc_notify_cb_h h, char **tag)
+{
+ char *new_tag;
+ char buf[128];
+
+ if (h == nullptr || tag == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id);
+ new_tag = strdup(buf);
+ if (new_tag == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *tag = new_tag;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_notify_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_notify_cb_h h)
+{
+ GList *found;
+
+ if (proxy == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ found = g_list_find(proxy->delegates, h);
+ if (found == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ proxy->delegates = g_list_remove_link(proxy->delegates, found);
+ rpc_port_proxy_vc_notify_cb_destroy(h);
+ g_list_free(found);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void __rpc_port_proxy_vc_notify_cb_delegate_handler(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id)
+{
+ rpc_port_proxy_vc_notify_cb_h handle;
+ GList *iter;
+ bool once;
+ int pid = -1;
+ bundle *msg = nullptr;
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_bundle(parcel, &msg);
+ if (msg == nullptr) {
+ _E("Failed to read data");
+ goto out;
+ }
+
+ iter = *delegates;
+ while (iter) {
+ handle = iter->data;
+ iter = g_list_next(iter);
+ if (handle->id == id && handle->seq_id == seq_id) {
+ once = handle->once;
+ _W("Invoke id(%d), seq_id(%d)", id, seq_id);
+ if (handle->callback)
+ handle->callback(handle->user_data, pid, msg);
+ else
+ _W("The callback function is nullptr");
+
+ if (once) {
+ *delegates = g_list_remove(*delegates, handle);
+ rpc_port_proxy_vc_notify_cb_destroy(handle);
+ }
+
+ break;
+ }
+ }
+
+out:
+
+ if (msg)
+ bundle_free(msg);
+}
+
+static void __rpc_port_proxy_vc_feedback_cb_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_vc_feedback_cb_h h = data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->id);
+
+ rpc_port_parcel_write_int32(parcel, h->seq_id);
+
+ rpc_port_parcel_write_bool(parcel, h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+}
+
+static void __rpc_port_proxy_vc_feedback_cb_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_proxy_vc_feedback_cb_h h = data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->id);
+
+ rpc_port_parcel_read_int32(parcel, &h->seq_id);
+
+ rpc_port_parcel_read_bool(parcel, &h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_proxy_vc_feedback_cb_create(rpc_port_proxy_vc_feedback_cb_h *h)
+{
+ rpc_port_proxy_vc_feedback_cb_t *handle;
+ static int seq_num;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_proxy_vc_feedback_cb_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_proxy_vc_feedback_cb_to;
+ handle->parcelable.from = __rpc_port_proxy_vc_feedback_cb_from;
+ handle->id = RPC_PORT_PROXY_VC_DELEGATE_FEEDBACK_CB;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ _I("id(%d), seq_id(%d)", handle->id, handle->seq_id);
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_feedback_cb_destroy(rpc_port_proxy_vc_feedback_cb_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_feedback_cb_clone(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_h *clone)
+{
+ rpc_port_proxy_vc_feedback_cb_h handle;
+ rpc_port_parcel_h parcel;
+ int ret;
+
+ if (h == nullptr || clone == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_proxy_vc_feedback_cb_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ ret = rpc_port_parcel_create(&parcel);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret);
+ rpc_port_proxy_vc_feedback_cb_destroy(handle);
+ return ret;
+ }
+
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_read(parcel, &handle->parcelable, handle);
+ ret = get_last_result();
+ rpc_port_parcel_destroy(parcel);
+
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read data. error(%d)", ret);
+ rpc_port_proxy_vc_feedback_cb_destroy(handle);
+ return ret;
+ }
+
+ handle->callback = h->callback;
+ handle->user_data = h->user_data;
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_feedback_cb_set_callback(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_cb callback, void *user_data)
+{
+ if (h == nullptr || callback == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ h->callback = callback;
+ h->user_data = user_data;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_feedback_cb_set_once(rpc_port_proxy_vc_feedback_cb_h h, bool once)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ h->once = once;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_feedback_cb_get_id(rpc_port_proxy_vc_feedback_cb_h h, int *id)
+{
+ if (h == nullptr || id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *id = h->id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_feedback_cb_get_seq_id(rpc_port_proxy_vc_feedback_cb_h h, int *seq_id)
+{
+ if (h == nullptr || seq_id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *seq_id = h->seq_id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_feedback_cb_is_once(rpc_port_proxy_vc_feedback_cb_h h, bool *once)
+{
+ if (h == nullptr || once == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *once = h->once;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_feedback_cb_get_tag(rpc_port_proxy_vc_feedback_cb_h h, char **tag)
+{
+ char *new_tag;
+ char buf[128];
+
+ if (h == nullptr || tag == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id);
+ new_tag = strdup(buf);
+ if (new_tag == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *tag = new_tag;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_feedback_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_feedback_cb_h h)
+{
+ GList *found;
+
+ if (proxy == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ found = g_list_find(proxy->delegates, h);
+ if (found == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ proxy->delegates = g_list_remove_link(proxy->delegates, found);
+ rpc_port_proxy_vc_feedback_cb_destroy(h);
+ g_list_free(found);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void __rpc_port_proxy_vc_feedback_cb_delegate_handler(GList **delegates, rpc_port_parcel_h parcel, int id, int seq_id)
+{
+ rpc_port_proxy_vc_feedback_cb_h handle;
+ GList *iter;
+ bool once;
+ int utt_id = -1;
+ int event = -1;
+ rpc_port_proxy_array_char_h pcm_data = nullptr;
+ int len = -1;
+
+ rpc_port_parcel_read_int32(parcel, &utt_id);
+
+ rpc_port_parcel_read_int32(parcel, &event);
+
+ rpc_port_proxy_array_char_create(&pcm_data);
+ if (pcm_data == nullptr) {
+ _E("Failed to create handle");
+ goto out;
+ }
+
+ rpc_port_parcel_read(parcel, &pcm_data->parcelable, pcm_data);
+ if (get_last_result() != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read data");
+ goto out;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &len);
+
+ iter = *delegates;
+ while (iter) {
+ handle = iter->data;
+ iter = g_list_next(iter);
+ if (handle->id == id && handle->seq_id == seq_id) {
+ once = handle->once;
+ _W("Invoke id(%d), seq_id(%d)", id, seq_id);
+ if (handle->callback)
+ handle->callback(handle->user_data, utt_id, event, pcm_data, len);
+ else
+ _W("The callback function is nullptr");
+
+ if (once) {
+ *delegates = g_list_remove(*delegates, handle);
+ rpc_port_proxy_vc_feedback_cb_destroy(handle);
+ }
+
+ break;
+ }
+ }
+
+out:
+
+ if (pcm_data)
+ rpc_port_proxy_array_char_destroy(pcm_data);
+}
+
+static rpc_port_proxy_delegate_cb __rpc_port_proxy_vc_delegate_table[] = {
+ [RPC_PORT_PROXY_VC_DELEGATE_NOTIFY_CB] = __rpc_port_proxy_vc_notify_cb_delegate_handler,
+ [RPC_PORT_PROXY_VC_DELEGATE_FEEDBACK_CB] = __rpc_port_proxy_vc_feedback_cb_delegate_handler,
+};
+
+typedef enum {
+ RPC_PORT_PROXY_VC_METHOD_RESULT_,
+ RPC_PORT_PROXY_VC_METHOD_CALLBACK_,
+ RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB,
+ RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB_SYNC,
+ RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB,
+ RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC,
+ RPC_PORT_PROXY_VC_METHOD_INITIALIZE,
+ RPC_PORT_PROXY_VC_METHOD_FINALIZE,
+ RPC_PORT_PROXY_VC_METHOD_SET_COMMAND,
+ RPC_PORT_PROXY_VC_METHOD_UNSET_COMMAND,
+ RPC_PORT_PROXY_VC_METHOD_SET_FOREGROUND,
+ RPC_PORT_PROXY_VC_METHOD_SET_SERVER_DIALOG,
+ RPC_PORT_PROXY_VC_METHOD_REQUEST_DIALOG,
+ RPC_PORT_PROXY_VC_METHOD_IS_SYSTEM_COMMAND_VALID,
+ RPC_PORT_PROXY_VC_METHOD_AUTH_ENABLE,
+ RPC_PORT_PROXY_VC_METHOD_AUTH_DISABLE,
+ RPC_PORT_PROXY_VC_METHOD_AUTH_START,
+ RPC_PORT_PROXY_VC_METHOD_AUTH_STOP,
+ RPC_PORT_PROXY_VC_METHOD_AUTH_CANCEL,
+ RPC_PORT_PROXY_VC_METHOD_REQUEST_TTS,
+ RPC_PORT_PROXY_VC_METHOD_CANCEL_TTS,
+ RPC_PORT_PROXY_VC_METHOD_GET_TTS_AUDIO_FORMAT,
+} rpc_port_proxy_vc_method_e;
+
+static void __rpc_port_proxy_vc_process_received_event(GList **delegates, rpc_port_parcel_h parcel)
+{
+ int id = 0;
+ int seq_id = 0;
+ bool once = false;
+
+ rpc_port_parcel_read_int32(parcel, &id);
+ rpc_port_parcel_read_int32(parcel, &seq_id);
+ rpc_port_parcel_read_bool(parcel, &once);
+ _W("id(%d), seq_id(%d)", id, seq_id);
+
+ if (id > 0 && id < ARRAY_SIZE(__rpc_port_proxy_vc_delegate_table)) {
+ if (__rpc_port_proxy_vc_delegate_table[id])
+ __rpc_port_proxy_vc_delegate_table[id](delegates, parcel, id, seq_id);
+ } else {
+ _W("Unknown ID(%d)", id);
+ }
+}
+
+static void __rpc_port_proxy_vc_consume_command(rpc_port_h port, rpc_port_parcel_h *p)
+{
+ rpc_port_parcel_h parcel;
+ int cmd = -1;
+ int ret;
+
+ do {
+ ret = rpc_port_parcel_create_from_port(&parcel, port);
+ if (ret != RPC_PORT_ERROR_NONE)
+ break;
+
+ rpc_port_parcel_read_int32(parcel, &cmd);
+ if (cmd == RPC_PORT_PROXY_VC_METHOD_RESULT_) {
+ *p = parcel;
+ return;
+ }
+
+ rpc_port_parcel_destroy(parcel);
+ } while (true);
+
+ *p = nullptr;
+}
+
+static void __rpc_port_proxy_vc_connected(const char *endpoint, const char *port_name, rpc_port_h port, void *data)
+{
+ rpc_port_proxy_vc_h h = data;
+
+ _I("endpoint(%s), port_name(%s)", endpoint, port_name);
+ h->port = port;
+ rpc_port_proxy_get_port(h->proxy, RPC_PORT_PORT_CALLBACK, &h->callback_port);
+ h->callback.connected(h, h->user_data);
+}
+
+static void __rpc_port_proxy_vc_disconnected(const char *endpoint, const char *port_name, void *data)
+{
+ rpc_port_proxy_vc_h h = data;
+
+ _W("endpoint(%s), port_name(%s)", endpoint, port_name);
+ h->port = nullptr;
+ h->callback.disconnected(h, h->user_data);
+}
+
+static void __rpc_port_proxy_vc_rejected(const char *endpoint, const char *port_name, void *data)
+{
+ rpc_port_proxy_vc_h h = data;
+
+ _W("endpoint(%s), port_name(%s)", endpoint, port_name);
+ h->port = nullptr;
+ h->callback.rejected(h, h->user_data);
+}
+
+static void __rpc_port_proxy_vc_received(const char *endpoint, const char *port_name, void *data)
+{
+ rpc_port_proxy_vc_h h = data;
+ rpc_port_parcel_h parcel;
+ int cmd = -1;
+ int ret;
+
+ _W("endpoint(%s), port_name(%s)", endpoint, port_name);
+ ret = rpc_port_parcel_create_from_port(&parcel, h->callback_port);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle from port. error(%d)", ret);
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &cmd);
+ if (cmd != RPC_PORT_PROXY_VC_METHOD_CALLBACK_) {
+ _E("Invalid protocol");
+ rpc_port_parcel_destroy(parcel);
+ return;
+ }
+
+ __rpc_port_proxy_vc_process_received_event(&h->delegates, parcel);
+ rpc_port_parcel_destroy(parcel);
+}
+
+int rpc_port_proxy_vc_create(const char *stub_appid, rpc_port_proxy_vc_callback_s *callback, void *user_data, rpc_port_proxy_vc_h *h)
+{
+ rpc_port_proxy_vc_t *handle;
+ int ret;
+
+ if (stub_appid == nullptr || callback == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (callback->connected == nullptr || callback->disconnected == nullptr || callback->rejected == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_proxy_vc_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ g_rec_mutex_init(&handle->mutex);
+
+ handle->stub_appid = strdup(stub_appid);
+ if (handle->stub_appid == nullptr) {
+ _E("Failed to duplicate stub appid");
+ rpc_port_proxy_vc_destroy(handle);
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ ret = rpc_port_proxy_create(&handle->proxy);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create proxy handle. error(%d)", ret);
+ rpc_port_proxy_vc_destroy(handle);
+ return ret;
+ }
+
+ handle->callback = *callback;
+ handle->user_data = user_data;
+
+ ret = rpc_port_proxy_add_connected_event_cb(handle->proxy, __rpc_port_proxy_vc_connected, handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add connected event cb. error(%d)", ret);
+ rpc_port_proxy_vc_destroy(handle);
+ return ret;
+ }
+
+ ret = rpc_port_proxy_add_disconnected_event_cb(handle->proxy, __rpc_port_proxy_vc_disconnected, handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add disconnected event cb. error(%d)", ret);
+ rpc_port_proxy_vc_destroy(handle);
+ return ret;
+ }
+
+ ret = rpc_port_proxy_add_rejected_event_cb(handle->proxy, __rpc_port_proxy_vc_rejected, handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add rejected event cb. error(%d)", ret);
+ rpc_port_proxy_vc_destroy(handle);
+ return ret;
+ }
+
+ ret = rpc_port_proxy_add_received_event_cb(handle->proxy, __rpc_port_proxy_vc_received, handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add received event cb. error(%d)", ret);
+ rpc_port_proxy_vc_destroy(handle);
+ return ret;
+ }
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_destroy(rpc_port_proxy_vc_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ g_rec_mutex_unlock(&h->mutex);
+ g_rec_mutex_clear(&h->mutex);
+
+ if (h->delegates)
+ g_list_free_full(h->delegates, free);
+
+ if (h->proxy)
+ rpc_port_proxy_destroy(h->proxy);
+
+ if (h->stub_appid)
+ free(h->stub_appid);
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_connect(rpc_port_proxy_vc_h h)
+{
+ int ret;
+
+ if (h == nullptr || h->proxy == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_proxy_connect(h->proxy, h->stub_appid, "vc");
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to connect to stub. error(%d)", ret);
+ return ret;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_connect_sync(rpc_port_proxy_vc_h h)
+{
+ int ret;
+
+ if (h == nullptr || h->proxy == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_proxy_connect_sync(h->proxy, h->stub_appid, "vc");
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to connect to stub. error(%d)", ret);
+ return ret;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_proxy_vc_disconnect(rpc_port_proxy_vc_h h)
+{
+ int ret;
+
+ if (h == nullptr || h->proxy == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_disconnect(h->port);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to disconnect from stub. error(%d)", ret);
+ return ret;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+void rpc_port_proxy_vc_invoke_register_notify_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int res_;
+
+ if (h == nullptr || callback == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+ return;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write(parcel_, &callback->parcelable, callback);
+
+ h->delegates = g_list_append(h->delegates, callback);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE)
+ _E("Failed to send parcel. error(%d)", res_);
+
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+}
+
+int rpc_port_proxy_vc_invoke_register_notify_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr || callback == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_NOTIFY_CB_SYNC);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write(parcel_, &callback->parcelable, callback);
+
+ h->delegates = g_list_append(h->delegates, callback);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+void rpc_port_proxy_vc_invoke_register_feedback_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int res_;
+
+ if (h == nullptr || callback == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+ return;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write(parcel_, &callback->parcelable, callback);
+
+ h->delegates = g_list_append(h->delegates, callback);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE)
+ _E("Failed to send parcel. error(%d)", res_);
+
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+}
+
+int rpc_port_proxy_vc_invoke_register_feedback_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr || callback == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write(parcel_, &callback->parcelable, callback);
+
+ h->delegates = g_list_append(h->delegates, callback);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_initialize(rpc_port_proxy_vc_h h, int pid, int *mgr_pid, int *service_state, int *daemon_pid)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+ int new_mgr_pid;
+ int new_service_state;
+ int new_daemon_pid;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_INITIALIZE);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &new_mgr_pid);
+
+ *mgr_pid = new_mgr_pid;
+
+ rpc_port_parcel_read_int32(parcel_, &new_service_state);
+
+ *service_state = new_service_state;
+
+ rpc_port_parcel_read_int32(parcel_, &new_daemon_pid);
+
+ *daemon_pid = new_daemon_pid;
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_finalize(rpc_port_proxy_vc_h h, int pid)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_FINALIZE);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_set_command(rpc_port_proxy_vc_h h, int pid, int cmd_type)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_SET_COMMAND);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_int32(parcel_, cmd_type);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_unset_command(rpc_port_proxy_vc_h h, int pid, int cmd_type)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_UNSET_COMMAND);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_int32(parcel_, cmd_type);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_set_foreground(rpc_port_proxy_vc_h h, int pid, bool value)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_SET_FOREGROUND);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_bool(parcel_, value);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_set_server_dialog(rpc_port_proxy_vc_h h, int pid, const char *app_id, const char *credential)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr || app_id == nullptr || credential == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_SET_SERVER_DIALOG);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_string(parcel_, app_id);
+
+ rpc_port_parcel_write_string(parcel_, credential);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_request_dialog(rpc_port_proxy_vc_h h, int pid, const char *disp_text, const char *utt_text, bool continuous)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr || disp_text == nullptr || utt_text == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REQUEST_DIALOG);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_string(parcel_, disp_text);
+
+ rpc_port_parcel_write_string(parcel_, utt_text);
+
+ rpc_port_parcel_write_bool(parcel_, continuous);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_is_system_command_valid(rpc_port_proxy_vc_h h, int pid, bool *is_sys_cmd_valid)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+ bool new_is_sys_cmd_valid;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_IS_SYSTEM_COMMAND_VALID);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_bool(parcel_, &new_is_sys_cmd_valid);
+
+ *is_sys_cmd_valid = new_is_sys_cmd_valid;
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_auth_enable(rpc_port_proxy_vc_h h, int pid, int mgr_pid)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_ENABLE);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_int32(parcel_, mgr_pid);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_auth_disable(rpc_port_proxy_vc_h h, int pid, int mgr_pid)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_DISABLE);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_int32(parcel_, mgr_pid);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_auth_start(rpc_port_proxy_vc_h h, int pid, int mgr_pid)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_START);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_int32(parcel_, mgr_pid);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_auth_stop(rpc_port_proxy_vc_h h, int pid, int mgr_pid)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_STOP);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_int32(parcel_, mgr_pid);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_auth_cancel(rpc_port_proxy_vc_h h, int pid, int mgr_pid)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_AUTH_CANCEL);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_int32(parcel_, mgr_pid);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_request_tts(rpc_port_proxy_vc_h h, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+ int new_utt_id;
+
+ if (h == nullptr || text == nullptr || lang == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_REQUEST_TTS);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_string(parcel_, text);
+
+ rpc_port_parcel_write_string(parcel_, lang);
+
+ rpc_port_parcel_write_bool(parcel_, to_vcm);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &new_utt_id);
+
+ *utt_id = new_utt_id;
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_cancel_tts(rpc_port_proxy_vc_h h, int pid, int utt_id)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_CANCEL_TTS);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_int32(parcel_, utt_id);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
+
+int rpc_port_proxy_vc_invoke_get_tts_audio_format(rpc_port_proxy_vc_h h, int pid, int *rate, int *channel, int *audio_type)
+{
+ rpc_port_parcel_h parcel_;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ int recv_seq_num_ = -1;
+ char *tag_ = nullptr;
+ bool done_ = false;
+ int res_;
+ int ret_ = -1;
+ int new_rate;
+ int new_channel;
+ int new_audio_type;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return ret_;
+ }
+
+ g_rec_mutex_lock(&h->mutex);
+ if (h->port == nullptr) {
+ _E("Not connected");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ res_ = rpc_port_parcel_create(&parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Version] \"%s\", [Sequence] %d", TIDL_VERSION, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_PROXY_VC_METHOD_GET_TTS_AUDIO_FORMAT);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ res_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ if (res_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to send parcel. error(%d)", res_);
+ set_last_result(res_);
+ g_rec_mutex_unlock(&h->mutex);
+ return ret_;
+ }
+
+ do {
+ parcel_ = nullptr;
+ __rpc_port_proxy_vc_consume_command(h->port, &parcel_);
+ if (parcel_ == nullptr) {
+ _E("Invalid protocol");
+ res_ = RPC_PORT_ERROR_IO_ERROR;
+ break;
+ }
+
+ header_ = nullptr;
+ rpc_port_parcel_get_header(parcel_, &header_);
+ tag_ = nullptr;
+ rpc_port_parcel_header_get_tag(header_, &tag_);
+ if (tag_ && tag_[0] != '\0') {
+ _W("[Version] %s", tag_);
+ rpc_port_parcel_header_get_seq_num(header_, &recv_seq_num_);
+ if (recv_seq_num_ != seq_num_) {
+ _E("Invalid protocol. %d", recv_seq_num_);
+ free(tag_);
+ rpc_port_parcel_destroy(parcel_);
+ continue;
+ }
+ }
+ done_ = true;
+ free(tag_);
+
+ rpc_port_parcel_read_int32(parcel_, &new_rate);
+
+ *rate = new_rate;
+
+ rpc_port_parcel_read_int32(parcel_, &new_channel);
+
+ *channel = new_channel;
+
+ rpc_port_parcel_read_int32(parcel_, &new_audio_type);
+
+ *audio_type = new_audio_type;
+
+ rpc_port_parcel_read_int32(parcel_, &ret_);
+
+ rpc_port_parcel_destroy(parcel_);
+ } while (!done_);
+ g_rec_mutex_unlock(&h->mutex);
+ set_last_result(res_);
+
+ return ret_;
+}
--- /dev/null
+/*
+ * Generated by tidlc 1.8.1.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+#include <bundle.h>
+#include <rpc-port.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief The rpc_port_proxy_array_char handle.
+ */
+typedef struct rpc_port_proxy_array_char_s *rpc_port_proxy_array_char_h;
+
+/**
+ * @brief The rpc_port_proxy_vc handle.
+ */
+typedef struct rpc_port_proxy_vc_s *rpc_port_proxy_vc_h;
+
+/**
+ * @brief The rpc_port_proxy_vc_notify_cb handle.
+ */
+typedef struct rpc_port_proxy_vc_notify_cb_s *rpc_port_proxy_vc_notify_cb_h;
+
+/**
+ * @brief The rpc_port_proxy_vc_feedback_cb handle.
+ */
+typedef struct rpc_port_proxy_vc_feedback_cb_s *rpc_port_proxy_vc_feedback_cb_h;
+
+/**
+ * @briefs Creates a rpc_port_proxy_array_char handle.
+ *
+ * @remarks The @a h should be released using the rpc_port_proxy_array_char_destroy()
+ * if it's no longer needed.
+ * @param[out] h The rpc_port_proxy_array_char handle that is newly created
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_array_char_destroy()
+ */
+int rpc_port_proxy_array_char_create(rpc_port_proxy_array_char_h *h);
+
+/**
+ * @brief Destroys the rpc_port_proxy_array_char handle.
+ *
+ * @param[in] h The rpc_port_proxy_array_char handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_proxy_array_char_create()
+ */
+int rpc_port_proxy_array_char_destroy(rpc_port_proxy_array_char_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_proxy_array_char handle.
+ *
+ * @remarks A new created rpc_port_proxy_array_char should be released using
+ * the rpc_port_proxy_array_char_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_proxy_array_char handle
+ * @param[out] clone If successful, a new created rpc_port_proxy_array_char handle will be returned
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_array_char_destroy()
+ */
+int rpc_port_proxy_array_char_clone(rpc_port_proxy_array_char_h h, rpc_port_proxy_array_char_h *clone);
+
+/**
+ * @brief Sets the value to the rpc_port_proxy_array_char handle.
+ *
+ * @remarks The value is internally copied and stored.
+ * You should release it if it's allocaed when it's no longer needed,
+ * @param[in] h The rpc_port_proxy_array_char handle
+ * @param[in] value The array value
+ * @param[in] size The size of the array
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_array_char_get()
+ */
+int rpc_port_proxy_array_char_set(rpc_port_proxy_array_char_h h, char *value, int size);
+
+/**
+ * @brief Gets the value from the rpc_port_proxy_array_char handle.
+ *
+ * @remarks A new created value should be released if it's no longer needed.
+ * @param[in] h The rpc_port_proxy_array_char handle
+ * @param[out] value The array value
+ * @param[out] size The size of the array
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_array_char_set()
+ */
+int rpc_port_proxy_array_char_get(rpc_port_proxy_array_char_h h, char **value, int *size);
+
+/**
+ * @brief Called when the event is received.
+ *
+ * @param[in] user_data The user data passed from the callback registration function
+ * @param[in] ...
+ *
+ * @see rpc_port_proxy_vc_notify_cb_create()
+ */
+typedef void (*rpc_port_proxy_vc_notify_cb_cb)(void *user_data, int pid, bundle *msg);
+
+/**
+ * @brief Creates a rpc_port_proxy_vc_notify_cb handle.
+ *
+ * @param[out] h The rpc_port_proxy_vc_notify_cb handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memorya
+ * @see rpc_port_proxy_vc_notify_cb_destroy()
+ * @see rpc_port_proxy_vc_notify_cb_dispose()
+ * @see rpc_port_proxy_vc_notify_cb_set_callback()
+ * @see rpc_port_proxy_vc_notify_cb_set_once()
+ */
+int rpc_port_proxy_vc_notify_cb_create(rpc_port_proxy_vc_notify_cb_h *h);
+
+/**
+ * @brief Destroys the rpc_port_proxy_vc_notify_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_vc_notify_cb handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_proxy_vc_notify_cb_create()
+ */
+int rpc_port_proxy_vc_notify_cb_destroy(rpc_port_proxy_vc_notify_cb_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_proxy_vc_notify_cb handle.
+ *
+ * @remarks A new created rpc_port_proxy_vc_notify_cb should be released using
+ * the rpc_port_proxy_vc_notify_cb_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_proxy_vc_notify_cb handle
+ * @param[out] clone If successful, a new created rpc_port_proxy_vc_notify_cb handle will be returned
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_vc_notify_cb_destroy()
+ */
+int rpc_port_proxy_vc_notify_cb_clone(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_h *clone);
+
+/**
+ * @brief Sets the callback function to the rpc_port_proxy_vc_notify_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_vc_notify_cb handle
+ * @param[in] callback The callback function
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_vc_notify_cb_set_callback(rpc_port_proxy_vc_notify_cb_h h, rpc_port_proxy_vc_notify_cb_cb callback, void *user_data);
+
+/**
+ * @brief Set the once flag to the rpc_port_proxy_vc_notify_cb handle.
+ * @details If the once flag is 'true', the delegate handle will be deleted after invocation.
+ * If the @a h handle is not used using the method, the handle should be released using
+ * the rpc_port_proxy_vc_notify_cb_destroy() when it's no longer needed.
+ * If you don't want the delegate callback function to be called after it's used using the method,
+ * you should release the handle using the rpc_port_proxy_vc_notify_cb_dispose().
+ *
+ * @param[in] h The rpc_port_proxy_vc_notify_cb handle
+ * @param[in] once The flag if it's true, the delegate will be deleted after invocation
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_vc_notify_cb_set_once(rpc_port_proxy_vc_notify_cb_h h, bool once);
+
+/**
+ * @brief Gets the ID of the rpc_port_proxy_vc_notify_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_vc_notify_cb handle
+ * @param[out] id The ID
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_vc_notify_cb_get_id(rpc_port_proxy_vc_notify_cb_h h, int *id);
+
+/**
+ * @brief Gets the sequence ID of the rpc_port_proxy_vc_notify_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_vc_notify_cb handle
+ * @param[out] seq_id The Sequence ID
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_vc_notify_cb_get_seq_id(rpc_port_proxy_vc_notify_cb_h h, int *seq_id);
+
+/**
+ * @brief Checks whether the delegate is for one-time or not.
+ *
+ * @param[in] h The rpc_port_proxy_vc_notify_cb handle
+ * @param[out] once The flag, it's true, the handle is for one-time
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_vc_notify_cb_is_once(rpc_port_proxy_vc_notify_cb_h h, bool *once);
+
+/**
+ * @brief Gets the tag from the rpc_port_proxy_vc_notify_cb handle.
+ *
+ * @remarks The @a tag should be released using free().
+ * @param[in] h The rpc_port_proxy_vc_notify_cb handle
+ * @param[out] tag The tag
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_proxy_vc_notify_cb_get_tag(rpc_port_proxy_vc_notify_cb_h h, char **tag);
+
+/**
+ * @brief Disposes the rpc_port_proxy_vc_notify_cb handle from the rpc_port_proxy_vc handle.
+ *
+ * @param[in] proxy The rpc_port_proxy_vc handle
+ * @param[in] h The rpc_port_proxy_vc_notify_cb handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_proxy_vc_notify_cb_create()
+ */
+int rpc_port_proxy_vc_notify_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_notify_cb_h h);
+
+/**
+ * @brief Called when the event is received.
+ *
+ * @param[in] user_data The user data passed from the callback registration function
+ * @param[in] ...
+ *
+ * @see rpc_port_proxy_vc_feedback_cb_create()
+ */
+typedef void (*rpc_port_proxy_vc_feedback_cb_cb)(void *user_data, int utt_id, int event, rpc_port_proxy_array_char_h pcm_data, int len);
+
+/**
+ * @brief Creates a rpc_port_proxy_vc_feedback_cb handle.
+ *
+ * @param[out] h The rpc_port_proxy_vc_feedback_cb handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memorya
+ * @see rpc_port_proxy_vc_feedback_cb_destroy()
+ * @see rpc_port_proxy_vc_feedback_cb_dispose()
+ * @see rpc_port_proxy_vc_feedback_cb_set_callback()
+ * @see rpc_port_proxy_vc_feedback_cb_set_once()
+ */
+int rpc_port_proxy_vc_feedback_cb_create(rpc_port_proxy_vc_feedback_cb_h *h);
+
+/**
+ * @brief Destroys the rpc_port_proxy_vc_feedback_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_vc_feedback_cb handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_proxy_vc_feedback_cb_create()
+ */
+int rpc_port_proxy_vc_feedback_cb_destroy(rpc_port_proxy_vc_feedback_cb_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_proxy_vc_feedback_cb handle.
+ *
+ * @remarks A new created rpc_port_proxy_vc_feedback_cb should be released using
+ * the rpc_port_proxy_vc_feedback_cb_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_proxy_vc_feedback_cb handle
+ * @param[out] clone If successful, a new created rpc_port_proxy_vc_feedback_cb handle will be returned
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_vc_feedback_cb_destroy()
+ */
+int rpc_port_proxy_vc_feedback_cb_clone(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_h *clone);
+
+/**
+ * @brief Sets the callback function to the rpc_port_proxy_vc_feedback_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_vc_feedback_cb handle
+ * @param[in] callback The callback function
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_vc_feedback_cb_set_callback(rpc_port_proxy_vc_feedback_cb_h h, rpc_port_proxy_vc_feedback_cb_cb callback, void *user_data);
+
+/**
+ * @brief Set the once flag to the rpc_port_proxy_vc_feedback_cb handle.
+ * @details If the once flag is 'true', the delegate handle will be deleted after invocation.
+ * If the @a h handle is not used using the method, the handle should be released using
+ * the rpc_port_proxy_vc_feedback_cb_destroy() when it's no longer needed.
+ * If you don't want the delegate callback function to be called after it's used using the method,
+ * you should release the handle using the rpc_port_proxy_vc_feedback_cb_dispose().
+ *
+ * @param[in] h The rpc_port_proxy_vc_feedback_cb handle
+ * @param[in] once The flag if it's true, the delegate will be deleted after invocation
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_vc_feedback_cb_set_once(rpc_port_proxy_vc_feedback_cb_h h, bool once);
+
+/**
+ * @brief Gets the ID of the rpc_port_proxy_vc_feedback_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_vc_feedback_cb handle
+ * @param[out] id The ID
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_vc_feedback_cb_get_id(rpc_port_proxy_vc_feedback_cb_h h, int *id);
+
+/**
+ * @brief Gets the sequence ID of the rpc_port_proxy_vc_feedback_cb handle.
+ *
+ * @param[in] h The rpc_port_proxy_vc_feedback_cb handle
+ * @param[out] seq_id The Sequence ID
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_vc_feedback_cb_get_seq_id(rpc_port_proxy_vc_feedback_cb_h h, int *seq_id);
+
+/**
+ * @brief Checks whether the delegate is for one-time or not.
+ *
+ * @param[in] h The rpc_port_proxy_vc_feedback_cb handle
+ * @param[out] once The flag, it's true, the handle is for one-time
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_vc_feedback_cb_is_once(rpc_port_proxy_vc_feedback_cb_h h, bool *once);
+
+/**
+ * @brief Gets the tag from the rpc_port_proxy_vc_feedback_cb handle.
+ *
+ * @remarks The @a tag should be released using free().
+ * @param[in] h The rpc_port_proxy_vc_feedback_cb handle
+ * @param[out] tag The tag
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_proxy_vc_feedback_cb_get_tag(rpc_port_proxy_vc_feedback_cb_h h, char **tag);
+
+/**
+ * @brief Disposes the rpc_port_proxy_vc_feedback_cb handle from the rpc_port_proxy_vc handle.
+ *
+ * @param[in] proxy The rpc_port_proxy_vc handle
+ * @param[in] h The rpc_port_proxy_vc_feedback_cb handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_proxy_vc_feedback_cb_create()
+ */
+int rpc_port_proxy_vc_feedback_cb_dispose(rpc_port_proxy_vc_h proxy, rpc_port_proxy_vc_feedback_cb_h h);
+
+/**
+ * @brief Called when the proxy is connected.
+ * @details The callback function is called when the proxy is connected to the stub.
+ *
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] user_data The user data passed from the registeration function
+ * @see #rpc_port_proxy_vc_callback_s
+ */
+typedef void (*rpc_port_proxy_vc_connected_cb)(rpc_port_proxy_vc_h h, void *user_data);
+
+/**
+ * @brief Called when the proxy is disconnected.
+ * @details The callback function is called when the proxy is disconnected from the stub.
+ *
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] user_data The user data passed from the registeration function
+ * @see #rpc_port_proxy_vc_callback_s
+ */
+typedef void (*rpc_port_proxy_vc_disconnected_cb)(rpc_port_proxy_vc_h h, void *user_data);
+
+/**
+ * @brief Called when the proxy is rejected.
+ * @details The callback function is called when the proxy is rejected to connect to the stub.
+ *
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] user_data The user data passed from the registeration function
+ * @see #rpc_port_proxy_vc_callback_s
+ */
+typedef void (*rpc_port_proxy_vc_rejected_cb)(rpc_port_proxy_vc_h h, void *user_data);
+
+/**
+ * @brief The structure type containing the set of callback functions for handling proxy events.
+ * @details It is one of the input parameters of the rpc_port_proxy_vc_create() function.
+ *
+ * @see rpc_port_proxy_vc_connected_cb
+ * @see rpc_port_proxy_vc_disconnected_cb
+ * @see rpc_port_proxy_vc_rejected_cb
+ */
+typedef struct {
+ rpc_port_proxy_vc_connected_cb connected; /**< This callback function is called when the proxy is connected to the stub. */
+ rpc_port_proxy_vc_disconnected_cb disconnected; /**< This callback function is called when the proxy is disconnected from the stub. */
+ rpc_port_proxy_vc_rejected_cb rejected; /**< This callback function is called when the proxy is rejected to connect to the stub. */
+} rpc_port_proxy_vc_callback_s;
+
+/**
+ * @brief Creates a rpc_port_proxy_vc handle.
+ * @remarks The @a h handle should be released using
+ * the rpc_port_proxy_vc_destroy() if it's no longer needed.
+ *
+ * @param[in] stub_appid The application ID of the stub
+ * @param[in] callback The set of callback functions to handle proxy events
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] h The rpc_port_proxy_vc handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_proxy_vc_destroy()
+ * @see #rpc_port_proxy_vc_callback_s
+ */
+int rpc_port_proxy_vc_create(const char *stub_appid, rpc_port_proxy_vc_callback_s *callback, void *user_data, rpc_port_proxy_vc_h *h);
+
+/**
+ * @brief Destroys the rpc_port_proxy_vc handle.
+ *
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_proxy_vc_create()
+ */
+int rpc_port_proxy_vc_destroy(rpc_port_proxy_vc_h h);
+
+/**
+ * @brief Connects to the stub.
+ *
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_IO_ERROR I/O error
+ * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied
+ */
+int rpc_port_proxy_vc_connect(rpc_port_proxy_vc_h h);
+
+/**
+ * @brief Connects to the stub synchronously.
+ *
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_IO_ERROR I/O error
+ * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied
+ */
+int rpc_port_proxy_vc_connect_sync(rpc_port_proxy_vc_h h);
+
+/**
+ * @brief Disconnects from the stub.
+ *
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_proxy_vc_disconnect(rpc_port_proxy_vc_h h);
+
+/**
+ * @brief Calls the register_notify_cb() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+void rpc_port_proxy_vc_invoke_register_notify_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback);
+
+/**
+ * @brief Calls the register_notify_cb_sync() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_register_notify_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_notify_cb_h callback);
+
+/**
+ * @brief Calls the register_feedback_cb() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+void rpc_port_proxy_vc_invoke_register_feedback_cb(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback);
+
+/**
+ * @brief Calls the register_feedback_cb_sync() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_register_feedback_cb_sync(rpc_port_proxy_vc_h h, int pid, rpc_port_proxy_vc_feedback_cb_h callback);
+
+/**
+ * @brief Calls the initialize() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_initialize(rpc_port_proxy_vc_h h, int pid, int *mgr_pid, int *service_state, int *daemon_pid);
+
+/**
+ * @brief Calls the finalize() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_finalize(rpc_port_proxy_vc_h h, int pid);
+
+/**
+ * @brief Calls the set_command() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_set_command(rpc_port_proxy_vc_h h, int pid, int cmd_type);
+
+/**
+ * @brief Calls the unset_command() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_unset_command(rpc_port_proxy_vc_h h, int pid, int cmd_type);
+
+/**
+ * @brief Calls the set_foreground() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_set_foreground(rpc_port_proxy_vc_h h, int pid, bool value);
+
+/**
+ * @brief Calls the set_server_dialog() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_set_server_dialog(rpc_port_proxy_vc_h h, int pid, const char *app_id, const char *credential);
+
+/**
+ * @brief Calls the request_dialog() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_request_dialog(rpc_port_proxy_vc_h h, int pid, const char *disp_text, const char *utt_text, bool continuous);
+
+/**
+ * @brief Calls the is_system_command_valid() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_is_system_command_valid(rpc_port_proxy_vc_h h, int pid, bool *is_sys_cmd_valid);
+
+/**
+ * @brief Calls the auth_enable() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_auth_enable(rpc_port_proxy_vc_h h, int pid, int mgr_pid);
+
+/**
+ * @brief Calls the auth_disable() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_auth_disable(rpc_port_proxy_vc_h h, int pid, int mgr_pid);
+
+/**
+ * @brief Calls the auth_start() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_auth_start(rpc_port_proxy_vc_h h, int pid, int mgr_pid);
+
+/**
+ * @brief Calls the auth_stop() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_auth_stop(rpc_port_proxy_vc_h h, int pid, int mgr_pid);
+
+/**
+ * @brief Calls the auth_cancel() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_auth_cancel(rpc_port_proxy_vc_h h, int pid, int mgr_pid);
+
+/**
+ * @brief Calls the request_tts() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_request_tts(rpc_port_proxy_vc_h h, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id);
+
+/**
+ * @brief Calls the cancel_tts() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_cancel_tts(rpc_port_proxy_vc_h h, int pid, int utt_id);
+
+/**
+ * @brief Calls the get_tts_audio_format() method.
+ * @details The return value and args are decided by the interface declaration.
+ * You can get the result using get_last_result().
+ * Before returning the function, the function sets the result using set_last_result().
+ * @remarks The specific error code can be obtained using the get_last_result() function. Error codes are described in Exception section.
+ * @param[in] h The rpc_port_proxy_vc handle
+ * @param[in] ...
+ * @exception #RPC_PORT_ERROR_NONE Successful
+ * @exception #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @exception #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @exception #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_proxy_vc_invoke_get_tts_audio_format(rpc_port_proxy_vc_h h, int pid, int *rate, int *channel, int *audio_type);
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null
+/*
+* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+#include "vc_command.h"
+#include "vc_tidl.h"
+#include "vc_proxy.h"
+#include "vc_main.h"
+
+#include <vconf.h>
+
+typedef struct {
+ int pid;
+ bool connected;
+ bool connection_requesting;
+ bool register_notify_callback_invoked;
+ bool register_feedback_callback_invoked;
+
+ rpc_port_proxy_vc_h rpc_h;
+ rpc_port_proxy_vc_notify_cb_h notify_cb_h;
+ rpc_port_proxy_vc_feedback_cb_h feedback_cb_h;
+
+ char* engine_appid;
+} vc_tidl_info_s;
+
+static GList* g_tidl_infos = NULL;
+
+extern int __vc_cb_error(int reason, int daemon_pid, char* msg);
+extern int __vc_cb_error_to_app(int pid, int reason, char* msg);
+extern void __vc_cb_result();
+extern int __vc_cb_service_state(int state);
+extern int __vc_cb_manager_pid(int manager_pid);
+extern int __vc_cb_tts_streaming(int utt_id, vc_feedback_event_e event, char* buffer, int len);
+extern int __vc_cb_utterance_status(int utt_id, int utt_status);
+
+
+static vc_tidl_info_s* __get_tidl_info_s(int pid)
+{
+ GList* iter = NULL;
+ vc_tidl_info_s* info = NULL;
+
+ if (g_list_length(g_tidl_infos) > 0) {
+ /* Get a first item */
+ iter = g_list_first(g_tidl_infos);
+
+ while (NULL != iter) {
+ info = iter->data;
+
+ if (info->pid == pid) {
+ return info;
+ }
+
+ /* Next item */
+ iter = g_list_next(iter);
+ }
+ }
+
+ return NULL;
+}
+
+static char* __get_engine_appid(void)
+{
+ char* engine_name = vconf_get_str(VC_ENGINE_DB_DEFAULT);
+ if (NULL == engine_name) {
+ SLOG(LOG_WARN, TAG_VCC, "[WARNING] Fail to get engine name. Please use default engine name.");
+ engine_name = strdup("org.tizen.vc-engine-default");
+ }
+
+ char* appid = strdup(engine_name);
+
+ return appid;
+}
+
+static void __on_connected(rpc_port_proxy_vc_h h, void* user_data)
+{
+ unsigned int pid = (uintptr_t)user_data;
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETM_IF(NULL == info, "[ERROR] Fail to get tidl info");
+
+ info->connected = true;
+ info->connection_requesting = false;
+ info->register_notify_callback_invoked = false;
+
+ SLOG(LOG_INFO, TAG_VCC, "[INFO] Connected to server");
+}
+
+static void __on_disconnected(rpc_port_proxy_vc_h h, void* user_data)
+{
+ unsigned int pid = (uintptr_t)user_data;
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETM_IF(NULL == info, "[ERROR] Fail to get tidl info");
+
+ info->connected = false;
+ info->connection_requesting = false;
+ info->register_notify_callback_invoked = false;
+
+ /* retry to connect */
+ SLOG(LOG_INFO, TAG_VCC, "[INFO] Disconnected to server");
+}
+
+static void __on_rejected(rpc_port_proxy_vc_h h, void* user_data)
+{
+ unsigned int pid = (uintptr_t)user_data;
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETM_IF(NULL == info, "[ERROR] Fail to get tidl info");
+
+ info->connection_requesting = false;
+ info->register_notify_callback_invoked = false;
+
+ SLOG(LOG_INFO, TAG_VCC, "[INFO] Rejected from server(%d)", pid);
+}
+
+
+static rpc_port_proxy_vc_h __create_rpc_port(int pid, const char* engine_app_id)
+{
+ rpc_port_proxy_vc_callback_s rpc_callback = {
+ .connected = __on_connected,
+ .disconnected = __on_disconnected,
+ .rejected = __on_rejected
+ };
+
+ rpc_port_proxy_vc_h handle = NULL;
+ uintptr_t ptr_pid = pid;
+ if (0 != rpc_port_proxy_vc_create(engine_app_id, &rpc_callback, (void*)ptr_pid, &handle)) {
+ return NULL;
+ }
+
+ return handle;
+}
+
+static void __request_tidl_connect(vc_tidl_info_s* info)
+{
+ if (info->connection_requesting) {
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] Already connection is requested. Skip to call rpc_port_proxy_vc_connect().");
+ return ;
+ }
+
+ int ret = rpc_port_proxy_vc_connect(info->rpc_h);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request connection to stub. ret(%d)", ret);
+ return ;
+ }
+
+ SLOG(LOG_INFO, TAG_VCC, "[INFO] Request connection to stub. ret(%d)", ret);
+ info->connection_requesting = true;
+}
+
+static void __notify_cb(void* user_data, int pid, bundle* msg)
+{
+ // corresponding to listener_event_callback
+ char* method = NULL;
+
+ SLOG(LOG_DEBUG, TAG_VCC, "__notify_cb is invoked pid(%d)", pid);
+
+ bundle_get_str(msg, VC_BUNDLE_METHOD, &method);
+
+ if (0 == strncmp(VCD_METHOD_HELLO, method, strlen(VCD_METHOD_HELLO))) {
+ } /* VCD_METHOD_HELLO */
+ else if (0 == strncmp(VCD_METHOD_SET_SERVICE_STATE, method, strlen(VCD_METHOD_SET_SERVICE_STATE))) {
+ /* signal!!! */
+ char* state = NULL;
+ bundle_get_str(msg, VC_BUNDLE_SERVICE_STATE, &state);
+ if (state) {
+ __vc_cb_service_state(atoi(state));
+ }
+ } /* VCD_METHOD_SET_SERVICE_STATE */
+ else if (0 == strncmp(VCD_METHOD_RESULT, method, strlen(VCD_METHOD_RESULT))) {
+ SLOG(LOG_DEBUG, TAG_VCC, "@@@ Get Client Result");
+
+ __vc_cb_result();
+ } /* VCD_METHOD_RESULT */
+ else if (0 == strncmp(VCD_METHOD_SEND_MANAGER_PID, method, strlen(VCD_METHOD_SEND_MANAGER_PID))) {
+ /* signal!!! */
+ char* manager_pid = NULL;
+ bundle_get_str(msg, VC_BUNDLE_MANAGER_PID, &manager_pid);
+ if (manager_pid) {
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ manager pid is changed : %d", atoi(manager_pid));
+ __vc_cb_manager_pid(atoi(manager_pid));
+ }
+ } /* VCD_METHOD_SEND_MANAGER_PID */
+ else if (0 == strncmp(VCD_METHOD_ERROR, method, strlen(VCD_METHOD_ERROR))) {
+ /* signal!!! */
+ char* reason;
+ char* daemon_pid;
+ char* err_msg = NULL;
+
+ bundle_get_str(msg, VC_BUNDLE_REASON, &reason);
+ bundle_get_str(msg, VC_BUNDLE_DAEMON_PID, &daemon_pid);
+ bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg);
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), daemon_pid(%d), msg(%s)", atoi(reason), atoi(daemon_pid), err_msg);
+ __vc_cb_error(atoi(reason), atoi(daemon_pid), err_msg);
+ } /* VCD_METHOD_ERROR */
+ else if (0 == strncmp(VCD_METHOD_ERROR_TO_APP, method, strlen(VCD_METHOD_ERROR_TO_APP))) {
+ /* signal!!! */
+ char* pid;
+ char* reason;
+ char* err_msg = NULL;
+
+ bundle_get_str(msg, VC_BUNDLE_PID, &pid);
+ bundle_get_str(msg, VC_BUNDLE_REASON, &reason);
+ bundle_get_str(msg, VC_BUNDLE_ERR_MSG, &err_msg);
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc Get Error message : reason(%d), pid(%d), msg(%s)", atoi(reason), atoi(pid), err_msg);
+ __vc_cb_error_to_app(atoi(pid), atoi(reason), err_msg);
+ } /* VCD_METHOD_ERROR_TO_APP */
+ else if (0 == strncmp(VC_MANAGER_METHOD_UTTERANCE_STATUS, method, strlen(VC_MANAGER_METHOD_UTTERANCE_STATUS))) {
+ } /* VC_MANAGER_METHOD_UTTERANCE_STATUS */
+ else {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Invalid msg");
+ }
+}
+
+void __feedback_cb(void *user_data, int utt_id, int event, rpc_port_proxy_array_char_h pcm_data, int len)
+{
+ // corresponding to listener_event_callback (only for tts_streaming)
+ SLOG(LOG_DEBUG, TAG_VCC, "__feedback_cb is invoked utt_id(%d) event(%d)", utt_id, event);
+
+ // char* utt_id;
+ // char* event;
+
+ // bundle_get_str(msg, VC_BUNDLE_UTTID, &utt_id);
+ // bundle_get_str(msg, VC_BUNDLE_FEEDBACK_EVENT, &event);
+ // __vc_cb_tts_streaming(utt_id, event, buffer, len);
+ /* VCD_METHOD_FEEDBACK_STREAMING */
+}
+
+static int __create_notify_callback_handle(vc_tidl_info_s* info)
+{
+ if (NULL != info->notify_cb_h) {
+ rpc_port_proxy_vc_notify_cb_dispose(info->rpc_h, info->notify_cb_h);
+ info->notify_cb_h = NULL;
+ }
+
+ if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_notify_cb_create(&info->notify_cb_h)) {
+ return VC_ERROR_OUT_OF_MEMORY;
+ }
+
+ rpc_port_proxy_vc_notify_cb_set_callback(info->notify_cb_h, __notify_cb, NULL);
+ rpc_port_proxy_vc_notify_cb_set_once(info->notify_cb_h, false);
+
+ return VC_ERROR_NONE;
+}
+
+static int __create_feedback_callback_handle(vc_tidl_info_s* info)
+{
+ if (NULL != info) {
+ rpc_port_proxy_vc_feedback_cb_dispose(info->rpc_h, info->feedback_cb_h);
+ info->feedback_cb_h = NULL;
+ }
+
+ if (RPC_PORT_ERROR_NONE != rpc_port_proxy_vc_feedback_cb_create(&info->feedback_cb_h)) {
+ return VC_ERROR_OUT_OF_MEMORY;
+ }
+
+ rpc_port_proxy_vc_feedback_cb_set_callback(info->feedback_cb_h, __feedback_cb, NULL);
+ rpc_port_proxy_vc_feedback_cb_set_once(info->feedback_cb_h, false);
+
+ return VC_ERROR_NONE;
+}
+
+static int __invoke_register_notify_callback(int pid, vc_tidl_info_s* info)
+{
+ if (info->register_notify_callback_invoked) {
+ SLOG(LOG_ERROR, TAG_VCC, "[INFO] Already register callback is invoked");
+ return VC_ERROR_NONE;
+ }
+
+ int ret = __create_notify_callback_handle(info);
+ if (VC_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create callback handle. ret(%d)", ret);
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
+ rpc_port_proxy_vc_invoke_register_notify_cb(info->rpc_h, pid, info->notify_cb_h);
+ info->register_notify_callback_invoked = true;
+ return VC_ERROR_NONE;
+}
+
+static int __invoke_register_feedback_callback(int pid, vc_tidl_info_s* info)
+{
+ if (info->register_feedback_callback_invoked) {
+ SLOG(LOG_ERROR, TAG_VCC, "[INFO] Already register callback is invoked");
+ return VC_ERROR_NONE;
+ }
+
+ int ret = __create_feedback_callback_handle(info);
+ if (VC_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to create callback handle. ret(%d)", ret);
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
+ rpc_port_proxy_vc_invoke_register_feedback_cb(info->rpc_h, pid, info->feedback_cb_h);
+ info->register_feedback_callback_invoked = true;
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_open_connection()
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_open_connection");
+
+ vc_tidl_info_s* info = (vc_tidl_info_s*)calloc(1, sizeof(vc_tidl_info_s));
+ if (NULL == info) {
+ SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create tidl_info_s");
+ return VC_ERROR_OUT_OF_MEMORY;
+ }
+
+ int pid = getpid();
+ char* engine_appid = __get_engine_appid();
+
+ info->rpc_h = __create_rpc_port(pid, engine_appid);
+ if (NULL == info->rpc_h) {
+ SLOG(LOG_ERROR, TAG_VCC, "[TIDL ERROR] Fail to create proxy");
+ free(info);
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
+ info->pid = pid;
+ g_tidl_infos = g_list_append(g_tidl_infos, info);
+
+ SLOG(LOG_ERROR, TAG_VCC, "[TIDL] pid(%d) rpc_h(%p), engine_appid(%s)", pid, info->rpc_h, info->engine_appid);
+ return VC_ERROR_NONE;
+
+}
+
+int vc_tidl_close_connection()
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_close_connection");
+
+ int pid = getpid();
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+
+ if (0 != rpc_port_proxy_vc_destroy(info->rpc_h)) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to disconnect");
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
+ info->rpc_h = NULL;
+ info->notify_cb_h = NULL;
+
+ g_tidl_infos = g_list_remove(g_tidl_infos, info);
+ free(info);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_hello()
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_hello");
+
+ int pid = getpid();
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+
+ if (!info->connected) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()");
+ __request_tidl_connect(info);
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, ">>>>> VCC Hello");
+ if (VC_ERROR_NONE != __invoke_register_notify_callback(pid, info)) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register callback");
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "<<<<");
+ return VC_ERROR_NONE;
+
+}
+
+static int __covert_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;
+}
+
+int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_initialize");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_initialize(info->rpc_h, pid, mgr_pid, service_state, daemon_pid);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc initialize : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc initialize : mgr = %d service = %d daemon_pid = %d", *mgr_pid, *service_state, *daemon_pid); //LCOV_EXCL_LINE
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_finalize(int pid)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_finalize");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_finalize(info->rpc_h, pid);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc finalize : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : result = %d", ret);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_set_command(int pid, vc_cmd_type_e cmd_type)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_command");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_set_command(info->rpc_h, pid, cmd_type);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set command : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set command : pid(%d), cmd_type(%d)", pid, cmd_type);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_unset_command(int pid, vc_cmd_type_e cmd_type)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_unset_command");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_unset_command(info->rpc_h, pid, cmd_type);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc unset command : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc unset command : pid(%d), cmd_type(%d)", pid, cmd_type);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_set_foreground(int pid, bool value)
+{
+ // method no reply --> async
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_foreground");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_set_foreground(info->rpc_h, pid, value);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set foreground : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set foreground : pid(%d), value(%d)", pid, value);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* credential)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_set_server_dialog");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_set_server_dialog(info->rpc_h, pid, app_id, credential);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc set server dialog : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc set server dialog : pid(%d), app_id(%s), credential(%s)", pid, app_id, credential);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous)
+{
+ // method no reply --> async
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_request_dialog");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_request_dialog(info->rpc_h, pid, disp_text, utt_text, continuous);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request dialog : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_is_system_command_valid");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_is_system_command_valid(info->rpc_h, pid, is_sys_cmd_valid);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc is system command valid : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc is system command valid : pid(%d), is_sys_cmd_valid(%d)", pid, *is_sys_cmd_valid);
+
+ return VC_ERROR_NONE;
+}
+
+/* Authority */
+int vc_tidl_request_auth_enable(int pid, int mgr_pid)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_enable");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_auth_enable(info->rpc_h, pid, mgr_pid);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth enable : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth enable : pid(%d), mgr_pid(%d)", pid, mgr_pid);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_auth_disable(int pid, int mgr_pid)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_disable");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_auth_disable(info->rpc_h, pid, mgr_pid);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth disable : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth disable : pid(%d), mgr_pid(%d)", pid, mgr_pid);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_auth_start(int pid, int mgr_pid)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_start");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_auth_start(info->rpc_h, pid, mgr_pid);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth start : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth start : pid(%d), mgr_pid(%d)", pid, mgr_pid);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_auth_stop(int pid, int mgr_pid)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_stop");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_auth_stop(info->rpc_h, pid, mgr_pid);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth stop : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth stop : pid(%d), mgr_pid(%d)", pid, mgr_pid);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_auth_cancel(int pid, int mgr_pid)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_auth_cancel");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_auth_cancel(info->rpc_h, pid, mgr_pid);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc auth cancel : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc auth cancel : pid(%d), mgr_pid(%d)", pid, mgr_pid);
+
+ return VC_ERROR_NONE;
+}
+
+/* tts feedback */
+int vc_tidl_request_request_tts(int pid, const char* text, const char* language, bool to_vcm, int* utt_id)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_request_tts");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ if (VC_ERROR_NONE != __invoke_register_feedback_callback(pid, info)) {
+ SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register feedback callback");
+ return VC_ERROR_OPERATION_FAILED;
+ }
+
+ int ret = rpc_port_proxy_vc_invoke_request_tts(info->rpc_h, pid, text, language, to_vcm, utt_id);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc request tts : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc request tts : pid(%d)", pid);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_cancel_tts(int pid, int utt_id)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_cancel_tts");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_cancel_tts(info->rpc_h, pid, utt_id);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc cancel tts : Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc cancel tts : pid(%d), utt_id(%d)", pid, utt_id);
+
+ return VC_ERROR_NONE;
+}
+
+int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type)
+{
+ SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_get_tts_audio_format");
+
+ vc_tidl_info_s* info = __get_tidl_info_s(pid);
+ RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, "[ERROR] Fail to get tidl info");
+ RETVM_IF(false == info->connected, VC_ERROR_OPERATION_FAILED, "[ERROR] Not Connected");
+
+ int ret = rpc_port_proxy_vc_invoke_get_tts_audio_format(info->rpc_h, pid, rate, (int*)channel, (int*)audio_type);
+ if (RPC_PORT_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc get tts audio format: Fail to invoke message");
+ return __covert_unhandled_error(ret);
+ }
+
+ SLOG(LOG_DEBUG, TAG_VCC, "@@ vc get tts audio format : pid(%d), rate(%d), channel(%d), audio_type(%d)", pid, *rate, *channel, *audio_type);
+
+ return VC_ERROR_NONE;
+}
--- /dev/null
+/*
+* Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+#ifndef __VC_TIDL_H_
+#define __VC_TIDL_H_
+
+#include "voice_control_common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int vc_tidl_open_connection();
+
+int vc_tidl_close_connection();
+
+
+int vc_tidl_request_hello();
+
+int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid);
+
+int vc_tidl_request_finalize(int pid);
+
+int vc_tidl_request_set_command(int pid, vc_cmd_type_e cmd_type);
+
+int vc_tidl_request_unset_command(int pid, vc_cmd_type_e cmd_type);
+
+int vc_tidl_request_set_foreground(int pid, bool value);
+
+int vc_tidl_request_set_server_dialog(int pid, const char* app_id, const char* credential);
+
+int vc_tidl_request_request_dialog(int pid, const char* disp_text, const char* utt_text, bool continuous);
+
+int vc_tidl_request_is_system_command_valid(int pid, bool* is_sys_cmd_valid);
+
+#if 0
+int vc_tidl_request_start(int pid, int silence);
+
+int vc_tidl_request_stop(int pid);
+
+int vc_tidl_request_cancel(int pid);
+
+int vc_tidl_request_set_exclusive_command(int pid, bool value);
+#endif
+
+/* Authority */
+int vc_tidl_request_auth_enable(int pid, int mgr_pid);
+
+int vc_tidl_request_auth_disable(int pid, int mgr_pid);
+
+int vc_tidl_request_auth_start(int pid, int mgr_pid);
+
+int vc_tidl_request_auth_stop(int pid, int mgr_pid);
+
+int vc_tidl_request_auth_cancel(int pid, int mgr_pid);
+
+/* tts feedback */
+
+int vc_tidl_request_request_tts(int pid, const char* text, const char* language, bool to_vcm, int* utt_id);
+
+int vc_tidl_request_cancel_tts(int pid, int utt_id);
+
+int vc_tidl_request_get_tts_audio_format(int pid, int* rate, vc_audio_channel_e* channel, vc_audio_type_e* audio_type);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __VC_TIDL_H_ */
#define VC_ENGINE_DB_DEFAULT "db/voice/vc/engine/default"
/******************************************************************************************
+* Message Definitions for Bundle
+*******************************************************************************************/
+#define VC_BUNDLE_METHOD "method"
+#define VC_BUNDLE_SERVICE_STATE "service_state"
+#define VC_BUNDLE_MANAGER_PID "manager_pid"
+#define VC_BUNDLE_REASON "reason"
+#define VC_BUNDLE_DAEMON_PID "daemon_pid"
+#define VC_BUNDLE_ERR_MSG "err_msg"
+#define VC_BUNDLE_PID "pid"
+#define VC_BUNDLE_UTTID "uttid"
+#define VC_BUNDLE_UTTSTATUS "uttstatus"
+#define VC_BUNDLE_FEEDBACK_EVENT "feedback_event"
+#define VC_BUNDLE_LENGTH "length"
+
+/******************************************************************************************
* Message Definition for all
*******************************************************************************************/
#define VC_CONNECTION_RETRY_COUNT 10
#define VC_INVALID_TTS_UID 0
#define VC_TIDL_RETRY_COUNT 100
+#define VC_ENGINE_APPID_LEN 256
#define VC_FEATURE_PATH "tizen.org/feature/speech.control"
#define VC_MGR_FEATURE_PATH "tizen.org/feature/speech.control_manager"
#define FREE(x) { if (NULL != x) { free(x); x = NULL; } }
#define G_FREE(x) { if (NULL != x) { g_free(x); x = NULL; } }
+#define COLOR_RED "\033[0;31m"
+#define COLOR_GREEN "\033[0;32m"
+#define COLOR_BROWN "\033[0;33m"
+#define COLOR_BLUE "\033[0;34m"
+#define COLOR_PURPLE "\033[0;35m"
+#define COLOR_CYAN "\033[0;36m"
+#define COLOR_LIGHTBLUE "\033[0;37m"
+#define COLOR_END "\033[0;m"
+
+#define PERR(fmt, args...) LOGE(COLOR_RED "* Critical * " fmt COLOR_END, ##args)
+
+#define RETM_IF(expr, fmt, arg...) \
+do { \
+ if (expr) { \
+ PERR(fmt, ##arg); \
+ return; \
+ } \
+} while (0)
+
+#define RETVM_IF(expr, val, fmt, arg...) \
+do { \
+ if (expr) { \
+ PERR(fmt, ##arg); \
+ return (val); \
+ } \
+} while (0)
+
+
#ifdef __cplusplus
}
#endif
BuildRequires: pkgconfig(pkgmgr-info)
BuildRequires: pkgconfig(pkgmgr-installer)
BuildRequires: pkgconfig(vconf)
-BuildRequires: cmake
BuildRequires: pkgconfig(gmock)
-BuildRequires: tidl
BuildRequires: pkgconfig(rpc-port)
BuildRequires: pkgconfig(bundle)
+BuildRequires: cmake
+BuildRequires: tidl
+
%if 0%{?gcov:1}
BuildRequires: lcov
BuildRequires: zip
%setup -q -n %{name}-%{version}
cp %{SOURCE1001} %{SOURCE1002} .
+tidlc -p -l C -i tidl/vc.tidl -o vc_proxy
+tidlc -s -l C -i tidl/vc.tidl -o vcd_stub
+
tidlc -p -l C -i tidl/vc_mgr.tidl -o vc_mgr_proxy
tidlc -s -l C -i tidl/vc_mgr.tidl -o vcd_mgr_stub
tidlc -s -l C -i tidl/vcd_mgr.tidl -o vc_mgr_stub
static manager_info_s g_manager;
+/* Client IPC info list */
+static GSList* g_client_ipc_info_list = NULL;
+
/* Manager IPC info */
static manager_tidl_info_s* g_mgr_tidl_info = NULL;
return 0;
}
+GSList* __get_client_ipc_info_item(const int pid)
+{
+ GSList *iter = NULL;
+ client_ipc_info_s *data = NULL;
+
+ int count = g_slist_length(g_client_ipc_info_list);
+ int i;
+
+ if (0 < count) {
+ iter = g_slist_nth(g_client_ipc_info_list, 0);
+ for (i = 0; i < count; i++) {
+ if (NULL == iter)
+ break;
+
+ data = iter->data;
+ if (NULL != data) {
+ if (pid == data->pid)
+ return iter;
+ }
+
+ iter = g_slist_next(iter);
+ }
+ }
+
+ return NULL;
+}
+
+client_ipc_info_s* __get_client_ipc_info_element(int pid)
+{
+ GSList *iter = NULL;
+ client_ipc_info_s *data = NULL;
+
+ int count = g_slist_length(g_client_ipc_info_list);
+ int i;
+
+ if (0 < count) {
+ iter = g_slist_nth(g_client_ipc_info_list, 0);
+ for (i = 0; i < count; i++) {
+ if (NULL == iter)
+ break;
+
+ data = iter->data;
+
+ if (NULL != data) {
+ if (pid == data->pid)
+ return data;
+ }
+
+ iter = g_slist_next(iter);
+ }
+ }
+
+ return NULL;
+}
+
+int vcd_client_add_ipc_info(int pid)
+{
+ /*Check pid is duplicated*/
+ client_ipc_info_s* info = NULL;
+ info = __get_client_ipc_info_element(pid);
+
+ if (NULL != info) {
+ SLOG(LOG_WARN, TAG_VCD, "[Client Data] Client ipc info pid is already registered");
+ return VCD_ERROR_NONE;
+ }
+
+ SLOG(LOG_INFO, TAG_VCD, "[Client Data] There is no ipc info of pid(%d). Create new one.", pid);
+ info = (client_ipc_info_s*)calloc(1, sizeof(client_ipc_info_s));
+ if (NULL == info) {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to allocate memory");
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
+
+ info->pid = pid;
+ info->notify_cb = NULL;
+ info->notify_cb_user_data = NULL;
+ info->feedback_cb = NULL;
+ info->feedback_cb_user_data = NULL;
+
+ g_client_ipc_info_list = g_slist_append(g_client_ipc_info_list, info);
+ if (NULL == g_client_ipc_info_list) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to add new client ipc info");
+
+ free(info);
+ info = NULL;
+
+ return -1;
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new client ipc info. pid(%d)", pid);
+ }
+
+ return VCD_ERROR_NONE;
+}
+
+int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vc_notify_cb_h callback, void* user_data)
+{
+ /*Check pid*/
+ client_ipc_info_s* info = NULL;
+ info = __get_client_ipc_info_element(pid);
+
+ if (NULL == info) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid);
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = -1;
+ ret = rpc_port_stub_vc_notify_cb_clone(callback, &(info->notify_cb));
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone notify callback. ret(%d)", ret);
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to clone notify callback. ret(%d)", ret);
+ }
+ info->notify_cb_user_data = user_data;
+
+ return VCD_ERROR_NONE;
+}
+
+int vcd_client_unset_ipc_notify_cb(int pid)
+{
+ /*Check pid*/
+ client_ipc_info_s* info = NULL;
+ info = __get_client_ipc_info_element(pid);
+
+ if (NULL == info) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid);
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = -1;
+ ret = rpc_port_stub_vc_notify_cb_destroy(info->notify_cb);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy notify callback. ret(%d)", ret);
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to destroy notify callback. ret(%d)", ret);
+ }
+ info->notify_cb = NULL;
+ info->notify_cb_user_data = NULL;
+
+ return VCD_ERROR_NONE;
+}
+
+int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vc_feedback_cb_h callback, void* user_data)
+{
+ /*Check pid*/
+ client_ipc_info_s* info = NULL;
+ info = __get_client_ipc_info_element(pid);
+
+ if (NULL == info) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid);
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = -1;
+ ret = rpc_port_stub_vc_feedback_cb_clone(callback, &(info->feedback_cb));
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to clone feedback callback. ret(%d)", ret);
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to clone feedback callback. ret(%d)", ret);
+ }
+ info->feedback_cb_user_data = user_data;
+
+ return VCD_ERROR_NONE;
+}
+
+int vcd_client_unset_ipc_feedback_cb(int pid)
+{
+ /*Check pid*/
+ client_ipc_info_s* info = NULL;
+ info = __get_client_ipc_info_element(pid);
+
+ if (NULL == info) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] There is no ipc info in the list. pid(%d)", pid);
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = -1;
+ ret = rpc_port_stub_vc_feedback_cb_destroy(info->feedback_cb);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to destroy feedback callback. ret(%d)", ret);
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[Client Data] Succeed to destroy feedback callback. ret(%d)", ret);
+ }
+ info->feedback_cb = NULL;
+ info->feedback_cb_user_data = NULL;
+
+ return VCD_ERROR_NONE;
+}
+
+int vcd_client_delete_ipc_info(int pid)
+{
+ GSList *tmp = NULL;
+ client_ipc_info_s* client_ipc_info = NULL;
+
+ /*Get handle*/
+ tmp = __get_client_ipc_info_item(pid);
+ if (NULL == tmp) {
+ SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] pid(%d) is NOT valid", pid);
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ /*Free client structure*/
+ client_ipc_info = tmp->data;
+ if (NULL != client_ipc_info) {
+ free(client_ipc_info);
+ }
+
+ /*Remove handle from list*/
+ g_client_ipc_info_list = g_slist_remove_link(g_client_ipc_info_list, tmp);
+
+ return 0;
+}
+
+client_ipc_info_s* vcd_client_get_ipc_info(int pid)
+{
+ return __get_client_ipc_info_element(pid);
+}
+
bool vcd_client_is_available(int pid)
{
vc_client_info_s* client_info = NULL;
#include <glib.h>
#include "vc_command.h"
#include "vc_info_parser.h"
+#include "vcd_stub.h"
#include "vcd_mgr_stub.h"
#include "vcd_mgr_proxy.h"
#include "vcd_widget_stub.h"
typedef struct {
int pid;
+ rpc_port_stub_vc_notify_cb_h notify_cb;
+ void* notify_cb_user_data;
+ rpc_port_stub_vc_feedback_cb_h feedback_cb;
+ void* feedback_cb_user_data;
+} client_ipc_info_s;
+typedef struct {
+ int pid;
rpc_port_stub_vc_mgr_notify_cb_h notify_cb;
void* notify_cb_user_data;
rpc_port_stub_vc_mgr_send_buffer_cb_h send_buffer_cb;
int vcd_client_delete(int pid);
+int vcd_client_add_ipc_info(int pid);
+
+int vcd_client_set_ipc_notify_cb(int pid, rpc_port_stub_vc_notify_cb_h callback, void* user_data);
+
+int vcd_client_unset_ipc_notify_cb(int pid);
+
+int vcd_client_set_ipc_feedback_cb(int pid, rpc_port_stub_vc_feedback_cb_h callback, void* user_data);
+
+int vcd_client_unset_ipc_feedback_cb(int pid);
+
+int vcd_client_delete_ipc_info(int pid);
+
+client_ipc_info_s* vcd_client_get_ipc_info(int pid);
+
bool vcd_client_is_available(int pid);
int vcd_client_get_ref_count();
return 0;
}
-int vcdc_send_hello(int pid, vcd_client_type_e type)
-{
- if (0 != __dbus_check()) {
- return VCD_ERROR_OPERATION_FAILED;
- }
-
- DBusMessage* msg = NULL;
-
- if (VCD_CLIENT_TYPE_NORMAL == type) {
- msg = __get_message(pid, VCD_METHOD_HELLO, VCD_CLIENT_TYPE_NORMAL);
- } else if (VCD_CLIENT_TYPE_WIDGET == type) {
- // msg = __get_message(pid, VCD_WIDGET_METHOD_HELLO, VCD_CLIENT_TYPE_WIDGET);
- vcdc_tidl_send_hello(pid, type);
- return VCD_ERROR_NONE;
- } else if (VCD_CLIENT_TYPE_MANAGER == type) {
- vcdc_tidl_send_hello(pid, type);
- return VCD_ERROR_NONE;
- } else {
- SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Client type is NOT valid");
- return -1;
- }
-
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to create message");
- return VCD_ERROR_OUT_OF_MEMORY;
- }
-
- dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
-
- DBusError err;
- dbus_error_init(&err);
-
- DBusMessage* result_msg;
- int result = -1;
-
- result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
- dbus_message_unref(msg);
-
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] %s", err.message);
- if (NULL != err.name) {
- if (!strcmp(err.name, DBUS_ERROR_SERVICE_UNKNOWN)) {
- SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Unknown service. Client is not available");
- dbus_error_free(&err);
- return 0;
- }
- }
- dbus_error_free(&err);
- }
-
- if (NULL != result_msg) {
- dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
-
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_VCD, "[Dbus] Get arguments error (%s)", err.message);
- dbus_error_free(&err);
- result = VCD_ERROR_OPERATION_FAILED;
- }
-
- dbus_message_unref(result_msg);
- } else {
- SLOG(LOG_WARN, TAG_VCD, "[Dbus] Result message is NULL. Client is not available");
- }
-
- return result;
-}
+// int vcdc_send_hello(int pid, vcd_client_type_e type)
+// {
+// if (0 != __dbus_check()) {
+// return VCD_ERROR_OPERATION_FAILED;
+// }
+
+// DBusMessage* msg = NULL;
+
+// if (VCD_CLIENT_TYPE_NORMAL == type) {
+// msg = __get_message(pid, VCD_METHOD_HELLO, VCD_CLIENT_TYPE_NORMAL);
+// } else if (VCD_CLIENT_TYPE_WIDGET == type) {
+// msg = __get_message(pid, VCD_WIDGET_METHOD_HELLO, VCD_CLIENT_TYPE_WIDGET);
+// } else if (VCD_CLIENT_TYPE_MANAGER == type) {
+// msg = __get_message(pid, VCD_MANAGER_METHOD_HELLO, VCD_CLIENT_TYPE_MANAGER);
+// } else {
+// SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Client type is NOT valid");
+// return -1;
+// }
+
+// if (NULL == msg) {
+// SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Fail to create message");
+// return VCD_ERROR_OUT_OF_MEMORY;
+// }
+
+// dbus_message_append_args(msg, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
+
+// DBusError err;
+// dbus_error_init(&err);
+
+// DBusMessage* result_msg;
+// int result = -1;
+
+// result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_time, &err);
+// dbus_message_unref(msg);
+
+// if (dbus_error_is_set(&err)) {
+// SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] %s", err.message);
+// if (NULL != err.name) {
+// if (!strcmp(err.name, DBUS_ERROR_SERVICE_UNKNOWN)) {
+// SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Unknown service. Client is not available");
+// dbus_error_free(&err);
+// return 0;
+// }
+// }
+// dbus_error_free(&err);
+// }
+
+// if (NULL != result_msg) {
+// dbus_message_get_args(result_msg, &err, DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
+
+// if (dbus_error_is_set(&err)) {
+// SLOG(LOG_ERROR, TAG_VCD, "[Dbus] Get arguments error (%s)", err.message);
+// dbus_error_free(&err);
+// result = VCD_ERROR_OPERATION_FAILED;
+// }
+
+// dbus_message_unref(result_msg);
+// } else {
+// SLOG(LOG_WARN, TAG_VCD, "[Dbus] Result message is NULL. Client is not available");
+// }
+
+// return result;
+// }
+/*
int vcdc_send_result(int pid, int manager_pid, int cmd_type)
{
if (0 != __dbus_check()) {
case VC_COMMAND_TYPE_SYSTEM:
case VC_COMMAND_TYPE_SYSTEM_BACKGROUND:
case VC_COMMAND_TYPE_EXCLUSIVE:
- // msg = __get_message(pid, VCD_MANAGER_METHOD_RESULT, VCD_CLIENT_TYPE_MANAGER);
- // break;
- vcdc_tidl_send_result(pid, manager_pid, VCD_CLIENT_TYPE_MANAGER);
- return 0;
default:
SLOG(LOG_ERROR, TAG_VCD, "[Dbus ERROR] Command type is NOT valid(%d)", cmd_type);
return 0;
}
-
+*/
int vcdc_send_manager_pid(int manager_pid)
{
DBusError err;
return 0;
}
-
+/*
int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg)
{
if (NULL == err_msg) {
return VCD_ERROR_NONE;
}
+*/
+/*
+>>>>>>> Replace IPC (VCC) from dbus to tidl
int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len)
{
SLOG(LOG_INFO, TAG_VCD, "[Dbus] Send TTS feedback streaming : pid(%d), utt_id(%d), feedback event(%d), buffer(%p), length(%d)", pid, utt_id, event, buffer, len);
DBusError err;
dbus_error_init(&err);
- /* make dbus message */
+ // make dbus message
DBusMessage* msg = NULL;
msg = __get_message(pid, VCD_METHOD_FEEDBACK_STREAMING, VCD_CLIENT_TYPE_NORMAL);
if (NULL == msg) {
return ret;
}
-
+*/
static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
{
if (NULL == g_conn_listener) return ECORE_CALLBACK_RENEW;
int vcd_check_dbus_connection();
-int vcdc_send_hello(int pid, vcd_client_type_e type);
+// int vcdc_send_hello(int pid, vcd_client_type_e type);
-int vcdc_send_result(int pid, int manager_pid, int cmd_type);
+//int vcdc_send_result(int pid, int manager_pid, int cmd_type);
int vcdc_send_error_signal(int reason, char *err_msg);
-int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg);
+//int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg);
int vcdc_send_manager_pid(int manager_pid);
/* for TTS feedback */
-int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len);
+//int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len);
#ifdef __cplusplus
}
--- /dev/null
+/*
+ * Generated by tidlc 1.8.1.
+ */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+
+#include <pthread.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <libgen.h>
+#include <glib.h>
+#include <dlog.h>
+#include <rpc-port.h>
+#include <rpc-port-parcel.h>
+
+#include "vcd_stub.h"
+
+#undef LOG_TAG
+#define LOG_TAG "RPC_PORT_STUB"
+
+#undef _E
+#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _W
+#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _I
+#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#undef _D
+#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__)
+
+#ifndef TIDL_VERSION
+#define TIDL_VERSION "1.8.1"
+#endif
+
+#ifndef nullptr
+#define nullptr NULL
+#endif
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
+#endif
+
+#ifndef STRING_GET
+#define STRING_GET(x) ((x) ? x : "")
+#endif
+
+typedef int (*rpc_port_stub_method_handler)(rpc_port_h port, rpc_port_parcel_h parcel, void *data);
+
+typedef enum {
+ RPC_PORT_STUB_VC_METHOD_RESULT_,
+ RPC_PORT_STUB_VC_METHOD_CALLBACK_,
+ RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB,
+ RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB_SYNC,
+ RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB,
+ RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC,
+ RPC_PORT_STUB_VC_METHOD_INITIALIZE,
+ RPC_PORT_STUB_VC_METHOD_FINALIZE,
+ RPC_PORT_STUB_VC_METHOD_SET_COMMAND,
+ RPC_PORT_STUB_VC_METHOD_UNSET_COMMAND,
+ RPC_PORT_STUB_VC_METHOD_SET_FOREGROUND,
+ RPC_PORT_STUB_VC_METHOD_SET_SERVER_DIALOG,
+ RPC_PORT_STUB_VC_METHOD_REQUEST_DIALOG,
+ RPC_PORT_STUB_VC_METHOD_IS_SYSTEM_COMMAND_VALID,
+ RPC_PORT_STUB_VC_METHOD_AUTH_ENABLE,
+ RPC_PORT_STUB_VC_METHOD_AUTH_DISABLE,
+ RPC_PORT_STUB_VC_METHOD_AUTH_START,
+ RPC_PORT_STUB_VC_METHOD_AUTH_STOP,
+ RPC_PORT_STUB_VC_METHOD_AUTH_CANCEL,
+ RPC_PORT_STUB_VC_METHOD_REQUEST_TTS,
+ RPC_PORT_STUB_VC_METHOD_CANCEL_TTS,
+ RPC_PORT_STUB_VC_METHOD_GET_TTS_AUDIO_FORMAT,
+} rpc_port_stub_vc_method_e;
+
+typedef enum {
+ RPC_PORT_STUB_VC_DELEGATE_NOTIFY_CB = 1,
+ RPC_PORT_STUB_VC_DELEGATE_FEEDBACK_CB = 2,
+} rpc_port_stub_vc_delegate_e;
+
+typedef struct rpc_port_stub_array_char_s {
+ rpc_port_parcelable_t parcelable;
+ char *value;
+ int size;
+} rpc_port_stub_array_char_t;
+
+typedef struct rpc_port_stub_vc_notify_cb_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+} rpc_port_stub_vc_notify_cb_t;
+
+typedef struct rpc_port_stub_vc_feedback_cb_s {
+ rpc_port_parcelable_t parcelable;
+ rpc_port_h port;
+ int id;
+ int seq_id;
+ bool once;
+ bool valid;
+} rpc_port_stub_vc_feedback_cb_t;
+
+static bool __rpc_port_stub_vc_exist_callback_port(rpc_port_h callback_port);
+
+typedef struct rpc_port_stub_vc_context_s {
+ char *sender;
+ char *instance;
+ rpc_port_h port;
+ rpc_port_h callback_port;
+ void *tag;
+ rpc_port_stub_vc_callback_s callback;
+ void *user_data;
+#ifdef TIDL_THREAD_ENABLE
+ GThread *thread;
+ GQueue *queue;
+ GMutex mutex;
+ GCond cond;
+ bool done;
+#endif /* TIDL_THREAD_ENABLE */
+} rpc_port_stub_vc_context_t;
+
+typedef struct rpc_port_stub_vc_s {
+ rpc_port_stub_h stub;
+ rpc_port_stub_vc_callback_s callback;
+ void *user_data;
+ GList* contexts;
+ GList* callback_ports;
+ GRecMutex mutex;
+} rpc_port_stub_vc_t;
+
+static rpc_port_stub_vc_t __vc;
+
+static void __rpc_port_stub_array_char_to(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_array_char_h h = data;
+ int i;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_array_count(parcel, h->size);
+
+ for (i = 0; i < h->size; ++i)
+ rpc_port_parcel_write_byte(parcel, h->value[i]);
+}
+
+static void __rpc_port_stub_array_char_from(rpc_port_parcel_h parcel, void *data)
+{
+ rpc_port_stub_array_char_h h = data;
+ char value;
+ int ret;
+ int i;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ ret = rpc_port_parcel_read_array_count(parcel, &h->size);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read array count. error(%d)", ret);
+ set_last_result(ret);
+ return;
+ }
+
+ h->value = calloc(h->size, sizeof(char));
+ if (h->value == nullptr) {
+ _E("Out of memory");
+ set_last_result(RPC_PORT_ERROR_OUT_OF_MEMORY);
+ return;
+ }
+
+ for (i = 0; i < h->size; ++i) {
+ rpc_port_parcel_read_byte(parcel, &value);
+ h->value[i] = value;
+ }
+
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_stub_array_char_create(rpc_port_stub_array_char_h *h)
+{
+ rpc_port_stub_array_char_t *handle;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_stub_array_char_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_stub_array_char_to;
+ handle->parcelable.from = __rpc_port_stub_array_char_from;
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_array_char_destroy(rpc_port_stub_array_char_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->value)
+ free(h->value);
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_array_char_clone(rpc_port_stub_array_char_h h, rpc_port_stub_array_char_h *clone)
+{
+ rpc_port_stub_array_char_h handle;
+ rpc_port_parcel_h parcel;
+ int ret;
+
+ if (h == nullptr || clone == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_stub_array_char_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ ret = rpc_port_parcel_create(&parcel);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret);
+ rpc_port_stub_array_char_destroy(handle);
+ return ret;
+ }
+
+ rpc_port_parcel_write(parcel, &h->parcelable, h);
+ rpc_port_parcel_read(parcel, &handle->parcelable, handle);
+ ret = get_last_result();
+ rpc_port_parcel_destroy(parcel);
+
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read data. error(%d)", ret);
+ rpc_port_stub_array_char_destroy(handle);
+ return ret;
+ }
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_array_char_set(rpc_port_stub_array_char_h h, char *value, int size)
+{
+ rpc_port_stub_array_char_h handle;
+ rpc_port_stub_array_char_h clone;
+ int ret;
+
+ if (h == nullptr || value == nullptr || size <= 0) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_stub_array_char_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ handle->value = (char *)value;
+ handle->size = size;
+
+ ret = rpc_port_stub_array_char_clone(handle, &clone);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to clone handle. error(%d)", ret);
+ handle->value = nullptr;
+ handle->size = 0;
+ rpc_port_stub_array_char_destroy(handle);
+ return ret;
+ }
+
+ handle->value = h->value;
+ handle->size = h->size;
+ rpc_port_stub_array_char_destroy(handle);
+
+ h->value = clone->value;
+ h->size = clone->size;
+
+ clone->value = nullptr;
+ clone->size = 0;
+ rpc_port_stub_array_char_destroy(clone);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_array_char_get(rpc_port_stub_array_char_h h, char **value, int *size)
+{
+ rpc_port_stub_array_char_h handle;
+ int ret;
+
+ if (h == nullptr || value == nullptr || size == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_stub_array_char_clone(h, &handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to clone handle. error(%d)", ret);
+ return ret;
+ }
+
+ *value = handle->value;
+ *size = handle->size;
+
+ handle->value = nullptr;
+ handle->size = 0;
+ rpc_port_stub_array_char_destroy(handle);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+static void __rpc_port_stub_vc_notify_cb_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_notify_cb_h h = user_data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->id);
+
+ rpc_port_parcel_write_int32(parcel, h->seq_id);
+
+ rpc_port_parcel_write_bool(parcel, h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+}
+
+static void __rpc_port_stub_vc_notify_cb_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_notify_cb_h h = user_data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->id);
+
+ rpc_port_parcel_read_int32(parcel, &h->seq_id);
+
+ rpc_port_parcel_read_bool(parcel, &h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_stub_vc_notify_cb_create(rpc_port_stub_vc_notify_cb_h *h)
+{
+ rpc_port_stub_vc_notify_cb_t *handle;
+ static int seq_num;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_stub_vc_notify_cb_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_stub_vc_notify_cb_to;
+ handle->parcelable.from = __rpc_port_stub_vc_notify_cb_from;
+ handle->id = RPC_PORT_STUB_VC_DELEGATE_NOTIFY_CB;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ handle->once = false;
+ handle->valid = true;
+ _I("id(%d), seq_id(%d)", handle->id, handle->seq_id);
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_notify_cb_destroy(rpc_port_stub_vc_notify_cb_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_notify_cb_clone(rpc_port_stub_vc_notify_cb_h h, rpc_port_stub_vc_notify_cb_h *clone)
+{
+ rpc_port_stub_vc_notify_cb_h handle;
+ int ret;
+
+ if (h == nullptr || clone == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_stub_vc_notify_cb_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ handle->port = h->port;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->valid = h->valid;
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_notify_cb_get_id(rpc_port_stub_vc_notify_cb_h h, int *id)
+{
+ if (h == nullptr || id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *id = h->id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_notify_cb_get_seq_id(rpc_port_stub_vc_notify_cb_h h, int *seq_id)
+{
+ if (h == nullptr || seq_id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *seq_id = h->seq_id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_notify_cb_is_once(rpc_port_stub_vc_notify_cb_h h, bool *once)
+{
+ if (h == nullptr || once == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *once = h->once;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_notify_cb_get_tag(rpc_port_stub_vc_notify_cb_h h, char **tag)
+{
+ char *value;
+ char buf[128];
+
+ if (h == nullptr || tag == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id);
+ value = strdup(buf);
+ if (value == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *tag = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_notify_cb_set_port(rpc_port_stub_vc_notify_cb_h h, rpc_port_h port)
+{
+ if (h == nullptr || port == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ h->port = port;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_notify_cb_invoke(rpc_port_stub_vc_notify_cb_h h, int pid, bundle *msg)
+{
+ rpc_port_parcel_h parcel_;
+ int ret_;
+
+ if (h == nullptr || h->port == nullptr || msg == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!__rpc_port_stub_vc_exist_callback_port(h->port)) {
+ _E("Not connected");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->once && !h->valid) {
+ _E("The delegate handle is already used");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ return ret_;
+ }
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_CALLBACK_);
+
+ rpc_port_parcel_write(parcel_, &h->parcelable, h);
+
+ rpc_port_parcel_write_int32(parcel_, pid);
+
+ rpc_port_parcel_write_bundle(parcel_, msg);
+
+ ret_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ h->valid = false;
+
+ return ret_;
+}
+
+static void __rpc_port_stub_vc_feedback_cb_to(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_feedback_cb_h h = user_data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ return;
+ }
+
+ rpc_port_parcel_write_int32(parcel, h->id);
+
+ rpc_port_parcel_write_int32(parcel, h->seq_id);
+
+ rpc_port_parcel_write_bool(parcel, h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+}
+
+static void __rpc_port_stub_vc_feedback_cb_from(rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_feedback_cb_h h = user_data;
+
+ if (parcel == nullptr || h == nullptr) {
+ _E("Invalid parameter");
+ set_last_result(RPC_PORT_ERROR_INVALID_PARAMETER);
+ return;
+ }
+
+ rpc_port_parcel_read_int32(parcel, &h->id);
+
+ rpc_port_parcel_read_int32(parcel, &h->seq_id);
+
+ rpc_port_parcel_read_bool(parcel, &h->once);
+
+ _I("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+ set_last_result(RPC_PORT_ERROR_NONE);
+}
+
+int rpc_port_stub_vc_feedback_cb_create(rpc_port_stub_vc_feedback_cb_h *h)
+{
+ rpc_port_stub_vc_feedback_cb_t *handle;
+ static int seq_num;
+
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_stub_vc_feedback_cb_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ handle->parcelable.to = __rpc_port_stub_vc_feedback_cb_to;
+ handle->parcelable.from = __rpc_port_stub_vc_feedback_cb_from;
+ handle->id = RPC_PORT_STUB_VC_DELEGATE_FEEDBACK_CB;
+ handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1;
+ handle->once = false;
+ handle->valid = true;
+ _I("id(%d), seq_id(%d)", handle->id, handle->seq_id);
+
+ *h = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_feedback_cb_destroy(rpc_port_stub_vc_feedback_cb_h h)
+{
+ if (h == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ _W("id(%d), seq_id(%d), once(%s)", h->id, h->seq_id, h->once ? "true" : "false");
+
+ free(h);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_feedback_cb_clone(rpc_port_stub_vc_feedback_cb_h h, rpc_port_stub_vc_feedback_cb_h *clone)
+{
+ rpc_port_stub_vc_feedback_cb_h handle;
+ int ret;
+
+ if (h == nullptr || clone == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = rpc_port_stub_vc_feedback_cb_create(&handle);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret);
+ return ret;
+ }
+
+ handle->port = h->port;
+ handle->seq_id = h->seq_id;
+ handle->once = h->once;
+ handle->valid = h->valid;
+
+ *clone = handle;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_feedback_cb_get_id(rpc_port_stub_vc_feedback_cb_h h, int *id)
+{
+ if (h == nullptr || id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *id = h->id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_feedback_cb_get_seq_id(rpc_port_stub_vc_feedback_cb_h h, int *seq_id)
+{
+ if (h == nullptr || seq_id == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *seq_id = h->seq_id;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_feedback_cb_is_once(rpc_port_stub_vc_feedback_cb_h h, bool *once)
+{
+ if (h == nullptr || once == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *once = h->once;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_feedback_cb_get_tag(rpc_port_stub_vc_feedback_cb_h h, char **tag)
+{
+ char *value;
+ char buf[128];
+
+ if (h == nullptr || tag == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ snprintf(buf, sizeof(buf), "%d::%d", h->id, h->seq_id);
+ value = strdup(buf);
+ if (value == nullptr) {
+ _E("Out of memory");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *tag = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_feedback_cb_set_port(rpc_port_stub_vc_feedback_cb_h h, rpc_port_h port)
+{
+ if (h == nullptr || port == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ h->port = port;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_feedback_cb_invoke(rpc_port_stub_vc_feedback_cb_h h, int utt_id, int event, rpc_port_stub_array_char_h pcm_data, int len)
+{
+ rpc_port_parcel_h parcel_;
+ int ret_;
+
+ if (h == nullptr || h->port == nullptr || pcm_data == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (!__rpc_port_stub_vc_exist_callback_port(h->port)) {
+ _E("Not connected");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (h->once && !h->valid) {
+ _E("The delegate handle is already used");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ return ret_;
+ }
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_CALLBACK_);
+
+ rpc_port_parcel_write(parcel_, &h->parcelable, h);
+
+ rpc_port_parcel_write_int32(parcel_, utt_id);
+
+ rpc_port_parcel_write_int32(parcel_, event);
+
+ rpc_port_parcel_write(parcel_, &pcm_data->parcelable, pcm_data);
+
+ rpc_port_parcel_write_int32(parcel_, len);
+
+ ret_ = rpc_port_parcel_send(parcel_, h->port);
+ rpc_port_parcel_destroy(parcel_);
+ h->valid = false;
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_register_notify_cb_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ rpc_port_stub_vc_notify_cb_h callback = nullptr;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ ret_ = rpc_port_stub_vc_notify_cb_create(&callback);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_stub_vc_notify_cb_set_port(callback, callback_port_);
+ rpc_port_parcel_read(parcel, &callback->parcelable, callback);
+ ret_ = get_last_result();
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read data. error(%d)", ret_);
+ goto out;
+ }
+
+ if (context_->callback.register_notify_cb)
+ context_->callback.register_notify_cb(context_, pid, callback, context_->user_data);
+
+out:
+ if (callback)
+ rpc_port_stub_vc_notify_cb_destroy(callback);
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_register_notify_cb_sync_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ rpc_port_stub_vc_notify_cb_h callback = nullptr;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ ret_ = rpc_port_stub_vc_notify_cb_create(&callback);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_stub_vc_notify_cb_set_port(callback, callback_port_);
+ rpc_port_parcel_read(parcel, &callback->parcelable, callback);
+ ret_ = get_last_result();
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read data. error(%d)", ret_);
+ goto out;
+ }
+
+ if (context_->callback.register_notify_cb_sync)
+ res_ = context_->callback.register_notify_cb_sync(context_, pid, callback, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+ if (callback)
+ rpc_port_stub_vc_notify_cb_destroy(callback);
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_register_feedback_cb_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ rpc_port_stub_vc_feedback_cb_h callback = nullptr;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ ret_ = rpc_port_stub_vc_feedback_cb_create(&callback);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_stub_vc_feedback_cb_set_port(callback, callback_port_);
+ rpc_port_parcel_read(parcel, &callback->parcelable, callback);
+ ret_ = get_last_result();
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read data. error(%d)", ret_);
+ goto out;
+ }
+
+ if (context_->callback.register_feedback_cb)
+ context_->callback.register_feedback_cb(context_, pid, callback, context_->user_data);
+
+out:
+ if (callback)
+ rpc_port_stub_vc_feedback_cb_destroy(callback);
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_register_feedback_cb_sync_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ rpc_port_stub_vc_feedback_cb_h callback = nullptr;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ ret_ = rpc_port_stub_vc_feedback_cb_create(&callback);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_stub_vc_feedback_cb_set_port(callback, callback_port_);
+ rpc_port_parcel_read(parcel, &callback->parcelable, callback);
+ ret_ = get_last_result();
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to read data. error(%d)", ret_);
+ goto out;
+ }
+
+ if (context_->callback.register_feedback_cb_sync)
+ res_ = context_->callback.register_feedback_cb_sync(context_, pid, callback, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+ if (callback)
+ rpc_port_stub_vc_feedback_cb_destroy(callback);
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_initialize_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ int mgr_pid = -1;
+ int service_state = -1;
+ int daemon_pid = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ if (context_->callback.initialize)
+ res_ = context_->callback.initialize(context_, pid, &mgr_pid, &service_state, &daemon_pid, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, mgr_pid);
+
+ rpc_port_parcel_write_int32(parcel_, service_state);
+
+ rpc_port_parcel_write_int32(parcel_, daemon_pid);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_finalize_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ if (context_->callback.finalize)
+ res_ = context_->callback.finalize(context_, pid, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_set_command_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ int cmd_type = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_int32(parcel, &cmd_type);
+
+ if (context_->callback.set_command)
+ res_ = context_->callback.set_command(context_, pid, cmd_type, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_unset_command_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ int cmd_type = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_int32(parcel, &cmd_type);
+
+ if (context_->callback.unset_command)
+ res_ = context_->callback.unset_command(context_, pid, cmd_type, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_set_foreground_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ bool value = false;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_bool(parcel, &value);
+
+ if (context_->callback.set_foreground)
+ res_ = context_->callback.set_foreground(context_, pid, value, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_set_server_dialog_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ char *app_id = nullptr;
+ char *credential = nullptr;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_string(parcel, &app_id);
+ if (app_id == nullptr) {
+ _E("Failed to read data");
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ rpc_port_parcel_read_string(parcel, &credential);
+ if (credential == nullptr) {
+ _E("Failed to read data");
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ if (context_->callback.set_server_dialog)
+ res_ = context_->callback.set_server_dialog(context_, pid, app_id, credential, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+ if (app_id)
+ free(app_id);
+
+ if (credential)
+ free(credential);
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_request_dialog_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ char *disp_text = nullptr;
+ char *utt_text = nullptr;
+ bool continuous = false;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_string(parcel, &disp_text);
+ if (disp_text == nullptr) {
+ _E("Failed to read data");
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ rpc_port_parcel_read_string(parcel, &utt_text);
+ if (utt_text == nullptr) {
+ _E("Failed to read data");
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ rpc_port_parcel_read_bool(parcel, &continuous);
+
+ if (context_->callback.request_dialog)
+ res_ = context_->callback.request_dialog(context_, pid, disp_text, utt_text, continuous, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+ if (disp_text)
+ free(disp_text);
+
+ if (utt_text)
+ free(utt_text);
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_is_system_command_valid_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ bool is_sys_cmd_valid = false;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ if (context_->callback.is_system_command_valid)
+ res_ = context_->callback.is_system_command_valid(context_, pid, &is_sys_cmd_valid, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_bool(parcel_, is_sys_cmd_valid);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_auth_enable_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ int mgr_pid = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_int32(parcel, &mgr_pid);
+
+ if (context_->callback.auth_enable)
+ res_ = context_->callback.auth_enable(context_, pid, mgr_pid, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_auth_disable_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ int mgr_pid = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_int32(parcel, &mgr_pid);
+
+ if (context_->callback.auth_disable)
+ res_ = context_->callback.auth_disable(context_, pid, mgr_pid, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_auth_start_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ int mgr_pid = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_int32(parcel, &mgr_pid);
+
+ if (context_->callback.auth_start)
+ res_ = context_->callback.auth_start(context_, pid, mgr_pid, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_auth_stop_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ int mgr_pid = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_int32(parcel, &mgr_pid);
+
+ if (context_->callback.auth_stop)
+ res_ = context_->callback.auth_stop(context_, pid, mgr_pid, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_auth_cancel_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ int mgr_pid = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_int32(parcel, &mgr_pid);
+
+ if (context_->callback.auth_cancel)
+ res_ = context_->callback.auth_cancel(context_, pid, mgr_pid, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_request_tts_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ char *text = nullptr;
+ char *lang = nullptr;
+ bool to_vcm = false;
+ int utt_id = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_string(parcel, &text);
+ if (text == nullptr) {
+ _E("Failed to read data");
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ rpc_port_parcel_read_string(parcel, &lang);
+ if (lang == nullptr) {
+ _E("Failed to read data");
+ ret_ = RPC_PORT_ERROR_OUT_OF_MEMORY;
+ goto out;
+ }
+
+ rpc_port_parcel_read_bool(parcel, &to_vcm);
+
+ if (context_->callback.request_tts)
+ res_ = context_->callback.request_tts(context_, pid, text, lang, to_vcm, &utt_id, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, utt_id);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+ if (text)
+ free(text);
+
+ if (lang)
+ free(lang);
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_cancel_tts_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ int utt_id = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ rpc_port_parcel_read_int32(parcel, &utt_id);
+
+ if (context_->callback.cancel_tts)
+ res_ = context_->callback.cancel_tts(context_, pid, utt_id, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static int __rpc_port_stub_vc_method_get_tts_audio_format_handler(rpc_port_h port, rpc_port_parcel_h parcel, void *user_data)
+{
+ rpc_port_stub_vc_context_h context_ = user_data;
+ rpc_port_parcel_header_h header_;
+ int seq_num_ = -1;
+ rpc_port_h callback_port_;
+ int ret_;
+ int pid = -1;
+ int rate = -1;
+ int channel = -1;
+ int audio_type = -1;
+ rpc_port_parcel_h parcel_;
+ int res_ = -1;
+
+ ret_ = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, context_->instance, &callback_port_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel, &header_);
+ rpc_port_parcel_header_get_seq_num(header_, &seq_num_);
+ _W("[Sequence] %d", seq_num_);
+
+ rpc_port_parcel_read_int32(parcel, &pid);
+
+ if (context_->callback.get_tts_audio_format)
+ res_ = context_->callback.get_tts_audio_format(context_, pid, &rate, &channel, &audio_type, context_->user_data);
+
+ ret_ = rpc_port_parcel_create(&parcel_);
+ if (ret_ != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle. error(%d)", ret_);
+ goto out;
+ }
+
+ rpc_port_parcel_get_header(parcel_, &header_);
+ rpc_port_parcel_header_set_tag(header_, TIDL_VERSION);
+ rpc_port_parcel_header_set_seq_num(header_, seq_num_);
+
+ rpc_port_parcel_write_int32(parcel_, RPC_PORT_STUB_VC_METHOD_RESULT_);
+
+ rpc_port_parcel_write_int32(parcel_, rate);
+
+ rpc_port_parcel_write_int32(parcel_, channel);
+
+ rpc_port_parcel_write_int32(parcel_, audio_type);
+
+ rpc_port_parcel_write_int32(parcel_, res_);
+
+ ret_ = rpc_port_parcel_send(parcel_, port);
+ rpc_port_parcel_destroy(parcel_);
+
+out:
+
+ return ret_;
+}
+
+static rpc_port_stub_method_handler __vc_method_table[] = {
+ [RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB] = __rpc_port_stub_vc_method_register_notify_cb_handler,
+ [RPC_PORT_STUB_VC_METHOD_REGISTER_NOTIFY_CB_SYNC] = __rpc_port_stub_vc_method_register_notify_cb_sync_handler,
+ [RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB] = __rpc_port_stub_vc_method_register_feedback_cb_handler,
+ [RPC_PORT_STUB_VC_METHOD_REGISTER_FEEDBACK_CB_SYNC] = __rpc_port_stub_vc_method_register_feedback_cb_sync_handler,
+ [RPC_PORT_STUB_VC_METHOD_INITIALIZE] = __rpc_port_stub_vc_method_initialize_handler,
+ [RPC_PORT_STUB_VC_METHOD_FINALIZE] = __rpc_port_stub_vc_method_finalize_handler,
+ [RPC_PORT_STUB_VC_METHOD_SET_COMMAND] = __rpc_port_stub_vc_method_set_command_handler,
+ [RPC_PORT_STUB_VC_METHOD_UNSET_COMMAND] = __rpc_port_stub_vc_method_unset_command_handler,
+ [RPC_PORT_STUB_VC_METHOD_SET_FOREGROUND] = __rpc_port_stub_vc_method_set_foreground_handler,
+ [RPC_PORT_STUB_VC_METHOD_SET_SERVER_DIALOG] = __rpc_port_stub_vc_method_set_server_dialog_handler,
+ [RPC_PORT_STUB_VC_METHOD_REQUEST_DIALOG] = __rpc_port_stub_vc_method_request_dialog_handler,
+ [RPC_PORT_STUB_VC_METHOD_IS_SYSTEM_COMMAND_VALID] = __rpc_port_stub_vc_method_is_system_command_valid_handler,
+ [RPC_PORT_STUB_VC_METHOD_AUTH_ENABLE] = __rpc_port_stub_vc_method_auth_enable_handler,
+ [RPC_PORT_STUB_VC_METHOD_AUTH_DISABLE] = __rpc_port_stub_vc_method_auth_disable_handler,
+ [RPC_PORT_STUB_VC_METHOD_AUTH_START] = __rpc_port_stub_vc_method_auth_start_handler,
+ [RPC_PORT_STUB_VC_METHOD_AUTH_STOP] = __rpc_port_stub_vc_method_auth_stop_handler,
+ [RPC_PORT_STUB_VC_METHOD_AUTH_CANCEL] = __rpc_port_stub_vc_method_auth_cancel_handler,
+ [RPC_PORT_STUB_VC_METHOD_REQUEST_TTS] = __rpc_port_stub_vc_method_request_tts_handler,
+ [RPC_PORT_STUB_VC_METHOD_CANCEL_TTS] = __rpc_port_stub_vc_method_cancel_tts_handler,
+ [RPC_PORT_STUB_VC_METHOD_GET_TTS_AUDIO_FORMAT] = __rpc_port_stub_vc_method_get_tts_audio_format_handler,
+};
+
+static int __rpc_port_stub_vc_context_handle_request(rpc_port_stub_vc_context_h h, rpc_port_parcel_h parcel)
+{
+ int ret = RPC_PORT_ERROR_NONE;
+ int cmd = -1;
+
+ rpc_port_parcel_read_int32(parcel, &cmd);
+ if (cmd > 1 && cmd < ARRAY_SIZE(__vc_method_table)) {
+ if (__vc_method_table[cmd])
+ ret = __vc_method_table[cmd](h->port, parcel, h);
+ } else {
+ _W("Invalid protocol. cmd(%d)", cmd);
+ ret = RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ return ret;
+}
+
+#ifdef TIDL_THREAD_ENABLE
+static int __rpc_port_stub_vc_context_push(rpc_port_stub_vc_context_h h, rpc_port_parcel_h parcel)
+{
+ g_mutex_lock(&h->mutex);
+ g_queue_push_tail(h->queue, parcel);
+ g_cond_signal(&h->cond);
+ g_mutex_unlock(&h->mutex);
+
+ return 0;
+}
+
+static rpc_port_parcel_h __rpc_port_stub_vc_context_wait_and_pop(rpc_port_stub_vc_context_h h)
+{
+ rpc_port_parcel_h parcel;
+
+ g_mutex_lock(&h->mutex);
+ while (g_queue_is_empty(h->queue) && !h->done)
+ g_cond_wait(&h->cond, &h->mutex);
+
+ parcel = g_queue_pop_head(h->queue);
+ g_mutex_unlock(&h->mutex);
+
+ return parcel;
+}
+
+static gpointer __rpc_port_stub_vc_context_thread_cb(gpointer user_data)
+{
+ rpc_port_stub_vc_context_h h = user_data;
+ rpc_port_parcel_h parcel;
+
+ _W("START");
+ while (!h->done) {
+ parcel = __rpc_port_stub_vc_context_wait_and_pop(h);
+ if (parcel) {
+ __rpc_port_stub_vc_context_handle_request(h, parcel);
+ rpc_port_parcel_destroy(parcel);
+ }
+ }
+ _W("END");
+
+ return nullptr;
+}
+#endif /* TIDL_THREAD_ENABLE */
+
+static void __rpc_port_stub_vc_context_destroy(gpointer data)
+{
+ rpc_port_stub_vc_context_h h = data;
+#ifdef TIDL_THREAD_ENABLE
+ rpc_port_parcel_h parcel;
+#endif /* TIDL_THREAD_ENABLE */
+
+ if (h == nullptr)
+ return;
+
+#ifdef TIDL_THREAD_ENABLE
+ g_mutex_lock(&h->mutex);
+ h->done = true;
+ g_cond_signal(&h->cond);
+ g_mutex_unlock(&h->mutex);
+
+ if (h->thread) {
+ g_thread_join(h->thread);
+ g_thread_unref(h->thread);
+ }
+
+ g_mutex_clear(&h->mutex);
+ g_cond_clear(&h->cond);
+
+ if (h->queue) {
+ while (!g_queue_is_empty(h->queue)) {
+ parcel = g_queue_pop_head(h->queue);
+ rpc_port_parcel_destroy(parcel);
+ }
+
+ g_queue_free(h->queue);
+ }
+#endif /* TIDL_THREAD_ENABLE */
+
+ if (h->instance)
+ free(h->instance);
+
+ if (h->sender)
+ free(h->sender);
+
+ free(h);
+}
+
+static rpc_port_stub_vc_context_h __rpc_port_stub_vc_context_create(const char *sender, const char *instance, rpc_port_h callback_port)
+{
+ rpc_port_stub_vc_context_t *handle;
+
+ if (sender == nullptr || instance == nullptr || callback_port == nullptr) {
+ _E("Invalid parameter");
+ return nullptr;
+ }
+
+ handle = calloc(1, sizeof(rpc_port_stub_vc_context_t));
+ if (handle == nullptr) {
+ _E("Out of memory");
+ return nullptr;
+ }
+
+ handle->sender = strdup(sender);
+ if (handle->sender == nullptr) {
+ _E("Failed to duplicate sender");
+ __rpc_port_stub_vc_context_destroy(handle);
+ return nullptr;
+ }
+
+ handle->instance = strdup(instance);
+ if (handle->instance == nullptr) {
+ _E("Failed to duplicate instance");
+ __rpc_port_stub_vc_context_destroy(handle);
+ return nullptr;
+ }
+
+#ifdef TIDL_THREAD_ENABLE
+ g_mutex_init(&handle->mutex);
+ g_cond_init(&handle->cond);
+
+ handle->queue = g_queue_new();
+ if (handle->queue == nullptr) {
+ _E("Failed to create queue");
+ __rpc_port_stub_vc_context_destroy(handle);
+ return nullptr;
+ }
+
+ handle->thread = g_thread_new(instance, __rpc_port_stub_vc_context_thread_cb, handle);
+ if (handle->thread == nullptr) {
+ _E("Failed to create thread");
+ __rpc_port_stub_vc_context_destroy(handle);
+ return nullptr;
+ }
+#endif /* TIDL_THREAD_ENABLE */
+
+ handle->callback_port = callback_port;
+ handle->callback = __vc.callback;
+ handle->user_data = __vc.user_data;
+
+ return handle;
+}
+
+int rpc_port_stub_vc_context_set_tag(rpc_port_stub_vc_context_h context, void *tag)
+{
+ if (context == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ context->tag = tag;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_context_get_tag(rpc_port_stub_vc_context_h context, void **tag)
+{
+ if (context == nullptr || tag == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ *tag = context->tag;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_context_get_sender(rpc_port_stub_vc_context_h context, char **sender)
+{
+ char *value;
+
+ if (context == nullptr || sender == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ value = strdup(context->sender);
+ if (value == nullptr) {
+ _E("Failed to duplicate sender");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *sender = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_context_get_instance(rpc_port_stub_vc_context_h context, char **instance)
+{
+ char *value;
+
+ if (context == nullptr || instance == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ value = strdup(context->instance);
+ if (value == nullptr) {
+ _E("Failed to duplicate instance");
+ return RPC_PORT_ERROR_OUT_OF_MEMORY;
+ }
+
+ *instance = value;
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_context_disconnect(rpc_port_stub_vc_context_h context)
+{
+ int ret;
+
+ if (context == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_rec_mutex_lock(&__vc.mutex);
+
+ ret = rpc_port_disconnect(context->callback_port);
+ if (ret != RPC_PORT_ERROR_NONE)
+ _E("Failed to disconnect. error(%d)", ret);
+
+ g_rec_mutex_unlock(&__vc.mutex);
+
+ return ret;
+}
+
+static rpc_port_stub_vc_context_h __rpc_port_stub_vc_find_context(const char *instance)
+{
+ rpc_port_stub_vc_context_h context;
+ GList *iter;
+
+ g_rec_mutex_lock(&__vc.mutex);
+ iter = __vc.contexts;
+ while (iter) {
+ context = iter->data;
+ if (!strcmp(context->instance, instance)) {
+ g_rec_mutex_unlock(&__vc.mutex);
+ return context;
+ }
+
+ iter = g_list_next(iter);
+ }
+ g_rec_mutex_unlock(&__vc.mutex);
+
+ return nullptr;
+}
+
+static void __rpc_port_stub_vc_add_context(rpc_port_stub_vc_context_h context)
+{
+ g_rec_mutex_lock(&__vc.mutex);
+ __vc.contexts = g_list_append(__vc.contexts, context);
+ g_rec_mutex_unlock(&__vc.mutex);
+}
+
+static void __rpc_port_stub_vc_remove_context(rpc_port_stub_vc_context_h context)
+{
+ g_rec_mutex_lock(&__vc.mutex);
+ __vc.contexts = g_list_remove(__vc.contexts, context);
+ g_rec_mutex_unlock(&__vc.mutex);
+}
+
+static bool __rpc_port_stub_vc_exist_callback_port(rpc_port_h callback_port)
+{
+ rpc_port_h port;
+ GList *iter;
+
+ g_rec_mutex_lock(&__vc.mutex);
+ iter = __vc.callback_ports;
+ while (iter) {
+ port = iter->data;
+ if (port == callback_port) {
+ g_rec_mutex_unlock(&__vc.mutex);
+ return true;
+ }
+
+ iter = g_list_next(iter);
+ }
+ g_rec_mutex_unlock(&__vc.mutex);
+
+ return false;
+}
+
+static void __rpc_port_stub_vc_add_callback_port(rpc_port_h callback_port)
+{
+ g_rec_mutex_lock(&__vc.mutex);
+ __vc.callback_ports = g_list_append(__vc.callback_ports, callback_port);
+ g_rec_mutex_unlock(&__vc.mutex);
+}
+
+static void __rpc_port_stub_vc_remove_callback_port(rpc_port_h callback_port)
+{
+ g_rec_mutex_lock(&__vc.mutex);
+ __vc.callback_ports = g_list_remove(__vc.callback_ports, callback_port);
+ g_rec_mutex_unlock(&__vc.mutex);
+}
+
+static void __rpc_port_stub_vc_connected_event_cb(const char *sender, const char *instance, void *user_data)
+{
+ rpc_port_stub_vc_context_h context;
+ rpc_port_h callback_port = nullptr;
+ int ret;
+
+ _W("sender(%s), instance(%s)", sender, instance);
+ ret = rpc_port_stub_get_port(__vc.stub, RPC_PORT_PORT_CALLBACK, instance, &callback_port);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to get callback port. error(%d)", ret);
+ return;
+ }
+
+ context = __rpc_port_stub_vc_context_create(sender, instance, callback_port);
+ if (context == nullptr)
+ return;
+
+ __rpc_port_stub_vc_add_context(context);
+ __rpc_port_stub_vc_add_callback_port(context->callback_port);
+ context->callback.create(context, context->user_data);
+}
+
+static void __rpc_port_stub_vc_disconnected_event_cb(const char *sender, const char *instance, void *user_data)
+{
+ rpc_port_stub_vc_context_h context;
+
+ _W("sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_vc_find_context(instance);
+ if (context == nullptr)
+ return;
+
+ __rpc_port_stub_vc_remove_callback_port(context->callback_port);
+ context->callback.terminate(context, context->user_data);
+ __rpc_port_stub_vc_remove_context(context);
+ __rpc_port_stub_vc_context_destroy(context);
+}
+
+static int __rpc_port_stub_vc_received_event_cb(const char *sender, const char *instance, rpc_port_h port, void *user_data)
+{
+ rpc_port_stub_vc_context_h context;
+ rpc_port_parcel_h parcel;
+ int ret;
+
+ _W("sender(%s), instance(%s)", sender, instance);
+ context = __rpc_port_stub_vc_find_context(instance);
+ if (context == nullptr) {
+ _E("Failed to find context. instance(%s)", instance);
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ context->port = port;
+ ret = rpc_port_parcel_create_from_port(&parcel, port);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create parcel handle from port. error(%d)", ret);
+ return ret;
+ }
+
+#ifdef TIDL_THREAD_ENABLE
+ ret = __rpc_port_stub_vc_context_push(context, parcel);
+#else
+ ret = __rpc_port_stub_vc_context_handle_request(context, parcel);
+ rpc_port_parcel_destroy(parcel);
+#endif /* TIDL_THREAD_ENABLE */
+
+ return ret;
+}
+
+static int __rpc_port_stub_vc_set_access_control(void)
+{
+ int ret = RPC_PORT_ERROR_NONE;
+
+ return ret;
+}
+
+int rpc_port_stub_vc_register(rpc_port_stub_vc_callback_s *callback, void *user_data)
+{
+ int ret;
+
+ if (callback == nullptr || callback->create == nullptr || callback->terminate == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (__vc.stub) {
+ _E("Already exists");
+ return RPC_PORT_ERROR_NONE;
+ }
+
+ g_rec_mutex_init(&__vc.mutex);
+ __vc.callback = *callback;
+ __vc.user_data = user_data;
+
+ ret = rpc_port_stub_create(&__vc.stub, "vc");
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to create stub handle. error(%d)", ret);
+ g_rec_mutex_clear(&__vc.mutex);
+ return ret;
+ }
+
+ ret = rpc_port_stub_add_received_event_cb(__vc.stub, __rpc_port_stub_vc_received_event_cb, &__vc);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add received event callback");
+ rpc_port_stub_vc_unregister();
+ return ret;
+ }
+
+ ret = rpc_port_stub_add_connected_event_cb(__vc.stub, __rpc_port_stub_vc_connected_event_cb, &__vc);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add connected event callback");
+ rpc_port_stub_vc_unregister();
+ return ret;
+ }
+
+ ret = rpc_port_stub_add_disconnected_event_cb(__vc.stub, __rpc_port_stub_vc_disconnected_event_cb, &__vc);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add disconnected event callback");
+ rpc_port_stub_vc_unregister();
+ return ret;
+ }
+
+ ret = __rpc_port_stub_vc_set_access_control();
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to add privileges");
+ rpc_port_stub_vc_unregister();
+ return ret;
+ }
+
+ ret = rpc_port_stub_listen(__vc.stub);
+ if (ret != RPC_PORT_ERROR_NONE) {
+ _E("Failed to listen events. error(%d)", ret);
+ rpc_port_stub_vc_unregister();
+ return ret;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_unregister(void)
+{
+ if (__vc.stub == nullptr)
+ return RPC_PORT_ERROR_NONE;
+
+ g_rec_mutex_lock(&__vc.mutex);
+ g_rec_mutex_unlock(&__vc.mutex);
+ g_rec_mutex_clear(&__vc.mutex);
+
+ if (__vc.contexts) {
+ g_list_free_full(__vc.contexts, __rpc_port_stub_vc_context_destroy);
+ __vc.contexts = nullptr;
+ }
+
+ if (__vc.stub) {
+ rpc_port_stub_destroy(__vc.stub);
+ __vc.stub = nullptr;
+ }
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_foreach_context(rpc_port_stub_vc_context_cb callback, void *user_data)
+{
+ rpc_port_stub_vc_context_h context;
+ GList *iter;
+
+ if (callback == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_rec_mutex_lock(&__vc.mutex);
+ iter = __vc.contexts;
+ while (iter) {
+ context = iter->data;
+ if (!callback(context, user_data))
+ break;
+
+ iter = g_list_next(iter);
+ }
+ g_rec_mutex_unlock(&__vc.mutex);
+
+ return RPC_PORT_ERROR_NONE;
+}
+
+int rpc_port_stub_vc_get_client_number(unsigned int *client_number)
+{
+ if (client_number == nullptr) {
+ _E("Invalid parameter");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ if (__vc.stub == nullptr) {
+ _E("Invalid context");
+ return RPC_PORT_ERROR_INVALID_PARAMETER;
+ }
+
+ g_rec_mutex_lock(&__vc.mutex);
+ *client_number = g_list_length(__vc.contexts);
+ g_rec_mutex_unlock(&__vc.mutex);
+
+ return RPC_PORT_ERROR_NONE;
+}
--- /dev/null
+/*
+ * Generated by tidlc 1.8.1.
+ */
+
+#pragma once
+
+#include <stdbool.h>
+#include <bundle.h>
+#include <rpc-port.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief The rpc_port_stub_array_char handle.
+ */
+typedef struct rpc_port_stub_array_char_s *rpc_port_stub_array_char_h;
+
+/**
+ * @brief The rpc_port_stub_vc_context handle.
+ */
+typedef struct rpc_port_stub_vc_context_s *rpc_port_stub_vc_context_h;
+
+/**
+ * @brief The rpc_port_stub_vc_notify_cb handle.
+ */
+typedef struct rpc_port_stub_vc_notify_cb_s *rpc_port_stub_vc_notify_cb_h;
+
+/**
+ * @brief The rpc_port_stub_vc_feedback_cb handle.
+ */
+typedef struct rpc_port_stub_vc_feedback_cb_s *rpc_port_stub_vc_feedback_cb_h;
+
+/**
+ * @briefs Creates a rpc_port_stub_array_char handle.
+ *
+ * @remarks The @a h should be released using the rpc_port_stub_array_char_destroy()
+ * if it's no longer needed.
+ * @param[out] h The rpc_port_stub_array_char handle that is newly created
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_array_char_destroy()
+ */
+int rpc_port_stub_array_char_create(rpc_port_stub_array_char_h *h);
+
+/**
+ * @brief Destroys the rpc_port_stub_array_char handle.
+ *
+ * @param[in] h The rpc_port_stub_array_char handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_stub_array_char_create()
+ */
+int rpc_port_stub_array_char_destroy(rpc_port_stub_array_char_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_stub_array_char handle.
+ *
+ * @remarks A new created rpc_port_stub_array_char should be released using
+ * the rpc_port_stub_array_char_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_stub_array_char handle
+ * @param[out] clone If successful, a new created rpc_port_stub_array_char handle will be returned
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_array_char_destroy()
+ */
+int rpc_port_stub_array_char_clone(rpc_port_stub_array_char_h h, rpc_port_stub_array_char_h *clone);
+
+/**
+ * @brief Sets the value to the rpc_port_stub_array_char handle.
+ *
+ * @remarks The value is internally copied and stored.
+ * You should release it if it's allocaed when it's no longer needed,
+ * @param[in] h The rpc_port_stub_array_char handle
+ * @param[in] value The array value
+ * @param[in] size The size of the array
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_array_char_get()
+ */
+int rpc_port_stub_array_char_set(rpc_port_stub_array_char_h h, char *value, int size);
+
+/**
+ * @brief Gets the value from the rpc_port_stub_array_char handle.
+ *
+ * @remarks A new created value should be released if it's no longer needed.
+ * @param[in] h The rpc_port_stub_array_char handle
+ * @param[out] value The array value
+ * @param[out] size The size of the array
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_array_char_set()
+ */
+int rpc_port_stub_array_char_get(rpc_port_stub_array_char_h h, char **value, int *size);
+
+/**
+ * @brief Called when the proxy is connected.
+ * @details The callback function is called when the proxy is connected to the stub.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s
+ */
+typedef void (*rpc_port_stub_vc_create_cb)(rpc_port_stub_vc_context_h context, void *user_data);
+
+/**
+ * @brief Called when the proxy is disconnected.
+ * @details The callback function is called when the proxy is disconnected from the stub.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s
+ */
+typedef void (*rpc_port_stub_vc_terminate_cb)(rpc_port_stub_vc_context_h context, void *user_data);
+
+/**
+ * @brief Called to get the proxy context once for each connected proxy.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @return @c true to continue with the next iteration of the loop,
+ * otherwise @c false to break out of the loop
+ * @pre rpc_port_stub_vc_foreach_context() will invoke this callback.
+ * @see rpc_port_stub_vc_foreach_context()
+ */
+typedef bool (*rpc_port_stub_vc_context_cb)(rpc_port_stub_vc_context_h context, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef void (*rpc_port_stub_vc_register_notify_cb_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_register_notify_cb_sync_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef void (*rpc_port_stub_vc_register_feedback_cb_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_register_feedback_cb_sync_cb)(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_initialize_cb)(rpc_port_stub_vc_context_h context, int pid, int *mgr_pid, int *service_state, int *daemon_pid, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_finalize_cb)(rpc_port_stub_vc_context_h context, int pid, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_set_command_cb)(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_unset_command_cb)(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_set_foreground_cb)(rpc_port_stub_vc_context_h context, int pid, bool value, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_set_server_dialog_cb)(rpc_port_stub_vc_context_h context, int pid, const char *app_id, const char *credential, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_request_dialog_cb)(rpc_port_stub_vc_context_h context, int pid, const char *disp_text, const char *utt_text, bool continuous, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_is_system_command_valid_cb)(rpc_port_stub_vc_context_h context, int pid, bool *is_sys_cmd_valid, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_auth_enable_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_auth_disable_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_auth_start_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_auth_stop_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_auth_cancel_cb)(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_request_tts_cb)(rpc_port_stub_vc_context_h context, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_cancel_tts_cb)(rpc_port_stub_vc_context_h context, int pid, int utt_id, void *user_data);
+
+/**
+ * @brief Called when the request of the proxy is delivered.
+ *
+ * @param[in] context The context handle
+ * @param[in] user_data The user data passed from the registration function
+ * @see #rpc_port_stub_vc_callback_s;
+ */
+typedef int (*rpc_port_stub_vc_get_tts_audio_format_cb)(rpc_port_stub_vc_context_h context, int pid, int *rate, int *channel, int *audio_type, void *user_data);
+
+/**
+ * @brief Sets the tag to the context handle.
+ *
+ * @param[in] context The context handle
+ * @param[in] tag The tag
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_stub_vc_context_get_tag()
+ */
+int rpc_port_stub_vc_context_set_tag(rpc_port_stub_vc_context_h context, void *tag);
+
+/**
+ * @brief Gets the tag from the context handle.
+ *
+ * @param[in] context The context handle
+ * @param[out] tag The tag
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_stub_vc_context_set_tag()
+ */
+int rpc_port_stub_vc_context_get_tag(rpc_port_stub_vc_context_h context, void **tag);
+
+/**
+ * @brief Gets the sender ID from the context handle.
+ * @details The @a sender should be released using free().
+ *
+ * @param[in] context The context handle
+ * @param[out] sender The sender ID of the context handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_stub_vc_context_get_sender(rpc_port_stub_vc_context_h context, char **sender);
+
+/**
+ * @brief Gets the instance ID from the context handle.
+ * @details The @a instance should be released using free().
+ *
+ * @param[in] context The context handle
+ * @param[out] instance The instance ID of the context handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_stub_vc_context_get_instance(rpc_port_stub_vc_context_h context, char **instance);
+
+/**
+ * @brief Disconnects from the proxy.
+ *
+ * @param[in] context The context handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_vc_context_disconnect(rpc_port_stub_vc_context_h context);
+
+/**
+ * @brief Creates a rpc_port_stub_vc_notify_cb handle.
+ *
+ * @param[out] h The rpc_port_stub_vc_notify_cb handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_vc_notify_cb_destroy()
+ */
+int rpc_port_stub_vc_notify_cb_create(rpc_port_stub_vc_notify_cb_h *h);
+
+/**
+ * @brief Destroys the rpc_port_stub_vc_notify_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_vc_notify_cb handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_stub_vc_notify_cb_clone()
+ */
+int rpc_port_stub_vc_notify_cb_destroy(rpc_port_stub_vc_notify_cb_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_stub_vc_notify_cb handle.
+ *
+ * @remarks A new created rpc_port_stub_vc_notify_cb should be released using
+ * the rpc_port_stub_vc_notify_cb_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_stub_vc_notify_cb handle
+ * @param[out] clone If successful, a new created rpc_port_stub_vc_notify_cb handle will be returned
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_vc_notify_cb_destroy()
+ */
+int rpc_port_stub_vc_notify_cb_clone(rpc_port_stub_vc_notify_cb_h h, rpc_port_stub_vc_notify_cb_h *clone);
+
+/**
+ * @brief Gets the ID of the rpc_port_stub_vc_notify_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_vc_notify_cb handle
+ * @param[out] id The ID
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_vc_notify_cb_get_id(rpc_port_stub_vc_notify_cb_h h, int *id);
+
+/**
+ * @brief Gets the sequence ID of the rpc_port_stub_vc_notify_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_vc_notify_cb handle
+ * @param[out] seq_id The Sequence ID
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_vc_notify_cb_get_seq_id(rpc_port_stub_vc_notify_cb_h h, int *seq_id);
+
+/**
+ * @brief Checks whether the delegate is for one-time or not.
+ *
+ * @param[in] h The rpc_port_stub_vc_notify_cb handle
+ * @param[out] once The flag, it's true, the handle is for one-time
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_vc_notify_cb_is_once(rpc_port_stub_vc_notify_cb_h h, bool *once);
+
+/**
+ * @brief Gets the tag from the rpc_port_stub_vc_notify_cb handle.
+ *
+ * @remarks The @a tag should be released using free().
+ * @param[in] h The rpc_port_stub_vc_notify_cb handle
+ * @param[out] tag The tag
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_stub_vc_notify_cb_get_tag(rpc_port_stub_vc_notify_cb_h h, char **tag);
+
+/**
+ * @brief Invokes the callback function of the rpc_port_stub_vc_notify_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_vc_notify_cb handle
+ * @param[in] ...
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_stub_vc_notify_cb_invoke(rpc_port_stub_vc_notify_cb_h h, int pid, bundle *msg);
+
+/**
+ * @brief Creates a rpc_port_stub_vc_feedback_cb handle.
+ *
+ * @param[out] h The rpc_port_stub_vc_feedback_cb handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_vc_feedback_cb_destroy()
+ */
+int rpc_port_stub_vc_feedback_cb_create(rpc_port_stub_vc_feedback_cb_h *h);
+
+/**
+ * @brief Destroys the rpc_port_stub_vc_feedback_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_vc_feedback_cb handle
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_stub_vc_feedback_cb_clone()
+ */
+int rpc_port_stub_vc_feedback_cb_destroy(rpc_port_stub_vc_feedback_cb_h h);
+
+/**
+ * @brief Creates and returns a copy of the given rpc_port_stub_vc_feedback_cb handle.
+ *
+ * @remarks A new created rpc_port_stub_vc_feedback_cb should be released using
+ * the rpc_port_stub_vc_feedback_cb_destroy() if it's no longer needed.
+ * @param[in] h The rpc_port_stub_vc_feedback_cb handle
+ * @param[out] clone If successful, a new created rpc_port_stub_vc_feedback_cb handle will be returned
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see rpc_port_stub_vc_feedback_cb_destroy()
+ */
+int rpc_port_stub_vc_feedback_cb_clone(rpc_port_stub_vc_feedback_cb_h h, rpc_port_stub_vc_feedback_cb_h *clone);
+
+/**
+ * @brief Gets the ID of the rpc_port_stub_vc_feedback_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_vc_feedback_cb handle
+ * @param[out] id The ID
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_vc_feedback_cb_get_id(rpc_port_stub_vc_feedback_cb_h h, int *id);
+
+/**
+ * @brief Gets the sequence ID of the rpc_port_stub_vc_feedback_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_vc_feedback_cb handle
+ * @param[out] seq_id The Sequence ID
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_vc_feedback_cb_get_seq_id(rpc_port_stub_vc_feedback_cb_h h, int *seq_id);
+
+/**
+ * @brief Checks whether the delegate is for one-time or not.
+ *
+ * @param[in] h The rpc_port_stub_vc_feedback_cb handle
+ * @param[out] once The flag, it's true, the handle is for one-time
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_vc_feedback_cb_is_once(rpc_port_stub_vc_feedback_cb_h h, bool *once);
+
+/**
+ * @brief Gets the tag from the rpc_port_stub_vc_feedback_cb handle.
+ *
+ * @remarks The @a tag should be released using free().
+ * @param[in] h The rpc_port_stub_vc_feedback_cb handle
+ * @param[out] tag The tag
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int rpc_port_stub_vc_feedback_cb_get_tag(rpc_port_stub_vc_feedback_cb_h h, char **tag);
+
+/**
+ * @brief Invokes the callback function of the rpc_port_stub_vc_feedback_cb handle.
+ *
+ * @param[in] h The rpc_port_stub_vc_feedback_cb handle
+ * @param[in] ...
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #RPC_PORT_ERROR_IO_ERROR I/O error
+ */
+int rpc_port_stub_vc_feedback_cb_invoke(rpc_port_stub_vc_feedback_cb_h h, int utt_id, int event, rpc_port_stub_array_char_h pcm_data, int len);
+
+/**
+ * @brief The structure type containing the set of callback functions for handling stub events.
+ * @details It is one of the input parameters of the rpc_port_stub_vc_register() function.
+ *
+ * @see rpc_port_stub_vc_create_cb
+ * @see rpc_port_stub_vc_terminate_cb
+ */
+typedef struct {
+ rpc_port_stub_vc_create_cb create; /**< This callback function is invoked when the proxy is connected. */
+ rpc_port_stub_vc_terminate_cb terminate; /**< This callback function is invoked when the proxy is disconnected. */
+ rpc_port_stub_vc_register_notify_cb_cb register_notify_cb; /**< This callback function is invoked when the register_notify_cb request is delivered. */
+ rpc_port_stub_vc_register_notify_cb_sync_cb register_notify_cb_sync; /**< This callback function is invoked when the register_notify_cb_sync request is delivered. */
+ rpc_port_stub_vc_register_feedback_cb_cb register_feedback_cb; /**< This callback function is invoked when the register_feedback_cb request is delivered. */
+ rpc_port_stub_vc_register_feedback_cb_sync_cb register_feedback_cb_sync; /**< This callback function is invoked when the register_feedback_cb_sync request is delivered. */
+ rpc_port_stub_vc_initialize_cb initialize; /**< This callback function is invoked when the initialize request is delivered. */
+ rpc_port_stub_vc_finalize_cb finalize; /**< This callback function is invoked when the finalize request is delivered. */
+ rpc_port_stub_vc_set_command_cb set_command; /**< This callback function is invoked when the set_command request is delivered. */
+ rpc_port_stub_vc_unset_command_cb unset_command; /**< This callback function is invoked when the unset_command request is delivered. */
+ rpc_port_stub_vc_set_foreground_cb set_foreground; /**< This callback function is invoked when the set_foreground request is delivered. */
+ rpc_port_stub_vc_set_server_dialog_cb set_server_dialog; /**< This callback function is invoked when the set_server_dialog request is delivered. */
+ rpc_port_stub_vc_request_dialog_cb request_dialog; /**< This callback function is invoked when the request_dialog request is delivered. */
+ rpc_port_stub_vc_is_system_command_valid_cb is_system_command_valid; /**< This callback function is invoked when the is_system_command_valid request is delivered. */
+ rpc_port_stub_vc_auth_enable_cb auth_enable; /**< This callback function is invoked when the auth_enable request is delivered. */
+ rpc_port_stub_vc_auth_disable_cb auth_disable; /**< This callback function is invoked when the auth_disable request is delivered. */
+ rpc_port_stub_vc_auth_start_cb auth_start; /**< This callback function is invoked when the auth_start request is delivered. */
+ rpc_port_stub_vc_auth_stop_cb auth_stop; /**< This callback function is invoked when the auth_stop request is delivered. */
+ rpc_port_stub_vc_auth_cancel_cb auth_cancel; /**< This callback function is invoked when the auth_cancel request is delivered. */
+ rpc_port_stub_vc_request_tts_cb request_tts; /**< This callback function is invoked when the request_tts request is delivered. */
+ rpc_port_stub_vc_cancel_tts_cb cancel_tts; /**< This callback function is invoked when the cancel_tts request is delivered. */
+ rpc_port_stub_vc_get_tts_audio_format_cb get_tts_audio_format; /**< This callback function is invoked when the get_tts_audio_format request is delivered. */
+} rpc_port_stub_vc_callback_s;
+
+/**
+ * @brief Registers the set of the callback functions and the port.
+ * @details This function registers the set of the callback functions to handle stub events.
+ * And, the rpc_port_stub_listen() is called internally to handle events.
+ *
+ * @param[in] callback The set of callback functions to handle stub events
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #RPC_PORT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #RPC_PORT_ERROR_IO_ERROR I/O error
+ * @retval #RPC_PORT_ERROR_PERMISSION_DENIED Permission denied
+ * @see rpc_port_stub_vc_unregister()
+ * @see #rpc_port_stub_vc_callback_s
+ */
+int rpc_port_stub_vc_register(rpc_port_stub_vc_callback_s *callback, void *user_data);
+
+/**
+ * @brief Unregisters the registered port.
+ */
+int rpc_port_stub_vc_unregister(void);
+
+/**
+ * @brief Retrieves the connected context handles.
+ *
+ * @param[in] callback The callback function
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see rpc_port_stub_vc_context_cb()
+ */
+int rpc_port_stub_vc_foreach_context(rpc_port_stub_vc_context_cb callback, void *user_data);
+
+/**
+ * @brief Gets the number of connected clients.
+ *
+ * @param[out] client_number The client number
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #RPC_PORT_ERROR_NONE Successful
+ * @retval #RPC_PORT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int rpc_port_stub_vc_get_client_number(unsigned int *client_number);
+
+#ifdef __cplusplus
+}
+#endif
#include "vcd_config.h"
#include "vcd_tidl.h"
+#include "vcd_stub.h"
#include "vcd_mgr_stub.h"
#include "vcd_mgr_proxy.h"
#include "vcd_widget_stub.h"
#include "vcd_widget_proxy.h"
+
static rpc_port_stub_vc_mgr_callback_s g_mgr_callback;
static pthread_mutex_t g_mgr_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t g_widget_tidl_info_mutex = PTHREAD_MUTEX_INITIALIZER;
+static rpc_port_stub_vc_callback_s g_vc_callback;
+
static int g_volume_count = 0;
int vcd_mgr_tidl_open_connection();
pthread_mutex_unlock(&g_widget_tidl_info_mutex);
}
+/**
+ * TIDL functions for VC client
+ */
+
+static void __vc_create_cb(rpc_port_stub_vc_context_h context, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_create_cb");
+
+ char *sender = NULL;
+
+ rpc_port_stub_SamsungAIAppPort_context_get_sender(context, &sender);
+ if (!sender) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Sender is NULL");
+ return ;
+ }
+
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] sender(%s)", sender); // sender (app_id)
+ free(sender);
+}
+
+static void __vc_terminate_cb(rpc_port_stub_vc_context_h context, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_terminate_cb");
+}
+
+static void __vc_register_notify_cb_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_notify_cb_cb. pid(%d)", pid);
+
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null.");
+ return ;
+ }
+
+ int ret = -1;
+ ret = vcd_client_add_ipc_info(pid);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info.");
+ return ;
+ }
+
+ ret = vcd_client_set_ipc_notify_cb(pid, callback, user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback.");
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback.");
+ }
+}
+
+static int __vc_register_notify_cb_sync_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_notify_cb_h callback, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_notify_cb_sync_cb. pid(%d)", pid);
+
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null.");
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = -1;
+ ret = vcd_client_add_ipc_info(pid);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info.");
+ return ret;
+ }
+
+ ret = vcd_client_set_ipc_notify_cb(pid, callback, user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback.");
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set notify callback.");
+ }
+
+ return ret;
+}
+
+static void __vc_register_feedback_cb_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_feedback_cb_cb. pid(%d)", pid);
+
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null.");
+ return ;
+ }
+
+ int ret = -1;
+ ret = vcd_client_add_ipc_info(pid);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info.");
+ return ;
+ }
+
+ ret = vcd_client_set_ipc_feedback_cb(pid, callback, user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set feedback callback.");
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set feedback callback.");
+ }
+}
+
+static int __vc_register_feedback_cb_sync_cb(rpc_port_stub_vc_context_h context, int pid, rpc_port_stub_vc_feedback_cb_h callback, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_register_feedback_cb_sync_cb. pid(%d)", pid);
+
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] callback is null.");
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = -1;
+ ret = vcd_client_add_ipc_info(pid);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to add ipc info.");
+ return ret;
+ }
+
+ ret = vcd_client_set_ipc_feedback_cb(pid, callback, user_data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set feedback callback.");
+ } else {
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] Succeed to set feedback callback.");
+ }
+
+ return ret;
+}
+
+static int __vc_initialize_cb(rpc_port_stub_vc_context_h context, int pid, int *mgr_pid, int *service_state, int *daemon_pid, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_initialize_cb. pid(%d)", pid);
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ ret = vcd_server_initialize(pid);
+ *service_state = vcd_server_get_service_state();
+ *daemon_pid = getpid();
+ *mgr_pid = vcd_client_manager_get_pid();
+
+ if (VCD_ERROR_NONE == ret) {
+ SLOG(LOG_INFO, TAG_VCD, "[IN] vcd initialize : pid(%d) daemon_pid(%d)", pid, daemon_pid);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd initialize : pid(%d) daemon_pid(%d) ret(%d)", pid, daemon_pid, ret);
+ }
+
+ return ret;
+}
+
+static int __vc_finalize_cb(rpc_port_stub_vc_context_h context, int pid, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_finalize_cb");
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ ret = vcd_server_finalize(pid);
+ if (VCD_ERROR_NONE == ret) {
+ SLOG(LOG_INFO, TAG_VCD, "[IN] vcd finalize : pid(%d)", pid);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd finalize : pid(%d) ret(%d)", pid, ret);
+ }
+
+ return ret;
+}
+
+static int __vc_set_command_cb(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_command_cb");
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ ret = vcd_server_set_command(pid, (vc_cmd_type_e)cmd_type);
+ if (VCD_ERROR_NONE == ret) {
+ SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set command : pid(%d), cmd_type(%d)", pid, cmd_type);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set command : pid(%d), cmd_type(%d) ret(%d)", pid, cmd_type, ret);
+ }
+
+ return ret;
+}
+
+static int __vc_unset_command_cb(rpc_port_stub_vc_context_h context, int pid, int cmd_type, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_unset_command_cb");
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ ret = vcd_server_unset_command(pid, (vc_cmd_type_e)cmd_type);
+ if (VCD_ERROR_NONE == ret) {
+ SLOG(LOG_INFO, TAG_VCD, "[IN] vcd unset command : pid(%d), cmd_type(%d)", pid, cmd_type);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd unset command : pid(%d), cmd_type(%d) ret(%d)", pid, cmd_type, ret);
+ }
+
+ return ret;
+}
+
+static int __vc_set_foreground_cb(rpc_port_stub_vc_context_h context, int pid, bool value, void *user_data)
+{
+ // check more...
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_foreground_cb");
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ ret = vcd_server_set_foreground(pid, value);
+ if (VCD_ERROR_NONE == ret) {
+ SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set foreground : pid(%d)", pid);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set foreground : pid(%d) ret(%d)", pid, ret);
+ }
+
+ return ret;
+}
+
+static int __vc_set_server_dialog_cb(rpc_port_stub_vc_context_h context, int pid, const char *app_id, const char *credential, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_set_server_dialog_cb");
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ ret = vcd_server_set_server_dialog(pid, app_id, credential);
+ if (VCD_ERROR_NONE == ret) {
+ SLOG(LOG_INFO, TAG_VCD, "[IN] vcd set server dialog : pid(%d), app_id(%s)", pid, app_id);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd set server dialog : pid(%d), app_id(%s) ret(%d)", pid, app_id, ret);
+ }
+
+ return ret;
+}
+
+static int __vc_request_dialog_cb(rpc_port_stub_vc_context_h context, int pid, const char *disp_text, const char *utt_text, bool continuous, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_request_dialog_cb");
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ ret = vcd_server_dialog(pid, disp_text, utt_text, continuous);
+ if (VCD_ERROR_NONE == ret) {
+ SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d)", pid, disp_text, utt_text, continuous);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd request dialog : pid(%d), disp_text(%s), utt_text(%s), continuous(%d), ret(%d)", pid, disp_text, utt_text, continuous, ret(%d));
+ }
+
+ return ret;
+}
+
+static int __vc_is_system_command_valid_cb(rpc_port_stub_vc_context_h context, int pid, bool *is_sys_cmd_valid, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_is_system_command_valid_cb");
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ ret = vcd_server_is_system_command_valid(pid, &is_sys_cmd_valid);
+ if (VCD_ERROR_NONE == ret) {
+ SLOG(LOG_INFO, TAG_VCD, "[IN] vcd check system command is valid : pid(%d), is_sys_cmd_valid(%d)", pid, *is_sys_cmd_valid);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd check system command is valid : pid(%d), ret(%d)", pid, ret);
+ }
+
+ return ret;
+}
+
+static int __vc_auth_enable_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_enable_cb");
+
+}
+
+static int __vc_auth_disable_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_disable_cb");
+}
+
+static int __vc_auth_start_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_start_cb");
+}
+
+static int __vc_auth_stop_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_stop_cb");
+}
+
+static int __vc_auth_cancel_cb(rpc_port_stub_vc_context_h context, int pid, int mgr_pid, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_auth_cancel_cb");
+}
+
+static int __vc_request_tts_cb(rpc_port_stub_vc_context_h context, int pid, const char *text, const char *lang, bool to_vcm, int *utt_id, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_request_tts_cb");
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ ret = vcd_server_request_tts(pid, text, lang, to_vcm, &utt_id);
+ if (VCD_ERROR_NONE == ret) {
+ SLOG(LOG_INFO, TAG_VCD, "[IN] vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d)", pid, text, lang, to_vcm);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd request tts : pid(%d), text(%s), language(%s), to_vcm(%d), ret(%d)", pid, text, lang, to_vcm, ret);
+ }
+
+ return ret;
+}
+
+static int __vc_cancel_tts_cb(rpc_port_stub_vc_context_h context, int pid, int utt_id, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_cancel_tts_cb");
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ ret = vcd_server_cancel_tts(pid, utt_id);
+ if (VCD_ERROR_NONE == ret) {
+ SLOG(LOG_INFO, TAG_VCD, "[IN] vcd cancel tts : pid(%d), utt_id(%d)", pid, utt_id);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd cancel tts : pid(%d), utt_id(%d), ret(%d)", pid, utt_id, ret);
+ }
+
+ return ret;
+}
+
+static int __vc_get_tts_audio_format_cb(rpc_port_stub_vc_context_h context, int pid, int *rate, int *channel, int *audio_type, void *user_data)
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] __vc_get_tts_audio_format_cb");
+
+ int ret = VCD_ERROR_OPERATION_FAILED;
+
+ ret = vcd_server_get_tts_audio_format(pid, &rate, &channel, &audio_type);
+ if (VCD_ERROR_NONE == ret) {
+ SLOG(LOG_INFO, TAG_VCD, "[IN] vcd get tts audio format : pid(%d), rate(%d), channel(%d), audio_type(%d)", pid, *rate, *channel, *audio_type);
+ } else {
+ SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Fail to vcd get tts audio format : pid(%d) ret(%d)", pid, ret);
+ }
+
+ return ret;
+}
+
+int vcd_tidl_open_connection()
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_tidl_open_connection");
+
+ g_vc_callback.create = __vc_create_cb;
+ g_vc_callback.terminate = __vc_terminate_cb;
+ g_vc_callback.register_notify_cb = __vc_register_notify_cb_cb;
+ g_vc_callback.register_notify_cb_sync = __vc_register_notify_cb_sync_cb;
+ g_vc_callback.register_feedback_cb = __vc_register_feedback_cb_cb;
+ g_vc_callback.register_feedback_cb_sync = __vc_register_feedback_cb_sync_cb;
+ g_vc_callback.initialize = __vc_initialize_cb;
+ g_vc_callback.finalize = __vc_finalize_cb;
+ g_vc_callback.set_command = __vc_set_command_cb;
+ g_vc_callback.unset_command = __vc_unset_command_cb;
+ g_vc_callback.set_foreground = __vc_set_foreground_cb;
+ g_vc_callback.set_server_dialog = __vc_set_server_dialog_cb;
+ g_vc_callback.request_dialog = __vc_request_dialog_cb;
+ g_vc_callback.is_system_command_valid = __vc_is_system_command_valid_cb;
+ g_vc_callback.auth_enable = __vc_auth_enable_cb;
+ g_vc_callback.auth_disable = __vc_auth_disable_cb;
+ g_vc_callback.auth_start = __vc_auth_start_cb;
+ g_vc_callback.auth_stop = __vc_auth_stop_cb;
+ g_vc_callback.auth_cancel = __vc_auth_cancel_cb;
+ g_vc_callback.request_tts = __vc_request_tts_cb;
+ g_vc_callback.cancel_tts = __vc_cancel_tts_cb;
+ g_vc_callback.get_tts_audio_format = __vc_get_tts_audio_format_cb;
+
+ int ret = -1;
+ ret = rpc_port_stub_vc_register(&g_vc_callback, NULL);
+ if (VCD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to register TIDL callbacks. ret(%d)", ret);
+ return VCD_ERROR_OPERATION_FAILED;
+ }
+
+ return VCD_ERROR_NONE;
+}
+
+int vcd_tidl_close_connection()
+{
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] vcd_tidl_close_connection");
+ rpc_port_stub_vc_unregister();
+
+ return VCD_ERROR_NONE;
+}
+
+int vcdc_send_result(int pid, int manager_pid, int cmd_type)
+{
+ client_ipc_info_s* info = vcd_client_get_ipc_info(pid);
+ if (NULL == info) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get ipc info. pid(%d)", pid);
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ bundle* bundle_data = bundle_create();
+ if (NULL == bundle_data) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data");
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
+
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] Result command type(%d)", cmd_type);
+
+ char pid_char[10] = {0};
+ snprintf(pid_char, 10, "%d", pid);
+ bundle_add_str(bundle_data, VC_BUNDLE_PID, pid_char);
+
+ switch (cmd_type) {
+ case VC_COMMAND_TYPE_FOREGROUND:
+ case VC_COMMAND_TYPE_BACKGROUND:
+ if (pid == manager_pid) {
+ bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT);
+ } else {
+ bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_METHOD_RESULT);
+ }
+ break;
+ case VC_COMMAND_TYPE_WIDGET:
+ bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_WIDGET_METHOD_RESULT);
+ break;
+ case VC_COMMAND_TYPE_SYSTEM:
+ case VC_COMMAND_TYPE_SYSTEM_BACKGROUND:
+ case VC_COMMAND_TYPE_EXCLUSIVE:
+ bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_MANAGER_METHOD_RESULT);
+ break;
+
+ default:
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Command type is NOT valid(%d)", cmd_type);
+ return -1;
+ }
+
+ rpc_port_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data);
+
+ return VCD_ERROR_NONE;
+}
+
+int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg)
+{
+ if (NULL == err_msg) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Input parameter is NULL");
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ client_ipc_info_s* info = vcd_client_get_ipc_info(pid);
+ if (NULL == info) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get ipc info. pid(%d)", pid);
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ bundle* bundle_data = bundle_create();
+ if (NULL == bundle_data) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data");
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
+
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send error signal to app(%d)", pid);
+
+ char pid_char[10] = {0};
+ char reason_char[10] = {0};
+ snprintf(pid_char, 10, "%d", pid);
+ snprintf(reason_char, 10, "%d", reason);
+
+ bundle_add_str(bundle_data, VC_BUNDLE_METHOD, VCD_METHOD_ERROR_TO_APP);
+ bundle_add_str(bundle_data, VC_BUNDLE_PID, pid_char);
+ bundle_add_str(bundle_data, VC_BUNDLE_REASON, reason_char);
+ bundle_add_str(bundle_data, VC_BUNDLE_ERR_MSG, err_msg);
+
+ rpc_port_stub_vc_notify_cb_invoke(info->notify_cb, pid, bundle_data);
+
+ return VCD_ERROR_NONE;
+}
+
+int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len)
+{
+ if (NULL == buffer || 0 >= len) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Invalid parameter");
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ client_ipc_info_s* info = vcd_client_get_ipc_info(pid);
+ if (NULL == info) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get ipc info. pid(%d)", pid);
+ return VCD_ERROR_INVALID_PARAMETER;
+ }
+
+ bundle* bundle_data = bundle_create();
+ if (NULL == bundle_data) {
+ SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create bundle data");
+ return VCD_ERROR_OUT_OF_MEMORY;
+ }
+
+ SLOG(LOG_INFO, TAG_VCD, "[TIDL] Send feedback streaming to app(%d), utt_id(%d), event(%d), length(%d)", pid, utt_id, event, len);
+
+ rpc_port_stub_array_char_h arr_char = NULL;
+ rpc_port_stub_array_char_create(&arr_char);
+ rpc_port_stub_array_char_set(arr_char, buffer, len);
+
+ rpc_port_stub_vc_feedback_cb_invoke(info->feedback_cb, utt_id, event, arr_char, len);
+
+ return VCD_ERROR_NONE;
+}
+
// TODO: remove _tidl after all dbus removed
int vcdc_tidl_send_hello(int pid, vcd_client_type_e type)
{
// VCD_CLIENT_TYPE_MANAGER
// } vcd_client_type_e;
+
int vcd_tidl_open_connection();
int vcd_tidl_close_connection();
int vcdc_send_feedback_streaming_to_manager(int manager_pid, int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len);
+int vcdc_send_result(int pid, int manager_pid, int cmd_type);
+
+int vcdc_send_error_signal_to_app(int pid, int reason, char *err_msg);
+
+int vcdc_send_feedback_streaming(int pid, int utt_id, vc_feedback_event_e event, char* buffer, int len);
#ifdef __cplusplus
}
#endif
+<<<<<<< HEAD
+#endif /* __VCD_TIDL_h__ */
+=======
#endif /* __VCD_TIDL_h__ */
+>>>>>>> Replace IPC (VCC) from dbus to tidl
--- /dev/null
+interface vc {
+ void notify_cb(int pid, bundle msg) delegate;
+ void feedback_cb(int utt_id, int event, array<char> pcm_data, int len) delegate;
+
+ void register_notify_cb(int pid, notify_cb callback) async;
+ int register_notify_cb_sync(int pid, notify_cb callback);
+ void register_feedback_cb(int pid, feedback_cb callback) async;
+ int register_feedback_cb_sync(int pid, feedback_cb callback);
+
+ int initialize(in int pid, out int mgr_pid, out int service_state, out int daemon_pid);
+ int finalize(in int pid);
+ int set_command(in int pid, in int cmd_type);
+ int unset_command(in int pid, in int cmd_type);
+ int set_foreground(in int pid, in bool value);
+ int set_server_dialog(in int pid, in string app_id, in string credential);
+ int request_dialog(in int pid, in string disp_text, in string utt_text, in bool continuous);
+ int is_system_command_valid(in int pid, out bool is_sys_cmd_valid);
+
+ int auth_enable(in int pid, in int mgr_pid);
+ int auth_disable(in int pid, in int mgr_pid);
+ int auth_start(in int pid, in int mgr_pid);
+ int auth_stop(in int pid, in int mgr_pid);
+ int auth_cancel(in int pid, in int mgr_pid);
+
+ int request_tts(in int pid, string text, string lang, bool to_vcm, out int utt_id);
+ int cancel_tts(in int pid, in int utt_id);
+ int get_tts_audio_format(in int pid, out int rate, out int channel, out int audio_type);
+}