Add internal method for enable/disable command type 87/109987/1
authorKwangyoun Kim <ky85.kim@samsung.com>
Wed, 28 Dec 2016 12:50:54 +0000 (21:50 +0900)
committerWonnam Jang <wn.jang@samsung.com>
Thu, 12 Jan 2017 10:47:03 +0000 (02:47 -0800)
Change-Id: I95241d6fcab013766bb3febb5a2445c639143a28
Signed-off-by: Kwangyoun Kim <ky85.kim@samsung.com>
(cherry picked from commit 4f7cc1642addef112004b8223eeb3372f3db7012)

13 files changed:
client/vc_mgr.c
client/vc_mgr_dbus.c
client/vc_mgr_dbus.h
common/vc_defs.h
include/voice_control_manager.h
server/vcd_client_data.c
server/vcd_config.c
server/vcd_config.h
server/vcd_dbus.c
server/vcd_dbus_server.c
server/vcd_dbus_server.h
server/vcd_server.c
server/vcd_server.h

index 878f3a7..2001006 100644 (file)
@@ -650,6 +650,118 @@ int vc_mgr_is_command_format_supported(vc_cmd_format_e format, bool* support)
        return VC_ERROR_NONE;
 }
 
+int vc_mgr_enable_command_type(int cmd_type)
+{
+       SLOG(LOG_DEBUG, TAG_VCM, "===== [Manager] Enable Command Type");
+
+       vc_state_e state;
+       if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) {
+               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_VCM, "=====");
+               SLOG(LOG_DEBUG, TAG_VCM, " ");
+               return VC_ERROR_INVALID_STATE;
+       }
+
+       /* check state */
+       if (state != VC_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'");
+               SLOG(LOG_DEBUG, TAG_VCM, "=====");
+               SLOG(LOG_DEBUG, TAG_VCM, " ");
+               return VC_ERROR_INVALID_STATE;
+       }
+
+       /* Check service state */
+       vc_service_state_e service_state = -1;
+       vc_mgr_client_get_service_state(g_vc_m, &service_state);
+       if (service_state != VC_SERVICE_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'");
+               SLOG(LOG_DEBUG, TAG_VCM, "=====");
+               SLOG(LOG_DEBUG, TAG_VCM, " ");
+               return VC_ERROR_INVALID_STATE;
+       }
+
+       int ret;
+       int count = 0;
+       do {
+               ret = vc_mgr_dbus_request_enable_command_type(g_vc_m->handle, cmd_type);
+               if (0 != ret) {
+                       if (VC_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request enable command type : %s", __vc_mgr_get_error_code(ret));
+                               break;
+                       } else {
+                               SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry request enable command type : %s", __vc_mgr_get_error_code(ret));
+                               usleep(10000);
+                               count++;
+                               if (VC_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request");
+                                       break;
+                               }
+                       }
+               }
+       } while (0 != ret);
+
+       SLOG(LOG_DEBUG, TAG_VCM, "=====");
+       SLOG(LOG_DEBUG, TAG_VCM, " ");
+
+       return ret;
+}
+
+int vc_mgr_disable_command_type(int cmd_type)
+{
+       SLOG(LOG_DEBUG, TAG_VCM, "===== [Manager] Disable Command Type");
+
+       vc_state_e state;
+       if (0 != vc_mgr_client_get_client_state(g_vc_m, &state)) {
+               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] A handle is not available");
+               SLOG(LOG_DEBUG, TAG_VCM, "=====");
+               SLOG(LOG_DEBUG, TAG_VCM, " ");
+               return VC_ERROR_INVALID_STATE;
+       }
+
+       /* check state */
+       if (state != VC_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: Current state is not 'READY'");
+               SLOG(LOG_DEBUG, TAG_VCM, "=====");
+               SLOG(LOG_DEBUG, TAG_VCM, " ");
+               return VC_ERROR_INVALID_STATE;
+       }
+
+       /* Check service state */
+       vc_service_state_e service_state = -1;
+       vc_mgr_client_get_service_state(g_vc_m, &service_state);
+       if (service_state != VC_SERVICE_STATE_READY) {
+               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Invalid State: service state is not 'READY'");
+               SLOG(LOG_DEBUG, TAG_VCM, "=====");
+               SLOG(LOG_DEBUG, TAG_VCM, " ");
+               return VC_ERROR_INVALID_STATE;
+       }
+
+       int ret;
+       int count = 0;
+       do {
+               ret = vc_mgr_dbus_request_disable_command_type(g_vc_m->handle, cmd_type);
+               if (0 != ret) {
+                       if (VC_ERROR_TIMED_OUT != ret) {
+                               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request disable command type : %s", __vc_mgr_get_error_code(ret));
+                               break;
+                       } else {
+                               SLOG(LOG_WARN, TAG_VCM, "[WARNING] retry request disable command type : %s", __vc_mgr_get_error_code(ret));
+                               usleep(10000);
+                               count++;
+                               if (VC_RETRY_COUNT == count) {
+                                       SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request");
+                                       break;
+                               }
+                       }
+               }
+       } while (0 != ret);
+
+       SLOG(LOG_DEBUG, TAG_VCM, "=====");
+       SLOG(LOG_DEBUG, TAG_VCM, " ");
+
+       return ret;
+}
+
 int vc_mgr_set_command_list(vc_cmd_list_h vc_cmd_list)
 {
        SLOG(LOG_DEBUG, TAG_VCM, "===== [Manager] Set Command list");
index 93cbb17..2349eea 100644 (file)
@@ -1829,6 +1829,164 @@ int vc_mgr_dbus_request_cancel(int pid)
        return result;
 }
 
