Update ISE language locale before emitting LANGUAGE_CHANGED event 68/169068/1
authorJi-hoon Lee <dalton.lee@samsung.com>
Fri, 2 Feb 2018 05:54:29 +0000 (14:54 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Fri, 2 Feb 2018 05:54:34 +0000 (14:54 +0900)
Change-Id: I4a078d5bcce5ea231007c06ab52416606093701c

ism/modules/panelagent/ecoresocket/ecore_socket_panel_agent_module.cpp
ism/modules/panelagent/wayland/wayland_panel_agent_module.cpp
ism/src/isf_info_manager.cpp
ism/src/isf_info_manager.h
ism/src/isf_panel_agent_base.cpp
ism/src/isf_panel_agent_base.h
ism/src/isf_panel_agent_manager.cpp
ism/src/isf_panel_agent_manager.h
ism/src/scim_helper.cpp
ism/src/scim_panel_client.h
ism/src/scim_trans_commands.h

index 1f19192..15c4e31 100644 (file)
@@ -2702,6 +2702,21 @@ private:
                     } else {
                         LOGW ("wrong format of transaction");
                     }
+                } else if (cmd == ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE) {
+                    String locale;
+
+                    char* data = NULL;
+                    size_t len;
+                    if (m_recv_trans.get_data(&data, len)) {
+                        if (data && len) {
+                            locale = String(data, len);
+                            m_info_manager->socket_helper_update_language_locale(client_id, locale);
+                        } else {
+                            LOGW("wrong format of transaction : %p %d", data, len);
+                        }
+                    } else {
+                        LOGW("wrong format of transaction");
+                    }
                 } else if (cmd == ISM_TRANS_CMD_GET_KEYBOARD_ISE_LIST) {
                     String uuid;
 
index e1d6418..1b6ad74 100644 (file)
@@ -3019,15 +3019,32 @@ public:
 
         if (type == ECORE_IMF_INPUT_PANEL_LANGUAGE_EVENT) {
             WSCContextISF* ic = find_ic (context);
-            if (ic) {
-                isf_wsc_context_input_panel_language_locale_get (_focused_ic, &(ic->language));
-                if (ic->language)
-                    wl_input_method_context_language (_focused_ic->im_ctx, _focused_ic->serial, ic->language);
+            if (ic && ic->language) {
+                wl_input_method_context_language (_focused_ic->im_ctx, _focused_ic->serial, ic->language);
+            }
+            else {
+                LOGE("language locale query failed : %p %s", ic, (ic ? ic->language : "NULL"));
+                wl_input_method_context_language (_focused_ic->im_ctx, _focused_ic->serial, "");
             }
         }
         wl_input_method_context_input_panel_event (_focused_ic->im_ctx, _focused_ic->serial, type, value);
     }
 
+    void
+    update_ise_language_locale (int client, uint32 context, String locale) {
+        if (!_focused_ic || !_focused_ic->im_ctx)
+            return;
+
+        WSCContextISF* ic = find_ic (context);
+        if (ic && locale.length() > 0) {
+            if (ic->language) {
+                free(ic->language);
+                ic->language = NULL;
+            }
+            ic->language = strdup(locale.c_str());
+        }
+    }
+
 #if 0
     void
     request_help (int id, uint32 context_id) {
index 5261802..c0e68b8 100644 (file)
@@ -318,6 +318,7 @@ class InfoManager::InfoManagerImpl
     InfoManagerSignalVoid                m_signal_start_default_ise;
     InfoManagerSignalVoid                m_signal_stop_default_ise;
     InfoManagerSignalIntInt              m_signal_update_input_context;
+    InfoManagerSignalString              m_signal_update_language_locale;
     InfoManagerSignalIntInt              m_signal_set_candidate_ui;
     InfoManagerSignalIntInt2             m_signal_get_candidate_ui;
     InfoManagerSignalIntInt              m_signal_set_candidate_position;
@@ -2451,6 +2452,10 @@ public:
         return m_signal_update_input_context.connect (slot);
     }
 
+    Connection signal_connect_update_language_locale(InfoManagerSlotString*                 slot) {
+        return m_signal_update_language_locale.connect(slot);
+    }
+
     Connection signal_connect_show_ise (InfoManagerSlotVoid*                slot) {
         return m_signal_show_ise.connect (slot);
     }
@@ -3803,6 +3808,22 @@ client context helpers: %d, helpers uuid count: %d",
             std::cerr << "focused client is not existed!!!" << "\n";
         }
     }
