/*
-* Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
+* Copyright (c) 2011-2016 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
#include "stt_client.h"
+#include <vconf/vconf.h>
+#include <buxton2.h>
+
static int g_waiting_time = 3000;
static int g_waiting_short_time = 500;
+static char* g_server_service_name = NULL;
+static char* g_server_service_object = NULL;
+static char* g_server_service_interface = NULL;
+
static Ecore_Fd_Handler* g_fd_handler = NULL;
static DBusConnection* g_conn_sender = NULL;
static DBusConnection* g_conn_listener = NULL;
+void __stt_dbus_service_free();
extern int __stt_cb_error(int uid, int reason, char* err_msg);
extern int __stt_cb_set_volume(int uid, float volume);
+extern int __stt_cb_speech_status(int uid, int status);
+
+char* __stt_get_service_name(char* engine_id)
+{
+ char* service_name = NULL;
+ const char* engine_default = NULL;
+
+ struct buxton_client * bux_cli;
+ struct buxton_layer * bux_layer;
+ struct buxton_value * bux_val;
+
+ int ret = buxton_open(&bux_cli, NULL, NULL);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] Fail to open buxton client, ret(%d)", ret);
+ return NULL;
+ }
+ SLOG(LOG_DEBUG, TAG_STTC, "[DBUS-BUXTON2] buxton_open: %d", ret);
+ bux_layer = buxton_create_layer("system");
+ if (NULL == bux_layer) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] buxton_create_layer FAIL");
+ buxton_close(bux_cli);
+ bux_cli = NULL;
+ return NULL;
+ }
+
+ bux_val = buxton_value_create_string("stt-engine-default");
+ if (NULL == bux_val) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] buxton_value_create_string FAIL");
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+ bux_layer = NULL;
+ bux_cli = NULL;
+ return NULL;
+ }
+
+ ret = buxton_get_value_sync(bux_cli, bux_layer, STT_ENGINE_DB_DEFAULT, &bux_val);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] Fail to get value sync, ret(%d)", ret);
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ ret = buxton_value_get_string(bux_val, &engine_default);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] Fail to get value string, ret(%d)", ret);
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ SLOG(LOG_DEBUG, TAG_STTC, "[DBUS-BUXTON2] buxton_value_get_string: engine_default: %s", engine_default);
+
+
+ if (NULL == engine_id || NULL == engine_default || 0 == strncmp(engine_id, engine_default, strlen(engine_id))) {
+ service_name = (char*)calloc(strlen(STT_SERVER_SERVICE_NAME) + 1, sizeof(char));
+ if (NULL == service_name) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Memory allocation Failed!!");
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ snprintf(service_name, strlen(STT_SERVER_SERVICE_NAME) + 1, "%s", STT_SERVER_SERVICE_NAME);
+ } else {
+ service_name = (char*)calloc(strlen(STT_SERVER_SERVICE_NAME) + strlen(engine_id) - 8, sizeof(char));
+ if (NULL == service_name) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Memory allocation Failed!!");
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ snprintf(service_name, strlen(STT_SERVER_SERVICE_NAME) + strlen(engine_id) - 8, "%s%s%s", STT_SERVER_SERVICE_NAME, ".", (engine_id + 10));
+ }
+
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+
+ SLOG(LOG_DEBUG, TAG_STTC, "[get_service_name] FINISH!! service name: %s", service_name);
+
+ return service_name;
+}
+
+char* __stt_get_service_object(char* engine_id)
+{
+ char* service_object = NULL;
+ const char* engine_default = NULL;
+
+ struct buxton_client * bux_cli;
+ struct buxton_layer * bux_layer;
+ struct buxton_value * bux_val;
+
+ int ret = buxton_open(&bux_cli, NULL, NULL);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] Fail to open buxton client, ret(%d)", ret);
+ return NULL;
+ }
+ bux_layer = buxton_create_layer("system");
+ if (NULL == bux_layer) {
+ SLOG(LOG_DEBUG, TAG_STTC, "[DBUS-BUXTON2] buxton_create_layer FAIL");
+ buxton_close(bux_cli);
+ bux_cli = NULL;
+ return NULL;
+ }
+
+ bux_val = buxton_value_create_string("stt-engine-default");
+ if (NULL == bux_val) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] buxton_value_create_string FAIL");
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+ bux_layer = NULL;
+ bux_cli = NULL;
+ return NULL;
+ }
+
+ ret = buxton_get_value_sync(bux_cli, bux_layer, STT_ENGINE_DB_DEFAULT, &bux_val);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] Fail to get value sync, ret(%d)", ret);
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ ret = buxton_value_get_string(bux_val, &engine_default);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] Fail to get string, ret(%d)", ret);
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ SLOG(LOG_DEBUG, TAG_STTC, "[DBUS-BUXTON2] buxton_value_get_string: engine_default: %s", engine_default);
+
+ if (NULL == engine_id || NULL == engine_default || 0 == strncmp(engine_id, engine_default, strlen(engine_id))) {
+ service_object = (char*)calloc(strlen(STT_SERVER_SERVICE_OBJECT_PATH) + 1, sizeof(char));
+ if (NULL == service_object) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Memory allocation Failed!!");
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ snprintf(service_object, strlen(STT_SERVER_SERVICE_OBJECT_PATH) + 1, "%s", STT_SERVER_SERVICE_OBJECT_PATH);
+ } else {
+ service_object = (char*)calloc(strlen(STT_SERVER_SERVICE_OBJECT_PATH) + strlen(engine_id) - 8, sizeof(char));
+ if (NULL == service_object) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Memory allocation Failed!!");
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ snprintf(service_object, strlen(STT_SERVER_SERVICE_OBJECT_PATH) + strlen(engine_id) - 8, "%s%s%s", STT_SERVER_SERVICE_OBJECT_PATH, "/", (engine_id + 10));
+ }
+
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+
+ SLOG(LOG_DEBUG, TAG_STTC, "[get_service_object] FINISH!! service object: %s", service_object);
+
+ return service_object;
+}
+
+char* __stt_get_service_interface(char* engine_id)
+{
+ char* service_interface = NULL;
+ const char* engine_default = NULL;
+
+ struct buxton_client * bux_cli;
+ struct buxton_layer * bux_layer;
+ struct buxton_value * bux_val;
+
+ int ret = buxton_open(&bux_cli, NULL, NULL);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] Fail to open buxton client, ret(%d)", ret);
+ return NULL;
+ }
+ bux_layer = buxton_create_layer("system");
+ if (NULL == bux_layer) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] buxton_create_layer FAIL");
+ buxton_close(bux_cli);
+ bux_cli = NULL;
+ return NULL;
+ }
+
+ bux_val = buxton_value_create_string("stt-engine-default");
+ if (NULL == bux_val) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] buxton_value_create_string FAIL");
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+ bux_layer = NULL;
+ bux_cli = NULL;
+ return NULL;
+ }
+
+ ret = buxton_get_value_sync(bux_cli, bux_layer, STT_ENGINE_DB_DEFAULT, &bux_val);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] Fail to get value sync, ret(%d)", ret);
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ ret = buxton_value_get_string(bux_val, &engine_default);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, TAG_STTC, "[DBUS-BUXTON2] Fail to get string, ret(%d)", ret);
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ SLOG(LOG_DEBUG, TAG_STTC, "[DBUS-BUXTON2] buxton_value_get_string: engine_default: %s", engine_default);
+
+ if (NULL == engine_id || NULL == engine_default || 0 == strncmp(engine_id, engine_default, strlen(engine_id))) {
+ service_interface = (char*)calloc(strlen(STT_SERVER_SERVICE_INTERFACE) + 1, sizeof(char));
+ if (NULL == service_interface) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Memory allocation Failed!!");
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ snprintf(service_interface, strlen(STT_SERVER_SERVICE_INTERFACE) + 1, "%s", STT_SERVER_SERVICE_INTERFACE);
+ } else {
+ service_interface = (char*)calloc(strlen(STT_SERVER_SERVICE_INTERFACE) + strlen(engine_id) - 8, sizeof(char));
+ if (NULL == service_interface) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Memory allocation Failed!!");
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+ return NULL;
+ }
+ snprintf(service_interface, strlen(STT_SERVER_SERVICE_INTERFACE) + strlen(engine_id) - 8, "%s%s%s", STT_SERVER_SERVICE_INTERFACE, ".", (engine_id + 10));
+ }
+
+ char* ret_char = strchr(service_interface, '-');
+ while (NULL != ret_char) {
+ ret_char[0] = '_';
+ ret_char = strchr(service_interface, '-');
+ }
+
+ buxton_value_free(bux_val);
+ buxton_free_layer(bux_layer);
+ ret = buxton_close(bux_cli);
+
+ bux_cli = NULL;
+ bux_layer = NULL;
+ bux_val = NULL;
+
+ SLOG(LOG_DEBUG, TAG_STTC, "[get_service_interface] FINISH!! service interface: %s", service_interface);
+
+ return service_interface;
+}
+
+
static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
{
if (NULL == g_conn_listener) return ECORE_CALLBACK_RENEW;
dbus_error_free(&err);
}
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set volume : uid(%d), volume(%f)", uid, volume);
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set volume : uid(%d), volume(%f)", uid, volume);
__stt_cb_set_volume(uid, volume);
/* SLOG(LOG_DEBUG, TAG_STTC, "====="); */
SLOG(LOG_DEBUG, TAG_STTC, " ");
} /* STTD_METHOD_ERROR */
+ else if (dbus_message_is_signal(msg, if_name, STTD_METHOD_SPEECH_STATUS)) {
+ SLOG(LOG_DEBUG, TAG_STTC, "===== Speech status");
+ int uid = 0;
+ int status = -1;
+
+ dbus_message_get_args(msg, &err,
+ DBUS_TYPE_INT32, &uid,
+ DBUS_TYPE_INT32, &status,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ }
+
+ if (uid > 0 && status >= 0) {
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt speech status : uid(%d), status(%d)", uid, status);
+ __stt_cb_speech_status(uid, status);
+ } else {
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set status : invalid uid or status");
+ }
+
+ SLOG(LOG_DEBUG, TAG_STTC, "=====");
+ SLOG(LOG_DEBUG, TAG_STTC, " ");
+ } /* STTD_METHOD_SPEECH_STATUS */
+
+ else if (dbus_message_is_signal(msg, "org.freedesktop.DBus", "NameOwnerChanged")) {
+ SLOG(LOG_DEBUG, TAG_STTC, "===== Owner Changed");
+ DBusError err;
+ dbus_error_init(&err);
+
+ /* remove a rule for daemon error */
+ char rule_err[256] = {0, };
+ snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", g_server_service_interface);
+ dbus_bus_remove_match(g_conn_listener, rule_err, &err);
+ dbus_connection_flush(g_conn_listener);
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)", err.message);
+ dbus_error_free(&err);
+ }
+
+ __stt_cb_error(-1, STT_ERROR_SERVICE_RESET, "Daemon Reset");
+ SLOG(LOG_DEBUG, TAG_STTC, "=====");
+ SLOG(LOG_DEBUG, TAG_STTC, " ");
+ } /* NameOwnerChanged */
+
else {
SLOG(LOG_DEBUG, TAG_STTC, "Message is NOT valid");
dbus_message_unref(msg);
return ECORE_CALLBACK_RENEW;
}
+static void __stt_dbus_connection_free()
+{
+ if (NULL != g_conn_listener) {
+ dbus_connection_close(g_conn_listener);
+ dbus_connection_unref(g_conn_listener);
+ g_conn_listener = NULL;
+ }
+ if (NULL != g_conn_sender) {
+ dbus_connection_close(g_conn_sender);
+ dbus_connection_unref(g_conn_sender);
+ g_conn_sender = NULL;
+ }
+}
+
int stt_dbus_open_connection()
{
if (NULL != g_conn_sender && NULL != g_conn_listener) {
dbus_error_init(&err);
/* connect to the DBUS system bus, and check for errors */
- g_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Dbus Connection Error (%s)", err.message);
- dbus_error_free(&err);
+ if (NULL == g_conn_sender) {
+ g_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Dbus Connection Error (%s)", err.message);
+ dbus_error_free(&err);
+ }
}
if (NULL == g_conn_sender) {
dbus_connection_set_exit_on_disconnect(g_conn_sender, false);
/* connect to the DBUS system bus, and check for errors */
- g_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
-
- if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_STTC, "Dbus Connection Error (%s)", err.message);
- dbus_error_free(&err);
+ if (NULL == g_conn_listener) {
+ g_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_STTC, "Dbus Connection Error (%s)", err.message);
+ dbus_error_free(&err);
+ }
}
if (NULL == g_conn_listener) {
SLOG(LOG_ERROR, TAG_STTC, "Fail to get dbus connection");
+ __stt_dbus_connection_free();
return STT_ERROR_OPERATION_FAILED;
}
+ dbus_connection_set_exit_on_disconnect(g_conn_listener, false);
+
int pid = getpid();
char service_name[64];
dbus_bus_request_name(g_conn_listener, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING , &err);
if (dbus_error_is_set(&err)) {
- SLOG(LOG_ERROR, TAG_STTC, "Name Error (%s)", err.message);
- dbus_error_free(&err);
+ SLOG(LOG_ERROR, TAG_STTC, "Name Error (%s)", err.message);
+ dbus_error_free(&err);
}
char rule[128] = {0, };
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)", err.message);
dbus_error_free(&err);
+ __stt_dbus_connection_free();
return STT_ERROR_OPERATION_FAILED;
}
int fd = 0;
if (true != dbus_connection_get_unix_fd(g_conn_listener, &fd)) {
SLOG(LOG_ERROR, TAG_STTC, "Fail to get fd from dbus");
+ __stt_dbus_connection_free();
return STT_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_STTC, "Get fd from dbus : %d", fd);
g_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_event_callback, g_conn_listener, NULL, NULL);
if (NULL == g_fd_handler) {
SLOG(LOG_ERROR, TAG_STTC, "fail to get fd handler from ecore");
+ __stt_dbus_connection_free();
return STT_ERROR_OPERATION_FAILED;
}
dbus_error_free(&err);
}
- dbus_connection_close(g_conn_sender);
- dbus_connection_close(g_conn_listener);
-
- g_conn_sender = NULL;
- g_conn_listener = NULL;
+ __stt_dbus_connection_free();
+ __stt_dbus_service_free();
return 0;
}
int stt_dbus_reconnect()
{
+ if (!g_conn_sender || !g_conn_listener) {
+ stt_dbus_close_connection();
+
+ if (0 != stt_dbus_open_connection()) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to reconnect");
+ return -1;
+ }
+
+ SLOG(LOG_DEBUG, TAG_STTC, "[DBUS] Reconnect");
+ return 0;
+ }
+
bool sender_connected = dbus_connection_get_is_connected(g_conn_sender);
bool listener_connected = dbus_connection_get_is_connected(g_conn_listener);
SLOG(LOG_DEBUG, TAG_STTC, "[DBUS] Sender(%s) Listener(%s)",
return 0;
}
-int stt_dbus_request_hello()
+void __stt_dbus_service_free()
{
- DBusMessage* msg;
-
- msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
- STT_METHOD_HELLO);
-
- if (NULL == msg) {
- SLOG(LOG_ERROR, TAG_STTC, ">>>> Request stt hello : Fail to make message");
- return STT_ERROR_OPERATION_FAILED;
+ if (NULL != g_server_service_name) {
+ free(g_server_service_name);
+ g_server_service_name = NULL;
+ }
+ if (NULL != g_server_service_object) {
+ free(g_server_service_object);
+ g_server_service_object = NULL;
}
+ if (NULL != g_server_service_interface) {
+ free(g_server_service_interface);
+ g_server_service_interface = NULL;
+ }
+}
+
+int stt_dbus_request_hello(int uid)
+{
+ stt_client_s* client = stt_client_get_by_uid(uid);
+ /* Check whether there is any dbus whose name has owner or not */
+ dbus_bool_t is_exist = FALSE;
DBusError err;
dbus_error_init(&err);
+ DBusMessage* msg = NULL;
DBusMessage* result_msg = NULL;
int result = 0;
if (g_conn_sender) {
+ if (NULL != client) {
+ __stt_dbus_service_free();
+
+ if (NULL == client->current_engine_id) {
+ /* Default engine */
+ g_server_service_name = strdup(STT_SERVER_SERVICE_NAME);
+ if (NULL == g_server_service_name) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory");
+ return STT_ERROR_OUT_OF_MEMORY;
+ }
+ g_server_service_object = strdup(STT_SERVER_SERVICE_OBJECT_PATH);
+ if (NULL == g_server_service_name) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory");
+ return STT_ERROR_OUT_OF_MEMORY;
+ }
+ g_server_service_interface = strdup(STT_SERVER_SERVICE_INTERFACE);
+ if (NULL == g_server_service_name) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to allocate memory");
+ return STT_ERROR_OUT_OF_MEMORY;
+ }
+
+ msg = dbus_message_new_method_call(
+ STT_SERVER_SERVICE_NAME,
+ STT_SERVER_SERVICE_OBJECT_PATH,
+ STT_SERVER_SERVICE_INTERFACE,
+ STT_METHOD_HELLO);
+ } else {
+ /* Get service name, object, interface */
+ SLOG(LOG_DEBUG, TAG_STTC, "[DBUS] current_engine_id: %s", client->current_engine_id);
+
+ g_server_service_name = __stt_get_service_name(client->current_engine_id);
+ g_server_service_object = __stt_get_service_object(client->current_engine_id);
+ g_server_service_interface = __stt_get_service_interface(client->current_engine_id);
+
+ if (NULL == g_server_service_name || NULL == g_server_service_object || NULL == g_server_service_interface) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] dbus service info invalid");
+ return STT_ERROR_OPERATION_FAILED;
+ }
+
+ SLOG(LOG_DEBUG, TAG_STTC, "[DBUS] service name: %s, object path: %s, interface: %s", g_server_service_name, g_server_service_object, g_server_service_interface);
+
+ /* Custom engine */
+ is_exist = dbus_bus_name_has_owner(g_conn_sender, g_server_service_name, &err);
+ SLOG(LOG_DEBUG, TAG_STTC, "[DBUS] is there dbus name has owner??: %s (g_server_service_name: %s)", (is_exist == TRUE) ? "True" : "False", g_server_service_name);
+
+ if (TRUE == is_exist) {
+ SLOG(LOG_DEBUG, TAG_STTC, "[DBUS] dbus: is_exist: True");
+ msg = dbus_message_new_method_call(
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_HELLO);
+ } else {
+ SLOG(LOG_DEBUG, TAG_STTC, "[DBUS] dbus: is_exist: False");
+ msg = dbus_message_new_method_call(
+ STT_SERVER_CUSTOM_SERVICE_NAME,
+ STT_SERVER_CUSTOM_SERVICE_OBJECT_PATH,
+ STT_SERVER_CUSTOM_SERVICE_INTERFACE,
+ STT_METHOD_HELLO);
+ }
+ }
+ }
+ }
+
+ if (NULL == msg) {
+// SLOG(LOG_ERROR, TAG_STTC, ">>>> Request stt hello : Fail to make message");
+ result = stt_dbus_reconnect();
+ if (0 != result)
+ return STT_ERROR_OPERATION_FAILED;
+ }
+
+ if (g_conn_sender) {
result_msg = dbus_connection_send_with_reply_and_block(g_conn_sender, msg, g_waiting_short_time, &err);
dbus_message_unref(msg);
if (dbus_error_is_set(&err)) {
SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt hello");
} else {
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ }
+
result = STT_ERROR_TIMED_OUT;
}
} else {
SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender);
+ stt_dbus_reconnect();
result = STT_ERROR_OPERATION_FAILED;
}
}
-int stt_dbus_request_initialize(int uid, bool* silence_supported)
+int stt_dbus_request_initialize(int uid, bool* silence_supported, bool* credential_needed)
{
DBusMessage* msg;
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
STT_METHOD_INITIALIZE);
if (NULL == msg) {
}
if (NULL != result_msg) {
+ int int_silence_supported = 0;
+ int int_credential_needed = 0;
dbus_message_get_args(result_msg, &err,
DBUS_TYPE_INT32, &result,
- DBUS_TYPE_INT32, silence_supported,
+ DBUS_TYPE_INT32, &int_silence_supported,
+ DBUS_TYPE_INT32, &int_credential_needed,
DBUS_TYPE_INVALID);
+ *silence_supported = (bool)(int_silence_supported);
+ *credential_needed = (bool)(int_credential_needed);
+
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
dbus_error_free(&err);
}
if (0 == result) {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d, silence(%d)",
- result, *silence_supported);
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt initialize : result = %d, silence(%d), credential(%d)",
+ result, *silence_supported, *credential_needed);
+
+ /* add a rule for daemon error */
+ char rule_err[256] = {0, };
+ snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", g_server_service_interface);
+ dbus_bus_add_match(g_conn_listener, rule_err, &err);
+ dbus_connection_flush(g_conn_listener);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)", err.message);
+ dbus_error_free(&err);
+ return STT_ERROR_OPERATION_FAILED;
+ }
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< stt initialize : result = %d", result);
}
{
DBusMessage* msg;
+ DBusError err;
+ dbus_error_init(&err);
+
+ /* remove a rule for daemon error */
+ char rule_err[256] = {0, };
+ snprintf(rule_err, 256, "sender='org.freedesktop.DBus',path='/org/freedesktop/DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',type='signal',arg0='%s'", g_server_service_interface);
+ dbus_bus_remove_match(g_conn_listener, rule_err, &err);
+ dbus_connection_flush(g_conn_listener);
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_STTC, "Match Error (%s)", err.message);
+ dbus_error_free(&err);
+ }
+
+ SLOG(LOG_DEBUG, TAG_STTC, "[dbus_info] service name: %s, service object: %s, service interface: %s", g_server_service_name, g_server_service_object, g_server_service_interface);
+
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
STT_METHOD_FINALIZE);
if (NULL == msg) {
dbus_message_append_args(msg, DBUS_TYPE_INT32, &uid, DBUS_TYPE_INVALID);
- DBusError err;
- dbus_error_init(&err);
-
DBusMessage* result_msg;
int result = STT_ERROR_OPERATION_FAILED;
return result;
}
-int stt_dbus_request_set_current_engine(int uid, const char* engine_id, bool* silence_supported)
+int stt_dbus_request_set_current_engine(int uid, const char* engine_id, bool* silence_supported, bool* credential_needed)
{
DBusMessage* msg;
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
STT_METHOD_SET_CURRENT_ENGINE);
+
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set engine : Fail to make message");
return STT_ERROR_OPERATION_FAILED;
} else {
- SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set engine : uid(%d)", uid);
+ SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set engine : uid(%d), engine_id(%s)", uid, (NULL == engine_id) ? "NULL" : engine_id);
}
dbus_message_append_args(msg,
}
if (NULL != result_msg) {
+ int int_silence_supported = 0;
+ int int_credential_needed = 0;
+
dbus_message_get_args(result_msg, &err,
DBUS_TYPE_INT32, &result,
- DBUS_TYPE_INT32, silence_supported,
+ DBUS_TYPE_INT32, &int_silence_supported,
+ DBUS_TYPE_INT32, &int_credential_needed,
DBUS_TYPE_INVALID);
+ *silence_supported = (bool)(int_silence_supported);
+ *credential_needed = (bool)(int_credential_needed);
+
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
- dbus_error_free(&err);
+ dbus_error_free(&err);
result = STT_ERROR_OPERATION_FAILED;
}
dbus_message_unref(result_msg);
if (0 == result) {
- SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set engine : result = %d , silence(%d)",
- result, *silence_supported);
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set engine : result = %d , silence(%d), credential(%d)",
+ result, *silence_supported, *credential_needed);
} else {
SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set engine : result = %d", result);
}
DBusMessage* msg;
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
STT_METHOD_CHECK_APP_AGREED);
if (NULL == msg) {
DBusMessage* msg;
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
STT_METHOD_GET_SUPPORT_LANGS);
if (NULL == msg) {
DBusMessage* msg;
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
STT_METHOD_GET_CURRENT_LANG);
if (NULL == msg) {
return result;
}
+int stt_dbus_request_set_private_data(int uid, const char* key, const char* data)
+{
+ if (NULL == key || NULL == data) {
+ SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
+ return STT_ERROR_INVALID_PARAMETER;
+ }
+
+ DBusMessage* msg;
+
+ msg = dbus_message_new_method_call(
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_SET_PRIVATE_DATA);
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set private data : Fail to make message");
+ return STT_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt set private data : uid(%d)", uid);
+ }
+
+ if (true != dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &uid,
+ DBUS_TYPE_STRING, &key,
+ DBUS_TYPE_STRING, &data,
+ DBUS_TYPE_INVALID)) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to append args");
+ return STT_ERROR_OPERATION_FAILED;
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ DBusMessage* result_msg;
+ int result = STT_ERROR_OPERATION_FAILED;
+
+ 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_STTC, "[ERROR] Send Error (%s)", err.message);
+ 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_STTC, "<<<< Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ result = STT_ERROR_OPERATION_FAILED;
+ }
+ dbus_message_unref(result_msg);
+
+ if (0 == result) {
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt set private data : result = %d", result);
+ } else {
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< stt set private data : result = %d", result);
+ }
+ } else {
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+ stt_dbus_reconnect();
+ result = STT_ERROR_TIMED_OUT;
+ }
+
+ return result;
+}
+
+int stt_dbus_request_get_private_data(int uid, const char* key, char** data)
+{
+ if (NULL == key || NULL == data) {
+ SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
+ return STT_ERROR_INVALID_PARAMETER;
+ }
+
+ DBusMessage* msg;
+
+ msg = dbus_message_new_method_call(
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_GET_PRIVATE_DATA);
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_STTC, ">>>> stt get private data : Fail to make message");
+ return STT_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt get private data : uid(%d)", uid);
+ }
+
+ if (true != dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &uid,
+ DBUS_TYPE_STRING, &key,
+ DBUS_TYPE_INVALID)) {
+ SLOG(LOG_ERROR, TAG_STTC, "[ERROR] Fail to append args");
+ return STT_ERROR_OPERATION_FAILED;
+ }
+
+ DBusError err;
+ dbus_error_init(&err);
+
+ DBusMessage* result_msg;
+ int result = STT_ERROR_OPERATION_FAILED;
+
+ 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_STTC, "[ERROR] Send Error (%s)", err.message);
+ dbus_error_free(&err);
+ }
+
+ char* temp = NULL;
+ if (NULL != result_msg) {
+ dbus_message_get_args(result_msg, &err,
+ DBUS_TYPE_INT32, &result,
+ DBUS_TYPE_STRING, &temp,
+ DBUS_TYPE_INVALID);
+
+ if (dbus_error_is_set(&err)) {
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< Get arguments error (%s)", err.message);
+ dbus_error_free(&err);
+ result = STT_ERROR_OPERATION_FAILED;
+ }
+ dbus_message_unref(result_msg);
+
+ if (0 == result) {
+ SLOG(LOG_DEBUG, TAG_STTC, "<<<< stt get private data : result = %d", result);
+ if (NULL != temp) {
+ *data = strdup(temp);
+ }
+ } else {
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< stt get private data : result = %d", result);
+ }
+ } else {
+ SLOG(LOG_ERROR, TAG_STTC, "<<<< Result message is NULL");
+ stt_dbus_reconnect();
+ result = STT_ERROR_TIMED_OUT;
+ }
+
+ return result;
+}
+
+
+
int stt_dbus_request_is_recognition_type_supported(int uid, const char* type, bool* support)
{
if (NULL == support || NULL == type) {
DBusMessage* msg;
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
- STT_METHOD_IS_TYPE_SUPPORTED);
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_IS_TYPE_SUPPORTED);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> stt is partial result supported : Fail to make message");
DBusMessage* msg;
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
- STT_METHOD_SET_START_SOUND);
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_SET_START_SOUND);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set start sound : Fail to make message");
DBusMessage* msg;
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
- STT_METHOD_UNSET_START_SOUND);
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_UNSET_START_SOUND);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset start sound : Fail to make message");
DBusMessage* msg;
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
- STT_METHOD_SET_STOP_SOUND);
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_SET_STOP_SOUND);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> stt set stop sound : Fail to make message");
DBusMessage* msg;
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
- STT_METHOD_UNSET_STOP_SOUND);
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_UNSET_STOP_SOUND);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> stt unset stop sound : Fail to make message");
return result;
}
-int stt_dbus_request_start(int uid, const char* lang, const char* type, int silence, const char* appid)
+int stt_dbus_request_start(int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential)
{
if (NULL == lang || NULL == type || NULL == appid) {
SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
/* create a signal & check for errors */
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
- STT_METHOD_START);
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_START);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> stt start : Fail to make message");
SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start : uid(%d), language(%s), type(%s)", uid, lang, type);
}
+ char *temp = NULL;
+ if (NULL == credential) {
+ temp = strdup("NULL");
+ } else {
+ temp = strdup(credential);
+ }
+
dbus_message_append_args(msg,
DBUS_TYPE_INT32, &uid,
DBUS_TYPE_STRING, &lang,
DBUS_TYPE_STRING, &type,
DBUS_TYPE_INT32, &silence,
DBUS_TYPE_STRING, &appid,
+ DBUS_TYPE_STRING, &temp,
DBUS_TYPE_INVALID);
#if 1
if (g_conn_sender) {
if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
SLOG(LOG_ERROR, TAG_STTC, "[Dbus ERROR] <<<< stt start message : Out Of Memory !");
+ if (NULL != temp) {
+ free(temp);
+ temp = NULL;
+ }
return STT_ERROR_OUT_OF_MEMORY;
} else {
dbus_connection_flush(g_conn_sender);
} else {
SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender);
+ if (NULL != temp) {
+ free(temp);
+ temp = NULL;
+ }
return STT_ERROR_OPERATION_FAILED;
}
+ if (NULL != temp) {
+ free(temp);
+ temp = NULL;
+ }
return 0;
#else
DBusError err;
/* create a signal & check for errors */
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH,
- STT_SERVER_SERVICE_INTERFACE,
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
STT_METHOD_STOP);
if (NULL == msg) {
/* create a signal & check for errors */
msg = dbus_message_new_method_call(
- STT_SERVER_SERVICE_NAME,
- STT_SERVER_SERVICE_OBJECT_PATH, /* object name of the signal */
- STT_SERVER_SERVICE_INTERFACE, /* interface name of the signal */
- STT_METHOD_CANCEL); /* name of the signal */
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_CANCEL);
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_STTC, ">>>> stt cancel : Fail to make message");
return result;
#endif
}
+
+int stt_dbus_request_start_file(int uid, const char* lang, const char* type, int silence, const char* appid, const char* credential, const char* filepath, stt_audio_type_e audio_type, int sample_rate)
+{
+ if (NULL == lang || NULL == type || NULL == appid) {
+ SLOG(LOG_ERROR, TAG_STTC, "Input parameter is NULL");
+ return STT_ERROR_INVALID_PARAMETER;
+ }
+
+ DBusMessage* msg;
+
+ /* create a signal & check for errors */
+ msg = dbus_message_new_method_call(
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_START_FILE);
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_STTC, ">>>> stt start file : Fail to make message");
+ return STT_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt start file : uid(%d), language(%s), type(%s), appid(%s), filepath(%s), audio_type(%d), sample_rate(%d)", uid, lang, type, appid, filepath, audio_type, sample_rate);
+ }
+
+ char *temp = NULL;
+ if (NULL == credential) {
+ temp = strdup("NULL");
+ } else {
+ temp = strdup(credential);
+ }
+
+ dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &uid,
+ DBUS_TYPE_STRING, &lang,
+ DBUS_TYPE_STRING, &type,
+ DBUS_TYPE_INT32, &silence,
+ DBUS_TYPE_STRING, &appid,
+ DBUS_TYPE_STRING, &temp,
+ DBUS_TYPE_STRING, &filepath,
+ DBUS_TYPE_INT32, &audio_type,
+ DBUS_TYPE_INT32, &sample_rate,
+ DBUS_TYPE_INVALID);
+ if (g_conn_sender) {
+ dbus_message_set_no_reply(msg, TRUE);
+
+ if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
+ SLOG(LOG_ERROR, TAG_STTC, "[Dbus ERROR] <<<< stt start message : Out Of Memory !");
+ if (NULL != temp) {
+ free(temp);
+ temp = NULL;
+ }
+ return STT_ERROR_OUT_OF_MEMORY;
+ } else {
+ dbus_connection_flush(g_conn_sender);
+ }
+
+ dbus_message_unref(msg);
+
+ } else {
+ SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender);
+ if (NULL != temp) {
+ free(temp);
+ temp = NULL;
+ }
+ return STT_ERROR_OPERATION_FAILED;
+ }
+
+ if (NULL != temp) {
+ free(temp);
+ temp = NULL;
+ }
+ return 0;
+}
+
+int stt_dbus_request_cancel_file(int uid)
+{
+ DBusMessage* msg;
+
+ /* create a signal & check for errors */
+ msg = dbus_message_new_method_call(
+ g_server_service_name,
+ g_server_service_object,
+ g_server_service_interface,
+ STT_METHOD_CANCEL_FILE);
+
+ if (NULL == msg) {
+ SLOG(LOG_ERROR, TAG_STTC, ">>>> stt cancel file : Fail to make message");
+ return STT_ERROR_OPERATION_FAILED;
+ } else {
+ SLOG(LOG_DEBUG, TAG_STTC, ">>>> stt cancel file : uid(%d)", uid);
+ }
+
+ dbus_message_append_args(msg,
+ DBUS_TYPE_INT32, &uid,
+ DBUS_TYPE_INVALID);
+
+ if (g_conn_sender) {
+ dbus_message_set_no_reply(msg, TRUE);
+
+ if (!dbus_connection_send(g_conn_sender, msg, NULL)) {
+ SLOG(LOG_ERROR, TAG_STTC, "[Dbus ERROR] <<<< stt stop message : Out Of Memory !");
+ return STT_ERROR_OUT_OF_MEMORY;
+ } else {
+ dbus_connection_flush(g_conn_sender);
+ }
+
+ dbus_message_unref(msg);
+ } else {
+ SLOG(LOG_WARN, TAG_STTC, "[WARN] dbus connection handle is null (%p)", g_conn_sender);
+ return STT_ERROR_OPERATION_FAILED;
+ }
+
+ return 0;
+}
+