+int vc_mgr_dbus_request_enable_command_type(int pid, int cmd_type)
+{
+       DBusError err;
+       dbus_error_init(&err);
+
+       bool exist = dbus_bus_name_has_owner(g_m_conn_sender, VC_SERVER_SERVICE_NAME, &err);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
+
+       int ret;
+       if (false == exist) {
+               ret = __dbus_restore_daemon();
+               if (VC_ERROR_NONE != ret) {
+                       SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to restore daemon");
+                       return VC_ERROR_TIMED_OUT;
+               }
+               return VC_ERROR_OPERATION_FAILED;
+       }
+
+       DBusMessage* msg;
+
+       /* create a signal & check for errors */
+       msg = dbus_message_new_method_call(
+                         VC_SERVER_SERVICE_NAME,
+                         VC_SERVER_SERVICE_OBJECT_PATH,        /* object name of the signal */
+                         VC_SERVER_SERVICE_INTERFACE,  /* interface name of the signal */
+                         VC_MANAGER_METHOD_ENABLE_COMMAND_TYPE);       /* name of the signal */
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, TAG_VCM, ">>>> vc enable command type : Fail to make message ");
+               return VC_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCM, ">>>> vc enable command type : pid(%d) type(%d)", pid, cmd_type);
+       }
+
+       dbus_message_append_args(msg,
+                                DBUS_TYPE_INT32, &pid,
+                                DBUS_TYPE_INT32, &cmd_type,
+                                DBUS_TYPE_INVALID);
+
+       DBusMessage* result_msg;
+       int result = VC_ERROR_OPERATION_FAILED;
+
+       result_msg = dbus_connection_send_with_reply_and_block(g_m_conn_sender, msg, g_m_waiting_time, &err);
+       dbus_message_unref(msg);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCM, "[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_VCM, "<<<< Get arguments error (%s)", err.message);
+                       dbus_error_free(&err);
+                       result = VC_ERROR_OPERATION_FAILED;
+               }
+               dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc enable command type : result = %d", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_VCM, "<<<< vc enable command type : result = %d", result);
+               }
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCM, "<<<< Result Message is NULL");
+               vc_mgr_dbus_reconnect();
+               result = VC_ERROR_TIMED_OUT;
+       }
+
+       return result;
+}
+
+int vc_mgr_dbus_request_disable_command_type(int pid, int cmd_type)
+{
+       DBusError err;
+       dbus_error_init(&err);
+
+       bool exist = dbus_bus_name_has_owner(g_m_conn_sender, VC_SERVER_SERVICE_NAME, &err);
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Dbus Error (%s)", err.message);
+               dbus_error_free(&err);
+       }
+
+       int ret;
+       if (false == exist) {
+               ret = __dbus_restore_daemon();
+               if (VC_ERROR_NONE != ret) {
+                       SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to restore daemon");
+                       return VC_ERROR_TIMED_OUT;
+               }
+               return VC_ERROR_OPERATION_FAILED;
+       }
+
+       DBusMessage* msg;
+
+       /* create a signal & check for errors */
+       msg = dbus_message_new_method_call(
+                         VC_SERVER_SERVICE_NAME,
+                         VC_SERVER_SERVICE_OBJECT_PATH,        /* object name of the signal */
+                         VC_SERVER_SERVICE_INTERFACE,  /* interface name of the signal */
+                         VC_MANAGER_METHOD_DISABLE_COMMAND_TYPE);      /* name of the signal */
+
+       if (NULL == msg) {
+               SLOG(LOG_ERROR, TAG_VCM, ">>>> vc disable command type : Fail to make message ");
+               return VC_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCM, ">>>> vc disable command type : pid(%d) type(%d)", pid, cmd_type);
+       }
+
+       dbus_message_append_args(msg,
+                                DBUS_TYPE_INT32, &pid,
+                                DBUS_TYPE_INT32, &cmd_type,
+                                DBUS_TYPE_INVALID);
+
+       DBusMessage* result_msg;
+       int result = VC_ERROR_OPERATION_FAILED;
+
+       result_msg = dbus_connection_send_with_reply_and_block(g_m_conn_sender, msg, g_m_waiting_time, &err);
+       dbus_message_unref(msg);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCM, "[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_VCM, "<<<< Get arguments error (%s)", err.message);
+                       dbus_error_free(&err);
+                       result = VC_ERROR_OPERATION_FAILED;
+               }
+               dbus_message_unref(result_msg);
+
+               if (0 == result) {
+                       SLOG(LOG_DEBUG, TAG_VCM, "<<<< vc disable command type : result = %d", result);
+               } else {
+                       SLOG(LOG_ERROR, TAG_VCM, "<<<< vc disable command type : result = %d", result);
+               }
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCM, "<<<< Result Message is NULL");
+               vc_mgr_dbus_reconnect();
+               result = VC_ERROR_TIMED_OUT;
+       }
+
+       return result;
+}
+
 static DBusMessage* __get_message(int pid, const char* method, int type)
 {
        char service_name[64];
index c12baa6..267aa05 100644 (file)
@@ -64,6 +64,9 @@ int vc_mgr_dbus_send_result(int pid, int cmd_type, int result_id);
 
 int vc_mgr_dbus_send_result_selection(int pid);
 
+int vc_mgr_dbus_request_enable_command_type(int pid, int cmd_type);
+
+int vc_mgr_dbus_request_disable_command_type(int pid, int cmd_type);
 
 #ifdef __cplusplus
 }
