Fix unintended recording cancel by changing language 67/149767/4
authorSuyeon Hwang <stom.hwang@samsung.com>
Wed, 13 Sep 2017 05:15:10 +0000 (14:15 +0900)
committerSuyeon Hwang <stom.hwang@samsung.com>
Fri, 15 Sep 2017 01:33:32 +0000 (10:33 +0900)
Change-Id: Ib0c14671d7e57ed9e0aad208a3ec2a29dda2460e
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
14 files changed:
client/CMakeLists.txt
client/vc_dbus.c
client/vc_dbus.h
client/vc_setting.c [changed mode: 0644->0755]
client/vc_setting_dbus.c [new file with mode: 0755]
client/vc_setting_dbus.h [new file with mode: 0755]
common/vc_defs.h [changed mode: 0644->0755]
server/vcd_config.c [changed mode: 0644->0755]
server/vcd_config.h [changed mode: 0644->0755]
server/vcd_dbus.c [changed mode: 0644->0755]
server/vcd_dbus_server.c [changed mode: 0644->0755]
server/vcd_dbus_server.h
server/vcd_server.c [changed mode: 0644->0755]
server/vcd_server.h

index 0103780bbc90d0c65889c2cb40a23320acf2c7b2..074d790c9b485815cd5591ab2e71c1ff822807ae 100644 (file)
@@ -11,6 +11,7 @@ SET(SRCS
 )
 
 SET(SETTING_SRCS
+       vc_setting_dbus.c
        vc_setting.c
        ../common/vc_config_mgr.c
        ../common/vc_config_parser.c
index 6bbfdf0528481815dc9cd607710ce3e854414ac3..245ea13d4f13eaee00864842fd41c3e173621f67 100644 (file)
@@ -14,8 +14,7 @@
 * limitations under the License.
 */
 
-
-#include "vc_client.h"
+#include "vc_command.h"
 #include "vc_dbus.h"
 #include "vc_main.h"
 
@@ -1571,4 +1570,4 @@ int vc_dbus_request_auth_cancel(int pid, int mgr_pid)
        }
 
        return result;
-}
+}
\ No newline at end of file
index a3fd99663fd668bac6db944bb073fb036487588b..b5db90b7d5fe12b7af7fed897c272f7db41a2aad 100644 (file)
@@ -65,7 +65,6 @@ int vc_dbus_request_auth_stop(int pid, int mgr_pid);
 
 int vc_dbus_request_auth_cancel(int pid, int mgr_pid);
 
-
 #ifdef __cplusplus
 }
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index 82826a0..8fe5496
@@ -17,6 +17,7 @@
 
 #include "vc_config_mgr.h"
 #include "vc_main.h"
+#include "vc_setting_dbus.h"
 #include "voice_control_common.h"
 #include "voice_control_setting.h"
 
@@ -202,7 +203,22 @@ int vc_setting_set_language(const char* language)
        if (0 != ret) {
                SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Result : %d", ret);
        } else {
-               SLOG(LOG_DEBUG, TAG_VCS, "[SUCCESS] Set default language");
+               if (0 != vc_setting_dbus_open_connection()) {
+                       SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to open connection");
+                       return VC_ERROR_OPERATION_FAILED;
+               }
+
+               if (0 != vc_setting_dbus_request_hello()) {
+                       SLOG(LOG_DEBUG, TAG_VCS, "[DEBUG] Daemon is not available");
+               } else {
+                       ret = vc_setting_dbus_request_set_language(getpid(), language);
+                       SLOG(LOG_DEBUG, TAG_VCS, "[DEBUG] Set default language (%d)", ret);
+               }
+
+               if (0 != vc_setting_dbus_close_connection()) {
+                       SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to close connection");
+                       return VC_ERROR_OPERATION_FAILED;
+               }
        }
 
        SLOG(LOG_DEBUG, TAG_VCS, "@@@");
