From 8b0684010c87f1d74d61194f8760b797c02be99f Mon Sep 17 00:00:00 2001 From: InHong Han Date: Wed, 24 Aug 2016 19:44:45 +0900 Subject: [PATCH] Add remote_control_delete_surrounding_text API Change-Id: I0b0dd16a850cfa4609fc7abd3bd369fdd9437253 --- .../ecore_socket_panel_agent_module.cpp | 19 +++++++++++++++ ism/src/isf_remote_client.cpp | 28 ++++++++++++++++++++++ ism/src/isf_remote_client.h | 1 + ism/src/isf_remote_control.cpp | 25 ++++++++++++++----- ism/src/isf_remote_control.h | 22 +++++++++++++++++ ism/src/scim_trans_commands.h | 1 + 6 files changed, 90 insertions(+), 6 deletions(-) diff --git a/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp b/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp index 8329309..7e828f1 100755 --- a/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp +++ b/ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp @@ -3019,6 +3019,25 @@ private: trans.put_command(SCIM_TRANS_CMD_REPLY); trans.put_command(ret ? SCIM_TRANS_CMD_OK : SCIM_TRANS_CMD_FAIL); trans.write_to_socket(client_socket); + } else if (cmd == ISM_TRANS_CMD_DELETE_REMOTE_SURROUNDING_TEXT) { + uint32 offset; + uint32 len; + bool ret = false; + + if (m_recv_trans.get_data(offset) && m_recv_trans.get_data(len)) { + m_info_manager->socket_helper_delete_surrounding_text(client_id, offset, len); + ret = true; + } else { + LOGW ("wrong format of transaction\n"); + } + + Transaction trans; + Socket client_socket(client_id); + + trans.clear(); + trans.put_command(SCIM_TRANS_CMD_REPLY); + trans.put_command(ret ? SCIM_TRANS_CMD_OK : SCIM_TRANS_CMD_FAIL); + trans.write_to_socket(client_socket); } else { LOGW ("unknow cmd: %d\n", cmd); } diff --git a/ism/src/isf_remote_client.cpp b/ism/src/isf_remote_client.cpp index cd19361..027940a 100644 --- a/ism/src/isf_remote_client.cpp +++ b/ism/src/isf_remote_client.cpp @@ -277,6 +277,28 @@ public: return true; } + bool delete_surrounding_text(int offset, int len) { + int cmd; + + m_trans.put_command (ISM_TRANS_CMD_DELETE_REMOTE_SURROUNDING_TEXT); + m_trans.put_data (offset); + m_trans.put_data (len); + m_trans.write_to_socket (m_socket_remoteinput2panel); + if (!m_trans.read_from_socket (m_socket_remoteinput2panel, m_socket_timeout)) { + std::cerr << __func__ << " read_from_socket() may be timeout \n"; + return false; + } + + if (m_trans.get_command (cmd) && cmd == SCIM_TRANS_CMD_REPLY && + m_trans.get_command (cmd) && cmd == SCIM_TRANS_CMD_OK) { + } else { + std::cerr << __func__ << " get_command() or get_data() may fail!!!\n"; + return false; + } + + return true; + } + remote_control_callback_type recv_callback_message(void) { if (! m_socket_panel2remoteinput.is_connected () || ! m_trans_recv.read_from_socket(m_socket_panel2remoteinput, m_socket_timeout)) return REMOTE_CONTROL_CALLBACK_ERROR; @@ -397,6 +419,12 @@ RemoteInputClient::check_privilege (void) return m_impl->check_privilege (); } +bool +RemoteInputClient::delete_surrounding_text (int offset, int len) +{ + return m_impl->delete_surrounding_text (offset, len); +} + remote_control_callback_type RemoteInputClient::recv_callback_message (void) { diff --git a/ism/src/isf_remote_client.h b/ism/src/isf_remote_client.h index 86fec48..de36daf 100644 --- a/ism/src/isf_remote_client.h +++ b/ism/src/isf_remote_client.h @@ -53,6 +53,7 @@ public: bool has_pending_event (void) const; bool send_remote_input_message (const char* str); bool check_privilege (void); + bool delete_surrounding_text(int offset, int len); remote_control_callback_type recv_callback_message (void); void get_entry_metadata (int *hint, int *layout, int *variation, int *autocapital_type); void get_default_text (String &default_text, int *cursor); diff --git a/ism/src/isf_remote_control.cpp b/ism/src/isf_remote_control.cpp index f8384e8..a2ccdad 100644 --- a/ism/src/isf_remote_control.cpp +++ b/ism/src/isf_remote_control.cpp @@ -17,12 +17,6 @@ using namespace scim; static bool focus_flag, event_check_flag; -enum remote_control_command_option{ - REMOTE_CONTROL_COMMAND_KEY = 0, - REMOTE_CONTROL_COMMAND_COMMIT, - REMOTE_CONTROL_COMMAND_PREEDIT, -}; - struct _remote_control_client { RemoteInputClient remote_client; Ecore_Fd_Handler *remote_fd_handler = NULL; @@ -363,4 +357,23 @@ EXAPI int remote_control_update_preedit_string(remote_control_client *client, co return REMOTE_CONTROL_ERROR_NONE; } return REMOTE_CONTROL_INVALID_OPERATION; +} + +EXAPI int remote_control_delete_surrounding_text(remote_control_client *client, int offset, int len) +{ + if (client == NULL || len < 0) + return REMOTE_CONTROL_INVALID_PARAMETER; + + if (!client->remote_client.prepare()) + return REMOTE_CONTROL_REPLY_TIMEOUT; + + if (!client->remote_client.check_privilege()) + return REMOTE_CONTROL_PERMISSION_DENIED; + + if (!client->remote_client.prepare()) + return REMOTE_CONTROL_REPLY_TIMEOUT; + if (focus_flag && client->remote_client.delete_surrounding_text(offset, len)) + return REMOTE_CONTROL_ERROR_NONE; + + return REMOTE_CONTROL_INVALID_OPERATION; } \ No newline at end of file diff --git a/ism/src/isf_remote_control.h b/ism/src/isf_remote_control.h index 67be9e4..dedbaa4 100644 --- a/ism/src/isf_remote_control.h +++ b/ism/src/isf_remote_control.h @@ -441,6 +441,28 @@ EXAPI int remote_control_send_commit_string(remote_control_client *client, const */ EXAPI int remote_control_update_preedit_string(remote_control_client *client, const char *text, Eina_List *attrs, int cursor_pos); +/** + * @brief Requests to delete surrounding text. + * + * @since_tizen @if TV 3.0 @endif + * + * @privlevel platform + * + * @privilege %http://tizen.org/privilege/imemanager + * + * @param[in] client The remote control client + * @param[in] offset The offset value from the cursor position + * @param[in] len The length of the text to delete + * + * @return 0 on success, otherwise a negative error value + * @retval #REMOTE_CONTROL_ERROR_NONE No error + * @retval #REMOTE_CONTROL_PERMISSION_DENIED The application does not have the privilege to call this function + * @retval #REMOTE_CONTROL_INVALID_OPERATION Invalid operation + * @retval #REMOTE_CONTROL_INVALID_PARAMETER Invalid parameter + * @retval #REMOTE_CONTROL_REPLY_TIMEOUT Socket connection failed + */ +EXAPI int remote_control_delete_surrounding_text(remote_control_client *client, int offset, int len); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ism/src/scim_trans_commands.h b/ism/src/scim_trans_commands.h index 77f3dc5..d0a51bf 100644 --- a/ism/src/scim_trans_commands.h +++ b/ism/src/scim_trans_commands.h @@ -643,6 +643,7 @@ const int ISM_TRANS_CMD_RECV_REMOTE_FOCUS_OUT = 1027; const int ISM_TRANS_CMD_RECV_REMOTE_ENTRY_METADATA = 1028; const int ISM_TRANS_CMD_RECV_REMOTE_DEFAULT_TEXT = 1029; const int ISM_TRANS_CMD_CHECK_REMOTE_PRIVILEGE = 1030; +const int ISM_TRANS_CMD_DELETE_REMOTE_SURROUNDING_TEXT = 1031; /* IMControl to ISE */ const int ISM_TRANS_CMD_SET_ISE_MODE = 1108; -- 2.7.4