index 095ba66..f647506 100644 (file)
@@ -127,6 +127,8 @@ extern "C" {
 #define VC_MANAGER_METHOD_SET_CLIENT_INFO      "vc_manager_method_set_client_info"
 #define VC_MANAGER_METHOD_SET_PRIVATE_DATA     "vc_manager_method_set_private_data"
 #define VC_MANAGER_METHOD_GET_PRIVATE_DATA     "vc_manager_method_get_private_data"
+#define VC_MANAGER_METHOD_ENABLE_COMMAND_TYPE  "vc_manager_method_enable_command_type"
+#define VC_MANAGER_METHOD_DISABLE_COMMAND_TYPE "vc_manager_method_disable_command_type"
 
 #define VC_MANAGER_METHOD_START                        "vc_manager_method_request_start"
 #define VC_MANAGER_METHOD_STOP                 "vc_manager_method_request_stop"
@@ -149,6 +151,7 @@ extern "C" {
 #define VCC_MANAGER_METHOD_SET_FOREGROUND      "vcd_manager_method_set_foreground"
 
 
+
 /******************************************************************************************
 * Definitions for configuration
 *******************************************************************************************/
index 32f4cd7..9d738dc 100644 (file)
@@ -982,6 +982,31 @@ int vc_mgr_set_dialog_request_cb(vc_mgr_dialog_request_cb callback, void* user_d
 */
 int vc_mgr_unset_dialog_request_cb();
 
+/**
+* @brief Enable command type as candidate command.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #VC_STATE_READY.
+*
+* @see vc_mgr_disable_command_type()
+*/
+int vc_mgr_enable_command_type(int cmd_type);
+
+/**
+* @brief Disable command type as candidate command.
+*
+* @return 0 on success, otherwise a negative error value
+* @retval #VC_ERROR_NONE Successful
+* @retval #VC_ERROR_INVALID_STATE Invalid state
+*
+* @pre The state should be #VC_STATE_READY.
+*
+* @see vc_mgr_enable_command_type()
+*/
+int vc_mgr_disable_command_type(int cmd_type);
 
 #ifdef __cplusplus
 }
index 5e0253d..562b77a 100644 (file)
@@ -319,7 +319,7 @@ int vcd_client_command_collect_command()
        __vcd_client_release_commands();
 
        /* Check exclusive system command */
-       if (true == g_manager.exclusive_cmd_option) {
+       if (true == g_manager.exclusive_cmd_option && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_EXCLUSIVE)) {
                SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] Exclusive option of manager is ON");
 
                GSList* ex_sys_cmd_list = NULL;
@@ -339,7 +339,7 @@ int vcd_client_command_collect_command()
 
        /* 3. Set system command */
        GSList* sys_cmd_list = NULL;
-       if (true == g_manager.manager_cmd) {
+       if (true == g_manager.manager_cmd && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_SYSTEM)) {
                ret = vc_cmd_parser_get_commands(g_manager.pid, VC_COMMAND_TYPE_SYSTEM, &sys_cmd_list);
                if (0 != ret) {
                        SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the system command list");
@@ -351,7 +351,7 @@ int vcd_client_command_collect_command()
        }
 
        GSList* sys_back_cmd_list = NULL;
-       if (true == g_manager.manager_cmd) {
+       if (true == g_manager.manager_cmd && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_SYSTEM_BACKGROUND)) {
                ret = vc_cmd_parser_get_commands(g_manager.pid, VC_COMMAND_TYPE_SYSTEM_BACKGROUND, &sys_back_cmd_list);
                if (0 != ret) {
                        SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the system command list");
@@ -372,7 +372,7 @@ int vcd_client_command_collect_command()
                /* 4-1. Set widget command */
                widget_info_s* widget_info = NULL;
                widget_info = __widget_get_element(fg_pid);
-               if (NULL != widget_info) {
+               if (NULL != widget_info && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) {
                        if (true == widget_info->widget_cmd) {
                                ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_WIDGET, &widget_cmd_list);
                                if (0 != ret) {
@@ -386,16 +386,18 @@ int vcd_client_command_collect_command()
                }
 
                /* 4-2. Set foreground command of foreground app */
-               ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_FOREGROUND, &fg_cmd_list);
-               if (0 != ret) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the fg command list");
-               } else {
-                       g_cur_cmd_list.foreground_cmds = fg_cmd_list;
+               if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_FOREGROUND)) {
+                       ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_FOREGROUND, &fg_cmd_list);
+                       if (0 != ret) {
+                               SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the fg command list");
+                       } else {
+                               g_cur_cmd_list.foreground_cmds = fg_cmd_list;
+                       }
                }
        } else {
                SLOG(LOG_DEBUG, TAG_VCD, "[Client Data] No foreground app");
        }
-       if (true == g_manager.manager_cmd) {
+       if (true == g_manager.manager_cmd && 1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_FOREGROUND)) {
                /* 4-3. Set foreground command by manager */
                ret = vc_cmd_parser_get_commands(g_manager.pid, VC_COMMAND_TYPE_FOREGROUND, &fg_cmd_list);
                if (0 != ret) {
@@ -407,12 +409,14 @@ int vcd_client_command_collect_command()
 
        /* 5. Set background commands */
        GSList* bg_cmd_list = NULL;
-       ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_BACKGROUND, &bg_cmd_list);
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the bg command list");
-       } else {
-               /* Add item to global command list */
-               g_cur_cmd_list.background_cmds = bg_cmd_list;
+       if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_BACKGROUND)) {
+               ret = vc_cmd_parser_get_commands(fg_pid, VC_COMMAND_TYPE_BACKGROUND, &bg_cmd_list);
+               if (0 != ret) {
+                       SLOG(LOG_ERROR, TAG_VCD, "[Client Data ERROR] Fail to get the bg command list");
+               } else {
+                       /* Add item to global command list */
+                       g_cur_cmd_list.background_cmds = bg_cmd_list;
+               }
        }
        return 0;
 }