diff --git a/client/vc_setting_dbus.c b/client/vc_setting_dbus.c
new file mode 100755 (executable)
index 0000000..7f6b7d8
--- /dev/null
@@ -0,0 +1,381 @@
+/*
+* Copyright (c) 2017 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_setting_dbus.h"
+#include "vc_main.h"
+
+
+static int g_s_waiting_time = 3000;
+
+static Ecore_Fd_Handler* g_s_fd_handler = NULL;
+
+static DBusConnection* g_s_conn_sender = NULL;
+static DBusConnection* g_s_conn_listener = NULL;
+
+
+static Eina_Bool listener_setting_event_callback(void* data, Ecore_Fd_Handler *fd_handler)
+{
+       if (NULL == g_s_conn_listener)  return ECORE_CALLBACK_RENEW;
+
+       dbus_connection_read_write_dispatch(g_s_conn_listener, 50);
+
+       while (1) {
+               DBusMessage* msg = NULL;
+               msg = dbus_connection_pop_message(g_s_conn_listener);
+
+               /* loop again if we haven't read a message */
+               if (NULL == msg) {
+                       break;
+               }
+
+               DBusError err;
+               dbus_error_init(&err);
+
+               char if_name[64] = {0, };
+               snprintf(if_name, 64, "%s", VC_SETTING_SERVICE_INTERFACE);
+
+               if (dbus_message_is_method_call(msg, if_name, VCD_METHOD_HELLO)) {
+                       SLOG(LOG_DEBUG, TAG_VCS, "@@@ Get Hello");
+                       int pid = 0;
+                       int response = -1;
+
+                       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_INVALID);
+
+                       if (dbus_error_is_set(&err)) {
+                               SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus Error (%s)", err.message);
+                               dbus_error_free(&err);
+                       }
+
+                       if (pid > 0) {
+                               SLOG(LOG_DEBUG, TAG_VCS, "@@ vc get hello : pid(%d) ", pid);
+                               response = 1;
+                       } else {
+                               SLOG(LOG_ERROR, TAG_VCS, "@@ vc get hello : invalid pid ");
+                       }
+
+                       DBusMessage* reply = NULL;
+                       reply = dbus_message_new_method_return(msg);
+
+                       if (NULL != reply) {
+                               dbus_message_append_args(reply, DBUS_TYPE_INT32, &response, DBUS_TYPE_INVALID);
+
+                               if (!dbus_connection_send(g_s_conn_listener, reply, NULL))
+                                       SLOG(LOG_ERROR, TAG_VCS, "@@ vc get hello : fail to send reply");
+                               else
+                                       SLOG(LOG_DEBUG, TAG_VCS, "@@ vc get hello : result(%d)", response);
+
+                               dbus_connection_flush(g_s_conn_listener);
+                               dbus_message_unref(reply);
+                       } else {
+                               SLOG(LOG_ERROR, TAG_VCS, "@@ vc get hello : fail to create reply message");
+                       }
+
+                       SLOG(LOG_DEBUG, TAG_VCS, "@@@");
+               } /* VCD_METHOD_HELLO */
+
+               else {
+                       SLOG(LOG_DEBUG, TAG_VCS, "Message is NOT valid");
+                       dbus_message_unref(msg);
+                       break;
+               }
+
+               /* free the message */
+               dbus_message_unref(msg);
+       } /* while(1) */
+
+       return ECORE_CALLBACK_PASS_ON;
+}
+
+static void __vc_setting_dbus_connection_free()
+{
+       if (NULL != g_s_conn_listener) {
+               dbus_connection_close(g_s_conn_listener);
+               dbus_connection_unref(g_s_conn_listener);
+               g_s_conn_listener = NULL;
+       }
+       if (NULL != g_s_conn_sender) {
+               dbus_connection_close(g_s_conn_sender);
+               dbus_connection_unref(g_s_conn_sender);
+               g_s_conn_sender = NULL;
+       }
+}
+
+int vc_setting_dbus_open_connection()
+{
+       if (NULL != g_s_conn_sender && NULL != g_s_conn_listener) {
+               SLOG(LOG_WARN, TAG_VCS, "already existed connection ");
+               return 0;
+       }
+
+       DBusError err;
+       int ret;
+
+       /* initialise the error value */
+       dbus_error_init(&err);
+
+       /* connect to the DBUS system bus, and check for errors */
+       g_s_conn_sender = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCS, "Dbus Connection Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
+
+       if (NULL == g_s_conn_sender) {
+               SLOG(LOG_ERROR, TAG_VCS, "Fail to get dbus connection ");
+               return VC_ERROR_OPERATION_FAILED;
+       }
+
+       g_s_conn_listener = dbus_bus_get_private(DBUS_BUS_SESSION, &err);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCS, "Dbus Connection Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
+
+       if (NULL == g_s_conn_listener) {
+               SLOG(LOG_ERROR, TAG_VCS, "Fail to get dbus connection ");
+               __vc_setting_dbus_connection_free();
+               return VC_ERROR_OPERATION_FAILED;
+       }
+
+       int pid = getpid();
+
+       char service_name[64];
+       memset(service_name, '\0', 64);
+       snprintf(service_name, 64, "%s%d", VC_SETTING_SERVICE_NAME, pid);
+
+       SLOG(LOG_DEBUG, TAG_VCS, "service name is %s", service_name);
+
+       /* register our name on the bus, and check for errors */
+       ret = dbus_bus_request_name(g_s_conn_listener, service_name, DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCS, "Name Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
+
+       if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
+               SLOG(LOG_ERROR, TAG_VCS, "fail dbus_bus_request_name()");
+               __vc_setting_dbus_connection_free();
+               return -2;
+       }
+
+       if (NULL != g_s_fd_handler) {
+               SLOG(LOG_WARN, TAG_VCS, "The handler already exists.");
+               __vc_setting_dbus_connection_free();
+               return 0;
+       }
+
+       char rule[128] = {0, };
+       snprintf(rule, 128, "type='signal',interface='%s'", VC_SETTING_SERVICE_INTERFACE);
+
+       /* add a rule for which messages we want to see */
+       dbus_bus_add_match(g_s_conn_listener, rule, &err);
+       dbus_connection_flush(g_s_conn_listener);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCS, "Match Error (%s)", err.message);
+               dbus_error_free(&err);
+               __vc_setting_dbus_connection_free();
+               return VC_ERROR_OPERATION_FAILED;
+       }
+
+       int fd = 0;
+       if (1 != dbus_connection_get_unix_fd(g_s_conn_listener, &fd)) {
+               SLOG(LOG_ERROR, TAG_VCS, "fail to get fd from dbus ");
+               __vc_setting_dbus_connection_free();
+               return VC_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCS, "Get fd from dbus : %d", fd);
+       }
+
+       g_s_fd_handler = ecore_main_fd_handler_add(fd, ECORE_FD_READ, (Ecore_Fd_Cb)listener_setting_event_callback, g_s_conn_listener, NULL, NULL);
+       if (NULL == g_s_fd_handler) {
+               SLOG(LOG_ERROR, TAG_VCS, "fail to get fd handler from ecore ");
+               __vc_setting_dbus_connection_free();
+               return VC_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
+int vc_setting_dbus_close_connection()
+{
+       DBusError err;
+       dbus_error_init(&err);
+
+       if (NULL != g_s_fd_handler) {
+               ecore_main_fd_handler_del(g_s_fd_handler);
+               g_s_fd_handler = NULL;
+       }
+
+       int pid = getpid();
+
+       char service_name[64];
+       memset(service_name, '\0', 64);
+       snprintf(service_name, 64, "%s%d", VC_SETTING_SERVICE_NAME, pid);
+
+       dbus_bus_release_name(g_s_conn_listener, service_name, &err);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
+
+       __vc_setting_dbus_connection_free();
+
+       return 0;
+}
+
+int vc_setting_dbus_reconnect()
+{
+       if (!g_s_conn_sender || !g_s_conn_listener) {
+               vc_setting_dbus_close_connection();
+
+               if (0 != vc_setting_dbus_open_connection()) {
+                       SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to reconnect");
+                       return -1;
+               }
+
+               SLOG(LOG_DEBUG, TAG_VCS, "[DBUS] Reconnect");
+               return 0;
+       }
+
+       bool sender_connected = dbus_connection_get_is_connected(g_s_conn_sender);
+       bool listener_connected = dbus_connection_get_is_connected(g_s_conn_listener);
+       SLOG(LOG_WARN, TAG_VCS, "[DBUS] Sender(%s) Listener(%s)",
+                sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected");
+
+       if (false == sender_connected || false == listener_connected) {
+               vc_setting_dbus_close_connection();
+
+               if (0 != vc_setting_dbus_open_connection()) {
+                       SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Fail to reconnect");
+                       return -1;
+               }
+
+               SLOG(LOG_DEBUG, TAG_VCS, "[DBUS] Reconnect");
+       }
+
+       return 0;
+}
+
+int vc_setting_dbus_request_hello()
+{
+       if (NULL == g_s_conn_sender) {
+               return VC_ERROR_OPERATION_FAILED;
+       }
+
+       DBusMessage* msg;
+
+       msg = dbus_message_new_method_call(
+                         VC_SERVER_SERVICE_NAME,
+                         VC_SERVER_SERVICE_OBJECT_PATH,
+                         VC_SERVER_SERVICE_INTERFACE,
+                         VC_METHOD_HELLO);
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, TAG_VCS, "@@ Request vc hello : Fail to make message");
+               return VC_ERROR_OPERATION_FAILED;
+       }
+
+       DBusError err;
+       dbus_error_init(&err);
+
+       DBusMessage* result_msg = NULL;
+       int result = 0;
+
+       result_msg = dbus_connection_send_with_reply_and_block(g_s_conn_sender, msg, 500, &err);
+
+       if (dbus_error_is_set(&err)) {
+               dbus_error_free(&err);
+       }
+
+       dbus_message_unref(msg);
+
+       if (NULL != result_msg) {
+               dbus_message_unref(result_msg);
+               result = 0;
+       } else {
+               result = VC_ERROR_TIMED_OUT;
+       }
+
+       return result;
+}
+
+int vc_setting_dbus_request_set_language(int pid, const char* language)
+{
+       if (NULL == g_s_conn_sender) {
+               SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus does not open");
+               return VC_ERROR_OPERATION_FAILED;
+       }
+
+       DBusMessage* msg;
+
+       msg = dbus_message_new_method_call(
+                         VC_SERVER_SERVICE_NAME,
+                         VC_SERVER_SERVICE_OBJECT_PATH,
+                         VC_SERVER_SERVICE_INTERFACE,
+                         VC_SETTING_METHOD_SET_LANGUAGE);
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, TAG_VCS, "@@ vc set language : Fail to make message");
+               return VC_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCS, "@@ vc set language : pid(%d)", pid);
+       }
+
+       dbus_message_append_args(msg,
+                                                        DBUS_TYPE_INT32, &pid,
+                                                        DBUS_TYPE_STRING, &language,
+                                                        DBUS_TYPE_INVALID);
+
+       DBusError err;
+       dbus_error_init(&err);
+
+       DBusMessage* result_msg;
+       int result = VC_ERROR_OPERATION_FAILED;
+
+       result_msg = dbus_connection_send_with_reply_and_block(g_s_conn_sender, msg, g_s_waiting_time, &err);
+       dbus_message_unref(msg);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCS, "[ERROR] Dbus 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_VCS, "@@ Get arguments error (%s)", err.message);
+                       dbus_error_free(&err);
+                       result = VC_ERROR_OPERATION_FAILED;
+               }
+               dbus_message_unref(result_msg);
+
+               SLOG(LOG_DEBUG, TAG_VCS, "@@ vcd set language : result = %d", result);
+       } else {
+               SLOG(LOG_ERROR, TAG_VCS, "@@ Result message is NULL");
+               vc_setting_dbus_reconnect();
+               result = VC_ERROR_TIMED_OUT;
+       }
+
+       return result;
+}
\ No newline at end of file
diff --git a/client/vc_setting_dbus.h b/client/vc_setting_dbus.h
new file mode 100755 (executable)
index 0000000..3404d4f
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+* Copyright (c) 2017 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_SETTING_DBUS_H_
+#define __VC_SETTING_DBUS_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int vc_setting_dbus_open_connection();
+
+int vc_setting_dbus_close_connection();
+
+int vc_setting_dbus_request_hello();
+
+int vc_setting_dbus_request_set_language(int pid, const char* language);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __VC_SETTING_DBUS_H_ */
old mode 100644 (file)
new mode 100755 (executable)
index 60e0aa4..31d4725
@@ -45,6 +45,9 @@ extern "C" {
 #define VC_SERVER_SERVICE_OBJECT_PATH  "/org/tizen/voice/vcserver"
 #define VC_SERVER_SERVICE_INTERFACE    "org.tizen.voice.vcserver"
 
+#define VC_SETTING_SERVICE_NAME         "org.tizen.voice.vcsetting"
+#define VC_SETTING_SERVICE_OBJECT_PATH  "/org/tize/voice/vcsetting"
+#define VC_SETTING_SERVICE_INTERFACE    "org.tizen.voice.vcsetting"
 
 /******************************************************************************************
 * Message Definition for all
@@ -154,6 +157,13 @@ extern "C" {
 
 
 
+/******************************************************************************************
+* Message Definitions for setting
+*******************************************************************************************/
+
+#define VC_SETTING_METHOD_SET_LANGUAGE         "vc_setting_method_set_language"
+
+
 /******************************************************************************************
 * Definitions for configuration
 *******************************************************************************************/
old mode 100644 (file)
new mode 100755 (executable)
index 287ba23..8d707b7
@@ -41,10 +41,12 @@ static int g_enabled_command_type[COMMAND_TYPE_MAX] = {
 
 void __vcd_config_lang_changed_cb(const char* before_lang, const char* current_lang)
 {
-       if (NULL != g_lang_cb)
-               g_lang_cb(current_lang, g_user_data);
-       else
-               SLOG(LOG_ERROR, TAG_VCD, "Language changed callback is NULL");
+       if (NULL != before_lang && NULL != current_lang && strncmp(before_lang, current_lang, strlen(before_lang))) {
+               if (NULL != g_lang_cb)
+                       g_lang_cb(current_lang, g_user_data);
+               else
+                       SLOG(LOG_ERROR, TAG_VCD, "Language changed callback is NULL");
+       }
 }
 
 
@@ -107,6 +109,19 @@ int vcd_config_get_default_language(char** language)
        return 0;
 }
 
+int vcd_config_set_default_language(const char* language)
+{
+       if (NULL == language)
+               return VCD_ERROR_INVALID_PARAMETER;
+
+       if (0 != vc_config_mgr_set_default_language(language)) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Config ERROR] Fail to get language");
+               return VCD_ERROR_OPERATION_FAILED;
+       }
+
+       return 0;
+}
+
 int vcd_config_set_service_state(vcd_state_e state)
 {
        g_state = state;
old mode 100644 (file)
new mode 100755 (executable)
index 047d6d6..de6589d
@@ -35,6 +35,8 @@ int vcd_config_finalize();
 
 int vcd_config_get_default_language(char** language);
 
+int vcd_config_set_default_language(const char* language);
+
 int vcd_config_set_service_state(vcd_state_e state);
 
 vcd_state_e vcd_config_get_service_state();
old mode 100644 (file)
new mode 100755 (executable)
index 186abf4..3493459
@@ -1053,6 +1053,9 @@ static Eina_Bool listener_event_callback(void* data, Ecore_Fd_Handler *fd_handle
                else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_WIDGET_METHOD_ENABLE_ASR_RESULT))
                        vcd_dbus_server_widget_enable_asr_result(g_conn_listener, msg);
 
