ism/modules/config/Makefile
ism/modules/panelagent/ecoresocket/Makefile
ism/modules/panelagent/wayland/Makefile
+ ism/modules/panelagent/socketconfigserver/Makefile
ism/configs/Makefile
ism/extras/Makefile
ism/extras/gtk2_immodule/Makefile
/DefaultConfigModule = simple
/DefaultSocketFrontEndAddress = local:/tmp/scim-socket-frontend
/DefaultSocketIMEngineAddress = local:/tmp/scim-socket-frontend
-/DefaultSocketConfigAddress = local:/tmp/scim-panel-socket
+/DefaultSocketConfigAddress = local:/tmp/scim-socket-config
/DefaultPanelSocketAddress = local:/tmp/scim-panel-socket
/DefaultHelperManagerSocketAddress = local:/tmp/scim-socket-frontend
/DefaultSocketTimeout = 5000
_config->flush ();
_config->reload ();
- _info_manager->reload_config ();
#if HAVE_VCONF
vconf_set_str (VCONFKEY_ISF_ACTIVE_KEYBOARD_UUID, uuid.c_str ());
static void config_reload_cb (const ConfigPointer &config)
{
SCIM_DEBUG_MAIN (3) << __FUNCTION__ << "...\n";
- _info_manager->reload_config();
/* load_config (); */
}
String language = String ("~other");/*scim_get_locale_language (scim_get_current_locale ());*/
_config->write (String (SCIM_CONFIG_DEFAULT_IMENGINE_FACTORY) + String ("/") + language, uuid);
_config->flush ();
- _config->reload ();
_info_manager->change_factory (uuid);
- _info_manager->reload_config ();
+ _config->reload ();
}
/**
_ise_state = WINDOW_STATE_HIDE;
_info_manager->set_current_toolbar_mode (TOOLBAR_KEYBOARD_MODE);
_info_manager->hide_helper (helper_uuid);
- _info_manager->reload_config ();
/* Check whether stop soft keyboard */
if (_focus_in && (_ime_info[get_ise_index (helper_uuid)].options & ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT)) {
MAINTAINERCLEANFILES = Makefile.in
CLEANFILES = *.bak
-SUBDIRS = frontend imengine config filter panelagent/ecoresocket panelagent/wayland
+SUBDIRS = frontend imengine config filter panelagent/ecoresocket panelagent/wayland panelagent/socketconfigserver
{
SCIM_DEBUG_CONFIG (2) << " Construct SocketConfig object.\n";
- String display_name;
- {
- const char *p = getenv ("DISPLAY");
- if (p) display_name = String (p);
- }
- m_socket_address = scim_get_default_panel_socket_address (display_name);
-
m_valid = open_connection ();
}
#define scim_panel_agent_module_get_instance ecoresocket_LTX_scim_panel_agent_module_get_instance
-static ConfigPointer _config;
-
-
//==================================== PanelAgent ===========================
class EcoreSocketPanelAgent: public PanelAgentBase
{
bool m_should_shared_ise;
bool m_ise_exiting;
- bool m_config_readonly;
std::vector<Ecore_Fd_Handler*> _read_handler_list;
m_should_exit(false),
m_socket_timeout(scim_get_default_socket_timeout()),
m_should_shared_ise(false),
- m_ise_exiting(false),
- m_config_readonly (false) {
+ m_ise_exiting(false) {
m_socket_server.signal_connect_accept(slot(this, &EcoreSocketPanelAgent::socket_accept_callback));
m_socket_server.signal_connect_receive(slot(this, &EcoreSocketPanelAgent::socket_receive_callback));
m_socket_server.signal_connect_exception(slot(this, &EcoreSocketPanelAgent::socket_exception_callback));
m_info_manager = info_manager;
m_socket_address = scim_get_default_panel_socket_address(display);
- if (!_config.null ())
- m_config_readonly = _config->read (String (SCIM_CONFIG_PANEL_SOCKET_CONFIG_READONLY), false);
- else {
- m_config_readonly = false;
- LOGW("config is not ready");
- }
-
m_socket_server.shutdown();
if (m_socket_server.create(SocketAddress(m_socket_address))) {
if (client.connect(SocketAddress(m_socket_address))) {
client.close();
}
- _config.reset();
}
private:
void update_panel_event(int client, uint32 context_id, int cmd, uint32 nType, uint32 nValue) {
m_info_manager->socket_helper_update_property(client_id, property);
else
LOGW ("wrong format of transaction\n");
-#if 0 //only receives reload message by socketconfig
- } else if (cmd == SCIM_TRANS_CMD_RELOAD_CONFIG) {
- m_info_manager->reload_config();
-#endif
} else if (cmd == ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT) {
uint32 type;
uint32 value;
}
socket_transaction_end();
- } else if (client_info.type == CONFIG_CLIENT) {
- socket_transaction_start ();
- while (m_recv_trans.get_command (cmd)) {
- LOGD ("PanelAgent::cmd = %d\n", cmd);
-
- if (cmd == SCIM_TRANS_CMD_FLUSH_CONFIG) {
- if (m_config_readonly) {
- LOGW ("sorry config readonly");
- continue;
- }
- if (_config.null ()) {
- LOGW ("config is not ready");
- continue;
- }
- SCIM_DEBUG_FRONTEND (2) << " socket_flush_config.\n";
-
- _config->flush ();
-
- } else if (cmd == SCIM_TRANS_CMD_ERASE_CONFIG) {
-
- String key;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_erase_config.\n";
-
- if (m_recv_trans.get_data (key)) {
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
- if (m_config_readonly) {
- LOGW ("sorry config readonly");
- continue;
- }
- _config->erase (key);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
- } else if (cmd == SCIM_TRANS_CMD_RELOAD_CONFIG) {
-
- SCIM_DEBUG_FRONTEND (2) << " socket_reload_config.\n";
- Socket client_socket (client_id);
- m_send_trans.clear ();
- m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
-
- if (_config.null ()) {
- LOGW ("config is not ready");
- m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
- } else {
- static timeval last_timestamp = {0, 0};
-
- timeval timestamp;
-
- gettimeofday (×tamp, 0);
-
- if (timestamp.tv_sec >= last_timestamp.tv_sec)
- _config->reload ();
-
- gettimeofday (&last_timestamp, 0);
- m_send_trans.put_command (SCIM_TRANS_CMD_OK);
- }
-
- m_send_trans.write_to_socket (client_socket);
-
- } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_STRING) {
- String key;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_get_config_string.\n";
-
- if (m_recv_trans.get_data (key)) {
- String value;
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
- Socket client_socket (client_id);
- m_send_trans.clear ();
- m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
- if (!_config.null () && _config->read (key, &value)) {
- m_send_trans.put_data (value);
- m_send_trans.put_command (SCIM_TRANS_CMD_OK);
- } else {
- m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
- LOGW ("read config key = %s faided\n", key.c_str());
- }
- m_send_trans.write_to_socket (client_socket);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
- } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_STRING) {
- String key;
- String value;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_set_config_string.\n";
-
- if (m_recv_trans.get_data (key) &&
- m_recv_trans.get_data (value)) {
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
- SCIM_DEBUG_FRONTEND (3) << " Value (" << value << ").\n";
- if (m_config_readonly) {
- LOGW ("sorry config readonly");
- continue;
- }
- if (_config.null ()) {
- LOGW ("config is not ready");
- continue;
- }
- _config->write (key, value);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
- } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_INT) {
- if (_config.null ()) {
- LOGW ("config not ready");
- break;
- }
-
- String key;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_get_config_int.\n";
-
- if (m_recv_trans.get_data (key)) {
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
-
- int value;
- Socket client_socket (client_id);
- m_send_trans.clear ();
- m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
- if (_config->read (key, &value)) {
- m_send_trans.put_data ((uint32) value);
- m_send_trans.put_command (SCIM_TRANS_CMD_OK);
- } else {
- m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
- LOGW ("read config key = %s faided\n", key.c_str());
- }
- m_send_trans.write_to_socket (client_socket);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
-
- } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_INT) {
-
- String key;
- uint32 value;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_set_config_int.\n";
-
- if (m_recv_trans.get_data (key) &&
- m_recv_trans.get_data (value)) {
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
- SCIM_DEBUG_FRONTEND (3) << " Value (" << value << ").\n";
- if (m_config_readonly) {
- LOGW ("sorry config readonly");
- continue;
- }
- if (_config.null ()) {
- LOGW ("config is not ready");
- continue;
- }
- _config->write (key, (int) value);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
-
- } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_BOOL) {
-
- String key;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_get_config_bool.\n";
-
- if (m_recv_trans.get_data (key)) {
- bool value;
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
- Socket client_socket (client_id);
- m_send_trans.clear ();
- m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
-
- if (!_config.null () && _config->read (key, &value)) {
- m_send_trans.put_data ((uint32) value);
- m_send_trans.put_command (SCIM_TRANS_CMD_OK);
- } else {
- m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
- LOGW ("read config key = %s faided\n", key.c_str());
- }
- m_send_trans.write_to_socket (client_socket);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
-
- } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_BOOL) {
-
- String key;
- uint32 value;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_set_config_bool.\n";
-
- if (m_recv_trans.get_data (key) &&
- m_recv_trans.get_data (value)) {
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
- SCIM_DEBUG_FRONTEND (3) << " Value (" << value << ").\n";
- if (m_config_readonly) {
- LOGW ("sorry config readonly");
- continue;
- }
- if (_config.null ()) {
- LOGW ("config is not ready");
- continue;
- }
- _config->write (key, (bool) value);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
-
- } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_DOUBLE) {
- String key;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_get_config_double.\n";
-
- if (m_recv_trans.get_data (key)) {
- double value;
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
- Socket client_socket (client_id);
- m_send_trans.clear ();
- m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
-
- if (!_config.null () && _config->read (key, &value)) {
- char buf [80];
- snprintf (buf, 79, "%lE", value);
- m_send_trans.put_data (String (buf));
- m_send_trans.put_command (SCIM_TRANS_CMD_OK);
- } else {
- m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
- LOGW ("read config key = %s faided\n", key.c_str());
- }
- m_send_trans.write_to_socket (client_socket);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
-
- } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_DOUBLE) {
-
- String key;
- String str;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_set_config_double.\n";
-
- if (m_recv_trans.get_data (key) &&
- m_recv_trans.get_data (str)) {
- double value;
- sscanf (str.c_str (), "%lE", &value);
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
- SCIM_DEBUG_FRONTEND (3) << " Value (" << value << ").\n";
- if (m_config_readonly) {
- LOGW ("sorry config readonly");
- continue;
- }
- if (_config.null ()) {
- LOGW ("config is not ready");
- continue;
- }
- _config->write (key, value);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
-
- } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_VECTOR_STRING) {
-
- String key;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_get_config_vector_string.\n";
-
- if (m_recv_trans.get_data (key)) {
- std::vector <String> vec;
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
- Socket client_socket (client_id);
- m_send_trans.clear ();
- m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
-
- if (!_config.null () && _config->read (key, &vec)) {
- m_send_trans.put_data (vec);
- m_send_trans.put_command (SCIM_TRANS_CMD_OK);
- } else {
- m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
- LOGW ("read config key = %s faided\n", key.c_str());
- }
- m_send_trans.write_to_socket (client_socket);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
-
- } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_VECTOR_STRING) {
-
- String key;
- std::vector<String> vec;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_set_config_vector_string.\n";
-
- if (m_recv_trans.get_data (key) &&
- m_recv_trans.get_data (vec)) {
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
- if (m_config_readonly) {
- LOGW ("sorry config readonly");
- continue;
- }
- if (_config.null ()) {
- LOGW ("config is not ready");
- continue;
- }
- _config->write (key, vec);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
-
- } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_VECTOR_INT) {
-
- String key;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_get_config_vector_int.\n";
-
- if (m_recv_trans.get_data (key)) {
- std::vector <int> vec;
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
- Socket client_socket (client_id);
- m_send_trans.clear ();
- m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
-
- if (!_config.null () && _config->read (key, &vec)) {
- std::vector <uint32> reply;
-
- for (uint32 i=0; i<vec.size (); ++i)
- reply.push_back ((uint32) vec[i]);
-
- m_send_trans.put_data (reply);
- m_send_trans.put_command (SCIM_TRANS_CMD_OK);
- } else {
- m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
- LOGW ("read config key = %s faided\n", key.c_str());
- }
- m_send_trans.write_to_socket (client_socket);
-
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
-
- } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_VECTOR_INT) {
-
- String key;
- std::vector<uint32> vec;
-
- SCIM_DEBUG_FRONTEND (2) << " socket_set_config_vector_int.\n";
-
- if (m_recv_trans.get_data (key) &&
- m_recv_trans.get_data (vec)) {
- if (m_config_readonly) {
- LOGW ("sorry config readonly");
- continue;
- }
- if (_config.null ()) {
- LOGW ("config is not ready");
- continue;
- }
- std::vector<int> req;
-
- SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
-
- for (uint32 i=0; i<vec.size (); ++i)
- req.push_back ((int) vec[i]);
-
- _config->write (key, req);
- } else {
- LOGW ("wrong format of transaction\n");
- break;
- }
-
- }
- }
-
- socket_transaction_end ();
}
}
EXAPI void scim_panel_agent_module_init(const scim::ConfigPointer& config)
{
LOGD ("");
- scim::_config = config;
}
EXAPI scim::PanelAgentPointer scim_panel_agent_module_get_instance()
--- /dev/null
+MAINTAINERCLEANFILES = Makefile.in
+CLEANFILES = *.bak *.edj
+EXTRA_DIST = socketconfigserver.version-script
+
+AM_CPPFLAGS = -I$(top_builddir) \
+ -I$(top_builddir)/ism/src \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/ism/src \
+ -I$(top_srcdir)/ism/intl \
+ -I$(top_srcdir)/ism/data \
+ -I$(top_srcdir)/ism/utils \
+ -I$(includedir) \
+ -DSCIM_DATADIR=\"@SCIM_DATADIR@\" \
+ -DSCIM_LOCALEDIR=\"@SCIM_LOCALEDIR@\" \
+ -DSCIM_SYSCONFDIR=\"@SCIM_SYSCONFDIR@\" \
+ -DSCIM_LIBEXECDIR=\"@SCIM_LIBEXECDIR@\" \
+ -DSCIM_ICONDIR=\"@SCIM_ICONDIR@\" \
+ -DSCIM_MODULE_PATH=\"@SCIM_MODULE_PATH@\" \
+ -DSCIM_TEMPDIR=\"@SCIM_TEMPDIR@\"
+
+noinst_HEADERS =
+
+
+CONFIG_SOCKETCONFIGSERVER_PANELAGENT_MODULE = socket_config_server.la
+
+
+if SCIM_LD_VERSION_SCRIPT
+LD_VERSION_SCRIPT_OPTION="-Wl,--version-script=$(srcdir)/socketconfigserver.version-script"
+endif
+
+moduledir = @SCIM_MODULE_PATH@/$(SCIM_BINARY_VERSION)/PanelAgent
+module_LTLIBRARIES = $(CONFIG_SOCKETCONFIGSERVER_PANELAGENT_MODULE)
+
+socket_config_server_la_SOURCES = socket_config_server_panel_agent_module.cpp
+
+socket_config_server_la_CXXFLAGS = @DLOG_CFLAGS@ @ECORE_CFLAGS@
+
+socket_config_server_la_LDFLAGS = -avoid-version \
+ -rpath $(moduledir) \
+ -module \
+ $(LD_VERSION_SCRIPT_OPTION) \
+ @LIBTOOL_EXPORT_OPTIONS@ \
+ @LTLIBINTL@ \
+ @DLOG_LIBS@ \
+ @ECORE_LIBS@
+
+socket_config_server_la_LIBADD = $(top_builddir)/ism/src/libscim@SCIM_EPOCH@.la
--- /dev/null
+/*
+ * ISF(Input Service Framework)
+ *
+ * ISF is based on SCIM 1.4.7 and extended for supporting more mobile fitable.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ *
+ * Contact: Li Zhang <li2012.zhang@samsung.com>
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#define Uses_SCIM_TRANSACTION
+#define Uses_SCIM_TRANS_COMMANDS
+#define Uses_SCIM_PANEL_AGENT
+#define Uses_SCIM_SOCKET
+#define Uses_SCIM_EVENT
+#define Uses_SCIM_CONFIG
+#define Uses_SCIM_CONFIG_MODULE
+#define Uses_SCIM_CONFIG_PATH
+#define Uses_SCIM_UTILITY
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/times.h>
+#include <dlog.h>
+#include <unistd.h>
+#include <Ecore.h>
+#include "scim_private.h"
+#include "scim.h"
+#include "scim_stl_map.h"
+
+#ifdef LOG_TAG
+# undef LOG_TAG
+#endif
+#define LOG_TAG "ISF_SOCKET_CONFIG_SERVER_MODULE"
+
+#define SCIM_CONFIG_PANEL_SOCKET_CONFIG_READONLY "/Panel/Socket/ConfigReadOnly"
+
+
+namespace scim
+{
+
+#if SCIM_USE_STL_EXT_HASH_MAP
+typedef __gnu_cxx::hash_map <int, ClientInfo, __gnu_cxx::hash <int> > ClientRepository;
+#elif SCIM_USE_STL_HASH_MAP
+typedef std::hash_map <int, ClientInfo, std::hash <int> > ClientRepository;
+#else
+typedef std::map <int, ClientInfo> ClientRepository;
+#endif
+
+
+#define scim_module_init socketconfigserver_LTX_scim_module_init
+#define scim_module_exit socketconfigserver_LTX_scim_module_exit
+#define scim_panel_agent_module_init socketconfigserver_LTX_scim_panel_agent_module_init
+#define scim_panel_agent_module_get_instance socketconfigserver_LTX_scim_panel_agent_module_get_instance
+
+
+static ConfigPointer _config;
+
+
+class SocketConfigServerPanelAgent: public PanelAgentBase
+{
+ bool m_should_exit;
+
+ int m_socket_timeout;
+ String m_socket_address;
+ SocketServer m_socket_server;
+
+ Transaction m_send_trans;
+ Transaction m_recv_trans;
+
+ bool m_ise_exiting;
+ bool m_config_readonly;
+
+ ClientRepository m_clients;
+ std::vector<Ecore_Fd_Handler*> _read_handler_list;
+ Connection m_config_connection;
+
+public:
+ SocketConfigServerPanelAgent ()
+ : PanelAgentBase ("socket_config_server"),
+ m_should_exit (false),
+ m_socket_timeout (scim_get_default_socket_timeout ()),
+ m_ise_exiting (false),
+ m_config_readonly (false) {
+ m_socket_server.signal_connect_accept (slot (this, &SocketConfigServerPanelAgent::socket_accept_callback));
+ m_socket_server.signal_connect_receive (slot (this, &SocketConfigServerPanelAgent::socket_receive_callback));
+ m_socket_server.signal_connect_exception (slot (this, &SocketConfigServerPanelAgent::socket_exception_callback));
+ }
+
+ ~SocketConfigServerPanelAgent () {
+ for (unsigned int ii = 0; ii < _read_handler_list.size (); ++ii) {
+ ecore_main_fd_handler_del (_read_handler_list[ii]);
+ }
+ _read_handler_list.clear ();
+ }
+
+ bool initialize (InfoManager* info_manager, const String& display, bool resident) {
+ LOGD ("");
+ m_socket_address = scim_get_default_socket_config_address ();
+
+ if (!_config.null ())
+ m_config_readonly = _config->read (String (SCIM_CONFIG_PANEL_SOCKET_CONFIG_READONLY), false);
+ else {
+ m_config_readonly = false;
+ LOGW ("config is not ready");
+ }
+
+ m_config_connection = _config->signal_connect_reload (slot (this, &SocketConfigServerPanelAgent::reload_config_callback));
+
+ m_socket_server.shutdown ();
+
+ if (m_socket_server.create (SocketAddress (m_socket_address))) {
+ Ecore_Fd_Handler* panel_agent_read_handler = ecore_main_fd_handler_add (m_socket_server.get_id (), ECORE_FD_READ, panel_agent_handler, this, NULL, NULL);
+ _read_handler_list.push_back (panel_agent_read_handler);
+ return true;
+ }
+
+ LOGE ("create socketconfig server failed\n");
+ return false;
+ }
+
+ bool valid (void) const {
+ return m_socket_server.valid ();
+ }
+
+ void stop (void) {
+ SCIM_DEBUG_MAIN(1) << "PanelAgent::stop ()\n";
+ LOGD ("");
+ m_config_connection.disconnect ();
+ lock ();
+ m_should_exit = true;
+ unlock ();
+ SocketClient client;
+ if (client.connect (SocketAddress (m_socket_address))) {
+ client.close ();
+ }
+ m_socket_server.shutdown ();
+ m_clients.clear ();
+ _config.reset ();
+ }
+private:
+
+ void reload_config_callback (const ConfigPointer &config) {
+
+ SCIM_DEBUG_MAIN(1) << "PanelAgent::reload_config ()\n";
+ LOGD ("");
+ for (unsigned int ii = 0; ii < _read_handler_list.size (); ++ii) {
+
+ m_send_trans.clear ();
+ m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
+ m_send_trans.put_command (SCIM_TRANS_CMD_RELOAD_CONFIG);
+
+ Socket client_socket (ecore_main_fd_handler_fd_get (_read_handler_list[ii]));
+ m_send_trans.write_to_socket (client_socket);
+ }
+ }
+
+private:
+
+ bool socket_check_client_connection (const Socket& client) {
+ SCIM_DEBUG_MAIN(3) << "PanelAgent::socket_check_client_connection (" << client.get_id () << ")\n";
+
+ unsigned char buf [sizeof(uint32)];
+
+ int nbytes = client.read_with_timeout (buf, sizeof(uint32), m_socket_timeout);
+
+ if (nbytes == sizeof(uint32))
+ return true;
+
+ if (nbytes < 0) {
+ LOGW ("Error occurred when reading socket: %s\n", client.get_error_message ().c_str());
+ } else {
+ LOGW ("Timeout when reading socket\n");
+ }
+
+ return false;
+ }
+
+ /**
+ * @brief Callback function for ecore fd handler.
+ *
+ * @param data The data to pass to this callback.
+ * @param fd_handler The ecore fd handler.
+ *
+ * @return ECORE_CALLBACK_RENEW
+ */
+ static Eina_Bool panel_agent_handler (void* data, Ecore_Fd_Handler* fd_handler) {
+ if (fd_handler == NULL || data == NULL)
+ return ECORE_CALLBACK_RENEW;
+
+ SocketConfigServerPanelAgent* _agent = (SocketConfigServerPanelAgent*)data;
+
+ int fd = ecore_main_fd_handler_fd_get (fd_handler);
+
+ for (unsigned int i = 0; i < _agent->_read_handler_list.size (); i++) {
+ if (fd_handler == _agent->_read_handler_list [i]) {
+ if (!_agent->filter_event (fd)) {
+ std::cerr << "_panel_agent->filter_event () is failed!!!\n";
+ ::close (fd);
+ ecore_main_fd_handler_del (fd_handler);
+
+ ISF_SAVE_LOG ("_panel_agent->filter_event (fd=%d) is failed!!!\n", fd);
+ }
+
+ return ECORE_CALLBACK_RENEW;
+ }
+ }
+
+ std::cerr << "panel_agent_handler () has received exception event!!!\n";
+ _agent->filter_exception_event (fd);
+ ::close (fd);
+ ecore_main_fd_handler_del (fd_handler);
+
+ ISF_SAVE_LOG ("Received exception event (fd=%d)!!!\n", fd);
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ void socket_accept_callback (SocketServer* server,
+ const Socket& client) {
+ SCIM_DEBUG_MAIN(2) << "PanelAgent::socket_accept_callback (" << client.get_id () << ")\n";
+ LOGD ("");
+ lock ();
+
+ if (m_should_exit) {
+ SCIM_DEBUG_MAIN (3) << "Exit Socket Server Thread.\n";
+ server->shutdown();
+ } else {
+ //m_signal_accept_connection (client.get_id ());
+ Ecore_Fd_Handler* panel_agent_read_handler = ecore_main_fd_handler_add (client.get_id (), ECORE_FD_READ, panel_agent_handler, this, NULL, NULL);
+ _read_handler_list.push_back (panel_agent_read_handler);
+ }
+
+ unlock ();
+ }
+
+ void socket_receive_callback (SocketServer* server,
+ const Socket& client) {
+ int client_id = client.get_id ();
+ int cmd = 0;
+ uint32 key = 0;
+
+ ClientInfo client_info;
+
+ SCIM_DEBUG_MAIN(1) << "PanelAgent::socket_receive_callback (" << client_id << ")\n";
+
+ /* If the connection is closed then close this client. */
+ if (!socket_check_client_connection (client)) {
+ LOGW ("check client connection failed\n");
+ socket_close_connection (server, client);
+ return;
+ }
+
+ ClientRepository::iterator it = m_clients.find (client.get_id ());
+ if (it == m_clients.end ()) {
+ socket_open_connection (server, client);
+ return;
+ } else
+ client_info = it->second;
+
+ /* If can not read the transaction,
+ * or the transaction is not started with SCIM_TRANS_CMD_REQUEST,
+ * or the key is mismatch,
+ * just return. */
+ if (!m_recv_trans.read_from_socket (client, m_socket_timeout) ||
+ !m_recv_trans.get_command (cmd) || cmd != SCIM_TRANS_CMD_REQUEST ||
+ !m_recv_trans.get_data (key) || key != (uint32) client_info.key) {
+ LOGW ("cmd:%d key:%d client info key: %d\n", cmd, key, client_info.key);
+ return;
+ }
+
+ {
+ socket_transaction_start ();
+ while (m_recv_trans.get_command (cmd)) {
+ LOGD ("PanelAgent::cmd = %d\n", cmd);
+
+ if (cmd == SCIM_TRANS_CMD_FLUSH_CONFIG) {
+ if (m_config_readonly) {
+ LOGW ("sorry config readonly");
+ continue;
+ }
+ if (_config.null ()) {
+ LOGW ("config is not ready");
+ continue;
+ }
+ SCIM_DEBUG_FRONTEND (2) << " socket_flush_config.\n";
+
+ _config->flush ();
+
+ } else if (cmd == SCIM_TRANS_CMD_ERASE_CONFIG) {
+
+ String key;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_erase_config.\n";
+
+ if (m_recv_trans.get_data (key)) {
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+ if (m_config_readonly) {
+ LOGW ("sorry config readonly");
+ continue;
+ }
+ _config->erase (key);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+ } else if (cmd == SCIM_TRANS_CMD_RELOAD_CONFIG) {
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_reload_config.\n";
+ Socket client_socket (client_id);
+ m_send_trans.clear ();
+ m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
+
+ if (_config.null ()) {
+ LOGW ("config is not ready");
+ m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
+ } else {
+ static timeval last_timestamp = {0, 0};
+
+ timeval timestamp;
+
+ gettimeofday (×tamp, 0);
+
+ if (timestamp.tv_sec >= last_timestamp.tv_sec)
+ _config->reload ();
+
+ gettimeofday (&last_timestamp, 0);
+ m_send_trans.put_command (SCIM_TRANS_CMD_OK);
+ }
+
+ m_send_trans.write_to_socket (client_socket);
+
+ } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_STRING) {
+ String key;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_get_config_string.\n";
+
+ if (m_recv_trans.get_data (key)) {
+ String value;
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+ Socket client_socket (client_id);
+ m_send_trans.clear ();
+ m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
+ if (!_config.null () && _config->read (key, &value)) {
+ LOGD ("get %s:%s", key.c_str (), value.c_str ());
+ m_send_trans.put_data (value);
+ m_send_trans.put_command (SCIM_TRANS_CMD_OK);
+ } else {
+ m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
+ LOGW ("read config key = %s faided\n", key.c_str ());
+ }
+ m_send_trans.write_to_socket (client_socket);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+ } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_STRING) {
+ String key;
+ String value;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_set_config_string.\n";
+
+ if (m_recv_trans.get_data (key) &&
+ m_recv_trans.get_data (value)) {
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+ SCIM_DEBUG_FRONTEND (3) << " Value (" << value << ").\n";
+ if (m_config_readonly) {
+ LOGW ("sorry config readonly");
+ continue;
+ }
+ if (_config.null ()) {
+ LOGW ("config is not ready");
+ continue;
+ }
+ LOGD ("set %s:%s", key.c_str (), value.c_str ());
+ _config->write (key, value);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+ } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_INT) {
+ if (_config.null ()) {
+ LOGW ("config not ready");
+ break;
+ }
+
+ String key;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_get_config_int.\n";
+
+ if (m_recv_trans.get_data (key)) {
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+
+ int value;
+ Socket client_socket (client_id);
+ m_send_trans.clear ();
+ m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
+ if (_config->read (key, &value)) {
+ LOGD ("get %s:%d", key.c_str (), value);
+ m_send_trans.put_data ((uint32) value);
+ m_send_trans.put_command (SCIM_TRANS_CMD_OK);
+ } else {
+ m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
+ LOGW ("read config key = %s faided\n", key.c_str ());
+ }
+ m_send_trans.write_to_socket (client_socket);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+
+ } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_INT) {
+
+ String key;
+ uint32 value;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_set_config_int.\n";
+
+ if (m_recv_trans.get_data (key) &&
+ m_recv_trans.get_data (value)) {
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+ SCIM_DEBUG_FRONTEND (3) << " Value (" << value << ").\n";
+ if (m_config_readonly) {
+ LOGW ("sorry config readonly");
+ continue;
+ }
+ if (_config.null ()) {
+ LOGW ("config is not ready");
+ continue;
+ }
+ LOGD ("set %s:%d", key.c_str (), value);
+ _config->write (key, (int) value);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+
+ } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_BOOL) {
+
+ String key;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_get_config_bool.\n";
+
+ if (m_recv_trans.get_data (key)) {
+ bool value;
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+ Socket client_socket (client_id);
+ m_send_trans.clear ();
+ m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
+
+ if (!_config.null () && _config->read (key, &value)) {
+ m_send_trans.put_data ((uint32) value);
+ m_send_trans.put_command (SCIM_TRANS_CMD_OK);
+ } else {
+ m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
+ LOGW ("read config key = %s faided\n", key.c_str ());
+ }
+ m_send_trans.write_to_socket (client_socket);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+
+ } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_BOOL) {
+
+ String key;
+ uint32 value;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_set_config_bool.\n";
+
+ if (m_recv_trans.get_data (key) &&
+ m_recv_trans.get_data (value)) {
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+ SCIM_DEBUG_FRONTEND (3) << " Value (" << value << ").\n";
+ if (m_config_readonly) {
+ LOGW ("sorry config readonly");
+ continue;
+ }
+ if (_config.null ()) {
+ LOGW ("config is not ready");
+ continue;
+ }
+ _config->write (key, (bool) value);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+
+ } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_DOUBLE) {
+ String key;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_get_config_double.\n";
+
+ if (m_recv_trans.get_data (key)) {
+ double value;
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+ Socket client_socket (client_id);
+ m_send_trans.clear ();
+ m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
+
+ if (!_config.null () && _config->read (key, &value)) {
+ char buf [80];
+ snprintf (buf, 79, "%lE", value);
+ m_send_trans.put_data (String (buf));
+ m_send_trans.put_command (SCIM_TRANS_CMD_OK);
+ } else {
+ m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
+ LOGW ("read config key = %s faided\n", key.c_str());
+ }
+ m_send_trans.write_to_socket (client_socket);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+
+ } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_DOUBLE) {
+
+ String key;
+ String str;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_set_config_double.\n";
+
+ if (m_recv_trans.get_data (key) &&
+ m_recv_trans.get_data (str)) {
+ double value;
+ sscanf (str.c_str (), "%lE", &value);
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+ SCIM_DEBUG_FRONTEND (3) << " Value (" << value << ").\n";
+ if (m_config_readonly) {
+ LOGW ("sorry config readonly");
+ continue;
+ }
+ if (_config.null ()) {
+ LOGW ("config is not ready");
+ continue;
+ }
+ _config->write (key, value);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+
+ } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_VECTOR_STRING) {
+
+ String key;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_get_config_vector_string.\n";
+
+ if (m_recv_trans.get_data (key)) {
+ std::vector <String> vec;
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+ Socket client_socket (client_id);
+ m_send_trans.clear ();
+ m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
+
+ if (!_config.null () && _config->read (key, &vec)) {
+ m_send_trans.put_data (vec);
+ m_send_trans.put_command (SCIM_TRANS_CMD_OK);
+ } else {
+ m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
+ LOGW ("read config key = %s faided\n", key.c_str());
+ }
+ m_send_trans.write_to_socket (client_socket);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+
+ } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_VECTOR_STRING) {
+
+ String key;
+ std::vector<String> vec;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_set_config_vector_string.\n";
+
+ if (m_recv_trans.get_data (key) &&
+ m_recv_trans.get_data (vec)) {
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+ if (m_config_readonly) {
+ LOGW ("sorry config readonly");
+ continue;
+ }
+ if (_config.null ()) {
+ LOGW ("config is not ready");
+ continue;
+ }
+ _config->write (key, vec);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+
+ } else if (cmd == SCIM_TRANS_CMD_GET_CONFIG_VECTOR_INT) {
+
+ String key;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_get_config_vector_int.\n";
+
+ if (m_recv_trans.get_data (key)) {
+ std::vector <int> vec;
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+ Socket client_socket (client_id);
+ m_send_trans.clear ();
+ m_send_trans.put_command (SCIM_TRANS_CMD_REPLY);
+
+ if (!_config.null () && _config->read (key, &vec)) {
+ std::vector <uint32> reply;
+
+ for (uint32 i=0; i < vec.size (); ++i)
+ reply.push_back ((uint32) vec[i]);
+
+ m_send_trans.put_data (reply);
+ m_send_trans.put_command (SCIM_TRANS_CMD_OK);
+ } else {
+ m_send_trans.put_command (SCIM_TRANS_CMD_FAIL);
+ LOGW ("read config key = %s faided\n", key.c_str());
+ }
+ m_send_trans.write_to_socket (client_socket);
+
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+
+ } else if (cmd == SCIM_TRANS_CMD_SET_CONFIG_VECTOR_INT) {
+
+ String key;
+ std::vector<uint32> vec;
+
+ SCIM_DEBUG_FRONTEND (2) << " socket_set_config_vector_int.\n";
+
+ if (m_recv_trans.get_data (key) &&
+ m_recv_trans.get_data (vec)) {
+ if (m_config_readonly) {
+ LOGW ("sorry config readonly");
+ continue;
+ }
+ if (_config.null ()) {
+ LOGW ("config is not ready");
+ continue;
+ }
+ std::vector<int> req;
+
+ SCIM_DEBUG_FRONTEND (3) << " Key (" << key << ").\n";
+
+ for (uint32 i=0; i < vec.size (); ++i)
+ req.push_back ((int) vec[i]);
+
+ _config->write (key, req);
+ } else {
+ LOGW ("wrong format of transaction\n");
+ break;
+ }
+
+ }
+ }
+
+ socket_transaction_end ();
+ }
+ }
+
+ void socket_exception_callback (SocketServer* server,
+ const Socket& client) {
+ SCIM_DEBUG_MAIN(2) << "PanelAgent::socket_exception_callback (" << client.get_id() << ")\n";
+ LOGD ("client id:%d\n", client.get_id ());
+ socket_close_connection (server, client);
+ }
+
+ bool socket_open_connection (SocketServer* server,
+ const Socket& client) {
+ SCIM_DEBUG_MAIN(3) << "PanelAgent::socket_open_connection (" << client.get_id() << ")\n";
+ LOGD ("client id:%d\n", client.get_id());
+ uint32 key;
+ String type = scim_socket_accept_connection (key,
+ String ("Panel"),
+ String ("SocketConfig"),
+ client,
+ m_socket_timeout);
+
+ SCIM_DEBUG_MAIN (3) << "type = " << type << "\n";
+ if (type.length ()) {
+ ClientInfo info;
+ info.key = key;
+ info.type = CONFIG_CLIENT;
+ m_clients [client.get_id ()] = info;
+ return true;
+ }
+ LOGW ("open_connection failed\n");
+
+ SCIM_DEBUG_MAIN(4) << "Close client connection " << client.get_id () << "\n";
+ server->close_connection (client);
+ return false;
+ }
+
+ void socket_close_connection (SocketServer* server,
+ const Socket& client) {
+ SCIM_DEBUG_MAIN(3) << "PanelAgent::socket_close_connection (" << client.get_id () << ")\n";
+ LOGD ("client id:%d\n", client.get_id ());
+
+ ClientRepository::iterator it = m_clients.find (client.get_id ());
+ if (it != m_clients.end ())
+ m_clients.erase (client.get_id ());
+
+ int i = 0;
+ std::vector<Ecore_Fd_Handler *>::iterator IterPos;
+
+ for (IterPos = _read_handler_list.begin (); IterPos != _read_handler_list.end (); ++IterPos,++i) {
+ if (ecore_main_fd_handler_fd_get (_read_handler_list[i]) == client.get_id ()) {
+ ecore_main_fd_handler_del (_read_handler_list[i]);
+ ::close (client.get_id ());
+ _read_handler_list.erase (IterPos);
+ break;
+ }
+ }
+ LOGD ("client:%d , read handler: %d", m_clients.size (), _read_handler_list.size ());
+ }
+
+ bool filter_event (int fd) {
+ SCIM_DEBUG_MAIN(1) << "PanelAgent::filter_event ()\n";
+
+ return m_socket_server.filter_event (fd);
+ }
+
+ bool filter_exception_event (int fd) {
+ SCIM_DEBUG_MAIN(1) << "PanelAgent::filter_exception_event ()\n";
+
+ return m_socket_server.filter_exception_event (fd);
+ }
+
+ void socket_transaction_start (void) {
+ //m_signal_transaction_start ();
+ }
+
+ void socket_transaction_end (void) {
+ //m_signal_transaction_end ();
+ }
+
+ void lock (void) {
+ //m_signal_lock ();
+ }
+ void unlock (void) {
+ //m_signal_unlock ();
+ }
+};
+
+} /* namespace scim */
+
+/***************************************************/
+/*** Beginning of panel agent interface for ISF ***/
+/***************************************************/
+static scim::PanelAgentPointer instance;
+
+extern "C" {
+
+ EXAPI void scim_module_init (void)
+ {
+ }
+
+ EXAPI void scim_module_exit (void)
+ {
+ instance.reset ();
+ }
+
+ EXAPI void scim_panel_agent_module_init (const scim::ConfigPointer& config)
+ {
+ LOGD ("");
+ scim::_config = config;
+ }
+
+ EXAPI scim::PanelAgentPointer scim_panel_agent_module_get_instance ()
+ {
+ scim::PanelAgentBase* _instance = NULL;
+ if (instance.null ()) {
+ try {
+ _instance = new scim::SocketConfigServerPanelAgent ();
+ } catch (...) {
+ delete _instance;
+ _instance = NULL;
+ }
+ if (_instance)
+ instance = _instance;
+ }
+ return instance;
+ }
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab
+*/
--- /dev/null
+SCIM_IMENGINE_1.0 {
+ global:
+ extern "C" {
+ *scim_panel_agent_module_create_instance*;
+ *scim_panel_agent_module_init*;
+ *scim_module_exit*;
+ *scim_module_init*;
+ };
+
+ local:
+ extern "C++" {
+ scim::*;
+ std::*;
+ __gnu_cxx::*;
+ };
+};
int caret);
static void panel_req_update_bidi_direction (WSCContextISF *ic, int direction);
-/* Panel iochannel handler*/
-static void panel_initialize (void);
-static void panel_finalize (void);
-
-
/* utility functions */
static bool filter_keys (const char *keyname,
const char *config_path);
static void set_ic_capabilities (WSCContextISF *ic);
-static void initialize (void);
-static void finalize (void);
-
static void send_wl_key_event (WSCContextISF *ic, const KeyEvent &key, bool fake);
static void _hide_preedit_string (int context, bool update_preedit);
static WSCContextISF *_focused_ic = 0;
-static bool _scim_initialized = false;
-
static int _panel_client_id = 0;
static uint32 _active_helper_option = 0;
return new_text;
}
-/* Public functions */
-void
-isf_wsc_context_init (void)
-{
- SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << "...\n";
- LOGD ("");
- int val;
-
- if (!_scim_initialized) {
- ecore_wl_init (NULL);
- initialize ();
- _scim_initialized = true;
- isf_wsc_input_panel_init ();
- //isf_wsc_context_set_hardware_keyboard_mode(context_scim);
-
- /* get autoperiod allow vconf value */
- if (vconf_get_bool (VCONFKEY_AUTOPERIOD_ALLOW_BOOL, &val) == 0) {
- if (val == EINA_TRUE)
- autoperiod_allow = EINA_TRUE;
- }
-
- vconf_notify_key_changed (VCONFKEY_AUTOPERIOD_ALLOW_BOOL, autoperiod_allow_changed_cb, NULL);
-
- /* get autocapital allow vconf value */
- if (vconf_get_bool (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, &val) == 0) {
- if (val == EINA_TRUE)
- autocap_allow = EINA_TRUE;
- }
-
- vconf_notify_key_changed (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, autocapital_allow_changed_cb, NULL);
-
- /* get input language vconf value */
- get_input_language ();
-
- vconf_notify_key_changed (VCONFKEY_ISF_INPUT_LANGUAGE, input_language_changed_cb, NULL);
- }
-}
-
-void
-isf_wsc_context_shutdown (void)
-{
- LOGD ("");
- SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << "...\n";
-
- if (_scim_initialized) {
- _scim_initialized = false;
-
- vconf_ignore_key_changed (VCONFKEY_AUTOPERIOD_ALLOW_BOOL, autoperiod_allow_changed_cb);
- vconf_ignore_key_changed (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, autocapital_allow_changed_cb);
- vconf_ignore_key_changed (VCONFKEY_ISF_INPUT_LANGUAGE, input_language_changed_cb);
-
- isf_wsc_input_panel_shutdown ();
- finalize ();
- ecore_wl_shutdown ();
- }
-}
-
void
isf_wsc_context_add (WSCContextISF *wsc_ctx)
{
}
static void
-panel_initialize (void)
-{
- SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << "...\n";
- LOGD ("");
- String display_name;
- {
- const char *p = getenv ("DISPLAY");
- if (p) display_name = String (p);
- }
- g_info_manager->add_client (WAYLAND_MODULE_CLIENT_ID, 2, FRONTEND_CLIENT);
- _panel_client_id = WAYLAND_MODULE_CLIENT_ID;
- g_info_manager->register_panel_client (_panel_client_id, _panel_client_id);
- WSCContextISF* context_scim = _ic_list;
-
- while (context_scim != NULL) {
- //FIXME:modify the parameter
- g_info_manager->register_input_context (WAYLAND_MODULE_CLIENT_ID, context_scim->id, "");
-
- context_scim = context_scim->next;
- }
-
- if (_focused_ic) {
- _focused_ic = 0;
- }
-}
-
-static void
-panel_finalize (void)
-{
- SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << "...\n";
- LOGD ("");
- g_info_manager->del_client (WAYLAND_MODULE_CLIENT_ID);
-}
-
-static void
panel_slot_update_preedit_caret (int context, int caret)
{
LOGD ("");
}
}
-void
-initialize (void)
-{
-
- LOGD ("Initializing Wayland ISF IMModule...\n");
-
- // Get system language.
- _language = scim_get_locale_language (scim_get_current_locale ());
-
- panel_initialize ();
-}
-
-static void
-finalize (void)
-{
- LOGD ("Finalizing Ecore ISF IMModule...\n");
-
- SCIM_DEBUG_FRONTEND(2) << "Finalize all IC partially.\n";
- while (_used_ic_impl_list) {
- // In case in "shared input method" mode,
- // all contexts share only one instance,
- // so we need point the reference pointer correctly before finalizing.
- #if 0 //REMOVE
- if (_used_ic_impl_list->si) {
- _used_ic_impl_list->si->set_frontend_data (static_cast <void*> (_used_ic_impl_list->parent));
- }
- #endif
- if (_used_ic_impl_list->parent && _used_ic_impl_list->parent->ctx) {
- isf_wsc_context_del (_used_ic_impl_list->parent);
- }
- }
-
- delete_all_ic_impl ();
-
- SCIM_DEBUG_FRONTEND(2) << " Releasing Config...\n";
- _config.reset ();
- _focused_ic = NULL;
- _ic_list = NULL;
-
- _scim_initialized = false;
- panel_finalize ();
-}
-
static uint32_t _keyname_to_keysym (uint32_t keyname, uint32_t *modifiers)
{
if (!modifiers)
: PanelAgentBase ("wayland") {
}
~WaylandPanelAgent () {
- stop ();
}
bool initialize (InfoManager* info_manager, const String& display, bool resident) {
- LOGD ("");
+ LOGD ("Initializing Wayland ISF IMModule...\n");
+
g_info_manager = info_manager;
- isf_wsc_context_init ();
+ int val;
+
+ ecore_wl_init (NULL);
+
+ // Get system language.
+ _language = scim_get_locale_language (scim_get_current_locale ());
+
+ String display_name;
+ {
+ const char *p = getenv ("DISPLAY");
+ if (p) display_name = String (p);
+ }
+
+ g_info_manager->add_client (WAYLAND_MODULE_CLIENT_ID, 2, FRONTEND_CLIENT);
+ _panel_client_id = WAYLAND_MODULE_CLIENT_ID;
+ g_info_manager->register_panel_client (_panel_client_id, _panel_client_id);
+ WSCContextISF* context_scim = _ic_list;
+
+ while (context_scim != NULL) {
+ //FIXME:modify the parameter
+ g_info_manager->register_input_context (WAYLAND_MODULE_CLIENT_ID, context_scim->id, "");
+
+ context_scim = context_scim->next;
+ }
+
+ if (_focused_ic) {
+ _focused_ic = 0;
+ }
+
+ isf_wsc_input_panel_init ();
+ //isf_wsc_context_set_hardware_keyboard_mode(context_scim);
+
+ /* get autoperiod allow vconf value */
+ if (vconf_get_bool (VCONFKEY_AUTOPERIOD_ALLOW_BOOL, &val) == 0) {
+ if (val == EINA_TRUE)
+ autoperiod_allow = EINA_TRUE;
+ }
+
+ vconf_notify_key_changed (VCONFKEY_AUTOPERIOD_ALLOW_BOOL, autoperiod_allow_changed_cb, NULL);
+
+ /* get autocapital allow vconf value */
+ if (vconf_get_bool (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, &val) == 0) {
+ if (val == EINA_TRUE)
+ autocap_allow = EINA_TRUE;
+ }
+
+ vconf_notify_key_changed (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, autocapital_allow_changed_cb, NULL);
+
+ /* get input language vconf value */
+ get_input_language ();
+
+ vconf_notify_key_changed (VCONFKEY_ISF_INPUT_LANGUAGE, input_language_changed_cb, NULL);
if (!_wsc_setup (&_wsc)) {
return false;
return true;
}
+
bool valid (void) const {
return true;
}
void stop (void) {
+ LOGD ("");
+ SCIM_DEBUG_FRONTEND (1) << __FUNCTION__ << "...\n";
+
+ vconf_ignore_key_changed (VCONFKEY_AUTOPERIOD_ALLOW_BOOL, autoperiod_allow_changed_cb);
+ vconf_ignore_key_changed (VCONFKEY_AUTOCAPITAL_ALLOW_BOOL, autocapital_allow_changed_cb);
+ vconf_ignore_key_changed (VCONFKEY_ISF_INPUT_LANGUAGE, input_language_changed_cb);
+
+ isf_wsc_input_panel_shutdown ();
+
+ while (_used_ic_impl_list) {
+ // In case in "shared input method" mode,
+ // all contexts share only one instance,
+ // so we need point the reference pointer correctly before finalizing.
+ #if 0 //REMOVE
+ if (_used_ic_impl_list->si) {
+ _used_ic_impl_list->si->set_frontend_data (static_cast <void*> (_used_ic_impl_list->parent));
+ }
+ #endif
+ if (_used_ic_impl_list->parent && _used_ic_impl_list->parent->ctx) {
+ isf_wsc_context_del (_used_ic_impl_list->parent);
+ }
+ }
+
+ delete_all_ic_impl ();
+
+ _focused_ic = NULL;
+ _ic_list = NULL;
+
+ g_info_manager->del_client (WAYLAND_MODULE_CLIENT_ID);
+
_config_connection.disconnect ();
- isf_wsc_context_shutdown ();
+ _config.reset ();
+
+ ecore_wl_shutdown ();
}
public:
- void
- exit (int id, uint32 contextid) {
- LOGD ("client id:%d", id);
- finalize ();
- }
void
update_preedit_caret (int id, uint32 context_id, uint32 caret) {
}
void
- reload_config (int id)
- {
- LOGD ("client id:%d", id);
- }
-
- void
hide_helper_ise (int id, uint32 context_id)
{
LOGD ("client id:%d", id);
set_helper_caps_mode (m_current_helper_uuid, mode);
}
- //SCIM_TRANS_CMD_RELOAD_CONFIG
- void reload_config (void) {
- SCIM_DEBUG_MAIN (1) << "InfoManager::reload_config ()\n";
- LOGD ("");
- lock ();
-
- for (ClientRepository::iterator it = m_client_repository.begin (); it != m_client_repository.end (); ++it) {
- if (it->second.type == FRONTEND_CLIENT || it->second.type == HELPER_CLIENT) {
- m_panel_agent_manager.reload_config (it->first);
- }
- }
-
- unlock ();
- }
-
- bool exit (void) {
- SCIM_DEBUG_MAIN (1) << "InfoManager::exit ()\n";
- lock ();
-
- for (ClientRepository::iterator it = m_client_repository.begin (); it != m_client_repository.end (); ++it) {
- m_panel_agent_manager.exit (it->first, 0);
- }
-
- unlock ();
- stop ();
- return true;
- }
-
void update_ise_list (std::vector<String>& strList) {
/* request PanelClient to update keyboard ise list */
update_keyboard_ise_list ();
void
InfoManager::stop (void)
{
- if (m_impl != NULL)
- m_impl->stop ();
+ m_impl->stop ();
}
const ClientInfo&
m_impl->set_should_shared_ise (should_shared_ise);
}
-//void
-//InfoManager::reload_config (void)
-//{
-// m_impl->reload_config ();
-//}
-
-bool
-InfoManager::exit (void)
-{
- return m_impl->exit ();
-}
void
InfoManager::update_ise_list (std::vector<String>& strList)
{
m_impl->set_ise_caps_mode (client_id, mode);
}
-//SCIM_TRANS_CMD_RELOAD_CONFIG
-void InfoManager::reload_config (void)
-{
- m_impl->reload_config ();
-}
-
//ISM_TRANS_CMD_SEND_WILL_SHOW_ACK
void InfoManager::will_show_ack (int client_id)
{
bool stop_helper (const String& uuid);
/**
- * @brief Let all FrontEnds and Helpers reload configuration.
- * @return true if the command was sent correctly.
- */
- //void reload_config (void);
-
- /**
- * @brief Let all FrontEnds, Helpers and this Panel exit.
- * @return true if the command was sent correctly.
- */
- bool exit (void);
-
-
- /**
* @brief Send candidate longpress event to ISE.
*
* @param type The candidate object type.
void set_ise_caps_mode (int client_id, uint32 mode);
- //SCIM_TRANS_CMD_RELOAD_CONFIG
- void reload_config (void);
-
-
//ISM_TRANS_CMD_SEND_WILL_SHOW_ACK
void will_show_ack (int client_id);
LOGW ("not implemented for %s", m_name.c_str ());
}
-
void PanelAgentBase::exit (int client, uint32 context)
{
LOGW ("not implemented for %s", m_name.c_str ());
LOGW ("not implemented for %s", m_name.c_str ());
}
-void PanelAgentBase::reload_config (int client)
-{
- LOGW ("not implemented for %s", m_name.c_str ());
-}
-
void PanelAgentBase::socket_update_surrounding_text (int client, uint32 context, const String& uuid, String& text, uint32 cursor)
{
LOGW ("not implemented for %s", m_name.c_str ());
virtual void trigger_property (int client, uint32 context, const String& property);
/**
- * @brief Let all FrontEnds and Helpers reload configuration.
- * @return true if the command was sent correctly.
- */
- virtual void reload_config (int client);
-
- /**
* @brief Let all FrontEnds, Helpers and this Panel exit.
* @return true if the command was sent correctly.
*/
PanelAgentPointer m_socket;
PanelAgentPointer m_wayland;
+ PanelAgentPointer m_config;
public:
PanelAgentManagerImpl () {
}
~PanelAgentManagerImpl () {
m_socket.reset(0);
m_wayland.reset(0);
+ m_config.reset (0);
std::vector<PanelAgentModule*>::iterator iter = m_panel_agent_modules.begin ();
for (; iter != m_panel_agent_modules.end (); iter++) {
if (_panel_agent_module->get_module_name () == "wayland")
m_impl->m_wayland = _panelagent;
- else
+ else if (_panel_agent_module->get_module_name () == "ecoresocket")
m_impl->m_socket = _panelagent;
+ else if (_panel_agent_module->get_module_name () == "socketconfigserver")
+ m_impl->m_config = _panelagent;
}
return true;
void PanelAgentManager::stop (void)
{
- SCIM_DEBUG_MAIN (1) << "PanelAgent::stop ()\n";
+ LOGD ("");
+ if (!m_impl->m_wayland.null ())
+ m_impl->m_wayland->stop ();
+ if (!m_impl->m_socket.null ())
+ m_impl->m_socket->stop ();
+ if (!m_impl->m_config.null ())
+ m_impl->m_config->stop ();
}
void PanelAgentManager::update_panel_event (int id, uint32 context_id, int cmd, uint32 nType, uint32 nValue)
_p->socket_start_helper (id, context_id, ic_uuid);
}
-
void PanelAgentManager::exit (int id, uint32 context_id)
{
PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
_p->reset_helper_context (id, context_id, uuid);
}
-void PanelAgentManager::reload_config (int id)
-{
- PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
-
- if (!_p.null ())
- _p->reload_config (id);
-}
-
void PanelAgentManager::socket_update_surrounding_text (int id, uint32 context_id, const String& uuid, String& text, uint32 cursor)
{
PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
*/
void trigger_property (int client, uint32 context, const String& property);
-
-
- /**
- * @brief Let all FrontEnds and Helpers reload configuration.
- * @return true if the command was sent correctly.
- */
- void reload_config (int client);
-
/**
* @brief Let all FrontEnds, Helpers and this Panel exit.
* @return true if the command was sent correctly.
HelperAgentSignalVoid signal_exit;
HelperAgentSignalVoid signal_attach_input_context;
HelperAgentSignalVoid signal_detach_input_context;
- HelperAgentSignalVoid signal_reload_config;
+ //Deprecated
+ //HelperAgentSignalVoid signal_reload_config;
HelperAgentSignalInt signal_update_screen;
HelperAgentSignalIntInt signal_update_spot_location;
HelperAgentSignalInt signal_update_cursor_position;
send.write_to_socket (socket_active, magic_active);
}
}
+
private:
HelperAgentImpl () : magic (0), magic_active (0), timeout (-1), focused_ic ((uint32) -1) { }
};
m_impl->signal_exit(this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
break;
}
- case SCIM_TRANS_CMD_RELOAD_CONFIG:
- {
- MessageItemReloadConfig *subclass = static_cast<MessageItemReloadConfig*>(message);
- m_impl->signal_reload_config (this, subclass->get_ic_ref(), subclass->get_ic_uuid_ref());
- if (!m_impl->m_config.null())
- m_impl->m_config->ConfigBase::reload();
- break;
- }
case SCIM_TRANS_CMD_UPDATE_SCREEN:
{
MessageItemUpdateScreen *subclass = static_cast<MessageItemUpdateScreen*>(message);
}
/**
+ * Deprecated: replace by ConfigBase::get (false, "socket")->reload()
* @brief Request SCIM to reload all configuration.
*
* This function should only by used by Setup Helper to request
HelperAgent::reload_config () const
{
LOGD ("");
-#if 0 //reload config message only send by socketconfig client
- if (m_impl->socket_active.is_connected ()) {
- m_impl->send.clear ();
- m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
- m_impl->send.put_data (m_impl->magic_active);
- m_impl->send.put_command (SCIM_TRANS_CMD_RELOAD_CONFIG);
- m_impl->send.write_to_socket (m_impl->socket_active, m_impl->magic_active);
- }
-#endif
if (!m_impl->m_config.null())
m_impl->m_config->reload();
}
}
/**
+ * Deprecated: replace by ConfigBase::get (false, "socket")->signal_connect_reload (slot (reload_config_callback));
* @brief Connect a slot to Helper reload config signal.
*
* This signal is used to let the Helper reload configuration.
Connection
HelperAgent::signal_connect_reload_config (HelperAgentSlotVoid *slot)
{
- return m_impl->signal_reload_config.connect (slot);
+ //return m_impl->signal_reload_config.connect (slot);
+ return Connection();
}
/**
return -1;
}
- //FIXME
- //Temporary solution
- //remove this if simple socket config server is done
- config = "simple";
-
ConfigPointer config_pointer = ConfigBase::get (true, config);
if (config_pointer.null ()) {
#define SCIM_DEFAULT_SOCKET_FRONTEND_ADDRESS "local:/tmp/scim-socket-frontend"
#define SCIM_DEFAULT_PANEL_SOCKET_ADDRESS "local:/tmp/scim-panel-socket"
#define SCIM_DEFAULT_HELPER_MANAGER_SOCKET_ADDRESS "local:/tmp/scim-socket-frontend"
+#define SCIM_DEFAULT_SOCKET_CONFIG_SOCKET_ADDRESS "local:/tmp/scim-socket-config"
String scim_get_default_socket_frontend_address ()
{
String scim_get_default_socket_config_address ()
{
- String address (SCIM_DEFAULT_SOCKET_FRONTEND_ADDRESS);
+ String address (SCIM_DEFAULT_SOCKET_CONFIG_SOCKET_ADDRESS);
address = scim_global_config_read (SCIM_GLOBAL_CONFIG_DEFAULT_SOCKET_CONFIG_ADDRESS, address);
}
if (address == "default")
- address = SCIM_DEFAULT_SOCKET_FRONTEND_ADDRESS;
+ address = SCIM_DEFAULT_SOCKET_CONFIG_SOCKET_ADDRESS;
return address;
}