index 7c46573..287ba23 100644 (file)
@@ -28,6 +28,16 @@ static vcd_state_e g_state;
 
 static int g_foreground_pid;
 
+#define COMMAND_TYPE_MAX       7
+static int g_enabled_command_type[COMMAND_TYPE_MAX] = {
+       0,      /* NONE */
+       1,      /* FOREGROUND */
+       1,      /* BACKGROUND */
+       1,      /* WIDGET */
+       1,      /* SYSTEM */
+       1,      /* SYSTEM_BACKGROUND */
+       1       /* EXCLUSIVE */
+};
 
 void __vcd_config_lang_changed_cb(const char* before_lang, const char* current_lang)
 {
@@ -128,3 +138,35 @@ int vcd_config_set_foreground(int pid, bool value)
        }
        return 0;
 }
+
+int vcd_config_enable_command_type(int cmd_type)
+{
+       if (cmd_type <= 0 || cmd_type >= COMMAND_TYPE_MAX) {
+               SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid command type");
+               return -1;
+       }
+
+       g_enabled_command_type[cmd_type] = 1;
+       return 0;
+}
+
+int vcd_config_disable_command_type(int cmd_type)
+{
+       if (cmd_type <= 0 || cmd_type >= COMMAND_TYPE_MAX) {
+               SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid command type");
+               return -1;
+       }
+
+       g_enabled_command_type[cmd_type] = 0;
+       return 0;
+}
+
+int vcd_config_get_command_type_enabled(int cmd_type)
+{
+       if (cmd_type <= 0 || cmd_type >= COMMAND_TYPE_MAX) {
+               SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Invalid command type");
+               return 0;
+       }
+
+       return g_enabled_command_type[cmd_type];
+}
index 2cf332f..047d6d6 100644 (file)
@@ -43,6 +43,11 @@ int vcd_config_get_foreground(int* pid);
 
 int vcd_config_set_foreground(int pid, bool value);
 