+    //ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE
+    void socket_helper_update_language_locale(int client, String locale) {
+        SCIM_DEBUG_MAIN(4) << "InfoManager::socket_helper_update_language_locale (" << client << ")\n";
+        m_signal_update_language_locale(locale);
+
+        int    focused_client;
+        uint32 focused_context;
+        get_focused_context(focused_client, focused_context);
+        ClientInfo client_info = socket_get_client_info(focused_client);
+
+        if (client_info.type == FRONTEND_CLIENT) {
+            m_panel_agent_manager.update_ise_language_locale(focused_client, focused_context, locale);
+        } else {
+            std::cerr << "focused client is not existed!!!" << "\n";
+        }
+    }
     //SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND
     void socket_helper_send_private_command (int client, String command) {
         SCIM_DEBUG_MAIN (4) << __FUNCTION__ << " (" << client << ")\n";
@@ -5291,6 +5312,12 @@ void InfoManager::socket_helper_update_input_context (int client, uint32 type, u
     m_impl->socket_helper_update_input_context (client, type, value);
 }
 
+//ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE
+void InfoManager::socket_helper_update_language_locale(int client, String locale)
+{
+    m_impl->socket_helper_update_language_locale(client, locale);
+}
+
 //SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND
 void InfoManager::socket_helper_send_private_command (int client, String command)
 {
index 9b8bbb5..485f00e 100644 (file)
@@ -958,6 +958,9 @@ public:
     //ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT
     void socket_helper_update_input_context (int client, uint32 type, uint32 value);
 
+    //ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE
+    void socket_helper_update_language_locale(int client, String locale);
+
     //SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND
     void socket_helper_send_private_command (int client, String command);
 
index 19a2668..463936a 100644 (file)
@@ -402,6 +402,12 @@ void PanelAgentBase::update_ise_input_context (int client, uint32 context, uint3
 {
 }
 
+//socket_helper_update_language_locale
+//ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE
+void PanelAgentBase::update_ise_language_locale(int client, uint32 context, String locale)
+{
+}
+
 //socket_helper_send_private_command
 //SCIM_TRANS_CMD_SEND_PRIVATE_COMMAND
 void PanelAgentBase::send_private_command (int client, uint32 context, const String& command)
index 15f55ad..9615f2f 100644 (file)
@@ -782,6 +782,15 @@ public:
     virtual void update_ise_input_context (int client, uint32 context, uint32 type, uint32 value);
 
     /**
+     * @brief update_ise_language_locale.
+     *
+     * @param
+     *
+     * @return none.
+     */
+    virtual void update_ise_language_locale (int client, uint32 context, String locale);
+
+    /**
      * @brief send_private_command.
      *
      * @param
index eb66fc9..004cd79 100644 (file)
@@ -781,6 +781,14 @@ void PanelAgentManager::update_ise_input_context (int id, uint32 context_id, uin
         _p->update_ise_input_context (id, context_id, type, value);
 }
 
+void PanelAgentManager::update_ise_language_locale(int id, uint32 context_id, String locale)
+{
+    PanelAgentPointer _p = m_impl->get_panel_agent_by_id(id);
+
+    if (!_p.null())
+        _p->update_ise_language_locale(id, context_id, locale);
+}
+
 void PanelAgentManager::send_private_command (int id, uint32 context_id, String command)
 {
     PanelAgentPointer _p = m_impl->get_panel_agent_by_id (id);
index 7f3e4fc..9bfb565 100644 (file)
@@ -340,7 +340,8 @@ public:
     void socket_helper_delete_surrounding_text (int client, uint32 context_id, uint32 offset, uint32 len);
     void socket_helper_get_selection (int client, uint32 context_id);
     void socket_helper_set_selection (int client, uint32 context_id, uint32 start, uint32 end);
-    void update_ise_input_context (int    focused_client, uint32 focused_context, uint32 type, uint32 value);
+    void update_ise_input_context (int focused_client, uint32 focused_context, uint32 type, uint32 value);
+    void update_ise_language_locale (int focused_client, uint32 focused_context, String locale);
     void send_private_command (int    focused_client, uint32 focused_context, String command);
     void commit_content (int    focused_client, uint32 focused_context, String content, String description, String mime_types);
     void helper_all_update_spot_location (int client_id, uint32 context_id, String uuid, int x, int y);
index 5b908c5..5e9e58d 100644 (file)
@@ -2010,6 +2010,23 @@ HelperAgent::update_associate_string (const LookupTable &table) const
 void
 HelperAgent::update_input_context (uint32 type, uint32 value) const
 {
+    /* Update all state variables that could be queried by the client application */
+    char *buf = NULL;
+    m_impl->signal_get_language_locale(this, -1, &buf);
+
+    if (buf != NULL) {
+        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(ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE);
+            m_impl->send.put_data(buf, strlen(buf));
+            m_impl->send.write_to_socket(m_impl->socket_active, m_impl->magic_active);
+        }
+        delete[] buf;
+        buf = NULL;
+    }
+
     if (m_impl->socket_active.is_connected ()) {
         m_impl->send.clear ();
         m_impl->send.put_command (SCIM_TRANS_CMD_REQUEST);
index ba44479..04b1e1e 100644 (file)
@@ -38,7 +38,7 @@
  *    c. m_signal_get_surrounding_text and m_signal_delete_surrounding_text
  *    d. m_signal_show_preedit_string, m_signal_hide_preedit_string, m_signal_update_preedit_string and m_signal_update_preedit_caret
  *    e. m_signal_candidate_more_window_show, m_signal_candidate_more_window_hide, m_signal_longpress_candidate
- *    f. m_signal_update_ise_input_context, m_signal_update_isf_candidate_panel
+ *    f. m_signal_update_ise_input_context, m_signal_update_ise_language_locale, m_signal_update_isf_candidate_panel
  * 2. Add new interface APIs in PanelClient class
  *    a. update_cursor_position () and update_surrounding_text ()
  *    b. expand_candidate (), contract_candidate () and set_candidate_style ()
index 1bce735..ec6a3c5 100644 (file)
@@ -678,6 +678,7 @@ const int ISM_TRANS_CMD_SET_PREDICTION_HINT_DATA          = 1132;
 /* ISE/Panel to IMControl */
 const int ISM_TRANS_CMD_UPDATE_ISE_INPUT_CONTEXT          = 1151;
 const int ISM_TRANS_CMD_UPDATE_ISF_CANDIDATE_PANEL        = 1152;
+const int ISM_TRANS_CMD_UPDATE_ISE_LANGUAGE_LOCALE        = 1153;
 
 
 /* ISE to Panel */