summaryrefslogtreecommitdiff
path: root/ism/src/scim_helper.cpp
diff options
context:
space:
mode:
authorJihoon Kim <jihoon48.kim@samsung.com>2016-06-09 18:38:47 -0700
committerJihoon Kim <jihoon48.kim@samsung.com>2016-06-09 18:38:47 -0700
commitd3bac44b4e492d8bd30668b29a3833ad8ff4b934 (patch)
tree2996176d04960a78cff937b91b420738037c8f31 /ism/src/scim_helper.cpp
parent7e9fb71b07db6b8b92ccf19cb017dd6b9e9c30a2 (diff)
downloadisf-d3bac44b4e492d8bd30668b29a3833ad8ff4b934.tar.gz
isf-d3bac44b4e492d8bd30668b29a3833ad8ff4b934.tar.bz2
isf-d3bac44b4e492d8bd30668b29a3833ad8ff4b934.zip
Revert "Get surrounding and selection text by fd"
This reverts commit 7e9fb71b07db6b8b92ccf19cb017dd6b9e9c30a2. Change-Id: Iac18454738cdcb54575149cde163edb2a8997f08
Diffstat (limited to 'ism/src/scim_helper.cpp')
-rw-r--r--ism/src/scim_helper.cpp94
1 files changed, 9 insertions, 85 deletions
diff --git a/ism/src/scim_helper.cpp b/ism/src/scim_helper.cpp
index 760b20a9..a7537fdb 100644
--- a/ism/src/scim_helper.cpp
+++ b/ism/src/scim_helper.cpp
@@ -48,7 +48,6 @@
#include <string.h>
#include <unistd.h>
-#include <fcntl.h>
#include "scim_private.h"
#include "scim.h"
@@ -1956,6 +1955,10 @@ void
HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &text, int &cursor)
{
LOGD ("");
+ if (m_impl->surrounding_text) {
+ free (m_impl->surrounding_text);
+ m_impl->surrounding_text = NULL;
+ }
if (!m_impl->socket_active.is_connected ())
return;
@@ -1969,48 +1972,6 @@ HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &
m_impl->send.put_data (maxlen_after);
m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
-#ifdef WAYLAND
- int filedes[2];
- if (pipe2(filedes,O_CLOEXEC|O_NONBLOCK) ==-1 ) {
- LOGD ("create pipe failed");
- return;
- }
- LOGD("%d,%d",filedes[0],filedes[1]);
-
- m_impl->socket_active.write_fd (filedes[1]);
- close (filedes[1]);
-
- for (int i = 0; i < 3; i++) {
- int fds[3];
- fds[0] = m_impl->socket_active.get_id();
- fds[1] = filedes[0];
- fds[2] = 0;
- if (!scim_wait_for_data (fds)) {
- LOGE ("");
- break;
- }
-
- if (fds[1]) {
- char buff[512];
- int len = read (fds[1], buff, sizeof(buff));
- if (len <= 0)
- break;
- else {
- buff[len] = '\0';
- text.append (buff);
- }
- }
- if (fds[0])
- filter_event ();
- }
- close (filedes[0]);
- cursor = m_impl->cursor_pos;
-#else
- if (m_impl->surrounding_text) {
- free (m_impl->surrounding_text);
- m_impl->surrounding_text = NULL;
- }
-
for (int i = 0; i < 3; i++) {
if (filter_event () && m_impl->surrounding_text) {
text = m_impl->surrounding_text;
@@ -2023,7 +1984,6 @@ HelperAgent::get_surrounding_text (int maxlen_before, int maxlen_after, String &
free (m_impl->surrounding_text);
m_impl->surrounding_text = NULL;
}
-#endif
}
/**
@@ -2078,6 +2038,10 @@ void
HelperAgent::get_selection_text (String &text)
{
LOGD ("");
+ if (m_impl->selection_text) {
+ free (m_impl->selection_text);
+ m_impl->selection_text = NULL;
+ }
if (!m_impl->socket_active.is_connected ())
return;
@@ -2088,46 +2052,6 @@ HelperAgent::get_selection_text (String &text)
m_impl->send.put_command (SCIM_TRANS_CMD_GET_SELECTION);
m_impl->send.put_data ("");
m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
-#ifdef WAYLAND
- int filedes[2];
- if (pipe2 (filedes,O_CLOEXEC|O_NONBLOCK) == -1 ) {
- LOGD ("create pipe failed");
- return;
- }
- LOGD("%d,%d", filedes[0], filedes[1]);
-
- m_impl->socket_active.write_fd (filedes[1]);
- close (filedes[1]);
-
- for (int i = 0; i < 3; i++) {
- int fds[3];
- fds[0] = m_impl->socket_active.get_id();
- fds[1] = filedes[0];
- fds[2] = 0;
- if (!scim_wait_for_data (fds)) {
- LOGE ("");
- break;
- }
-
- if (fds[1]) {
- char buff[512];
- int len = read (fds[1], buff, sizeof(buff));
- if (len <= 0)
- break;
- else {
- buff[len] = '\0';
- text.append (buff);
- }
- }
- if (fds[0])
- filter_event ();
- }
- close (filedes[0]);
-#else
- if (m_impl->selection_text) {
- free (m_impl->selection_text);
- m_impl->selection_text = NULL;
- }
for (int i = 0; i < 3; i++) {
if (filter_event () && m_impl->selection_text) {
@@ -2135,11 +2059,11 @@ HelperAgent::get_selection_text (String &text)
break;
}
}
+
if (m_impl->selection_text) {
free (m_impl->selection_text);
m_impl->selection_text = NULL;
}
-#endif
}
/**