+               else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_SETTING_METHOD_SET_LANGUAGE))
+                       vcd_dbus_server_set_language(g_conn_listener, msg);
+
                else {
                        SLOG(LOG_DEBUG, TAG_VCD, "Message is NOT valid");
                        dbus_message_unref(msg);
old mode 100644 (file)
new mode 100755 (executable)
index 5a72d01..6a6a15d
@@ -1944,3 +1944,51 @@ int vcd_dbus_server_widget_enable_asr_result(DBusConnection* conn, DBusMessage*
 
        return 0;
 }
+
+int vcd_dbus_server_set_language(DBusConnection* conn, DBusMessage* msg)
+{
+       DBusError err;
+       dbus_error_init(&err);
+
+       int pid;
+       char* language;
+       int ret = VCD_ERROR_OPERATION_FAILED;
+       dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &pid, DBUS_TYPE_STRING, &language, DBUS_TYPE_INVALID);
+
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@ VCD server set language");
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd server set language : get arguments error (%s)", err.message);
+               dbus_error_free(&err);
+               ret = VCD_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd server set language : language(%s)", language);
+               ret = vcd_server_set_language(language);
+       }
+
+       DBusMessage* reply;
+       reply = dbus_message_new_method_return(msg);
+
+       if (NULL != reply) {
+               dbus_message_append_args(reply, DBUS_TYPE_INT32, &ret, DBUS_TYPE_INVALID);
+
+               if (0 == ret) {
+                       SLOG(LOG_DEBUG, TAG_VCD, "[OUT SUCCESS] Result(%d)", ret);
+               } else {
+                       SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Result(%d)", ret);
+               }
+
+               if (!dbus_connection_send(conn, reply, NULL)) {
+                       SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Out Of Memory!");
+               }
+
+               dbus_connection_flush(conn);
+               dbus_message_unref(reply);
+       } else {
+               SLOG(LOG_ERROR, TAG_VCD, "[OUT ERROR] Fail to create reply message!!");
+       }
+
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@");
+
+       return 0;
+}
\ No newline at end of file
index 626d4150e578251969c210d169b4012adf96f3b6..caa87dff99ef5459d40f04b8f03d1f5550f816fe 100644 (file)
@@ -114,6 +114,8 @@ int vcd_dbus_server_widget_cancel(DBusConnection* conn, DBusMessage* msg);
 
 int vcd_dbus_server_widget_enable_asr_result(DBusConnection* conn, DBusMessage* msg);
 
+int vcd_dbus_server_set_language(DBusConnection* conn, DBusMessage* msg);
+
 #ifdef __cplusplus
 }
 #endif
old mode 100644 (file)
new mode 100755 (executable)
index c8e3304..0129914
@@ -2346,3 +2346,22 @@ int vcd_server_widget_enable_asr_result(int pid, bool enable)
 
        return ret;
 }
+
+int vcd_server_set_language(const char* language)
+{
+       int ret = VCD_ERROR_NONE;
+
+       ret = vcd_config_set_default_language(language);
+       if (0 != ret) {
+               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Fail to set language : %d", ret);
+               return ret;
+       }
+
+       ret = vcd_engine_set_current_language(language);
+       if (0 != ret) {
+               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Fail to set language : %d", ret);
+               return ret;
+       }
+
+       return ret;
+}
\ No newline at end of file
index b97589d0b55c4709f84e766520cfda24613246a1..14fcbd21965aede18e33d004804b5d10a25203ce 100644 (file)
@@ -122,6 +122,8 @@ int vcd_server_widget_cancel(int pid);
 
 int vcd_server_widget_enable_asr_result(int pid, bool enable);
 
+int vcd_server_set_language(const char* language);
+
 #ifdef __cplusplus
 }
 #endif