+int vcd_config_enable_command_type(int cmd_type);
+
+int vcd_config_disable_command_type(int cmd_type);
+
+int vcd_config_get_command_type_enabled(int cmd_type);
 
 #ifdef __cplusplus
 }
index 7d0f348..586e65b 100644 (file)
@@ -839,6 +839,12 @@ 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_MANAGER_METHOD_DO_ACTION))
                        vcd_dbus_server_mgr_do_action(g_conn_listener, msg);
 
+               else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_ENABLE_COMMAND_TYPE))
+                       vcd_dbus_server_mgr_enable_command_type(g_conn_listener, msg);
+
+               else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_MANAGER_METHOD_DISABLE_COMMAND_TYPE))
+                       vcd_dbus_server_mgr_disable_command_type(g_conn_listener, msg);
+
                /* client event */
                else if (dbus_message_is_method_call(msg, VC_SERVER_SERVICE_INTERFACE, VC_METHOD_INITIALIZE))
                        vcd_dbus_server_initialize(g_conn_listener, msg);
index 4a19a0b..169e3f4 100644 (file)
@@ -742,6 +742,114 @@ int vcd_dbus_server_mgr_do_action(DBusConnection* conn, DBusMessage* msg)
        return 0;
 }
 
+int vcd_dbus_server_mgr_enable_command_type(DBusConnection* conn, DBusMessage* msg)
+{
+       DBusError err;
+       dbus_error_init(&err);
+
+       int pid = 0;
+       int cmd_type = 0;
+
+       int ret = VCD_ERROR_OPERATION_FAILED;
+
+       SLOG(LOG_DEBUG, TAG_VCD, ">>>>> VCD Manager enable command type");
+
+       dbus_message_get_args(msg, &err,
+                               DBUS_TYPE_INT32, &pid,
+                               DBUS_TYPE_INT32, &cmd_type,
+                               DBUS_TYPE_INVALID);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd mgr enable command type : get arguments error (%s)", err.message);
+               dbus_error_free(&err);
+               ret = VCD_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd mgr enable command type : pid(%d), cmd_type(%d)", pid, cmd_type);
+               ret = vcd_server_mgr_enable_command_type(pid, cmd_type);
+       }
+
+       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, "<<<<<");
+       SLOG(LOG_DEBUG, TAG_VCD, "  ");
+
+       return 0;
+}
+
+int vcd_dbus_server_mgr_disable_command_type(DBusConnection* conn, DBusMessage* msg)
+{
+       DBusError err;
+       dbus_error_init(&err);
+
+       int pid = 0;
+       int cmd_type = 0;
+
+       int ret = VCD_ERROR_OPERATION_FAILED;
+
+       SLOG(LOG_DEBUG, TAG_VCD, ">>>>> VCD Manager disable command type");
+
+       dbus_message_get_args(msg, &err,
+                               DBUS_TYPE_INT32, &pid,
+                               DBUS_TYPE_INT32, &cmd_type,
+                               DBUS_TYPE_INVALID);
+
+       if (dbus_error_is_set(&err)) {
+               SLOG(LOG_ERROR, TAG_VCD, "[IN ERROR] vcd mgr disable command type : get arguments error (%s)", err.message);
+               dbus_error_free(&err);
+               ret = VCD_ERROR_OPERATION_FAILED;
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCD, "[IN] vcd mgr disable command type : pid(%d), cmd_type(%d)", pid, cmd_type);
+               ret = vcd_server_mgr_disable_command_type(pid, cmd_type);
+       }
+
+       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, "<<<<<");
+       SLOG(LOG_DEBUG, TAG_VCD, "  ");
+
+       return 0;
+}
+
 int vcd_dbus_server_mgr_start(DBusConnection* conn, DBusMessage* msg)
 {
        DBusError err;
index 4a7fc7b..626d415 100644 (file)
@@ -63,6 +63,10 @@ int vcd_dbus_server_mgr_cancel(DBusConnection* conn, DBusMessage* msg);
 
 int vcd_dbus_server_mgr_result_selection(DBusConnection* conn, DBusMessage* msg);
 
+int vcd_dbus_server_mgr_enable_command_type(DBusConnection* conn, DBusMessage* msg);
+
+int vcd_dbus_server_mgr_disable_command_type(DBusConnection* conn, DBusMessage* msg);
+
 /*
 * Dbus Server functions for client
 */
index a452b68..07f9fbe 100755 (executable)
@@ -1535,11 +1535,13 @@ int vcd_server_mgr_start(vcd_recognition_mode_e recognition_mode, bool exclusive
 
        if (false == exclusive_cmd) {
                /* Notify show tooltip */
-               int pid = vcd_client_widget_get_foreground_pid();
-               if (-1 != pid) {
-                       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip show and widget command");
-                       ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true);
-                       return 0;
+               if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) {
+                       int pid = vcd_client_widget_get_foreground_pid();
+                       if (-1 != pid) {
+                               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip show and widget command");
+                               ecore_timer_add(0, __vcd_request_show_tooltip, (void*)true);
+                               return 0;
+                       }
                }
        } else {
                vcd_client_manager_set_exclusive(exclusive_cmd);
@@ -1627,10 +1629,12 @@ int vcd_server_mgr_cancel()
        }
 
        if (false == vcd_client_manager_get_exclusive()) {
-               int pid = vcd_client_widget_get_foreground_pid();
-               if (-1 != pid) {
-                       SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip hide");
-                       ecore_timer_add(0, __vcd_request_show_tooltip, (void*)false);
+               if (1 == vcd_config_get_command_type_enabled(VC_COMMAND_TYPE_WIDGET)) {
+                       int pid = vcd_client_widget_get_foreground_pid();
+                       if (-1 != pid) {
+                               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Request tooltip hide");
+                               ecore_timer_add(0, __vcd_request_show_tooltip, (void*)false);
+                       }
                }
        } else {
                vcd_client_manager_set_exclusive(false);
@@ -1758,6 +1762,58 @@ int vcd_server_mgr_do_action(int pid, int type, const char* action)
        return ret;
 }
 
+int vcd_server_mgr_enable_command_type(int pid, int cmd_type)
+{
+       int ret = -1;
+
+       /* check if pid is valid */
+       if (false == vcd_client_manager_is_valid(pid)) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] The manager pid(%d) is NOT valid", pid);
+               return VCD_ERROR_INVALID_PARAMETER;
+       }
+
+       vcd_state_e state = vcd_config_get_service_state();
+       if (VCD_STATE_READY != state) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready");
+               return VCD_ERROR_INVALID_STATE;
+       }
+
+       ret = vcd_config_enable_command_type(cmd_type);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to enable command type");
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Enable command type(%d)", cmd_type);
+       }
+
+       return ret;
+}
+
+int vcd_server_mgr_disable_command_type(int pid, int cmd_type)
+{
+       int ret = -1;
+
+       /* check if pid is valid */
+       if (false == vcd_client_manager_is_valid(pid)) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] The manager pid(%d) is NOT valid", pid);
+               return VCD_ERROR_INVALID_PARAMETER;
+       }
+
+       vcd_state_e state = vcd_config_get_service_state();
+       if (VCD_STATE_READY != state) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Current state is not ready");
+               return VCD_ERROR_INVALID_STATE;
+       }
+
+       ret = vcd_config_disable_command_type(cmd_type);
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[Server ERROR] Fail to disable command type");
+       } else {
+               SLOG(LOG_DEBUG, TAG_VCD, "[Server] Disable command type(%d)", cmd_type);
+       }
+
+       return ret;
+}
+
 /*
 * VC Server Functions for Client
 */
index c8b0284..b97589d 100644 (file)
@@ -74,6 +74,10 @@ int vcd_server_mgr_get_private_data(int pid, const char* key, char** data);
 
 int vcd_server_mgr_do_action(int pid, int type, const char* action);
 
+int vcd_server_mgr_enable_command_type(int pid, int cmd_type);
+
+int vcd_server_mgr_disable_command_type(int pid, int cmd_type);
+
 /*
 * For client
 */